agent-dag 1.33.36 → 1.33.37

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 iw;function fR(){if(iw)return Wc;iw=1;var e=na(),n=dR();function i(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var s=typeof Object.is=="function"?Object.is:i,o=n.useSyncExternalStore,l=e.useRef,u=e.useEffect,c=e.useMemo,p=e.useDebugValue;return Wc.useSyncExternalStoreWithSelector=function(h,f,m,y,x){var N=l(null);if(N.current===null){var _={hasValue:!1,value:null};N.current=_}else _=N.current;N=c(function(){function b(O){if(!E){if(E=!0,C=O,O=y(O),x!==void 0&&_.hasValue){var q=_.value;if(x(q,O))return j=q}return j=O}if(q=j,s(C,O))return q;var B=y(O);return x!==void 0&&x(q,B)?(C=O,q):(C=O,j=B)}var E=!1,C,j,P=m===void 0?null:m;return[function(){return b(f())},P===null?void 0:function(){return b(P())}]},[f,m,y,x]);var S=o(h,N[0],N[1]);return u(function(){_.hasValue=!0,_.value=S},[S]),p(S),S},Wc}var sw;function hR(){return sw||(sw=1,Vc.exports=fR()),Vc.exports}var pR=hR();const mR=Yg(pR),gR={},ow=e=>{let n;const i=new Set,s=(f,m)=>{const y=typeof f=="function"?f(n):f;if(!Object.is(y,n)){const x=n;n=m??(typeof y!="object"||y===null)?y:Object.assign({},n,y),i.forEach(N=>N(n,x))}},o=()=>n,p={setState:s,getState:o,getInitialState:()=>h,subscribe:f=>(i.add(f),()=>i.delete(f)),destroy:()=>{(gR?"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."),i.clear()}},h=n=e(s,o,p);return p},vR=e=>e?ow(e):ow,{useDebugValue:yR}=le,{useSyncExternalStoreWithSelector:wR}=mR,xR=e=>e;function Vk(e,n=xR,i){const s=wR(e.subscribe,e.getState,e.getServerState||e.getInitialState,n,i);return yR(s),s}const aw=(e,n)=>{const i=vR(e),s=(o,l=n)=>Vk(i,o,l);return Object.assign(s,i),s},_R=(e,n)=>e?aw(e,n):aw;function Ct(e,n){if(Object.is(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(const[s,o]of e)if(!Object.is(o,n.get(s)))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(const s of e)if(!n.has(s))return!1;return!0}const i=Object.keys(e);if(i.length!==Object.keys(n).length)return!1;for(const s of i)if(!Object.prototype.hasOwnProperty.call(n,s)||!Object.is(e[s],n[s]))return!1;return!0}var SR={value:()=>{}};function Vl(){for(var e=0,n=arguments.length,i={},s;e<n;++e){if(!(s=arguments[e]+"")||s in i||/[\s.]/.test(s))throw new Error("illegal type: "+s);i[s]=[]}return new Rl(i)}function Rl(e){this._=e}function bR(e,n){return e.trim().split(/^|\s+/).map(function(i){var s="",o=i.indexOf(".");if(o>=0&&(s=i.slice(o+1),i=i.slice(0,o)),i&&!n.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:s}})}Rl.prototype=Vl.prototype={constructor:Rl,on:function(e,n){var i=this._,s=bR(e+"",i),o,l=-1,u=s.length;if(arguments.length<2){for(;++l<u;)if((o=(e=s[l]).type)&&(o=kR(i[o],e.name)))return o;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++l<u;)if(o=(e=s[l]).type)i[o]=lw(i[o],e.name,n);else if(n==null)for(o in i)i[o]=lw(i[o],e.name,null);return this},copy:function(){var e={},n=this._;for(var i in n)e[i]=n[i].slice();return new Rl(e)},call:function(e,n){if((o=arguments.length-2)>0)for(var i=new Array(o),s=0,o,l;s<o;++s)i[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(l=this._[e],s=0,o=l.length;s<o;++s)l[s].value.apply(n,i)},apply:function(e,n,i){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var s=this._[e],o=0,l=s.length;o<l;++o)s[o].value.apply(n,i)}};function kR(e,n){for(var i=0,s=e.length,o;i<s;++i)if((o=e[i]).name===n)return o.value}function lw(e,n,i){for(var s=0,o=e.length;s<o;++s)if(e[s].name===n){e[s]=SR,e=e.slice(0,s).concat(e.slice(s+1));break}return i!=null&&e.push({name:n,value:i}),e}var Ng="http://www.w3.org/1999/xhtml";const uw={svg:"http://www.w3.org/2000/svg",xhtml:Ng,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Wl(e){var n=e+="",i=n.indexOf(":");return i>=0&&(n=e.slice(0,i))!=="xmlns"&&(e=e.slice(i+1)),uw.hasOwnProperty(n)?{space:uw[n],local:e}:e}function ER(e){return function(){var n=this.ownerDocument,i=this.namespaceURI;return i===Ng&&n.documentElement.namespaceURI===Ng?n.createElement(e):n.createElementNS(i,e)}}function NR(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Wk(e){var n=Wl(e);return(n.local?NR:ER)(n)}function CR(){}function Xg(e){return e==null?CR:function(){return this.querySelector(e)}}function jR(e){typeof e!="function"&&(e=Xg(e));for(var n=this._groups,i=n.length,s=new Array(i),o=0;o<i;++o)for(var l=n[o],u=l.length,c=s[o]=new Array(u),p,h,f=0;f<u;++f)(p=l[f])&&(h=e.call(p,p.__data__,f,l))&&("__data__"in p&&(h.__data__=p.__data__),c[f]=h);return new Sn(s,this._parents)}function RR(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function TR(){return[]}function Gk(e){return e==null?TR:function(){return this.querySelectorAll(e)}}function AR(e){return function(){return RR(e.apply(this,arguments))}}function IR(e){typeof e=="function"?e=AR(e):e=Gk(e);for(var n=this._groups,i=n.length,s=[],o=[],l=0;l<i;++l)for(var u=n[l],c=u.length,p,h=0;h<c;++h)(p=u[h])&&(s.push(e.call(p,p.__data__,h,u)),o.push(p));return new Sn(s,o)}function Kk(e){return function(){return this.matches(e)}}function Yk(e){return function(n){return n.matches(e)}}var MR=Array.prototype.find;function PR(e){return function(){return MR.call(this.children,e)}}function OR(){return this.firstElementChild}function qR(e){return this.select(e==null?OR:PR(typeof e=="function"?e:Yk(e)))}var LR=Array.prototype.filter;function $R(){return Array.from(this.children)}function DR(e){return function(){return LR.call(this.children,e)}}function FR(e){return this.selectAll(e==null?$R:DR(typeof e=="function"?e:Yk(e)))}function zR(e){typeof e!="function"&&(e=Kk(e));for(var n=this._groups,i=n.length,s=new Array(i),o=0;o<i;++o)for(var l=n[o],u=l.length,c=s[o]=[],p,h=0;h<u;++h)(p=l[h])&&e.call(p,p.__data__,h,l)&&c.push(p);return new Sn(s,this._parents)}function Xk(e){return new Array(e.length)}function BR(){return new Sn(this._enter||this._groups.map(Xk),this._parents)}function Ml(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}Ml.prototype={constructor:Ml,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 UR(e){return function(){return e}}function HR(e,n,i,s,o,l){for(var u=0,c,p=n.length,h=l.length;u<h;++u)(c=n[u])?(c.__data__=l[u],s[u]=c):i[u]=new Ml(e,l[u]);for(;u<p;++u)(c=n[u])&&(o[u]=c)}function VR(e,n,i,s,o,l,u){var c,p,h=new Map,f=n.length,m=l.length,y=new Array(f),x;for(c=0;c<f;++c)(p=n[c])&&(y[c]=x=u.call(p,p.__data__,c,n)+"",h.has(x)?o[c]=p:h.set(x,p));for(c=0;c<m;++c)x=u.call(e,l[c],c,l)+"",(p=h.get(x))?(s[c]=p,p.__data__=l[c],h.delete(x)):i[c]=new Ml(e,l[c]);for(c=0;c<f;++c)(p=n[c])&&h.get(y[c])===p&&(o[c]=p)}function WR(e){return e.__data__}function GR(e,n){if(!arguments.length)return Array.from(this,WR);var i=n?VR:HR,s=this._parents,o=this._groups;typeof e!="function"&&(e=UR(e));for(var l=o.length,u=new Array(l),c=new Array(l),p=new Array(l),h=0;h<l;++h){var f=s[h],m=o[h],y=m.length,x=KR(e.call(f,f&&f.__data__,h,s)),N=x.length,_=c[h]=new Array(N),S=u[h]=new Array(N),b=p[h]=new Array(y);i(f,m,_,S,b,x,n);for(var E=0,C=0,j,P;E<N;++E)if(j=_[E]){for(E>=C&&(C=E+1);!(P=S[C])&&++C<N;);j._next=P||null}}return u=new Sn(u,s),u._enter=c,u._exit=p,u}function KR(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function YR(){return new Sn(this._exit||this._groups.map(Xk),this._parents)}function XR(e,n,i){var s=this.enter(),o=this,l=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),n!=null&&(o=n(o),o&&(o=o.selection())),i==null?l.remove():i(l),s&&o?s.merge(o).order():o}function QR(e){for(var n=e.selection?e.selection():e,i=this._groups,s=n._groups,o=i.length,l=s.length,u=Math.min(o,l),c=new Array(o),p=0;p<u;++p)for(var h=i[p],f=s[p],m=h.length,y=c[p]=new Array(m),x,N=0;N<m;++N)(x=h[N]||f[N])&&(y[N]=x);for(;p<o;++p)c[p]=i[p];return new Sn(c,this._parents)}function ZR(){for(var e=this._groups,n=-1,i=e.length;++n<i;)for(var s=e[n],o=s.length-1,l=s[o],u;--o>=0;)(u=s[o])&&(l&&u.compareDocumentPosition(l)^4&&l.parentNode.insertBefore(u,l),l=u);return this}function JR(e){e||(e=eT);function n(m,y){return m&&y?e(m.__data__,y.__data__):!m-!y}for(var i=this._groups,s=i.length,o=new Array(s),l=0;l<s;++l){for(var u=i[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 Sn(o,this._parents).order()}function eT(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function tT(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function nT(){return Array.from(this)}function rT(){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var s=e[n],o=0,l=s.length;o<l;++o){var u=s[o];if(u)return u}return null}function iT(){let e=0;for(const n of this)++e;return e}function sT(){return!this.node()}function oT(e){for(var n=this._groups,i=0,s=n.length;i<s;++i)for(var o=n[i],l=0,u=o.length,c;l<u;++l)(c=o[l])&&e.call(c,c.__data__,l,o);return this}function aT(e){return function(){this.removeAttribute(e)}}function lT(e){return function(){this.removeAttributeNS(e.space,e.local)}}function uT(e,n){return function(){this.setAttribute(e,n)}}function cT(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function dT(e,n){return function(){var i=n.apply(this,arguments);i==null?this.removeAttribute(e):this.setAttribute(e,i)}}function fT(e,n){return function(){var i=n.apply(this,arguments);i==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,i)}}function hT(e,n){var i=Wl(e);if(arguments.length<2){var s=this.node();return i.local?s.getAttributeNS(i.space,i.local):s.getAttribute(i)}return this.each((n==null?i.local?lT:aT:typeof n=="function"?i.local?fT:dT:i.local?cT:uT)(i,n))}function Qk(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function pT(e){return function(){this.style.removeProperty(e)}}function mT(e,n,i){return function(){this.style.setProperty(e,n,i)}}function gT(e,n,i){return function(){var s=n.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,i)}}function vT(e,n,i){return arguments.length>1?this.each((n==null?pT:typeof n=="function"?gT:mT)(e,n,i??"")):Bs(this.node(),e)}function Bs(e,n){return e.style.getPropertyValue(n)||Qk(e).getComputedStyle(e,null).getPropertyValue(n)}function yT(e){return function(){delete this[e]}}function wT(e,n){return function(){this[e]=n}}function xT(e,n){return function(){var i=n.apply(this,arguments);i==null?delete this[e]:this[e]=i}}function _T(e,n){return arguments.length>1?this.each((n==null?yT:typeof n=="function"?xT:wT)(e,n)):this.node()[e]}function Zk(e){return e.trim().split(/^|\s+/)}function Qg(e){return e.classList||new Jk(e)}function Jk(e){this._node=e,this._names=Zk(e.getAttribute("class")||"")}Jk.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 eE(e,n){for(var i=Qg(e),s=-1,o=n.length;++s<o;)i.add(n[s])}function tE(e,n){for(var i=Qg(e),s=-1,o=n.length;++s<o;)i.remove(n[s])}function ST(e){return function(){eE(this,e)}}function bT(e){return function(){tE(this,e)}}function kT(e,n){return function(){(n.apply(this,arguments)?eE:tE)(this,e)}}function ET(e,n){var i=Zk(e+"");if(arguments.length<2){for(var s=Qg(this.node()),o=-1,l=i.length;++o<l;)if(!s.contains(i[o]))return!1;return!0}return this.each((typeof n=="function"?kT:n?ST:bT)(i,n))}function NT(){this.textContent=""}function CT(e){return function(){this.textContent=e}}function jT(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function RT(e){return arguments.length?this.each(e==null?NT:(typeof e=="function"?jT:CT)(e)):this.node().textContent}function TT(){this.innerHTML=""}function AT(e){return function(){this.innerHTML=e}}function IT(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function MT(e){return arguments.length?this.each(e==null?TT:(typeof e=="function"?IT:AT)(e)):this.node().innerHTML}function PT(){this.nextSibling&&this.parentNode.appendChild(this)}function OT(){return this.each(PT)}function qT(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function LT(){return this.each(qT)}function $T(e){var n=typeof e=="function"?e:Wk(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function DT(){return null}function FT(e,n){var i=typeof e=="function"?e:Wk(e),s=n==null?DT:typeof n=="function"?n:Xg(n);return this.select(function(){return this.insertBefore(i.apply(this,arguments),s.apply(this,arguments)||null)})}function zT(){var e=this.parentNode;e&&e.removeChild(this)}function BT(){return this.each(zT)}function UT(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function HT(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function VT(e){return this.select(e?HT:UT)}function WT(e){return arguments.length?this.property("__data__",e):this.node().__data__}function GT(e){return function(n){e.call(this,n,this.__data__)}}function KT(e){return e.trim().split(/^|\s+/).map(function(n){var i="",s=n.indexOf(".");return s>=0&&(i=n.slice(s+1),n=n.slice(0,s)),{type:n,name:i}})}function YT(e){return function(){var n=this.__on;if(n){for(var i=0,s=-1,o=n.length,l;i<o;++i)l=n[i],(!e.type||l.type===e.type)&&l.name===e.name?this.removeEventListener(l.type,l.listener,l.options):n[++s]=l;++s?n.length=s:delete this.__on}}}function XT(e,n,i){return function(){var s=this.__on,o,l=GT(n);if(s){for(var u=0,c=s.length;u<c;++u)if((o=s[u]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=l,o.options=i),o.value=n;return}}this.addEventListener(e.type,l,i),o={type:e.type,name:e.name,value:n,listener:l,options:i},s?s.push(o):this.__on=[o]}}function QT(e,n,i){var s=KT(e+""),o,l=s.length,u;if(arguments.length<2){var c=this.node().__on;if(c){for(var p=0,h=c.length,f;p<h;++p)for(o=0,f=c[p];o<l;++o)if((u=s[o]).type===f.type&&u.name===f.name)return f.value}return}for(c=n?XT:YT,o=0;o<l;++o)this.each(c(s[o],n,i));return this}function nE(e,n,i){var s=Qk(e),o=s.CustomEvent;typeof o=="function"?o=new o(n,i):(o=s.document.createEvent("Event"),i?(o.initEvent(n,i.bubbles,i.cancelable),o.detail=i.detail):o.initEvent(n,!1,!1)),e.dispatchEvent(o)}function ZT(e,n){return function(){return nE(this,e,n)}}function JT(e,n){return function(){return nE(this,e,n.apply(this,arguments))}}function e2(e,n){return this.each((typeof n=="function"?JT:ZT)(e,n))}function*t2(){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var s=e[n],o=0,l=s.length,u;o<l;++o)(u=s[o])&&(yield u)}var rE=[null];function Sn(e,n){this._groups=e,this._parents=n}function ra(){return new Sn([[document.documentElement]],rE)}function n2(){return this}Sn.prototype=ra.prototype={constructor:Sn,select:jR,selectAll:IR,selectChild:qR,selectChildren:FR,filter:zR,data:GR,enter:BR,exit:YR,join:XR,merge:QR,selection:n2,order:ZR,sort:JR,call:tT,nodes:nT,node:rT,size:iT,empty:sT,each:oT,attr:hT,style:vT,property:_T,classed:ET,text:RT,html:MT,raise:OT,lower:LT,append:$T,insert:FT,remove:BT,clone:VT,datum:WT,on:QT,dispatch:e2,[Symbol.iterator]:t2};function Mn(e){return typeof e=="string"?new Sn([[document.querySelector(e)]],[document.documentElement]):new Sn([[e]],rE)}function r2(e){let n;for(;n=e.sourceEvent;)e=n;return e}function Kn(e,n){if(e=r2(e),n===void 0&&(n=e.currentTarget),n){var i=n.ownerSVGElement||n;if(i.createSVGPoint){var s=i.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,s=s.matrixTransform(n.getScreenCTM().inverse()),[s.x,s.y]}if(n.getBoundingClientRect){var o=n.getBoundingClientRect();return[e.clientX-o.left-n.clientLeft,e.clientY-o.top-n.clientTop]}}return[e.pageX,e.pageY]}const i2={passive:!1},Go={capture:!0,passive:!1};function Yc(e){e.stopImmediatePropagation()}function $s(e){e.preventDefault(),e.stopImmediatePropagation()}function iE(e){var n=e.document.documentElement,i=Mn(e).on("dragstart.drag",$s,Go);"onselectstart"in n?i.on("selectstart.drag",$s,Go):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function sE(e,n){var i=e.document.documentElement,s=Mn(e).on("dragstart.drag",null);n&&(s.on("click.drag",$s,Go),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in i?s.on("selectstart.drag",null):(i.style.MozUserSelect=i.__noselect,delete i.__noselect)}const pl=e=>()=>e;function Cg(e,{sourceEvent:n,subject:i,target:s,identifier:o,active:l,x:u,y:c,dx:p,dy:h,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:i,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:l,enumerable:!0,configurable:!0},x:{value:u,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:f}})}Cg.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function s2(e){return!e.ctrlKey&&!e.button}function o2(){return this.parentNode}function a2(e,n){return n??{x:e.x,y:e.y}}function l2(){return navigator.maxTouchPoints||"ontouchstart"in this}function u2(){var e=s2,n=o2,i=a2,s=l2,o={},l=Vl("start","drag","end"),u=0,c,p,h,f,m=0;function y(j){j.on("mousedown.drag",x).filter(s).on("touchstart.drag",S).on("touchmove.drag",b,i2).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(j,P){if(!(f||!e.call(this,j,P))){var O=C(this,n.call(this,j,P),j,P,"mouse");O&&(Mn(j.view).on("mousemove.drag",N,Go).on("mouseup.drag",_,Go),iE(j.view),Yc(j),h=!1,c=j.clientX,p=j.clientY,O("start",j))}}function N(j){if($s(j),!h){var P=j.clientX-c,O=j.clientY-p;h=P*P+O*O>m}o.mouse("drag",j)}function _(j){Mn(j.view).on("mousemove.drag mouseup.drag",null),sE(j.view,h),$s(j),o.mouse("end",j)}function S(j,P){if(e.call(this,j,P)){var O=j.changedTouches,q=n.call(this,j,P),B=O.length,T,M;for(T=0;T<B;++T)(M=C(this,q,j,P,O[T].identifier,O[T]))&&(Yc(j),M("start",j,O[T]))}}function b(j){var P=j.changedTouches,O=P.length,q,B;for(q=0;q<O;++q)(B=o[P[q].identifier])&&($s(j),B("drag",j,P[q]))}function E(j){var P=j.changedTouches,O=P.length,q,B;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),q=0;q<O;++q)(B=o[P[q].identifier])&&(Yc(j),B("end",j,P[q]))}function C(j,P,O,q,B,T){var M=l.copy(),F=Kn(T||O,P),X,Y,I;if((I=i.call(j,new Cg("beforestart",{sourceEvent:O,target:y,identifier:B,active:u,x:F[0],y:F[1],dx:0,dy:0,dispatch:M}),q))!=null)return X=I.x-F[0]||0,Y=I.y-F[1]||0,function H(U,ne,J){var D=F,G;switch(U){case"start":o[B]=H,G=u++;break;case"end":delete o[B],--u;case"drag":F=Kn(J||ne,P),G=u;break}M.call(U,j,new Cg(U,{sourceEvent:ne,subject:I,target:y,identifier:B,active:G,x:F[0]+X,y:F[1]+Y,dx:F[0]-D[0],dy:F[1]-D[1],dispatch:M}),q)}}return y.filter=function(j){return arguments.length?(e=typeof j=="function"?j:pl(!!j),y):e},y.container=function(j){return arguments.length?(n=typeof j=="function"?j:pl(j),y):n},y.subject=function(j){return arguments.length?(i=typeof j=="function"?j:pl(j),y):i},y.touchable=function(j){return arguments.length?(s=typeof j=="function"?j:pl(!!j),y):s},y.on=function(){var j=l.on.apply(l,arguments);return j===l?y:j},y.clickDistance=function(j){return arguments.length?(m=(j=+j)*j,y):Math.sqrt(m)},y}function Zg(e,n,i){e.prototype=n.prototype=i,i.constructor=e}function oE(e,n){var i=Object.create(e.prototype);for(var s in n)i[s]=n[s];return i}function ia(){}var Ko=.7,Pl=1/Ko,Ds="\\s*([+-]?\\d+)\\s*",Yo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",cr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",c2=/^#([0-9a-f]{3,8})$/,d2=new RegExp(`^rgb\\(${Ds},${Ds},${Ds}\\)$`),f2=new RegExp(`^rgb\\(${cr},${cr},${cr}\\)$`),h2=new RegExp(`^rgba\\(${Ds},${Ds},${Ds},${Yo}\\)$`),p2=new RegExp(`^rgba\\(${cr},${cr},${cr},${Yo}\\)$`),m2=new RegExp(`^hsl\\(${Yo},${cr},${cr}\\)$`),g2=new RegExp(`^hsla\\(${Yo},${cr},${cr},${Yo}\\)$`),cw={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};Zg(ia,Xo,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:dw,formatHex:dw,formatHex8:v2,formatHsl:y2,formatRgb:fw,toString:fw});function dw(){return this.rgb().formatHex()}function v2(){return this.rgb().formatHex8()}function y2(){return aE(this).formatHsl()}function fw(){return this.rgb().formatRgb()}function Xo(e){var n,i;return e=(e+"").trim().toLowerCase(),(n=c2.exec(e))?(i=n[1].length,n=parseInt(n[1],16),i===6?hw(n):i===3?new cn(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):i===8?ml(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):i===4?ml(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=d2.exec(e))?new cn(n[1],n[2],n[3],1):(n=f2.exec(e))?new cn(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=h2.exec(e))?ml(n[1],n[2],n[3],n[4]):(n=p2.exec(e))?ml(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=m2.exec(e))?gw(n[1],n[2]/100,n[3]/100,1):(n=g2.exec(e))?gw(n[1],n[2]/100,n[3]/100,n[4]):cw.hasOwnProperty(e)?hw(cw[e]):e==="transparent"?new cn(NaN,NaN,NaN,0):null}function hw(e){return new cn(e>>16&255,e>>8&255,e&255,1)}function ml(e,n,i,s){return s<=0&&(e=n=i=NaN),new cn(e,n,i,s)}function w2(e){return e instanceof ia||(e=Xo(e)),e?(e=e.rgb(),new cn(e.r,e.g,e.b,e.opacity)):new cn}function jg(e,n,i,s){return arguments.length===1?w2(e):new cn(e,n,i,s??1)}function cn(e,n,i,s){this.r=+e,this.g=+n,this.b=+i,this.opacity=+s}Zg(cn,jg,oE(ia,{brighter(e){return e=e==null?Pl:Math.pow(Pl,e),new cn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ko:Math.pow(Ko,e),new cn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new cn(Ki(this.r),Ki(this.g),Ki(this.b),Ol(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:pw,formatHex:pw,formatHex8:x2,formatRgb:mw,toString:mw}));function pw(){return`#${Wi(this.r)}${Wi(this.g)}${Wi(this.b)}`}function x2(){return`#${Wi(this.r)}${Wi(this.g)}${Wi(this.b)}${Wi((isNaN(this.opacity)?1:this.opacity)*255)}`}function mw(){const e=Ol(this.opacity);return`${e===1?"rgb(":"rgba("}${Ki(this.r)}, ${Ki(this.g)}, ${Ki(this.b)}${e===1?")":`, ${e})`}`}function Ol(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ki(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Wi(e){return e=Ki(e),(e<16?"0":"")+e.toString(16)}function gw(e,n,i,s){return s<=0?e=n=i=NaN:i<=0||i>=1?e=n=NaN:n<=0&&(e=NaN),new Yn(e,n,i,s)}function aE(e){if(e instanceof Yn)return new Yn(e.h,e.s,e.l,e.opacity);if(e instanceof ia||(e=Xo(e)),!e)return new Yn;if(e instanceof Yn)return e;e=e.rgb();var n=e.r/255,i=e.g/255,s=e.b/255,o=Math.min(n,i,s),l=Math.max(n,i,s),u=NaN,c=l-o,p=(l+o)/2;return c?(n===l?u=(i-s)/c+(i<s)*6:i===l?u=(s-n)/c+2:u=(n-i)/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 _2(e,n,i,s){return arguments.length===1?aE(e):new Yn(e,n,i,s??1)}function Yn(e,n,i,s){this.h=+e,this.s=+n,this.l=+i,this.opacity=+s}Zg(Yn,_2,oE(ia,{brighter(e){return e=e==null?Pl:Math.pow(Pl,e),new Yn(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ko:Math.pow(Ko,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,i=this.l,s=i+(i<.5?i:1-i)*n,o=2*i-s;return new cn(Xc(e>=240?e-240:e+120,o,s),Xc(e,o,s),Xc(e<120?e+240:e-120,o,s),this.opacity)},clamp(){return new Yn(vw(this.h),gl(this.s),gl(this.l),Ol(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=Ol(this.opacity);return`${e===1?"hsl(":"hsla("}${vw(this.h)}, ${gl(this.s)*100}%, ${gl(this.l)*100}%${e===1?")":`, ${e})`}`}}));function vw(e){return e=(e||0)%360,e<0?e+360:e}function gl(e){return Math.max(0,Math.min(1,e||0))}function Xc(e,n,i){return(e<60?n+(i-n)*e/60:e<180?i:e<240?n+(i-n)*(240-e)/60:n)*255}const lE=e=>()=>e;function S2(e,n){return function(i){return e+i*n}}function b2(e,n,i){return e=Math.pow(e,i),n=Math.pow(n,i)-e,i=1/i,function(s){return Math.pow(e+s*n,i)}}function k2(e){return(e=+e)==1?uE:function(n,i){return i-n?b2(n,i,e):lE(isNaN(n)?i:n)}}function uE(e,n){var i=n-e;return i?S2(e,i):lE(isNaN(e)?n:e)}const yw=(function e(n){var i=k2(n);function s(o,l){var u=i((o=jg(o)).r,(l=jg(l)).r),c=i(o.g,l.g),p=i(o.b,l.b),h=uE(o.opacity,l.opacity);return function(f){return o.r=u(f),o.g=c(f),o.b=p(f),o.opacity=h(f),o+""}}return s.gamma=e,s})(1);function fi(e,n){return e=+e,n=+n,function(i){return e*(1-i)+n*i}}var Rg=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Qc=new RegExp(Rg.source,"g");function E2(e){return function(){return e}}function N2(e){return function(n){return e(n)+""}}function C2(e,n){var i=Rg.lastIndex=Qc.lastIndex=0,s,o,l,u=-1,c=[],p=[];for(e=e+"",n=n+"";(s=Rg.exec(e))&&(o=Qc.exec(n));)(l=o.index)>i&&(l=n.slice(i,l),c[u]?c[u]+=l:c[++u]=l),(s=s[0])===(o=o[0])?c[u]?c[u]+=o:c[++u]=o:(c[++u]=null,p.push({i:u,x:fi(s,o)})),i=Qc.lastIndex;return i<n.length&&(l=n.slice(i),c[u]?c[u]+=l:c[++u]=l),c.length<2?p[0]?N2(p[0].x):E2(n):(n=p.length,function(h){for(var f=0,m;f<n;++f)c[(m=p[f]).i]=m.x(h);return c.join("")})}var ww=180/Math.PI,Tg={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function cE(e,n,i,s,o,l){var u,c,p;return(u=Math.sqrt(e*e+n*n))&&(e/=u,n/=u),(p=e*i+n*s)&&(i-=e*p,s-=n*p),(c=Math.sqrt(i*i+s*s))&&(i/=c,s/=c,p/=c),e*s<n*i&&(e=-e,n=-n,p=-p,u=-u),{translateX:o,translateY:l,rotate:Math.atan2(n,e)*ww,skewX:Math.atan(p)*ww,scaleX:u,scaleY:c}}var vl;function j2(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?Tg:cE(n.a,n.b,n.c,n.d,n.e,n.f)}function R2(e){return e==null||(vl||(vl=document.createElementNS("http://www.w3.org/2000/svg","g")),vl.setAttribute("transform",e),!(e=vl.transform.baseVal.consolidate()))?Tg:(e=e.matrix,cE(e.a,e.b,e.c,e.d,e.e,e.f))}function dE(e,n,i,s){function o(h){return h.length?h.pop()+" ":""}function l(h,f,m,y,x,N){if(h!==m||f!==y){var _=x.push("translate(",null,n,null,i);N.push({i:_-4,x:fi(h,m)},{i:_-2,x:fi(f,y)})}else(m||y)&&x.push("translate("+m+n+y+i)}function u(h,f,m,y){h!==f?(h-f>180?f+=360:f-h>180&&(h+=360),y.push({i:m.push(o(m)+"rotate(",null,s)-2,x:fi(h,f)})):f&&m.push(o(m)+"rotate("+f+s)}function c(h,f,m,y){h!==f?y.push({i:m.push(o(m)+"skewX(",null,s)-2,x:fi(h,f)}):f&&m.push(o(m)+"skewX("+f+s)}function p(h,f,m,y,x,N){if(h!==m||f!==y){var _=x.push(o(x)+"scale(",null,",",null,")");N.push({i:_-4,x:fi(h,m)},{i:_-2,x:fi(f,y)})}else(m!==1||y!==1)&&x.push(o(x)+"scale("+m+","+y+")")}return function(h,f){var m=[],y=[];return h=e(h),f=e(f),l(h.translateX,h.translateY,f.translateX,f.translateY,m,y),u(h.rotate,f.rotate,m,y),c(h.skewX,f.skewX,m,y),p(h.scaleX,h.scaleY,f.scaleX,f.scaleY,m,y),h=f=null,function(x){for(var N=-1,_=y.length,S;++N<_;)m[(S=y[N]).i]=S.x(x);return m.join("")}}}var T2=dE(j2,"px, ","px)","deg)"),A2=dE(R2,", ",")",")"),I2=1e-12;function xw(e){return((e=Math.exp(e))+1/e)/2}function M2(e){return((e=Math.exp(e))-1/e)/2}function P2(e){return((e=Math.exp(2*e))-1)/(e+1)}const O2=(function e(n,i,s){function o(l,u){var c=l[0],p=l[1],h=l[2],f=u[0],m=u[1],y=u[2],x=f-c,N=m-p,_=x*x+N*N,S,b;if(_<I2)b=Math.log(y/h)/n,S=function(q){return[c+q*x,p+q*N,h*Math.exp(n*q*b)]};else{var E=Math.sqrt(_),C=(y*y-h*h+s*_)/(2*h*i*E),j=(y*y-h*h-s*_)/(2*y*i*E),P=Math.log(Math.sqrt(C*C+1)-C),O=Math.log(Math.sqrt(j*j+1)-j);b=(O-P)/n,S=function(q){var B=q*b,T=xw(P),M=h/(i*E)*(T*P2(n*B+P)-M2(P));return[c+M*x,p+M*N,h*T/xw(n*B+P)]}}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 Us=0,Fo=0,Oo=0,fE=1e3,ql,zo,Ll=0,Qi=0,Gl=0,Qo=typeof performance=="object"&&performance.now?performance:Date,hE=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Jg(){return Qi||(hE(q2),Qi=Qo.now()+Gl)}function q2(){Qi=0}function $l(){this._call=this._time=this._next=null}$l.prototype=pE.prototype={constructor:$l,restart:function(e,n,i){if(typeof e!="function")throw new TypeError("callback is not a function");i=(i==null?Jg():+i)+(n==null?0:+n),!this._next&&zo!==this&&(zo?zo._next=this:ql=this,zo=this),this._call=e,this._time=i,Ag()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ag())}};function pE(e,n,i){var s=new $l;return s.restart(e,n,i),s}function L2(){Jg(),++Us;for(var e=ql,n;e;)(n=Qi-e._time)>=0&&e._call.call(void 0,n),e=e._next;--Us}function _w(){Qi=(Ll=Qo.now())+Gl,Us=Fo=0;try{L2()}finally{Us=0,D2(),Qi=0}}function $2(){var e=Qo.now(),n=e-Ll;n>fE&&(Gl-=n,Ll=e)}function D2(){for(var e,n=ql,i,s=1/0;n;)n._call?(s>n._time&&(s=n._time),e=n,n=n._next):(i=n._next,n._next=null,n=e?e._next=i:ql=i);zo=e,Ag(s)}function Ag(e){if(!Us){Fo&&(Fo=clearTimeout(Fo));var n=e-Qi;n>24?(e<1/0&&(Fo=setTimeout(_w,e-Qo.now()-Gl)),Oo&&(Oo=clearInterval(Oo))):(Oo||(Ll=Qo.now(),Oo=setInterval($2,fE)),Us=1,hE(_w))}}function Sw(e,n,i){var s=new $l;return n=n==null?0:+n,s.restart(o=>{s.stop(),e(o+n)},n,i),s}var F2=Vl("start","end","cancel","interrupt"),z2=[],mE=0,bw=1,Ig=2,Tl=3,kw=4,Mg=5,Al=6;function Kl(e,n,i,s,o,l){var u=e.__transition;if(!u)e.__transition={};else if(i in u)return;B2(e,i,{name:n,index:s,group:o,on:F2,tween:z2,time:l.time,delay:l.delay,duration:l.duration,ease:l.ease,timer:null,state:mE})}function ev(e,n){var i=Zn(e,n);if(i.state>mE)throw new Error("too late; already scheduled");return i}function dr(e,n){var i=Zn(e,n);if(i.state>Tl)throw new Error("too late; already running");return i}function Zn(e,n){var i=e.__transition;if(!i||!(i=i[n]))throw new Error("transition not found");return i}function B2(e,n,i){var s=e.__transition,o;s[n]=i,i.timer=pE(l,0,i.time);function l(h){i.state=bw,i.timer.restart(u,i.delay,i.time),i.delay<=h&&u(h-i.delay)}function u(h){var f,m,y,x;if(i.state!==bw)return p();for(f in s)if(x=s[f],x.name===i.name){if(x.state===Tl)return Sw(u);x.state===kw?(x.state=Al,x.timer.stop(),x.on.call("interrupt",e,e.__data__,x.index,x.group),delete s[f]):+f<n&&(x.state=Al,x.timer.stop(),x.on.call("cancel",e,e.__data__,x.index,x.group),delete s[f])}if(Sw(function(){i.state===Tl&&(i.state=kw,i.timer.restart(c,i.delay,i.time),c(h))}),i.state=Ig,i.on.call("start",e,e.__data__,i.index,i.group),i.state===Ig){for(i.state=Tl,o=new Array(y=i.tween.length),f=0,m=-1;f<y;++f)(x=i.tween[f].value.call(e,e.__data__,i.index,i.group))&&(o[++m]=x);o.length=m+1}}function c(h){for(var f=h<i.duration?i.ease.call(null,h/i.duration):(i.timer.restart(p),i.state=Mg,1),m=-1,y=o.length;++m<y;)o[m].call(e,f);i.state===Mg&&(i.on.call("end",e,e.__data__,i.index,i.group),p())}function p(){i.state=Al,i.timer.stop(),delete s[n];for(var h in s)return;delete e.__transition}}function Il(e,n){var i=e.__transition,s,o,l=!0,u;if(i){n=n==null?null:n+"";for(u in i){if((s=i[u]).name!==n){l=!1;continue}o=s.state>Ig&&s.state<Mg,s.state=Al,s.timer.stop(),s.on.call(o?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete i[u]}l&&delete e.__transition}}function U2(e){return this.each(function(){Il(this,e)})}function H2(e,n){var i,s;return function(){var o=dr(this,e),l=o.tween;if(l!==i){s=i=l;for(var u=0,c=s.length;u<c;++u)if(s[u].name===n){s=s.slice(),s.splice(u,1);break}}o.tween=s}}function V2(e,n,i){var s,o;if(typeof i!="function")throw new Error;return function(){var l=dr(this,e),u=l.tween;if(u!==s){o=(s=u).slice();for(var c={name:n,value:i},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 W2(e,n){var i=this._id;if(e+="",arguments.length<2){for(var s=Zn(this.node(),i).tween,o=0,l=s.length,u;o<l;++o)if((u=s[o]).name===e)return u.value;return null}return this.each((n==null?H2:V2)(i,e,n))}function tv(e,n,i){var s=e._id;return e.each(function(){var o=dr(this,s);(o.value||(o.value={}))[n]=i.apply(this,arguments)}),function(o){return Zn(o,s).value[n]}}function gE(e,n){var i;return(typeof n=="number"?fi:n instanceof Xo?yw:(i=Xo(n))?(n=i,yw):C2)(e,n)}function G2(e){return function(){this.removeAttribute(e)}}function K2(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Y2(e,n,i){var s,o=i+"",l;return function(){var u=this.getAttribute(e);return u===o?null:u===s?l:l=n(s=u,i)}}function X2(e,n,i){var s,o=i+"",l;return function(){var u=this.getAttributeNS(e.space,e.local);return u===o?null:u===s?l:l=n(s=u,i)}}function Q2(e,n,i){var s,o,l;return function(){var u,c=i(this),p;return c==null?void this.removeAttribute(e):(u=this.getAttribute(e),p=c+"",u===p?null:u===s&&p===o?l:(o=p,l=n(s=u,c)))}}function Z2(e,n,i){var s,o,l;return function(){var u,c=i(this),p;return c==null?void this.removeAttributeNS(e.space,e.local):(u=this.getAttributeNS(e.space,e.local),p=c+"",u===p?null:u===s&&p===o?l:(o=p,l=n(s=u,c)))}}function J2(e,n){var i=Wl(e),s=i==="transform"?A2:gE;return this.attrTween(e,typeof n=="function"?(i.local?Z2:Q2)(i,s,tv(this,"attr."+e,n)):n==null?(i.local?K2:G2)(i):(i.local?X2:Y2)(i,s,n))}function eA(e,n){return function(i){this.setAttribute(e,n.call(this,i))}}function tA(e,n){return function(i){this.setAttributeNS(e.space,e.local,n.call(this,i))}}function nA(e,n){var i,s;function o(){var l=n.apply(this,arguments);return l!==s&&(i=(s=l)&&tA(e,l)),i}return o._value=n,o}function rA(e,n){var i,s;function o(){var l=n.apply(this,arguments);return l!==s&&(i=(s=l)&&eA(e,l)),i}return o._value=n,o}function iA(e,n){var i="attr."+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;var s=Wl(e);return this.tween(i,(s.local?nA:rA)(s,n))}function sA(e,n){return function(){ev(this,e).delay=+n.apply(this,arguments)}}function oA(e,n){return n=+n,function(){ev(this,e).delay=n}}function aA(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?sA:oA)(n,e)):Zn(this.node(),n).delay}function lA(e,n){return function(){dr(this,e).duration=+n.apply(this,arguments)}}function uA(e,n){return n=+n,function(){dr(this,e).duration=n}}function cA(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?lA:uA)(n,e)):Zn(this.node(),n).duration}function dA(e,n){if(typeof n!="function")throw new Error;return function(){dr(this,e).ease=n}}function fA(e){var n=this._id;return arguments.length?this.each(dA(n,e)):Zn(this.node(),n).ease}function hA(e,n){return function(){var i=n.apply(this,arguments);if(typeof i!="function")throw new Error;dr(this,e).ease=i}}function pA(e){if(typeof e!="function")throw new Error;return this.each(hA(this._id,e))}function mA(e){typeof e!="function"&&(e=Kk(e));for(var n=this._groups,i=n.length,s=new Array(i),o=0;o<i;++o)for(var l=n[o],u=l.length,c=s[o]=[],p,h=0;h<u;++h)(p=l[h])&&e.call(p,p.__data__,h,l)&&c.push(p);return new Pr(s,this._parents,this._name,this._id)}function gA(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,i=e._groups,s=n.length,o=i.length,l=Math.min(s,o),u=new Array(s),c=0;c<l;++c)for(var p=n[c],h=i[c],f=p.length,m=u[c]=new Array(f),y,x=0;x<f;++x)(y=p[x]||h[x])&&(m[x]=y);for(;c<s;++c)u[c]=n[c];return new Pr(u,this._parents,this._name,this._id)}function vA(e){return(e+"").trim().split(/^|\s+/).every(function(n){var i=n.indexOf(".");return i>=0&&(n=n.slice(0,i)),!n||n==="start"})}function yA(e,n,i){var s,o,l=vA(n)?ev:dr;return function(){var u=l(this,e),c=u.on;c!==s&&(o=(s=c).copy()).on(n,i),u.on=o}}function wA(e,n){var i=this._id;return arguments.length<2?Zn(this.node(),i).on.on(e):this.each(yA(i,e,n))}function xA(e){return function(){var n=this.parentNode;for(var i in this.__transition)if(+i!==e)return;n&&n.removeChild(this)}}function _A(){return this.on("end.remove",xA(this._id))}function SA(e){var n=this._name,i=this._id;typeof e!="function"&&(e=Xg(e));for(var s=this._groups,o=s.length,l=new Array(o),u=0;u<o;++u)for(var c=s[u],p=c.length,h=l[u]=new Array(p),f,m,y=0;y<p;++y)(f=c[y])&&(m=e.call(f,f.__data__,y,c))&&("__data__"in f&&(m.__data__=f.__data__),h[y]=m,Kl(h[y],n,i,y,h,Zn(f,i)));return new Pr(l,this._parents,n,i)}function bA(e){var n=this._name,i=this._id;typeof e!="function"&&(e=Gk(e));for(var s=this._groups,o=s.length,l=[],u=[],c=0;c<o;++c)for(var p=s[c],h=p.length,f,m=0;m<h;++m)if(f=p[m]){for(var y=e.call(f,f.__data__,m,p),x,N=Zn(f,i),_=0,S=y.length;_<S;++_)(x=y[_])&&Kl(x,n,i,_,y,N);l.push(y),u.push(f)}return new Pr(l,u,n,i)}var kA=ra.prototype.constructor;function EA(){return new kA(this._groups,this._parents)}function NA(e,n){var i,s,o;return function(){var l=Bs(this,e),u=(this.style.removeProperty(e),Bs(this,e));return l===u?null:l===i&&u===s?o:o=n(i=l,s=u)}}function vE(e){return function(){this.style.removeProperty(e)}}function CA(e,n,i){var s,o=i+"",l;return function(){var u=Bs(this,e);return u===o?null:u===s?l:l=n(s=u,i)}}function jA(e,n,i){var s,o,l;return function(){var u=Bs(this,e),c=i(this),p=c+"";return c==null&&(p=c=(this.style.removeProperty(e),Bs(this,e))),u===p?null:u===s&&p===o?l:(o=p,l=n(s=u,c))}}function RA(e,n){var i,s,o,l="style."+n,u="end."+l,c;return function(){var p=dr(this,e),h=p.on,f=p.value[l]==null?c||(c=vE(n)):void 0;(h!==i||o!==f)&&(s=(i=h).copy()).on(u,o=f),p.on=s}}function TA(e,n,i){var s=(e+="")=="transform"?T2:gE;return n==null?this.styleTween(e,NA(e,s)).on("end.style."+e,vE(e)):typeof n=="function"?this.styleTween(e,jA(e,s,tv(this,"style."+e,n))).each(RA(this._id,e)):this.styleTween(e,CA(e,s,n),i).on("end.style."+e,null)}function AA(e,n,i){return function(s){this.style.setProperty(e,n.call(this,s),i)}}function IA(e,n,i){var s,o;function l(){var u=n.apply(this,arguments);return u!==o&&(s=(o=u)&&AA(e,u,i)),s}return l._value=n,l}function MA(e,n,i){var s="style."+(e+="");if(arguments.length<2)return(s=this.tween(s))&&s._value;if(n==null)return this.tween(s,null);if(typeof n!="function")throw new Error;return this.tween(s,IA(e,n,i??""))}function PA(e){return function(){this.textContent=e}}function OA(e){return function(){var n=e(this);this.textContent=n??""}}function qA(e){return this.tween("text",typeof e=="function"?OA(tv(this,"text",e)):PA(e==null?"":e+""))}function LA(e){return function(n){this.textContent=e.call(this,n)}}function $A(e){var n,i;function s(){var o=e.apply(this,arguments);return o!==i&&(n=(i=o)&&LA(o)),n}return s._value=e,s}function DA(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,$A(e))}function FA(){for(var e=this._name,n=this._id,i=yE(),s=this._groups,o=s.length,l=0;l<o;++l)for(var u=s[l],c=u.length,p,h=0;h<c;++h)if(p=u[h]){var f=Zn(p,n);Kl(p,e,i,h,u,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new Pr(s,this._parents,e,i)}function zA(){var e,n,i=this,s=i._id,o=i.size();return new Promise(function(l,u){var c={value:u},p={value:function(){--o===0&&l()}};i.each(function(){var h=dr(this,s),f=h.on;f!==e&&(n=(e=f).copy(),n._.cancel.push(c),n._.interrupt.push(c),n._.end.push(p)),h.on=n}),o===0&&l()})}var BA=0;function Pr(e,n,i,s){this._groups=e,this._parents=n,this._name=i,this._id=s}function yE(){return++BA}var Tr=ra.prototype;Pr.prototype={constructor:Pr,select:SA,selectAll:bA,selectChild:Tr.selectChild,selectChildren:Tr.selectChildren,filter:mA,merge:gA,selection:EA,transition:FA,call:Tr.call,nodes:Tr.nodes,node:Tr.node,size:Tr.size,empty:Tr.empty,each:Tr.each,on:wA,attr:J2,attrTween:iA,style:TA,styleTween:MA,text:qA,textTween:DA,remove:_A,tween:W2,delay:aA,duration:cA,ease:fA,easeVarying:pA,end:zA,[Symbol.iterator]:Tr[Symbol.iterator]};function UA(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var HA={time:null,delay:0,duration:250,ease:UA};function VA(e,n){for(var i;!(i=e.__transition)||!(i=i[n]);)if(!(e=e.parentNode))throw new Error(`transition ${n} not found`);return i}function WA(e){var n,i;e instanceof Pr?(n=e._id,e=e._name):(n=yE(),(i=HA).time=Jg(),e=e==null?null:e+"");for(var s=this._groups,o=s.length,l=0;l<o;++l)for(var u=s[l],c=u.length,p,h=0;h<c;++h)(p=u[h])&&Kl(p,e,n,h,u,i||VA(p,n));return new Pr(s,this._parents,e,n)}ra.prototype.interrupt=U2;ra.prototype.transition=WA;const yl=e=>()=>e;function GA(e,{sourceEvent:n,target:i,transform:s,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:o}})}function Ir(e,n,i){this.k=e,this.x=n,this.y=i}Ir.prototype={constructor:Ir,scale:function(e){return e===1?this:new Ir(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new Ir(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 Mr=new Ir(1,0,0);Ir.prototype;function Zc(e){e.stopImmediatePropagation()}function qo(e){e.preventDefault(),e.stopImmediatePropagation()}function KA(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function YA(){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 Ew(){return this.__zoom||Mr}function XA(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function QA(){return navigator.maxTouchPoints||"ontouchstart"in this}function ZA(e,n,i){var s=e.invertX(n[0][0])-i[0][0],o=e.invertX(n[1][0])-i[1][0],l=e.invertY(n[0][1])-i[0][1],u=e.invertY(n[1][1])-i[1][1];return e.translate(o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o),u>l?(l+u)/2:Math.min(0,l)||Math.max(0,u))}function wE(){var e=KA,n=YA,i=ZA,s=XA,o=QA,l=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],c=250,p=O2,h=Vl("start","zoom","end"),f,m,y,x=500,N=150,_=0,S=10;function b(I){I.property("__zoom",Ew).on("wheel.zoom",B,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",M).filter(o).on("touchstart.zoom",F).on("touchmove.zoom",X).on("touchend.zoom touchcancel.zoom",Y).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}b.transform=function(I,H,U,ne){var J=I.selection?I.selection():I;J.property("__zoom",Ew),I!==J?P(I,H,U,ne):J.interrupt().each(function(){O(this,arguments).event(ne).start().zoom(null,typeof H=="function"?H.apply(this,arguments):H).end()})},b.scaleBy=function(I,H,U,ne){b.scaleTo(I,function(){var J=this.__zoom.k,D=typeof H=="function"?H.apply(this,arguments):H;return J*D},U,ne)},b.scaleTo=function(I,H,U,ne){b.transform(I,function(){var J=n.apply(this,arguments),D=this.__zoom,G=U==null?j(J):typeof U=="function"?U.apply(this,arguments):U,k=D.invert(G),L=typeof H=="function"?H.apply(this,arguments):H;return i(C(E(D,L),G,k),J,u)},U,ne)},b.translateBy=function(I,H,U,ne){b.transform(I,function(){return i(this.__zoom.translate(typeof H=="function"?H.apply(this,arguments):H,typeof U=="function"?U.apply(this,arguments):U),n.apply(this,arguments),u)},null,ne)},b.translateTo=function(I,H,U,ne,J){b.transform(I,function(){var D=n.apply(this,arguments),G=this.__zoom,k=ne==null?j(D):typeof ne=="function"?ne.apply(this,arguments):ne;return i(Mr.translate(k[0],k[1]).scale(G.k).translate(typeof H=="function"?-H.apply(this,arguments):-H,typeof U=="function"?-U.apply(this,arguments):-U),D,u)},ne,J)};function E(I,H){return H=Math.max(l[0],Math.min(l[1],H)),H===I.k?I:new Ir(H,I.x,I.y)}function C(I,H,U){var ne=H[0]-U[0]*I.k,J=H[1]-U[1]*I.k;return ne===I.x&&J===I.y?I:new Ir(I.k,ne,J)}function j(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function P(I,H,U,ne){I.on("start.zoom",function(){O(this,arguments).event(ne).start()}).on("interrupt.zoom end.zoom",function(){O(this,arguments).event(ne).end()}).tween("zoom",function(){var J=this,D=arguments,G=O(J,D).event(ne),k=n.apply(J,D),L=U==null?j(k):typeof U=="function"?U.apply(J,D):U,oe=Math.max(k[1][0]-k[0][0],k[1][1]-k[0][1]),$=J.__zoom,Q=typeof H=="function"?H.apply(J,D):H,ee=p($.invert(L).concat(oe/$.k),Q.invert(L).concat(oe/Q.k));return function(se){if(se===1)se=Q;else{var ae=ee(se),pe=oe/ae[2];se=new Ir(pe,L[0]-ae[0]*pe,L[1]-ae[1]*pe)}G.zoom(null,se)}})}function O(I,H,U){return!U&&I.__zooming||new q(I,H)}function q(I,H){this.that=I,this.args=H,this.active=0,this.sourceEvent=null,this.extent=n.apply(I,H),this.taps=0}q.prototype={event:function(I){return I&&(this.sourceEvent=I),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(I,H){return this.mouse&&I!=="mouse"&&(this.mouse[1]=H.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=H.invert(this.touch0[0])),this.touch1&&I!=="touch"&&(this.touch1[1]=H.invert(this.touch1[0])),this.that.__zoom=H,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(I){var H=Mn(this.that).datum();h.call(I,this.that,new GA(I,{sourceEvent:this.sourceEvent,target:b,transform:this.that.__zoom,dispatch:h}),H)}};function B(I,...H){if(!e.apply(this,arguments))return;var U=O(this,H).event(I),ne=this.__zoom,J=Math.max(l[0],Math.min(l[1],ne.k*Math.pow(2,s.apply(this,arguments)))),D=Kn(I);if(U.wheel)(U.mouse[0][0]!==D[0]||U.mouse[0][1]!==D[1])&&(U.mouse[1]=ne.invert(U.mouse[0]=D)),clearTimeout(U.wheel);else{if(ne.k===J)return;U.mouse=[D,ne.invert(D)],Il(this),U.start()}qo(I),U.wheel=setTimeout(G,N),U.zoom("mouse",i(C(E(ne,J),U.mouse[0],U.mouse[1]),U.extent,u));function G(){U.wheel=null,U.end()}}function T(I,...H){if(y||!e.apply(this,arguments))return;var U=I.currentTarget,ne=O(this,H,!0).event(I),J=Mn(I.view).on("mousemove.zoom",L,!0).on("mouseup.zoom",oe,!0),D=Kn(I,U),G=I.clientX,k=I.clientY;iE(I.view),Zc(I),ne.mouse=[D,this.__zoom.invert(D)],Il(this),ne.start();function L($){if(qo($),!ne.moved){var Q=$.clientX-G,ee=$.clientY-k;ne.moved=Q*Q+ee*ee>_}ne.event($).zoom("mouse",i(C(ne.that.__zoom,ne.mouse[0]=Kn($,U),ne.mouse[1]),ne.extent,u))}function oe($){J.on("mousemove.zoom mouseup.zoom",null),sE($.view,ne.moved),qo($),ne.event($).end()}}function M(I,...H){if(e.apply(this,arguments)){var U=this.__zoom,ne=Kn(I.changedTouches?I.changedTouches[0]:I,this),J=U.invert(ne),D=U.k*(I.shiftKey?.5:2),G=i(C(E(U,D),ne,J),n.apply(this,H),u);qo(I),c>0?Mn(this).transition().duration(c).call(P,G,ne,I):Mn(this).call(b.transform,G,ne,I)}}function F(I,...H){if(e.apply(this,arguments)){var U=I.touches,ne=U.length,J=O(this,H,I.changedTouches.length===ne).event(I),D,G,k,L;for(Zc(I),G=0;G<ne;++G)k=U[G],L=Kn(k,this),L=[L,this.__zoom.invert(L),k.identifier],J.touch0?!J.touch1&&J.touch0[2]!==L[2]&&(J.touch1=L,J.taps=0):(J.touch0=L,D=!0,J.taps=1+!!f);f&&(f=clearTimeout(f)),D&&(J.taps<2&&(m=L[0],f=setTimeout(function(){f=null},x)),Il(this),J.start())}}function X(I,...H){if(this.__zooming){var U=O(this,H).event(I),ne=I.changedTouches,J=ne.length,D,G,k,L;for(qo(I),D=0;D<J;++D)G=ne[D],k=Kn(G,this),U.touch0&&U.touch0[2]===G.identifier?U.touch0[0]=k:U.touch1&&U.touch1[2]===G.identifier&&(U.touch1[0]=k);if(G=U.that.__zoom,U.touch1){var oe=U.touch0[0],$=U.touch0[1],Q=U.touch1[0],ee=U.touch1[1],se=(se=Q[0]-oe[0])*se+(se=Q[1]-oe[1])*se,ae=(ae=ee[0]-$[0])*ae+(ae=ee[1]-$[1])*ae;G=E(G,Math.sqrt(se/ae)),k=[(oe[0]+Q[0])/2,(oe[1]+Q[1])/2],L=[($[0]+ee[0])/2,($[1]+ee[1])/2]}else if(U.touch0)k=U.touch0[0],L=U.touch0[1];else return;U.zoom("touch",i(C(G,k,L),U.extent,u))}}function Y(I,...H){if(this.__zooming){var U=O(this,H).event(I),ne=I.changedTouches,J=ne.length,D,G;for(Zc(I),y&&clearTimeout(y),y=setTimeout(function(){y=null},x),D=0;D<J;++D)G=ne[D],U.touch0&&U.touch0[2]===G.identifier?delete U.touch0:U.touch1&&U.touch1[2]===G.identifier&&delete U.touch1;if(U.touch1&&!U.touch0&&(U.touch0=U.touch1,delete U.touch1),U.touch0)U.touch0[1]=this.__zoom.invert(U.touch0[0]);else if(U.end(),U.taps===2&&(G=Kn(G,this),Math.hypot(m[0]-G[0],m[1]-G[1])<S)){var k=Mn(this).on("dblclick.zoom");k&&k.apply(this,arguments)}}}return b.wheelDelta=function(I){return arguments.length?(s=typeof I=="function"?I:yl(+I),b):s},b.filter=function(I){return arguments.length?(e=typeof I=="function"?I:yl(!!I),b):e},b.touchable=function(I){return arguments.length?(o=typeof I=="function"?I:yl(!!I),b):o},b.extent=function(I){return arguments.length?(n=typeof I=="function"?I:yl([[+I[0][0],+I[0][1]],[+I[1][0],+I[1][1]]]),b):n},b.scaleExtent=function(I){return arguments.length?(l[0]=+I[0],l[1]=+I[1],b):[l[0],l[1]]},b.translateExtent=function(I){return arguments.length?(u[0][0]=+I[0][0],u[1][0]=+I[1][0],u[0][1]=+I[0][1],u[1][1]=+I[1][1],b):[[u[0][0],u[0][1]],[u[1][0],u[1][1]]]},b.constrain=function(I){return arguments.length?(i=I,b):i},b.duration=function(I){return arguments.length?(c=+I,b):c},b.interpolate=function(I){return arguments.length?(p=I,b):p},b.on=function(){var I=h.on.apply(h,arguments);return I===h?b:I},b.clickDistance=function(I){return arguments.length?(_=(I=+I)*I,b):Math.sqrt(_)},b.tapDistance=function(I){return arguments.length?(S=+I,b):S},b}var JA=Hk();const Yl=A.createContext(null),eI=Yl.Provider,Or={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.`},xE=Or.error001();function Xe(e,n){const i=A.useContext(Yl);if(i===null)throw new Error(xE);return Vk(i,e,n)}const jt=()=>{const e=A.useContext(Yl);if(e===null)throw new Error(xE);return A.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},tI=e=>e.userSelectionActive?"none":"all";function nv({position:e,children:n,className:i,style:s,...o}){const l=Xe(tI),u=`${e}`.split("-");return le.createElement("div",{className:Ft(["react-flow__panel",i,...u]),style:{...s,pointerEvents:l},...o},n)}function nI({proOptions:e,position:n="bottom-right"}){return e!=null&&e.hideAttribution?null:le.createElement(nv,{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 rI=({x:e,y:n,label:i,labelStyle:s={},labelShowBg:o=!0,labelBgStyle:l={},labelBgPadding:u=[2,4],labelBgBorderRadius:c=2,children:p,className:h,...f})=>{const m=A.useRef(null),[y,x]=A.useState({x:0,y:0,width:0,height:0}),N=Ft(["react-flow__edge-textwrapper",h]);return A.useEffect(()=>{if(m.current){const _=m.current.getBBox();x({x:_.x,y:_.y,width:_.width,height:_.height})}},[i]),typeof i>"u"||!i?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:m,style:s},i),p)};var iI=A.memo(rI);const rv=e=>({width:e.offsetWidth,height:e.offsetHeight}),Hs=(e,n=0,i=1)=>Math.min(Math.max(e,n),i),iv=(e={x:0,y:0},n)=>({x:Hs(e.x,n[0][0],n[1][0]),y:Hs(e.y,n[0][1],n[1][1])}),Nw=(e,n,i)=>e<n?Hs(Math.abs(e-n),1,50)/50:e>i?-Hs(Math.abs(e-i),1,50)/50:0,_E=(e,n)=>{const i=Nw(e.x,35,n.width-35)*20,s=Nw(e.y,35,n.height-35)*20;return[i,s]},SE=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)}),Zo=({x:e,y:n,width:i,height:s})=>({x:e,y:n,x2:e+i,y2:n+s}),kE=({x:e,y:n,x2:i,y2:s})=>({x:e,y:n,width:i-e,height:s-n}),Cw=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),sI=(e,n)=>kE(bE(Zo(e),Zo(n))),Pg=(e,n)=>{const i=Math.max(0,Math.min(e.x+e.width,n.x+n.width)-Math.max(e.x,n.x)),s=Math.max(0,Math.min(e.y+e.height,n.y+n.height)-Math.max(e.y,n.y));return Math.ceil(i*s)},oI=e=>Pn(e.width)&&Pn(e.height)&&Pn(e.x)&&Pn(e.y),Pn=e=>!isNaN(e)&&isFinite(e),ht=Symbol.for("internals"),EE=["Enter"," ","Escape"],aI=(e,n)=>{},lI=e=>"nativeEvent"in e;function Og(e){var o,l;const n=lI(e)?e.nativeEvent:e,i=((l=(o=n.composedPath)==null?void 0:o.call(n))==null?void 0:l[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(i==null?void 0:i.nodeName)||(i==null?void 0:i.hasAttribute("contenteditable"))||!!(i!=null&&i.closest(".nokey"))}const NE=e=>"clientX"in e,mi=(e,n)=>{var l,u;const i=NE(e),s=i?e.clientX:(l=e.touches)==null?void 0:l[0].clientX,o=i?e.clientY:(u=e.touches)==null?void 0:u[0].clientY;return{x:s-((n==null?void 0:n.left)??0),y:o-((n==null?void 0:n.top)??0)}},Dl=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},sa=({id:e,path:n,labelX:i,labelY:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h,style:f,markerEnd:m,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:m,markerStart:y}),x&&le.createElement("path",{d:n,fill:"none",strokeOpacity:0,strokeWidth:x,className:"react-flow__edge-interaction"}),o&&Pn(i)&&Pn(s)?le.createElement(iI,{x:i,y:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h}):null);sa.displayName="BaseEdge";function Lo(e,n,i){return i===void 0?i:s=>{const o=n().edges.find(l=>l.id===e);o&&i(s,{...o})}}function CE({sourceX:e,sourceY:n,targetX:i,targetY:s}){const o=Math.abs(i-e)/2,l=i<e?i+o:i-o,u=Math.abs(s-n)/2,c=s<n?s+u:s-u;return[l,c,o,u]}function jE({sourceX:e,sourceY:n,targetX:i,targetY:s,sourceControlX:o,sourceControlY:l,targetControlX:u,targetControlY:c}){const p=e*.125+o*.375+u*.375+i*.125,h=n*.125+l*.375+c*.375+s*.125,f=Math.abs(p-e),m=Math.abs(h-n);return[p,h,f,m]}var Zi;(function(e){e.Strict="strict",e.Loose="loose"})(Zi||(Zi={}));var Gi;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Gi||(Gi={}));var Jo;(function(e){e.Partial="partial",e.Full="full"})(Jo||(Jo={}));var pi;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(pi||(pi={}));var Fl;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Fl||(Fl={}));var Ce;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ce||(Ce={}));function jw({pos:e,x1:n,y1:i,x2:s,y2:o}){return e===Ce.Left||e===Ce.Right?[.5*(n+s),i]:[n,.5*(i+o)]}function RE({sourceX:e,sourceY:n,sourcePosition:i=Ce.Bottom,targetX:s,targetY:o,targetPosition:l=Ce.Top}){const[u,c]=jw({pos:i,x1:e,y1:n,x2:s,y2:o}),[p,h]=jw({pos:l,x1:s,y1:o,x2:e,y2:n}),[f,m,y,x]=jE({sourceX:e,sourceY:n,targetX:s,targetY:o,sourceControlX:u,sourceControlY:c,targetControlX:p,targetControlY:h});return[`M${e},${n} C${u},${c} ${p},${h} ${s},${o}`,f,m,y,x]}const sv=A.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,sourcePosition:o=Ce.Bottom,targetPosition:l=Ce.Top,label:u,labelStyle:c,labelShowBg:p,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,interactionWidth:_})=>{const[S,b,E]=RE({sourceX:e,sourceY:n,sourcePosition:o,targetX:i,targetY:s,targetPosition:l});return le.createElement(sa,{path:S,labelX:b,labelY:E,label:u,labelStyle:c,labelShowBg:p,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,interactionWidth:_})});sv.displayName="SimpleBezierEdge";const Rw={[Ce.Left]:{x:-1,y:0},[Ce.Right]:{x:1,y:0},[Ce.Top]:{x:0,y:-1},[Ce.Bottom]:{x:0,y:1}},uI=({source:e,sourcePosition:n=Ce.Bottom,target:i})=>n===Ce.Left||n===Ce.Right?e.x<i.x?{x:1,y:0}:{x:-1,y:0}:e.y<i.y?{x:0,y:1}:{x:0,y:-1},Tw=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function cI({source:e,sourcePosition:n=Ce.Bottom,target:i,targetPosition:s=Ce.Top,center:o,offset:l}){const u=Rw[n],c=Rw[s],p={x:e.x+u.x*l,y:e.y+u.y*l},h={x:i.x+c.x*l,y:i.y+c.y*l},f=uI({source:p,sourcePosition:n,target:h}),m=f.x!==0?"x":"y",y=f[m];let x=[],N,_;const S={x:0,y:0},b={x:0,y:0},[E,C,j,P]=CE({sourceX:e.x,sourceY:e.y,targetX:i.x,targetY:i.y});if(u[m]*c[m]===-1){N=o.x??E,_=o.y??C;const q=[{x:N,y:p.y},{x:N,y:h.y}],B=[{x:p.x,y:_},{x:h.x,y:_}];u[m]===y?x=m==="x"?q:B:x=m==="x"?B:q}else{const q=[{x:p.x,y:h.y}],B=[{x:h.x,y:p.y}];if(m==="x"?x=u.x===y?B:q:x=u.y===y?q:B,n===s){const Y=Math.abs(e[m]-i[m]);if(Y<=l){const I=Math.min(l-1,l-Y);u[m]===y?S[m]=(p[m]>e[m]?-1:1)*I:b[m]=(h[m]>i[m]?-1:1)*I}}if(n!==s){const Y=m==="x"?"y":"x",I=u[m]===c[Y],H=p[Y]>h[Y],U=p[Y]<h[Y];(u[m]===1&&(!I&&H||I&&U)||u[m]!==1&&(!I&&U||I&&H))&&(x=m==="x"?q:B)}const T={x:p.x+S.x,y:p.y+S.y},M={x:h.x+b.x,y:h.y+b.y},F=Math.max(Math.abs(T.x-x[0].x),Math.abs(M.x-x[0].x)),X=Math.max(Math.abs(T.y-x[0].y),Math.abs(M.y-x[0].y));F>=X?(N=(T.x+M.x)/2,_=x[0].y):(N=x[0].x,_=(T.y+M.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},i],N,_,j,P]}function dI(e,n,i,s){const o=Math.min(Tw(e,n)/2,Tw(n,i)/2,s),{x:l,y:u}=n;if(e.x===l&&l===i.x||e.y===u&&u===i.y)return`L${l} ${u}`;if(e.y===u){const h=e.x<i.x?-1:1,f=e.y<i.y?1:-1;return`L ${l+o*h},${u}Q ${l},${u} ${l},${u+o*f}`}const c=e.x<i.x?1:-1,p=e.y<i.y?-1:1;return`L ${l},${u+o*p}Q ${l},${u} ${l+o*c},${u}`}function qg({sourceX:e,sourceY:n,sourcePosition:i=Ce.Bottom,targetX:s,targetY:o,targetPosition:l=Ce.Top,borderRadius:u=5,centerX:c,centerY:p,offset:h=20}){const[f,m,y,x,N]=cI({source:{x:e,y:n},sourcePosition:i,target:{x:s,y:o},targetPosition:l,center:{x:c,y:p},offset:h});return[f.reduce((S,b,E)=>{let C="";return E>0&&E<f.length-1?C=dI(f[E-1],b,f[E+1],u):C=`${E===0?"M":"L"}${b.x} ${b.y}`,S+=C,S},""),m,y,x,N]}const Xl=A.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h,style:f,sourcePosition:m=Ce.Bottom,targetPosition:y=Ce.Top,markerEnd:x,markerStart:N,pathOptions:_,interactionWidth:S})=>{const[b,E,C]=qg({sourceX:e,sourceY:n,sourcePosition:m,targetX:i,targetY:s,targetPosition:y,borderRadius:_==null?void 0:_.borderRadius,offset:_==null?void 0:_.offset});return le.createElement(sa,{path:b,labelX:E,labelY:C,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h,style:f,markerEnd:x,markerStart:N,interactionWidth:S})});Xl.displayName="SmoothStepEdge";const ov=A.memo(e=>{var n;return le.createElement(Xl,{...e,pathOptions:A.useMemo(()=>{var i;return{borderRadius:0,offset:(i=e.pathOptions)==null?void 0:i.offset}},[(n=e.pathOptions)==null?void 0:n.offset])})});ov.displayName="StepEdge";function fI({sourceX:e,sourceY:n,targetX:i,targetY:s}){const[o,l,u,c]=CE({sourceX:e,sourceY:n,targetX:i,targetY:s});return[`M ${e},${n}L ${i},${s}`,o,l,u,c]}const av=A.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:y,interactionWidth:x})=>{const[N,_,S]=fI({sourceX:e,sourceY:n,targetX:i,targetY:s});return le.createElement(sa,{path:N,labelX:_,labelY:S,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:y,interactionWidth:x})});av.displayName="StraightEdge";function wl(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function Aw({pos:e,x1:n,y1:i,x2:s,y2:o,c:l}){switch(e){case Ce.Left:return[n-wl(n-s,l),i];case Ce.Right:return[n+wl(s-n,l),i];case Ce.Top:return[n,i-wl(i-o,l)];case Ce.Bottom:return[n,i+wl(o-i,l)]}}function TE({sourceX:e,sourceY:n,sourcePosition:i=Ce.Bottom,targetX:s,targetY:o,targetPosition:l=Ce.Top,curvature:u=.25}){const[c,p]=Aw({pos:i,x1:e,y1:n,x2:s,y2:o,c:u}),[h,f]=Aw({pos:l,x1:s,y1:o,x2:e,y2:n,c:u}),[m,y,x,N]=jE({sourceX:e,sourceY:n,targetX:s,targetY:o,sourceControlX:c,sourceControlY:p,targetControlX:h,targetControlY:f});return[`M${e},${n} C${c},${p} ${h},${f} ${s},${o}`,m,y,x,N]}const zl=A.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,sourcePosition:o=Ce.Bottom,targetPosition:l=Ce.Top,label:u,labelStyle:c,labelShowBg:p,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,pathOptions:_,interactionWidth:S})=>{const[b,E,C]=TE({sourceX:e,sourceY:n,sourcePosition:o,targetX:i,targetY:s,targetPosition:l,curvature:_==null?void 0:_.curvature});return le.createElement(sa,{path:b,labelX:E,labelY:C,label:u,labelStyle:c,labelShowBg:p,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,interactionWidth:S})});zl.displayName="BezierEdge";const lv=A.createContext(null),hI=lv.Provider;lv.Consumer;const pI=()=>A.useContext(lv),mI=e=>"id"in e&&"source"in e&&"target"in e,gI=({source:e,sourceHandle:n,target:i,targetHandle:s})=>`reactflow__edge-${e}${n||""}-${i}${s||""}`,Lg=(e,n)=>typeof e>"u"?"":typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`,vI=(e,n)=>n.some(i=>i.source===e.source&&i.target===e.target&&(i.sourceHandle===e.sourceHandle||!i.sourceHandle&&!e.sourceHandle)&&(i.targetHandle===e.targetHandle||!i.targetHandle&&!e.targetHandle)),yI=(e,n)=>{if(!e.source||!e.target)return n;let i;return mI(e)?i={...e}:i={...e,id:gI(e)},vI(i,n)?n:n.concat(i)},$g=({x:e,y:n},[i,s,o],l,[u,c])=>{const p={x:(e-i)/o,y:(n-s)/o};return l?{x:u*Math.round(p.x/u),y:c*Math.round(p.y/c)}:p},AE=({x:e,y:n},[i,s,o])=>({x:e*o+i,y:n*o+s}),Yi=(e,n=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const i=(e.width??0)*n[0],s=(e.height??0)*n[1],o={x:e.position.x-i,y:e.position.y-s};return{...o,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-i,y:e.positionAbsolute.y-s}:o}},Ql=(e,n=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const i=e.reduce((s,o)=>{const{x:l,y:u}=Yi(o,n).positionAbsolute;return bE(s,Zo({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 kE(i)},IE=(e,n,[i,s,o]=[0,0,1],l=!1,u=!1,c=[0,0])=>{const p={x:(n.x-i)/o,y:(n.y-s)/o,width:n.width/o,height:n.height/o},h=[];return e.forEach(f=>{const{width:m,height:y,selectable:x=!0,hidden:N=!1}=f;if(u&&!x||N)return!1;const{positionAbsolute:_}=Yi(f,c),S={x:_.x,y:_.y,width:m||0,height:y||0},b=Pg(p,S),E=typeof m>"u"||typeof y>"u"||m===null||y===null,C=l&&b>0,j=(m||0)*(y||0);(E||C||b>=j||f.dragging)&&h.push(f)}),h},ME=(e,n)=>{const i=e.map(s=>s.id);return n.filter(s=>i.includes(s.source)||i.includes(s.target))},PE=(e,n,i,s,o,l=.1)=>{const u=n/(e.width*(1+l)),c=i/(e.height*(1+l)),p=Math.min(u,c),h=Hs(p,s,o),f=e.x+e.width/2,m=e.y+e.height/2,y=n/2-f*h,x=i/2-m*h;return{x:y,y:x,zoom:h}},Vi=(e,n=0)=>e.transition().duration(n);function Iw(e,n,i,s){return(n[i]||[]).reduce((o,l)=>{var u,c;return`${e.id}-${l.id}-${i}`!==s&&o.push({id:l.id||null,type:i,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 wI(e,n,i,s,o,l){const{x:u,y:c}=mi(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 _=uv(void 0,h),S=h.getAttribute("data-handleid"),b=l({nodeId:N,id:S,type:_});if(b){const E=o.find(C=>C.nodeId===N&&C.type===_&&C.id===S);return{handle:{id:S,type:_,nodeId:N,x:(E==null?void 0:E.x)||i.x,y:(E==null?void 0:E.y)||i.y},validHandleResult:b}}}}let f=[],m=1/0;if(o.forEach(N=>{const _=Math.sqrt((N.x-i.x)**2+(N.y-i.y)**2);if(_<=s){const S=l(N);_<=m&&(_<m?f=[{handle:N,validHandleResult:S}]:_===m&&f.push({handle:N,validHandleResult:S}),m=_)}}),!f.length)return{handle:null,validHandleResult:OE()};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 xI={source:null,target:null,sourceHandle:null,targetHandle:null},OE=()=>({handleDomNode:null,isValid:!1,connection:xI,endHandle:null});function qE(e,n,i,s,o,l,u){const c=o==="target",p=u.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),h={...OE(),handleDomNode:p};if(p){const f=uv(void 0,p),m=p.getAttribute("data-nodeid"),y=p.getAttribute("data-handleid"),x=p.classList.contains("connectable"),N=p.classList.contains("connectableend"),_={source:c?m:i,sourceHandle:c?y:s,target:c?i:m,targetHandle:c?s:y};h.connection=_,x&&N&&(n===Zi.Strict?c&&f==="source"||!c&&f==="target":m!==i||y!==s)&&(h.endHandle={nodeId:m,handleId:y,type:f},h.isValid=l(_))}return h}function _I({nodes:e,nodeId:n,handleId:i,handleType:s}){return e.reduce((o,l)=>{if(l[ht]){const{handleBounds:u}=l[ht];let c=[],p=[];u&&(c=Iw(l,u,"source",`${n}-${i}-${s}`),p=Iw(l,u,"target",`${n}-${i}-${s}`)),o.push(...c,...p)}return o},[])}function uv(e,n){return e||(n!=null&&n.classList.contains("target")?"target":n!=null&&n.classList.contains("source")?"source":null)}function Jc(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function SI(e,n){let i=null;return n?i="valid":e&&!n&&(i="invalid"),i}function LE({event:e,handleId:n,nodeId:i,onConnect:s,isTarget:o,getState:l,setState:u,isValidConnection:c,edgeUpdaterType:p,onReconnectEnd:h}){const f=SE(e.target),{connectionMode:m,domNode:y,autoPanOnConnect:x,connectionRadius:N,onConnectStart:_,panBy:S,getNodes:b,cancelConnection:E}=l();let C=0,j;const{x:P,y:O}=mi(e),q=f==null?void 0:f.elementFromPoint(P,O),B=uv(p,q),T=y==null?void 0:y.getBoundingClientRect();if(!T||!B)return;let M,F=mi(e,T),X=!1,Y=null,I=!1,H=null;const U=_I({nodes:b(),nodeId:i,handleId:n,handleType:B}),ne=()=>{if(!x)return;const[G,k]=_E(F,T);S({x:G,y:k}),C=requestAnimationFrame(ne)};u({connectionPosition:F,connectionStatus:null,connectionNodeId:i,connectionHandleId:n,connectionHandleType:B,connectionStartHandle:{nodeId:i,handleId:n,type:B},connectionEndHandle:null}),_==null||_(e,{nodeId:i,handleId:n,handleType:B});function J(G){const{transform:k}=l();F=mi(G,T);const{handle:L,validHandleResult:oe}=wI(G,f,$g(F,k,!1,[1,1]),N,U,$=>qE($,m,i,n,o?"target":"source",c,f));if(j=L,X||(ne(),X=!0),H=oe.handleDomNode,Y=oe.connection,I=oe.isValid,u({connectionPosition:j&&I?AE({x:j.x,y:j.y},k):F,connectionStatus:SI(!!j,I),connectionEndHandle:oe.endHandle}),!j&&!I&&!H)return Jc(M);Y.source!==Y.target&&H&&(Jc(M),M=H,H.classList.add("connecting","react-flow__handle-connecting"),H.classList.toggle("valid",I),H.classList.toggle("react-flow__handle-valid",I))}function D(G){var k,L;(j||H)&&Y&&I&&(s==null||s(Y)),(L=(k=l()).onConnectEnd)==null||L.call(k,G),p&&(h==null||h(G)),Jc(M),E(),cancelAnimationFrame(C),X=!1,I=!1,Y=null,H=null,f.removeEventListener("mousemove",J),f.removeEventListener("mouseup",D),f.removeEventListener("touchmove",J),f.removeEventListener("touchend",D)}f.addEventListener("mousemove",J),f.addEventListener("mouseup",D),f.addEventListener("touchmove",J),f.addEventListener("touchend",D)}const Mw=()=>!0,bI=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),kI=(e,n,i)=>s=>{const{connectionStartHandle:o,connectionEndHandle:l,connectionClickStartHandle:u}=s;return{connecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.handleId)===n&&(o==null?void 0:o.type)===i||(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.handleId)===n&&(l==null?void 0:l.type)===i,clickConnecting:(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.handleId)===n&&(u==null?void 0:u.type)===i}},$E=A.forwardRef(({type:e="source",position:n=Ce.Top,isValidConnection:i,isConnectable:s=!0,isConnectableStart:o=!0,isConnectableEnd:l=!0,id:u,onConnect:c,children:p,className:h,onMouseDown:f,onTouchStart:m,...y},x)=>{var T,M;const N=u||null,_=e==="target",S=jt(),b=pI(),{connectOnClick:E,noPanClassName:C}=Xe(bI,Ct),{connecting:j,clickConnecting:P}=Xe(kI(b,N,e),Ct);b||(M=(T=S.getState()).onError)==null||M.call(T,"010",Or.error010());const O=F=>{const{defaultEdgeOptions:X,onConnect:Y,hasDefaultEdges:I}=S.getState(),H={...X,...F};if(I){const{edges:U,setEdges:ne}=S.getState();ne(yI(H,U))}Y==null||Y(H),c==null||c(H)},q=F=>{if(!b)return;const X=NE(F);o&&(X&&F.button===0||!X)&&LE({event:F,handleId:N,nodeId:b,onConnect:O,isTarget:_,getState:S.getState,setState:S.setState,isValidConnection:i||S.getState().isValidConnection||Mw}),X?f==null||f(F):m==null||m(F)},B=F=>{const{onClickConnectStart:X,onClickConnectEnd:Y,connectionClickStartHandle:I,connectionMode:H,isValidConnection:U}=S.getState();if(!b||!I&&!o)return;if(!I){X==null||X(F,{nodeId:b,handleId:N,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:b,type:e,handleId:N}});return}const ne=SE(F.target),J=i||U||Mw,{connection:D,isValid:G}=qE({nodeId:b,id:N,type:e},H,I.nodeId,I.handleId||null,I.type,J,ne);G&&O(D),Y==null||Y(F),S.setState({connectionClickStartHandle:null})};return le.createElement("div",{"data-handleid":N,"data-nodeid":b,"data-handlepos":n,"data-id":`${b}-${N}-${e}`,className:Ft(["react-flow__handle",`react-flow__handle-${n}`,"nodrag",C,h,{source:!_,target:_,connectable:s,connectablestart:o,connectableend:l,connecting:P,connectionindicator:s&&(o&&!j||l&&j)}]),onMouseDown:q,onTouchStart:q,onClick:E?B:void 0,ref:x,...y},p)});$E.displayName="Handle";var Vs=A.memo($E);const DE=({data:e,isConnectable:n,targetPosition:i=Ce.Top,sourcePosition:s=Ce.Bottom})=>le.createElement(le.Fragment,null,le.createElement(Vs,{type:"target",position:i,isConnectable:n}),e==null?void 0:e.label,le.createElement(Vs,{type:"source",position:s,isConnectable:n}));DE.displayName="DefaultNode";var Dg=A.memo(DE);const FE=({data:e,isConnectable:n,sourcePosition:i=Ce.Bottom})=>le.createElement(le.Fragment,null,e==null?void 0:e.label,le.createElement(Vs,{type:"source",position:i,isConnectable:n}));FE.displayName="InputNode";var zE=A.memo(FE);const BE=({data:e,isConnectable:n,targetPosition:i=Ce.Top})=>le.createElement(le.Fragment,null,le.createElement(Vs,{type:"target",position:i,isConnectable:n}),e==null?void 0:e.label);BE.displayName="OutputNode";var UE=A.memo(BE);const cv=()=>null;cv.displayName="GroupNode";const EI=e=>({selectedNodes:e.getNodes().filter(n=>n.selected),selectedEdges:e.edges.filter(n=>n.selected).map(n=>({...n}))}),xl=e=>e.id;function NI(e,n){return Ct(e.selectedNodes.map(xl),n.selectedNodes.map(xl))&&Ct(e.selectedEdges.map(xl),n.selectedEdges.map(xl))}const HE=A.memo(({onSelectionChange:e})=>{const n=jt(),{selectedNodes:i,selectedEdges:s}=Xe(EI,NI);return A.useEffect(()=>{const o={nodes:i,edges:s};e==null||e(o),n.getState().onSelectionChange.forEach(l=>l(o))},[i,s,e]),null});HE.displayName="SelectionListener";const CI=e=>!!e.onSelectionChange;function jI({onSelectionChange:e}){const n=Xe(CI);return e||n?le.createElement(HE,{onSelectionChange:e}):null}const RI=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 Ts(e,n){A.useEffect(()=>{typeof e<"u"&&n(e)},[e])}function Le(e,n,i){A.useEffect(()=>{typeof n<"u"&&i({[e]:n})},[n])}const TI=({nodes:e,edges:n,defaultNodes:i,defaultEdges:s,onConnect:o,onConnectStart:l,onConnectEnd:u,onClickConnectStart:c,onClickConnectEnd:p,nodesDraggable:h,nodesConnectable:f,nodesFocusable:m,edgesFocusable:y,edgesUpdatable:x,elevateNodesOnSelect:N,minZoom:_,maxZoom:S,nodeExtent:b,onNodesChange:E,onEdgesChange:C,elementsSelectable:j,connectionMode:P,snapGrid:O,snapToGrid:q,translateExtent:B,connectOnClick:T,defaultEdgeOptions:M,fitView:F,fitViewOptions:X,onNodesDelete:Y,onEdgesDelete:I,onNodeDrag:H,onNodeDragStart:U,onNodeDragStop:ne,onSelectionDrag:J,onSelectionDragStart:D,onSelectionDragStop:G,noPanClassName:k,nodeOrigin:L,rfId:oe,autoPanOnConnect:$,autoPanOnNodeDrag:Q,onError:ee,connectionRadius:se,isValidConnection:ae,nodeDragThreshold:pe})=>{const{setNodes:ge,setEdges:Ae,setDefaultNodesAndEdges:Oe,setMinZoom:Me,setMaxZoom:Pe,setTranslateExtent:ke,setNodeExtent:We,reset:ve}=Xe(RI,Ct),ye=jt();return A.useEffect(()=>{const Ge=s==null?void 0:s.map(ut=>({...ut,...M}));return Oe(i,Ge),()=>{ve()}},[]),Le("defaultEdgeOptions",M,ye.setState),Le("connectionMode",P,ye.setState),Le("onConnect",o,ye.setState),Le("onConnectStart",l,ye.setState),Le("onConnectEnd",u,ye.setState),Le("onClickConnectStart",c,ye.setState),Le("onClickConnectEnd",p,ye.setState),Le("nodesDraggable",h,ye.setState),Le("nodesConnectable",f,ye.setState),Le("nodesFocusable",m,ye.setState),Le("edgesFocusable",y,ye.setState),Le("edgesUpdatable",x,ye.setState),Le("elementsSelectable",j,ye.setState),Le("elevateNodesOnSelect",N,ye.setState),Le("snapToGrid",q,ye.setState),Le("snapGrid",O,ye.setState),Le("onNodesChange",E,ye.setState),Le("onEdgesChange",C,ye.setState),Le("connectOnClick",T,ye.setState),Le("fitViewOnInit",F,ye.setState),Le("fitViewOnInitOptions",X,ye.setState),Le("onNodesDelete",Y,ye.setState),Le("onEdgesDelete",I,ye.setState),Le("onNodeDrag",H,ye.setState),Le("onNodeDragStart",U,ye.setState),Le("onNodeDragStop",ne,ye.setState),Le("onSelectionDrag",J,ye.setState),Le("onSelectionDragStart",D,ye.setState),Le("onSelectionDragStop",G,ye.setState),Le("noPanClassName",k,ye.setState),Le("nodeOrigin",L,ye.setState),Le("rfId",oe,ye.setState),Le("autoPanOnConnect",$,ye.setState),Le("autoPanOnNodeDrag",Q,ye.setState),Le("onError",ee,ye.setState),Le("connectionRadius",se,ye.setState),Le("isValidConnection",ae,ye.setState),Le("nodeDragThreshold",pe,ye.setState),Ts(e,ge),Ts(n,Ae),Ts(_,Me),Ts(S,Pe),Ts(B,ke),Ts(b,We),null},Pw={display:"none"},AI={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},VE="react-flow__node-desc",WE="react-flow__edge-desc",II="react-flow__aria-live",MI=e=>e.ariaLiveMessage;function PI({rfId:e}){const n=Xe(MI);return le.createElement("div",{id:`${II}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:AI},n)}function OI({rfId:e,disableKeyboardA11y:n}){return le.createElement(le.Fragment,null,le.createElement("div",{id:`${VE}-${e}`,style:Pw},"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:`${WE}-${e}`,style:Pw},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!n&&le.createElement(PI,{rfId:e}))}var ea=(e=null,n={actInsideInputWithModifier:!0})=>{const[i,s]=A.useState(!1),o=A.useRef(!1),l=A.useRef(new Set([])),[u,c]=A.useMemo(()=>{if(e!==null){const h=(Array.isArray(e)?e:[e]).filter(m=>typeof m=="string").map(m=>m.split("+")),f=h.reduce((m,y)=>m.concat(...y),[]);return[h,f]}return[[],[]]},[e]);return A.useEffect(()=>{const p=typeof document<"u"?document:null,h=(n==null?void 0:n.target)||p;if(e!==null){const f=x=>{if(o.current=x.ctrlKey||x.metaKey||x.shiftKey,(!o.current||o.current&&!n.actInsideInputWithModifier)&&Og(x))return!1;const _=qw(x.code,c);l.current.add(x[_]),Ow(u,l.current,!1)&&(x.preventDefault(),s(!0))},m=x=>{if((!o.current||o.current&&!n.actInsideInputWithModifier)&&Og(x))return!1;const _=qw(x.code,c);Ow(u,l.current,!0)?(s(!1),l.current.clear()):l.current.delete(x[_]),x.key==="Meta"&&l.current.clear(),o.current=!1},y=()=>{l.current.clear(),s(!1)};return h==null||h.addEventListener("keydown",f),h==null||h.addEventListener("keyup",m),window.addEventListener("blur",y),()=>{h==null||h.removeEventListener("keydown",f),h==null||h.removeEventListener("keyup",m),window.removeEventListener("blur",y)}}},[e,s]),i};function Ow(e,n,i){return e.filter(s=>i||s.length===n.size).some(s=>s.every(o=>n.has(o)))}function qw(e,n){return n.includes(e)?"code":"key"}function GE(e,n,i,s){var c,p;const o=e.parentNode||e.parentId;if(!o)return i;const l=n.get(o),u=Yi(l,s);return GE(l,n,{x:(i.x??0)+u.x,y:(i.y??0)+u.y,z:(((c=l[ht])==null?void 0:c.z)??0)>(i.z??0)?((p=l[ht])==null?void 0:p.z)??0:i.z??0},s)}function KE(e,n,i){e.forEach(s=>{var l;const o=s.parentNode||s.parentId;if(o&&!e.has(o))throw new Error(`Parent node ${o} not found`);if(o||i!=null&&i[s.id]){const{x:u,y:c,z:p}=GE(s,e,{...s.position,z:((l=s[ht])==null?void 0:l.z)??0},n);s.positionAbsolute={x:u,y:c},s[ht].z=p,i!=null&&i[s.id]&&(s[ht].isParent=!0)}})}function ed(e,n,i,s){const o=new Map,l={},u=s?1e3:0;return e.forEach(c=>{var x;const p=(Pn(c.zIndex)?c.zIndex:0)+(c.selected?u:0),h=n.get(c.id),f={...c,positionAbsolute:{x:c.position.x,y:c.position.y}},m=c.parentNode||c.parentId;m&&(l[m]=!0);const y=(h==null?void 0:h.type)&&(h==null?void 0:h.type)!==c.type;Object.defineProperty(f,ht,{enumerable:!1,value:{handleBounds:y||(x=h==null?void 0:h[ht])==null?void 0:x.handleBounds,z:p}}),o.set(c.id,f)}),KE(o,i,l),o}function YE(e,n={}){const{getNodes:i,width:s,height:o,minZoom:l,maxZoom:u,d3Zoom:c,d3Selection:p,fitViewOnInitDone:h,fitViewOnInit:f,nodeOrigin:m}=e(),y=n.initial&&!h&&f;if(c&&p&&(y||!n.initial)){const N=i().filter(S=>{var E;const b=n.includeHiddenNodes?S.width&&S.height:!S.hidden;return(E=n.nodes)!=null&&E.length?b&&n.nodes.some(C=>C.id===S.id):b}),_=N.every(S=>S.width&&S.height);if(N.length>0&&_){const S=Ql(N,m),{x:b,y:E,zoom:C}=PE(S,s,o,n.minZoom??l,n.maxZoom??u,n.padding??.1),j=Mr.translate(b,E).scale(C);return typeof n.duration=="number"&&n.duration>0?c.transform(Vi(p,n.duration),j):c.transform(p,j),!0}}return!1}function qI(e,n){return e.forEach(i=>{const s=n.get(i.id);s&&n.set(s.id,{...s,[ht]:s[ht],selected:i.selected})}),new Map(n)}function LI(e,n){return n.map(i=>{const s=e.find(o=>o.id===i.id);return s&&(i.selected=s.selected),i})}function _l({changedNodes:e,changedEdges:n,get:i,set:s}){const{nodeInternals:o,edges:l,onNodesChange:u,onEdgesChange:c,hasDefaultNodes:p,hasDefaultEdges:h}=i();e!=null&&e.length&&(p&&s({nodeInternals:qI(e,o)}),u==null||u(e)),n!=null&&n.length&&(h&&s({edges:LI(n,l)}),c==null||c(n))}const As=()=>{},$I={zoomIn:As,zoomOut:As,zoomTo:As,getZoom:()=>1,setViewport:As,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:As,fitBounds:As,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},DI=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),FI=()=>{const e=jt(),{d3Zoom:n,d3Selection:i}=Xe(DI,Ct);return A.useMemo(()=>i&&n?{zoomIn:o=>n.scaleBy(Vi(i,o==null?void 0:o.duration),1.2),zoomOut:o=>n.scaleBy(Vi(i,o==null?void 0:o.duration),1/1.2),zoomTo:(o,l)=>n.scaleTo(Vi(i,l==null?void 0:l.duration),o),getZoom:()=>e.getState().transform[2],setViewport:(o,l)=>{const[u,c,p]=e.getState().transform,h=Mr.translate(o.x??u,o.y??c).scale(o.zoom??p);n.transform(Vi(i,l==null?void 0:l.duration),h)},getViewport:()=>{const[o,l,u]=e.getState().transform;return{x:o,y:l,zoom:u}},fitView:o=>YE(e.getState,o),setCenter:(o,l,u)=>{const{width:c,height:p,maxZoom:h}=e.getState(),f=typeof(u==null?void 0:u.zoom)<"u"?u.zoom:h,m=c/2-o*f,y=p/2-l*f,x=Mr.translate(m,y).scale(f);n.transform(Vi(i,u==null?void 0:u.duration),x)},fitBounds:(o,l)=>{const{width:u,height:c,minZoom:p,maxZoom:h}=e.getState(),{x:f,y:m,zoom:y}=PE(o,u,c,p,h,(l==null?void 0:l.padding)??.1),x=Mr.translate(f,m).scale(y);n.transform(Vi(i,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"),$g(o,l,u,c)},screenToFlowPosition:o=>{const{transform:l,snapToGrid:u,snapGrid:c,domNode:p}=e.getState();if(!p)return o;const{x:h,y:f}=p.getBoundingClientRect(),m={x:o.x-h,y:o.y-f};return $g(m,l,u,c)},flowToScreenPosition:o=>{const{transform:l,domNode:u}=e.getState();if(!u)return o;const{x:c,y:p}=u.getBoundingClientRect(),h=AE(o,l);return{x:h.x+c,y:h.y+p}},viewportInitialized:!0}:$I,[n,i])};function oa(){const e=FI(),n=jt(),i=A.useCallback(()=>n.getState().getNodes().map(_=>({..._})),[]),s=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:E,onNodesChange:C}=n.getState(),j=S(),P=typeof _=="function"?_(j):_;if(E)b(P);else if(C){const O=P.length===0?j.map(q=>({type:"remove",id:q.id})):P.map(q=>({item:q,type:"reset"}));C(O)}},[]),c=A.useCallback(_=>{const{edges:S=[],setEdges:b,hasDefaultEdges:E,onEdgesChange:C}=n.getState(),j=typeof _=="function"?_(S):_;if(E)b(j);else if(C){const P=j.length===0?S.map(O=>({type:"remove",id:O.id})):j.map(O=>({item:O,type:"reset"}));C(P)}},[]),p=A.useCallback(_=>{const S=Array.isArray(_)?_:[_],{getNodes:b,setNodes:E,hasDefaultNodes:C,onNodesChange:j}=n.getState();if(C){const O=[...b(),...S];E(O)}else if(j){const P=S.map(O=>({item:O,type:"add"}));j(P)}},[]),h=A.useCallback(_=>{const S=Array.isArray(_)?_:[_],{edges:b=[],setEdges:E,hasDefaultEdges:C,onEdgesChange:j}=n.getState();if(C)E([...b,...S]);else if(j){const P=S.map(O=>({item:O,type:"add"}));j(P)}},[]),f=A.useCallback(()=>{const{getNodes:_,edges:S=[],transform:b}=n.getState(),[E,C,j]=b;return{nodes:_().map(P=>({...P})),edges:S.map(P=>({...P})),viewport:{x:E,y:C,zoom:j}}},[]),m=A.useCallback(({nodes:_,edges:S})=>{const{nodeInternals:b,getNodes:E,edges:C,hasDefaultNodes:j,hasDefaultEdges:P,onNodesDelete:O,onEdgesDelete:q,onNodesChange:B,onEdgesChange:T}=n.getState(),M=(_||[]).map(H=>H.id),F=(S||[]).map(H=>H.id),X=E().reduce((H,U)=>{const ne=U.parentNode||U.parentId,J=!M.includes(U.id)&&ne&&H.find(G=>G.id===ne);return(typeof U.deletable=="boolean"?U.deletable:!0)&&(M.includes(U.id)||J)&&H.push(U),H},[]),Y=C.filter(H=>typeof H.deletable=="boolean"?H.deletable:!0),I=Y.filter(H=>F.includes(H.id));if(X||I){const H=ME(X,Y),U=[...I,...H],ne=U.reduce((J,D)=>(J.includes(D.id)||J.push(D.id),J),[]);if((P||j)&&(P&&n.setState({edges:C.filter(J=>!ne.includes(J.id))}),j&&(X.forEach(J=>{b.delete(J.id)}),n.setState({nodeInternals:new Map(b)}))),ne.length>0&&(q==null||q(U),T&&T(ne.map(J=>({id:J,type:"remove"})))),X.length>0&&(O==null||O(X),B)){const J=X.map(D=>({id:D.id,type:"remove"}));B(J)}}},[]),y=A.useCallback(_=>{const S=oI(_),b=S?null:n.getState().nodeInternals.get(_.id);return!S&&!b?[null,null,S]:[S?_:Cw(b),b,S]},[]),x=A.useCallback((_,S=!0,b)=>{const[E,C,j]=y(_);return E?(b||n.getState().getNodes()).filter(P=>{if(!j&&(P.id===C.id||!P.positionAbsolute))return!1;const O=Cw(P),q=Pg(O,E);return S&&q>0||q>=E.width*E.height}):[]},[]),N=A.useCallback((_,S,b=!0)=>{const[E]=y(_);if(!E)return!1;const C=Pg(E,S);return b&&C>0||C>=E.width*E.height},[]);return A.useMemo(()=>({...e,getNodes:i,getNode:s,getEdges:o,getEdge:l,setNodes:u,setEdges:c,addNodes:p,addEdges:h,toObject:f,deleteElements:m,getIntersectingNodes:x,isNodeIntersecting:N}),[e,i,s,o,l,u,c,p,h,f,m,x,N])}const zI={actInsideInputWithModifier:!1};var BI=({deleteKeyCode:e,multiSelectionKeyCode:n})=>{const i=jt(),{deleteElements:s}=oa(),o=ea(e,zI),l=ea(n);A.useEffect(()=>{if(o){const{edges:u,getNodes:c}=i.getState(),p=c().filter(f=>f.selected),h=u.filter(f=>f.selected);s({nodes:p,edges:h}),i.setState({nodesSelectionActive:!1})}},[o]),A.useEffect(()=>{i.setState({multiSelectionActive:l})},[l])};function UI(e){const n=jt();A.useEffect(()=>{let i;const s=()=>{var l,u;if(!e.current)return;const o=rv(e.current);(o.height===0||o.width===0)&&((u=(l=n.getState()).onError)==null||u.call(l,"004",Or.error004())),n.setState({width:o.width||500,height:o.height||500})};return s(),window.addEventListener("resize",s),e.current&&(i=new ResizeObserver(()=>s()),i.observe(e.current)),()=>{window.removeEventListener("resize",s),i&&e.current&&i.unobserve(e.current)}},[])}const dv={position:"absolute",width:"100%",height:"100%",top:0,left:0},HI=(e,n)=>e.x!==n.x||e.y!==n.y||e.zoom!==n.k,Sl=e=>({x:e.x,y:e.y,zoom:e.k}),Is=(e,n)=>e.target.closest(`.${n}`),Lw=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),$w=e=>{const n=e.ctrlKey&&Dl()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n},VI=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),WI=({onMove:e,onMoveStart:n,onMoveEnd:i,onPaneContextMenu:s,zoomOnScroll:o=!0,zoomOnPinch:l=!0,panOnScroll:u=!1,panOnScrollSpeed:c=.5,panOnScrollMode:p=Gi.Free,zoomOnDoubleClick:h=!0,elementsSelectable:f,panOnDrag:m=!0,defaultViewport:y,translateExtent:x,minZoom:N,maxZoom:_,zoomActivationKeyCode:S,preventScrolling:b=!0,children:E,noWheelClassName:C,noPanClassName:j})=>{const P=A.useRef(),O=jt(),q=A.useRef(!1),B=A.useRef(!1),T=A.useRef(null),M=A.useRef({x:0,y:0,zoom:0}),{d3Zoom:F,d3Selection:X,d3ZoomHandler:Y,userSelectionActive:I}=Xe(VI,Ct),H=ea(S),U=A.useRef(0),ne=A.useRef(!1),J=A.useRef();return UI(T),A.useEffect(()=>{if(T.current){const D=T.current.getBoundingClientRect(),G=wE().scaleExtent([N,_]).translateExtent(x),k=Mn(T.current).call(G),L=Mr.translate(y.x,y.y).scale(Hs(y.zoom,N,_)),oe=[[0,0],[D.width,D.height]],$=G.constrain()(L,oe,x);G.transform(k,$),G.wheelDelta($w),O.setState({d3Zoom:G,d3Selection:k,d3ZoomHandler:k.on("wheel.zoom"),transform:[$.x,$.y,$.k],domNode:T.current.closest(".react-flow")})}},[]),A.useEffect(()=>{X&&F&&(u&&!H&&!I?X.on("wheel.zoom",D=>{if(Is(D,C))return!1;D.preventDefault(),D.stopImmediatePropagation();const G=X.property("__zoom").k||1;if(D.ctrlKey&&l){const ae=Kn(D),pe=$w(D),ge=G*Math.pow(2,pe);F.scaleTo(X,ge,ae,D);return}const k=D.deltaMode===1?20:1;let L=p===Gi.Vertical?0:D.deltaX*k,oe=p===Gi.Horizontal?0:D.deltaY*k;!Dl()&&D.shiftKey&&p!==Gi.Vertical&&(L=D.deltaY*k,oe=0),F.translateBy(X,-(L/G)*c,-(oe/G)*c,{internal:!0});const $=Sl(X.property("__zoom")),{onViewportChangeStart:Q,onViewportChange:ee,onViewportChangeEnd:se}=O.getState();clearTimeout(J.current),ne.current||(ne.current=!0,n==null||n(D,$),Q==null||Q($)),ne.current&&(e==null||e(D,$),ee==null||ee($),J.current=setTimeout(()=>{i==null||i(D,$),se==null||se($),ne.current=!1},150))},{passive:!1}):typeof Y<"u"&&X.on("wheel.zoom",function(D,G){if(!b&&D.type==="wheel"&&!D.ctrlKey||Is(D,C))return null;D.preventDefault(),Y.call(this,D,G)},{passive:!1}))},[I,u,p,X,F,Y,H,l,b,C,n,e,i]),A.useEffect(()=>{F&&F.on("start",D=>{var L,oe;if(!D.sourceEvent||D.sourceEvent.internal)return null;U.current=(L=D.sourceEvent)==null?void 0:L.button;const{onViewportChangeStart:G}=O.getState(),k=Sl(D.transform);q.current=!0,M.current=k,((oe=D.sourceEvent)==null?void 0:oe.type)==="mousedown"&&O.setState({paneDragging:!0}),G==null||G(k),n==null||n(D.sourceEvent,k)})},[F,n]),A.useEffect(()=>{F&&(I&&!q.current?F.on("zoom",null):I||F.on("zoom",D=>{var k;const{onViewportChange:G}=O.getState();if(O.setState({transform:[D.transform.x,D.transform.y,D.transform.k]}),B.current=!!(s&&Lw(m,U.current??0)),(e||G)&&!((k=D.sourceEvent)!=null&&k.internal)){const L=Sl(D.transform);G==null||G(L),e==null||e(D.sourceEvent,L)}}))},[I,F,e,m,s]),A.useEffect(()=>{F&&F.on("end",D=>{if(!D.sourceEvent||D.sourceEvent.internal)return null;const{onViewportChangeEnd:G}=O.getState();if(q.current=!1,O.setState({paneDragging:!1}),s&&Lw(m,U.current??0)&&!B.current&&s(D.sourceEvent),B.current=!1,(i||G)&&HI(M.current,D.transform)){const k=Sl(D.transform);M.current=k,clearTimeout(P.current),P.current=setTimeout(()=>{G==null||G(k),i==null||i(D.sourceEvent,k)},u?150:0)}})},[F,u,m,i,s]),A.useEffect(()=>{F&&F.filter(D=>{const G=H||o,k=l&&D.ctrlKey;if((m===!0||Array.isArray(m)&&m.includes(1))&&D.button===1&&D.type==="mousedown"&&(Is(D,"react-flow__node")||Is(D,"react-flow__edge")))return!0;if(!m&&!G&&!u&&!h&&!l||I||!h&&D.type==="dblclick"||Is(D,C)&&D.type==="wheel"||Is(D,j)&&(D.type!=="wheel"||u&&D.type==="wheel"&&!H)||!l&&D.ctrlKey&&D.type==="wheel"||!G&&!u&&!k&&D.type==="wheel"||!m&&(D.type==="mousedown"||D.type==="touchstart")||Array.isArray(m)&&!m.includes(D.button)&&D.type==="mousedown")return!1;const L=Array.isArray(m)&&m.includes(D.button)||!D.button||D.button<=1;return(!D.ctrlKey||D.type==="wheel")&&L})},[I,F,o,l,u,h,m,f,H]),le.createElement("div",{className:"react-flow__renderer",ref:T,style:dv},E)},GI=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function KI(){const{userSelectionActive:e,userSelectionRect:n}=Xe(GI,Ct);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 Dw(e,n){const i=n.parentNode||n.parentId,s=e.find(o=>o.id===i);if(s){const o=n.position.x+n.width-s.width,l=n.position.y+n.height-s.height;if(o>0||l>0||n.position.x<0||n.position.y<0){if(s.style={...s.style},s.style.width=s.style.width??s.width,s.style.height=s.style.height??s.height,o>0&&(s.style.width+=o),l>0&&(s.style.height+=l),n.position.x<0){const u=Math.abs(n.position.x);s.position.x=s.position.x-u,s.style.width+=u,n.position.x=0}if(n.position.y<0){const u=Math.abs(n.position.y);s.position.y=s.position.y-u,s.style.height+=u,n.position.y=0}s.width=s.style.width,s.height=s.style.height}}}function YI(e,n){if(e.some(s=>s.type==="reset"))return e.filter(s=>s.type==="reset").map(s=>s.item);const i=e.filter(s=>s.type==="add").map(s=>s.item);return n.reduce((s,o)=>{const l=e.filter(c=>c.id===o.id);if(l.length===0)return s.push(o),s;const u={...o};for(const c of l)if(c)switch(c.type){case"select":{u.selected=c.selected;break}case"position":{typeof c.position<"u"&&(u.position=c.position),typeof c.positionAbsolute<"u"&&(u.positionAbsolute=c.positionAbsolute),typeof c.dragging<"u"&&(u.dragging=c.dragging),u.expandParent&&Dw(s,u);break}case"dimensions":{typeof c.dimensions<"u"&&(u.width=c.dimensions.width,u.height=c.dimensions.height),typeof c.updateStyle<"u"&&(u.style={...u.style||{},...c.dimensions}),typeof c.resizing=="boolean"&&(u.resizing=c.resizing),u.expandParent&&Dw(s,u);break}case"remove":return s}return s.push(u),s},i)}function XI(e,n){return YI(e,n)}const hi=(e,n)=>({id:e,type:"select",selected:n});function qs(e,n){return e.reduce((i,s)=>{const o=n.includes(s.id);return!s.selected&&o?(s.selected=!0,i.push(hi(s.id,!0))):s.selected&&!o&&(s.selected=!1,i.push(hi(s.id,!1))),i},[])}const td=(e,n)=>i=>{i.target===n.current&&(e==null||e(i))},QI=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),XE=A.memo(({isSelecting:e,selectionMode:n=Jo.Full,panOnDrag:i,onSelectionStart:s,onSelectionEnd:o,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:c,onPaneMouseEnter:p,onPaneMouseMove:h,onPaneMouseLeave:f,children:m})=>{const y=A.useRef(null),x=jt(),N=A.useRef(0),_=A.useRef(0),S=A.useRef(),{userSelectionActive:b,elementsSelectable:E,dragging:C}=Xe(QI,Ct),j=()=>{x.setState({userSelectionActive:!1,userSelectionRect:null}),N.current=0,_.current=0},P=Y=>{l==null||l(Y),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},O=Y=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){Y.preventDefault();return}u==null||u(Y)},q=c?Y=>c(Y):void 0,B=Y=>{const{resetSelectedElements:I,domNode:H}=x.getState();if(S.current=H==null?void 0:H.getBoundingClientRect(),!E||!e||Y.button!==0||Y.target!==y.current||!S.current)return;const{x:U,y:ne}=mi(Y,S.current);I(),x.setState({userSelectionRect:{width:0,height:0,startX:U,startY:ne,x:U,y:ne}}),s==null||s(Y)},T=Y=>{const{userSelectionRect:I,nodeInternals:H,edges:U,transform:ne,onNodesChange:J,onEdgesChange:D,nodeOrigin:G,getNodes:k}=x.getState();if(!e||!S.current||!I)return;x.setState({userSelectionActive:!0,nodesSelectionActive:!1});const L=mi(Y,S.current),oe=I.startX??0,$=I.startY??0,Q={...I,x:L.x<oe?L.x:oe,y:L.y<$?L.y:$,width:Math.abs(L.x-oe),height:Math.abs(L.y-$)},ee=k(),se=IE(H,Q,ne,n===Jo.Partial,!0,G),ae=ME(se,U).map(ge=>ge.id),pe=se.map(ge=>ge.id);if(N.current!==pe.length){N.current=pe.length;const ge=qs(ee,pe);ge.length&&(J==null||J(ge))}if(_.current!==ae.length){_.current=ae.length;const ge=qs(U,ae);ge.length&&(D==null||D(ge))}x.setState({userSelectionRect:Q})},M=Y=>{if(Y.button!==0)return;const{userSelectionRect:I}=x.getState();!b&&I&&Y.target===y.current&&(P==null||P(Y)),x.setState({nodesSelectionActive:N.current>0}),j(),o==null||o(Y)},F=Y=>{b&&(x.setState({nodesSelectionActive:N.current>0}),o==null||o(Y)),j()},X=E&&(e||b);return le.createElement("div",{className:Ft(["react-flow__pane",{dragging:C,selection:e}]),onClick:X?void 0:td(P,y),onContextMenu:td(O,y),onWheel:td(q,y),onMouseEnter:X?void 0:p,onMouseDown:X?B:void 0,onMouseMove:X?T:h,onMouseUp:X?M:void 0,onMouseLeave:X?F:f,ref:y,style:dv},m,le.createElement(KI,null))});XE.displayName="Pane";function QE(e,n){const i=e.parentNode||e.parentId;if(!i)return!1;const s=n.get(i);return s?s.selected?!0:QE(s,n):!1}function Fw(e,n,i){let s=e;do{if(s!=null&&s.matches(n))return!0;if(s===i.current)return!1;s=s.parentElement}while(s);return!1}function ZI(e,n,i,s){return Array.from(e.values()).filter(o=>(o.selected||o.id===s)&&(!o.parentNode||o.parentId||!QE(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:i.x-(((l=o.positionAbsolute)==null?void 0:l.x)??0),y:i.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 JI(e,n){return!n||n==="parent"?n:[n[0],[n[1][0]-(e.width||0),n[1][1]-(e.height||0)]]}function ZE(e,n,i,s,o=[0,0],l){const u=JI(e,e.extent||s);let c=u;const p=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(p&&e.width&&e.height){const m=i.get(p),{x:y,y:x}=Yi(m,o).positionAbsolute;c=m&&Pn(y)&&Pn(x)&&Pn(m.width)&&Pn(m.height)?[[y+e.width*o[0],x+e.height*o[1]],[y+m.width-e.width+e.width*o[0],x+m.height-e.height+e.height*o[1]]]:c}else l==null||l("005",Or.error005()),c=u;else if(e.extent&&p&&e.extent!=="parent"){const m=i.get(p),{x:y,y:x}=Yi(m,o).positionAbsolute;c=[[e.extent[0][0]+y,e.extent[0][1]+x],[e.extent[1][0]+y,e.extent[1][1]+x]]}let h={x:0,y:0};if(p){const m=i.get(p);h=Yi(m,o).positionAbsolute}const f=c&&c!=="parent"?iv(n,c):n;return{position:{x:f.x-h.x,y:f.y-h.y},positionAbsolute:f}}function nd({nodeId:e,dragItems:n,nodeInternals:i}){const s=n.map(o=>({...i.get(o.id),position:o.position,positionAbsolute:o.positionAbsolute}));return[e?s.find(o=>o.id===e):s[0],s]}const zw=(e,n,i,s)=>{const o=n.querySelectorAll(e);if(!o||!o.length)return null;const l=Array.from(o),u=n.getBoundingClientRect(),c={x:u.width*s[0],y:u.height*s[1]};return l.map(p=>{const h=p.getBoundingClientRect();return{id:p.getAttribute("data-handleid"),position:p.getAttribute("data-handlepos"),x:(h.left-u.left-c.x)/i,y:(h.top-u.top-c.y)/i,...rv(p)}})};function $o(e,n,i){return i===void 0?i:s=>{const o=n().nodeInternals.get(e);o&&i(s,{...o})}}function Fg({id:e,store:n,unselect:i=!1,nodeRef:s}){const{addSelectedNodes:o,unselectNodesAndEdges:l,multiSelectionActive:u,nodeInternals:c,onError:p}=n.getState(),h=c.get(e);if(!h){p==null||p("012",Or.error012(e));return}n.setState({nodesSelectionActive:!1}),h.selected?(i||h.selected&&u)&&(l({nodes:[h],edges:[]}),requestAnimationFrame(()=>{var f;return(f=s==null?void 0:s.current)==null?void 0:f.blur()})):o([e])}function eM(){const e=jt();return A.useCallback(({sourceEvent:i})=>{const{transform:s,snapGrid:o,snapToGrid:l}=e.getState(),u=i.touches?i.touches[0].clientX:i.clientX,c=i.touches?i.touches[0].clientY:i.clientY,p={x:(u-s[0])/s[2],y:(c-s[1])/s[2]};return{xSnapped:l?o[0]*Math.round(p.x/o[0]):p.x,ySnapped:l?o[1]*Math.round(p.y/o[1]):p.y,...p}},[])}function rd(e){return(n,i,s)=>e==null?void 0:e(n,s)}function JE({nodeRef:e,disabled:n=!1,noDragClassName:i,handleSelector:s,nodeId:o,isSelectable:l,selectNodesOnDrag:u}){const c=jt(),[p,h]=A.useState(!1),f=A.useRef([]),m=A.useRef({x:null,y:null}),y=A.useRef(0),x=A.useRef(null),N=A.useRef({x:0,y:0}),_=A.useRef(null),S=A.useRef(!1),b=A.useRef(!1),E=A.useRef(!1),C=eM();return A.useEffect(()=>{if(e!=null&&e.current){const j=Mn(e.current),P=({x:B,y:T})=>{const{nodeInternals:M,onNodeDrag:F,onSelectionDrag:X,updateNodePositions:Y,nodeExtent:I,snapGrid:H,snapToGrid:U,nodeOrigin:ne,onError:J}=c.getState();m.current={x:B,y:T};let D=!1,G={x:0,y:0,x2:0,y2:0};if(f.current.length>1&&I){const L=Ql(f.current,ne);G=Zo(L)}if(f.current=f.current.map(L=>{const oe={x:B-L.distance.x,y:T-L.distance.y};U&&(oe.x=H[0]*Math.round(oe.x/H[0]),oe.y=H[1]*Math.round(oe.y/H[1]));const $=[[I[0][0],I[0][1]],[I[1][0],I[1][1]]];f.current.length>1&&I&&!L.extent&&($[0][0]=L.positionAbsolute.x-G.x+I[0][0],$[1][0]=L.positionAbsolute.x+(L.width??0)-G.x2+I[1][0],$[0][1]=L.positionAbsolute.y-G.y+I[0][1],$[1][1]=L.positionAbsolute.y+(L.height??0)-G.y2+I[1][1]);const Q=ZE(L,oe,M,$,ne,J);return D=D||L.position.x!==Q.position.x||L.position.y!==Q.position.y,L.position=Q.position,L.positionAbsolute=Q.positionAbsolute,L}),!D)return;Y(f.current,!0,!0),h(!0);const k=o?F:rd(X);if(k&&_.current){const[L,oe]=nd({nodeId:o,dragItems:f.current,nodeInternals:M});k(_.current,L,oe)}},O=()=>{if(!x.current)return;const[B,T]=_E(N.current,x.current);if(B!==0||T!==0){const{transform:M,panBy:F}=c.getState();m.current.x=(m.current.x??0)-B/M[2],m.current.y=(m.current.y??0)-T/M[2],F({x:B,y:T})&&P(m.current)}y.current=requestAnimationFrame(O)},q=B=>{var ne;const{nodeInternals:T,multiSelectionActive:M,nodesDraggable:F,unselectNodesAndEdges:X,onNodeDragStart:Y,onSelectionDragStart:I}=c.getState();b.current=!0;const H=o?Y:rd(I);(!u||!l)&&!M&&o&&((ne=T.get(o))!=null&&ne.selected||X()),o&&l&&u&&Fg({id:o,store:c,nodeRef:e});const U=C(B);if(m.current=U,f.current=ZI(T,F,U,o),H&&f.current){const[J,D]=nd({nodeId:o,dragItems:f.current,nodeInternals:T});H(B.sourceEvent,J,D)}};if(n)j.on(".drag",null);else{const B=u2().on("start",T=>{const{domNode:M,nodeDragThreshold:F}=c.getState();F===0&&q(T),E.current=!1;const X=C(T);m.current=X,x.current=(M==null?void 0:M.getBoundingClientRect())||null,N.current=mi(T.sourceEvent,x.current)}).on("drag",T=>{var Y,I;const M=C(T),{autoPanOnNodeDrag:F,nodeDragThreshold:X}=c.getState();if(T.sourceEvent.type==="touchmove"&&T.sourceEvent.touches.length>1&&(E.current=!0),!E.current){if(!S.current&&b.current&&F&&(S.current=!0,O()),!b.current){const H=M.xSnapped-(((Y=m==null?void 0:m.current)==null?void 0:Y.x)??0),U=M.ySnapped-(((I=m==null?void 0:m.current)==null?void 0:I.y)??0);Math.sqrt(H*H+U*U)>X&&q(T)}(m.current.x!==M.xSnapped||m.current.y!==M.ySnapped)&&f.current&&b.current&&(_.current=T.sourceEvent,N.current=mi(T.sourceEvent,x.current),P(M))}}).on("end",T=>{if(!(!b.current||E.current)&&(h(!1),S.current=!1,b.current=!1,cancelAnimationFrame(y.current),f.current)){const{updateNodePositions:M,nodeInternals:F,onNodeDragStop:X,onSelectionDragStop:Y}=c.getState(),I=o?X:rd(Y);if(M(f.current,!1,!1),I){const[H,U]=nd({nodeId:o,dragItems:f.current,nodeInternals:F});I(T.sourceEvent,H,U)}}}).filter(T=>{const M=T.target;return!T.button&&(!i||!Fw(M,`.${i}`,e))&&(!s||Fw(M,s,e))});return j.call(B),()=>{j.on(".drag",null)}}}},[e,n,i,s,l,c,o,u,C]),p}function eN(){const e=jt();return A.useCallback(i=>{const{nodeInternals:s,nodeExtent:o,updateNodePositions:l,getNodes:u,snapToGrid:c,snapGrid:p,onError:h,nodesDraggable:f}=e.getState(),m=u().filter(E=>E.selected&&(E.draggable||f&&typeof E.draggable>"u")),y=c?p[0]:5,x=c?p[1]:5,N=i.isShiftPressed?4:1,_=i.x*y*N,S=i.y*x*N,b=m.map(E=>{if(E.positionAbsolute){const C={x:E.positionAbsolute.x+_,y:E.positionAbsolute.y+S};c&&(C.x=p[0]*Math.round(C.x/p[0]),C.y=p[1]*Math.round(C.y/p[1]));const{positionAbsolute:j,position:P}=ZE(E,C,s,o,void 0,h);E.position=P,E.positionAbsolute=j}return E});l(b,!0,!1)},[])}const Fs={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var Do=e=>{const n=({id:i,type:s,data:o,xPos:l,yPos:u,xPosOrigin:c,yPosOrigin:p,selected:h,onClick:f,onMouseEnter:m,onMouseMove:y,onMouseLeave:x,onContextMenu:N,onDoubleClick:_,style:S,className:b,isDraggable:E,isSelectable:C,isConnectable:j,isFocusable:P,selectNodesOnDrag:O,sourcePosition:q,targetPosition:B,hidden:T,resizeObserver:M,dragHandle:F,zIndex:X,isParent:Y,noDragClassName:I,noPanClassName:H,initialized:U,disableKeyboardA11y:ne,ariaLabel:J,rfId:D,hasHandleBounds:G})=>{const k=jt(),L=A.useRef(null),oe=A.useRef(null),$=A.useRef(q),Q=A.useRef(B),ee=A.useRef(s),se=C||E||f||m||y||x,ae=eN(),pe=$o(i,k.getState,m),ge=$o(i,k.getState,y),Ae=$o(i,k.getState,x),Oe=$o(i,k.getState,N),Me=$o(i,k.getState,_),Pe=ve=>{const{nodeDragThreshold:ye}=k.getState();if(C&&(!O||!E||ye>0)&&Fg({id:i,store:k,nodeRef:L}),f){const Ge=k.getState().nodeInternals.get(i);Ge&&f(ve,{...Ge})}},ke=ve=>{if(!Og(ve)&&!ne)if(EE.includes(ve.key)&&C){const ye=ve.key==="Escape";Fg({id:i,store:k,unselect:ye,nodeRef:L})}else E&&h&&Object.prototype.hasOwnProperty.call(Fs,ve.key)&&(k.setState({ariaLiveMessage:`Moved selected node ${ve.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~l}, y: ${~~u}`}),ae({x:Fs[ve.key].x,y:Fs[ve.key].y,isShiftPressed:ve.shiftKey}))};A.useEffect(()=>()=>{oe.current&&(M==null||M.unobserve(oe.current),oe.current=null)},[]),A.useEffect(()=>{if(L.current&&!T){const ve=L.current;(!U||!G||oe.current!==ve)&&(oe.current&&(M==null||M.unobserve(oe.current)),M==null||M.observe(ve),oe.current=ve)}},[T,U,G]),A.useEffect(()=>{const ve=ee.current!==s,ye=$.current!==q,Ge=Q.current!==B;L.current&&(ve||ye||Ge)&&(ve&&(ee.current=s),ye&&($.current=q),Ge&&(Q.current=B),k.getState().updateNodeDimensions([{id:i,nodeElement:L.current,forceUpdate:!0}]))},[i,s,q,B]);const We=JE({nodeRef:L,disabled:T||!E,noDragClassName:I,handleSelector:F,nodeId:i,isSelectable:C,selectNodesOnDrag:O});return T?null:le.createElement("div",{className:Ft(["react-flow__node",`react-flow__node-${s}`,{[H]:E},b,{selected:h,selectable:C,parent:Y,dragging:We}]),ref:L,style:{zIndex:X,transform:`translate(${c}px,${p}px)`,pointerEvents:se?"all":"none",visibility:U?"visible":"hidden",...S},"data-id":i,"data-testid":`rf__node-${i}`,onMouseEnter:pe,onMouseMove:ge,onMouseLeave:Ae,onContextMenu:Oe,onClick:Pe,onDoubleClick:Me,onKeyDown:P?ke:void 0,tabIndex:P?0:void 0,role:P?"button":void 0,"aria-describedby":ne?void 0:`${VE}-${D}`,"aria-label":J},le.createElement(hI,{value:i},le.createElement(e,{id:i,data:o,type:s,xPos:l,yPos:u,selected:h,isConnectable:j,sourcePosition:q,targetPosition:B,dragging:We,dragHandle:F,zIndex:X})))};return n.displayName="NodeWrapper",A.memo(n)};const tM=e=>{const n=e.getNodes().filter(i=>i.selected);return{...Ql(n,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function nM({onSelectionContextMenu:e,noPanClassName:n,disableKeyboardA11y:i}){const s=jt(),{width:o,height:l,x:u,y:c,transformString:p,userSelectionActive:h}=Xe(tM,Ct),f=eN(),m=A.useRef(null);if(A.useEffect(()=>{var N;i||(N=m.current)==null||N.focus({preventScroll:!0})},[i]),JE({nodeRef:m}),h||!o||!l)return null;const y=e?N=>{const _=s.getState().getNodes().filter(S=>S.selected);e(N,_)}:void 0,x=N=>{Object.prototype.hasOwnProperty.call(Fs,N.key)&&f({x:Fs[N.key].x,y:Fs[N.key].y,isShiftPressed:N.shiftKey})};return le.createElement("div",{className:Ft(["react-flow__nodesselection","react-flow__container",n]),style:{transform:p}},le.createElement("div",{ref:m,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:i?void 0:-1,onKeyDown:i?void 0:x,style:{width:o,height:l,top:c,left:u}}))}var rM=A.memo(nM);const iM=e=>e.nodesSelectionActive,tN=({children:e,onPaneClick:n,onPaneMouseEnter:i,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:l,onPaneScroll:u,deleteKeyCode:c,onMove:p,onMoveStart:h,onMoveEnd:f,selectionKeyCode:m,selectionOnDrag:y,selectionMode:x,onSelectionStart:N,onSelectionEnd:_,multiSelectionKeyCode:S,panActivationKeyCode:b,zoomActivationKeyCode:E,elementsSelectable:C,zoomOnScroll:j,zoomOnPinch:P,panOnScroll:O,panOnScrollSpeed:q,panOnScrollMode:B,zoomOnDoubleClick:T,panOnDrag:M,defaultViewport:F,translateExtent:X,minZoom:Y,maxZoom:I,preventScrolling:H,onSelectionContextMenu:U,noWheelClassName:ne,noPanClassName:J,disableKeyboardA11y:D})=>{const G=Xe(iM),k=ea(m),L=ea(b),oe=L||M,$=L||O,Q=k||y&&oe!==!0;return BI({deleteKeyCode:c,multiSelectionKeyCode:S}),le.createElement(WI,{onMove:p,onMoveStart:h,onMoveEnd:f,onPaneContextMenu:l,elementsSelectable:C,zoomOnScroll:j,zoomOnPinch:P,panOnScroll:$,panOnScrollSpeed:q,panOnScrollMode:B,zoomOnDoubleClick:T,panOnDrag:!k&&oe,defaultViewport:F,translateExtent:X,minZoom:Y,maxZoom:I,zoomActivationKeyCode:E,preventScrolling:H,noWheelClassName:ne,noPanClassName:J},le.createElement(XE,{onSelectionStart:N,onSelectionEnd:_,onPaneClick:n,onPaneMouseEnter:i,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:l,onPaneScroll:u,panOnDrag:oe,isSelecting:!!Q,selectionMode:x},e,G&&le.createElement(rM,{onSelectionContextMenu:U,noPanClassName:J,disableKeyboardA11y:D})))};tN.displayName="FlowRenderer";var sM=A.memo(tN);function oM(e){return Xe(A.useCallback(i=>e?IE(i.nodeInternals,{x:0,y:0,width:i.width,height:i.height},i.transform,!0):i.getNodes(),[e]))}function aM(e){const n={input:Do(e.input||zE),default:Do(e.default||Dg),output:Do(e.output||UE),group:Do(e.group||cv)},i={},s=Object.keys(e).filter(o=>!["input","default","output","group"].includes(o)).reduce((o,l)=>(o[l]=Do(e[l]||Dg),o),i);return{...n,...s}}const lM=({x:e,y:n,width:i,height:s,origin:o})=>!i||!s?{x:e,y:n}:o[0]<0||o[1]<0||o[0]>1||o[1]>1?{x:e,y:n}:{x:e-i*o[0],y:n-s*o[1]},uM=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),nN=e=>{const{nodesDraggable:n,nodesConnectable:i,nodesFocusable:s,elementsSelectable:o,updateNodeDimensions:l,onError:u}=Xe(uM,Ct),c=oM(e.onlyRenderVisibleElements),p=A.useRef(),h=A.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const f=new ResizeObserver(m=>{const y=m.map(x=>({id:x.target.getAttribute("data-id"),nodeElement:x.target,forceUpdate:!0}));l(y)});return p.current=f,f},[]);return A.useEffect(()=>()=>{var f;(f=p==null?void 0:p.current)==null||f.disconnect()},[]),le.createElement("div",{className:"react-flow__nodes",style:dv},c.map(f=>{var P,O,q;let m=f.type||"default";e.nodeTypes[m]||(u==null||u("003",Or.error003(m)),m="default");const y=e.nodeTypes[m]||e.nodeTypes.default,x=!!(f.draggable||n&&typeof f.draggable>"u"),N=!!(f.selectable||o&&typeof f.selectable>"u"),_=!!(f.connectable||i&&typeof f.connectable>"u"),S=!!(f.focusable||s&&typeof f.focusable>"u"),b=e.nodeExtent?iv(f.positionAbsolute,e.nodeExtent):f.positionAbsolute,E=(b==null?void 0:b.x)??0,C=(b==null?void 0:b.y)??0,j=lM({x:E,y:C,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:m,data:f.data,sourcePosition:f.sourcePosition||Ce.Bottom,targetPosition:f.targetPosition||Ce.Top,hidden:f.hidden,xPos:E,yPos:C,xPosOrigin:j.x,yPosOrigin:j.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:((P=f[ht])==null?void 0:P.z)??0,isParent:!!((O=f[ht])!=null&&O.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!f.width&&!!f.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:f.ariaLabel,hasHandleBounds:!!((q=f[ht])!=null&&q.handleBounds)})}))};nN.displayName="NodeRenderer";var cM=A.memo(nN);const dM=(e,n,i)=>i===Ce.Left?e-n:i===Ce.Right?e+n:e,fM=(e,n,i)=>i===Ce.Top?e-n:i===Ce.Bottom?e+n:e,Bw="react-flow__edgeupdater",Uw=({position:e,centerX:n,centerY:i,radius:s=10,onMouseDown:o,onMouseEnter:l,onMouseOut:u,type:c})=>le.createElement("circle",{onMouseDown:o,onMouseEnter:l,onMouseOut:u,className:Ft([Bw,`${Bw}-${c}`]),cx:dM(n,s,e),cy:fM(i,s,e),r:s,stroke:"transparent",fill:"transparent"}),hM=()=>!0;var Ms=e=>{const n=({id:i,className:s,type:o,data:l,onClick:u,onEdgeDoubleClick:c,selected:p,animated:h,label:f,labelStyle:m,labelShowBg:y,labelBgStyle:x,labelBgPadding:N,labelBgBorderRadius:_,style:S,source:b,target:E,sourceX:C,sourceY:j,targetX:P,targetY:O,sourcePosition:q,targetPosition:B,elementsSelectable:T,hidden:M,sourceHandleId:F,targetHandleId:X,onContextMenu:Y,onMouseEnter:I,onMouseMove:H,onMouseLeave:U,reconnectRadius:ne,onReconnect:J,onReconnectStart:D,onReconnectEnd:G,markerEnd:k,markerStart:L,rfId:oe,ariaLabel:$,isFocusable:Q,isReconnectable:ee,pathOptions:se,interactionWidth:ae,disableKeyboardA11y:pe})=>{const ge=A.useRef(null),[Ae,Oe]=A.useState(!1),[Me,Pe]=A.useState(!1),ke=jt(),We=A.useMemo(()=>`url('#${Lg(L,oe)}')`,[L,oe]),ve=A.useMemo(()=>`url('#${Lg(k,oe)}')`,[k,oe]);if(M)return null;const ye=Je=>{var zt;const{edges:dt,addSelectedEdges:gt,unselectNodesAndEdges:yt,multiSelectionActive:Gt}=ke.getState(),Pt=dt.find(Ln=>Ln.id===i);Pt&&(T&&(ke.setState({nodesSelectionActive:!1}),Pt.selected&&Gt?(yt({nodes:[],edges:[Pt]}),(zt=ge.current)==null||zt.blur()):gt([i])),u&&u(Je,Pt))},Ge=Lo(i,ke.getState,c),ut=Lo(i,ke.getState,Y),it=Lo(i,ke.getState,I),Ke=Lo(i,ke.getState,H),$e=Lo(i,ke.getState,U),Qe=(Je,dt)=>{if(Je.button!==0)return;const{edges:gt,isValidConnection:yt}=ke.getState(),Gt=dt?E:b,Pt=(dt?X:F)||null,zt=dt?"target":"source",Ln=yt||hM,er=dt,bn=gt.find(hn=>hn.id===i);Pe(!0),D==null||D(Je,bn,zt);const Bt=hn=>{Pe(!1),G==null||G(hn,bn,zt)};LE({event:Je,handleId:Pt,nodeId:Gt,onConnect:hn=>J==null?void 0:J(bn,hn),isTarget:er,getState:ke.getState,setState:ke.setState,isValidConnection:Ln,edgeUpdaterType:zt,onReconnectEnd:Bt})},bt=Je=>Qe(Je,!0),ct=Je=>Qe(Je,!1),pt=()=>Oe(!0),mt=()=>Oe(!1),kt=!T&&!u,He=Je=>{var dt;if(!pe&&EE.includes(Je.key)&&T){const{unselectNodesAndEdges:gt,addSelectedEdges:yt,edges:Gt}=ke.getState();Je.key==="Escape"?((dt=ge.current)==null||dt.blur(),gt({edges:[Gt.find(zt=>zt.id===i)]})):yt([i])}};return le.createElement("g",{className:Ft(["react-flow__edge",`react-flow__edge-${o}`,s,{selected:p,animated:h,inactive:kt,updating:Ae}]),onClick:ye,onDoubleClick:Ge,onContextMenu:ut,onMouseEnter:it,onMouseMove:Ke,onMouseLeave:$e,onKeyDown:Q?He:void 0,tabIndex:Q?0:void 0,role:Q?"button":"img","data-testid":`rf__edge-${i}`,"aria-label":$===null?void 0:$||`Edge from ${b} to ${E}`,"aria-describedby":Q?`${WE}-${oe}`:void 0,ref:ge},!Me&&le.createElement(e,{id:i,source:b,target:E,selected:p,animated:h,label:f,labelStyle:m,labelShowBg:y,labelBgStyle:x,labelBgPadding:N,labelBgBorderRadius:_,data:l,style:S,sourceX:C,sourceY:j,targetX:P,targetY:O,sourcePosition:q,targetPosition:B,sourceHandleId:F,targetHandleId:X,markerStart:We,markerEnd:ve,pathOptions:se,interactionWidth:ae}),ee&&le.createElement(le.Fragment,null,(ee==="source"||ee===!0)&&le.createElement(Uw,{position:q,centerX:C,centerY:j,radius:ne,onMouseDown:bt,onMouseEnter:pt,onMouseOut:mt,type:"source"}),(ee==="target"||ee===!0)&&le.createElement(Uw,{position:B,centerX:P,centerY:O,radius:ne,onMouseDown:ct,onMouseEnter:pt,onMouseOut:mt,type:"target"})))};return n.displayName="EdgeWrapper",A.memo(n)};function pM(e){const n={default:Ms(e.default||zl),straight:Ms(e.bezier||av),step:Ms(e.step||ov),smoothstep:Ms(e.step||Xl),simplebezier:Ms(e.simplebezier||sv)},i={},s=Object.keys(e).filter(o=>!["default","bezier"].includes(o)).reduce((o,l)=>(o[l]=Ms(e[l]||zl),o),i);return{...n,...s}}function Hw(e,n,i=null){const s=((i==null?void 0:i.x)||0)+n.x,o=((i==null?void 0:i.y)||0)+n.y,l=(i==null?void 0:i.width)||n.width,u=(i==null?void 0:i.height)||n.height;switch(e){case Ce.Top:return{x:s+l/2,y:o};case Ce.Right:return{x:s+l,y:o+u/2};case Ce.Bottom:return{x:s+l/2,y:o+u};case Ce.Left:return{x:s,y:o+u/2}}}function Vw(e,n){return e?e.length===1||!n?e[0]:n&&e.find(i=>i.id===n)||null:null}const mM=(e,n,i,s,o,l)=>{const u=Hw(i,e,n),c=Hw(l,s,o);return{sourceX:u.x,sourceY:u.y,targetX:c.x,targetY:c.y}};function gM({sourcePos:e,targetPos:n,sourceWidth:i,sourceHeight:s,targetWidth:o,targetHeight:l,width:u,height:c,transform:p}){const h={x:Math.min(e.x,n.x),y:Math.min(e.y,n.y),x2:Math.max(e.x+i,n.x+o),y2:Math.max(e.y+s,n.y+l)};h.x===h.x2&&(h.x2+=1),h.y===h.y2&&(h.y2+=1);const f=Zo({x:(0-p[0])/p[2],y:(0-p[1])/p[2],width:u/p[2],height:c/p[2]}),m=Math.max(0,Math.min(f.x2,h.x2)-Math.max(f.x,h.x)),y=Math.max(0,Math.min(f.y2,h.y2)-Math.max(f.y,h.y));return Math.ceil(m*y)>0}function Ww(e){var s,o,l,u,c;const n=((s=e==null?void 0:e[ht])==null?void 0:s.handleBounds)||null,i=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,!!i]}const vM=[{level:0,isMaxLevel:!0,edges:[]}];function yM(e,n,i=!1){let s=-1;const o=e.reduce((u,c)=>{var f,m;const p=Pn(c.zIndex);let h=p?c.zIndex:0;if(i){const y=n.get(c.target),x=n.get(c.source),N=c.selected||(y==null?void 0:y.selected)||(x==null?void 0:x.selected),_=Math.max(((f=x==null?void 0:x[ht])==null?void 0:f.z)||0,((m=y==null?void 0:y[ht])==null?void 0:m.z)||0,1e3);h=(p?c.zIndex:0)+(N?_:0)}return u[h]?u[h].push(c):u[h]=[c],s=h>s?h:s,u},{}),l=Object.entries(o).map(([u,c])=>{const p=+u;return{edges:c,level:p,isMaxLevel:p===s}});return l.length===0?vM:l}function wM(e,n,i){const s=Xe(A.useCallback(o=>e?o.edges.filter(l=>{const u=n.get(l.source),c=n.get(l.target);return(u==null?void 0:u.width)&&(u==null?void 0:u.height)&&(c==null?void 0:c.width)&&(c==null?void 0:c.height)&&gM({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 yM(s,n,i)}const xM=({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"}),_M=({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"}),Gw={[Fl.Arrow]:xM,[Fl.ArrowClosed]:_M};function SM(e){const n=jt();return A.useMemo(()=>{var o,l;return Object.prototype.hasOwnProperty.call(Gw,e)?Gw[e]:((l=(o=n.getState()).onError)==null||l.call(o,"009",Or.error009(e)),null)},[e])}const bM=({id:e,type:n,color:i,width:s=12.5,height:o=12.5,markerUnits:l="strokeWidth",strokeWidth:u,orient:c="auto-start-reverse"})=>{const p=SM(n);return p?le.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:l,orient:c,refX:"0",refY:"0"},le.createElement(p,{color:i,strokeWidth:u})):null},kM=({defaultColor:e,rfId:n})=>i=>{const s=[];return i.edges.reduce((o,l)=>([l.markerStart,l.markerEnd].forEach(u=>{if(u&&typeof u=="object"){const c=Lg(u,n);s.includes(c)||(o.push({id:c,color:u.color||e,...u}),s.push(c))}}),o),[]).sort((o,l)=>o.id.localeCompare(l.id))},rN=({defaultColor:e,rfId:n})=>{const i=Xe(A.useCallback(kM({defaultColor:e,rfId:n}),[e,n]),(s,o)=>!(s.length!==o.length||s.some((l,u)=>l.id!==o[u].id)));return le.createElement("defs",null,i.map(s=>le.createElement(bM,{id:s.id,key:s.id,type:s.type,color:s.color,width:s.width,height:s.height,markerUnits:s.markerUnits,strokeWidth:s.strokeWidth,orient:s.orient})))};rN.displayName="MarkerDefinitions";var EM=A.memo(rN);const NM=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}),iN=({defaultMarkerColor:e,onlyRenderVisibleElements:n,elevateEdgesOnSelect:i,rfId:s,edgeTypes:o,noPanClassName:l,onEdgeContextMenu:u,onEdgeMouseEnter:c,onEdgeMouseMove:p,onEdgeMouseLeave:h,onEdgeClick:f,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:x,onReconnectEnd:N,reconnectRadius:_,children:S,disableKeyboardA11y:b})=>{const{edgesFocusable:E,edgesUpdatable:C,elementsSelectable:j,width:P,height:O,connectionMode:q,nodeInternals:B,onError:T}=Xe(NM,Ct),M=wM(n,B,i);return P?le.createElement(le.Fragment,null,M.map(({level:F,edges:X,isMaxLevel:Y})=>le.createElement("svg",{key:F,style:{zIndex:F},width:P,height:O,className:"react-flow__edges react-flow__container"},Y&&le.createElement(EM,{defaultColor:e,rfId:s}),le.createElement("g",null,X.map(I=>{const[H,U,ne]=Ww(B.get(I.source)),[J,D,G]=Ww(B.get(I.target));if(!ne||!G)return null;let k=I.type||"default";o[k]||(T==null||T("011",Or.error011(k)),k="default");const L=o[k]||o.default,oe=q===Zi.Strict?D.target:(D.target??[]).concat(D.source??[]),$=Vw(U.source,I.sourceHandle),Q=Vw(oe,I.targetHandle),ee=($==null?void 0:$.position)||Ce.Bottom,se=(Q==null?void 0:Q.position)||Ce.Top,ae=!!(I.focusable||E&&typeof I.focusable>"u"),pe=I.reconnectable||I.updatable,ge=typeof y<"u"&&(pe||C&&typeof pe>"u");if(!$||!Q)return T==null||T("008",Or.error008($,I)),null;const{sourceX:Ae,sourceY:Oe,targetX:Me,targetY:Pe}=mM(H,$,ee,J,Q,se);return le.createElement(L,{key:I.id,id:I.id,className:Ft([I.className,l]),type:k,data:I.data,selected:!!I.selected,animated:!!I.animated,hidden:!!I.hidden,label:I.label,labelStyle:I.labelStyle,labelShowBg:I.labelShowBg,labelBgStyle:I.labelBgStyle,labelBgPadding:I.labelBgPadding,labelBgBorderRadius:I.labelBgBorderRadius,style:I.style,source:I.source,target:I.target,sourceHandleId:I.sourceHandle,targetHandleId:I.targetHandle,markerEnd:I.markerEnd,markerStart:I.markerStart,sourceX:Ae,sourceY:Oe,targetX:Me,targetY:Pe,sourcePosition:ee,targetPosition:se,elementsSelectable:j,onContextMenu:u,onMouseEnter:c,onMouseMove:p,onMouseLeave:h,onClick:f,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:x,onReconnectEnd:N,reconnectRadius:_,rfId:s,ariaLabel:I.ariaLabel,isFocusable:ae,isReconnectable:ge,pathOptions:"pathOptions"in I?I.pathOptions:void 0,interactionWidth:I.interactionWidth,disableKeyboardA11y:b})})))),S):null};iN.displayName="EdgeRenderer";var CM=A.memo(iN);const jM=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function RM({children:e}){const n=Xe(jM);return le.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:n}},e)}function TM(e){const n=oa(),i=A.useRef(!1);A.useEffect(()=>{!i.current&&n.viewportInitialized&&e&&(setTimeout(()=>e(n),1),i.current=!0)},[e,n.viewportInitialized])}const AM={[Ce.Left]:Ce.Right,[Ce.Right]:Ce.Left,[Ce.Top]:Ce.Bottom,[Ce.Bottom]:Ce.Top},sN=({nodeId:e,handleType:n,style:i,type:s=pi.Bezier,CustomComponent:o,connectionStatus:l})=>{var O,q,B;const{fromNode:u,handleId:c,toX:p,toY:h,connectionMode:f}=Xe(A.useCallback(T=>({fromNode:T.nodeInternals.get(e),handleId:T.connectionHandleId,toX:(T.connectionPosition.x-T.transform[0])/T.transform[2],toY:(T.connectionPosition.y-T.transform[1])/T.transform[2],connectionMode:T.connectionMode}),[e]),Ct),m=(O=u==null?void 0:u[ht])==null?void 0:O.handleBounds;let y=m==null?void 0:m[n];if(f===Zi.Loose&&(y=y||(m==null?void 0:m[n==="source"?"target":"source"])),!u||!y)return null;const x=c?y.find(T=>T.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=(((q=u.positionAbsolute)==null?void 0:q.x)??0)+N,b=(((B=u.positionAbsolute)==null?void 0:B.y)??0)+_,E=x==null?void 0:x.position,C=E?AM[E]:null;if(!E||!C)return null;if(o)return le.createElement(o,{connectionLineType:s,connectionLineStyle:i,fromNode:u,fromHandle:x,fromX:S,fromY:b,toX:p,toY:h,fromPosition:E,toPosition:C,connectionStatus:l});let j="";const P={sourceX:S,sourceY:b,sourcePosition:E,targetX:p,targetY:h,targetPosition:C};return s===pi.Bezier?[j]=TE(P):s===pi.Step?[j]=qg({...P,borderRadius:0}):s===pi.SmoothStep?[j]=qg(P):s===pi.SimpleBezier?[j]=RE(P):j=`M${S},${b} ${p},${h}`,le.createElement("path",{d:j,fill:"none",className:"react-flow__connection-path",style:i})};sN.displayName="ConnectionLine";const IM=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function MM({containerStyle:e,style:n,type:i,component:s}){const{nodeId:o,handleType:l,nodesConnectable:u,width:c,height:p,connectionStatus:h}=Xe(IM,Ct);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:Ft(["react-flow__connection",h])},le.createElement(sN,{nodeId:o,handleType:l,style:n,type:i,CustomComponent:s,connectionStatus:h})))}function Kw(e,n){return A.useRef(null),jt(),A.useMemo(()=>n(e),[e])}const oN=({nodeTypes:e,edgeTypes:n,onMove:i,onMoveStart:s,onMoveEnd:o,onInit:l,onNodeClick:u,onEdgeClick:c,onNodeDoubleClick:p,onEdgeDoubleClick:h,onNodeMouseEnter:f,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:x,onSelectionContextMenu:N,onSelectionStart:_,onSelectionEnd:S,connectionLineType:b,connectionLineStyle:E,connectionLineComponent:C,connectionLineContainerStyle:j,selectionKeyCode:P,selectionOnDrag:O,selectionMode:q,multiSelectionKeyCode:B,panActivationKeyCode:T,zoomActivationKeyCode:M,deleteKeyCode:F,onlyRenderVisibleElements:X,elementsSelectable:Y,selectNodesOnDrag:I,defaultViewport:H,translateExtent:U,minZoom:ne,maxZoom:J,preventScrolling:D,defaultMarkerColor:G,zoomOnScroll:k,zoomOnPinch:L,panOnScroll:oe,panOnScrollSpeed:$,panOnScrollMode:Q,zoomOnDoubleClick:ee,panOnDrag:se,onPaneClick:ae,onPaneMouseEnter:pe,onPaneMouseMove:ge,onPaneMouseLeave:Ae,onPaneScroll:Oe,onPaneContextMenu:Me,onEdgeContextMenu:Pe,onEdgeMouseEnter:ke,onEdgeMouseMove:We,onEdgeMouseLeave:ve,onReconnect:ye,onReconnectStart:Ge,onReconnectEnd:ut,reconnectRadius:it,noDragClassName:Ke,noWheelClassName:$e,noPanClassName:Qe,elevateEdgesOnSelect:bt,disableKeyboardA11y:ct,nodeOrigin:pt,nodeExtent:mt,rfId:kt})=>{const He=Kw(e,aM),Je=Kw(n,pM);return TM(l),le.createElement(sM,{onPaneClick:ae,onPaneMouseEnter:pe,onPaneMouseMove:ge,onPaneMouseLeave:Ae,onPaneContextMenu:Me,onPaneScroll:Oe,deleteKeyCode:F,selectionKeyCode:P,selectionOnDrag:O,selectionMode:q,onSelectionStart:_,onSelectionEnd:S,multiSelectionKeyCode:B,panActivationKeyCode:T,zoomActivationKeyCode:M,elementsSelectable:Y,onMove:i,onMoveStart:s,onMoveEnd:o,zoomOnScroll:k,zoomOnPinch:L,zoomOnDoubleClick:ee,panOnScroll:oe,panOnScrollSpeed:$,panOnScrollMode:Q,panOnDrag:se,defaultViewport:H,translateExtent:U,minZoom:ne,maxZoom:J,onSelectionContextMenu:N,preventScrolling:D,noDragClassName:Ke,noWheelClassName:$e,noPanClassName:Qe,disableKeyboardA11y:ct},le.createElement(RM,null,le.createElement(CM,{edgeTypes:Je,onEdgeClick:c,onEdgeDoubleClick:h,onlyRenderVisibleElements:X,onEdgeContextMenu:Pe,onEdgeMouseEnter:ke,onEdgeMouseMove:We,onEdgeMouseLeave:ve,onReconnect:ye,onReconnectStart:Ge,onReconnectEnd:ut,reconnectRadius:it,defaultMarkerColor:G,noPanClassName:Qe,elevateEdgesOnSelect:!!bt,disableKeyboardA11y:ct,rfId:kt},le.createElement(MM,{style:E,type:b,component:C,containerStyle:j})),le.createElement("div",{className:"react-flow__edgelabel-renderer"}),le.createElement(cM,{nodeTypes:He,onNodeClick:u,onNodeDoubleClick:p,onNodeMouseEnter:f,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:x,selectNodesOnDrag:I,onlyRenderVisibleElements:X,noPanClassName:Qe,noDragClassName:Ke,disableKeyboardA11y:ct,nodeOrigin:pt,nodeExtent:mt,rfId:kt})))};oN.displayName="GraphView";var PM=A.memo(oN);const zg=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],di={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:zg,nodeExtent:zg,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Zi.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:aI,isValidConnection:void 0},OM=()=>_R((e,n)=>({...di,setNodes:i=>{const{nodeInternals:s,nodeOrigin:o,elevateNodesOnSelect:l}=n();e({nodeInternals:ed(i,s,o,l)})},getNodes:()=>Array.from(n().nodeInternals.values()),setEdges:i=>{const{defaultEdgeOptions:s={}}=n();e({edges:i.map(o=>({...s,...o}))})},setDefaultNodesAndEdges:(i,s)=>{const o=typeof i<"u",l=typeof s<"u",u=o?ed(i,new Map,n().nodeOrigin,n().elevateNodesOnSelect):new Map;e({nodeInternals:u,edges:l?s:[],hasDefaultNodes:o,hasDefaultEdges:l})},updateNodeDimensions:i=>{const{onNodesChange:s,nodeInternals:o,fitViewOnInit:l,fitViewOnInitDone:u,fitViewOnInitOptions:c,domNode:p,nodeOrigin:h}=n(),f=p==null?void 0:p.querySelector(".react-flow__viewport");if(!f)return;const m=window.getComputedStyle(f),{m22:y}=new window.DOMMatrixReadOnly(m.transform),x=i.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 E=rv(S.nodeElement);!!(E.width&&E.height&&(b.width!==E.width||b.height!==E.height||S.forceUpdate))&&(o.set(b.id,{...b,[ht]:{...b[ht],handleBounds:{source:zw(".source",S.nodeElement,y,h),target:zw(".target",S.nodeElement,y,h)}},...E}),_.push({id:b.id,type:"dimensions",dimensions:E}))}return _},[]);KE(o,h);const N=u||l&&!u&&YE(n,{initial:!0,...c});e({nodeInternals:new Map(o),fitViewOnInitDone:N}),(x==null?void 0:x.length)>0&&(s==null||s(x))},updateNodePositions:(i,s=!0,o=!1)=>{const{triggerNodeChanges:l}=n(),u=i.map(c=>{const p={id:c.id,type:"position",dragging:o};return s&&(p.positionAbsolute=c.positionAbsolute,p.position=c.position),p});l(u)},triggerNodeChanges:i=>{const{onNodesChange:s,nodeInternals:o,hasDefaultNodes:l,nodeOrigin:u,getNodes:c,elevateNodesOnSelect:p}=n();if(i!=null&&i.length){if(l){const h=XI(i,c()),f=ed(h,o,u,p);e({nodeInternals:f})}s==null||s(i)}},addSelectedNodes:i=>{const{multiSelectionActive:s,edges:o,getNodes:l}=n();let u,c=null;s?u=i.map(p=>hi(p,!0)):(u=qs(l(),i),c=qs(o,[])),_l({changedNodes:u,changedEdges:c,get:n,set:e})},addSelectedEdges:i=>{const{multiSelectionActive:s,edges:o,getNodes:l}=n();let u,c=null;s?u=i.map(p=>hi(p,!0)):(u=qs(o,i),c=qs(l(),[])),_l({changedNodes:c,changedEdges:u,get:n,set:e})},unselectNodesAndEdges:({nodes:i,edges:s}={})=>{const{edges:o,getNodes:l}=n(),u=i||l(),c=s||o,p=u.map(f=>(f.selected=!1,hi(f.id,!1))),h=c.map(f=>hi(f.id,!1));_l({changedNodes:p,changedEdges:h,get:n,set:e})},setMinZoom:i=>{const{d3Zoom:s,maxZoom:o}=n();s==null||s.scaleExtent([i,o]),e({minZoom:i})},setMaxZoom:i=>{const{d3Zoom:s,minZoom:o}=n();s==null||s.scaleExtent([o,i]),e({maxZoom:i})},setTranslateExtent:i=>{var s;(s=n().d3Zoom)==null||s.translateExtent(i),e({translateExtent:i})},resetSelectedElements:()=>{const{edges:i,getNodes:s}=n(),l=s().filter(c=>c.selected).map(c=>hi(c.id,!1)),u=i.filter(c=>c.selected).map(c=>hi(c.id,!1));_l({changedNodes:l,changedEdges:u,get:n,set:e})},setNodeExtent:i=>{const{nodeInternals:s}=n();s.forEach(o=>{o.positionAbsolute=iv(o.position,i)}),e({nodeExtent:i,nodeInternals:new Map(s)})},panBy:i=>{const{transform:s,width:o,height:l,d3Zoom:u,d3Selection:c,translateExtent:p}=n();if(!u||!c||!i.x&&!i.y)return!1;const h=Mr.translate(s[0]+i.x,s[1]+i.y).scale(s[2]),f=[[0,0],[o,l]],m=u==null?void 0:u.constrain()(h,f,p);return u.transform(c,m),s[0]!==m.x||s[1]!==m.y||s[2]!==m.k},cancelConnection:()=>e({connectionNodeId:di.connectionNodeId,connectionHandleId:di.connectionHandleId,connectionHandleType:di.connectionHandleType,connectionStatus:di.connectionStatus,connectionStartHandle:di.connectionStartHandle,connectionEndHandle:di.connectionEndHandle}),reset:()=>e({...di})}),Object.is),fv=({children:e})=>{const n=A.useRef(null);return n.current||(n.current=OM()),le.createElement(eI,{value:n.current},e)};fv.displayName="ReactFlowProvider";const aN=({children:e})=>A.useContext(Yl)?le.createElement(le.Fragment,null,e):le.createElement(fv,null,e);aN.displayName="ReactFlowWrapper";const qM={input:zE,default:Dg,output:UE,group:cv},LM={default:zl,straight:av,step:ov,smoothstep:Xl,simplebezier:sv},$M=[0,0],DM=[15,15],FM={x:0,y:0,zoom:1},zM={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},lN=A.forwardRef(({nodes:e,edges:n,defaultNodes:i,defaultEdges:s,className:o,nodeTypes:l=qM,edgeTypes:u=LM,onNodeClick:c,onEdgeClick:p,onInit:h,onMove:f,onMoveStart:m,onMoveEnd:y,onConnect:x,onConnectStart:N,onConnectEnd:_,onClickConnectStart:S,onClickConnectEnd:b,onNodeMouseEnter:E,onNodeMouseMove:C,onNodeMouseLeave:j,onNodeContextMenu:P,onNodeDoubleClick:O,onNodeDragStart:q,onNodeDrag:B,onNodeDragStop:T,onNodesDelete:M,onEdgesDelete:F,onSelectionChange:X,onSelectionDragStart:Y,onSelectionDrag:I,onSelectionDragStop:H,onSelectionContextMenu:U,onSelectionStart:ne,onSelectionEnd:J,connectionMode:D=Zi.Strict,connectionLineType:G=pi.Bezier,connectionLineStyle:k,connectionLineComponent:L,connectionLineContainerStyle:oe,deleteKeyCode:$="Backspace",selectionKeyCode:Q="Shift",selectionOnDrag:ee=!1,selectionMode:se=Jo.Full,panActivationKeyCode:ae="Space",multiSelectionKeyCode:pe=Dl()?"Meta":"Control",zoomActivationKeyCode:ge=Dl()?"Meta":"Control",snapToGrid:Ae=!1,snapGrid:Oe=DM,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Pe=!0,nodesDraggable:ke,nodesConnectable:We,nodesFocusable:ve,nodeOrigin:ye=$M,edgesFocusable:Ge,edgesUpdatable:ut,elementsSelectable:it,defaultViewport:Ke=FM,minZoom:$e=.5,maxZoom:Qe=2,translateExtent:bt=zg,preventScrolling:ct=!0,nodeExtent:pt,defaultMarkerColor:mt="#b1b1b7",zoomOnScroll:kt=!0,zoomOnPinch:He=!0,panOnScroll:Je=!1,panOnScrollSpeed:dt=.5,panOnScrollMode:gt=Gi.Free,zoomOnDoubleClick:yt=!0,panOnDrag:Gt=!0,onPaneClick:Pt,onPaneMouseEnter:zt,onPaneMouseMove:Ln,onPaneMouseLeave:er,onPaneScroll:bn,onPaneContextMenu:Bt,children:Jt,onEdgeContextMenu:hn,onEdgeDoubleClick:$r,onEdgeMouseEnter:Rt,onEdgeMouseMove:hr,onEdgeMouseLeave:pr,onEdgeUpdate:pn,onEdgeUpdateStart:wi,onEdgeUpdateEnd:tr,onReconnect:xi,onReconnectStart:mn,onReconnectEnd:rs,reconnectRadius:nr=10,edgeUpdaterRadius:Dr=10,onNodesChange:mr,onEdgesChange:Fr,noDragClassName:Ot="nodrag",noWheelClassName:_i="nowheel",noPanClassName:$n="nopan",fitView:Dn=!1,fitViewOptions:Kt,connectOnClick:zr=!0,attributionPosition:Si,proOptions:bi,defaultEdgeOptions:gr,elevateNodesOnSelect:Br=!0,elevateEdgesOnSelect:kn=!1,disableKeyboardA11y:ki=!1,autoPanOnConnect:is=!0,autoPanOnNodeDrag:et=!0,connectionRadius:Qs=20,isValidConnection:vr,onError:Fn,style:yr,id:ss,nodeDragThreshold:Ei,...wr},en)=>{const Tt=ss||"1";return le.createElement("div",{...wr,style:{...yr,...zM},ref:en,className:Ft(["react-flow",o]),"data-testid":"rf__wrapper",id:ss},le.createElement(aN,null,le.createElement(PM,{onInit:h,onMove:f,onMoveStart:m,onMoveEnd:y,onNodeClick:c,onEdgeClick:p,onNodeMouseEnter:E,onNodeMouseMove:C,onNodeMouseLeave:j,onNodeContextMenu:P,onNodeDoubleClick:O,nodeTypes:l,edgeTypes:u,connectionLineType:G,connectionLineStyle:k,connectionLineComponent:L,connectionLineContainerStyle:oe,selectionKeyCode:Q,selectionOnDrag:ee,selectionMode:se,deleteKeyCode:$,multiSelectionKeyCode:pe,panActivationKeyCode:ae,zoomActivationKeyCode:ge,onlyRenderVisibleElements:Me,selectNodesOnDrag:Pe,defaultViewport:Ke,translateExtent:bt,minZoom:$e,maxZoom:Qe,preventScrolling:ct,zoomOnScroll:kt,zoomOnPinch:He,zoomOnDoubleClick:yt,panOnScroll:Je,panOnScrollSpeed:dt,panOnScrollMode:gt,panOnDrag:Gt,onPaneClick:Pt,onPaneMouseEnter:zt,onPaneMouseMove:Ln,onPaneMouseLeave:er,onPaneScroll:bn,onPaneContextMenu:Bt,onSelectionContextMenu:U,onSelectionStart:ne,onSelectionEnd:J,onEdgeContextMenu:hn,onEdgeDoubleClick:$r,onEdgeMouseEnter:Rt,onEdgeMouseMove:hr,onEdgeMouseLeave:pr,onReconnect:xi??pn,onReconnectStart:mn??wi,onReconnectEnd:rs??tr,reconnectRadius:nr??Dr,defaultMarkerColor:mt,noDragClassName:Ot,noWheelClassName:_i,noPanClassName:$n,elevateEdgesOnSelect:kn,rfId:Tt,disableKeyboardA11y:ki,nodeOrigin:ye,nodeExtent:pt}),le.createElement(TI,{nodes:e,edges:n,defaultNodes:i,defaultEdges:s,onConnect:x,onConnectStart:N,onConnectEnd:_,onClickConnectStart:S,onClickConnectEnd:b,nodesDraggable:ke,nodesConnectable:We,nodesFocusable:ve,edgesFocusable:Ge,edgesUpdatable:ut,elementsSelectable:it,elevateNodesOnSelect:Br,minZoom:$e,maxZoom:Qe,nodeExtent:pt,onNodesChange:mr,onEdgesChange:Fr,snapToGrid:Ae,snapGrid:Oe,connectionMode:D,translateExtent:bt,connectOnClick:zr,defaultEdgeOptions:gr,fitView:Dn,fitViewOptions:Kt,onNodesDelete:M,onEdgesDelete:F,onNodeDragStart:q,onNodeDrag:B,onNodeDragStop:T,onSelectionDrag:I,onSelectionDragStart:Y,onSelectionDragStop:H,noPanClassName:$n,nodeOrigin:ye,rfId:Tt,autoPanOnConnect:is,autoPanOnNodeDrag:et,onError:Fn,connectionRadius:Qs,isValidConnection:vr,nodeDragThreshold:Ei}),le.createElement(jI,{onSelectionChange:X}),Jt,le.createElement(nI,{proOptions:bi,position:Si}),le.createElement(OI,{rfId:Tt,disableKeyboardA11y:ki})))});lN.displayName="ReactFlow";const BM=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function uN(){return Xe(BM,Ct)}const cN=({id:e,x:n,y:i,width:s,height:o,style:l,color:u,strokeColor:c,strokeWidth:p,className:h,borderRadius:f,shapeRendering:m,onClick:y,selected:x})=>{const{background:N,backgroundColor:_}=l||{},S=u||N||_;return le.createElement("rect",{className:Ft(["react-flow__minimap-node",{selected:x},h]),x:n,y:i,rx:f,ry:f,width:s,height:o,fill:S,stroke:c,strokeWidth:p,shapeRendering:m,onClick:y?b=>y(b,e):void 0})};cN.displayName="MiniMapNode";var UM=A.memo(cN);const HM=e=>e.nodeOrigin,VM=e=>e.getNodes().filter(n=>!n.hidden&&n.width&&n.height),id=e=>e instanceof Function?e:()=>e;function WM({nodeStrokeColor:e="transparent",nodeColor:n="#e2e2e2",nodeClassName:i="",nodeBorderRadius:s=5,nodeStrokeWidth:o=2,nodeComponent:l=UM,onClick:u}){const c=Xe(VM,Ct),p=Xe(HM),h=id(n),f=id(e),m=id(i),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return le.createElement(le.Fragment,null,c.map(x=>{const{x:N,y:_}=Yi(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:m(x),color:h(x),borderRadius:s,strokeColor:f(x),strokeWidth:o,shapeRendering:y,onClick:u,id:x.id})}))}var GM=A.memo(WM);const KM=200,YM=150,XM=e=>{const n=e.getNodes(),i={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:i,boundingRect:n.length>0?sI(Ql(n,e.nodeOrigin),i):i,rfId:e.rfId}},QM="react-flow__minimap-desc";function dN({style:e,className:n,nodeStrokeColor:i="transparent",nodeColor:s="#e2e2e2",nodeClassName:o="",nodeBorderRadius:l=5,nodeStrokeWidth:u=2,nodeComponent:c,maskColor:p="rgb(240, 240, 240, 0.6)",maskStrokeColor:h="none",maskStrokeWidth:f=1,position:m="bottom-right",onClick:y,onNodeClick:x,pannable:N=!1,zoomable:_=!1,ariaLabel:S="React Flow mini map",inversePan:b=!1,zoomStep:E=10,offsetScale:C=5}){const j=jt(),P=A.useRef(null),{boundingRect:O,viewBB:q,rfId:B}=Xe(XM,Ct),T=(e==null?void 0:e.width)??KM,M=(e==null?void 0:e.height)??YM,F=O.width/T,X=O.height/M,Y=Math.max(F,X),I=Y*T,H=Y*M,U=C*Y,ne=O.x-(I-O.width)/2-U,J=O.y-(H-O.height)/2-U,D=I+U*2,G=H+U*2,k=`${QM}-${B}`,L=A.useRef(0);L.current=Y,A.useEffect(()=>{if(P.current){const Q=Mn(P.current),ee=pe=>{const{transform:ge,d3Selection:Ae,d3Zoom:Oe}=j.getState();if(pe.sourceEvent.type!=="wheel"||!Ae||!Oe)return;const Me=-pe.sourceEvent.deltaY*(pe.sourceEvent.deltaMode===1?.05:pe.sourceEvent.deltaMode?1:.002)*E,Pe=ge[2]*Math.pow(2,Me);Oe.scaleTo(Ae,Pe)},se=pe=>{const{transform:ge,d3Selection:Ae,d3Zoom:Oe,translateExtent:Me,width:Pe,height:ke}=j.getState();if(pe.sourceEvent.type!=="mousemove"||!Ae||!Oe)return;const We=L.current*Math.max(1,ge[2])*(b?-1:1),ve={x:ge[0]-pe.sourceEvent.movementX*We,y:ge[1]-pe.sourceEvent.movementY*We},ye=[[0,0],[Pe,ke]],Ge=Mr.translate(ve.x,ve.y).scale(ge[2]),ut=Oe.constrain()(Ge,ye,Me);Oe.transform(Ae,ut)},ae=wE().on("zoom",N?se:null).on("zoom.wheel",_?ee:null);return Q.call(ae),()=>{Q.on("zoom",null)}}},[N,_,b,E]);const oe=y?Q=>{const ee=Kn(Q);y(Q,{x:ee[0],y:ee[1]})}:void 0,$=x?(Q,ee)=>{const se=j.getState().nodeInternals.get(ee);x(Q,se)}:void 0;return le.createElement(nv,{position:m,style:e,className:Ft(["react-flow__minimap",n]),"data-testid":"rf__minimap"},le.createElement("svg",{width:T,height:M,viewBox:`${ne} ${J} ${D} ${G}`,role:"img","aria-labelledby":k,ref:P,onClick:oe},S&&le.createElement("title",{id:k},S),le.createElement(GM,{onClick:$,nodeColor:s,nodeStrokeColor:i,nodeBorderRadius:l,nodeClassName:o,nodeStrokeWidth:u,nodeComponent:c}),le.createElement("path",{className:"react-flow__minimap-mask",d:`M${ne-U},${J-U}h${D+U*2}v${G+U*2}h${-D-U*2}z
57
57
  M${q.x},${q.y}h${q.width}v${q.height}h${-q.width}z`,fill:p,fillRule:"evenodd",stroke:h,strokeWidth:f,pointerEvents:"none"})))}dN.displayName="MiniMap";var ZM=A.memo(dN);function JM(){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 eP(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},le.createElement("path",{d:"M0 0h32v4.2H0z"}))}function tP(){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 nP(){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 rP(){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 Ls=({children:e,className:n,...i})=>le.createElement("button",{type:"button",className:Ft(["react-flow__controls-button",n]),...i},e);Ls.displayName="ControlButton";const iP=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),fN=({style:e,showZoom:n=!0,showFitView:i=!0,showInteractive:s=!0,fitViewOptions:o,onZoomIn:l,onZoomOut:u,onFitView:c,onInteractiveChange:p,className:h,children:f,position:m="bottom-left"})=>{const y=jt(),[x,N]=A.useState(!1),{isInteractive:_,minZoomReached:S,maxZoomReached:b}=Xe(iP,Ct),{zoomIn:E,zoomOut:C,fitView:j}=oa();if(A.useEffect(()=>{N(!0)},[]),!x)return null;const P=()=>{E(),l==null||l()},O=()=>{C(),u==null||u()},q=()=>{j(o),c==null||c()},B=()=>{y.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),p==null||p(!_)};return le.createElement(nv,{className:Ft(["react-flow__controls",h]),position:m,style:e,"data-testid":"rf__controls"},n&&le.createElement(le.Fragment,null,le.createElement(Ls,{onClick:P,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:b},le.createElement(JM,null)),le.createElement(Ls,{onClick:O,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:S},le.createElement(eP,null))),i&&le.createElement(Ls,{className:"react-flow__controls-fitview",onClick:q,title:"fit view","aria-label":"fit view"},le.createElement(tP,null)),s&&le.createElement(Ls,{className:"react-flow__controls-interactive",onClick:B,title:"toggle interactivity","aria-label":"toggle interactivity"},_?le.createElement(rP,null):le.createElement(nP,null)),f)};fN.displayName="Controls";var sP=A.memo(fN),Xn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Xn||(Xn={}));function oP({color:e,dimensions:n,lineWidth:i}){return le.createElement("path",{stroke:e,strokeWidth:i,d:`M${n[0]/2} 0 V${n[1]} M0 ${n[1]/2} H${n[0]}`})}function aP({color:e,radius:n}){return le.createElement("circle",{cx:n,cy:n,r:n,fill:e})}const lP={[Xn.Dots]:"#91919a",[Xn.Lines]:"#eee",[Xn.Cross]:"#e2e2e2"},uP={[Xn.Dots]:1,[Xn.Lines]:1,[Xn.Cross]:6},cP=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function hN({id:e,variant:n=Xn.Dots,gap:i=20,size:s,lineWidth:o=1,offset:l=2,color:u,style:c,className:p}){const h=A.useRef(null),{transform:f,patternId:m}=Xe(cP,Ct),y=u||lP[n],x=s||uP[n],N=n===Xn.Dots,_=n===Xn.Cross,S=Array.isArray(i)?i:[i,i],b=[S[0]*f[2]||1,S[1]*f[2]||1],E=x*f[2],C=_?[E,E]:b,j=N?[E/l,E/l]:[C[0]/l,C[1]/l];return le.createElement("svg",{className:Ft(["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:m+e,x:f[0]%b[0],y:f[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${j[0]},-${j[1]})`},N?le.createElement(aP,{color:y,radius:E/l}):le.createElement(oP,{dimensions:C,color:y,lineWidth:o})),le.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${m+e})`}))}hN.displayName="Background";var dP=A.memo(hN);function pN(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function mN(e,n=0){if(!e||typeof e!="object"||n>6)return null;const i=e;if(typeof i.input_tokens=="number"||typeof i.output_tokens=="number"||typeof i.cache_read_input_tokens=="number"||typeof i.cache_creation_input_tokens=="number")return{inputTokens:Number(i.input_tokens??0),outputTokens:Number(i.output_tokens??0),cacheReadTokens:Number(i.cache_read_input_tokens??0),cacheCreateTokens:Number(i.cache_creation_input_tokens??0)};for(const s of Object.values(i)){const o=mN(s,n+1);if(o)return o}return null}function fP(e,n){e.inputTokens+=n.inputTokens,e.outputTokens+=n.outputTokens,e.cacheReadTokens+=n.cacheReadTokens,e.cacheCreateTokens+=n.cacheCreateTokens}const hP=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i;function gN(e,n=0){if(!e||typeof e!="object"||n>6)return null;const i=e;if(typeof i.model=="string"&&hP.test(i.model))return i.model;for(const s of Object.values(i)){const o=gN(s,n+1);if(o)return o}return null}function Bg(){return{agents:new Map,toolIndex:new Map,toolOwner:new Map,activeSubagentStack:new Map,lastSeq:0,seqEpoch:null,totalEvents:0}}function gi(e){if(!e)return;const n=e.replace(/\\/g,"/").split("/").filter(Boolean);return n[n.length-1]}function hv(e,n){return`${e}::${n}`}function Bl(e){return e.agent_type??e.subagent_type??"subagent"}function Ug(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function Wo(e,n,i,s){const o=n;let l=e.agents.get(o);return l||(l={id:o,sessionId:n,label:"session",kind:"root",state:"active",startedAt:i,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:s,inFlightTool:null,usage:pN()},e.agents.set(o,l),l)}function vN(e,n,i,s){const o=hv(n,i),l=e.agents.get(o);if(!l)return null;!l.cwd&&s.cwd&&(l.cwd=s.cwd,l.cwdBasename=gi(s.cwd));const u=Bl(s);return u&&(l.label==="subagent"||!l.label)&&(l.label=u),l}function Yw(e,n,i){const s=n.session_id??"unknown",o=Ug(n);if(o){const p=vN(e,s,o,n);if(p)return p}const l=e.activeSubagentStack.get(s),u=l&&l.length>0?l[l.length-1]:null;if(u){const p=e.agents.get(hv(s,u));if(p)return!p.cwd&&n.cwd&&(p.cwd=n.cwd,p.cwdBasename=gi(n.cwd)),p}const c=Wo(e,s,i,!1);return c.synthetic&&(c.synthetic=!1,c.startedAt=i),!c.cwd&&n.cwd&&(c.cwd=n.cwd,c.cwdBasename=gi(n.cwd)),c.label==="session"&&n.cwd&&(c.label=gi(n.cwd)??"session"),c}function pP(e,n,i,s,o){const l=hv(n,i),u=Wo(e,n,o,!0);let c=e.agents.get(l);if(c){!c.cwd&&s.cwd&&(c.cwd=s.cwd,c.cwdBasename=gi(s.cwd));const p=Bl(s);return p&&(c.label==="subagent"||!c.label)&&(c.label=p),c}return c={id:l,sessionId:n,label:Bl(s),kind:"subagent",parentId:u.id,state:"active",startedAt:o,tools:[],prompts:[],cwd:s.cwd,cwdBasename:gi(s.cwd),toolCount:0,childCount:0,inFlightTool:null,usage:pN()},e.agents.set(l,c),u.childCount+=1,c}function mP(e,n,i){const s=e.activeSubagentStack.get(n)??[];s.push(i),e.activeSubagentStack.set(n,s)}function gP(e,n,i){const s=e.activeSubagentStack.get(n);if(s){for(let o=s.length-1;o>=0;o--)if(s[o]===i){s.splice(o,1);break}s.length===0&&e.activeSubagentStack.delete(n)}}function sd(e,n=80){if(e==null)return"";if(typeof e=="string")return e.length>n?e.slice(0,n-1)+"…":e;try{const i=JSON.stringify(e);return i.length>n?i.slice(0,n-1)+"…":i}catch{return String(e)}}function Bo(e){let n=null;for(let i=e.tools.length-1;i>=0;i--){const s=e.tools[i];if(s.endedAt==null){n=s;break}}e.inFlightTool=n}function vP(e,n,i,s){if(e.agents.size<=i)return!1;const o=[];for(const[u,c]of e.agents)c.state==="done"&&c.endedAt!=null&&n-c.endedAt>s&&o.push({id:u,endedAt:c.endedAt});if(o.length===0)return!1;o.sort((u,c)=>u.endedAt-c.endedAt);let l=0;for(const u of o){if(e.agents.size<=i)break;e.agents.delete(u.id),l++}return l>0}function yP(e,n,i,s){const o=new Map;for(const[h,f]of e.agents){let m=o.get(f.sessionId);m||(m={ids:[],endedAt:0,live:!1},o.set(f.sessionId,m)),m.ids.push(h),f.state==="done"&&f.endedAt!=null?m.endedAt=Math.max(m.endedAt,f.endedAt):m.live=!0}const l=[...o.values()].filter(h=>!h.live&&h.endedAt>0&&n-h.endedAt>s).sort((h,f)=>h.endedAt-f.endedAt);let c=[...o.values()].filter(h=>!h.live).length-i;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 wP(e,n,i){let s=!1;for(const o of e.agents.values()){let l=!1;for(const u of o.tools)u.endedAt==null&&n-u.startedAt>i&&(u.endedAt=u.startedAt+i,u.ok=!1,u.errorPreview="stale (no PostToolUse received)",e.toolIndex.delete(u.id),e.toolOwner.delete(u.id),l=!0,s=!0);l&&Bo(o)}return s}function Xw(e,n){const i=n.epoch??null;if(i!==null&&i!==e.seqEpoch)e.seqEpoch=i,e.lastSeq=0;else if(n.seq<=e.lastSeq)return e;const s=n.payload??{},o=n.receivedAt,l=s.hook_event_name??"Unknown";if(l==="__clear")return{...Bg(),lastSeq:n.seq,seqEpoch:e.seqEpoch};e.totalEvents+=1,e.lastSeq=n.seq;const u=s.session_id??"unknown";if(l==="ModelObserved"){const h=typeof s.model=="string"?s.model:null;if(h){const m=e.agents.get(u);m&&(m.model=h)}const f=s.subagentModels;if(f&&typeof f=="object")for(const[m,y]of Object.entries(f)){if(typeof y!="string")continue;const x=`${u}::${m}`,N=e.agents.get(x);N&&(N.model=y)}return e}if(l==="ContextObserved"){const h=s.context??null;if(h){const f=e.agents.get(u);f&&(f.context={msgsUser:Number(h.msgsUser??0),msgsAssistant:Number(h.msgsAssistant??0),toolUses:Number(h.toolUses??0),toolResults:Number(h.toolResults??0),systemReminders:Number(h.systemReminders??0),currentContextTokens:Number(h.currentContextTokens??0),claudeMdFiles:Array.isArray(h.claudeMdFiles)?h.claudeMdFiles:[]})}return e}if(l==="UsageObserved"){const h=s.usage??null;if(h){const f=e.agents.get(u);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),typeof h.reasoning_output_tokens=="number"&&(f.usage.reasoningOutputTokens=Number(h.reasoning_output_tokens)))}return e}const c=Yw(e,s,o);c.provider||(c.provider=s.provider==="codex"?"codex":"claude"),typeof s.model_context_window=="number"&&s.model_context_window>0&&(c.contextWindow=s.model_context_window);const p=gN(s);switch(p&&(c.model=p),l){case"SessionStart":{const h=Wo(e,u,o,!1);h.synthetic=!1,h.state="active",h.startedAt=h.startedAt||o,!h.cwd&&s.cwd&&(h.cwd=s.cwd,h.cwdBasename=gi(s.cwd)),h.label==="session"&&s.cwd&&(h.label=gi(s.cwd)??"session");break}case"UserPromptSubmit":{for(const y of e.agents.values())y.sessionId===u&&y.kind==="subagent"&&y.state==="done"&&y.exitAt==null&&y.endedAt!=null&&y.endedAt<o&&(y.exitAt=o);const h=Wo(e,u,o,!1);h.state="active",h.endedAt=void 0,h.exitAt=void 0;const f=Yw(e,s,o);f.state="active",f.exitAt=void 0,f.endedAt=void 0;const m=(typeof s.prompt=="string"?s.prompt:typeof s.message=="string"?s.message:"")??"";m&&(f.prompts.push({at:o,text:m}),f.firstPrompt||(f.firstPrompt=sd(m,120)));break}case"PreToolUse":{const h=s.tool_use_id??`${c.id}:${c.toolCount}`,f={id:h,name:s.tool_name??"?",input:s.tool_input,inputPreview:sd(s.tool_input),agentId:c.id,startedAt:o};c.tools.push(f),c.toolCount+=1,c.state="active",e.toolIndex.set(h,f),e.toolOwner.set(h,c.id),Bo(c);break}case"PostToolUse":case"PostToolUseFailure":{const h=s.tool_use_id;if(!h)break;let f=e.toolIndex.get(h),m=!1;if(!f)for(const N of e.agents.values()){const _=N.tools.find(S=>S.id===h);if(_){f=_,m=!0;break}}if(!f)break;f.endedAt=o,f.ok=l==="PostToolUse",f.response=s.tool_response,l==="PostToolUseFailure"?f.errorPreview=sd(s.tool_response):m&&(f.errorPreview=void 0);const y=mN(s.tool_response);y&&(f.usage=y),e.toolIndex.delete(h);const x=e.toolOwner.get(h)??f.agentId;if(e.toolOwner.delete(h),x){const N=e.agents.get(x);N&&(y&&fP(N.usage,y),Bo(N))}break}case"SubagentStart":{const h=Ug(s);if(!h)break;const f=pP(e,u,h,s,o);f.state="active",f.startedAt=f.startedAt||o,f.exitAt=void 0,f.endedAt=void 0;const m=Bl(s);m&&(f.label=m),mP(e,u,h);break}case"SubagentStop":{const h=Ug(s);if(!h)break;const f=vN(e,u,h,s);if(!f)break;f.state="done",f.endedAt=o,Bo(f),gP(e,u,h);break}case"Stop":case"SessionEnd":{const h=Wo(e,u,o,!1);h.state="done",h.endedAt=o,Bo(h),e.activeSubagentStack.delete(u);break}}return e}function pv(e){let n=5381;for(let i=0;i<e.length;i++)n=(n<<5)+n^e.charCodeAt(i);return Math.abs(n)%360}const xP=Date.UTC(2026,8,1);function _P(){return Date.now()<xP?{input:2,output:10,cacheRead:.2,cacheWrite:2.5}:{input:3,output:15,cacheRead:.3,cacheWrite:3.75}}const SP=[{match:/^claude[-_](fable|mythos)[-_]5\b/i,rates:{input:10,output:50,cacheRead:1,cacheWrite:12.5}},{match:/^claude[-_]opus[-_]5\b/i,rates:{input:5,output:25,cacheRead:.5,cacheWrite:6.25}},{match:/^claude[-_]sonnet[-_]5\b/i,rates:_P()},{match:/^claude[-_]opus[-_]4[-_.](?:5|6|7|8)\b/i,rates:{input:5,output:25,cacheRead:.5,cacheWrite:6.25}},{match:/^claude[-_]opus[-_]4(?:[-_.]1)?\b/i,rates:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}},{match:/^claude[-_]sonnet[-_]4[-_.](?:5|6)\b/i,rates:{input:3,output:15,cacheRead:.3,cacheWrite:3.75}},{match:/^claude[-_]sonnet[-_]4\b/i,rates:{input:3,output:15,cacheRead:.3,cacheWrite:3.75}},{match:/^claude[-_]haiku[-_]4[-_.]5\b/i,rates:{input:1,output:5,cacheRead:.1,cacheWrite:1.25}},{match:/^claude[-_]haiku[-_]3[-_.]5\b/i,rates:{input:.8,output:4,cacheRead:.08,cacheWrite:1}},{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 bP(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function mv(e){if(!e)return null;for(const n of SP)if(n.match.test(e))return n.rates;return null}function dn(e,n){const i=mv(n);if(!i)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const l=(bP(n)?Math.max(0,e.inputTokens-e.cacheReadTokens):e.inputTokens)*i.input/1e6,u=e.outputTokens*i.output/1e6,c=e.cacheReadTokens*i.cacheRead/1e6,p=e.cacheCreateTokens*i.cacheWrite/1e6;return{input:l,output:u,cacheRead:c,cacheWrite:p,total:l+u+c+p}}const Qw=2e5,kP=1e6,EP=[/\[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],NP=[{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 yN(e){if(!e)return Qw;for(const n of EP)if(n.test(e))return kP;for(const n of NP)if(n.match.test(e))return n.window;return Qw}function Be(e){return e<=0?"—":e<.005?"<1¢":e<1?`${(e*100).toFixed(e<.1?1:0)}¢`:e<100?`$${e.toFixed(2)}`:e<1e4?`$${e.toFixed(0)}`:`$${(e/1e3).toFixed(1)}k`}function Ul(e,n){if(e<=0||n<10)return null;const i=e/n,s=i*60;return s>=.01?`${Be(s)}/min`:`${Be(i*3600)}/hr`}function In(e){return e.toLocaleString()}function CP(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function jP({agent:e,onClose:n}){var h;const i=e.context,s=e.usage,o=(i==null?void 0:i.currentContextTokens)??0,l=yN(e.model),u=Math.min(100,o/l*100),c=dn(s,e.model),p=s.inputTokens+s.cacheReadTokens+s.cacheCreateTokens;return g.jsx("div",{className:"ctx-modal-backdrop",onClick:n,role:"presentation",children:g.jsxs("div",{className:"ctx-modal",onClick:f=>f.stopPropagation(),role:"dialog","aria-label":"Context breakdown",children:[g.jsxs("header",{className:"ctx-modal-head",children:[g.jsxs("div",{children:[g.jsxs("div",{className:"ctx-modal-title",children:["Context · ",e.label]}),g.jsx("div",{className:"ctx-modal-sub",children:"approximation — CC's /context isn't hook-exposed"})]}),g.jsx("button",{className:"ctx-modal-close",onClick:n,"aria-label":"Close",children:"×"})]}),g.jsxs("section",{className:"ctx-window-row",children:[g.jsx("div",{className:"ctx-window-bar",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(u),children:g.jsx("div",{className:"ctx-window-fill",style:{width:`${u}%`}})}),g.jsxs("div",{className:"ctx-window-meta",children:[g.jsxs("span",{className:"ctx-window-pct",children:[u.toFixed(1),"%"]}),g.jsxs("span",{className:"ctx-window-num",children:[In(o)," / ",In(l)," tok (current turn)"]})]})]}),g.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),g.jsxs("div",{className:"ctx-grid",children:[g.jsx(Gn,{label:"input tokens",val:In(s.inputTokens)}),g.jsx(Gn,{label:"output tokens",val:In(s.outputTokens)}),g.jsx(Gn,{label:"cache reads",val:In(s.cacheReadTokens)}),g.jsx(Gn,{label:"cache writes",val:In(s.cacheCreateTokens)}),g.jsx(Gn,{label:"cumulative total",val:In(p)}),g.jsx(Gn,{label:"estimated cost",val:Be(c.total),accent:!0})]}),g.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),g.jsxs("div",{className:"ctx-grid",children:[g.jsx(Gn,{label:"user messages",val:In((i==null?void 0:i.msgsUser)??0)}),g.jsx(Gn,{label:"assistant messages",val:In((i==null?void 0:i.msgsAssistant)??0)}),g.jsx(Gn,{label:"tool uses",val:In((i==null?void 0:i.toolUses)??0)}),g.jsx(Gn,{label:"tool results",val:In((i==null?void 0:i.toolResults)??0)}),g.jsx(Gn,{label:"system-reminders",val:In((i==null?void 0:i.systemReminders)??0)})]}),g.jsx("h3",{className:"ctx-section-title",children:"CLAUDE.md files in scope"}),(((h=i==null?void 0:i.claudeMdFiles)==null?void 0:h.length)??0)===0?g.jsx("div",{className:"ctx-empty",children:"No CLAUDE.md files found on the path from cwd to ~/.claude."}):g.jsx("ul",{className:"ctx-md-list",children:i.claudeMdFiles.map(f=>g.jsxs("li",{children:[g.jsx("span",{className:"ctx-md-path",title:f.path,children:f.path}),g.jsx("span",{className:"ctx-md-size",children:CP(f.bytes)})]},f.path))})]})})}function Gn({label:e,val:n,accent:i}){return g.jsxs("div",{className:`ctx-row${i?" accent":""}`,children:[g.jsx("span",{className:"ctx-row-label",children:e}),g.jsx("span",{className:"ctx-row-val",children:n})]})}function RP({currentContextTokens:e,modelId:n,size:i=26,onClick:s,title:o}){const l=yN(n),u=Math.min(1,e/l),c=i/2-3,p=i/2,h=2*Math.PI*c,f=h*u,m=u>.9?"var(--err)":u>.7?"var(--inflight)":"var(--accent)";return g.jsx("button",{type:"button",className:"ctx-donut",onClick:s,title:o??`context: ${e.toLocaleString()} / ${l.toLocaleString()} (${(u*100).toFixed(1)}%)`,"aria-label":"Show context breakdown",children:g.jsxs("svg",{width:i,height:i,viewBox:`0 0 ${i} ${i}`,children:[g.jsx("circle",{cx:p,cy:p,r:c,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),g.jsx("circle",{cx:p,cy:p,r:c,stroke:m,strokeWidth:"2.5",fill:"none",strokeDasharray:`${f} ${h-f}`,strokeDashoffset:h/4,strokeLinecap:"round",style:{transition:"stroke-dasharray 400ms ease"}}),g.jsx("text",{x:p,y:p+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(u*100)})]})})}function TP(e,n){const i=mv(n);if(!i)return"no rates for this model";const s=u=>u.toLocaleString(),o=u=>`$${u}/MTok`,l=dn(e,n);return[`model: ${n}`,`input ${s(e.inputTokens).padStart(14)} × ${o(i.input).padEnd(11)} = ${Be(l.input)}`,`output ${s(e.outputTokens).padStart(14)} × ${o(i.output).padEnd(11)} = ${Be(l.output)}`,`cache r ${s(e.cacheReadTokens).padStart(14)} × ${o(i.cacheRead).padEnd(11)} = ${Be(l.cacheRead)}`,`cache w ${s(e.cacheCreateTokens).padStart(14)} × ${o(i.cacheWrite).padEnd(11)} = ${Be(l.cacheWrite)}`,"─────────────────────────────────────────",`total = ${Be(l.total)}`].join(`
58
58
  `)}function AP(e,n,i){const s=(n??i)-e;if(s<1e3)return`${Math.max(0,s)}ms`;const o=Math.floor(s/1e3);if(o<60)return`${o}s`;const l=Math.floor(o/60),u=o%60;return`${l}m ${String(u).padStart(2,"0")}s`}function IP({data:e,selected:n}){var h;const i=e.now??Date.now(),s=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":"",n?"selected":""].filter(Boolean).join(" "),o=e.tools.filter(f=>!f.endedAt).length,u=`hsl(${pv(e.sessionId)} 70% 60%)`,c=((h=e.context)==null?void 0:h.currentContextTokens)??0,p=e.kind==="root"&&c>0;return g.jsxs("div",{className:s,style:{"--accent":u},children:[g.jsx("span",{className:"accent-stripe"}),g.jsx(Vs,{type:"target",position:Ce.Left,style:{background:"transparent",border:"none"}}),g.jsxs("div",{className:"head",children:[g.jsxs("div",{className:"title",children:[g.jsx(MP,{state:e.state}),g.jsx("span",{className:"label",title:e.cwd,children:e.label}),e.synthetic&&g.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"})]}),g.jsxs("div",{className:"head-right",children:[p&&e.onOpenContext&&g.jsx(RP,{currentContextTokens:c,modelId:e.model,onClick:()=>e.onOpenContext(e.sessionId)}),g.jsx("div",{className:"time",title:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:AP(e.startedAt,e.endedAt,i)})]})]}),g.jsxs("div",{className:"sub",children:[e.kind==="root"?"session":"subagent",e.childCount>0&&g.jsxs("span",{className:"spawn-badge",title:`${e.childCount} subagents spawned`,children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model&&g.jsx("span",{className:"model-chip",title:e.model,children:aa(e.model)})]}),e.tools.length>0&&g.jsx(OP,{tools:e.tools,now:i}),g.jsxs("div",{className:"meta",children:[g.jsxs("span",{children:[g.jsx("b",{children:e.toolCount})," tools"]}),o>0&&g.jsxs("span",{className:"inflight-meta",children:[g.jsx("b",{children:o})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&g.jsxs("span",{className:"tokens-meta",title:`in:${e.usage.inputTokens} out:${e.usage.outputTokens} cache-r:${e.usage.cacheReadTokens} cache-c:${e.usage.cacheCreateTokens}${(e.usage.reasoningOutputTokens??0)>0?` reasoning:${e.usage.reasoningOutputTokens}`:""}`,children:[g.jsx("b",{children:PP(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),e.model&&mv(e.model)&&(()=>{const f=dn(e.usage,e.model);if(f.total<=0)return null;const m=Math.max(0,((e.endedAt??i)-e.startedAt)/1e3),y=e.state==="active"?Ul(f.total,m):null,x=TP(e.usage,e.model)+(y?`
59
- burn: ${y}`:"");return g.jsxs("span",{className:"cost-meta",title:x,children:[g.jsx("b",{children:Be(f.total)}),y&&g.jsx("span",{className:"cost-rate",children:y})]})})()]}),g.jsx(Vs,{type:"source",position:Ce.Right,style:{background:"transparent",border:"none"}})]})}function MP({state:e}){const n=e==="active"?"live":e==="done"?"done":"err";return g.jsx("span",{className:`state-pill state-${e}`,children:n})}function PP(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function OP({tools:e,now:n}){const l=new Array(24).fill(0);let u=0;for(const y of e){const x=n-y.startedAt;if(x<0||x>=6e4)continue;const N=23-Math.floor(x/2500);N>=0&&N<24&&(l[N]+=1,u+=1)}const c=Math.max(1,...l),p=132,h=14,f=p/24,m=c/(2500/1e3);return g.jsxs("div",{className:"tool-spark-row",title:`${u} tool calls in last 60s · peak ${m.toFixed(1)}/s`,children:[g.jsx("svg",{className:"tool-spark",width:p,height:h,viewBox:`0 0 ${p} ${h}`,"aria-hidden":!0,children:l.map((y,x)=>{const N=y===0?1.5:Math.max(1.5,y/c*h),_=x===23&&y>0,b=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return g.jsx("rect",{x:x*f+.4,y:h-N,width:Math.max(.5,f-1),height:N,rx:.8,className:b},x)})}),g.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function aa(e){const n=e.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const o=n[1][0].toUpperCase()+n[1].slice(1).toLowerCase(),l=n[2].replace(/[-_]/g,".");return`${o} ${l}`}const i=e.match(/^gpt[-_](\d+(?:[-_.]\d+)*)[-_]codex\b/i);if(i)return`GPT-${i[1].replace(/[-_]/g,".")} Codex`;const s=e.match(/^gpt[-_](\d+(?:[-_.]\d+)*)/i);return s?`GPT-${s[1].replace(/[-_]/g,".")}`:e}function Zw(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function qP(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 LP({tool:e,onClose:n}){A.useEffect(()=>{const s=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]);const i=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return g.jsx("div",{className:"modal-backdrop",onClick:n,role:"dialog","aria-modal":"true",children:g.jsxs("div",{className:"modal",onClick:s=>s.stopPropagation(),children:[g.jsxs("header",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:`status-dot ${i}`}),g.jsx("span",{className:"modal-tool-name",children:e.name}),g.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",children:qP(e)}),g.jsx("button",{className:"btn icon-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),g.jsxs("section",{className:"modal-body",children:[g.jsxs("div",{className:"modal-section",children:[g.jsx("h4",{children:"Input"}),g.jsx("pre",{children:Zw(e.input??e.inputPreview)})]}),g.jsxs("div",{className:"modal-section",children:[g.jsxs("h4",{children:["Response ",i==="err"&&g.jsx("span",{className:"err-tag",children:"error"})]}),g.jsx("pre",{children:e.endedAt==null?"(waiting…)":Zw(e.response??e.errorPreview)})]})]})]})})}const bl=18,Jw=26,$P=12;function DP(e){const n=new Map;for(const o of e.nodeInternals.values()){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=ex(l)??f.label)):n.set(l.sessionId,{minX:u,minY:c,maxX:p,maxY:h,label:ex(l)??l.sessionId})}const i=new Map;for(const o of n.values())i.set(o.label,(i.get(o.label)??0)+1);const s=[];for(const[o,l]of n){const c=(i.get(l.label)??0)>1?`${l.label} · ${FP(o)}`:l.label;s.push({sessionId:o,label:c,x:l.minX-bl,y:l.minY-bl-Jw,w:l.maxX-l.minX+bl*2,h:l.maxY-l.minY+bl*2+Jw})}return s}function FP(e){const n=e.match(/[a-zA-Z0-9]{4}/);return n?n[0]:e.slice(0,4)}function ex(e){if(e.kind==="root")return e.label}function zP(){const{x:e,y:n,zoom:i}=uN(),s=oa(),o=Xe(DP,BP);if(o.length<=1)return null;const l=u=>{try{const c=s.getNodes().filter(p=>{const h=p.data;return(h==null?void 0:h.sessionId)===u});if(c.length===0)return;s.fitView({padding:.3,duration:500,nodes:c})}catch{}};return g.jsx("div",{className:"session-clusters",children:o.map(u=>{const c=pv(u.sessionId),p={position:"absolute",left:u.x*i+e,top:u.y*i+n,width:u.w*i,height:u.h*i,borderColor:`hsl(${c} 65% 55% / 0.32)`,background:`hsl(${c} 70% 50% / 0.04)`},h={position:"absolute",left:u.x*i+e+16*i,top:(u.y-$P)*i+n,color:`hsl(${c} 70% 78%)`,borderColor:`hsl(${c} 65% 55% / 0.5)`,transform:`scale(${Math.min(1,i)})`,transformOrigin:"left top"};return g.jsxs(le.Fragment,{children:[g.jsx("div",{className:"cluster-card",style:p,"aria-hidden":!0}),g.jsx("button",{type:"button",className:"cluster-label",style:h,title:`Fit view to ${u.label} · drag the wrapper to move the whole session`,onClick:()=>l(u.sessionId),children:u.label})]},u.sessionId)})})}function BP(e,n){if(e.length!==n.length)return!1;for(let i=0;i<e.length;i++){const s=e[i],o=n[i];if(s.sessionId!==o.sessionId||s.label!==o.label||s.x!==o.x||s.y!==o.y||s.w!==o.w||s.h!==o.h)return!1}return!0}function UP({data:e}){return g.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const wN=600,HP=36,Hg=16,VP=60,WP=6,tx=220,nx=96,GP=28,KP={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 YP(e){return e.startsWith("mcp__")?"mcp":KP[e]??"other"}const XP={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 rx(e){return e.startsWith("mcp__")?"🔌":XP[e]??"✨"}const QP={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 xN(e){if(!e)return null;let n=e.trim();if(!n)return null;const i=n.match(/^(?:bash|sh|zsh|fish|powershell|pwsh)(?:\.exe)?\s+(?:-c|-Command|-NoProfile|-NonInteractive|\s)+["']([^"']+)["']/i);if(i)return xN(i[1]);for(;;){const l=n.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!l)break;n=n.slice(l[0].length)}n=n.replace(/^sudo(?:\s+-\S+)*\s+/,""),n=n.replace(/^(?:time|nohup|xargs)\s+/,"");const s=n.match(/^([^\s|;&<>(]+)/);if(!s)return null;let o=s[1];return o=o.replace(/^.*[/\\]/,""),o=o.replace(/\.(exe|cmd|bat|ps1)$/i,""),o||null}function ZP(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(i=>typeof i=="string")){const i=n.command;if(/powershell|cmd|bash|sh(\.exe)?$/i.test(i[0]??"")){const s=i.findIndex(o=>/^(-Command|-c)$/i.test(o));if(s>=0&&s+1<i.length)return i[s+1]}return i.join(" ")}return typeof n.script=="string"?n.script:null}const JP=new Set(["Bash","PowerShell","shell","exec_command","shell_command","write_stdin","wait"]),e3=new Set(["shell","exec_command","shell_command","write_stdin","wait","apply_patch","update_plan"]);function t3(e,n){return e3.has(e)?Math.max(nx,34+n.length*7.5):nx}function n3(e,n){if(!JP.has(e))return null;const i=ZP(n);if(!i)return null;const s=xN(i);return s?{emoji:QP[s]??"⚙️",label:s,category:"shell",detail:i}:null}const r3=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),ix={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:"🗄️"},sx={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 i3(e){const i=e.replace(/\\/g,"/").replace(/\/+$/,""),s=i.lastIndexOf("/");return s>=0?i.slice(s+1):i}function s3(e){const n=e.toLowerCase();if(sx[n])return sx[n];if(n.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(n))return"🧪";const i=n.lastIndexOf(".");if(i>0&&i<n.length-1){const s=n.slice(i+1);if(ix[s])return ix[s]}return"📄"}function o3(e,n){if(!n||typeof n!="object")return null;const i=n;if(e==="apply_patch"&&typeof i.patch=="string"){const s=i.patch.match(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/m);return s?s[1].trim():null}return typeof i.file_path=="string"?i.file_path:typeof i.notebook_path=="string"?i.notebook_path:typeof i.path=="string"?i.path:e==="Glob"&&typeof i.pattern=="string"?i.pattern:null}function a3(e,n){if(!r3.has(e))return null;const i=o3(e,n);if(!i)return null;const s=i3(i);return s?{emoji:e==="LS"?"📂":s3(s),label:s,category:"file",detail:i}:null}const _N={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 SN(e){if(!e.startsWith("mcp__"))return null;const n=e.slice(5),i=n.indexOf("__");return i<=0?{server:n,method:""}:{server:n.slice(0,i),method:n.slice(i+2)}}function l3(e){let n=5381;for(let i=0;i<e.length;i++)n=(n<<5)+n^e.charCodeAt(i);return Math.abs(n)%360}function u3(e,n){const i=SN(e);if(!i)return null;const{server:s,method:o}=i;if(!o)return null;const l=_N[s.toLowerCase()];return{emoji:(l==null?void 0:l.emoji)??"🔌",label:o,category:"mcp",detail:l?`${l.name} · ${o}`:`${s} · ${o}`}}function c3(e,n){return n3(e,n)??a3(e,n)??u3(e)}const d3={shell:"Shell",exec_command:"Shell",shell_command:"Shell",write_stdin:"stdin",wait:"wait",apply_patch:"Edit",update_plan:"Plan"};function f3(e){const n=SN(e);if(n){const s=_N[n.server.toLowerCase()];return s?{emoji:s.emoji,label:s.name}:{emoji:"🔌",label:n.server,hue:l3(n.server)}}const i=d3[e];return i?{emoji:rx(e),label:i}:{emoji:rx(e),label:e}}function h3(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function p3(e,n,i){if(i==null)return 1;const s=n-i;return s<0?1:Math.max(0,1-s/wN)}function m3(e,n,i,s,o,l){const u=[];for(const c of e.values()){if(!n.has(c.id)||c.exitAt!=null&&l-c.exitAt>wN)continue;const p=s.get(c.id)??i.get(c.id);if(!p)continue;const h=c.tools.slice(-4);if(h.length===0)continue;const f=c.exitAt??null,m=o.get(c.id),y=Math.max((m==null?void 0:m.width)??tx,tx),x=(m==null?void 0:m.height)??130,N=p.x,_=p.y,S=N+y,b=_+x/2;h.forEach((E,C)=>{const j=C*HP,P=N+y+VP,O=_+WP+j,q=p3(E,l,f),B=E.inputPreview??"",T=h3(E),M=q<.999,F=f3(E.name);u.push({id:E.id,toolId:E.id,agentId:c.id,toolName:E.name,name:F.label,emoji:F.emoji,status:T,category:YP(E.name),mcpHue:F.hue,inputPreview:B,fade:q,fading:M,worldX:P,worldY:O,anchorX:S,anchorY:b,spawnDx:S-P,spawnDy:b-(O+Hg)});const X=c3(E.name,E.input);if(X){const Y=t3(E.name,F.label),I=P+Y+GP,H=O,U=P+Y,ne=O+Hg;u.push({id:`sub:${E.id}`,toolId:E.id,agentId:c.id,toolName:E.name,name:X.label,emoji:X.emoji,isSub:!0,status:T,category:X.category,inputPreview:X.detail??B,fade:q,fading:M,worldX:I,worldY:H,anchorX:U,anchorY:ne,spawnDx:U-I,spawnDy:0})}})}return u}function g3({agents:e,visibleAgentIds:n,positions:i,pinned:s,measured:o,dimUnmatched:l,spotlight:u,hiddenCategories:c,now:p,onOpenTool:h}){const{x:f,y:m,zoom:y}=uN(),x=m3(e,n,i,s,o,p),N=c&&c.size>0?x.filter(_=>!c.has(_.category)):x;return g.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[g.jsx("svg",{className:"tool-bursts-svg",children:N.map(_=>{const S=_.anchorX*y+f,b=_.anchorY*y+m,E=(_.worldX+6)*y+f,C=(_.worldY+Hg)*y+m,j=S+(E-S)*.55,P=l!=null&&!l.has(_.agentId),O=u!=null&&!u.has(_.agentId),q=_.fade*(P||O?.14:1);return g.jsx("path",{d:`M ${S} ${b} Q ${j} ${b}, ${E} ${C}`,className:`tool-conn status-${_.status}${_.fading?" fading":""}`,opacity:q},`l:${_.id}`)})}),N.map(_=>{const S=_.worldX*y+f,b=_.worldY*y+m,E={left:`${S}px`,top:`${b}px`,transform:`scale(${y})`,transformOrigin:"left top","--spawn-dx":`${_.spawnDx}px`,"--spawn-dy":`${_.spawnDy}px`},C=_.isSub?`${_.toolName} · ${_.name}`:_.toolName,j=_.inputPreview?`${C} · ${_.inputPreview}`:C,P=h!=null,O=_.mcpHue!=null?{"--cat-accent":`hsl(${_.mcpHue} 65% 65%)`}:{},q=l!=null&&!l.has(_.agentId),B=u!=null&&!u.has(_.agentId),T=q||B?" dim":"";return g.jsx("div",{className:"tool-burst-wrap",style:E,children:g.jsxs("div",{className:`tool-burst cat-${_.category} status-${_.status}${_.fading?" fading":""}${P?" clickable":""}${_.isSub?" sub":""}${T}`,style:O,title:j,role:P?"button":void 0,tabIndex:P?0:void 0,"aria-label":P?`Open ${_.toolName} ${_.status==="inflight"?"in flight":_.status} — click for details`:void 0,onClick:P?()=>h(_.toolId):void 0,onKeyDown:P?M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),h(_.toolId))}:void 0,children:[g.jsx("span",{className:"tb-emoji",children:_.emoji}),g.jsx("span",{className:"tb-name",children:_.name}),_.status==="inflight"&&g.jsx("span",{className:"tb-spin"}),_.status==="done"&&g.jsx("span",{className:"tb-mark done",children:"✓"}),_.status==="err"&&g.jsx("span",{className:"tb-mark err",children:"×"})]})},_.id)})]})}function v3({state:e,sessionId:n,onClose:i}){const s=A.useMemo(()=>w3(e,n),[e,n]);return s?g.jsx("div",{className:"modal-backdrop",onClick:i,role:"presentation",children:g.jsxs("div",{className:"modal session-summary",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[g.jsxs("div",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),g.jsx("span",{id:"ss-title",className:"modal-tool-name",title:s.cwd??s.sessionId,children:s.label}),g.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.durationLabel}),g.jsx("button",{className:"btn",onClick:i,"aria-label":"Close",children:"×"})]})]}),g.jsxs("div",{className:"modal-body",children:[g.jsxs("section",{className:"ss-hero",children:[g.jsxs("div",{className:"ss-hero-left",children:[g.jsx("div",{className:"ss-cost-label",children:"total spend"}),g.jsx("div",{className:"ss-cost",children:Be(s.cost.total)}),s.modelChips.length>0&&g.jsx("div",{className:"ss-models",children:s.modelChips.map(o=>g.jsx("span",{className:"model-chip",title:o,children:aa(o)},o))})]}),g.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&g.jsxs(g.Fragment,{children:[g.jsx(y3,{cost:s.cost}),g.jsxs("div",{className:"ss-cost-legend",children:[g.jsxs("span",{className:"ssl ssl-in",children:["input ",g.jsx("b",{children:Be(s.cost.input)})]}),g.jsxs("span",{className:"ssl ssl-out",children:["output ",g.jsx("b",{children:Be(s.cost.output)})]}),g.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",g.jsx("b",{children:Be(s.cost.cacheRead)})]}),g.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",g.jsx("b",{children:Be(s.cost.cacheWrite)})]})]})]})})]}),g.jsxs("section",{className:"ss-stats",children:[g.jsx(Ps,{label:"agents",value:s.agentCount}),g.jsx(Ps,{label:"subagents",value:s.subagentCount}),g.jsx(Ps,{label:"tool calls",value:s.toolCount}),g.jsx(Ps,{label:"prompts",value:s.promptCount}),g.jsx(Ps,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&g.jsx(Ps,{label:"errors",value:s.errCount,tone:"err"})]}),s.topTools.length>0&&g.jsxs("section",{className:"modal-section",children:[g.jsx("h4",{children:"Most-used tools"}),g.jsx("div",{className:"ss-top-tools",children:s.topTools.map(([o,l])=>g.jsxs("div",{className:"ss-tt",children:[g.jsx("span",{className:"ss-tt-name",children:o}),g.jsx("span",{className:"ss-tt-bar",children:g.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${l/s.topTools[0][1]*100}%`}})}),g.jsx("span",{className:"ss-tt-count",children:l})]},o))})]}),s.firstPrompt&&g.jsxs("section",{className:"modal-section",children:[g.jsx("h4",{children:"Opening prompt"}),g.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]})]})}):null}function Ps({label:e,value:n,tone:i}){return g.jsxs("div",{className:`ss-stat${i?` tone-${i}`:""}`,children:[g.jsx("div",{className:"ss-stat-value",children:n}),g.jsx("div",{className:"ss-stat-label",children:e})]})}function y3({cost:e}){const n=e.total;if(n<=0)return null;const i=(s,o,l)=>{if(s<=0)return null;const u=s/n*100;return g.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${Be(s)} (${u.toFixed(0)}%)`},o)};return g.jsxs("div",{className:"cost-bar cost-bar-lg","aria-label":"Cost breakdown",children:[i(e.input,"cb-input","input"),i(e.output,"cb-output","output"),i(e.cacheRead,"cb-cache-r","cache read"),i(e.cacheWrite,"cb-cache-w","cache write")]})}function w3(e,n){const i=e.agents.get(n);if(!i)return null;const s=[];for(const C of e.agents.values())C.sessionId===n&&s.push(C);if(s.length===0)return null;const o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},l=new Set,u=new Map;let c=0,p=0,h=0,f=0,m=0,y,x=1/0,N=0;for(const C of s){const j=dn(C.usage,C.model);o.input+=j.input,o.output+=j.output,o.cacheRead+=j.cacheRead,o.cacheWrite+=j.cacheWrite,o.total+=j.total,C.model&&l.add(C.model),C.kind==="subagent"&&m++,p+=C.prompts.length,!y&&C.prompts.length>0&&(y=C.prompts[0].text),h+=C.usage.inputTokens+C.usage.outputTokens,c+=C.tools.length,x=Math.min(x,C.startedAt),N=Math.max(N,C.endedAt??Date.now());for(const P of C.tools)u.set(P.name,(u.get(P.name)??0)+1),P.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`,E=Array.from(u.entries()).sort((C,j)=>j[1]-C[1]).slice(0,5);return{sessionId:n,label:i.label||i.cwdBasename||"session",cwd:i.cwd,durationLabel:b,cost:o,modelChips:Array.from(l),agentCount:s.length,subagentCount:m,toolCount:c,promptCount:p,tokensSum:h,errCount:f,topTools:E,firstPrompt:y}}function x3(e,n){const i=[];for(const s of e.agents.values()){if(s.kind!=="root")continue;let o=s.tools.length,l=dn(s.usage,s.model).total,u=s.endedAt??s.startedAt;for(const c of e.agents.values()){if(c.sessionId!==s.sessionId||c.kind==="root")continue;o+=c.tools.length,l+=dn(c.usage,c.model).total;const p=c.endedAt??c.startedAt;p>u&&(u=p)}i.push({sessionId:s.sessionId,label:s.label||s.cwdBasename||"session",cwdBasename:s.cwdBasename,state:s.state,modelId:s.model,toolCount:o,cost:l,startedAt:s.startedAt,lastActivity:u})}return i.sort((s,o)=>{if(s.state!==o.state){if(s.state==="active")return-1;if(o.state==="active")return 1}return o.lastActivity-s.lastActivity}),i}function _3(e,n,i){const s=(n??i)-e;if(s<1e3)return"<1s";const o=Math.floor(s/1e3);if(o<60)return`${o}s`;const l=Math.floor(o/60);return l<60?`${l}m`:`${Math.floor(l/60)}h ${l%60}m`}function S3({state:e,now:n,selectedIds:i,onSelect:s,onClose:o}){const l=A.useMemo(()=>x3(e),[e,e.lastSeq,n]),u=l.filter(c=>c.state==="active").length;return g.jsxs("aside",{className:"session-list","aria-label":"Sessions",children:[g.jsxs("div",{className:"sl-header",children:[g.jsxs("h3",{children:["Sessions ",g.jsx("span",{className:"sl-count",children:l.length})]}),u>0&&g.jsxs("span",{className:"sl-live-count",children:[u," live"]}),g.jsx("button",{className:"btn icon-btn sl-close",onClick:o,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),g.jsxs("div",{className:"sl-rows",children:[l.length===0&&g.jsx("div",{className:"sl-empty",children:"No sessions yet."}),l.map(c=>{const p=i.has(c.sessionId);return g.jsxs("button",{type:"button",className:`sl-row state-${c.state}${p?" selected":""}`,onClick:()=>s(c.sessionId),title:`Focus ${c.label}`,children:[g.jsx("span",{className:`sl-dot state-${c.state}`,"aria-hidden":!0}),g.jsxs("div",{className:"sl-row-body",children:[g.jsxs("div",{className:"sl-row-head",children:[g.jsx("span",{className:"sl-label",children:c.label}),c.modelId&&g.jsx("span",{className:"model-chip",title:c.modelId,children:aa(c.modelId)})]}),g.jsxs("div",{className:"sl-row-meta",children:[g.jsxs("span",{title:"tool calls",children:[g.jsx("b",{children:c.toolCount})," tools"]}),c.cost>0&&g.jsx("span",{className:"sl-cost",title:"total spend",children:g.jsx("b",{children:Be(c.cost)})}),g.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(c.startedAt).toLocaleString()}`,children:_3(c.startedAt,c.state==="active"?void 0:c.lastActivity,n)})]})]})]},c.sessionId)})]})]})}function ox(e,n){if(!e)return null;const i=n-Math.floor(e/1e3);return i<10?"just now":i<60?`${i}s ago`:i<3600?`${Math.floor(i/60)}m ago`:`${Math.floor(i/3600)}h ago`}function b3(e){return e==="claude-swap"?"Read from claude-swap's last collection — costs no request against your usage-endpoint budget":e==="api"?"Fetched from Anthropic's usage endpoint, at most once every 5 minutes":e==="cli"?"Parsed from `claude /usage`, at most once every 5 minutes":"Last update"}function Ar(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function k3({cost:e}){const n=e.total;if(n<=0)return null;const i=(s,o,l)=>{if(s<=0)return null;const u=s/n*100;return g.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${Be(s)} (${u.toFixed(0)}%)`},o)};return g.jsxs("div",{className:"cost-bar","aria-label":"Cost breakdown",children:[i(e.input,"cb-input","input"),i(e.output,"cb-output","output"),i(e.cacheRead,"cb-cache-r","cache read"),i(e.cacheWrite,"cb-cache-w","cache write")]})}function E3(e,n){const i=e-n;if(i<=0)return null;const s=Math.floor(i/3600),o=Math.floor(i%3600/60);if(s>23){const l=Math.floor(i/86400),u=Math.floor(i%86400/3600);return`${l}d ${u}h`}return s>0?`${s}h ${o}m`:`${o}m`}function N3(e,n,i,s){const o=Math.max(0,n-s),l=Math.max(0,i-o);if(l<120)return null;const u=Math.min(100,l/i*100),c=e-u;if(Math.abs(c)<3)return{label:"on pace",color:"var(--ok)",expectedPct:u,isDeficit:!1};if(c>0){const p=100-e,h=l>0?e/l:0,f=h>0?p/h:1/0,m={label:`${Math.round(c)}% ahead`,color:"var(--warn)",expectedPct:u,isDeficit:!0};if(f<o&&f<86400){const y=Math.floor(f/3600),x=Math.floor(f%3600/60);m.runsOutIn=y>0?`${y}h ${x}m`:`${x}m`}return m}return{label:`${Math.round(-c)}% reserve`,color:"var(--ok)",expectedPct:u,isDeficit:!1}}function Bi({pct:e,label:n,reset:i,resetAt:s,windowSec:o,limitReached:l,nowSec:u}){const c=Math.min(100,Math.max(0,e)),h=l||c>=90?"var(--err)":c>=70?"var(--warn)":"var(--accent)",f=c===0?"< 1%":`${c}%`,m=c===0?2:c,y=s?E3(s,u):null,x=s&&o?N3(c,s,o,u):null;return g.jsxs("div",{className:"qb-row",children:[g.jsxs("div",{className:"qb-meta",children:[g.jsxs("span",{className:"qb-label",children:[n,l&&g.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),g.jsx("span",{className:"qb-pct",style:{color:h},children:f})]}),g.jsxs("div",{className:"qb-track",children:[g.jsx("div",{className:"qb-fill",style:{width:`${m}%`,background:h,opacity:c===0?.4:1}}),x&&g.jsx("div",{className:"qb-pace-marker",style:{left:`${x.expectedPct}%`,background:x.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(x.expectedPct)}% by now`})]}),g.jsxs("div",{className:"qb-reset-row",children:[y?g.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):i?g.jsxs("span",{className:"qb-reset",children:["resets ",i]}):null,x&&g.jsx("span",{className:"qb-pace",style:{color:x.color},children:x.runsOutIn?`runs out in ${x.runsOutIn}`:x.label})]})]})}const C3=6e4;function j3(){const[e,n]=A.useState(null),[i,s]=A.useState(!1),o=A.useRef(null),l=async(c=!1)=>{c&&s(!0);try{const h=await fetch(c?"/api/quota?refresh=1":"/api/quota");h.ok&&n(await h.json())}catch{}finally{c&&s(!1)}};return A.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),C3),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{quota:e,loading:i,refresh:()=>l(!0)}}function R3(e){switch(e){case"no_token":return"Run codex login to authenticate.";case"api_key_mode":return"API-key login — ChatGPT quota is only available for codex login.";case"refresh_rejected":return"Codex session expired — run codex login.";case"refresh_failed":return"Couldn't refresh the Codex token — click ↻ to retry.";default:return"ChatGPT API unreachable — click ↻ to retry."}}const bN=6e4;function T3(){const[e,n]=A.useState(null),[i,s]=A.useState(!1),o=A.useRef(null),l=async(c=!1)=>{c&&s(!0);try{const h=await fetch(c?"/api/codex-quota?refresh=1":"/api/codex-quota");h.ok&&n(await h.json())}catch{}finally{c&&s(!1)}};return A.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),bN),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{data:e,loading:i,refresh:()=>l(!0)}}function A3(){const[e,n]=A.useState(null),i=A.useRef(null),s=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return A.useEffect(()=>(s(),i.current=window.setInterval(s,bN),()=>{i.current!=null&&window.clearInterval(i.current)}),[]),{data:e}}function I3({state:e,now:n,onClose:i}){var q,B;const{quota:s,loading:o,refresh:l}=j3(),{data:u,loading:c,refresh:p}=T3(),{data:h}=A3(),[f,m]=A.useState(()=>Math.floor(Date.now()/1e3));A.useEffect(()=>{const T=window.setInterval(()=>m(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(T)},[]);const{byModel:y,totalCost:x,totalTokens:N,burnRate:_}=A.useMemo(()=>{const T=new Map,M={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let F=0,X=0,Y=0,I=0;for(const D of e.agents.values()){const G=D.model??"__unknown__",k=dn(D.usage,D.model),L=T.get(G);L?(L.inputTokens+=D.usage.inputTokens,L.outputTokens+=D.usage.outputTokens,L.cacheReadTokens+=D.usage.cacheReadTokens,L.cacheCreateTokens+=D.usage.cacheCreateTokens,L.cost.total+=k.total,L.cost.input+=k.input,L.cost.output+=k.output,L.cost.cacheRead+=k.cacheRead,L.cost.cacheWrite+=k.cacheWrite,L.agentCount++):T.set(G,{model:G,inputTokens:D.usage.inputTokens,outputTokens:D.usage.outputTokens,cacheReadTokens:D.usage.cacheReadTokens,cacheCreateTokens:D.usage.cacheCreateTokens,cost:{...k},agentCount:1}),M.total+=k.total,M.input+=k.input,M.output+=k.output,M.cacheRead+=k.cacheRead,M.cacheWrite+=k.cacheWrite,F+=D.usage.inputTokens,X+=D.usage.outputTokens,Y+=D.usage.cacheReadTokens,I+=D.usage.cacheCreateTokens}const H=Array.from(T.values()).sort((D,G)=>G.cost.total-D.cost.total);let U=0,ne=0;for(const D of e.agents.values()){if(D.state!=="active")continue;const G=dn(D.usage,D.model);U+=G.total,ne=Math.max(ne,((D.endedAt??n)-D.startedAt)/1e3)}const J=ne>0?Ul(U,ne):null;return{byModel:H,totalCost:M,totalTokens:{in:F,out:X,cacheR:Y,cacheC:I},burnRate:J}},[e,e.lastSeq,n]),S=A.useMemo(()=>{const T=[];for(const M of e.agents.values()){if(M.kind!=="root")continue;let F=dn(M.usage,M.model).total,X=M.usage.inputTokens,Y=M.usage.outputTokens;for(const I of e.agents.values())I.sessionId!==M.sessionId||I.kind==="root"||(F+=dn(I.usage,I.model).total,X+=I.usage.inputTokens,Y+=I.usage.outputTokens);T.push({sessionId:M.sessionId,label:M.label||M.cwdBasename||"session",state:M.state,cost:F,inputTokens:X,outputTokens:Y})}return T.sort((M,F)=>F.cost-M.cost).slice(0,12)},[e,e.lastSeq]),b=x.total>0,E=N.in+N.out,C=o||c,j=ox(s==null?void 0:s.fetchedAt,f),P=ox(u==null?void 0:u.fetchedAt,f),O=()=>{l(),p()};return g.jsxs("div",{className:"usage-panel","aria-label":"Usage",children:[g.jsxs("div",{className:"up-header",children:[g.jsx("h3",{children:"Usage"}),_&&g.jsx("span",{className:"up-rate",children:_}),g.jsxs("div",{className:"up-header-right",children:[g.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:O,disabled:C,title:"Refresh Claude + Codex quota",children:C?"…":"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn up-close",onClick:i,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h4",{className:"up-section-title",children:["Claude quota",j&&!o&&g.jsx("span",{className:"up-section-age",title:b3(s==null?void 0:s.source),children:j})]}),s!=null&&s.ok?g.jsxs("div",{className:"up-quota-bars",children:[s.session5hPct!=null&&g.jsx(Bi,{label:"5-hour window",pct:s.session5hPct,reset:s.session5hReset,resetAt:s.session5hResetAt,windowSec:s.session5hWindowSec,nowSec:f}),s.week7dPct!=null&&g.jsx(Bi,{label:"7-day window",pct:s.week7dPct,reset:s.week7dReset,resetAt:s.week7dResetAt,windowSec:s.week7dWindowSec,nowSec:f}),s.weekSonnetPct!=null&&g.jsx(Bi,{label:"Sonnet (7d)",pct:s.weekSonnetPct,nowSec:f}),s.weekOpusPct!=null&&g.jsx(Bi,{label:"Opus (7d)",pct:s.weekOpusPct,nowSec:f})]}):(s==null?void 0:s.ok)===!1?g.jsxs("div",{className:"up-quota-na",children:[g.jsx("span",{children:"Quota unavailable."}),g.jsxs("span",{className:"up-quota-hint",children:["Run ",g.jsx("code",{children:"/usage"})," in a claude session, then click ↻"]})]}):g.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h4",{className:"up-section-title",children:["Codex quota",(u==null?void 0:u.ok)&&u.planLabel&&g.jsx("span",{className:"up-plan-badge",children:u.planLabel}),P&&!c&&g.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:P})]}),u!=null&&u.ok?g.jsxs("div",{className:"up-quota-bars",children:[(q=u.windows)==null?void 0:q.map(T=>g.jsx(Bi,{label:T.label,pct:T.pct,reset:T.reset??void 0,resetAt:T.resetAt??void 0,windowSec:T.windowSec??void 0,limitReached:u.limitReached&&T.pct>=100,nowSec:f},T.id)),(B=u.extraWindows)==null?void 0:B.map(T=>g.jsx(Bi,{label:T.label,pct:T.pct,reset:T.reset??void 0,resetAt:T.resetAt??void 0,windowSec:T.windowSec??void 0,nowSec:f},T.id)),u.creditLimit&&g.jsx(Bi,{label:`spend cap · $${Math.round(u.creditLimit.used)} of $${Math.round(u.creditLimit.limit)}`,pct:u.creditLimit.usedPct,reset:u.creditLimit.reset??void 0,resetAt:u.creditLimit.resetAt??void 0,limitReached:u.spendControlReached,nowSec:f}),(h==null?void 0:h.ok)&&h.window7d&&h.window7d.sessionCount>0&&g.jsxs("div",{className:"up-quota-sub",children:[Ar(h.window7d.totalTokens)," tokens · ",h.window7d.sessionCount," session",h.window7d.sessionCount!==1?"s":""," (7d)"]}),u.creditsBalance&&!u.creditsUnlimited&&g.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",u.creditsBalance,u.overageReached&&" · overage limit reached"]}),u.creditsUnlimited&&g.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),u.resetCredits&&u.resetCredits.availableCount>0&&g.jsxs("div",{className:"up-quota-sub up-reset-credits",title:"Redeem in the Codex CLI or ChatGPT — agents-deck only reports them",children:[u.resetCredits.availableCount," rate-limit reset",u.resetCredits.availableCount!==1?"s":""," available",u.resetCredits.nextExpiryAt&&` · expires ${new Date(u.resetCredits.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`]}),u.promo&&g.jsx("div",{className:"up-quota-sub",children:u.promo}),u.partial&&g.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(u==null?void 0:u.ok)===!1?g.jsxs("div",{className:"up-quota-na",children:[g.jsx("span",{children:"Quota unavailable."}),g.jsx("span",{className:"up-quota-hint",children:R3(u.reason)})]}):g.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),b?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"up-total",children:[g.jsx("span",{className:"up-total-value",children:Be(x.total)}),g.jsx("span",{className:"up-total-label",children:"total spend"})]}),g.jsx(k3,{cost:x}),E>0&&g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),Ar(N.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),Ar(N.out)]}),N.cacheR>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache r"}),Ar(N.cacheR)]}),N.cacheC>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache c"}),Ar(N.cacheC)]})]}),y.filter(T=>T.cost.total>0).length>0&&g.jsxs("section",{className:"up-section",children:[g.jsx("h4",{className:"up-section-title",children:"By model"}),g.jsxs("table",{className:"up-table",children:[g.jsx("thead",{children:g.jsxs("tr",{children:[g.jsx("th",{children:"Model"}),g.jsx("th",{children:"Tokens"}),g.jsx("th",{children:"Cost"})]})}),g.jsx("tbody",{children:y.filter(T=>T.cost.total>0).map(T=>g.jsxs("tr",{children:[g.jsx("td",{className:"up-model-name",title:T.model,children:aa(T.model)}),g.jsx("td",{className:"up-num",children:Ar(T.inputTokens+T.outputTokens)}),g.jsx("td",{className:"up-num up-cost-val",children:Be(T.cost.total)})]},T.model))})]})]}),S.filter(T=>T.cost>0).length>0&&g.jsxs("section",{className:"up-section",children:[g.jsx("h4",{className:"up-section-title",children:"By session"}),g.jsx("div",{className:"up-sessions",children:S.filter(T=>T.cost>0).map(T=>g.jsxs("div",{className:"up-session-row",children:[g.jsx("span",{className:`sl-dot state-${T.state}`,"aria-hidden":!0}),g.jsx("span",{className:"up-session-label",children:T.label}),g.jsx("span",{className:"up-session-tokens",children:Ar(T.inputTokens+T.outputTokens)}),g.jsx("span",{className:"up-session-cost",children:Be(T.cost)})]},T.sessionId))})]})]}):E>0?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),Ar(N.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),Ar(N.out)]})]}),g.jsx("div",{className:"up-hint",children:"Cost appears once a known model is detected."})]}):g.jsxs("div",{className:"up-empty",children:["No usage data yet.",g.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const ax=18,M3=1100,Os=(e,n)=>{const i=Math.sin(e*12.9898+n*78.233)*43758.5453;return i-Math.floor(i)},P3=Array.from({length:ax},(e,n)=>{const i=-72+144*n/(ax-1)+(Os(n,1)-.5)*9,s=(i-90)*(Math.PI/180),o=(54+32*Math.cos(i*Math.PI/180))*(.74+Os(n,2)*.52);return{dx:Math.cos(s)*o,dy:Math.sin(s)*o,rot:(n%2?1:-1)*(100+Os(n,3)*260),delay:Math.round(Os(n,4)*90),dur:760+Math.round(Os(n,5)*260),scale:.8+Os(n,6)*.45,hue:n%4,round:n%3===0}});function lx({anchor:e,lifetimeMs:n=M3}){var l;const[i,s]=A.useState(null),o=typeof window<"u"&&((l=window.matchMedia)==null?void 0:l.call(window,"(prefers-reduced-motion: reduce)").matches);return A.useEffect(()=>{if(o)return;const u=e.current;if(!u)return;const c=u.getBoundingClientRect();s({x:c.left+c.width/2,y:c.top+c.height/2});const p=window.setTimeout(()=>s(null),n);return()=>window.clearTimeout(p)},[e,n,o]),o||!i?null:JA.createPortal(g.jsx("div",{className:"confetti",style:{left:`${i.x}px`,top:`${i.y}px`},"aria-hidden":!0,children:P3.map((u,c)=>g.jsx("span",{className:`confetti-bit${u.round?" round":""}`,"data-hue":u.hue,style:{"--dx":`${u.dx.toFixed(1)}px`,"--dy":`${u.dy.toFixed(1)}px`,"--rot":`${u.rot}deg`,"--s":u.scale.toFixed(2),animationDelay:`${u.delay}ms`,animationDuration:`${u.dur}ms, ${u.dur}ms`}},c))}),document.body)}const O3=1500;async function kl(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const q3={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"},od=(e,n)=>(e==null?void 0:e.detail)||(e!=null&&e.reason?q3[e.reason]??e.reason:null)||(e==null?void 0:e.error)||n,Vg=le.forwardRef((e,n)=>g.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:n,children:[g.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),g.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));Vg.displayName="SuccessMark";function L3({onClose:e,onChanged:n}){const[i,s]=A.useState("login"),[o,l]=A.useState(null),[u,c]=A.useState(""),[p,h]=A.useState(""),[f,m]=A.useState(!1),[y,x]=A.useState(null),[N,_]=A.useState(null),S=A.useRef(!1),b=A.useRef(null),E=A.useRef(null),C=A.useRef(null),j=A.useCallback(()=>{S.current&&kl({action:"login-cancel"}).catch(()=>{}),e()},[e]);A.useEffect(()=>{const T=M=>{M.key==="Escape"&&j()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[j]);const P=A.useCallback(async()=>{m(!0),x(null),S.current=!0;const T=await kl({action:"login"}).catch(()=>null);if(m(!1),!(T!=null&&T.ok)){x(od(T,"could not start the sign-in"));return}l(T)},[]);A.useEffect(()=>{if(!o||o.state==="done"||o.state==="failed")return;const T=window.setInterval(async()=>{try{const M=await fetch("/api/claude-accounts/login");M.ok&&l(await M.json())}catch{}},O3);return()=>window.clearInterval(T)},[o]),A.useEffect(()=>{var T;(o==null?void 0:o.state)==="awaiting_code"&&((T=b.current)==null||T.focus()),(o==null?void 0:o.state)==="done"&&n()},[o==null?void 0:o.state,n]),A.useEffect(()=>{var T;i==="paste"&&((T=E.current)==null||T.focus())},[i]);const O=A.useCallback(async()=>{var M;m(!0),x(null);const T=await kl({action:"login-code",code:u}).catch(()=>null);if(m(!1),!(T!=null&&T.ok)){x(od(T,"the code was not accepted")),T!=null&&T.state&&l(T),(M=b.current)==null||M.select();return}c(""),l(T)},[u,o]),q=A.useCallback(async()=>{m(!0),x(null);const T=await kl({action:"import",blob:p}).catch(()=>null);if(m(!1),!(T!=null&&T.ok)){x(od(T,"the import failed"));return}h(""),_({added:T.added===!0,num:T.num??null,email:T.email??null}),n()},[p,n]),B=(o==null?void 0:o.state)==="done"?o.account:null;return g.jsx("div",{className:"modal-backdrop",onClick:j,role:"presentation",children:g.jsxs("div",{className:"modal aa-modal",onClick:T=>T.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[g.jsxs("header",{className:"modal-head",children:[g.jsx("div",{className:"modal-title",children:g.jsxs("span",{className:"aa-tabs",role:"tablist",children:[g.jsx("button",{type:"button",role:"tab","aria-selected":i==="login",className:`aa-tab${i==="login"?" on":""}`,onClick:()=>s("login"),children:"Sign in"}),g.jsx("button",{type:"button",role:"tab","aria-selected":i==="paste",className:`aa-tab${i==="paste"?" on":""}`,onClick:()=>s("paste"),children:"Paste a share"})]})}),g.jsx("div",{className:"modal-actions",children:g.jsx("button",{type:"button",className:"btn icon-btn",onClick:j,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),g.jsx("section",{className:"modal-body aa-body",children:i==="login"?B?g.jsxs("div",{className:"aa-done",children:[g.jsx(Vg,{ref:C}),g.jsx(lx,{anchor:C}),g.jsx("h4",{children:B.added?`Account ${B.num} added`:"Credentials refreshed"}),g.jsxs("p",{className:"aa-note",children:[g.jsx("strong",{children:B.email}),B.added?" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),g.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"})]}):(o==null?void 0:o.state)==="awaiting_code"||(o==null?void 0:o.state)==="registering"?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"1 · Approve in the browser"}),g.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),g.jsx("a",{className:"aa-link",href:o.url??"#",target:"_blank",rel:"noreferrer noopener",children:o.url})]}),g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"2 · Paste the code it gives you"}),g.jsxs("div",{className:"aa-field",children:[g.jsx("input",{ref:b,type:"text",value:u,onChange:T=>c(T.target.value),onKeyDown:T=>{T.key==="Enter"&&u.trim()&&!f&&O()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:o.state==="registering"}),g.jsx("button",{type:"button",className:"btn primary",disabled:f||!u.trim()||o.state==="registering",onClick:O,children:o.state==="registering"?"registering…":"Continue"})]}),(y||o.error)&&g.jsx("p",{className:"aa-err",children:y??o.error}),g.jsx("p",{className:"aa-note",children:"The code goes straight to the claude CLI on this machine. It is never stored or sent anywhere else."})]})]}):(o==null?void 0:o.state)==="failed"||y&&S.current&&!f?g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"Sign-in failed"}),g.jsx("p",{className:"aa-err",children:y??(o==null?void 0:o.error)}),g.jsx("button",{type:"button",className:"btn",onClick:()=>{S.current=!1,l(null),x(null),P()},children:"Try again"})]}):f||S.current?g.jsx("div",{className:"aa-step",children:g.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):g.jsxs("div",{className:"aa-step aa-primer",children:[g.jsx("h4",{children:"Sign in to Anthropic"}),g.jsx("p",{className:"aa-note",children:"Opens a browser tab where you approve the sign-in, then asks for the code it shows you. claude-swap records the account when it completes, and the account you are using now stays active."}),g.jsx("div",{className:"aa-actions",children:g.jsx("button",{type:"button",className:"btn primary",onClick:P,disabled:f,children:"Open the sign-in page"})})]}):N?g.jsxs("div",{className:"aa-done",children:[g.jsx(Vg,{ref:C}),N.added&&g.jsx(lx,{anchor:C}),g.jsx("h4",{children:N.added?`Account ${N.num} imported`:"Already here"}),g.jsx("p",{className:"aa-note",children:N.added?g.jsxs(g.Fragment,{children:[N.email?g.jsx("strong",{children:N.email}):"That account"," is in the rotation now. Nothing changed on the deck you copied it from."]}):"This deck already holds that account, so nothing changed."}),g.jsxs("div",{className:"aa-actions",children:[g.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"}),g.jsx("button",{type:"button",className:"btn",onClick:()=>_(null),children:"Import another"})]})]}):g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"Paste an account shared from another deck"}),g.jsxs("div",{className:"aa-field",children:[g.jsx("input",{ref:E,type:"text",value:p,onChange:T=>h(T.target.value),onKeyDown:T=>{T.key==="Enter"&&p.trim()&&!f&&q()},placeholder:"ccdeck1:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),g.jsx("button",{type:"button",className:"btn primary",disabled:f||!p.trim(),onClick:q,children:f?"importing…":"Import"})]}),y&&g.jsx("p",{className:"aa-err",children:y}),g.jsxs("p",{className:"aa-note",children:["Use ",g.jsx("strong",{children:"share"})," on an account in the other deck. A share carries a live login and expires ten minutes after it is made."]})]})})]})})}const $3=15e3,D3=[70,80,85,90,95];function F3(e,n){const i=e-n;if(i<=0)return null;const s=Math.floor(i/86400),o=Math.floor(i%86400/3600),l=Math.floor(i%3600/60);return s>0?`${s}d ${o}h`:o>0?`${o}h ${l}m`:`${l}m`}function ux(e,n){const i=n-Math.floor(e/1e3);return i<60?"just now":i<3600?`${Math.floor(i/60)}m ago`:i<86400?`${Math.floor(i/3600)}h ago`:`${Math.floor(i/86400)}d ago`}function z3(e,n){if(!e)return"";const i=Math.floor(e/1e3)-n;return i<=0?" · due":i<60?` · next in ${i}s`:` · next in ${Math.round(i/60)}m`}function B3(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 U3({lane:e,nowSec:n}){const i=Math.min(100,Math.max(0,e.pct)),s=i>=90?"var(--err)":i>=70?"var(--warn)":"var(--accent)",o=e.resetAt?F3(e.resetAt,n):null;return g.jsxs("div",{className:"ap-lane",children:[g.jsx("span",{className:"ap-lane-label",children:e.label}),g.jsx("div",{className:"ap-lane-track",children:g.jsx("div",{className:"ap-lane-fill",style:{width:`${i===0?1.5:i}%`,background:s,opacity:i===0?.4:1}})}),g.jsxs("span",{className:"ap-lane-pct",style:{color:s},children:[i,"%"]}),g.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}function H3(e){const n=e.map(s=>s.num),i=n.length?Math.max(...n):0;return[...new Set([...n,i+1])].sort((s,o)=>s-o)}async function V3(e){var i;let n=!1;try{n=await Promise.race([((i=navigator.clipboard)==null?void 0:i.writeText(e).then(()=>!0))??Promise.resolve(!1),new Promise(s=>window.setTimeout(()=>s(!1),500))])}catch{n=!1}if(n)return!0;try{const s=document.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(s),s.select(),n=document.execCommand("copy"),s.remove()}catch{n=!1}return n}function W3(e,n){const i=Math.round(e/1e3)-n;return i<=0?{text:"expired",tone:"gone"}:i<60?{text:`expires in ${i}s`,tone:"soon"}:{text:`expires in ${Math.round(i/60)}m`,tone:"ok"}}function G3({onClose:e}){var J,D,G;const[n,i]=A.useState(null),[s,o]=A.useState(null),[l,u]=A.useState(null),[c,p]=A.useState(null),[h,f]=A.useState(null),[m,y]=A.useState(()=>Math.floor(Date.now()/1e3)),x=A.useRef(null),[N,_]=A.useState(null),[S,b]=A.useState(!1),[E,C]=A.useState(""),[j,P]=A.useState(null),[O,q]=A.useState(null),[B,T]=A.useState(!1),M=A.useCallback(async(k=!1)=>{try{const[L,oe]=await Promise.all([fetch(`/api/claude-accounts${k?"?refresh=1":""}`),fetch("/api/cswap-auto")]);L.ok&&i(await L.json()),oe.ok&&o(await oe.json())}catch{}},[]),F=A.useCallback(async(k,L)=>{u(L),f(null);try{const $=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)})).json().catch(()=>null);return $!=null&&$.ok||f(($==null?void 0:$.detail)||($==null?void 0:$.reason)||"command failed"),$}catch{return f("server unreachable"),null}finally{u(null)}},[]),X=A.useCallback(async(k,L)=>{u(L),f(null);try{const $=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)})).json().catch(()=>null);return $!=null&&$.ok||f(($==null?void 0:$.detail)||($==null?void 0:$.reason)||"command failed"),$}catch{return f("server unreachable"),null}finally{u(null)}},[]);A.useEffect(()=>(M(!0),x.current=window.setInterval(()=>M(!1),$3),()=>{x.current!=null&&window.clearInterval(x.current)}),[M]),A.useEffect(()=>{const k=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(k)},[]);const Y=((J=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:J.value)??"90",I=(D=n==null?void 0:n.accounts)==null?void 0:D.find(k=>k.active),H=I!=null&&I.lanes.length?Math.max(...I.lanes.map(k=>k.pct)):null,U=H!=null&&H>=Number(Y)-15,ne=async k=>{p(k),f(null);try{const oe=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:k})})).json().catch(()=>null);oe!=null&&oe.ok||f((oe==null?void 0:oe.output)||(oe==null?void 0:oe.reason)||"switch failed"),await M(!0)}catch{f("server unreachable")}finally{p(null)}};return g.jsxs("div",{className:"accounts-panel","aria-label":"Claude accounts",children:[g.jsxs("div",{className:"ap-header",children:[g.jsx("h3",{children:"Accounts"}),g.jsxs("div",{className:"ap-header-right",children:[g.jsx("button",{type:"button",className:"btn ap-add",onClick:()=>b(!0),title:"Sign in to another Claude account, or paste one shared from another deck",children:"+"}),g.jsx("button",{type:"button",className:"btn ap-refresh",onClick:()=>M(!0),title:"Reload from claude-swap",children:"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),n==null?g.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?g.jsxs(g.Fragment,{children:[(G=n.accounts)==null?void 0:G.map(k=>g.jsxs("div",{className:`ap-account${k.active?" active":""}${k.disabled?" disabled":""}`,children:[g.jsxs("div",{className:"ap-account-head",children:[g.jsx("span",{className:"ap-num",children:k.num}),k.alias&&g.jsx("span",{className:"ap-alias",children:k.alias}),g.jsx("span",{className:"ap-email",title:k.org??void 0,children:k.email}),g.jsx("button",{type:"button",className:`ap-more${N===k.num?" on":""}`,"aria-label":`Manage account ${k.num}`,"aria-expanded":N===k.num,title:"Share, rename, move, remove",onClick:()=>{_(N===k.num?null:k.num),C(k.alias??""),P(null),q(null),T(!1)},children:"⋯"}),k.active?g.jsx("span",{className:"ap-badge-active",children:"● active"}):g.jsx("button",{type:"button",className:"btn ap-switch",disabled:c!=null||k.disabled,onClick:()=>ne(k.num),title:k.disabled?"Held out of rotation":`Switch to ${k.alias??k.email}`,children:c===k.num?"…":"switch"})]}),k.lanes.length>0?k.lanes.map(L=>g.jsx(U3,{lane:L,nowSec:m},L.id)):g.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),g.jsxs("div",{className:"ap-meta",children:[k.error&&(()=>{const L=B3(k.error);return g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"ap-err",title:L.hint,children:L.text}),L.fixable&&g.jsx("button",{type:"button",className:"ap-fix",onClick:()=>b(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"sign in again"})]})})(),((s==null?void 0:s.enabled)||(s==null?void 0:s.external))&&!k.active&&g.jsx("button",{type:"button",className:"ap-rotate",disabled:l!=null,onClick:()=>F({action:"account",account:k.num,enabled:k.disabled},`rot-${k.num}`).then(()=>M(!0)),title:k.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:k.disabled?"held out":"in rotation"}),k.fetchedAt?g.jsxs("span",{className:`ap-age${k.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 ",ux(k.fetchedAt,m),z3(k.nextAt,m)]}):g.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),N===k.num&&g.jsxs("div",{className:"ap-manage",children:[g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("span",{className:"ap-manage-label",children:"name"}),g.jsx("input",{className:"ap-manage-input",type:"text",value:E,onChange:L=>C(L.target.value),onKeyDown:L=>{L.key==="Enter"&&X({action:"alias",account:k.num,alias:E},`alias-${k.num}`).then(()=>M(!0))},placeholder:"no alias",spellCheck:!1,"aria-label":`Alias for account ${k.num}`}),g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null||E.trim()===(k.alias??""),onClick:()=>X({action:"alias",account:k.num,alias:E},`alias-${k.num}`).then(()=>M(!0)),title:"A short name to show instead of the email",children:"save"})]}),g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("span",{className:"ap-manage-label",children:"slot"}),g.jsx("span",{className:"ap-field",children:g.jsx("select",{"aria-label":`Slot for account ${k.num}`,value:String(k.num),disabled:l!=null,onChange:L=>X({action:"move",account:k.num,slot:Number(L.target.value)},`move-${k.num}`).then(()=>M(!0)),children:H3(n.accounts??[]).map(L=>g.jsx("option",{value:L,children:L},L))})}),g.jsx("span",{className:"ap-manage-hint",children:"rotation order"})]}),g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,title:"Copy this account to another agents-deck. The share carries a live login and expires in 10 minutes.",onClick:async()=>{T(!1);const L=await X({action:"share",account:k.num},`share-${k.num}`);L!=null&&L.ok&&q({num:k.num,blob:L.blob,expiresAt:L.expiresAt})},children:"share…"}),g.jsx("button",{type:"button",className:`ap-manage-btn danger${j===k.num?" armed":""}`,disabled:l!=null,title:j===k.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(j!==k.num){P(k.num),window.setTimeout(()=>P(L=>L===k.num?null:L),4e3);return}P(null),X({action:"remove",account:k.num},`rm-${k.num}`).then(()=>{_(null),M(!0)})},children:j===k.num?"confirm remove":"remove"})]}),(O==null?void 0:O.num)===k.num&&(()=>{const L=W3(O.expiresAt,m),oe=L.tone==="gone";return g.jsxs("div",{className:`ap-share${oe?" expired":""}`,children:[g.jsx("code",{className:"ap-share-blob",children:O.blob}),g.jsxs("div",{className:"ap-share-foot",children:[g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,onClick:async()=>{if(oe){T(!1);const $=await X({action:"share",account:k.num},`share-${k.num}`);$!=null&&$.ok&&q({num:k.num,blob:$.blob,expiresAt:$.expiresAt});return}await V3(O.blob)&&(T(!0),window.setTimeout(()=>T(!1),1800))},children:oe?"make a new share":B?"copied":"copy"}),g.jsxs("span",{className:"ap-manage-hint",children:["carries a live login · ",g.jsx("span",{className:`ap-share-expiry ${L.tone}`,children:L.text})]})]})]})})()]})]},k.num)),(s==null?void 0:s.ok)&&g.jsxs("div",{className:"ap-auto",children:[g.jsxs("div",{className:"ap-auto-head",children:[g.jsx("span",{className:"ap-auto-title",children:"Auto-switch"}),g.jsxs("span",{className:"ap-auto-ctl",children:[H!=null&&g.jsxs("span",{className:`ap-auto-now${U?" near":""}`,children:[Math.round(H),"%"]}),g.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:g.jsx("select",{"aria-label":"Switch threshold",value:Y,disabled:l!=null,onChange:k=>F({action:"setting",key:"autoswitch.threshold",value:k.target.value},"threshold").then(()=>M(!0)),children:D3.map(k=>g.jsxs("option",{value:k,children:[k,"%"]},k))})}),g.jsxs("button",{type:"button",className:`ap-auto-state toggle${s.enabled?" live":""}`,role:"switch","aria-checked":s.enabled,disabled:l!=null,onClick:()=>F({action:"enable",enabled:!s.enabled},"enable").then(()=>M(!0)),title:s.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[g.jsx("i",{className:s.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),s.enabled?"on":"off"]})]})]}),s.external&&g.jsxs("p",{className:"ap-auto-note",children:[g.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",g.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",s.enabled?" — this toggle takes over when you stop it.":"."]}),s.lastTick&&g.jsx("div",{className:"ap-auto-foot",children:g.jsxs("span",{className:"ap-auto-result",children:["checked ",ux(s.lastTick.at,m)]})})]}),h&&g.jsx("div",{className:"ap-failure",children:h}),g.jsx("p",{className:"ap-footnote",title:"Anthropic's usage endpoint allows roughly 28–30 requests per hour per account, shared by every tool on this machine — polling it from here would rate-limit your account. So the deck never fetches: it asks claude-swap to collect while this panel is open, at most once every three minutes, and claude-swap decides whether that touches the network at all.",children:"Collected by claude-swap while this panel is open."})]}):g.jsx("div",{className:"ap-empty",children:n.reason==="no_cswap"?g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"claude-swap isn't installed."}),g.jsx("span",{className:"ap-hint",children:"This panel reads the account store claude-swap keeps — without it there is nothing to show. It is a separate tool, published on PyPI, so it does not come with this package."}),n.hint&&g.jsx("code",{className:"ap-cmd",children:n.hint}),g.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",g.jsx("strong",{children:"+"})," button above."]})]}):n.reason==="no_accounts"?g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"No accounts added yet."}),g.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",g.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"Couldn't read the account store."}),g.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",n.reason?` (${n.reason})`:"","."]})]})}),S&&g.jsx(L3,{onClose:()=>b(!1),onChanged:()=>M(!0)})]})}const K3=3e4;function Y3({bundle:e,running:n,lastTried:i}){return!n||e===n?!1:i!==n}function X3(e){const n=e.thresholdMs??K3;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 Q3(e){return e.ctrlKey||e.metaKey||e.altKey}function cx(e,n){if(n.size!==0)for(const i of Array.from(e.keys()))n.has(i)||e.delete(i)}function Z3(){let e=0;return{begin(){const n=++e;return()=>n===e},cancel(){e++}}}function Ui(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 dx(e){return e.replace(/^anthropic\./,"").replace(/^claude-/,"").replace(/-\d{8}$/,"")}function El(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"}function J3(e){return new Date(Date.now()-(e-1)*864e5).toISOString().slice(0,10).replace(/-/g,"")}const eO=[7,14,30,90];function tO(e){const[n,i]=A.useState(null),[s,o]=A.useState(!1),l=A.useRef(Z3()).current,u=(c=!1)=>{const p=l.begin();o(!0);const f=`/api/ccusage?since=${J3(e)}${c?"&refresh=1":""}`;fetch(f).then(m=>m.json()).then(m=>{p()&&i(m)}).catch(()=>{p()&&i({ok:!1,error:"request failed"})}).finally(()=>{p()&&o(!1)})};return A.useEffect(()=>(u(!1),()=>l.cancel()),[e]),{data:n,loading:s,reload:()=>u(!0)}}function nO({onClose:e}){var b,E;const[n,i]=A.useState(30),[s,o]=A.useState(null),{data:l,loading:u,reload:c}=tO(n);A.useEffect(()=>{const C=j=>{j.key==="Escape"&&e()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[e]);const p=l!=null&&l.ok?l.days??[]:[],h=A.useMemo(()=>p.reduce((C,j)=>Math.max(C,j.totalCost),0),[p]),{totalCost:f,totalTok:m,inOut:y,cacheRead:x,modelCosts:N}=A.useMemo(()=>{let C=0,j=0,P=0,O=0;const q=new Map;for(const B of p){C+=B.totalCost,j+=B.totalTokens,P+=B.inputTokens+B.outputTokens,O+=B.cacheReadTokens;for(const T of B.modelBreakdowns)q.set(T.modelName,(q.get(T.modelName)??0)+T.cost)}return{totalCost:C,totalTok:j,inOut:P,cacheRead:O,modelCosts:q}},[p]),_=A.useMemo(()=>Array.from(N.entries()).sort((C,j)=>j[1]-C[1]),[N]),S=s?p.find(C=>C.period===s)??null:null;return g.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:g.jsxs("div",{className:"uh-modal",onClick:C=>C.stopPropagation(),role:"dialog","aria-label":"Usage history",children:[g.jsxs("header",{className:"uh-head",children:[g.jsxs("div",{className:"uh-titlewrap",children:[g.jsx("div",{className:"uh-title",children:"Usage history"}),g.jsx("div",{className:"uh-sub",children:"via ccusage · local Claude / Codex logs"})]}),g.jsx("div",{className:"uh-range",role:"tablist","aria-label":"Range",children:eO.map(C=>g.jsxs("button",{role:"tab","aria-selected":n===C,className:`uh-range-btn${n===C?" on":""}`,onClick:()=>{i(C),o(null)},children:[C,"d"]},C))}),g.jsx("button",{className:"btn icon-btn uh-reload",onClick:c,title:"Re-run ccusage","aria-label":"Reload",children:"↻"}),g.jsx("button",{className:"uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),u&&p.length===0?g.jsx("div",{className:"uh-status",children:"running ccusage… (first run downloads the package)"}):l&&!l.ok?g.jsxs("div",{className:"uh-status uh-err",children:["ccusage failed: ",l.error]}):p.length===0?g.jsx("div",{className:"uh-status",children:"no usage in this range"}):g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"uh-totals",children:[g.jsx(Nl,{label:"total cost",val:Be(f),accent:!0}),g.jsx(Nl,{label:"tokens",val:Ui(m)}),g.jsx(Nl,{label:"input+output",val:Ui(y)}),g.jsx(Nl,{label:"cache reads",val:Ui(x)})]}),g.jsx("div",{className:"uh-chart",role:"img","aria-label":"Daily cost by model",children:p.map(C=>{const j=h>0?C.totalCost/h*100:0,P=C.period===s;return g.jsxs("button",{className:`uh-bar-col${P?" sel":""}`,onClick:()=>o(P?null:C.period),title:`${C.period} · ${Be(C.totalCost)}`,style:{flexBasis:`${100/p.length}%`},children:[g.jsx("div",{className:"uh-bar",style:{height:`${Math.max(j,C.totalCost>0?2:0)}%`},children:C.modelBreakdowns.slice().sort((O,q)=>q.cost-O.cost).map(O=>{const q=C.totalCost>0?O.cost/C.totalCost*100:0;return g.jsx("div",{className:"uh-bar-seg",style:{height:`${q}%`,background:El(O.modelName)}},O.modelName)})}),g.jsx("span",{className:"uh-bar-label",children:C.period.slice(5)})]},C.period)})}),g.jsx("div",{className:"uh-legend",children:_.map(([C,j])=>g.jsxs("span",{className:"uh-legend-item",children:[g.jsx("span",{className:"uh-legend-dot",style:{background:El(C)}}),dx(C)," ",g.jsx("span",{className:"uh-legend-cost",children:Be(j)})]},C))}),S&&g.jsxs("div",{className:"uh-detail",children:[g.jsxs("div",{className:"uh-detail-head",children:[g.jsx("span",{className:"uh-detail-date",children:S.period}),g.jsx("span",{className:"uh-detail-cost",children:Be(S.totalCost)}),(E=(b=S.metadata)==null?void 0:b.agents)!=null&&E.length?g.jsx("span",{className:"uh-detail-agents",children:S.metadata.agents.join(" · ")}):null]}),g.jsxs("div",{className:"uh-detail-mini",children:[g.jsx(Cl,{label:"input",val:Ui(S.inputTokens)}),g.jsx(Cl,{label:"output",val:Ui(S.outputTokens)}),g.jsx(Cl,{label:"cache write",val:Ui(S.cacheCreationTokens)}),g.jsx(Cl,{label:"cache read",val:Ui(S.cacheReadTokens)})]}),g.jsx("div",{className:"uh-detail-models",children:S.modelBreakdowns.slice().sort((C,j)=>j.cost-C.cost).map(C=>{const j=S.totalCost>0?C.cost/S.totalCost*100:0;return g.jsxs("div",{className:"uh-model-row",children:[g.jsxs("span",{className:"uh-model-name",children:[g.jsx("span",{className:"uh-legend-dot",style:{background:El(C.modelName)}}),dx(C.modelName)]}),g.jsx("span",{className:"uh-model-bar",children:g.jsx("span",{className:"uh-model-bar-fill",style:{width:`${j}%`,background:El(C.modelName)}})}),g.jsx("span",{className:"uh-model-cost",children:Be(C.cost)})]},C.modelName)})})]})]})]})})}function Nl({label:e,val:n,accent:i}){return g.jsxs("div",{className:"uh-stat",children:[g.jsx("span",{className:`uh-stat-val${i?" accent":""}`,children:n}),g.jsx("span",{className:"uh-stat-label",children:e})]})}function Cl({label:e,val:n}){return g.jsxs("div",{className:"uh-ministat",children:[g.jsx("span",{className:"uh-ministat-val",children:n}),g.jsx("span",{className:"uh-ministat-label",children:e})]})}function gv(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 ad,fx;function rO(){if(fx)return ad;fx=1;function e(){this.__data__=[],this.size=0}return ad=e,ad}var ld,hx;function Ws(){if(hx)return ld;hx=1;function e(n,i){return n===i||n!==n&&i!==i}return ld=e,ld}var ud,px;function Zl(){if(px)return ud;px=1;var e=Ws();function n(i,s){for(var o=i.length;o--;)if(e(i[o][0],s))return o;return-1}return ud=n,ud}var cd,mx;function iO(){if(mx)return cd;mx=1;var e=Zl(),n=Array.prototype,i=n.splice;function s(o){var l=this.__data__,u=e(l,o);if(u<0)return!1;var c=l.length-1;return u==c?l.pop():i.call(l,u,1),--this.size,!0}return cd=s,cd}var dd,gx;function sO(){if(gx)return dd;gx=1;var e=Zl();function n(i){var s=this.__data__,o=e(s,i);return o<0?void 0:s[o][1]}return dd=n,dd}var fd,vx;function oO(){if(vx)return fd;vx=1;var e=Zl();function n(i){return e(this.__data__,i)>-1}return fd=n,fd}var hd,yx;function aO(){if(yx)return hd;yx=1;var e=Zl();function n(i,s){var o=this.__data__,l=e(o,i);return l<0?(++this.size,o.push([i,s])):o[l][1]=s,this}return hd=n,hd}var pd,wx;function Jl(){if(wx)return pd;wx=1;var e=rO(),n=iO(),i=sO(),s=oO(),o=aO();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=i,l.prototype.has=s,l.prototype.set=o,pd=l,pd}var md,xx;function lO(){if(xx)return md;xx=1;var e=Jl();function n(){this.__data__=new e,this.size=0}return md=n,md}var gd,_x;function uO(){if(_x)return gd;_x=1;function e(n){var i=this.__data__,s=i.delete(n);return this.size=i.size,s}return gd=e,gd}var vd,Sx;function cO(){if(Sx)return vd;Sx=1;function e(n){return this.__data__.get(n)}return vd=e,vd}var yd,bx;function dO(){if(bx)return yd;bx=1;function e(n){return this.__data__.has(n)}return yd=e,yd}var wd,kx;function kN(){if(kx)return wd;kx=1;var e=typeof fl=="object"&&fl&&fl.Object===Object&&fl;return wd=e,wd}var xd,Ex;function Jn(){if(Ex)return xd;Ex=1;var e=kN(),n=typeof self=="object"&&self&&self.Object===Object&&self,i=e||n||Function("return this")();return xd=i,xd}var _d,Nx;function Gs(){if(Nx)return _d;Nx=1;var e=Jn(),n=e.Symbol;return _d=n,_d}var Sd,Cx;function fO(){if(Cx)return Sd;Cx=1;var e=Gs(),n=Object.prototype,i=n.hasOwnProperty,s=n.toString,o=e?e.toStringTag:void 0;function l(u){var c=i.call(u,o),p=u[o];try{u[o]=void 0;var h=!0}catch{}var f=s.call(u);return h&&(c?u[o]=p:delete u[o]),f}return Sd=l,Sd}var bd,jx;function hO(){if(jx)return bd;jx=1;var e=Object.prototype,n=e.toString;function i(s){return n.call(s)}return bd=i,bd}var kd,Rx;function Ji(){if(Rx)return kd;Rx=1;var e=Gs(),n=fO(),i=hO(),s="[object Null]",o="[object Undefined]",l=e?e.toStringTag:void 0;function u(c){return c==null?c===void 0?o:s:l&&l in Object(c)?n(c):i(c)}return kd=u,kd}var Ed,Tx;function On(){if(Tx)return Ed;Tx=1;function e(n){var i=typeof n;return n!=null&&(i=="object"||i=="function")}return Ed=e,Ed}var Nd,Ax;function la(){if(Ax)return Nd;Ax=1;var e=Ji(),n=On(),i="[object AsyncFunction]",s="[object Function]",o="[object GeneratorFunction]",l="[object Proxy]";function u(c){if(!n(c))return!1;var p=e(c);return p==s||p==o||p==i||p==l}return Nd=u,Nd}var Cd,Ix;function pO(){if(Ix)return Cd;Ix=1;var e=Jn(),n=e["__core-js_shared__"];return Cd=n,Cd}var jd,Mx;function mO(){if(Mx)return jd;Mx=1;var e=pO(),n=(function(){var s=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""})();function i(s){return!!n&&n in s}return jd=i,jd}var Rd,Px;function EN(){if(Px)return Rd;Px=1;var e=Function.prototype,n=e.toString;function i(s){if(s!=null){try{return n.call(s)}catch{}try{return s+""}catch{}}return""}return Rd=i,Rd}var Td,Ox;function gO(){if(Ox)return Td;Ox=1;var e=la(),n=mO(),i=On(),s=EN(),o=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,p=u.toString,h=c.hasOwnProperty,f=RegExp("^"+p.call(h).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!i(y)||n(y))return!1;var x=e(y)?f:l;return x.test(s(y))}return Td=m,Td}var Ad,qx;function vO(){if(qx)return Ad;qx=1;function e(n,i){return n==null?void 0:n[i]}return Ad=e,Ad}var Id,Lx;function es(){if(Lx)return Id;Lx=1;var e=gO(),n=vO();function i(s,o){var l=n(s,o);return e(l)?l:void 0}return Id=i,Id}var Md,$x;function vv(){if($x)return Md;$x=1;var e=es(),n=Jn(),i=e(n,"Map");return Md=i,Md}var Pd,Dx;function eu(){if(Dx)return Pd;Dx=1;var e=es(),n=e(Object,"create");return Pd=n,Pd}var Od,Fx;function yO(){if(Fx)return Od;Fx=1;var e=eu();function n(){this.__data__=e?e(null):{},this.size=0}return Od=n,Od}var qd,zx;function wO(){if(zx)return qd;zx=1;function e(n){var i=this.has(n)&&delete this.__data__[n];return this.size-=i?1:0,i}return qd=e,qd}var Ld,Bx;function xO(){if(Bx)return Ld;Bx=1;var e=eu(),n="__lodash_hash_undefined__",i=Object.prototype,s=i.hasOwnProperty;function o(l){var u=this.__data__;if(e){var c=u[l];return c===n?void 0:c}return s.call(u,l)?u[l]:void 0}return Ld=o,Ld}var $d,Ux;function _O(){if(Ux)return $d;Ux=1;var e=eu(),n=Object.prototype,i=n.hasOwnProperty;function s(o){var l=this.__data__;return e?l[o]!==void 0:i.call(l,o)}return $d=s,$d}var Dd,Hx;function SO(){if(Hx)return Dd;Hx=1;var e=eu(),n="__lodash_hash_undefined__";function i(s,o){var l=this.__data__;return this.size+=this.has(s)?0:1,l[s]=e&&o===void 0?n:o,this}return Dd=i,Dd}var Fd,Vx;function bO(){if(Vx)return Fd;Vx=1;var e=yO(),n=wO(),i=xO(),s=_O(),o=SO();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=i,l.prototype.has=s,l.prototype.set=o,Fd=l,Fd}var zd,Wx;function kO(){if(Wx)return zd;Wx=1;var e=bO(),n=Jl(),i=vv();function s(){this.size=0,this.__data__={hash:new e,map:new(i||n),string:new e}}return zd=s,zd}var Bd,Gx;function EO(){if(Gx)return Bd;Gx=1;function e(n){var i=typeof n;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?n!=="__proto__":n===null}return Bd=e,Bd}var Ud,Kx;function tu(){if(Kx)return Ud;Kx=1;var e=EO();function n(i,s){var o=i.__data__;return e(s)?o[typeof s=="string"?"string":"hash"]:o.map}return Ud=n,Ud}var Hd,Yx;function NO(){if(Yx)return Hd;Yx=1;var e=tu();function n(i){var s=e(this,i).delete(i);return this.size-=s?1:0,s}return Hd=n,Hd}var Vd,Xx;function CO(){if(Xx)return Vd;Xx=1;var e=tu();function n(i){return e(this,i).get(i)}return Vd=n,Vd}var Wd,Qx;function jO(){if(Qx)return Wd;Qx=1;var e=tu();function n(i){return e(this,i).has(i)}return Wd=n,Wd}var Gd,Zx;function RO(){if(Zx)return Gd;Zx=1;var e=tu();function n(i,s){var o=e(this,i),l=o.size;return o.set(i,s),this.size+=o.size==l?0:1,this}return Gd=n,Gd}var Kd,Jx;function yv(){if(Jx)return Kd;Jx=1;var e=kO(),n=NO(),i=CO(),s=jO(),o=RO();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=i,l.prototype.has=s,l.prototype.set=o,Kd=l,Kd}var Yd,e1;function TO(){if(e1)return Yd;e1=1;var e=Jl(),n=vv(),i=yv(),s=200;function o(l,u){var c=this.__data__;if(c instanceof e){var p=c.__data__;if(!n||p.length<s-1)return p.push([l,u]),this.size=++c.size,this;c=this.__data__=new i(p)}return c.set(l,u),this.size=c.size,this}return Yd=o,Yd}var Xd,t1;function nu(){if(t1)return Xd;t1=1;var e=Jl(),n=lO(),i=uO(),s=cO(),o=dO(),l=TO();function u(c){var p=this.__data__=new e(c);this.size=p.size}return u.prototype.clear=n,u.prototype.delete=i,u.prototype.get=s,u.prototype.has=o,u.prototype.set=l,Xd=u,Xd}var Qd,n1;function wv(){if(n1)return Qd;n1=1;function e(n,i){for(var s=-1,o=n==null?0:n.length;++s<o&&i(n[s],s,n)!==!1;);return n}return Qd=e,Qd}var Zd,r1;function NN(){if(r1)return Zd;r1=1;var e=es(),n=(function(){try{var i=e(Object,"defineProperty");return i({},"",{}),i}catch{}})();return Zd=n,Zd}var Jd,i1;function ru(){if(i1)return Jd;i1=1;var e=NN();function n(i,s,o){s=="__proto__"&&e?e(i,s,{configurable:!0,enumerable:!0,value:o,writable:!0}):i[s]=o}return Jd=n,Jd}var ef,s1;function iu(){if(s1)return ef;s1=1;var e=ru(),n=Ws(),i=Object.prototype,s=i.hasOwnProperty;function o(l,u,c){var p=l[u];(!(s.call(l,u)&&n(p,c))||c===void 0&&!(u in l))&&e(l,u,c)}return ef=o,ef}var tf,o1;function ua(){if(o1)return tf;o1=1;var e=iu(),n=ru();function i(s,o,l,u){var c=!l;l||(l={});for(var p=-1,h=o.length;++p<h;){var f=o[p],m=u?u(l[f],s[f],f,l,s):void 0;m===void 0&&(m=s[f]),c?n(l,f,m):e(l,f,m)}return l}return tf=i,tf}var nf,a1;function AO(){if(a1)return nf;a1=1;function e(n,i){for(var s=-1,o=Array(n);++s<n;)o[s]=i(s);return o}return nf=e,nf}var rf,l1;function fr(){if(l1)return rf;l1=1;function e(n){return n!=null&&typeof n=="object"}return rf=e,rf}var sf,u1;function IO(){if(u1)return sf;u1=1;var e=Ji(),n=fr(),i="[object Arguments]";function s(o){return n(o)&&e(o)==i}return sf=s,sf}var of,c1;function ca(){if(c1)return of;c1=1;var e=IO(),n=fr(),i=Object.prototype,s=i.hasOwnProperty,o=i.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(u){return n(u)&&s.call(u,"callee")&&!o.call(u,"callee")};return of=l,of}var af,d1;function St(){if(d1)return af;d1=1;var e=Array.isArray;return af=e,af}var Uo={exports:{}},lf,f1;function MO(){if(f1)return lf;f1=1;function e(){return!1}return lf=e,lf}Uo.exports;var h1;function Ks(){return h1||(h1=1,(function(e,n){var i=Jn(),s=MO(),o=n&&!n.nodeType&&n,l=o&&!0&&e&&!e.nodeType&&e,u=l&&l.exports===o,c=u?i.Buffer:void 0,p=c?c.isBuffer:void 0,h=p||s;e.exports=h})(Uo,Uo.exports)),Uo.exports}var uf,p1;function su(){if(p1)return uf;p1=1;var e=9007199254740991,n=/^(?:0|[1-9]\d*)$/;function i(s,o){var l=typeof s;return o=o??e,!!o&&(l=="number"||l!="symbol"&&n.test(s))&&s>-1&&s%1==0&&s<o}return uf=i,uf}var cf,m1;function xv(){if(m1)return cf;m1=1;var e=9007199254740991;function n(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=e}return cf=n,cf}var df,g1;function PO(){if(g1)return df;g1=1;var e=Ji(),n=xv(),i=fr(),s="[object Arguments]",o="[object Array]",l="[object Boolean]",u="[object Date]",c="[object Error]",p="[object Function]",h="[object Map]",f="[object Number]",m="[object Object]",y="[object RegExp]",x="[object Set]",N="[object String]",_="[object WeakMap]",S="[object ArrayBuffer]",b="[object DataView]",E="[object Float32Array]",C="[object Float64Array]",j="[object Int8Array]",P="[object Int16Array]",O="[object Int32Array]",q="[object Uint8Array]",B="[object Uint8ClampedArray]",T="[object Uint16Array]",M="[object Uint32Array]",F={};F[E]=F[C]=F[j]=F[P]=F[O]=F[q]=F[B]=F[T]=F[M]=!0,F[s]=F[o]=F[S]=F[l]=F[b]=F[u]=F[c]=F[p]=F[h]=F[f]=F[m]=F[y]=F[x]=F[N]=F[_]=!1;function X(Y){return i(Y)&&n(Y.length)&&!!F[e(Y)]}return df=X,df}var ff,v1;function ou(){if(v1)return ff;v1=1;function e(n){return function(i){return n(i)}}return ff=e,ff}var Ho={exports:{}};Ho.exports;var y1;function _v(){return y1||(y1=1,(function(e,n){var i=kN(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,u=l&&i.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})(Ho,Ho.exports)),Ho.exports}var hf,w1;function da(){if(w1)return hf;w1=1;var e=PO(),n=ou(),i=_v(),s=i&&i.isTypedArray,o=s?n(s):e;return hf=o,hf}var pf,x1;function CN(){if(x1)return pf;x1=1;var e=AO(),n=ca(),i=St(),s=Ks(),o=su(),l=da(),u=Object.prototype,c=u.hasOwnProperty;function p(h,f){var m=i(h),y=!m&&n(h),x=!m&&!y&&s(h),N=!m&&!y&&!x&&l(h),_=m||y||x||N,S=_?e(h.length,String):[],b=S.length;for(var E in h)(f||c.call(h,E))&&!(_&&(E=="length"||x&&(E=="offset"||E=="parent")||N&&(E=="buffer"||E=="byteLength"||E=="byteOffset")||o(E,b)))&&S.push(E);return S}return pf=p,pf}var mf,_1;function au(){if(_1)return mf;_1=1;var e=Object.prototype;function n(i){var s=i&&i.constructor,o=typeof s=="function"&&s.prototype||e;return i===o}return mf=n,mf}var gf,S1;function jN(){if(S1)return gf;S1=1;function e(n,i){return function(s){return n(i(s))}}return gf=e,gf}var vf,b1;function OO(){if(b1)return vf;b1=1;var e=jN(),n=e(Object.keys,Object);return vf=n,vf}var yf,k1;function Sv(){if(k1)return yf;k1=1;var e=au(),n=OO(),i=Object.prototype,s=i.hasOwnProperty;function o(l){if(!e(l))return n(l);var u=[];for(var c in Object(l))s.call(l,c)&&c!="constructor"&&u.push(c);return u}return yf=o,yf}var wf,E1;function qr(){if(E1)return wf;E1=1;var e=la(),n=xv();function i(s){return s!=null&&n(s.length)&&!e(s)}return wf=i,wf}var xf,N1;function yi(){if(N1)return xf;N1=1;var e=CN(),n=Sv(),i=qr();function s(o){return i(o)?e(o):n(o)}return xf=s,xf}var _f,C1;function qO(){if(C1)return _f;C1=1;var e=ua(),n=yi();function i(s,o){return s&&e(o,n(o),s)}return _f=i,_f}var Sf,j1;function LO(){if(j1)return Sf;j1=1;function e(n){var i=[];if(n!=null)for(var s in Object(n))i.push(s);return i}return Sf=e,Sf}var bf,R1;function $O(){if(R1)return bf;R1=1;var e=On(),n=au(),i=LO(),s=Object.prototype,o=s.hasOwnProperty;function l(u){if(!e(u))return i(u);var c=n(u),p=[];for(var h in u)h=="constructor"&&(c||!o.call(u,h))||p.push(h);return p}return bf=l,bf}var kf,T1;function ts(){if(T1)return kf;T1=1;var e=CN(),n=$O(),i=qr();function s(o){return i(o)?e(o,!0):n(o)}return kf=s,kf}var Ef,A1;function DO(){if(A1)return Ef;A1=1;var e=ua(),n=ts();function i(s,o){return s&&e(o,n(o),s)}return Ef=i,Ef}var Vo={exports:{}};Vo.exports;var I1;function RN(){return I1||(I1=1,(function(e,n){var i=Jn(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,u=l?i.Buffer:void 0,c=u?u.allocUnsafe:void 0;function p(h,f){if(f)return h.slice();var m=h.length,y=c?c(m):new h.constructor(m);return h.copy(y),y}e.exports=p})(Vo,Vo.exports)),Vo.exports}var Nf,M1;function TN(){if(M1)return Nf;M1=1;function e(n,i){var s=-1,o=n.length;for(i||(i=Array(o));++s<o;)i[s]=n[s];return i}return Nf=e,Nf}var Cf,P1;function AN(){if(P1)return Cf;P1=1;function e(n,i){for(var s=-1,o=n==null?0:n.length,l=0,u=[];++s<o;){var c=n[s];i(c,s,n)&&(u[l++]=c)}return u}return Cf=e,Cf}var jf,O1;function IN(){if(O1)return jf;O1=1;function e(){return[]}return jf=e,jf}var Rf,q1;function bv(){if(q1)return Rf;q1=1;var e=AN(),n=IN(),i=Object.prototype,s=i.propertyIsEnumerable,o=Object.getOwnPropertySymbols,l=o?function(u){return u==null?[]:(u=Object(u),e(o(u),function(c){return s.call(u,c)}))}:n;return Rf=l,Rf}var Tf,L1;function FO(){if(L1)return Tf;L1=1;var e=ua(),n=bv();function i(s,o){return e(s,n(s),o)}return Tf=i,Tf}var Af,$1;function kv(){if($1)return Af;$1=1;function e(n,i){for(var s=-1,o=i.length,l=n.length;++s<o;)n[l+s]=i[s];return n}return Af=e,Af}var If,D1;function lu(){if(D1)return If;D1=1;var e=jN(),n=e(Object.getPrototypeOf,Object);return If=n,If}var Mf,F1;function MN(){if(F1)return Mf;F1=1;var e=kv(),n=lu(),i=bv(),s=IN(),o=Object.getOwnPropertySymbols,l=o?function(u){for(var c=[];u;)e(c,i(u)),u=n(u);return c}:s;return Mf=l,Mf}var Pf,z1;function zO(){if(z1)return Pf;z1=1;var e=ua(),n=MN();function i(s,o){return e(s,n(s),o)}return Pf=i,Pf}var Of,B1;function PN(){if(B1)return Of;B1=1;var e=kv(),n=St();function i(s,o,l){var u=o(s);return n(s)?u:e(u,l(s))}return Of=i,Of}var qf,U1;function ON(){if(U1)return qf;U1=1;var e=PN(),n=bv(),i=yi();function s(o){return e(o,i,n)}return qf=s,qf}var Lf,H1;function BO(){if(H1)return Lf;H1=1;var e=PN(),n=MN(),i=ts();function s(o){return e(o,i,n)}return Lf=s,Lf}var $f,V1;function UO(){if(V1)return $f;V1=1;var e=es(),n=Jn(),i=e(n,"DataView");return $f=i,$f}var Df,W1;function HO(){if(W1)return Df;W1=1;var e=es(),n=Jn(),i=e(n,"Promise");return Df=i,Df}var Ff,G1;function qN(){if(G1)return Ff;G1=1;var e=es(),n=Jn(),i=e(n,"Set");return Ff=i,Ff}var zf,K1;function VO(){if(K1)return zf;K1=1;var e=es(),n=Jn(),i=e(n,"WeakMap");return zf=i,zf}var Bf,Y1;function Ys(){if(Y1)return Bf;Y1=1;var e=UO(),n=vv(),i=HO(),s=qN(),o=VO(),l=Ji(),u=EN(),c="[object Map]",p="[object Object]",h="[object Promise]",f="[object Set]",m="[object WeakMap]",y="[object DataView]",x=u(e),N=u(n),_=u(i),S=u(s),b=u(o),E=l;return(e&&E(new e(new ArrayBuffer(1)))!=y||n&&E(new n)!=c||i&&E(i.resolve())!=h||s&&E(new s)!=f||o&&E(new o)!=m)&&(E=function(C){var j=l(C),P=j==p?C.constructor:void 0,O=P?u(P):"";if(O)switch(O){case x:return y;case N:return c;case _:return h;case S:return f;case b:return m}return j}),Bf=E,Bf}var Uf,X1;function WO(){if(X1)return Uf;X1=1;var e=Object.prototype,n=e.hasOwnProperty;function i(s){var o=s.length,l=new s.constructor(o);return o&&typeof s[0]=="string"&&n.call(s,"index")&&(l.index=s.index,l.input=s.input),l}return Uf=i,Uf}var Hf,Q1;function LN(){if(Q1)return Hf;Q1=1;var e=Jn(),n=e.Uint8Array;return Hf=n,Hf}var Vf,Z1;function Ev(){if(Z1)return Vf;Z1=1;var e=LN();function n(i){var s=new i.constructor(i.byteLength);return new e(s).set(new e(i)),s}return Vf=n,Vf}var Wf,J1;function GO(){if(J1)return Wf;J1=1;var e=Ev();function n(i,s){var o=s?e(i.buffer):i.buffer;return new i.constructor(o,i.byteOffset,i.byteLength)}return Wf=n,Wf}var Gf,e_;function KO(){if(e_)return Gf;e_=1;var e=/\w*$/;function n(i){var s=new i.constructor(i.source,e.exec(i));return s.lastIndex=i.lastIndex,s}return Gf=n,Gf}var Kf,t_;function YO(){if(t_)return Kf;t_=1;var e=Gs(),n=e?e.prototype:void 0,i=n?n.valueOf:void 0;function s(o){return i?Object(i.call(o)):{}}return Kf=s,Kf}var Yf,n_;function $N(){if(n_)return Yf;n_=1;var e=Ev();function n(i,s){var o=s?e(i.buffer):i.buffer;return new i.constructor(o,i.byteOffset,i.length)}return Yf=n,Yf}var Xf,r_;function XO(){if(r_)return Xf;r_=1;var e=Ev(),n=GO(),i=KO(),s=YO(),o=$N(),l="[object Boolean]",u="[object Date]",c="[object Map]",p="[object Number]",h="[object RegExp]",f="[object Set]",m="[object String]",y="[object Symbol]",x="[object ArrayBuffer]",N="[object DataView]",_="[object Float32Array]",S="[object Float64Array]",b="[object Int8Array]",E="[object Int16Array]",C="[object Int32Array]",j="[object Uint8Array]",P="[object Uint8ClampedArray]",O="[object Uint16Array]",q="[object Uint32Array]";function B(T,M,F){var X=T.constructor;switch(M){case x:return e(T);case l:case u:return new X(+T);case N:return n(T,F);case _:case S:case b:case E:case C:case j:case P:case O:case q:return o(T,F);case c:return new X;case p:case m:return new X(T);case h:return i(T);case f:return new X;case y:return s(T)}}return Xf=B,Xf}var Qf,i_;function DN(){if(i_)return Qf;i_=1;var e=On(),n=Object.create,i=(function(){function s(){}return function(o){if(!e(o))return{};if(n)return n(o);s.prototype=o;var l=new s;return s.prototype=void 0,l}})();return Qf=i,Qf}var Zf,s_;function FN(){if(s_)return Zf;s_=1;var e=DN(),n=lu(),i=au();function s(o){return typeof o.constructor=="function"&&!i(o)?e(n(o)):{}}return Zf=s,Zf}var Jf,o_;function QO(){if(o_)return Jf;o_=1;var e=Ys(),n=fr(),i="[object Map]";function s(o){return n(o)&&e(o)==i}return Jf=s,Jf}var eh,a_;function ZO(){if(a_)return eh;a_=1;var e=QO(),n=ou(),i=_v(),s=i&&i.isMap,o=s?n(s):e;return eh=o,eh}var th,l_;function JO(){if(l_)return th;l_=1;var e=Ys(),n=fr(),i="[object Set]";function s(o){return n(o)&&e(o)==i}return th=s,th}var nh,u_;function eq(){if(u_)return nh;u_=1;var e=JO(),n=ou(),i=_v(),s=i&&i.isSet,o=s?n(s):e;return nh=o,nh}var rh,c_;function zN(){if(c_)return rh;c_=1;var e=nu(),n=wv(),i=iu(),s=qO(),o=DO(),l=RN(),u=TN(),c=FO(),p=zO(),h=ON(),f=BO(),m=Ys(),y=WO(),x=XO(),N=FN(),_=St(),S=Ks(),b=ZO(),E=On(),C=eq(),j=yi(),P=ts(),O=1,q=2,B=4,T="[object Arguments]",M="[object Array]",F="[object Boolean]",X="[object Date]",Y="[object Error]",I="[object Function]",H="[object GeneratorFunction]",U="[object Map]",ne="[object Number]",J="[object Object]",D="[object RegExp]",G="[object Set]",k="[object String]",L="[object Symbol]",oe="[object WeakMap]",$="[object ArrayBuffer]",Q="[object DataView]",ee="[object Float32Array]",se="[object Float64Array]",ae="[object Int8Array]",pe="[object Int16Array]",ge="[object Int32Array]",Ae="[object Uint8Array]",Oe="[object Uint8ClampedArray]",Me="[object Uint16Array]",Pe="[object Uint32Array]",ke={};ke[T]=ke[M]=ke[$]=ke[Q]=ke[F]=ke[X]=ke[ee]=ke[se]=ke[ae]=ke[pe]=ke[ge]=ke[U]=ke[ne]=ke[J]=ke[D]=ke[G]=ke[k]=ke[L]=ke[Ae]=ke[Oe]=ke[Me]=ke[Pe]=!0,ke[Y]=ke[I]=ke[oe]=!1;function We(ve,ye,Ge,ut,it,Ke){var $e,Qe=ye&O,bt=ye&q,ct=ye&B;if(Ge&&($e=it?Ge(ve,ut,it,Ke):Ge(ve)),$e!==void 0)return $e;if(!E(ve))return ve;var pt=_(ve);if(pt){if($e=y(ve),!Qe)return u(ve,$e)}else{var mt=m(ve),kt=mt==I||mt==H;if(S(ve))return l(ve,Qe);if(mt==J||mt==T||kt&&!it){if($e=bt||kt?{}:N(ve),!Qe)return bt?p(ve,o($e,ve)):c(ve,s($e,ve))}else{if(!ke[mt])return it?ve:{};$e=x(ve,mt,Qe)}}Ke||(Ke=new e);var He=Ke.get(ve);if(He)return He;Ke.set(ve,$e),C(ve)?ve.forEach(function(gt){$e.add(We(gt,ye,Ge,gt,ve,Ke))}):b(ve)&&ve.forEach(function(gt,yt){$e.set(yt,We(gt,ye,Ge,yt,ve,Ke))});var Je=ct?bt?f:h:bt?P:j,dt=pt?void 0:Je(ve);return n(dt||ve,function(gt,yt){dt&&(yt=gt,gt=ve[yt]),i($e,yt,We(gt,ye,Ge,yt,ve,Ke))}),$e}return rh=We,rh}var ih,d_;function tq(){if(d_)return ih;d_=1;var e=zN(),n=4;function i(s){return e(s,n)}return ih=i,ih}var sh,f_;function Nv(){if(f_)return sh;f_=1;function e(n){return function(){return n}}return sh=e,sh}var oh,h_;function nq(){if(h_)return oh;h_=1;function e(n){return function(i,s,o){for(var l=-1,u=Object(i),c=o(i),p=c.length;p--;){var h=c[n?p:++l];if(s(u[h],h,u)===!1)break}return i}}return oh=e,oh}var ah,p_;function Cv(){if(p_)return ah;p_=1;var e=nq(),n=e();return ah=n,ah}var lh,m_;function jv(){if(m_)return lh;m_=1;var e=Cv(),n=yi();function i(s,o){return s&&e(s,o,n)}return lh=i,lh}var uh,g_;function rq(){if(g_)return uh;g_=1;var e=qr();function n(i,s){return function(o,l){if(o==null)return o;if(!e(o))return i(o,l);for(var u=o.length,c=s?u:-1,p=Object(o);(s?c--:++c<u)&&l(p[c],c,p)!==!1;);return o}}return uh=n,uh}var ch,v_;function uu(){if(v_)return ch;v_=1;var e=jv(),n=rq(),i=n(e);return ch=i,ch}var dh,y_;function ns(){if(y_)return dh;y_=1;function e(n){return n}return dh=e,dh}var fh,w_;function BN(){if(w_)return fh;w_=1;var e=ns();function n(i){return typeof i=="function"?i:e}return fh=n,fh}var hh,x_;function UN(){if(x_)return hh;x_=1;var e=wv(),n=uu(),i=BN(),s=St();function o(l,u){var c=s(l)?e:n;return c(l,i(u))}return hh=o,hh}var ph,__;function HN(){return __||(__=1,ph=UN()),ph}var mh,S_;function iq(){if(S_)return mh;S_=1;var e=uu();function n(i,s){var o=[];return e(i,function(l,u,c){s(l,u,c)&&o.push(l)}),o}return mh=n,mh}var gh,b_;function sq(){if(b_)return gh;b_=1;var e="__lodash_hash_undefined__";function n(i){return this.__data__.set(i,e),this}return gh=n,gh}var vh,k_;function oq(){if(k_)return vh;k_=1;function e(n){return this.__data__.has(n)}return vh=e,vh}var yh,E_;function VN(){if(E_)return yh;E_=1;var e=yv(),n=sq(),i=oq();function s(o){var l=-1,u=o==null?0:o.length;for(this.__data__=new e;++l<u;)this.add(o[l])}return s.prototype.add=s.prototype.push=n,s.prototype.has=i,yh=s,yh}var wh,N_;function aq(){if(N_)return wh;N_=1;function e(n,i){for(var s=-1,o=n==null?0:n.length;++s<o;)if(i(n[s],s,n))return!0;return!1}return wh=e,wh}var xh,C_;function WN(){if(C_)return xh;C_=1;function e(n,i){return n.has(i)}return xh=e,xh}var _h,j_;function GN(){if(j_)return _h;j_=1;var e=VN(),n=aq(),i=WN(),s=1,o=2;function l(u,c,p,h,f,m){var y=p&s,x=u.length,N=c.length;if(x!=N&&!(y&&N>x))return!1;var _=m.get(u),S=m.get(c);if(_&&S)return _==c&&S==u;var b=-1,E=!0,C=p&o?new e:void 0;for(m.set(u,c),m.set(c,u);++b<x;){var j=u[b],P=c[b];if(h)var O=y?h(P,j,b,c,u,m):h(j,P,b,u,c,m);if(O!==void 0){if(O)continue;E=!1;break}if(C){if(!n(c,function(q,B){if(!i(C,B)&&(j===q||f(j,q,p,h,m)))return C.push(B)})){E=!1;break}}else if(!(j===P||f(j,P,p,h,m))){E=!1;break}}return m.delete(u),m.delete(c),E}return _h=l,_h}var Sh,R_;function lq(){if(R_)return Sh;R_=1;function e(n){var i=-1,s=Array(n.size);return n.forEach(function(o,l){s[++i]=[l,o]}),s}return Sh=e,Sh}var bh,T_;function Rv(){if(T_)return bh;T_=1;function e(n){var i=-1,s=Array(n.size);return n.forEach(function(o){s[++i]=o}),s}return bh=e,bh}var kh,A_;function uq(){if(A_)return kh;A_=1;var e=Gs(),n=LN(),i=Ws(),s=GN(),o=lq(),l=Rv(),u=1,c=2,p="[object Boolean]",h="[object Date]",f="[object Error]",m="[object Map]",y="[object Number]",x="[object RegExp]",N="[object Set]",_="[object String]",S="[object Symbol]",b="[object ArrayBuffer]",E="[object DataView]",C=e?e.prototype:void 0,j=C?C.valueOf:void 0;function P(O,q,B,T,M,F,X){switch(B){case E:if(O.byteLength!=q.byteLength||O.byteOffset!=q.byteOffset)return!1;O=O.buffer,q=q.buffer;case b:return!(O.byteLength!=q.byteLength||!F(new n(O),new n(q)));case p:case h:case y:return i(+O,+q);case f:return O.name==q.name&&O.message==q.message;case x:case _:return O==q+"";case m:var Y=o;case N:var I=T&u;if(Y||(Y=l),O.size!=q.size&&!I)return!1;var H=X.get(O);if(H)return H==q;T|=c,X.set(O,q);var U=s(Y(O),Y(q),T,M,F,X);return X.delete(O),U;case S:if(j)return j.call(O)==j.call(q)}return!1}return kh=P,kh}var Eh,I_;function cq(){if(I_)return Eh;I_=1;var e=ON(),n=1,i=Object.prototype,s=i.hasOwnProperty;function o(l,u,c,p,h,f){var m=c&n,y=e(l),x=y.length,N=e(u),_=N.length;if(x!=_&&!m)return!1;for(var S=x;S--;){var b=y[S];if(!(m?b in u:s.call(u,b)))return!1}var E=f.get(l),C=f.get(u);if(E&&C)return E==u&&C==l;var j=!0;f.set(l,u),f.set(u,l);for(var P=m;++S<x;){b=y[S];var O=l[b],q=u[b];if(p)var B=m?p(q,O,b,u,l,f):p(O,q,b,l,u,f);if(!(B===void 0?O===q||h(O,q,c,p,f):B)){j=!1;break}P||(P=b=="constructor")}if(j&&!P){var T=l.constructor,M=u.constructor;T!=M&&"constructor"in l&&"constructor"in u&&!(typeof T=="function"&&T instanceof T&&typeof M=="function"&&M instanceof M)&&(j=!1)}return f.delete(l),f.delete(u),j}return Eh=o,Eh}var Nh,M_;function dq(){if(M_)return Nh;M_=1;var e=nu(),n=GN(),i=uq(),s=cq(),o=Ys(),l=St(),u=Ks(),c=da(),p=1,h="[object Arguments]",f="[object Array]",m="[object Object]",y=Object.prototype,x=y.hasOwnProperty;function N(_,S,b,E,C,j){var P=l(_),O=l(S),q=P?f:o(_),B=O?f:o(S);q=q==h?m:q,B=B==h?m:B;var T=q==m,M=B==m,F=q==B;if(F&&u(_)){if(!u(S))return!1;P=!0,T=!1}if(F&&!T)return j||(j=new e),P||c(_)?n(_,S,b,E,C,j):i(_,S,q,b,E,C,j);if(!(b&p)){var X=T&&x.call(_,"__wrapped__"),Y=M&&x.call(S,"__wrapped__");if(X||Y){var I=X?_.value():_,H=Y?S.value():S;return j||(j=new e),C(I,H,b,E,j)}}return F?(j||(j=new e),s(_,S,b,E,C,j)):!1}return Nh=N,Nh}var Ch,P_;function KN(){if(P_)return Ch;P_=1;var e=dq(),n=fr();function i(s,o,l,u,c){return s===o?!0:s==null||o==null||!n(s)&&!n(o)?s!==s&&o!==o:e(s,o,l,u,i,c)}return Ch=i,Ch}var jh,O_;function fq(){if(O_)return jh;O_=1;var e=nu(),n=KN(),i=1,s=2;function o(l,u,c,p){var h=c.length,f=h,m=!p;if(l==null)return!f;for(l=Object(l);h--;){var y=c[h];if(m&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++h<f;){y=c[h];var x=y[0],N=l[x],_=y[1];if(m&&y[2]){if(N===void 0&&!(x in l))return!1}else{var S=new e;if(p)var b=p(N,_,x,l,u,S);if(!(b===void 0?n(_,N,i|s,p,S):b))return!1}}return!0}return jh=o,jh}var Rh,q_;function YN(){if(q_)return Rh;q_=1;var e=On();function n(i){return i===i&&!e(i)}return Rh=n,Rh}var Th,L_;function hq(){if(L_)return Th;L_=1;var e=YN(),n=yi();function i(s){for(var o=n(s),l=o.length;l--;){var u=o[l],c=s[u];o[l]=[u,c,e(c)]}return o}return Th=i,Th}var Ah,$_;function XN(){if($_)return Ah;$_=1;function e(n,i){return function(s){return s==null?!1:s[n]===i&&(i!==void 0||n in Object(s))}}return Ah=e,Ah}var Ih,D_;function pq(){if(D_)return Ih;D_=1;var e=fq(),n=hq(),i=XN();function s(o){var l=n(o);return l.length==1&&l[0][2]?i(l[0][0],l[0][1]):function(u){return u===o||e(u,o,l)}}return Ih=s,Ih}var Mh,F_;function Xs(){if(F_)return Mh;F_=1;var e=Ji(),n=fr(),i="[object Symbol]";function s(o){return typeof o=="symbol"||n(o)&&e(o)==i}return Mh=s,Mh}var Ph,z_;function Tv(){if(z_)return Ph;z_=1;var e=St(),n=Xs(),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function o(l,u){if(e(l))return!1;var c=typeof l;return c=="number"||c=="symbol"||c=="boolean"||l==null||n(l)?!0:s.test(l)||!i.test(l)||u!=null&&l in Object(u)}return Ph=o,Ph}var Oh,B_;function mq(){if(B_)return Oh;B_=1;var e=yv(),n="Expected a function";function i(s,o){if(typeof s!="function"||o!=null&&typeof o!="function")throw new TypeError(n);var l=function(){var u=arguments,c=o?o.apply(this,u):u[0],p=l.cache;if(p.has(c))return p.get(c);var h=s.apply(this,u);return l.cache=p.set(c,h)||p,h};return l.cache=new(i.Cache||e),l}return i.Cache=e,Oh=i,Oh}var qh,U_;function gq(){if(U_)return qh;U_=1;var e=mq(),n=500;function i(s){var o=e(s,function(u){return l.size===n&&l.clear(),u}),l=o.cache;return o}return qh=i,qh}var Lh,H_;function vq(){if(H_)return Lh;H_=1;var e=gq(),n=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,s=e(function(o){var l=[];return o.charCodeAt(0)===46&&l.push(""),o.replace(n,function(u,c,p,h){l.push(p?h.replace(i,"$1"):c||u)}),l});return Lh=s,Lh}var $h,V_;function cu(){if(V_)return $h;V_=1;function e(n,i){for(var s=-1,o=n==null?0:n.length,l=Array(o);++s<o;)l[s]=i(n[s],s,n);return l}return $h=e,$h}var Dh,W_;function yq(){if(W_)return Dh;W_=1;var e=Gs(),n=cu(),i=St(),s=Xs(),o=e?e.prototype:void 0,l=o?o.toString:void 0;function u(c){if(typeof c=="string")return c;if(i(c))return n(c,u)+"";if(s(c))return l?l.call(c):"";var p=c+"";return p=="0"&&1/c==-1/0?"-0":p}return Dh=u,Dh}var Fh,G_;function QN(){if(G_)return Fh;G_=1;var e=yq();function n(i){return i==null?"":e(i)}return Fh=n,Fh}var zh,K_;function du(){if(K_)return zh;K_=1;var e=St(),n=Tv(),i=vq(),s=QN();function o(l,u){return e(l)?l:n(l,u)?[l]:i(s(l))}return zh=o,zh}var Bh,Y_;function fa(){if(Y_)return Bh;Y_=1;var e=Xs();function n(i){if(typeof i=="string"||e(i))return i;var s=i+"";return s=="0"&&1/i==-1/0?"-0":s}return Bh=n,Bh}var Uh,X_;function fu(){if(X_)return Uh;X_=1;var e=du(),n=fa();function i(s,o){o=e(o,s);for(var l=0,u=o.length;s!=null&&l<u;)s=s[n(o[l++])];return l&&l==u?s:void 0}return Uh=i,Uh}var Hh,Q_;function wq(){if(Q_)return Hh;Q_=1;var e=fu();function n(i,s,o){var l=i==null?void 0:e(i,s);return l===void 0?o:l}return Hh=n,Hh}var Vh,Z_;function xq(){if(Z_)return Vh;Z_=1;function e(n,i){return n!=null&&i in Object(n)}return Vh=e,Vh}var Wh,J_;function ZN(){if(J_)return Wh;J_=1;var e=du(),n=ca(),i=St(),s=su(),o=xv(),l=fa();function u(c,p,h){p=e(p,c);for(var f=-1,m=p.length,y=!1;++f<m;){var x=l(p[f]);if(!(y=c!=null&&h(c,x)))break;c=c[x]}return y||++f!=m?y:(m=c==null?0:c.length,!!m&&o(m)&&s(x,m)&&(i(c)||n(c)))}return Wh=u,Wh}var Gh,eS;function JN(){if(eS)return Gh;eS=1;var e=xq(),n=ZN();function i(s,o){return s!=null&&n(s,o,e)}return Gh=i,Gh}var Kh,tS;function _q(){if(tS)return Kh;tS=1;var e=KN(),n=wq(),i=JN(),s=Tv(),o=YN(),l=XN(),u=fa(),c=1,p=2;function h(f,m){return s(f)&&o(m)?l(u(f),m):function(y){var x=n(y,f);return x===void 0&&x===m?i(y,f):e(m,x,c|p)}}return Kh=h,Kh}var Yh,nS;function eC(){if(nS)return Yh;nS=1;function e(n){return function(i){return i==null?void 0:i[n]}}return Yh=e,Yh}var Xh,rS;function Sq(){if(rS)return Xh;rS=1;var e=fu();function n(i){return function(s){return e(s,i)}}return Xh=n,Xh}var Qh,iS;function bq(){if(iS)return Qh;iS=1;var e=eC(),n=Sq(),i=Tv(),s=fa();function o(l){return i(l)?e(s(l)):n(l)}return Qh=o,Qh}var Zh,sS;function Lr(){if(sS)return Zh;sS=1;var e=pq(),n=_q(),i=ns(),s=St(),o=bq();function l(u){return typeof u=="function"?u:u==null?i:typeof u=="object"?s(u)?n(u[0],u[1]):e(u):o(u)}return Zh=l,Zh}var Jh,oS;function tC(){if(oS)return Jh;oS=1;var e=AN(),n=iq(),i=Lr(),s=St();function o(l,u){var c=s(l)?e:n;return c(l,i(u,3))}return Jh=o,Jh}var ep,aS;function kq(){if(aS)return ep;aS=1;var e=Object.prototype,n=e.hasOwnProperty;function i(s,o){return s!=null&&n.call(s,o)}return ep=i,ep}var tp,lS;function nC(){if(lS)return tp;lS=1;var e=kq(),n=ZN();function i(s,o){return s!=null&&n(s,o,e)}return tp=i,tp}var np,uS;function Eq(){if(uS)return np;uS=1;var e=Sv(),n=Ys(),i=ca(),s=St(),o=qr(),l=Ks(),u=au(),c=da(),p="[object Map]",h="[object Set]",f=Object.prototype,m=f.hasOwnProperty;function y(x){if(x==null)return!0;if(o(x)&&(s(x)||typeof x=="string"||typeof x.splice=="function"||l(x)||c(x)||i(x)))return!x.length;var N=n(x);if(N==p||N==h)return!x.size;if(u(x))return!e(x).length;for(var _ in x)if(m.call(x,_))return!1;return!0}return np=y,np}var rp,cS;function rC(){if(cS)return rp;cS=1;function e(n){return n===void 0}return rp=e,rp}var ip,dS;function iC(){if(dS)return ip;dS=1;var e=uu(),n=qr();function i(s,o){var l=-1,u=n(s)?Array(s.length):[];return e(s,function(c,p,h){u[++l]=o(c,p,h)}),u}return ip=i,ip}var sp,fS;function sC(){if(fS)return sp;fS=1;var e=cu(),n=Lr(),i=iC(),s=St();function o(l,u){var c=s(l)?e:i;return c(l,n(u,3))}return sp=o,sp}var op,hS;function Nq(){if(hS)return op;hS=1;function e(n,i,s,o){var l=-1,u=n==null?0:n.length;for(o&&u&&(s=n[++l]);++l<u;)s=i(s,n[l],l,n);return s}return op=e,op}var ap,pS;function Cq(){if(pS)return ap;pS=1;function e(n,i,s,o,l){return l(n,function(u,c,p){s=o?(o=!1,u):i(s,u,c,p)}),s}return ap=e,ap}var lp,mS;function oC(){if(mS)return lp;mS=1;var e=Nq(),n=uu(),i=Lr(),s=Cq(),o=St();function l(u,c,p){var h=o(u)?e:s,f=arguments.length<3;return h(u,i(c,4),p,f,n)}return lp=l,lp}var up,gS;function jq(){if(gS)return up;gS=1;var e=Ji(),n=St(),i=fr(),s="[object String]";function o(l){return typeof l=="string"||!n(l)&&i(l)&&e(l)==s}return up=o,up}var cp,vS;function Rq(){if(vS)return cp;vS=1;var e=eC(),n=e("length");return cp=n,cp}var dp,yS;function Tq(){if(yS)return dp;yS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",i="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+i+s,l="\\ufe0e\\ufe0f",u="\\u200d",c=RegExp("["+u+e+o+l+"]");function p(h){return c.test(h)}return dp=p,dp}var fp,wS;function Aq(){if(wS)return fp;wS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",i="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+i+s,l="\\ufe0e\\ufe0f",u="["+e+"]",c="["+o+"]",p="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+p+")",f="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",x="\\u200d",N=h+"?",_="["+l+"]?",S="(?:"+x+"(?:"+[f,m,y].join("|")+")"+_+N+")*",b=_+N+S,E="(?:"+[f+c+"?",c,m,y,u].join("|")+")",C=RegExp(p+"(?="+p+")|"+E+b,"g");function j(P){for(var O=C.lastIndex=0;C.test(P);)++O;return O}return fp=j,fp}var hp,xS;function Iq(){if(xS)return hp;xS=1;var e=Rq(),n=Tq(),i=Aq();function s(o){return n(o)?i(o):e(o)}return hp=s,hp}var pp,_S;function Mq(){if(_S)return pp;_S=1;var e=Sv(),n=Ys(),i=qr(),s=jq(),o=Iq(),l="[object Map]",u="[object Set]";function c(p){if(p==null)return 0;if(i(p))return s(p)?o(p):p.length;var h=n(p);return h==l||h==u?p.size:e(p).length}return pp=c,pp}var mp,SS;function Pq(){if(SS)return mp;SS=1;var e=wv(),n=DN(),i=jv(),s=Lr(),o=lu(),l=St(),u=Ks(),c=la(),p=On(),h=da();function f(m,y,x){var N=l(m),_=N||u(m)||h(m);if(y=s(y,4),x==null){var S=m&&m.constructor;_?x=N?new S:[]:p(m)?x=c(S)?n(o(m)):{}:x={}}return(_?e:i)(m,function(b,E,C){return y(x,b,E,C)}),x}return mp=f,mp}var gp,bS;function Oq(){if(bS)return gp;bS=1;var e=Gs(),n=ca(),i=St(),s=e?e.isConcatSpreadable:void 0;function o(l){return i(l)||n(l)||!!(s&&l&&l[s])}return gp=o,gp}var vp,kS;function Av(){if(kS)return vp;kS=1;var e=kv(),n=Oq();function i(s,o,l,u,c){var p=-1,h=s.length;for(l||(l=n),c||(c=[]);++p<h;){var f=s[p];o>0&&l(f)?o>1?i(f,o-1,l,u,c):e(c,f):u||(c[c.length]=f)}return c}return vp=i,vp}var yp,ES;function qq(){if(ES)return yp;ES=1;function e(n,i,s){switch(s.length){case 0:return n.call(i);case 1:return n.call(i,s[0]);case 2:return n.call(i,s[0],s[1]);case 3:return n.call(i,s[0],s[1],s[2])}return n.apply(i,s)}return yp=e,yp}var wp,NS;function aC(){if(NS)return wp;NS=1;var e=qq(),n=Math.max;function i(s,o,l){return o=n(o===void 0?s.length-1:o,0),function(){for(var u=arguments,c=-1,p=n(u.length-o,0),h=Array(p);++c<p;)h[c]=u[o+c];c=-1;for(var f=Array(o+1);++c<o;)f[c]=u[c];return f[o]=l(h),e(s,this,f)}}return wp=i,wp}var xp,CS;function Lq(){if(CS)return xp;CS=1;var e=Nv(),n=NN(),i=ns(),s=n?function(o,l){return n(o,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:i;return xp=s,xp}var _p,jS;function $q(){if(jS)return _p;jS=1;var e=800,n=16,i=Date.now;function s(o){var l=0,u=0;return function(){var c=i(),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 _p=s,_p}var Sp,RS;function lC(){if(RS)return Sp;RS=1;var e=Lq(),n=$q(),i=n(e);return Sp=i,Sp}var bp,TS;function hu(){if(TS)return bp;TS=1;var e=ns(),n=aC(),i=lC();function s(o,l){return i(n(o,l,e),o+"")}return bp=s,bp}var kp,AS;function uC(){if(AS)return kp;AS=1;function e(n,i,s,o){for(var l=n.length,u=s+(o?1:-1);o?u--:++u<l;)if(i(n[u],u,n))return u;return-1}return kp=e,kp}var Ep,IS;function Dq(){if(IS)return Ep;IS=1;function e(n){return n!==n}return Ep=e,Ep}var Np,MS;function Fq(){if(MS)return Np;MS=1;function e(n,i,s){for(var o=s-1,l=n.length;++o<l;)if(n[o]===i)return o;return-1}return Np=e,Np}var Cp,PS;function zq(){if(PS)return Cp;PS=1;var e=uC(),n=Dq(),i=Fq();function s(o,l,u){return l===l?i(o,l,u):e(o,n,u)}return Cp=s,Cp}var jp,OS;function Bq(){if(OS)return jp;OS=1;var e=zq();function n(i,s){var o=i==null?0:i.length;return!!o&&e(i,s,0)>-1}return jp=n,jp}var Rp,qS;function Uq(){if(qS)return Rp;qS=1;function e(n,i,s){for(var o=-1,l=n==null?0:n.length;++o<l;)if(s(i,n[o]))return!0;return!1}return Rp=e,Rp}var Tp,LS;function Hq(){if(LS)return Tp;LS=1;function e(){}return Tp=e,Tp}var Ap,$S;function Vq(){if($S)return Ap;$S=1;var e=qN(),n=Hq(),i=Rv(),s=1/0,o=e&&1/i(new e([,-0]))[1]==s?function(l){return new e(l)}:n;return Ap=o,Ap}var Ip,DS;function Wq(){if(DS)return Ip;DS=1;var e=VN(),n=Bq(),i=Uq(),s=WN(),o=Vq(),l=Rv(),u=200;function c(p,h,f){var m=-1,y=n,x=p.length,N=!0,_=[],S=_;if(f)N=!1,y=i;else if(x>=u){var b=h?null:o(p);if(b)return l(b);N=!1,y=s,S=new e}else S=h?[]:_;e:for(;++m<x;){var E=p[m],C=h?h(E):E;if(E=f||E!==0?E:0,N&&C===C){for(var j=S.length;j--;)if(S[j]===C)continue e;h&&S.push(C),_.push(E)}else y(S,C,f)||(S!==_&&S.push(C),_.push(E))}return _}return Ip=c,Ip}var Mp,FS;function cC(){if(FS)return Mp;FS=1;var e=qr(),n=fr();function i(s){return n(s)&&e(s)}return Mp=i,Mp}var Pp,zS;function Gq(){if(zS)return Pp;zS=1;var e=Av(),n=hu(),i=Wq(),s=cC(),o=n(function(l){return i(e(l,1,s,!0))});return Pp=o,Pp}var Op,BS;function Kq(){if(BS)return Op;BS=1;var e=cu();function n(i,s){return e(s,function(o){return i[o]})}return Op=n,Op}var qp,US;function dC(){if(US)return qp;US=1;var e=Kq(),n=yi();function i(s){return s==null?[]:e(s,n(s))}return qp=i,qp}var Lp,HS;function qn(){if(HS)return Lp;HS=1;var e;if(typeof gv=="function")try{e={clone:tq(),constant:Nv(),each:HN(),filter:tC(),has:nC(),isArray:St(),isEmpty:Eq(),isFunction:la(),isUndefined:rC(),keys:yi(),map:sC(),reduce:oC(),size:Mq(),transform:Pq(),union:Gq(),values:dC()}}catch{}return e||(e=window._),Lp=e,Lp}var $p,VS;function Iv(){if(VS)return $p;VS=1;var e=qn();$p=o;var n="\0",i="\0",s="";function o(f){this._isDirected=e.has(f,"directed")?f.directed:!0,this._isMultigraph=e.has(f,"multigraph")?f.multigraph:!1,this._isCompound=e.has(f,"compound")?f.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[i]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(f){return this._label=f,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultNodeLabelFn=f,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var f=this;return e.filter(this.nodes(),function(m){return e.isEmpty(f._in[m])})},o.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(m){return e.isEmpty(f._out[m])})},o.prototype.setNodes=function(f,m){var y=arguments,x=this;return e.each(f,function(N){y.length>1?x.setNode(N,m):x.setNode(N)}),this},o.prototype.setNode=function(f,m){return e.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=m),this):(this._nodes[f]=arguments.length>1?m:this._defaultNodeLabelFn(f),this._isCompound&&(this._parent[f]=i,this._children[f]={},this._children[i][f]=!0),this._in[f]={},this._preds[f]={},this._out[f]={},this._sucs[f]={},++this._nodeCount,this)},o.prototype.node=function(f){return this._nodes[f]},o.prototype.hasNode=function(f){return e.has(this._nodes,f)},o.prototype.removeNode=function(f){var m=this;if(e.has(this._nodes,f)){var y=function(x){m.removeEdge(m._edgeObjs[x])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(x){m.setParent(x)}),delete this._children[f]),e.each(e.keys(this._in[f]),y),delete this._in[f],delete this._preds[f],e.each(e.keys(this._out[f]),y),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},o.prototype.setParent=function(f,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(m))m=i;else{m+="";for(var y=m;!e.isUndefined(y);y=this.parent(y))if(y===f)throw new Error("Setting "+m+" as parent of "+f+" would create a cycle");this.setNode(m)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=m,this._children[m][f]=!0,this},o.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},o.prototype.parent=function(f){if(this._isCompound){var m=this._parent[f];if(m!==i)return m}},o.prototype.children=function(f){if(e.isUndefined(f)&&(f=i),this._isCompound){var m=this._children[f];if(m)return e.keys(m)}else{if(f===i)return this.nodes();if(this.hasNode(f))return[]}},o.prototype.predecessors=function(f){var m=this._preds[f];if(m)return e.keys(m)},o.prototype.successors=function(f){var m=this._sucs[f];if(m)return e.keys(m)},o.prototype.neighbors=function(f){var m=this.predecessors(f);if(m)return e.union(m,this.successors(f))},o.prototype.isLeaf=function(f){var m;return this.isDirected()?m=this.successors(f):m=this.neighbors(f),m.length===0},o.prototype.filterNodes=function(f){var m=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});m.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,S){f(S)&&m.setNode(S,_)}),e.each(this._edgeObjs,function(_){m.hasNode(_.v)&&m.hasNode(_.w)&&m.setEdge(_,y.edge(_))});var x={};function N(_){var S=y.parent(_);return S===void 0||m.hasNode(S)?(x[_]=S,S):S in x?x[S]:N(S)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,N(_))}),m},o.prototype.setDefaultEdgeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultEdgeLabelFn=f,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(f,m){var y=this,x=arguments;return e.reduce(f,function(N,_){return x.length>1?y.setEdge(N,_,m):y.setEdge(N,_),_}),this},o.prototype.setEdge=function(){var f,m,y,x,N=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(f=_.v,m=_.w,y=_.name,arguments.length===2&&(x=arguments[1],N=!0)):(f=_,m=arguments[1],y=arguments[3],arguments.length>2&&(x=arguments[2],N=!0)),f=""+f,m=""+m,e.isUndefined(y)||(y=""+y);var S=c(this._isDirected,f,m,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(m),this._edgeLabels[S]=N?x:this._defaultEdgeLabelFn(f,m,y);var b=p(this._isDirected,f,m,y);return f=b.v,m=b.w,Object.freeze(b),this._edgeObjs[S]=b,l(this._preds[m],f),l(this._sucs[f],m),this._in[m][S]=b,this._out[f][S]=b,this._edgeCount++,this},o.prototype.edge=function(f,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,m,y);return this._edgeLabels[x]},o.prototype.hasEdge=function(f,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,m,y);return e.has(this._edgeLabels,x)},o.prototype.removeEdge=function(f,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,m,y),N=this._edgeObjs[x];return N&&(f=N.v,m=N.w,delete this._edgeLabels[x],delete this._edgeObjs[x],u(this._preds[m],f),u(this._sucs[f],m),delete this._in[m][x],delete this._out[f][x],this._edgeCount--),this},o.prototype.inEdges=function(f,m){var y=this._in[f];if(y){var x=e.values(y);return m?e.filter(x,function(N){return N.v===m}):x}},o.prototype.outEdges=function(f,m){var y=this._out[f];if(y){var x=e.values(y);return m?e.filter(x,function(N){return N.w===m}):x}},o.prototype.nodeEdges=function(f,m){var y=this.inEdges(f,m);if(y)return y.concat(this.outEdges(f,m))};function l(f,m){f[m]?f[m]++:f[m]=1}function u(f,m){--f[m]||delete f[m]}function c(f,m,y,x){var N=""+m,_=""+y;if(!f&&N>_){var S=N;N=_,_=S}return N+s+_+s+(e.isUndefined(x)?n:x)}function p(f,m,y,x){var N=""+m,_=""+y;if(!f&&N>_){var S=N;N=_,_=S}var b={v:N,w:_};return x&&(b.name=x),b}function h(f,m){return c(f,m.v,m.w,m.name)}return $p}var Dp,WS;function Yq(){return WS||(WS=1,Dp="2.1.8"),Dp}var Fp,GS;function Xq(){return GS||(GS=1,Fp={Graph:Iv(),version:Yq()}),Fp}var zp,KS;function Qq(){if(KS)return zp;KS=1;var e=qn(),n=Iv();zp={write:i,read:l};function i(u){var c={options:{directed:u.isDirected(),multigraph:u.isMultigraph(),compound:u.isCompound()},nodes:s(u),edges:o(u)};return e.isUndefined(u.graph())||(c.value=e.clone(u.graph())),c}function s(u){return e.map(u.nodes(),function(c){var p=u.node(c),h=u.parent(c),f={v:c};return e.isUndefined(p)||(f.value=p),e.isUndefined(h)||(f.parent=h),f})}function o(u){return e.map(u.edges(),function(c){var p=u.edge(c),h={v:c.v,w:c.w};return e.isUndefined(c.name)||(h.name=c.name),e.isUndefined(p)||(h.value=p),h})}function l(u){var c=new n(u.options).setGraph(u.value);return e.each(u.nodes,function(p){c.setNode(p.v,p.value),p.parent&&c.setParent(p.v,p.parent)}),e.each(u.edges,function(p){c.setEdge({v:p.v,w:p.w,name:p.name},p.value)}),c}return zp}var Bp,YS;function Zq(){if(YS)return Bp;YS=1;var e=qn();Bp=n;function n(i){var s={},o=[],l;function u(c){e.has(s,c)||(s[c]=!0,l.push(c),e.each(i.successors(c),u),e.each(i.predecessors(c),u))}return e.each(i.nodes(),function(c){l=[],u(c),l.length&&o.push(l)}),o}return Bp}var Up,XS;function fC(){if(XS)return Up;XS=1;var e=qn();Up=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(i){return i.key})},n.prototype.has=function(i){return e.has(this._keyIndices,i)},n.prototype.priority=function(i){var s=this._keyIndices[i];if(s!==void 0)return this._arr[s].priority},n.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},n.prototype.add=function(i,s){var o=this._keyIndices;if(i=String(i),!e.has(o,i)){var l=this._arr,u=l.length;return o[i]=u,l.push({key:i,priority:s}),this._decrease(u),!0}return!1},n.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var i=this._arr.pop();return delete this._keyIndices[i.key],this._heapify(0),i.key},n.prototype.decrease=function(i,s){var o=this._keyIndices[i];if(s>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+i+" Old: "+this._arr[o].priority+" New: "+s);this._arr[o].priority=s,this._decrease(o)},n.prototype._heapify=function(i){var s=this._arr,o=2*i,l=o+1,u=i;o<s.length&&(u=s[o].priority<s[u].priority?o:u,l<s.length&&(u=s[l].priority<s[u].priority?l:u),u!==i&&(this._swap(i,u),this._heapify(u)))},n.prototype._decrease=function(i){for(var s=this._arr,o=s[i].priority,l;i!==0&&(l=i>>1,!(s[l].priority<o));)this._swap(i,l),i=l},n.prototype._swap=function(i,s){var o=this._arr,l=this._keyIndices,u=o[i],c=o[s];o[i]=c,o[s]=u,l[c.key]=i,l[u.key]=s},Up}var Hp,QS;function hC(){if(QS)return Hp;QS=1;var e=qn(),n=fC();Hp=s;var i=e.constant(1);function s(l,u,c,p){return o(l,String(u),c||i,p||function(h){return l.outEdges(h)})}function o(l,u,c,p){var h={},f=new n,m,y,x=function(N){var _=N.v!==m?N.v:N.w,S=h[_],b=c(N),E=y.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+N+" Weight: "+b);E<S.distance&&(S.distance=E,S.predecessor=m,f.decrease(_,E))};for(l.nodes().forEach(function(N){var _=N===u?0:Number.POSITIVE_INFINITY;h[N]={distance:_},f.add(N,_)});f.size()>0&&(m=f.removeMin(),y=h[m],y.distance!==Number.POSITIVE_INFINITY);)p(m).forEach(x);return h}return Hp}var Vp,ZS;function Jq(){if(ZS)return Vp;ZS=1;var e=hC(),n=qn();Vp=i;function i(s,o,l){return n.transform(s.nodes(),function(u,c){u[c]=e(s,c,o,l)},{})}return Vp}var Wp,JS;function pC(){if(JS)return Wp;JS=1;var e=qn();Wp=n;function n(i){var s=0,o=[],l={},u=[];function c(p){var h=l[p]={onStack:!0,lowlink:s,index:s++};if(o.push(p),i.successors(p).forEach(function(y){e.has(l,y)?l[y].onStack&&(h.lowlink=Math.min(h.lowlink,l[y].index)):(c(y),h.lowlink=Math.min(h.lowlink,l[y].lowlink))}),h.lowlink===h.index){var f=[],m;do m=o.pop(),l[m].onStack=!1,f.push(m);while(p!==m);u.push(f)}}return i.nodes().forEach(function(p){e.has(l,p)||c(p)}),u}return Wp}var Gp,eb;function eL(){if(eb)return Gp;eb=1;var e=qn(),n=pC();Gp=i;function i(s){return e.filter(n(s),function(o){return o.length>1||o.length===1&&s.hasEdge(o[0],o[0])})}return Gp}var Kp,tb;function tL(){if(tb)return Kp;tb=1;var e=qn();Kp=i;var n=e.constant(1);function i(o,l,u){return s(o,l||n,u||function(c){return o.outEdges(c)})}function s(o,l,u){var c={},p=o.nodes();return p.forEach(function(h){c[h]={},c[h][h]={distance:0},p.forEach(function(f){h!==f&&(c[h][f]={distance:Number.POSITIVE_INFINITY})}),u(h).forEach(function(f){var m=f.v===h?f.w:f.v,y=l(f);c[h][m]={distance:y,predecessor:h}})}),p.forEach(function(h){var f=c[h];p.forEach(function(m){var y=c[m];p.forEach(function(x){var N=y[h],_=f[x],S=y[x],b=N.distance+_.distance;b<S.distance&&(S.distance=b,S.predecessor=_.predecessor)})})}),c}return Kp}var Yp,nb;function mC(){if(nb)return Yp;nb=1;var e=qn();Yp=n,n.CycleException=i;function n(s){var o={},l={},u=[];function c(p){if(e.has(l,p))throw new i;e.has(o,p)||(l[p]=!0,o[p]=!0,e.each(s.predecessors(p),c),delete l[p],u.push(p))}if(e.each(s.sinks(),c),e.size(o)!==s.nodeCount())throw new i;return u}function i(){}return i.prototype=new Error,Yp}var Xp,rb;function nL(){if(rb)return Xp;rb=1;var e=mC();Xp=n;function n(i){try{e(i)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return Xp}var Qp,ib;function gC(){if(ib)return Qp;ib=1;var e=qn();Qp=n;function n(s,o,l){e.isArray(o)||(o=[o]);var u=(s.isDirected()?s.successors:s.neighbors).bind(s),c=[],p={};return e.each(o,function(h){if(!s.hasNode(h))throw new Error("Graph does not have node: "+h);i(s,h,l==="post",p,u,c)}),c}function i(s,o,l,u,c,p){e.has(u,o)||(u[o]=!0,l||p.push(o),e.each(c(o),function(h){i(s,h,l,u,c,p)}),l&&p.push(o))}return Qp}var Zp,sb;function rL(){if(sb)return Zp;sb=1;var e=gC();Zp=n;function n(i,s){return e(i,s,"post")}return Zp}var Jp,ob;function iL(){if(ob)return Jp;ob=1;var e=gC();Jp=n;function n(i,s){return e(i,s,"pre")}return Jp}var em,ab;function sL(){if(ab)return em;ab=1;var e=qn(),n=Iv(),i=fC();em=s;function s(o,l){var u=new n,c={},p=new i,h;function f(y){var x=y.v===h?y.w:y.v,N=p.priority(x);if(N!==void 0){var _=l(y);_<N&&(c[x]=h,p.decrease(x,_))}}if(o.nodeCount()===0)return u;e.each(o.nodes(),function(y){p.add(y,Number.POSITIVE_INFINITY),u.setNode(y)}),p.decrease(o.nodes()[0],0);for(var m=!1;p.size()>0;){if(h=p.removeMin(),e.has(c,h))u.setEdge(h,c[h]);else{if(m)throw new Error("Input graph is not connected: "+o);m=!0}o.nodeEdges(h).forEach(f)}return u}return em}var tm,lb;function oL(){return lb||(lb=1,tm={components:Zq(),dijkstra:hC(),dijkstraAll:Jq(),findCycles:eL(),floydWarshall:tL(),isAcyclic:nL(),postorder:rL(),preorder:iL(),prim:sL(),tarjan:pC(),topsort:mC()}),tm}var nm,ub;function aL(){if(ub)return nm;ub=1;var e=Xq();return nm={Graph:e.Graph,json:Qq(),alg:oL(),version:e.version},nm}var rm,cb;function Qn(){if(cb)return rm;cb=1;var e;if(typeof gv=="function")try{e=aL()}catch{}return e||(e=window.graphlib),rm=e,rm}var im,db;function lL(){if(db)return im;db=1;var e=zN(),n=1,i=4;function s(o){return e(o,n|i)}return im=s,im}var sm,fb;function pu(){if(fb)return sm;fb=1;var e=Ws(),n=qr(),i=su(),s=On();function o(l,u,c){if(!s(c))return!1;var p=typeof u;return(p=="number"?n(c)&&i(u,c.length):p=="string"&&u in c)?e(c[u],l):!1}return sm=o,sm}var om,hb;function uL(){if(hb)return om;hb=1;var e=hu(),n=Ws(),i=pu(),s=ts(),o=Object.prototype,l=o.hasOwnProperty,u=e(function(c,p){c=Object(c);var h=-1,f=p.length,m=f>2?p[2]:void 0;for(m&&i(p[0],p[1],m)&&(f=1);++h<f;)for(var y=p[h],x=s(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 om=u,om}var am,pb;function cL(){if(pb)return am;pb=1;var e=Lr(),n=qr(),i=yi();function s(o){return function(l,u,c){var p=Object(l);if(!n(l)){var h=e(u,3);l=i(l),u=function(m){return h(p[m],m,p)}}var f=o(l,u,c);return f>-1?p[h?l[f]:f]:void 0}}return am=s,am}var lm,mb;function dL(){if(mb)return lm;mb=1;var e=/\s/;function n(i){for(var s=i.length;s--&&e.test(i.charAt(s)););return s}return lm=n,lm}var um,gb;function fL(){if(gb)return um;gb=1;var e=dL(),n=/^\s+/;function i(s){return s&&s.slice(0,e(s)+1).replace(n,"")}return um=i,um}var cm,vb;function hL(){if(vb)return cm;vb=1;var e=fL(),n=On(),i=Xs(),s=NaN,o=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;function p(h){if(typeof h=="number")return h;if(i(h))return s;if(n(h)){var f=typeof h.valueOf=="function"?h.valueOf():h;h=n(f)?f+"":f}if(typeof h!="string")return h===0?h:+h;h=e(h);var m=l.test(h);return m||u.test(h)?c(h.slice(2),m?2:8):o.test(h)?s:+h}return cm=p,cm}var dm,yb;function vC(){if(yb)return dm;yb=1;var e=hL(),n=1/0,i=17976931348623157e292;function s(o){if(!o)return o===0?o:0;if(o=e(o),o===n||o===-n){var l=o<0?-1:1;return l*i}return o===o?o:0}return dm=s,dm}var fm,wb;function pL(){if(wb)return fm;wb=1;var e=vC();function n(i){var s=e(i),o=s%1;return s===s?o?s-o:s:0}return fm=n,fm}var hm,xb;function mL(){if(xb)return hm;xb=1;var e=uC(),n=Lr(),i=pL(),s=Math.max;function o(l,u,c){var p=l==null?0:l.length;if(!p)return-1;var h=c==null?0:i(c);return h<0&&(h=s(p+h,0)),e(l,n(u,3),h)}return hm=o,hm}var pm,_b;function gL(){if(_b)return pm;_b=1;var e=cL(),n=mL(),i=e(n);return pm=i,pm}var mm,Sb;function yC(){if(Sb)return mm;Sb=1;var e=Av();function n(i){var s=i==null?0:i.length;return s?e(i,1):[]}return mm=n,mm}var gm,bb;function vL(){if(bb)return gm;bb=1;var e=Cv(),n=BN(),i=ts();function s(o,l){return o==null?o:e(o,n(l),i)}return gm=s,gm}var vm,kb;function yL(){if(kb)return vm;kb=1;function e(n){var i=n==null?0:n.length;return i?n[i-1]:void 0}return vm=e,vm}var ym,Eb;function wL(){if(Eb)return ym;Eb=1;var e=ru(),n=jv(),i=Lr();function s(o,l){var u={};return l=i(l,3),n(o,function(c,p,h){e(u,p,l(c,p,h))}),u}return ym=s,ym}var wm,Nb;function Mv(){if(Nb)return wm;Nb=1;var e=Xs();function n(i,s,o){for(var l=-1,u=i.length;++l<u;){var c=i[l],p=s(c);if(p!=null&&(h===void 0?p===p&&!e(p):o(p,h)))var h=p,f=c}return f}return wm=n,wm}var xm,Cb;function xL(){if(Cb)return xm;Cb=1;function e(n,i){return n>i}return xm=e,xm}var _m,jb;function _L(){if(jb)return _m;jb=1;var e=Mv(),n=xL(),i=ns();function s(o){return o&&o.length?e(o,i,n):void 0}return _m=s,_m}var Sm,Rb;function wC(){if(Rb)return Sm;Rb=1;var e=ru(),n=Ws();function i(s,o,l){(l!==void 0&&!n(s[o],l)||l===void 0&&!(o in s))&&e(s,o,l)}return Sm=i,Sm}var bm,Tb;function SL(){if(Tb)return bm;Tb=1;var e=Ji(),n=lu(),i=fr(),s="[object Object]",o=Function.prototype,l=Object.prototype,u=o.toString,c=l.hasOwnProperty,p=u.call(Object);function h(f){if(!i(f)||e(f)!=s)return!1;var m=n(f);if(m===null)return!0;var y=c.call(m,"constructor")&&m.constructor;return typeof y=="function"&&y instanceof y&&u.call(y)==p}return bm=h,bm}var km,Ab;function xC(){if(Ab)return km;Ab=1;function e(n,i){if(!(i==="constructor"&&typeof n[i]=="function")&&i!="__proto__")return n[i]}return km=e,km}var Em,Ib;function bL(){if(Ib)return Em;Ib=1;var e=ua(),n=ts();function i(s){return e(s,n(s))}return Em=i,Em}var Nm,Mb;function kL(){if(Mb)return Nm;Mb=1;var e=wC(),n=RN(),i=$N(),s=TN(),o=FN(),l=ca(),u=St(),c=cC(),p=Ks(),h=la(),f=On(),m=SL(),y=da(),x=xC(),N=bL();function _(S,b,E,C,j,P,O){var q=x(S,E),B=x(b,E),T=O.get(B);if(T){e(S,E,T);return}var M=P?P(q,B,E+"",S,b,O):void 0,F=M===void 0;if(F){var X=u(B),Y=!X&&p(B),I=!X&&!Y&&y(B);M=B,X||Y||I?u(q)?M=q:c(q)?M=s(q):Y?(F=!1,M=n(B,!0)):I?(F=!1,M=i(B,!0)):M=[]:m(B)||l(B)?(M=q,l(q)?M=N(q):(!f(q)||h(q))&&(M=o(B))):F=!1}F&&(O.set(B,M),j(M,B,C,P,O),O.delete(B)),e(S,E,M)}return Nm=_,Nm}var Cm,Pb;function EL(){if(Pb)return Cm;Pb=1;var e=nu(),n=wC(),i=Cv(),s=kL(),o=On(),l=ts(),u=xC();function c(p,h,f,m,y){p!==h&&i(h,function(x,N){if(y||(y=new e),o(x))s(p,h,N,f,c,m,y);else{var _=m?m(u(p,N),x,N+"",p,h,y):void 0;_===void 0&&(_=x),n(p,N,_)}},l)}return Cm=c,Cm}var jm,Ob;function NL(){if(Ob)return jm;Ob=1;var e=hu(),n=pu();function i(s){return e(function(o,l){var u=-1,c=l.length,p=c>1?l[c-1]:void 0,h=c>2?l[2]:void 0;for(p=s.length>3&&typeof p=="function"?(c--,p):void 0,h&&n(l[0],l[1],h)&&(p=c<3?void 0:p,c=1),o=Object(o);++u<c;){var f=l[u];f&&s(o,f,u,p)}return o})}return jm=i,jm}var Rm,qb;function CL(){if(qb)return Rm;qb=1;var e=EL(),n=NL(),i=n(function(s,o,l){e(s,o,l)});return Rm=i,Rm}var Tm,Lb;function _C(){if(Lb)return Tm;Lb=1;function e(n,i){return n<i}return Tm=e,Tm}var Am,$b;function jL(){if($b)return Am;$b=1;var e=Mv(),n=_C(),i=ns();function s(o){return o&&o.length?e(o,i,n):void 0}return Am=s,Am}var Im,Db;function RL(){if(Db)return Im;Db=1;var e=Mv(),n=Lr(),i=_C();function s(o,l){return o&&o.length?e(o,n(l,2),i):void 0}return Im=s,Im}var Mm,Fb;function TL(){if(Fb)return Mm;Fb=1;var e=Jn(),n=function(){return e.Date.now()};return Mm=n,Mm}var Pm,zb;function AL(){if(zb)return Pm;zb=1;var e=iu(),n=du(),i=su(),s=On(),o=fa();function l(u,c,p,h){if(!s(u))return u;c=n(c,u);for(var f=-1,m=c.length,y=m-1,x=u;x!=null&&++f<m;){var N=o(c[f]),_=p;if(N==="__proto__"||N==="constructor"||N==="prototype")return u;if(f!=y){var S=x[N];_=h?h(S,N,x):void 0,_===void 0&&(_=s(S)?S:i(c[f+1])?[]:{})}e(x,N,_),x=x[N]}return u}return Pm=l,Pm}var Om,Bb;function IL(){if(Bb)return Om;Bb=1;var e=fu(),n=AL(),i=du();function s(o,l,u){for(var c=-1,p=l.length,h={};++c<p;){var f=l[c],m=e(o,f);u(m,f)&&n(h,i(f,o),m)}return h}return Om=s,Om}var qm,Ub;function ML(){if(Ub)return qm;Ub=1;var e=IL(),n=JN();function i(s,o){return e(s,o,function(l,u){return n(s,u)})}return qm=i,qm}var Lm,Hb;function PL(){if(Hb)return Lm;Hb=1;var e=yC(),n=aC(),i=lC();function s(o){return i(n(o,void 0,e),o+"")}return Lm=s,Lm}var $m,Vb;function OL(){if(Vb)return $m;Vb=1;var e=ML(),n=PL(),i=n(function(s,o){return s==null?{}:e(s,o)});return $m=i,$m}var Dm,Wb;function qL(){if(Wb)return Dm;Wb=1;var e=Math.ceil,n=Math.max;function i(s,o,l,u){for(var c=-1,p=n(e((o-s)/(l||1)),0),h=Array(p);p--;)h[u?p:++c]=s,s+=l;return h}return Dm=i,Dm}var Fm,Gb;function LL(){if(Gb)return Fm;Gb=1;var e=qL(),n=pu(),i=vC();function s(o){return function(l,u,c){return c&&typeof c!="number"&&n(l,u,c)&&(u=c=void 0),l=i(l),u===void 0?(u=l,l=0):u=i(u),c=c===void 0?l<u?1:-1:i(c),e(l,u,c,o)}}return Fm=s,Fm}var zm,Kb;function $L(){if(Kb)return zm;Kb=1;var e=LL(),n=e();return zm=n,zm}var Bm,Yb;function DL(){if(Yb)return Bm;Yb=1;function e(n,i){var s=n.length;for(n.sort(i);s--;)n[s]=n[s].value;return n}return Bm=e,Bm}var Um,Xb;function FL(){if(Xb)return Um;Xb=1;var e=Xs();function n(i,s){if(i!==s){var o=i!==void 0,l=i===null,u=i===i,c=e(i),p=s!==void 0,h=s===null,f=s===s,m=e(s);if(!h&&!m&&!c&&i>s||c&&p&&f&&!h&&!m||l&&p&&f||!o&&f||!u)return 1;if(!l&&!c&&!m&&i<s||m&&o&&u&&!l&&!c||h&&o&&u||!p&&u||!f)return-1}return 0}return Um=n,Um}var Hm,Qb;function zL(){if(Qb)return Hm;Qb=1;var e=FL();function n(i,s,o){for(var l=-1,u=i.criteria,c=s.criteria,p=u.length,h=o.length;++l<p;){var f=e(u[l],c[l]);if(f){if(l>=h)return f;var m=o[l];return f*(m=="desc"?-1:1)}}return i.index-s.index}return Hm=n,Hm}var Vm,Zb;function BL(){if(Zb)return Vm;Zb=1;var e=cu(),n=fu(),i=Lr(),s=iC(),o=DL(),l=ou(),u=zL(),c=ns(),p=St();function h(f,m,y){m.length?m=e(m,function(_){return p(_)?function(S){return n(S,_.length===1?_[0]:_)}:_}):m=[c];var x=-1;m=e(m,l(i));var N=s(f,function(_,S,b){var E=e(m,function(C){return C(_)});return{criteria:E,index:++x,value:_}});return o(N,function(_,S){return u(_,S,y)})}return Vm=h,Vm}var Wm,Jb;function UL(){if(Jb)return Wm;Jb=1;var e=Av(),n=BL(),i=hu(),s=pu(),o=i(function(l,u){if(l==null)return[];var c=u.length;return c>1&&s(l,u[0],u[1])?u=[]:c>2&&s(u[0],u[1],u[2])&&(u=[u[0]]),n(l,e(u,1),[])});return Wm=o,Wm}var Gm,ek;function HL(){if(ek)return Gm;ek=1;var e=QN(),n=0;function i(s){var o=++n;return e(s)+o}return Gm=i,Gm}var Km,tk;function VL(){if(tk)return Km;tk=1;function e(n,i,s){for(var o=-1,l=n.length,u=i.length,c={};++o<l;){var p=o<u?i[o]:void 0;s(c,n[o],p)}return c}return Km=e,Km}var Ym,nk;function WL(){if(nk)return Ym;nk=1;var e=iu(),n=VL();function i(s,o){return n(s||[],o||[],e)}return Ym=i,Ym}var Xm,rk;function ot(){if(rk)return Xm;rk=1;var e;if(typeof gv=="function")try{e={cloneDeep:lL(),constant:Nv(),defaults:uL(),each:HN(),filter:tC(),find:gL(),flatten:yC(),forEach:UN(),forIn:vL(),has:nC(),isUndefined:rC(),last:yL(),map:sC(),mapValues:wL(),max:_L(),merge:CL(),min:jL(),minBy:RL(),now:TL(),pick:OL(),range:$L(),reduce:oC(),sortBy:UL(),uniqueId:HL(),values:dC(),zipObject:WL()}}catch{}return e||(e=window._),Xm=e,Xm}var Qm,ik;function GL(){if(ik)return Qm;ik=1,Qm=e;function e(){var s={};s._next=s._prev=s,this._sentinel=s}e.prototype.dequeue=function(){var s=this._sentinel,o=s._prev;if(o!==s)return n(o),o},e.prototype.enqueue=function(s){var o=this._sentinel;s._prev&&s._next&&n(s),s._next=o._next,o._next._prev=s,o._next=s,s._prev=o},e.prototype.toString=function(){for(var s=[],o=this._sentinel,l=o._prev;l!==o;)s.push(JSON.stringify(l,i)),l=l._prev;return"["+s.join(", ")+"]"};function n(s){s._prev._next=s._next,s._next._prev=s._prev,delete s._next,delete s._prev}function i(s,o){if(s!=="_next"&&s!=="_prev")return o}return Qm}var Zm,sk;function KL(){if(sk)return Zm;sk=1;var e=ot(),n=Qn().Graph,i=GL();Zm=o;var s=e.constant(1);function o(h,f){if(h.nodeCount()<=1)return[];var m=c(h,f||s),y=l(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(x){return h.outEdges(x.v,x.w)}),!0)}function l(h,f,m){for(var y=[],x=f[f.length-1],N=f[0],_;h.nodeCount();){for(;_=N.dequeue();)u(h,f,m,_);for(;_=x.dequeue();)u(h,f,m,_);if(h.nodeCount()){for(var S=f.length-2;S>0;--S)if(_=f[S].dequeue(),_){y=y.concat(u(h,f,m,_,!0));break}}}return y}function u(h,f,m,y,x){var N=x?[]:void 0;return e.forEach(h.inEdges(y.v),function(_){var S=h.edge(_),b=h.node(_.v);x&&N.push({v:_.v,w:_.w}),b.out-=S,p(f,m,b)}),e.forEach(h.outEdges(y.v),function(_){var S=h.edge(_),b=_.w,E=h.node(b);E.in-=S,p(f,m,E)}),h.removeNode(y.v),N}function c(h,f){var m=new n,y=0,x=0;e.forEach(h.nodes(),function(S){m.setNode(S,{v:S,in:0,out:0})}),e.forEach(h.edges(),function(S){var b=m.edge(S.v,S.w)||0,E=f(S),C=b+E;m.setEdge(S.v,S.w,C),x=Math.max(x,m.node(S.v).out+=E),y=Math.max(y,m.node(S.w).in+=E)});var N=e.range(x+y+3).map(function(){return new i}),_=y+1;return e.forEach(m.nodes(),function(S){p(N,_,m.node(S))}),{graph:m,buckets:N,zeroIdx:_}}function p(h,f,m){m.out?m.in?h[m.out-m.in+f].enqueue(m):h[h.length-1].enqueue(m):h[0].enqueue(m)}return Zm}var Jm,ok;function YL(){if(ok)return Jm;ok=1;var e=ot(),n=KL();Jm={run:i,undo:o};function i(l){var u=l.graph().acyclicer==="greedy"?n(l,c(l)):s(l);e.forEach(u,function(p){var h=l.edge(p);l.removeEdge(p),h.forwardName=p.name,h.reversed=!0,l.setEdge(p.w,p.v,h,e.uniqueId("rev"))});function c(p){return function(h){return p.edge(h).weight}}}function s(l){var u=[],c={},p={};function h(f){e.has(p,f)||(p[f]=!0,c[f]=!0,e.forEach(l.outEdges(f),function(m){e.has(c,m.w)?u.push(m):h(m.w)}),delete c[f])}return e.forEach(l.nodes(),h),u}function o(l){e.forEach(l.edges(),function(u){var c=l.edge(u);if(c.reversed){l.removeEdge(u);var p=c.forwardName;delete c.reversed,delete c.forwardName,l.setEdge(u.w,u.v,c,p)}})}return Jm}var eg,ak;function fn(){if(ak)return eg;ak=1;var e=ot(),n=Qn().Graph;eg={addDummyNode:i,simplify:s,asNonCompoundGraph:o,successorWeights:l,predecessorWeights:u,intersectRect:c,buildLayerMatrix:p,normalizeRanks:h,removeEmptyRanks:f,addBorderNode:m,maxRank:y,partition:x,time:N,notime:_};function i(S,b,E,C){var j;do j=e.uniqueId(C);while(S.hasNode(j));return E.dummy=b,S.setNode(j,E),j}function s(S){var b=new n().setGraph(S.graph());return e.forEach(S.nodes(),function(E){b.setNode(E,S.node(E))}),e.forEach(S.edges(),function(E){var C=b.edge(E.v,E.w)||{weight:0,minlen:1},j=S.edge(E);b.setEdge(E.v,E.w,{weight:C.weight+j.weight,minlen:Math.max(C.minlen,j.minlen)})}),b}function o(S){var b=new n({multigraph:S.isMultigraph()}).setGraph(S.graph());return e.forEach(S.nodes(),function(E){S.children(E).length||b.setNode(E,S.node(E))}),e.forEach(S.edges(),function(E){b.setEdge(E,S.edge(E))}),b}function l(S){var b=e.map(S.nodes(),function(E){var C={};return e.forEach(S.outEdges(E),function(j){C[j.w]=(C[j.w]||0)+S.edge(j).weight}),C});return e.zipObject(S.nodes(),b)}function u(S){var b=e.map(S.nodes(),function(E){var C={};return e.forEach(S.inEdges(E),function(j){C[j.v]=(C[j.v]||0)+S.edge(j).weight}),C});return e.zipObject(S.nodes(),b)}function c(S,b){var E=S.x,C=S.y,j=b.x-E,P=b.y-C,O=S.width/2,q=S.height/2;if(!j&&!P)throw new Error("Not possible to find intersection inside of the rectangle");var B,T;return Math.abs(P)*O>Math.abs(j)*q?(P<0&&(q=-q),B=q*j/P,T=q):(j<0&&(O=-O),B=O,T=O*P/j),{x:E+B,y:C+T}}function p(S){var b=e.map(e.range(y(S)+1),function(){return[]});return e.forEach(S.nodes(),function(E){var C=S.node(E),j=C.rank;e.isUndefined(j)||(b[j][C.order]=E)}),b}function h(S){var b=e.min(e.map(S.nodes(),function(E){return S.node(E).rank}));e.forEach(S.nodes(),function(E){var C=S.node(E);e.has(C,"rank")&&(C.rank-=b)})}function f(S){var b=e.min(e.map(S.nodes(),function(P){return S.node(P).rank})),E=[];e.forEach(S.nodes(),function(P){var O=S.node(P).rank-b;E[O]||(E[O]=[]),E[O].push(P)});var C=0,j=S.graph().nodeRankFactor;e.forEach(E,function(P,O){e.isUndefined(P)&&O%j!==0?--C:C&&e.forEach(P,function(q){S.node(q).rank+=C})})}function m(S,b,E,C){var j={width:0,height:0};return arguments.length>=4&&(j.rank=E,j.order=C),i(S,"border",j,b)}function y(S){return e.max(e.map(S.nodes(),function(b){var E=S.node(b).rank;if(!e.isUndefined(E))return E}))}function x(S,b){var E={lhs:[],rhs:[]};return e.forEach(S,function(C){b(C)?E.lhs.push(C):E.rhs.push(C)}),E}function N(S,b){var E=e.now();try{return b()}finally{console.log(S+" time: "+(e.now()-E)+"ms")}}function _(S,b){return b()}return eg}var tg,lk;function XL(){if(lk)return tg;lk=1;var e=ot(),n=fn();tg={run:i,undo:o};function i(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(u){s(l,u)})}function s(l,u){var c=u.v,p=l.node(c).rank,h=u.w,f=l.node(h).rank,m=u.name,y=l.edge(u),x=y.labelRank;if(f!==p+1){l.removeEdge(u);var N,_,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},m),S===0&&l.graph().dummyChains.push(N),c=N;l.setEdge(c,h,{weight:y.weight},m)}}function o(l){e.forEach(l.graph().dummyChains,function(u){var c=l.node(u),p=c.edgeLabel,h;for(l.setEdge(c.edgeObj,p);c.dummy;)h=l.successors(u)[0],l.removeNode(u),p.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(p.x=c.x,p.y=c.y,p.width=c.width,p.height=c.height),u=h,c=l.node(u)})}return tg}var ng,uk;function Hl(){if(uk)return ng;uk=1;var e=ot();ng={longestPath:n,slack:i};function n(s){var o={};function l(u){var c=s.node(u);if(e.has(o,u))return c.rank;o[u]=!0;var p=e.min(e.map(s.outEdges(u),function(h){return l(h.w)-s.edge(h).minlen}));return(p===Number.POSITIVE_INFINITY||p===void 0||p===null)&&(p=0),c.rank=p}e.forEach(s.sources(),l)}function i(s,o){return s.node(o.w).rank-s.node(o.v).rank-s.edge(o).minlen}return ng}var rg,ck;function SC(){if(ck)return rg;ck=1;var e=ot(),n=Qn().Graph,i=Hl().slack;rg=s;function s(c){var p=new n({directed:!1}),h=c.nodes()[0],f=c.nodeCount();p.setNode(h,{});for(var m,y;o(p,c)<f;)m=l(p,c),y=p.hasNode(m.v)?i(c,m):-i(c,m),u(p,c,y);return p}function o(c,p){function h(f){e.forEach(p.nodeEdges(f),function(m){var y=m.v,x=f===y?m.w:y;!c.hasNode(x)&&!i(p,m)&&(c.setNode(x,{}),c.setEdge(f,x,{}),h(x))})}return e.forEach(c.nodes(),h),c.nodeCount()}function l(c,p){return e.minBy(p.edges(),function(h){if(c.hasNode(h.v)!==c.hasNode(h.w))return i(p,h)})}function u(c,p,h){e.forEach(c.nodes(),function(f){p.node(f).rank+=h})}return rg}var ig,dk;function QL(){if(dk)return ig;dk=1;var e=ot(),n=SC(),i=Hl().slack,s=Hl().longestPath,o=Qn().alg.preorder,l=Qn().alg.postorder,u=fn().simplify;ig=c,c.initLowLimValues=m,c.initCutValues=p,c.calcCutValue=f,c.leaveEdge=x,c.enterEdge=N,c.exchangeEdges=_;function c(C){C=u(C),s(C);var j=n(C);m(j),p(j,C);for(var P,O;P=x(j);)O=N(j,C,P),_(j,C,P,O)}function p(C,j){var P=l(C,C.nodes());P=P.slice(0,P.length-1),e.forEach(P,function(O){h(C,j,O)})}function h(C,j,P){var O=C.node(P),q=O.parent;C.edge(P,q).cutvalue=f(C,j,P)}function f(C,j,P){var O=C.node(P),q=O.parent,B=!0,T=j.edge(P,q),M=0;return T||(B=!1,T=j.edge(q,P)),M=T.weight,e.forEach(j.nodeEdges(P),function(F){var X=F.v===P,Y=X?F.w:F.v;if(Y!==q){var I=X===B,H=j.edge(F).weight;if(M+=I?H:-H,b(C,P,Y)){var U=C.edge(P,Y).cutvalue;M+=I?-U:U}}}),M}function m(C,j){arguments.length<2&&(j=C.nodes()[0]),y(C,{},1,j)}function y(C,j,P,O,q){var B=P,T=C.node(O);return j[O]=!0,e.forEach(C.neighbors(O),function(M){e.has(j,M)||(P=y(C,j,P,M,O))}),T.low=B,T.lim=P++,q?T.parent=q:delete T.parent,P}function x(C){return e.find(C.edges(),function(j){return C.edge(j).cutvalue<0})}function N(C,j,P){var O=P.v,q=P.w;j.hasEdge(O,q)||(O=P.w,q=P.v);var B=C.node(O),T=C.node(q),M=B,F=!1;B.lim>T.lim&&(M=T,F=!0);var X=e.filter(j.edges(),function(Y){return F===E(C,C.node(Y.v),M)&&F!==E(C,C.node(Y.w),M)});return e.minBy(X,function(Y){return i(j,Y)})}function _(C,j,P,O){var q=P.v,B=P.w;C.removeEdge(q,B),C.setEdge(O.v,O.w,{}),m(C),p(C,j),S(C,j)}function S(C,j){var P=e.find(C.nodes(),function(q){return!j.node(q).parent}),O=o(C,P);O=O.slice(1),e.forEach(O,function(q){var B=C.node(q).parent,T=j.edge(q,B),M=!1;T||(T=j.edge(B,q),M=!0),j.node(q).rank=j.node(B).rank+(M?T.minlen:-T.minlen)})}function b(C,j,P){return C.hasEdge(j,P)}function E(C,j,P){return P.low<=j.lim&&j.lim<=P.lim}return ig}var sg,fk;function ZL(){if(fk)return sg;fk=1;var e=Hl(),n=e.longestPath,i=SC(),s=QL();sg=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),i(p)}function c(p){s(p)}return sg}var og,hk;function JL(){if(hk)return og;hk=1;var e=ot();og=n;function n(o){var l=s(o);e.forEach(o.graph().dummyChains,function(u){for(var c=o.node(u),p=c.edgeObj,h=i(o,l,p.v,p.w),f=h.path,m=h.lca,y=0,x=f[y],N=!0;u!==p.w;){if(c=o.node(u),N){for(;(x=f[y])!==m&&o.node(x).maxRank<c.rank;)y++;x===m&&(N=!1)}if(!N){for(;y<f.length-1&&o.node(x=f[y+1]).minRank<=c.rank;)y++;x=f[y]}o.setParent(u,x),u=o.successors(u)[0]}})}function i(o,l,u,c){var p=[],h=[],f=Math.min(l[u].low,l[c].low),m=Math.max(l[u].lim,l[c].lim),y,x;y=u;do y=o.parent(y),p.push(y);while(y&&(l[y].low>f||m>l[y].lim));for(x=y,y=c;(y=o.parent(y))!==x;)h.push(y);return{path:p.concat(h.reverse()),lca:x}}function s(o){var l={},u=0;function c(p){var h=u;e.forEach(o.children(p),c),l[p]={low:h,lim:u++}}return e.forEach(o.children(),c),l}return og}var ag,pk;function e$(){if(pk)return ag;pk=1;var e=ot(),n=fn();ag={run:i,cleanup:u};function i(c){var p=n.addDummyNode(c,"root",{},"_root"),h=o(c),f=e.max(e.values(h))-1,m=2*f+1;c.graph().nestingRoot=p,e.forEach(c.edges(),function(x){c.edge(x).minlen*=m});var y=l(c)+1;e.forEach(c.children(),function(x){s(c,p,m,y,f,h,x)}),c.graph().nodeRankFactor=m}function s(c,p,h,f,m,y,x){var N=c.children(x);if(!N.length){x!==p&&c.setEdge(p,x,{weight:0,minlen:h});return}var _=n.addBorderNode(c,"_bt"),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(E){s(c,p,h,f,m,y,E);var C=c.node(E),j=C.borderTop?C.borderTop:E,P=C.borderBottom?C.borderBottom:E,O=C.borderTop?f:2*f,q=j!==P?1:m-y[x]+1;c.setEdge(_,j,{weight:O,minlen:q,nestingEdge:!0}),c.setEdge(P,S,{weight:O,minlen:q,nestingEdge:!0})}),c.parent(x)||c.setEdge(p,_,{weight:0,minlen:m+y[x]})}function o(c){var p={};function h(f,m){var y=c.children(f);y&&y.length&&e.forEach(y,function(x){h(x,m+1)}),p[f]=m}return e.forEach(c.children(),function(f){h(f,1)}),p}function l(c){return e.reduce(c.edges(),function(p,h){return p+c.edge(h).weight},0)}function u(c){var p=c.graph();c.removeNode(p.nestingRoot),delete p.nestingRoot,e.forEach(c.edges(),function(h){var f=c.edge(h);f.nestingEdge&&c.removeEdge(h)})}return ag}var lg,mk;function t$(){if(mk)return lg;mk=1;var e=ot(),n=fn();lg=i;function i(o){function l(u){var c=o.children(u),p=o.node(u);if(c.length&&e.forEach(c,l),e.has(p,"minRank")){p.borderLeft=[],p.borderRight=[];for(var h=p.minRank,f=p.maxRank+1;h<f;++h)s(o,"borderLeft","_bl",u,p,h),s(o,"borderRight","_br",u,p,h)}}e.forEach(o.children(),l)}function s(o,l,u,c,p,h){var f={width:0,height:0,rank:h,borderType:l},m=p[l][h-1],y=n.addDummyNode(o,"border",f,u);p[l][h]=y,o.setParent(y,c),m&&o.setEdge(m,y,{weight:1})}return lg}var ug,gk;function n$(){if(gk)return ug;gk=1;var e=ot();ug={adjust:n,undo:i};function n(h){var f=h.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&s(h)}function i(h){var f=h.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&l(h),(f==="lr"||f==="rl")&&(c(h),s(h))}function s(h){e.forEach(h.nodes(),function(f){o(h.node(f))}),e.forEach(h.edges(),function(f){o(h.edge(f))})}function o(h){var f=h.width;h.width=h.height,h.height=f}function l(h){e.forEach(h.nodes(),function(f){u(h.node(f))}),e.forEach(h.edges(),function(f){var m=h.edge(f);e.forEach(m.points,u),e.has(m,"y")&&u(m)})}function u(h){h.y=-h.y}function c(h){e.forEach(h.nodes(),function(f){p(h.node(f))}),e.forEach(h.edges(),function(f){var m=h.edge(f);e.forEach(m.points,p),e.has(m,"x")&&p(m)})}function p(h){var f=h.x;h.x=h.y,h.y=f}return ug}var cg,vk;function r$(){if(vk)return cg;vk=1;var e=ot();cg=n;function n(i){var s={},o=e.filter(i.nodes(),function(h){return!i.children(h).length}),l=e.max(e.map(o,function(h){return i.node(h).rank})),u=e.map(e.range(l+1),function(){return[]});function c(h){if(!e.has(s,h)){s[h]=!0;var f=i.node(h);u[f.rank].push(h),e.forEach(i.successors(h),c)}}var p=e.sortBy(o,function(h){return i.node(h).rank});return e.forEach(p,c),u}return cg}var dg,yk;function i$(){if(yk)return dg;yk=1;var e=ot();dg=n;function n(s,o){for(var l=0,u=1;u<o.length;++u)l+=i(s,o[u-1],o[u]);return l}function i(s,o,l){for(var u=e.zipObject(l,e.map(l,function(y,x){return x})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(s.outEdges(y),function(x){return{pos:u[x.w],weight:s.edge(x).weight}}),"pos")}),!0),p=1;p<l.length;)p<<=1;var h=2*p-1;p-=1;var f=e.map(new Array(h),function(){return 0}),m=0;return e.forEach(c.forEach(function(y){var x=y.pos+p;f[x]+=y.weight;for(var N=0;x>0;)x%2&&(N+=f[x+1]),x=x-1>>1,f[x]+=y.weight;m+=y.weight*N})),m}return dg}var fg,wk;function s$(){if(wk)return fg;wk=1;var e=ot();fg=n;function n(i,s){return e.map(s,function(o){var l=i.inEdges(o);if(l.length){var u=e.reduce(l,function(c,p){var h=i.edge(p),f=i.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 fg}var hg,xk;function o$(){if(xk)return hg;xk=1;var e=ot();hg=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 i(c)}function i(o){var l=[];function u(h){return function(f){f.merged||(e.isUndefined(f.barycenter)||e.isUndefined(h.barycenter)||f.barycenter>=h.barycenter)&&s(h,f)}}function c(h){return function(f){f.in.push(h),--f.indegree===0&&o.push(f)}}for(;o.length;){var p=o.pop();l.push(p),e.forEach(p.in.reverse(),u(p)),e.forEach(p.out,c(p))}return e.map(e.filter(l,function(h){return!h.merged}),function(h){return e.pick(h,["vs","i","barycenter","weight"])})}function s(o,l){var u=0,c=0;o.weight&&(u+=o.barycenter*o.weight,c+=o.weight),l.weight&&(u+=l.barycenter*l.weight,c+=l.weight),o.vs=l.vs.concat(o.vs),o.barycenter=u/c,o.weight=c,o.i=Math.min(l.i,o.i),l.merged=!0}return hg}var pg,_k;function a$(){if(_k)return pg;_k=1;var e=ot(),n=fn();pg=i;function i(l,u){var c=n.partition(l,function(_){return e.has(_,"barycenter")}),p=c.lhs,h=e.sortBy(c.rhs,function(_){return-_.i}),f=[],m=0,y=0,x=0;p.sort(o(!!u)),x=s(f,h,x),e.forEach(p,function(_){x+=_.vs.length,f.push(_.vs),m+=_.barycenter*_.weight,y+=_.weight,x=s(f,h,x)});var N={vs:e.flatten(f,!0)};return y&&(N.barycenter=m/y,N.weight=y),N}function s(l,u,c){for(var p;u.length&&(p=e.last(u)).i<=c;)u.pop(),l.push(p.vs),c++;return c}function o(l){return function(u,c){return u.barycenter<c.barycenter?-1:u.barycenter>c.barycenter?1:l?c.i-u.i:u.i-c.i}}return pg}var mg,Sk;function l$(){if(Sk)return mg;Sk=1;var e=ot(),n=s$(),i=o$(),s=a$();mg=o;function o(c,p,h,f){var m=c.children(p),y=c.node(p),x=y?y.borderLeft:void 0,N=y?y.borderRight:void 0,_={};x&&(m=e.filter(m,function(P){return P!==x&&P!==N}));var S=n(c,m);e.forEach(S,function(P){if(c.children(P.v).length){var O=o(c,P.v,h,f);_[P.v]=O,e.has(O,"barycenter")&&u(P,O)}});var b=i(S,h);l(b,_);var E=s(b,f);if(x&&(E.vs=e.flatten([x,E.vs,N],!0),c.predecessors(x).length)){var C=c.node(c.predecessors(x)[0]),j=c.node(c.predecessors(N)[0]);e.has(E,"barycenter")||(E.barycenter=0,E.weight=0),E.barycenter=(E.barycenter*E.weight+C.order+j.order)/(E.weight+2),E.weight+=2}return E}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 mg}var gg,bk;function u$(){if(bk)return gg;bk=1;var e=ot(),n=Qn().Graph;gg=i;function i(o,l,u){var c=s(o),p=new n({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(h){return o.node(h)});return e.forEach(o.nodes(),function(h){var f=o.node(h),m=o.parent(h);(f.rank===l||f.minRank<=l&&l<=f.maxRank)&&(p.setNode(h),p.setParent(h,m||c),e.forEach(o[u](h),function(y){var x=y.v===h?y.w:y.v,N=p.edge(x,h),_=e.isUndefined(N)?0:N.weight;p.setEdge(x,h,{weight:o.edge(y).weight+_})}),e.has(f,"minRank")&&p.setNode(h,{borderLeft:f.borderLeft[l],borderRight:f.borderRight[l]}))}),p}function s(o){for(var l;o.hasNode(l=e.uniqueId("_root")););return l}return gg}var vg,kk;function c$(){if(kk)return vg;kk=1;var e=ot();vg=n;function n(i,s,o){var l={},u;e.forEach(o,function(c){for(var p=i.parent(c),h,f;p;){if(h=i.parent(p),h?(f=l[h],l[h]=p):(f=u,u=p),f&&f!==p){s.setEdge(f,p);return}p=h}})}return vg}var yg,Ek;function d$(){if(Ek)return yg;Ek=1;var e=ot(),n=r$(),i=i$(),s=l$(),o=u$(),l=c$(),u=Qn().Graph,c=fn();yg=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);m(y,S);for(var b=Number.POSITIVE_INFINITY,E,C=0,j=0;j<4;++C,++j){f(C%2?N:_,C%4>=2),S=c.buildLayerMatrix(y);var P=i(y,S);P<b&&(j=0,E=e.cloneDeep(S),b=P)}m(y,E)}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=s(_,S,N,x);e.forEach(b.vs,function(E,C){_.node(E).order=C}),l(_,N,b.vs)})}function m(y,x){e.forEach(x,function(N){e.forEach(N,function(_,S){y.node(_).order=S})})}return yg}var wg,Nk;function f$(){if(Nk)return wg;Nk=1;var e=ot(),n=Qn().Graph,i=fn();wg={positionX:N,findType1Conflicts:s,findType2Conflicts:o,addConflict:u,hasConflict:c,verticalAlignment:p,horizontalCompaction:h,alignCoordinates:y,findSmallestWidthAlignment:m,balance:x};function s(b,E){var C={};function j(P,O){var q=0,B=0,T=P.length,M=e.last(O);return e.forEach(O,function(F,X){var Y=l(b,F),I=Y?b.node(Y).order:T;(Y||F===M)&&(e.forEach(O.slice(B,X+1),function(H){e.forEach(b.predecessors(H),function(U){var ne=b.node(U),J=ne.order;(J<q||I<J)&&!(ne.dummy&&b.node(H).dummy)&&u(C,U,H)})}),B=X+1,q=I)}),O}return e.reduce(E,j),C}function o(b,E){var C={};function j(O,q,B,T,M){var F;e.forEach(e.range(q,B),function(X){F=O[X],b.node(F).dummy&&e.forEach(b.predecessors(F),function(Y){var I=b.node(Y);I.dummy&&(I.order<T||I.order>M)&&u(C,Y,F)})})}function P(O,q){var B=-1,T,M=0;return e.forEach(q,function(F,X){if(b.node(F).dummy==="border"){var Y=b.predecessors(F);Y.length&&(T=b.node(Y[0]).order,j(q,M,X,B,T),M=X,B=T)}j(q,M,q.length,T,O.length)}),q}return e.reduce(E,P),C}function l(b,E){if(b.node(E).dummy)return e.find(b.predecessors(E),function(C){return b.node(C).dummy})}function u(b,E,C){if(E>C){var j=E;E=C,C=j}var P=b[E];P||(b[E]=P={}),P[C]=!0}function c(b,E,C){if(E>C){var j=E;E=C,C=j}return e.has(b[E],C)}function p(b,E,C,j){var P={},O={},q={};return e.forEach(E,function(B){e.forEach(B,function(T,M){P[T]=T,O[T]=T,q[T]=M})}),e.forEach(E,function(B){var T=-1;e.forEach(B,function(M){var F=j(M);if(F.length){F=e.sortBy(F,function(U){return q[U]});for(var X=(F.length-1)/2,Y=Math.floor(X),I=Math.ceil(X);Y<=I;++Y){var H=F[Y];O[M]===M&&T<q[H]&&!c(C,M,H)&&(O[H]=M,O[M]=P[M]=P[H],T=q[H])}}})}),{root:P,align:O}}function h(b,E,C,j,P){var O={},q=f(b,E,C,P),B=P?"borderLeft":"borderRight";function T(X,Y){for(var I=q.nodes(),H=I.pop(),U={};H;)U[H]?X(H):(U[H]=!0,I.push(H),I=I.concat(Y(H))),H=I.pop()}function M(X){O[X]=q.inEdges(X).reduce(function(Y,I){return Math.max(Y,O[I.v]+q.edge(I))},0)}function F(X){var Y=q.outEdges(X).reduce(function(H,U){return Math.min(H,O[U.w]-q.edge(U))},Number.POSITIVE_INFINITY),I=b.node(X);Y!==Number.POSITIVE_INFINITY&&I.borderType!==B&&(O[X]=Math.max(O[X],Y))}return T(M,q.predecessors.bind(q)),T(F,q.successors.bind(q)),e.forEach(j,function(X){O[X]=O[C[X]]}),O}function f(b,E,C,j){var P=new n,O=b.graph(),q=_(O.nodesep,O.edgesep,j);return e.forEach(E,function(B){var T;e.forEach(B,function(M){var F=C[M];if(P.setNode(F),T){var X=C[T],Y=P.edge(X,F);P.setEdge(X,F,Math.max(q(b,M,T),Y||0))}T=M})}),P}function m(b,E){return e.minBy(e.values(E),function(C){var j=Number.NEGATIVE_INFINITY,P=Number.POSITIVE_INFINITY;return e.forIn(C,function(O,q){var B=S(b,q)/2;j=Math.max(O+B,j),P=Math.min(O-B,P)}),j-P})}function y(b,E){var C=e.values(E),j=e.min(C),P=e.max(C);e.forEach(["u","d"],function(O){e.forEach(["l","r"],function(q){var B=O+q,T=b[B],M;if(T!==E){var F=e.values(T);M=q==="l"?j-e.min(F):P-e.max(F),M&&(b[B]=e.mapValues(T,function(X){return X+M}))}})})}function x(b,E){return e.mapValues(b.ul,function(C,j){if(E)return b[E.toLowerCase()][j];var P=e.sortBy(e.map(b,j));return(P[1]+P[2])/2})}function N(b){var E=i.buildLayerMatrix(b),C=e.merge(s(b,E),o(b,E)),j={},P;e.forEach(["u","d"],function(q){P=q==="u"?E:e.values(E).reverse(),e.forEach(["l","r"],function(B){B==="r"&&(P=e.map(P,function(X){return e.values(X).reverse()}));var T=(q==="u"?b.predecessors:b.successors).bind(b),M=p(b,P,C,T),F=h(b,P,M.root,M.align,B==="r");B==="r"&&(F=e.mapValues(F,function(X){return-X})),j[q+B]=F})});var O=m(b,j);return y(j,O),x(j,b.graph().align)}function _(b,E,C){return function(j,P,O){var q=j.node(P),B=j.node(O),T=0,M;if(T+=q.width/2,e.has(q,"labelpos"))switch(q.labelpos.toLowerCase()){case"l":M=-q.width/2;break;case"r":M=q.width/2;break}if(M&&(T+=C?M:-M),M=0,T+=(q.dummy?E:b)/2,T+=(B.dummy?E:b)/2,T+=B.width/2,e.has(B,"labelpos"))switch(B.labelpos.toLowerCase()){case"l":M=B.width/2;break;case"r":M=-B.width/2;break}return M&&(T+=C?M:-M),M=0,T}}function S(b,E){return b.node(E).width}return wg}var xg,Ck;function h$(){if(Ck)return xg;Ck=1;var e=ot(),n=fn(),i=f$().positionX;xg=s;function s(l){l=n.asNonCompoundGraph(l),o(l),e.forEach(i(l),function(u,c){l.node(c).x=u})}function o(l){var u=n.buildLayerMatrix(l),c=l.graph().ranksep,p=0;e.forEach(u,function(h){var f=e.max(e.map(h,function(m){return l.node(m).height}));e.forEach(h,function(m){l.node(m).y=p+f/2}),p+=f+c})}return xg}var _g,jk;function p$(){if(jk)return _g;jk=1;var e=ot(),n=YL(),i=XL(),s=ZL(),o=fn().normalizeRanks,l=JL(),u=fn().removeEmptyRanks,c=e$(),p=t$(),h=n$(),f=d$(),m=h$(),y=fn(),x=Qn().Graph;_g=N;function N($,Q){var ee=Q&&Q.debugTiming?y.time:y.notime;ee("layout",function(){var se=ee(" buildLayoutGraph",function(){return T($)});ee(" runLayout",function(){_(se,ee)}),ee(" updateInputGraph",function(){S($,se)})})}function _($,Q){Q(" makeSpaceForEdgeLabels",function(){M($)}),Q(" removeSelfEdges",function(){D($)}),Q(" acyclic",function(){n.run($)}),Q(" nestingGraph.run",function(){c.run($)}),Q(" rank",function(){s(y.asNonCompoundGraph($))}),Q(" injectEdgeLabelProxies",function(){F($)}),Q(" removeEmptyRanks",function(){u($)}),Q(" nestingGraph.cleanup",function(){c.cleanup($)}),Q(" normalizeRanks",function(){o($)}),Q(" assignRankMinMax",function(){X($)}),Q(" removeEdgeLabelProxies",function(){Y($)}),Q(" normalize.run",function(){i.run($)}),Q(" parentDummyChains",function(){l($)}),Q(" addBorderSegments",function(){p($)}),Q(" order",function(){f($)}),Q(" insertSelfEdges",function(){G($)}),Q(" adjustCoordinateSystem",function(){h.adjust($)}),Q(" position",function(){m($)}),Q(" positionSelfEdges",function(){k($)}),Q(" removeBorderNodes",function(){J($)}),Q(" normalize.undo",function(){i.undo($)}),Q(" fixupEdgeLabelCoords",function(){U($)}),Q(" undoCoordinateSystem",function(){h.undo($)}),Q(" translateGraph",function(){I($)}),Q(" assignNodeIntersects",function(){H($)}),Q(" reversePoints",function(){ne($)}),Q(" acyclic.undo",function(){n.undo($)})}function S($,Q){e.forEach($.nodes(),function(ee){var se=$.node(ee),ae=Q.node(ee);se&&(se.x=ae.x,se.y=ae.y,Q.children(ee).length&&(se.width=ae.width,se.height=ae.height))}),e.forEach($.edges(),function(ee){var se=$.edge(ee),ae=Q.edge(ee);se.points=ae.points,e.has(ae,"x")&&(se.x=ae.x,se.y=ae.y)}),$.graph().width=Q.graph().width,$.graph().height=Q.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],E={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},C=["acyclicer","ranker","rankdir","align"],j=["width","height"],P={width:0,height:0},O=["minlen","weight","width","height","labeloffset"],q={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},B=["labelpos"];function T($){var Q=new x({multigraph:!0,compound:!0}),ee=oe($.graph());return Q.setGraph(e.merge({},E,L(ee,b),e.pick(ee,C))),e.forEach($.nodes(),function(se){var ae=oe($.node(se));Q.setNode(se,e.defaults(L(ae,j),P)),Q.setParent(se,$.parent(se))}),e.forEach($.edges(),function(se){var ae=oe($.edge(se));Q.setEdge(se,e.merge({},q,L(ae,O),e.pick(ae,B)))}),Q}function M($){var Q=$.graph();Q.ranksep/=2,e.forEach($.edges(),function(ee){var se=$.edge(ee);se.minlen*=2,se.labelpos.toLowerCase()!=="c"&&(Q.rankdir==="TB"||Q.rankdir==="BT"?se.width+=se.labeloffset:se.height+=se.labeloffset)})}function F($){e.forEach($.edges(),function(Q){var ee=$.edge(Q);if(ee.width&&ee.height){var se=$.node(Q.v),ae=$.node(Q.w),pe={rank:(ae.rank-se.rank)/2+se.rank,e:Q};y.addDummyNode($,"edge-proxy",pe,"_ep")}})}function X($){var Q=0;e.forEach($.nodes(),function(ee){var se=$.node(ee);se.borderTop&&(se.minRank=$.node(se.borderTop).rank,se.maxRank=$.node(se.borderBottom).rank,Q=e.max(Q,se.maxRank))}),$.graph().maxRank=Q}function Y($){e.forEach($.nodes(),function(Q){var ee=$.node(Q);ee.dummy==="edge-proxy"&&($.edge(ee.e).labelRank=ee.rank,$.removeNode(Q))})}function I($){var Q=Number.POSITIVE_INFINITY,ee=0,se=Number.POSITIVE_INFINITY,ae=0,pe=$.graph(),ge=pe.marginx||0,Ae=pe.marginy||0;function Oe(Me){var Pe=Me.x,ke=Me.y,We=Me.width,ve=Me.height;Q=Math.min(Q,Pe-We/2),ee=Math.max(ee,Pe+We/2),se=Math.min(se,ke-ve/2),ae=Math.max(ae,ke+ve/2)}e.forEach($.nodes(),function(Me){Oe($.node(Me))}),e.forEach($.edges(),function(Me){var Pe=$.edge(Me);e.has(Pe,"x")&&Oe(Pe)}),Q-=ge,se-=Ae,e.forEach($.nodes(),function(Me){var Pe=$.node(Me);Pe.x-=Q,Pe.y-=se}),e.forEach($.edges(),function(Me){var Pe=$.edge(Me);e.forEach(Pe.points,function(ke){ke.x-=Q,ke.y-=se}),e.has(Pe,"x")&&(Pe.x-=Q),e.has(Pe,"y")&&(Pe.y-=se)}),pe.width=ee-Q+ge,pe.height=ae-se+Ae}function H($){e.forEach($.edges(),function(Q){var ee=$.edge(Q),se=$.node(Q.v),ae=$.node(Q.w),pe,ge;ee.points?(pe=ee.points[0],ge=ee.points[ee.points.length-1]):(ee.points=[],pe=ae,ge=se),ee.points.unshift(y.intersectRect(se,pe)),ee.points.push(y.intersectRect(ae,ge))})}function U($){e.forEach($.edges(),function(Q){var ee=$.edge(Q);if(e.has(ee,"x"))switch((ee.labelpos==="l"||ee.labelpos==="r")&&(ee.width-=ee.labeloffset),ee.labelpos){case"l":ee.x-=ee.width/2+ee.labeloffset;break;case"r":ee.x+=ee.width/2+ee.labeloffset;break}})}function ne($){e.forEach($.edges(),function(Q){var ee=$.edge(Q);ee.reversed&&ee.points.reverse()})}function J($){e.forEach($.nodes(),function(Q){if($.children(Q).length){var ee=$.node(Q),se=$.node(ee.borderTop),ae=$.node(ee.borderBottom),pe=$.node(e.last(ee.borderLeft)),ge=$.node(e.last(ee.borderRight));ee.width=Math.abs(ge.x-pe.x),ee.height=Math.abs(ae.y-se.y),ee.x=pe.x+ee.width/2,ee.y=se.y+ee.height/2}}),e.forEach($.nodes(),function(Q){$.node(Q).dummy==="border"&&$.removeNode(Q)})}function D($){e.forEach($.edges(),function(Q){if(Q.v===Q.w){var ee=$.node(Q.v);ee.selfEdges||(ee.selfEdges=[]),ee.selfEdges.push({e:Q,label:$.edge(Q)}),$.removeEdge(Q)}})}function G($){var Q=y.buildLayerMatrix($);e.forEach(Q,function(ee){var se=0;e.forEach(ee,function(ae,pe){var ge=$.node(ae);ge.order=pe+se,e.forEach(ge.selfEdges,function(Ae){y.addDummyNode($,"selfedge",{width:Ae.label.width,height:Ae.label.height,rank:ge.rank,order:pe+ ++se,e:Ae.e,label:Ae.label},"_se")}),delete ge.selfEdges})})}function k($){e.forEach($.nodes(),function(Q){var ee=$.node(Q);if(ee.dummy==="selfedge"){var se=$.node(ee.e.v),ae=se.x+se.width/2,pe=se.y,ge=ee.x-ae,Ae=se.height/2;$.setEdge(ee.e,ee.label),$.removeNode(Q),ee.label.points=[{x:ae+2*ge/3,y:pe-Ae},{x:ae+5*ge/6,y:pe-Ae},{x:ae+ge,y:pe},{x:ae+5*ge/6,y:pe+Ae},{x:ae+2*ge/3,y:pe+Ae}],ee.label.x=ee.x,ee.label.y=ee.y}})}function L($,Q){return e.mapValues(e.pick($,Q),Number)}function oe($){var Q={};return e.forEach($,function(ee,se){Q[se.toLowerCase()]=ee}),Q}return _g}var Sg,Rk;function m$(){if(Rk)return Sg;Rk=1;var e=ot(),n=fn(),i=Qn().Graph;Sg={debugOrdering:s};function s(o){var l=n.buildLayerMatrix(o),u=new i({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(c){u.setNode(c,{label:c}),u.setParent(c,"layer"+o.node(c).rank)}),e.forEach(o.edges(),function(c){u.setEdge(c.v,c.w,{},c.name)}),e.forEach(l,function(c,p){var h="layer"+p;u.setNode(h,{rank:"same"}),e.reduce(c,function(f,m){return u.setEdge(f,m,{style:"invis"}),m})}),u}return Sg}var bg,Tk;function g$(){return Tk||(Tk=1,bg="0.8.5"),bg}var kg,Ak;function v$(){return Ak||(Ak=1,kg={graphlib:Qn(),layout:p$(),debug:m$(),util:{time:fn().time,notime:fn().notime},version:g$()}),kg}var y$=v$();const Ik=Yg(y$),vi=240,Xi=130,zs=74,mu=72,Mk=zs+mu;function w$(e){let n=vi;for(const i of e.values())n=Math.max(n,i.width);return n}const bC=420,x$=2;function ta(e){var i;return((i=e.data)==null?void 0:i.sessionId)??"_default"}function Pk(e,n){return((n==null?void 0:n.get(e))??0)>0?bC:0}function Ok(e,n){const i=(n==null?void 0:n.get(e))??0;return i>0?6+i*36:0}function _$(e,n,i,s,o,l){const u=new Ik.graphlib.Graph;u.setDefaultEdgeLabel(()=>({})),u.setGraph({rankdir:i,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const c=e.filter(S=>!o.has(S)),p=new Set(c);for(const S of c){const b=s.get(S);u.setNode(S,{width:((b==null?void 0:b.width)??vi)+Pk(S,l),height:Math.max((b==null?void 0:b.height)??Xi,Ok(S,l))})}for(const S of n)p.has(S.source)&&p.has(S.target)&&u.setEdge(S.source,S.target);Ik.layout(u);const h=new Map;let f=1/0,m=1/0,y=-1/0,x=-1/0;for(const S of c){const b=u.node(S);if(!b)continue;const E=s.get(S),C=(E==null?void 0:E.width)??vi,j=(E==null?void 0:E.height)??Xi,P=C+Pk(S,l),O=Math.max(j,Ok(S,l)),q=b.x-P/2,B=b.y-O/2;h.set(S,{x:q,y:B}),q<f&&(f=q),B<m&&(m=B),q+C>y&&(y=q+C),B+j>x&&(x=B+j)}if(Number.isFinite(f)&&Number.isFinite(m))for(const[S,b]of h)h.set(S,{x:b.x-f,y:b.y-m});let N=Number.isFinite(y)?y-f:0,_=Number.isFinite(x)?x-m:0;for(const S of e){const b=o.get(S);if(!b)continue;const E=s.get(S);N=Math.max(N,b.x+((E==null?void 0:E.width)??vi)),_=Math.max(_,b.y+((E==null?void 0:E.height)??Xi))}return{positions:h,width:N,height:_}}function S$(e,n,i={}){const s=i.direction??"LR",o=i.pinned??new Map,l=i.measured??new Map,u=i.lanes,c=new Map;for(const b of e){const E=ta(b),C=c.get(E);C?C.push(b.id):c.set(E,[b.id])}const h=Array.from(c.keys()).sort().map(b=>({sid:b,..._$(c.get(b),n,s,l,o,u)})),f=w$(l),m=i.availableHeight&&i.availableHeight>0?i.availableHeight:Number.POSITIVE_INFINITY,y=b=>{const E=[[]];let C=0;for(const j of h)E.length<b&&C>0&&C+j.height>m&&(E.push([]),C=0),E[E.length-1].push(j),C+=j.height+Mk;return E},x=b=>b.reduce((E,C)=>Math.max(E,C.width),0)+bC;let N=y(i.availableWidth?x$:1);N.length>1&&N.reduce((E,C)=>E+x(C),0)+f*(N.length-1)>(i.availableWidth??0)&&(N=y(1));const _=new Map;let S=0;for(const b of N){let E=0;for(const{positions:C,height:j}of b){for(const[P,O]of C)_.set(P,{x:O.x+S,y:O.y+E});E+=j+Mk}S+=x(b)+f}return e.map(b=>{const E=o.get(b.id);if(E)return{...b,position:E};const C=_.get(b.id);return C?{...b,position:C}:b})}function b$(e,n,i,s){const l=zs+mu,u=60,c=y=>{const x=s.get(y);return{w:(x==null?void 0:x.width)??vi,h:(x==null?void 0:x.height)??Xi}},p=new Map(e.map(y=>[y.id,ta(y)])),h=[],f=e.map(y=>({id:y.id,pos:i.get(y.id)??n.get(y.id)})).filter(y=>y.pos!=null).sort((y,x)=>y.pos.y-x.pos.y||y.pos.x-x.pos.x||y.id.localeCompare(x.id)),m=[];for(const{id:y,pos:x}of f){const{w:N,h:_}=c(y),S=p.get(y)??"_default";if(i.has(y)){h.push({x:x.x,y:x.y,w:N,h:_,sid:S});continue}let b=x.y;for(let E=0;E<h.length+1;E++){const C=h.find(j=>{const P=j.sid===S?24:u,O=j.sid===S?24:l;return x.x<j.x+j.w+P&&j.x<x.x+N+P&&b<j.y+j.h+O&&j.y<b+_+O});if(!C)break;b=C.y+C.h+(C.sid===S?24:l)}b!==x.y&&(n.set(y,{x:x.x,y:b}),m.push(y)),h.push({x:x.x,y:b,w:N,h:_,sid:S})}return m}function k$(e,n,i,s,o){const l=N=>{const _=s.get(N);return{w:(_==null?void 0:_.width)??vi,h:(_==null?void 0:_.height)??Xi}},u=N=>i.get(N)??n.get(N),c=new Map;for(const N of e){if(!u(N.id))continue;const _=ta(N),S=c.get(_);S?S.push(N):c.set(_,[N])}const p=new Set;for(const[N,_]of c)_.every(S=>o.has(S.id)&&!i.has(S.id))&&p.add(N);const h=new Map,f=[];for(const N of e){const _=u(N.id);if(!_)continue;const{w:S,h:b}=l(N.id),E=ta(N);p.has(E)?(h.get(E)??h.set(E,[]).get(E)).push(N):f.push({x:_.x,y:_.y,w:S,h:b})}if(h.size===0)return[];const m=zs+mu,y=(N,_,S,b)=>f.some(E=>N<E.x+E.w+zs&&E.x<N+S+zs&&_<E.y+E.h+m&&E.y<_+b+m),x=[];for(const N of[...h.keys()].sort()){const _=h.get(N);let S=1/0,b=1/0,E=-1/0,C=-1/0;for(const M of _){const F=u(M.id),{w:X,h:Y}=l(M.id);S=Math.min(S,F.x),b=Math.min(b,F.y),E=Math.max(E,F.x+X),C=Math.max(C,F.y+Y)}const j=E-S,P=C-b,O=[...new Set(f.map(M=>Math.round(M.x)))].sort((M,F)=>M-F),q=O.length?O:[S],B=[0,...f.map(M=>M.y+M.h+m)].sort((M,F)=>M-F);let T=null;e:for(const M of q)for(const F of B){if(F>=b)break;if(!y(M,F,j,P)){T={x:M,y:F};break e}}if(T){const M=T.x-S,F=T.y-b;for(const X of _){const Y=u(X.id);n.set(X.id,{x:Y.x+M,y:Y.y+F})}x.push(N)}for(const M of _){const F=u(M.id),{w:X,h:Y}=l(M.id);f.push({x:F.x,y:F.y,w:X,h:Y})}}return x}function E$(e,n,i,s,o,l=!1){const p=zs+mu+1,h=8,f=1.75,m=200,y=.7,x=.01,N=T=>{const M=s.get(T);return{w:(M==null?void 0:M.width)??vi,h:(M==null?void 0:M.height)??Xi}},_=T=>i.get(T)??n.get(T),S=new Map;for(const T of e){if(!_(T.id))continue;const M=ta(T),F=S.get(M);F?F.push(T):S.set(M,[T])}const b=[],E=new Set,C=new Set,j=o.size===0;for(const T of[...S.keys()].sort()){const M=S.get(T);let F=1/0,X=1/0,Y=-1/0,I=-1/0,H=!1;for(const D of M){const G=_(D.id),{w:k,h:L}=N(D.id);F=Math.min(F,G.x),X=Math.min(X,G.y),Y=Math.max(Y,G.x+k),I=Math.max(I,G.y+L),i.has(D.id)&&(H=!0)}const U=Y-F,ne=I-X;C.add(T);const J=o.get(T);J&&(U>J.w+h||ne>J.h+h)&&E.add(T),o.set(T,{w:U,h:ne}),b.push({sid:T,members:M.map(D=>D.id),x:F,y:X,w:U,h:ne,anchored:H,mass:1})}for(const T of[...o.keys()])C.has(T)||o.delete(T);if(l||j)return[];let P=!1;for(let T=0;T<b.length&&!P;T++)for(let M=T+1;M<b.length;M++){const F=b[T],X=b[M];if(!(F.anchored&&X.anchored)&&Math.abs(F.x+F.w/2-(X.x+X.w/2))<(F.w+X.w)/2+61&&Math.abs(F.y+F.h/2-(X.y+X.h/2))<(F.h+X.h)/2+p){P=!0;break}}if(E.size===0&&!P)return[];if(E.size>0)for(const T of b)E.has(T.sid)&&(T.mass=8);else for(const T of b)T.mass=Math.max(1,T.w*T.h/(vi*Xi));const O=new Map(b.map(T=>[T.sid,T.x])),q=new Map(b.map(T=>[T.sid,T.y]));for(let T=0;T<m;T++){const M=new Map,F=new Map;let X=0;for(let Y=0;Y<b.length;Y++)for(let I=Y+1;I<b.length;I++){const H=b[Y],U=b[I];if(H.anchored&&U.anchored)continue;const ne=H.x+H.w/2,J=H.y+H.h/2,D=U.x+U.w/2,G=U.y+U.h/2,k=(H.w+U.w)/2+61-Math.abs(ne-D),L=(H.h+U.h)/2+p-Math.abs(J-G);if(k<=0||L<=0)continue;const oe=(Ke,$e)=>!Ke.anchored&&!($e<0&&Ke.x<=0),$=(Ke,$e)=>!Ke.anchored&&!($e<0&&Ke.y<=0),Q=(Ke,$e,Qe)=>{const bt=Ke===$e,ct=bt?H.sid<U.sid?-1:1:Math.sign(Ke-$e);return Qe(H,ct)||Qe(U,-ct)?ct:bt&&(Qe(H,-ct)||Qe(U,ct))?-ct:0},ee=Q(ne,D,oe),se=Q(J,G,$),ae=ee!==0,pe=se!==0;if(!ae&&!pe)continue;const ge=ae&&(!pe||k*f<L),[Ae,Oe,Me,Pe]=ge?[ee,k,M,oe]:[se,L,F,$],ke=Pe(H,Ae),We=Pe(U,-Ae),ve=H.mass,ye=U.mass,Ge=ke?We?ye/(ve+ye):1:0,ut=We?ke?ve/(ve+ye):1:0,it=Oe*y;Me.set(H.sid,(Me.get(H.sid)??0)+Ae*it*Ge),Me.set(U.sid,(Me.get(U.sid)??0)-Ae*it*ut),X+=it}for(const Y of b)Y.anchored||(Y.x=Math.max(0,Y.x+(M.get(Y.sid)??0)),Y.y=Math.max(0,Y.y+(F.get(Y.sid)??0)));if(X<x)break}const B=[];for(const T of b){const M=T.x-O.get(T.sid),F=T.y-q.get(T.sid);if(!(Math.abs(M)<1&&Math.abs(F)<1)){for(const X of T.members){if(i.has(X))continue;const Y=n.get(X);Y&&n.set(X,{x:Y.x+M,y:Y.y+F})}B.push(T.sid)}}return B}const N$=600;function Wg(e,n){return!(e.exitAt!=null&&n-e.exitAt>N$||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function C$(e,n){const i=new Set;for(const s of e.agents.values())Wg(s,n)&&i.add(s.id);return i}function j$(e,n,i=0){return e.right+i>n.left&&e.left-i<n.right&&e.bottom+i>n.top&&e.top-i<n.bottom}function R$(e,n,i=0){if(!e)return!1;for(const s of n)if(j$(e,s,i))return!0;return!1}function Hi(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function T$(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}const A$={agent:IP,sessionGroup:UP},I$=420,jl=18,M$=9e4,P$=200,O$=5*6e4,q$=6,L$=2*6e4,Pv="agent-dag.layout",Ov="agent-dag.viewport",kC="agent-dag.summariesDismissed",EC="agent-dag.sessionListOpen",NC="agent-dag.detailOpen",CC="agent-dag.usagePanelOpen",qk="agent-dag.accountsPanelOpen",Lk="agent-dag.versionNoticeDismissed",$k={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 $$(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 Dk="agent-dag.autoRestart",Fk="agent-dag.bundleReloadedFor";function D$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(EC)==="1"}catch{return!1}}function F$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(EC,e?"1":"0")}catch{}}function z$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(NC)==="1"}catch{return!1}}function B$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(NC,e?"1":"0")}catch{}}function U$(){if(typeof window>"u")return!0;const e=window.localStorage.getItem(CC);try{return e===null?!0:e==="1"}catch{return!0}}function H$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(CC,e?"1":"0")}catch{}}function V$(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(kC);if(!e)return new Set;const n=JSON.parse(e);return new Set(Array.isArray(n)?n.filter(i=>typeof i=="string"):[])}catch{return new Set}}function zk(e){if(!(typeof window>"u"))try{const n=Array.from(e),i=n.length>200?n.slice(-200):n;window.localStorage.setItem(kC,JSON.stringify(i))}catch{}}function W$(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(Pv);if(!n)return e;const i=JSON.parse(n);if(!("v"in i)){const o=Object.entries(i).filter(([,l])=>l&&typeof l.x=="number"&&typeof l.y=="number");return{positions:o,pins:o.map(([l])=>l)}}return{positions:Object.entries(i.positions??{}).filter(([,o])=>o&&typeof o.x=="number"&&typeof o.y=="number"),pins:Array.isArray(i.pins)?i.pins:[]}}catch{return e}}function Eg(e,n){if(!(typeof window>"u"))try{const i={};for(const[s,o]of e)i[s]=o;for(const[s,o]of n)i[s]=o;window.localStorage.setItem(Pv,JSON.stringify({v:2,positions:i,pins:Array.from(n.keys())}))}catch{}}function G$(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Ov);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 K$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Ov,JSON.stringify(e))}catch{}}function Bk(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Pv)}catch{}try{window.localStorage.removeItem(Ov)}catch{}}}function Y$(e,n){const i=e.agents.get(n);if(!i)return;const s=[];for(const f of e.agents.values())f.sessionId===n&&s.push(f);const o={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:n,label:i.label,cwd:i.cwd,startedAt:i.startedAt,endedAt:i.endedAt,model:i.model,agents:s.map(f=>({id:f.id,kind:f.kind,label:f.label,parentId:f.parentId,state:f.state,startedAt:f.startedAt,endedAt:f.endedAt,model:f.model,cwd:f.cwd,usage:f.usage,prompts:f.prompts,tools:f.tools.map(m=>({id:m.id,name:m.name,inputPreview:m.inputPreview,startedAt:m.startedAt,endedAt:m.endedAt,ok:m.ok,errorPreview:m.errorPreview,usage:m.usage}))}))},l=JSON.stringify(o,null,2),u=new Blob([l],{type:"application/json"}),c=URL.createObjectURL(u),p=document.createElement("a"),h=(i.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 Gg={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Kg={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},X$={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",shell:"shell",exec_command:"shell",shell_command:"shell",write_stdin:"shell",wait:"shell",apply_patch:"file",update_plan:"task",WebFetch:"web",WebSearch:"web",Task:"agent",Agent:"agent",TodoWrite:"task",TaskCreate:"task",TaskUpdate:"task",TaskList:"task",TaskGet:"task",TaskOutput:"task",TaskStop:"task",EnterPlanMode:"plan",ExitPlanMode:"plan",AskUserQuestion:"plan",Skill:"plan",Workflow:"plan"};function jC(e){return e.startsWith("mcp__")?"mcp":X$[e]??"other"}function RC(e,n){var s,o,l;if(!n)return!0;const i=n.toLowerCase();if(e.label.toLowerCase().includes(i)||(s=e.cwd)!=null&&s.toLowerCase().includes(i)||(o=e.cwdBasename)!=null&&o.toLowerCase().includes(i)||e.sessionId.toLowerCase().includes(i)||(l=e.firstPrompt)!=null&&l.toLowerCase().includes(i))return!0;for(const u of e.tools)if(u.name.toLowerCase().includes(i))return!0;return!1}function Q$(e,n){if(!n)return null;const i=new Set([n]);let s=n;for(;s;){const l=e.agents.get(s);if(!(l!=null&&l.parentId)||i.has(l.parentId))break;i.add(l.parentId),s=l.parentId}let o=!0;for(;o;){o=!1;for(const l of e.agents.values())l.parentId&&i.has(l.parentId)&&!i.has(l.id)&&(i.add(l.id),o=!0)}return i}function Z$(e,n,i,s,o,l,u,c,p,h,f,m,y,x,N,_,S,b){const E=[],C=[],j=new Set;if(l)for(const M of e.agents.values())RC(M,l)&&j.add(M.id);for(const M of e.agents.values()){if(!S.has(M.id))continue;const F=l?!j.has(M.id):!1,X=M.exitAt!=null,Y=_!=null&&!_.has(M.id),I=[F?"rf-dim":"",X?"rf-exiting":"",Y?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,H=u.get(M.id);if(E.push({id:M.id,type:"agent",position:{x:0,y:0},data:{...M,now:n,dim:F,onOpenContext:b},className:I,...H?{width:H.width,height:H.height}:null}),M.parentId&&S.has(M.parentId)){const U=pv(M.sessionId),ne=M.state==="active"?`hsl(${U} 80% 72%)`:`hsl(${U} 50% 55%)`,J=l&&!j.has(M.id)&&!j.has(M.parentId),D=X,G=N.size>0&&(N.has(M.id)||N.has(M.parentId)),k=_!=null&&!_.has(M.id)&&!_.has(M.parentId),L=M.state==="active"?2:1.5,oe=G?L+1.5:L,$=J||D?.2:k?.12:1,Q=[D?"rf-edge-exiting":"",G?"rf-edge-selected":""].filter(Boolean).join(" ")||void 0;C.push({id:`e:${M.parentId}->${M.id}`,source:M.parentId,target:M.id,animated:(M.state==="active"||G)&&!J&&!D,type:"smoothstep",style:{stroke:ne,strokeWidth:oe,opacity:$,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:Q})}}const P=new Map;for(const M of e.agents.values())M.tools.length>0&&P.set(M.id,Math.min(4,M.tools.length));const O=E.filter(M=>!o.has(M.id)&&!m.has(M.id));if(O.length>0||y!==x.current){if(O.length>0){const M=S$(E,C,{direction:"LR",pinned:o,measured:u,availableWidth:i,availableHeight:s,lanes:P});for(const F of M)m.has(F.id)||m.set(F.id,F.position);k$(E,m,o,u,new Set(O.map(F=>F.id)))}b$(E,m,o,u),x.current=y}const q=E$(E,m,o,u,c,!h||f);q.length>0&&p(q),cx(m,e.agents),cx(o,e.agents);const B=[];let T=!1;for(const M of E){let F=o.get(M.id)??m.get(M.id);F||(F={x:0,y:0},m.set(M.id,F),T=!0),B.push({...M,position:F})}return T&&(x.current=""),{nodes:B,edges:C}}function J$(){return g.jsx(fv,{children:g.jsx(e4,{})})}function e4(){var ao,ya,Wr,Gr;const e=oa(),n=A.useRef(Bg()),[,i]=A.useState(0),s=A.useCallback(()=>i(V=>V+1),[]),[o,l]=A.useState(()=>new Set),[u,c]=A.useState(null),[p,h]=A.useState(null),f=A.useCallback((V,K)=>{l(ue=>{if(!K)return new Set([V]);const fe=new Set(ue);return fe.has(V)?fe.delete(V):fe.add(V),fe}),c(ue=>K&&ue===V?ue:V)},[]),m=A.useCallback(()=>{l(new Set),c(null)},[]),[y,x]=A.useState(null),[N,_]=A.useState(null),S=A.useCallback(V=>_(V),[]),b=A.useRef(V$()),[E,C]=A.useState(D$);A.useEffect(()=>{F$(E)},[E]);const[j,P]=A.useState(z$);A.useEffect(()=>{B$(j)},[j]);const[O,q]=A.useState(U$);A.useEffect(()=>{H$(O)},[O]);const[B,T]=A.useState(()=>{try{const V=window.localStorage.getItem(qk);return V===null?!0:V==="1"}catch{return!0}});A.useEffect(()=>{try{window.localStorage.setItem(qk,B?"1":"0")}catch{}},[B]);const[M,F]=A.useState(null),[X,Y]=A.useState(!1),[I,H]=A.useState(0),[U,ne]=A.useState(0);A.useEffect(()=>{fetch("/api/sound-hook").then(V=>V.ok?V.json():null).then(V=>{V!=null&&V.ok&&(F(V.enabled===!0),H((V.foreign??[]).filter(K=>K.worksHere).length),ne(typeof V.parked=="number"?V.parked:0))}).catch(()=>{})},[]);const J=A.useCallback(async()=>{Y(!0);try{const K=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!M})})).json().catch(()=>null);K!=null&&K.ok&&F(K.enabled===!0),fetch("/api/sound-hook").then(ue=>ue.ok?ue.json():null).then(ue=>{ue!=null&&ue.ok&&(H((ue.foreign??[]).filter(fe=>fe.worksHere).length),ne(typeof ue.parked=="number"?ue.parked:0))}).catch(()=>{})}catch{}finally{Y(!1)}},[M]),[D,G]=A.useState(!1),[k,L]=A.useState(null),[oe,$]=A.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(Lk)??""}catch{return""}}),[Q,ee]=A.useState(!1),se=A.useCallback((V=!1)=>{fetch(V?"/api/version?refresh=1":"/api/version").then(K=>K.ok?K.json():null).then(K=>{K&&L(K)}).catch(()=>{})},[]);A.useEffect(()=>{se();const V=window.setInterval(se,5*6e4),K=()=>{document.visibilityState==="visible"&&se()};return document.addEventListener("visibilitychange",K),()=>{window.clearInterval(V),document.removeEventListener("visibilitychange",K)}},[se]),A.useEffect(()=>{D&&se()},[D,se]);const ae=(k==null?void 0:k.notice)??null,pe=ae?`${ae.kind}:${ae.to}`:"",ge=ae!=null&&oe!==pe,Ae=A.useCallback(()=>{if(!ae)return;const V=oe===pe?"":pe;$(V);try{window.localStorage.setItem(Lk,V)}catch{}},[ae,pe,oe]),Oe=((ao=k==null?void 0:k.upgrade)==null?void 0:ao.state)??"idle",Me=A.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}se()},[se]);A.useEffect(()=>{if(Oe!=="running")return;const V=window.setInterval(se,3e3);return()=>window.clearInterval(V)},[Oe,se]);const Pe=A.useCallback(async()=>{var ue;const V=k==null?void 0:k.command;if(!V)return;let K=!1;try{K=await Promise.race([((ue=navigator.clipboard)==null?void 0:ue.writeText(V).then(()=>!0))??Promise.resolve(!1),new Promise(fe=>window.setTimeout(()=>fe(!1),500))])}catch{K=!1}if(!K)try{const fe=document.createElement("textarea");fe.value=V,fe.setAttribute("readonly",""),fe.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(fe),fe.select(),K=document.execCommand("copy"),fe.remove()}catch{K=!1}K&&(ee(!0),window.setTimeout(()=>ee(!1),1600))},[k==null?void 0:k.command]),ke=A.useCallback(()=>{C(V=>(V||T(!1),!V))},[]),We=A.useCallback(()=>{T(V=>(V||C(!1),!V))},[]),[ve,ye]=A.useState(!1),[Ge,ut]=A.useState(0),it=A.useRef(null),[Ke,$e]=A.useState(!1),Qe=A.useRef(null),[bt,ct]=A.useState(0),[pt,mt]=A.useState(!1),kt=A.useRef([]),[He,Je]=A.useState(Date.now()),[dt,gt]=A.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(Dk)!=="0"}catch{return!0}}),yt=A.useCallback(()=>{gt(V=>{const K=!V;try{window.localStorage.setItem(Dk,K?"1":"0")}catch{}return K})},[]),[Gt,Pt]=A.useState(!1),[zt,Ln]=A.useState("restart"),[er,bn]=A.useState(null),Bt=A.useRef(!1),Jt=A.useCallback(async V=>{if(Bt.current)return;const K=(V==null?void 0:V.upgrade)===!0;Bt.current=!0,Ln(K?"npx":"restart"),Pt(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(ae==null?void 0:ae.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:K})})}catch{}window.setTimeout(()=>{if(Bt.current){Bt.current=!1,Pt(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},K?18e4:3e4)},[ae==null?void 0:ae.to]),hn=A.useRef(null);A.useEffect(()=>{let V=!1;for(const ue of n.current.agents.values())if(ue.state==="active"){V=!0;break}const K=X3({enabled:dt,kind:ae==null?void 0:ae.kind,canRestart:(k==null?void 0:k.canRestart)===!0,busy:V,idleSince:hn.current,now:He});hn.current=K.idleSince,K.restart&&Jt()},[dt,ae==null?void 0:ae.kind,k==null?void 0:k.canRestart,He,Jt]),A.useEffect(()=>{let V=null;try{V=window.sessionStorage.getItem(Fk)}catch{return}if(Y3({bundle:"1.33.36",running:k==null?void 0:k.running,lastTried:V})){try{window.sessionStorage.setItem(Fk,(k==null?void 0:k.running)??"")}catch{return}window.location.reload()}},[k==null?void 0:k.running]),A.useEffect(()=>{const V=k==null?void 0:k.running;if(!V)return;let K=null;try{K=window.sessionStorage.getItem("agent-dag.restartPending")}catch{return}if(K==null||K&&K!==V)return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}Bt.current=!1,Pt(!1),bn(V);const ue=window.setTimeout(()=>bn(null),6e3);return()=>window.clearTimeout(ue)},[k==null?void 0:k.running]);const $r=A.useRef(W$()).current;A.useRef(!1);const Rt=A.useRef(new Map($r.positions.filter(([V])=>$r.pins.includes(V)))),hr=A.useRef(null),pr=A.useState(()=>G$())[0],[pn,wi]=A.useState(""),[tr,xi]=A.useState(()=>new Set),[mn,rs]=A.useState(()=>typeof window>"u"?"dark":window.localStorage.getItem("agent-dag.theme")??"dark"),[nr,Dr]=A.useState(!1),mr=A.useRef(null);A.useEffect(()=>{document.documentElement.dataset.theme=mn;try{window.localStorage.setItem("agent-dag.theme",mn)}catch{}},[mn]),A.useEffect(()=>{if(!pr)return;const V=window.setTimeout(()=>{try{e.setViewport(pr,{duration:0})}catch{}},60);return()=>window.clearTimeout(V)},[e,pr]);const Fr=A.useRef(!0),Ot=A.useRef(null);A.useEffect(()=>{const V=new EventSource("/events");return V.addEventListener("open",()=>{G(!0),Dr(!0)}),V.addEventListener("error",()=>G(!1)),V.addEventListener("replay-end",()=>{Fr.current=!1,Ot.current!=null&&(window.clearTimeout(Ot.current),Ot.current=null),s()}),V.addEventListener("hook",K=>{try{const ue=JSON.parse(K.data);if(pt){kt.current.push(ue);return}n.current=Xw(n.current,ue),ue.replay===!0||Fr.current||Date.now()-ue.receivedAt>3e4?(Ot.current!=null&&window.clearTimeout(Ot.current),Ot.current=window.setTimeout(()=>{Ot.current=null,s()},120)):(Ot.current!=null&&(window.clearTimeout(Ot.current),Ot.current=null),s())}catch{}}),()=>{V.close(),Ot.current!=null&&(window.clearTimeout(Ot.current),Ot.current=null)}},[pt,s]),A.useEffect(()=>{if(!pt&&kt.current.length!==0){for(const V of kt.current)n.current=Xw(n.current,V);kt.current.length=0,s()}},[pt,s]),A.useEffect(()=>{const V=setInterval(()=>{const K=Date.now();Je(K);let ue=wP(n.current,K,M$);vP(n.current,K,P$,O$)&&(ue=!0),yP(n.current,K,q$,L$)&&(ue=!0),ue&&s()},250);return()=>clearInterval(V)},[s]);const _i=A.useRef(null),$n=A.useRef(0),Dn=420,Kt=A.useCallback((V=500)=>{try{const we=document.querySelector(".canvas-wrap"),Ie=Array.from(document.querySelectorAll(".react-flow__node")).filter(xt=>xt.offsetWidth>0);if(!we||Ie.length===0)return;const Fe=we.getBoundingClientRect(),De=e.getViewport();if(!Number.isFinite(De.zoom)||De.zoom<=0)return;const Ye=xt=>(xt-Fe.left-De.x)/De.zoom,Ze=xt=>(xt-Fe.top-De.y)/De.zoom,yn=Ie.map(xt=>xt.getBoundingClientRect()),sr=Math.min(...yn.map(xt=>Ye(xt.left))),Kr=Math.max(...yn.map(xt=>Ye(xt.right))),Yr=Math.min(...yn.map(xt=>Ze(xt.top))),Lt=Math.max(...yn.map(xt=>Ze(xt.bottom))),_r=Kr-sr,Xr=Lt-Yr;if(!(_r>0&&Xr>0))return;const Xt=Math.max(.2,Math.min(1,(Fe.width-160)/(_r+Dn)*.86,(Fe.height-160)/Xr*.86));e.setViewport({x:80-sr*Xt,y:Math.max(80,(Fe.height-Xr*Xt)/2)-Yr*Xt,zoom:Xt},{duration:V}),$n.current=Date.now(),window.setTimeout(()=>{try{const xt={x:80-sr*Xt,y:Math.max(80,(Fe.height-Xr*Xt)/2)-Yr*Xt,zoom:Xt},us=e.getViewport();(Math.abs(us.zoom-Xt)>.01||Math.abs(us.x-xt.x)>2)&&e.setViewport(xt,{duration:0})}catch{}},V+60)}catch{}},[e]),zr=A.useRef(""),Si=A.useRef(null),bi=A.useRef(0),gr=A.useCallback(()=>{bi.current=Date.now()},[]),Br="agent-dag.autoFitDisabled",kn=A.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Br)==="1"}catch{return!1}})()),[ki,is]=A.useState(kn.current),et=A.useCallback(()=>{if(!kn.current){kn.current=!0,is(!0);try{window.localStorage.setItem(Br,"1")}catch{}}},[]),Qs=A.useCallback(()=>{kn.current=!1,is(!1);try{window.localStorage.removeItem(Br)}catch{}Kt(400)},[e,Kt]);A.useEffect(()=>{const V=setInterval(()=>{if(kn.current||Date.now()-bi.current<800)return;const K=n.current,ue=Date.now(),fe=[];for(const Ye of K.agents.values())Wg(Ye,ue)&&fe.push({id:Ye.id});if(fe.length===0)return;const xe=e.getViewport(),we=window.innerWidth-360,Ie=window.innerHeight-52;let Fe=!1,De=!1;for(const{id:Ye}of fe){const Ze=Fn.current.get(Ye),yn=Rt.current.get(Ye)??Tt.current.get(Ye);if(!Ze||!yn)continue;De=!0;const sr=yn.x*xe.zoom+xe.x,Kr=yn.y*xe.zoom+xe.y,Yr=(yn.x+Ze.width)*xe.zoom+xe.x,Lt=(yn.y+Ze.height)*xe.zoom+xe.y;if(Yr>0&&sr<we&&Lt>0&&Kr<Ie){Fe=!0;break}}De&&!Fe&&Kt(600)},1500);return()=>clearInterval(V)},[e]);const vr=A.useRef(!1),Fn=A.useRef(new Map),yr=A.useRef(0),ss=A.useCallback(V=>{const K=Fn.current;let ue=!1;for(const fe of V.nodeInternals.values()){const xe=fe.width,we=fe.height;if(xe==null||we==null)continue;const Ie=K.get(fe.id);Ie?(Math.abs(Ie.height-we)>4||Math.abs(Ie.width-xe)>4)&&(K.set(fe.id,{width:xe,height:we}),ue=!0):(K.set(fe.id,{width:xe,height:we}),ue=!0)}return ue&&(yr.current+=1),yr.current},[]),Ei=Xe(ss),[wr,en]=A.useState(0);A.useEffect(()=>{let V=0;const K=()=>{const fe=Fn.current;let xe=!1;for(const we of document.querySelectorAll(".react-flow__node[data-id]")){const Ie=we.getAttribute("data-id");if(!Ie)continue;const Fe=we.offsetWidth,De=we.offsetHeight;if(!Fe||!De)continue;const Ye=fe.get(Ie);(!Ye||Math.abs(Ye.width-Fe)>4||Math.abs(Ye.height-De)>4)&&(fe.set(Ie,{width:Fe,height:De}),xe=!0)}xe&&en(we=>we+1)};if(vr.current)return;let ue=0;return document.visibilityState==="hidden"?ue=window.setTimeout(K,32):V=requestAnimationFrame(K),()=>{cancelAnimationFrame(V),window.clearTimeout(ue)}});const Tt=A.useRef(new Map($r.positions)),Yt=A.useRef(""),Ur=A.useMemo(()=>{const V=[];for(const K of n.current.agents.values())Wg(K,He)&&V.push(K.id+(K.parentId?`>${K.parentId}`:""));return V.sort(),`${V.join("|")}#sv${Ei}.${wr}`},[n.current,n.current.lastSeq,He,Ei,wr]),Ni=A.useRef(null);A.useEffect(()=>(Ni.current!=null&&window.clearTimeout(Ni.current),Ni.current=window.setTimeout(()=>{Eg(Tt.current,Rt.current)},1500),()=>{Ni.current!=null&&window.clearTimeout(Ni.current)}),[Ur]),A.useEffect(()=>{if(zr.current===Ur)return;const V=zr.current;if(zr.current=Ur,!V||kn.current)return;Date.now()-$n.current>1200&&Kt(400),_i.current&&window.clearTimeout(_i.current),_i.current=window.setTimeout(()=>{kn.current||Kt(500)},280)},[Ur,e,Kt]);const Zs=A.useMemo(()=>{if(o.size===0)return null;const V=new Set;for(const K of o){const ue=Q$(n.current,K);if(ue)for(const fe of ue)V.add(fe)}return V.size>0?V:null},[n.current,n.current.lastSeq,o]),Hr=A.useMemo(()=>C$(n.current,He),[n.current,n.current.lastSeq,He]),Ci=A.useRef(null),[rr,ji]=A.useState({w:0,h:0});A.useEffect(()=>{const V=Ci.current;if(!V||typeof ResizeObserver>"u")return;const K=new ResizeObserver(ue=>{var xe;const fe=(xe=ue[0])==null?void 0:xe.contentRect;fe&&ji(we=>Math.abs(we.w-fe.width)>40||Math.abs(we.h-fe.height)>40?{w:fe.width,h:fe.height}:we)});return K.observe(V),ji({w:V.clientWidth,h:V.clientHeight}),()=>K.disconnect()},[]);const gu=A.useRef(new Map),[ha,Js]=A.useState(!1);A.useEffect(()=>{const V=window.setTimeout(()=>Js(!0),2500);return()=>window.clearTimeout(V)},[]);const[pa,Ri]=A.useState(!1),tn=A.useRef(null),[eo,os]=A.useState(!1),Ve=A.useCallback(()=>{tn.current&&(window.clearTimeout(tn.current),tn.current=null),Ri(!1)},[]),ma=A.useCallback(V=>{V.length!==0&&queueMicrotask(()=>{Ri(!0),tn.current&&window.clearTimeout(tn.current),tn.current=window.setTimeout(()=>Ri(!1),I$+80)})},[]);A.useEffect(()=>()=>{tn.current&&window.clearTimeout(tn.current)},[]);const to=rr.w>0?rr.w*.92:0,as=rr.h>0?rr.h:0,{nodes:gn,edges:ga}=A.useMemo(()=>Z$(n.current,He,to,as,Rt.current,pn,Fn.current,gu.current,ma,ha,eo,Tt.current,Ur,Yt,o,Zs,Hr,S),[n.current,n.current.lastSeq,He,to,as,ha,eo,pn,Ur,o,Zs,Hr,S,Ge]),no=A.useMemo(()=>{const V=new Map;for(const ue of gn){const fe=ue.data;if(!(fe!=null&&fe.sessionId)||fe.exitAt!=null)continue;const xe=ue.width,we=ue.height;if(xe==null||we==null)continue;const Ie=ue.position.x,Fe=ue.position.y,De=Ie+xe,Ye=Fe+we,Ze=V.get(fe.sessionId);Ze?(Ze.minX=Math.min(Ze.minX,Ie),Ze.minY=Math.min(Ze.minY,Fe),Ze.maxX=Math.max(Ze.maxX,De),Ze.maxY=Math.max(Ze.maxY,Ye)):V.set(fe.sessionId,{minX:Ie,minY:Fe,maxX:De,maxY:Ye})}const K=[];for(const[ue,fe]of V){const xe=fe.maxX-fe.minX+jl*2,we=fe.maxY-fe.minY+jl*2;K.push({id:`group:${ue}`,type:"sessionGroup",position:{x:fe.minX-jl,y:fe.minY-jl},data:{sessionId:ue,w:xe,h:we},width:xe,height:we,style:{width:xe,height:we},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return K},[gn,He]),ro=A.useMemo(()=>{const V=[...no,...gn],K=Qe.current;return!K||K.size===0?V:V.map(ue=>{const fe=K.get(ue.id);return fe?{...ue,position:fe}:ue})},[no,gn,bt]),ls=A.useMemo(()=>{if(!pn)return null;const V=new Set;for(const K of n.current.agents.values())RC(K,pn)&&V.add(K.id);return V},[n.current,n.current.lastSeq,pn]),vn=A.useMemo(()=>{const V=new Set;for(const K of n.current.agents.values())for(const ue of K.tools)V.add(jC(ue.name));return Object.keys(Gg).filter(K=>V.has(K))},[n.current,n.current.lastSeq]);A.useEffect(()=>{if(vn.length<=1){$e(!1);return}let V=0;const K=()=>{const ue=it.current;if(ue&&!document.hidden){const fe=ue.getBoundingClientRect(),xe=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Ie=>Ie.getBoundingClientRect()),we=R$(fe,xe,8);$e(Ie=>Ie===we?Ie:we)}V=window.setTimeout(K,300)};return K(),()=>window.clearTimeout(V)},[vn.length]);const nn=A.useMemo(()=>{const V=new Map;for(const ue of n.current.agents.values())for(const fe of ue.tools){if(!fe.name.startsWith("mcp__"))continue;const xe=fe.name.slice(5),we=xe.indexOf("__"),Ie=we>0?xe.slice(0,we):xe;V.set(Ie,(V.get(Ie)??0)+1)}const K=[];for(const[ue,fe]of V){let xe=5381;for(let we=0;we<ue.length;we++)xe=(xe<<5)+xe^ue.charCodeAt(we);K.push({server:ue,count:fe,hue:Math.abs(xe)%360})}return K.sort((ue,fe)=>fe.count-ue.count),K},[n.current,n.current.lastSeq]),ir=A.useCallback(V=>{xi(K=>{const ue=new Set(K);return ue.has(V)?ue.delete(V):ue.add(V),ue})},[]),wt=u?n.current.agents.get(u):null,Vr=p?Array.from(n.current.agents.values()).flatMap(V=>V.tools).find(V=>V.id===p)??null:null,En=A.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=Bg(),Rt.current.clear(),Fn.current.clear(),Tt.current.clear(),Yt.current="",Bk(),m(),s()},[s,m]),io=A.useCallback(()=>{Rt.current.clear(),Tt.current.clear(),Yt.current="",Bk(),s(),window.setTimeout(()=>Kt(500),80)},[s,e,Kt]),so=A.useCallback(()=>Kt(500),[Kt]),xr=A.useCallback(V=>{if(gn.length===0)return;const K=gn.slice().sort((we,Ie)=>we.position.y-Ie.position.y||we.position.x-Ie.position.x),ue=u?K.findIndex(we=>we.id===u):-1;let fe;ue===-1?fe=V===1?0:K.length-1:fe=(ue+V+K.length)%K.length;const xe=K[fe];xe&&(f(xe.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[xe]})}catch{}$n.current=Date.now()},30))},[gn,u,f,e]);A.useEffect(()=>{const V=K=>{var fe,xe;const ue=((fe=K.target)==null?void 0:fe.tagName)==="INPUT";if(K.key==="Escape"){ue?K.target.blur():m();return}if(!ue&&!Q3(K)){if(K.key==="/"){K.preventDefault(),(xe=mr.current)==null||xe.focus();return}K.key===" "&&(K.preventDefault(),mt(we=>!we)),(K.key==="c"||K.key==="C")&&En(),(K.key==="r"||K.key==="R")&&io(),(K.key==="f"||K.key==="F")&&so(),(K.key==="l"||K.key==="L")&&ke(),(K.key==="h"||K.key==="H")&&ye(we=>!we),(K.key==="u"||K.key==="U")&&q(we=>!we),(K.key==="a"||K.key==="A")&&We(),(K.key==="j"||K.key==="J")&&xr(1),(K.key==="k"||K.key==="K")&&xr(-1),(K.key==="t"||K.key==="T")&&rs(we=>we==="dark"?"light":"dark")}};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[En,io,so,m,xr]);const oo=n.current.agents.size,va=new Set(Array.from(n.current.agents.values()).map(V=>V.sessionId)).size,qt=A.useMemo(()=>{let V=0,K=0,ue=0,fe=0,xe=0,we=0,Ie=0,Fe=0,De=0;for(const Ye of n.current.agents.values()){V+=Ye.usage.inputTokens,K+=Ye.usage.outputTokens,ue+=Ye.usage.cacheReadTokens,fe+=Ye.usage.cacheCreateTokens;const Ze=dn(Ye.usage,Ye.model);xe+=Ze.total,we+=Ze.input,Ie+=Ze.output,Fe+=Ze.cacheRead,De+=Ze.cacheWrite}return{inT:V,outT:K,cacheR:ue,cacheC:fe,sum:V+K,cost:{total:xe,input:we,output:Ie,cacheRead:Fe,cacheWrite:De}}},[n.current,n.current.lastSeq]);return g.jsxs("div",{className:"app",children:[g.jsxs("header",{className:"topbar",children:[g.jsxs("div",{className:"brand",children:[g.jsx("span",{className:"logo"}),"agents-deck",ae?g.jsxs("button",{type:"button",className:"v stale",onClick:Ae,title:ae.kind==="restart"?`Running v${ae.from}; v${ae.to} is installed on disk. Restart to pick it up.`:`Running v${ae.from}; v${ae.to} is on npm.`,children:["v",ae.from,g.jsx("span",{className:"v-dot","aria-hidden":!0})]}):g.jsxs("button",{type:"button",className:"v",onClick:()=>se(!0),title:k!=null&&k.checkDisabled?"Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1).":`${k!=null&&k.latest?`npm has v${k.latest}`:"npm not reached yet"}${k!=null&&k.checkedAt?` · checked ${$$(He-k.checkedAt)}`:""} · click to check now`,children:["v",(k==null?void 0:k.running)??"1.33.36"]})]}),wt&&(()=>{const V=dn(wt.usage,wt.model),K=Math.max(0,((wt.endedAt??He)-wt.startedAt)/1e3),ue=wt.state==="active"?Ul(V.total,K):null,fe=o.size-1;return g.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${wt.label}`,onClick:()=>{try{const xe=gn.find(we=>we.id===wt.id);xe&&e.fitView({padding:.35,duration:500,nodes:[xe]}),$n.current=Date.now()}catch{}},children:[g.jsx("span",{className:`state-pill state-${wt.state}`,children:wt.state==="active"?"live":wt.state}),g.jsx("span",{className:"selected-label",children:wt.label}),V.total>0&&g.jsxs("span",{className:"selected-cost",children:[Be(V.total),ue?g.jsxs("span",{className:"selected-rate",children:[" · ",ue]}):null]}),fe>0&&g.jsxs("span",{className:"selected-extra",children:["+",fe]}),g.jsx("span",{role:"button","aria-label":"Deselect",className:"selected-close",onClick:xe=>{xe.stopPropagation(),m()},children:"×"})]})})(),g.jsxs("div",{className:"actions",children:[g.jsxs("div",{className:"search",children:[g.jsx("span",{className:"search-icon","aria-hidden":!0,children:"⌕"}),g.jsx("input",{ref:mr,type:"text",placeholder:"Search agents, cwd, tools…",value:pn,onChange:V=>wi(V.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),pn?g.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>wi(""),children:"×"}):g.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"})]}),g.jsxs("span",{className:"status",role:"status",children:[g.jsx("span",{className:`pill ${D?"live":"dead"}`,title:D?"Receiving events":"SSE disconnected",children:D?"live":"offline"}),g.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[g.jsx("span",{className:"count",children:va}),g.jsx("span",{className:"lbl",children:"sessions"})]}),g.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[g.jsx("span",{className:"count",children:oo}),g.jsx("span",{className:"lbl",children:"agents"})]}),g.jsxs("span",{className:"stat",title:"Total hook events received",children:[g.jsx("span",{className:"count",children:n.current.totalEvents}),g.jsx("span",{className:"lbl",children:"events"})]}),qt.sum>0&&g.jsxs("span",{className:"stat",title:`in:${qt.inT.toLocaleString()} out:${qt.outT.toLocaleString()} cache-r:${qt.cacheR.toLocaleString()} cache-c:${qt.cacheC.toLocaleString()}`,children:[g.jsx("span",{className:"count",children:T$(qt.sum)}),g.jsx("span",{className:"lbl",children:"tokens"})]}),nn.length>0&&g.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
59
+ burn: ${y}`:"");return g.jsxs("span",{className:"cost-meta",title:x,children:[g.jsx("b",{children:Be(f.total)}),y&&g.jsx("span",{className:"cost-rate",children:y})]})})()]}),g.jsx(Vs,{type:"source",position:Ce.Right,style:{background:"transparent",border:"none"}})]})}function MP({state:e}){const n=e==="active"?"live":e==="done"?"done":"err";return g.jsx("span",{className:`state-pill state-${e}`,children:n})}function PP(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function OP({tools:e,now:n}){const l=new Array(24).fill(0);let u=0;for(const y of e){const x=n-y.startedAt;if(x<0||x>=6e4)continue;const N=23-Math.floor(x/2500);N>=0&&N<24&&(l[N]+=1,u+=1)}const c=Math.max(1,...l),p=132,h=14,f=p/24,m=c/(2500/1e3);return g.jsxs("div",{className:"tool-spark-row",title:`${u} tool calls in last 60s · peak ${m.toFixed(1)}/s`,children:[g.jsx("svg",{className:"tool-spark",width:p,height:h,viewBox:`0 0 ${p} ${h}`,"aria-hidden":!0,children:l.map((y,x)=>{const N=y===0?1.5:Math.max(1.5,y/c*h),_=x===23&&y>0,b=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return g.jsx("rect",{x:x*f+.4,y:h-N,width:Math.max(.5,f-1),height:N,rx:.8,className:b},x)})}),g.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function aa(e){const n=e.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const o=n[1][0].toUpperCase()+n[1].slice(1).toLowerCase(),l=n[2].replace(/[-_]/g,".");return`${o} ${l}`}const i=e.match(/^gpt[-_](\d+(?:[-_.]\d+)*)[-_]codex\b/i);if(i)return`GPT-${i[1].replace(/[-_]/g,".")} Codex`;const s=e.match(/^gpt[-_](\d+(?:[-_.]\d+)*)/i);return s?`GPT-${s[1].replace(/[-_]/g,".")}`:e}function Zw(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function qP(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 LP({tool:e,onClose:n}){A.useEffect(()=>{const s=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]);const i=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return g.jsx("div",{className:"modal-backdrop",onClick:n,role:"dialog","aria-modal":"true",children:g.jsxs("div",{className:"modal",onClick:s=>s.stopPropagation(),children:[g.jsxs("header",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:`status-dot ${i}`}),g.jsx("span",{className:"modal-tool-name",children:e.name}),g.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",children:qP(e)}),g.jsx("button",{className:"btn icon-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),g.jsxs("section",{className:"modal-body",children:[g.jsxs("div",{className:"modal-section",children:[g.jsx("h4",{children:"Input"}),g.jsx("pre",{children:Zw(e.input??e.inputPreview)})]}),g.jsxs("div",{className:"modal-section",children:[g.jsxs("h4",{children:["Response ",i==="err"&&g.jsx("span",{className:"err-tag",children:"error"})]}),g.jsx("pre",{children:e.endedAt==null?"(waiting…)":Zw(e.response??e.errorPreview)})]})]})]})})}const bl=18,Jw=26,$P=12;function DP(e){const n=new Map;for(const o of e.nodeInternals.values()){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=ex(l)??f.label)):n.set(l.sessionId,{minX:u,minY:c,maxX:p,maxY:h,label:ex(l)??l.sessionId})}const i=new Map;for(const o of n.values())i.set(o.label,(i.get(o.label)??0)+1);const s=[];for(const[o,l]of n){const c=(i.get(l.label)??0)>1?`${l.label} · ${FP(o)}`:l.label;s.push({sessionId:o,label:c,x:l.minX-bl,y:l.minY-bl-Jw,w:l.maxX-l.minX+bl*2,h:l.maxY-l.minY+bl*2+Jw})}return s}function FP(e){const n=e.match(/[a-zA-Z0-9]{4}/);return n?n[0]:e.slice(0,4)}function ex(e){if(e.kind==="root")return e.label}function zP(){const{x:e,y:n,zoom:i}=uN(),s=oa(),o=Xe(DP,BP);if(o.length<=1)return null;const l=u=>{try{const c=s.getNodes().filter(p=>{const h=p.data;return(h==null?void 0:h.sessionId)===u});if(c.length===0)return;s.fitView({padding:.3,duration:500,nodes:c})}catch{}};return g.jsx("div",{className:"session-clusters",children:o.map(u=>{const c=pv(u.sessionId),p={position:"absolute",left:u.x*i+e,top:u.y*i+n,width:u.w*i,height:u.h*i,borderColor:`hsl(${c} 65% 55% / 0.32)`,background:`hsl(${c} 70% 50% / 0.04)`},h={position:"absolute",left:u.x*i+e+16*i,top:(u.y-$P)*i+n,color:`hsl(${c} 70% 78%)`,borderColor:`hsl(${c} 65% 55% / 0.5)`,transform:`scale(${Math.min(1,i)})`,transformOrigin:"left top"};return g.jsxs(le.Fragment,{children:[g.jsx("div",{className:"cluster-card",style:p,"aria-hidden":!0}),g.jsx("button",{type:"button",className:"cluster-label",style:h,title:`Fit view to ${u.label} · drag the wrapper to move the whole session`,onClick:()=>l(u.sessionId),children:u.label})]},u.sessionId)})})}function BP(e,n){if(e.length!==n.length)return!1;for(let i=0;i<e.length;i++){const s=e[i],o=n[i];if(s.sessionId!==o.sessionId||s.label!==o.label||s.x!==o.x||s.y!==o.y||s.w!==o.w||s.h!==o.h)return!1}return!0}function UP({data:e}){return g.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const wN=600,HP=36,Hg=16,VP=60,WP=6,tx=220,nx=96,GP=28,KP={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 YP(e){return e.startsWith("mcp__")?"mcp":KP[e]??"other"}const XP={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 rx(e){return e.startsWith("mcp__")?"🔌":XP[e]??"✨"}const QP={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 xN(e){if(!e)return null;let n=e.trim();if(!n)return null;const i=n.match(/^(?:bash|sh|zsh|fish|powershell|pwsh)(?:\.exe)?\s+(?:-c|-Command|-NoProfile|-NonInteractive|\s)+["']([^"']+)["']/i);if(i)return xN(i[1]);for(;;){const l=n.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!l)break;n=n.slice(l[0].length)}n=n.replace(/^sudo(?:\s+-\S+)*\s+/,""),n=n.replace(/^(?:time|nohup|xargs)\s+/,"");const s=n.match(/^([^\s|;&<>(]+)/);if(!s)return null;let o=s[1];return o=o.replace(/^.*[/\\]/,""),o=o.replace(/\.(exe|cmd|bat|ps1)$/i,""),o||null}function ZP(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(i=>typeof i=="string")){const i=n.command;if(/powershell|cmd|bash|sh(\.exe)?$/i.test(i[0]??"")){const s=i.findIndex(o=>/^(-Command|-c)$/i.test(o));if(s>=0&&s+1<i.length)return i[s+1]}return i.join(" ")}return typeof n.script=="string"?n.script:null}const JP=new Set(["Bash","PowerShell","shell","exec_command","shell_command","write_stdin","wait"]),e3=new Set(["shell","exec_command","shell_command","write_stdin","wait","apply_patch","update_plan"]);function t3(e,n){return e3.has(e)?Math.max(nx,34+n.length*7.5):nx}function n3(e,n){if(!JP.has(e))return null;const i=ZP(n);if(!i)return null;const s=xN(i);return s?{emoji:QP[s]??"⚙️",label:s,category:"shell",detail:i}:null}const r3=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),ix={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:"🗄️"},sx={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 i3(e){const i=e.replace(/\\/g,"/").replace(/\/+$/,""),s=i.lastIndexOf("/");return s>=0?i.slice(s+1):i}function s3(e){const n=e.toLowerCase();if(sx[n])return sx[n];if(n.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(n))return"🧪";const i=n.lastIndexOf(".");if(i>0&&i<n.length-1){const s=n.slice(i+1);if(ix[s])return ix[s]}return"📄"}function o3(e,n){if(!n||typeof n!="object")return null;const i=n;if(e==="apply_patch"&&typeof i.patch=="string"){const s=i.patch.match(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/m);return s?s[1].trim():null}return typeof i.file_path=="string"?i.file_path:typeof i.notebook_path=="string"?i.notebook_path:typeof i.path=="string"?i.path:e==="Glob"&&typeof i.pattern=="string"?i.pattern:null}function a3(e,n){if(!r3.has(e))return null;const i=o3(e,n);if(!i)return null;const s=i3(i);return s?{emoji:e==="LS"?"📂":s3(s),label:s,category:"file",detail:i}:null}const _N={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 SN(e){if(!e.startsWith("mcp__"))return null;const n=e.slice(5),i=n.indexOf("__");return i<=0?{server:n,method:""}:{server:n.slice(0,i),method:n.slice(i+2)}}function l3(e){let n=5381;for(let i=0;i<e.length;i++)n=(n<<5)+n^e.charCodeAt(i);return Math.abs(n)%360}function u3(e,n){const i=SN(e);if(!i)return null;const{server:s,method:o}=i;if(!o)return null;const l=_N[s.toLowerCase()];return{emoji:(l==null?void 0:l.emoji)??"🔌",label:o,category:"mcp",detail:l?`${l.name} · ${o}`:`${s} · ${o}`}}function c3(e,n){return n3(e,n)??a3(e,n)??u3(e)}const d3={shell:"Shell",exec_command:"Shell",shell_command:"Shell",write_stdin:"stdin",wait:"wait",apply_patch:"Edit",update_plan:"Plan"};function f3(e){const n=SN(e);if(n){const s=_N[n.server.toLowerCase()];return s?{emoji:s.emoji,label:s.name}:{emoji:"🔌",label:n.server,hue:l3(n.server)}}const i=d3[e];return i?{emoji:rx(e),label:i}:{emoji:rx(e),label:e}}function h3(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function p3(e,n,i){if(i==null)return 1;const s=n-i;return s<0?1:Math.max(0,1-s/wN)}function m3(e,n,i,s,o,l){const u=[];for(const c of e.values()){if(!n.has(c.id)||c.exitAt!=null&&l-c.exitAt>wN)continue;const p=s.get(c.id)??i.get(c.id);if(!p)continue;const h=c.tools.slice(-4);if(h.length===0)continue;const f=c.exitAt??null,m=o.get(c.id),y=Math.max((m==null?void 0:m.width)??tx,tx),x=(m==null?void 0:m.height)??130,N=p.x,_=p.y,S=N+y,b=_+x/2;h.forEach((E,C)=>{const j=C*HP,P=N+y+VP,O=_+WP+j,q=p3(E,l,f),B=E.inputPreview??"",T=h3(E),M=q<.999,F=f3(E.name);u.push({id:E.id,toolId:E.id,agentId:c.id,toolName:E.name,name:F.label,emoji:F.emoji,status:T,category:YP(E.name),mcpHue:F.hue,inputPreview:B,fade:q,fading:M,worldX:P,worldY:O,anchorX:S,anchorY:b,spawnDx:S-P,spawnDy:b-(O+Hg)});const X=c3(E.name,E.input);if(X){const Y=t3(E.name,F.label),I=P+Y+GP,H=O,U=P+Y,ne=O+Hg;u.push({id:`sub:${E.id}`,toolId:E.id,agentId:c.id,toolName:E.name,name:X.label,emoji:X.emoji,isSub:!0,status:T,category:X.category,inputPreview:X.detail??B,fade:q,fading:M,worldX:I,worldY:H,anchorX:U,anchorY:ne,spawnDx:U-I,spawnDy:0})}})}return u}function g3({agents:e,visibleAgentIds:n,positions:i,pinned:s,measured:o,dimUnmatched:l,spotlight:u,hiddenCategories:c,now:p,onOpenTool:h}){const{x:f,y:m,zoom:y}=uN(),x=m3(e,n,i,s,o,p),N=c&&c.size>0?x.filter(_=>!c.has(_.category)):x;return g.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[g.jsx("svg",{className:"tool-bursts-svg",children:N.map(_=>{const S=_.anchorX*y+f,b=_.anchorY*y+m,E=(_.worldX+6)*y+f,C=(_.worldY+Hg)*y+m,j=S+(E-S)*.55,P=l!=null&&!l.has(_.agentId),O=u!=null&&!u.has(_.agentId),q=_.fade*(P||O?.14:1);return g.jsx("path",{d:`M ${S} ${b} Q ${j} ${b}, ${E} ${C}`,className:`tool-conn status-${_.status}${_.fading?" fading":""}`,opacity:q},`l:${_.id}`)})}),N.map(_=>{const S=_.worldX*y+f,b=_.worldY*y+m,E={left:`${S}px`,top:`${b}px`,transform:`scale(${y})`,transformOrigin:"left top","--spawn-dx":`${_.spawnDx}px`,"--spawn-dy":`${_.spawnDy}px`},C=_.isSub?`${_.toolName} · ${_.name}`:_.toolName,j=_.inputPreview?`${C} · ${_.inputPreview}`:C,P=h!=null,O=_.mcpHue!=null?{"--cat-accent":`hsl(${_.mcpHue} 65% 65%)`}:{},q=l!=null&&!l.has(_.agentId),B=u!=null&&!u.has(_.agentId),T=q||B?" dim":"";return g.jsx("div",{className:"tool-burst-wrap",style:E,children:g.jsxs("div",{className:`tool-burst cat-${_.category} status-${_.status}${_.fading?" fading":""}${P?" clickable":""}${_.isSub?" sub":""}${T}`,style:O,title:j,role:P?"button":void 0,tabIndex:P?0:void 0,"aria-label":P?`Open ${_.toolName} ${_.status==="inflight"?"in flight":_.status} — click for details`:void 0,onClick:P?()=>h(_.toolId):void 0,onKeyDown:P?M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),h(_.toolId))}:void 0,children:[g.jsx("span",{className:"tb-emoji",children:_.emoji}),g.jsx("span",{className:"tb-name",children:_.name}),_.status==="inflight"&&g.jsx("span",{className:"tb-spin"}),_.status==="done"&&g.jsx("span",{className:"tb-mark done",children:"✓"}),_.status==="err"&&g.jsx("span",{className:"tb-mark err",children:"×"})]})},_.id)})]})}function v3({state:e,sessionId:n,onClose:i}){const s=A.useMemo(()=>w3(e,n),[e,n]);return s?g.jsx("div",{className:"modal-backdrop",onClick:i,role:"presentation",children:g.jsxs("div",{className:"modal session-summary",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[g.jsxs("div",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),g.jsx("span",{id:"ss-title",className:"modal-tool-name",title:s.cwd??s.sessionId,children:s.label}),g.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.durationLabel}),g.jsx("button",{className:"btn",onClick:i,"aria-label":"Close",children:"×"})]})]}),g.jsxs("div",{className:"modal-body",children:[g.jsxs("section",{className:"ss-hero",children:[g.jsxs("div",{className:"ss-hero-left",children:[g.jsx("div",{className:"ss-cost-label",children:"total spend"}),g.jsx("div",{className:"ss-cost",children:Be(s.cost.total)}),s.modelChips.length>0&&g.jsx("div",{className:"ss-models",children:s.modelChips.map(o=>g.jsx("span",{className:"model-chip",title:o,children:aa(o)},o))})]}),g.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&g.jsxs(g.Fragment,{children:[g.jsx(y3,{cost:s.cost}),g.jsxs("div",{className:"ss-cost-legend",children:[g.jsxs("span",{className:"ssl ssl-in",children:["input ",g.jsx("b",{children:Be(s.cost.input)})]}),g.jsxs("span",{className:"ssl ssl-out",children:["output ",g.jsx("b",{children:Be(s.cost.output)})]}),g.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",g.jsx("b",{children:Be(s.cost.cacheRead)})]}),g.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",g.jsx("b",{children:Be(s.cost.cacheWrite)})]})]})]})})]}),g.jsxs("section",{className:"ss-stats",children:[g.jsx(Ps,{label:"agents",value:s.agentCount}),g.jsx(Ps,{label:"subagents",value:s.subagentCount}),g.jsx(Ps,{label:"tool calls",value:s.toolCount}),g.jsx(Ps,{label:"prompts",value:s.promptCount}),g.jsx(Ps,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&g.jsx(Ps,{label:"errors",value:s.errCount,tone:"err"})]}),s.topTools.length>0&&g.jsxs("section",{className:"modal-section",children:[g.jsx("h4",{children:"Most-used tools"}),g.jsx("div",{className:"ss-top-tools",children:s.topTools.map(([o,l])=>g.jsxs("div",{className:"ss-tt",children:[g.jsx("span",{className:"ss-tt-name",children:o}),g.jsx("span",{className:"ss-tt-bar",children:g.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${l/s.topTools[0][1]*100}%`}})}),g.jsx("span",{className:"ss-tt-count",children:l})]},o))})]}),s.firstPrompt&&g.jsxs("section",{className:"modal-section",children:[g.jsx("h4",{children:"Opening prompt"}),g.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]})]})}):null}function Ps({label:e,value:n,tone:i}){return g.jsxs("div",{className:`ss-stat${i?` tone-${i}`:""}`,children:[g.jsx("div",{className:"ss-stat-value",children:n}),g.jsx("div",{className:"ss-stat-label",children:e})]})}function y3({cost:e}){const n=e.total;if(n<=0)return null;const i=(s,o,l)=>{if(s<=0)return null;const u=s/n*100;return g.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${Be(s)} (${u.toFixed(0)}%)`},o)};return g.jsxs("div",{className:"cost-bar cost-bar-lg","aria-label":"Cost breakdown",children:[i(e.input,"cb-input","input"),i(e.output,"cb-output","output"),i(e.cacheRead,"cb-cache-r","cache read"),i(e.cacheWrite,"cb-cache-w","cache write")]})}function w3(e,n){const i=e.agents.get(n);if(!i)return null;const s=[];for(const C of e.agents.values())C.sessionId===n&&s.push(C);if(s.length===0)return null;const o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},l=new Set,u=new Map;let c=0,p=0,h=0,f=0,m=0,y,x=1/0,N=0;for(const C of s){const j=dn(C.usage,C.model);o.input+=j.input,o.output+=j.output,o.cacheRead+=j.cacheRead,o.cacheWrite+=j.cacheWrite,o.total+=j.total,C.model&&l.add(C.model),C.kind==="subagent"&&m++,p+=C.prompts.length,!y&&C.prompts.length>0&&(y=C.prompts[0].text),h+=C.usage.inputTokens+C.usage.outputTokens,c+=C.tools.length,x=Math.min(x,C.startedAt),N=Math.max(N,C.endedAt??Date.now());for(const P of C.tools)u.set(P.name,(u.get(P.name)??0)+1),P.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`,E=Array.from(u.entries()).sort((C,j)=>j[1]-C[1]).slice(0,5);return{sessionId:n,label:i.label||i.cwdBasename||"session",cwd:i.cwd,durationLabel:b,cost:o,modelChips:Array.from(l),agentCount:s.length,subagentCount:m,toolCount:c,promptCount:p,tokensSum:h,errCount:f,topTools:E,firstPrompt:y}}function x3(e,n){const i=[];for(const s of e.agents.values()){if(s.kind!=="root")continue;let o=s.tools.length,l=dn(s.usage,s.model).total,u=s.endedAt??s.startedAt;for(const c of e.agents.values()){if(c.sessionId!==s.sessionId||c.kind==="root")continue;o+=c.tools.length,l+=dn(c.usage,c.model).total;const p=c.endedAt??c.startedAt;p>u&&(u=p)}i.push({sessionId:s.sessionId,label:s.label||s.cwdBasename||"session",cwdBasename:s.cwdBasename,state:s.state,modelId:s.model,toolCount:o,cost:l,startedAt:s.startedAt,lastActivity:u})}return i.sort((s,o)=>{if(s.state!==o.state){if(s.state==="active")return-1;if(o.state==="active")return 1}return o.lastActivity-s.lastActivity}),i}function _3(e,n,i){const s=(n??i)-e;if(s<1e3)return"<1s";const o=Math.floor(s/1e3);if(o<60)return`${o}s`;const l=Math.floor(o/60);return l<60?`${l}m`:`${Math.floor(l/60)}h ${l%60}m`}function S3({state:e,now:n,selectedIds:i,onSelect:s,onClose:o}){const l=A.useMemo(()=>x3(e),[e,e.lastSeq,n]),u=l.filter(c=>c.state==="active").length;return g.jsxs("aside",{className:"session-list","aria-label":"Sessions",children:[g.jsxs("div",{className:"sl-header",children:[g.jsxs("h3",{children:["Sessions ",g.jsx("span",{className:"sl-count",children:l.length})]}),u>0&&g.jsxs("span",{className:"sl-live-count",children:[u," live"]}),g.jsx("button",{className:"btn icon-btn sl-close",onClick:o,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),g.jsxs("div",{className:"sl-rows",children:[l.length===0&&g.jsx("div",{className:"sl-empty",children:"No sessions yet."}),l.map(c=>{const p=i.has(c.sessionId);return g.jsxs("button",{type:"button",className:`sl-row state-${c.state}${p?" selected":""}`,onClick:()=>s(c.sessionId),title:`Focus ${c.label}`,children:[g.jsx("span",{className:`sl-dot state-${c.state}`,"aria-hidden":!0}),g.jsxs("div",{className:"sl-row-body",children:[g.jsxs("div",{className:"sl-row-head",children:[g.jsx("span",{className:"sl-label",children:c.label}),c.modelId&&g.jsx("span",{className:"model-chip",title:c.modelId,children:aa(c.modelId)})]}),g.jsxs("div",{className:"sl-row-meta",children:[g.jsxs("span",{title:"tool calls",children:[g.jsx("b",{children:c.toolCount})," tools"]}),c.cost>0&&g.jsx("span",{className:"sl-cost",title:"total spend",children:g.jsx("b",{children:Be(c.cost)})}),g.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(c.startedAt).toLocaleString()}`,children:_3(c.startedAt,c.state==="active"?void 0:c.lastActivity,n)})]})]})]},c.sessionId)})]})]})}function ox(e,n){if(!e)return null;const i=n-Math.floor(e/1e3);return i<10?"just now":i<60?`${i}s ago`:i<3600?`${Math.floor(i/60)}m ago`:`${Math.floor(i/3600)}h ago`}function b3(e){return e==="claude-swap"?"Read from claude-swap's last collection — costs no request against your usage-endpoint budget":e==="api"?"Fetched from Anthropic's usage endpoint, at most once every 5 minutes":e==="cli"?"Parsed from `claude /usage`, at most once every 5 minutes":"Last update"}function Ar(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function k3({cost:e}){const n=e.total;if(n<=0)return null;const i=(s,o,l)=>{if(s<=0)return null;const u=s/n*100;return g.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${Be(s)} (${u.toFixed(0)}%)`},o)};return g.jsxs("div",{className:"cost-bar","aria-label":"Cost breakdown",children:[i(e.input,"cb-input","input"),i(e.output,"cb-output","output"),i(e.cacheRead,"cb-cache-r","cache read"),i(e.cacheWrite,"cb-cache-w","cache write")]})}function E3(e,n){const i=e-n;if(i<=0)return null;const s=Math.floor(i/3600),o=Math.floor(i%3600/60);if(s>23){const l=Math.floor(i/86400),u=Math.floor(i%86400/3600);return`${l}d ${u}h`}return s>0?`${s}h ${o}m`:`${o}m`}function N3(e,n,i,s){const o=Math.max(0,n-s),l=Math.max(0,i-o);if(l<120)return null;const u=Math.min(100,l/i*100),c=e-u;if(Math.abs(c)<3)return{label:"on pace",color:"var(--ok)",expectedPct:u,isDeficit:!1};if(c>0){const p=100-e,h=l>0?e/l:0,f=h>0?p/h:1/0,m={label:`${Math.round(c)}% ahead`,color:"var(--warn)",expectedPct:u,isDeficit:!0};if(f<o&&f<86400){const y=Math.floor(f/3600),x=Math.floor(f%3600/60);m.runsOutIn=y>0?`${y}h ${x}m`:`${x}m`}return m}return{label:`${Math.round(-c)}% reserve`,color:"var(--ok)",expectedPct:u,isDeficit:!1}}function Bi({pct:e,label:n,reset:i,resetAt:s,windowSec:o,limitReached:l,nowSec:u}){const c=Math.min(100,Math.max(0,e)),h=l||c>=90?"var(--err)":c>=70?"var(--warn)":"var(--accent)",f=c===0?"< 1%":`${c}%`,m=c===0?2:c,y=s?E3(s,u):null,x=s&&o?N3(c,s,o,u):null;return g.jsxs("div",{className:"qb-row",children:[g.jsxs("div",{className:"qb-meta",children:[g.jsxs("span",{className:"qb-label",children:[n,l&&g.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),g.jsx("span",{className:"qb-pct",style:{color:h},children:f})]}),g.jsxs("div",{className:"qb-track",children:[g.jsx("div",{className:"qb-fill",style:{width:`${m}%`,background:h,opacity:c===0?.4:1}}),x&&g.jsx("div",{className:"qb-pace-marker",style:{left:`${x.expectedPct}%`,background:x.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(x.expectedPct)}% by now`})]}),g.jsxs("div",{className:"qb-reset-row",children:[y?g.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):i?g.jsxs("span",{className:"qb-reset",children:["resets ",i]}):null,x&&g.jsx("span",{className:"qb-pace",style:{color:x.color},children:x.runsOutIn?`runs out in ${x.runsOutIn}`:x.label})]})]})}const C3=6e4;function j3(){const[e,n]=A.useState(null),[i,s]=A.useState(!1),o=A.useRef(null),l=async(c=!1)=>{c&&s(!0);try{const h=await fetch(c?"/api/quota?refresh=1":"/api/quota");h.ok&&n(await h.json())}catch{}finally{c&&s(!1)}};return A.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),C3),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{quota:e,loading:i,refresh:()=>l(!0)}}function R3(e){switch(e){case"no_token":return"Run codex login to authenticate.";case"api_key_mode":return"API-key login — ChatGPT quota is only available for codex login.";case"refresh_rejected":return"Codex session expired — run codex login.";case"refresh_failed":return"Couldn't refresh the Codex token — click ↻ to retry.";default:return"ChatGPT API unreachable — click ↻ to retry."}}const bN=6e4;function T3(){const[e,n]=A.useState(null),[i,s]=A.useState(!1),o=A.useRef(null),l=async(c=!1)=>{c&&s(!0);try{const h=await fetch(c?"/api/codex-quota?refresh=1":"/api/codex-quota");h.ok&&n(await h.json())}catch{}finally{c&&s(!1)}};return A.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),bN),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{data:e,loading:i,refresh:()=>l(!0)}}function A3(){const[e,n]=A.useState(null),i=A.useRef(null),s=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return A.useEffect(()=>(s(),i.current=window.setInterval(s,bN),()=>{i.current!=null&&window.clearInterval(i.current)}),[]),{data:e}}function I3({state:e,now:n,onClose:i}){var q,B;const{quota:s,loading:o,refresh:l}=j3(),{data:u,loading:c,refresh:p}=T3(),{data:h}=A3(),[f,m]=A.useState(()=>Math.floor(Date.now()/1e3));A.useEffect(()=>{const T=window.setInterval(()=>m(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(T)},[]);const{byModel:y,totalCost:x,totalTokens:N,burnRate:_}=A.useMemo(()=>{const T=new Map,M={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let F=0,X=0,Y=0,I=0;for(const D of e.agents.values()){const G=D.model??"__unknown__",k=dn(D.usage,D.model),L=T.get(G);L?(L.inputTokens+=D.usage.inputTokens,L.outputTokens+=D.usage.outputTokens,L.cacheReadTokens+=D.usage.cacheReadTokens,L.cacheCreateTokens+=D.usage.cacheCreateTokens,L.cost.total+=k.total,L.cost.input+=k.input,L.cost.output+=k.output,L.cost.cacheRead+=k.cacheRead,L.cost.cacheWrite+=k.cacheWrite,L.agentCount++):T.set(G,{model:G,inputTokens:D.usage.inputTokens,outputTokens:D.usage.outputTokens,cacheReadTokens:D.usage.cacheReadTokens,cacheCreateTokens:D.usage.cacheCreateTokens,cost:{...k},agentCount:1}),M.total+=k.total,M.input+=k.input,M.output+=k.output,M.cacheRead+=k.cacheRead,M.cacheWrite+=k.cacheWrite,F+=D.usage.inputTokens,X+=D.usage.outputTokens,Y+=D.usage.cacheReadTokens,I+=D.usage.cacheCreateTokens}const H=Array.from(T.values()).sort((D,G)=>G.cost.total-D.cost.total);let U=0,ne=0;for(const D of e.agents.values()){if(D.state!=="active")continue;const G=dn(D.usage,D.model);U+=G.total,ne=Math.max(ne,((D.endedAt??n)-D.startedAt)/1e3)}const J=ne>0?Ul(U,ne):null;return{byModel:H,totalCost:M,totalTokens:{in:F,out:X,cacheR:Y,cacheC:I},burnRate:J}},[e,e.lastSeq,n]),S=A.useMemo(()=>{const T=[];for(const M of e.agents.values()){if(M.kind!=="root")continue;let F=dn(M.usage,M.model).total,X=M.usage.inputTokens,Y=M.usage.outputTokens;for(const I of e.agents.values())I.sessionId!==M.sessionId||I.kind==="root"||(F+=dn(I.usage,I.model).total,X+=I.usage.inputTokens,Y+=I.usage.outputTokens);T.push({sessionId:M.sessionId,label:M.label||M.cwdBasename||"session",state:M.state,cost:F,inputTokens:X,outputTokens:Y})}return T.sort((M,F)=>F.cost-M.cost).slice(0,12)},[e,e.lastSeq]),b=x.total>0,E=N.in+N.out,C=o||c,j=ox(s==null?void 0:s.fetchedAt,f),P=ox(u==null?void 0:u.fetchedAt,f),O=()=>{l(),p()};return g.jsxs("div",{className:"usage-panel","aria-label":"Usage",children:[g.jsxs("div",{className:"up-header",children:[g.jsx("h3",{children:"Usage"}),_&&g.jsx("span",{className:"up-rate",children:_}),g.jsxs("div",{className:"up-header-right",children:[g.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:O,disabled:C,title:"Refresh Claude + Codex quota",children:C?"…":"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn up-close",onClick:i,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h4",{className:"up-section-title",children:["Claude quota",j&&!o&&g.jsx("span",{className:"up-section-age",title:b3(s==null?void 0:s.source),children:j})]}),s!=null&&s.ok?g.jsxs("div",{className:"up-quota-bars",children:[s.session5hPct!=null&&g.jsx(Bi,{label:"5-hour window",pct:s.session5hPct,reset:s.session5hReset,resetAt:s.session5hResetAt,windowSec:s.session5hWindowSec,nowSec:f}),s.week7dPct!=null&&g.jsx(Bi,{label:"7-day window",pct:s.week7dPct,reset:s.week7dReset,resetAt:s.week7dResetAt,windowSec:s.week7dWindowSec,nowSec:f}),s.weekSonnetPct!=null&&g.jsx(Bi,{label:"Sonnet (7d)",pct:s.weekSonnetPct,nowSec:f}),s.weekOpusPct!=null&&g.jsx(Bi,{label:"Opus (7d)",pct:s.weekOpusPct,nowSec:f})]}):(s==null?void 0:s.ok)===!1?g.jsxs("div",{className:"up-quota-na",children:[g.jsx("span",{children:"Quota unavailable."}),g.jsxs("span",{className:"up-quota-hint",children:["Run ",g.jsx("code",{children:"/usage"})," in a claude session, then click ↻"]})]}):g.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h4",{className:"up-section-title",children:["Codex quota",(u==null?void 0:u.ok)&&u.planLabel&&g.jsx("span",{className:"up-plan-badge",children:u.planLabel}),P&&!c&&g.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:P})]}),u!=null&&u.ok?g.jsxs("div",{className:"up-quota-bars",children:[(q=u.windows)==null?void 0:q.map(T=>g.jsx(Bi,{label:T.label,pct:T.pct,reset:T.reset??void 0,resetAt:T.resetAt??void 0,windowSec:T.windowSec??void 0,limitReached:u.limitReached&&T.pct>=100,nowSec:f},T.id)),(B=u.extraWindows)==null?void 0:B.map(T=>g.jsx(Bi,{label:T.label,pct:T.pct,reset:T.reset??void 0,resetAt:T.resetAt??void 0,windowSec:T.windowSec??void 0,nowSec:f},T.id)),u.creditLimit&&g.jsx(Bi,{label:`spend cap · $${Math.round(u.creditLimit.used)} of $${Math.round(u.creditLimit.limit)}`,pct:u.creditLimit.usedPct,reset:u.creditLimit.reset??void 0,resetAt:u.creditLimit.resetAt??void 0,limitReached:u.spendControlReached,nowSec:f}),(h==null?void 0:h.ok)&&h.window7d&&h.window7d.sessionCount>0&&g.jsxs("div",{className:"up-quota-sub",children:[Ar(h.window7d.totalTokens)," tokens · ",h.window7d.sessionCount," session",h.window7d.sessionCount!==1?"s":""," (7d)"]}),u.creditsBalance&&!u.creditsUnlimited&&g.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",u.creditsBalance,u.overageReached&&" · overage limit reached"]}),u.creditsUnlimited&&g.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),u.resetCredits&&u.resetCredits.availableCount>0&&g.jsxs("div",{className:"up-quota-sub up-reset-credits",title:"Redeem in the Codex CLI or ChatGPT — agents-deck only reports them",children:[u.resetCredits.availableCount," rate-limit reset",u.resetCredits.availableCount!==1?"s":""," available",u.resetCredits.nextExpiryAt&&` · expires ${new Date(u.resetCredits.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`]}),u.promo&&g.jsx("div",{className:"up-quota-sub",children:u.promo}),u.partial&&g.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(u==null?void 0:u.ok)===!1?g.jsxs("div",{className:"up-quota-na",children:[g.jsx("span",{children:"Quota unavailable."}),g.jsx("span",{className:"up-quota-hint",children:R3(u.reason)})]}):g.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),b?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"up-total",children:[g.jsx("span",{className:"up-total-value",children:Be(x.total)}),g.jsx("span",{className:"up-total-label",children:"total spend"})]}),g.jsx(k3,{cost:x}),E>0&&g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),Ar(N.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),Ar(N.out)]}),N.cacheR>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache r"}),Ar(N.cacheR)]}),N.cacheC>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache c"}),Ar(N.cacheC)]})]}),y.filter(T=>T.cost.total>0).length>0&&g.jsxs("section",{className:"up-section",children:[g.jsx("h4",{className:"up-section-title",children:"By model"}),g.jsxs("table",{className:"up-table",children:[g.jsx("thead",{children:g.jsxs("tr",{children:[g.jsx("th",{children:"Model"}),g.jsx("th",{children:"Tokens"}),g.jsx("th",{children:"Cost"})]})}),g.jsx("tbody",{children:y.filter(T=>T.cost.total>0).map(T=>g.jsxs("tr",{children:[g.jsx("td",{className:"up-model-name",title:T.model,children:aa(T.model)}),g.jsx("td",{className:"up-num",children:Ar(T.inputTokens+T.outputTokens)}),g.jsx("td",{className:"up-num up-cost-val",children:Be(T.cost.total)})]},T.model))})]})]}),S.filter(T=>T.cost>0).length>0&&g.jsxs("section",{className:"up-section",children:[g.jsx("h4",{className:"up-section-title",children:"By session"}),g.jsx("div",{className:"up-sessions",children:S.filter(T=>T.cost>0).map(T=>g.jsxs("div",{className:"up-session-row",children:[g.jsx("span",{className:`sl-dot state-${T.state}`,"aria-hidden":!0}),g.jsx("span",{className:"up-session-label",children:T.label}),g.jsx("span",{className:"up-session-tokens",children:Ar(T.inputTokens+T.outputTokens)}),g.jsx("span",{className:"up-session-cost",children:Be(T.cost)})]},T.sessionId))})]})]}):E>0?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),Ar(N.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),Ar(N.out)]})]}),g.jsx("div",{className:"up-hint",children:"Cost appears once a known model is detected."})]}):g.jsxs("div",{className:"up-empty",children:["No usage data yet.",g.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const ax=18,M3=1100,Os=(e,n)=>{const i=Math.sin(e*12.9898+n*78.233)*43758.5453;return i-Math.floor(i)},P3=Array.from({length:ax},(e,n)=>{const i=-72+144*n/(ax-1)+(Os(n,1)-.5)*9,s=(i-90)*(Math.PI/180),o=(54+32*Math.cos(i*Math.PI/180))*(.74+Os(n,2)*.52);return{dx:Math.cos(s)*o,dy:Math.sin(s)*o,rot:(n%2?1:-1)*(100+Os(n,3)*260),delay:Math.round(Os(n,4)*90),dur:760+Math.round(Os(n,5)*260),scale:.8+Os(n,6)*.45,hue:n%4,round:n%3===0}});function lx({anchor:e,lifetimeMs:n=M3}){var l;const[i,s]=A.useState(null),o=typeof window<"u"&&((l=window.matchMedia)==null?void 0:l.call(window,"(prefers-reduced-motion: reduce)").matches);return A.useEffect(()=>{if(o)return;const u=e.current;if(!u)return;const c=u.getBoundingClientRect();s({x:c.left+c.width/2,y:c.top+c.height/2});const p=window.setTimeout(()=>s(null),n);return()=>window.clearTimeout(p)},[e,n,o]),o||!i?null:JA.createPortal(g.jsx("div",{className:"confetti",style:{left:`${i.x}px`,top:`${i.y}px`},"aria-hidden":!0,children:P3.map((u,c)=>g.jsx("span",{className:`confetti-bit${u.round?" round":""}`,"data-hue":u.hue,style:{"--dx":`${u.dx.toFixed(1)}px`,"--dy":`${u.dy.toFixed(1)}px`,"--rot":`${u.rot}deg`,"--s":u.scale.toFixed(2),animationDelay:`${u.delay}ms`,animationDuration:`${u.dur}ms, ${u.dur}ms`}},c))}),document.body)}const O3=1500;async function kl(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const q3={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"},od=(e,n)=>(e==null?void 0:e.detail)||(e!=null&&e.reason?q3[e.reason]??e.reason:null)||(e==null?void 0:e.error)||n,Vg=le.forwardRef((e,n)=>g.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:n,children:[g.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),g.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));Vg.displayName="SuccessMark";function L3({onClose:e,onChanged:n}){const[i,s]=A.useState("login"),[o,l]=A.useState(null),[u,c]=A.useState(""),[p,h]=A.useState(""),[f,m]=A.useState(!1),[y,x]=A.useState(null),[N,_]=A.useState(null),S=A.useRef(!1),b=A.useRef(null),E=A.useRef(null),C=A.useRef(null),j=A.useCallback(()=>{S.current&&kl({action:"login-cancel"}).catch(()=>{}),e()},[e]);A.useEffect(()=>{const T=M=>{M.key==="Escape"&&j()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[j]);const P=A.useCallback(async()=>{m(!0),x(null),S.current=!0;const T=await kl({action:"login"}).catch(()=>null);if(m(!1),!(T!=null&&T.ok)){x(od(T,"could not start the sign-in"));return}l(T)},[]);A.useEffect(()=>{if(!o||o.state==="done"||o.state==="failed")return;const T=window.setInterval(async()=>{try{const M=await fetch("/api/claude-accounts/login");M.ok&&l(await M.json())}catch{}},O3);return()=>window.clearInterval(T)},[o]),A.useEffect(()=>{var T;(o==null?void 0:o.state)==="awaiting_code"&&((T=b.current)==null||T.focus()),(o==null?void 0:o.state)==="done"&&n()},[o==null?void 0:o.state,n]),A.useEffect(()=>{var T;i==="paste"&&((T=E.current)==null||T.focus())},[i]);const O=A.useCallback(async()=>{var M;m(!0),x(null);const T=await kl({action:"login-code",code:u}).catch(()=>null);if(m(!1),!(T!=null&&T.ok)){x(od(T,"the code was not accepted")),T!=null&&T.state&&l(T),(M=b.current)==null||M.select();return}c(""),l(T)},[u,o]),q=A.useCallback(async()=>{m(!0),x(null);const T=await kl({action:"import",blob:p}).catch(()=>null);if(m(!1),!(T!=null&&T.ok)){x(od(T,"the import failed"));return}h(""),_({added:T.added===!0,num:T.num??null,email:T.email??null}),n()},[p,n]),B=(o==null?void 0:o.state)==="done"?o.account:null;return g.jsx("div",{className:"modal-backdrop",onClick:j,role:"presentation",children:g.jsxs("div",{className:"modal aa-modal",onClick:T=>T.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[g.jsxs("header",{className:"modal-head",children:[g.jsx("div",{className:"modal-title",children:g.jsxs("span",{className:"aa-tabs",role:"tablist",children:[g.jsx("button",{type:"button",role:"tab","aria-selected":i==="login",className:`aa-tab${i==="login"?" on":""}`,onClick:()=>s("login"),children:"Sign in"}),g.jsx("button",{type:"button",role:"tab","aria-selected":i==="paste",className:`aa-tab${i==="paste"?" on":""}`,onClick:()=>s("paste"),children:"Paste a share"})]})}),g.jsx("div",{className:"modal-actions",children:g.jsx("button",{type:"button",className:"btn icon-btn",onClick:j,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),g.jsx("section",{className:"modal-body aa-body",children:i==="login"?B?g.jsxs("div",{className:"aa-done",children:[g.jsx(Vg,{ref:C}),g.jsx(lx,{anchor:C}),g.jsx("h4",{children:B.added?`Account ${B.num} added`:"Credentials refreshed"}),g.jsxs("p",{className:"aa-note",children:[g.jsx("strong",{children:B.email}),B.added?" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),g.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"})]}):(o==null?void 0:o.state)==="awaiting_code"||(o==null?void 0:o.state)==="registering"?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"1 · Approve in the browser"}),g.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),g.jsx("a",{className:"aa-link",href:o.url??"#",target:"_blank",rel:"noreferrer noopener",children:o.url})]}),g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"2 · Paste the code it gives you"}),g.jsxs("div",{className:"aa-field",children:[g.jsx("input",{ref:b,type:"text",value:u,onChange:T=>c(T.target.value),onKeyDown:T=>{T.key==="Enter"&&u.trim()&&!f&&O()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:o.state==="registering"}),g.jsx("button",{type:"button",className:"btn primary",disabled:f||!u.trim()||o.state==="registering",onClick:O,children:o.state==="registering"?"registering…":"Continue"})]}),(y||o.error)&&g.jsx("p",{className:"aa-err",children:y??o.error}),g.jsx("p",{className:"aa-note",children:"The code goes straight to the claude CLI on this machine. It is never stored or sent anywhere else."})]})]}):(o==null?void 0:o.state)==="failed"||y&&S.current&&!f?g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"Sign-in failed"}),g.jsx("p",{className:"aa-err",children:y??(o==null?void 0:o.error)}),g.jsx("button",{type:"button",className:"btn",onClick:()=>{S.current=!1,l(null),x(null),P()},children:"Try again"})]}):f||S.current?g.jsx("div",{className:"aa-step",children:g.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):g.jsxs("div",{className:"aa-step aa-primer",children:[g.jsx("h4",{children:"Sign in to Anthropic"}),g.jsx("p",{className:"aa-note",children:"Opens a browser tab where you approve the sign-in, then asks for the code it shows you. claude-swap records the account when it completes, and the account you are using now stays active."}),g.jsx("div",{className:"aa-actions",children:g.jsx("button",{type:"button",className:"btn primary",onClick:P,disabled:f,children:"Open the sign-in page"})})]}):N?g.jsxs("div",{className:"aa-done",children:[g.jsx(Vg,{ref:C}),N.added&&g.jsx(lx,{anchor:C}),g.jsx("h4",{children:N.added?`Account ${N.num} imported`:"Already here"}),g.jsx("p",{className:"aa-note",children:N.added?g.jsxs(g.Fragment,{children:[N.email?g.jsx("strong",{children:N.email}):"That account"," is in the rotation now. Nothing changed on the deck you copied it from."]}):"This deck already holds that account, so nothing changed."}),g.jsxs("div",{className:"aa-actions",children:[g.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"}),g.jsx("button",{type:"button",className:"btn",onClick:()=>_(null),children:"Import another"})]})]}):g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"Paste an account shared from another deck"}),g.jsxs("div",{className:"aa-field",children:[g.jsx("input",{ref:E,type:"text",value:p,onChange:T=>h(T.target.value),onKeyDown:T=>{T.key==="Enter"&&p.trim()&&!f&&q()},placeholder:"ccdeck1:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),g.jsx("button",{type:"button",className:"btn primary",disabled:f||!p.trim(),onClick:q,children:f?"importing…":"Import"})]}),y&&g.jsx("p",{className:"aa-err",children:y}),g.jsxs("p",{className:"aa-note",children:["Use ",g.jsx("strong",{children:"share"})," on an account in the other deck. A share carries a live login and expires ten minutes after it is made."]})]})})]})})}const $3=15e3,D3=[70,80,85,90,95];function F3(e,n){const i=e-n;if(i<=0)return null;const s=Math.floor(i/86400),o=Math.floor(i%86400/3600),l=Math.floor(i%3600/60);return s>0?`${s}d ${o}h`:o>0?`${o}h ${l}m`:`${l}m`}function ux(e,n){const i=n-Math.floor(e/1e3);return i<60?"just now":i<3600?`${Math.floor(i/60)}m ago`:i<86400?`${Math.floor(i/3600)}h ago`:`${Math.floor(i/86400)}d ago`}function z3(e,n){if(!e)return"";const i=Math.floor(e/1e3)-n;return i<=0?" · due":i<60?` · next in ${i}s`:` · next in ${Math.round(i/60)}m`}function B3(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 U3({lane:e,nowSec:n}){const i=Math.min(100,Math.max(0,e.pct)),s=i>=90?"var(--err)":i>=70?"var(--warn)":"var(--accent)",o=e.resetAt?F3(e.resetAt,n):null;return g.jsxs("div",{className:"ap-lane",children:[g.jsx("span",{className:"ap-lane-label",children:e.label}),g.jsx("div",{className:"ap-lane-track",children:g.jsx("div",{className:"ap-lane-fill",style:{width:`${i===0?1.5:i}%`,background:s,opacity:i===0?.4:1}})}),g.jsxs("span",{className:"ap-lane-pct",style:{color:s},children:[i,"%"]}),g.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}function H3(e){const n=e.map(s=>s.num),i=n.length?Math.max(...n):0;return[...new Set([...n,i+1])].sort((s,o)=>s-o)}async function V3(e){var i;let n=!1;try{n=await Promise.race([((i=navigator.clipboard)==null?void 0:i.writeText(e).then(()=>!0))??Promise.resolve(!1),new Promise(s=>window.setTimeout(()=>s(!1),500))])}catch{n=!1}if(n)return!0;try{const s=document.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(s),s.select(),n=document.execCommand("copy"),s.remove()}catch{n=!1}return n}function W3(e,n){const i=Math.round(e/1e3)-n;return i<=0?{text:"expired",tone:"gone"}:i<60?{text:`expires in ${i}s`,tone:"soon"}:{text:`expires in ${Math.round(i/60)}m`,tone:"ok"}}function G3({onClose:e}){var J,D,G;const[n,i]=A.useState(null),[s,o]=A.useState(null),[l,u]=A.useState(null),[c,p]=A.useState(null),[h,f]=A.useState(null),[m,y]=A.useState(()=>Math.floor(Date.now()/1e3)),x=A.useRef(null),[N,_]=A.useState(null),[S,b]=A.useState(!1),[E,C]=A.useState(""),[j,P]=A.useState(null),[O,q]=A.useState(null),[B,T]=A.useState(!1),M=A.useCallback(async(k=!1)=>{try{const[L,oe]=await Promise.all([fetch(`/api/claude-accounts${k?"?refresh=1":""}`),fetch("/api/cswap-auto")]);L.ok&&i(await L.json()),oe.ok&&o(await oe.json())}catch{}},[]),F=A.useCallback(async(k,L)=>{u(L),f(null);try{const $=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)})).json().catch(()=>null);return $!=null&&$.ok||f(($==null?void 0:$.detail)||($==null?void 0:$.reason)||"command failed"),$}catch{return f("server unreachable"),null}finally{u(null)}},[]),X=A.useCallback(async(k,L)=>{u(L),f(null);try{const $=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)})).json().catch(()=>null);return $!=null&&$.ok||f(($==null?void 0:$.detail)||($==null?void 0:$.reason)||"command failed"),$}catch{return f("server unreachable"),null}finally{u(null)}},[]);A.useEffect(()=>(M(!0),x.current=window.setInterval(()=>M(!1),$3),()=>{x.current!=null&&window.clearInterval(x.current)}),[M]),A.useEffect(()=>{const k=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(k)},[]);const Y=((J=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:J.value)??"90",I=(D=n==null?void 0:n.accounts)==null?void 0:D.find(k=>k.active),H=I!=null&&I.lanes.length?Math.max(...I.lanes.map(k=>k.pct)):null,U=H!=null&&H>=Number(Y)-15,ne=async k=>{p(k),f(null);try{const oe=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:k})})).json().catch(()=>null);oe!=null&&oe.ok||f((oe==null?void 0:oe.output)||(oe==null?void 0:oe.reason)||"switch failed"),await M(!0)}catch{f("server unreachable")}finally{p(null)}};return g.jsxs("div",{className:"accounts-panel","aria-label":"Claude accounts",children:[g.jsxs("div",{className:"ap-header",children:[g.jsx("h3",{children:"Accounts"}),g.jsxs("div",{className:"ap-header-right",children:[g.jsx("button",{type:"button",className:"btn ap-add",onClick:()=>b(!0),title:"Sign in to another Claude account, or paste one shared from another deck",children:"+"}),g.jsx("button",{type:"button",className:"btn ap-refresh",onClick:()=>M(!0),title:"Reload from claude-swap",children:"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),n==null?g.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?g.jsxs(g.Fragment,{children:[(G=n.accounts)==null?void 0:G.map(k=>g.jsxs("div",{className:`ap-account${k.active?" active":""}${k.disabled?" disabled":""}`,children:[g.jsxs("div",{className:"ap-account-head",children:[g.jsx("span",{className:"ap-num",children:k.num}),k.alias&&g.jsx("span",{className:"ap-alias",children:k.alias}),g.jsx("span",{className:"ap-email",title:k.org??void 0,children:k.email}),g.jsx("button",{type:"button",className:`ap-more${N===k.num?" on":""}`,"aria-label":`Manage account ${k.num}`,"aria-expanded":N===k.num,title:"Share, rename, move, remove",onClick:()=>{_(N===k.num?null:k.num),C(k.alias??""),P(null),q(null),T(!1)},children:"⋯"}),k.active?g.jsx("span",{className:"ap-badge-active",children:"● active"}):g.jsx("button",{type:"button",className:"btn ap-switch",disabled:c!=null||k.disabled,onClick:()=>ne(k.num),title:k.disabled?"Held out of rotation":`Switch to ${k.alias??k.email}`,children:c===k.num?"…":"switch"})]}),k.lanes.length>0?k.lanes.map(L=>g.jsx(U3,{lane:L,nowSec:m},L.id)):g.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),g.jsxs("div",{className:"ap-meta",children:[k.error&&(()=>{const L=B3(k.error);return g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"ap-err",title:L.hint,children:L.text}),L.fixable&&g.jsx("button",{type:"button",className:"ap-fix",onClick:()=>b(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"sign in again"})]})})(),((s==null?void 0:s.enabled)||(s==null?void 0:s.external))&&!k.active&&g.jsx("button",{type:"button",className:"ap-rotate",disabled:l!=null,onClick:()=>F({action:"account",account:k.num,enabled:k.disabled},`rot-${k.num}`).then(()=>M(!0)),title:k.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:k.disabled?"held out":"in rotation"}),k.fetchedAt?g.jsxs("span",{className:`ap-age${k.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 ",ux(k.fetchedAt,m),z3(k.nextAt,m)]}):g.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),N===k.num&&g.jsxs("div",{className:"ap-manage",children:[g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("span",{className:"ap-manage-label",children:"name"}),g.jsx("input",{className:"ap-manage-input",type:"text",value:E,onChange:L=>C(L.target.value),onKeyDown:L=>{L.key==="Enter"&&X({action:"alias",account:k.num,alias:E},`alias-${k.num}`).then(()=>M(!0))},placeholder:"no alias",spellCheck:!1,"aria-label":`Alias for account ${k.num}`}),g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null||E.trim()===(k.alias??""),onClick:()=>X({action:"alias",account:k.num,alias:E},`alias-${k.num}`).then(()=>M(!0)),title:"A short name to show instead of the email",children:"save"})]}),g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("span",{className:"ap-manage-label",children:"slot"}),g.jsx("span",{className:"ap-field",children:g.jsx("select",{"aria-label":`Slot for account ${k.num}`,value:String(k.num),disabled:l!=null,onChange:L=>X({action:"move",account:k.num,slot:Number(L.target.value)},`move-${k.num}`).then(()=>M(!0)),children:H3(n.accounts??[]).map(L=>g.jsx("option",{value:L,children:L},L))})}),g.jsx("span",{className:"ap-manage-hint",children:"rotation order"})]}),g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,title:"Copy this account to another agents-deck. The share carries a live login and expires in 10 minutes.",onClick:async()=>{T(!1);const L=await X({action:"share",account:k.num},`share-${k.num}`);L!=null&&L.ok&&q({num:k.num,blob:L.blob,expiresAt:L.expiresAt})},children:"share…"}),g.jsx("button",{type:"button",className:`ap-manage-btn danger${j===k.num?" armed":""}`,disabled:l!=null,title:j===k.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(j!==k.num){P(k.num),window.setTimeout(()=>P(L=>L===k.num?null:L),4e3);return}P(null),X({action:"remove",account:k.num},`rm-${k.num}`).then(()=>{_(null),M(!0)})},children:j===k.num?"confirm remove":"remove"})]}),(O==null?void 0:O.num)===k.num&&(()=>{const L=W3(O.expiresAt,m),oe=L.tone==="gone";return g.jsxs("div",{className:`ap-share${oe?" expired":""}`,children:[g.jsx("code",{className:"ap-share-blob",children:O.blob}),g.jsxs("div",{className:"ap-share-foot",children:[g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,onClick:async()=>{if(oe){T(!1);const $=await X({action:"share",account:k.num},`share-${k.num}`);$!=null&&$.ok&&q({num:k.num,blob:$.blob,expiresAt:$.expiresAt});return}await V3(O.blob)&&(T(!0),window.setTimeout(()=>T(!1),1800))},children:oe?"make a new share":B?"copied":"copy"}),g.jsxs("span",{className:"ap-manage-hint",children:["carries a live login · ",g.jsx("span",{className:`ap-share-expiry ${L.tone}`,children:L.text})]})]})]})})()]})]},k.num)),(s==null?void 0:s.ok)&&g.jsxs("div",{className:"ap-auto",children:[g.jsxs("div",{className:"ap-auto-head",children:[g.jsx("span",{className:"ap-auto-title",children:"Auto-switch"}),g.jsxs("span",{className:"ap-auto-ctl",children:[H!=null&&g.jsxs("span",{className:`ap-auto-now${U?" near":""}`,children:[Math.round(H),"%"]}),g.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:g.jsx("select",{"aria-label":"Switch threshold",value:Y,disabled:l!=null,onChange:k=>F({action:"setting",key:"autoswitch.threshold",value:k.target.value},"threshold").then(()=>M(!0)),children:D3.map(k=>g.jsxs("option",{value:k,children:[k,"%"]},k))})}),g.jsxs("button",{type:"button",className:`ap-auto-state toggle${s.enabled?" live":""}`,role:"switch","aria-checked":s.enabled,disabled:l!=null,onClick:()=>F({action:"enable",enabled:!s.enabled},"enable").then(()=>M(!0)),title:s.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[g.jsx("i",{className:s.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),s.enabled?"on":"off"]})]})]}),s.external&&g.jsxs("p",{className:"ap-auto-note",children:[g.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",g.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",s.enabled?" — this toggle takes over when you stop it.":"."]}),s.lastTick&&g.jsx("div",{className:"ap-auto-foot",children:g.jsxs("span",{className:"ap-auto-result",children:["checked ",ux(s.lastTick.at,m)]})})]}),h&&g.jsx("div",{className:"ap-failure",children:h}),g.jsx("p",{className:"ap-footnote",title:"Anthropic's usage endpoint allows roughly 28–30 requests per hour per account, shared by every tool on this machine — polling it from here would rate-limit your account. So the deck never fetches: it asks claude-swap to collect while this panel is open, at most once every three minutes, and claude-swap decides whether that touches the network at all.",children:"Collected by claude-swap while this panel is open."})]}):g.jsx("div",{className:"ap-empty",children:n.reason==="no_cswap"?g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"claude-swap isn't installed."}),g.jsx("span",{className:"ap-hint",children:"This panel reads the account store claude-swap keeps — without it there is nothing to show. It is a separate tool, published on PyPI, so it does not come with this package."}),n.hint&&g.jsx("code",{className:"ap-cmd",children:n.hint}),g.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",g.jsx("strong",{children:"+"})," button above."]})]}):n.reason==="no_accounts"?g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"No accounts added yet."}),g.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",g.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"Couldn't read the account store."}),g.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",n.reason?` (${n.reason})`:"","."]})]})}),S&&g.jsx(L3,{onClose:()=>b(!1),onChanged:()=>M(!0)})]})}const K3=3e4;function Y3({bundle:e,running:n,lastTried:i}){return!n||e===n?!1:i!==n}function X3(e){const n=e.thresholdMs??K3;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 Q3(e){return e.ctrlKey||e.metaKey||e.altKey}function cx(e,n){if(n.size!==0)for(const i of Array.from(e.keys()))n.has(i)||e.delete(i)}function Z3(){let e=0;return{begin(){const n=++e;return()=>n===e},cancel(){e++}}}function Ui(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 dx(e){return e.replace(/^anthropic\./,"").replace(/^claude-/,"").replace(/-\d{8}$/,"")}function El(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"}function J3(e){return new Date(Date.now()-(e-1)*864e5).toISOString().slice(0,10).replace(/-/g,"")}const eO=[7,14,30,90];function tO(e){const[n,i]=A.useState(null),[s,o]=A.useState(!1),l=A.useRef(Z3()).current,u=(c=!1)=>{const p=l.begin();o(!0);const f=`/api/ccusage?since=${J3(e)}${c?"&refresh=1":""}`;fetch(f).then(m=>m.json()).then(m=>{p()&&i(m)}).catch(()=>{p()&&i({ok:!1,error:"request failed"})}).finally(()=>{p()&&o(!1)})};return A.useEffect(()=>(u(!1),()=>l.cancel()),[e]),{data:n,loading:s,reload:()=>u(!0)}}function nO({onClose:e}){var b,E;const[n,i]=A.useState(30),[s,o]=A.useState(null),{data:l,loading:u,reload:c}=tO(n);A.useEffect(()=>{const C=j=>{j.key==="Escape"&&e()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[e]);const p=l!=null&&l.ok?l.days??[]:[],h=A.useMemo(()=>p.reduce((C,j)=>Math.max(C,j.totalCost),0),[p]),{totalCost:f,totalTok:m,inOut:y,cacheRead:x,modelCosts:N}=A.useMemo(()=>{let C=0,j=0,P=0,O=0;const q=new Map;for(const B of p){C+=B.totalCost,j+=B.totalTokens,P+=B.inputTokens+B.outputTokens,O+=B.cacheReadTokens;for(const T of B.modelBreakdowns)q.set(T.modelName,(q.get(T.modelName)??0)+T.cost)}return{totalCost:C,totalTok:j,inOut:P,cacheRead:O,modelCosts:q}},[p]),_=A.useMemo(()=>Array.from(N.entries()).sort((C,j)=>j[1]-C[1]),[N]),S=s?p.find(C=>C.period===s)??null:null;return g.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:g.jsxs("div",{className:"uh-modal",onClick:C=>C.stopPropagation(),role:"dialog","aria-label":"Usage history",children:[g.jsxs("header",{className:"uh-head",children:[g.jsxs("div",{className:"uh-titlewrap",children:[g.jsx("div",{className:"uh-title",children:"Usage history"}),g.jsx("div",{className:"uh-sub",children:"via ccusage · local Claude / Codex logs"})]}),g.jsx("div",{className:"uh-range",role:"tablist","aria-label":"Range",children:eO.map(C=>g.jsxs("button",{role:"tab","aria-selected":n===C,className:`uh-range-btn${n===C?" on":""}`,onClick:()=>{i(C),o(null)},children:[C,"d"]},C))}),g.jsx("button",{className:"btn icon-btn uh-reload",onClick:c,title:"Re-run ccusage","aria-label":"Reload",children:"↻"}),g.jsx("button",{className:"uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),u&&p.length===0?g.jsx("div",{className:"uh-status",children:"running ccusage… (first run downloads the package)"}):l&&!l.ok?g.jsxs("div",{className:"uh-status uh-err",children:["ccusage failed: ",l.error]}):p.length===0?g.jsx("div",{className:"uh-status",children:"no usage in this range"}):g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"uh-totals",children:[g.jsx(Nl,{label:"total cost",val:Be(f),accent:!0}),g.jsx(Nl,{label:"tokens",val:Ui(m)}),g.jsx(Nl,{label:"input+output",val:Ui(y)}),g.jsx(Nl,{label:"cache reads",val:Ui(x)})]}),g.jsx("div",{className:"uh-chart",role:"img","aria-label":"Daily cost by model",children:p.map(C=>{const j=h>0?C.totalCost/h*100:0,P=C.period===s;return g.jsxs("button",{className:`uh-bar-col${P?" sel":""}`,onClick:()=>o(P?null:C.period),title:`${C.period} · ${Be(C.totalCost)}`,style:{flexBasis:`${100/p.length}%`},children:[g.jsx("div",{className:"uh-bar",style:{height:`${Math.max(j,C.totalCost>0?2:0)}%`},children:C.modelBreakdowns.slice().sort((O,q)=>q.cost-O.cost).map(O=>{const q=C.totalCost>0?O.cost/C.totalCost*100:0;return g.jsx("div",{className:"uh-bar-seg",style:{height:`${q}%`,background:El(O.modelName)}},O.modelName)})}),g.jsx("span",{className:"uh-bar-label",children:C.period.slice(5)})]},C.period)})}),g.jsx("div",{className:"uh-legend",children:_.map(([C,j])=>g.jsxs("span",{className:"uh-legend-item",children:[g.jsx("span",{className:"uh-legend-dot",style:{background:El(C)}}),dx(C)," ",g.jsx("span",{className:"uh-legend-cost",children:Be(j)})]},C))}),S&&g.jsxs("div",{className:"uh-detail",children:[g.jsxs("div",{className:"uh-detail-head",children:[g.jsx("span",{className:"uh-detail-date",children:S.period}),g.jsx("span",{className:"uh-detail-cost",children:Be(S.totalCost)}),(E=(b=S.metadata)==null?void 0:b.agents)!=null&&E.length?g.jsx("span",{className:"uh-detail-agents",children:S.metadata.agents.join(" · ")}):null]}),g.jsxs("div",{className:"uh-detail-mini",children:[g.jsx(Cl,{label:"input",val:Ui(S.inputTokens)}),g.jsx(Cl,{label:"output",val:Ui(S.outputTokens)}),g.jsx(Cl,{label:"cache write",val:Ui(S.cacheCreationTokens)}),g.jsx(Cl,{label:"cache read",val:Ui(S.cacheReadTokens)})]}),g.jsx("div",{className:"uh-detail-models",children:S.modelBreakdowns.slice().sort((C,j)=>j.cost-C.cost).map(C=>{const j=S.totalCost>0?C.cost/S.totalCost*100:0;return g.jsxs("div",{className:"uh-model-row",children:[g.jsxs("span",{className:"uh-model-name",children:[g.jsx("span",{className:"uh-legend-dot",style:{background:El(C.modelName)}}),dx(C.modelName)]}),g.jsx("span",{className:"uh-model-bar",children:g.jsx("span",{className:"uh-model-bar-fill",style:{width:`${j}%`,background:El(C.modelName)}})}),g.jsx("span",{className:"uh-model-cost",children:Be(C.cost)})]},C.modelName)})})]})]})]})})}function Nl({label:e,val:n,accent:i}){return g.jsxs("div",{className:"uh-stat",children:[g.jsx("span",{className:`uh-stat-val${i?" accent":""}`,children:n}),g.jsx("span",{className:"uh-stat-label",children:e})]})}function Cl({label:e,val:n}){return g.jsxs("div",{className:"uh-ministat",children:[g.jsx("span",{className:"uh-ministat-val",children:n}),g.jsx("span",{className:"uh-ministat-label",children:e})]})}function gv(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 ad,fx;function rO(){if(fx)return ad;fx=1;function e(){this.__data__=[],this.size=0}return ad=e,ad}var ld,hx;function Ws(){if(hx)return ld;hx=1;function e(n,i){return n===i||n!==n&&i!==i}return ld=e,ld}var ud,px;function Zl(){if(px)return ud;px=1;var e=Ws();function n(i,s){for(var o=i.length;o--;)if(e(i[o][0],s))return o;return-1}return ud=n,ud}var cd,mx;function iO(){if(mx)return cd;mx=1;var e=Zl(),n=Array.prototype,i=n.splice;function s(o){var l=this.__data__,u=e(l,o);if(u<0)return!1;var c=l.length-1;return u==c?l.pop():i.call(l,u,1),--this.size,!0}return cd=s,cd}var dd,gx;function sO(){if(gx)return dd;gx=1;var e=Zl();function n(i){var s=this.__data__,o=e(s,i);return o<0?void 0:s[o][1]}return dd=n,dd}var fd,vx;function oO(){if(vx)return fd;vx=1;var e=Zl();function n(i){return e(this.__data__,i)>-1}return fd=n,fd}var hd,yx;function aO(){if(yx)return hd;yx=1;var e=Zl();function n(i,s){var o=this.__data__,l=e(o,i);return l<0?(++this.size,o.push([i,s])):o[l][1]=s,this}return hd=n,hd}var pd,wx;function Jl(){if(wx)return pd;wx=1;var e=rO(),n=iO(),i=sO(),s=oO(),o=aO();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=i,l.prototype.has=s,l.prototype.set=o,pd=l,pd}var md,xx;function lO(){if(xx)return md;xx=1;var e=Jl();function n(){this.__data__=new e,this.size=0}return md=n,md}var gd,_x;function uO(){if(_x)return gd;_x=1;function e(n){var i=this.__data__,s=i.delete(n);return this.size=i.size,s}return gd=e,gd}var vd,Sx;function cO(){if(Sx)return vd;Sx=1;function e(n){return this.__data__.get(n)}return vd=e,vd}var yd,bx;function dO(){if(bx)return yd;bx=1;function e(n){return this.__data__.has(n)}return yd=e,yd}var wd,kx;function kN(){if(kx)return wd;kx=1;var e=typeof fl=="object"&&fl&&fl.Object===Object&&fl;return wd=e,wd}var xd,Ex;function Jn(){if(Ex)return xd;Ex=1;var e=kN(),n=typeof self=="object"&&self&&self.Object===Object&&self,i=e||n||Function("return this")();return xd=i,xd}var _d,Nx;function Gs(){if(Nx)return _d;Nx=1;var e=Jn(),n=e.Symbol;return _d=n,_d}var Sd,Cx;function fO(){if(Cx)return Sd;Cx=1;var e=Gs(),n=Object.prototype,i=n.hasOwnProperty,s=n.toString,o=e?e.toStringTag:void 0;function l(u){var c=i.call(u,o),p=u[o];try{u[o]=void 0;var h=!0}catch{}var f=s.call(u);return h&&(c?u[o]=p:delete u[o]),f}return Sd=l,Sd}var bd,jx;function hO(){if(jx)return bd;jx=1;var e=Object.prototype,n=e.toString;function i(s){return n.call(s)}return bd=i,bd}var kd,Rx;function Ji(){if(Rx)return kd;Rx=1;var e=Gs(),n=fO(),i=hO(),s="[object Null]",o="[object Undefined]",l=e?e.toStringTag:void 0;function u(c){return c==null?c===void 0?o:s:l&&l in Object(c)?n(c):i(c)}return kd=u,kd}var Ed,Tx;function On(){if(Tx)return Ed;Tx=1;function e(n){var i=typeof n;return n!=null&&(i=="object"||i=="function")}return Ed=e,Ed}var Nd,Ax;function la(){if(Ax)return Nd;Ax=1;var e=Ji(),n=On(),i="[object AsyncFunction]",s="[object Function]",o="[object GeneratorFunction]",l="[object Proxy]";function u(c){if(!n(c))return!1;var p=e(c);return p==s||p==o||p==i||p==l}return Nd=u,Nd}var Cd,Ix;function pO(){if(Ix)return Cd;Ix=1;var e=Jn(),n=e["__core-js_shared__"];return Cd=n,Cd}var jd,Mx;function mO(){if(Mx)return jd;Mx=1;var e=pO(),n=(function(){var s=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""})();function i(s){return!!n&&n in s}return jd=i,jd}var Rd,Px;function EN(){if(Px)return Rd;Px=1;var e=Function.prototype,n=e.toString;function i(s){if(s!=null){try{return n.call(s)}catch{}try{return s+""}catch{}}return""}return Rd=i,Rd}var Td,Ox;function gO(){if(Ox)return Td;Ox=1;var e=la(),n=mO(),i=On(),s=EN(),o=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,p=u.toString,h=c.hasOwnProperty,f=RegExp("^"+p.call(h).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!i(y)||n(y))return!1;var x=e(y)?f:l;return x.test(s(y))}return Td=m,Td}var Ad,qx;function vO(){if(qx)return Ad;qx=1;function e(n,i){return n==null?void 0:n[i]}return Ad=e,Ad}var Id,Lx;function es(){if(Lx)return Id;Lx=1;var e=gO(),n=vO();function i(s,o){var l=n(s,o);return e(l)?l:void 0}return Id=i,Id}var Md,$x;function vv(){if($x)return Md;$x=1;var e=es(),n=Jn(),i=e(n,"Map");return Md=i,Md}var Pd,Dx;function eu(){if(Dx)return Pd;Dx=1;var e=es(),n=e(Object,"create");return Pd=n,Pd}var Od,Fx;function yO(){if(Fx)return Od;Fx=1;var e=eu();function n(){this.__data__=e?e(null):{},this.size=0}return Od=n,Od}var qd,zx;function wO(){if(zx)return qd;zx=1;function e(n){var i=this.has(n)&&delete this.__data__[n];return this.size-=i?1:0,i}return qd=e,qd}var Ld,Bx;function xO(){if(Bx)return Ld;Bx=1;var e=eu(),n="__lodash_hash_undefined__",i=Object.prototype,s=i.hasOwnProperty;function o(l){var u=this.__data__;if(e){var c=u[l];return c===n?void 0:c}return s.call(u,l)?u[l]:void 0}return Ld=o,Ld}var $d,Ux;function _O(){if(Ux)return $d;Ux=1;var e=eu(),n=Object.prototype,i=n.hasOwnProperty;function s(o){var l=this.__data__;return e?l[o]!==void 0:i.call(l,o)}return $d=s,$d}var Dd,Hx;function SO(){if(Hx)return Dd;Hx=1;var e=eu(),n="__lodash_hash_undefined__";function i(s,o){var l=this.__data__;return this.size+=this.has(s)?0:1,l[s]=e&&o===void 0?n:o,this}return Dd=i,Dd}var Fd,Vx;function bO(){if(Vx)return Fd;Vx=1;var e=yO(),n=wO(),i=xO(),s=_O(),o=SO();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=i,l.prototype.has=s,l.prototype.set=o,Fd=l,Fd}var zd,Wx;function kO(){if(Wx)return zd;Wx=1;var e=bO(),n=Jl(),i=vv();function s(){this.size=0,this.__data__={hash:new e,map:new(i||n),string:new e}}return zd=s,zd}var Bd,Gx;function EO(){if(Gx)return Bd;Gx=1;function e(n){var i=typeof n;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?n!=="__proto__":n===null}return Bd=e,Bd}var Ud,Kx;function tu(){if(Kx)return Ud;Kx=1;var e=EO();function n(i,s){var o=i.__data__;return e(s)?o[typeof s=="string"?"string":"hash"]:o.map}return Ud=n,Ud}var Hd,Yx;function NO(){if(Yx)return Hd;Yx=1;var e=tu();function n(i){var s=e(this,i).delete(i);return this.size-=s?1:0,s}return Hd=n,Hd}var Vd,Xx;function CO(){if(Xx)return Vd;Xx=1;var e=tu();function n(i){return e(this,i).get(i)}return Vd=n,Vd}var Wd,Qx;function jO(){if(Qx)return Wd;Qx=1;var e=tu();function n(i){return e(this,i).has(i)}return Wd=n,Wd}var Gd,Zx;function RO(){if(Zx)return Gd;Zx=1;var e=tu();function n(i,s){var o=e(this,i),l=o.size;return o.set(i,s),this.size+=o.size==l?0:1,this}return Gd=n,Gd}var Kd,Jx;function yv(){if(Jx)return Kd;Jx=1;var e=kO(),n=NO(),i=CO(),s=jO(),o=RO();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=i,l.prototype.has=s,l.prototype.set=o,Kd=l,Kd}var Yd,e1;function TO(){if(e1)return Yd;e1=1;var e=Jl(),n=vv(),i=yv(),s=200;function o(l,u){var c=this.__data__;if(c instanceof e){var p=c.__data__;if(!n||p.length<s-1)return p.push([l,u]),this.size=++c.size,this;c=this.__data__=new i(p)}return c.set(l,u),this.size=c.size,this}return Yd=o,Yd}var Xd,t1;function nu(){if(t1)return Xd;t1=1;var e=Jl(),n=lO(),i=uO(),s=cO(),o=dO(),l=TO();function u(c){var p=this.__data__=new e(c);this.size=p.size}return u.prototype.clear=n,u.prototype.delete=i,u.prototype.get=s,u.prototype.has=o,u.prototype.set=l,Xd=u,Xd}var Qd,n1;function wv(){if(n1)return Qd;n1=1;function e(n,i){for(var s=-1,o=n==null?0:n.length;++s<o&&i(n[s],s,n)!==!1;);return n}return Qd=e,Qd}var Zd,r1;function NN(){if(r1)return Zd;r1=1;var e=es(),n=(function(){try{var i=e(Object,"defineProperty");return i({},"",{}),i}catch{}})();return Zd=n,Zd}var Jd,i1;function ru(){if(i1)return Jd;i1=1;var e=NN();function n(i,s,o){s=="__proto__"&&e?e(i,s,{configurable:!0,enumerable:!0,value:o,writable:!0}):i[s]=o}return Jd=n,Jd}var ef,s1;function iu(){if(s1)return ef;s1=1;var e=ru(),n=Ws(),i=Object.prototype,s=i.hasOwnProperty;function o(l,u,c){var p=l[u];(!(s.call(l,u)&&n(p,c))||c===void 0&&!(u in l))&&e(l,u,c)}return ef=o,ef}var tf,o1;function ua(){if(o1)return tf;o1=1;var e=iu(),n=ru();function i(s,o,l,u){var c=!l;l||(l={});for(var p=-1,h=o.length;++p<h;){var f=o[p],m=u?u(l[f],s[f],f,l,s):void 0;m===void 0&&(m=s[f]),c?n(l,f,m):e(l,f,m)}return l}return tf=i,tf}var nf,a1;function AO(){if(a1)return nf;a1=1;function e(n,i){for(var s=-1,o=Array(n);++s<n;)o[s]=i(s);return o}return nf=e,nf}var rf,l1;function fr(){if(l1)return rf;l1=1;function e(n){return n!=null&&typeof n=="object"}return rf=e,rf}var sf,u1;function IO(){if(u1)return sf;u1=1;var e=Ji(),n=fr(),i="[object Arguments]";function s(o){return n(o)&&e(o)==i}return sf=s,sf}var of,c1;function ca(){if(c1)return of;c1=1;var e=IO(),n=fr(),i=Object.prototype,s=i.hasOwnProperty,o=i.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(u){return n(u)&&s.call(u,"callee")&&!o.call(u,"callee")};return of=l,of}var af,d1;function St(){if(d1)return af;d1=1;var e=Array.isArray;return af=e,af}var Uo={exports:{}},lf,f1;function MO(){if(f1)return lf;f1=1;function e(){return!1}return lf=e,lf}Uo.exports;var h1;function Ks(){return h1||(h1=1,(function(e,n){var i=Jn(),s=MO(),o=n&&!n.nodeType&&n,l=o&&!0&&e&&!e.nodeType&&e,u=l&&l.exports===o,c=u?i.Buffer:void 0,p=c?c.isBuffer:void 0,h=p||s;e.exports=h})(Uo,Uo.exports)),Uo.exports}var uf,p1;function su(){if(p1)return uf;p1=1;var e=9007199254740991,n=/^(?:0|[1-9]\d*)$/;function i(s,o){var l=typeof s;return o=o??e,!!o&&(l=="number"||l!="symbol"&&n.test(s))&&s>-1&&s%1==0&&s<o}return uf=i,uf}var cf,m1;function xv(){if(m1)return cf;m1=1;var e=9007199254740991;function n(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=e}return cf=n,cf}var df,g1;function PO(){if(g1)return df;g1=1;var e=Ji(),n=xv(),i=fr(),s="[object Arguments]",o="[object Array]",l="[object Boolean]",u="[object Date]",c="[object Error]",p="[object Function]",h="[object Map]",f="[object Number]",m="[object Object]",y="[object RegExp]",x="[object Set]",N="[object String]",_="[object WeakMap]",S="[object ArrayBuffer]",b="[object DataView]",E="[object Float32Array]",C="[object Float64Array]",j="[object Int8Array]",P="[object Int16Array]",O="[object Int32Array]",q="[object Uint8Array]",B="[object Uint8ClampedArray]",T="[object Uint16Array]",M="[object Uint32Array]",F={};F[E]=F[C]=F[j]=F[P]=F[O]=F[q]=F[B]=F[T]=F[M]=!0,F[s]=F[o]=F[S]=F[l]=F[b]=F[u]=F[c]=F[p]=F[h]=F[f]=F[m]=F[y]=F[x]=F[N]=F[_]=!1;function X(Y){return i(Y)&&n(Y.length)&&!!F[e(Y)]}return df=X,df}var ff,v1;function ou(){if(v1)return ff;v1=1;function e(n){return function(i){return n(i)}}return ff=e,ff}var Ho={exports:{}};Ho.exports;var y1;function _v(){return y1||(y1=1,(function(e,n){var i=kN(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,u=l&&i.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})(Ho,Ho.exports)),Ho.exports}var hf,w1;function da(){if(w1)return hf;w1=1;var e=PO(),n=ou(),i=_v(),s=i&&i.isTypedArray,o=s?n(s):e;return hf=o,hf}var pf,x1;function CN(){if(x1)return pf;x1=1;var e=AO(),n=ca(),i=St(),s=Ks(),o=su(),l=da(),u=Object.prototype,c=u.hasOwnProperty;function p(h,f){var m=i(h),y=!m&&n(h),x=!m&&!y&&s(h),N=!m&&!y&&!x&&l(h),_=m||y||x||N,S=_?e(h.length,String):[],b=S.length;for(var E in h)(f||c.call(h,E))&&!(_&&(E=="length"||x&&(E=="offset"||E=="parent")||N&&(E=="buffer"||E=="byteLength"||E=="byteOffset")||o(E,b)))&&S.push(E);return S}return pf=p,pf}var mf,_1;function au(){if(_1)return mf;_1=1;var e=Object.prototype;function n(i){var s=i&&i.constructor,o=typeof s=="function"&&s.prototype||e;return i===o}return mf=n,mf}var gf,S1;function jN(){if(S1)return gf;S1=1;function e(n,i){return function(s){return n(i(s))}}return gf=e,gf}var vf,b1;function OO(){if(b1)return vf;b1=1;var e=jN(),n=e(Object.keys,Object);return vf=n,vf}var yf,k1;function Sv(){if(k1)return yf;k1=1;var e=au(),n=OO(),i=Object.prototype,s=i.hasOwnProperty;function o(l){if(!e(l))return n(l);var u=[];for(var c in Object(l))s.call(l,c)&&c!="constructor"&&u.push(c);return u}return yf=o,yf}var wf,E1;function qr(){if(E1)return wf;E1=1;var e=la(),n=xv();function i(s){return s!=null&&n(s.length)&&!e(s)}return wf=i,wf}var xf,N1;function yi(){if(N1)return xf;N1=1;var e=CN(),n=Sv(),i=qr();function s(o){return i(o)?e(o):n(o)}return xf=s,xf}var _f,C1;function qO(){if(C1)return _f;C1=1;var e=ua(),n=yi();function i(s,o){return s&&e(o,n(o),s)}return _f=i,_f}var Sf,j1;function LO(){if(j1)return Sf;j1=1;function e(n){var i=[];if(n!=null)for(var s in Object(n))i.push(s);return i}return Sf=e,Sf}var bf,R1;function $O(){if(R1)return bf;R1=1;var e=On(),n=au(),i=LO(),s=Object.prototype,o=s.hasOwnProperty;function l(u){if(!e(u))return i(u);var c=n(u),p=[];for(var h in u)h=="constructor"&&(c||!o.call(u,h))||p.push(h);return p}return bf=l,bf}var kf,T1;function ts(){if(T1)return kf;T1=1;var e=CN(),n=$O(),i=qr();function s(o){return i(o)?e(o,!0):n(o)}return kf=s,kf}var Ef,A1;function DO(){if(A1)return Ef;A1=1;var e=ua(),n=ts();function i(s,o){return s&&e(o,n(o),s)}return Ef=i,Ef}var Vo={exports:{}};Vo.exports;var I1;function RN(){return I1||(I1=1,(function(e,n){var i=Jn(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,u=l?i.Buffer:void 0,c=u?u.allocUnsafe:void 0;function p(h,f){if(f)return h.slice();var m=h.length,y=c?c(m):new h.constructor(m);return h.copy(y),y}e.exports=p})(Vo,Vo.exports)),Vo.exports}var Nf,M1;function TN(){if(M1)return Nf;M1=1;function e(n,i){var s=-1,o=n.length;for(i||(i=Array(o));++s<o;)i[s]=n[s];return i}return Nf=e,Nf}var Cf,P1;function AN(){if(P1)return Cf;P1=1;function e(n,i){for(var s=-1,o=n==null?0:n.length,l=0,u=[];++s<o;){var c=n[s];i(c,s,n)&&(u[l++]=c)}return u}return Cf=e,Cf}var jf,O1;function IN(){if(O1)return jf;O1=1;function e(){return[]}return jf=e,jf}var Rf,q1;function bv(){if(q1)return Rf;q1=1;var e=AN(),n=IN(),i=Object.prototype,s=i.propertyIsEnumerable,o=Object.getOwnPropertySymbols,l=o?function(u){return u==null?[]:(u=Object(u),e(o(u),function(c){return s.call(u,c)}))}:n;return Rf=l,Rf}var Tf,L1;function FO(){if(L1)return Tf;L1=1;var e=ua(),n=bv();function i(s,o){return e(s,n(s),o)}return Tf=i,Tf}var Af,$1;function kv(){if($1)return Af;$1=1;function e(n,i){for(var s=-1,o=i.length,l=n.length;++s<o;)n[l+s]=i[s];return n}return Af=e,Af}var If,D1;function lu(){if(D1)return If;D1=1;var e=jN(),n=e(Object.getPrototypeOf,Object);return If=n,If}var Mf,F1;function MN(){if(F1)return Mf;F1=1;var e=kv(),n=lu(),i=bv(),s=IN(),o=Object.getOwnPropertySymbols,l=o?function(u){for(var c=[];u;)e(c,i(u)),u=n(u);return c}:s;return Mf=l,Mf}var Pf,z1;function zO(){if(z1)return Pf;z1=1;var e=ua(),n=MN();function i(s,o){return e(s,n(s),o)}return Pf=i,Pf}var Of,B1;function PN(){if(B1)return Of;B1=1;var e=kv(),n=St();function i(s,o,l){var u=o(s);return n(s)?u:e(u,l(s))}return Of=i,Of}var qf,U1;function ON(){if(U1)return qf;U1=1;var e=PN(),n=bv(),i=yi();function s(o){return e(o,i,n)}return qf=s,qf}var Lf,H1;function BO(){if(H1)return Lf;H1=1;var e=PN(),n=MN(),i=ts();function s(o){return e(o,i,n)}return Lf=s,Lf}var $f,V1;function UO(){if(V1)return $f;V1=1;var e=es(),n=Jn(),i=e(n,"DataView");return $f=i,$f}var Df,W1;function HO(){if(W1)return Df;W1=1;var e=es(),n=Jn(),i=e(n,"Promise");return Df=i,Df}var Ff,G1;function qN(){if(G1)return Ff;G1=1;var e=es(),n=Jn(),i=e(n,"Set");return Ff=i,Ff}var zf,K1;function VO(){if(K1)return zf;K1=1;var e=es(),n=Jn(),i=e(n,"WeakMap");return zf=i,zf}var Bf,Y1;function Ys(){if(Y1)return Bf;Y1=1;var e=UO(),n=vv(),i=HO(),s=qN(),o=VO(),l=Ji(),u=EN(),c="[object Map]",p="[object Object]",h="[object Promise]",f="[object Set]",m="[object WeakMap]",y="[object DataView]",x=u(e),N=u(n),_=u(i),S=u(s),b=u(o),E=l;return(e&&E(new e(new ArrayBuffer(1)))!=y||n&&E(new n)!=c||i&&E(i.resolve())!=h||s&&E(new s)!=f||o&&E(new o)!=m)&&(E=function(C){var j=l(C),P=j==p?C.constructor:void 0,O=P?u(P):"";if(O)switch(O){case x:return y;case N:return c;case _:return h;case S:return f;case b:return m}return j}),Bf=E,Bf}var Uf,X1;function WO(){if(X1)return Uf;X1=1;var e=Object.prototype,n=e.hasOwnProperty;function i(s){var o=s.length,l=new s.constructor(o);return o&&typeof s[0]=="string"&&n.call(s,"index")&&(l.index=s.index,l.input=s.input),l}return Uf=i,Uf}var Hf,Q1;function LN(){if(Q1)return Hf;Q1=1;var e=Jn(),n=e.Uint8Array;return Hf=n,Hf}var Vf,Z1;function Ev(){if(Z1)return Vf;Z1=1;var e=LN();function n(i){var s=new i.constructor(i.byteLength);return new e(s).set(new e(i)),s}return Vf=n,Vf}var Wf,J1;function GO(){if(J1)return Wf;J1=1;var e=Ev();function n(i,s){var o=s?e(i.buffer):i.buffer;return new i.constructor(o,i.byteOffset,i.byteLength)}return Wf=n,Wf}var Gf,e_;function KO(){if(e_)return Gf;e_=1;var e=/\w*$/;function n(i){var s=new i.constructor(i.source,e.exec(i));return s.lastIndex=i.lastIndex,s}return Gf=n,Gf}var Kf,t_;function YO(){if(t_)return Kf;t_=1;var e=Gs(),n=e?e.prototype:void 0,i=n?n.valueOf:void 0;function s(o){return i?Object(i.call(o)):{}}return Kf=s,Kf}var Yf,n_;function $N(){if(n_)return Yf;n_=1;var e=Ev();function n(i,s){var o=s?e(i.buffer):i.buffer;return new i.constructor(o,i.byteOffset,i.length)}return Yf=n,Yf}var Xf,r_;function XO(){if(r_)return Xf;r_=1;var e=Ev(),n=GO(),i=KO(),s=YO(),o=$N(),l="[object Boolean]",u="[object Date]",c="[object Map]",p="[object Number]",h="[object RegExp]",f="[object Set]",m="[object String]",y="[object Symbol]",x="[object ArrayBuffer]",N="[object DataView]",_="[object Float32Array]",S="[object Float64Array]",b="[object Int8Array]",E="[object Int16Array]",C="[object Int32Array]",j="[object Uint8Array]",P="[object Uint8ClampedArray]",O="[object Uint16Array]",q="[object Uint32Array]";function B(T,M,F){var X=T.constructor;switch(M){case x:return e(T);case l:case u:return new X(+T);case N:return n(T,F);case _:case S:case b:case E:case C:case j:case P:case O:case q:return o(T,F);case c:return new X;case p:case m:return new X(T);case h:return i(T);case f:return new X;case y:return s(T)}}return Xf=B,Xf}var Qf,i_;function DN(){if(i_)return Qf;i_=1;var e=On(),n=Object.create,i=(function(){function s(){}return function(o){if(!e(o))return{};if(n)return n(o);s.prototype=o;var l=new s;return s.prototype=void 0,l}})();return Qf=i,Qf}var Zf,s_;function FN(){if(s_)return Zf;s_=1;var e=DN(),n=lu(),i=au();function s(o){return typeof o.constructor=="function"&&!i(o)?e(n(o)):{}}return Zf=s,Zf}var Jf,o_;function QO(){if(o_)return Jf;o_=1;var e=Ys(),n=fr(),i="[object Map]";function s(o){return n(o)&&e(o)==i}return Jf=s,Jf}var eh,a_;function ZO(){if(a_)return eh;a_=1;var e=QO(),n=ou(),i=_v(),s=i&&i.isMap,o=s?n(s):e;return eh=o,eh}var th,l_;function JO(){if(l_)return th;l_=1;var e=Ys(),n=fr(),i="[object Set]";function s(o){return n(o)&&e(o)==i}return th=s,th}var nh,u_;function eq(){if(u_)return nh;u_=1;var e=JO(),n=ou(),i=_v(),s=i&&i.isSet,o=s?n(s):e;return nh=o,nh}var rh,c_;function zN(){if(c_)return rh;c_=1;var e=nu(),n=wv(),i=iu(),s=qO(),o=DO(),l=RN(),u=TN(),c=FO(),p=zO(),h=ON(),f=BO(),m=Ys(),y=WO(),x=XO(),N=FN(),_=St(),S=Ks(),b=ZO(),E=On(),C=eq(),j=yi(),P=ts(),O=1,q=2,B=4,T="[object Arguments]",M="[object Array]",F="[object Boolean]",X="[object Date]",Y="[object Error]",I="[object Function]",H="[object GeneratorFunction]",U="[object Map]",ne="[object Number]",J="[object Object]",D="[object RegExp]",G="[object Set]",k="[object String]",L="[object Symbol]",oe="[object WeakMap]",$="[object ArrayBuffer]",Q="[object DataView]",ee="[object Float32Array]",se="[object Float64Array]",ae="[object Int8Array]",pe="[object Int16Array]",ge="[object Int32Array]",Ae="[object Uint8Array]",Oe="[object Uint8ClampedArray]",Me="[object Uint16Array]",Pe="[object Uint32Array]",ke={};ke[T]=ke[M]=ke[$]=ke[Q]=ke[F]=ke[X]=ke[ee]=ke[se]=ke[ae]=ke[pe]=ke[ge]=ke[U]=ke[ne]=ke[J]=ke[D]=ke[G]=ke[k]=ke[L]=ke[Ae]=ke[Oe]=ke[Me]=ke[Pe]=!0,ke[Y]=ke[I]=ke[oe]=!1;function We(ve,ye,Ge,ut,it,Ke){var $e,Qe=ye&O,bt=ye&q,ct=ye&B;if(Ge&&($e=it?Ge(ve,ut,it,Ke):Ge(ve)),$e!==void 0)return $e;if(!E(ve))return ve;var pt=_(ve);if(pt){if($e=y(ve),!Qe)return u(ve,$e)}else{var mt=m(ve),kt=mt==I||mt==H;if(S(ve))return l(ve,Qe);if(mt==J||mt==T||kt&&!it){if($e=bt||kt?{}:N(ve),!Qe)return bt?p(ve,o($e,ve)):c(ve,s($e,ve))}else{if(!ke[mt])return it?ve:{};$e=x(ve,mt,Qe)}}Ke||(Ke=new e);var He=Ke.get(ve);if(He)return He;Ke.set(ve,$e),C(ve)?ve.forEach(function(gt){$e.add(We(gt,ye,Ge,gt,ve,Ke))}):b(ve)&&ve.forEach(function(gt,yt){$e.set(yt,We(gt,ye,Ge,yt,ve,Ke))});var Je=ct?bt?f:h:bt?P:j,dt=pt?void 0:Je(ve);return n(dt||ve,function(gt,yt){dt&&(yt=gt,gt=ve[yt]),i($e,yt,We(gt,ye,Ge,yt,ve,Ke))}),$e}return rh=We,rh}var ih,d_;function tq(){if(d_)return ih;d_=1;var e=zN(),n=4;function i(s){return e(s,n)}return ih=i,ih}var sh,f_;function Nv(){if(f_)return sh;f_=1;function e(n){return function(){return n}}return sh=e,sh}var oh,h_;function nq(){if(h_)return oh;h_=1;function e(n){return function(i,s,o){for(var l=-1,u=Object(i),c=o(i),p=c.length;p--;){var h=c[n?p:++l];if(s(u[h],h,u)===!1)break}return i}}return oh=e,oh}var ah,p_;function Cv(){if(p_)return ah;p_=1;var e=nq(),n=e();return ah=n,ah}var lh,m_;function jv(){if(m_)return lh;m_=1;var e=Cv(),n=yi();function i(s,o){return s&&e(s,o,n)}return lh=i,lh}var uh,g_;function rq(){if(g_)return uh;g_=1;var e=qr();function n(i,s){return function(o,l){if(o==null)return o;if(!e(o))return i(o,l);for(var u=o.length,c=s?u:-1,p=Object(o);(s?c--:++c<u)&&l(p[c],c,p)!==!1;);return o}}return uh=n,uh}var ch,v_;function uu(){if(v_)return ch;v_=1;var e=jv(),n=rq(),i=n(e);return ch=i,ch}var dh,y_;function ns(){if(y_)return dh;y_=1;function e(n){return n}return dh=e,dh}var fh,w_;function BN(){if(w_)return fh;w_=1;var e=ns();function n(i){return typeof i=="function"?i:e}return fh=n,fh}var hh,x_;function UN(){if(x_)return hh;x_=1;var e=wv(),n=uu(),i=BN(),s=St();function o(l,u){var c=s(l)?e:n;return c(l,i(u))}return hh=o,hh}var ph,__;function HN(){return __||(__=1,ph=UN()),ph}var mh,S_;function iq(){if(S_)return mh;S_=1;var e=uu();function n(i,s){var o=[];return e(i,function(l,u,c){s(l,u,c)&&o.push(l)}),o}return mh=n,mh}var gh,b_;function sq(){if(b_)return gh;b_=1;var e="__lodash_hash_undefined__";function n(i){return this.__data__.set(i,e),this}return gh=n,gh}var vh,k_;function oq(){if(k_)return vh;k_=1;function e(n){return this.__data__.has(n)}return vh=e,vh}var yh,E_;function VN(){if(E_)return yh;E_=1;var e=yv(),n=sq(),i=oq();function s(o){var l=-1,u=o==null?0:o.length;for(this.__data__=new e;++l<u;)this.add(o[l])}return s.prototype.add=s.prototype.push=n,s.prototype.has=i,yh=s,yh}var wh,N_;function aq(){if(N_)return wh;N_=1;function e(n,i){for(var s=-1,o=n==null?0:n.length;++s<o;)if(i(n[s],s,n))return!0;return!1}return wh=e,wh}var xh,C_;function WN(){if(C_)return xh;C_=1;function e(n,i){return n.has(i)}return xh=e,xh}var _h,j_;function GN(){if(j_)return _h;j_=1;var e=VN(),n=aq(),i=WN(),s=1,o=2;function l(u,c,p,h,f,m){var y=p&s,x=u.length,N=c.length;if(x!=N&&!(y&&N>x))return!1;var _=m.get(u),S=m.get(c);if(_&&S)return _==c&&S==u;var b=-1,E=!0,C=p&o?new e:void 0;for(m.set(u,c),m.set(c,u);++b<x;){var j=u[b],P=c[b];if(h)var O=y?h(P,j,b,c,u,m):h(j,P,b,u,c,m);if(O!==void 0){if(O)continue;E=!1;break}if(C){if(!n(c,function(q,B){if(!i(C,B)&&(j===q||f(j,q,p,h,m)))return C.push(B)})){E=!1;break}}else if(!(j===P||f(j,P,p,h,m))){E=!1;break}}return m.delete(u),m.delete(c),E}return _h=l,_h}var Sh,R_;function lq(){if(R_)return Sh;R_=1;function e(n){var i=-1,s=Array(n.size);return n.forEach(function(o,l){s[++i]=[l,o]}),s}return Sh=e,Sh}var bh,T_;function Rv(){if(T_)return bh;T_=1;function e(n){var i=-1,s=Array(n.size);return n.forEach(function(o){s[++i]=o}),s}return bh=e,bh}var kh,A_;function uq(){if(A_)return kh;A_=1;var e=Gs(),n=LN(),i=Ws(),s=GN(),o=lq(),l=Rv(),u=1,c=2,p="[object Boolean]",h="[object Date]",f="[object Error]",m="[object Map]",y="[object Number]",x="[object RegExp]",N="[object Set]",_="[object String]",S="[object Symbol]",b="[object ArrayBuffer]",E="[object DataView]",C=e?e.prototype:void 0,j=C?C.valueOf:void 0;function P(O,q,B,T,M,F,X){switch(B){case E:if(O.byteLength!=q.byteLength||O.byteOffset!=q.byteOffset)return!1;O=O.buffer,q=q.buffer;case b:return!(O.byteLength!=q.byteLength||!F(new n(O),new n(q)));case p:case h:case y:return i(+O,+q);case f:return O.name==q.name&&O.message==q.message;case x:case _:return O==q+"";case m:var Y=o;case N:var I=T&u;if(Y||(Y=l),O.size!=q.size&&!I)return!1;var H=X.get(O);if(H)return H==q;T|=c,X.set(O,q);var U=s(Y(O),Y(q),T,M,F,X);return X.delete(O),U;case S:if(j)return j.call(O)==j.call(q)}return!1}return kh=P,kh}var Eh,I_;function cq(){if(I_)return Eh;I_=1;var e=ON(),n=1,i=Object.prototype,s=i.hasOwnProperty;function o(l,u,c,p,h,f){var m=c&n,y=e(l),x=y.length,N=e(u),_=N.length;if(x!=_&&!m)return!1;for(var S=x;S--;){var b=y[S];if(!(m?b in u:s.call(u,b)))return!1}var E=f.get(l),C=f.get(u);if(E&&C)return E==u&&C==l;var j=!0;f.set(l,u),f.set(u,l);for(var P=m;++S<x;){b=y[S];var O=l[b],q=u[b];if(p)var B=m?p(q,O,b,u,l,f):p(O,q,b,l,u,f);if(!(B===void 0?O===q||h(O,q,c,p,f):B)){j=!1;break}P||(P=b=="constructor")}if(j&&!P){var T=l.constructor,M=u.constructor;T!=M&&"constructor"in l&&"constructor"in u&&!(typeof T=="function"&&T instanceof T&&typeof M=="function"&&M instanceof M)&&(j=!1)}return f.delete(l),f.delete(u),j}return Eh=o,Eh}var Nh,M_;function dq(){if(M_)return Nh;M_=1;var e=nu(),n=GN(),i=uq(),s=cq(),o=Ys(),l=St(),u=Ks(),c=da(),p=1,h="[object Arguments]",f="[object Array]",m="[object Object]",y=Object.prototype,x=y.hasOwnProperty;function N(_,S,b,E,C,j){var P=l(_),O=l(S),q=P?f:o(_),B=O?f:o(S);q=q==h?m:q,B=B==h?m:B;var T=q==m,M=B==m,F=q==B;if(F&&u(_)){if(!u(S))return!1;P=!0,T=!1}if(F&&!T)return j||(j=new e),P||c(_)?n(_,S,b,E,C,j):i(_,S,q,b,E,C,j);if(!(b&p)){var X=T&&x.call(_,"__wrapped__"),Y=M&&x.call(S,"__wrapped__");if(X||Y){var I=X?_.value():_,H=Y?S.value():S;return j||(j=new e),C(I,H,b,E,j)}}return F?(j||(j=new e),s(_,S,b,E,C,j)):!1}return Nh=N,Nh}var Ch,P_;function KN(){if(P_)return Ch;P_=1;var e=dq(),n=fr();function i(s,o,l,u,c){return s===o?!0:s==null||o==null||!n(s)&&!n(o)?s!==s&&o!==o:e(s,o,l,u,i,c)}return Ch=i,Ch}var jh,O_;function fq(){if(O_)return jh;O_=1;var e=nu(),n=KN(),i=1,s=2;function o(l,u,c,p){var h=c.length,f=h,m=!p;if(l==null)return!f;for(l=Object(l);h--;){var y=c[h];if(m&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++h<f;){y=c[h];var x=y[0],N=l[x],_=y[1];if(m&&y[2]){if(N===void 0&&!(x in l))return!1}else{var S=new e;if(p)var b=p(N,_,x,l,u,S);if(!(b===void 0?n(_,N,i|s,p,S):b))return!1}}return!0}return jh=o,jh}var Rh,q_;function YN(){if(q_)return Rh;q_=1;var e=On();function n(i){return i===i&&!e(i)}return Rh=n,Rh}var Th,L_;function hq(){if(L_)return Th;L_=1;var e=YN(),n=yi();function i(s){for(var o=n(s),l=o.length;l--;){var u=o[l],c=s[u];o[l]=[u,c,e(c)]}return o}return Th=i,Th}var Ah,$_;function XN(){if($_)return Ah;$_=1;function e(n,i){return function(s){return s==null?!1:s[n]===i&&(i!==void 0||n in Object(s))}}return Ah=e,Ah}var Ih,D_;function pq(){if(D_)return Ih;D_=1;var e=fq(),n=hq(),i=XN();function s(o){var l=n(o);return l.length==1&&l[0][2]?i(l[0][0],l[0][1]):function(u){return u===o||e(u,o,l)}}return Ih=s,Ih}var Mh,F_;function Xs(){if(F_)return Mh;F_=1;var e=Ji(),n=fr(),i="[object Symbol]";function s(o){return typeof o=="symbol"||n(o)&&e(o)==i}return Mh=s,Mh}var Ph,z_;function Tv(){if(z_)return Ph;z_=1;var e=St(),n=Xs(),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function o(l,u){if(e(l))return!1;var c=typeof l;return c=="number"||c=="symbol"||c=="boolean"||l==null||n(l)?!0:s.test(l)||!i.test(l)||u!=null&&l in Object(u)}return Ph=o,Ph}var Oh,B_;function mq(){if(B_)return Oh;B_=1;var e=yv(),n="Expected a function";function i(s,o){if(typeof s!="function"||o!=null&&typeof o!="function")throw new TypeError(n);var l=function(){var u=arguments,c=o?o.apply(this,u):u[0],p=l.cache;if(p.has(c))return p.get(c);var h=s.apply(this,u);return l.cache=p.set(c,h)||p,h};return l.cache=new(i.Cache||e),l}return i.Cache=e,Oh=i,Oh}var qh,U_;function gq(){if(U_)return qh;U_=1;var e=mq(),n=500;function i(s){var o=e(s,function(u){return l.size===n&&l.clear(),u}),l=o.cache;return o}return qh=i,qh}var Lh,H_;function vq(){if(H_)return Lh;H_=1;var e=gq(),n=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,s=e(function(o){var l=[];return o.charCodeAt(0)===46&&l.push(""),o.replace(n,function(u,c,p,h){l.push(p?h.replace(i,"$1"):c||u)}),l});return Lh=s,Lh}var $h,V_;function cu(){if(V_)return $h;V_=1;function e(n,i){for(var s=-1,o=n==null?0:n.length,l=Array(o);++s<o;)l[s]=i(n[s],s,n);return l}return $h=e,$h}var Dh,W_;function yq(){if(W_)return Dh;W_=1;var e=Gs(),n=cu(),i=St(),s=Xs(),o=e?e.prototype:void 0,l=o?o.toString:void 0;function u(c){if(typeof c=="string")return c;if(i(c))return n(c,u)+"";if(s(c))return l?l.call(c):"";var p=c+"";return p=="0"&&1/c==-1/0?"-0":p}return Dh=u,Dh}var Fh,G_;function QN(){if(G_)return Fh;G_=1;var e=yq();function n(i){return i==null?"":e(i)}return Fh=n,Fh}var zh,K_;function du(){if(K_)return zh;K_=1;var e=St(),n=Tv(),i=vq(),s=QN();function o(l,u){return e(l)?l:n(l,u)?[l]:i(s(l))}return zh=o,zh}var Bh,Y_;function fa(){if(Y_)return Bh;Y_=1;var e=Xs();function n(i){if(typeof i=="string"||e(i))return i;var s=i+"";return s=="0"&&1/i==-1/0?"-0":s}return Bh=n,Bh}var Uh,X_;function fu(){if(X_)return Uh;X_=1;var e=du(),n=fa();function i(s,o){o=e(o,s);for(var l=0,u=o.length;s!=null&&l<u;)s=s[n(o[l++])];return l&&l==u?s:void 0}return Uh=i,Uh}var Hh,Q_;function wq(){if(Q_)return Hh;Q_=1;var e=fu();function n(i,s,o){var l=i==null?void 0:e(i,s);return l===void 0?o:l}return Hh=n,Hh}var Vh,Z_;function xq(){if(Z_)return Vh;Z_=1;function e(n,i){return n!=null&&i in Object(n)}return Vh=e,Vh}var Wh,J_;function ZN(){if(J_)return Wh;J_=1;var e=du(),n=ca(),i=St(),s=su(),o=xv(),l=fa();function u(c,p,h){p=e(p,c);for(var f=-1,m=p.length,y=!1;++f<m;){var x=l(p[f]);if(!(y=c!=null&&h(c,x)))break;c=c[x]}return y||++f!=m?y:(m=c==null?0:c.length,!!m&&o(m)&&s(x,m)&&(i(c)||n(c)))}return Wh=u,Wh}var Gh,eS;function JN(){if(eS)return Gh;eS=1;var e=xq(),n=ZN();function i(s,o){return s!=null&&n(s,o,e)}return Gh=i,Gh}var Kh,tS;function _q(){if(tS)return Kh;tS=1;var e=KN(),n=wq(),i=JN(),s=Tv(),o=YN(),l=XN(),u=fa(),c=1,p=2;function h(f,m){return s(f)&&o(m)?l(u(f),m):function(y){var x=n(y,f);return x===void 0&&x===m?i(y,f):e(m,x,c|p)}}return Kh=h,Kh}var Yh,nS;function eC(){if(nS)return Yh;nS=1;function e(n){return function(i){return i==null?void 0:i[n]}}return Yh=e,Yh}var Xh,rS;function Sq(){if(rS)return Xh;rS=1;var e=fu();function n(i){return function(s){return e(s,i)}}return Xh=n,Xh}var Qh,iS;function bq(){if(iS)return Qh;iS=1;var e=eC(),n=Sq(),i=Tv(),s=fa();function o(l){return i(l)?e(s(l)):n(l)}return Qh=o,Qh}var Zh,sS;function Lr(){if(sS)return Zh;sS=1;var e=pq(),n=_q(),i=ns(),s=St(),o=bq();function l(u){return typeof u=="function"?u:u==null?i:typeof u=="object"?s(u)?n(u[0],u[1]):e(u):o(u)}return Zh=l,Zh}var Jh,oS;function tC(){if(oS)return Jh;oS=1;var e=AN(),n=iq(),i=Lr(),s=St();function o(l,u){var c=s(l)?e:n;return c(l,i(u,3))}return Jh=o,Jh}var ep,aS;function kq(){if(aS)return ep;aS=1;var e=Object.prototype,n=e.hasOwnProperty;function i(s,o){return s!=null&&n.call(s,o)}return ep=i,ep}var tp,lS;function nC(){if(lS)return tp;lS=1;var e=kq(),n=ZN();function i(s,o){return s!=null&&n(s,o,e)}return tp=i,tp}var np,uS;function Eq(){if(uS)return np;uS=1;var e=Sv(),n=Ys(),i=ca(),s=St(),o=qr(),l=Ks(),u=au(),c=da(),p="[object Map]",h="[object Set]",f=Object.prototype,m=f.hasOwnProperty;function y(x){if(x==null)return!0;if(o(x)&&(s(x)||typeof x=="string"||typeof x.splice=="function"||l(x)||c(x)||i(x)))return!x.length;var N=n(x);if(N==p||N==h)return!x.size;if(u(x))return!e(x).length;for(var _ in x)if(m.call(x,_))return!1;return!0}return np=y,np}var rp,cS;function rC(){if(cS)return rp;cS=1;function e(n){return n===void 0}return rp=e,rp}var ip,dS;function iC(){if(dS)return ip;dS=1;var e=uu(),n=qr();function i(s,o){var l=-1,u=n(s)?Array(s.length):[];return e(s,function(c,p,h){u[++l]=o(c,p,h)}),u}return ip=i,ip}var sp,fS;function sC(){if(fS)return sp;fS=1;var e=cu(),n=Lr(),i=iC(),s=St();function o(l,u){var c=s(l)?e:i;return c(l,n(u,3))}return sp=o,sp}var op,hS;function Nq(){if(hS)return op;hS=1;function e(n,i,s,o){var l=-1,u=n==null?0:n.length;for(o&&u&&(s=n[++l]);++l<u;)s=i(s,n[l],l,n);return s}return op=e,op}var ap,pS;function Cq(){if(pS)return ap;pS=1;function e(n,i,s,o,l){return l(n,function(u,c,p){s=o?(o=!1,u):i(s,u,c,p)}),s}return ap=e,ap}var lp,mS;function oC(){if(mS)return lp;mS=1;var e=Nq(),n=uu(),i=Lr(),s=Cq(),o=St();function l(u,c,p){var h=o(u)?e:s,f=arguments.length<3;return h(u,i(c,4),p,f,n)}return lp=l,lp}var up,gS;function jq(){if(gS)return up;gS=1;var e=Ji(),n=St(),i=fr(),s="[object String]";function o(l){return typeof l=="string"||!n(l)&&i(l)&&e(l)==s}return up=o,up}var cp,vS;function Rq(){if(vS)return cp;vS=1;var e=eC(),n=e("length");return cp=n,cp}var dp,yS;function Tq(){if(yS)return dp;yS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",i="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+i+s,l="\\ufe0e\\ufe0f",u="\\u200d",c=RegExp("["+u+e+o+l+"]");function p(h){return c.test(h)}return dp=p,dp}var fp,wS;function Aq(){if(wS)return fp;wS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",i="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+i+s,l="\\ufe0e\\ufe0f",u="["+e+"]",c="["+o+"]",p="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+p+")",f="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",x="\\u200d",N=h+"?",_="["+l+"]?",S="(?:"+x+"(?:"+[f,m,y].join("|")+")"+_+N+")*",b=_+N+S,E="(?:"+[f+c+"?",c,m,y,u].join("|")+")",C=RegExp(p+"(?="+p+")|"+E+b,"g");function j(P){for(var O=C.lastIndex=0;C.test(P);)++O;return O}return fp=j,fp}var hp,xS;function Iq(){if(xS)return hp;xS=1;var e=Rq(),n=Tq(),i=Aq();function s(o){return n(o)?i(o):e(o)}return hp=s,hp}var pp,_S;function Mq(){if(_S)return pp;_S=1;var e=Sv(),n=Ys(),i=qr(),s=jq(),o=Iq(),l="[object Map]",u="[object Set]";function c(p){if(p==null)return 0;if(i(p))return s(p)?o(p):p.length;var h=n(p);return h==l||h==u?p.size:e(p).length}return pp=c,pp}var mp,SS;function Pq(){if(SS)return mp;SS=1;var e=wv(),n=DN(),i=jv(),s=Lr(),o=lu(),l=St(),u=Ks(),c=la(),p=On(),h=da();function f(m,y,x){var N=l(m),_=N||u(m)||h(m);if(y=s(y,4),x==null){var S=m&&m.constructor;_?x=N?new S:[]:p(m)?x=c(S)?n(o(m)):{}:x={}}return(_?e:i)(m,function(b,E,C){return y(x,b,E,C)}),x}return mp=f,mp}var gp,bS;function Oq(){if(bS)return gp;bS=1;var e=Gs(),n=ca(),i=St(),s=e?e.isConcatSpreadable:void 0;function o(l){return i(l)||n(l)||!!(s&&l&&l[s])}return gp=o,gp}var vp,kS;function Av(){if(kS)return vp;kS=1;var e=kv(),n=Oq();function i(s,o,l,u,c){var p=-1,h=s.length;for(l||(l=n),c||(c=[]);++p<h;){var f=s[p];o>0&&l(f)?o>1?i(f,o-1,l,u,c):e(c,f):u||(c[c.length]=f)}return c}return vp=i,vp}var yp,ES;function qq(){if(ES)return yp;ES=1;function e(n,i,s){switch(s.length){case 0:return n.call(i);case 1:return n.call(i,s[0]);case 2:return n.call(i,s[0],s[1]);case 3:return n.call(i,s[0],s[1],s[2])}return n.apply(i,s)}return yp=e,yp}var wp,NS;function aC(){if(NS)return wp;NS=1;var e=qq(),n=Math.max;function i(s,o,l){return o=n(o===void 0?s.length-1:o,0),function(){for(var u=arguments,c=-1,p=n(u.length-o,0),h=Array(p);++c<p;)h[c]=u[o+c];c=-1;for(var f=Array(o+1);++c<o;)f[c]=u[c];return f[o]=l(h),e(s,this,f)}}return wp=i,wp}var xp,CS;function Lq(){if(CS)return xp;CS=1;var e=Nv(),n=NN(),i=ns(),s=n?function(o,l){return n(o,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:i;return xp=s,xp}var _p,jS;function $q(){if(jS)return _p;jS=1;var e=800,n=16,i=Date.now;function s(o){var l=0,u=0;return function(){var c=i(),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 _p=s,_p}var Sp,RS;function lC(){if(RS)return Sp;RS=1;var e=Lq(),n=$q(),i=n(e);return Sp=i,Sp}var bp,TS;function hu(){if(TS)return bp;TS=1;var e=ns(),n=aC(),i=lC();function s(o,l){return i(n(o,l,e),o+"")}return bp=s,bp}var kp,AS;function uC(){if(AS)return kp;AS=1;function e(n,i,s,o){for(var l=n.length,u=s+(o?1:-1);o?u--:++u<l;)if(i(n[u],u,n))return u;return-1}return kp=e,kp}var Ep,IS;function Dq(){if(IS)return Ep;IS=1;function e(n){return n!==n}return Ep=e,Ep}var Np,MS;function Fq(){if(MS)return Np;MS=1;function e(n,i,s){for(var o=s-1,l=n.length;++o<l;)if(n[o]===i)return o;return-1}return Np=e,Np}var Cp,PS;function zq(){if(PS)return Cp;PS=1;var e=uC(),n=Dq(),i=Fq();function s(o,l,u){return l===l?i(o,l,u):e(o,n,u)}return Cp=s,Cp}var jp,OS;function Bq(){if(OS)return jp;OS=1;var e=zq();function n(i,s){var o=i==null?0:i.length;return!!o&&e(i,s,0)>-1}return jp=n,jp}var Rp,qS;function Uq(){if(qS)return Rp;qS=1;function e(n,i,s){for(var o=-1,l=n==null?0:n.length;++o<l;)if(s(i,n[o]))return!0;return!1}return Rp=e,Rp}var Tp,LS;function Hq(){if(LS)return Tp;LS=1;function e(){}return Tp=e,Tp}var Ap,$S;function Vq(){if($S)return Ap;$S=1;var e=qN(),n=Hq(),i=Rv(),s=1/0,o=e&&1/i(new e([,-0]))[1]==s?function(l){return new e(l)}:n;return Ap=o,Ap}var Ip,DS;function Wq(){if(DS)return Ip;DS=1;var e=VN(),n=Bq(),i=Uq(),s=WN(),o=Vq(),l=Rv(),u=200;function c(p,h,f){var m=-1,y=n,x=p.length,N=!0,_=[],S=_;if(f)N=!1,y=i;else if(x>=u){var b=h?null:o(p);if(b)return l(b);N=!1,y=s,S=new e}else S=h?[]:_;e:for(;++m<x;){var E=p[m],C=h?h(E):E;if(E=f||E!==0?E:0,N&&C===C){for(var j=S.length;j--;)if(S[j]===C)continue e;h&&S.push(C),_.push(E)}else y(S,C,f)||(S!==_&&S.push(C),_.push(E))}return _}return Ip=c,Ip}var Mp,FS;function cC(){if(FS)return Mp;FS=1;var e=qr(),n=fr();function i(s){return n(s)&&e(s)}return Mp=i,Mp}var Pp,zS;function Gq(){if(zS)return Pp;zS=1;var e=Av(),n=hu(),i=Wq(),s=cC(),o=n(function(l){return i(e(l,1,s,!0))});return Pp=o,Pp}var Op,BS;function Kq(){if(BS)return Op;BS=1;var e=cu();function n(i,s){return e(s,function(o){return i[o]})}return Op=n,Op}var qp,US;function dC(){if(US)return qp;US=1;var e=Kq(),n=yi();function i(s){return s==null?[]:e(s,n(s))}return qp=i,qp}var Lp,HS;function qn(){if(HS)return Lp;HS=1;var e;if(typeof gv=="function")try{e={clone:tq(),constant:Nv(),each:HN(),filter:tC(),has:nC(),isArray:St(),isEmpty:Eq(),isFunction:la(),isUndefined:rC(),keys:yi(),map:sC(),reduce:oC(),size:Mq(),transform:Pq(),union:Gq(),values:dC()}}catch{}return e||(e=window._),Lp=e,Lp}var $p,VS;function Iv(){if(VS)return $p;VS=1;var e=qn();$p=o;var n="\0",i="\0",s="";function o(f){this._isDirected=e.has(f,"directed")?f.directed:!0,this._isMultigraph=e.has(f,"multigraph")?f.multigraph:!1,this._isCompound=e.has(f,"compound")?f.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[i]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(f){return this._label=f,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultNodeLabelFn=f,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var f=this;return e.filter(this.nodes(),function(m){return e.isEmpty(f._in[m])})},o.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(m){return e.isEmpty(f._out[m])})},o.prototype.setNodes=function(f,m){var y=arguments,x=this;return e.each(f,function(N){y.length>1?x.setNode(N,m):x.setNode(N)}),this},o.prototype.setNode=function(f,m){return e.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=m),this):(this._nodes[f]=arguments.length>1?m:this._defaultNodeLabelFn(f),this._isCompound&&(this._parent[f]=i,this._children[f]={},this._children[i][f]=!0),this._in[f]={},this._preds[f]={},this._out[f]={},this._sucs[f]={},++this._nodeCount,this)},o.prototype.node=function(f){return this._nodes[f]},o.prototype.hasNode=function(f){return e.has(this._nodes,f)},o.prototype.removeNode=function(f){var m=this;if(e.has(this._nodes,f)){var y=function(x){m.removeEdge(m._edgeObjs[x])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(x){m.setParent(x)}),delete this._children[f]),e.each(e.keys(this._in[f]),y),delete this._in[f],delete this._preds[f],e.each(e.keys(this._out[f]),y),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},o.prototype.setParent=function(f,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(m))m=i;else{m+="";for(var y=m;!e.isUndefined(y);y=this.parent(y))if(y===f)throw new Error("Setting "+m+" as parent of "+f+" would create a cycle");this.setNode(m)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=m,this._children[m][f]=!0,this},o.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},o.prototype.parent=function(f){if(this._isCompound){var m=this._parent[f];if(m!==i)return m}},o.prototype.children=function(f){if(e.isUndefined(f)&&(f=i),this._isCompound){var m=this._children[f];if(m)return e.keys(m)}else{if(f===i)return this.nodes();if(this.hasNode(f))return[]}},o.prototype.predecessors=function(f){var m=this._preds[f];if(m)return e.keys(m)},o.prototype.successors=function(f){var m=this._sucs[f];if(m)return e.keys(m)},o.prototype.neighbors=function(f){var m=this.predecessors(f);if(m)return e.union(m,this.successors(f))},o.prototype.isLeaf=function(f){var m;return this.isDirected()?m=this.successors(f):m=this.neighbors(f),m.length===0},o.prototype.filterNodes=function(f){var m=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});m.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,S){f(S)&&m.setNode(S,_)}),e.each(this._edgeObjs,function(_){m.hasNode(_.v)&&m.hasNode(_.w)&&m.setEdge(_,y.edge(_))});var x={};function N(_){var S=y.parent(_);return S===void 0||m.hasNode(S)?(x[_]=S,S):S in x?x[S]:N(S)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,N(_))}),m},o.prototype.setDefaultEdgeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultEdgeLabelFn=f,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(f,m){var y=this,x=arguments;return e.reduce(f,function(N,_){return x.length>1?y.setEdge(N,_,m):y.setEdge(N,_),_}),this},o.prototype.setEdge=function(){var f,m,y,x,N=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(f=_.v,m=_.w,y=_.name,arguments.length===2&&(x=arguments[1],N=!0)):(f=_,m=arguments[1],y=arguments[3],arguments.length>2&&(x=arguments[2],N=!0)),f=""+f,m=""+m,e.isUndefined(y)||(y=""+y);var S=c(this._isDirected,f,m,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(m),this._edgeLabels[S]=N?x:this._defaultEdgeLabelFn(f,m,y);var b=p(this._isDirected,f,m,y);return f=b.v,m=b.w,Object.freeze(b),this._edgeObjs[S]=b,l(this._preds[m],f),l(this._sucs[f],m),this._in[m][S]=b,this._out[f][S]=b,this._edgeCount++,this},o.prototype.edge=function(f,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,m,y);return this._edgeLabels[x]},o.prototype.hasEdge=function(f,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,m,y);return e.has(this._edgeLabels,x)},o.prototype.removeEdge=function(f,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,m,y),N=this._edgeObjs[x];return N&&(f=N.v,m=N.w,delete this._edgeLabels[x],delete this._edgeObjs[x],u(this._preds[m],f),u(this._sucs[f],m),delete this._in[m][x],delete this._out[f][x],this._edgeCount--),this},o.prototype.inEdges=function(f,m){var y=this._in[f];if(y){var x=e.values(y);return m?e.filter(x,function(N){return N.v===m}):x}},o.prototype.outEdges=function(f,m){var y=this._out[f];if(y){var x=e.values(y);return m?e.filter(x,function(N){return N.w===m}):x}},o.prototype.nodeEdges=function(f,m){var y=this.inEdges(f,m);if(y)return y.concat(this.outEdges(f,m))};function l(f,m){f[m]?f[m]++:f[m]=1}function u(f,m){--f[m]||delete f[m]}function c(f,m,y,x){var N=""+m,_=""+y;if(!f&&N>_){var S=N;N=_,_=S}return N+s+_+s+(e.isUndefined(x)?n:x)}function p(f,m,y,x){var N=""+m,_=""+y;if(!f&&N>_){var S=N;N=_,_=S}var b={v:N,w:_};return x&&(b.name=x),b}function h(f,m){return c(f,m.v,m.w,m.name)}return $p}var Dp,WS;function Yq(){return WS||(WS=1,Dp="2.1.8"),Dp}var Fp,GS;function Xq(){return GS||(GS=1,Fp={Graph:Iv(),version:Yq()}),Fp}var zp,KS;function Qq(){if(KS)return zp;KS=1;var e=qn(),n=Iv();zp={write:i,read:l};function i(u){var c={options:{directed:u.isDirected(),multigraph:u.isMultigraph(),compound:u.isCompound()},nodes:s(u),edges:o(u)};return e.isUndefined(u.graph())||(c.value=e.clone(u.graph())),c}function s(u){return e.map(u.nodes(),function(c){var p=u.node(c),h=u.parent(c),f={v:c};return e.isUndefined(p)||(f.value=p),e.isUndefined(h)||(f.parent=h),f})}function o(u){return e.map(u.edges(),function(c){var p=u.edge(c),h={v:c.v,w:c.w};return e.isUndefined(c.name)||(h.name=c.name),e.isUndefined(p)||(h.value=p),h})}function l(u){var c=new n(u.options).setGraph(u.value);return e.each(u.nodes,function(p){c.setNode(p.v,p.value),p.parent&&c.setParent(p.v,p.parent)}),e.each(u.edges,function(p){c.setEdge({v:p.v,w:p.w,name:p.name},p.value)}),c}return zp}var Bp,YS;function Zq(){if(YS)return Bp;YS=1;var e=qn();Bp=n;function n(i){var s={},o=[],l;function u(c){e.has(s,c)||(s[c]=!0,l.push(c),e.each(i.successors(c),u),e.each(i.predecessors(c),u))}return e.each(i.nodes(),function(c){l=[],u(c),l.length&&o.push(l)}),o}return Bp}var Up,XS;function fC(){if(XS)return Up;XS=1;var e=qn();Up=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(i){return i.key})},n.prototype.has=function(i){return e.has(this._keyIndices,i)},n.prototype.priority=function(i){var s=this._keyIndices[i];if(s!==void 0)return this._arr[s].priority},n.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},n.prototype.add=function(i,s){var o=this._keyIndices;if(i=String(i),!e.has(o,i)){var l=this._arr,u=l.length;return o[i]=u,l.push({key:i,priority:s}),this._decrease(u),!0}return!1},n.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var i=this._arr.pop();return delete this._keyIndices[i.key],this._heapify(0),i.key},n.prototype.decrease=function(i,s){var o=this._keyIndices[i];if(s>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+i+" Old: "+this._arr[o].priority+" New: "+s);this._arr[o].priority=s,this._decrease(o)},n.prototype._heapify=function(i){var s=this._arr,o=2*i,l=o+1,u=i;o<s.length&&(u=s[o].priority<s[u].priority?o:u,l<s.length&&(u=s[l].priority<s[u].priority?l:u),u!==i&&(this._swap(i,u),this._heapify(u)))},n.prototype._decrease=function(i){for(var s=this._arr,o=s[i].priority,l;i!==0&&(l=i>>1,!(s[l].priority<o));)this._swap(i,l),i=l},n.prototype._swap=function(i,s){var o=this._arr,l=this._keyIndices,u=o[i],c=o[s];o[i]=c,o[s]=u,l[c.key]=i,l[u.key]=s},Up}var Hp,QS;function hC(){if(QS)return Hp;QS=1;var e=qn(),n=fC();Hp=s;var i=e.constant(1);function s(l,u,c,p){return o(l,String(u),c||i,p||function(h){return l.outEdges(h)})}function o(l,u,c,p){var h={},f=new n,m,y,x=function(N){var _=N.v!==m?N.v:N.w,S=h[_],b=c(N),E=y.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+N+" Weight: "+b);E<S.distance&&(S.distance=E,S.predecessor=m,f.decrease(_,E))};for(l.nodes().forEach(function(N){var _=N===u?0:Number.POSITIVE_INFINITY;h[N]={distance:_},f.add(N,_)});f.size()>0&&(m=f.removeMin(),y=h[m],y.distance!==Number.POSITIVE_INFINITY);)p(m).forEach(x);return h}return Hp}var Vp,ZS;function Jq(){if(ZS)return Vp;ZS=1;var e=hC(),n=qn();Vp=i;function i(s,o,l){return n.transform(s.nodes(),function(u,c){u[c]=e(s,c,o,l)},{})}return Vp}var Wp,JS;function pC(){if(JS)return Wp;JS=1;var e=qn();Wp=n;function n(i){var s=0,o=[],l={},u=[];function c(p){var h=l[p]={onStack:!0,lowlink:s,index:s++};if(o.push(p),i.successors(p).forEach(function(y){e.has(l,y)?l[y].onStack&&(h.lowlink=Math.min(h.lowlink,l[y].index)):(c(y),h.lowlink=Math.min(h.lowlink,l[y].lowlink))}),h.lowlink===h.index){var f=[],m;do m=o.pop(),l[m].onStack=!1,f.push(m);while(p!==m);u.push(f)}}return i.nodes().forEach(function(p){e.has(l,p)||c(p)}),u}return Wp}var Gp,eb;function eL(){if(eb)return Gp;eb=1;var e=qn(),n=pC();Gp=i;function i(s){return e.filter(n(s),function(o){return o.length>1||o.length===1&&s.hasEdge(o[0],o[0])})}return Gp}var Kp,tb;function tL(){if(tb)return Kp;tb=1;var e=qn();Kp=i;var n=e.constant(1);function i(o,l,u){return s(o,l||n,u||function(c){return o.outEdges(c)})}function s(o,l,u){var c={},p=o.nodes();return p.forEach(function(h){c[h]={},c[h][h]={distance:0},p.forEach(function(f){h!==f&&(c[h][f]={distance:Number.POSITIVE_INFINITY})}),u(h).forEach(function(f){var m=f.v===h?f.w:f.v,y=l(f);c[h][m]={distance:y,predecessor:h}})}),p.forEach(function(h){var f=c[h];p.forEach(function(m){var y=c[m];p.forEach(function(x){var N=y[h],_=f[x],S=y[x],b=N.distance+_.distance;b<S.distance&&(S.distance=b,S.predecessor=_.predecessor)})})}),c}return Kp}var Yp,nb;function mC(){if(nb)return Yp;nb=1;var e=qn();Yp=n,n.CycleException=i;function n(s){var o={},l={},u=[];function c(p){if(e.has(l,p))throw new i;e.has(o,p)||(l[p]=!0,o[p]=!0,e.each(s.predecessors(p),c),delete l[p],u.push(p))}if(e.each(s.sinks(),c),e.size(o)!==s.nodeCount())throw new i;return u}function i(){}return i.prototype=new Error,Yp}var Xp,rb;function nL(){if(rb)return Xp;rb=1;var e=mC();Xp=n;function n(i){try{e(i)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return Xp}var Qp,ib;function gC(){if(ib)return Qp;ib=1;var e=qn();Qp=n;function n(s,o,l){e.isArray(o)||(o=[o]);var u=(s.isDirected()?s.successors:s.neighbors).bind(s),c=[],p={};return e.each(o,function(h){if(!s.hasNode(h))throw new Error("Graph does not have node: "+h);i(s,h,l==="post",p,u,c)}),c}function i(s,o,l,u,c,p){e.has(u,o)||(u[o]=!0,l||p.push(o),e.each(c(o),function(h){i(s,h,l,u,c,p)}),l&&p.push(o))}return Qp}var Zp,sb;function rL(){if(sb)return Zp;sb=1;var e=gC();Zp=n;function n(i,s){return e(i,s,"post")}return Zp}var Jp,ob;function iL(){if(ob)return Jp;ob=1;var e=gC();Jp=n;function n(i,s){return e(i,s,"pre")}return Jp}var em,ab;function sL(){if(ab)return em;ab=1;var e=qn(),n=Iv(),i=fC();em=s;function s(o,l){var u=new n,c={},p=new i,h;function f(y){var x=y.v===h?y.w:y.v,N=p.priority(x);if(N!==void 0){var _=l(y);_<N&&(c[x]=h,p.decrease(x,_))}}if(o.nodeCount()===0)return u;e.each(o.nodes(),function(y){p.add(y,Number.POSITIVE_INFINITY),u.setNode(y)}),p.decrease(o.nodes()[0],0);for(var m=!1;p.size()>0;){if(h=p.removeMin(),e.has(c,h))u.setEdge(h,c[h]);else{if(m)throw new Error("Input graph is not connected: "+o);m=!0}o.nodeEdges(h).forEach(f)}return u}return em}var tm,lb;function oL(){return lb||(lb=1,tm={components:Zq(),dijkstra:hC(),dijkstraAll:Jq(),findCycles:eL(),floydWarshall:tL(),isAcyclic:nL(),postorder:rL(),preorder:iL(),prim:sL(),tarjan:pC(),topsort:mC()}),tm}var nm,ub;function aL(){if(ub)return nm;ub=1;var e=Xq();return nm={Graph:e.Graph,json:Qq(),alg:oL(),version:e.version},nm}var rm,cb;function Qn(){if(cb)return rm;cb=1;var e;if(typeof gv=="function")try{e=aL()}catch{}return e||(e=window.graphlib),rm=e,rm}var im,db;function lL(){if(db)return im;db=1;var e=zN(),n=1,i=4;function s(o){return e(o,n|i)}return im=s,im}var sm,fb;function pu(){if(fb)return sm;fb=1;var e=Ws(),n=qr(),i=su(),s=On();function o(l,u,c){if(!s(c))return!1;var p=typeof u;return(p=="number"?n(c)&&i(u,c.length):p=="string"&&u in c)?e(c[u],l):!1}return sm=o,sm}var om,hb;function uL(){if(hb)return om;hb=1;var e=hu(),n=Ws(),i=pu(),s=ts(),o=Object.prototype,l=o.hasOwnProperty,u=e(function(c,p){c=Object(c);var h=-1,f=p.length,m=f>2?p[2]:void 0;for(m&&i(p[0],p[1],m)&&(f=1);++h<f;)for(var y=p[h],x=s(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 om=u,om}var am,pb;function cL(){if(pb)return am;pb=1;var e=Lr(),n=qr(),i=yi();function s(o){return function(l,u,c){var p=Object(l);if(!n(l)){var h=e(u,3);l=i(l),u=function(m){return h(p[m],m,p)}}var f=o(l,u,c);return f>-1?p[h?l[f]:f]:void 0}}return am=s,am}var lm,mb;function dL(){if(mb)return lm;mb=1;var e=/\s/;function n(i){for(var s=i.length;s--&&e.test(i.charAt(s)););return s}return lm=n,lm}var um,gb;function fL(){if(gb)return um;gb=1;var e=dL(),n=/^\s+/;function i(s){return s&&s.slice(0,e(s)+1).replace(n,"")}return um=i,um}var cm,vb;function hL(){if(vb)return cm;vb=1;var e=fL(),n=On(),i=Xs(),s=NaN,o=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;function p(h){if(typeof h=="number")return h;if(i(h))return s;if(n(h)){var f=typeof h.valueOf=="function"?h.valueOf():h;h=n(f)?f+"":f}if(typeof h!="string")return h===0?h:+h;h=e(h);var m=l.test(h);return m||u.test(h)?c(h.slice(2),m?2:8):o.test(h)?s:+h}return cm=p,cm}var dm,yb;function vC(){if(yb)return dm;yb=1;var e=hL(),n=1/0,i=17976931348623157e292;function s(o){if(!o)return o===0?o:0;if(o=e(o),o===n||o===-n){var l=o<0?-1:1;return l*i}return o===o?o:0}return dm=s,dm}var fm,wb;function pL(){if(wb)return fm;wb=1;var e=vC();function n(i){var s=e(i),o=s%1;return s===s?o?s-o:s:0}return fm=n,fm}var hm,xb;function mL(){if(xb)return hm;xb=1;var e=uC(),n=Lr(),i=pL(),s=Math.max;function o(l,u,c){var p=l==null?0:l.length;if(!p)return-1;var h=c==null?0:i(c);return h<0&&(h=s(p+h,0)),e(l,n(u,3),h)}return hm=o,hm}var pm,_b;function gL(){if(_b)return pm;_b=1;var e=cL(),n=mL(),i=e(n);return pm=i,pm}var mm,Sb;function yC(){if(Sb)return mm;Sb=1;var e=Av();function n(i){var s=i==null?0:i.length;return s?e(i,1):[]}return mm=n,mm}var gm,bb;function vL(){if(bb)return gm;bb=1;var e=Cv(),n=BN(),i=ts();function s(o,l){return o==null?o:e(o,n(l),i)}return gm=s,gm}var vm,kb;function yL(){if(kb)return vm;kb=1;function e(n){var i=n==null?0:n.length;return i?n[i-1]:void 0}return vm=e,vm}var ym,Eb;function wL(){if(Eb)return ym;Eb=1;var e=ru(),n=jv(),i=Lr();function s(o,l){var u={};return l=i(l,3),n(o,function(c,p,h){e(u,p,l(c,p,h))}),u}return ym=s,ym}var wm,Nb;function Mv(){if(Nb)return wm;Nb=1;var e=Xs();function n(i,s,o){for(var l=-1,u=i.length;++l<u;){var c=i[l],p=s(c);if(p!=null&&(h===void 0?p===p&&!e(p):o(p,h)))var h=p,f=c}return f}return wm=n,wm}var xm,Cb;function xL(){if(Cb)return xm;Cb=1;function e(n,i){return n>i}return xm=e,xm}var _m,jb;function _L(){if(jb)return _m;jb=1;var e=Mv(),n=xL(),i=ns();function s(o){return o&&o.length?e(o,i,n):void 0}return _m=s,_m}var Sm,Rb;function wC(){if(Rb)return Sm;Rb=1;var e=ru(),n=Ws();function i(s,o,l){(l!==void 0&&!n(s[o],l)||l===void 0&&!(o in s))&&e(s,o,l)}return Sm=i,Sm}var bm,Tb;function SL(){if(Tb)return bm;Tb=1;var e=Ji(),n=lu(),i=fr(),s="[object Object]",o=Function.prototype,l=Object.prototype,u=o.toString,c=l.hasOwnProperty,p=u.call(Object);function h(f){if(!i(f)||e(f)!=s)return!1;var m=n(f);if(m===null)return!0;var y=c.call(m,"constructor")&&m.constructor;return typeof y=="function"&&y instanceof y&&u.call(y)==p}return bm=h,bm}var km,Ab;function xC(){if(Ab)return km;Ab=1;function e(n,i){if(!(i==="constructor"&&typeof n[i]=="function")&&i!="__proto__")return n[i]}return km=e,km}var Em,Ib;function bL(){if(Ib)return Em;Ib=1;var e=ua(),n=ts();function i(s){return e(s,n(s))}return Em=i,Em}var Nm,Mb;function kL(){if(Mb)return Nm;Mb=1;var e=wC(),n=RN(),i=$N(),s=TN(),o=FN(),l=ca(),u=St(),c=cC(),p=Ks(),h=la(),f=On(),m=SL(),y=da(),x=xC(),N=bL();function _(S,b,E,C,j,P,O){var q=x(S,E),B=x(b,E),T=O.get(B);if(T){e(S,E,T);return}var M=P?P(q,B,E+"",S,b,O):void 0,F=M===void 0;if(F){var X=u(B),Y=!X&&p(B),I=!X&&!Y&&y(B);M=B,X||Y||I?u(q)?M=q:c(q)?M=s(q):Y?(F=!1,M=n(B,!0)):I?(F=!1,M=i(B,!0)):M=[]:m(B)||l(B)?(M=q,l(q)?M=N(q):(!f(q)||h(q))&&(M=o(B))):F=!1}F&&(O.set(B,M),j(M,B,C,P,O),O.delete(B)),e(S,E,M)}return Nm=_,Nm}var Cm,Pb;function EL(){if(Pb)return Cm;Pb=1;var e=nu(),n=wC(),i=Cv(),s=kL(),o=On(),l=ts(),u=xC();function c(p,h,f,m,y){p!==h&&i(h,function(x,N){if(y||(y=new e),o(x))s(p,h,N,f,c,m,y);else{var _=m?m(u(p,N),x,N+"",p,h,y):void 0;_===void 0&&(_=x),n(p,N,_)}},l)}return Cm=c,Cm}var jm,Ob;function NL(){if(Ob)return jm;Ob=1;var e=hu(),n=pu();function i(s){return e(function(o,l){var u=-1,c=l.length,p=c>1?l[c-1]:void 0,h=c>2?l[2]:void 0;for(p=s.length>3&&typeof p=="function"?(c--,p):void 0,h&&n(l[0],l[1],h)&&(p=c<3?void 0:p,c=1),o=Object(o);++u<c;){var f=l[u];f&&s(o,f,u,p)}return o})}return jm=i,jm}var Rm,qb;function CL(){if(qb)return Rm;qb=1;var e=EL(),n=NL(),i=n(function(s,o,l){e(s,o,l)});return Rm=i,Rm}var Tm,Lb;function _C(){if(Lb)return Tm;Lb=1;function e(n,i){return n<i}return Tm=e,Tm}var Am,$b;function jL(){if($b)return Am;$b=1;var e=Mv(),n=_C(),i=ns();function s(o){return o&&o.length?e(o,i,n):void 0}return Am=s,Am}var Im,Db;function RL(){if(Db)return Im;Db=1;var e=Mv(),n=Lr(),i=_C();function s(o,l){return o&&o.length?e(o,n(l,2),i):void 0}return Im=s,Im}var Mm,Fb;function TL(){if(Fb)return Mm;Fb=1;var e=Jn(),n=function(){return e.Date.now()};return Mm=n,Mm}var Pm,zb;function AL(){if(zb)return Pm;zb=1;var e=iu(),n=du(),i=su(),s=On(),o=fa();function l(u,c,p,h){if(!s(u))return u;c=n(c,u);for(var f=-1,m=c.length,y=m-1,x=u;x!=null&&++f<m;){var N=o(c[f]),_=p;if(N==="__proto__"||N==="constructor"||N==="prototype")return u;if(f!=y){var S=x[N];_=h?h(S,N,x):void 0,_===void 0&&(_=s(S)?S:i(c[f+1])?[]:{})}e(x,N,_),x=x[N]}return u}return Pm=l,Pm}var Om,Bb;function IL(){if(Bb)return Om;Bb=1;var e=fu(),n=AL(),i=du();function s(o,l,u){for(var c=-1,p=l.length,h={};++c<p;){var f=l[c],m=e(o,f);u(m,f)&&n(h,i(f,o),m)}return h}return Om=s,Om}var qm,Ub;function ML(){if(Ub)return qm;Ub=1;var e=IL(),n=JN();function i(s,o){return e(s,o,function(l,u){return n(s,u)})}return qm=i,qm}var Lm,Hb;function PL(){if(Hb)return Lm;Hb=1;var e=yC(),n=aC(),i=lC();function s(o){return i(n(o,void 0,e),o+"")}return Lm=s,Lm}var $m,Vb;function OL(){if(Vb)return $m;Vb=1;var e=ML(),n=PL(),i=n(function(s,o){return s==null?{}:e(s,o)});return $m=i,$m}var Dm,Wb;function qL(){if(Wb)return Dm;Wb=1;var e=Math.ceil,n=Math.max;function i(s,o,l,u){for(var c=-1,p=n(e((o-s)/(l||1)),0),h=Array(p);p--;)h[u?p:++c]=s,s+=l;return h}return Dm=i,Dm}var Fm,Gb;function LL(){if(Gb)return Fm;Gb=1;var e=qL(),n=pu(),i=vC();function s(o){return function(l,u,c){return c&&typeof c!="number"&&n(l,u,c)&&(u=c=void 0),l=i(l),u===void 0?(u=l,l=0):u=i(u),c=c===void 0?l<u?1:-1:i(c),e(l,u,c,o)}}return Fm=s,Fm}var zm,Kb;function $L(){if(Kb)return zm;Kb=1;var e=LL(),n=e();return zm=n,zm}var Bm,Yb;function DL(){if(Yb)return Bm;Yb=1;function e(n,i){var s=n.length;for(n.sort(i);s--;)n[s]=n[s].value;return n}return Bm=e,Bm}var Um,Xb;function FL(){if(Xb)return Um;Xb=1;var e=Xs();function n(i,s){if(i!==s){var o=i!==void 0,l=i===null,u=i===i,c=e(i),p=s!==void 0,h=s===null,f=s===s,m=e(s);if(!h&&!m&&!c&&i>s||c&&p&&f&&!h&&!m||l&&p&&f||!o&&f||!u)return 1;if(!l&&!c&&!m&&i<s||m&&o&&u&&!l&&!c||h&&o&&u||!p&&u||!f)return-1}return 0}return Um=n,Um}var Hm,Qb;function zL(){if(Qb)return Hm;Qb=1;var e=FL();function n(i,s,o){for(var l=-1,u=i.criteria,c=s.criteria,p=u.length,h=o.length;++l<p;){var f=e(u[l],c[l]);if(f){if(l>=h)return f;var m=o[l];return f*(m=="desc"?-1:1)}}return i.index-s.index}return Hm=n,Hm}var Vm,Zb;function BL(){if(Zb)return Vm;Zb=1;var e=cu(),n=fu(),i=Lr(),s=iC(),o=DL(),l=ou(),u=zL(),c=ns(),p=St();function h(f,m,y){m.length?m=e(m,function(_){return p(_)?function(S){return n(S,_.length===1?_[0]:_)}:_}):m=[c];var x=-1;m=e(m,l(i));var N=s(f,function(_,S,b){var E=e(m,function(C){return C(_)});return{criteria:E,index:++x,value:_}});return o(N,function(_,S){return u(_,S,y)})}return Vm=h,Vm}var Wm,Jb;function UL(){if(Jb)return Wm;Jb=1;var e=Av(),n=BL(),i=hu(),s=pu(),o=i(function(l,u){if(l==null)return[];var c=u.length;return c>1&&s(l,u[0],u[1])?u=[]:c>2&&s(u[0],u[1],u[2])&&(u=[u[0]]),n(l,e(u,1),[])});return Wm=o,Wm}var Gm,ek;function HL(){if(ek)return Gm;ek=1;var e=QN(),n=0;function i(s){var o=++n;return e(s)+o}return Gm=i,Gm}var Km,tk;function VL(){if(tk)return Km;tk=1;function e(n,i,s){for(var o=-1,l=n.length,u=i.length,c={};++o<l;){var p=o<u?i[o]:void 0;s(c,n[o],p)}return c}return Km=e,Km}var Ym,nk;function WL(){if(nk)return Ym;nk=1;var e=iu(),n=VL();function i(s,o){return n(s||[],o||[],e)}return Ym=i,Ym}var Xm,rk;function ot(){if(rk)return Xm;rk=1;var e;if(typeof gv=="function")try{e={cloneDeep:lL(),constant:Nv(),defaults:uL(),each:HN(),filter:tC(),find:gL(),flatten:yC(),forEach:UN(),forIn:vL(),has:nC(),isUndefined:rC(),last:yL(),map:sC(),mapValues:wL(),max:_L(),merge:CL(),min:jL(),minBy:RL(),now:TL(),pick:OL(),range:$L(),reduce:oC(),sortBy:UL(),uniqueId:HL(),values:dC(),zipObject:WL()}}catch{}return e||(e=window._),Xm=e,Xm}var Qm,ik;function GL(){if(ik)return Qm;ik=1,Qm=e;function e(){var s={};s._next=s._prev=s,this._sentinel=s}e.prototype.dequeue=function(){var s=this._sentinel,o=s._prev;if(o!==s)return n(o),o},e.prototype.enqueue=function(s){var o=this._sentinel;s._prev&&s._next&&n(s),s._next=o._next,o._next._prev=s,o._next=s,s._prev=o},e.prototype.toString=function(){for(var s=[],o=this._sentinel,l=o._prev;l!==o;)s.push(JSON.stringify(l,i)),l=l._prev;return"["+s.join(", ")+"]"};function n(s){s._prev._next=s._next,s._next._prev=s._prev,delete s._next,delete s._prev}function i(s,o){if(s!=="_next"&&s!=="_prev")return o}return Qm}var Zm,sk;function KL(){if(sk)return Zm;sk=1;var e=ot(),n=Qn().Graph,i=GL();Zm=o;var s=e.constant(1);function o(h,f){if(h.nodeCount()<=1)return[];var m=c(h,f||s),y=l(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(x){return h.outEdges(x.v,x.w)}),!0)}function l(h,f,m){for(var y=[],x=f[f.length-1],N=f[0],_;h.nodeCount();){for(;_=N.dequeue();)u(h,f,m,_);for(;_=x.dequeue();)u(h,f,m,_);if(h.nodeCount()){for(var S=f.length-2;S>0;--S)if(_=f[S].dequeue(),_){y=y.concat(u(h,f,m,_,!0));break}}}return y}function u(h,f,m,y,x){var N=x?[]:void 0;return e.forEach(h.inEdges(y.v),function(_){var S=h.edge(_),b=h.node(_.v);x&&N.push({v:_.v,w:_.w}),b.out-=S,p(f,m,b)}),e.forEach(h.outEdges(y.v),function(_){var S=h.edge(_),b=_.w,E=h.node(b);E.in-=S,p(f,m,E)}),h.removeNode(y.v),N}function c(h,f){var m=new n,y=0,x=0;e.forEach(h.nodes(),function(S){m.setNode(S,{v:S,in:0,out:0})}),e.forEach(h.edges(),function(S){var b=m.edge(S.v,S.w)||0,E=f(S),C=b+E;m.setEdge(S.v,S.w,C),x=Math.max(x,m.node(S.v).out+=E),y=Math.max(y,m.node(S.w).in+=E)});var N=e.range(x+y+3).map(function(){return new i}),_=y+1;return e.forEach(m.nodes(),function(S){p(N,_,m.node(S))}),{graph:m,buckets:N,zeroIdx:_}}function p(h,f,m){m.out?m.in?h[m.out-m.in+f].enqueue(m):h[h.length-1].enqueue(m):h[0].enqueue(m)}return Zm}var Jm,ok;function YL(){if(ok)return Jm;ok=1;var e=ot(),n=KL();Jm={run:i,undo:o};function i(l){var u=l.graph().acyclicer==="greedy"?n(l,c(l)):s(l);e.forEach(u,function(p){var h=l.edge(p);l.removeEdge(p),h.forwardName=p.name,h.reversed=!0,l.setEdge(p.w,p.v,h,e.uniqueId("rev"))});function c(p){return function(h){return p.edge(h).weight}}}function s(l){var u=[],c={},p={};function h(f){e.has(p,f)||(p[f]=!0,c[f]=!0,e.forEach(l.outEdges(f),function(m){e.has(c,m.w)?u.push(m):h(m.w)}),delete c[f])}return e.forEach(l.nodes(),h),u}function o(l){e.forEach(l.edges(),function(u){var c=l.edge(u);if(c.reversed){l.removeEdge(u);var p=c.forwardName;delete c.reversed,delete c.forwardName,l.setEdge(u.w,u.v,c,p)}})}return Jm}var eg,ak;function fn(){if(ak)return eg;ak=1;var e=ot(),n=Qn().Graph;eg={addDummyNode:i,simplify:s,asNonCompoundGraph:o,successorWeights:l,predecessorWeights:u,intersectRect:c,buildLayerMatrix:p,normalizeRanks:h,removeEmptyRanks:f,addBorderNode:m,maxRank:y,partition:x,time:N,notime:_};function i(S,b,E,C){var j;do j=e.uniqueId(C);while(S.hasNode(j));return E.dummy=b,S.setNode(j,E),j}function s(S){var b=new n().setGraph(S.graph());return e.forEach(S.nodes(),function(E){b.setNode(E,S.node(E))}),e.forEach(S.edges(),function(E){var C=b.edge(E.v,E.w)||{weight:0,minlen:1},j=S.edge(E);b.setEdge(E.v,E.w,{weight:C.weight+j.weight,minlen:Math.max(C.minlen,j.minlen)})}),b}function o(S){var b=new n({multigraph:S.isMultigraph()}).setGraph(S.graph());return e.forEach(S.nodes(),function(E){S.children(E).length||b.setNode(E,S.node(E))}),e.forEach(S.edges(),function(E){b.setEdge(E,S.edge(E))}),b}function l(S){var b=e.map(S.nodes(),function(E){var C={};return e.forEach(S.outEdges(E),function(j){C[j.w]=(C[j.w]||0)+S.edge(j).weight}),C});return e.zipObject(S.nodes(),b)}function u(S){var b=e.map(S.nodes(),function(E){var C={};return e.forEach(S.inEdges(E),function(j){C[j.v]=(C[j.v]||0)+S.edge(j).weight}),C});return e.zipObject(S.nodes(),b)}function c(S,b){var E=S.x,C=S.y,j=b.x-E,P=b.y-C,O=S.width/2,q=S.height/2;if(!j&&!P)throw new Error("Not possible to find intersection inside of the rectangle");var B,T;return Math.abs(P)*O>Math.abs(j)*q?(P<0&&(q=-q),B=q*j/P,T=q):(j<0&&(O=-O),B=O,T=O*P/j),{x:E+B,y:C+T}}function p(S){var b=e.map(e.range(y(S)+1),function(){return[]});return e.forEach(S.nodes(),function(E){var C=S.node(E),j=C.rank;e.isUndefined(j)||(b[j][C.order]=E)}),b}function h(S){var b=e.min(e.map(S.nodes(),function(E){return S.node(E).rank}));e.forEach(S.nodes(),function(E){var C=S.node(E);e.has(C,"rank")&&(C.rank-=b)})}function f(S){var b=e.min(e.map(S.nodes(),function(P){return S.node(P).rank})),E=[];e.forEach(S.nodes(),function(P){var O=S.node(P).rank-b;E[O]||(E[O]=[]),E[O].push(P)});var C=0,j=S.graph().nodeRankFactor;e.forEach(E,function(P,O){e.isUndefined(P)&&O%j!==0?--C:C&&e.forEach(P,function(q){S.node(q).rank+=C})})}function m(S,b,E,C){var j={width:0,height:0};return arguments.length>=4&&(j.rank=E,j.order=C),i(S,"border",j,b)}function y(S){return e.max(e.map(S.nodes(),function(b){var E=S.node(b).rank;if(!e.isUndefined(E))return E}))}function x(S,b){var E={lhs:[],rhs:[]};return e.forEach(S,function(C){b(C)?E.lhs.push(C):E.rhs.push(C)}),E}function N(S,b){var E=e.now();try{return b()}finally{console.log(S+" time: "+(e.now()-E)+"ms")}}function _(S,b){return b()}return eg}var tg,lk;function XL(){if(lk)return tg;lk=1;var e=ot(),n=fn();tg={run:i,undo:o};function i(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(u){s(l,u)})}function s(l,u){var c=u.v,p=l.node(c).rank,h=u.w,f=l.node(h).rank,m=u.name,y=l.edge(u),x=y.labelRank;if(f!==p+1){l.removeEdge(u);var N,_,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},m),S===0&&l.graph().dummyChains.push(N),c=N;l.setEdge(c,h,{weight:y.weight},m)}}function o(l){e.forEach(l.graph().dummyChains,function(u){var c=l.node(u),p=c.edgeLabel,h;for(l.setEdge(c.edgeObj,p);c.dummy;)h=l.successors(u)[0],l.removeNode(u),p.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(p.x=c.x,p.y=c.y,p.width=c.width,p.height=c.height),u=h,c=l.node(u)})}return tg}var ng,uk;function Hl(){if(uk)return ng;uk=1;var e=ot();ng={longestPath:n,slack:i};function n(s){var o={};function l(u){var c=s.node(u);if(e.has(o,u))return c.rank;o[u]=!0;var p=e.min(e.map(s.outEdges(u),function(h){return l(h.w)-s.edge(h).minlen}));return(p===Number.POSITIVE_INFINITY||p===void 0||p===null)&&(p=0),c.rank=p}e.forEach(s.sources(),l)}function i(s,o){return s.node(o.w).rank-s.node(o.v).rank-s.edge(o).minlen}return ng}var rg,ck;function SC(){if(ck)return rg;ck=1;var e=ot(),n=Qn().Graph,i=Hl().slack;rg=s;function s(c){var p=new n({directed:!1}),h=c.nodes()[0],f=c.nodeCount();p.setNode(h,{});for(var m,y;o(p,c)<f;)m=l(p,c),y=p.hasNode(m.v)?i(c,m):-i(c,m),u(p,c,y);return p}function o(c,p){function h(f){e.forEach(p.nodeEdges(f),function(m){var y=m.v,x=f===y?m.w:y;!c.hasNode(x)&&!i(p,m)&&(c.setNode(x,{}),c.setEdge(f,x,{}),h(x))})}return e.forEach(c.nodes(),h),c.nodeCount()}function l(c,p){return e.minBy(p.edges(),function(h){if(c.hasNode(h.v)!==c.hasNode(h.w))return i(p,h)})}function u(c,p,h){e.forEach(c.nodes(),function(f){p.node(f).rank+=h})}return rg}var ig,dk;function QL(){if(dk)return ig;dk=1;var e=ot(),n=SC(),i=Hl().slack,s=Hl().longestPath,o=Qn().alg.preorder,l=Qn().alg.postorder,u=fn().simplify;ig=c,c.initLowLimValues=m,c.initCutValues=p,c.calcCutValue=f,c.leaveEdge=x,c.enterEdge=N,c.exchangeEdges=_;function c(C){C=u(C),s(C);var j=n(C);m(j),p(j,C);for(var P,O;P=x(j);)O=N(j,C,P),_(j,C,P,O)}function p(C,j){var P=l(C,C.nodes());P=P.slice(0,P.length-1),e.forEach(P,function(O){h(C,j,O)})}function h(C,j,P){var O=C.node(P),q=O.parent;C.edge(P,q).cutvalue=f(C,j,P)}function f(C,j,P){var O=C.node(P),q=O.parent,B=!0,T=j.edge(P,q),M=0;return T||(B=!1,T=j.edge(q,P)),M=T.weight,e.forEach(j.nodeEdges(P),function(F){var X=F.v===P,Y=X?F.w:F.v;if(Y!==q){var I=X===B,H=j.edge(F).weight;if(M+=I?H:-H,b(C,P,Y)){var U=C.edge(P,Y).cutvalue;M+=I?-U:U}}}),M}function m(C,j){arguments.length<2&&(j=C.nodes()[0]),y(C,{},1,j)}function y(C,j,P,O,q){var B=P,T=C.node(O);return j[O]=!0,e.forEach(C.neighbors(O),function(M){e.has(j,M)||(P=y(C,j,P,M,O))}),T.low=B,T.lim=P++,q?T.parent=q:delete T.parent,P}function x(C){return e.find(C.edges(),function(j){return C.edge(j).cutvalue<0})}function N(C,j,P){var O=P.v,q=P.w;j.hasEdge(O,q)||(O=P.w,q=P.v);var B=C.node(O),T=C.node(q),M=B,F=!1;B.lim>T.lim&&(M=T,F=!0);var X=e.filter(j.edges(),function(Y){return F===E(C,C.node(Y.v),M)&&F!==E(C,C.node(Y.w),M)});return e.minBy(X,function(Y){return i(j,Y)})}function _(C,j,P,O){var q=P.v,B=P.w;C.removeEdge(q,B),C.setEdge(O.v,O.w,{}),m(C),p(C,j),S(C,j)}function S(C,j){var P=e.find(C.nodes(),function(q){return!j.node(q).parent}),O=o(C,P);O=O.slice(1),e.forEach(O,function(q){var B=C.node(q).parent,T=j.edge(q,B),M=!1;T||(T=j.edge(B,q),M=!0),j.node(q).rank=j.node(B).rank+(M?T.minlen:-T.minlen)})}function b(C,j,P){return C.hasEdge(j,P)}function E(C,j,P){return P.low<=j.lim&&j.lim<=P.lim}return ig}var sg,fk;function ZL(){if(fk)return sg;fk=1;var e=Hl(),n=e.longestPath,i=SC(),s=QL();sg=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),i(p)}function c(p){s(p)}return sg}var og,hk;function JL(){if(hk)return og;hk=1;var e=ot();og=n;function n(o){var l=s(o);e.forEach(o.graph().dummyChains,function(u){for(var c=o.node(u),p=c.edgeObj,h=i(o,l,p.v,p.w),f=h.path,m=h.lca,y=0,x=f[y],N=!0;u!==p.w;){if(c=o.node(u),N){for(;(x=f[y])!==m&&o.node(x).maxRank<c.rank;)y++;x===m&&(N=!1)}if(!N){for(;y<f.length-1&&o.node(x=f[y+1]).minRank<=c.rank;)y++;x=f[y]}o.setParent(u,x),u=o.successors(u)[0]}})}function i(o,l,u,c){var p=[],h=[],f=Math.min(l[u].low,l[c].low),m=Math.max(l[u].lim,l[c].lim),y,x;y=u;do y=o.parent(y),p.push(y);while(y&&(l[y].low>f||m>l[y].lim));for(x=y,y=c;(y=o.parent(y))!==x;)h.push(y);return{path:p.concat(h.reverse()),lca:x}}function s(o){var l={},u=0;function c(p){var h=u;e.forEach(o.children(p),c),l[p]={low:h,lim:u++}}return e.forEach(o.children(),c),l}return og}var ag,pk;function e$(){if(pk)return ag;pk=1;var e=ot(),n=fn();ag={run:i,cleanup:u};function i(c){var p=n.addDummyNode(c,"root",{},"_root"),h=o(c),f=e.max(e.values(h))-1,m=2*f+1;c.graph().nestingRoot=p,e.forEach(c.edges(),function(x){c.edge(x).minlen*=m});var y=l(c)+1;e.forEach(c.children(),function(x){s(c,p,m,y,f,h,x)}),c.graph().nodeRankFactor=m}function s(c,p,h,f,m,y,x){var N=c.children(x);if(!N.length){x!==p&&c.setEdge(p,x,{weight:0,minlen:h});return}var _=n.addBorderNode(c,"_bt"),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(E){s(c,p,h,f,m,y,E);var C=c.node(E),j=C.borderTop?C.borderTop:E,P=C.borderBottom?C.borderBottom:E,O=C.borderTop?f:2*f,q=j!==P?1:m-y[x]+1;c.setEdge(_,j,{weight:O,minlen:q,nestingEdge:!0}),c.setEdge(P,S,{weight:O,minlen:q,nestingEdge:!0})}),c.parent(x)||c.setEdge(p,_,{weight:0,minlen:m+y[x]})}function o(c){var p={};function h(f,m){var y=c.children(f);y&&y.length&&e.forEach(y,function(x){h(x,m+1)}),p[f]=m}return e.forEach(c.children(),function(f){h(f,1)}),p}function l(c){return e.reduce(c.edges(),function(p,h){return p+c.edge(h).weight},0)}function u(c){var p=c.graph();c.removeNode(p.nestingRoot),delete p.nestingRoot,e.forEach(c.edges(),function(h){var f=c.edge(h);f.nestingEdge&&c.removeEdge(h)})}return ag}var lg,mk;function t$(){if(mk)return lg;mk=1;var e=ot(),n=fn();lg=i;function i(o){function l(u){var c=o.children(u),p=o.node(u);if(c.length&&e.forEach(c,l),e.has(p,"minRank")){p.borderLeft=[],p.borderRight=[];for(var h=p.minRank,f=p.maxRank+1;h<f;++h)s(o,"borderLeft","_bl",u,p,h),s(o,"borderRight","_br",u,p,h)}}e.forEach(o.children(),l)}function s(o,l,u,c,p,h){var f={width:0,height:0,rank:h,borderType:l},m=p[l][h-1],y=n.addDummyNode(o,"border",f,u);p[l][h]=y,o.setParent(y,c),m&&o.setEdge(m,y,{weight:1})}return lg}var ug,gk;function n$(){if(gk)return ug;gk=1;var e=ot();ug={adjust:n,undo:i};function n(h){var f=h.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&s(h)}function i(h){var f=h.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&l(h),(f==="lr"||f==="rl")&&(c(h),s(h))}function s(h){e.forEach(h.nodes(),function(f){o(h.node(f))}),e.forEach(h.edges(),function(f){o(h.edge(f))})}function o(h){var f=h.width;h.width=h.height,h.height=f}function l(h){e.forEach(h.nodes(),function(f){u(h.node(f))}),e.forEach(h.edges(),function(f){var m=h.edge(f);e.forEach(m.points,u),e.has(m,"y")&&u(m)})}function u(h){h.y=-h.y}function c(h){e.forEach(h.nodes(),function(f){p(h.node(f))}),e.forEach(h.edges(),function(f){var m=h.edge(f);e.forEach(m.points,p),e.has(m,"x")&&p(m)})}function p(h){var f=h.x;h.x=h.y,h.y=f}return ug}var cg,vk;function r$(){if(vk)return cg;vk=1;var e=ot();cg=n;function n(i){var s={},o=e.filter(i.nodes(),function(h){return!i.children(h).length}),l=e.max(e.map(o,function(h){return i.node(h).rank})),u=e.map(e.range(l+1),function(){return[]});function c(h){if(!e.has(s,h)){s[h]=!0;var f=i.node(h);u[f.rank].push(h),e.forEach(i.successors(h),c)}}var p=e.sortBy(o,function(h){return i.node(h).rank});return e.forEach(p,c),u}return cg}var dg,yk;function i$(){if(yk)return dg;yk=1;var e=ot();dg=n;function n(s,o){for(var l=0,u=1;u<o.length;++u)l+=i(s,o[u-1],o[u]);return l}function i(s,o,l){for(var u=e.zipObject(l,e.map(l,function(y,x){return x})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(s.outEdges(y),function(x){return{pos:u[x.w],weight:s.edge(x).weight}}),"pos")}),!0),p=1;p<l.length;)p<<=1;var h=2*p-1;p-=1;var f=e.map(new Array(h),function(){return 0}),m=0;return e.forEach(c.forEach(function(y){var x=y.pos+p;f[x]+=y.weight;for(var N=0;x>0;)x%2&&(N+=f[x+1]),x=x-1>>1,f[x]+=y.weight;m+=y.weight*N})),m}return dg}var fg,wk;function s$(){if(wk)return fg;wk=1;var e=ot();fg=n;function n(i,s){return e.map(s,function(o){var l=i.inEdges(o);if(l.length){var u=e.reduce(l,function(c,p){var h=i.edge(p),f=i.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 fg}var hg,xk;function o$(){if(xk)return hg;xk=1;var e=ot();hg=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 i(c)}function i(o){var l=[];function u(h){return function(f){f.merged||(e.isUndefined(f.barycenter)||e.isUndefined(h.barycenter)||f.barycenter>=h.barycenter)&&s(h,f)}}function c(h){return function(f){f.in.push(h),--f.indegree===0&&o.push(f)}}for(;o.length;){var p=o.pop();l.push(p),e.forEach(p.in.reverse(),u(p)),e.forEach(p.out,c(p))}return e.map(e.filter(l,function(h){return!h.merged}),function(h){return e.pick(h,["vs","i","barycenter","weight"])})}function s(o,l){var u=0,c=0;o.weight&&(u+=o.barycenter*o.weight,c+=o.weight),l.weight&&(u+=l.barycenter*l.weight,c+=l.weight),o.vs=l.vs.concat(o.vs),o.barycenter=u/c,o.weight=c,o.i=Math.min(l.i,o.i),l.merged=!0}return hg}var pg,_k;function a$(){if(_k)return pg;_k=1;var e=ot(),n=fn();pg=i;function i(l,u){var c=n.partition(l,function(_){return e.has(_,"barycenter")}),p=c.lhs,h=e.sortBy(c.rhs,function(_){return-_.i}),f=[],m=0,y=0,x=0;p.sort(o(!!u)),x=s(f,h,x),e.forEach(p,function(_){x+=_.vs.length,f.push(_.vs),m+=_.barycenter*_.weight,y+=_.weight,x=s(f,h,x)});var N={vs:e.flatten(f,!0)};return y&&(N.barycenter=m/y,N.weight=y),N}function s(l,u,c){for(var p;u.length&&(p=e.last(u)).i<=c;)u.pop(),l.push(p.vs),c++;return c}function o(l){return function(u,c){return u.barycenter<c.barycenter?-1:u.barycenter>c.barycenter?1:l?c.i-u.i:u.i-c.i}}return pg}var mg,Sk;function l$(){if(Sk)return mg;Sk=1;var e=ot(),n=s$(),i=o$(),s=a$();mg=o;function o(c,p,h,f){var m=c.children(p),y=c.node(p),x=y?y.borderLeft:void 0,N=y?y.borderRight:void 0,_={};x&&(m=e.filter(m,function(P){return P!==x&&P!==N}));var S=n(c,m);e.forEach(S,function(P){if(c.children(P.v).length){var O=o(c,P.v,h,f);_[P.v]=O,e.has(O,"barycenter")&&u(P,O)}});var b=i(S,h);l(b,_);var E=s(b,f);if(x&&(E.vs=e.flatten([x,E.vs,N],!0),c.predecessors(x).length)){var C=c.node(c.predecessors(x)[0]),j=c.node(c.predecessors(N)[0]);e.has(E,"barycenter")||(E.barycenter=0,E.weight=0),E.barycenter=(E.barycenter*E.weight+C.order+j.order)/(E.weight+2),E.weight+=2}return E}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 mg}var gg,bk;function u$(){if(bk)return gg;bk=1;var e=ot(),n=Qn().Graph;gg=i;function i(o,l,u){var c=s(o),p=new n({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(h){return o.node(h)});return e.forEach(o.nodes(),function(h){var f=o.node(h),m=o.parent(h);(f.rank===l||f.minRank<=l&&l<=f.maxRank)&&(p.setNode(h),p.setParent(h,m||c),e.forEach(o[u](h),function(y){var x=y.v===h?y.w:y.v,N=p.edge(x,h),_=e.isUndefined(N)?0:N.weight;p.setEdge(x,h,{weight:o.edge(y).weight+_})}),e.has(f,"minRank")&&p.setNode(h,{borderLeft:f.borderLeft[l],borderRight:f.borderRight[l]}))}),p}function s(o){for(var l;o.hasNode(l=e.uniqueId("_root")););return l}return gg}var vg,kk;function c$(){if(kk)return vg;kk=1;var e=ot();vg=n;function n(i,s,o){var l={},u;e.forEach(o,function(c){for(var p=i.parent(c),h,f;p;){if(h=i.parent(p),h?(f=l[h],l[h]=p):(f=u,u=p),f&&f!==p){s.setEdge(f,p);return}p=h}})}return vg}var yg,Ek;function d$(){if(Ek)return yg;Ek=1;var e=ot(),n=r$(),i=i$(),s=l$(),o=u$(),l=c$(),u=Qn().Graph,c=fn();yg=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);m(y,S);for(var b=Number.POSITIVE_INFINITY,E,C=0,j=0;j<4;++C,++j){f(C%2?N:_,C%4>=2),S=c.buildLayerMatrix(y);var P=i(y,S);P<b&&(j=0,E=e.cloneDeep(S),b=P)}m(y,E)}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=s(_,S,N,x);e.forEach(b.vs,function(E,C){_.node(E).order=C}),l(_,N,b.vs)})}function m(y,x){e.forEach(x,function(N){e.forEach(N,function(_,S){y.node(_).order=S})})}return yg}var wg,Nk;function f$(){if(Nk)return wg;Nk=1;var e=ot(),n=Qn().Graph,i=fn();wg={positionX:N,findType1Conflicts:s,findType2Conflicts:o,addConflict:u,hasConflict:c,verticalAlignment:p,horizontalCompaction:h,alignCoordinates:y,findSmallestWidthAlignment:m,balance:x};function s(b,E){var C={};function j(P,O){var q=0,B=0,T=P.length,M=e.last(O);return e.forEach(O,function(F,X){var Y=l(b,F),I=Y?b.node(Y).order:T;(Y||F===M)&&(e.forEach(O.slice(B,X+1),function(H){e.forEach(b.predecessors(H),function(U){var ne=b.node(U),J=ne.order;(J<q||I<J)&&!(ne.dummy&&b.node(H).dummy)&&u(C,U,H)})}),B=X+1,q=I)}),O}return e.reduce(E,j),C}function o(b,E){var C={};function j(O,q,B,T,M){var F;e.forEach(e.range(q,B),function(X){F=O[X],b.node(F).dummy&&e.forEach(b.predecessors(F),function(Y){var I=b.node(Y);I.dummy&&(I.order<T||I.order>M)&&u(C,Y,F)})})}function P(O,q){var B=-1,T,M=0;return e.forEach(q,function(F,X){if(b.node(F).dummy==="border"){var Y=b.predecessors(F);Y.length&&(T=b.node(Y[0]).order,j(q,M,X,B,T),M=X,B=T)}j(q,M,q.length,T,O.length)}),q}return e.reduce(E,P),C}function l(b,E){if(b.node(E).dummy)return e.find(b.predecessors(E),function(C){return b.node(C).dummy})}function u(b,E,C){if(E>C){var j=E;E=C,C=j}var P=b[E];P||(b[E]=P={}),P[C]=!0}function c(b,E,C){if(E>C){var j=E;E=C,C=j}return e.has(b[E],C)}function p(b,E,C,j){var P={},O={},q={};return e.forEach(E,function(B){e.forEach(B,function(T,M){P[T]=T,O[T]=T,q[T]=M})}),e.forEach(E,function(B){var T=-1;e.forEach(B,function(M){var F=j(M);if(F.length){F=e.sortBy(F,function(U){return q[U]});for(var X=(F.length-1)/2,Y=Math.floor(X),I=Math.ceil(X);Y<=I;++Y){var H=F[Y];O[M]===M&&T<q[H]&&!c(C,M,H)&&(O[H]=M,O[M]=P[M]=P[H],T=q[H])}}})}),{root:P,align:O}}function h(b,E,C,j,P){var O={},q=f(b,E,C,P),B=P?"borderLeft":"borderRight";function T(X,Y){for(var I=q.nodes(),H=I.pop(),U={};H;)U[H]?X(H):(U[H]=!0,I.push(H),I=I.concat(Y(H))),H=I.pop()}function M(X){O[X]=q.inEdges(X).reduce(function(Y,I){return Math.max(Y,O[I.v]+q.edge(I))},0)}function F(X){var Y=q.outEdges(X).reduce(function(H,U){return Math.min(H,O[U.w]-q.edge(U))},Number.POSITIVE_INFINITY),I=b.node(X);Y!==Number.POSITIVE_INFINITY&&I.borderType!==B&&(O[X]=Math.max(O[X],Y))}return T(M,q.predecessors.bind(q)),T(F,q.successors.bind(q)),e.forEach(j,function(X){O[X]=O[C[X]]}),O}function f(b,E,C,j){var P=new n,O=b.graph(),q=_(O.nodesep,O.edgesep,j);return e.forEach(E,function(B){var T;e.forEach(B,function(M){var F=C[M];if(P.setNode(F),T){var X=C[T],Y=P.edge(X,F);P.setEdge(X,F,Math.max(q(b,M,T),Y||0))}T=M})}),P}function m(b,E){return e.minBy(e.values(E),function(C){var j=Number.NEGATIVE_INFINITY,P=Number.POSITIVE_INFINITY;return e.forIn(C,function(O,q){var B=S(b,q)/2;j=Math.max(O+B,j),P=Math.min(O-B,P)}),j-P})}function y(b,E){var C=e.values(E),j=e.min(C),P=e.max(C);e.forEach(["u","d"],function(O){e.forEach(["l","r"],function(q){var B=O+q,T=b[B],M;if(T!==E){var F=e.values(T);M=q==="l"?j-e.min(F):P-e.max(F),M&&(b[B]=e.mapValues(T,function(X){return X+M}))}})})}function x(b,E){return e.mapValues(b.ul,function(C,j){if(E)return b[E.toLowerCase()][j];var P=e.sortBy(e.map(b,j));return(P[1]+P[2])/2})}function N(b){var E=i.buildLayerMatrix(b),C=e.merge(s(b,E),o(b,E)),j={},P;e.forEach(["u","d"],function(q){P=q==="u"?E:e.values(E).reverse(),e.forEach(["l","r"],function(B){B==="r"&&(P=e.map(P,function(X){return e.values(X).reverse()}));var T=(q==="u"?b.predecessors:b.successors).bind(b),M=p(b,P,C,T),F=h(b,P,M.root,M.align,B==="r");B==="r"&&(F=e.mapValues(F,function(X){return-X})),j[q+B]=F})});var O=m(b,j);return y(j,O),x(j,b.graph().align)}function _(b,E,C){return function(j,P,O){var q=j.node(P),B=j.node(O),T=0,M;if(T+=q.width/2,e.has(q,"labelpos"))switch(q.labelpos.toLowerCase()){case"l":M=-q.width/2;break;case"r":M=q.width/2;break}if(M&&(T+=C?M:-M),M=0,T+=(q.dummy?E:b)/2,T+=(B.dummy?E:b)/2,T+=B.width/2,e.has(B,"labelpos"))switch(B.labelpos.toLowerCase()){case"l":M=B.width/2;break;case"r":M=-B.width/2;break}return M&&(T+=C?M:-M),M=0,T}}function S(b,E){return b.node(E).width}return wg}var xg,Ck;function h$(){if(Ck)return xg;Ck=1;var e=ot(),n=fn(),i=f$().positionX;xg=s;function s(l){l=n.asNonCompoundGraph(l),o(l),e.forEach(i(l),function(u,c){l.node(c).x=u})}function o(l){var u=n.buildLayerMatrix(l),c=l.graph().ranksep,p=0;e.forEach(u,function(h){var f=e.max(e.map(h,function(m){return l.node(m).height}));e.forEach(h,function(m){l.node(m).y=p+f/2}),p+=f+c})}return xg}var _g,jk;function p$(){if(jk)return _g;jk=1;var e=ot(),n=YL(),i=XL(),s=ZL(),o=fn().normalizeRanks,l=JL(),u=fn().removeEmptyRanks,c=e$(),p=t$(),h=n$(),f=d$(),m=h$(),y=fn(),x=Qn().Graph;_g=N;function N($,Q){var ee=Q&&Q.debugTiming?y.time:y.notime;ee("layout",function(){var se=ee(" buildLayoutGraph",function(){return T($)});ee(" runLayout",function(){_(se,ee)}),ee(" updateInputGraph",function(){S($,se)})})}function _($,Q){Q(" makeSpaceForEdgeLabels",function(){M($)}),Q(" removeSelfEdges",function(){D($)}),Q(" acyclic",function(){n.run($)}),Q(" nestingGraph.run",function(){c.run($)}),Q(" rank",function(){s(y.asNonCompoundGraph($))}),Q(" injectEdgeLabelProxies",function(){F($)}),Q(" removeEmptyRanks",function(){u($)}),Q(" nestingGraph.cleanup",function(){c.cleanup($)}),Q(" normalizeRanks",function(){o($)}),Q(" assignRankMinMax",function(){X($)}),Q(" removeEdgeLabelProxies",function(){Y($)}),Q(" normalize.run",function(){i.run($)}),Q(" parentDummyChains",function(){l($)}),Q(" addBorderSegments",function(){p($)}),Q(" order",function(){f($)}),Q(" insertSelfEdges",function(){G($)}),Q(" adjustCoordinateSystem",function(){h.adjust($)}),Q(" position",function(){m($)}),Q(" positionSelfEdges",function(){k($)}),Q(" removeBorderNodes",function(){J($)}),Q(" normalize.undo",function(){i.undo($)}),Q(" fixupEdgeLabelCoords",function(){U($)}),Q(" undoCoordinateSystem",function(){h.undo($)}),Q(" translateGraph",function(){I($)}),Q(" assignNodeIntersects",function(){H($)}),Q(" reversePoints",function(){ne($)}),Q(" acyclic.undo",function(){n.undo($)})}function S($,Q){e.forEach($.nodes(),function(ee){var se=$.node(ee),ae=Q.node(ee);se&&(se.x=ae.x,se.y=ae.y,Q.children(ee).length&&(se.width=ae.width,se.height=ae.height))}),e.forEach($.edges(),function(ee){var se=$.edge(ee),ae=Q.edge(ee);se.points=ae.points,e.has(ae,"x")&&(se.x=ae.x,se.y=ae.y)}),$.graph().width=Q.graph().width,$.graph().height=Q.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],E={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},C=["acyclicer","ranker","rankdir","align"],j=["width","height"],P={width:0,height:0},O=["minlen","weight","width","height","labeloffset"],q={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},B=["labelpos"];function T($){var Q=new x({multigraph:!0,compound:!0}),ee=oe($.graph());return Q.setGraph(e.merge({},E,L(ee,b),e.pick(ee,C))),e.forEach($.nodes(),function(se){var ae=oe($.node(se));Q.setNode(se,e.defaults(L(ae,j),P)),Q.setParent(se,$.parent(se))}),e.forEach($.edges(),function(se){var ae=oe($.edge(se));Q.setEdge(se,e.merge({},q,L(ae,O),e.pick(ae,B)))}),Q}function M($){var Q=$.graph();Q.ranksep/=2,e.forEach($.edges(),function(ee){var se=$.edge(ee);se.minlen*=2,se.labelpos.toLowerCase()!=="c"&&(Q.rankdir==="TB"||Q.rankdir==="BT"?se.width+=se.labeloffset:se.height+=se.labeloffset)})}function F($){e.forEach($.edges(),function(Q){var ee=$.edge(Q);if(ee.width&&ee.height){var se=$.node(Q.v),ae=$.node(Q.w),pe={rank:(ae.rank-se.rank)/2+se.rank,e:Q};y.addDummyNode($,"edge-proxy",pe,"_ep")}})}function X($){var Q=0;e.forEach($.nodes(),function(ee){var se=$.node(ee);se.borderTop&&(se.minRank=$.node(se.borderTop).rank,se.maxRank=$.node(se.borderBottom).rank,Q=e.max(Q,se.maxRank))}),$.graph().maxRank=Q}function Y($){e.forEach($.nodes(),function(Q){var ee=$.node(Q);ee.dummy==="edge-proxy"&&($.edge(ee.e).labelRank=ee.rank,$.removeNode(Q))})}function I($){var Q=Number.POSITIVE_INFINITY,ee=0,se=Number.POSITIVE_INFINITY,ae=0,pe=$.graph(),ge=pe.marginx||0,Ae=pe.marginy||0;function Oe(Me){var Pe=Me.x,ke=Me.y,We=Me.width,ve=Me.height;Q=Math.min(Q,Pe-We/2),ee=Math.max(ee,Pe+We/2),se=Math.min(se,ke-ve/2),ae=Math.max(ae,ke+ve/2)}e.forEach($.nodes(),function(Me){Oe($.node(Me))}),e.forEach($.edges(),function(Me){var Pe=$.edge(Me);e.has(Pe,"x")&&Oe(Pe)}),Q-=ge,se-=Ae,e.forEach($.nodes(),function(Me){var Pe=$.node(Me);Pe.x-=Q,Pe.y-=se}),e.forEach($.edges(),function(Me){var Pe=$.edge(Me);e.forEach(Pe.points,function(ke){ke.x-=Q,ke.y-=se}),e.has(Pe,"x")&&(Pe.x-=Q),e.has(Pe,"y")&&(Pe.y-=se)}),pe.width=ee-Q+ge,pe.height=ae-se+Ae}function H($){e.forEach($.edges(),function(Q){var ee=$.edge(Q),se=$.node(Q.v),ae=$.node(Q.w),pe,ge;ee.points?(pe=ee.points[0],ge=ee.points[ee.points.length-1]):(ee.points=[],pe=ae,ge=se),ee.points.unshift(y.intersectRect(se,pe)),ee.points.push(y.intersectRect(ae,ge))})}function U($){e.forEach($.edges(),function(Q){var ee=$.edge(Q);if(e.has(ee,"x"))switch((ee.labelpos==="l"||ee.labelpos==="r")&&(ee.width-=ee.labeloffset),ee.labelpos){case"l":ee.x-=ee.width/2+ee.labeloffset;break;case"r":ee.x+=ee.width/2+ee.labeloffset;break}})}function ne($){e.forEach($.edges(),function(Q){var ee=$.edge(Q);ee.reversed&&ee.points.reverse()})}function J($){e.forEach($.nodes(),function(Q){if($.children(Q).length){var ee=$.node(Q),se=$.node(ee.borderTop),ae=$.node(ee.borderBottom),pe=$.node(e.last(ee.borderLeft)),ge=$.node(e.last(ee.borderRight));ee.width=Math.abs(ge.x-pe.x),ee.height=Math.abs(ae.y-se.y),ee.x=pe.x+ee.width/2,ee.y=se.y+ee.height/2}}),e.forEach($.nodes(),function(Q){$.node(Q).dummy==="border"&&$.removeNode(Q)})}function D($){e.forEach($.edges(),function(Q){if(Q.v===Q.w){var ee=$.node(Q.v);ee.selfEdges||(ee.selfEdges=[]),ee.selfEdges.push({e:Q,label:$.edge(Q)}),$.removeEdge(Q)}})}function G($){var Q=y.buildLayerMatrix($);e.forEach(Q,function(ee){var se=0;e.forEach(ee,function(ae,pe){var ge=$.node(ae);ge.order=pe+se,e.forEach(ge.selfEdges,function(Ae){y.addDummyNode($,"selfedge",{width:Ae.label.width,height:Ae.label.height,rank:ge.rank,order:pe+ ++se,e:Ae.e,label:Ae.label},"_se")}),delete ge.selfEdges})})}function k($){e.forEach($.nodes(),function(Q){var ee=$.node(Q);if(ee.dummy==="selfedge"){var se=$.node(ee.e.v),ae=se.x+se.width/2,pe=se.y,ge=ee.x-ae,Ae=se.height/2;$.setEdge(ee.e,ee.label),$.removeNode(Q),ee.label.points=[{x:ae+2*ge/3,y:pe-Ae},{x:ae+5*ge/6,y:pe-Ae},{x:ae+ge,y:pe},{x:ae+5*ge/6,y:pe+Ae},{x:ae+2*ge/3,y:pe+Ae}],ee.label.x=ee.x,ee.label.y=ee.y}})}function L($,Q){return e.mapValues(e.pick($,Q),Number)}function oe($){var Q={};return e.forEach($,function(ee,se){Q[se.toLowerCase()]=ee}),Q}return _g}var Sg,Rk;function m$(){if(Rk)return Sg;Rk=1;var e=ot(),n=fn(),i=Qn().Graph;Sg={debugOrdering:s};function s(o){var l=n.buildLayerMatrix(o),u=new i({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(c){u.setNode(c,{label:c}),u.setParent(c,"layer"+o.node(c).rank)}),e.forEach(o.edges(),function(c){u.setEdge(c.v,c.w,{},c.name)}),e.forEach(l,function(c,p){var h="layer"+p;u.setNode(h,{rank:"same"}),e.reduce(c,function(f,m){return u.setEdge(f,m,{style:"invis"}),m})}),u}return Sg}var bg,Tk;function g$(){return Tk||(Tk=1,bg="0.8.5"),bg}var kg,Ak;function v$(){return Ak||(Ak=1,kg={graphlib:Qn(),layout:p$(),debug:m$(),util:{time:fn().time,notime:fn().notime},version:g$()}),kg}var y$=v$();const Ik=Yg(y$),vi=240,Xi=130,zs=74,mu=72,Mk=zs+mu;function w$(e){let n=vi;for(const i of e.values())n=Math.max(n,i.width);return n}const bC=420,x$=2;function ta(e){var i;return((i=e.data)==null?void 0:i.sessionId)??"_default"}function Pk(e,n){return((n==null?void 0:n.get(e))??0)>0?bC:0}function Ok(e,n){const i=(n==null?void 0:n.get(e))??0;return i>0?6+i*36:0}function _$(e,n,i,s,o,l){const u=new Ik.graphlib.Graph;u.setDefaultEdgeLabel(()=>({})),u.setGraph({rankdir:i,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const c=e.filter(S=>!o.has(S)),p=new Set(c);for(const S of c){const b=s.get(S);u.setNode(S,{width:((b==null?void 0:b.width)??vi)+Pk(S,l),height:Math.max((b==null?void 0:b.height)??Xi,Ok(S,l))})}for(const S of n)p.has(S.source)&&p.has(S.target)&&u.setEdge(S.source,S.target);Ik.layout(u);const h=new Map;let f=1/0,m=1/0,y=-1/0,x=-1/0;for(const S of c){const b=u.node(S);if(!b)continue;const E=s.get(S),C=(E==null?void 0:E.width)??vi,j=(E==null?void 0:E.height)??Xi,P=C+Pk(S,l),O=Math.max(j,Ok(S,l)),q=b.x-P/2,B=b.y-O/2;h.set(S,{x:q,y:B}),q<f&&(f=q),B<m&&(m=B),q+C>y&&(y=q+C),B+j>x&&(x=B+j)}if(Number.isFinite(f)&&Number.isFinite(m))for(const[S,b]of h)h.set(S,{x:b.x-f,y:b.y-m});let N=Number.isFinite(y)?y-f:0,_=Number.isFinite(x)?x-m:0;for(const S of e){const b=o.get(S);if(!b)continue;const E=s.get(S);N=Math.max(N,b.x+((E==null?void 0:E.width)??vi)),_=Math.max(_,b.y+((E==null?void 0:E.height)??Xi))}return{positions:h,width:N,height:_}}function S$(e,n,i={}){const s=i.direction??"LR",o=i.pinned??new Map,l=i.measured??new Map,u=i.lanes,c=new Map;for(const b of e){const E=ta(b),C=c.get(E);C?C.push(b.id):c.set(E,[b.id])}const h=Array.from(c.keys()).sort().map(b=>({sid:b,..._$(c.get(b),n,s,l,o,u)})),f=w$(l),m=i.availableHeight&&i.availableHeight>0?i.availableHeight:Number.POSITIVE_INFINITY,y=b=>{const E=[[]];let C=0;for(const j of h)E.length<b&&C>0&&C+j.height>m&&(E.push([]),C=0),E[E.length-1].push(j),C+=j.height+Mk;return E},x=b=>b.reduce((E,C)=>Math.max(E,C.width),0)+bC;let N=y(i.availableWidth?x$:1);N.length>1&&N.reduce((E,C)=>E+x(C),0)+f*(N.length-1)>(i.availableWidth??0)&&(N=y(1));const _=new Map;let S=0;for(const b of N){let E=0;for(const{positions:C,height:j}of b){for(const[P,O]of C)_.set(P,{x:O.x+S,y:O.y+E});E+=j+Mk}S+=x(b)+f}return e.map(b=>{const E=o.get(b.id);if(E)return{...b,position:E};const C=_.get(b.id);return C?{...b,position:C}:b})}function b$(e,n,i,s){const l=zs+mu,u=60,c=y=>{const x=s.get(y);return{w:(x==null?void 0:x.width)??vi,h:(x==null?void 0:x.height)??Xi}},p=new Map(e.map(y=>[y.id,ta(y)])),h=[],f=e.map(y=>({id:y.id,pos:i.get(y.id)??n.get(y.id)})).filter(y=>y.pos!=null).sort((y,x)=>y.pos.y-x.pos.y||y.pos.x-x.pos.x||y.id.localeCompare(x.id)),m=[];for(const{id:y,pos:x}of f){const{w:N,h:_}=c(y),S=p.get(y)??"_default";if(i.has(y)){h.push({x:x.x,y:x.y,w:N,h:_,sid:S});continue}let b=x.y;for(let E=0;E<h.length+1;E++){const C=h.find(j=>{const P=j.sid===S?24:u,O=j.sid===S?24:l;return x.x<j.x+j.w+P&&j.x<x.x+N+P&&b<j.y+j.h+O&&j.y<b+_+O});if(!C)break;b=C.y+C.h+(C.sid===S?24:l)}b!==x.y&&(n.set(y,{x:x.x,y:b}),m.push(y)),h.push({x:x.x,y:b,w:N,h:_,sid:S})}return m}function k$(e,n,i,s,o){const l=N=>{const _=s.get(N);return{w:(_==null?void 0:_.width)??vi,h:(_==null?void 0:_.height)??Xi}},u=N=>i.get(N)??n.get(N),c=new Map;for(const N of e){if(!u(N.id))continue;const _=ta(N),S=c.get(_);S?S.push(N):c.set(_,[N])}const p=new Set;for(const[N,_]of c)_.every(S=>o.has(S.id)&&!i.has(S.id))&&p.add(N);const h=new Map,f=[];for(const N of e){const _=u(N.id);if(!_)continue;const{w:S,h:b}=l(N.id),E=ta(N);p.has(E)?(h.get(E)??h.set(E,[]).get(E)).push(N):f.push({x:_.x,y:_.y,w:S,h:b})}if(h.size===0)return[];const m=zs+mu,y=(N,_,S,b)=>f.some(E=>N<E.x+E.w+zs&&E.x<N+S+zs&&_<E.y+E.h+m&&E.y<_+b+m),x=[];for(const N of[...h.keys()].sort()){const _=h.get(N);let S=1/0,b=1/0,E=-1/0,C=-1/0;for(const M of _){const F=u(M.id),{w:X,h:Y}=l(M.id);S=Math.min(S,F.x),b=Math.min(b,F.y),E=Math.max(E,F.x+X),C=Math.max(C,F.y+Y)}const j=E-S,P=C-b,O=[...new Set(f.map(M=>Math.round(M.x)))].sort((M,F)=>M-F),q=O.length?O:[S],B=[0,...f.map(M=>M.y+M.h+m)].sort((M,F)=>M-F);let T=null;e:for(const M of q)for(const F of B){if(F>=b)break;if(!y(M,F,j,P)){T={x:M,y:F};break e}}if(T){const M=T.x-S,F=T.y-b;for(const X of _){const Y=u(X.id);n.set(X.id,{x:Y.x+M,y:Y.y+F})}x.push(N)}for(const M of _){const F=u(M.id),{w:X,h:Y}=l(M.id);f.push({x:F.x,y:F.y,w:X,h:Y})}}return x}function E$(e,n,i,s,o,l=!1){const p=zs+mu+1,h=8,f=1.75,m=200,y=.7,x=.01,N=T=>{const M=s.get(T);return{w:(M==null?void 0:M.width)??vi,h:(M==null?void 0:M.height)??Xi}},_=T=>i.get(T)??n.get(T),S=new Map;for(const T of e){if(!_(T.id))continue;const M=ta(T),F=S.get(M);F?F.push(T):S.set(M,[T])}const b=[],E=new Set,C=new Set,j=o.size===0;for(const T of[...S.keys()].sort()){const M=S.get(T);let F=1/0,X=1/0,Y=-1/0,I=-1/0,H=!1;for(const D of M){const G=_(D.id),{w:k,h:L}=N(D.id);F=Math.min(F,G.x),X=Math.min(X,G.y),Y=Math.max(Y,G.x+k),I=Math.max(I,G.y+L),i.has(D.id)&&(H=!0)}const U=Y-F,ne=I-X;C.add(T);const J=o.get(T);J&&(U>J.w+h||ne>J.h+h)&&E.add(T),o.set(T,{w:U,h:ne}),b.push({sid:T,members:M.map(D=>D.id),x:F,y:X,w:U,h:ne,anchored:H,mass:1})}for(const T of[...o.keys()])C.has(T)||o.delete(T);if(l||j)return[];let P=!1;for(let T=0;T<b.length&&!P;T++)for(let M=T+1;M<b.length;M++){const F=b[T],X=b[M];if(!(F.anchored&&X.anchored)&&Math.abs(F.x+F.w/2-(X.x+X.w/2))<(F.w+X.w)/2+61&&Math.abs(F.y+F.h/2-(X.y+X.h/2))<(F.h+X.h)/2+p){P=!0;break}}if(E.size===0&&!P)return[];if(E.size>0)for(const T of b)E.has(T.sid)&&(T.mass=8);else for(const T of b)T.mass=Math.max(1,T.w*T.h/(vi*Xi));const O=new Map(b.map(T=>[T.sid,T.x])),q=new Map(b.map(T=>[T.sid,T.y]));for(let T=0;T<m;T++){const M=new Map,F=new Map;let X=0;for(let Y=0;Y<b.length;Y++)for(let I=Y+1;I<b.length;I++){const H=b[Y],U=b[I];if(H.anchored&&U.anchored)continue;const ne=H.x+H.w/2,J=H.y+H.h/2,D=U.x+U.w/2,G=U.y+U.h/2,k=(H.w+U.w)/2+61-Math.abs(ne-D),L=(H.h+U.h)/2+p-Math.abs(J-G);if(k<=0||L<=0)continue;const oe=(Ke,$e)=>!Ke.anchored&&!($e<0&&Ke.x<=0),$=(Ke,$e)=>!Ke.anchored&&!($e<0&&Ke.y<=0),Q=(Ke,$e,Qe)=>{const bt=Ke===$e,ct=bt?H.sid<U.sid?-1:1:Math.sign(Ke-$e);return Qe(H,ct)||Qe(U,-ct)?ct:bt&&(Qe(H,-ct)||Qe(U,ct))?-ct:0},ee=Q(ne,D,oe),se=Q(J,G,$),ae=ee!==0,pe=se!==0;if(!ae&&!pe)continue;const ge=ae&&(!pe||k*f<L),[Ae,Oe,Me,Pe]=ge?[ee,k,M,oe]:[se,L,F,$],ke=Pe(H,Ae),We=Pe(U,-Ae),ve=H.mass,ye=U.mass,Ge=ke?We?ye/(ve+ye):1:0,ut=We?ke?ve/(ve+ye):1:0,it=Oe*y;Me.set(H.sid,(Me.get(H.sid)??0)+Ae*it*Ge),Me.set(U.sid,(Me.get(U.sid)??0)-Ae*it*ut),X+=it}for(const Y of b)Y.anchored||(Y.x=Math.max(0,Y.x+(M.get(Y.sid)??0)),Y.y=Math.max(0,Y.y+(F.get(Y.sid)??0)));if(X<x)break}const B=[];for(const T of b){const M=T.x-O.get(T.sid),F=T.y-q.get(T.sid);if(!(Math.abs(M)<1&&Math.abs(F)<1)){for(const X of T.members){if(i.has(X))continue;const Y=n.get(X);Y&&n.set(X,{x:Y.x+M,y:Y.y+F})}B.push(T.sid)}}return B}const N$=600;function Wg(e,n){return!(e.exitAt!=null&&n-e.exitAt>N$||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function C$(e,n){const i=new Set;for(const s of e.agents.values())Wg(s,n)&&i.add(s.id);return i}function j$(e,n,i=0){return e.right+i>n.left&&e.left-i<n.right&&e.bottom+i>n.top&&e.top-i<n.bottom}function R$(e,n,i=0){if(!e)return!1;for(const s of n)if(j$(e,s,i))return!0;return!1}function Hi(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function T$(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}const A$={agent:IP,sessionGroup:UP},I$=420,jl=18,M$=9e4,P$=200,O$=5*6e4,q$=6,L$=2*6e4,Pv="agent-dag.layout",Ov="agent-dag.viewport",kC="agent-dag.summariesDismissed",EC="agent-dag.sessionListOpen",NC="agent-dag.detailOpen",CC="agent-dag.usagePanelOpen",qk="agent-dag.accountsPanelOpen",Lk="agent-dag.versionNoticeDismissed",$k={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 $$(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 Dk="agent-dag.autoRestart",Fk="agent-dag.bundleReloadedFor";function D$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(EC)==="1"}catch{return!1}}function F$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(EC,e?"1":"0")}catch{}}function z$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(NC)==="1"}catch{return!1}}function B$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(NC,e?"1":"0")}catch{}}function U$(){if(typeof window>"u")return!0;const e=window.localStorage.getItem(CC);try{return e===null?!0:e==="1"}catch{return!0}}function H$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(CC,e?"1":"0")}catch{}}function V$(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(kC);if(!e)return new Set;const n=JSON.parse(e);return new Set(Array.isArray(n)?n.filter(i=>typeof i=="string"):[])}catch{return new Set}}function zk(e){if(!(typeof window>"u"))try{const n=Array.from(e),i=n.length>200?n.slice(-200):n;window.localStorage.setItem(kC,JSON.stringify(i))}catch{}}function W$(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(Pv);if(!n)return e;const i=JSON.parse(n);if(!("v"in i)){const o=Object.entries(i).filter(([,l])=>l&&typeof l.x=="number"&&typeof l.y=="number");return{positions:o,pins:o.map(([l])=>l)}}return{positions:Object.entries(i.positions??{}).filter(([,o])=>o&&typeof o.x=="number"&&typeof o.y=="number"),pins:Array.isArray(i.pins)?i.pins:[]}}catch{return e}}function Eg(e,n){if(!(typeof window>"u"))try{const i={};for(const[s,o]of e)i[s]=o;for(const[s,o]of n)i[s]=o;window.localStorage.setItem(Pv,JSON.stringify({v:2,positions:i,pins:Array.from(n.keys())}))}catch{}}function G$(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Ov);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 K$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Ov,JSON.stringify(e))}catch{}}function Bk(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Pv)}catch{}try{window.localStorage.removeItem(Ov)}catch{}}}function Y$(e,n){const i=e.agents.get(n);if(!i)return;const s=[];for(const f of e.agents.values())f.sessionId===n&&s.push(f);const o={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:n,label:i.label,cwd:i.cwd,startedAt:i.startedAt,endedAt:i.endedAt,model:i.model,agents:s.map(f=>({id:f.id,kind:f.kind,label:f.label,parentId:f.parentId,state:f.state,startedAt:f.startedAt,endedAt:f.endedAt,model:f.model,cwd:f.cwd,usage:f.usage,prompts:f.prompts,tools:f.tools.map(m=>({id:m.id,name:m.name,inputPreview:m.inputPreview,startedAt:m.startedAt,endedAt:m.endedAt,ok:m.ok,errorPreview:m.errorPreview,usage:m.usage}))}))},l=JSON.stringify(o,null,2),u=new Blob([l],{type:"application/json"}),c=URL.createObjectURL(u),p=document.createElement("a"),h=(i.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 Gg={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Kg={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},X$={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",shell:"shell",exec_command:"shell",shell_command:"shell",write_stdin:"shell",wait:"shell",apply_patch:"file",update_plan:"task",WebFetch:"web",WebSearch:"web",Task:"agent",Agent:"agent",TodoWrite:"task",TaskCreate:"task",TaskUpdate:"task",TaskList:"task",TaskGet:"task",TaskOutput:"task",TaskStop:"task",EnterPlanMode:"plan",ExitPlanMode:"plan",AskUserQuestion:"plan",Skill:"plan",Workflow:"plan"};function jC(e){return e.startsWith("mcp__")?"mcp":X$[e]??"other"}function RC(e,n){var s,o,l;if(!n)return!0;const i=n.toLowerCase();if(e.label.toLowerCase().includes(i)||(s=e.cwd)!=null&&s.toLowerCase().includes(i)||(o=e.cwdBasename)!=null&&o.toLowerCase().includes(i)||e.sessionId.toLowerCase().includes(i)||(l=e.firstPrompt)!=null&&l.toLowerCase().includes(i))return!0;for(const u of e.tools)if(u.name.toLowerCase().includes(i))return!0;return!1}function Q$(e,n){if(!n)return null;const i=new Set([n]);let s=n;for(;s;){const l=e.agents.get(s);if(!(l!=null&&l.parentId)||i.has(l.parentId))break;i.add(l.parentId),s=l.parentId}let o=!0;for(;o;){o=!1;for(const l of e.agents.values())l.parentId&&i.has(l.parentId)&&!i.has(l.id)&&(i.add(l.id),o=!0)}return i}function Z$(e,n,i,s,o,l,u,c,p,h,f,m,y,x,N,_,S,b){const E=[],C=[],j=new Set;if(l)for(const M of e.agents.values())RC(M,l)&&j.add(M.id);for(const M of e.agents.values()){if(!S.has(M.id))continue;const F=l?!j.has(M.id):!1,X=M.exitAt!=null,Y=_!=null&&!_.has(M.id),I=[F?"rf-dim":"",X?"rf-exiting":"",Y?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,H=u.get(M.id);if(E.push({id:M.id,type:"agent",position:{x:0,y:0},data:{...M,now:n,dim:F,onOpenContext:b},className:I,...H?{width:H.width,height:H.height}:null}),M.parentId&&S.has(M.parentId)){const U=pv(M.sessionId),ne=M.state==="active"?`hsl(${U} 80% 72%)`:`hsl(${U} 50% 55%)`,J=l&&!j.has(M.id)&&!j.has(M.parentId),D=X,G=N.size>0&&(N.has(M.id)||N.has(M.parentId)),k=_!=null&&!_.has(M.id)&&!_.has(M.parentId),L=M.state==="active"?2:1.5,oe=G?L+1.5:L,$=J||D?.2:k?.12:1,Q=[D?"rf-edge-exiting":"",G?"rf-edge-selected":""].filter(Boolean).join(" ")||void 0;C.push({id:`e:${M.parentId}->${M.id}`,source:M.parentId,target:M.id,animated:(M.state==="active"||G)&&!J&&!D,type:"smoothstep",style:{stroke:ne,strokeWidth:oe,opacity:$,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:Q})}}const P=new Map;for(const M of e.agents.values())M.tools.length>0&&P.set(M.id,Math.min(4,M.tools.length));const O=E.filter(M=>!o.has(M.id)&&!m.has(M.id));if(O.length>0||y!==x.current){if(O.length>0){const M=S$(E,C,{direction:"LR",pinned:o,measured:u,availableWidth:i,availableHeight:s,lanes:P});for(const F of M)m.has(F.id)||m.set(F.id,F.position);k$(E,m,o,u,new Set(O.map(F=>F.id)))}b$(E,m,o,u),x.current=y}const q=E$(E,m,o,u,c,!h||f);q.length>0&&p(q),cx(m,e.agents),cx(o,e.agents);const B=[];let T=!1;for(const M of E){let F=o.get(M.id)??m.get(M.id);F||(F={x:0,y:0},m.set(M.id,F),T=!0),B.push({...M,position:F})}return T&&(x.current=""),{nodes:B,edges:C}}function J$(){return g.jsx(fv,{children:g.jsx(e4,{})})}function e4(){var ao,ya,Wr,Gr;const e=oa(),n=A.useRef(Bg()),[,i]=A.useState(0),s=A.useCallback(()=>i(V=>V+1),[]),[o,l]=A.useState(()=>new Set),[u,c]=A.useState(null),[p,h]=A.useState(null),f=A.useCallback((V,K)=>{l(ue=>{if(!K)return new Set([V]);const fe=new Set(ue);return fe.has(V)?fe.delete(V):fe.add(V),fe}),c(ue=>K&&ue===V?ue:V)},[]),m=A.useCallback(()=>{l(new Set),c(null)},[]),[y,x]=A.useState(null),[N,_]=A.useState(null),S=A.useCallback(V=>_(V),[]),b=A.useRef(V$()),[E,C]=A.useState(D$);A.useEffect(()=>{F$(E)},[E]);const[j,P]=A.useState(z$);A.useEffect(()=>{B$(j)},[j]);const[O,q]=A.useState(U$);A.useEffect(()=>{H$(O)},[O]);const[B,T]=A.useState(()=>{try{const V=window.localStorage.getItem(qk);return V===null?!0:V==="1"}catch{return!0}});A.useEffect(()=>{try{window.localStorage.setItem(qk,B?"1":"0")}catch{}},[B]);const[M,F]=A.useState(null),[X,Y]=A.useState(!1),[I,H]=A.useState(0),[U,ne]=A.useState(0);A.useEffect(()=>{fetch("/api/sound-hook").then(V=>V.ok?V.json():null).then(V=>{V!=null&&V.ok&&(F(V.enabled===!0),H((V.foreign??[]).filter(K=>K.worksHere).length),ne(typeof V.parked=="number"?V.parked:0))}).catch(()=>{})},[]);const J=A.useCallback(async()=>{Y(!0);try{const K=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!M})})).json().catch(()=>null);K!=null&&K.ok&&F(K.enabled===!0),fetch("/api/sound-hook").then(ue=>ue.ok?ue.json():null).then(ue=>{ue!=null&&ue.ok&&(H((ue.foreign??[]).filter(fe=>fe.worksHere).length),ne(typeof ue.parked=="number"?ue.parked:0))}).catch(()=>{})}catch{}finally{Y(!1)}},[M]),[D,G]=A.useState(!1),[k,L]=A.useState(null),[oe,$]=A.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(Lk)??""}catch{return""}}),[Q,ee]=A.useState(!1),se=A.useCallback((V=!1)=>{fetch(V?"/api/version?refresh=1":"/api/version").then(K=>K.ok?K.json():null).then(K=>{K&&L(K)}).catch(()=>{})},[]);A.useEffect(()=>{se();const V=window.setInterval(se,5*6e4),K=()=>{document.visibilityState==="visible"&&se()};return document.addEventListener("visibilitychange",K),()=>{window.clearInterval(V),document.removeEventListener("visibilitychange",K)}},[se]),A.useEffect(()=>{D&&se()},[D,se]);const ae=(k==null?void 0:k.notice)??null,pe=ae?`${ae.kind}:${ae.to}`:"",ge=ae!=null&&oe!==pe,Ae=A.useCallback(()=>{if(!ae)return;const V=oe===pe?"":pe;$(V);try{window.localStorage.setItem(Lk,V)}catch{}},[ae,pe,oe]),Oe=((ao=k==null?void 0:k.upgrade)==null?void 0:ao.state)??"idle",Me=A.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}se()},[se]);A.useEffect(()=>{if(Oe!=="running")return;const V=window.setInterval(se,3e3);return()=>window.clearInterval(V)},[Oe,se]);const Pe=A.useCallback(async()=>{var ue;const V=k==null?void 0:k.command;if(!V)return;let K=!1;try{K=await Promise.race([((ue=navigator.clipboard)==null?void 0:ue.writeText(V).then(()=>!0))??Promise.resolve(!1),new Promise(fe=>window.setTimeout(()=>fe(!1),500))])}catch{K=!1}if(!K)try{const fe=document.createElement("textarea");fe.value=V,fe.setAttribute("readonly",""),fe.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(fe),fe.select(),K=document.execCommand("copy"),fe.remove()}catch{K=!1}K&&(ee(!0),window.setTimeout(()=>ee(!1),1600))},[k==null?void 0:k.command]),ke=A.useCallback(()=>{C(V=>(V||T(!1),!V))},[]),We=A.useCallback(()=>{T(V=>(V||C(!1),!V))},[]),[ve,ye]=A.useState(!1),[Ge,ut]=A.useState(0),it=A.useRef(null),[Ke,$e]=A.useState(!1),Qe=A.useRef(null),[bt,ct]=A.useState(0),[pt,mt]=A.useState(!1),kt=A.useRef([]),[He,Je]=A.useState(Date.now()),[dt,gt]=A.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(Dk)!=="0"}catch{return!0}}),yt=A.useCallback(()=>{gt(V=>{const K=!V;try{window.localStorage.setItem(Dk,K?"1":"0")}catch{}return K})},[]),[Gt,Pt]=A.useState(!1),[zt,Ln]=A.useState("restart"),[er,bn]=A.useState(null),Bt=A.useRef(!1),Jt=A.useCallback(async V=>{if(Bt.current)return;const K=(V==null?void 0:V.upgrade)===!0;Bt.current=!0,Ln(K?"npx":"restart"),Pt(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(ae==null?void 0:ae.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:K})})}catch{}window.setTimeout(()=>{if(Bt.current){Bt.current=!1,Pt(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},K?18e4:3e4)},[ae==null?void 0:ae.to]),hn=A.useRef(null);A.useEffect(()=>{let V=!1;for(const ue of n.current.agents.values())if(ue.state==="active"){V=!0;break}const K=X3({enabled:dt,kind:ae==null?void 0:ae.kind,canRestart:(k==null?void 0:k.canRestart)===!0,busy:V,idleSince:hn.current,now:He});hn.current=K.idleSince,K.restart&&Jt()},[dt,ae==null?void 0:ae.kind,k==null?void 0:k.canRestart,He,Jt]),A.useEffect(()=>{let V=null;try{V=window.sessionStorage.getItem(Fk)}catch{return}if(Y3({bundle:"1.33.37",running:k==null?void 0:k.running,lastTried:V})){try{window.sessionStorage.setItem(Fk,(k==null?void 0:k.running)??"")}catch{return}window.location.reload()}},[k==null?void 0:k.running]),A.useEffect(()=>{const V=k==null?void 0:k.running;if(!V)return;let K=null;try{K=window.sessionStorage.getItem("agent-dag.restartPending")}catch{return}if(K==null||K&&K!==V)return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}Bt.current=!1,Pt(!1),bn(V);const ue=window.setTimeout(()=>bn(null),6e3);return()=>window.clearTimeout(ue)},[k==null?void 0:k.running]);const $r=A.useRef(W$()).current;A.useRef(!1);const Rt=A.useRef(new Map($r.positions.filter(([V])=>$r.pins.includes(V)))),hr=A.useRef(null),pr=A.useState(()=>G$())[0],[pn,wi]=A.useState(""),[tr,xi]=A.useState(()=>new Set),[mn,rs]=A.useState(()=>typeof window>"u"?"dark":window.localStorage.getItem("agent-dag.theme")??"dark"),[nr,Dr]=A.useState(!1),mr=A.useRef(null);A.useEffect(()=>{document.documentElement.dataset.theme=mn;try{window.localStorage.setItem("agent-dag.theme",mn)}catch{}},[mn]),A.useEffect(()=>{if(!pr)return;const V=window.setTimeout(()=>{try{e.setViewport(pr,{duration:0})}catch{}},60);return()=>window.clearTimeout(V)},[e,pr]);const Fr=A.useRef(!0),Ot=A.useRef(null);A.useEffect(()=>{const V=new EventSource("/events");return V.addEventListener("open",()=>{G(!0),Dr(!0)}),V.addEventListener("error",()=>G(!1)),V.addEventListener("replay-end",()=>{Fr.current=!1,Ot.current!=null&&(window.clearTimeout(Ot.current),Ot.current=null),s()}),V.addEventListener("hook",K=>{try{const ue=JSON.parse(K.data);if(pt){kt.current.push(ue);return}n.current=Xw(n.current,ue),ue.replay===!0||Fr.current||Date.now()-ue.receivedAt>3e4?(Ot.current!=null&&window.clearTimeout(Ot.current),Ot.current=window.setTimeout(()=>{Ot.current=null,s()},120)):(Ot.current!=null&&(window.clearTimeout(Ot.current),Ot.current=null),s())}catch{}}),()=>{V.close(),Ot.current!=null&&(window.clearTimeout(Ot.current),Ot.current=null)}},[pt,s]),A.useEffect(()=>{if(!pt&&kt.current.length!==0){for(const V of kt.current)n.current=Xw(n.current,V);kt.current.length=0,s()}},[pt,s]),A.useEffect(()=>{const V=setInterval(()=>{const K=Date.now();Je(K);let ue=wP(n.current,K,M$);vP(n.current,K,P$,O$)&&(ue=!0),yP(n.current,K,q$,L$)&&(ue=!0),ue&&s()},250);return()=>clearInterval(V)},[s]);const _i=A.useRef(null),$n=A.useRef(0),Dn=420,Kt=A.useCallback((V=500)=>{try{const we=document.querySelector(".canvas-wrap"),Ie=Array.from(document.querySelectorAll(".react-flow__node")).filter(xt=>xt.offsetWidth>0);if(!we||Ie.length===0)return;const Fe=we.getBoundingClientRect(),De=e.getViewport();if(!Number.isFinite(De.zoom)||De.zoom<=0)return;const Ye=xt=>(xt-Fe.left-De.x)/De.zoom,Ze=xt=>(xt-Fe.top-De.y)/De.zoom,yn=Ie.map(xt=>xt.getBoundingClientRect()),sr=Math.min(...yn.map(xt=>Ye(xt.left))),Kr=Math.max(...yn.map(xt=>Ye(xt.right))),Yr=Math.min(...yn.map(xt=>Ze(xt.top))),Lt=Math.max(...yn.map(xt=>Ze(xt.bottom))),_r=Kr-sr,Xr=Lt-Yr;if(!(_r>0&&Xr>0))return;const Xt=Math.max(.2,Math.min(1,(Fe.width-160)/(_r+Dn)*.86,(Fe.height-160)/Xr*.86));e.setViewport({x:80-sr*Xt,y:Math.max(80,(Fe.height-Xr*Xt)/2)-Yr*Xt,zoom:Xt},{duration:V}),$n.current=Date.now(),window.setTimeout(()=>{try{const xt={x:80-sr*Xt,y:Math.max(80,(Fe.height-Xr*Xt)/2)-Yr*Xt,zoom:Xt},us=e.getViewport();(Math.abs(us.zoom-Xt)>.01||Math.abs(us.x-xt.x)>2)&&e.setViewport(xt,{duration:0})}catch{}},V+60)}catch{}},[e]),zr=A.useRef(""),Si=A.useRef(null),bi=A.useRef(0),gr=A.useCallback(()=>{bi.current=Date.now()},[]),Br="agent-dag.autoFitDisabled",kn=A.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Br)==="1"}catch{return!1}})()),[ki,is]=A.useState(kn.current),et=A.useCallback(()=>{if(!kn.current){kn.current=!0,is(!0);try{window.localStorage.setItem(Br,"1")}catch{}}},[]),Qs=A.useCallback(()=>{kn.current=!1,is(!1);try{window.localStorage.removeItem(Br)}catch{}Kt(400)},[e,Kt]);A.useEffect(()=>{const V=setInterval(()=>{if(kn.current||Date.now()-bi.current<800)return;const K=n.current,ue=Date.now(),fe=[];for(const Ye of K.agents.values())Wg(Ye,ue)&&fe.push({id:Ye.id});if(fe.length===0)return;const xe=e.getViewport(),we=window.innerWidth-360,Ie=window.innerHeight-52;let Fe=!1,De=!1;for(const{id:Ye}of fe){const Ze=Fn.current.get(Ye),yn=Rt.current.get(Ye)??Tt.current.get(Ye);if(!Ze||!yn)continue;De=!0;const sr=yn.x*xe.zoom+xe.x,Kr=yn.y*xe.zoom+xe.y,Yr=(yn.x+Ze.width)*xe.zoom+xe.x,Lt=(yn.y+Ze.height)*xe.zoom+xe.y;if(Yr>0&&sr<we&&Lt>0&&Kr<Ie){Fe=!0;break}}De&&!Fe&&Kt(600)},1500);return()=>clearInterval(V)},[e]);const vr=A.useRef(!1),Fn=A.useRef(new Map),yr=A.useRef(0),ss=A.useCallback(V=>{const K=Fn.current;let ue=!1;for(const fe of V.nodeInternals.values()){const xe=fe.width,we=fe.height;if(xe==null||we==null)continue;const Ie=K.get(fe.id);Ie?(Math.abs(Ie.height-we)>4||Math.abs(Ie.width-xe)>4)&&(K.set(fe.id,{width:xe,height:we}),ue=!0):(K.set(fe.id,{width:xe,height:we}),ue=!0)}return ue&&(yr.current+=1),yr.current},[]),Ei=Xe(ss),[wr,en]=A.useState(0);A.useEffect(()=>{let V=0;const K=()=>{const fe=Fn.current;let xe=!1;for(const we of document.querySelectorAll(".react-flow__node[data-id]")){const Ie=we.getAttribute("data-id");if(!Ie)continue;const Fe=we.offsetWidth,De=we.offsetHeight;if(!Fe||!De)continue;const Ye=fe.get(Ie);(!Ye||Math.abs(Ye.width-Fe)>4||Math.abs(Ye.height-De)>4)&&(fe.set(Ie,{width:Fe,height:De}),xe=!0)}xe&&en(we=>we+1)};if(vr.current)return;let ue=0;return document.visibilityState==="hidden"?ue=window.setTimeout(K,32):V=requestAnimationFrame(K),()=>{cancelAnimationFrame(V),window.clearTimeout(ue)}});const Tt=A.useRef(new Map($r.positions)),Yt=A.useRef(""),Ur=A.useMemo(()=>{const V=[];for(const K of n.current.agents.values())Wg(K,He)&&V.push(K.id+(K.parentId?`>${K.parentId}`:""));return V.sort(),`${V.join("|")}#sv${Ei}.${wr}`},[n.current,n.current.lastSeq,He,Ei,wr]),Ni=A.useRef(null);A.useEffect(()=>(Ni.current!=null&&window.clearTimeout(Ni.current),Ni.current=window.setTimeout(()=>{Eg(Tt.current,Rt.current)},1500),()=>{Ni.current!=null&&window.clearTimeout(Ni.current)}),[Ur]),A.useEffect(()=>{if(zr.current===Ur)return;const V=zr.current;if(zr.current=Ur,!V||kn.current)return;Date.now()-$n.current>1200&&Kt(400),_i.current&&window.clearTimeout(_i.current),_i.current=window.setTimeout(()=>{kn.current||Kt(500)},280)},[Ur,e,Kt]);const Zs=A.useMemo(()=>{if(o.size===0)return null;const V=new Set;for(const K of o){const ue=Q$(n.current,K);if(ue)for(const fe of ue)V.add(fe)}return V.size>0?V:null},[n.current,n.current.lastSeq,o]),Hr=A.useMemo(()=>C$(n.current,He),[n.current,n.current.lastSeq,He]),Ci=A.useRef(null),[rr,ji]=A.useState({w:0,h:0});A.useEffect(()=>{const V=Ci.current;if(!V||typeof ResizeObserver>"u")return;const K=new ResizeObserver(ue=>{var xe;const fe=(xe=ue[0])==null?void 0:xe.contentRect;fe&&ji(we=>Math.abs(we.w-fe.width)>40||Math.abs(we.h-fe.height)>40?{w:fe.width,h:fe.height}:we)});return K.observe(V),ji({w:V.clientWidth,h:V.clientHeight}),()=>K.disconnect()},[]);const gu=A.useRef(new Map),[ha,Js]=A.useState(!1);A.useEffect(()=>{const V=window.setTimeout(()=>Js(!0),2500);return()=>window.clearTimeout(V)},[]);const[pa,Ri]=A.useState(!1),tn=A.useRef(null),[eo,os]=A.useState(!1),Ve=A.useCallback(()=>{tn.current&&(window.clearTimeout(tn.current),tn.current=null),Ri(!1)},[]),ma=A.useCallback(V=>{V.length!==0&&queueMicrotask(()=>{Ri(!0),tn.current&&window.clearTimeout(tn.current),tn.current=window.setTimeout(()=>Ri(!1),I$+80)})},[]);A.useEffect(()=>()=>{tn.current&&window.clearTimeout(tn.current)},[]);const to=rr.w>0?rr.w*.92:0,as=rr.h>0?rr.h:0,{nodes:gn,edges:ga}=A.useMemo(()=>Z$(n.current,He,to,as,Rt.current,pn,Fn.current,gu.current,ma,ha,eo,Tt.current,Ur,Yt,o,Zs,Hr,S),[n.current,n.current.lastSeq,He,to,as,ha,eo,pn,Ur,o,Zs,Hr,S,Ge]),no=A.useMemo(()=>{const V=new Map;for(const ue of gn){const fe=ue.data;if(!(fe!=null&&fe.sessionId)||fe.exitAt!=null)continue;const xe=ue.width,we=ue.height;if(xe==null||we==null)continue;const Ie=ue.position.x,Fe=ue.position.y,De=Ie+xe,Ye=Fe+we,Ze=V.get(fe.sessionId);Ze?(Ze.minX=Math.min(Ze.minX,Ie),Ze.minY=Math.min(Ze.minY,Fe),Ze.maxX=Math.max(Ze.maxX,De),Ze.maxY=Math.max(Ze.maxY,Ye)):V.set(fe.sessionId,{minX:Ie,minY:Fe,maxX:De,maxY:Ye})}const K=[];for(const[ue,fe]of V){const xe=fe.maxX-fe.minX+jl*2,we=fe.maxY-fe.minY+jl*2;K.push({id:`group:${ue}`,type:"sessionGroup",position:{x:fe.minX-jl,y:fe.minY-jl},data:{sessionId:ue,w:xe,h:we},width:xe,height:we,style:{width:xe,height:we},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return K},[gn,He]),ro=A.useMemo(()=>{const V=[...no,...gn],K=Qe.current;return!K||K.size===0?V:V.map(ue=>{const fe=K.get(ue.id);return fe?{...ue,position:fe}:ue})},[no,gn,bt]),ls=A.useMemo(()=>{if(!pn)return null;const V=new Set;for(const K of n.current.agents.values())RC(K,pn)&&V.add(K.id);return V},[n.current,n.current.lastSeq,pn]),vn=A.useMemo(()=>{const V=new Set;for(const K of n.current.agents.values())for(const ue of K.tools)V.add(jC(ue.name));return Object.keys(Gg).filter(K=>V.has(K))},[n.current,n.current.lastSeq]);A.useEffect(()=>{if(vn.length<=1){$e(!1);return}let V=0;const K=()=>{const ue=it.current;if(ue&&!document.hidden){const fe=ue.getBoundingClientRect(),xe=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Ie=>Ie.getBoundingClientRect()),we=R$(fe,xe,8);$e(Ie=>Ie===we?Ie:we)}V=window.setTimeout(K,300)};return K(),()=>window.clearTimeout(V)},[vn.length]);const nn=A.useMemo(()=>{const V=new Map;for(const ue of n.current.agents.values())for(const fe of ue.tools){if(!fe.name.startsWith("mcp__"))continue;const xe=fe.name.slice(5),we=xe.indexOf("__"),Ie=we>0?xe.slice(0,we):xe;V.set(Ie,(V.get(Ie)??0)+1)}const K=[];for(const[ue,fe]of V){let xe=5381;for(let we=0;we<ue.length;we++)xe=(xe<<5)+xe^ue.charCodeAt(we);K.push({server:ue,count:fe,hue:Math.abs(xe)%360})}return K.sort((ue,fe)=>fe.count-ue.count),K},[n.current,n.current.lastSeq]),ir=A.useCallback(V=>{xi(K=>{const ue=new Set(K);return ue.has(V)?ue.delete(V):ue.add(V),ue})},[]),wt=u?n.current.agents.get(u):null,Vr=p?Array.from(n.current.agents.values()).flatMap(V=>V.tools).find(V=>V.id===p)??null:null,En=A.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=Bg(),Rt.current.clear(),Fn.current.clear(),Tt.current.clear(),Yt.current="",Bk(),m(),s()},[s,m]),io=A.useCallback(()=>{Rt.current.clear(),Tt.current.clear(),Yt.current="",Bk(),s(),window.setTimeout(()=>Kt(500),80)},[s,e,Kt]),so=A.useCallback(()=>Kt(500),[Kt]),xr=A.useCallback(V=>{if(gn.length===0)return;const K=gn.slice().sort((we,Ie)=>we.position.y-Ie.position.y||we.position.x-Ie.position.x),ue=u?K.findIndex(we=>we.id===u):-1;let fe;ue===-1?fe=V===1?0:K.length-1:fe=(ue+V+K.length)%K.length;const xe=K[fe];xe&&(f(xe.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[xe]})}catch{}$n.current=Date.now()},30))},[gn,u,f,e]);A.useEffect(()=>{const V=K=>{var fe,xe;const ue=((fe=K.target)==null?void 0:fe.tagName)==="INPUT";if(K.key==="Escape"){ue?K.target.blur():m();return}if(!ue&&!Q3(K)){if(K.key==="/"){K.preventDefault(),(xe=mr.current)==null||xe.focus();return}K.key===" "&&(K.preventDefault(),mt(we=>!we)),(K.key==="c"||K.key==="C")&&En(),(K.key==="r"||K.key==="R")&&io(),(K.key==="f"||K.key==="F")&&so(),(K.key==="l"||K.key==="L")&&ke(),(K.key==="h"||K.key==="H")&&ye(we=>!we),(K.key==="u"||K.key==="U")&&q(we=>!we),(K.key==="a"||K.key==="A")&&We(),(K.key==="j"||K.key==="J")&&xr(1),(K.key==="k"||K.key==="K")&&xr(-1),(K.key==="t"||K.key==="T")&&rs(we=>we==="dark"?"light":"dark")}};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[En,io,so,m,xr]);const oo=n.current.agents.size,va=new Set(Array.from(n.current.agents.values()).map(V=>V.sessionId)).size,qt=A.useMemo(()=>{let V=0,K=0,ue=0,fe=0,xe=0,we=0,Ie=0,Fe=0,De=0;for(const Ye of n.current.agents.values()){V+=Ye.usage.inputTokens,K+=Ye.usage.outputTokens,ue+=Ye.usage.cacheReadTokens,fe+=Ye.usage.cacheCreateTokens;const Ze=dn(Ye.usage,Ye.model);xe+=Ze.total,we+=Ze.input,Ie+=Ze.output,Fe+=Ze.cacheRead,De+=Ze.cacheWrite}return{inT:V,outT:K,cacheR:ue,cacheC:fe,sum:V+K,cost:{total:xe,input:we,output:Ie,cacheRead:Fe,cacheWrite:De}}},[n.current,n.current.lastSeq]);return g.jsxs("div",{className:"app",children:[g.jsxs("header",{className:"topbar",children:[g.jsxs("div",{className:"brand",children:[g.jsx("span",{className:"logo"}),"agents-deck",ae?g.jsxs("button",{type:"button",className:"v stale",onClick:Ae,title:ae.kind==="restart"?`Running v${ae.from}; v${ae.to} is installed on disk. Restart to pick it up.`:`Running v${ae.from}; v${ae.to} is on npm.`,children:["v",ae.from,g.jsx("span",{className:"v-dot","aria-hidden":!0})]}):g.jsxs("button",{type:"button",className:"v",onClick:()=>se(!0),title:k!=null&&k.checkDisabled?"Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1).":`${k!=null&&k.latest?`npm has v${k.latest}`:"npm not reached yet"}${k!=null&&k.checkedAt?` · checked ${$$(He-k.checkedAt)}`:""} · click to check now`,children:["v",(k==null?void 0:k.running)??"1.33.37"]})]}),wt&&(()=>{const V=dn(wt.usage,wt.model),K=Math.max(0,((wt.endedAt??He)-wt.startedAt)/1e3),ue=wt.state==="active"?Ul(V.total,K):null,fe=o.size-1;return g.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${wt.label}`,onClick:()=>{try{const xe=gn.find(we=>we.id===wt.id);xe&&e.fitView({padding:.35,duration:500,nodes:[xe]}),$n.current=Date.now()}catch{}},children:[g.jsx("span",{className:`state-pill state-${wt.state}`,children:wt.state==="active"?"live":wt.state}),g.jsx("span",{className:"selected-label",children:wt.label}),V.total>0&&g.jsxs("span",{className:"selected-cost",children:[Be(V.total),ue?g.jsxs("span",{className:"selected-rate",children:[" · ",ue]}):null]}),fe>0&&g.jsxs("span",{className:"selected-extra",children:["+",fe]}),g.jsx("span",{role:"button","aria-label":"Deselect",className:"selected-close",onClick:xe=>{xe.stopPropagation(),m()},children:"×"})]})})(),g.jsxs("div",{className:"actions",children:[g.jsxs("div",{className:"search",children:[g.jsx("span",{className:"search-icon","aria-hidden":!0,children:"⌕"}),g.jsx("input",{ref:mr,type:"text",placeholder:"Search agents, cwd, tools…",value:pn,onChange:V=>wi(V.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),pn?g.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>wi(""),children:"×"}):g.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"})]}),g.jsxs("span",{className:"status",role:"status",children:[g.jsx("span",{className:`pill ${D?"live":"dead"}`,title:D?"Receiving events":"SSE disconnected",children:D?"live":"offline"}),g.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[g.jsx("span",{className:"count",children:va}),g.jsx("span",{className:"lbl",children:"sessions"})]}),g.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[g.jsx("span",{className:"count",children:oo}),g.jsx("span",{className:"lbl",children:"agents"})]}),g.jsxs("span",{className:"stat",title:"Total hook events received",children:[g.jsx("span",{className:"count",children:n.current.totalEvents}),g.jsx("span",{className:"lbl",children:"events"})]}),qt.sum>0&&g.jsxs("span",{className:"stat",title:`in:${qt.inT.toLocaleString()} out:${qt.outT.toLocaleString()} cache-r:${qt.cacheR.toLocaleString()} cache-c:${qt.cacheC.toLocaleString()}`,children:[g.jsx("span",{className:"count",children:T$(qt.sum)}),g.jsx("span",{className:"lbl",children:"tokens"})]}),nn.length>0&&g.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
60
60
  ${nn.map(V=>` ${V.server}: ${V.count} call${V.count===1?"":"s"}`).join(`
61
61
  `)}`,children:[nn.slice(0,6).map(V=>g.jsx("span",{className:"mcp-dot",style:{background:`hsl(${V.hue} 65% 65%)`}},V.server)),nn.length>6&&g.jsxs("span",{className:"mcp-more",children:["+",nn.length-6]}),g.jsx("span",{className:"lbl",children:"mcp"})]}),qt.cost.total>0&&(()=>{let V=0,K=0;for(const xe of n.current.agents.values()){if(xe.state!=="active")continue;const we=dn(xe.usage,xe.model);V+=we.total,K=Math.max(K,((xe.endedAt??He)-xe.startedAt)/1e3)}const ue=K>0?Ul(V,K):null,fe=`input ${Be(qt.cost.input)} + output ${Be(qt.cost.output)} + cache r ${Be(qt.cost.cacheRead)} + cache w ${Be(qt.cost.cacheWrite)}${ue?`
62
62
  active burn: ${ue}`:""}`;return g.jsxs("span",{className:"stat",title:fe,children:[g.jsx("span",{className:"count",children:Be(qt.cost.total)}),g.jsxs("span",{className:"lbl",children:["cost",ue?` · ${ue}`:""]})]})})()]}),g.jsx("button",{className:`btn ${pt?"warn":""}`,onClick:()=>mt(V=>!V),title:"Pause/resume live updates (Space)",children:pt?`Resume${kt.current.length?` · ${kt.current.length}`:""}`:"Pause"}),g.jsx("button",{className:`btn icon-btn ${O?"primary":""}`,onClick:()=>q(V=>!V),title:`${O?"Hide":"Show"} usage panel (U)`,"aria-label":"Toggle usage panel",children:"$"}),M!==null&&g.jsx("button",{className:`btn icon-btn ${M?"primary":""}`,onClick:V=>{if(V.shiftKey&&U>0){Y(!0),fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restore"})}).then(()=>fetch("/api/sound-hook")).then(K=>K.ok?K.json():null).then(K=>{K!=null&&K.ok&&(F(K.enabled===!0),ne(K.parked??0))}).catch(()=>{}).finally(()=>Y(!1));return}J()},disabled:X,title:(M?"Sound on turn finish: on — click to remove the hook":"Sound on turn finish: off — click to add a Stop hook")+(I>0?`