agent-dag 1.33.13 → 1.33.14

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,11 +56,11 @@ Error generating stack: `+x.message+`
56
56
  */var iw;function dT(){if(iw)return Wc;iw=1;var e=ta(),n=cT();function i(p,h){return p===h&&(p!==0||1/p===1/h)||p!==p&&h!==h}var s=typeof Object.is=="function"?Object.is:i,o=n.useSyncExternalStore,l=e.useRef,u=e.useEffect,c=e.useMemo,f=e.useDebugValue;return Wc.useSyncExternalStoreWithSelector=function(p,h,g,y,w){var C=l(null);if(C.current===null){var _={hasValue:!1,value:null};C.current=_}else _=C.current;C=c(function(){function b(O){if(!E){if(E=!0,N=O,O=y(O),w!==void 0&&_.hasValue){var q=_.value;if(w(q,O))return j=q}return j=O}if(q=j,s(N,O))return q;var F=y(O);return w!==void 0&&w(q,F)?(N=O,q):(N=O,j=F)}var E=!1,N,j,P=g===void 0?null:g;return[function(){return b(h())},P===null?void 0:function(){return b(P())}]},[h,g,y,w]);var S=o(p,C[0],C[1]);return u(function(){_.hasValue=!0,_.value=S},[S]),f(S),S},Wc}var sw;function fT(){return sw||(sw=1,Vc.exports=dT()),Vc.exports}var hT=fT();const pT=Yg(hT),mT={},ow=e=>{let n;const i=new Set,s=(h,g)=>{const y=typeof h=="function"?h(n):h;if(!Object.is(y,n)){const w=n;n=g??(typeof y!="object"||y===null)?y:Object.assign({},n,y),i.forEach(C=>C(n,w))}},o=()=>n,f={setState:s,getState:o,getInitialState:()=>p,subscribe:h=>(i.add(h),()=>i.delete(h)),destroy:()=>{(mT?"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()}},p=n=e(s,o,f);return f},gT=e=>e?ow(e):ow,{useDebugValue:vT}=le,{useSyncExternalStoreWithSelector:yT}=pT,wT=e=>e;function Hk(e,n=wT,i){const s=yT(e.subscribe,e.getState,e.getServerState||e.getInitialState,n,i);return vT(s),s}const aw=(e,n)=>{const i=gT(e),s=(o,l=n)=>Hk(i,o,l);return Object.assign(s,i),s},xT=(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 _T={value:()=>{}};function Hl(){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 jl(i)}function jl(e){this._=e}function ST(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}})}jl.prototype=Hl.prototype={constructor:jl,on:function(e,n){var i=this._,s=ST(e+"",i),o,l=-1,u=s.length;if(arguments.length<2){for(;++l<u;)if((o=(e=s[l]).type)&&(o=bT(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 jl(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 bT(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]=_T,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 Vl(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 kT(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 ET(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Vk(e){var n=Vl(e);return(n.local?ET:kT)(n)}function NT(){}function Xg(e){return e==null?NT:function(){return this.querySelector(e)}}function CT(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),f,p,h=0;h<u;++h)(f=l[h])&&(p=e.call(f,f.__data__,h,l))&&("__data__"in f&&(p.__data__=f.__data__),c[h]=p);return new Sn(s,this._parents)}function jT(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function TT(){return[]}function Wk(e){return e==null?TT:function(){return this.querySelectorAll(e)}}function RT(e){return function(){return jT(e.apply(this,arguments))}}function AT(e){typeof e=="function"?e=RT(e):e=Wk(e);for(var n=this._groups,i=n.length,s=[],o=[],l=0;l<i;++l)for(var u=n[l],c=u.length,f,p=0;p<c;++p)(f=u[p])&&(s.push(e.call(f,f.__data__,p,u)),o.push(f));return new Sn(s,o)}function Gk(e){return function(){return this.matches(e)}}function Kk(e){return function(n){return n.matches(e)}}var IT=Array.prototype.find;function MT(e){return function(){return IT.call(this.children,e)}}function PT(){return this.firstElementChild}function OT(e){return this.select(e==null?PT:MT(typeof e=="function"?e:Kk(e)))}var qT=Array.prototype.filter;function LT(){return Array.from(this.children)}function $T(e){return function(){return qT.call(this.children,e)}}function DT(e){return this.selectAll(e==null?LT:$T(typeof e=="function"?e:Kk(e)))}function FT(e){typeof e!="function"&&(e=Gk(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]=[],f,p=0;p<u;++p)(f=l[p])&&e.call(f,f.__data__,p,l)&&c.push(f);return new Sn(s,this._parents)}function Yk(e){return new Array(e.length)}function zT(){return new Sn(this._enter||this._groups.map(Yk),this._parents)}function Il(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}Il.prototype={constructor:Il,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 BT(e){return function(){return e}}function UT(e,n,i,s,o,l){for(var u=0,c,f=n.length,p=l.length;u<p;++u)(c=n[u])?(c.__data__=l[u],s[u]=c):i[u]=new Il(e,l[u]);for(;u<f;++u)(c=n[u])&&(o[u]=c)}function HT(e,n,i,s,o,l,u){var c,f,p=new Map,h=n.length,g=l.length,y=new Array(h),w;for(c=0;c<h;++c)(f=n[c])&&(y[c]=w=u.call(f,f.__data__,c,n)+"",p.has(w)?o[c]=f:p.set(w,f));for(c=0;c<g;++c)w=u.call(e,l[c],c,l)+"",(f=p.get(w))?(s[c]=f,f.__data__=l[c],p.delete(w)):i[c]=new Il(e,l[c]);for(c=0;c<h;++c)(f=n[c])&&p.get(y[c])===f&&(o[c]=f)}function VT(e){return e.__data__}function WT(e,n){if(!arguments.length)return Array.from(this,VT);var i=n?HT:UT,s=this._parents,o=this._groups;typeof e!="function"&&(e=BT(e));for(var l=o.length,u=new Array(l),c=new Array(l),f=new Array(l),p=0;p<l;++p){var h=s[p],g=o[p],y=g.length,w=GT(e.call(h,h&&h.__data__,p,s)),C=w.length,_=c[p]=new Array(C),S=u[p]=new Array(C),b=f[p]=new Array(y);i(h,g,_,S,b,w,n);for(var E=0,N=0,j,P;E<C;++E)if(j=_[E]){for(E>=N&&(N=E+1);!(P=S[N])&&++N<C;);j._next=P||null}}return u=new Sn(u,s),u._enter=c,u._exit=f,u}function GT(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function KT(){return new Sn(this._exit||this._groups.map(Yk),this._parents)}function YT(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 XT(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),f=0;f<u;++f)for(var p=i[f],h=s[f],g=p.length,y=c[f]=new Array(g),w,C=0;C<g;++C)(w=p[C]||h[C])&&(y[C]=w);for(;f<o;++f)c[f]=i[f];return new Sn(c,this._parents)}function QT(){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 ZT(e){e||(e=JT);function n(g,y){return g&&y?e(g.__data__,y.__data__):!g-!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,f=o[l]=new Array(c),p,h=0;h<c;++h)(p=u[h])&&(f[h]=p);f.sort(n)}return new Sn(o,this._parents).order()}function JT(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function eR(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function tR(){return Array.from(this)}function nR(){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 rR(){let e=0;for(const n of this)++e;return e}function iR(){return!this.node()}function sR(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 oR(e){return function(){this.removeAttribute(e)}}function aR(e){return function(){this.removeAttributeNS(e.space,e.local)}}function lR(e,n){return function(){this.setAttribute(e,n)}}function uR(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function cR(e,n){return function(){var i=n.apply(this,arguments);i==null?this.removeAttribute(e):this.setAttribute(e,i)}}function dR(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 fR(e,n){var i=Vl(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?aR:oR:typeof n=="function"?i.local?dR:cR:i.local?uR:lR)(i,n))}function Xk(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function hR(e){return function(){this.style.removeProperty(e)}}function pR(e,n,i){return function(){this.style.setProperty(e,n,i)}}function mR(e,n,i){return function(){var s=n.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,i)}}function gR(e,n,i){return arguments.length>1?this.each((n==null?hR:typeof n=="function"?mR:pR)(e,n,i??"")):Bs(this.node(),e)}function Bs(e,n){return e.style.getPropertyValue(n)||Xk(e).getComputedStyle(e,null).getPropertyValue(n)}function vR(e){return function(){delete this[e]}}function yR(e,n){return function(){this[e]=n}}function wR(e,n){return function(){var i=n.apply(this,arguments);i==null?delete this[e]:this[e]=i}}function xR(e,n){return arguments.length>1?this.each((n==null?vR:typeof n=="function"?wR:yR)(e,n)):this.node()[e]}function Qk(e){return e.trim().split(/^|\s+/)}function Qg(e){return e.classList||new Zk(e)}function Zk(e){this._node=e,this._names=Qk(e.getAttribute("class")||"")}Zk.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 Jk(e,n){for(var i=Qg(e),s=-1,o=n.length;++s<o;)i.add(n[s])}function eE(e,n){for(var i=Qg(e),s=-1,o=n.length;++s<o;)i.remove(n[s])}function _R(e){return function(){Jk(this,e)}}function SR(e){return function(){eE(this,e)}}function bR(e,n){return function(){(n.apply(this,arguments)?Jk:eE)(this,e)}}function kR(e,n){var i=Qk(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"?bR:n?_R:SR)(i,n))}function ER(){this.textContent=""}function NR(e){return function(){this.textContent=e}}function CR(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function jR(e){return arguments.length?this.each(e==null?ER:(typeof e=="function"?CR:NR)(e)):this.node().textContent}function TR(){this.innerHTML=""}function RR(e){return function(){this.innerHTML=e}}function AR(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function IR(e){return arguments.length?this.each(e==null?TR:(typeof e=="function"?AR:RR)(e)):this.node().innerHTML}function MR(){this.nextSibling&&this.parentNode.appendChild(this)}function PR(){return this.each(MR)}function OR(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function qR(){return this.each(OR)}function LR(e){var n=typeof e=="function"?e:Vk(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function $R(){return null}function DR(e,n){var i=typeof e=="function"?e:Vk(e),s=n==null?$R:typeof n=="function"?n:Xg(n);return this.select(function(){return this.insertBefore(i.apply(this,arguments),s.apply(this,arguments)||null)})}function FR(){var e=this.parentNode;e&&e.removeChild(this)}function zR(){return this.each(FR)}function BR(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function UR(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function HR(e){return this.select(e?UR:BR)}function VR(e){return arguments.length?this.property("__data__",e):this.node().__data__}function WR(e){return function(n){e.call(this,n,this.__data__)}}function GR(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 KR(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 YR(e,n,i){return function(){var s=this.__on,o,l=WR(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 XR(e,n,i){var s=GR(e+""),o,l=s.length,u;if(arguments.length<2){var c=this.node().__on;if(c){for(var f=0,p=c.length,h;f<p;++f)for(o=0,h=c[f];o<l;++o)if((u=s[o]).type===h.type&&u.name===h.name)return h.value}return}for(c=n?YR:KR,o=0;o<l;++o)this.each(c(s[o],n,i));return this}function tE(e,n,i){var s=Xk(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 QR(e,n){return function(){return tE(this,e,n)}}function ZR(e,n){return function(){return tE(this,e,n.apply(this,arguments))}}function JR(e,n){return this.each((typeof n=="function"?ZR:QR)(e,n))}function*e2(){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 nE=[null];function Sn(e,n){this._groups=e,this._parents=n}function na(){return new Sn([[document.documentElement]],nE)}function t2(){return this}Sn.prototype=na.prototype={constructor:Sn,select:CT,selectAll:AT,selectChild:OT,selectChildren:DT,filter:FT,data:WT,enter:zT,exit:KT,join:YT,merge:XT,selection:t2,order:QT,sort:ZT,call:eR,nodes:tR,node:nR,size:rR,empty:iR,each:sR,attr:fR,style:gR,property:xR,classed:kR,text:jR,html:IR,raise:PR,lower:qR,append:LR,insert:DR,remove:zR,clone:HR,datum:VR,on:XR,dispatch:JR,[Symbol.iterator]:e2};function Mn(e){return typeof e=="string"?new Sn([[document.querySelector(e)]],[document.documentElement]):new Sn([[e]],nE)}function n2(e){let n;for(;n=e.sourceEvent;)e=n;return e}function Kn(e,n){if(e=n2(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 r2={passive:!1},Go={capture:!0,passive:!1};function Yc(e){e.stopImmediatePropagation()}function $s(e){e.preventDefault(),e.stopImmediatePropagation()}function rE(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 iE(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 hl=e=>()=>e;function Cg(e,{sourceEvent:n,subject:i,target:s,identifier:o,active:l,x:u,y:c,dx:f,dy:p,dispatch:h}){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:f,enumerable:!0,configurable:!0},dy:{value:p,enumerable:!0,configurable:!0},_:{value:h}})}Cg.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function i2(e){return!e.ctrlKey&&!e.button}function s2(){return this.parentNode}function o2(e,n){return n??{x:e.x,y:e.y}}function a2(){return navigator.maxTouchPoints||"ontouchstart"in this}function l2(){var e=i2,n=s2,i=o2,s=a2,o={},l=Hl("start","drag","end"),u=0,c,f,p,h,g=0;function y(j){j.on("mousedown.drag",w).filter(s).on("touchstart.drag",S).on("touchmove.drag",b,r2).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function w(j,P){if(!(h||!e.call(this,j,P))){var O=N(this,n.call(this,j,P),j,P,"mouse");O&&(Mn(j.view).on("mousemove.drag",C,Go).on("mouseup.drag",_,Go),rE(j.view),Yc(j),p=!1,c=j.clientX,f=j.clientY,O("start",j))}}function C(j){if($s(j),!p){var P=j.clientX-c,O=j.clientY-f;p=P*P+O*O>g}o.mouse("drag",j)}function _(j){Mn(j.view).on("mousemove.drag mouseup.drag",null),iE(j.view,p),$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),F=O.length,T,M;for(T=0;T<F;++T)(M=N(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,F;for(q=0;q<O;++q)(F=o[P[q].identifier])&&($s(j),F("drag",j,P[q]))}function E(j){var P=j.changedTouches,O=P.length,q,F;for(h&&clearTimeout(h),h=setTimeout(function(){h=null},500),q=0;q<O;++q)(F=o[P[q].identifier])&&(Yc(j),F("end",j,P[q]))}function N(j,P,O,q,F,T){var M=l.copy(),B=Kn(T||O,P),J,Z,A;if((A=i.call(j,new Cg("beforestart",{sourceEvent:O,target:y,identifier:F,active:u,x:B[0],y:B[1],dx:0,dy:0,dispatch:M}),q))!=null)return J=A.x-B[0]||0,Z=A.y-B[1]||0,function H(U,ne,Q){var D=B,G;switch(U){case"start":o[F]=H,G=u++;break;case"end":delete o[F],--u;case"drag":B=Kn(Q||ne,P),G=u;break}M.call(U,j,new Cg(U,{sourceEvent:ne,subject:A,target:y,identifier:F,active:G,x:B[0]+J,y:B[1]+Z,dx:B[0]-D[0],dy:B[1]-D[1],dispatch:M}),q)}}return y.filter=function(j){return arguments.length?(e=typeof j=="function"?j:hl(!!j),y):e},y.container=function(j){return arguments.length?(n=typeof j=="function"?j:hl(j),y):n},y.subject=function(j){return arguments.length?(i=typeof j=="function"?j:hl(j),y):i},y.touchable=function(j){return arguments.length?(s=typeof j=="function"?j:hl(!!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?(g=(j=+j)*j,y):Math.sqrt(g)},y}function Zg(e,n,i){e.prototype=n.prototype=i,i.constructor=e}function sE(e,n){var i=Object.create(e.prototype);for(var s in n)i[s]=n[s];return i}function ra(){}var Ko=.7,Ml=1/Ko,Ds="\\s*([+-]?\\d+)\\s*",Yo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",cr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",u2=/^#([0-9a-f]{3,8})$/,c2=new RegExp(`^rgb\\(${Ds},${Ds},${Ds}\\)$`),d2=new RegExp(`^rgb\\(${cr},${cr},${cr}\\)$`),f2=new RegExp(`^rgba\\(${Ds},${Ds},${Ds},${Yo}\\)$`),h2=new RegExp(`^rgba\\(${cr},${cr},${cr},${Yo}\\)$`),p2=new RegExp(`^hsl\\(${Yo},${cr},${cr}\\)$`),m2=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(ra,Xo,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:dw,formatHex:dw,formatHex8:g2,formatHsl:v2,formatRgb:fw,toString:fw});function dw(){return this.rgb().formatHex()}function g2(){return this.rgb().formatHex8()}function v2(){return oE(this).formatHsl()}function fw(){return this.rgb().formatRgb()}function Xo(e){var n,i;return e=(e+"").trim().toLowerCase(),(n=u2.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?pl(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):i===4?pl(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=c2.exec(e))?new cn(n[1],n[2],n[3],1):(n=d2.exec(e))?new cn(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=f2.exec(e))?pl(n[1],n[2],n[3],n[4]):(n=h2.exec(e))?pl(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=p2.exec(e))?gw(n[1],n[2]/100,n[3]/100,1):(n=m2.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 pl(e,n,i,s){return s<=0&&(e=n=i=NaN),new cn(e,n,i,s)}function y2(e){return e instanceof ra||(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?y2(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,sE(ra,{brighter(e){return e=e==null?Ml:Math.pow(Ml,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),Pl(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:w2,formatRgb:mw,toString:mw}));function pw(){return`#${Wi(this.r)}${Wi(this.g)}${Wi(this.b)}`}function w2(){return`#${Wi(this.r)}${Wi(this.g)}${Wi(this.b)}${Wi((isNaN(this.opacity)?1:this.opacity)*255)}`}function mw(){const e=Pl(this.opacity);return`${e===1?"rgb(":"rgba("}${Ki(this.r)}, ${Ki(this.g)}, ${Ki(this.b)}${e===1?")":`, ${e})`}`}function Pl(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 oE(e){if(e instanceof Yn)return new Yn(e.h,e.s,e.l,e.opacity);if(e instanceof ra||(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,f=(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/=f<.5?l+o:2-l-o,u*=60):c=f>0&&f<1?0:u,new Yn(u,c,f,e.opacity)}function x2(e,n,i,s){return arguments.length===1?oE(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,x2,sE(ra,{brighter(e){return e=e==null?Ml:Math.pow(Ml,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),ml(this.s),ml(this.l),Pl(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=Pl(this.opacity);return`${e===1?"hsl(":"hsla("}${vw(this.h)}, ${ml(this.s)*100}%, ${ml(this.l)*100}%${e===1?")":`, ${e})`}`}}));function vw(e){return e=(e||0)%360,e<0?e+360:e}function ml(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 aE=e=>()=>e;function _2(e,n){return function(i){return e+i*n}}function S2(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 b2(e){return(e=+e)==1?lE:function(n,i){return i-n?S2(n,i,e):aE(isNaN(n)?i:n)}}function lE(e,n){var i=n-e;return i?_2(e,i):aE(isNaN(e)?n:e)}const yw=(function e(n){var i=b2(n);function s(o,l){var u=i((o=jg(o)).r,(l=jg(l)).r),c=i(o.g,l.g),f=i(o.b,l.b),p=lE(o.opacity,l.opacity);return function(h){return o.r=u(h),o.g=c(h),o.b=f(h),o.opacity=p(h),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 Tg=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Qc=new RegExp(Tg.source,"g");function k2(e){return function(){return e}}function E2(e){return function(n){return e(n)+""}}function N2(e,n){var i=Tg.lastIndex=Qc.lastIndex=0,s,o,l,u=-1,c=[],f=[];for(e=e+"",n=n+"";(s=Tg.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,f.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?f[0]?E2(f[0].x):k2(n):(n=f.length,function(p){for(var h=0,g;h<n;++h)c[(g=f[h]).i]=g.x(p);return c.join("")})}var ww=180/Math.PI,Rg={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function uE(e,n,i,s,o,l){var u,c,f;return(u=Math.sqrt(e*e+n*n))&&(e/=u,n/=u),(f=e*i+n*s)&&(i-=e*f,s-=n*f),(c=Math.sqrt(i*i+s*s))&&(i/=c,s/=c,f/=c),e*s<n*i&&(e=-e,n=-n,f=-f,u=-u),{translateX:o,translateY:l,rotate:Math.atan2(n,e)*ww,skewX:Math.atan(f)*ww,scaleX:u,scaleY:c}}var gl;function C2(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?Rg:uE(n.a,n.b,n.c,n.d,n.e,n.f)}function j2(e){return e==null||(gl||(gl=document.createElementNS("http://www.w3.org/2000/svg","g")),gl.setAttribute("transform",e),!(e=gl.transform.baseVal.consolidate()))?Rg:(e=e.matrix,uE(e.a,e.b,e.c,e.d,e.e,e.f))}function cE(e,n,i,s){function o(p){return p.length?p.pop()+" ":""}function l(p,h,g,y,w,C){if(p!==g||h!==y){var _=w.push("translate(",null,n,null,i);C.push({i:_-4,x:fi(p,g)},{i:_-2,x:fi(h,y)})}else(g||y)&&w.push("translate("+g+n+y+i)}function u(p,h,g,y){p!==h?(p-h>180?h+=360:h-p>180&&(p+=360),y.push({i:g.push(o(g)+"rotate(",null,s)-2,x:fi(p,h)})):h&&g.push(o(g)+"rotate("+h+s)}function c(p,h,g,y){p!==h?y.push({i:g.push(o(g)+"skewX(",null,s)-2,x:fi(p,h)}):h&&g.push(o(g)+"skewX("+h+s)}function f(p,h,g,y,w,C){if(p!==g||h!==y){var _=w.push(o(w)+"scale(",null,",",null,")");C.push({i:_-4,x:fi(p,g)},{i:_-2,x:fi(h,y)})}else(g!==1||y!==1)&&w.push(o(w)+"scale("+g+","+y+")")}return function(p,h){var g=[],y=[];return p=e(p),h=e(h),l(p.translateX,p.translateY,h.translateX,h.translateY,g,y),u(p.rotate,h.rotate,g,y),c(p.skewX,h.skewX,g,y),f(p.scaleX,p.scaleY,h.scaleX,h.scaleY,g,y),p=h=null,function(w){for(var C=-1,_=y.length,S;++C<_;)g[(S=y[C]).i]=S.x(w);return g.join("")}}}var T2=cE(C2,"px, ","px)","deg)"),R2=cE(j2,", ",")",")"),A2=1e-12;function xw(e){return((e=Math.exp(e))+1/e)/2}function I2(e){return((e=Math.exp(e))-1/e)/2}function M2(e){return((e=Math.exp(2*e))-1)/(e+1)}const P2=(function e(n,i,s){function o(l,u){var c=l[0],f=l[1],p=l[2],h=u[0],g=u[1],y=u[2],w=h-c,C=g-f,_=w*w+C*C,S,b;if(_<A2)b=Math.log(y/p)/n,S=function(q){return[c+q*w,f+q*C,p*Math.exp(n*q*b)]};else{var E=Math.sqrt(_),N=(y*y-p*p+s*_)/(2*p*i*E),j=(y*y-p*p-s*_)/(2*y*i*E),P=Math.log(Math.sqrt(N*N+1)-N),O=Math.log(Math.sqrt(j*j+1)-j);b=(O-P)/n,S=function(q){var F=q*b,T=xw(P),M=p/(i*E)*(T*M2(n*F+P)-I2(P));return[c+M*w,f+M*C,p*T/xw(n*F+P)]}}return S.duration=b*1e3*n/Math.SQRT2,S}return o.rho=function(l){var u=Math.max(.001,+l),c=u*u,f=c*c;return e(u,c,f)},o})(Math.SQRT2,2,4);var Us=0,Fo=0,Oo=0,dE=1e3,Ol,zo,ql=0,Qi=0,Wl=0,Qo=typeof performance=="object"&&performance.now?performance:Date,fE=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Jg(){return Qi||(fE(O2),Qi=Qo.now()+Wl)}function O2(){Qi=0}function Ll(){this._call=this._time=this._next=null}Ll.prototype=hE.prototype={constructor:Ll,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:Ol=this,zo=this),this._call=e,this._time=i,Ag()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ag())}};function hE(e,n,i){var s=new Ll;return s.restart(e,n,i),s}function q2(){Jg(),++Us;for(var e=Ol,n;e;)(n=Qi-e._time)>=0&&e._call.call(void 0,n),e=e._next;--Us}function _w(){Qi=(ql=Qo.now())+Wl,Us=Fo=0;try{q2()}finally{Us=0,$2(),Qi=0}}function L2(){var e=Qo.now(),n=e-ql;n>dE&&(Wl-=n,ql=e)}function $2(){for(var e,n=Ol,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:Ol=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()-Wl)),Oo&&(Oo=clearInterval(Oo))):(Oo||(ql=Qo.now(),Oo=setInterval(L2,dE)),Us=1,fE(_w))}}function Sw(e,n,i){var s=new Ll;return n=n==null?0:+n,s.restart(o=>{s.stop(),e(o+n)},n,i),s}var D2=Hl("start","end","cancel","interrupt"),F2=[],pE=0,bw=1,Ig=2,Tl=3,kw=4,Mg=5,Rl=6;function Gl(e,n,i,s,o,l){var u=e.__transition;if(!u)e.__transition={};else if(i in u)return;z2(e,i,{name:n,index:s,group:o,on:D2,tween:F2,time:l.time,delay:l.delay,duration:l.duration,ease:l.ease,timer:null,state:pE})}function ev(e,n){var i=Zn(e,n);if(i.state>pE)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 z2(e,n,i){var s=e.__transition,o;s[n]=i,i.timer=hE(l,0,i.time);function l(p){i.state=bw,i.timer.restart(u,i.delay,i.time),i.delay<=p&&u(p-i.delay)}function u(p){var h,g,y,w;if(i.state!==bw)return f();for(h in s)if(w=s[h],w.name===i.name){if(w.state===Tl)return Sw(u);w.state===kw?(w.state=Rl,w.timer.stop(),w.on.call("interrupt",e,e.__data__,w.index,w.group),delete s[h]):+h<n&&(w.state=Rl,w.timer.stop(),w.on.call("cancel",e,e.__data__,w.index,w.group),delete s[h])}if(Sw(function(){i.state===Tl&&(i.state=kw,i.timer.restart(c,i.delay,i.time),c(p))}),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),h=0,g=-1;h<y;++h)(w=i.tween[h].value.call(e,e.__data__,i.index,i.group))&&(o[++g]=w);o.length=g+1}}function c(p){for(var h=p<i.duration?i.ease.call(null,p/i.duration):(i.timer.restart(f),i.state=Mg,1),g=-1,y=o.length;++g<y;)o[g].call(e,h);i.state===Mg&&(i.on.call("end",e,e.__data__,i.index,i.group),f())}function f(){i.state=Rl,i.timer.stop(),delete s[n];for(var p in s)return;delete e.__transition}}function Al(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=Rl,s.timer.stop(),s.on.call(o?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete i[u]}l&&delete e.__transition}}function B2(e){return this.each(function(){Al(this,e)})}function U2(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 H2(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},f=0,p=o.length;f<p;++f)if(o[f].name===n){o[f]=c;break}f===p&&o.push(c)}l.tween=o}}function V2(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?U2:H2)(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 mE(e,n){var i;return(typeof n=="number"?fi:n instanceof Xo?yw:(i=Xo(n))?(n=i,yw):N2)(e,n)}function W2(e){return function(){this.removeAttribute(e)}}function G2(e){return function(){this.removeAttributeNS(e.space,e.local)}}function K2(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 Y2(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 X2(e,n,i){var s,o,l;return function(){var u,c=i(this),f;return c==null?void this.removeAttribute(e):(u=this.getAttribute(e),f=c+"",u===f?null:u===s&&f===o?l:(o=f,l=n(s=u,c)))}}function Q2(e,n,i){var s,o,l;return function(){var u,c=i(this),f;return c==null?void this.removeAttributeNS(e.space,e.local):(u=this.getAttributeNS(e.space,e.local),f=c+"",u===f?null:u===s&&f===o?l:(o=f,l=n(s=u,c)))}}function Z2(e,n){var i=Vl(e),s=i==="transform"?R2:mE;return this.attrTween(e,typeof n=="function"?(i.local?Q2:X2)(i,s,tv(this,"attr."+e,n)):n==null?(i.local?G2:W2)(i):(i.local?Y2:K2)(i,s,n))}function J2(e,n){return function(i){this.setAttribute(e,n.call(this,i))}}function eA(e,n){return function(i){this.setAttributeNS(e.space,e.local,n.call(this,i))}}function tA(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 nA(e,n){var i,s;function o(){var l=n.apply(this,arguments);return l!==s&&(i=(s=l)&&J2(e,l)),i}return o._value=n,o}function rA(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=Vl(e);return this.tween(i,(s.local?tA:nA)(s,n))}function iA(e,n){return function(){ev(this,e).delay=+n.apply(this,arguments)}}function sA(e,n){return n=+n,function(){ev(this,e).delay=n}}function oA(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?iA:sA)(n,e)):Zn(this.node(),n).delay}function aA(e,n){return function(){dr(this,e).duration=+n.apply(this,arguments)}}function lA(e,n){return n=+n,function(){dr(this,e).duration=n}}function uA(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?aA:lA)(n,e)):Zn(this.node(),n).duration}function cA(e,n){if(typeof n!="function")throw new Error;return function(){dr(this,e).ease=n}}function dA(e){var n=this._id;return arguments.length?this.each(cA(n,e)):Zn(this.node(),n).ease}function fA(e,n){return function(){var i=n.apply(this,arguments);if(typeof i!="function")throw new Error;dr(this,e).ease=i}}function hA(e){if(typeof e!="function")throw new Error;return this.each(fA(this._id,e))}function pA(e){typeof e!="function"&&(e=Gk(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]=[],f,p=0;p<u;++p)(f=l[p])&&e.call(f,f.__data__,p,l)&&c.push(f);return new Pr(s,this._parents,this._name,this._id)}function mA(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 f=n[c],p=i[c],h=f.length,g=u[c]=new Array(h),y,w=0;w<h;++w)(y=f[w]||p[w])&&(g[w]=y);for(;c<s;++c)u[c]=n[c];return new Pr(u,this._parents,this._name,this._id)}function gA(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 vA(e,n,i){var s,o,l=gA(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 yA(e,n){var i=this._id;return arguments.length<2?Zn(this.node(),i).on.on(e):this.each(vA(i,e,n))}function wA(e){return function(){var n=this.parentNode;for(var i in this.__transition)if(+i!==e)return;n&&n.removeChild(this)}}function xA(){return this.on("end.remove",wA(this._id))}function _A(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],f=c.length,p=l[u]=new Array(f),h,g,y=0;y<f;++y)(h=c[y])&&(g=e.call(h,h.__data__,y,c))&&("__data__"in h&&(g.__data__=h.__data__),p[y]=g,Gl(p[y],n,i,y,p,Zn(h,i)));return new Pr(l,this._parents,n,i)}function SA(e){var n=this._name,i=this._id;typeof e!="function"&&(e=Wk(e));for(var s=this._groups,o=s.length,l=[],u=[],c=0;c<o;++c)for(var f=s[c],p=f.length,h,g=0;g<p;++g)if(h=f[g]){for(var y=e.call(h,h.__data__,g,f),w,C=Zn(h,i),_=0,S=y.length;_<S;++_)(w=y[_])&&Gl(w,n,i,_,y,C);l.push(y),u.push(h)}return new Pr(l,u,n,i)}var bA=na.prototype.constructor;function kA(){return new bA(this._groups,this._parents)}function EA(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 gE(e){return function(){this.style.removeProperty(e)}}function NA(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 CA(e,n,i){var s,o,l;return function(){var u=Bs(this,e),c=i(this),f=c+"";return c==null&&(f=c=(this.style.removeProperty(e),Bs(this,e))),u===f?null:u===s&&f===o?l:(o=f,l=n(s=u,c))}}function jA(e,n){var i,s,o,l="style."+n,u="end."+l,c;return function(){var f=dr(this,e),p=f.on,h=f.value[l]==null?c||(c=gE(n)):void 0;(p!==i||o!==h)&&(s=(i=p).copy()).on(u,o=h),f.on=s}}function TA(e,n,i){var s=(e+="")=="transform"?T2:mE;return n==null?this.styleTween(e,EA(e,s)).on("end.style."+e,gE(e)):typeof n=="function"?this.styleTween(e,CA(e,s,tv(this,"style."+e,n))).each(jA(this._id,e)):this.styleTween(e,NA(e,s,n),i).on("end.style."+e,null)}function RA(e,n,i){return function(s){this.style.setProperty(e,n.call(this,s),i)}}function AA(e,n,i){var s,o;function l(){var u=n.apply(this,arguments);return u!==o&&(s=(o=u)&&RA(e,u,i)),s}return l._value=n,l}function IA(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,AA(e,n,i??""))}function MA(e){return function(){this.textContent=e}}function PA(e){return function(){var n=e(this);this.textContent=n??""}}function OA(e){return this.tween("text",typeof e=="function"?PA(tv(this,"text",e)):MA(e==null?"":e+""))}function qA(e){return function(n){this.textContent=e.call(this,n)}}function LA(e){var n,i;function s(){var o=e.apply(this,arguments);return o!==i&&(n=(i=o)&&qA(o)),n}return s._value=e,s}function $A(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,LA(e))}function DA(){for(var e=this._name,n=this._id,i=vE(),s=this._groups,o=s.length,l=0;l<o;++l)for(var u=s[l],c=u.length,f,p=0;p<c;++p)if(f=u[p]){var h=Zn(f,n);Gl(f,e,i,p,u,{time:h.time+h.delay+h.duration,delay:0,duration:h.duration,ease:h.ease})}return new Pr(s,this._parents,e,i)}function FA(){var e,n,i=this,s=i._id,o=i.size();return new Promise(function(l,u){var c={value:u},f={value:function(){--o===0&&l()}};i.each(function(){var p=dr(this,s),h=p.on;h!==e&&(n=(e=h).copy(),n._.cancel.push(c),n._.interrupt.push(c),n._.end.push(f)),p.on=n}),o===0&&l()})}var zA=0;function Pr(e,n,i,s){this._groups=e,this._parents=n,this._name=i,this._id=s}function vE(){return++zA}var Rr=na.prototype;Pr.prototype={constructor:Pr,select:_A,selectAll:SA,selectChild:Rr.selectChild,selectChildren:Rr.selectChildren,filter:pA,merge:mA,selection:kA,transition:DA,call:Rr.call,nodes:Rr.nodes,node:Rr.node,size:Rr.size,empty:Rr.empty,each:Rr.each,on:yA,attr:Z2,attrTween:rA,style:TA,styleTween:IA,text:OA,textTween:$A,remove:xA,tween:V2,delay:oA,duration:uA,ease:dA,easeVarying:hA,end:FA,[Symbol.iterator]:Rr[Symbol.iterator]};function BA(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var UA={time:null,delay:0,duration:250,ease:BA};function HA(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 VA(e){var n,i;e instanceof Pr?(n=e._id,e=e._name):(n=vE(),(i=UA).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,f,p=0;p<c;++p)(f=u[p])&&Gl(f,e,n,p,u,i||HA(f,n));return new Pr(s,this._parents,e,n)}na.prototype.interrupt=B2;na.prototype.transition=VA;const vl=e=>()=>e;function WA(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 GA(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function KA(){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 YA(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function XA(){return navigator.maxTouchPoints||"ontouchstart"in this}function QA(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 yE(){var e=GA,n=KA,i=QA,s=YA,o=XA,l=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],c=250,f=P2,p=Hl("start","zoom","end"),h,g,y,w=500,C=150,_=0,S=10;function b(A){A.property("__zoom",Ew).on("wheel.zoom",F,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",M).filter(o).on("touchstart.zoom",B).on("touchmove.zoom",J).on("touchend.zoom touchcancel.zoom",Z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}b.transform=function(A,H,U,ne){var Q=A.selection?A.selection():A;Q.property("__zoom",Ew),A!==Q?P(A,H,U,ne):Q.interrupt().each(function(){O(this,arguments).event(ne).start().zoom(null,typeof H=="function"?H.apply(this,arguments):H).end()})},b.scaleBy=function(A,H,U,ne){b.scaleTo(A,function(){var Q=this.__zoom.k,D=typeof H=="function"?H.apply(this,arguments):H;return Q*D},U,ne)},b.scaleTo=function(A,H,U,ne){b.transform(A,function(){var Q=n.apply(this,arguments),D=this.__zoom,G=U==null?j(Q):typeof U=="function"?U.apply(this,arguments):U,k=D.invert(G),L=typeof H=="function"?H.apply(this,arguments):H;return i(N(E(D,L),G,k),Q,u)},U,ne)},b.translateBy=function(A,H,U,ne){b.transform(A,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(A,H,U,ne,Q){b.transform(A,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,Q)};function E(A,H){return H=Math.max(l[0],Math.min(l[1],H)),H===A.k?A:new Ir(H,A.x,A.y)}function N(A,H,U){var ne=H[0]-U[0]*A.k,Q=H[1]-U[1]*A.k;return ne===A.x&&Q===A.y?A:new Ir(A.k,ne,Q)}function j(A){return[(+A[0][0]+ +A[1][0])/2,(+A[0][1]+ +A[1][1])/2]}function P(A,H,U,ne){A.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 Q=this,D=arguments,G=O(Q,D).event(ne),k=n.apply(Q,D),L=U==null?j(k):typeof U=="function"?U.apply(Q,D):U,oe=Math.max(k[1][0]-k[0][0],k[1][1]-k[0][1]),$=Q.__zoom,Y=typeof H=="function"?H.apply(Q,D):H,ee=f($.invert(L).concat(oe/$.k),Y.invert(L).concat(oe/Y.k));return function(se){if(se===1)se=Y;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(A,H,U){return!U&&A.__zooming||new q(A,H)}function q(A,H){this.that=A,this.args=H,this.active=0,this.sourceEvent=null,this.extent=n.apply(A,H),this.taps=0}q.prototype={event:function(A){return A&&(this.sourceEvent=A),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(A,H){return this.mouse&&A!=="mouse"&&(this.mouse[1]=H.invert(this.mouse[0])),this.touch0&&A!=="touch"&&(this.touch0[1]=H.invert(this.touch0[0])),this.touch1&&A!=="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(A){var H=Mn(this.that).datum();p.call(A,this.that,new WA(A,{sourceEvent:this.sourceEvent,target:b,transform:this.that.__zoom,dispatch:p}),H)}};function F(A,...H){if(!e.apply(this,arguments))return;var U=O(this,H).event(A),ne=this.__zoom,Q=Math.max(l[0],Math.min(l[1],ne.k*Math.pow(2,s.apply(this,arguments)))),D=Kn(A);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===Q)return;U.mouse=[D,ne.invert(D)],Al(this),U.start()}qo(A),U.wheel=setTimeout(G,C),U.zoom("mouse",i(N(E(ne,Q),U.mouse[0],U.mouse[1]),U.extent,u));function G(){U.wheel=null,U.end()}}function T(A,...H){if(y||!e.apply(this,arguments))return;var U=A.currentTarget,ne=O(this,H,!0).event(A),Q=Mn(A.view).on("mousemove.zoom",L,!0).on("mouseup.zoom",oe,!0),D=Kn(A,U),G=A.clientX,k=A.clientY;rE(A.view),Zc(A),ne.mouse=[D,this.__zoom.invert(D)],Al(this),ne.start();function L($){if(qo($),!ne.moved){var Y=$.clientX-G,ee=$.clientY-k;ne.moved=Y*Y+ee*ee>_}ne.event($).zoom("mouse",i(N(ne.that.__zoom,ne.mouse[0]=Kn($,U),ne.mouse[1]),ne.extent,u))}function oe($){Q.on("mousemove.zoom mouseup.zoom",null),iE($.view,ne.moved),qo($),ne.event($).end()}}function M(A,...H){if(e.apply(this,arguments)){var U=this.__zoom,ne=Kn(A.changedTouches?A.changedTouches[0]:A,this),Q=U.invert(ne),D=U.k*(A.shiftKey?.5:2),G=i(N(E(U,D),ne,Q),n.apply(this,H),u);qo(A),c>0?Mn(this).transition().duration(c).call(P,G,ne,A):Mn(this).call(b.transform,G,ne,A)}}function B(A,...H){if(e.apply(this,arguments)){var U=A.touches,ne=U.length,Q=O(this,H,A.changedTouches.length===ne).event(A),D,G,k,L;for(Zc(A),G=0;G<ne;++G)k=U[G],L=Kn(k,this),L=[L,this.__zoom.invert(L),k.identifier],Q.touch0?!Q.touch1&&Q.touch0[2]!==L[2]&&(Q.touch1=L,Q.taps=0):(Q.touch0=L,D=!0,Q.taps=1+!!h);h&&(h=clearTimeout(h)),D&&(Q.taps<2&&(g=L[0],h=setTimeout(function(){h=null},w)),Al(this),Q.start())}}function J(A,...H){if(this.__zooming){var U=O(this,H).event(A),ne=A.changedTouches,Q=ne.length,D,G,k,L;for(qo(A),D=0;D<Q;++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],Y=U.touch1[0],ee=U.touch1[1],se=(se=Y[0]-oe[0])*se+(se=Y[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]+Y[0])/2,(oe[1]+Y[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(N(G,k,L),U.extent,u))}}function Z(A,...H){if(this.__zooming){var U=O(this,H).event(A),ne=A.changedTouches,Q=ne.length,D,G;for(Zc(A),y&&clearTimeout(y),y=setTimeout(function(){y=null},w),D=0;D<Q;++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(g[0]-G[0],g[1]-G[1])<S)){var k=Mn(this).on("dblclick.zoom");k&&k.apply(this,arguments)}}}return b.wheelDelta=function(A){return arguments.length?(s=typeof A=="function"?A:vl(+A),b):s},b.filter=function(A){return arguments.length?(e=typeof A=="function"?A:vl(!!A),b):e},b.touchable=function(A){return arguments.length?(o=typeof A=="function"?A:vl(!!A),b):o},b.extent=function(A){return arguments.length?(n=typeof A=="function"?A:vl([[+A[0][0],+A[0][1]],[+A[1][0],+A[1][1]]]),b):n},b.scaleExtent=function(A){return arguments.length?(l[0]=+A[0],l[1]=+A[1],b):[l[0],l[1]]},b.translateExtent=function(A){return arguments.length?(u[0][0]=+A[0][0],u[1][0]=+A[1][0],u[0][1]=+A[0][1],u[1][1]=+A[1][1],b):[[u[0][0],u[0][1]],[u[1][0],u[1][1]]]},b.constrain=function(A){return arguments.length?(i=A,b):i},b.duration=function(A){return arguments.length?(c=+A,b):c},b.interpolate=function(A){return arguments.length?(f=A,b):f},b.on=function(){var A=p.on.apply(p,arguments);return A===p?b:A},b.clickDistance=function(A){return arguments.length?(_=(A=+A)*A,b):Math.sqrt(_)},b.tapDistance=function(A){return arguments.length?(S=+A,b):S},b}var ZA=Uk();const Kl=I.createContext(null),JA=Kl.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.`},wE=Or.error001();function Xe(e,n){const i=I.useContext(Kl);if(i===null)throw new Error(wE);return Hk(i,e,n)}const jt=()=>{const e=I.useContext(Kl);if(e===null)throw new Error(wE);return I.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},eI=e=>e.userSelectionActive?"none":"all";function nv({position:e,children:n,className:i,style:s,...o}){const l=Xe(eI),u=`${e}`.split("-");return le.createElement("div",{className:Ft(["react-flow__panel",i,...u]),style:{...s,pointerEvents:l},...o},n)}function tI({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 nI=({x:e,y:n,label:i,labelStyle:s={},labelShowBg:o=!0,labelBgStyle:l={},labelBgPadding:u=[2,4],labelBgBorderRadius:c=2,children:f,className:p,...h})=>{const g=I.useRef(null),[y,w]=I.useState({x:0,y:0,width:0,height:0}),C=Ft(["react-flow__edge-textwrapper",p]);return I.useEffect(()=>{if(g.current){const _=g.current.getBBox();w({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:C,visibility:y.width?"visible":"hidden",...h},o&&le.createElement("rect",{width:y.width+2*u[0],x:-u[0],y:-u[1],height:y.height+2*u[1],className:"react-flow__edge-textbg",style:l,rx:c,ry:c}),le.createElement("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:g,style:s},i),f)};var rI=I.memo(nI);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,xE=(e,n)=>{const i=Nw(e.x,35,n.width-35)*20,s=Nw(e.y,35,n.height-35)*20;return[i,s]},_E=e=>{var n;return((n=e.getRootNode)==null?void 0:n.call(e))||(window==null?void 0:window.document)},SE=(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}),bE=({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}),iI=(e,n)=>bE(SE(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)},sI=e=>Pn(e.width)&&Pn(e.height)&&Pn(e.x)&&Pn(e.y),Pn=e=>!isNaN(e)&&isFinite(e),ht=Symbol.for("internals"),kE=["Enter"," ","Escape"],oI=(e,n)=>{},aI=e=>"nativeEvent"in e;function Og(e){var o,l;const n=aI(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 EE=e=>"clientX"in e,mi=(e,n)=>{var l,u;const i=EE(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)}},$l=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},ia=({id:e,path:n,labelX:i,labelY:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:p,style:h,markerEnd:g,markerStart:y,interactionWidth:w=20})=>le.createElement(le.Fragment,null,le.createElement("path",{id:e,style:h,d:n,fill:"none",className:"react-flow__edge-path",markerEnd:g,markerStart:y}),w&&le.createElement("path",{d:n,fill:"none",strokeOpacity:0,strokeWidth:w,className:"react-flow__edge-interaction"}),o&&Pn(i)&&Pn(s)?le.createElement(rI,{x:i,y:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:p}):null);ia.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 NE({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 CE({sourceX:e,sourceY:n,targetX:i,targetY:s,sourceControlX:o,sourceControlY:l,targetControlX:u,targetControlY:c}){const f=e*.125+o*.375+u*.375+i*.125,p=n*.125+l*.375+c*.375+s*.125,h=Math.abs(f-e),g=Math.abs(p-n);return[f,p,h,g]}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 Dl;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Dl||(Dl={}));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 jE({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}),[f,p]=jw({pos:l,x1:s,y1:o,x2:e,y2:n}),[h,g,y,w]=CE({sourceX:e,sourceY:n,targetX:s,targetY:o,sourceControlX:u,sourceControlY:c,targetControlX:f,targetControlY:p});return[`M${e},${n} C${u},${c} ${f},${p} ${s},${o}`,h,g,y,w]}const sv=I.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,sourcePosition:o=Ce.Bottom,targetPosition:l=Ce.Top,label:u,labelStyle:c,labelShowBg:f,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:g,style:y,markerEnd:w,markerStart:C,interactionWidth:_})=>{const[S,b,E]=jE({sourceX:e,sourceY:n,sourcePosition:o,targetX:i,targetY:s,targetPosition:l});return le.createElement(ia,{path:S,labelX:b,labelY:E,label:u,labelStyle:c,labelShowBg:f,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:g,style:y,markerEnd:w,markerStart:C,interactionWidth:_})});sv.displayName="SimpleBezierEdge";const Tw={[Ce.Left]:{x:-1,y:0},[Ce.Right]:{x:1,y:0},[Ce.Top]:{x:0,y:-1},[Ce.Bottom]:{x:0,y:1}},lI=({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},Rw=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function uI({source:e,sourcePosition:n=Ce.Bottom,target:i,targetPosition:s=Ce.Top,center:o,offset:l}){const u=Tw[n],c=Tw[s],f={x:e.x+u.x*l,y:e.y+u.y*l},p={x:i.x+c.x*l,y:i.y+c.y*l},h=lI({source:f,sourcePosition:n,target:p}),g=h.x!==0?"x":"y",y=h[g];let w=[],C,_;const S={x:0,y:0},b={x:0,y:0},[E,N,j,P]=NE({sourceX:e.x,sourceY:e.y,targetX:i.x,targetY:i.y});if(u[g]*c[g]===-1){C=o.x??E,_=o.y??N;const q=[{x:C,y:f.y},{x:C,y:p.y}],F=[{x:f.x,y:_},{x:p.x,y:_}];u[g]===y?w=g==="x"?q:F:w=g==="x"?F:q}else{const q=[{x:f.x,y:p.y}],F=[{x:p.x,y:f.y}];if(g==="x"?w=u.x===y?F:q:w=u.y===y?q:F,n===s){const Z=Math.abs(e[g]-i[g]);if(Z<=l){const A=Math.min(l-1,l-Z);u[g]===y?S[g]=(f[g]>e[g]?-1:1)*A:b[g]=(p[g]>i[g]?-1:1)*A}}if(n!==s){const Z=g==="x"?"y":"x",A=u[g]===c[Z],H=f[Z]>p[Z],U=f[Z]<p[Z];(u[g]===1&&(!A&&H||A&&U)||u[g]!==1&&(!A&&U||A&&H))&&(w=g==="x"?q:F)}const T={x:f.x+S.x,y:f.y+S.y},M={x:p.x+b.x,y:p.y+b.y},B=Math.max(Math.abs(T.x-w[0].x),Math.abs(M.x-w[0].x)),J=Math.max(Math.abs(T.y-w[0].y),Math.abs(M.y-w[0].y));B>=J?(C=(T.x+M.x)/2,_=w[0].y):(C=w[0].x,_=(T.y+M.y)/2)}return[[e,{x:f.x+S.x,y:f.y+S.y},...w,{x:p.x+b.x,y:p.y+b.y},i],C,_,j,P]}function cI(e,n,i,s){const o=Math.min(Rw(e,n)/2,Rw(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 p=e.x<i.x?-1:1,h=e.y<i.y?1:-1;return`L ${l+o*p},${u}Q ${l},${u} ${l},${u+o*h}`}const c=e.x<i.x?1:-1,f=e.y<i.y?-1:1;return`L ${l},${u+o*f}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:f,offset:p=20}){const[h,g,y,w,C]=uI({source:{x:e,y:n},sourcePosition:i,target:{x:s,y:o},targetPosition:l,center:{x:c,y:f},offset:p});return[h.reduce((S,b,E)=>{let N="";return E>0&&E<h.length-1?N=cI(h[E-1],b,h[E+1],u):N=`${E===0?"M":"L"}${b.x} ${b.y}`,S+=N,S},""),g,y,w,C]}const Yl=I.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:p,style:h,sourcePosition:g=Ce.Bottom,targetPosition:y=Ce.Top,markerEnd:w,markerStart:C,pathOptions:_,interactionWidth:S})=>{const[b,E,N]=qg({sourceX:e,sourceY:n,sourcePosition:g,targetX:i,targetY:s,targetPosition:y,borderRadius:_==null?void 0:_.borderRadius,offset:_==null?void 0:_.offset});return le.createElement(ia,{path:b,labelX:E,labelY:N,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:p,style:h,markerEnd:w,markerStart:C,interactionWidth:S})});Yl.displayName="SmoothStepEdge";const ov=I.memo(e=>{var n;return le.createElement(Yl,{...e,pathOptions:I.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 dI({sourceX:e,sourceY:n,targetX:i,targetY:s}){const[o,l,u,c]=NE({sourceX:e,sourceY:n,targetX:i,targetY:s});return[`M ${e},${n}L ${i},${s}`,o,l,u,c]}const av=I.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:p,style:h,markerEnd:g,markerStart:y,interactionWidth:w})=>{const[C,_,S]=dI({sourceX:e,sourceY:n,targetX:i,targetY:s});return le.createElement(ia,{path:C,labelX:_,labelY:S,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:p,style:h,markerEnd:g,markerStart:y,interactionWidth:w})});av.displayName="StraightEdge";function yl(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-yl(n-s,l),i];case Ce.Right:return[n+yl(s-n,l),i];case Ce.Top:return[n,i-yl(i-o,l)];case Ce.Bottom:return[n,i+yl(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,f]=Aw({pos:i,x1:e,y1:n,x2:s,y2:o,c:u}),[p,h]=Aw({pos:l,x1:s,y1:o,x2:e,y2:n,c:u}),[g,y,w,C]=CE({sourceX:e,sourceY:n,targetX:s,targetY:o,sourceControlX:c,sourceControlY:f,targetControlX:p,targetControlY:h});return[`M${e},${n} C${c},${f} ${p},${h} ${s},${o}`,g,y,w,C]}const Fl=I.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,sourcePosition:o=Ce.Bottom,targetPosition:l=Ce.Top,label:u,labelStyle:c,labelShowBg:f,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:g,style:y,markerEnd:w,markerStart:C,pathOptions:_,interactionWidth:S})=>{const[b,E,N]=TE({sourceX:e,sourceY:n,sourcePosition:o,targetX:i,targetY:s,targetPosition:l,curvature:_==null?void 0:_.curvature});return le.createElement(ia,{path:b,labelX:E,labelY:N,label:u,labelStyle:c,labelShowBg:f,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:g,style:y,markerEnd:w,markerStart:C,interactionWidth:S})});Fl.displayName="BezierEdge";const lv=I.createContext(null),fI=lv.Provider;lv.Consumer;const hI=()=>I.useContext(lv),pI=e=>"id"in e&&"source"in e&&"target"in e,mI=({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("&")}`,gI=(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)),vI=(e,n)=>{if(!e.source||!e.target)return n;let i;return pI(e)?i={...e}:i={...e,id:mI(e)},gI(i,n)?n:n.concat(i)},$g=({x:e,y:n},[i,s,o],l,[u,c])=>{const f={x:(e-i)/o,y:(n-s)/o};return l?{x:u*Math.round(f.x/u),y:c*Math.round(f.y/c)}:f},RE=({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}},Xl=(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 SE(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 bE(i)},AE=(e,n,[i,s,o]=[0,0,1],l=!1,u=!1,c=[0,0])=>{const f={x:(n.x-i)/o,y:(n.y-s)/o,width:n.width/o,height:n.height/o},p=[];return e.forEach(h=>{const{width:g,height:y,selectable:w=!0,hidden:C=!1}=h;if(u&&!w||C)return!1;const{positionAbsolute:_}=Yi(h,c),S={x:_.x,y:_.y,width:g||0,height:y||0},b=Pg(f,S),E=typeof g>"u"||typeof y>"u"||g===null||y===null,N=l&&b>0,j=(g||0)*(y||0);(E||N||b>=j||h.dragging)&&p.push(h)}),p},IE=(e,n)=>{const i=e.map(s=>s.id);return n.filter(s=>i.includes(s.source)||i.includes(s.target))},ME=(e,n,i,s,o,l=.1)=>{const u=n/(e.width*(1+l)),c=i/(e.height*(1+l)),f=Math.min(u,c),p=Hs(f,s,o),h=e.x+e.width/2,g=e.y+e.height/2,y=n/2-h*p,w=i/2-g*p;return{x:y,y:w,zoom:p}},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 yI(e,n,i,s,o,l){const{x:u,y:c}=mi(e),p=n.elementsFromPoint(u,c).find(C=>C.classList.contains("react-flow__handle"));if(p){const C=p.getAttribute("data-nodeid");if(C){const _=uv(void 0,p),S=p.getAttribute("data-handleid"),b=l({nodeId:C,id:S,type:_});if(b){const E=o.find(N=>N.nodeId===C&&N.type===_&&N.id===S);return{handle:{id:S,type:_,nodeId:C,x:(E==null?void 0:E.x)||i.x,y:(E==null?void 0:E.y)||i.y},validHandleResult:b}}}}let h=[],g=1/0;if(o.forEach(C=>{const _=Math.sqrt((C.x-i.x)**2+(C.y-i.y)**2);if(_<=s){const S=l(C);_<=g&&(_<g?h=[{handle:C,validHandleResult:S}]:_===g&&h.push({handle:C,validHandleResult:S}),g=_)}}),!h.length)return{handle:null,validHandleResult:PE()};if(h.length===1)return h[0];const y=h.some(({validHandleResult:C})=>C.isValid),w=h.some(({handle:C})=>C.type==="target");return h.find(({handle:C,validHandleResult:_})=>w?C.type==="target":y?_.isValid:!0)||h[0]}const wI={source:null,target:null,sourceHandle:null,targetHandle:null},PE=()=>({handleDomNode:null,isValid:!1,connection:wI,endHandle:null});function OE(e,n,i,s,o,l,u){const c=o==="target",f=u.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),p={...PE(),handleDomNode:f};if(f){const h=uv(void 0,f),g=f.getAttribute("data-nodeid"),y=f.getAttribute("data-handleid"),w=f.classList.contains("connectable"),C=f.classList.contains("connectableend"),_={source:c?g:i,sourceHandle:c?y:s,target:c?i:g,targetHandle:c?s:y};p.connection=_,w&&C&&(n===Zi.Strict?c&&h==="source"||!c&&h==="target":g!==i||y!==s)&&(p.endHandle={nodeId:g,handleId:y,type:h},p.isValid=l(_))}return p}function xI({nodes:e,nodeId:n,handleId:i,handleType:s}){return e.reduce((o,l)=>{if(l[ht]){const{handleBounds:u}=l[ht];let c=[],f=[];u&&(c=Iw(l,u,"source",`${n}-${i}-${s}`),f=Iw(l,u,"target",`${n}-${i}-${s}`)),o.push(...c,...f)}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 _I(e,n){let i=null;return n?i="valid":e&&!n&&(i="invalid"),i}function qE({event:e,handleId:n,nodeId:i,onConnect:s,isTarget:o,getState:l,setState:u,isValidConnection:c,edgeUpdaterType:f,onReconnectEnd:p}){const h=_E(e.target),{connectionMode:g,domNode:y,autoPanOnConnect:w,connectionRadius:C,onConnectStart:_,panBy:S,getNodes:b,cancelConnection:E}=l();let N=0,j;const{x:P,y:O}=mi(e),q=h==null?void 0:h.elementFromPoint(P,O),F=uv(f,q),T=y==null?void 0:y.getBoundingClientRect();if(!T||!F)return;let M,B=mi(e,T),J=!1,Z=null,A=!1,H=null;const U=xI({nodes:b(),nodeId:i,handleId:n,handleType:F}),ne=()=>{if(!w)return;const[G,k]=xE(B,T);S({x:G,y:k}),N=requestAnimationFrame(ne)};u({connectionPosition:B,connectionStatus:null,connectionNodeId:i,connectionHandleId:n,connectionHandleType:F,connectionStartHandle:{nodeId:i,handleId:n,type:F},connectionEndHandle:null}),_==null||_(e,{nodeId:i,handleId:n,handleType:F});function Q(G){const{transform:k}=l();B=mi(G,T);const{handle:L,validHandleResult:oe}=yI(G,h,$g(B,k,!1,[1,1]),C,U,$=>OE($,g,i,n,o?"target":"source",c,h));if(j=L,J||(ne(),J=!0),H=oe.handleDomNode,Z=oe.connection,A=oe.isValid,u({connectionPosition:j&&A?RE({x:j.x,y:j.y},k):B,connectionStatus:_I(!!j,A),connectionEndHandle:oe.endHandle}),!j&&!A&&!H)return Jc(M);Z.source!==Z.target&&H&&(Jc(M),M=H,H.classList.add("connecting","react-flow__handle-connecting"),H.classList.toggle("valid",A),H.classList.toggle("react-flow__handle-valid",A))}function D(G){var k,L;(j||H)&&Z&&A&&(s==null||s(Z)),(L=(k=l()).onConnectEnd)==null||L.call(k,G),f&&(p==null||p(G)),Jc(M),E(),cancelAnimationFrame(N),J=!1,A=!1,Z=null,H=null,h.removeEventListener("mousemove",Q),h.removeEventListener("mouseup",D),h.removeEventListener("touchmove",Q),h.removeEventListener("touchend",D)}h.addEventListener("mousemove",Q),h.addEventListener("mouseup",D),h.addEventListener("touchmove",Q),h.addEventListener("touchend",D)}const Mw=()=>!0,SI=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),bI=(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}},LE=I.forwardRef(({type:e="source",position:n=Ce.Top,isValidConnection:i,isConnectable:s=!0,isConnectableStart:o=!0,isConnectableEnd:l=!0,id:u,onConnect:c,children:f,className:p,onMouseDown:h,onTouchStart:g,...y},w)=>{var T,M;const C=u||null,_=e==="target",S=jt(),b=hI(),{connectOnClick:E,noPanClassName:N}=Xe(SI,Ct),{connecting:j,clickConnecting:P}=Xe(bI(b,C,e),Ct);b||(M=(T=S.getState()).onError)==null||M.call(T,"010",Or.error010());const O=B=>{const{defaultEdgeOptions:J,onConnect:Z,hasDefaultEdges:A}=S.getState(),H={...J,...B};if(A){const{edges:U,setEdges:ne}=S.getState();ne(vI(H,U))}Z==null||Z(H),c==null||c(H)},q=B=>{if(!b)return;const J=EE(B);o&&(J&&B.button===0||!J)&&qE({event:B,handleId:C,nodeId:b,onConnect:O,isTarget:_,getState:S.getState,setState:S.setState,isValidConnection:i||S.getState().isValidConnection||Mw}),J?h==null||h(B):g==null||g(B)},F=B=>{const{onClickConnectStart:J,onClickConnectEnd:Z,connectionClickStartHandle:A,connectionMode:H,isValidConnection:U}=S.getState();if(!b||!A&&!o)return;if(!A){J==null||J(B,{nodeId:b,handleId:C,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:b,type:e,handleId:C}});return}const ne=_E(B.target),Q=i||U||Mw,{connection:D,isValid:G}=OE({nodeId:b,id:C,type:e},H,A.nodeId,A.handleId||null,A.type,Q,ne);G&&O(D),Z==null||Z(B),S.setState({connectionClickStartHandle:null})};return le.createElement("div",{"data-handleid":C,"data-nodeid":b,"data-handlepos":n,"data-id":`${b}-${C}-${e}`,className:Ft(["react-flow__handle",`react-flow__handle-${n}`,"nodrag",N,p,{source:!_,target:_,connectable:s,connectablestart:o,connectableend:l,connecting:P,connectionindicator:s&&(o&&!j||l&&j)}]),onMouseDown:q,onTouchStart:q,onClick:E?F:void 0,ref:w,...y},f)});LE.displayName="Handle";var Vs=I.memo(LE);const $E=({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}));$E.displayName="DefaultNode";var Dg=I.memo($E);const DE=({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}));DE.displayName="InputNode";var FE=I.memo(DE);const zE=({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);zE.displayName="OutputNode";var BE=I.memo(zE);const cv=()=>null;cv.displayName="GroupNode";const kI=e=>({selectedNodes:e.getNodes().filter(n=>n.selected),selectedEdges:e.edges.filter(n=>n.selected).map(n=>({...n}))}),wl=e=>e.id;function EI(e,n){return Ct(e.selectedNodes.map(wl),n.selectedNodes.map(wl))&&Ct(e.selectedEdges.map(wl),n.selectedEdges.map(wl))}const UE=I.memo(({onSelectionChange:e})=>{const n=jt(),{selectedNodes:i,selectedEdges:s}=Xe(kI,EI);return I.useEffect(()=>{const o={nodes:i,edges:s};e==null||e(o),n.getState().onSelectionChange.forEach(l=>l(o))},[i,s,e]),null});UE.displayName="SelectionListener";const NI=e=>!!e.onSelectionChange;function CI({onSelectionChange:e}){const n=Xe(NI);return e||n?le.createElement(UE,{onSelectionChange:e}):null}const jI=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 Rs(e,n){I.useEffect(()=>{typeof e<"u"&&n(e)},[e])}function Le(e,n,i){I.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:f,nodesDraggable:p,nodesConnectable:h,nodesFocusable:g,edgesFocusable:y,edgesUpdatable:w,elevateNodesOnSelect:C,minZoom:_,maxZoom:S,nodeExtent:b,onNodesChange:E,onEdgesChange:N,elementsSelectable:j,connectionMode:P,snapGrid:O,snapToGrid:q,translateExtent:F,connectOnClick:T,defaultEdgeOptions:M,fitView:B,fitViewOptions:J,onNodesDelete:Z,onEdgesDelete:A,onNodeDrag:H,onNodeDragStart:U,onNodeDragStop:ne,onSelectionDrag:Q,onSelectionDragStart:D,onSelectionDragStop:G,noPanClassName:k,nodeOrigin:L,rfId:oe,autoPanOnConnect:$,autoPanOnNodeDrag:Y,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(jI,Ct),ye=jt();return I.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",f,ye.setState),Le("nodesDraggable",p,ye.setState),Le("nodesConnectable",h,ye.setState),Le("nodesFocusable",g,ye.setState),Le("edgesFocusable",y,ye.setState),Le("edgesUpdatable",w,ye.setState),Le("elementsSelectable",j,ye.setState),Le("elevateNodesOnSelect",C,ye.setState),Le("snapToGrid",q,ye.setState),Le("snapGrid",O,ye.setState),Le("onNodesChange",E,ye.setState),Le("onEdgesChange",N,ye.setState),Le("connectOnClick",T,ye.setState),Le("fitViewOnInit",B,ye.setState),Le("fitViewOnInitOptions",J,ye.setState),Le("onNodesDelete",Z,ye.setState),Le("onEdgesDelete",A,ye.setState),Le("onNodeDrag",H,ye.setState),Le("onNodeDragStart",U,ye.setState),Le("onNodeDragStop",ne,ye.setState),Le("onSelectionDrag",Q,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",Y,ye.setState),Le("onError",ee,ye.setState),Le("connectionRadius",se,ye.setState),Le("isValidConnection",ae,ye.setState),Le("nodeDragThreshold",pe,ye.setState),Rs(e,ge),Rs(n,Ae),Rs(_,Me),Rs(S,Pe),Rs(F,ke),Rs(b,We),null},Pw={display:"none"},RI={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},HE="react-flow__node-desc",VE="react-flow__edge-desc",AI="react-flow__aria-live",II=e=>e.ariaLiveMessage;function MI({rfId:e}){const n=Xe(II);return le.createElement("div",{id:`${AI}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:RI},n)}function PI({rfId:e,disableKeyboardA11y:n}){return le.createElement(le.Fragment,null,le.createElement("div",{id:`${HE}-${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:`${VE}-${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(MI,{rfId:e}))}var ea=(e=null,n={actInsideInputWithModifier:!0})=>{const[i,s]=I.useState(!1),o=I.useRef(!1),l=I.useRef(new Set([])),[u,c]=I.useMemo(()=>{if(e!==null){const p=(Array.isArray(e)?e:[e]).filter(g=>typeof g=="string").map(g=>g.split("+")),h=p.reduce((g,y)=>g.concat(...y),[]);return[p,h]}return[[],[]]},[e]);return I.useEffect(()=>{const f=typeof document<"u"?document:null,p=(n==null?void 0:n.target)||f;if(e!==null){const h=w=>{if(o.current=w.ctrlKey||w.metaKey||w.shiftKey,(!o.current||o.current&&!n.actInsideInputWithModifier)&&Og(w))return!1;const _=qw(w.code,c);l.current.add(w[_]),Ow(u,l.current,!1)&&(w.preventDefault(),s(!0))},g=w=>{if((!o.current||o.current&&!n.actInsideInputWithModifier)&&Og(w))return!1;const _=qw(w.code,c);Ow(u,l.current,!0)?(s(!1),l.current.clear()):l.current.delete(w[_]),w.key==="Meta"&&l.current.clear(),o.current=!1},y=()=>{l.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",h),p==null||p.addEventListener("keyup",g),window.addEventListener("blur",y),()=>{p==null||p.removeEventListener("keydown",h),p==null||p.removeEventListener("keyup",g),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 WE(e,n,i,s){var c,f;const o=e.parentNode||e.parentId;if(!o)return i;const l=n.get(o),u=Yi(l,s);return WE(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)?((f=l[ht])==null?void 0:f.z)??0:i.z??0},s)}function GE(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:f}=WE(s,e,{...s.position,z:((l=s[ht])==null?void 0:l.z)??0},n);s.positionAbsolute={x:u,y:c},s[ht].z=f,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 w;const f=(Pn(c.zIndex)?c.zIndex:0)+(c.selected?u:0),p=n.get(c.id),h={...c,positionAbsolute:{x:c.position.x,y:c.position.y}},g=c.parentNode||c.parentId;g&&(l[g]=!0);const y=(p==null?void 0:p.type)&&(p==null?void 0:p.type)!==c.type;Object.defineProperty(h,ht,{enumerable:!1,value:{handleBounds:y||(w=p==null?void 0:p[ht])==null?void 0:w.handleBounds,z:f}}),o.set(c.id,h)}),GE(o,i,l),o}function KE(e,n={}){const{getNodes:i,width:s,height:o,minZoom:l,maxZoom:u,d3Zoom:c,d3Selection:f,fitViewOnInitDone:p,fitViewOnInit:h,nodeOrigin:g}=e(),y=n.initial&&!p&&h;if(c&&f&&(y||!n.initial)){const C=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(N=>N.id===S.id):b}),_=C.every(S=>S.width&&S.height);if(C.length>0&&_){const S=Xl(C,g),{x:b,y:E,zoom:N}=ME(S,s,o,n.minZoom??l,n.maxZoom??u,n.padding??.1),j=Mr.translate(b,E).scale(N);return typeof n.duration=="number"&&n.duration>0?c.transform(Vi(f,n.duration),j):c.transform(f,j),!0}}return!1}function OI(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 qI(e,n){return n.map(i=>{const s=e.find(o=>o.id===i.id);return s&&(i.selected=s.selected),i})}function xl({changedNodes:e,changedEdges:n,get:i,set:s}){const{nodeInternals:o,edges:l,onNodesChange:u,onEdgesChange:c,hasDefaultNodes:f,hasDefaultEdges:p}=i();e!=null&&e.length&&(f&&s({nodeInternals:OI(e,o)}),u==null||u(e)),n!=null&&n.length&&(p&&s({edges:qI(n,l)}),c==null||c(n))}const As=()=>{},LI={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},$I=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),DI=()=>{const e=jt(),{d3Zoom:n,d3Selection:i}=Xe($I,Ct);return I.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,f]=e.getState().transform,p=Mr.translate(o.x??u,o.y??c).scale(o.zoom??f);n.transform(Vi(i,l==null?void 0:l.duration),p)},getViewport:()=>{const[o,l,u]=e.getState().transform;return{x:o,y:l,zoom:u}},fitView:o=>KE(e.getState,o),setCenter:(o,l,u)=>{const{width:c,height:f,maxZoom:p}=e.getState(),h=typeof(u==null?void 0:u.zoom)<"u"?u.zoom:p,g=c/2-o*h,y=f/2-l*h,w=Mr.translate(g,y).scale(h);n.transform(Vi(i,u==null?void 0:u.duration),w)},fitBounds:(o,l)=>{const{width:u,height:c,minZoom:f,maxZoom:p}=e.getState(),{x:h,y:g,zoom:y}=ME(o,u,c,f,p,(l==null?void 0:l.padding)??.1),w=Mr.translate(h,g).scale(y);n.transform(Vi(i,l==null?void 0:l.duration),w)},project:o=>{const{transform:l,snapToGrid:u,snapGrid:c}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),$g(o,l,u,c)},screenToFlowPosition:o=>{const{transform:l,snapToGrid:u,snapGrid:c,domNode:f}=e.getState();if(!f)return o;const{x:p,y:h}=f.getBoundingClientRect(),g={x:o.x-p,y:o.y-h};return $g(g,l,u,c)},flowToScreenPosition:o=>{const{transform:l,domNode:u}=e.getState();if(!u)return o;const{x:c,y:f}=u.getBoundingClientRect(),p=RE(o,l);return{x:p.x+c,y:p.y+f}},viewportInitialized:!0}:LI,[n,i])};function sa(){const e=DI(),n=jt(),i=I.useCallback(()=>n.getState().getNodes().map(_=>({..._})),[]),s=I.useCallback(_=>n.getState().nodeInternals.get(_),[]),o=I.useCallback(()=>{const{edges:_=[]}=n.getState();return _.map(S=>({...S}))},[]),l=I.useCallback(_=>{const{edges:S=[]}=n.getState();return S.find(b=>b.id===_)},[]),u=I.useCallback(_=>{const{getNodes:S,setNodes:b,hasDefaultNodes:E,onNodesChange:N}=n.getState(),j=S(),P=typeof _=="function"?_(j):_;if(E)b(P);else if(N){const O=P.length===0?j.map(q=>({type:"remove",id:q.id})):P.map(q=>({item:q,type:"reset"}));N(O)}},[]),c=I.useCallback(_=>{const{edges:S=[],setEdges:b,hasDefaultEdges:E,onEdgesChange:N}=n.getState(),j=typeof _=="function"?_(S):_;if(E)b(j);else if(N){const P=j.length===0?S.map(O=>({type:"remove",id:O.id})):j.map(O=>({item:O,type:"reset"}));N(P)}},[]),f=I.useCallback(_=>{const S=Array.isArray(_)?_:[_],{getNodes:b,setNodes:E,hasDefaultNodes:N,onNodesChange:j}=n.getState();if(N){const O=[...b(),...S];E(O)}else if(j){const P=S.map(O=>({item:O,type:"add"}));j(P)}},[]),p=I.useCallback(_=>{const S=Array.isArray(_)?_:[_],{edges:b=[],setEdges:E,hasDefaultEdges:N,onEdgesChange:j}=n.getState();if(N)E([...b,...S]);else if(j){const P=S.map(O=>({item:O,type:"add"}));j(P)}},[]),h=I.useCallback(()=>{const{getNodes:_,edges:S=[],transform:b}=n.getState(),[E,N,j]=b;return{nodes:_().map(P=>({...P})),edges:S.map(P=>({...P})),viewport:{x:E,y:N,zoom:j}}},[]),g=I.useCallback(({nodes:_,edges:S})=>{const{nodeInternals:b,getNodes:E,edges:N,hasDefaultNodes:j,hasDefaultEdges:P,onNodesDelete:O,onEdgesDelete:q,onNodesChange:F,onEdgesChange:T}=n.getState(),M=(_||[]).map(H=>H.id),B=(S||[]).map(H=>H.id),J=E().reduce((H,U)=>{const ne=U.parentNode||U.parentId,Q=!M.includes(U.id)&&ne&&H.find(G=>G.id===ne);return(typeof U.deletable=="boolean"?U.deletable:!0)&&(M.includes(U.id)||Q)&&H.push(U),H},[]),Z=N.filter(H=>typeof H.deletable=="boolean"?H.deletable:!0),A=Z.filter(H=>B.includes(H.id));if(J||A){const H=IE(J,Z),U=[...A,...H],ne=U.reduce((Q,D)=>(Q.includes(D.id)||Q.push(D.id),Q),[]);if((P||j)&&(P&&n.setState({edges:N.filter(Q=>!ne.includes(Q.id))}),j&&(J.forEach(Q=>{b.delete(Q.id)}),n.setState({nodeInternals:new Map(b)}))),ne.length>0&&(q==null||q(U),T&&T(ne.map(Q=>({id:Q,type:"remove"})))),J.length>0&&(O==null||O(J),F)){const Q=J.map(D=>({id:D.id,type:"remove"}));F(Q)}}},[]),y=I.useCallback(_=>{const S=sI(_),b=S?null:n.getState().nodeInternals.get(_.id);return!S&&!b?[null,null,S]:[S?_:Cw(b),b,S]},[]),w=I.useCallback((_,S=!0,b)=>{const[E,N,j]=y(_);return E?(b||n.getState().getNodes()).filter(P=>{if(!j&&(P.id===N.id||!P.positionAbsolute))return!1;const O=Cw(P),q=Pg(O,E);return S&&q>0||q>=E.width*E.height}):[]},[]),C=I.useCallback((_,S,b=!0)=>{const[E]=y(_);if(!E)return!1;const N=Pg(E,S);return b&&N>0||N>=E.width*E.height},[]);return I.useMemo(()=>({...e,getNodes:i,getNode:s,getEdges:o,getEdge:l,setNodes:u,setEdges:c,addNodes:f,addEdges:p,toObject:h,deleteElements:g,getIntersectingNodes:w,isNodeIntersecting:C}),[e,i,s,o,l,u,c,f,p,h,g,w,C])}const FI={actInsideInputWithModifier:!1};var zI=({deleteKeyCode:e,multiSelectionKeyCode:n})=>{const i=jt(),{deleteElements:s}=sa(),o=ea(e,FI),l=ea(n);I.useEffect(()=>{if(o){const{edges:u,getNodes:c}=i.getState(),f=c().filter(h=>h.selected),p=u.filter(h=>h.selected);s({nodes:f,edges:p}),i.setState({nodesSelectionActive:!1})}},[o]),I.useEffect(()=>{i.setState({multiSelectionActive:l})},[l])};function BI(e){const n=jt();I.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},UI=(e,n)=>e.x!==n.x||e.y!==n.y||e.zoom!==n.k,_l=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&&$l()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n},HI=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),VI=({onMove:e,onMoveStart:n,onMoveEnd:i,onPaneContextMenu:s,zoomOnScroll:o=!0,zoomOnPinch:l=!0,panOnScroll:u=!1,panOnScrollSpeed:c=.5,panOnScrollMode:f=Gi.Free,zoomOnDoubleClick:p=!0,elementsSelectable:h,panOnDrag:g=!0,defaultViewport:y,translateExtent:w,minZoom:C,maxZoom:_,zoomActivationKeyCode:S,preventScrolling:b=!0,children:E,noWheelClassName:N,noPanClassName:j})=>{const P=I.useRef(),O=jt(),q=I.useRef(!1),F=I.useRef(!1),T=I.useRef(null),M=I.useRef({x:0,y:0,zoom:0}),{d3Zoom:B,d3Selection:J,d3ZoomHandler:Z,userSelectionActive:A}=Xe(HI,Ct),H=ea(S),U=I.useRef(0),ne=I.useRef(!1),Q=I.useRef();return BI(T),I.useEffect(()=>{if(T.current){const D=T.current.getBoundingClientRect(),G=yE().scaleExtent([C,_]).translateExtent(w),k=Mn(T.current).call(G),L=Mr.translate(y.x,y.y).scale(Hs(y.zoom,C,_)),oe=[[0,0],[D.width,D.height]],$=G.constrain()(L,oe,w);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")})}},[]),I.useEffect(()=>{J&&B&&(u&&!H&&!A?J.on("wheel.zoom",D=>{if(Is(D,N))return!1;D.preventDefault(),D.stopImmediatePropagation();const G=J.property("__zoom").k||1;if(D.ctrlKey&&l){const ae=Kn(D),pe=$w(D),ge=G*Math.pow(2,pe);B.scaleTo(J,ge,ae,D);return}const k=D.deltaMode===1?20:1;let L=f===Gi.Vertical?0:D.deltaX*k,oe=f===Gi.Horizontal?0:D.deltaY*k;!$l()&&D.shiftKey&&f!==Gi.Vertical&&(L=D.deltaY*k,oe=0),B.translateBy(J,-(L/G)*c,-(oe/G)*c,{internal:!0});const $=_l(J.property("__zoom")),{onViewportChangeStart:Y,onViewportChange:ee,onViewportChangeEnd:se}=O.getState();clearTimeout(Q.current),ne.current||(ne.current=!0,n==null||n(D,$),Y==null||Y($)),ne.current&&(e==null||e(D,$),ee==null||ee($),Q.current=setTimeout(()=>{i==null||i(D,$),se==null||se($),ne.current=!1},150))},{passive:!1}):typeof Z<"u"&&J.on("wheel.zoom",function(D,G){if(!b&&D.type==="wheel"&&!D.ctrlKey||Is(D,N))return null;D.preventDefault(),Z.call(this,D,G)},{passive:!1}))},[A,u,f,J,B,Z,H,l,b,N,n,e,i]),I.useEffect(()=>{B&&B.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=_l(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)})},[B,n]),I.useEffect(()=>{B&&(A&&!q.current?B.on("zoom",null):A||B.on("zoom",D=>{var k;const{onViewportChange:G}=O.getState();if(O.setState({transform:[D.transform.x,D.transform.y,D.transform.k]}),F.current=!!(s&&Lw(g,U.current??0)),(e||G)&&!((k=D.sourceEvent)!=null&&k.internal)){const L=_l(D.transform);G==null||G(L),e==null||e(D.sourceEvent,L)}}))},[A,B,e,g,s]),I.useEffect(()=>{B&&B.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(g,U.current??0)&&!F.current&&s(D.sourceEvent),F.current=!1,(i||G)&&UI(M.current,D.transform)){const k=_l(D.transform);M.current=k,clearTimeout(P.current),P.current=setTimeout(()=>{G==null||G(k),i==null||i(D.sourceEvent,k)},u?150:0)}})},[B,u,g,i,s]),I.useEffect(()=>{B&&B.filter(D=>{const G=H||o,k=l&&D.ctrlKey;if((g===!0||Array.isArray(g)&&g.includes(1))&&D.button===1&&D.type==="mousedown"&&(Is(D,"react-flow__node")||Is(D,"react-flow__edge")))return!0;if(!g&&!G&&!u&&!p&&!l||A||!p&&D.type==="dblclick"||Is(D,N)&&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"||!g&&(D.type==="mousedown"||D.type==="touchstart")||Array.isArray(g)&&!g.includes(D.button)&&D.type==="mousedown")return!1;const L=Array.isArray(g)&&g.includes(D.button)||!D.button||D.button<=1;return(!D.ctrlKey||D.type==="wheel")&&L})},[A,B,o,l,u,p,g,h,H]),le.createElement("div",{className:"react-flow__renderer",ref:T,style:dv},E)},WI=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function GI(){const{userSelectionActive:e,userSelectionRect:n}=Xe(WI,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 KI(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 YI(e,n){return KI(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))},XI=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),YE=I.memo(({isSelecting:e,selectionMode:n=Jo.Full,panOnDrag:i,onSelectionStart:s,onSelectionEnd:o,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:c,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:h,children:g})=>{const y=I.useRef(null),w=jt(),C=I.useRef(0),_=I.useRef(0),S=I.useRef(),{userSelectionActive:b,elementsSelectable:E,dragging:N}=Xe(XI,Ct),j=()=>{w.setState({userSelectionActive:!1,userSelectionRect:null}),C.current=0,_.current=0},P=Z=>{l==null||l(Z),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},O=Z=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){Z.preventDefault();return}u==null||u(Z)},q=c?Z=>c(Z):void 0,F=Z=>{const{resetSelectedElements:A,domNode:H}=w.getState();if(S.current=H==null?void 0:H.getBoundingClientRect(),!E||!e||Z.button!==0||Z.target!==y.current||!S.current)return;const{x:U,y:ne}=mi(Z,S.current);A(),w.setState({userSelectionRect:{width:0,height:0,startX:U,startY:ne,x:U,y:ne}}),s==null||s(Z)},T=Z=>{const{userSelectionRect:A,nodeInternals:H,edges:U,transform:ne,onNodesChange:Q,onEdgesChange:D,nodeOrigin:G,getNodes:k}=w.getState();if(!e||!S.current||!A)return;w.setState({userSelectionActive:!0,nodesSelectionActive:!1});const L=mi(Z,S.current),oe=A.startX??0,$=A.startY??0,Y={...A,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=AE(H,Y,ne,n===Jo.Partial,!0,G),ae=IE(se,U).map(ge=>ge.id),pe=se.map(ge=>ge.id);if(C.current!==pe.length){C.current=pe.length;const ge=qs(ee,pe);ge.length&&(Q==null||Q(ge))}if(_.current!==ae.length){_.current=ae.length;const ge=qs(U,ae);ge.length&&(D==null||D(ge))}w.setState({userSelectionRect:Y})},M=Z=>{if(Z.button!==0)return;const{userSelectionRect:A}=w.getState();!b&&A&&Z.target===y.current&&(P==null||P(Z)),w.setState({nodesSelectionActive:C.current>0}),j(),o==null||o(Z)},B=Z=>{b&&(w.setState({nodesSelectionActive:C.current>0}),o==null||o(Z)),j()},J=E&&(e||b);return le.createElement("div",{className:Ft(["react-flow__pane",{dragging:N,selection:e}]),onClick:J?void 0:td(P,y),onContextMenu:td(O,y),onWheel:td(q,y),onMouseEnter:J?void 0:f,onMouseDown:J?F:void 0,onMouseMove:J?T:p,onMouseUp:J?M:void 0,onMouseLeave:J?B:h,ref:y,style:dv},g,le.createElement(GI,null))});YE.displayName="Pane";function XE(e,n){const i=e.parentNode||e.parentId;if(!i)return!1;const s=n.get(i);return s?s.selected?!0:XE(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 QI(e,n,i,s){return Array.from(e.values()).filter(o=>(o.selected||o.id===s)&&(!o.parentNode||o.parentId||!XE(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 ZI(e,n){return!n||n==="parent"?n:[n[0],[n[1][0]-(e.width||0),n[1][1]-(e.height||0)]]}function QE(e,n,i,s,o=[0,0],l){const u=ZI(e,e.extent||s);let c=u;const f=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(f&&e.width&&e.height){const g=i.get(f),{x:y,y:w}=Yi(g,o).positionAbsolute;c=g&&Pn(y)&&Pn(w)&&Pn(g.width)&&Pn(g.height)?[[y+e.width*o[0],w+e.height*o[1]],[y+g.width-e.width+e.width*o[0],w+g.height-e.height+e.height*o[1]]]:c}else l==null||l("005",Or.error005()),c=u;else if(e.extent&&f&&e.extent!=="parent"){const g=i.get(f),{x:y,y:w}=Yi(g,o).positionAbsolute;c=[[e.extent[0][0]+y,e.extent[0][1]+w],[e.extent[1][0]+y,e.extent[1][1]+w]]}let p={x:0,y:0};if(f){const g=i.get(f);p=Yi(g,o).positionAbsolute}const h=c&&c!=="parent"?iv(n,c):n;return{position:{x:h.x-p.x,y:h.y-p.y},positionAbsolute:h}}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(f=>{const p=f.getBoundingClientRect();return{id:f.getAttribute("data-handleid"),position:f.getAttribute("data-handlepos"),x:(p.left-u.left-c.x)/i,y:(p.top-u.top-c.y)/i,...rv(f)}})};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:f}=n.getState(),p=c.get(e);if(!p){f==null||f("012",Or.error012(e));return}n.setState({nodesSelectionActive:!1}),p.selected?(i||p.selected&&u)&&(l({nodes:[p],edges:[]}),requestAnimationFrame(()=>{var h;return(h=s==null?void 0:s.current)==null?void 0:h.blur()})):o([e])}function JI(){const e=jt();return I.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,f={x:(u-s[0])/s[2],y:(c-s[1])/s[2]};return{xSnapped:l?o[0]*Math.round(f.x/o[0]):f.x,ySnapped:l?o[1]*Math.round(f.y/o[1]):f.y,...f}},[])}function rd(e){return(n,i,s)=>e==null?void 0:e(n,s)}function ZE({nodeRef:e,disabled:n=!1,noDragClassName:i,handleSelector:s,nodeId:o,isSelectable:l,selectNodesOnDrag:u}){const c=jt(),[f,p]=I.useState(!1),h=I.useRef([]),g=I.useRef({x:null,y:null}),y=I.useRef(0),w=I.useRef(null),C=I.useRef({x:0,y:0}),_=I.useRef(null),S=I.useRef(!1),b=I.useRef(!1),E=I.useRef(!1),N=JI();return I.useEffect(()=>{if(e!=null&&e.current){const j=Mn(e.current),P=({x:F,y:T})=>{const{nodeInternals:M,onNodeDrag:B,onSelectionDrag:J,updateNodePositions:Z,nodeExtent:A,snapGrid:H,snapToGrid:U,nodeOrigin:ne,onError:Q}=c.getState();g.current={x:F,y:T};let D=!1,G={x:0,y:0,x2:0,y2:0};if(h.current.length>1&&A){const L=Xl(h.current,ne);G=Zo(L)}if(h.current=h.current.map(L=>{const oe={x:F-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 $=[[A[0][0],A[0][1]],[A[1][0],A[1][1]]];h.current.length>1&&A&&!L.extent&&($[0][0]=L.positionAbsolute.x-G.x+A[0][0],$[1][0]=L.positionAbsolute.x+(L.width??0)-G.x2+A[1][0],$[0][1]=L.positionAbsolute.y-G.y+A[0][1],$[1][1]=L.positionAbsolute.y+(L.height??0)-G.y2+A[1][1]);const Y=QE(L,oe,M,$,ne,Q);return D=D||L.position.x!==Y.position.x||L.position.y!==Y.position.y,L.position=Y.position,L.positionAbsolute=Y.positionAbsolute,L}),!D)return;Z(h.current,!0,!0),p(!0);const k=o?B:rd(J);if(k&&_.current){const[L,oe]=nd({nodeId:o,dragItems:h.current,nodeInternals:M});k(_.current,L,oe)}},O=()=>{if(!w.current)return;const[F,T]=xE(C.current,w.current);if(F!==0||T!==0){const{transform:M,panBy:B}=c.getState();g.current.x=(g.current.x??0)-F/M[2],g.current.y=(g.current.y??0)-T/M[2],B({x:F,y:T})&&P(g.current)}y.current=requestAnimationFrame(O)},q=F=>{var ne;const{nodeInternals:T,multiSelectionActive:M,nodesDraggable:B,unselectNodesAndEdges:J,onNodeDragStart:Z,onSelectionDragStart:A}=c.getState();b.current=!0;const H=o?Z:rd(A);(!u||!l)&&!M&&o&&((ne=T.get(o))!=null&&ne.selected||J()),o&&l&&u&&Fg({id:o,store:c,nodeRef:e});const U=N(F);if(g.current=U,h.current=QI(T,B,U,o),H&&h.current){const[Q,D]=nd({nodeId:o,dragItems:h.current,nodeInternals:T});H(F.sourceEvent,Q,D)}};if(n)j.on(".drag",null);else{const F=l2().on("start",T=>{const{domNode:M,nodeDragThreshold:B}=c.getState();B===0&&q(T),E.current=!1;const J=N(T);g.current=J,w.current=(M==null?void 0:M.getBoundingClientRect())||null,C.current=mi(T.sourceEvent,w.current)}).on("drag",T=>{var Z,A;const M=N(T),{autoPanOnNodeDrag:B,nodeDragThreshold:J}=c.getState();if(T.sourceEvent.type==="touchmove"&&T.sourceEvent.touches.length>1&&(E.current=!0),!E.current){if(!S.current&&b.current&&B&&(S.current=!0,O()),!b.current){const H=M.xSnapped-(((Z=g==null?void 0:g.current)==null?void 0:Z.x)??0),U=M.ySnapped-(((A=g==null?void 0:g.current)==null?void 0:A.y)??0);Math.sqrt(H*H+U*U)>J&&q(T)}(g.current.x!==M.xSnapped||g.current.y!==M.ySnapped)&&h.current&&b.current&&(_.current=T.sourceEvent,C.current=mi(T.sourceEvent,w.current),P(M))}}).on("end",T=>{if(!(!b.current||E.current)&&(p(!1),S.current=!1,b.current=!1,cancelAnimationFrame(y.current),h.current)){const{updateNodePositions:M,nodeInternals:B,onNodeDragStop:J,onSelectionDragStop:Z}=c.getState(),A=o?J:rd(Z);if(M(h.current,!1,!1),A){const[H,U]=nd({nodeId:o,dragItems:h.current,nodeInternals:B});A(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(F),()=>{j.on(".drag",null)}}}},[e,n,i,s,l,c,o,u,N]),f}function JE(){const e=jt();return I.useCallback(i=>{const{nodeInternals:s,nodeExtent:o,updateNodePositions:l,getNodes:u,snapToGrid:c,snapGrid:f,onError:p,nodesDraggable:h}=e.getState(),g=u().filter(E=>E.selected&&(E.draggable||h&&typeof E.draggable>"u")),y=c?f[0]:5,w=c?f[1]:5,C=i.isShiftPressed?4:1,_=i.x*y*C,S=i.y*w*C,b=g.map(E=>{if(E.positionAbsolute){const N={x:E.positionAbsolute.x+_,y:E.positionAbsolute.y+S};c&&(N.x=f[0]*Math.round(N.x/f[0]),N.y=f[1]*Math.round(N.y/f[1]));const{positionAbsolute:j,position:P}=QE(E,N,s,o,void 0,p);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:f,selected:p,onClick:h,onMouseEnter:g,onMouseMove:y,onMouseLeave:w,onContextMenu:C,onDoubleClick:_,style:S,className:b,isDraggable:E,isSelectable:N,isConnectable:j,isFocusable:P,selectNodesOnDrag:O,sourcePosition:q,targetPosition:F,hidden:T,resizeObserver:M,dragHandle:B,zIndex:J,isParent:Z,noDragClassName:A,noPanClassName:H,initialized:U,disableKeyboardA11y:ne,ariaLabel:Q,rfId:D,hasHandleBounds:G})=>{const k=jt(),L=I.useRef(null),oe=I.useRef(null),$=I.useRef(q),Y=I.useRef(F),ee=I.useRef(s),se=N||E||h||g||y||w,ae=JE(),pe=$o(i,k.getState,g),ge=$o(i,k.getState,y),Ae=$o(i,k.getState,w),Oe=$o(i,k.getState,C),Me=$o(i,k.getState,_),Pe=ve=>{const{nodeDragThreshold:ye}=k.getState();if(N&&(!O||!E||ye>0)&&Fg({id:i,store:k,nodeRef:L}),h){const Ge=k.getState().nodeInternals.get(i);Ge&&h(ve,{...Ge})}},ke=ve=>{if(!Og(ve)&&!ne)if(kE.includes(ve.key)&&N){const ye=ve.key==="Escape";Fg({id:i,store:k,unselect:ye,nodeRef:L})}else E&&p&&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}))};I.useEffect(()=>()=>{oe.current&&(M==null||M.unobserve(oe.current),oe.current=null)},[]),I.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]),I.useEffect(()=>{const ve=ee.current!==s,ye=$.current!==q,Ge=Y.current!==F;L.current&&(ve||ye||Ge)&&(ve&&(ee.current=s),ye&&($.current=q),Ge&&(Y.current=F),k.getState().updateNodeDimensions([{id:i,nodeElement:L.current,forceUpdate:!0}]))},[i,s,q,F]);const We=ZE({nodeRef:L,disabled:T||!E,noDragClassName:A,handleSelector:B,nodeId:i,isSelectable:N,selectNodesOnDrag:O});return T?null:le.createElement("div",{className:Ft(["react-flow__node",`react-flow__node-${s}`,{[H]:E},b,{selected:p,selectable:N,parent:Z,dragging:We}]),ref:L,style:{zIndex:J,transform:`translate(${c}px,${f}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:`${HE}-${D}`,"aria-label":Q},le.createElement(fI,{value:i},le.createElement(e,{id:i,data:o,type:s,xPos:l,yPos:u,selected:p,isConnectable:j,sourcePosition:q,targetPosition:F,dragging:We,dragHandle:B,zIndex:J})))};return n.displayName="NodeWrapper",I.memo(n)};const eM=e=>{const n=e.getNodes().filter(i=>i.selected);return{...Xl(n,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function tM({onSelectionContextMenu:e,noPanClassName:n,disableKeyboardA11y:i}){const s=jt(),{width:o,height:l,x:u,y:c,transformString:f,userSelectionActive:p}=Xe(eM,Ct),h=JE(),g=I.useRef(null);if(I.useEffect(()=>{var C;i||(C=g.current)==null||C.focus({preventScroll:!0})},[i]),ZE({nodeRef:g}),p||!o||!l)return null;const y=e?C=>{const _=s.getState().getNodes().filter(S=>S.selected);e(C,_)}:void 0,w=C=>{Object.prototype.hasOwnProperty.call(Fs,C.key)&&h({x:Fs[C.key].x,y:Fs[C.key].y,isShiftPressed:C.shiftKey})};return le.createElement("div",{className:Ft(["react-flow__nodesselection","react-flow__container",n]),style:{transform:f}},le.createElement("div",{ref:g,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:i?void 0:-1,onKeyDown:i?void 0:w,style:{width:o,height:l,top:c,left:u}}))}var nM=I.memo(tM);const rM=e=>e.nodesSelectionActive,eN=({children:e,onPaneClick:n,onPaneMouseEnter:i,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:l,onPaneScroll:u,deleteKeyCode:c,onMove:f,onMoveStart:p,onMoveEnd:h,selectionKeyCode:g,selectionOnDrag:y,selectionMode:w,onSelectionStart:C,onSelectionEnd:_,multiSelectionKeyCode:S,panActivationKeyCode:b,zoomActivationKeyCode:E,elementsSelectable:N,zoomOnScroll:j,zoomOnPinch:P,panOnScroll:O,panOnScrollSpeed:q,panOnScrollMode:F,zoomOnDoubleClick:T,panOnDrag:M,defaultViewport:B,translateExtent:J,minZoom:Z,maxZoom:A,preventScrolling:H,onSelectionContextMenu:U,noWheelClassName:ne,noPanClassName:Q,disableKeyboardA11y:D})=>{const G=Xe(rM),k=ea(g),L=ea(b),oe=L||M,$=L||O,Y=k||y&&oe!==!0;return zI({deleteKeyCode:c,multiSelectionKeyCode:S}),le.createElement(VI,{onMove:f,onMoveStart:p,onMoveEnd:h,onPaneContextMenu:l,elementsSelectable:N,zoomOnScroll:j,zoomOnPinch:P,panOnScroll:$,panOnScrollSpeed:q,panOnScrollMode:F,zoomOnDoubleClick:T,panOnDrag:!k&&oe,defaultViewport:B,translateExtent:J,minZoom:Z,maxZoom:A,zoomActivationKeyCode:E,preventScrolling:H,noWheelClassName:ne,noPanClassName:Q},le.createElement(YE,{onSelectionStart:C,onSelectionEnd:_,onPaneClick:n,onPaneMouseEnter:i,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:l,onPaneScroll:u,panOnDrag:oe,isSelecting:!!Y,selectionMode:w},e,G&&le.createElement(nM,{onSelectionContextMenu:U,noPanClassName:Q,disableKeyboardA11y:D})))};eN.displayName="FlowRenderer";var iM=I.memo(eN);function sM(e){return Xe(I.useCallback(i=>e?AE(i.nodeInternals,{x:0,y:0,width:i.width,height:i.height},i.transform,!0):i.getNodes(),[e]))}function oM(e){const n={input:Do(e.input||FE),default:Do(e.default||Dg),output:Do(e.output||BE),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 aM=({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]},lM=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),tN=e=>{const{nodesDraggable:n,nodesConnectable:i,nodesFocusable:s,elementsSelectable:o,updateNodeDimensions:l,onError:u}=Xe(lM,Ct),c=sM(e.onlyRenderVisibleElements),f=I.useRef(),p=I.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const h=new ResizeObserver(g=>{const y=g.map(w=>({id:w.target.getAttribute("data-id"),nodeElement:w.target,forceUpdate:!0}));l(y)});return f.current=h,h},[]);return I.useEffect(()=>()=>{var h;(h=f==null?void 0:f.current)==null||h.disconnect()},[]),le.createElement("div",{className:"react-flow__nodes",style:dv},c.map(h=>{var P,O,q;let g=h.type||"default";e.nodeTypes[g]||(u==null||u("003",Or.error003(g)),g="default");const y=e.nodeTypes[g]||e.nodeTypes.default,w=!!(h.draggable||n&&typeof h.draggable>"u"),C=!!(h.selectable||o&&typeof h.selectable>"u"),_=!!(h.connectable||i&&typeof h.connectable>"u"),S=!!(h.focusable||s&&typeof h.focusable>"u"),b=e.nodeExtent?iv(h.positionAbsolute,e.nodeExtent):h.positionAbsolute,E=(b==null?void 0:b.x)??0,N=(b==null?void 0:b.y)??0,j=aM({x:E,y:N,width:h.width??0,height:h.height??0,origin:e.nodeOrigin});return le.createElement(y,{key:h.id,id:h.id,className:h.className,style:h.style,type:g,data:h.data,sourcePosition:h.sourcePosition||Ce.Bottom,targetPosition:h.targetPosition||Ce.Top,hidden:h.hidden,xPos:E,yPos:N,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:!!h.selected,isDraggable:w,isSelectable:C,isConnectable:_,isFocusable:S,resizeObserver:p,dragHandle:h.dragHandle,zIndex:((P=h[ht])==null?void 0:P.z)??0,isParent:!!((O=h[ht])!=null&&O.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!h.width&&!!h.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:h.ariaLabel,hasHandleBounds:!!((q=h[ht])!=null&&q.handleBounds)})}))};tN.displayName="NodeRenderer";var uM=I.memo(tN);const cM=(e,n,i)=>i===Ce.Left?e-n:i===Ce.Right?e+n:e,dM=(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:cM(n,s,e),cy:dM(i,s,e),r:s,stroke:"transparent",fill:"transparent"}),fM=()=>!0;var Ms=e=>{const n=({id:i,className:s,type:o,data:l,onClick:u,onEdgeDoubleClick:c,selected:f,animated:p,label:h,labelStyle:g,labelShowBg:y,labelBgStyle:w,labelBgPadding:C,labelBgBorderRadius:_,style:S,source:b,target:E,sourceX:N,sourceY:j,targetX:P,targetY:O,sourcePosition:q,targetPosition:F,elementsSelectable:T,hidden:M,sourceHandleId:B,targetHandleId:J,onContextMenu:Z,onMouseEnter:A,onMouseMove:H,onMouseLeave:U,reconnectRadius:ne,onReconnect:Q,onReconnectStart:D,onReconnectEnd:G,markerEnd:k,markerStart:L,rfId:oe,ariaLabel:$,isFocusable:Y,isReconnectable:ee,pathOptions:se,interactionWidth:ae,disableKeyboardA11y:pe})=>{const ge=I.useRef(null),[Ae,Oe]=I.useState(!1),[Me,Pe]=I.useState(!1),ke=jt(),We=I.useMemo(()=>`url('#${Lg(L,oe)}')`,[L,oe]),ve=I.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,Z),it=Lo(i,ke.getState,A),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?J:B)||null,zt=dt?"target":"source",Ln=yt||fM,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)};qE({event:Je,handleId:Pt,nodeId:Gt,onConnect:hn=>Q==null?void 0:Q(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&&kE.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:f,animated:p,inactive:kt,updating:Ae}]),onClick:ye,onDoubleClick:Ge,onContextMenu:ut,onMouseEnter:it,onMouseMove:Ke,onMouseLeave:$e,onKeyDown:Y?He:void 0,tabIndex:Y?0:void 0,role:Y?"button":"img","data-testid":`rf__edge-${i}`,"aria-label":$===null?void 0:$||`Edge from ${b} to ${E}`,"aria-describedby":Y?`${VE}-${oe}`:void 0,ref:ge},!Me&&le.createElement(e,{id:i,source:b,target:E,selected:f,animated:p,label:h,labelStyle:g,labelShowBg:y,labelBgStyle:w,labelBgPadding:C,labelBgBorderRadius:_,data:l,style:S,sourceX:N,sourceY:j,targetX:P,targetY:O,sourcePosition:q,targetPosition:F,sourceHandleId:B,targetHandleId:J,markerStart:We,markerEnd:ve,pathOptions:se,interactionWidth:ae}),ee&&le.createElement(le.Fragment,null,(ee==="source"||ee===!0)&&le.createElement(Uw,{position:q,centerX:N,centerY:j,radius:ne,onMouseDown:bt,onMouseEnter:pt,onMouseOut:mt,type:"source"}),(ee==="target"||ee===!0)&&le.createElement(Uw,{position:F,centerX:P,centerY:O,radius:ne,onMouseDown:ct,onMouseEnter:pt,onMouseOut:mt,type:"target"})))};return n.displayName="EdgeWrapper",I.memo(n)};function hM(e){const n={default:Ms(e.default||Fl),straight:Ms(e.bezier||av),step:Ms(e.step||ov),smoothstep:Ms(e.step||Yl),simplebezier:Ms(e.simplebezier||sv)},i={},s=Object.keys(e).filter(o=>!["default","bezier"].includes(o)).reduce((o,l)=>(o[l]=Ms(e[l]||Fl),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 pM=(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 mM({sourcePos:e,targetPos:n,sourceWidth:i,sourceHeight:s,targetWidth:o,targetHeight:l,width:u,height:c,transform:f}){const p={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)};p.x===p.x2&&(p.x2+=1),p.y===p.y2&&(p.y2+=1);const h=Zo({x:(0-f[0])/f[2],y:(0-f[1])/f[2],width:u/f[2],height:c/f[2]}),g=Math.max(0,Math.min(h.x2,p.x2)-Math.max(h.x,p.x)),y=Math.max(0,Math.min(h.y2,p.y2)-Math.max(h.y,p.y));return Math.ceil(g*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 gM=[{level:0,isMaxLevel:!0,edges:[]}];function vM(e,n,i=!1){let s=-1;const o=e.reduce((u,c)=>{var h,g;const f=Pn(c.zIndex);let p=f?c.zIndex:0;if(i){const y=n.get(c.target),w=n.get(c.source),C=c.selected||(y==null?void 0:y.selected)||(w==null?void 0:w.selected),_=Math.max(((h=w==null?void 0:w[ht])==null?void 0:h.z)||0,((g=y==null?void 0:y[ht])==null?void 0:g.z)||0,1e3);p=(f?c.zIndex:0)+(C?_:0)}return u[p]?u[p].push(c):u[p]=[c],s=p>s?p:s,u},{}),l=Object.entries(o).map(([u,c])=>{const f=+u;return{edges:c,level:f,isMaxLevel:f===s}});return l.length===0?gM:l}function yM(e,n,i){const s=Xe(I.useCallback(o=>e?o.edges.filter(l=>{const u=n.get(l.source),c=n.get(l.target);return(u==null?void 0:u.width)&&(u==null?void 0:u.height)&&(c==null?void 0:c.width)&&(c==null?void 0:c.height)&&mM({sourcePos:u.positionAbsolute||{x:0,y:0},targetPos:c.positionAbsolute||{x:0,y:0},sourceWidth:u.width,sourceHeight:u.height,targetWidth:c.width,targetHeight:c.height,width:o.width,height:o.height,transform:o.transform})}):o.edges,[e,n]));return vM(s,n,i)}const wM=({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"}),xM=({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={[Dl.Arrow]:wM,[Dl.ArrowClosed]:xM};function _M(e){const n=jt();return I.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 SM=({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 f=_M(n);return f?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(f,{color:i,strokeWidth:u})):null},bM=({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))},nN=({defaultColor:e,rfId:n})=>{const i=Xe(I.useCallback(bM({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(SM,{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})))};nN.displayName="MarkerDefinitions";var kM=I.memo(nN);const EM=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}),rN=({defaultMarkerColor:e,onlyRenderVisibleElements:n,elevateEdgesOnSelect:i,rfId:s,edgeTypes:o,noPanClassName:l,onEdgeContextMenu:u,onEdgeMouseEnter:c,onEdgeMouseMove:f,onEdgeMouseLeave:p,onEdgeClick:h,onEdgeDoubleClick:g,onReconnect:y,onReconnectStart:w,onReconnectEnd:C,reconnectRadius:_,children:S,disableKeyboardA11y:b})=>{const{edgesFocusable:E,edgesUpdatable:N,elementsSelectable:j,width:P,height:O,connectionMode:q,nodeInternals:F,onError:T}=Xe(EM,Ct),M=yM(n,F,i);return P?le.createElement(le.Fragment,null,M.map(({level:B,edges:J,isMaxLevel:Z})=>le.createElement("svg",{key:B,style:{zIndex:B},width:P,height:O,className:"react-flow__edges react-flow__container"},Z&&le.createElement(kM,{defaultColor:e,rfId:s}),le.createElement("g",null,J.map(A=>{const[H,U,ne]=Ww(F.get(A.source)),[Q,D,G]=Ww(F.get(A.target));if(!ne||!G)return null;let k=A.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,A.sourceHandle),Y=Vw(oe,A.targetHandle),ee=($==null?void 0:$.position)||Ce.Bottom,se=(Y==null?void 0:Y.position)||Ce.Top,ae=!!(A.focusable||E&&typeof A.focusable>"u"),pe=A.reconnectable||A.updatable,ge=typeof y<"u"&&(pe||N&&typeof pe>"u");if(!$||!Y)return T==null||T("008",Or.error008($,A)),null;const{sourceX:Ae,sourceY:Oe,targetX:Me,targetY:Pe}=pM(H,$,ee,Q,Y,se);return le.createElement(L,{key:A.id,id:A.id,className:Ft([A.className,l]),type:k,data:A.data,selected:!!A.selected,animated:!!A.animated,hidden:!!A.hidden,label:A.label,labelStyle:A.labelStyle,labelShowBg:A.labelShowBg,labelBgStyle:A.labelBgStyle,labelBgPadding:A.labelBgPadding,labelBgBorderRadius:A.labelBgBorderRadius,style:A.style,source:A.source,target:A.target,sourceHandleId:A.sourceHandle,targetHandleId:A.targetHandle,markerEnd:A.markerEnd,markerStart:A.markerStart,sourceX:Ae,sourceY:Oe,targetX:Me,targetY:Pe,sourcePosition:ee,targetPosition:se,elementsSelectable:j,onContextMenu:u,onMouseEnter:c,onMouseMove:f,onMouseLeave:p,onClick:h,onEdgeDoubleClick:g,onReconnect:y,onReconnectStart:w,onReconnectEnd:C,reconnectRadius:_,rfId:s,ariaLabel:A.ariaLabel,isFocusable:ae,isReconnectable:ge,pathOptions:"pathOptions"in A?A.pathOptions:void 0,interactionWidth:A.interactionWidth,disableKeyboardA11y:b})})))),S):null};rN.displayName="EdgeRenderer";var NM=I.memo(rN);const CM=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function jM({children:e}){const n=Xe(CM);return le.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:n}},e)}function TM(e){const n=sa(),i=I.useRef(!1);I.useEffect(()=>{!i.current&&n.viewportInitialized&&e&&(setTimeout(()=>e(n),1),i.current=!0)},[e,n.viewportInitialized])}const RM={[Ce.Left]:Ce.Right,[Ce.Right]:Ce.Left,[Ce.Top]:Ce.Bottom,[Ce.Bottom]:Ce.Top},iN=({nodeId:e,handleType:n,style:i,type:s=pi.Bezier,CustomComponent:o,connectionStatus:l})=>{var O,q,F;const{fromNode:u,handleId:c,toX:f,toY:p,connectionMode:h}=Xe(I.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),g=(O=u==null?void 0:u[ht])==null?void 0:O.handleBounds;let y=g==null?void 0:g[n];if(h===Zi.Loose&&(y=y||(g==null?void 0:g[n==="source"?"target":"source"])),!u||!y)return null;const w=c?y.find(T=>T.id===c):y[0],C=w?w.x+w.width/2:(u.width??0)/2,_=w?w.y+w.height/2:u.height??0,S=(((q=u.positionAbsolute)==null?void 0:q.x)??0)+C,b=(((F=u.positionAbsolute)==null?void 0:F.y)??0)+_,E=w==null?void 0:w.position,N=E?RM[E]:null;if(!E||!N)return null;if(o)return le.createElement(o,{connectionLineType:s,connectionLineStyle:i,fromNode:u,fromHandle:w,fromX:S,fromY:b,toX:f,toY:p,fromPosition:E,toPosition:N,connectionStatus:l});let j="";const P={sourceX:S,sourceY:b,sourcePosition:E,targetX:f,targetY:p,targetPosition:N};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]=jE(P):j=`M${S},${b} ${f},${p}`,le.createElement("path",{d:j,fill:"none",className:"react-flow__connection-path",style:i})};iN.displayName="ConnectionLine";const AM=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function IM({containerStyle:e,style:n,type:i,component:s}){const{nodeId:o,handleType:l,nodesConnectable:u,width:c,height:f,connectionStatus:p}=Xe(AM,Ct);return!(o&&l&&c&&u)?null:le.createElement("svg",{style:e,width:c,height:f,className:"react-flow__edges react-flow__connectionline react-flow__container"},le.createElement("g",{className:Ft(["react-flow__connection",p])},le.createElement(iN,{nodeId:o,handleType:l,style:n,type:i,CustomComponent:s,connectionStatus:p})))}function Kw(e,n){return I.useRef(null),jt(),I.useMemo(()=>n(e),[e])}const sN=({nodeTypes:e,edgeTypes:n,onMove:i,onMoveStart:s,onMoveEnd:o,onInit:l,onNodeClick:u,onEdgeClick:c,onNodeDoubleClick:f,onEdgeDoubleClick:p,onNodeMouseEnter:h,onNodeMouseMove:g,onNodeMouseLeave:y,onNodeContextMenu:w,onSelectionContextMenu:C,onSelectionStart:_,onSelectionEnd:S,connectionLineType:b,connectionLineStyle:E,connectionLineComponent:N,connectionLineContainerStyle:j,selectionKeyCode:P,selectionOnDrag:O,selectionMode:q,multiSelectionKeyCode:F,panActivationKeyCode:T,zoomActivationKeyCode:M,deleteKeyCode:B,onlyRenderVisibleElements:J,elementsSelectable:Z,selectNodesOnDrag:A,defaultViewport:H,translateExtent:U,minZoom:ne,maxZoom:Q,preventScrolling:D,defaultMarkerColor:G,zoomOnScroll:k,zoomOnPinch:L,panOnScroll:oe,panOnScrollSpeed:$,panOnScrollMode:Y,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,oM),Je=Kw(n,hM);return TM(l),le.createElement(iM,{onPaneClick:ae,onPaneMouseEnter:pe,onPaneMouseMove:ge,onPaneMouseLeave:Ae,onPaneContextMenu:Me,onPaneScroll:Oe,deleteKeyCode:B,selectionKeyCode:P,selectionOnDrag:O,selectionMode:q,onSelectionStart:_,onSelectionEnd:S,multiSelectionKeyCode:F,panActivationKeyCode:T,zoomActivationKeyCode:M,elementsSelectable:Z,onMove:i,onMoveStart:s,onMoveEnd:o,zoomOnScroll:k,zoomOnPinch:L,zoomOnDoubleClick:ee,panOnScroll:oe,panOnScrollSpeed:$,panOnScrollMode:Y,panOnDrag:se,defaultViewport:H,translateExtent:U,minZoom:ne,maxZoom:Q,onSelectionContextMenu:C,preventScrolling:D,noDragClassName:Ke,noWheelClassName:$e,noPanClassName:Qe,disableKeyboardA11y:ct},le.createElement(jM,null,le.createElement(NM,{edgeTypes:Je,onEdgeClick:c,onEdgeDoubleClick:p,onlyRenderVisibleElements:J,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(IM,{style:E,type:b,component:N,containerStyle:j})),le.createElement("div",{className:"react-flow__edgelabel-renderer"}),le.createElement(uM,{nodeTypes:He,onNodeClick:u,onNodeDoubleClick:f,onNodeMouseEnter:h,onNodeMouseMove:g,onNodeMouseLeave:y,onNodeContextMenu:w,selectNodesOnDrag:A,onlyRenderVisibleElements:J,noPanClassName:Qe,noDragClassName:Ke,disableKeyboardA11y:ct,nodeOrigin:pt,nodeExtent:mt,rfId:kt})))};sN.displayName="GraphView";var MM=I.memo(sN);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:oI,isValidConnection:void 0},PM=()=>xT((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:f,nodeOrigin:p}=n(),h=f==null?void 0:f.querySelector(".react-flow__viewport");if(!h)return;const g=window.getComputedStyle(h),{m22:y}=new window.DOMMatrixReadOnly(g.transform),w=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,p),target:zw(".target",S.nodeElement,y,p)}},...E}),_.push({id:b.id,type:"dimensions",dimensions:E}))}return _},[]);GE(o,p);const C=u||l&&!u&&KE(n,{initial:!0,...c});e({nodeInternals:new Map(o),fitViewOnInitDone:C}),(w==null?void 0:w.length)>0&&(s==null||s(w))},updateNodePositions:(i,s=!0,o=!1)=>{const{triggerNodeChanges:l}=n(),u=i.map(c=>{const f={id:c.id,type:"position",dragging:o};return s&&(f.positionAbsolute=c.positionAbsolute,f.position=c.position),f});l(u)},triggerNodeChanges:i=>{const{onNodesChange:s,nodeInternals:o,hasDefaultNodes:l,nodeOrigin:u,getNodes:c,elevateNodesOnSelect:f}=n();if(i!=null&&i.length){if(l){const p=YI(i,c()),h=ed(p,o,u,f);e({nodeInternals:h})}s==null||s(i)}},addSelectedNodes:i=>{const{multiSelectionActive:s,edges:o,getNodes:l}=n();let u,c=null;s?u=i.map(f=>hi(f,!0)):(u=qs(l(),i),c=qs(o,[])),xl({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(f=>hi(f,!0)):(u=qs(o,i),c=qs(l(),[])),xl({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,f=u.map(h=>(h.selected=!1,hi(h.id,!1))),p=c.map(h=>hi(h.id,!1));xl({changedNodes:f,changedEdges:p,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));xl({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:f}=n();if(!u||!c||!i.x&&!i.y)return!1;const p=Mr.translate(s[0]+i.x,s[1]+i.y).scale(s[2]),h=[[0,0],[o,l]],g=u==null?void 0:u.constrain()(p,h,f);return u.transform(c,g),s[0]!==g.x||s[1]!==g.y||s[2]!==g.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=I.useRef(null);return n.current||(n.current=PM()),le.createElement(JA,{value:n.current},e)};fv.displayName="ReactFlowProvider";const oN=({children:e})=>I.useContext(Kl)?le.createElement(le.Fragment,null,e):le.createElement(fv,null,e);oN.displayName="ReactFlowWrapper";const OM={input:FE,default:Dg,output:BE,group:cv},qM={default:Fl,straight:av,step:ov,smoothstep:Yl,simplebezier:sv},LM=[0,0],$M=[15,15],DM={x:0,y:0,zoom:1},FM={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},aN=I.forwardRef(({nodes:e,edges:n,defaultNodes:i,defaultEdges:s,className:o,nodeTypes:l=OM,edgeTypes:u=qM,onNodeClick:c,onEdgeClick:f,onInit:p,onMove:h,onMoveStart:g,onMoveEnd:y,onConnect:w,onConnectStart:C,onConnectEnd:_,onClickConnectStart:S,onClickConnectEnd:b,onNodeMouseEnter:E,onNodeMouseMove:N,onNodeMouseLeave:j,onNodeContextMenu:P,onNodeDoubleClick:O,onNodeDragStart:q,onNodeDrag:F,onNodeDragStop:T,onNodesDelete:M,onEdgesDelete:B,onSelectionChange:J,onSelectionDragStart:Z,onSelectionDrag:A,onSelectionDragStop:H,onSelectionContextMenu:U,onSelectionStart:ne,onSelectionEnd:Q,connectionMode:D=Zi.Strict,connectionLineType:G=pi.Bezier,connectionLineStyle:k,connectionLineComponent:L,connectionLineContainerStyle:oe,deleteKeyCode:$="Backspace",selectionKeyCode:Y="Shift",selectionOnDrag:ee=!1,selectionMode:se=Jo.Full,panActivationKeyCode:ae="Space",multiSelectionKeyCode:pe=$l()?"Meta":"Control",zoomActivationKeyCode:ge=$l()?"Meta":"Control",snapToGrid:Ae=!1,snapGrid:Oe=$M,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Pe=!0,nodesDraggable:ke,nodesConnectable:We,nodesFocusable:ve,nodeOrigin:ye=LM,edgesFocusable:Ge,edgesUpdatable:ut,elementsSelectable:it,defaultViewport:Ke=DM,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:Tt,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 Rt=ss||"1";return le.createElement("div",{...wr,style:{...yr,...FM},ref:en,className:Ft(["react-flow",o]),"data-testid":"rf__wrapper",id:ss},le.createElement(oN,null,le.createElement(MM,{onInit:p,onMove:h,onMoveStart:g,onMoveEnd:y,onNodeClick:c,onEdgeClick:f,onNodeMouseEnter:E,onNodeMouseMove:N,onNodeMouseLeave:j,onNodeContextMenu:P,onNodeDoubleClick:O,nodeTypes:l,edgeTypes:u,connectionLineType:G,connectionLineStyle:k,connectionLineComponent:L,connectionLineContainerStyle:oe,selectionKeyCode:Y,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:Q,onEdgeContextMenu:hn,onEdgeDoubleClick:$r,onEdgeMouseEnter:Tt,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:Rt,disableKeyboardA11y:ki,nodeOrigin:ye,nodeExtent:pt}),le.createElement(TI,{nodes:e,edges:n,defaultNodes:i,defaultEdges:s,onConnect:w,onConnectStart:C,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:B,onNodeDragStart:q,onNodeDrag:F,onNodeDragStop:T,onSelectionDrag:A,onSelectionDragStart:Z,onSelectionDragStop:H,noPanClassName:$n,nodeOrigin:ye,rfId:Rt,autoPanOnConnect:is,autoPanOnNodeDrag:et,onError:Fn,connectionRadius:Qs,isValidConnection:vr,nodeDragThreshold:Ei}),le.createElement(CI,{onSelectionChange:J}),Jt,le.createElement(tI,{proOptions:bi,position:Si}),le.createElement(PI,{rfId:Rt,disableKeyboardA11y:ki})))});aN.displayName="ReactFlow";const zM=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function lN(){return Xe(zM,Ct)}const uN=({id:e,x:n,y:i,width:s,height:o,style:l,color:u,strokeColor:c,strokeWidth:f,className:p,borderRadius:h,shapeRendering:g,onClick:y,selected:w})=>{const{background:C,backgroundColor:_}=l||{},S=u||C||_;return le.createElement("rect",{className:Ft(["react-flow__minimap-node",{selected:w},p]),x:n,y:i,rx:h,ry:h,width:s,height:o,fill:S,stroke:c,strokeWidth:f,shapeRendering:g,onClick:y?b=>y(b,e):void 0})};uN.displayName="MiniMapNode";var BM=I.memo(uN);const UM=e=>e.nodeOrigin,HM=e=>e.getNodes().filter(n=>!n.hidden&&n.width&&n.height),id=e=>e instanceof Function?e:()=>e;function VM({nodeStrokeColor:e="transparent",nodeColor:n="#e2e2e2",nodeClassName:i="",nodeBorderRadius:s=5,nodeStrokeWidth:o=2,nodeComponent:l=BM,onClick:u}){const c=Xe(HM,Ct),f=Xe(UM),p=id(n),h=id(e),g=id(i),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return le.createElement(le.Fragment,null,c.map(w=>{const{x:C,y:_}=Yi(w,f).positionAbsolute;return le.createElement(l,{key:w.id,x:C,y:_,width:w.width,height:w.height,style:w.style,selected:w.selected,className:g(w),color:p(w),borderRadius:s,strokeColor:h(w),strokeWidth:o,shapeRendering:y,onClick:u,id:w.id})}))}var WM=I.memo(VM);const GM=200,KM=150,YM=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?iI(Xl(n,e.nodeOrigin),i):i,rfId:e.rfId}},XM="react-flow__minimap-desc";function cN({style:e,className:n,nodeStrokeColor:i="transparent",nodeColor:s="#e2e2e2",nodeClassName:o="",nodeBorderRadius:l=5,nodeStrokeWidth:u=2,nodeComponent:c,maskColor:f="rgb(240, 240, 240, 0.6)",maskStrokeColor:p="none",maskStrokeWidth:h=1,position:g="bottom-right",onClick:y,onNodeClick:w,pannable:C=!1,zoomable:_=!1,ariaLabel:S="React Flow mini map",inversePan:b=!1,zoomStep:E=10,offsetScale:N=5}){const j=jt(),P=I.useRef(null),{boundingRect:O,viewBB:q,rfId:F}=Xe(YM,Ct),T=(e==null?void 0:e.width)??GM,M=(e==null?void 0:e.height)??KM,B=O.width/T,J=O.height/M,Z=Math.max(B,J),A=Z*T,H=Z*M,U=N*Z,ne=O.x-(A-O.width)/2-U,Q=O.y-(H-O.height)/2-U,D=A+U*2,G=H+U*2,k=`${XM}-${F}`,L=I.useRef(0);L.current=Z,I.useEffect(()=>{if(P.current){const Y=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=yE().on("zoom",C?se:null).on("zoom.wheel",_?ee:null);return Y.call(ae),()=>{Y.on("zoom",null)}}},[C,_,b,E]);const oe=y?Y=>{const ee=Kn(Y);y(Y,{x:ee[0],y:ee[1]})}:void 0,$=w?(Y,ee)=>{const se=j.getState().nodeInternals.get(ee);w(Y,se)}:void 0;return le.createElement(nv,{position:g,style:e,className:Ft(["react-flow__minimap",n]),"data-testid":"rf__minimap"},le.createElement("svg",{width:T,height:M,viewBox:`${ne} ${Q} ${D} ${G}`,role:"img","aria-labelledby":k,ref:P,onClick:oe},S&&le.createElement("title",{id:k},S),le.createElement(WM,{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},${Q-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:f,fillRule:"evenodd",stroke:p,strokeWidth:h,pointerEvents:"none"})))}cN.displayName="MiniMap";var QM=I.memo(cN);function ZM(){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 JM(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},le.createElement("path",{d:"M0 0h32v4.2H0z"}))}function eP(){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 tP(){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 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 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 rP=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),dN=({style:e,showZoom:n=!0,showFitView:i=!0,showInteractive:s=!0,fitViewOptions:o,onZoomIn:l,onZoomOut:u,onFitView:c,onInteractiveChange:f,className:p,children:h,position:g="bottom-left"})=>{const y=jt(),[w,C]=I.useState(!1),{isInteractive:_,minZoomReached:S,maxZoomReached:b}=Xe(rP,Ct),{zoomIn:E,zoomOut:N,fitView:j}=sa();if(I.useEffect(()=>{C(!0)},[]),!w)return null;const P=()=>{E(),l==null||l()},O=()=>{N(),u==null||u()},q=()=>{j(o),c==null||c()},F=()=>{y.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),f==null||f(!_)};return le.createElement(nv,{className:Ft(["react-flow__controls",p]),position:g,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(ZM,null)),le.createElement(Ls,{onClick:O,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:S},le.createElement(JM,null))),i&&le.createElement(Ls,{className:"react-flow__controls-fitview",onClick:q,title:"fit view","aria-label":"fit view"},le.createElement(eP,null)),s&&le.createElement(Ls,{className:"react-flow__controls-interactive",onClick:F,title:"toggle interactivity","aria-label":"toggle interactivity"},_?le.createElement(nP,null):le.createElement(tP,null)),h)};dN.displayName="Controls";var iP=I.memo(dN),Xn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Xn||(Xn={}));function sP({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 oP({color:e,radius:n}){return le.createElement("circle",{cx:n,cy:n,r:n,fill:e})}const aP={[Xn.Dots]:"#91919a",[Xn.Lines]:"#eee",[Xn.Cross]:"#e2e2e2"},lP={[Xn.Dots]:1,[Xn.Lines]:1,[Xn.Cross]:6},uP=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function fN({id:e,variant:n=Xn.Dots,gap:i=20,size:s,lineWidth:o=1,offset:l=2,color:u,style:c,className:f}){const p=I.useRef(null),{transform:h,patternId:g}=Xe(uP,Ct),y=u||aP[n],w=s||lP[n],C=n===Xn.Dots,_=n===Xn.Cross,S=Array.isArray(i)?i:[i,i],b=[S[0]*h[2]||1,S[1]*h[2]||1],E=w*h[2],N=_?[E,E]:b,j=C?[E/l,E/l]:[N[0]/l,N[1]/l];return le.createElement("svg",{className:Ft(["react-flow__background",f]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:p,"data-testid":"rf__background"},le.createElement("pattern",{id:g+e,x:h[0]%b[0],y:h[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${j[0]},-${j[1]})`},C?le.createElement(oP,{color:y,radius:E/l}):le.createElement(sP,{dimensions:N,color:y,lineWidth:o})),le.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${g+e})`}))}fN.displayName="Background";var cP=I.memo(fN);function hN(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function pN(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=pN(s,n+1);if(o)return o}return null}function dP(e,n){e.inputTokens+=n.inputTokens,e.outputTokens+=n.outputTokens,e.cacheReadTokens+=n.cacheReadTokens,e.cacheCreateTokens+=n.cacheCreateTokens}const fP=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i;function mN(e,n=0){if(!e||typeof e!="object"||n>6)return null;const i=e;if(typeof i.model=="string"&&fP.test(i.model))return i.model;for(const s of Object.values(i)){const o=mN(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,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 zl(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:hN()},e.agents.set(o,l),l)}function gN(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=zl(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 f=gN(e,s,o,n);if(f)return f}const l=e.activeSubagentStack.get(s),u=l&&l.length>0?l[l.length-1]:null;if(u){const f=e.agents.get(hv(s,u));if(f)return!f.cwd&&n.cwd&&(f.cwd=n.cwd,f.cwdBasename=gi(n.cwd)),f}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 hP(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 f=zl(s);return f&&(c.label==="subagent"||!c.label)&&(c.label=f),c}return c={id:l,sessionId:n,label:zl(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:hN()},e.agents.set(l,c),u.childCount+=1,c}function pP(e,n,i){const s=e.activeSubagentStack.get(n)??[];s.push(i),e.activeSubagentStack.set(n,s)}function mP(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 gP(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 vP(e,n,i,s){const o=new Map;for(const[p,h]of e.agents){let g=o.get(h.sessionId);g||(g={ids:[],endedAt:0,live:!1},o.set(h.sessionId,g)),g.ids.push(p),h.state==="done"&&h.endedAt!=null?g.endedAt=Math.max(g.endedAt,h.endedAt):g.live=!0}const l=[...o.values()].filter(p=>!p.live&&p.endedAt>0&&n-p.endedAt>s).sort((p,h)=>p.endedAt-h.endedAt);let c=[...o.values()].filter(p=>!p.live).length-i;if(c<=0)return!1;let f=!1;for(const p of l){if(c<=0)break;for(const h of p.ids)e.agents.delete(h);c--,f=!0}return f}function yP(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){if(n.seq<=e.lastSeq)return e;const i=n.payload??{},s=n.receivedAt,o=i.hook_event_name??"Unknown";if(o==="__clear")return{...Bg(),lastSeq:n.seq};e.totalEvents+=1,e.lastSeq=n.seq;const l=i.session_id??"unknown";if(o==="ModelObserved"){const f=typeof i.model=="string"?i.model:null;if(f){const h=e.agents.get(l);h&&(h.model=f)}const p=i.subagentModels;if(p&&typeof p=="object")for(const[h,g]of Object.entries(p)){if(typeof g!="string")continue;const y=`${l}::${h}`,w=e.agents.get(y);w&&(w.model=g)}return e}if(o==="ContextObserved"){const f=i.context??null;if(f){const p=e.agents.get(l);p&&(p.context={msgsUser:Number(f.msgsUser??0),msgsAssistant:Number(f.msgsAssistant??0),toolUses:Number(f.toolUses??0),toolResults:Number(f.toolResults??0),systemReminders:Number(f.systemReminders??0),currentContextTokens:Number(f.currentContextTokens??0),claudeMdFiles:Array.isArray(f.claudeMdFiles)?f.claudeMdFiles:[]})}return e}if(o==="UsageObserved"){const f=i.usage??null;if(f){const p=e.agents.get(l);p&&(p.usage.inputTokens=Number(f.input_tokens??0),p.usage.outputTokens=Number(f.output_tokens??0),p.usage.cacheReadTokens=Number(f.cache_read_input_tokens??f.cached_input_tokens??0),p.usage.cacheCreateTokens=Number(f.cache_creation_input_tokens??0),typeof f.reasoning_output_tokens=="number"&&(p.usage.reasoningOutputTokens=Number(f.reasoning_output_tokens)))}return e}const u=Yw(e,i,s);u.provider||(u.provider=i.provider==="codex"?"codex":"claude"),typeof i.model_context_window=="number"&&i.model_context_window>0&&(u.contextWindow=i.model_context_window);const c=mN(i);switch(c&&(u.model=c),o){case"SessionStart":{const f=Wo(e,l,s,!1);f.synthetic=!1,f.state="active",f.startedAt=f.startedAt||s,!f.cwd&&i.cwd&&(f.cwd=i.cwd,f.cwdBasename=gi(i.cwd)),f.label==="session"&&i.cwd&&(f.label=gi(i.cwd)??"session");break}case"UserPromptSubmit":{for(const g of e.agents.values())g.sessionId===l&&g.kind==="subagent"&&g.state==="done"&&g.exitAt==null&&g.endedAt!=null&&g.endedAt<s&&(g.exitAt=s);const f=Wo(e,l,s,!1);f.state="active",f.endedAt=void 0,f.exitAt=void 0;const p=Yw(e,i,s);p.state="active",p.exitAt=void 0,p.endedAt=void 0;const h=(typeof i.prompt=="string"?i.prompt:typeof i.message=="string"?i.message:"")??"";h&&(p.prompts.push({at:s,text:h}),p.firstPrompt||(p.firstPrompt=sd(h,120)));break}case"PreToolUse":{const f=i.tool_use_id??`${u.id}:${u.toolCount}`,p={id:f,name:i.tool_name??"?",input:i.tool_input,inputPreview:sd(i.tool_input),agentId:u.id,startedAt:s};u.tools.push(p),u.toolCount+=1,u.state="active",e.toolIndex.set(f,p),e.toolOwner.set(f,u.id),Bo(u);break}case"PostToolUse":case"PostToolUseFailure":{const f=i.tool_use_id;if(!f)break;let p=e.toolIndex.get(f),h=!1;if(!p)for(const w of e.agents.values()){const C=w.tools.find(_=>_.id===f);if(C){p=C,h=!0;break}}if(!p)break;p.endedAt=s,p.ok=o==="PostToolUse",p.response=i.tool_response,o==="PostToolUseFailure"?p.errorPreview=sd(i.tool_response):h&&(p.errorPreview=void 0);const g=pN(i.tool_response);g&&(p.usage=g),e.toolIndex.delete(f);const y=e.toolOwner.get(f)??p.agentId;if(e.toolOwner.delete(f),y){const w=e.agents.get(y);w&&(g&&dP(w.usage,g),Bo(w))}break}case"SubagentStart":{const f=Ug(i);if(!f)break;const p=hP(e,l,f,i,s);p.state="active",p.startedAt=p.startedAt||s,p.exitAt=void 0,p.endedAt=void 0;const h=zl(i);h&&(p.label=h),pP(e,l,f);break}case"SubagentStop":{const f=Ug(i);if(!f)break;const p=gN(e,l,f,i);if(!p)break;p.state="done",p.endedAt=s,Bo(p),mP(e,l,f);break}case"Stop":case"SessionEnd":{const f=Wo(e,l,s,!1);f.state="done",f.endedAt=s,Bo(f);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 wP=Date.UTC(2026,8,1);function xP(){return Date.now()<wP?{input:2,output:10,cacheRead:.2,cacheWrite:2.5}:{input:3,output:15,cacheRead:.3,cacheWrite:3.75}}const _P=[{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:xP()},{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 SP(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function mv(e){if(!e)return null;for(const n of _P)if(n.match.test(e))return n.rates;return null}const bP=272e3,kP=/^gpt[-_]5[-_.](?:6(?![-_]cyber)|5|4)/i;function EP(e,n){return!e||n<=bP?{input:1,output:1}:kP.test(e)?{input:2,output:1.5}:{input:1,output:1}}function dn(e,n){const i=mv(n);if(!i)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const s=SP(n),o=s?Math.max(0,e.inputTokens-e.cacheReadTokens):e.inputTokens,l=s?EP(n,e.inputTokens):{input:1,output:1},u=o*i.input*l.input/1e6,c=e.outputTokens*i.output*l.output/1e6,f=e.cacheReadTokens*i.cacheRead*l.input/1e6,p=e.cacheCreateTokens*i.cacheWrite*l.input/1e6;return{input:u,output:c,cacheRead:f,cacheWrite:p,total:u+c+f+p}}const Qw=2e5,NP=1e6,CP=[/\[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],jP=[{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 vN(e){if(!e)return Qw;for(const n of CP)if(n.test(e))return NP;for(const n of jP)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 Bl(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 TP(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function RP({agent:e,onClose:n}){var p;const i=e.context,s=e.usage,o=(i==null?void 0:i.currentContextTokens)??0,l=vN(e.model),u=Math.min(100,o/l*100),c=dn(s,e.model),f=s.inputTokens+s.cacheReadTokens+s.cacheCreateTokens;return m.jsx("div",{className:"ctx-modal-backdrop",onClick:n,role:"presentation",children:m.jsxs("div",{className:"ctx-modal",onClick:h=>h.stopPropagation(),role:"dialog","aria-label":"Context breakdown",children:[m.jsxs("header",{className:"ctx-modal-head",children:[m.jsxs("div",{children:[m.jsxs("div",{className:"ctx-modal-title",children:["Context · ",e.label]}),m.jsx("div",{className:"ctx-modal-sub",children:"approximation — CC's /context isn't hook-exposed"})]}),m.jsx("button",{className:"ctx-modal-close",onClick:n,"aria-label":"Close",children:"×"})]}),m.jsxs("section",{className:"ctx-window-row",children:[m.jsx("div",{className:"ctx-window-bar",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(u),children:m.jsx("div",{className:"ctx-window-fill",style:{width:`${u}%`}})}),m.jsxs("div",{className:"ctx-window-meta",children:[m.jsxs("span",{className:"ctx-window-pct",children:[u.toFixed(1),"%"]}),m.jsxs("span",{className:"ctx-window-num",children:[In(o)," / ",In(l)," tok (current turn)"]})]})]}),m.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),m.jsxs("div",{className:"ctx-grid",children:[m.jsx(Gn,{label:"input tokens",val:In(s.inputTokens)}),m.jsx(Gn,{label:"output tokens",val:In(s.outputTokens)}),m.jsx(Gn,{label:"cache reads",val:In(s.cacheReadTokens)}),m.jsx(Gn,{label:"cache writes",val:In(s.cacheCreateTokens)}),m.jsx(Gn,{label:"cumulative total",val:In(f)}),m.jsx(Gn,{label:"estimated cost",val:Be(c.total),accent:!0})]}),m.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),m.jsxs("div",{className:"ctx-grid",children:[m.jsx(Gn,{label:"user messages",val:In((i==null?void 0:i.msgsUser)??0)}),m.jsx(Gn,{label:"assistant messages",val:In((i==null?void 0:i.msgsAssistant)??0)}),m.jsx(Gn,{label:"tool uses",val:In((i==null?void 0:i.toolUses)??0)}),m.jsx(Gn,{label:"tool results",val:In((i==null?void 0:i.toolResults)??0)}),m.jsx(Gn,{label:"system-reminders",val:In((i==null?void 0:i.systemReminders)??0)})]}),m.jsx("h3",{className:"ctx-section-title",children:"CLAUDE.md files in scope"}),(((p=i==null?void 0:i.claudeMdFiles)==null?void 0:p.length)??0)===0?m.jsx("div",{className:"ctx-empty",children:"No CLAUDE.md files found on the path from cwd to ~/.claude."}):m.jsx("ul",{className:"ctx-md-list",children:i.claudeMdFiles.map(h=>m.jsxs("li",{children:[m.jsx("span",{className:"ctx-md-path",title:h.path,children:h.path}),m.jsx("span",{className:"ctx-md-size",children:TP(h.bytes)})]},h.path))})]})})}function Gn({label:e,val:n,accent:i}){return m.jsxs("div",{className:`ctx-row${i?" accent":""}`,children:[m.jsx("span",{className:"ctx-row-label",children:e}),m.jsx("span",{className:"ctx-row-val",children:n})]})}function AP({currentContextTokens:e,modelId:n,size:i=26,onClick:s,title:o}){const l=vN(n),u=Math.min(1,e/l),c=i/2-3,f=i/2,p=2*Math.PI*c,h=p*u,g=u>.9?"var(--err)":u>.7?"var(--inflight)":"var(--accent)";return m.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:m.jsxs("svg",{width:i,height:i,viewBox:`0 0 ${i} ${i}`,children:[m.jsx("circle",{cx:f,cy:f,r:c,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),m.jsx("circle",{cx:f,cy:f,r:c,stroke:g,strokeWidth:"2.5",fill:"none",strokeDasharray:`${h} ${p-h}`,strokeDashoffset:p/4,strokeLinecap:"round",style:{transition:"stroke-dasharray 400ms ease"}}),m.jsx("text",{x:f,y:f+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(u*100)})]})})}function IP(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 MP(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 PP({data:e,selected:n}){var p;const i=e.now??Date.now(),s=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":"",n?"selected":""].filter(Boolean).join(" "),o=e.tools.filter(h=>!h.endedAt).length,u=`hsl(${pv(e.sessionId)} 70% 60%)`,c=((p=e.context)==null?void 0:p.currentContextTokens)??0,f=e.kind==="root"&&c>0;return m.jsxs("div",{className:s,style:{"--accent":u},children:[m.jsx("span",{className:"accent-stripe"}),m.jsx(Vs,{type:"target",position:Ce.Left,style:{background:"transparent",border:"none"}}),m.jsxs("div",{className:"head",children:[m.jsxs("div",{className:"title",children:[m.jsx(OP,{state:e.state}),m.jsx("span",{className:"label",title:e.cwd,children:e.label}),e.synthetic&&m.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"})]}),m.jsxs("div",{className:"head-right",children:[f&&e.onOpenContext&&m.jsx(AP,{currentContextTokens:c,modelId:e.model,onClick:()=>e.onOpenContext(e.sessionId)}),m.jsx("div",{className:"time",title:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:MP(e.startedAt,e.endedAt,i)})]})]}),m.jsxs("div",{className:"sub",children:[e.kind==="root"?"session":"subagent",e.childCount>0&&m.jsxs("span",{className:"spawn-badge",title:`${e.childCount} subagents spawned`,children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model&&m.jsx("span",{className:"model-chip",title:e.model,children:oa(e.model)})]}),e.tools.length>0&&m.jsx(LP,{tools:e.tools,now:i}),m.jsxs("div",{className:"meta",children:[m.jsxs("span",{children:[m.jsx("b",{children:e.toolCount})," tools"]}),o>0&&m.jsxs("span",{className:"inflight-meta",children:[m.jsx("b",{children:o})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&m.jsxs("span",{className:"tokens-meta",title:`in:${e.usage.inputTokens} out:${e.usage.outputTokens} cache-r:${e.usage.cacheReadTokens} cache-c:${e.usage.cacheCreateTokens}${(e.usage.reasoningOutputTokens??0)>0?` reasoning:${e.usage.reasoningOutputTokens}`:""}`,children:[m.jsx("b",{children:qP(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),e.model&&mv(e.model)&&(()=>{const h=dn(e.usage,e.model);if(h.total<=0)return null;const g=Math.max(0,((e.endedAt??i)-e.startedAt)/1e3),y=e.state==="active"?Bl(h.total,g):null,w=IP(e.usage,e.model)+(y?`
59
- burn: ${y}`:"");return m.jsxs("span",{className:"cost-meta",title:w,children:[m.jsx("b",{children:Be(h.total)}),y&&m.jsx("span",{className:"cost-rate",children:y})]})})()]}),m.jsx(Vs,{type:"source",position:Ce.Right,style:{background:"transparent",border:"none"}})]})}function OP({state:e}){const n=e==="active"?"live":e==="done"?"done":"err";return m.jsx("span",{className:`state-pill state-${e}`,children:n})}function qP(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function LP({tools:e,now:n}){const l=new Array(24).fill(0);let u=0;for(const y of e){const w=n-y.startedAt;if(w<0||w>=6e4)continue;const C=23-Math.floor(w/2500);C>=0&&C<24&&(l[C]+=1,u+=1)}const c=Math.max(1,...l),f=132,p=14,h=f/24,g=c/(2500/1e3);return m.jsxs("div",{className:"tool-spark-row",title:`${u} tool calls in last 60s · peak ${g.toFixed(1)}/s`,children:[m.jsx("svg",{className:"tool-spark",width:f,height:p,viewBox:`0 0 ${f} ${p}`,"aria-hidden":!0,children:l.map((y,w)=>{const C=y===0?1.5:Math.max(1.5,y/c*p),_=w===23&&y>0,b=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return m.jsx("rect",{x:w*h+.4,y:p-C,width:Math.max(.5,h-1),height:C,rx:.8,className:b},w)})}),m.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function oa(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 $P(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 DP({tool:e,onClose:n}){I.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 m.jsx("div",{className:"modal-backdrop",onClick:n,role:"dialog","aria-modal":"true",children:m.jsxs("div",{className:"modal",onClick:s=>s.stopPropagation(),children:[m.jsxs("header",{className:"modal-head",children:[m.jsxs("div",{className:"modal-title",children:[m.jsx("span",{className:`status-dot ${i}`}),m.jsx("span",{className:"modal-tool-name",children:e.name}),m.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),m.jsxs("div",{className:"modal-actions",children:[m.jsx("span",{className:"modal-dur",children:$P(e)}),m.jsx("button",{className:"btn icon-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),m.jsxs("section",{className:"modal-body",children:[m.jsxs("div",{className:"modal-section",children:[m.jsx("h4",{children:"Input"}),m.jsx("pre",{children:Zw(e.input??e.inputPreview)})]}),m.jsxs("div",{className:"modal-section",children:[m.jsxs("h4",{children:["Response ",i==="err"&&m.jsx("span",{className:"err-tag",children:"error"})]}),m.jsx("pre",{children:e.endedAt==null?"(waiting…)":Zw(e.response??e.errorPreview)})]})]})]})})}const Sl=18,Jw=26,FP=12;function zP(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,f=u+o.width,p=c+o.height,h=n.get(l.sessionId);h?(h.minX=Math.min(h.minX,u),h.minY=Math.min(h.minY,c),h.maxX=Math.max(h.maxX,f),h.maxY=Math.max(h.maxY,p),l.kind==="root"&&(h.label=ex(l)??h.label)):n.set(l.sessionId,{minX:u,minY:c,maxX:f,maxY:p,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} · ${BP(o)}`:l.label;s.push({sessionId:o,label:c,x:l.minX-Sl,y:l.minY-Sl-Jw,w:l.maxX-l.minX+Sl*2,h:l.maxY-l.minY+Sl*2+Jw})}return s}function BP(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 UP(){const{x:e,y:n,zoom:i}=lN(),s=sa(),o=Xe(zP,HP);if(o.length<=1)return null;const l=u=>{try{const c=s.getNodes().filter(f=>{const p=f.data;return(p==null?void 0:p.sessionId)===u});if(c.length===0)return;s.fitView({padding:.3,duration:500,nodes:c})}catch{}};return m.jsx("div",{className:"session-clusters",children:o.map(u=>{const c=pv(u.sessionId),f={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)`},p={position:"absolute",left:u.x*i+e+16*i,top:(u.y-FP)*i+n,color:`hsl(${c} 70% 78%)`,borderColor:`hsl(${c} 65% 55% / 0.5)`,transform:`scale(${Math.min(1,i)})`,transformOrigin:"left top"};return m.jsxs(le.Fragment,{children:[m.jsx("div",{className:"cluster-card",style:f,"aria-hidden":!0}),m.jsx("button",{type:"button",className:"cluster-label",style:p,title:`Fit view to ${u.label} · drag the wrapper to move the whole session`,onClick:()=>l(u.sessionId),children:u.label})]},u.sessionId)})})}function HP(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 VP({data:e}){return m.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const yN=600,WP=36,Hg=16,GP=60,KP=6,tx=220,nx=96,YP=28,XP={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 QP(e){return e.startsWith("mcp__")?"mcp":XP[e]??"other"}const ZP={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__")?"🔌":ZP[e]??"✨"}const JP={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 wN(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 wN(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 e3(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 t3=new Set(["Bash","PowerShell","shell","exec_command","shell_command","write_stdin","wait"]),n3=new Set(["shell","exec_command","shell_command","write_stdin","wait","apply_patch","update_plan"]);function r3(e,n){return n3.has(e)?Math.max(nx,34+n.length*7.5):nx}function i3(e,n){if(!t3.has(e))return null;const i=e3(n);if(!i)return null;const s=wN(i);return s?{emoji:JP[s]??"⚙️",label:s,category:"shell",detail:i}:null}const s3=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 o3(e){const i=e.replace(/\\/g,"/").replace(/\/+$/,""),s=i.lastIndexOf("/");return s>=0?i.slice(s+1):i}function a3(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 l3(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 u3(e,n){if(!s3.has(e))return null;const i=l3(e,n);if(!i)return null;const s=o3(i);return s?{emoji:e==="LS"?"📂":a3(s),label:s,category:"file",detail:i}:null}const xN={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 _N(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 c3(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 d3(e,n){const i=_N(e);if(!i)return null;const{server:s,method:o}=i;if(!o)return null;const l=xN[s.toLowerCase()];return{emoji:(l==null?void 0:l.emoji)??"🔌",label:o,category:"mcp",detail:l?`${l.name} · ${o}`:`${s} · ${o}`}}function f3(e,n){return i3(e,n)??u3(e,n)??d3(e)}const h3={shell:"Shell",exec_command:"Shell",shell_command:"Shell",write_stdin:"stdin",wait:"wait",apply_patch:"Edit",update_plan:"Plan"};function p3(e){const n=_N(e);if(n){const s=xN[n.server.toLowerCase()];return s?{emoji:s.emoji,label:s.name}:{emoji:"🔌",label:n.server,hue:c3(n.server)}}const i=h3[e];return i?{emoji:rx(e),label:i}:{emoji:rx(e),label:e}}function m3(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function g3(e,n,i){if(i==null)return 1;const s=n-i;return s<0?1:Math.max(0,1-s/yN)}function v3(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>yN)continue;const f=s.get(c.id)??i.get(c.id);if(!f)continue;const p=c.tools.slice(-4);if(p.length===0)continue;const h=c.exitAt??null,g=o.get(c.id),y=Math.max((g==null?void 0:g.width)??tx,tx),w=(g==null?void 0:g.height)??130,C=f.x,_=f.y,S=C+y,b=_+w/2;p.forEach((E,N)=>{const j=N*WP,P=C+y+GP,O=_+KP+j,q=g3(E,l,h),F=E.inputPreview??"",T=m3(E),M=q<.999,B=p3(E.name);u.push({id:E.id,toolId:E.id,agentId:c.id,toolName:E.name,name:B.label,emoji:B.emoji,status:T,category:QP(E.name),mcpHue:B.hue,inputPreview:F,fade:q,fading:M,worldX:P,worldY:O,anchorX:S,anchorY:b,spawnDx:S-P,spawnDy:b-(O+Hg)});const J=f3(E.name,E.input);if(J){const Z=r3(E.name,B.label),A=P+Z+YP,H=O,U=P+Z,ne=O+Hg;u.push({id:`sub:${E.id}`,toolId:E.id,agentId:c.id,toolName:E.name,name:J.label,emoji:J.emoji,isSub:!0,status:T,category:J.category,inputPreview:J.detail??F,fade:q,fading:M,worldX:A,worldY:H,anchorX:U,anchorY:ne,spawnDx:U-A,spawnDy:0})}})}return u}function y3({agents:e,visibleAgentIds:n,positions:i,pinned:s,measured:o,dimUnmatched:l,spotlight:u,hiddenCategories:c,now:f,onOpenTool:p}){const{x:h,y:g,zoom:y}=lN(),w=v3(e,n,i,s,o,f),C=c&&c.size>0?w.filter(_=>!c.has(_.category)):w;return m.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[m.jsx("svg",{className:"tool-bursts-svg",children:C.map(_=>{const S=_.anchorX*y+h,b=_.anchorY*y+g,E=(_.worldX+6)*y+h,N=(_.worldY+Hg)*y+g,j=S+(E-S)*.55,P=l!=null&&!l.has(_.agentId),O=u!=null&&!u.has(_.agentId),q=_.fade*(P||O?.14:1);return m.jsx("path",{d:`M ${S} ${b} Q ${j} ${b}, ${E} ${N}`,className:`tool-conn status-${_.status}${_.fading?" fading":""}`,opacity:q},`l:${_.id}`)})}),C.map(_=>{const S=_.worldX*y+h,b=_.worldY*y+g,E={left:`${S}px`,top:`${b}px`,transform:`scale(${y})`,transformOrigin:"left top","--spawn-dx":`${_.spawnDx}px`,"--spawn-dy":`${_.spawnDy}px`},N=_.isSub?`${_.toolName} · ${_.name}`:_.toolName,j=_.inputPreview?`${N} · ${_.inputPreview}`:N,P=p!=null,O=_.mcpHue!=null?{"--cat-accent":`hsl(${_.mcpHue} 65% 65%)`}:{},q=l!=null&&!l.has(_.agentId),F=u!=null&&!u.has(_.agentId),T=q||F?" dim":"";return m.jsx("div",{className:"tool-burst-wrap",style:E,children:m.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?()=>p(_.toolId):void 0,onKeyDown:P?M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),p(_.toolId))}:void 0,children:[m.jsx("span",{className:"tb-emoji",children:_.emoji}),m.jsx("span",{className:"tb-name",children:_.name}),_.status==="inflight"&&m.jsx("span",{className:"tb-spin"}),_.status==="done"&&m.jsx("span",{className:"tb-mark done",children:"✓"}),_.status==="err"&&m.jsx("span",{className:"tb-mark err",children:"×"})]})},_.id)})]})}function w3({state:e,sessionId:n,onClose:i}){const s=I.useMemo(()=>_3(e,n),[e,n]);return s?m.jsx("div",{className:"modal-backdrop",onClick:i,role:"presentation",children:m.jsxs("div",{className:"modal session-summary",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[m.jsxs("div",{className:"modal-head",children:[m.jsxs("div",{className:"modal-title",children:[m.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),m.jsx("span",{id:"ss-title",className:"modal-tool-name",title:s.cwd??s.sessionId,children:s.label}),m.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),m.jsxs("div",{className:"modal-actions",children:[m.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.durationLabel}),m.jsx("button",{className:"btn",onClick:i,"aria-label":"Close",children:"×"})]})]}),m.jsxs("div",{className:"modal-body",children:[m.jsxs("section",{className:"ss-hero",children:[m.jsxs("div",{className:"ss-hero-left",children:[m.jsx("div",{className:"ss-cost-label",children:"total spend"}),m.jsx("div",{className:"ss-cost",children:Be(s.cost.total)}),s.modelChips.length>0&&m.jsx("div",{className:"ss-models",children:s.modelChips.map(o=>m.jsx("span",{className:"model-chip",title:o,children:oa(o)},o))})]}),m.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&m.jsxs(m.Fragment,{children:[m.jsx(x3,{cost:s.cost}),m.jsxs("div",{className:"ss-cost-legend",children:[m.jsxs("span",{className:"ssl ssl-in",children:["input ",m.jsx("b",{children:Be(s.cost.input)})]}),m.jsxs("span",{className:"ssl ssl-out",children:["output ",m.jsx("b",{children:Be(s.cost.output)})]}),m.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",m.jsx("b",{children:Be(s.cost.cacheRead)})]}),m.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",m.jsx("b",{children:Be(s.cost.cacheWrite)})]})]})]})})]}),m.jsxs("section",{className:"ss-stats",children:[m.jsx(Ps,{label:"agents",value:s.agentCount}),m.jsx(Ps,{label:"subagents",value:s.subagentCount}),m.jsx(Ps,{label:"tool calls",value:s.toolCount}),m.jsx(Ps,{label:"prompts",value:s.promptCount}),m.jsx(Ps,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&m.jsx(Ps,{label:"errors",value:s.errCount,tone:"err"})]}),s.topTools.length>0&&m.jsxs("section",{className:"modal-section",children:[m.jsx("h4",{children:"Most-used tools"}),m.jsx("div",{className:"ss-top-tools",children:s.topTools.map(([o,l])=>m.jsxs("div",{className:"ss-tt",children:[m.jsx("span",{className:"ss-tt-name",children:o}),m.jsx("span",{className:"ss-tt-bar",children:m.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${l/s.topTools[0][1]*100}%`}})}),m.jsx("span",{className:"ss-tt-count",children:l})]},o))})]}),s.firstPrompt&&m.jsxs("section",{className:"modal-section",children:[m.jsx("h4",{children:"Opening prompt"}),m.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]})]})}):null}function Ps({label:e,value:n,tone:i}){return m.jsxs("div",{className:`ss-stat${i?` tone-${i}`:""}`,children:[m.jsx("div",{className:"ss-stat-value",children:n}),m.jsx("div",{className:"ss-stat-label",children:e})]})}function x3({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 m.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${Be(s)} (${u.toFixed(0)}%)`},o)};return m.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 _3(e,n){const i=e.agents.get(n);if(!i)return null;const s=[];for(const N of e.agents.values())N.sessionId===n&&s.push(N);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,f=0,p=0,h=0,g=0,y,w=1/0,C=0;for(const N of s){const j=dn(N.usage,N.model);o.input+=j.input,o.output+=j.output,o.cacheRead+=j.cacheRead,o.cacheWrite+=j.cacheWrite,o.total+=j.total,N.model&&l.add(N.model),N.kind==="subagent"&&g++,f+=N.prompts.length,!y&&N.prompts.length>0&&(y=N.prompts[0].text),p+=N.usage.inputTokens+N.usage.outputTokens,c+=N.tools.length,w=Math.min(w,N.startedAt),C=Math.max(C,N.endedAt??Date.now());for(const P of N.tools)u.set(P.name,(u.get(P.name)??0)+1),P.ok===!1&&h++}const _=Math.max(0,C-w),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((N,j)=>j[1]-N[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:g,toolCount:c,promptCount:f,tokensSum:p,errCount:h,topTools:E,firstPrompt:y}}function S3(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 f=c.endedAt??c.startedAt;f>u&&(u=f)}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 b3(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 k3({state:e,now:n,selectedIds:i,onSelect:s,onClose:o}){const l=I.useMemo(()=>S3(e),[e,e.lastSeq,n]),u=l.filter(c=>c.state==="active").length;return m.jsxs("aside",{className:"session-list","aria-label":"Sessions",children:[m.jsxs("div",{className:"sl-header",children:[m.jsxs("h3",{children:["Sessions ",m.jsx("span",{className:"sl-count",children:l.length})]}),u>0&&m.jsxs("span",{className:"sl-live-count",children:[u," live"]}),m.jsx("button",{className:"btn icon-btn sl-close",onClick:o,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),m.jsxs("div",{className:"sl-rows",children:[l.length===0&&m.jsx("div",{className:"sl-empty",children:"No sessions yet."}),l.map(c=>{const f=i.has(c.sessionId);return m.jsxs("button",{type:"button",className:`sl-row state-${c.state}${f?" selected":""}`,onClick:()=>s(c.sessionId),title:`Focus ${c.label}`,children:[m.jsx("span",{className:`sl-dot state-${c.state}`,"aria-hidden":!0}),m.jsxs("div",{className:"sl-row-body",children:[m.jsxs("div",{className:"sl-row-head",children:[m.jsx("span",{className:"sl-label",children:c.label}),c.modelId&&m.jsx("span",{className:"model-chip",title:c.modelId,children:oa(c.modelId)})]}),m.jsxs("div",{className:"sl-row-meta",children:[m.jsxs("span",{title:"tool calls",children:[m.jsx("b",{children:c.toolCount})," tools"]}),c.cost>0&&m.jsx("span",{className:"sl-cost",title:"total spend",children:m.jsx("b",{children:Be(c.cost)})}),m.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(c.startedAt).toLocaleString()}`,children:b3(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 E3(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 N3({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 m.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${Be(s)} (${u.toFixed(0)}%)`},o)};return m.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 C3(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 j3(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 f=100-e,p=l>0?e/l:0,h=p>0?f/p:1/0,g={label:`${Math.round(c)}% ahead`,color:"var(--warn)",expectedPct:u,isDeficit:!0};if(h<o&&h<86400){const y=Math.floor(h/3600),w=Math.floor(h%3600/60);g.runsOutIn=y>0?`${y}h ${w}m`:`${w}m`}return g}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)),p=l||c>=90?"var(--err)":c>=70?"var(--warn)":"var(--accent)",h=c===0?"< 1%":`${c}%`,g=c===0?2:c,y=s?C3(s,u):null,w=s&&o?j3(c,s,o,u):null;return m.jsxs("div",{className:"qb-row",children:[m.jsxs("div",{className:"qb-meta",children:[m.jsxs("span",{className:"qb-label",children:[n,l&&m.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),m.jsx("span",{className:"qb-pct",style:{color:p},children:h})]}),m.jsxs("div",{className:"qb-track",children:[m.jsx("div",{className:"qb-fill",style:{width:`${g}%`,background:p,opacity:c===0?.4:1}}),w&&m.jsx("div",{className:"qb-pace-marker",style:{left:`${w.expectedPct}%`,background:w.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(w.expectedPct)}% by now`})]}),m.jsxs("div",{className:"qb-reset-row",children:[y?m.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):i?m.jsxs("span",{className:"qb-reset",children:["resets ",i]}):null,w&&m.jsx("span",{className:"qb-pace",style:{color:w.color},children:w.runsOutIn?`runs out in ${w.runsOutIn}`:w.label})]})]})}const T3=6e4;function R3(){const[e,n]=I.useState(null),[i,s]=I.useState(!1),o=I.useRef(null),l=async(c=!1)=>{c&&s(!0);try{const p=await fetch(c?"/api/quota?refresh=1":"/api/quota");p.ok&&n(await p.json())}catch{}finally{c&&s(!1)}};return I.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),T3),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{quota:e,loading:i,refresh:()=>l(!0)}}function A3(e){switch(e){case"no_token":return"Run codex login to authenticate.";case"api_key_mode":return"API-key login — ChatGPT quota is only available for codex login.";case"refresh_rejected":return"Codex session expired — run codex login.";case"refresh_failed":return"Couldn't refresh the Codex token — click ↻ to retry.";default:return"ChatGPT API unreachable — click ↻ to retry."}}const SN=6e4;function I3(){const[e,n]=I.useState(null),[i,s]=I.useState(!1),o=I.useRef(null),l=async(c=!1)=>{c&&s(!0);try{const p=await fetch(c?"/api/codex-quota?refresh=1":"/api/codex-quota");p.ok&&n(await p.json())}catch{}finally{c&&s(!1)}};return I.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),SN),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{data:e,loading:i,refresh:()=>l(!0)}}function M3(){const[e,n]=I.useState(null),i=I.useRef(null),s=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return I.useEffect(()=>(s(),i.current=window.setInterval(s,SN),()=>{i.current!=null&&window.clearInterval(i.current)}),[]),{data:e}}function P3({state:e,now:n,onClose:i}){var q,F;const{quota:s,loading:o,refresh:l}=R3(),{data:u,loading:c,refresh:f}=I3(),{data:p}=M3(),[h,g]=I.useState(()=>Math.floor(Date.now()/1e3));I.useEffect(()=>{const T=window.setInterval(()=>g(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(T)},[]);const{byModel:y,totalCost:w,totalTokens:C,burnRate:_}=I.useMemo(()=>{const T=new Map,M={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let B=0,J=0,Z=0,A=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,B+=D.usage.inputTokens,J+=D.usage.outputTokens,Z+=D.usage.cacheReadTokens,A+=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 Q=ne>0?Bl(U,ne):null;return{byModel:H,totalCost:M,totalTokens:{in:B,out:J,cacheR:Z,cacheC:A},burnRate:Q}},[e,e.lastSeq,n]),S=I.useMemo(()=>{const T=[];for(const M of e.agents.values()){if(M.kind!=="root")continue;let B=dn(M.usage,M.model).total,J=M.usage.inputTokens,Z=M.usage.outputTokens;for(const A of e.agents.values())A.sessionId!==M.sessionId||A.kind==="root"||(B+=dn(A.usage,A.model).total,J+=A.usage.inputTokens,Z+=A.usage.outputTokens);T.push({sessionId:M.sessionId,label:M.label||M.cwdBasename||"session",state:M.state,cost:B,inputTokens:J,outputTokens:Z})}return T.sort((M,B)=>B.cost-M.cost).slice(0,12)},[e,e.lastSeq]),b=w.total>0,E=C.in+C.out,N=o||c,j=ox(s==null?void 0:s.fetchedAt,h),P=ox(u==null?void 0:u.fetchedAt,h),O=()=>{l(),f()};return m.jsxs("div",{className:"usage-panel","aria-label":"Usage",children:[m.jsxs("div",{className:"up-header",children:[m.jsx("h3",{children:"Usage"}),_&&m.jsx("span",{className:"up-rate",children:_}),m.jsxs("div",{className:"up-header-right",children:[m.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:O,disabled:N,title:"Refresh Claude + Codex quota",children:N?"…":"↻"}),m.jsx("button",{type:"button",className:"btn icon-btn up-close",onClick:i,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),m.jsxs("section",{className:"up-section up-quota-section",children:[m.jsxs("h4",{className:"up-section-title",children:["Claude quota",j&&!o&&m.jsx("span",{className:"up-section-age",title:E3(s==null?void 0:s.source),children:j})]}),s!=null&&s.ok?m.jsxs("div",{className:"up-quota-bars",children:[s.session5hPct!=null&&m.jsx(Bi,{label:"5-hour window",pct:s.session5hPct,reset:s.session5hReset,resetAt:s.session5hResetAt,windowSec:s.session5hWindowSec,nowSec:h}),s.week7dPct!=null&&m.jsx(Bi,{label:"7-day window",pct:s.week7dPct,reset:s.week7dReset,resetAt:s.week7dResetAt,windowSec:s.week7dWindowSec,nowSec:h}),s.weekSonnetPct!=null&&m.jsx(Bi,{label:"Sonnet (7d)",pct:s.weekSonnetPct,nowSec:h}),s.weekOpusPct!=null&&m.jsx(Bi,{label:"Opus (7d)",pct:s.weekOpusPct,nowSec:h})]}):(s==null?void 0:s.ok)===!1?m.jsxs("div",{className:"up-quota-na",children:[m.jsx("span",{children:"Quota unavailable."}),m.jsxs("span",{className:"up-quota-hint",children:["Run ",m.jsx("code",{children:"/usage"})," in a claude session, then click ↻"]})]}):m.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),m.jsxs("section",{className:"up-section up-quota-section",children:[m.jsxs("h4",{className:"up-section-title",children:["Codex quota",(u==null?void 0:u.ok)&&u.planLabel&&m.jsx("span",{className:"up-plan-badge",children:u.planLabel}),P&&!c&&m.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:P})]}),u!=null&&u.ok?m.jsxs("div",{className:"up-quota-bars",children:[(q=u.windows)==null?void 0:q.map(T=>m.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:h},T.id)),(F=u.extraWindows)==null?void 0:F.map(T=>m.jsx(Bi,{label:T.label,pct:T.pct,reset:T.reset??void 0,resetAt:T.resetAt??void 0,windowSec:T.windowSec??void 0,nowSec:h},T.id)),u.creditLimit&&m.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:h}),(p==null?void 0:p.ok)&&p.window7d&&p.window7d.sessionCount>0&&m.jsxs("div",{className:"up-quota-sub",children:[Ar(p.window7d.totalTokens)," tokens · ",p.window7d.sessionCount," session",p.window7d.sessionCount!==1?"s":""," (7d)"]}),u.creditsBalance&&!u.creditsUnlimited&&m.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",u.creditsBalance,u.overageReached&&" · overage limit reached"]}),u.creditsUnlimited&&m.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),u.resetCredits&&u.resetCredits.availableCount>0&&m.jsxs("div",{className:"up-quota-sub up-reset-credits",title:"Redeem in the Codex CLI or ChatGPT — agents-deck only reports them",children:[u.resetCredits.availableCount," rate-limit reset",u.resetCredits.availableCount!==1?"s":""," available",u.resetCredits.nextExpiryAt&&` · expires ${new Date(u.resetCredits.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`]}),u.promo&&m.jsx("div",{className:"up-quota-sub",children:u.promo}),u.partial&&m.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(u==null?void 0:u.ok)===!1?m.jsxs("div",{className:"up-quota-na",children:[m.jsx("span",{children:"Quota unavailable."}),m.jsx("span",{className:"up-quota-hint",children:A3(u.reason)})]}):m.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),b?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"up-total",children:[m.jsx("span",{className:"up-total-value",children:Be(w.total)}),m.jsx("span",{className:"up-total-label",children:"total spend"})]}),m.jsx(N3,{cost:w}),E>0&&m.jsxs("div",{className:"up-tokens-row",children:[m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"in"}),Ar(C.in)]}),m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"out"}),Ar(C.out)]}),C.cacheR>0&&m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"cache r"}),Ar(C.cacheR)]}),C.cacheC>0&&m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"cache c"}),Ar(C.cacheC)]})]}),y.filter(T=>T.cost.total>0).length>0&&m.jsxs("section",{className:"up-section",children:[m.jsx("h4",{className:"up-section-title",children:"By model"}),m.jsxs("table",{className:"up-table",children:[m.jsx("thead",{children:m.jsxs("tr",{children:[m.jsx("th",{children:"Model"}),m.jsx("th",{children:"Tokens"}),m.jsx("th",{children:"Cost"})]})}),m.jsx("tbody",{children:y.filter(T=>T.cost.total>0).map(T=>m.jsxs("tr",{children:[m.jsx("td",{className:"up-model-name",title:T.model,children:oa(T.model)}),m.jsx("td",{className:"up-num",children:Ar(T.inputTokens+T.outputTokens)}),m.jsx("td",{className:"up-num up-cost-val",children:Be(T.cost.total)})]},T.model))})]})]}),S.filter(T=>T.cost>0).length>0&&m.jsxs("section",{className:"up-section",children:[m.jsx("h4",{className:"up-section-title",children:"By session"}),m.jsx("div",{className:"up-sessions",children:S.filter(T=>T.cost>0).map(T=>m.jsxs("div",{className:"up-session-row",children:[m.jsx("span",{className:`sl-dot state-${T.state}`,"aria-hidden":!0}),m.jsx("span",{className:"up-session-label",children:T.label}),m.jsx("span",{className:"up-session-tokens",children:Ar(T.inputTokens+T.outputTokens)}),m.jsx("span",{className:"up-session-cost",children:Be(T.cost)})]},T.sessionId))})]})]}):E>0?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"up-tokens-row",children:[m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"in"}),Ar(C.in)]}),m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"out"}),Ar(C.out)]})]}),m.jsx("div",{className:"up-hint",children:"Cost appears once a known model is detected."})]}):m.jsxs("div",{className:"up-empty",children:["No usage data yet.",m.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const ax=18,O3=1100,Os=(e,n)=>{const i=Math.sin(e*12.9898+n*78.233)*43758.5453;return i-Math.floor(i)},q3=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=O3}){var l;const[i,s]=I.useState(null),o=typeof window<"u"&&((l=window.matchMedia)==null?void 0:l.call(window,"(prefers-reduced-motion: reduce)").matches);return I.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 f=window.setTimeout(()=>s(null),n);return()=>window.clearTimeout(f)},[e,n,o]),o||!i?null:ZA.createPortal(m.jsx("div",{className:"confetti",style:{left:`${i.x}px`,top:`${i.y}px`},"aria-hidden":!0,children:q3.map((u,c)=>m.jsx("span",{className:`confetti-bit${u.round?" round":""}`,"data-hue":u.hue,style:{"--dx":`${u.dx.toFixed(1)}px`,"--dy":`${u.dy.toFixed(1)}px`,"--rot":`${u.rot}deg`,"--s":u.scale.toFixed(2),animationDelay:`${u.delay}ms`,animationDuration:`${u.dur}ms, ${u.dur}ms`}},c))}),document.body)}const L3=1500;async function bl(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const $3={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?$3[e.reason]??e.reason:null)||(e==null?void 0:e.error)||n,Vg=le.forwardRef((e,n)=>m.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:n,children:[m.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),m.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));Vg.displayName="SuccessMark";function D3({onClose:e,onChanged:n}){const[i,s]=I.useState("login"),[o,l]=I.useState(null),[u,c]=I.useState(""),[f,p]=I.useState(""),[h,g]=I.useState(!1),[y,w]=I.useState(null),[C,_]=I.useState(null),S=I.useRef(!1),b=I.useRef(null),E=I.useRef(null),N=I.useRef(null),j=I.useCallback(()=>{S.current&&bl({action:"login-cancel"}).catch(()=>{}),e()},[e]);I.useEffect(()=>{const T=M=>{M.key==="Escape"&&j()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[j]);const P=I.useCallback(async()=>{g(!0),w(null),S.current=!0;const T=await bl({action:"login"}).catch(()=>null);if(g(!1),!(T!=null&&T.ok)){w(od(T,"could not start the sign-in"));return}l(T)},[]);I.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{}},L3);return()=>window.clearInterval(T)},[o]),I.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]),I.useEffect(()=>{var T;i==="paste"&&((T=E.current)==null||T.focus())},[i]);const O=I.useCallback(async()=>{var M;g(!0),w(null);const T=await bl({action:"login-code",code:u}).catch(()=>null);if(g(!1),!(T!=null&&T.ok)){w(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=I.useCallback(async()=>{g(!0),w(null);const T=await bl({action:"import",blob:f}).catch(()=>null);if(g(!1),!(T!=null&&T.ok)){w(od(T,"the import failed"));return}p(""),_({added:T.added===!0,num:T.num??null,email:T.email??null}),n()},[f,n]),F=(o==null?void 0:o.state)==="done"?o.account:null;return m.jsx("div",{className:"modal-backdrop",onClick:j,role:"presentation",children:m.jsxs("div",{className:"modal aa-modal",onClick:T=>T.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[m.jsxs("header",{className:"modal-head",children:[m.jsx("div",{className:"modal-title",children:m.jsxs("span",{className:"aa-tabs",role:"tablist",children:[m.jsx("button",{type:"button",role:"tab","aria-selected":i==="login",className:`aa-tab${i==="login"?" on":""}`,onClick:()=>s("login"),children:"Sign in"}),m.jsx("button",{type:"button",role:"tab","aria-selected":i==="paste",className:`aa-tab${i==="paste"?" on":""}`,onClick:()=>s("paste"),children:"Paste a share"})]})}),m.jsx("div",{className:"modal-actions",children:m.jsx("button",{type:"button",className:"btn icon-btn",onClick:j,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),m.jsx("section",{className:"modal-body aa-body",children:i==="login"?F?m.jsxs("div",{className:"aa-done",children:[m.jsx(Vg,{ref:N}),m.jsx(lx,{anchor:N}),m.jsx("h4",{children:F.added?`Account ${F.num} added`:"Credentials refreshed"}),m.jsxs("p",{className:"aa-note",children:[m.jsx("strong",{children:F.email}),F.added?" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),m.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"})]}):(o==null?void 0:o.state)==="awaiting_code"||(o==null?void 0:o.state)==="registering"?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:"1 · Approve in the browser"}),m.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),m.jsx("a",{className:"aa-link",href:o.url??"#",target:"_blank",rel:"noreferrer noopener",children:o.url})]}),m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:"2 · Paste the code it gives you"}),m.jsxs("div",{className:"aa-field",children:[m.jsx("input",{ref:b,type:"text",value:u,onChange:T=>c(T.target.value),onKeyDown:T=>{T.key==="Enter"&&u.trim()&&!h&&O()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:o.state==="registering"}),m.jsx("button",{type:"button",className:"btn primary",disabled:h||!u.trim()||o.state==="registering",onClick:O,children:o.state==="registering"?"registering…":"Continue"})]}),(y||o.error)&&m.jsx("p",{className:"aa-err",children:y??o.error}),m.jsx("p",{className:"aa-note",children:"The code goes straight to the claude CLI on this machine. It is never stored or sent anywhere else."})]})]}):(o==null?void 0:o.state)==="failed"||y&&S.current&&!h?m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:"Sign-in failed"}),m.jsx("p",{className:"aa-err",children:y??(o==null?void 0:o.error)}),m.jsx("button",{type:"button",className:"btn",onClick:()=>{S.current=!1,l(null),w(null),P()},children:"Try again"})]}):h||S.current?m.jsx("div",{className:"aa-step",children:m.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):m.jsxs("div",{className:"aa-step aa-primer",children:[m.jsx("h4",{children:"Sign in to Anthropic"}),m.jsx("p",{className:"aa-note",children:"Opens a browser tab where you approve the sign-in, then asks for the code it shows you. claude-swap records the account when it completes, and the account you are using now stays active."}),m.jsx("div",{className:"aa-actions",children:m.jsx("button",{type:"button",className:"btn primary",onClick:P,disabled:h,children:"Open the sign-in page"})})]}):C?m.jsxs("div",{className:"aa-done",children:[m.jsx(Vg,{ref:N}),C.added&&m.jsx(lx,{anchor:N}),m.jsx("h4",{children:C.added?`Account ${C.num} imported`:"Already here"}),m.jsx("p",{className:"aa-note",children:C.added?m.jsxs(m.Fragment,{children:[C.email?m.jsx("strong",{children:C.email}):"That account"," is in the rotation now. Nothing changed on the deck you copied it from."]}):"This deck already holds that account, so nothing changed."}),m.jsxs("div",{className:"aa-actions",children:[m.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"}),m.jsx("button",{type:"button",className:"btn",onClick:()=>_(null),children:"Import another"})]})]}):m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:"Paste an account shared from another deck"}),m.jsxs("div",{className:"aa-field",children:[m.jsx("input",{ref:E,type:"text",value:f,onChange:T=>p(T.target.value),onKeyDown:T=>{T.key==="Enter"&&f.trim()&&!h&&q()},placeholder:"ccdeck1:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),m.jsx("button",{type:"button",className:"btn primary",disabled:h||!f.trim(),onClick:q,children:h?"importing…":"Import"})]}),y&&m.jsx("p",{className:"aa-err",children:y}),m.jsxs("p",{className:"aa-note",children:["Use ",m.jsx("strong",{children:"share"})," on an account in the other deck. A share carries a live login and expires ten minutes after it is made."]})]})})]})})}const F3=15e3,z3=[70,80,85,90,95];function B3(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 U3(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 H3(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 V3({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?B3(e.resetAt,n):null;return m.jsxs("div",{className:"ap-lane",children:[m.jsx("span",{className:"ap-lane-label",children:e.label}),m.jsx("div",{className:"ap-lane-track",children:m.jsx("div",{className:"ap-lane-fill",style:{width:`${i===0?1.5:i}%`,background:s,opacity:i===0?.4:1}})}),m.jsxs("span",{className:"ap-lane-pct",style:{color:s},children:[i,"%"]}),m.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}function W3(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 G3(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 K3(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 Y3({onClose:e}){var Q,D,G;const[n,i]=I.useState(null),[s,o]=I.useState(null),[l,u]=I.useState(null),[c,f]=I.useState(null),[p,h]=I.useState(null),[g,y]=I.useState(()=>Math.floor(Date.now()/1e3)),w=I.useRef(null),[C,_]=I.useState(null),[S,b]=I.useState(!1),[E,N]=I.useState(""),[j,P]=I.useState(null),[O,q]=I.useState(null),[F,T]=I.useState(!1),M=I.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{}},[]),B=I.useCallback(async(k,L)=>{u(L),h(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||h(($==null?void 0:$.detail)||($==null?void 0:$.reason)||"command failed"),$}catch{return h("server unreachable"),null}finally{u(null)}},[]),J=I.useCallback(async(k,L)=>{u(L),h(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||h(($==null?void 0:$.detail)||($==null?void 0:$.reason)||"command failed"),$}catch{return h("server unreachable"),null}finally{u(null)}},[]);I.useEffect(()=>(M(!0),w.current=window.setInterval(()=>M(!1),F3),()=>{w.current!=null&&window.clearInterval(w.current)}),[M]),I.useEffect(()=>{const k=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(k)},[]);const Z=((Q=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:Q.value)??"90",A=(D=n==null?void 0:n.accounts)==null?void 0:D.find(k=>k.active),H=A!=null&&A.lanes.length?Math.max(...A.lanes.map(k=>k.pct)):null,U=H!=null&&H>=Number(Z)-15,ne=async k=>{f(k),h(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||h((oe==null?void 0:oe.output)||(oe==null?void 0:oe.reason)||"switch failed"),await M(!0)}catch{h("server unreachable")}finally{f(null)}};return m.jsxs("div",{className:"accounts-panel","aria-label":"Claude accounts",children:[m.jsxs("div",{className:"ap-header",children:[m.jsx("h3",{children:"Accounts"}),m.jsxs("div",{className:"ap-header-right",children:[m.jsx("button",{type:"button",className:"btn ap-add",onClick:()=>b(!0),title:"Sign in to another Claude account, or paste one shared from another deck",children:"+"}),m.jsx("button",{type:"button",className:"btn ap-refresh",onClick:()=>M(!0),title:"Reload from claude-swap",children:"↻"}),m.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),n==null?m.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?m.jsxs(m.Fragment,{children:[(G=n.accounts)==null?void 0:G.map(k=>m.jsxs("div",{className:`ap-account${k.active?" active":""}${k.disabled?" disabled":""}`,children:[m.jsxs("div",{className:"ap-account-head",children:[m.jsx("span",{className:"ap-num",children:k.num}),k.alias&&m.jsx("span",{className:"ap-alias",children:k.alias}),m.jsx("span",{className:"ap-email",title:k.org??void 0,children:k.email}),m.jsx("button",{type:"button",className:`ap-more${C===k.num?" on":""}`,"aria-label":`Manage account ${k.num}`,"aria-expanded":C===k.num,title:"Share, rename, move, remove",onClick:()=>{_(C===k.num?null:k.num),N(k.alias??""),P(null),q(null),T(!1)},children:"⋯"}),k.active?m.jsx("span",{className:"ap-badge-active",children:"● active"}):m.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=>m.jsx(V3,{lane:L,nowSec:g},L.id)):m.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),m.jsxs("div",{className:"ap-meta",children:[k.error&&(()=>{const L=H3(k.error);return m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"ap-err",title:L.hint,children:L.text}),L.fixable&&m.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&&m.jsx("button",{type:"button",className:"ap-rotate",disabled:l!=null,onClick:()=>B({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?m.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,g),U3(k.nextAt,g)]}):m.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),C===k.num&&m.jsxs("div",{className:"ap-manage",children:[m.jsxs("div",{className:"ap-manage-row",children:[m.jsx("span",{className:"ap-manage-label",children:"name"}),m.jsx("input",{className:"ap-manage-input",type:"text",value:E,onChange:L=>N(L.target.value),onKeyDown:L=>{L.key==="Enter"&&J({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}`}),m.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null||E.trim()===(k.alias??""),onClick:()=>J({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"})]}),m.jsxs("div",{className:"ap-manage-row",children:[m.jsx("span",{className:"ap-manage-label",children:"slot"}),m.jsx("span",{className:"ap-field",children:m.jsx("select",{"aria-label":`Slot for account ${k.num}`,value:String(k.num),disabled:l!=null,onChange:L=>J({action:"move",account:k.num,slot:Number(L.target.value)},`move-${k.num}`).then(()=>M(!0)),children:W3(n.accounts??[]).map(L=>m.jsx("option",{value:L,children:L},L))})}),m.jsx("span",{className:"ap-manage-hint",children:"rotation order"})]}),m.jsxs("div",{className:"ap-manage-row",children:[m.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,title:"Copy this account to another agents-deck. The share carries a live login and expires in 10 minutes.",onClick:async()=>{T(!1);const L=await J({action:"share",account:k.num},`share-${k.num}`);L!=null&&L.ok&&q({num:k.num,blob:L.blob,expiresAt:L.expiresAt})},children:"share…"}),m.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),J({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=K3(O.expiresAt,g),oe=L.tone==="gone";return m.jsxs("div",{className:`ap-share${oe?" expired":""}`,children:[m.jsx("code",{className:"ap-share-blob",children:O.blob}),m.jsxs("div",{className:"ap-share-foot",children:[m.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,onClick:async()=>{if(oe){T(!1);const $=await J({action:"share",account:k.num},`share-${k.num}`);$!=null&&$.ok&&q({num:k.num,blob:$.blob,expiresAt:$.expiresAt});return}await G3(O.blob)&&(T(!0),window.setTimeout(()=>T(!1),1800))},children:oe?"make a new share":F?"copied":"copy"}),m.jsxs("span",{className:"ap-manage-hint",children:["carries a live login · ",m.jsx("span",{className:`ap-share-expiry ${L.tone}`,children:L.text})]})]})]})})()]})]},k.num)),(s==null?void 0:s.ok)&&m.jsxs("div",{className:"ap-auto",children:[m.jsxs("div",{className:"ap-auto-head",children:[m.jsx("span",{className:"ap-auto-title",children:"Auto-switch"}),m.jsxs("span",{className:"ap-auto-ctl",children:[H!=null&&m.jsxs("span",{className:`ap-auto-now${U?" near":""}`,children:[Math.round(H),"%"]}),m.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:m.jsx("select",{"aria-label":"Switch threshold",value:Z,disabled:l!=null,onChange:k=>B({action:"setting",key:"autoswitch.threshold",value:k.target.value},"threshold").then(()=>M(!0)),children:z3.map(k=>m.jsxs("option",{value:k,children:[k,"%"]},k))})}),m.jsxs("button",{type:"button",className:`ap-auto-state toggle${s.enabled?" live":""}`,role:"switch","aria-checked":s.enabled,disabled:l!=null,onClick:()=>B({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:[m.jsx("i",{className:s.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),s.enabled?"on":"off"]})]})]}),s.external&&m.jsxs("p",{className:"ap-auto-note",children:[m.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",m.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",s.enabled?" — this toggle takes over when you stop it.":"."]}),s.lastTick&&m.jsx("div",{className:"ap-auto-foot",children:m.jsxs("span",{className:"ap-auto-result",children:["checked ",ux(s.lastTick.at,g)]})})]}),p&&m.jsx("div",{className:"ap-failure",children:p}),m.jsx("p",{className:"ap-footnote",title:"Anthropic's usage endpoint allows roughly 28–30 requests per hour per account, shared by every tool on this machine — polling it from here would rate-limit your account. So the deck never fetches: it asks claude-swap to collect while this panel is open, at most once every three minutes, and claude-swap decides whether that touches the network at all.",children:"Collected by claude-swap while this panel is open."})]}):m.jsx("div",{className:"ap-empty",children:n.reason==="no_cswap"?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"claude-swap isn't installed."}),m.jsx("span",{className:"ap-hint",children:"This panel reads the account store claude-swap keeps — without it there is nothing to show. It is a separate tool, published on PyPI, so it does not come with this package."}),n.hint&&m.jsx("code",{className:"ap-cmd",children:n.hint}),m.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",m.jsx("strong",{children:"+"})," button above."]})]}):n.reason==="no_accounts"?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"No accounts added yet."}),m.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",m.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"Couldn't read the account store."}),m.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",n.reason?` (${n.reason})`:"","."]})]})}),S&&m.jsx(D3,{onClose:()=>b(!1),onChanged:()=>M(!0)})]})}const X3=3e4;function Q3({bundle:e,running:n,lastTried:i}){return!n||e===n?!1:i!==n}function Z3(e){const n=e.thresholdMs??X3;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 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 cx(e){return e.replace(/^anthropic\./,"").replace(/^claude-/,"").replace(/-\d{8}$/,"")}function kl(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]=I.useState(null),[s,o]=I.useState(!1),l=(u=!1)=>{o(!0);const f=`/api/ccusage?since=${J3(e)}${u?"&refresh=1":""}`;fetch(f).then(p=>p.json()).then(i).catch(()=>i({ok:!1,error:"request failed"})).finally(()=>o(!1))};return I.useEffect(()=>{l(!1)},[e]),{data:n,loading:s,reload:()=>l(!0)}}function nO({onClose:e}){var b,E;const[n,i]=I.useState(30),[s,o]=I.useState(null),{data:l,loading:u,reload:c}=tO(n);I.useEffect(()=>{const N=j=>{j.key==="Escape"&&e()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e]);const f=l!=null&&l.ok?l.days??[]:[],p=I.useMemo(()=>f.reduce((N,j)=>Math.max(N,j.totalCost),0),[f]),{totalCost:h,totalTok:g,inOut:y,cacheRead:w,modelCosts:C}=I.useMemo(()=>{let N=0,j=0,P=0,O=0;const q=new Map;for(const F of f){N+=F.totalCost,j+=F.totalTokens,P+=F.inputTokens+F.outputTokens,O+=F.cacheReadTokens;for(const T of F.modelBreakdowns)q.set(T.modelName,(q.get(T.modelName)??0)+T.cost)}return{totalCost:N,totalTok:j,inOut:P,cacheRead:O,modelCosts:q}},[f]),_=I.useMemo(()=>Array.from(C.entries()).sort((N,j)=>j[1]-N[1]),[C]),S=s?f.find(N=>N.period===s)??null:null;return m.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:m.jsxs("div",{className:"uh-modal",onClick:N=>N.stopPropagation(),role:"dialog","aria-label":"Usage history",children:[m.jsxs("header",{className:"uh-head",children:[m.jsxs("div",{className:"uh-titlewrap",children:[m.jsx("div",{className:"uh-title",children:"Usage history"}),m.jsx("div",{className:"uh-sub",children:"via ccusage · local Claude / Codex logs"})]}),m.jsx("div",{className:"uh-range",role:"tablist","aria-label":"Range",children:eO.map(N=>m.jsxs("button",{role:"tab","aria-selected":n===N,className:`uh-range-btn${n===N?" on":""}`,onClick:()=>{i(N),o(null)},children:[N,"d"]},N))}),m.jsx("button",{className:"btn icon-btn uh-reload",onClick:c,title:"Re-run ccusage","aria-label":"Reload",children:"↻"}),m.jsx("button",{className:"uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),u&&f.length===0?m.jsx("div",{className:"uh-status",children:"running ccusage… (first run downloads the package)"}):l&&!l.ok?m.jsxs("div",{className:"uh-status uh-err",children:["ccusage failed: ",l.error]}):f.length===0?m.jsx("div",{className:"uh-status",children:"no usage in this range"}):m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"uh-totals",children:[m.jsx(El,{label:"total cost",val:Be(h),accent:!0}),m.jsx(El,{label:"tokens",val:Ui(g)}),m.jsx(El,{label:"input+output",val:Ui(y)}),m.jsx(El,{label:"cache reads",val:Ui(w)})]}),m.jsx("div",{className:"uh-chart",role:"img","aria-label":"Daily cost by model",children:f.map(N=>{const j=p>0?N.totalCost/p*100:0,P=N.period===s;return m.jsxs("button",{className:`uh-bar-col${P?" sel":""}`,onClick:()=>o(P?null:N.period),title:`${N.period} · ${Be(N.totalCost)}`,style:{flexBasis:`${100/f.length}%`},children:[m.jsx("div",{className:"uh-bar",style:{height:`${Math.max(j,N.totalCost>0?2:0)}%`},children:N.modelBreakdowns.slice().sort((O,q)=>q.cost-O.cost).map(O=>{const q=N.totalCost>0?O.cost/N.totalCost*100:0;return m.jsx("div",{className:"uh-bar-seg",style:{height:`${q}%`,background:kl(O.modelName)}},O.modelName)})}),m.jsx("span",{className:"uh-bar-label",children:N.period.slice(5)})]},N.period)})}),m.jsx("div",{className:"uh-legend",children:_.map(([N,j])=>m.jsxs("span",{className:"uh-legend-item",children:[m.jsx("span",{className:"uh-legend-dot",style:{background:kl(N)}}),cx(N)," ",m.jsx("span",{className:"uh-legend-cost",children:Be(j)})]},N))}),S&&m.jsxs("div",{className:"uh-detail",children:[m.jsxs("div",{className:"uh-detail-head",children:[m.jsx("span",{className:"uh-detail-date",children:S.period}),m.jsx("span",{className:"uh-detail-cost",children:Be(S.totalCost)}),(E=(b=S.metadata)==null?void 0:b.agents)!=null&&E.length?m.jsx("span",{className:"uh-detail-agents",children:S.metadata.agents.join(" · ")}):null]}),m.jsxs("div",{className:"uh-detail-mini",children:[m.jsx(Nl,{label:"input",val:Ui(S.inputTokens)}),m.jsx(Nl,{label:"output",val:Ui(S.outputTokens)}),m.jsx(Nl,{label:"cache write",val:Ui(S.cacheCreationTokens)}),m.jsx(Nl,{label:"cache read",val:Ui(S.cacheReadTokens)})]}),m.jsx("div",{className:"uh-detail-models",children:S.modelBreakdowns.slice().sort((N,j)=>j.cost-N.cost).map(N=>{const j=S.totalCost>0?N.cost/S.totalCost*100:0;return m.jsxs("div",{className:"uh-model-row",children:[m.jsxs("span",{className:"uh-model-name",children:[m.jsx("span",{className:"uh-legend-dot",style:{background:kl(N.modelName)}}),cx(N.modelName)]}),m.jsx("span",{className:"uh-model-bar",children:m.jsx("span",{className:"uh-model-bar-fill",style:{width:`${j}%`,background:kl(N.modelName)}})}),m.jsx("span",{className:"uh-model-cost",children:Be(N.cost)})]},N.modelName)})})]})]})]})})}function El({label:e,val:n,accent:i}){return m.jsxs("div",{className:"uh-stat",children:[m.jsx("span",{className:`uh-stat-val${i?" accent":""}`,children:n}),m.jsx("span",{className:"uh-stat-label",children:e})]})}function Nl({label:e,val:n}){return m.jsxs("div",{className:"uh-ministat",children:[m.jsx("span",{className:"uh-ministat-val",children:n}),m.jsx("span",{className:"uh-ministat-label",children:e})]})}function 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,dx;function rO(){if(dx)return ad;dx=1;function e(){this.__data__=[],this.size=0}return ad=e,ad}var ld,fx;function Ws(){if(fx)return ld;fx=1;function e(n,i){return n===i||n!==n&&i!==i}return ld=e,ld}var ud,hx;function Ql(){if(hx)return ud;hx=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,px;function iO(){if(px)return cd;px=1;var e=Ql(),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,mx;function sO(){if(mx)return dd;mx=1;var e=Ql();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,gx;function oO(){if(gx)return fd;gx=1;var e=Ql();function n(i){return e(this.__data__,i)>-1}return fd=n,fd}var hd,vx;function aO(){if(vx)return hd;vx=1;var e=Ql();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,yx;function Zl(){if(yx)return pd;yx=1;var e=rO(),n=iO(),i=sO(),s=oO(),o=aO();function l(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var p=u[c];this.set(p[0],p[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,wx;function lO(){if(wx)return md;wx=1;var e=Zl();function n(){this.__data__=new e,this.size=0}return md=n,md}var gd,xx;function uO(){if(xx)return gd;xx=1;function e(n){var i=this.__data__,s=i.delete(n);return this.size=i.size,s}return gd=e,gd}var vd,_x;function cO(){if(_x)return vd;_x=1;function e(n){return this.__data__.get(n)}return vd=e,vd}var yd,Sx;function dO(){if(Sx)return yd;Sx=1;function e(n){return this.__data__.has(n)}return yd=e,yd}var wd,bx;function bN(){if(bx)return wd;bx=1;var e=typeof dl=="object"&&dl&&dl.Object===Object&&dl;return wd=e,wd}var xd,kx;function Jn(){if(kx)return xd;kx=1;var e=bN(),n=typeof self=="object"&&self&&self.Object===Object&&self,i=e||n||Function("return this")();return xd=i,xd}var _d,Ex;function Gs(){if(Ex)return _d;Ex=1;var e=Jn(),n=e.Symbol;return _d=n,_d}var Sd,Nx;function fO(){if(Nx)return Sd;Nx=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),f=u[o];try{u[o]=void 0;var p=!0}catch{}var h=s.call(u);return p&&(c?u[o]=f:delete u[o]),h}return Sd=l,Sd}var bd,Cx;function hO(){if(Cx)return bd;Cx=1;var e=Object.prototype,n=e.toString;function i(s){return n.call(s)}return bd=i,bd}var kd,jx;function Ji(){if(jx)return kd;jx=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,Rx;function aa(){if(Rx)return Nd;Rx=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 f=e(c);return f==s||f==o||f==i||f==l}return Nd=u,Nd}var Cd,Ax;function pO(){if(Ax)return Cd;Ax=1;var e=Jn(),n=e["__core-js_shared__"];return Cd=n,Cd}var jd,Ix;function mO(){if(Ix)return jd;Ix=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 Td,Mx;function kN(){if(Mx)return Td;Mx=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 Td=i,Td}var Rd,Px;function gO(){if(Px)return Rd;Px=1;var e=aa(),n=mO(),i=On(),s=kN(),o=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,f=u.toString,p=c.hasOwnProperty,h=RegExp("^"+f.call(p).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function g(y){if(!i(y)||n(y))return!1;var w=e(y)?h:l;return w.test(s(y))}return Rd=g,Rd}var Ad,Ox;function vO(){if(Ox)return Ad;Ox=1;function e(n,i){return n==null?void 0:n[i]}return Ad=e,Ad}var Id,qx;function es(){if(qx)return Id;qx=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,Lx;function vv(){if(Lx)return Md;Lx=1;var e=es(),n=Jn(),i=e(n,"Map");return Md=i,Md}var Pd,$x;function Jl(){if($x)return Pd;$x=1;var e=es(),n=e(Object,"create");return Pd=n,Pd}var Od,Dx;function yO(){if(Dx)return Od;Dx=1;var e=Jl();function n(){this.__data__=e?e(null):{},this.size=0}return Od=n,Od}var qd,Fx;function wO(){if(Fx)return qd;Fx=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,zx;function xO(){if(zx)return Ld;zx=1;var e=Jl(),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,Bx;function _O(){if(Bx)return $d;Bx=1;var e=Jl(),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,Ux;function SO(){if(Ux)return Dd;Ux=1;var e=Jl(),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,Hx;function bO(){if(Hx)return Fd;Hx=1;var e=yO(),n=wO(),i=xO(),s=_O(),o=SO();function l(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var p=u[c];this.set(p[0],p[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,Vx;function kO(){if(Vx)return zd;Vx=1;var e=bO(),n=Zl(),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,Wx;function EO(){if(Wx)return Bd;Wx=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,Gx;function eu(){if(Gx)return Ud;Gx=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,Kx;function NO(){if(Kx)return Hd;Kx=1;var e=eu();function n(i){var s=e(this,i).delete(i);return this.size-=s?1:0,s}return Hd=n,Hd}var Vd,Yx;function CO(){if(Yx)return Vd;Yx=1;var e=eu();function n(i){return e(this,i).get(i)}return Vd=n,Vd}var Wd,Xx;function jO(){if(Xx)return Wd;Xx=1;var e=eu();function n(i){return e(this,i).has(i)}return Wd=n,Wd}var Gd,Qx;function TO(){if(Qx)return Gd;Qx=1;var e=eu();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,Zx;function yv(){if(Zx)return Kd;Zx=1;var e=kO(),n=NO(),i=CO(),s=jO(),o=TO();function l(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var p=u[c];this.set(p[0],p[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,Jx;function RO(){if(Jx)return Yd;Jx=1;var e=Zl(),n=vv(),i=yv(),s=200;function o(l,u){var c=this.__data__;if(c instanceof e){var f=c.__data__;if(!n||f.length<s-1)return f.push([l,u]),this.size=++c.size,this;c=this.__data__=new i(f)}return c.set(l,u),this.size=c.size,this}return Yd=o,Yd}var Xd,e1;function tu(){if(e1)return Xd;e1=1;var e=Zl(),n=lO(),i=uO(),s=cO(),o=dO(),l=RO();function u(c){var f=this.__data__=new e(c);this.size=f.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,t1;function wv(){if(t1)return Qd;t1=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,n1;function EN(){if(n1)return Zd;n1=1;var e=es(),n=(function(){try{var i=e(Object,"defineProperty");return i({},"",{}),i}catch{}})();return Zd=n,Zd}var Jd,r1;function nu(){if(r1)return Jd;r1=1;var e=EN();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,i1;function ru(){if(i1)return ef;i1=1;var e=nu(),n=Ws(),i=Object.prototype,s=i.hasOwnProperty;function o(l,u,c){var f=l[u];(!(s.call(l,u)&&n(f,c))||c===void 0&&!(u in l))&&e(l,u,c)}return ef=o,ef}var tf,s1;function la(){if(s1)return tf;s1=1;var e=ru(),n=nu();function i(s,o,l,u){var c=!l;l||(l={});for(var f=-1,p=o.length;++f<p;){var h=o[f],g=u?u(l[h],s[h],h,l,s):void 0;g===void 0&&(g=s[h]),c?n(l,h,g):e(l,h,g)}return l}return tf=i,tf}var nf,o1;function AO(){if(o1)return nf;o1=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,a1;function fr(){if(a1)return rf;a1=1;function e(n){return n!=null&&typeof n=="object"}return rf=e,rf}var sf,l1;function IO(){if(l1)return sf;l1=1;var e=Ji(),n=fr(),i="[object Arguments]";function s(o){return n(o)&&e(o)==i}return sf=s,sf}var of,u1;function ua(){if(u1)return of;u1=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,c1;function St(){if(c1)return af;c1=1;var e=Array.isArray;return af=e,af}var Uo={exports:{}},lf,d1;function MO(){if(d1)return lf;d1=1;function e(){return!1}return lf=e,lf}Uo.exports;var f1;function Ks(){return f1||(f1=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,f=c?c.isBuffer:void 0,p=f||s;e.exports=p})(Uo,Uo.exports)),Uo.exports}var uf,h1;function iu(){if(h1)return uf;h1=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,p1;function xv(){if(p1)return cf;p1=1;var e=9007199254740991;function n(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=e}return cf=n,cf}var df,m1;function PO(){if(m1)return df;m1=1;var e=Ji(),n=xv(),i=fr(),s="[object Arguments]",o="[object Array]",l="[object Boolean]",u="[object Date]",c="[object Error]",f="[object Function]",p="[object Map]",h="[object Number]",g="[object Object]",y="[object RegExp]",w="[object Set]",C="[object String]",_="[object WeakMap]",S="[object ArrayBuffer]",b="[object DataView]",E="[object Float32Array]",N="[object Float64Array]",j="[object Int8Array]",P="[object Int16Array]",O="[object Int32Array]",q="[object Uint8Array]",F="[object Uint8ClampedArray]",T="[object Uint16Array]",M="[object Uint32Array]",B={};B[E]=B[N]=B[j]=B[P]=B[O]=B[q]=B[F]=B[T]=B[M]=!0,B[s]=B[o]=B[S]=B[l]=B[b]=B[u]=B[c]=B[f]=B[p]=B[h]=B[g]=B[y]=B[w]=B[C]=B[_]=!1;function J(Z){return i(Z)&&n(Z.length)&&!!B[e(Z)]}return df=J,df}var ff,g1;function su(){if(g1)return ff;g1=1;function e(n){return function(i){return n(i)}}return ff=e,ff}var Ho={exports:{}};Ho.exports;var v1;function _v(){return v1||(v1=1,(function(e,n){var i=bN(),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 f=o&&o.require&&o.require("util").types;return f||u&&u.binding&&u.binding("util")}catch{}})();e.exports=c})(Ho,Ho.exports)),Ho.exports}var hf,y1;function ca(){if(y1)return hf;y1=1;var e=PO(),n=su(),i=_v(),s=i&&i.isTypedArray,o=s?n(s):e;return hf=o,hf}var pf,w1;function NN(){if(w1)return pf;w1=1;var e=AO(),n=ua(),i=St(),s=Ks(),o=iu(),l=ca(),u=Object.prototype,c=u.hasOwnProperty;function f(p,h){var g=i(p),y=!g&&n(p),w=!g&&!y&&s(p),C=!g&&!y&&!w&&l(p),_=g||y||w||C,S=_?e(p.length,String):[],b=S.length;for(var E in p)(h||c.call(p,E))&&!(_&&(E=="length"||w&&(E=="offset"||E=="parent")||C&&(E=="buffer"||E=="byteLength"||E=="byteOffset")||o(E,b)))&&S.push(E);return S}return pf=f,pf}var mf,x1;function ou(){if(x1)return mf;x1=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,_1;function CN(){if(_1)return gf;_1=1;function e(n,i){return function(s){return n(i(s))}}return gf=e,gf}var vf,S1;function OO(){if(S1)return vf;S1=1;var e=CN(),n=e(Object.keys,Object);return vf=n,vf}var yf,b1;function Sv(){if(b1)return yf;b1=1;var e=ou(),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,k1;function qr(){if(k1)return wf;k1=1;var e=aa(),n=xv();function i(s){return s!=null&&n(s.length)&&!e(s)}return wf=i,wf}var xf,E1;function yi(){if(E1)return xf;E1=1;var e=NN(),n=Sv(),i=qr();function s(o){return i(o)?e(o):n(o)}return xf=s,xf}var _f,N1;function qO(){if(N1)return _f;N1=1;var e=la(),n=yi();function i(s,o){return s&&e(o,n(o),s)}return _f=i,_f}var Sf,C1;function LO(){if(C1)return Sf;C1=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,j1;function $O(){if(j1)return bf;j1=1;var e=On(),n=ou(),i=LO(),s=Object.prototype,o=s.hasOwnProperty;function l(u){if(!e(u))return i(u);var c=n(u),f=[];for(var p in u)p=="constructor"&&(c||!o.call(u,p))||f.push(p);return f}return bf=l,bf}var kf,T1;function ts(){if(T1)return kf;T1=1;var e=NN(),n=$O(),i=qr();function s(o){return i(o)?e(o,!0):n(o)}return kf=s,kf}var Ef,R1;function DO(){if(R1)return Ef;R1=1;var e=la(),n=ts();function i(s,o){return s&&e(o,n(o),s)}return Ef=i,Ef}var Vo={exports:{}};Vo.exports;var A1;function jN(){return A1||(A1=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 f(p,h){if(h)return p.slice();var g=p.length,y=c?c(g):new p.constructor(g);return p.copy(y),y}e.exports=f})(Vo,Vo.exports)),Vo.exports}var Nf,I1;function TN(){if(I1)return Nf;I1=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,M1;function RN(){if(M1)return Cf;M1=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,P1;function AN(){if(P1)return jf;P1=1;function e(){return[]}return jf=e,jf}var Tf,O1;function bv(){if(O1)return Tf;O1=1;var e=RN(),n=AN(),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 Tf=l,Tf}var Rf,q1;function FO(){if(q1)return Rf;q1=1;var e=la(),n=bv();function i(s,o){return e(s,n(s),o)}return Rf=i,Rf}var Af,L1;function kv(){if(L1)return Af;L1=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,$1;function au(){if($1)return If;$1=1;var e=CN(),n=e(Object.getPrototypeOf,Object);return If=n,If}var Mf,D1;function IN(){if(D1)return Mf;D1=1;var e=kv(),n=au(),i=bv(),s=AN(),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,F1;function zO(){if(F1)return Pf;F1=1;var e=la(),n=IN();function i(s,o){return e(s,n(s),o)}return Pf=i,Pf}var Of,z1;function MN(){if(z1)return Of;z1=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,B1;function PN(){if(B1)return qf;B1=1;var e=MN(),n=bv(),i=yi();function s(o){return e(o,i,n)}return qf=s,qf}var Lf,U1;function BO(){if(U1)return Lf;U1=1;var e=MN(),n=IN(),i=ts();function s(o){return e(o,i,n)}return Lf=s,Lf}var $f,H1;function UO(){if(H1)return $f;H1=1;var e=es(),n=Jn(),i=e(n,"DataView");return $f=i,$f}var Df,V1;function HO(){if(V1)return Df;V1=1;var e=es(),n=Jn(),i=e(n,"Promise");return Df=i,Df}var Ff,W1;function ON(){if(W1)return Ff;W1=1;var e=es(),n=Jn(),i=e(n,"Set");return Ff=i,Ff}var zf,G1;function VO(){if(G1)return zf;G1=1;var e=es(),n=Jn(),i=e(n,"WeakMap");return zf=i,zf}var Bf,K1;function Ys(){if(K1)return Bf;K1=1;var e=UO(),n=vv(),i=HO(),s=ON(),o=VO(),l=Ji(),u=kN(),c="[object Map]",f="[object Object]",p="[object Promise]",h="[object Set]",g="[object WeakMap]",y="[object DataView]",w=u(e),C=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())!=p||s&&E(new s)!=h||o&&E(new o)!=g)&&(E=function(N){var j=l(N),P=j==f?N.constructor:void 0,O=P?u(P):"";if(O)switch(O){case w:return y;case C:return c;case _:return p;case S:return h;case b:return g}return j}),Bf=E,Bf}var Uf,Y1;function WO(){if(Y1)return Uf;Y1=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,X1;function qN(){if(X1)return Hf;X1=1;var e=Jn(),n=e.Uint8Array;return Hf=n,Hf}var Vf,Q1;function Ev(){if(Q1)return Vf;Q1=1;var e=qN();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,Z1;function GO(){if(Z1)return Wf;Z1=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,J1;function KO(){if(J1)return Gf;J1=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,e_;function YO(){if(e_)return Kf;e_=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,t_;function LN(){if(t_)return Yf;t_=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,n_;function XO(){if(n_)return Xf;n_=1;var e=Ev(),n=GO(),i=KO(),s=YO(),o=LN(),l="[object Boolean]",u="[object Date]",c="[object Map]",f="[object Number]",p="[object RegExp]",h="[object Set]",g="[object String]",y="[object Symbol]",w="[object ArrayBuffer]",C="[object DataView]",_="[object Float32Array]",S="[object Float64Array]",b="[object Int8Array]",E="[object Int16Array]",N="[object Int32Array]",j="[object Uint8Array]",P="[object Uint8ClampedArray]",O="[object Uint16Array]",q="[object Uint32Array]";function F(T,M,B){var J=T.constructor;switch(M){case w:return e(T);case l:case u:return new J(+T);case C:return n(T,B);case _:case S:case b:case E:case N:case j:case P:case O:case q:return o(T,B);case c:return new J;case f:case g:return new J(T);case p:return i(T);case h:return new J;case y:return s(T)}}return Xf=F,Xf}var Qf,r_;function $N(){if(r_)return Qf;r_=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,i_;function DN(){if(i_)return Zf;i_=1;var e=$N(),n=au(),i=ou();function s(o){return typeof o.constructor=="function"&&!i(o)?e(n(o)):{}}return Zf=s,Zf}var Jf,s_;function QO(){if(s_)return Jf;s_=1;var e=Ys(),n=fr(),i="[object Map]";function s(o){return n(o)&&e(o)==i}return Jf=s,Jf}var eh,o_;function ZO(){if(o_)return eh;o_=1;var e=QO(),n=su(),i=_v(),s=i&&i.isMap,o=s?n(s):e;return eh=o,eh}var th,a_;function JO(){if(a_)return th;a_=1;var e=Ys(),n=fr(),i="[object Set]";function s(o){return n(o)&&e(o)==i}return th=s,th}var nh,l_;function eq(){if(l_)return nh;l_=1;var e=JO(),n=su(),i=_v(),s=i&&i.isSet,o=s?n(s):e;return nh=o,nh}var rh,u_;function FN(){if(u_)return rh;u_=1;var e=tu(),n=wv(),i=ru(),s=qO(),o=DO(),l=jN(),u=TN(),c=FO(),f=zO(),p=PN(),h=BO(),g=Ys(),y=WO(),w=XO(),C=DN(),_=St(),S=Ks(),b=ZO(),E=On(),N=eq(),j=yi(),P=ts(),O=1,q=2,F=4,T="[object Arguments]",M="[object Array]",B="[object Boolean]",J="[object Date]",Z="[object Error]",A="[object Function]",H="[object GeneratorFunction]",U="[object Map]",ne="[object Number]",Q="[object Object]",D="[object RegExp]",G="[object Set]",k="[object String]",L="[object Symbol]",oe="[object WeakMap]",$="[object ArrayBuffer]",Y="[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[Y]=ke[B]=ke[J]=ke[ee]=ke[se]=ke[ae]=ke[pe]=ke[ge]=ke[U]=ke[ne]=ke[Q]=ke[D]=ke[G]=ke[k]=ke[L]=ke[Ae]=ke[Oe]=ke[Me]=ke[Pe]=!0,ke[Z]=ke[A]=ke[oe]=!1;function We(ve,ye,Ge,ut,it,Ke){var $e,Qe=ye&O,bt=ye&q,ct=ye&F;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=g(ve),kt=mt==A||mt==H;if(S(ve))return l(ve,Qe);if(mt==Q||mt==T||kt&&!it){if($e=bt||kt?{}:C(ve),!Qe)return bt?f(ve,o($e,ve)):c(ve,s($e,ve))}else{if(!ke[mt])return it?ve:{};$e=w(ve,mt,Qe)}}Ke||(Ke=new e);var He=Ke.get(ve);if(He)return He;Ke.set(ve,$e),N(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?h:p: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,c_;function tq(){if(c_)return ih;c_=1;var e=FN(),n=4;function i(s){return e(s,n)}return ih=i,ih}var sh,d_;function Nv(){if(d_)return sh;d_=1;function e(n){return function(){return n}}return sh=e,sh}var oh,f_;function nq(){if(f_)return oh;f_=1;function e(n){return function(i,s,o){for(var l=-1,u=Object(i),c=o(i),f=c.length;f--;){var p=c[n?f:++l];if(s(u[p],p,u)===!1)break}return i}}return oh=e,oh}var ah,h_;function Cv(){if(h_)return ah;h_=1;var e=nq(),n=e();return ah=n,ah}var lh,p_;function jv(){if(p_)return lh;p_=1;var e=Cv(),n=yi();function i(s,o){return s&&e(s,o,n)}return lh=i,lh}var uh,m_;function rq(){if(m_)return uh;m_=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,f=Object(o);(s?c--:++c<u)&&l(f[c],c,f)!==!1;);return o}}return uh=n,uh}var ch,g_;function lu(){if(g_)return ch;g_=1;var e=jv(),n=rq(),i=n(e);return ch=i,ch}var dh,v_;function ns(){if(v_)return dh;v_=1;function e(n){return n}return dh=e,dh}var fh,y_;function zN(){if(y_)return fh;y_=1;var e=ns();function n(i){return typeof i=="function"?i:e}return fh=n,fh}var hh,w_;function BN(){if(w_)return hh;w_=1;var e=wv(),n=lu(),i=zN(),s=St();function o(l,u){var c=s(l)?e:n;return c(l,i(u))}return hh=o,hh}var ph,x_;function UN(){return x_||(x_=1,ph=BN()),ph}var mh,__;function iq(){if(__)return mh;__=1;var e=lu();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,S_;function sq(){if(S_)return gh;S_=1;var e="__lodash_hash_undefined__";function n(i){return this.__data__.set(i,e),this}return gh=n,gh}var vh,b_;function oq(){if(b_)return vh;b_=1;function e(n){return this.__data__.has(n)}return vh=e,vh}var yh,k_;function HN(){if(k_)return yh;k_=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,E_;function aq(){if(E_)return wh;E_=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,N_;function VN(){if(N_)return xh;N_=1;function e(n,i){return n.has(i)}return xh=e,xh}var _h,C_;function WN(){if(C_)return _h;C_=1;var e=HN(),n=aq(),i=VN(),s=1,o=2;function l(u,c,f,p,h,g){var y=f&s,w=u.length,C=c.length;if(w!=C&&!(y&&C>w))return!1;var _=g.get(u),S=g.get(c);if(_&&S)return _==c&&S==u;var b=-1,E=!0,N=f&o?new e:void 0;for(g.set(u,c),g.set(c,u);++b<w;){var j=u[b],P=c[b];if(p)var O=y?p(P,j,b,c,u,g):p(j,P,b,u,c,g);if(O!==void 0){if(O)continue;E=!1;break}if(N){if(!n(c,function(q,F){if(!i(N,F)&&(j===q||h(j,q,f,p,g)))return N.push(F)})){E=!1;break}}else if(!(j===P||h(j,P,f,p,g))){E=!1;break}}return g.delete(u),g.delete(c),E}return _h=l,_h}var Sh,j_;function lq(){if(j_)return Sh;j_=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 Tv(){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,R_;function uq(){if(R_)return kh;R_=1;var e=Gs(),n=qN(),i=Ws(),s=WN(),o=lq(),l=Tv(),u=1,c=2,f="[object Boolean]",p="[object Date]",h="[object Error]",g="[object Map]",y="[object Number]",w="[object RegExp]",C="[object Set]",_="[object String]",S="[object Symbol]",b="[object ArrayBuffer]",E="[object DataView]",N=e?e.prototype:void 0,j=N?N.valueOf:void 0;function P(O,q,F,T,M,B,J){switch(F){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||!B(new n(O),new n(q)));case f:case p:case y:return i(+O,+q);case h:return O.name==q.name&&O.message==q.message;case w:case _:return O==q+"";case g:var Z=o;case C:var A=T&u;if(Z||(Z=l),O.size!=q.size&&!A)return!1;var H=J.get(O);if(H)return H==q;T|=c,J.set(O,q);var U=s(Z(O),Z(q),T,M,B,J);return J.delete(O),U;case S:if(j)return j.call(O)==j.call(q)}return!1}return kh=P,kh}var Eh,A_;function cq(){if(A_)return Eh;A_=1;var e=PN(),n=1,i=Object.prototype,s=i.hasOwnProperty;function o(l,u,c,f,p,h){var g=c&n,y=e(l),w=y.length,C=e(u),_=C.length;if(w!=_&&!g)return!1;for(var S=w;S--;){var b=y[S];if(!(g?b in u:s.call(u,b)))return!1}var E=h.get(l),N=h.get(u);if(E&&N)return E==u&&N==l;var j=!0;h.set(l,u),h.set(u,l);for(var P=g;++S<w;){b=y[S];var O=l[b],q=u[b];if(f)var F=g?f(q,O,b,u,l,h):f(O,q,b,l,u,h);if(!(F===void 0?O===q||p(O,q,c,f,h):F)){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 h.delete(l),h.delete(u),j}return Eh=o,Eh}var Nh,I_;function dq(){if(I_)return Nh;I_=1;var e=tu(),n=WN(),i=uq(),s=cq(),o=Ys(),l=St(),u=Ks(),c=ca(),f=1,p="[object Arguments]",h="[object Array]",g="[object Object]",y=Object.prototype,w=y.hasOwnProperty;function C(_,S,b,E,N,j){var P=l(_),O=l(S),q=P?h:o(_),F=O?h:o(S);q=q==p?g:q,F=F==p?g:F;var T=q==g,M=F==g,B=q==F;if(B&&u(_)){if(!u(S))return!1;P=!0,T=!1}if(B&&!T)return j||(j=new e),P||c(_)?n(_,S,b,E,N,j):i(_,S,q,b,E,N,j);if(!(b&f)){var J=T&&w.call(_,"__wrapped__"),Z=M&&w.call(S,"__wrapped__");if(J||Z){var A=J?_.value():_,H=Z?S.value():S;return j||(j=new e),N(A,H,b,E,j)}}return B?(j||(j=new e),s(_,S,b,E,N,j)):!1}return Nh=C,Nh}var Ch,M_;function GN(){if(M_)return Ch;M_=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,P_;function fq(){if(P_)return jh;P_=1;var e=tu(),n=GN(),i=1,s=2;function o(l,u,c,f){var p=c.length,h=p,g=!f;if(l==null)return!h;for(l=Object(l);p--;){var y=c[p];if(g&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++p<h;){y=c[p];var w=y[0],C=l[w],_=y[1];if(g&&y[2]){if(C===void 0&&!(w in l))return!1}else{var S=new e;if(f)var b=f(C,_,w,l,u,S);if(!(b===void 0?n(_,C,i|s,f,S):b))return!1}}return!0}return jh=o,jh}var Th,O_;function KN(){if(O_)return Th;O_=1;var e=On();function n(i){return i===i&&!e(i)}return Th=n,Th}var Rh,q_;function hq(){if(q_)return Rh;q_=1;var e=KN(),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 Rh=i,Rh}var Ah,L_;function YN(){if(L_)return Ah;L_=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,$_;function pq(){if($_)return Ih;$_=1;var e=fq(),n=hq(),i=YN();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,D_;function Xs(){if(D_)return Mh;D_=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,F_;function Rv(){if(F_)return Ph;F_=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,z_;function mq(){if(z_)return Oh;z_=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],f=l.cache;if(f.has(c))return f.get(c);var p=s.apply(this,u);return l.cache=f.set(c,p)||f,p};return l.cache=new(i.Cache||e),l}return i.Cache=e,Oh=i,Oh}var qh,B_;function gq(){if(B_)return qh;B_=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,U_;function vq(){if(U_)return Lh;U_=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,f,p){l.push(f?p.replace(i,"$1"):c||u)}),l});return Lh=s,Lh}var $h,H_;function uu(){if(H_)return $h;H_=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,V_;function yq(){if(V_)return Dh;V_=1;var e=Gs(),n=uu(),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 f=c+"";return f=="0"&&1/c==-1/0?"-0":f}return Dh=u,Dh}var Fh,W_;function XN(){if(W_)return Fh;W_=1;var e=yq();function n(i){return i==null?"":e(i)}return Fh=n,Fh}var zh,G_;function cu(){if(G_)return zh;G_=1;var e=St(),n=Rv(),i=vq(),s=XN();function o(l,u){return e(l)?l:n(l,u)?[l]:i(s(l))}return zh=o,zh}var Bh,K_;function da(){if(K_)return Bh;K_=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,Y_;function du(){if(Y_)return Uh;Y_=1;var e=cu(),n=da();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,X_;function wq(){if(X_)return Hh;X_=1;var e=du();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,Q_;function xq(){if(Q_)return Vh;Q_=1;function e(n,i){return n!=null&&i in Object(n)}return Vh=e,Vh}var Wh,Z_;function QN(){if(Z_)return Wh;Z_=1;var e=cu(),n=ua(),i=St(),s=iu(),o=xv(),l=da();function u(c,f,p){f=e(f,c);for(var h=-1,g=f.length,y=!1;++h<g;){var w=l(f[h]);if(!(y=c!=null&&p(c,w)))break;c=c[w]}return y||++h!=g?y:(g=c==null?0:c.length,!!g&&o(g)&&s(w,g)&&(i(c)||n(c)))}return Wh=u,Wh}var Gh,J_;function ZN(){if(J_)return Gh;J_=1;var e=xq(),n=QN();function i(s,o){return s!=null&&n(s,o,e)}return Gh=i,Gh}var Kh,eS;function _q(){if(eS)return Kh;eS=1;var e=GN(),n=wq(),i=ZN(),s=Rv(),o=KN(),l=YN(),u=da(),c=1,f=2;function p(h,g){return s(h)&&o(g)?l(u(h),g):function(y){var w=n(y,h);return w===void 0&&w===g?i(y,h):e(g,w,c|f)}}return Kh=p,Kh}var Yh,tS;function JN(){if(tS)return Yh;tS=1;function e(n){return function(i){return i==null?void 0:i[n]}}return Yh=e,Yh}var Xh,nS;function Sq(){if(nS)return Xh;nS=1;var e=du();function n(i){return function(s){return e(s,i)}}return Xh=n,Xh}var Qh,rS;function bq(){if(rS)return Qh;rS=1;var e=JN(),n=Sq(),i=Rv(),s=da();function o(l){return i(l)?e(s(l)):n(l)}return Qh=o,Qh}var Zh,iS;function Lr(){if(iS)return Zh;iS=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,sS;function eC(){if(sS)return Jh;sS=1;var e=RN(),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,oS;function kq(){if(oS)return ep;oS=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,aS;function tC(){if(aS)return tp;aS=1;var e=kq(),n=QN();function i(s,o){return s!=null&&n(s,o,e)}return tp=i,tp}var np,lS;function Eq(){if(lS)return np;lS=1;var e=Sv(),n=Ys(),i=ua(),s=St(),o=qr(),l=Ks(),u=ou(),c=ca(),f="[object Map]",p="[object Set]",h=Object.prototype,g=h.hasOwnProperty;function y(w){if(w==null)return!0;if(o(w)&&(s(w)||typeof w=="string"||typeof w.splice=="function"||l(w)||c(w)||i(w)))return!w.length;var C=n(w);if(C==f||C==p)return!w.size;if(u(w))return!e(w).length;for(var _ in w)if(g.call(w,_))return!1;return!0}return np=y,np}var rp,uS;function nC(){if(uS)return rp;uS=1;function e(n){return n===void 0}return rp=e,rp}var ip,cS;function rC(){if(cS)return ip;cS=1;var e=lu(),n=qr();function i(s,o){var l=-1,u=n(s)?Array(s.length):[];return e(s,function(c,f,p){u[++l]=o(c,f,p)}),u}return ip=i,ip}var sp,dS;function iC(){if(dS)return sp;dS=1;var e=uu(),n=Lr(),i=rC(),s=St();function o(l,u){var c=s(l)?e:i;return c(l,n(u,3))}return sp=o,sp}var op,fS;function Nq(){if(fS)return op;fS=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,hS;function Cq(){if(hS)return ap;hS=1;function e(n,i,s,o,l){return l(n,function(u,c,f){s=o?(o=!1,u):i(s,u,c,f)}),s}return ap=e,ap}var lp,pS;function sC(){if(pS)return lp;pS=1;var e=Nq(),n=lu(),i=Lr(),s=Cq(),o=St();function l(u,c,f){var p=o(u)?e:s,h=arguments.length<3;return p(u,i(c,4),f,h,n)}return lp=l,lp}var up,mS;function jq(){if(mS)return up;mS=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,gS;function Tq(){if(gS)return cp;gS=1;var e=JN(),n=e("length");return cp=n,cp}var dp,vS;function Rq(){if(vS)return dp;vS=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 f(p){return c.test(p)}return dp=f,dp}var fp,yS;function Aq(){if(yS)return fp;yS=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+"]",f="\\ud83c[\\udffb-\\udfff]",p="(?:"+c+"|"+f+")",h="[^"+e+"]",g="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",C=p+"?",_="["+l+"]?",S="(?:"+w+"(?:"+[h,g,y].join("|")+")"+_+C+")*",b=_+C+S,E="(?:"+[h+c+"?",c,g,y,u].join("|")+")",N=RegExp(f+"(?="+f+")|"+E+b,"g");function j(P){for(var O=N.lastIndex=0;N.test(P);)++O;return O}return fp=j,fp}var hp,wS;function Iq(){if(wS)return hp;wS=1;var e=Tq(),n=Rq(),i=Aq();function s(o){return n(o)?i(o):e(o)}return hp=s,hp}var pp,xS;function Mq(){if(xS)return pp;xS=1;var e=Sv(),n=Ys(),i=qr(),s=jq(),o=Iq(),l="[object Map]",u="[object Set]";function c(f){if(f==null)return 0;if(i(f))return s(f)?o(f):f.length;var p=n(f);return p==l||p==u?f.size:e(f).length}return pp=c,pp}var mp,_S;function Pq(){if(_S)return mp;_S=1;var e=wv(),n=$N(),i=jv(),s=Lr(),o=au(),l=St(),u=Ks(),c=aa(),f=On(),p=ca();function h(g,y,w){var C=l(g),_=C||u(g)||p(g);if(y=s(y,4),w==null){var S=g&&g.constructor;_?w=C?new S:[]:f(g)?w=c(S)?n(o(g)):{}:w={}}return(_?e:i)(g,function(b,E,N){return y(w,b,E,N)}),w}return mp=h,mp}var gp,SS;function Oq(){if(SS)return gp;SS=1;var e=Gs(),n=ua(),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,bS;function Av(){if(bS)return vp;bS=1;var e=kv(),n=Oq();function i(s,o,l,u,c){var f=-1,p=s.length;for(l||(l=n),c||(c=[]);++f<p;){var h=s[f];o>0&&l(h)?o>1?i(h,o-1,l,u,c):e(c,h):u||(c[c.length]=h)}return c}return vp=i,vp}var yp,kS;function qq(){if(kS)return yp;kS=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,ES;function oC(){if(ES)return wp;ES=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,f=n(u.length-o,0),p=Array(f);++c<f;)p[c]=u[o+c];c=-1;for(var h=Array(o+1);++c<o;)h[c]=u[c];return h[o]=l(p),e(s,this,h)}}return wp=i,wp}var xp,NS;function Lq(){if(NS)return xp;NS=1;var e=Nv(),n=EN(),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,CS;function $q(){if(CS)return _p;CS=1;var e=800,n=16,i=Date.now;function s(o){var l=0,u=0;return function(){var c=i(),f=n-(c-u);if(u=c,f>0){if(++l>=e)return arguments[0]}else l=0;return o.apply(void 0,arguments)}}return _p=s,_p}var Sp,jS;function aC(){if(jS)return Sp;jS=1;var e=Lq(),n=$q(),i=n(e);return Sp=i,Sp}var bp,TS;function fu(){if(TS)return bp;TS=1;var e=ns(),n=oC(),i=aC();function s(o,l){return i(n(o,l,e),o+"")}return bp=s,bp}var kp,RS;function lC(){if(RS)return kp;RS=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,AS;function Dq(){if(AS)return Ep;AS=1;function e(n){return n!==n}return Ep=e,Ep}var Np,IS;function Fq(){if(IS)return Np;IS=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,MS;function zq(){if(MS)return Cp;MS=1;var e=lC(),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,PS;function Bq(){if(PS)return jp;PS=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 Tp,OS;function Uq(){if(OS)return Tp;OS=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 Tp=e,Tp}var Rp,qS;function Hq(){if(qS)return Rp;qS=1;function e(){}return Rp=e,Rp}var Ap,LS;function Vq(){if(LS)return Ap;LS=1;var e=ON(),n=Hq(),i=Tv(),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,$S;function Wq(){if($S)return Ip;$S=1;var e=HN(),n=Bq(),i=Uq(),s=VN(),o=Vq(),l=Tv(),u=200;function c(f,p,h){var g=-1,y=n,w=f.length,C=!0,_=[],S=_;if(h)C=!1,y=i;else if(w>=u){var b=p?null:o(f);if(b)return l(b);C=!1,y=s,S=new e}else S=p?[]:_;e:for(;++g<w;){var E=f[g],N=p?p(E):E;if(E=h||E!==0?E:0,C&&N===N){for(var j=S.length;j--;)if(S[j]===N)continue e;p&&S.push(N),_.push(E)}else y(S,N,h)||(S!==_&&S.push(N),_.push(E))}return _}return Ip=c,Ip}var Mp,DS;function uC(){if(DS)return Mp;DS=1;var e=qr(),n=fr();function i(s){return n(s)&&e(s)}return Mp=i,Mp}var Pp,FS;function Gq(){if(FS)return Pp;FS=1;var e=Av(),n=fu(),i=Wq(),s=uC(),o=n(function(l){return i(e(l,1,s,!0))});return Pp=o,Pp}var Op,zS;function Kq(){if(zS)return Op;zS=1;var e=uu();function n(i,s){return e(s,function(o){return i[o]})}return Op=n,Op}var qp,BS;function cC(){if(BS)return qp;BS=1;var e=Kq(),n=yi();function i(s){return s==null?[]:e(s,n(s))}return qp=i,qp}var Lp,US;function qn(){if(US)return Lp;US=1;var e;if(typeof gv=="function")try{e={clone:tq(),constant:Nv(),each:UN(),filter:eC(),has:tC(),isArray:St(),isEmpty:Eq(),isFunction:aa(),isUndefined:nC(),keys:yi(),map:iC(),reduce:sC(),size:Mq(),transform:Pq(),union:Gq(),values:cC()}}catch{}return e||(e=window._),Lp=e,Lp}var $p,HS;function Iv(){if(HS)return $p;HS=1;var e=qn();$p=o;var n="\0",i="\0",s="";function o(h){this._isDirected=e.has(h,"directed")?h.directed:!0,this._isMultigraph=e.has(h,"multigraph")?h.multigraph:!1,this._isCompound=e.has(h,"compound")?h.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(h){return this._label=h,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultNodeLabelFn=h,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var h=this;return e.filter(this.nodes(),function(g){return e.isEmpty(h._in[g])})},o.prototype.sinks=function(){var h=this;return e.filter(this.nodes(),function(g){return e.isEmpty(h._out[g])})},o.prototype.setNodes=function(h,g){var y=arguments,w=this;return e.each(h,function(C){y.length>1?w.setNode(C,g):w.setNode(C)}),this},o.prototype.setNode=function(h,g){return e.has(this._nodes,h)?(arguments.length>1&&(this._nodes[h]=g),this):(this._nodes[h]=arguments.length>1?g:this._defaultNodeLabelFn(h),this._isCompound&&(this._parent[h]=i,this._children[h]={},this._children[i][h]=!0),this._in[h]={},this._preds[h]={},this._out[h]={},this._sucs[h]={},++this._nodeCount,this)},o.prototype.node=function(h){return this._nodes[h]},o.prototype.hasNode=function(h){return e.has(this._nodes,h)},o.prototype.removeNode=function(h){var g=this;if(e.has(this._nodes,h)){var y=function(w){g.removeEdge(g._edgeObjs[w])};delete this._nodes[h],this._isCompound&&(this._removeFromParentsChildList(h),delete this._parent[h],e.each(this.children(h),function(w){g.setParent(w)}),delete this._children[h]),e.each(e.keys(this._in[h]),y),delete this._in[h],delete this._preds[h],e.each(e.keys(this._out[h]),y),delete this._out[h],delete this._sucs[h],--this._nodeCount}return this},o.prototype.setParent=function(h,g){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(g))g=i;else{g+="";for(var y=g;!e.isUndefined(y);y=this.parent(y))if(y===h)throw new Error("Setting "+g+" as parent of "+h+" would create a cycle");this.setNode(g)}return this.setNode(h),this._removeFromParentsChildList(h),this._parent[h]=g,this._children[g][h]=!0,this},o.prototype._removeFromParentsChildList=function(h){delete this._children[this._parent[h]][h]},o.prototype.parent=function(h){if(this._isCompound){var g=this._parent[h];if(g!==i)return g}},o.prototype.children=function(h){if(e.isUndefined(h)&&(h=i),this._isCompound){var g=this._children[h];if(g)return e.keys(g)}else{if(h===i)return this.nodes();if(this.hasNode(h))return[]}},o.prototype.predecessors=function(h){var g=this._preds[h];if(g)return e.keys(g)},o.prototype.successors=function(h){var g=this._sucs[h];if(g)return e.keys(g)},o.prototype.neighbors=function(h){var g=this.predecessors(h);if(g)return e.union(g,this.successors(h))},o.prototype.isLeaf=function(h){var g;return this.isDirected()?g=this.successors(h):g=this.neighbors(h),g.length===0},o.prototype.filterNodes=function(h){var g=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});g.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,S){h(S)&&g.setNode(S,_)}),e.each(this._edgeObjs,function(_){g.hasNode(_.v)&&g.hasNode(_.w)&&g.setEdge(_,y.edge(_))});var w={};function C(_){var S=y.parent(_);return S===void 0||g.hasNode(S)?(w[_]=S,S):S in w?w[S]:C(S)}return this._isCompound&&e.each(g.nodes(),function(_){g.setParent(_,C(_))}),g},o.prototype.setDefaultEdgeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultEdgeLabelFn=h,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(h,g){var y=this,w=arguments;return e.reduce(h,function(C,_){return w.length>1?y.setEdge(C,_,g):y.setEdge(C,_),_}),this},o.prototype.setEdge=function(){var h,g,y,w,C=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(h=_.v,g=_.w,y=_.name,arguments.length===2&&(w=arguments[1],C=!0)):(h=_,g=arguments[1],y=arguments[3],arguments.length>2&&(w=arguments[2],C=!0)),h=""+h,g=""+g,e.isUndefined(y)||(y=""+y);var S=c(this._isDirected,h,g,y);if(e.has(this._edgeLabels,S))return C&&(this._edgeLabels[S]=w),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(h),this.setNode(g),this._edgeLabels[S]=C?w:this._defaultEdgeLabelFn(h,g,y);var b=f(this._isDirected,h,g,y);return h=b.v,g=b.w,Object.freeze(b),this._edgeObjs[S]=b,l(this._preds[g],h),l(this._sucs[h],g),this._in[g][S]=b,this._out[h][S]=b,this._edgeCount++,this},o.prototype.edge=function(h,g,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,h,g,y);return this._edgeLabels[w]},o.prototype.hasEdge=function(h,g,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,h,g,y);return e.has(this._edgeLabels,w)},o.prototype.removeEdge=function(h,g,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,h,g,y),C=this._edgeObjs[w];return C&&(h=C.v,g=C.w,delete this._edgeLabels[w],delete this._edgeObjs[w],u(this._preds[g],h),u(this._sucs[h],g),delete this._in[g][w],delete this._out[h][w],this._edgeCount--),this},o.prototype.inEdges=function(h,g){var y=this._in[h];if(y){var w=e.values(y);return g?e.filter(w,function(C){return C.v===g}):w}},o.prototype.outEdges=function(h,g){var y=this._out[h];if(y){var w=e.values(y);return g?e.filter(w,function(C){return C.w===g}):w}},o.prototype.nodeEdges=function(h,g){var y=this.inEdges(h,g);if(y)return y.concat(this.outEdges(h,g))};function l(h,g){h[g]?h[g]++:h[g]=1}function u(h,g){--h[g]||delete h[g]}function c(h,g,y,w){var C=""+g,_=""+y;if(!h&&C>_){var S=C;C=_,_=S}return C+s+_+s+(e.isUndefined(w)?n:w)}function f(h,g,y,w){var C=""+g,_=""+y;if(!h&&C>_){var S=C;C=_,_=S}var b={v:C,w:_};return w&&(b.name=w),b}function p(h,g){return c(h,g.v,g.w,g.name)}return $p}var Dp,VS;function Yq(){return VS||(VS=1,Dp="2.1.8"),Dp}var Fp,WS;function Xq(){return WS||(WS=1,Fp={Graph:Iv(),version:Yq()}),Fp}var zp,GS;function Qq(){if(GS)return zp;GS=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 f=u.node(c),p=u.parent(c),h={v:c};return e.isUndefined(f)||(h.value=f),e.isUndefined(p)||(h.parent=p),h})}function o(u){return e.map(u.edges(),function(c){var f=u.edge(c),p={v:c.v,w:c.w};return e.isUndefined(c.name)||(p.name=c.name),e.isUndefined(f)||(p.value=f),p})}function l(u){var c=new n(u.options).setGraph(u.value);return e.each(u.nodes,function(f){c.setNode(f.v,f.value),f.parent&&c.setParent(f.v,f.parent)}),e.each(u.edges,function(f){c.setEdge({v:f.v,w:f.w,name:f.name},f.value)}),c}return zp}var Bp,KS;function Zq(){if(KS)return Bp;KS=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,YS;function dC(){if(YS)return Up;YS=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,XS;function fC(){if(XS)return Hp;XS=1;var e=qn(),n=dC();Hp=s;var i=e.constant(1);function s(l,u,c,f){return o(l,String(u),c||i,f||function(p){return l.outEdges(p)})}function o(l,u,c,f){var p={},h=new n,g,y,w=function(C){var _=C.v!==g?C.v:C.w,S=p[_],b=c(C),E=y.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+C+" Weight: "+b);E<S.distance&&(S.distance=E,S.predecessor=g,h.decrease(_,E))};for(l.nodes().forEach(function(C){var _=C===u?0:Number.POSITIVE_INFINITY;p[C]={distance:_},h.add(C,_)});h.size()>0&&(g=h.removeMin(),y=p[g],y.distance!==Number.POSITIVE_INFINITY);)f(g).forEach(w);return p}return Hp}var Vp,QS;function Jq(){if(QS)return Vp;QS=1;var e=fC(),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,ZS;function hC(){if(ZS)return Wp;ZS=1;var e=qn();Wp=n;function n(i){var s=0,o=[],l={},u=[];function c(f){var p=l[f]={onStack:!0,lowlink:s,index:s++};if(o.push(f),i.successors(f).forEach(function(y){e.has(l,y)?l[y].onStack&&(p.lowlink=Math.min(p.lowlink,l[y].index)):(c(y),p.lowlink=Math.min(p.lowlink,l[y].lowlink))}),p.lowlink===p.index){var h=[],g;do g=o.pop(),l[g].onStack=!1,h.push(g);while(f!==g);u.push(h)}}return i.nodes().forEach(function(f){e.has(l,f)||c(f)}),u}return Wp}var Gp,JS;function eL(){if(JS)return Gp;JS=1;var e=qn(),n=hC();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,eb;function tL(){if(eb)return Kp;eb=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={},f=o.nodes();return f.forEach(function(p){c[p]={},c[p][p]={distance:0},f.forEach(function(h){p!==h&&(c[p][h]={distance:Number.POSITIVE_INFINITY})}),u(p).forEach(function(h){var g=h.v===p?h.w:h.v,y=l(h);c[p][g]={distance:y,predecessor:p}})}),f.forEach(function(p){var h=c[p];f.forEach(function(g){var y=c[g];f.forEach(function(w){var C=y[p],_=h[w],S=y[w],b=C.distance+_.distance;b<S.distance&&(S.distance=b,S.predecessor=_.predecessor)})})}),c}return Kp}var Yp,tb;function pC(){if(tb)return Yp;tb=1;var e=qn();Yp=n,n.CycleException=i;function n(s){var o={},l={},u=[];function c(f){if(e.has(l,f))throw new i;e.has(o,f)||(l[f]=!0,o[f]=!0,e.each(s.predecessors(f),c),delete l[f],u.push(f))}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,nb;function nL(){if(nb)return Xp;nb=1;var e=pC();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,rb;function mC(){if(rb)return Qp;rb=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=[],f={};return e.each(o,function(p){if(!s.hasNode(p))throw new Error("Graph does not have node: "+p);i(s,p,l==="post",f,u,c)}),c}function i(s,o,l,u,c,f){e.has(u,o)||(u[o]=!0,l||f.push(o),e.each(c(o),function(p){i(s,p,l,u,c,f)}),l&&f.push(o))}return Qp}var Zp,ib;function rL(){if(ib)return Zp;ib=1;var e=mC();Zp=n;function n(i,s){return e(i,s,"post")}return Zp}var Jp,sb;function iL(){if(sb)return Jp;sb=1;var e=mC();Jp=n;function n(i,s){return e(i,s,"pre")}return Jp}var em,ob;function sL(){if(ob)return em;ob=1;var e=qn(),n=Iv(),i=dC();em=s;function s(o,l){var u=new n,c={},f=new i,p;function h(y){var w=y.v===p?y.w:y.v,C=f.priority(w);if(C!==void 0){var _=l(y);_<C&&(c[w]=p,f.decrease(w,_))}}if(o.nodeCount()===0)return u;e.each(o.nodes(),function(y){f.add(y,Number.POSITIVE_INFINITY),u.setNode(y)}),f.decrease(o.nodes()[0],0);for(var g=!1;f.size()>0;){if(p=f.removeMin(),e.has(c,p))u.setEdge(p,c[p]);else{if(g)throw new Error("Input graph is not connected: "+o);g=!0}o.nodeEdges(p).forEach(h)}return u}return em}var tm,ab;function oL(){return ab||(ab=1,tm={components:Zq(),dijkstra:fC(),dijkstraAll:Jq(),findCycles:eL(),floydWarshall:tL(),isAcyclic:nL(),postorder:rL(),preorder:iL(),prim:sL(),tarjan:hC(),topsort:pC()}),tm}var nm,lb;function aL(){if(lb)return nm;lb=1;var e=Xq();return nm={Graph:e.Graph,json:Qq(),alg:oL(),version:e.version},nm}var rm,ub;function Qn(){if(ub)return rm;ub=1;var e;if(typeof gv=="function")try{e=aL()}catch{}return e||(e=window.graphlib),rm=e,rm}var im,cb;function lL(){if(cb)return im;cb=1;var e=FN(),n=1,i=4;function s(o){return e(o,n|i)}return im=s,im}var sm,db;function hu(){if(db)return sm;db=1;var e=Ws(),n=qr(),i=iu(),s=On();function o(l,u,c){if(!s(c))return!1;var f=typeof u;return(f=="number"?n(c)&&i(u,c.length):f=="string"&&u in c)?e(c[u],l):!1}return sm=o,sm}var om,fb;function uL(){if(fb)return om;fb=1;var e=fu(),n=Ws(),i=hu(),s=ts(),o=Object.prototype,l=o.hasOwnProperty,u=e(function(c,f){c=Object(c);var p=-1,h=f.length,g=h>2?f[2]:void 0;for(g&&i(f[0],f[1],g)&&(h=1);++p<h;)for(var y=f[p],w=s(y),C=-1,_=w.length;++C<_;){var S=w[C],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,hb;function cL(){if(hb)return am;hb=1;var e=Lr(),n=qr(),i=yi();function s(o){return function(l,u,c){var f=Object(l);if(!n(l)){var p=e(u,3);l=i(l),u=function(g){return p(f[g],g,f)}}var h=o(l,u,c);return h>-1?f[p?l[h]:h]:void 0}}return am=s,am}var lm,pb;function dL(){if(pb)return lm;pb=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,mb;function fL(){if(mb)return um;mb=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,gb;function hL(){if(gb)return cm;gb=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 f(p){if(typeof p=="number")return p;if(i(p))return s;if(n(p)){var h=typeof p.valueOf=="function"?p.valueOf():p;p=n(h)?h+"":h}if(typeof p!="string")return p===0?p:+p;p=e(p);var g=l.test(p);return g||u.test(p)?c(p.slice(2),g?2:8):o.test(p)?s:+p}return cm=f,cm}var dm,vb;function gC(){if(vb)return dm;vb=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,yb;function pL(){if(yb)return fm;yb=1;var e=gC();function n(i){var s=e(i),o=s%1;return s===s?o?s-o:s:0}return fm=n,fm}var hm,wb;function mL(){if(wb)return hm;wb=1;var e=lC(),n=Lr(),i=pL(),s=Math.max;function o(l,u,c){var f=l==null?0:l.length;if(!f)return-1;var p=c==null?0:i(c);return p<0&&(p=s(f+p,0)),e(l,n(u,3),p)}return hm=o,hm}var pm,xb;function gL(){if(xb)return pm;xb=1;var e=cL(),n=mL(),i=e(n);return pm=i,pm}var mm,_b;function vC(){if(_b)return mm;_b=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,Sb;function vL(){if(Sb)return gm;Sb=1;var e=Cv(),n=zN(),i=ts();function s(o,l){return o==null?o:e(o,n(l),i)}return gm=s,gm}var vm,bb;function yL(){if(bb)return vm;bb=1;function e(n){var i=n==null?0:n.length;return i?n[i-1]:void 0}return vm=e,vm}var ym,kb;function wL(){if(kb)return ym;kb=1;var e=nu(),n=jv(),i=Lr();function s(o,l){var u={};return l=i(l,3),n(o,function(c,f,p){e(u,f,l(c,f,p))}),u}return ym=s,ym}var wm,Eb;function Mv(){if(Eb)return wm;Eb=1;var e=Xs();function n(i,s,o){for(var l=-1,u=i.length;++l<u;){var c=i[l],f=s(c);if(f!=null&&(p===void 0?f===f&&!e(f):o(f,p)))var p=f,h=c}return h}return wm=n,wm}var xm,Nb;function xL(){if(Nb)return xm;Nb=1;function e(n,i){return n>i}return xm=e,xm}var _m,Cb;function _L(){if(Cb)return _m;Cb=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,jb;function yC(){if(jb)return Sm;jb=1;var e=nu(),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=au(),i=fr(),s="[object Object]",o=Function.prototype,l=Object.prototype,u=o.toString,c=l.hasOwnProperty,f=u.call(Object);function p(h){if(!i(h)||e(h)!=s)return!1;var g=n(h);if(g===null)return!0;var y=c.call(g,"constructor")&&g.constructor;return typeof y=="function"&&y instanceof y&&u.call(y)==f}return bm=p,bm}var km,Rb;function wC(){if(Rb)return km;Rb=1;function e(n,i){if(!(i==="constructor"&&typeof n[i]=="function")&&i!="__proto__")return n[i]}return km=e,km}var Em,Ab;function bL(){if(Ab)return Em;Ab=1;var e=la(),n=ts();function i(s){return e(s,n(s))}return Em=i,Em}var Nm,Ib;function kL(){if(Ib)return Nm;Ib=1;var e=yC(),n=jN(),i=LN(),s=TN(),o=DN(),l=ua(),u=St(),c=uC(),f=Ks(),p=aa(),h=On(),g=SL(),y=ca(),w=wC(),C=bL();function _(S,b,E,N,j,P,O){var q=w(S,E),F=w(b,E),T=O.get(F);if(T){e(S,E,T);return}var M=P?P(q,F,E+"",S,b,O):void 0,B=M===void 0;if(B){var J=u(F),Z=!J&&f(F),A=!J&&!Z&&y(F);M=F,J||Z||A?u(q)?M=q:c(q)?M=s(q):Z?(B=!1,M=n(F,!0)):A?(B=!1,M=i(F,!0)):M=[]:g(F)||l(F)?(M=q,l(q)?M=C(q):(!h(q)||p(q))&&(M=o(F))):B=!1}B&&(O.set(F,M),j(M,F,N,P,O),O.delete(F)),e(S,E,M)}return Nm=_,Nm}var Cm,Mb;function EL(){if(Mb)return Cm;Mb=1;var e=tu(),n=yC(),i=Cv(),s=kL(),o=On(),l=ts(),u=wC();function c(f,p,h,g,y){f!==p&&i(p,function(w,C){if(y||(y=new e),o(w))s(f,p,C,h,c,g,y);else{var _=g?g(u(f,C),w,C+"",f,p,y):void 0;_===void 0&&(_=w),n(f,C,_)}},l)}return Cm=c,Cm}var jm,Pb;function NL(){if(Pb)return jm;Pb=1;var e=fu(),n=hu();function i(s){return e(function(o,l){var u=-1,c=l.length,f=c>1?l[c-1]:void 0,p=c>2?l[2]:void 0;for(f=s.length>3&&typeof f=="function"?(c--,f):void 0,p&&n(l[0],l[1],p)&&(f=c<3?void 0:f,c=1),o=Object(o);++u<c;){var h=l[u];h&&s(o,h,u,f)}return o})}return jm=i,jm}var Tm,Ob;function CL(){if(Ob)return Tm;Ob=1;var e=EL(),n=NL(),i=n(function(s,o,l){e(s,o,l)});return Tm=i,Tm}var Rm,qb;function xC(){if(qb)return Rm;qb=1;function e(n,i){return n<i}return Rm=e,Rm}var Am,Lb;function jL(){if(Lb)return Am;Lb=1;var e=Mv(),n=xC(),i=ns();function s(o){return o&&o.length?e(o,i,n):void 0}return Am=s,Am}var Im,$b;function TL(){if($b)return Im;$b=1;var e=Mv(),n=Lr(),i=xC();function s(o,l){return o&&o.length?e(o,n(l,2),i):void 0}return Im=s,Im}var Mm,Db;function RL(){if(Db)return Mm;Db=1;var e=Jn(),n=function(){return e.Date.now()};return Mm=n,Mm}var Pm,Fb;function AL(){if(Fb)return Pm;Fb=1;var e=ru(),n=cu(),i=iu(),s=On(),o=da();function l(u,c,f,p){if(!s(u))return u;c=n(c,u);for(var h=-1,g=c.length,y=g-1,w=u;w!=null&&++h<g;){var C=o(c[h]),_=f;if(C==="__proto__"||C==="constructor"||C==="prototype")return u;if(h!=y){var S=w[C];_=p?p(S,C,w):void 0,_===void 0&&(_=s(S)?S:i(c[h+1])?[]:{})}e(w,C,_),w=w[C]}return u}return Pm=l,Pm}var Om,zb;function IL(){if(zb)return Om;zb=1;var e=du(),n=AL(),i=cu();function s(o,l,u){for(var c=-1,f=l.length,p={};++c<f;){var h=l[c],g=e(o,h);u(g,h)&&n(p,i(h,o),g)}return p}return Om=s,Om}var qm,Bb;function ML(){if(Bb)return qm;Bb=1;var e=IL(),n=ZN();function i(s,o){return e(s,o,function(l,u){return n(s,u)})}return qm=i,qm}var Lm,Ub;function PL(){if(Ub)return Lm;Ub=1;var e=vC(),n=oC(),i=aC();function s(o){return i(n(o,void 0,e),o+"")}return Lm=s,Lm}var $m,Hb;function OL(){if(Hb)return $m;Hb=1;var e=ML(),n=PL(),i=n(function(s,o){return s==null?{}:e(s,o)});return $m=i,$m}var Dm,Vb;function qL(){if(Vb)return Dm;Vb=1;var e=Math.ceil,n=Math.max;function i(s,o,l,u){for(var c=-1,f=n(e((o-s)/(l||1)),0),p=Array(f);f--;)p[u?f:++c]=s,s+=l;return p}return Dm=i,Dm}var Fm,Wb;function LL(){if(Wb)return Fm;Wb=1;var e=qL(),n=hu(),i=gC();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,Gb;function $L(){if(Gb)return zm;Gb=1;var e=LL(),n=e();return zm=n,zm}var Bm,Kb;function DL(){if(Kb)return Bm;Kb=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,Yb;function FL(){if(Yb)return Um;Yb=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),f=s!==void 0,p=s===null,h=s===s,g=e(s);if(!p&&!g&&!c&&i>s||c&&f&&h&&!p&&!g||l&&f&&h||!o&&h||!u)return 1;if(!l&&!c&&!g&&i<s||g&&o&&u&&!l&&!c||p&&o&&u||!f&&u||!h)return-1}return 0}return Um=n,Um}var Hm,Xb;function zL(){if(Xb)return Hm;Xb=1;var e=FL();function n(i,s,o){for(var l=-1,u=i.criteria,c=s.criteria,f=u.length,p=o.length;++l<f;){var h=e(u[l],c[l]);if(h){if(l>=p)return h;var g=o[l];return h*(g=="desc"?-1:1)}}return i.index-s.index}return Hm=n,Hm}var Vm,Qb;function BL(){if(Qb)return Vm;Qb=1;var e=uu(),n=du(),i=Lr(),s=rC(),o=DL(),l=su(),u=zL(),c=ns(),f=St();function p(h,g,y){g.length?g=e(g,function(_){return f(_)?function(S){return n(S,_.length===1?_[0]:_)}:_}):g=[c];var w=-1;g=e(g,l(i));var C=s(h,function(_,S,b){var E=e(g,function(N){return N(_)});return{criteria:E,index:++w,value:_}});return o(C,function(_,S){return u(_,S,y)})}return Vm=p,Vm}var Wm,Zb;function UL(){if(Zb)return Wm;Zb=1;var e=Av(),n=BL(),i=fu(),s=hu(),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,Jb;function HL(){if(Jb)return Gm;Jb=1;var e=XN(),n=0;function i(s){var o=++n;return e(s)+o}return Gm=i,Gm}var Km,ek;function VL(){if(ek)return Km;ek=1;function e(n,i,s){for(var o=-1,l=n.length,u=i.length,c={};++o<l;){var f=o<u?i[o]:void 0;s(c,n[o],f)}return c}return Km=e,Km}var Ym,tk;function WL(){if(tk)return Ym;tk=1;var e=ru(),n=VL();function i(s,o){return n(s||[],o||[],e)}return Ym=i,Ym}var Xm,nk;function ot(){if(nk)return Xm;nk=1;var e;if(typeof gv=="function")try{e={cloneDeep:lL(),constant:Nv(),defaults:uL(),each:UN(),filter:eC(),find:gL(),flatten:vC(),forEach:BN(),forIn:vL(),has:tC(),isUndefined:nC(),last:yL(),map:iC(),mapValues:wL(),max:_L(),merge:CL(),min:jL(),minBy:TL(),now:RL(),pick:OL(),range:$L(),reduce:sC(),sortBy:UL(),uniqueId:HL(),values:cC(),zipObject:WL()}}catch{}return e||(e=window._),Xm=e,Xm}var Qm,rk;function GL(){if(rk)return Qm;rk=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,ik;function KL(){if(ik)return Zm;ik=1;var e=ot(),n=Qn().Graph,i=GL();Zm=o;var s=e.constant(1);function o(p,h){if(p.nodeCount()<=1)return[];var g=c(p,h||s),y=l(g.graph,g.buckets,g.zeroIdx);return e.flatten(e.map(y,function(w){return p.outEdges(w.v,w.w)}),!0)}function l(p,h,g){for(var y=[],w=h[h.length-1],C=h[0],_;p.nodeCount();){for(;_=C.dequeue();)u(p,h,g,_);for(;_=w.dequeue();)u(p,h,g,_);if(p.nodeCount()){for(var S=h.length-2;S>0;--S)if(_=h[S].dequeue(),_){y=y.concat(u(p,h,g,_,!0));break}}}return y}function u(p,h,g,y,w){var C=w?[]:void 0;return e.forEach(p.inEdges(y.v),function(_){var S=p.edge(_),b=p.node(_.v);w&&C.push({v:_.v,w:_.w}),b.out-=S,f(h,g,b)}),e.forEach(p.outEdges(y.v),function(_){var S=p.edge(_),b=_.w,E=p.node(b);E.in-=S,f(h,g,E)}),p.removeNode(y.v),C}function c(p,h){var g=new n,y=0,w=0;e.forEach(p.nodes(),function(S){g.setNode(S,{v:S,in:0,out:0})}),e.forEach(p.edges(),function(S){var b=g.edge(S.v,S.w)||0,E=h(S),N=b+E;g.setEdge(S.v,S.w,N),w=Math.max(w,g.node(S.v).out+=E),y=Math.max(y,g.node(S.w).in+=E)});var C=e.range(w+y+3).map(function(){return new i}),_=y+1;return e.forEach(g.nodes(),function(S){f(C,_,g.node(S))}),{graph:g,buckets:C,zeroIdx:_}}function f(p,h,g){g.out?g.in?p[g.out-g.in+h].enqueue(g):p[p.length-1].enqueue(g):p[0].enqueue(g)}return Zm}var Jm,sk;function YL(){if(sk)return Jm;sk=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(f){var p=l.edge(f);l.removeEdge(f),p.forwardName=f.name,p.reversed=!0,l.setEdge(f.w,f.v,p,e.uniqueId("rev"))});function c(f){return function(p){return f.edge(p).weight}}}function s(l){var u=[],c={},f={};function p(h){e.has(f,h)||(f[h]=!0,c[h]=!0,e.forEach(l.outEdges(h),function(g){e.has(c,g.w)?u.push(g):p(g.w)}),delete c[h])}return e.forEach(l.nodes(),p),u}function o(l){e.forEach(l.edges(),function(u){var c=l.edge(u);if(c.reversed){l.removeEdge(u);var f=c.forwardName;delete c.reversed,delete c.forwardName,l.setEdge(u.w,u.v,c,f)}})}return Jm}var eg,ok;function fn(){if(ok)return eg;ok=1;var e=ot(),n=Qn().Graph;eg={addDummyNode:i,simplify:s,asNonCompoundGraph:o,successorWeights:l,predecessorWeights:u,intersectRect:c,buildLayerMatrix:f,normalizeRanks:p,removeEmptyRanks:h,addBorderNode:g,maxRank:y,partition:w,time:C,notime:_};function i(S,b,E,N){var j;do j=e.uniqueId(N);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 N=b.edge(E.v,E.w)||{weight:0,minlen:1},j=S.edge(E);b.setEdge(E.v,E.w,{weight:N.weight+j.weight,minlen:Math.max(N.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 N={};return e.forEach(S.outEdges(E),function(j){N[j.w]=(N[j.w]||0)+S.edge(j).weight}),N});return e.zipObject(S.nodes(),b)}function u(S){var b=e.map(S.nodes(),function(E){var N={};return e.forEach(S.inEdges(E),function(j){N[j.v]=(N[j.v]||0)+S.edge(j).weight}),N});return e.zipObject(S.nodes(),b)}function c(S,b){var E=S.x,N=S.y,j=b.x-E,P=b.y-N,O=S.width/2,q=S.height/2;if(!j&&!P)throw new Error("Not possible to find intersection inside of the rectangle");var F,T;return Math.abs(P)*O>Math.abs(j)*q?(P<0&&(q=-q),F=q*j/P,T=q):(j<0&&(O=-O),F=O,T=O*P/j),{x:E+F,y:N+T}}function f(S){var b=e.map(e.range(y(S)+1),function(){return[]});return e.forEach(S.nodes(),function(E){var N=S.node(E),j=N.rank;e.isUndefined(j)||(b[j][N.order]=E)}),b}function p(S){var b=e.min(e.map(S.nodes(),function(E){return S.node(E).rank}));e.forEach(S.nodes(),function(E){var N=S.node(E);e.has(N,"rank")&&(N.rank-=b)})}function h(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 N=0,j=S.graph().nodeRankFactor;e.forEach(E,function(P,O){e.isUndefined(P)&&O%j!==0?--N:N&&e.forEach(P,function(q){S.node(q).rank+=N})})}function g(S,b,E,N){var j={width:0,height:0};return arguments.length>=4&&(j.rank=E,j.order=N),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 w(S,b){var E={lhs:[],rhs:[]};return e.forEach(S,function(N){b(N)?E.lhs.push(N):E.rhs.push(N)}),E}function C(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,ak;function XL(){if(ak)return tg;ak=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,f=l.node(c).rank,p=u.w,h=l.node(p).rank,g=u.name,y=l.edge(u),w=y.labelRank;if(h!==f+1){l.removeEdge(u);var C,_,S;for(S=0,++f;f<h;++S,++f)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:u,rank:f},C=n.addDummyNode(l,"edge",_,"_d"),f===w&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),l.setEdge(c,C,{weight:y.weight},g),S===0&&l.graph().dummyChains.push(C),c=C;l.setEdge(c,p,{weight:y.weight},g)}}function o(l){e.forEach(l.graph().dummyChains,function(u){var c=l.node(u),f=c.edgeLabel,p;for(l.setEdge(c.edgeObj,f);c.dummy;)p=l.successors(u)[0],l.removeNode(u),f.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(f.x=c.x,f.y=c.y,f.width=c.width,f.height=c.height),u=p,c=l.node(u)})}return tg}var ng,lk;function Ul(){if(lk)return ng;lk=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 f=e.min(e.map(s.outEdges(u),function(p){return l(p.w)-s.edge(p).minlen}));return(f===Number.POSITIVE_INFINITY||f===void 0||f===null)&&(f=0),c.rank=f}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,uk;function _C(){if(uk)return rg;uk=1;var e=ot(),n=Qn().Graph,i=Ul().slack;rg=s;function s(c){var f=new n({directed:!1}),p=c.nodes()[0],h=c.nodeCount();f.setNode(p,{});for(var g,y;o(f,c)<h;)g=l(f,c),y=f.hasNode(g.v)?i(c,g):-i(c,g),u(f,c,y);return f}function o(c,f){function p(h){e.forEach(f.nodeEdges(h),function(g){var y=g.v,w=h===y?g.w:y;!c.hasNode(w)&&!i(f,g)&&(c.setNode(w,{}),c.setEdge(h,w,{}),p(w))})}return e.forEach(c.nodes(),p),c.nodeCount()}function l(c,f){return e.minBy(f.edges(),function(p){if(c.hasNode(p.v)!==c.hasNode(p.w))return i(f,p)})}function u(c,f,p){e.forEach(c.nodes(),function(h){f.node(h).rank+=p})}return rg}var ig,ck;function QL(){if(ck)return ig;ck=1;var e=ot(),n=_C(),i=Ul().slack,s=Ul().longestPath,o=Qn().alg.preorder,l=Qn().alg.postorder,u=fn().simplify;ig=c,c.initLowLimValues=g,c.initCutValues=f,c.calcCutValue=h,c.leaveEdge=w,c.enterEdge=C,c.exchangeEdges=_;function c(N){N=u(N),s(N);var j=n(N);g(j),f(j,N);for(var P,O;P=w(j);)O=C(j,N,P),_(j,N,P,O)}function f(N,j){var P=l(N,N.nodes());P=P.slice(0,P.length-1),e.forEach(P,function(O){p(N,j,O)})}function p(N,j,P){var O=N.node(P),q=O.parent;N.edge(P,q).cutvalue=h(N,j,P)}function h(N,j,P){var O=N.node(P),q=O.parent,F=!0,T=j.edge(P,q),M=0;return T||(F=!1,T=j.edge(q,P)),M=T.weight,e.forEach(j.nodeEdges(P),function(B){var J=B.v===P,Z=J?B.w:B.v;if(Z!==q){var A=J===F,H=j.edge(B).weight;if(M+=A?H:-H,b(N,P,Z)){var U=N.edge(P,Z).cutvalue;M+=A?-U:U}}}),M}function g(N,j){arguments.length<2&&(j=N.nodes()[0]),y(N,{},1,j)}function y(N,j,P,O,q){var F=P,T=N.node(O);return j[O]=!0,e.forEach(N.neighbors(O),function(M){e.has(j,M)||(P=y(N,j,P,M,O))}),T.low=F,T.lim=P++,q?T.parent=q:delete T.parent,P}function w(N){return e.find(N.edges(),function(j){return N.edge(j).cutvalue<0})}function C(N,j,P){var O=P.v,q=P.w;j.hasEdge(O,q)||(O=P.w,q=P.v);var F=N.node(O),T=N.node(q),M=F,B=!1;F.lim>T.lim&&(M=T,B=!0);var J=e.filter(j.edges(),function(Z){return B===E(N,N.node(Z.v),M)&&B!==E(N,N.node(Z.w),M)});return e.minBy(J,function(Z){return i(j,Z)})}function _(N,j,P,O){var q=P.v,F=P.w;N.removeEdge(q,F),N.setEdge(O.v,O.w,{}),g(N),f(N,j),S(N,j)}function S(N,j){var P=e.find(N.nodes(),function(q){return!j.node(q).parent}),O=o(N,P);O=O.slice(1),e.forEach(O,function(q){var F=N.node(q).parent,T=j.edge(q,F),M=!1;T||(T=j.edge(F,q),M=!0),j.node(q).rank=j.node(F).rank+(M?T.minlen:-T.minlen)})}function b(N,j,P){return N.hasEdge(j,P)}function E(N,j,P){return P.low<=j.lim&&j.lim<=P.lim}return ig}var sg,dk;function ZL(){if(dk)return sg;dk=1;var e=Ul(),n=e.longestPath,i=_C(),s=QL();sg=o;function o(f){switch(f.graph().ranker){case"network-simplex":c(f);break;case"tight-tree":u(f);break;case"longest-path":l(f);break;default:c(f)}}var l=n;function u(f){n(f),i(f)}function c(f){s(f)}return sg}var og,fk;function JL(){if(fk)return og;fk=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),f=c.edgeObj,p=i(o,l,f.v,f.w),h=p.path,g=p.lca,y=0,w=h[y],C=!0;u!==f.w;){if(c=o.node(u),C){for(;(w=h[y])!==g&&o.node(w).maxRank<c.rank;)y++;w===g&&(C=!1)}if(!C){for(;y<h.length-1&&o.node(w=h[y+1]).minRank<=c.rank;)y++;w=h[y]}o.setParent(u,w),u=o.successors(u)[0]}})}function i(o,l,u,c){var f=[],p=[],h=Math.min(l[u].low,l[c].low),g=Math.max(l[u].lim,l[c].lim),y,w;y=u;do y=o.parent(y),f.push(y);while(y&&(l[y].low>h||g>l[y].lim));for(w=y,y=c;(y=o.parent(y))!==w;)p.push(y);return{path:f.concat(p.reverse()),lca:w}}function s(o){var l={},u=0;function c(f){var p=u;e.forEach(o.children(f),c),l[f]={low:p,lim:u++}}return e.forEach(o.children(),c),l}return og}var ag,hk;function e$(){if(hk)return ag;hk=1;var e=ot(),n=fn();ag={run:i,cleanup:u};function i(c){var f=n.addDummyNode(c,"root",{},"_root"),p=o(c),h=e.max(e.values(p))-1,g=2*h+1;c.graph().nestingRoot=f,e.forEach(c.edges(),function(w){c.edge(w).minlen*=g});var y=l(c)+1;e.forEach(c.children(),function(w){s(c,f,g,y,h,p,w)}),c.graph().nodeRankFactor=g}function s(c,f,p,h,g,y,w){var C=c.children(w);if(!C.length){w!==f&&c.setEdge(f,w,{weight:0,minlen:p});return}var _=n.addBorderNode(c,"_bt"),S=n.addBorderNode(c,"_bb"),b=c.node(w);c.setParent(_,w),b.borderTop=_,c.setParent(S,w),b.borderBottom=S,e.forEach(C,function(E){s(c,f,p,h,g,y,E);var N=c.node(E),j=N.borderTop?N.borderTop:E,P=N.borderBottom?N.borderBottom:E,O=N.borderTop?h:2*h,q=j!==P?1:g-y[w]+1;c.setEdge(_,j,{weight:O,minlen:q,nestingEdge:!0}),c.setEdge(P,S,{weight:O,minlen:q,nestingEdge:!0})}),c.parent(w)||c.setEdge(f,_,{weight:0,minlen:g+y[w]})}function o(c){var f={};function p(h,g){var y=c.children(h);y&&y.length&&e.forEach(y,function(w){p(w,g+1)}),f[h]=g}return e.forEach(c.children(),function(h){p(h,1)}),f}function l(c){return e.reduce(c.edges(),function(f,p){return f+c.edge(p).weight},0)}function u(c){var f=c.graph();c.removeNode(f.nestingRoot),delete f.nestingRoot,e.forEach(c.edges(),function(p){var h=c.edge(p);h.nestingEdge&&c.removeEdge(p)})}return ag}var lg,pk;function t$(){if(pk)return lg;pk=1;var e=ot(),n=fn();lg=i;function i(o){function l(u){var c=o.children(u),f=o.node(u);if(c.length&&e.forEach(c,l),e.has(f,"minRank")){f.borderLeft=[],f.borderRight=[];for(var p=f.minRank,h=f.maxRank+1;p<h;++p)s(o,"borderLeft","_bl",u,f,p),s(o,"borderRight","_br",u,f,p)}}e.forEach(o.children(),l)}function s(o,l,u,c,f,p){var h={width:0,height:0,rank:p,borderType:l},g=f[l][p-1],y=n.addDummyNode(o,"border",h,u);f[l][p]=y,o.setParent(y,c),g&&o.setEdge(g,y,{weight:1})}return lg}var ug,mk;function n$(){if(mk)return ug;mk=1;var e=ot();ug={adjust:n,undo:i};function n(p){var h=p.graph().rankdir.toLowerCase();(h==="lr"||h==="rl")&&s(p)}function i(p){var h=p.graph().rankdir.toLowerCase();(h==="bt"||h==="rl")&&l(p),(h==="lr"||h==="rl")&&(c(p),s(p))}function s(p){e.forEach(p.nodes(),function(h){o(p.node(h))}),e.forEach(p.edges(),function(h){o(p.edge(h))})}function o(p){var h=p.width;p.width=p.height,p.height=h}function l(p){e.forEach(p.nodes(),function(h){u(p.node(h))}),e.forEach(p.edges(),function(h){var g=p.edge(h);e.forEach(g.points,u),e.has(g,"y")&&u(g)})}function u(p){p.y=-p.y}function c(p){e.forEach(p.nodes(),function(h){f(p.node(h))}),e.forEach(p.edges(),function(h){var g=p.edge(h);e.forEach(g.points,f),e.has(g,"x")&&f(g)})}function f(p){var h=p.x;p.x=p.y,p.y=h}return ug}var cg,gk;function r$(){if(gk)return cg;gk=1;var e=ot();cg=n;function n(i){var s={},o=e.filter(i.nodes(),function(p){return!i.children(p).length}),l=e.max(e.map(o,function(p){return i.node(p).rank})),u=e.map(e.range(l+1),function(){return[]});function c(p){if(!e.has(s,p)){s[p]=!0;var h=i.node(p);u[h.rank].push(p),e.forEach(i.successors(p),c)}}var f=e.sortBy(o,function(p){return i.node(p).rank});return e.forEach(f,c),u}return cg}var dg,vk;function i$(){if(vk)return dg;vk=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,w){return w})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(s.outEdges(y),function(w){return{pos:u[w.w],weight:s.edge(w).weight}}),"pos")}),!0),f=1;f<l.length;)f<<=1;var p=2*f-1;f-=1;var h=e.map(new Array(p),function(){return 0}),g=0;return e.forEach(c.forEach(function(y){var w=y.pos+f;h[w]+=y.weight;for(var C=0;w>0;)w%2&&(C+=h[w+1]),w=w-1>>1,h[w]+=y.weight;g+=y.weight*C})),g}return dg}var fg,yk;function s$(){if(yk)return fg;yk=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,f){var p=i.edge(f),h=i.node(f.v);return{sum:c.sum+p.weight*h.order,weight:c.weight+p.weight}},{sum:0,weight:0});return{v:o,barycenter:u.sum/u.weight,weight:u.weight}}else return{v:o}})}return fg}var hg,wk;function o$(){if(wk)return hg;wk=1;var e=ot();hg=n;function n(o,l){var u={};e.forEach(o,function(f,p){var h=u[f.v]={indegree:0,in:[],out:[],vs:[f.v],i:p};e.isUndefined(f.barycenter)||(h.barycenter=f.barycenter,h.weight=f.weight)}),e.forEach(l.edges(),function(f){var p=u[f.v],h=u[f.w];!e.isUndefined(p)&&!e.isUndefined(h)&&(h.indegree++,p.out.push(u[f.w]))});var c=e.filter(u,function(f){return!f.indegree});return i(c)}function i(o){var l=[];function u(p){return function(h){h.merged||(e.isUndefined(h.barycenter)||e.isUndefined(p.barycenter)||h.barycenter>=p.barycenter)&&s(p,h)}}function c(p){return function(h){h.in.push(p),--h.indegree===0&&o.push(h)}}for(;o.length;){var f=o.pop();l.push(f),e.forEach(f.in.reverse(),u(f)),e.forEach(f.out,c(f))}return e.map(e.filter(l,function(p){return!p.merged}),function(p){return e.pick(p,["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,xk;function a$(){if(xk)return pg;xk=1;var e=ot(),n=fn();pg=i;function i(l,u){var c=n.partition(l,function(_){return e.has(_,"barycenter")}),f=c.lhs,p=e.sortBy(c.rhs,function(_){return-_.i}),h=[],g=0,y=0,w=0;f.sort(o(!!u)),w=s(h,p,w),e.forEach(f,function(_){w+=_.vs.length,h.push(_.vs),g+=_.barycenter*_.weight,y+=_.weight,w=s(h,p,w)});var C={vs:e.flatten(h,!0)};return y&&(C.barycenter=g/y,C.weight=y),C}function s(l,u,c){for(var f;u.length&&(f=e.last(u)).i<=c;)u.pop(),l.push(f.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,_k;function l$(){if(_k)return mg;_k=1;var e=ot(),n=s$(),i=o$(),s=a$();mg=o;function o(c,f,p,h){var g=c.children(f),y=c.node(f),w=y?y.borderLeft:void 0,C=y?y.borderRight:void 0,_={};w&&(g=e.filter(g,function(P){return P!==w&&P!==C}));var S=n(c,g);e.forEach(S,function(P){if(c.children(P.v).length){var O=o(c,P.v,p,h);_[P.v]=O,e.has(O,"barycenter")&&u(P,O)}});var b=i(S,p);l(b,_);var E=s(b,h);if(w&&(E.vs=e.flatten([w,E.vs,C],!0),c.predecessors(w).length)){var N=c.node(c.predecessors(w)[0]),j=c.node(c.predecessors(C)[0]);e.has(E,"barycenter")||(E.barycenter=0,E.weight=0),E.barycenter=(E.barycenter*E.weight+N.order+j.order)/(E.weight+2),E.weight+=2}return E}function l(c,f){e.forEach(c,function(p){p.vs=e.flatten(p.vs.map(function(h){return f[h]?f[h].vs:h}),!0)})}function u(c,f){e.isUndefined(c.barycenter)?(c.barycenter=f.barycenter,c.weight=f.weight):(c.barycenter=(c.barycenter*c.weight+f.barycenter*f.weight)/(c.weight+f.weight),c.weight+=f.weight)}return mg}var gg,Sk;function u$(){if(Sk)return gg;Sk=1;var e=ot(),n=Qn().Graph;gg=i;function i(o,l,u){var c=s(o),f=new n({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(p){return o.node(p)});return e.forEach(o.nodes(),function(p){var h=o.node(p),g=o.parent(p);(h.rank===l||h.minRank<=l&&l<=h.maxRank)&&(f.setNode(p),f.setParent(p,g||c),e.forEach(o[u](p),function(y){var w=y.v===p?y.w:y.v,C=f.edge(w,p),_=e.isUndefined(C)?0:C.weight;f.setEdge(w,p,{weight:o.edge(y).weight+_})}),e.has(h,"minRank")&&f.setNode(p,{borderLeft:h.borderLeft[l],borderRight:h.borderRight[l]}))}),f}function s(o){for(var l;o.hasNode(l=e.uniqueId("_root")););return l}return gg}var vg,bk;function c$(){if(bk)return vg;bk=1;var e=ot();vg=n;function n(i,s,o){var l={},u;e.forEach(o,function(c){for(var f=i.parent(c),p,h;f;){if(p=i.parent(f),p?(h=l[p],l[p]=f):(h=u,u=f),h&&h!==f){s.setEdge(h,f);return}f=p}})}return vg}var yg,kk;function d$(){if(kk)return yg;kk=1;var e=ot(),n=r$(),i=i$(),s=l$(),o=u$(),l=c$(),u=Qn().Graph,c=fn();yg=f;function f(y){var w=c.maxRank(y),C=p(y,e.range(1,w+1),"inEdges"),_=p(y,e.range(w-1,-1,-1),"outEdges"),S=n(y);g(y,S);for(var b=Number.POSITIVE_INFINITY,E,N=0,j=0;j<4;++N,++j){h(N%2?C:_,N%4>=2),S=c.buildLayerMatrix(y);var P=i(y,S);P<b&&(j=0,E=e.cloneDeep(S),b=P)}g(y,E)}function p(y,w,C){return e.map(w,function(_){return o(y,_,C)})}function h(y,w){var C=new u;e.forEach(y,function(_){var S=_.graph().root,b=s(_,S,C,w);e.forEach(b.vs,function(E,N){_.node(E).order=N}),l(_,C,b.vs)})}function g(y,w){e.forEach(w,function(C){e.forEach(C,function(_,S){y.node(_).order=S})})}return yg}var wg,Ek;function f$(){if(Ek)return wg;Ek=1;var e=ot(),n=Qn().Graph,i=fn();wg={positionX:C,findType1Conflicts:s,findType2Conflicts:o,addConflict:u,hasConflict:c,verticalAlignment:f,horizontalCompaction:p,alignCoordinates:y,findSmallestWidthAlignment:g,balance:w};function s(b,E){var N={};function j(P,O){var q=0,F=0,T=P.length,M=e.last(O);return e.forEach(O,function(B,J){var Z=l(b,B),A=Z?b.node(Z).order:T;(Z||B===M)&&(e.forEach(O.slice(F,J+1),function(H){e.forEach(b.predecessors(H),function(U){var ne=b.node(U),Q=ne.order;(Q<q||A<Q)&&!(ne.dummy&&b.node(H).dummy)&&u(N,U,H)})}),F=J+1,q=A)}),O}return e.reduce(E,j),N}function o(b,E){var N={};function j(O,q,F,T,M){var B;e.forEach(e.range(q,F),function(J){B=O[J],b.node(B).dummy&&e.forEach(b.predecessors(B),function(Z){var A=b.node(Z);A.dummy&&(A.order<T||A.order>M)&&u(N,Z,B)})})}function P(O,q){var F=-1,T,M=0;return e.forEach(q,function(B,J){if(b.node(B).dummy==="border"){var Z=b.predecessors(B);Z.length&&(T=b.node(Z[0]).order,j(q,M,J,F,T),M=J,F=T)}j(q,M,q.length,T,O.length)}),q}return e.reduce(E,P),N}function l(b,E){if(b.node(E).dummy)return e.find(b.predecessors(E),function(N){return b.node(N).dummy})}function u(b,E,N){if(E>N){var j=E;E=N,N=j}var P=b[E];P||(b[E]=P={}),P[N]=!0}function c(b,E,N){if(E>N){var j=E;E=N,N=j}return e.has(b[E],N)}function f(b,E,N,j){var P={},O={},q={};return e.forEach(E,function(F){e.forEach(F,function(T,M){P[T]=T,O[T]=T,q[T]=M})}),e.forEach(E,function(F){var T=-1;e.forEach(F,function(M){var B=j(M);if(B.length){B=e.sortBy(B,function(U){return q[U]});for(var J=(B.length-1)/2,Z=Math.floor(J),A=Math.ceil(J);Z<=A;++Z){var H=B[Z];O[M]===M&&T<q[H]&&!c(N,M,H)&&(O[H]=M,O[M]=P[M]=P[H],T=q[H])}}})}),{root:P,align:O}}function p(b,E,N,j,P){var O={},q=h(b,E,N,P),F=P?"borderLeft":"borderRight";function T(J,Z){for(var A=q.nodes(),H=A.pop(),U={};H;)U[H]?J(H):(U[H]=!0,A.push(H),A=A.concat(Z(H))),H=A.pop()}function M(J){O[J]=q.inEdges(J).reduce(function(Z,A){return Math.max(Z,O[A.v]+q.edge(A))},0)}function B(J){var Z=q.outEdges(J).reduce(function(H,U){return Math.min(H,O[U.w]-q.edge(U))},Number.POSITIVE_INFINITY),A=b.node(J);Z!==Number.POSITIVE_INFINITY&&A.borderType!==F&&(O[J]=Math.max(O[J],Z))}return T(M,q.predecessors.bind(q)),T(B,q.successors.bind(q)),e.forEach(j,function(J){O[J]=O[N[J]]}),O}function h(b,E,N,j){var P=new n,O=b.graph(),q=_(O.nodesep,O.edgesep,j);return e.forEach(E,function(F){var T;e.forEach(F,function(M){var B=N[M];if(P.setNode(B),T){var J=N[T],Z=P.edge(J,B);P.setEdge(J,B,Math.max(q(b,M,T),Z||0))}T=M})}),P}function g(b,E){return e.minBy(e.values(E),function(N){var j=Number.NEGATIVE_INFINITY,P=Number.POSITIVE_INFINITY;return e.forIn(N,function(O,q){var F=S(b,q)/2;j=Math.max(O+F,j),P=Math.min(O-F,P)}),j-P})}function y(b,E){var N=e.values(E),j=e.min(N),P=e.max(N);e.forEach(["u","d"],function(O){e.forEach(["l","r"],function(q){var F=O+q,T=b[F],M;if(T!==E){var B=e.values(T);M=q==="l"?j-e.min(B):P-e.max(B),M&&(b[F]=e.mapValues(T,function(J){return J+M}))}})})}function w(b,E){return e.mapValues(b.ul,function(N,j){if(E)return b[E.toLowerCase()][j];var P=e.sortBy(e.map(b,j));return(P[1]+P[2])/2})}function C(b){var E=i.buildLayerMatrix(b),N=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(F){F==="r"&&(P=e.map(P,function(J){return e.values(J).reverse()}));var T=(q==="u"?b.predecessors:b.successors).bind(b),M=f(b,P,N,T),B=p(b,P,M.root,M.align,F==="r");F==="r"&&(B=e.mapValues(B,function(J){return-J})),j[q+F]=B})});var O=g(b,j);return y(j,O),w(j,b.graph().align)}function _(b,E,N){return function(j,P,O){var q=j.node(P),F=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+=N?M:-M),M=0,T+=(q.dummy?E:b)/2,T+=(F.dummy?E:b)/2,T+=F.width/2,e.has(F,"labelpos"))switch(F.labelpos.toLowerCase()){case"l":M=F.width/2;break;case"r":M=-F.width/2;break}return M&&(T+=N?M:-M),M=0,T}}function S(b,E){return b.node(E).width}return wg}var xg,Nk;function h$(){if(Nk)return xg;Nk=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,f=0;e.forEach(u,function(p){var h=e.max(e.map(p,function(g){return l.node(g).height}));e.forEach(p,function(g){l.node(g).y=f+h/2}),f+=h+c})}return xg}var _g,Ck;function p$(){if(Ck)return _g;Ck=1;var e=ot(),n=YL(),i=XL(),s=ZL(),o=fn().normalizeRanks,l=JL(),u=fn().removeEmptyRanks,c=e$(),f=t$(),p=n$(),h=d$(),g=h$(),y=fn(),w=Qn().Graph;_g=C;function C($,Y){var ee=Y&&Y.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 _($,Y){Y(" makeSpaceForEdgeLabels",function(){M($)}),Y(" removeSelfEdges",function(){D($)}),Y(" acyclic",function(){n.run($)}),Y(" nestingGraph.run",function(){c.run($)}),Y(" rank",function(){s(y.asNonCompoundGraph($))}),Y(" injectEdgeLabelProxies",function(){B($)}),Y(" removeEmptyRanks",function(){u($)}),Y(" nestingGraph.cleanup",function(){c.cleanup($)}),Y(" normalizeRanks",function(){o($)}),Y(" assignRankMinMax",function(){J($)}),Y(" removeEdgeLabelProxies",function(){Z($)}),Y(" normalize.run",function(){i.run($)}),Y(" parentDummyChains",function(){l($)}),Y(" addBorderSegments",function(){f($)}),Y(" order",function(){h($)}),Y(" insertSelfEdges",function(){G($)}),Y(" adjustCoordinateSystem",function(){p.adjust($)}),Y(" position",function(){g($)}),Y(" positionSelfEdges",function(){k($)}),Y(" removeBorderNodes",function(){Q($)}),Y(" normalize.undo",function(){i.undo($)}),Y(" fixupEdgeLabelCoords",function(){U($)}),Y(" undoCoordinateSystem",function(){p.undo($)}),Y(" translateGraph",function(){A($)}),Y(" assignNodeIntersects",function(){H($)}),Y(" reversePoints",function(){ne($)}),Y(" acyclic.undo",function(){n.undo($)})}function S($,Y){e.forEach($.nodes(),function(ee){var se=$.node(ee),ae=Y.node(ee);se&&(se.x=ae.x,se.y=ae.y,Y.children(ee).length&&(se.width=ae.width,se.height=ae.height))}),e.forEach($.edges(),function(ee){var se=$.edge(ee),ae=Y.edge(ee);se.points=ae.points,e.has(ae,"x")&&(se.x=ae.x,se.y=ae.y)}),$.graph().width=Y.graph().width,$.graph().height=Y.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],E={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},N=["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"},F=["labelpos"];function T($){var Y=new w({multigraph:!0,compound:!0}),ee=oe($.graph());return Y.setGraph(e.merge({},E,L(ee,b),e.pick(ee,N))),e.forEach($.nodes(),function(se){var ae=oe($.node(se));Y.setNode(se,e.defaults(L(ae,j),P)),Y.setParent(se,$.parent(se))}),e.forEach($.edges(),function(se){var ae=oe($.edge(se));Y.setEdge(se,e.merge({},q,L(ae,O),e.pick(ae,F)))}),Y}function M($){var Y=$.graph();Y.ranksep/=2,e.forEach($.edges(),function(ee){var se=$.edge(ee);se.minlen*=2,se.labelpos.toLowerCase()!=="c"&&(Y.rankdir==="TB"||Y.rankdir==="BT"?se.width+=se.labeloffset:se.height+=se.labeloffset)})}function B($){e.forEach($.edges(),function(Y){var ee=$.edge(Y);if(ee.width&&ee.height){var se=$.node(Y.v),ae=$.node(Y.w),pe={rank:(ae.rank-se.rank)/2+se.rank,e:Y};y.addDummyNode($,"edge-proxy",pe,"_ep")}})}function J($){var Y=0;e.forEach($.nodes(),function(ee){var se=$.node(ee);se.borderTop&&(se.minRank=$.node(se.borderTop).rank,se.maxRank=$.node(se.borderBottom).rank,Y=e.max(Y,se.maxRank))}),$.graph().maxRank=Y}function Z($){e.forEach($.nodes(),function(Y){var ee=$.node(Y);ee.dummy==="edge-proxy"&&($.edge(ee.e).labelRank=ee.rank,$.removeNode(Y))})}function A($){var Y=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;Y=Math.min(Y,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)}),Y-=ge,se-=Ae,e.forEach($.nodes(),function(Me){var Pe=$.node(Me);Pe.x-=Y,Pe.y-=se}),e.forEach($.edges(),function(Me){var Pe=$.edge(Me);e.forEach(Pe.points,function(ke){ke.x-=Y,ke.y-=se}),e.has(Pe,"x")&&(Pe.x-=Y),e.has(Pe,"y")&&(Pe.y-=se)}),pe.width=ee-Y+ge,pe.height=ae-se+Ae}function H($){e.forEach($.edges(),function(Y){var ee=$.edge(Y),se=$.node(Y.v),ae=$.node(Y.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(Y){var ee=$.edge(Y);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(Y){var ee=$.edge(Y);ee.reversed&&ee.points.reverse()})}function Q($){e.forEach($.nodes(),function(Y){if($.children(Y).length){var ee=$.node(Y),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(Y){$.node(Y).dummy==="border"&&$.removeNode(Y)})}function D($){e.forEach($.edges(),function(Y){if(Y.v===Y.w){var ee=$.node(Y.v);ee.selfEdges||(ee.selfEdges=[]),ee.selfEdges.push({e:Y,label:$.edge(Y)}),$.removeEdge(Y)}})}function G($){var Y=y.buildLayerMatrix($);e.forEach(Y,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(Y){var ee=$.node(Y);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(Y),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($,Y){return e.mapValues(e.pick($,Y),Number)}function oe($){var Y={};return e.forEach($,function(ee,se){Y[se.toLowerCase()]=ee}),Y}return _g}var Sg,jk;function m$(){if(jk)return Sg;jk=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,f){var p="layer"+f;u.setNode(p,{rank:"same"}),e.reduce(c,function(h,g){return u.setEdge(h,g,{style:"invis"}),g})}),u}return Sg}var bg,Tk;function g$(){return Tk||(Tk=1,bg="0.8.5"),bg}var kg,Rk;function v$(){return Rk||(Rk=1,kg={graphlib:Qn(),layout:p$(),debug:m$(),util:{time:fn().time,notime:fn().notime},version:g$()}),kg}var y$=v$();const Ak=Yg(y$),vi=240,Xi=130,zs=74,pu=72,Ik=zs+pu;function w$(e){let n=vi;for(const i of e.values())n=Math.max(n,i.width);return n}const SC=420,x$=2;function mu(e){var i;return((i=e.data)==null?void 0:i.sessionId)??"_default"}function Mk(e,n){return((n==null?void 0:n.get(e))??0)>0?SC:0}function Pk(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 Ak.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)),f=new Set(c);for(const S of c){const b=s.get(S);u.setNode(S,{width:((b==null?void 0:b.width)??vi)+Mk(S,l),height:Math.max((b==null?void 0:b.height)??Xi,Pk(S,l))})}for(const S of n)f.has(S.source)&&f.has(S.target)&&u.setEdge(S.source,S.target);Ak.layout(u);const p=new Map;let h=1/0,g=1/0,y=-1/0,w=-1/0;for(const S of c){const b=u.node(S);if(!b)continue;const E=s.get(S),N=(E==null?void 0:E.width)??vi,j=(E==null?void 0:E.height)??Xi,P=N+Mk(S,l),O=Math.max(j,Pk(S,l)),q=b.x-P/2,F=b.y-O/2;p.set(S,{x:q,y:F}),q<h&&(h=q),F<g&&(g=F),q+N>y&&(y=q+N),F+j>w&&(w=F+j)}if(Number.isFinite(h)&&Number.isFinite(g))for(const[S,b]of p)p.set(S,{x:b.x-h,y:b.y-g});let C=Number.isFinite(y)?y-h:0,_=Number.isFinite(w)?w-g:0;for(const S of e){const b=o.get(S);if(!b)continue;const E=s.get(S);C=Math.max(C,b.x+((E==null?void 0:E.width)??vi)),_=Math.max(_,b.y+((E==null?void 0:E.height)??Xi))}return{positions:p,width:C,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=mu(b),N=c.get(E);N?N.push(b.id):c.set(E,[b.id])}const p=Array.from(c.keys()).sort().map(b=>({sid:b,..._$(c.get(b),n,s,l,o,u)})),h=w$(l),g=i.availableHeight&&i.availableHeight>0?i.availableHeight:Number.POSITIVE_INFINITY,y=b=>{const E=[[]];let N=0;for(const j of p)E.length<b&&N>0&&N+j.height>g&&(E.push([]),N=0),E[E.length-1].push(j),N+=j.height+Ik;return E},w=b=>b.reduce((E,N)=>Math.max(E,N.width),0)+SC;let C=y(i.availableWidth?x$:1);C.length>1&&C.reduce((E,N)=>E+w(N),0)+h*(C.length-1)>(i.availableWidth??0)&&(C=y(1));const _=new Map;let S=0;for(const b of C){let E=0;for(const{positions:N,height:j}of b){for(const[P,O]of N)_.set(P,{x:O.x+S,y:O.y+E});E+=j+Ik}S+=w(b)+h}return e.map(b=>{const E=o.get(b.id);if(E)return{...b,position:E};const N=_.get(b.id);return N?{...b,position:N}:b})}function b$(e,n,i,s){const l=zs+pu,u=60,c=y=>{const w=s.get(y);return{w:(w==null?void 0:w.width)??vi,h:(w==null?void 0:w.height)??Xi}},f=new Map(e.map(y=>[y.id,mu(y)])),p=[],h=e.map(y=>({id:y.id,pos:i.get(y.id)??n.get(y.id)})).filter(y=>y.pos!=null).sort((y,w)=>y.pos.y-w.pos.y||y.pos.x-w.pos.x||y.id.localeCompare(w.id)),g=[];for(const{id:y,pos:w}of h){const{w:C,h:_}=c(y),S=f.get(y)??"_default";if(i.has(y)){p.push({x:w.x,y:w.y,w:C,h:_,sid:S});continue}let b=w.y;for(let E=0;E<p.length+1;E++){const N=p.find(j=>{const P=j.sid===S?24:u,O=j.sid===S?24:l;return w.x<j.x+j.w+P&&j.x<w.x+C+P&&b<j.y+j.h+O&&j.y<b+_+O});if(!N)break;b=N.y+N.h+(N.sid===S?24:l)}b!==w.y&&(n.set(y,{x:w.x,y:b}),g.push(y)),p.push({x:w.x,y:b,w:C,h:_,sid:S})}return g}function k$(e,n,i,s,o){const l=y=>{const w=s.get(y);return{w:(w==null?void 0:w.width)??vi,h:(w==null?void 0:w.height)??Xi}},u=y=>i.get(y)??n.get(y),c=new Map,f=[];for(const y of e){const w=u(y.id);if(!w)continue;const{w:C,h:_}=l(y.id);if(o.has(y.id)&&!i.has(y.id)){const S=mu(y);(c.get(S)??c.set(S,[]).get(S)).push(y)}else f.push({x:w.x,y:w.y,w:C,h:_})}if(c.size===0)return[];const p=zs+pu,h=(y,w,C,_)=>f.some(S=>y<S.x+S.w+zs&&S.x<y+C+zs&&w<S.y+S.h+p&&S.y<w+_+p),g=[];for(const y of[...c.keys()].sort()){const w=c.get(y);let C=1/0,_=1/0,S=-1/0,b=-1/0;for(const F of w){const T=u(F.id),{w:M,h:B}=l(F.id);C=Math.min(C,T.x),_=Math.min(_,T.y),S=Math.max(S,T.x+M),b=Math.max(b,T.y+B)}const E=S-C,N=b-_,j=[...new Set(f.map(F=>Math.round(F.x)))].sort((F,T)=>F-T),P=j.length?j:[C],O=[0,...f.map(F=>F.y+F.h+p)].sort((F,T)=>F-T);let q=null;e:for(const F of P)for(const T of O){if(T>=_)break;if(!h(F,T,E,N)){q={x:F,y:T};break e}}if(q){const F=q.x-C,T=q.y-_;for(const M of w){const B=u(M.id);n.set(M.id,{x:B.x+F,y:B.y+T})}g.push(y)}for(const F of w){const T=u(F.id),{w:M,h:B}=l(F.id);f.push({x:T.x,y:T.y,w:M,h:B})}}return g}function E$(e,n,i,s,o,l=!1){const f=zs+pu+1,p=8,h=1.75,g=200,y=.7,w=.01,C=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=mu(T),B=S.get(M);B?B.push(T):S.set(M,[T])}const b=[],E=new Set,N=new Set,j=o.size===0;for(const T of[...S.keys()].sort()){const M=S.get(T);let B=1/0,J=1/0,Z=-1/0,A=-1/0,H=!1;for(const D of M){const G=_(D.id),{w:k,h:L}=C(D.id);B=Math.min(B,G.x),J=Math.min(J,G.y),Z=Math.max(Z,G.x+k),A=Math.max(A,G.y+L),i.has(D.id)&&(H=!0)}const U=Z-B,ne=A-J;N.add(T);const Q=o.get(T);Q&&(U>Q.w+p||ne>Q.h+p)&&E.add(T),o.set(T,{w:U,h:ne}),b.push({sid:T,members:M.map(D=>D.id),x:B,y:J,w:U,h:ne,anchored:H,mass:1})}for(const T of[...o.keys()])N.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 B=b[T],J=b[M];if(!(B.anchored&&J.anchored)&&Math.abs(B.x+B.w/2-(J.x+J.w/2))<(B.w+J.w)/2+61&&Math.abs(B.y+B.h/2-(J.y+J.h/2))<(B.h+J.h)/2+f){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<g;T++){const M=new Map,B=new Map;let J=0;for(let Z=0;Z<b.length;Z++)for(let A=Z+1;A<b.length;A++){const H=b[Z],U=b[A];if(H.anchored&&U.anchored)continue;const ne=H.x+H.w/2,Q=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+f-Math.abs(Q-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),Y=(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=Y(ne,D,oe),se=Y(Q,G,$),ae=ee!==0,pe=se!==0;if(!ae&&!pe)continue;const ge=ae&&(!pe||k*h<L),[Ae,Oe,Me,Pe]=ge?[ee,k,M,oe]:[se,L,B,$],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),J+=it}for(const Z of b)Z.anchored||(Z.x=Math.max(0,Z.x+(M.get(Z.sid)??0)),Z.y=Math.max(0,Z.y+(B.get(Z.sid)??0)));if(J<w)break}const F=[];for(const T of b){const M=T.x-O.get(T.sid),B=T.y-q.get(T.sid);if(!(Math.abs(M)<1&&Math.abs(B)<1)){for(const J of T.members){if(i.has(J))continue;const Z=n.get(J);Z&&n.set(J,{x:Z.x+M,y:Z.y+B})}F.push(T.sid)}}return F}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 T$(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 R$(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}const A$={agent:PP,sessionGroup:VP},I$=420,Cl=18,M$=9e4,P$=200,O$=5*6e4,q$=6,L$=2*6e4,Pv="agent-dag.layout",Ov="agent-dag.viewport",bC="agent-dag.summariesDismissed",kC="agent-dag.sessionListOpen",EC="agent-dag.detailOpen",NC="agent-dag.usagePanelOpen",Ok="agent-dag.accountsPanelOpen",qk="agent-dag.versionNoticeDismissed",Lk={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 $k="agent-dag.autoRestart",Dk="agent-dag.bundleReloadedFor";function D$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(kC)==="1"}catch{return!1}}function F$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(kC,e?"1":"0")}catch{}}function z$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(EC)==="1"}catch{return!1}}function B$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(EC,e?"1":"0")}catch{}}function U$(){if(typeof window>"u")return!0;const e=window.localStorage.getItem(NC);try{return e===null?!0:e==="1"}catch{return!0}}function H$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(NC,e?"1":"0")}catch{}}function V$(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(bC);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 Fk(e){if(!(typeof window>"u"))try{const n=Array.from(e),i=n.length>200?n.slice(-200):n;window.localStorage.setItem(bC,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 zk(){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 h of e.agents.values())h.sessionId===n&&s.push(h);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(h=>({id:h.id,kind:h.kind,label:h.label,parentId:h.parentId,state:h.state,startedAt:h.startedAt,endedAt:h.endedAt,model:h.model,cwd:h.cwd,usage:h.usage,prompts:h.prompts,tools:h.tools.map(g=>({id:g.id,name:g.name,inputPreview:g.inputPreview,startedAt:g.startedAt,endedAt:g.endedAt,ok:g.ok,errorPreview:g.errorPreview,usage:g.usage}))}))},l=JSON.stringify(o,null,2),u=new Blob([l],{type:"application/json"}),c=URL.createObjectURL(u),f=document.createElement("a"),p=(i.label||"session").replace(/[^a-z0-9._-]/gi,"_");f.href=c,f.download=`agents-deck-${p}-${n.slice(0,8)}.json`,document.body.appendChild(f),f.click(),document.body.removeChild(f),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 CC(e){return e.startsWith("mcp__")?"mcp":X$[e]??"other"}function jC(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,f,p,h,g,y,w,C,_,S,b){const E=[],N=[],j=new Set;if(l)for(const M of e.agents.values())jC(M,l)&&j.add(M.id);for(const M of e.agents.values()){if(!S.has(M.id))continue;const B=l?!j.has(M.id):!1,J=M.exitAt!=null,Z=_!=null&&!_.has(M.id),A=[B?"rf-dim":"",J?"rf-exiting":"",Z?"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:B,onOpenContext:b},className:A,...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%)`,Q=l&&!j.has(M.id)&&!j.has(M.parentId),D=J,G=C.size>0&&(C.has(M.id)||C.has(M.parentId)),k=_!=null&&!_.has(M.id)&&!_.has(M.parentId),L=M.state==="active"?2:1.5,oe=G?L+1.5:L,$=Q||D?.2:k?.12:1,Y=[D?"rf-edge-exiting":"",G?"rf-edge-selected":""].filter(Boolean).join(" ")||void 0;N.push({id:`e:${M.parentId}->${M.id}`,source:M.parentId,target:M.id,animated:(M.state==="active"||G)&&!Q&&!D,type:"smoothstep",style:{stroke:ne,strokeWidth:oe,opacity:$,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:Y})}}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)&&!g.has(M.id));if(O.length>0||y!==w.current){if(O.length>0){const M=S$(E,N,{direction:"LR",pinned:o,measured:u,availableWidth:i,availableHeight:s,lanes:P});for(const B of M)g.has(B.id)||g.set(B.id,B.position);k$(E,g,o,u,new Set(O.map(B=>B.id)))}b$(E,g,o,u),w.current=y}const q=E$(E,g,o,u,c,!p||h);q.length>0&&f(q);for(const M of Array.from(g.keys()))e.agents.has(M)||g.delete(M);if(e.agents.size>0)for(const M of Array.from(o.keys()))e.agents.has(M)||o.delete(M);const F=[];let T=!1;for(const M of E){let B=o.get(M.id)??g.get(M.id);B||(B={x:0,y:0},g.set(M.id,B),T=!0),F.push({...M,position:B})}return T&&(w.current=""),{nodes:F,edges:N}}function J$(){return m.jsx(fv,{children:m.jsx(e4,{})})}function e4(){var ao,va,Wr,Gr;const e=sa(),n=I.useRef(Bg()),[,i]=I.useState(0),s=I.useCallback(()=>i(V=>V+1),[]),[o,l]=I.useState(()=>new Set),[u,c]=I.useState(null),[f,p]=I.useState(null),h=I.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)},[]),g=I.useCallback(()=>{l(new Set),c(null)},[]),[y,w]=I.useState(null),[C,_]=I.useState(null),S=I.useCallback(V=>_(V),[]),b=I.useRef(V$()),[E,N]=I.useState(D$);I.useEffect(()=>{F$(E)},[E]);const[j,P]=I.useState(z$);I.useEffect(()=>{B$(j)},[j]);const[O,q]=I.useState(U$);I.useEffect(()=>{H$(O)},[O]);const[F,T]=I.useState(()=>{try{const V=window.localStorage.getItem(Ok);return V===null?!0:V==="1"}catch{return!0}});I.useEffect(()=>{try{window.localStorage.setItem(Ok,F?"1":"0")}catch{}},[F]);const[M,B]=I.useState(null),[J,Z]=I.useState(!1),[A,H]=I.useState(0),[U,ne]=I.useState(0);I.useEffect(()=>{fetch("/api/sound-hook").then(V=>V.ok?V.json():null).then(V=>{V!=null&&V.ok&&(B(V.enabled===!0),H((V.foreign??[]).filter(K=>K.worksHere).length),ne(typeof V.parked=="number"?V.parked:0))}).catch(()=>{})},[]);const Q=I.useCallback(async()=>{Z(!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&&B(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{Z(!1)}},[M]),[D,G]=I.useState(!1),[k,L]=I.useState(null),[oe,$]=I.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(qk)??""}catch{return""}}),[Y,ee]=I.useState(!1),se=I.useCallback((V=!1)=>{fetch(V?"/api/version?refresh=1":"/api/version").then(K=>K.ok?K.json():null).then(K=>{K&&L(K)}).catch(()=>{})},[]);I.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]),I.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=I.useCallback(()=>{if(!ae)return;const V=oe===pe?"":pe;$(V);try{window.localStorage.setItem(qk,V)}catch{}},[ae,pe,oe]),Oe=((ao=k==null?void 0:k.upgrade)==null?void 0:ao.state)??"idle",Me=I.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}se()},[se]);I.useEffect(()=>{if(Oe!=="running")return;const V=window.setInterval(se,3e3);return()=>window.clearInterval(V)},[Oe,se]);const Pe=I.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=I.useCallback(()=>{N(V=>(V||T(!1),!V))},[]),We=I.useCallback(()=>{T(V=>(V||N(!1),!V))},[]),[ve,ye]=I.useState(!1),[Ge,ut]=I.useState(0),it=I.useRef(null),[Ke,$e]=I.useState(!1),Qe=I.useRef(null),[bt,ct]=I.useState(0),[pt,mt]=I.useState(!1),kt=I.useRef([]),[He,Je]=I.useState(Date.now()),[dt,gt]=I.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem($k)!=="0"}catch{return!0}}),yt=I.useCallback(()=>{gt(V=>{const K=!V;try{window.localStorage.setItem($k,K?"1":"0")}catch{}return K})},[]),[Gt,Pt]=I.useState(!1),[zt,Ln]=I.useState("restart"),[er,bn]=I.useState(null),Bt=I.useRef(!1),Jt=I.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=I.useRef(null);I.useEffect(()=>{let V=!1;for(const ue of n.current.agents.values())if(ue.state==="active"){V=!0;break}const K=Z3({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]),I.useEffect(()=>{let V=null;try{V=window.sessionStorage.getItem(Dk)}catch{return}if(Q3({bundle:"1.33.13",running:k==null?void 0:k.running,lastTried:V})){try{window.sessionStorage.setItem(Dk,(k==null?void 0:k.running)??"")}catch{return}window.location.reload()}},[k==null?void 0:k.running]),I.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=I.useRef(W$()).current;I.useRef(!1);const Tt=I.useRef(new Map($r.positions.filter(([V])=>$r.pins.includes(V)))),hr=I.useRef(null),pr=I.useState(()=>G$())[0],[pn,wi]=I.useState(""),[tr,xi]=I.useState(()=>new Set),[mn,rs]=I.useState(()=>typeof window>"u"?"dark":window.localStorage.getItem("agent-dag.theme")??"dark"),[nr,Dr]=I.useState(!1),mr=I.useRef(null);I.useEffect(()=>{document.documentElement.dataset.theme=mn;try{window.localStorage.setItem("agent-dag.theme",mn)}catch{}},[mn]),I.useEffect(()=>{if(!pr)return;const V=window.setTimeout(()=>{try{e.setViewport(pr,{duration:0})}catch{}},60);return()=>window.clearTimeout(V)},[e,pr]);const Fr=I.useRef(!0),Ot=I.useRef(null);I.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]),I.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]),I.useEffect(()=>{const V=setInterval(()=>{const K=Date.now();Je(K);let ue=yP(n.current,K,M$);gP(n.current,K,P$,O$)&&(ue=!0),vP(n.current,K,q$,L$)&&(ue=!0),ue&&s()},250);return()=>clearInterval(V)},[s]);const _i=I.useRef(null),$n=I.useRef(0),Dn=420,Kt=I.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=I.useRef(""),Si=I.useRef(null),bi=I.useRef(0),gr=I.useCallback(()=>{bi.current=Date.now()},[]),Br="agent-dag.autoFitDisabled",kn=I.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Br)==="1"}catch{return!1}})()),[ki,is]=I.useState(kn.current),et=I.useCallback(()=>{if(!kn.current){kn.current=!0,is(!0);try{window.localStorage.setItem(Br,"1")}catch{}}},[]),Qs=I.useCallback(()=>{kn.current=!1,is(!1);try{window.localStorage.removeItem(Br)}catch{}Kt(400)},[e,Kt]);I.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=Tt.current.get(Ye)??Rt.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=I.useRef(!1),Fn=I.useRef(new Map),yr=I.useRef(0),ss=I.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]=I.useState(0);I.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 Rt=I.useRef(new Map($r.positions)),Yt=I.useRef(""),Ur=I.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=I.useRef(null);I.useEffect(()=>(Ni.current!=null&&window.clearTimeout(Ni.current),Ni.current=window.setTimeout(()=>{Eg(Rt.current,Tt.current)},1500),()=>{Ni.current!=null&&window.clearTimeout(Ni.current)}),[Ur]),I.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=I.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=I.useMemo(()=>C$(n.current,He),[n.current,n.current.lastSeq,He]),Ci=I.useRef(null),[rr,ji]=I.useState({w:0,h:0});I.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=I.useRef(new Map),[fa,Js]=I.useState(!1);I.useEffect(()=>{const V=window.setTimeout(()=>Js(!0),2500);return()=>window.clearTimeout(V)},[]);const[ha,Ti]=I.useState(!1),tn=I.useRef(null),[eo,os]=I.useState(!1),Ve=I.useCallback(()=>{tn.current&&(window.clearTimeout(tn.current),tn.current=null),Ti(!1)},[]),pa=I.useCallback(V=>{V.length!==0&&queueMicrotask(()=>{Ti(!0),tn.current&&window.clearTimeout(tn.current),tn.current=window.setTimeout(()=>Ti(!1),I$+80)})},[]);I.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:ma}=I.useMemo(()=>Z$(n.current,He,to,as,Tt.current,pn,Fn.current,gu.current,pa,fa,eo,Rt.current,Ur,Yt,o,Zs,Hr,S),[n.current,n.current.lastSeq,He,to,as,fa,eo,pn,Ur,o,Zs,Hr,S,Ge]),no=I.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+Cl*2,we=fe.maxY-fe.minY+Cl*2;K.push({id:`group:${ue}`,type:"sessionGroup",position:{x:fe.minX-Cl,y:fe.minY-Cl},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=I.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=I.useMemo(()=>{if(!pn)return null;const V=new Set;for(const K of n.current.agents.values())jC(K,pn)&&V.add(K.id);return V},[n.current,n.current.lastSeq,pn]),vn=I.useMemo(()=>{const V=new Set;for(const K of n.current.agents.values())for(const ue of K.tools)V.add(CC(ue.name));return Object.keys(Gg).filter(K=>V.has(K))},[n.current,n.current.lastSeq]);I.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=T$(fe,xe,8);$e(Ie=>Ie===we?Ie:we)}V=window.setTimeout(K,300)};return K(),()=>window.clearTimeout(V)},[vn.length]);const nn=I.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=I.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=f?Array.from(n.current.agents.values()).flatMap(V=>V.tools).find(V=>V.id===f)??null:null,En=I.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=Bg(),Tt.current.clear(),Fn.current.clear(),Rt.current.clear(),Yt.current="",zk(),g(),s()},[s,g]),io=I.useCallback(()=>{Tt.current.clear(),Rt.current.clear(),Yt.current="",zk(),s(),window.setTimeout(()=>Kt(500),80)},[s,e,Kt]),so=I.useCallback(()=>Kt(500),[Kt]),xr=I.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&&(h(xe.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[xe]})}catch{}$n.current=Date.now()},30))},[gn,u,h,e]);I.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():g();return}if(!ue){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,g,xr]);const oo=n.current.agents.size,ga=new Set(Array.from(n.current.agents.values()).map(V=>V.sessionId)).size,qt=I.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 m.jsxs("div",{className:"app",children:[m.jsxs("header",{className:"topbar",children:[m.jsxs("div",{className:"brand",children:[m.jsx("span",{className:"logo"}),"agents-deck",ae?m.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,m.jsx("span",{className:"v-dot","aria-hidden":!0})]}):m.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.13"]})]}),wt&&(()=>{const V=dn(wt.usage,wt.model),K=Math.max(0,((wt.endedAt??He)-wt.startedAt)/1e3),ue=wt.state==="active"?Bl(V.total,K):null,fe=o.size-1;return m.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:[m.jsx("span",{className:`state-pill state-${wt.state}`,children:wt.state==="active"?"live":wt.state}),m.jsx("span",{className:"selected-label",children:wt.label}),V.total>0&&m.jsxs("span",{className:"selected-cost",children:[Be(V.total),ue?m.jsxs("span",{className:"selected-rate",children:[" · ",ue]}):null]}),fe>0&&m.jsxs("span",{className:"selected-extra",children:["+",fe]}),m.jsx("span",{role:"button","aria-label":"Deselect",className:"selected-close",onClick:xe=>{xe.stopPropagation(),g()},children:"×"})]})})(),m.jsxs("div",{className:"actions",children:[m.jsxs("div",{className:"search",children:[m.jsx("span",{className:"search-icon","aria-hidden":!0,children:"⌕"}),m.jsx("input",{ref:mr,type:"text",placeholder:"Search agents, cwd, tools…",value:pn,onChange:V=>wi(V.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),pn?m.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>wi(""),children:"×"}):m.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"})]}),m.jsxs("span",{className:"status",role:"status",children:[m.jsx("span",{className:`pill ${D?"live":"dead"}`,title:D?"Receiving events":"SSE disconnected",children:D?"live":"offline"}),m.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[m.jsx("span",{className:"count",children:ga}),m.jsx("span",{className:"lbl",children:"sessions"})]}),m.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[m.jsx("span",{className:"count",children:oo}),m.jsx("span",{className:"lbl",children:"agents"})]}),m.jsxs("span",{className:"stat",title:"Total hook events received",children:[m.jsx("span",{className:"count",children:n.current.totalEvents}),m.jsx("span",{className:"lbl",children:"events"})]}),qt.sum>0&&m.jsxs("span",{className:"stat",title:`in:${qt.inT.toLocaleString()} out:${qt.outT.toLocaleString()} cache-r:${qt.cacheR.toLocaleString()} cache-c:${qt.cacheC.toLocaleString()}`,children:[m.jsx("span",{className:"count",children:R$(qt.sum)}),m.jsx("span",{className:"lbl",children:"tokens"})]}),nn.length>0&&m.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
59
+ burn: ${y}`:"");return m.jsxs("span",{className:"cost-meta",title:w,children:[m.jsx("b",{children:Be(h.total)}),y&&m.jsx("span",{className:"cost-rate",children:y})]})})()]}),m.jsx(Vs,{type:"source",position:Ce.Right,style:{background:"transparent",border:"none"}})]})}function OP({state:e}){const n=e==="active"?"live":e==="done"?"done":"err";return m.jsx("span",{className:`state-pill state-${e}`,children:n})}function qP(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function LP({tools:e,now:n}){const l=new Array(24).fill(0);let u=0;for(const y of e){const w=n-y.startedAt;if(w<0||w>=6e4)continue;const C=23-Math.floor(w/2500);C>=0&&C<24&&(l[C]+=1,u+=1)}const c=Math.max(1,...l),f=132,p=14,h=f/24,g=c/(2500/1e3);return m.jsxs("div",{className:"tool-spark-row",title:`${u} tool calls in last 60s · peak ${g.toFixed(1)}/s`,children:[m.jsx("svg",{className:"tool-spark",width:f,height:p,viewBox:`0 0 ${f} ${p}`,"aria-hidden":!0,children:l.map((y,w)=>{const C=y===0?1.5:Math.max(1.5,y/c*p),_=w===23&&y>0,b=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return m.jsx("rect",{x:w*h+.4,y:p-C,width:Math.max(.5,h-1),height:C,rx:.8,className:b},w)})}),m.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function oa(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 $P(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 DP({tool:e,onClose:n}){I.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 m.jsx("div",{className:"modal-backdrop",onClick:n,role:"dialog","aria-modal":"true",children:m.jsxs("div",{className:"modal",onClick:s=>s.stopPropagation(),children:[m.jsxs("header",{className:"modal-head",children:[m.jsxs("div",{className:"modal-title",children:[m.jsx("span",{className:`status-dot ${i}`}),m.jsx("span",{className:"modal-tool-name",children:e.name}),m.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),m.jsxs("div",{className:"modal-actions",children:[m.jsx("span",{className:"modal-dur",children:$P(e)}),m.jsx("button",{className:"btn icon-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),m.jsxs("section",{className:"modal-body",children:[m.jsxs("div",{className:"modal-section",children:[m.jsx("h4",{children:"Input"}),m.jsx("pre",{children:Zw(e.input??e.inputPreview)})]}),m.jsxs("div",{className:"modal-section",children:[m.jsxs("h4",{children:["Response ",i==="err"&&m.jsx("span",{className:"err-tag",children:"error"})]}),m.jsx("pre",{children:e.endedAt==null?"(waiting…)":Zw(e.response??e.errorPreview)})]})]})]})})}const Sl=18,Jw=26,FP=12;function zP(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,f=u+o.width,p=c+o.height,h=n.get(l.sessionId);h?(h.minX=Math.min(h.minX,u),h.minY=Math.min(h.minY,c),h.maxX=Math.max(h.maxX,f),h.maxY=Math.max(h.maxY,p),l.kind==="root"&&(h.label=ex(l)??h.label)):n.set(l.sessionId,{minX:u,minY:c,maxX:f,maxY:p,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} · ${BP(o)}`:l.label;s.push({sessionId:o,label:c,x:l.minX-Sl,y:l.minY-Sl-Jw,w:l.maxX-l.minX+Sl*2,h:l.maxY-l.minY+Sl*2+Jw})}return s}function BP(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 UP(){const{x:e,y:n,zoom:i}=lN(),s=sa(),o=Xe(zP,HP);if(o.length<=1)return null;const l=u=>{try{const c=s.getNodes().filter(f=>{const p=f.data;return(p==null?void 0:p.sessionId)===u});if(c.length===0)return;s.fitView({padding:.3,duration:500,nodes:c})}catch{}};return m.jsx("div",{className:"session-clusters",children:o.map(u=>{const c=pv(u.sessionId),f={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)`},p={position:"absolute",left:u.x*i+e+16*i,top:(u.y-FP)*i+n,color:`hsl(${c} 70% 78%)`,borderColor:`hsl(${c} 65% 55% / 0.5)`,transform:`scale(${Math.min(1,i)})`,transformOrigin:"left top"};return m.jsxs(le.Fragment,{children:[m.jsx("div",{className:"cluster-card",style:f,"aria-hidden":!0}),m.jsx("button",{type:"button",className:"cluster-label",style:p,title:`Fit view to ${u.label} · drag the wrapper to move the whole session`,onClick:()=>l(u.sessionId),children:u.label})]},u.sessionId)})})}function HP(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 VP({data:e}){return m.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const yN=600,WP=36,Hg=16,GP=60,KP=6,tx=220,nx=96,YP=28,XP={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 QP(e){return e.startsWith("mcp__")?"mcp":XP[e]??"other"}const ZP={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__")?"🔌":ZP[e]??"✨"}const JP={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 wN(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 wN(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 e3(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 t3=new Set(["Bash","PowerShell","shell","exec_command","shell_command","write_stdin","wait"]),n3=new Set(["shell","exec_command","shell_command","write_stdin","wait","apply_patch","update_plan"]);function r3(e,n){return n3.has(e)?Math.max(nx,34+n.length*7.5):nx}function i3(e,n){if(!t3.has(e))return null;const i=e3(n);if(!i)return null;const s=wN(i);return s?{emoji:JP[s]??"⚙️",label:s,category:"shell",detail:i}:null}const s3=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 o3(e){const i=e.replace(/\\/g,"/").replace(/\/+$/,""),s=i.lastIndexOf("/");return s>=0?i.slice(s+1):i}function a3(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 l3(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 u3(e,n){if(!s3.has(e))return null;const i=l3(e,n);if(!i)return null;const s=o3(i);return s?{emoji:e==="LS"?"📂":a3(s),label:s,category:"file",detail:i}:null}const xN={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 _N(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 c3(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 d3(e,n){const i=_N(e);if(!i)return null;const{server:s,method:o}=i;if(!o)return null;const l=xN[s.toLowerCase()];return{emoji:(l==null?void 0:l.emoji)??"🔌",label:o,category:"mcp",detail:l?`${l.name} · ${o}`:`${s} · ${o}`}}function f3(e,n){return i3(e,n)??u3(e,n)??d3(e)}const h3={shell:"Shell",exec_command:"Shell",shell_command:"Shell",write_stdin:"stdin",wait:"wait",apply_patch:"Edit",update_plan:"Plan"};function p3(e){const n=_N(e);if(n){const s=xN[n.server.toLowerCase()];return s?{emoji:s.emoji,label:s.name}:{emoji:"🔌",label:n.server,hue:c3(n.server)}}const i=h3[e];return i?{emoji:rx(e),label:i}:{emoji:rx(e),label:e}}function m3(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function g3(e,n,i){if(i==null)return 1;const s=n-i;return s<0?1:Math.max(0,1-s/yN)}function v3(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>yN)continue;const f=s.get(c.id)??i.get(c.id);if(!f)continue;const p=c.tools.slice(-4);if(p.length===0)continue;const h=c.exitAt??null,g=o.get(c.id),y=Math.max((g==null?void 0:g.width)??tx,tx),w=(g==null?void 0:g.height)??130,C=f.x,_=f.y,S=C+y,b=_+w/2;p.forEach((E,N)=>{const j=N*WP,P=C+y+GP,O=_+KP+j,q=g3(E,l,h),F=E.inputPreview??"",T=m3(E),M=q<.999,B=p3(E.name);u.push({id:E.id,toolId:E.id,agentId:c.id,toolName:E.name,name:B.label,emoji:B.emoji,status:T,category:QP(E.name),mcpHue:B.hue,inputPreview:F,fade:q,fading:M,worldX:P,worldY:O,anchorX:S,anchorY:b,spawnDx:S-P,spawnDy:b-(O+Hg)});const J=f3(E.name,E.input);if(J){const Z=r3(E.name,B.label),A=P+Z+YP,H=O,U=P+Z,ne=O+Hg;u.push({id:`sub:${E.id}`,toolId:E.id,agentId:c.id,toolName:E.name,name:J.label,emoji:J.emoji,isSub:!0,status:T,category:J.category,inputPreview:J.detail??F,fade:q,fading:M,worldX:A,worldY:H,anchorX:U,anchorY:ne,spawnDx:U-A,spawnDy:0})}})}return u}function y3({agents:e,visibleAgentIds:n,positions:i,pinned:s,measured:o,dimUnmatched:l,spotlight:u,hiddenCategories:c,now:f,onOpenTool:p}){const{x:h,y:g,zoom:y}=lN(),w=v3(e,n,i,s,o,f),C=c&&c.size>0?w.filter(_=>!c.has(_.category)):w;return m.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[m.jsx("svg",{className:"tool-bursts-svg",children:C.map(_=>{const S=_.anchorX*y+h,b=_.anchorY*y+g,E=(_.worldX+6)*y+h,N=(_.worldY+Hg)*y+g,j=S+(E-S)*.55,P=l!=null&&!l.has(_.agentId),O=u!=null&&!u.has(_.agentId),q=_.fade*(P||O?.14:1);return m.jsx("path",{d:`M ${S} ${b} Q ${j} ${b}, ${E} ${N}`,className:`tool-conn status-${_.status}${_.fading?" fading":""}`,opacity:q},`l:${_.id}`)})}),C.map(_=>{const S=_.worldX*y+h,b=_.worldY*y+g,E={left:`${S}px`,top:`${b}px`,transform:`scale(${y})`,transformOrigin:"left top","--spawn-dx":`${_.spawnDx}px`,"--spawn-dy":`${_.spawnDy}px`},N=_.isSub?`${_.toolName} · ${_.name}`:_.toolName,j=_.inputPreview?`${N} · ${_.inputPreview}`:N,P=p!=null,O=_.mcpHue!=null?{"--cat-accent":`hsl(${_.mcpHue} 65% 65%)`}:{},q=l!=null&&!l.has(_.agentId),F=u!=null&&!u.has(_.agentId),T=q||F?" dim":"";return m.jsx("div",{className:"tool-burst-wrap",style:E,children:m.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?()=>p(_.toolId):void 0,onKeyDown:P?M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),p(_.toolId))}:void 0,children:[m.jsx("span",{className:"tb-emoji",children:_.emoji}),m.jsx("span",{className:"tb-name",children:_.name}),_.status==="inflight"&&m.jsx("span",{className:"tb-spin"}),_.status==="done"&&m.jsx("span",{className:"tb-mark done",children:"✓"}),_.status==="err"&&m.jsx("span",{className:"tb-mark err",children:"×"})]})},_.id)})]})}function w3({state:e,sessionId:n,onClose:i}){const s=I.useMemo(()=>_3(e,n),[e,n]);return s?m.jsx("div",{className:"modal-backdrop",onClick:i,role:"presentation",children:m.jsxs("div",{className:"modal session-summary",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[m.jsxs("div",{className:"modal-head",children:[m.jsxs("div",{className:"modal-title",children:[m.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),m.jsx("span",{id:"ss-title",className:"modal-tool-name",title:s.cwd??s.sessionId,children:s.label}),m.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),m.jsxs("div",{className:"modal-actions",children:[m.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.durationLabel}),m.jsx("button",{className:"btn",onClick:i,"aria-label":"Close",children:"×"})]})]}),m.jsxs("div",{className:"modal-body",children:[m.jsxs("section",{className:"ss-hero",children:[m.jsxs("div",{className:"ss-hero-left",children:[m.jsx("div",{className:"ss-cost-label",children:"total spend"}),m.jsx("div",{className:"ss-cost",children:Be(s.cost.total)}),s.modelChips.length>0&&m.jsx("div",{className:"ss-models",children:s.modelChips.map(o=>m.jsx("span",{className:"model-chip",title:o,children:oa(o)},o))})]}),m.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&m.jsxs(m.Fragment,{children:[m.jsx(x3,{cost:s.cost}),m.jsxs("div",{className:"ss-cost-legend",children:[m.jsxs("span",{className:"ssl ssl-in",children:["input ",m.jsx("b",{children:Be(s.cost.input)})]}),m.jsxs("span",{className:"ssl ssl-out",children:["output ",m.jsx("b",{children:Be(s.cost.output)})]}),m.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",m.jsx("b",{children:Be(s.cost.cacheRead)})]}),m.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",m.jsx("b",{children:Be(s.cost.cacheWrite)})]})]})]})})]}),m.jsxs("section",{className:"ss-stats",children:[m.jsx(Ps,{label:"agents",value:s.agentCount}),m.jsx(Ps,{label:"subagents",value:s.subagentCount}),m.jsx(Ps,{label:"tool calls",value:s.toolCount}),m.jsx(Ps,{label:"prompts",value:s.promptCount}),m.jsx(Ps,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&m.jsx(Ps,{label:"errors",value:s.errCount,tone:"err"})]}),s.topTools.length>0&&m.jsxs("section",{className:"modal-section",children:[m.jsx("h4",{children:"Most-used tools"}),m.jsx("div",{className:"ss-top-tools",children:s.topTools.map(([o,l])=>m.jsxs("div",{className:"ss-tt",children:[m.jsx("span",{className:"ss-tt-name",children:o}),m.jsx("span",{className:"ss-tt-bar",children:m.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${l/s.topTools[0][1]*100}%`}})}),m.jsx("span",{className:"ss-tt-count",children:l})]},o))})]}),s.firstPrompt&&m.jsxs("section",{className:"modal-section",children:[m.jsx("h4",{children:"Opening prompt"}),m.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]})]})}):null}function Ps({label:e,value:n,tone:i}){return m.jsxs("div",{className:`ss-stat${i?` tone-${i}`:""}`,children:[m.jsx("div",{className:"ss-stat-value",children:n}),m.jsx("div",{className:"ss-stat-label",children:e})]})}function x3({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 m.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${Be(s)} (${u.toFixed(0)}%)`},o)};return m.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 _3(e,n){const i=e.agents.get(n);if(!i)return null;const s=[];for(const N of e.agents.values())N.sessionId===n&&s.push(N);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,f=0,p=0,h=0,g=0,y,w=1/0,C=0;for(const N of s){const j=dn(N.usage,N.model);o.input+=j.input,o.output+=j.output,o.cacheRead+=j.cacheRead,o.cacheWrite+=j.cacheWrite,o.total+=j.total,N.model&&l.add(N.model),N.kind==="subagent"&&g++,f+=N.prompts.length,!y&&N.prompts.length>0&&(y=N.prompts[0].text),p+=N.usage.inputTokens+N.usage.outputTokens,c+=N.tools.length,w=Math.min(w,N.startedAt),C=Math.max(C,N.endedAt??Date.now());for(const P of N.tools)u.set(P.name,(u.get(P.name)??0)+1),P.ok===!1&&h++}const _=Math.max(0,C-w),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((N,j)=>j[1]-N[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:g,toolCount:c,promptCount:f,tokensSum:p,errCount:h,topTools:E,firstPrompt:y}}function S3(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 f=c.endedAt??c.startedAt;f>u&&(u=f)}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 b3(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 k3({state:e,now:n,selectedIds:i,onSelect:s,onClose:o}){const l=I.useMemo(()=>S3(e),[e,e.lastSeq,n]),u=l.filter(c=>c.state==="active").length;return m.jsxs("aside",{className:"session-list","aria-label":"Sessions",children:[m.jsxs("div",{className:"sl-header",children:[m.jsxs("h3",{children:["Sessions ",m.jsx("span",{className:"sl-count",children:l.length})]}),u>0&&m.jsxs("span",{className:"sl-live-count",children:[u," live"]}),m.jsx("button",{className:"btn icon-btn sl-close",onClick:o,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),m.jsxs("div",{className:"sl-rows",children:[l.length===0&&m.jsx("div",{className:"sl-empty",children:"No sessions yet."}),l.map(c=>{const f=i.has(c.sessionId);return m.jsxs("button",{type:"button",className:`sl-row state-${c.state}${f?" selected":""}`,onClick:()=>s(c.sessionId),title:`Focus ${c.label}`,children:[m.jsx("span",{className:`sl-dot state-${c.state}`,"aria-hidden":!0}),m.jsxs("div",{className:"sl-row-body",children:[m.jsxs("div",{className:"sl-row-head",children:[m.jsx("span",{className:"sl-label",children:c.label}),c.modelId&&m.jsx("span",{className:"model-chip",title:c.modelId,children:oa(c.modelId)})]}),m.jsxs("div",{className:"sl-row-meta",children:[m.jsxs("span",{title:"tool calls",children:[m.jsx("b",{children:c.toolCount})," tools"]}),c.cost>0&&m.jsx("span",{className:"sl-cost",title:"total spend",children:m.jsx("b",{children:Be(c.cost)})}),m.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(c.startedAt).toLocaleString()}`,children:b3(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 E3(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 N3({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 m.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${Be(s)} (${u.toFixed(0)}%)`},o)};return m.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 C3(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 j3(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 f=100-e,p=l>0?e/l:0,h=p>0?f/p:1/0,g={label:`${Math.round(c)}% ahead`,color:"var(--warn)",expectedPct:u,isDeficit:!0};if(h<o&&h<86400){const y=Math.floor(h/3600),w=Math.floor(h%3600/60);g.runsOutIn=y>0?`${y}h ${w}m`:`${w}m`}return g}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)),p=l||c>=90?"var(--err)":c>=70?"var(--warn)":"var(--accent)",h=c===0?"< 1%":`${c}%`,g=c===0?2:c,y=s?C3(s,u):null,w=s&&o?j3(c,s,o,u):null;return m.jsxs("div",{className:"qb-row",children:[m.jsxs("div",{className:"qb-meta",children:[m.jsxs("span",{className:"qb-label",children:[n,l&&m.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),m.jsx("span",{className:"qb-pct",style:{color:p},children:h})]}),m.jsxs("div",{className:"qb-track",children:[m.jsx("div",{className:"qb-fill",style:{width:`${g}%`,background:p,opacity:c===0?.4:1}}),w&&m.jsx("div",{className:"qb-pace-marker",style:{left:`${w.expectedPct}%`,background:w.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(w.expectedPct)}% by now`})]}),m.jsxs("div",{className:"qb-reset-row",children:[y?m.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):i?m.jsxs("span",{className:"qb-reset",children:["resets ",i]}):null,w&&m.jsx("span",{className:"qb-pace",style:{color:w.color},children:w.runsOutIn?`runs out in ${w.runsOutIn}`:w.label})]})]})}const T3=6e4;function R3(){const[e,n]=I.useState(null),[i,s]=I.useState(!1),o=I.useRef(null),l=async(c=!1)=>{c&&s(!0);try{const p=await fetch(c?"/api/quota?refresh=1":"/api/quota");p.ok&&n(await p.json())}catch{}finally{c&&s(!1)}};return I.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),T3),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{quota:e,loading:i,refresh:()=>l(!0)}}function A3(e){switch(e){case"no_token":return"Run codex login to authenticate.";case"api_key_mode":return"API-key login — ChatGPT quota is only available for codex login.";case"refresh_rejected":return"Codex session expired — run codex login.";case"refresh_failed":return"Couldn't refresh the Codex token — click ↻ to retry.";default:return"ChatGPT API unreachable — click ↻ to retry."}}const SN=6e4;function I3(){const[e,n]=I.useState(null),[i,s]=I.useState(!1),o=I.useRef(null),l=async(c=!1)=>{c&&s(!0);try{const p=await fetch(c?"/api/codex-quota?refresh=1":"/api/codex-quota");p.ok&&n(await p.json())}catch{}finally{c&&s(!1)}};return I.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),SN),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{data:e,loading:i,refresh:()=>l(!0)}}function M3(){const[e,n]=I.useState(null),i=I.useRef(null),s=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return I.useEffect(()=>(s(),i.current=window.setInterval(s,SN),()=>{i.current!=null&&window.clearInterval(i.current)}),[]),{data:e}}function P3({state:e,now:n,onClose:i}){var q,F;const{quota:s,loading:o,refresh:l}=R3(),{data:u,loading:c,refresh:f}=I3(),{data:p}=M3(),[h,g]=I.useState(()=>Math.floor(Date.now()/1e3));I.useEffect(()=>{const T=window.setInterval(()=>g(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(T)},[]);const{byModel:y,totalCost:w,totalTokens:C,burnRate:_}=I.useMemo(()=>{const T=new Map,M={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let B=0,J=0,Z=0,A=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,B+=D.usage.inputTokens,J+=D.usage.outputTokens,Z+=D.usage.cacheReadTokens,A+=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 Q=ne>0?Bl(U,ne):null;return{byModel:H,totalCost:M,totalTokens:{in:B,out:J,cacheR:Z,cacheC:A},burnRate:Q}},[e,e.lastSeq,n]),S=I.useMemo(()=>{const T=[];for(const M of e.agents.values()){if(M.kind!=="root")continue;let B=dn(M.usage,M.model).total,J=M.usage.inputTokens,Z=M.usage.outputTokens;for(const A of e.agents.values())A.sessionId!==M.sessionId||A.kind==="root"||(B+=dn(A.usage,A.model).total,J+=A.usage.inputTokens,Z+=A.usage.outputTokens);T.push({sessionId:M.sessionId,label:M.label||M.cwdBasename||"session",state:M.state,cost:B,inputTokens:J,outputTokens:Z})}return T.sort((M,B)=>B.cost-M.cost).slice(0,12)},[e,e.lastSeq]),b=w.total>0,E=C.in+C.out,N=o||c,j=ox(s==null?void 0:s.fetchedAt,h),P=ox(u==null?void 0:u.fetchedAt,h),O=()=>{l(),f()};return m.jsxs("div",{className:"usage-panel","aria-label":"Usage",children:[m.jsxs("div",{className:"up-header",children:[m.jsx("h3",{children:"Usage"}),_&&m.jsx("span",{className:"up-rate",children:_}),m.jsxs("div",{className:"up-header-right",children:[m.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:O,disabled:N,title:"Refresh Claude + Codex quota",children:N?"…":"↻"}),m.jsx("button",{type:"button",className:"btn icon-btn up-close",onClick:i,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),m.jsxs("section",{className:"up-section up-quota-section",children:[m.jsxs("h4",{className:"up-section-title",children:["Claude quota",j&&!o&&m.jsx("span",{className:"up-section-age",title:E3(s==null?void 0:s.source),children:j})]}),s!=null&&s.ok?m.jsxs("div",{className:"up-quota-bars",children:[s.session5hPct!=null&&m.jsx(Bi,{label:"5-hour window",pct:s.session5hPct,reset:s.session5hReset,resetAt:s.session5hResetAt,windowSec:s.session5hWindowSec,nowSec:h}),s.week7dPct!=null&&m.jsx(Bi,{label:"7-day window",pct:s.week7dPct,reset:s.week7dReset,resetAt:s.week7dResetAt,windowSec:s.week7dWindowSec,nowSec:h}),s.weekSonnetPct!=null&&m.jsx(Bi,{label:"Sonnet (7d)",pct:s.weekSonnetPct,nowSec:h}),s.weekOpusPct!=null&&m.jsx(Bi,{label:"Opus (7d)",pct:s.weekOpusPct,nowSec:h})]}):(s==null?void 0:s.ok)===!1?m.jsxs("div",{className:"up-quota-na",children:[m.jsx("span",{children:"Quota unavailable."}),m.jsxs("span",{className:"up-quota-hint",children:["Run ",m.jsx("code",{children:"/usage"})," in a claude session, then click ↻"]})]}):m.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),m.jsxs("section",{className:"up-section up-quota-section",children:[m.jsxs("h4",{className:"up-section-title",children:["Codex quota",(u==null?void 0:u.ok)&&u.planLabel&&m.jsx("span",{className:"up-plan-badge",children:u.planLabel}),P&&!c&&m.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:P})]}),u!=null&&u.ok?m.jsxs("div",{className:"up-quota-bars",children:[(q=u.windows)==null?void 0:q.map(T=>m.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:h},T.id)),(F=u.extraWindows)==null?void 0:F.map(T=>m.jsx(Bi,{label:T.label,pct:T.pct,reset:T.reset??void 0,resetAt:T.resetAt??void 0,windowSec:T.windowSec??void 0,nowSec:h},T.id)),u.creditLimit&&m.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:h}),(p==null?void 0:p.ok)&&p.window7d&&p.window7d.sessionCount>0&&m.jsxs("div",{className:"up-quota-sub",children:[Ar(p.window7d.totalTokens)," tokens · ",p.window7d.sessionCount," session",p.window7d.sessionCount!==1?"s":""," (7d)"]}),u.creditsBalance&&!u.creditsUnlimited&&m.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",u.creditsBalance,u.overageReached&&" · overage limit reached"]}),u.creditsUnlimited&&m.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),u.resetCredits&&u.resetCredits.availableCount>0&&m.jsxs("div",{className:"up-quota-sub up-reset-credits",title:"Redeem in the Codex CLI or ChatGPT — agents-deck only reports them",children:[u.resetCredits.availableCount," rate-limit reset",u.resetCredits.availableCount!==1?"s":""," available",u.resetCredits.nextExpiryAt&&` · expires ${new Date(u.resetCredits.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`]}),u.promo&&m.jsx("div",{className:"up-quota-sub",children:u.promo}),u.partial&&m.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(u==null?void 0:u.ok)===!1?m.jsxs("div",{className:"up-quota-na",children:[m.jsx("span",{children:"Quota unavailable."}),m.jsx("span",{className:"up-quota-hint",children:A3(u.reason)})]}):m.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),b?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"up-total",children:[m.jsx("span",{className:"up-total-value",children:Be(w.total)}),m.jsx("span",{className:"up-total-label",children:"total spend"})]}),m.jsx(N3,{cost:w}),E>0&&m.jsxs("div",{className:"up-tokens-row",children:[m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"in"}),Ar(C.in)]}),m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"out"}),Ar(C.out)]}),C.cacheR>0&&m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"cache r"}),Ar(C.cacheR)]}),C.cacheC>0&&m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"cache c"}),Ar(C.cacheC)]})]}),y.filter(T=>T.cost.total>0).length>0&&m.jsxs("section",{className:"up-section",children:[m.jsx("h4",{className:"up-section-title",children:"By model"}),m.jsxs("table",{className:"up-table",children:[m.jsx("thead",{children:m.jsxs("tr",{children:[m.jsx("th",{children:"Model"}),m.jsx("th",{children:"Tokens"}),m.jsx("th",{children:"Cost"})]})}),m.jsx("tbody",{children:y.filter(T=>T.cost.total>0).map(T=>m.jsxs("tr",{children:[m.jsx("td",{className:"up-model-name",title:T.model,children:oa(T.model)}),m.jsx("td",{className:"up-num",children:Ar(T.inputTokens+T.outputTokens)}),m.jsx("td",{className:"up-num up-cost-val",children:Be(T.cost.total)})]},T.model))})]})]}),S.filter(T=>T.cost>0).length>0&&m.jsxs("section",{className:"up-section",children:[m.jsx("h4",{className:"up-section-title",children:"By session"}),m.jsx("div",{className:"up-sessions",children:S.filter(T=>T.cost>0).map(T=>m.jsxs("div",{className:"up-session-row",children:[m.jsx("span",{className:`sl-dot state-${T.state}`,"aria-hidden":!0}),m.jsx("span",{className:"up-session-label",children:T.label}),m.jsx("span",{className:"up-session-tokens",children:Ar(T.inputTokens+T.outputTokens)}),m.jsx("span",{className:"up-session-cost",children:Be(T.cost)})]},T.sessionId))})]})]}):E>0?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"up-tokens-row",children:[m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"in"}),Ar(C.in)]}),m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"out"}),Ar(C.out)]})]}),m.jsx("div",{className:"up-hint",children:"Cost appears once a known model is detected."})]}):m.jsxs("div",{className:"up-empty",children:["No usage data yet.",m.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const ax=18,O3=1100,Os=(e,n)=>{const i=Math.sin(e*12.9898+n*78.233)*43758.5453;return i-Math.floor(i)},q3=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=O3}){var l;const[i,s]=I.useState(null),o=typeof window<"u"&&((l=window.matchMedia)==null?void 0:l.call(window,"(prefers-reduced-motion: reduce)").matches);return I.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 f=window.setTimeout(()=>s(null),n);return()=>window.clearTimeout(f)},[e,n,o]),o||!i?null:ZA.createPortal(m.jsx("div",{className:"confetti",style:{left:`${i.x}px`,top:`${i.y}px`},"aria-hidden":!0,children:q3.map((u,c)=>m.jsx("span",{className:`confetti-bit${u.round?" round":""}`,"data-hue":u.hue,style:{"--dx":`${u.dx.toFixed(1)}px`,"--dy":`${u.dy.toFixed(1)}px`,"--rot":`${u.rot}deg`,"--s":u.scale.toFixed(2),animationDelay:`${u.delay}ms`,animationDuration:`${u.dur}ms, ${u.dur}ms`}},c))}),document.body)}const L3=1500;async function bl(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const $3={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?$3[e.reason]??e.reason:null)||(e==null?void 0:e.error)||n,Vg=le.forwardRef((e,n)=>m.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:n,children:[m.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),m.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));Vg.displayName="SuccessMark";function D3({onClose:e,onChanged:n}){const[i,s]=I.useState("login"),[o,l]=I.useState(null),[u,c]=I.useState(""),[f,p]=I.useState(""),[h,g]=I.useState(!1),[y,w]=I.useState(null),[C,_]=I.useState(null),S=I.useRef(!1),b=I.useRef(null),E=I.useRef(null),N=I.useRef(null),j=I.useCallback(()=>{S.current&&bl({action:"login-cancel"}).catch(()=>{}),e()},[e]);I.useEffect(()=>{const T=M=>{M.key==="Escape"&&j()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[j]);const P=I.useCallback(async()=>{g(!0),w(null),S.current=!0;const T=await bl({action:"login"}).catch(()=>null);if(g(!1),!(T!=null&&T.ok)){w(od(T,"could not start the sign-in"));return}l(T)},[]);I.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{}},L3);return()=>window.clearInterval(T)},[o]),I.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]),I.useEffect(()=>{var T;i==="paste"&&((T=E.current)==null||T.focus())},[i]);const O=I.useCallback(async()=>{var M;g(!0),w(null);const T=await bl({action:"login-code",code:u}).catch(()=>null);if(g(!1),!(T!=null&&T.ok)){w(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=I.useCallback(async()=>{g(!0),w(null);const T=await bl({action:"import",blob:f}).catch(()=>null);if(g(!1),!(T!=null&&T.ok)){w(od(T,"the import failed"));return}p(""),_({added:T.added===!0,num:T.num??null,email:T.email??null}),n()},[f,n]),F=(o==null?void 0:o.state)==="done"?o.account:null;return m.jsx("div",{className:"modal-backdrop",onClick:j,role:"presentation",children:m.jsxs("div",{className:"modal aa-modal",onClick:T=>T.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[m.jsxs("header",{className:"modal-head",children:[m.jsx("div",{className:"modal-title",children:m.jsxs("span",{className:"aa-tabs",role:"tablist",children:[m.jsx("button",{type:"button",role:"tab","aria-selected":i==="login",className:`aa-tab${i==="login"?" on":""}`,onClick:()=>s("login"),children:"Sign in"}),m.jsx("button",{type:"button",role:"tab","aria-selected":i==="paste",className:`aa-tab${i==="paste"?" on":""}`,onClick:()=>s("paste"),children:"Paste a share"})]})}),m.jsx("div",{className:"modal-actions",children:m.jsx("button",{type:"button",className:"btn icon-btn",onClick:j,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),m.jsx("section",{className:"modal-body aa-body",children:i==="login"?F?m.jsxs("div",{className:"aa-done",children:[m.jsx(Vg,{ref:N}),m.jsx(lx,{anchor:N}),m.jsx("h4",{children:F.added?`Account ${F.num} added`:"Credentials refreshed"}),m.jsxs("p",{className:"aa-note",children:[m.jsx("strong",{children:F.email}),F.added?" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),m.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"})]}):(o==null?void 0:o.state)==="awaiting_code"||(o==null?void 0:o.state)==="registering"?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:"1 · Approve in the browser"}),m.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),m.jsx("a",{className:"aa-link",href:o.url??"#",target:"_blank",rel:"noreferrer noopener",children:o.url})]}),m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:"2 · Paste the code it gives you"}),m.jsxs("div",{className:"aa-field",children:[m.jsx("input",{ref:b,type:"text",value:u,onChange:T=>c(T.target.value),onKeyDown:T=>{T.key==="Enter"&&u.trim()&&!h&&O()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:o.state==="registering"}),m.jsx("button",{type:"button",className:"btn primary",disabled:h||!u.trim()||o.state==="registering",onClick:O,children:o.state==="registering"?"registering…":"Continue"})]}),(y||o.error)&&m.jsx("p",{className:"aa-err",children:y??o.error}),m.jsx("p",{className:"aa-note",children:"The code goes straight to the claude CLI on this machine. It is never stored or sent anywhere else."})]})]}):(o==null?void 0:o.state)==="failed"||y&&S.current&&!h?m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:"Sign-in failed"}),m.jsx("p",{className:"aa-err",children:y??(o==null?void 0:o.error)}),m.jsx("button",{type:"button",className:"btn",onClick:()=>{S.current=!1,l(null),w(null),P()},children:"Try again"})]}):h||S.current?m.jsx("div",{className:"aa-step",children:m.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):m.jsxs("div",{className:"aa-step aa-primer",children:[m.jsx("h4",{children:"Sign in to Anthropic"}),m.jsx("p",{className:"aa-note",children:"Opens a browser tab where you approve the sign-in, then asks for the code it shows you. claude-swap records the account when it completes, and the account you are using now stays active."}),m.jsx("div",{className:"aa-actions",children:m.jsx("button",{type:"button",className:"btn primary",onClick:P,disabled:h,children:"Open the sign-in page"})})]}):C?m.jsxs("div",{className:"aa-done",children:[m.jsx(Vg,{ref:N}),C.added&&m.jsx(lx,{anchor:N}),m.jsx("h4",{children:C.added?`Account ${C.num} imported`:"Already here"}),m.jsx("p",{className:"aa-note",children:C.added?m.jsxs(m.Fragment,{children:[C.email?m.jsx("strong",{children:C.email}):"That account"," is in the rotation now. Nothing changed on the deck you copied it from."]}):"This deck already holds that account, so nothing changed."}),m.jsxs("div",{className:"aa-actions",children:[m.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"}),m.jsx("button",{type:"button",className:"btn",onClick:()=>_(null),children:"Import another"})]})]}):m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:"Paste an account shared from another deck"}),m.jsxs("div",{className:"aa-field",children:[m.jsx("input",{ref:E,type:"text",value:f,onChange:T=>p(T.target.value),onKeyDown:T=>{T.key==="Enter"&&f.trim()&&!h&&q()},placeholder:"ccdeck1:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),m.jsx("button",{type:"button",className:"btn primary",disabled:h||!f.trim(),onClick:q,children:h?"importing…":"Import"})]}),y&&m.jsx("p",{className:"aa-err",children:y}),m.jsxs("p",{className:"aa-note",children:["Use ",m.jsx("strong",{children:"share"})," on an account in the other deck. A share carries a live login and expires ten minutes after it is made."]})]})})]})})}const F3=15e3,z3=[70,80,85,90,95];function B3(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 U3(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 H3(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 V3({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?B3(e.resetAt,n):null;return m.jsxs("div",{className:"ap-lane",children:[m.jsx("span",{className:"ap-lane-label",children:e.label}),m.jsx("div",{className:"ap-lane-track",children:m.jsx("div",{className:"ap-lane-fill",style:{width:`${i===0?1.5:i}%`,background:s,opacity:i===0?.4:1}})}),m.jsxs("span",{className:"ap-lane-pct",style:{color:s},children:[i,"%"]}),m.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}function W3(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 G3(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 K3(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 Y3({onClose:e}){var Q,D,G;const[n,i]=I.useState(null),[s,o]=I.useState(null),[l,u]=I.useState(null),[c,f]=I.useState(null),[p,h]=I.useState(null),[g,y]=I.useState(()=>Math.floor(Date.now()/1e3)),w=I.useRef(null),[C,_]=I.useState(null),[S,b]=I.useState(!1),[E,N]=I.useState(""),[j,P]=I.useState(null),[O,q]=I.useState(null),[F,T]=I.useState(!1),M=I.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{}},[]),B=I.useCallback(async(k,L)=>{u(L),h(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||h(($==null?void 0:$.detail)||($==null?void 0:$.reason)||"command failed"),$}catch{return h("server unreachable"),null}finally{u(null)}},[]),J=I.useCallback(async(k,L)=>{u(L),h(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||h(($==null?void 0:$.detail)||($==null?void 0:$.reason)||"command failed"),$}catch{return h("server unreachable"),null}finally{u(null)}},[]);I.useEffect(()=>(M(!0),w.current=window.setInterval(()=>M(!1),F3),()=>{w.current!=null&&window.clearInterval(w.current)}),[M]),I.useEffect(()=>{const k=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(k)},[]);const Z=((Q=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:Q.value)??"90",A=(D=n==null?void 0:n.accounts)==null?void 0:D.find(k=>k.active),H=A!=null&&A.lanes.length?Math.max(...A.lanes.map(k=>k.pct)):null,U=H!=null&&H>=Number(Z)-15,ne=async k=>{f(k),h(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||h((oe==null?void 0:oe.output)||(oe==null?void 0:oe.reason)||"switch failed"),await M(!0)}catch{h("server unreachable")}finally{f(null)}};return m.jsxs("div",{className:"accounts-panel","aria-label":"Claude accounts",children:[m.jsxs("div",{className:"ap-header",children:[m.jsx("h3",{children:"Accounts"}),m.jsxs("div",{className:"ap-header-right",children:[m.jsx("button",{type:"button",className:"btn ap-add",onClick:()=>b(!0),title:"Sign in to another Claude account, or paste one shared from another deck",children:"+"}),m.jsx("button",{type:"button",className:"btn ap-refresh",onClick:()=>M(!0),title:"Reload from claude-swap",children:"↻"}),m.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),n==null?m.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?m.jsxs(m.Fragment,{children:[(G=n.accounts)==null?void 0:G.map(k=>m.jsxs("div",{className:`ap-account${k.active?" active":""}${k.disabled?" disabled":""}`,children:[m.jsxs("div",{className:"ap-account-head",children:[m.jsx("span",{className:"ap-num",children:k.num}),k.alias&&m.jsx("span",{className:"ap-alias",children:k.alias}),m.jsx("span",{className:"ap-email",title:k.org??void 0,children:k.email}),m.jsx("button",{type:"button",className:`ap-more${C===k.num?" on":""}`,"aria-label":`Manage account ${k.num}`,"aria-expanded":C===k.num,title:"Share, rename, move, remove",onClick:()=>{_(C===k.num?null:k.num),N(k.alias??""),P(null),q(null),T(!1)},children:"⋯"}),k.active?m.jsx("span",{className:"ap-badge-active",children:"● active"}):m.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=>m.jsx(V3,{lane:L,nowSec:g},L.id)):m.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),m.jsxs("div",{className:"ap-meta",children:[k.error&&(()=>{const L=H3(k.error);return m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"ap-err",title:L.hint,children:L.text}),L.fixable&&m.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&&m.jsx("button",{type:"button",className:"ap-rotate",disabled:l!=null,onClick:()=>B({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?m.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,g),U3(k.nextAt,g)]}):m.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),C===k.num&&m.jsxs("div",{className:"ap-manage",children:[m.jsxs("div",{className:"ap-manage-row",children:[m.jsx("span",{className:"ap-manage-label",children:"name"}),m.jsx("input",{className:"ap-manage-input",type:"text",value:E,onChange:L=>N(L.target.value),onKeyDown:L=>{L.key==="Enter"&&J({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}`}),m.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null||E.trim()===(k.alias??""),onClick:()=>J({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"})]}),m.jsxs("div",{className:"ap-manage-row",children:[m.jsx("span",{className:"ap-manage-label",children:"slot"}),m.jsx("span",{className:"ap-field",children:m.jsx("select",{"aria-label":`Slot for account ${k.num}`,value:String(k.num),disabled:l!=null,onChange:L=>J({action:"move",account:k.num,slot:Number(L.target.value)},`move-${k.num}`).then(()=>M(!0)),children:W3(n.accounts??[]).map(L=>m.jsx("option",{value:L,children:L},L))})}),m.jsx("span",{className:"ap-manage-hint",children:"rotation order"})]}),m.jsxs("div",{className:"ap-manage-row",children:[m.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,title:"Copy this account to another agents-deck. The share carries a live login and expires in 10 minutes.",onClick:async()=>{T(!1);const L=await J({action:"share",account:k.num},`share-${k.num}`);L!=null&&L.ok&&q({num:k.num,blob:L.blob,expiresAt:L.expiresAt})},children:"share…"}),m.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),J({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=K3(O.expiresAt,g),oe=L.tone==="gone";return m.jsxs("div",{className:`ap-share${oe?" expired":""}`,children:[m.jsx("code",{className:"ap-share-blob",children:O.blob}),m.jsxs("div",{className:"ap-share-foot",children:[m.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,onClick:async()=>{if(oe){T(!1);const $=await J({action:"share",account:k.num},`share-${k.num}`);$!=null&&$.ok&&q({num:k.num,blob:$.blob,expiresAt:$.expiresAt});return}await G3(O.blob)&&(T(!0),window.setTimeout(()=>T(!1),1800))},children:oe?"make a new share":F?"copied":"copy"}),m.jsxs("span",{className:"ap-manage-hint",children:["carries a live login · ",m.jsx("span",{className:`ap-share-expiry ${L.tone}`,children:L.text})]})]})]})})()]})]},k.num)),(s==null?void 0:s.ok)&&m.jsxs("div",{className:"ap-auto",children:[m.jsxs("div",{className:"ap-auto-head",children:[m.jsx("span",{className:"ap-auto-title",children:"Auto-switch"}),m.jsxs("span",{className:"ap-auto-ctl",children:[H!=null&&m.jsxs("span",{className:`ap-auto-now${U?" near":""}`,children:[Math.round(H),"%"]}),m.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:m.jsx("select",{"aria-label":"Switch threshold",value:Z,disabled:l!=null,onChange:k=>B({action:"setting",key:"autoswitch.threshold",value:k.target.value},"threshold").then(()=>M(!0)),children:z3.map(k=>m.jsxs("option",{value:k,children:[k,"%"]},k))})}),m.jsxs("button",{type:"button",className:`ap-auto-state toggle${s.enabled?" live":""}`,role:"switch","aria-checked":s.enabled,disabled:l!=null,onClick:()=>B({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:[m.jsx("i",{className:s.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),s.enabled?"on":"off"]})]})]}),s.external&&m.jsxs("p",{className:"ap-auto-note",children:[m.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",m.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",s.enabled?" — this toggle takes over when you stop it.":"."]}),s.lastTick&&m.jsx("div",{className:"ap-auto-foot",children:m.jsxs("span",{className:"ap-auto-result",children:["checked ",ux(s.lastTick.at,g)]})})]}),p&&m.jsx("div",{className:"ap-failure",children:p}),m.jsx("p",{className:"ap-footnote",title:"Anthropic's usage endpoint allows roughly 28–30 requests per hour per account, shared by every tool on this machine — polling it from here would rate-limit your account. So the deck never fetches: it asks claude-swap to collect while this panel is open, at most once every three minutes, and claude-swap decides whether that touches the network at all.",children:"Collected by claude-swap while this panel is open."})]}):m.jsx("div",{className:"ap-empty",children:n.reason==="no_cswap"?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"claude-swap isn't installed."}),m.jsx("span",{className:"ap-hint",children:"This panel reads the account store claude-swap keeps — without it there is nothing to show. It is a separate tool, published on PyPI, so it does not come with this package."}),n.hint&&m.jsx("code",{className:"ap-cmd",children:n.hint}),m.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",m.jsx("strong",{children:"+"})," button above."]})]}):n.reason==="no_accounts"?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"No accounts added yet."}),m.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",m.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"Couldn't read the account store."}),m.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",n.reason?` (${n.reason})`:"","."]})]})}),S&&m.jsx(D3,{onClose:()=>b(!1),onChanged:()=>M(!0)})]})}const X3=3e4;function Q3({bundle:e,running:n,lastTried:i}){return!n||e===n?!1:i!==n}function Z3(e){const n=e.thresholdMs??X3;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 J3(e){return e.ctrlKey||e.metaKey||e.altKey}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 cx(e){return e.replace(/^anthropic\./,"").replace(/^claude-/,"").replace(/-\d{8}$/,"")}function kl(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 eO(e){return new Date(Date.now()-(e-1)*864e5).toISOString().slice(0,10).replace(/-/g,"")}const tO=[7,14,30,90];function nO(e){const[n,i]=I.useState(null),[s,o]=I.useState(!1),l=(u=!1)=>{o(!0);const f=`/api/ccusage?since=${eO(e)}${u?"&refresh=1":""}`;fetch(f).then(p=>p.json()).then(i).catch(()=>i({ok:!1,error:"request failed"})).finally(()=>o(!1))};return I.useEffect(()=>{l(!1)},[e]),{data:n,loading:s,reload:()=>l(!0)}}function rO({onClose:e}){var b,E;const[n,i]=I.useState(30),[s,o]=I.useState(null),{data:l,loading:u,reload:c}=nO(n);I.useEffect(()=>{const N=j=>{j.key==="Escape"&&e()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e]);const f=l!=null&&l.ok?l.days??[]:[],p=I.useMemo(()=>f.reduce((N,j)=>Math.max(N,j.totalCost),0),[f]),{totalCost:h,totalTok:g,inOut:y,cacheRead:w,modelCosts:C}=I.useMemo(()=>{let N=0,j=0,P=0,O=0;const q=new Map;for(const F of f){N+=F.totalCost,j+=F.totalTokens,P+=F.inputTokens+F.outputTokens,O+=F.cacheReadTokens;for(const T of F.modelBreakdowns)q.set(T.modelName,(q.get(T.modelName)??0)+T.cost)}return{totalCost:N,totalTok:j,inOut:P,cacheRead:O,modelCosts:q}},[f]),_=I.useMemo(()=>Array.from(C.entries()).sort((N,j)=>j[1]-N[1]),[C]),S=s?f.find(N=>N.period===s)??null:null;return m.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:m.jsxs("div",{className:"uh-modal",onClick:N=>N.stopPropagation(),role:"dialog","aria-label":"Usage history",children:[m.jsxs("header",{className:"uh-head",children:[m.jsxs("div",{className:"uh-titlewrap",children:[m.jsx("div",{className:"uh-title",children:"Usage history"}),m.jsx("div",{className:"uh-sub",children:"via ccusage · local Claude / Codex logs"})]}),m.jsx("div",{className:"uh-range",role:"tablist","aria-label":"Range",children:tO.map(N=>m.jsxs("button",{role:"tab","aria-selected":n===N,className:`uh-range-btn${n===N?" on":""}`,onClick:()=>{i(N),o(null)},children:[N,"d"]},N))}),m.jsx("button",{className:"btn icon-btn uh-reload",onClick:c,title:"Re-run ccusage","aria-label":"Reload",children:"↻"}),m.jsx("button",{className:"uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),u&&f.length===0?m.jsx("div",{className:"uh-status",children:"running ccusage… (first run downloads the package)"}):l&&!l.ok?m.jsxs("div",{className:"uh-status uh-err",children:["ccusage failed: ",l.error]}):f.length===0?m.jsx("div",{className:"uh-status",children:"no usage in this range"}):m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"uh-totals",children:[m.jsx(El,{label:"total cost",val:Be(h),accent:!0}),m.jsx(El,{label:"tokens",val:Ui(g)}),m.jsx(El,{label:"input+output",val:Ui(y)}),m.jsx(El,{label:"cache reads",val:Ui(w)})]}),m.jsx("div",{className:"uh-chart",role:"img","aria-label":"Daily cost by model",children:f.map(N=>{const j=p>0?N.totalCost/p*100:0,P=N.period===s;return m.jsxs("button",{className:`uh-bar-col${P?" sel":""}`,onClick:()=>o(P?null:N.period),title:`${N.period} · ${Be(N.totalCost)}`,style:{flexBasis:`${100/f.length}%`},children:[m.jsx("div",{className:"uh-bar",style:{height:`${Math.max(j,N.totalCost>0?2:0)}%`},children:N.modelBreakdowns.slice().sort((O,q)=>q.cost-O.cost).map(O=>{const q=N.totalCost>0?O.cost/N.totalCost*100:0;return m.jsx("div",{className:"uh-bar-seg",style:{height:`${q}%`,background:kl(O.modelName)}},O.modelName)})}),m.jsx("span",{className:"uh-bar-label",children:N.period.slice(5)})]},N.period)})}),m.jsx("div",{className:"uh-legend",children:_.map(([N,j])=>m.jsxs("span",{className:"uh-legend-item",children:[m.jsx("span",{className:"uh-legend-dot",style:{background:kl(N)}}),cx(N)," ",m.jsx("span",{className:"uh-legend-cost",children:Be(j)})]},N))}),S&&m.jsxs("div",{className:"uh-detail",children:[m.jsxs("div",{className:"uh-detail-head",children:[m.jsx("span",{className:"uh-detail-date",children:S.period}),m.jsx("span",{className:"uh-detail-cost",children:Be(S.totalCost)}),(E=(b=S.metadata)==null?void 0:b.agents)!=null&&E.length?m.jsx("span",{className:"uh-detail-agents",children:S.metadata.agents.join(" · ")}):null]}),m.jsxs("div",{className:"uh-detail-mini",children:[m.jsx(Nl,{label:"input",val:Ui(S.inputTokens)}),m.jsx(Nl,{label:"output",val:Ui(S.outputTokens)}),m.jsx(Nl,{label:"cache write",val:Ui(S.cacheCreationTokens)}),m.jsx(Nl,{label:"cache read",val:Ui(S.cacheReadTokens)})]}),m.jsx("div",{className:"uh-detail-models",children:S.modelBreakdowns.slice().sort((N,j)=>j.cost-N.cost).map(N=>{const j=S.totalCost>0?N.cost/S.totalCost*100:0;return m.jsxs("div",{className:"uh-model-row",children:[m.jsxs("span",{className:"uh-model-name",children:[m.jsx("span",{className:"uh-legend-dot",style:{background:kl(N.modelName)}}),cx(N.modelName)]}),m.jsx("span",{className:"uh-model-bar",children:m.jsx("span",{className:"uh-model-bar-fill",style:{width:`${j}%`,background:kl(N.modelName)}})}),m.jsx("span",{className:"uh-model-cost",children:Be(N.cost)})]},N.modelName)})})]})]})]})})}function El({label:e,val:n,accent:i}){return m.jsxs("div",{className:"uh-stat",children:[m.jsx("span",{className:`uh-stat-val${i?" accent":""}`,children:n}),m.jsx("span",{className:"uh-stat-label",children:e})]})}function Nl({label:e,val:n}){return m.jsxs("div",{className:"uh-ministat",children:[m.jsx("span",{className:"uh-ministat-val",children:n}),m.jsx("span",{className:"uh-ministat-label",children:e})]})}function 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,dx;function iO(){if(dx)return ad;dx=1;function e(){this.__data__=[],this.size=0}return ad=e,ad}var ld,fx;function Ws(){if(fx)return ld;fx=1;function e(n,i){return n===i||n!==n&&i!==i}return ld=e,ld}var ud,hx;function Ql(){if(hx)return ud;hx=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,px;function sO(){if(px)return cd;px=1;var e=Ql(),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,mx;function oO(){if(mx)return dd;mx=1;var e=Ql();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,gx;function aO(){if(gx)return fd;gx=1;var e=Ql();function n(i){return e(this.__data__,i)>-1}return fd=n,fd}var hd,vx;function lO(){if(vx)return hd;vx=1;var e=Ql();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,yx;function Zl(){if(yx)return pd;yx=1;var e=iO(),n=sO(),i=oO(),s=aO(),o=lO();function l(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var p=u[c];this.set(p[0],p[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,wx;function uO(){if(wx)return md;wx=1;var e=Zl();function n(){this.__data__=new e,this.size=0}return md=n,md}var gd,xx;function cO(){if(xx)return gd;xx=1;function e(n){var i=this.__data__,s=i.delete(n);return this.size=i.size,s}return gd=e,gd}var vd,_x;function dO(){if(_x)return vd;_x=1;function e(n){return this.__data__.get(n)}return vd=e,vd}var yd,Sx;function fO(){if(Sx)return yd;Sx=1;function e(n){return this.__data__.has(n)}return yd=e,yd}var wd,bx;function bN(){if(bx)return wd;bx=1;var e=typeof dl=="object"&&dl&&dl.Object===Object&&dl;return wd=e,wd}var xd,kx;function Jn(){if(kx)return xd;kx=1;var e=bN(),n=typeof self=="object"&&self&&self.Object===Object&&self,i=e||n||Function("return this")();return xd=i,xd}var _d,Ex;function Gs(){if(Ex)return _d;Ex=1;var e=Jn(),n=e.Symbol;return _d=n,_d}var Sd,Nx;function hO(){if(Nx)return Sd;Nx=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),f=u[o];try{u[o]=void 0;var p=!0}catch{}var h=s.call(u);return p&&(c?u[o]=f:delete u[o]),h}return Sd=l,Sd}var bd,Cx;function pO(){if(Cx)return bd;Cx=1;var e=Object.prototype,n=e.toString;function i(s){return n.call(s)}return bd=i,bd}var kd,jx;function Ji(){if(jx)return kd;jx=1;var e=Gs(),n=hO(),i=pO(),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,Rx;function aa(){if(Rx)return Nd;Rx=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 f=e(c);return f==s||f==o||f==i||f==l}return Nd=u,Nd}var Cd,Ax;function mO(){if(Ax)return Cd;Ax=1;var e=Jn(),n=e["__core-js_shared__"];return Cd=n,Cd}var jd,Ix;function gO(){if(Ix)return jd;Ix=1;var e=mO(),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 Td,Mx;function kN(){if(Mx)return Td;Mx=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 Td=i,Td}var Rd,Px;function vO(){if(Px)return Rd;Px=1;var e=aa(),n=gO(),i=On(),s=kN(),o=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,f=u.toString,p=c.hasOwnProperty,h=RegExp("^"+f.call(p).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function g(y){if(!i(y)||n(y))return!1;var w=e(y)?h:l;return w.test(s(y))}return Rd=g,Rd}var Ad,Ox;function yO(){if(Ox)return Ad;Ox=1;function e(n,i){return n==null?void 0:n[i]}return Ad=e,Ad}var Id,qx;function es(){if(qx)return Id;qx=1;var e=vO(),n=yO();function i(s,o){var l=n(s,o);return e(l)?l:void 0}return Id=i,Id}var Md,Lx;function vv(){if(Lx)return Md;Lx=1;var e=es(),n=Jn(),i=e(n,"Map");return Md=i,Md}var Pd,$x;function Jl(){if($x)return Pd;$x=1;var e=es(),n=e(Object,"create");return Pd=n,Pd}var Od,Dx;function wO(){if(Dx)return Od;Dx=1;var e=Jl();function n(){this.__data__=e?e(null):{},this.size=0}return Od=n,Od}var qd,Fx;function xO(){if(Fx)return qd;Fx=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,zx;function _O(){if(zx)return Ld;zx=1;var e=Jl(),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,Bx;function SO(){if(Bx)return $d;Bx=1;var e=Jl(),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,Ux;function bO(){if(Ux)return Dd;Ux=1;var e=Jl(),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,Hx;function kO(){if(Hx)return Fd;Hx=1;var e=wO(),n=xO(),i=_O(),s=SO(),o=bO();function l(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var p=u[c];this.set(p[0],p[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,Vx;function EO(){if(Vx)return zd;Vx=1;var e=kO(),n=Zl(),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,Wx;function NO(){if(Wx)return Bd;Wx=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,Gx;function eu(){if(Gx)return Ud;Gx=1;var e=NO();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,Kx;function CO(){if(Kx)return Hd;Kx=1;var e=eu();function n(i){var s=e(this,i).delete(i);return this.size-=s?1:0,s}return Hd=n,Hd}var Vd,Yx;function jO(){if(Yx)return Vd;Yx=1;var e=eu();function n(i){return e(this,i).get(i)}return Vd=n,Vd}var Wd,Xx;function TO(){if(Xx)return Wd;Xx=1;var e=eu();function n(i){return e(this,i).has(i)}return Wd=n,Wd}var Gd,Qx;function RO(){if(Qx)return Gd;Qx=1;var e=eu();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,Zx;function yv(){if(Zx)return Kd;Zx=1;var e=EO(),n=CO(),i=jO(),s=TO(),o=RO();function l(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var p=u[c];this.set(p[0],p[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,Jx;function AO(){if(Jx)return Yd;Jx=1;var e=Zl(),n=vv(),i=yv(),s=200;function o(l,u){var c=this.__data__;if(c instanceof e){var f=c.__data__;if(!n||f.length<s-1)return f.push([l,u]),this.size=++c.size,this;c=this.__data__=new i(f)}return c.set(l,u),this.size=c.size,this}return Yd=o,Yd}var Xd,e1;function tu(){if(e1)return Xd;e1=1;var e=Zl(),n=uO(),i=cO(),s=dO(),o=fO(),l=AO();function u(c){var f=this.__data__=new e(c);this.size=f.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,t1;function wv(){if(t1)return Qd;t1=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,n1;function EN(){if(n1)return Zd;n1=1;var e=es(),n=(function(){try{var i=e(Object,"defineProperty");return i({},"",{}),i}catch{}})();return Zd=n,Zd}var Jd,r1;function nu(){if(r1)return Jd;r1=1;var e=EN();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,i1;function ru(){if(i1)return ef;i1=1;var e=nu(),n=Ws(),i=Object.prototype,s=i.hasOwnProperty;function o(l,u,c){var f=l[u];(!(s.call(l,u)&&n(f,c))||c===void 0&&!(u in l))&&e(l,u,c)}return ef=o,ef}var tf,s1;function la(){if(s1)return tf;s1=1;var e=ru(),n=nu();function i(s,o,l,u){var c=!l;l||(l={});for(var f=-1,p=o.length;++f<p;){var h=o[f],g=u?u(l[h],s[h],h,l,s):void 0;g===void 0&&(g=s[h]),c?n(l,h,g):e(l,h,g)}return l}return tf=i,tf}var nf,o1;function IO(){if(o1)return nf;o1=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,a1;function fr(){if(a1)return rf;a1=1;function e(n){return n!=null&&typeof n=="object"}return rf=e,rf}var sf,l1;function MO(){if(l1)return sf;l1=1;var e=Ji(),n=fr(),i="[object Arguments]";function s(o){return n(o)&&e(o)==i}return sf=s,sf}var of,u1;function ua(){if(u1)return of;u1=1;var e=MO(),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,c1;function St(){if(c1)return af;c1=1;var e=Array.isArray;return af=e,af}var Uo={exports:{}},lf,d1;function PO(){if(d1)return lf;d1=1;function e(){return!1}return lf=e,lf}Uo.exports;var f1;function Ks(){return f1||(f1=1,(function(e,n){var i=Jn(),s=PO(),o=n&&!n.nodeType&&n,l=o&&!0&&e&&!e.nodeType&&e,u=l&&l.exports===o,c=u?i.Buffer:void 0,f=c?c.isBuffer:void 0,p=f||s;e.exports=p})(Uo,Uo.exports)),Uo.exports}var uf,h1;function iu(){if(h1)return uf;h1=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,p1;function xv(){if(p1)return cf;p1=1;var e=9007199254740991;function n(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=e}return cf=n,cf}var df,m1;function OO(){if(m1)return df;m1=1;var e=Ji(),n=xv(),i=fr(),s="[object Arguments]",o="[object Array]",l="[object Boolean]",u="[object Date]",c="[object Error]",f="[object Function]",p="[object Map]",h="[object Number]",g="[object Object]",y="[object RegExp]",w="[object Set]",C="[object String]",_="[object WeakMap]",S="[object ArrayBuffer]",b="[object DataView]",E="[object Float32Array]",N="[object Float64Array]",j="[object Int8Array]",P="[object Int16Array]",O="[object Int32Array]",q="[object Uint8Array]",F="[object Uint8ClampedArray]",T="[object Uint16Array]",M="[object Uint32Array]",B={};B[E]=B[N]=B[j]=B[P]=B[O]=B[q]=B[F]=B[T]=B[M]=!0,B[s]=B[o]=B[S]=B[l]=B[b]=B[u]=B[c]=B[f]=B[p]=B[h]=B[g]=B[y]=B[w]=B[C]=B[_]=!1;function J(Z){return i(Z)&&n(Z.length)&&!!B[e(Z)]}return df=J,df}var ff,g1;function su(){if(g1)return ff;g1=1;function e(n){return function(i){return n(i)}}return ff=e,ff}var Ho={exports:{}};Ho.exports;var v1;function _v(){return v1||(v1=1,(function(e,n){var i=bN(),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 f=o&&o.require&&o.require("util").types;return f||u&&u.binding&&u.binding("util")}catch{}})();e.exports=c})(Ho,Ho.exports)),Ho.exports}var hf,y1;function ca(){if(y1)return hf;y1=1;var e=OO(),n=su(),i=_v(),s=i&&i.isTypedArray,o=s?n(s):e;return hf=o,hf}var pf,w1;function NN(){if(w1)return pf;w1=1;var e=IO(),n=ua(),i=St(),s=Ks(),o=iu(),l=ca(),u=Object.prototype,c=u.hasOwnProperty;function f(p,h){var g=i(p),y=!g&&n(p),w=!g&&!y&&s(p),C=!g&&!y&&!w&&l(p),_=g||y||w||C,S=_?e(p.length,String):[],b=S.length;for(var E in p)(h||c.call(p,E))&&!(_&&(E=="length"||w&&(E=="offset"||E=="parent")||C&&(E=="buffer"||E=="byteLength"||E=="byteOffset")||o(E,b)))&&S.push(E);return S}return pf=f,pf}var mf,x1;function ou(){if(x1)return mf;x1=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,_1;function CN(){if(_1)return gf;_1=1;function e(n,i){return function(s){return n(i(s))}}return gf=e,gf}var vf,S1;function qO(){if(S1)return vf;S1=1;var e=CN(),n=e(Object.keys,Object);return vf=n,vf}var yf,b1;function Sv(){if(b1)return yf;b1=1;var e=ou(),n=qO(),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,k1;function qr(){if(k1)return wf;k1=1;var e=aa(),n=xv();function i(s){return s!=null&&n(s.length)&&!e(s)}return wf=i,wf}var xf,E1;function yi(){if(E1)return xf;E1=1;var e=NN(),n=Sv(),i=qr();function s(o){return i(o)?e(o):n(o)}return xf=s,xf}var _f,N1;function LO(){if(N1)return _f;N1=1;var e=la(),n=yi();function i(s,o){return s&&e(o,n(o),s)}return _f=i,_f}var Sf,C1;function $O(){if(C1)return Sf;C1=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,j1;function DO(){if(j1)return bf;j1=1;var e=On(),n=ou(),i=$O(),s=Object.prototype,o=s.hasOwnProperty;function l(u){if(!e(u))return i(u);var c=n(u),f=[];for(var p in u)p=="constructor"&&(c||!o.call(u,p))||f.push(p);return f}return bf=l,bf}var kf,T1;function ts(){if(T1)return kf;T1=1;var e=NN(),n=DO(),i=qr();function s(o){return i(o)?e(o,!0):n(o)}return kf=s,kf}var Ef,R1;function FO(){if(R1)return Ef;R1=1;var e=la(),n=ts();function i(s,o){return s&&e(o,n(o),s)}return Ef=i,Ef}var Vo={exports:{}};Vo.exports;var A1;function jN(){return A1||(A1=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 f(p,h){if(h)return p.slice();var g=p.length,y=c?c(g):new p.constructor(g);return p.copy(y),y}e.exports=f})(Vo,Vo.exports)),Vo.exports}var Nf,I1;function TN(){if(I1)return Nf;I1=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,M1;function RN(){if(M1)return Cf;M1=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,P1;function AN(){if(P1)return jf;P1=1;function e(){return[]}return jf=e,jf}var Tf,O1;function bv(){if(O1)return Tf;O1=1;var e=RN(),n=AN(),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 Tf=l,Tf}var Rf,q1;function zO(){if(q1)return Rf;q1=1;var e=la(),n=bv();function i(s,o){return e(s,n(s),o)}return Rf=i,Rf}var Af,L1;function kv(){if(L1)return Af;L1=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,$1;function au(){if($1)return If;$1=1;var e=CN(),n=e(Object.getPrototypeOf,Object);return If=n,If}var Mf,D1;function IN(){if(D1)return Mf;D1=1;var e=kv(),n=au(),i=bv(),s=AN(),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,F1;function BO(){if(F1)return Pf;F1=1;var e=la(),n=IN();function i(s,o){return e(s,n(s),o)}return Pf=i,Pf}var Of,z1;function MN(){if(z1)return Of;z1=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,B1;function PN(){if(B1)return qf;B1=1;var e=MN(),n=bv(),i=yi();function s(o){return e(o,i,n)}return qf=s,qf}var Lf,U1;function UO(){if(U1)return Lf;U1=1;var e=MN(),n=IN(),i=ts();function s(o){return e(o,i,n)}return Lf=s,Lf}var $f,H1;function HO(){if(H1)return $f;H1=1;var e=es(),n=Jn(),i=e(n,"DataView");return $f=i,$f}var Df,V1;function VO(){if(V1)return Df;V1=1;var e=es(),n=Jn(),i=e(n,"Promise");return Df=i,Df}var Ff,W1;function ON(){if(W1)return Ff;W1=1;var e=es(),n=Jn(),i=e(n,"Set");return Ff=i,Ff}var zf,G1;function WO(){if(G1)return zf;G1=1;var e=es(),n=Jn(),i=e(n,"WeakMap");return zf=i,zf}var Bf,K1;function Ys(){if(K1)return Bf;K1=1;var e=HO(),n=vv(),i=VO(),s=ON(),o=WO(),l=Ji(),u=kN(),c="[object Map]",f="[object Object]",p="[object Promise]",h="[object Set]",g="[object WeakMap]",y="[object DataView]",w=u(e),C=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())!=p||s&&E(new s)!=h||o&&E(new o)!=g)&&(E=function(N){var j=l(N),P=j==f?N.constructor:void 0,O=P?u(P):"";if(O)switch(O){case w:return y;case C:return c;case _:return p;case S:return h;case b:return g}return j}),Bf=E,Bf}var Uf,Y1;function GO(){if(Y1)return Uf;Y1=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,X1;function qN(){if(X1)return Hf;X1=1;var e=Jn(),n=e.Uint8Array;return Hf=n,Hf}var Vf,Q1;function Ev(){if(Q1)return Vf;Q1=1;var e=qN();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,Z1;function KO(){if(Z1)return Wf;Z1=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,J1;function YO(){if(J1)return Gf;J1=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,e_;function XO(){if(e_)return Kf;e_=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,t_;function LN(){if(t_)return Yf;t_=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,n_;function QO(){if(n_)return Xf;n_=1;var e=Ev(),n=KO(),i=YO(),s=XO(),o=LN(),l="[object Boolean]",u="[object Date]",c="[object Map]",f="[object Number]",p="[object RegExp]",h="[object Set]",g="[object String]",y="[object Symbol]",w="[object ArrayBuffer]",C="[object DataView]",_="[object Float32Array]",S="[object Float64Array]",b="[object Int8Array]",E="[object Int16Array]",N="[object Int32Array]",j="[object Uint8Array]",P="[object Uint8ClampedArray]",O="[object Uint16Array]",q="[object Uint32Array]";function F(T,M,B){var J=T.constructor;switch(M){case w:return e(T);case l:case u:return new J(+T);case C:return n(T,B);case _:case S:case b:case E:case N:case j:case P:case O:case q:return o(T,B);case c:return new J;case f:case g:return new J(T);case p:return i(T);case h:return new J;case y:return s(T)}}return Xf=F,Xf}var Qf,r_;function $N(){if(r_)return Qf;r_=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,i_;function DN(){if(i_)return Zf;i_=1;var e=$N(),n=au(),i=ou();function s(o){return typeof o.constructor=="function"&&!i(o)?e(n(o)):{}}return Zf=s,Zf}var Jf,s_;function ZO(){if(s_)return Jf;s_=1;var e=Ys(),n=fr(),i="[object Map]";function s(o){return n(o)&&e(o)==i}return Jf=s,Jf}var eh,o_;function JO(){if(o_)return eh;o_=1;var e=ZO(),n=su(),i=_v(),s=i&&i.isMap,o=s?n(s):e;return eh=o,eh}var th,a_;function eq(){if(a_)return th;a_=1;var e=Ys(),n=fr(),i="[object Set]";function s(o){return n(o)&&e(o)==i}return th=s,th}var nh,l_;function tq(){if(l_)return nh;l_=1;var e=eq(),n=su(),i=_v(),s=i&&i.isSet,o=s?n(s):e;return nh=o,nh}var rh,u_;function FN(){if(u_)return rh;u_=1;var e=tu(),n=wv(),i=ru(),s=LO(),o=FO(),l=jN(),u=TN(),c=zO(),f=BO(),p=PN(),h=UO(),g=Ys(),y=GO(),w=QO(),C=DN(),_=St(),S=Ks(),b=JO(),E=On(),N=tq(),j=yi(),P=ts(),O=1,q=2,F=4,T="[object Arguments]",M="[object Array]",B="[object Boolean]",J="[object Date]",Z="[object Error]",A="[object Function]",H="[object GeneratorFunction]",U="[object Map]",ne="[object Number]",Q="[object Object]",D="[object RegExp]",G="[object Set]",k="[object String]",L="[object Symbol]",oe="[object WeakMap]",$="[object ArrayBuffer]",Y="[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[Y]=ke[B]=ke[J]=ke[ee]=ke[se]=ke[ae]=ke[pe]=ke[ge]=ke[U]=ke[ne]=ke[Q]=ke[D]=ke[G]=ke[k]=ke[L]=ke[Ae]=ke[Oe]=ke[Me]=ke[Pe]=!0,ke[Z]=ke[A]=ke[oe]=!1;function We(ve,ye,Ge,ut,it,Ke){var $e,Qe=ye&O,bt=ye&q,ct=ye&F;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=g(ve),kt=mt==A||mt==H;if(S(ve))return l(ve,Qe);if(mt==Q||mt==T||kt&&!it){if($e=bt||kt?{}:C(ve),!Qe)return bt?f(ve,o($e,ve)):c(ve,s($e,ve))}else{if(!ke[mt])return it?ve:{};$e=w(ve,mt,Qe)}}Ke||(Ke=new e);var He=Ke.get(ve);if(He)return He;Ke.set(ve,$e),N(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?h:p: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,c_;function nq(){if(c_)return ih;c_=1;var e=FN(),n=4;function i(s){return e(s,n)}return ih=i,ih}var sh,d_;function Nv(){if(d_)return sh;d_=1;function e(n){return function(){return n}}return sh=e,sh}var oh,f_;function rq(){if(f_)return oh;f_=1;function e(n){return function(i,s,o){for(var l=-1,u=Object(i),c=o(i),f=c.length;f--;){var p=c[n?f:++l];if(s(u[p],p,u)===!1)break}return i}}return oh=e,oh}var ah,h_;function Cv(){if(h_)return ah;h_=1;var e=rq(),n=e();return ah=n,ah}var lh,p_;function jv(){if(p_)return lh;p_=1;var e=Cv(),n=yi();function i(s,o){return s&&e(s,o,n)}return lh=i,lh}var uh,m_;function iq(){if(m_)return uh;m_=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,f=Object(o);(s?c--:++c<u)&&l(f[c],c,f)!==!1;);return o}}return uh=n,uh}var ch,g_;function lu(){if(g_)return ch;g_=1;var e=jv(),n=iq(),i=n(e);return ch=i,ch}var dh,v_;function ns(){if(v_)return dh;v_=1;function e(n){return n}return dh=e,dh}var fh,y_;function zN(){if(y_)return fh;y_=1;var e=ns();function n(i){return typeof i=="function"?i:e}return fh=n,fh}var hh,w_;function BN(){if(w_)return hh;w_=1;var e=wv(),n=lu(),i=zN(),s=St();function o(l,u){var c=s(l)?e:n;return c(l,i(u))}return hh=o,hh}var ph,x_;function UN(){return x_||(x_=1,ph=BN()),ph}var mh,__;function sq(){if(__)return mh;__=1;var e=lu();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,S_;function oq(){if(S_)return gh;S_=1;var e="__lodash_hash_undefined__";function n(i){return this.__data__.set(i,e),this}return gh=n,gh}var vh,b_;function aq(){if(b_)return vh;b_=1;function e(n){return this.__data__.has(n)}return vh=e,vh}var yh,k_;function HN(){if(k_)return yh;k_=1;var e=yv(),n=oq(),i=aq();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,E_;function lq(){if(E_)return wh;E_=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,N_;function VN(){if(N_)return xh;N_=1;function e(n,i){return n.has(i)}return xh=e,xh}var _h,C_;function WN(){if(C_)return _h;C_=1;var e=HN(),n=lq(),i=VN(),s=1,o=2;function l(u,c,f,p,h,g){var y=f&s,w=u.length,C=c.length;if(w!=C&&!(y&&C>w))return!1;var _=g.get(u),S=g.get(c);if(_&&S)return _==c&&S==u;var b=-1,E=!0,N=f&o?new e:void 0;for(g.set(u,c),g.set(c,u);++b<w;){var j=u[b],P=c[b];if(p)var O=y?p(P,j,b,c,u,g):p(j,P,b,u,c,g);if(O!==void 0){if(O)continue;E=!1;break}if(N){if(!n(c,function(q,F){if(!i(N,F)&&(j===q||h(j,q,f,p,g)))return N.push(F)})){E=!1;break}}else if(!(j===P||h(j,P,f,p,g))){E=!1;break}}return g.delete(u),g.delete(c),E}return _h=l,_h}var Sh,j_;function uq(){if(j_)return Sh;j_=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 Tv(){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,R_;function cq(){if(R_)return kh;R_=1;var e=Gs(),n=qN(),i=Ws(),s=WN(),o=uq(),l=Tv(),u=1,c=2,f="[object Boolean]",p="[object Date]",h="[object Error]",g="[object Map]",y="[object Number]",w="[object RegExp]",C="[object Set]",_="[object String]",S="[object Symbol]",b="[object ArrayBuffer]",E="[object DataView]",N=e?e.prototype:void 0,j=N?N.valueOf:void 0;function P(O,q,F,T,M,B,J){switch(F){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||!B(new n(O),new n(q)));case f:case p:case y:return i(+O,+q);case h:return O.name==q.name&&O.message==q.message;case w:case _:return O==q+"";case g:var Z=o;case C:var A=T&u;if(Z||(Z=l),O.size!=q.size&&!A)return!1;var H=J.get(O);if(H)return H==q;T|=c,J.set(O,q);var U=s(Z(O),Z(q),T,M,B,J);return J.delete(O),U;case S:if(j)return j.call(O)==j.call(q)}return!1}return kh=P,kh}var Eh,A_;function dq(){if(A_)return Eh;A_=1;var e=PN(),n=1,i=Object.prototype,s=i.hasOwnProperty;function o(l,u,c,f,p,h){var g=c&n,y=e(l),w=y.length,C=e(u),_=C.length;if(w!=_&&!g)return!1;for(var S=w;S--;){var b=y[S];if(!(g?b in u:s.call(u,b)))return!1}var E=h.get(l),N=h.get(u);if(E&&N)return E==u&&N==l;var j=!0;h.set(l,u),h.set(u,l);for(var P=g;++S<w;){b=y[S];var O=l[b],q=u[b];if(f)var F=g?f(q,O,b,u,l,h):f(O,q,b,l,u,h);if(!(F===void 0?O===q||p(O,q,c,f,h):F)){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 h.delete(l),h.delete(u),j}return Eh=o,Eh}var Nh,I_;function fq(){if(I_)return Nh;I_=1;var e=tu(),n=WN(),i=cq(),s=dq(),o=Ys(),l=St(),u=Ks(),c=ca(),f=1,p="[object Arguments]",h="[object Array]",g="[object Object]",y=Object.prototype,w=y.hasOwnProperty;function C(_,S,b,E,N,j){var P=l(_),O=l(S),q=P?h:o(_),F=O?h:o(S);q=q==p?g:q,F=F==p?g:F;var T=q==g,M=F==g,B=q==F;if(B&&u(_)){if(!u(S))return!1;P=!0,T=!1}if(B&&!T)return j||(j=new e),P||c(_)?n(_,S,b,E,N,j):i(_,S,q,b,E,N,j);if(!(b&f)){var J=T&&w.call(_,"__wrapped__"),Z=M&&w.call(S,"__wrapped__");if(J||Z){var A=J?_.value():_,H=Z?S.value():S;return j||(j=new e),N(A,H,b,E,j)}}return B?(j||(j=new e),s(_,S,b,E,N,j)):!1}return Nh=C,Nh}var Ch,M_;function GN(){if(M_)return Ch;M_=1;var e=fq(),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,P_;function hq(){if(P_)return jh;P_=1;var e=tu(),n=GN(),i=1,s=2;function o(l,u,c,f){var p=c.length,h=p,g=!f;if(l==null)return!h;for(l=Object(l);p--;){var y=c[p];if(g&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++p<h;){y=c[p];var w=y[0],C=l[w],_=y[1];if(g&&y[2]){if(C===void 0&&!(w in l))return!1}else{var S=new e;if(f)var b=f(C,_,w,l,u,S);if(!(b===void 0?n(_,C,i|s,f,S):b))return!1}}return!0}return jh=o,jh}var Th,O_;function KN(){if(O_)return Th;O_=1;var e=On();function n(i){return i===i&&!e(i)}return Th=n,Th}var Rh,q_;function pq(){if(q_)return Rh;q_=1;var e=KN(),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 Rh=i,Rh}var Ah,L_;function YN(){if(L_)return Ah;L_=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,$_;function mq(){if($_)return Ih;$_=1;var e=hq(),n=pq(),i=YN();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,D_;function Xs(){if(D_)return Mh;D_=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,F_;function Rv(){if(F_)return Ph;F_=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,z_;function gq(){if(z_)return Oh;z_=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],f=l.cache;if(f.has(c))return f.get(c);var p=s.apply(this,u);return l.cache=f.set(c,p)||f,p};return l.cache=new(i.Cache||e),l}return i.Cache=e,Oh=i,Oh}var qh,B_;function vq(){if(B_)return qh;B_=1;var e=gq(),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,U_;function yq(){if(U_)return Lh;U_=1;var e=vq(),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,f,p){l.push(f?p.replace(i,"$1"):c||u)}),l});return Lh=s,Lh}var $h,H_;function uu(){if(H_)return $h;H_=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,V_;function wq(){if(V_)return Dh;V_=1;var e=Gs(),n=uu(),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 f=c+"";return f=="0"&&1/c==-1/0?"-0":f}return Dh=u,Dh}var Fh,W_;function XN(){if(W_)return Fh;W_=1;var e=wq();function n(i){return i==null?"":e(i)}return Fh=n,Fh}var zh,G_;function cu(){if(G_)return zh;G_=1;var e=St(),n=Rv(),i=yq(),s=XN();function o(l,u){return e(l)?l:n(l,u)?[l]:i(s(l))}return zh=o,zh}var Bh,K_;function da(){if(K_)return Bh;K_=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,Y_;function du(){if(Y_)return Uh;Y_=1;var e=cu(),n=da();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,X_;function xq(){if(X_)return Hh;X_=1;var e=du();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,Q_;function _q(){if(Q_)return Vh;Q_=1;function e(n,i){return n!=null&&i in Object(n)}return Vh=e,Vh}var Wh,Z_;function QN(){if(Z_)return Wh;Z_=1;var e=cu(),n=ua(),i=St(),s=iu(),o=xv(),l=da();function u(c,f,p){f=e(f,c);for(var h=-1,g=f.length,y=!1;++h<g;){var w=l(f[h]);if(!(y=c!=null&&p(c,w)))break;c=c[w]}return y||++h!=g?y:(g=c==null?0:c.length,!!g&&o(g)&&s(w,g)&&(i(c)||n(c)))}return Wh=u,Wh}var Gh,J_;function ZN(){if(J_)return Gh;J_=1;var e=_q(),n=QN();function i(s,o){return s!=null&&n(s,o,e)}return Gh=i,Gh}var Kh,eS;function Sq(){if(eS)return Kh;eS=1;var e=GN(),n=xq(),i=ZN(),s=Rv(),o=KN(),l=YN(),u=da(),c=1,f=2;function p(h,g){return s(h)&&o(g)?l(u(h),g):function(y){var w=n(y,h);return w===void 0&&w===g?i(y,h):e(g,w,c|f)}}return Kh=p,Kh}var Yh,tS;function JN(){if(tS)return Yh;tS=1;function e(n){return function(i){return i==null?void 0:i[n]}}return Yh=e,Yh}var Xh,nS;function bq(){if(nS)return Xh;nS=1;var e=du();function n(i){return function(s){return e(s,i)}}return Xh=n,Xh}var Qh,rS;function kq(){if(rS)return Qh;rS=1;var e=JN(),n=bq(),i=Rv(),s=da();function o(l){return i(l)?e(s(l)):n(l)}return Qh=o,Qh}var Zh,iS;function Lr(){if(iS)return Zh;iS=1;var e=mq(),n=Sq(),i=ns(),s=St(),o=kq();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,sS;function eC(){if(sS)return Jh;sS=1;var e=RN(),n=sq(),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,oS;function Eq(){if(oS)return ep;oS=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,aS;function tC(){if(aS)return tp;aS=1;var e=Eq(),n=QN();function i(s,o){return s!=null&&n(s,o,e)}return tp=i,tp}var np,lS;function Nq(){if(lS)return np;lS=1;var e=Sv(),n=Ys(),i=ua(),s=St(),o=qr(),l=Ks(),u=ou(),c=ca(),f="[object Map]",p="[object Set]",h=Object.prototype,g=h.hasOwnProperty;function y(w){if(w==null)return!0;if(o(w)&&(s(w)||typeof w=="string"||typeof w.splice=="function"||l(w)||c(w)||i(w)))return!w.length;var C=n(w);if(C==f||C==p)return!w.size;if(u(w))return!e(w).length;for(var _ in w)if(g.call(w,_))return!1;return!0}return np=y,np}var rp,uS;function nC(){if(uS)return rp;uS=1;function e(n){return n===void 0}return rp=e,rp}var ip,cS;function rC(){if(cS)return ip;cS=1;var e=lu(),n=qr();function i(s,o){var l=-1,u=n(s)?Array(s.length):[];return e(s,function(c,f,p){u[++l]=o(c,f,p)}),u}return ip=i,ip}var sp,dS;function iC(){if(dS)return sp;dS=1;var e=uu(),n=Lr(),i=rC(),s=St();function o(l,u){var c=s(l)?e:i;return c(l,n(u,3))}return sp=o,sp}var op,fS;function Cq(){if(fS)return op;fS=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,hS;function jq(){if(hS)return ap;hS=1;function e(n,i,s,o,l){return l(n,function(u,c,f){s=o?(o=!1,u):i(s,u,c,f)}),s}return ap=e,ap}var lp,pS;function sC(){if(pS)return lp;pS=1;var e=Cq(),n=lu(),i=Lr(),s=jq(),o=St();function l(u,c,f){var p=o(u)?e:s,h=arguments.length<3;return p(u,i(c,4),f,h,n)}return lp=l,lp}var up,mS;function Tq(){if(mS)return up;mS=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,gS;function Rq(){if(gS)return cp;gS=1;var e=JN(),n=e("length");return cp=n,cp}var dp,vS;function Aq(){if(vS)return dp;vS=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 f(p){return c.test(p)}return dp=f,dp}var fp,yS;function Iq(){if(yS)return fp;yS=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+"]",f="\\ud83c[\\udffb-\\udfff]",p="(?:"+c+"|"+f+")",h="[^"+e+"]",g="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",C=p+"?",_="["+l+"]?",S="(?:"+w+"(?:"+[h,g,y].join("|")+")"+_+C+")*",b=_+C+S,E="(?:"+[h+c+"?",c,g,y,u].join("|")+")",N=RegExp(f+"(?="+f+")|"+E+b,"g");function j(P){for(var O=N.lastIndex=0;N.test(P);)++O;return O}return fp=j,fp}var hp,wS;function Mq(){if(wS)return hp;wS=1;var e=Rq(),n=Aq(),i=Iq();function s(o){return n(o)?i(o):e(o)}return hp=s,hp}var pp,xS;function Pq(){if(xS)return pp;xS=1;var e=Sv(),n=Ys(),i=qr(),s=Tq(),o=Mq(),l="[object Map]",u="[object Set]";function c(f){if(f==null)return 0;if(i(f))return s(f)?o(f):f.length;var p=n(f);return p==l||p==u?f.size:e(f).length}return pp=c,pp}var mp,_S;function Oq(){if(_S)return mp;_S=1;var e=wv(),n=$N(),i=jv(),s=Lr(),o=au(),l=St(),u=Ks(),c=aa(),f=On(),p=ca();function h(g,y,w){var C=l(g),_=C||u(g)||p(g);if(y=s(y,4),w==null){var S=g&&g.constructor;_?w=C?new S:[]:f(g)?w=c(S)?n(o(g)):{}:w={}}return(_?e:i)(g,function(b,E,N){return y(w,b,E,N)}),w}return mp=h,mp}var gp,SS;function qq(){if(SS)return gp;SS=1;var e=Gs(),n=ua(),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,bS;function Av(){if(bS)return vp;bS=1;var e=kv(),n=qq();function i(s,o,l,u,c){var f=-1,p=s.length;for(l||(l=n),c||(c=[]);++f<p;){var h=s[f];o>0&&l(h)?o>1?i(h,o-1,l,u,c):e(c,h):u||(c[c.length]=h)}return c}return vp=i,vp}var yp,kS;function Lq(){if(kS)return yp;kS=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,ES;function oC(){if(ES)return wp;ES=1;var e=Lq(),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,f=n(u.length-o,0),p=Array(f);++c<f;)p[c]=u[o+c];c=-1;for(var h=Array(o+1);++c<o;)h[c]=u[c];return h[o]=l(p),e(s,this,h)}}return wp=i,wp}var xp,NS;function $q(){if(NS)return xp;NS=1;var e=Nv(),n=EN(),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,CS;function Dq(){if(CS)return _p;CS=1;var e=800,n=16,i=Date.now;function s(o){var l=0,u=0;return function(){var c=i(),f=n-(c-u);if(u=c,f>0){if(++l>=e)return arguments[0]}else l=0;return o.apply(void 0,arguments)}}return _p=s,_p}var Sp,jS;function aC(){if(jS)return Sp;jS=1;var e=$q(),n=Dq(),i=n(e);return Sp=i,Sp}var bp,TS;function fu(){if(TS)return bp;TS=1;var e=ns(),n=oC(),i=aC();function s(o,l){return i(n(o,l,e),o+"")}return bp=s,bp}var kp,RS;function lC(){if(RS)return kp;RS=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,AS;function Fq(){if(AS)return Ep;AS=1;function e(n){return n!==n}return Ep=e,Ep}var Np,IS;function zq(){if(IS)return Np;IS=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,MS;function Bq(){if(MS)return Cp;MS=1;var e=lC(),n=Fq(),i=zq();function s(o,l,u){return l===l?i(o,l,u):e(o,n,u)}return Cp=s,Cp}var jp,PS;function Uq(){if(PS)return jp;PS=1;var e=Bq();function n(i,s){var o=i==null?0:i.length;return!!o&&e(i,s,0)>-1}return jp=n,jp}var Tp,OS;function Hq(){if(OS)return Tp;OS=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 Tp=e,Tp}var Rp,qS;function Vq(){if(qS)return Rp;qS=1;function e(){}return Rp=e,Rp}var Ap,LS;function Wq(){if(LS)return Ap;LS=1;var e=ON(),n=Vq(),i=Tv(),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,$S;function Gq(){if($S)return Ip;$S=1;var e=HN(),n=Uq(),i=Hq(),s=VN(),o=Wq(),l=Tv(),u=200;function c(f,p,h){var g=-1,y=n,w=f.length,C=!0,_=[],S=_;if(h)C=!1,y=i;else if(w>=u){var b=p?null:o(f);if(b)return l(b);C=!1,y=s,S=new e}else S=p?[]:_;e:for(;++g<w;){var E=f[g],N=p?p(E):E;if(E=h||E!==0?E:0,C&&N===N){for(var j=S.length;j--;)if(S[j]===N)continue e;p&&S.push(N),_.push(E)}else y(S,N,h)||(S!==_&&S.push(N),_.push(E))}return _}return Ip=c,Ip}var Mp,DS;function uC(){if(DS)return Mp;DS=1;var e=qr(),n=fr();function i(s){return n(s)&&e(s)}return Mp=i,Mp}var Pp,FS;function Kq(){if(FS)return Pp;FS=1;var e=Av(),n=fu(),i=Gq(),s=uC(),o=n(function(l){return i(e(l,1,s,!0))});return Pp=o,Pp}var Op,zS;function Yq(){if(zS)return Op;zS=1;var e=uu();function n(i,s){return e(s,function(o){return i[o]})}return Op=n,Op}var qp,BS;function cC(){if(BS)return qp;BS=1;var e=Yq(),n=yi();function i(s){return s==null?[]:e(s,n(s))}return qp=i,qp}var Lp,US;function qn(){if(US)return Lp;US=1;var e;if(typeof gv=="function")try{e={clone:nq(),constant:Nv(),each:UN(),filter:eC(),has:tC(),isArray:St(),isEmpty:Nq(),isFunction:aa(),isUndefined:nC(),keys:yi(),map:iC(),reduce:sC(),size:Pq(),transform:Oq(),union:Kq(),values:cC()}}catch{}return e||(e=window._),Lp=e,Lp}var $p,HS;function Iv(){if(HS)return $p;HS=1;var e=qn();$p=o;var n="\0",i="\0",s="";function o(h){this._isDirected=e.has(h,"directed")?h.directed:!0,this._isMultigraph=e.has(h,"multigraph")?h.multigraph:!1,this._isCompound=e.has(h,"compound")?h.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(h){return this._label=h,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultNodeLabelFn=h,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var h=this;return e.filter(this.nodes(),function(g){return e.isEmpty(h._in[g])})},o.prototype.sinks=function(){var h=this;return e.filter(this.nodes(),function(g){return e.isEmpty(h._out[g])})},o.prototype.setNodes=function(h,g){var y=arguments,w=this;return e.each(h,function(C){y.length>1?w.setNode(C,g):w.setNode(C)}),this},o.prototype.setNode=function(h,g){return e.has(this._nodes,h)?(arguments.length>1&&(this._nodes[h]=g),this):(this._nodes[h]=arguments.length>1?g:this._defaultNodeLabelFn(h),this._isCompound&&(this._parent[h]=i,this._children[h]={},this._children[i][h]=!0),this._in[h]={},this._preds[h]={},this._out[h]={},this._sucs[h]={},++this._nodeCount,this)},o.prototype.node=function(h){return this._nodes[h]},o.prototype.hasNode=function(h){return e.has(this._nodes,h)},o.prototype.removeNode=function(h){var g=this;if(e.has(this._nodes,h)){var y=function(w){g.removeEdge(g._edgeObjs[w])};delete this._nodes[h],this._isCompound&&(this._removeFromParentsChildList(h),delete this._parent[h],e.each(this.children(h),function(w){g.setParent(w)}),delete this._children[h]),e.each(e.keys(this._in[h]),y),delete this._in[h],delete this._preds[h],e.each(e.keys(this._out[h]),y),delete this._out[h],delete this._sucs[h],--this._nodeCount}return this},o.prototype.setParent=function(h,g){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(g))g=i;else{g+="";for(var y=g;!e.isUndefined(y);y=this.parent(y))if(y===h)throw new Error("Setting "+g+" as parent of "+h+" would create a cycle");this.setNode(g)}return this.setNode(h),this._removeFromParentsChildList(h),this._parent[h]=g,this._children[g][h]=!0,this},o.prototype._removeFromParentsChildList=function(h){delete this._children[this._parent[h]][h]},o.prototype.parent=function(h){if(this._isCompound){var g=this._parent[h];if(g!==i)return g}},o.prototype.children=function(h){if(e.isUndefined(h)&&(h=i),this._isCompound){var g=this._children[h];if(g)return e.keys(g)}else{if(h===i)return this.nodes();if(this.hasNode(h))return[]}},o.prototype.predecessors=function(h){var g=this._preds[h];if(g)return e.keys(g)},o.prototype.successors=function(h){var g=this._sucs[h];if(g)return e.keys(g)},o.prototype.neighbors=function(h){var g=this.predecessors(h);if(g)return e.union(g,this.successors(h))},o.prototype.isLeaf=function(h){var g;return this.isDirected()?g=this.successors(h):g=this.neighbors(h),g.length===0},o.prototype.filterNodes=function(h){var g=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});g.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,S){h(S)&&g.setNode(S,_)}),e.each(this._edgeObjs,function(_){g.hasNode(_.v)&&g.hasNode(_.w)&&g.setEdge(_,y.edge(_))});var w={};function C(_){var S=y.parent(_);return S===void 0||g.hasNode(S)?(w[_]=S,S):S in w?w[S]:C(S)}return this._isCompound&&e.each(g.nodes(),function(_){g.setParent(_,C(_))}),g},o.prototype.setDefaultEdgeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultEdgeLabelFn=h,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(h,g){var y=this,w=arguments;return e.reduce(h,function(C,_){return w.length>1?y.setEdge(C,_,g):y.setEdge(C,_),_}),this},o.prototype.setEdge=function(){var h,g,y,w,C=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(h=_.v,g=_.w,y=_.name,arguments.length===2&&(w=arguments[1],C=!0)):(h=_,g=arguments[1],y=arguments[3],arguments.length>2&&(w=arguments[2],C=!0)),h=""+h,g=""+g,e.isUndefined(y)||(y=""+y);var S=c(this._isDirected,h,g,y);if(e.has(this._edgeLabels,S))return C&&(this._edgeLabels[S]=w),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(h),this.setNode(g),this._edgeLabels[S]=C?w:this._defaultEdgeLabelFn(h,g,y);var b=f(this._isDirected,h,g,y);return h=b.v,g=b.w,Object.freeze(b),this._edgeObjs[S]=b,l(this._preds[g],h),l(this._sucs[h],g),this._in[g][S]=b,this._out[h][S]=b,this._edgeCount++,this},o.prototype.edge=function(h,g,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,h,g,y);return this._edgeLabels[w]},o.prototype.hasEdge=function(h,g,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,h,g,y);return e.has(this._edgeLabels,w)},o.prototype.removeEdge=function(h,g,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,h,g,y),C=this._edgeObjs[w];return C&&(h=C.v,g=C.w,delete this._edgeLabels[w],delete this._edgeObjs[w],u(this._preds[g],h),u(this._sucs[h],g),delete this._in[g][w],delete this._out[h][w],this._edgeCount--),this},o.prototype.inEdges=function(h,g){var y=this._in[h];if(y){var w=e.values(y);return g?e.filter(w,function(C){return C.v===g}):w}},o.prototype.outEdges=function(h,g){var y=this._out[h];if(y){var w=e.values(y);return g?e.filter(w,function(C){return C.w===g}):w}},o.prototype.nodeEdges=function(h,g){var y=this.inEdges(h,g);if(y)return y.concat(this.outEdges(h,g))};function l(h,g){h[g]?h[g]++:h[g]=1}function u(h,g){--h[g]||delete h[g]}function c(h,g,y,w){var C=""+g,_=""+y;if(!h&&C>_){var S=C;C=_,_=S}return C+s+_+s+(e.isUndefined(w)?n:w)}function f(h,g,y,w){var C=""+g,_=""+y;if(!h&&C>_){var S=C;C=_,_=S}var b={v:C,w:_};return w&&(b.name=w),b}function p(h,g){return c(h,g.v,g.w,g.name)}return $p}var Dp,VS;function Xq(){return VS||(VS=1,Dp="2.1.8"),Dp}var Fp,WS;function Qq(){return WS||(WS=1,Fp={Graph:Iv(),version:Xq()}),Fp}var zp,GS;function Zq(){if(GS)return zp;GS=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 f=u.node(c),p=u.parent(c),h={v:c};return e.isUndefined(f)||(h.value=f),e.isUndefined(p)||(h.parent=p),h})}function o(u){return e.map(u.edges(),function(c){var f=u.edge(c),p={v:c.v,w:c.w};return e.isUndefined(c.name)||(p.name=c.name),e.isUndefined(f)||(p.value=f),p})}function l(u){var c=new n(u.options).setGraph(u.value);return e.each(u.nodes,function(f){c.setNode(f.v,f.value),f.parent&&c.setParent(f.v,f.parent)}),e.each(u.edges,function(f){c.setEdge({v:f.v,w:f.w,name:f.name},f.value)}),c}return zp}var Bp,KS;function Jq(){if(KS)return Bp;KS=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,YS;function dC(){if(YS)return Up;YS=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,XS;function fC(){if(XS)return Hp;XS=1;var e=qn(),n=dC();Hp=s;var i=e.constant(1);function s(l,u,c,f){return o(l,String(u),c||i,f||function(p){return l.outEdges(p)})}function o(l,u,c,f){var p={},h=new n,g,y,w=function(C){var _=C.v!==g?C.v:C.w,S=p[_],b=c(C),E=y.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+C+" Weight: "+b);E<S.distance&&(S.distance=E,S.predecessor=g,h.decrease(_,E))};for(l.nodes().forEach(function(C){var _=C===u?0:Number.POSITIVE_INFINITY;p[C]={distance:_},h.add(C,_)});h.size()>0&&(g=h.removeMin(),y=p[g],y.distance!==Number.POSITIVE_INFINITY);)f(g).forEach(w);return p}return Hp}var Vp,QS;function eL(){if(QS)return Vp;QS=1;var e=fC(),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,ZS;function hC(){if(ZS)return Wp;ZS=1;var e=qn();Wp=n;function n(i){var s=0,o=[],l={},u=[];function c(f){var p=l[f]={onStack:!0,lowlink:s,index:s++};if(o.push(f),i.successors(f).forEach(function(y){e.has(l,y)?l[y].onStack&&(p.lowlink=Math.min(p.lowlink,l[y].index)):(c(y),p.lowlink=Math.min(p.lowlink,l[y].lowlink))}),p.lowlink===p.index){var h=[],g;do g=o.pop(),l[g].onStack=!1,h.push(g);while(f!==g);u.push(h)}}return i.nodes().forEach(function(f){e.has(l,f)||c(f)}),u}return Wp}var Gp,JS;function tL(){if(JS)return Gp;JS=1;var e=qn(),n=hC();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,eb;function nL(){if(eb)return Kp;eb=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={},f=o.nodes();return f.forEach(function(p){c[p]={},c[p][p]={distance:0},f.forEach(function(h){p!==h&&(c[p][h]={distance:Number.POSITIVE_INFINITY})}),u(p).forEach(function(h){var g=h.v===p?h.w:h.v,y=l(h);c[p][g]={distance:y,predecessor:p}})}),f.forEach(function(p){var h=c[p];f.forEach(function(g){var y=c[g];f.forEach(function(w){var C=y[p],_=h[w],S=y[w],b=C.distance+_.distance;b<S.distance&&(S.distance=b,S.predecessor=_.predecessor)})})}),c}return Kp}var Yp,tb;function pC(){if(tb)return Yp;tb=1;var e=qn();Yp=n,n.CycleException=i;function n(s){var o={},l={},u=[];function c(f){if(e.has(l,f))throw new i;e.has(o,f)||(l[f]=!0,o[f]=!0,e.each(s.predecessors(f),c),delete l[f],u.push(f))}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,nb;function rL(){if(nb)return Xp;nb=1;var e=pC();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,rb;function mC(){if(rb)return Qp;rb=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=[],f={};return e.each(o,function(p){if(!s.hasNode(p))throw new Error("Graph does not have node: "+p);i(s,p,l==="post",f,u,c)}),c}function i(s,o,l,u,c,f){e.has(u,o)||(u[o]=!0,l||f.push(o),e.each(c(o),function(p){i(s,p,l,u,c,f)}),l&&f.push(o))}return Qp}var Zp,ib;function iL(){if(ib)return Zp;ib=1;var e=mC();Zp=n;function n(i,s){return e(i,s,"post")}return Zp}var Jp,sb;function sL(){if(sb)return Jp;sb=1;var e=mC();Jp=n;function n(i,s){return e(i,s,"pre")}return Jp}var em,ob;function oL(){if(ob)return em;ob=1;var e=qn(),n=Iv(),i=dC();em=s;function s(o,l){var u=new n,c={},f=new i,p;function h(y){var w=y.v===p?y.w:y.v,C=f.priority(w);if(C!==void 0){var _=l(y);_<C&&(c[w]=p,f.decrease(w,_))}}if(o.nodeCount()===0)return u;e.each(o.nodes(),function(y){f.add(y,Number.POSITIVE_INFINITY),u.setNode(y)}),f.decrease(o.nodes()[0],0);for(var g=!1;f.size()>0;){if(p=f.removeMin(),e.has(c,p))u.setEdge(p,c[p]);else{if(g)throw new Error("Input graph is not connected: "+o);g=!0}o.nodeEdges(p).forEach(h)}return u}return em}var tm,ab;function aL(){return ab||(ab=1,tm={components:Jq(),dijkstra:fC(),dijkstraAll:eL(),findCycles:tL(),floydWarshall:nL(),isAcyclic:rL(),postorder:iL(),preorder:sL(),prim:oL(),tarjan:hC(),topsort:pC()}),tm}var nm,lb;function lL(){if(lb)return nm;lb=1;var e=Qq();return nm={Graph:e.Graph,json:Zq(),alg:aL(),version:e.version},nm}var rm,ub;function Qn(){if(ub)return rm;ub=1;var e;if(typeof gv=="function")try{e=lL()}catch{}return e||(e=window.graphlib),rm=e,rm}var im,cb;function uL(){if(cb)return im;cb=1;var e=FN(),n=1,i=4;function s(o){return e(o,n|i)}return im=s,im}var sm,db;function hu(){if(db)return sm;db=1;var e=Ws(),n=qr(),i=iu(),s=On();function o(l,u,c){if(!s(c))return!1;var f=typeof u;return(f=="number"?n(c)&&i(u,c.length):f=="string"&&u in c)?e(c[u],l):!1}return sm=o,sm}var om,fb;function cL(){if(fb)return om;fb=1;var e=fu(),n=Ws(),i=hu(),s=ts(),o=Object.prototype,l=o.hasOwnProperty,u=e(function(c,f){c=Object(c);var p=-1,h=f.length,g=h>2?f[2]:void 0;for(g&&i(f[0],f[1],g)&&(h=1);++p<h;)for(var y=f[p],w=s(y),C=-1,_=w.length;++C<_;){var S=w[C],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,hb;function dL(){if(hb)return am;hb=1;var e=Lr(),n=qr(),i=yi();function s(o){return function(l,u,c){var f=Object(l);if(!n(l)){var p=e(u,3);l=i(l),u=function(g){return p(f[g],g,f)}}var h=o(l,u,c);return h>-1?f[p?l[h]:h]:void 0}}return am=s,am}var lm,pb;function fL(){if(pb)return lm;pb=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,mb;function hL(){if(mb)return um;mb=1;var e=fL(),n=/^\s+/;function i(s){return s&&s.slice(0,e(s)+1).replace(n,"")}return um=i,um}var cm,gb;function pL(){if(gb)return cm;gb=1;var e=hL(),n=On(),i=Xs(),s=NaN,o=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;function f(p){if(typeof p=="number")return p;if(i(p))return s;if(n(p)){var h=typeof p.valueOf=="function"?p.valueOf():p;p=n(h)?h+"":h}if(typeof p!="string")return p===0?p:+p;p=e(p);var g=l.test(p);return g||u.test(p)?c(p.slice(2),g?2:8):o.test(p)?s:+p}return cm=f,cm}var dm,vb;function gC(){if(vb)return dm;vb=1;var e=pL(),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,yb;function mL(){if(yb)return fm;yb=1;var e=gC();function n(i){var s=e(i),o=s%1;return s===s?o?s-o:s:0}return fm=n,fm}var hm,wb;function gL(){if(wb)return hm;wb=1;var e=lC(),n=Lr(),i=mL(),s=Math.max;function o(l,u,c){var f=l==null?0:l.length;if(!f)return-1;var p=c==null?0:i(c);return p<0&&(p=s(f+p,0)),e(l,n(u,3),p)}return hm=o,hm}var pm,xb;function vL(){if(xb)return pm;xb=1;var e=dL(),n=gL(),i=e(n);return pm=i,pm}var mm,_b;function vC(){if(_b)return mm;_b=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,Sb;function yL(){if(Sb)return gm;Sb=1;var e=Cv(),n=zN(),i=ts();function s(o,l){return o==null?o:e(o,n(l),i)}return gm=s,gm}var vm,bb;function wL(){if(bb)return vm;bb=1;function e(n){var i=n==null?0:n.length;return i?n[i-1]:void 0}return vm=e,vm}var ym,kb;function xL(){if(kb)return ym;kb=1;var e=nu(),n=jv(),i=Lr();function s(o,l){var u={};return l=i(l,3),n(o,function(c,f,p){e(u,f,l(c,f,p))}),u}return ym=s,ym}var wm,Eb;function Mv(){if(Eb)return wm;Eb=1;var e=Xs();function n(i,s,o){for(var l=-1,u=i.length;++l<u;){var c=i[l],f=s(c);if(f!=null&&(p===void 0?f===f&&!e(f):o(f,p)))var p=f,h=c}return h}return wm=n,wm}var xm,Nb;function _L(){if(Nb)return xm;Nb=1;function e(n,i){return n>i}return xm=e,xm}var _m,Cb;function SL(){if(Cb)return _m;Cb=1;var e=Mv(),n=_L(),i=ns();function s(o){return o&&o.length?e(o,i,n):void 0}return _m=s,_m}var Sm,jb;function yC(){if(jb)return Sm;jb=1;var e=nu(),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 bL(){if(Tb)return bm;Tb=1;var e=Ji(),n=au(),i=fr(),s="[object Object]",o=Function.prototype,l=Object.prototype,u=o.toString,c=l.hasOwnProperty,f=u.call(Object);function p(h){if(!i(h)||e(h)!=s)return!1;var g=n(h);if(g===null)return!0;var y=c.call(g,"constructor")&&g.constructor;return typeof y=="function"&&y instanceof y&&u.call(y)==f}return bm=p,bm}var km,Rb;function wC(){if(Rb)return km;Rb=1;function e(n,i){if(!(i==="constructor"&&typeof n[i]=="function")&&i!="__proto__")return n[i]}return km=e,km}var Em,Ab;function kL(){if(Ab)return Em;Ab=1;var e=la(),n=ts();function i(s){return e(s,n(s))}return Em=i,Em}var Nm,Ib;function EL(){if(Ib)return Nm;Ib=1;var e=yC(),n=jN(),i=LN(),s=TN(),o=DN(),l=ua(),u=St(),c=uC(),f=Ks(),p=aa(),h=On(),g=bL(),y=ca(),w=wC(),C=kL();function _(S,b,E,N,j,P,O){var q=w(S,E),F=w(b,E),T=O.get(F);if(T){e(S,E,T);return}var M=P?P(q,F,E+"",S,b,O):void 0,B=M===void 0;if(B){var J=u(F),Z=!J&&f(F),A=!J&&!Z&&y(F);M=F,J||Z||A?u(q)?M=q:c(q)?M=s(q):Z?(B=!1,M=n(F,!0)):A?(B=!1,M=i(F,!0)):M=[]:g(F)||l(F)?(M=q,l(q)?M=C(q):(!h(q)||p(q))&&(M=o(F))):B=!1}B&&(O.set(F,M),j(M,F,N,P,O),O.delete(F)),e(S,E,M)}return Nm=_,Nm}var Cm,Mb;function NL(){if(Mb)return Cm;Mb=1;var e=tu(),n=yC(),i=Cv(),s=EL(),o=On(),l=ts(),u=wC();function c(f,p,h,g,y){f!==p&&i(p,function(w,C){if(y||(y=new e),o(w))s(f,p,C,h,c,g,y);else{var _=g?g(u(f,C),w,C+"",f,p,y):void 0;_===void 0&&(_=w),n(f,C,_)}},l)}return Cm=c,Cm}var jm,Pb;function CL(){if(Pb)return jm;Pb=1;var e=fu(),n=hu();function i(s){return e(function(o,l){var u=-1,c=l.length,f=c>1?l[c-1]:void 0,p=c>2?l[2]:void 0;for(f=s.length>3&&typeof f=="function"?(c--,f):void 0,p&&n(l[0],l[1],p)&&(f=c<3?void 0:f,c=1),o=Object(o);++u<c;){var h=l[u];h&&s(o,h,u,f)}return o})}return jm=i,jm}var Tm,Ob;function jL(){if(Ob)return Tm;Ob=1;var e=NL(),n=CL(),i=n(function(s,o,l){e(s,o,l)});return Tm=i,Tm}var Rm,qb;function xC(){if(qb)return Rm;qb=1;function e(n,i){return n<i}return Rm=e,Rm}var Am,Lb;function TL(){if(Lb)return Am;Lb=1;var e=Mv(),n=xC(),i=ns();function s(o){return o&&o.length?e(o,i,n):void 0}return Am=s,Am}var Im,$b;function RL(){if($b)return Im;$b=1;var e=Mv(),n=Lr(),i=xC();function s(o,l){return o&&o.length?e(o,n(l,2),i):void 0}return Im=s,Im}var Mm,Db;function AL(){if(Db)return Mm;Db=1;var e=Jn(),n=function(){return e.Date.now()};return Mm=n,Mm}var Pm,Fb;function IL(){if(Fb)return Pm;Fb=1;var e=ru(),n=cu(),i=iu(),s=On(),o=da();function l(u,c,f,p){if(!s(u))return u;c=n(c,u);for(var h=-1,g=c.length,y=g-1,w=u;w!=null&&++h<g;){var C=o(c[h]),_=f;if(C==="__proto__"||C==="constructor"||C==="prototype")return u;if(h!=y){var S=w[C];_=p?p(S,C,w):void 0,_===void 0&&(_=s(S)?S:i(c[h+1])?[]:{})}e(w,C,_),w=w[C]}return u}return Pm=l,Pm}var Om,zb;function ML(){if(zb)return Om;zb=1;var e=du(),n=IL(),i=cu();function s(o,l,u){for(var c=-1,f=l.length,p={};++c<f;){var h=l[c],g=e(o,h);u(g,h)&&n(p,i(h,o),g)}return p}return Om=s,Om}var qm,Bb;function PL(){if(Bb)return qm;Bb=1;var e=ML(),n=ZN();function i(s,o){return e(s,o,function(l,u){return n(s,u)})}return qm=i,qm}var Lm,Ub;function OL(){if(Ub)return Lm;Ub=1;var e=vC(),n=oC(),i=aC();function s(o){return i(n(o,void 0,e),o+"")}return Lm=s,Lm}var $m,Hb;function qL(){if(Hb)return $m;Hb=1;var e=PL(),n=OL(),i=n(function(s,o){return s==null?{}:e(s,o)});return $m=i,$m}var Dm,Vb;function LL(){if(Vb)return Dm;Vb=1;var e=Math.ceil,n=Math.max;function i(s,o,l,u){for(var c=-1,f=n(e((o-s)/(l||1)),0),p=Array(f);f--;)p[u?f:++c]=s,s+=l;return p}return Dm=i,Dm}var Fm,Wb;function $L(){if(Wb)return Fm;Wb=1;var e=LL(),n=hu(),i=gC();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,Gb;function DL(){if(Gb)return zm;Gb=1;var e=$L(),n=e();return zm=n,zm}var Bm,Kb;function FL(){if(Kb)return Bm;Kb=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,Yb;function zL(){if(Yb)return Um;Yb=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),f=s!==void 0,p=s===null,h=s===s,g=e(s);if(!p&&!g&&!c&&i>s||c&&f&&h&&!p&&!g||l&&f&&h||!o&&h||!u)return 1;if(!l&&!c&&!g&&i<s||g&&o&&u&&!l&&!c||p&&o&&u||!f&&u||!h)return-1}return 0}return Um=n,Um}var Hm,Xb;function BL(){if(Xb)return Hm;Xb=1;var e=zL();function n(i,s,o){for(var l=-1,u=i.criteria,c=s.criteria,f=u.length,p=o.length;++l<f;){var h=e(u[l],c[l]);if(h){if(l>=p)return h;var g=o[l];return h*(g=="desc"?-1:1)}}return i.index-s.index}return Hm=n,Hm}var Vm,Qb;function UL(){if(Qb)return Vm;Qb=1;var e=uu(),n=du(),i=Lr(),s=rC(),o=FL(),l=su(),u=BL(),c=ns(),f=St();function p(h,g,y){g.length?g=e(g,function(_){return f(_)?function(S){return n(S,_.length===1?_[0]:_)}:_}):g=[c];var w=-1;g=e(g,l(i));var C=s(h,function(_,S,b){var E=e(g,function(N){return N(_)});return{criteria:E,index:++w,value:_}});return o(C,function(_,S){return u(_,S,y)})}return Vm=p,Vm}var Wm,Zb;function HL(){if(Zb)return Wm;Zb=1;var e=Av(),n=UL(),i=fu(),s=hu(),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,Jb;function VL(){if(Jb)return Gm;Jb=1;var e=XN(),n=0;function i(s){var o=++n;return e(s)+o}return Gm=i,Gm}var Km,ek;function WL(){if(ek)return Km;ek=1;function e(n,i,s){for(var o=-1,l=n.length,u=i.length,c={};++o<l;){var f=o<u?i[o]:void 0;s(c,n[o],f)}return c}return Km=e,Km}var Ym,tk;function GL(){if(tk)return Ym;tk=1;var e=ru(),n=WL();function i(s,o){return n(s||[],o||[],e)}return Ym=i,Ym}var Xm,nk;function ot(){if(nk)return Xm;nk=1;var e;if(typeof gv=="function")try{e={cloneDeep:uL(),constant:Nv(),defaults:cL(),each:UN(),filter:eC(),find:vL(),flatten:vC(),forEach:BN(),forIn:yL(),has:tC(),isUndefined:nC(),last:wL(),map:iC(),mapValues:xL(),max:SL(),merge:jL(),min:TL(),minBy:RL(),now:AL(),pick:qL(),range:DL(),reduce:sC(),sortBy:HL(),uniqueId:VL(),values:cC(),zipObject:GL()}}catch{}return e||(e=window._),Xm=e,Xm}var Qm,rk;function KL(){if(rk)return Qm;rk=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,ik;function YL(){if(ik)return Zm;ik=1;var e=ot(),n=Qn().Graph,i=KL();Zm=o;var s=e.constant(1);function o(p,h){if(p.nodeCount()<=1)return[];var g=c(p,h||s),y=l(g.graph,g.buckets,g.zeroIdx);return e.flatten(e.map(y,function(w){return p.outEdges(w.v,w.w)}),!0)}function l(p,h,g){for(var y=[],w=h[h.length-1],C=h[0],_;p.nodeCount();){for(;_=C.dequeue();)u(p,h,g,_);for(;_=w.dequeue();)u(p,h,g,_);if(p.nodeCount()){for(var S=h.length-2;S>0;--S)if(_=h[S].dequeue(),_){y=y.concat(u(p,h,g,_,!0));break}}}return y}function u(p,h,g,y,w){var C=w?[]:void 0;return e.forEach(p.inEdges(y.v),function(_){var S=p.edge(_),b=p.node(_.v);w&&C.push({v:_.v,w:_.w}),b.out-=S,f(h,g,b)}),e.forEach(p.outEdges(y.v),function(_){var S=p.edge(_),b=_.w,E=p.node(b);E.in-=S,f(h,g,E)}),p.removeNode(y.v),C}function c(p,h){var g=new n,y=0,w=0;e.forEach(p.nodes(),function(S){g.setNode(S,{v:S,in:0,out:0})}),e.forEach(p.edges(),function(S){var b=g.edge(S.v,S.w)||0,E=h(S),N=b+E;g.setEdge(S.v,S.w,N),w=Math.max(w,g.node(S.v).out+=E),y=Math.max(y,g.node(S.w).in+=E)});var C=e.range(w+y+3).map(function(){return new i}),_=y+1;return e.forEach(g.nodes(),function(S){f(C,_,g.node(S))}),{graph:g,buckets:C,zeroIdx:_}}function f(p,h,g){g.out?g.in?p[g.out-g.in+h].enqueue(g):p[p.length-1].enqueue(g):p[0].enqueue(g)}return Zm}var Jm,sk;function XL(){if(sk)return Jm;sk=1;var e=ot(),n=YL();Jm={run:i,undo:o};function i(l){var u=l.graph().acyclicer==="greedy"?n(l,c(l)):s(l);e.forEach(u,function(f){var p=l.edge(f);l.removeEdge(f),p.forwardName=f.name,p.reversed=!0,l.setEdge(f.w,f.v,p,e.uniqueId("rev"))});function c(f){return function(p){return f.edge(p).weight}}}function s(l){var u=[],c={},f={};function p(h){e.has(f,h)||(f[h]=!0,c[h]=!0,e.forEach(l.outEdges(h),function(g){e.has(c,g.w)?u.push(g):p(g.w)}),delete c[h])}return e.forEach(l.nodes(),p),u}function o(l){e.forEach(l.edges(),function(u){var c=l.edge(u);if(c.reversed){l.removeEdge(u);var f=c.forwardName;delete c.reversed,delete c.forwardName,l.setEdge(u.w,u.v,c,f)}})}return Jm}var eg,ok;function fn(){if(ok)return eg;ok=1;var e=ot(),n=Qn().Graph;eg={addDummyNode:i,simplify:s,asNonCompoundGraph:o,successorWeights:l,predecessorWeights:u,intersectRect:c,buildLayerMatrix:f,normalizeRanks:p,removeEmptyRanks:h,addBorderNode:g,maxRank:y,partition:w,time:C,notime:_};function i(S,b,E,N){var j;do j=e.uniqueId(N);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 N=b.edge(E.v,E.w)||{weight:0,minlen:1},j=S.edge(E);b.setEdge(E.v,E.w,{weight:N.weight+j.weight,minlen:Math.max(N.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 N={};return e.forEach(S.outEdges(E),function(j){N[j.w]=(N[j.w]||0)+S.edge(j).weight}),N});return e.zipObject(S.nodes(),b)}function u(S){var b=e.map(S.nodes(),function(E){var N={};return e.forEach(S.inEdges(E),function(j){N[j.v]=(N[j.v]||0)+S.edge(j).weight}),N});return e.zipObject(S.nodes(),b)}function c(S,b){var E=S.x,N=S.y,j=b.x-E,P=b.y-N,O=S.width/2,q=S.height/2;if(!j&&!P)throw new Error("Not possible to find intersection inside of the rectangle");var F,T;return Math.abs(P)*O>Math.abs(j)*q?(P<0&&(q=-q),F=q*j/P,T=q):(j<0&&(O=-O),F=O,T=O*P/j),{x:E+F,y:N+T}}function f(S){var b=e.map(e.range(y(S)+1),function(){return[]});return e.forEach(S.nodes(),function(E){var N=S.node(E),j=N.rank;e.isUndefined(j)||(b[j][N.order]=E)}),b}function p(S){var b=e.min(e.map(S.nodes(),function(E){return S.node(E).rank}));e.forEach(S.nodes(),function(E){var N=S.node(E);e.has(N,"rank")&&(N.rank-=b)})}function h(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 N=0,j=S.graph().nodeRankFactor;e.forEach(E,function(P,O){e.isUndefined(P)&&O%j!==0?--N:N&&e.forEach(P,function(q){S.node(q).rank+=N})})}function g(S,b,E,N){var j={width:0,height:0};return arguments.length>=4&&(j.rank=E,j.order=N),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 w(S,b){var E={lhs:[],rhs:[]};return e.forEach(S,function(N){b(N)?E.lhs.push(N):E.rhs.push(N)}),E}function C(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,ak;function QL(){if(ak)return tg;ak=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,f=l.node(c).rank,p=u.w,h=l.node(p).rank,g=u.name,y=l.edge(u),w=y.labelRank;if(h!==f+1){l.removeEdge(u);var C,_,S;for(S=0,++f;f<h;++S,++f)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:u,rank:f},C=n.addDummyNode(l,"edge",_,"_d"),f===w&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),l.setEdge(c,C,{weight:y.weight},g),S===0&&l.graph().dummyChains.push(C),c=C;l.setEdge(c,p,{weight:y.weight},g)}}function o(l){e.forEach(l.graph().dummyChains,function(u){var c=l.node(u),f=c.edgeLabel,p;for(l.setEdge(c.edgeObj,f);c.dummy;)p=l.successors(u)[0],l.removeNode(u),f.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(f.x=c.x,f.y=c.y,f.width=c.width,f.height=c.height),u=p,c=l.node(u)})}return tg}var ng,lk;function Ul(){if(lk)return ng;lk=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 f=e.min(e.map(s.outEdges(u),function(p){return l(p.w)-s.edge(p).minlen}));return(f===Number.POSITIVE_INFINITY||f===void 0||f===null)&&(f=0),c.rank=f}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,uk;function _C(){if(uk)return rg;uk=1;var e=ot(),n=Qn().Graph,i=Ul().slack;rg=s;function s(c){var f=new n({directed:!1}),p=c.nodes()[0],h=c.nodeCount();f.setNode(p,{});for(var g,y;o(f,c)<h;)g=l(f,c),y=f.hasNode(g.v)?i(c,g):-i(c,g),u(f,c,y);return f}function o(c,f){function p(h){e.forEach(f.nodeEdges(h),function(g){var y=g.v,w=h===y?g.w:y;!c.hasNode(w)&&!i(f,g)&&(c.setNode(w,{}),c.setEdge(h,w,{}),p(w))})}return e.forEach(c.nodes(),p),c.nodeCount()}function l(c,f){return e.minBy(f.edges(),function(p){if(c.hasNode(p.v)!==c.hasNode(p.w))return i(f,p)})}function u(c,f,p){e.forEach(c.nodes(),function(h){f.node(h).rank+=p})}return rg}var ig,ck;function ZL(){if(ck)return ig;ck=1;var e=ot(),n=_C(),i=Ul().slack,s=Ul().longestPath,o=Qn().alg.preorder,l=Qn().alg.postorder,u=fn().simplify;ig=c,c.initLowLimValues=g,c.initCutValues=f,c.calcCutValue=h,c.leaveEdge=w,c.enterEdge=C,c.exchangeEdges=_;function c(N){N=u(N),s(N);var j=n(N);g(j),f(j,N);for(var P,O;P=w(j);)O=C(j,N,P),_(j,N,P,O)}function f(N,j){var P=l(N,N.nodes());P=P.slice(0,P.length-1),e.forEach(P,function(O){p(N,j,O)})}function p(N,j,P){var O=N.node(P),q=O.parent;N.edge(P,q).cutvalue=h(N,j,P)}function h(N,j,P){var O=N.node(P),q=O.parent,F=!0,T=j.edge(P,q),M=0;return T||(F=!1,T=j.edge(q,P)),M=T.weight,e.forEach(j.nodeEdges(P),function(B){var J=B.v===P,Z=J?B.w:B.v;if(Z!==q){var A=J===F,H=j.edge(B).weight;if(M+=A?H:-H,b(N,P,Z)){var U=N.edge(P,Z).cutvalue;M+=A?-U:U}}}),M}function g(N,j){arguments.length<2&&(j=N.nodes()[0]),y(N,{},1,j)}function y(N,j,P,O,q){var F=P,T=N.node(O);return j[O]=!0,e.forEach(N.neighbors(O),function(M){e.has(j,M)||(P=y(N,j,P,M,O))}),T.low=F,T.lim=P++,q?T.parent=q:delete T.parent,P}function w(N){return e.find(N.edges(),function(j){return N.edge(j).cutvalue<0})}function C(N,j,P){var O=P.v,q=P.w;j.hasEdge(O,q)||(O=P.w,q=P.v);var F=N.node(O),T=N.node(q),M=F,B=!1;F.lim>T.lim&&(M=T,B=!0);var J=e.filter(j.edges(),function(Z){return B===E(N,N.node(Z.v),M)&&B!==E(N,N.node(Z.w),M)});return e.minBy(J,function(Z){return i(j,Z)})}function _(N,j,P,O){var q=P.v,F=P.w;N.removeEdge(q,F),N.setEdge(O.v,O.w,{}),g(N),f(N,j),S(N,j)}function S(N,j){var P=e.find(N.nodes(),function(q){return!j.node(q).parent}),O=o(N,P);O=O.slice(1),e.forEach(O,function(q){var F=N.node(q).parent,T=j.edge(q,F),M=!1;T||(T=j.edge(F,q),M=!0),j.node(q).rank=j.node(F).rank+(M?T.minlen:-T.minlen)})}function b(N,j,P){return N.hasEdge(j,P)}function E(N,j,P){return P.low<=j.lim&&j.lim<=P.lim}return ig}var sg,dk;function JL(){if(dk)return sg;dk=1;var e=Ul(),n=e.longestPath,i=_C(),s=ZL();sg=o;function o(f){switch(f.graph().ranker){case"network-simplex":c(f);break;case"tight-tree":u(f);break;case"longest-path":l(f);break;default:c(f)}}var l=n;function u(f){n(f),i(f)}function c(f){s(f)}return sg}var og,fk;function e$(){if(fk)return og;fk=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),f=c.edgeObj,p=i(o,l,f.v,f.w),h=p.path,g=p.lca,y=0,w=h[y],C=!0;u!==f.w;){if(c=o.node(u),C){for(;(w=h[y])!==g&&o.node(w).maxRank<c.rank;)y++;w===g&&(C=!1)}if(!C){for(;y<h.length-1&&o.node(w=h[y+1]).minRank<=c.rank;)y++;w=h[y]}o.setParent(u,w),u=o.successors(u)[0]}})}function i(o,l,u,c){var f=[],p=[],h=Math.min(l[u].low,l[c].low),g=Math.max(l[u].lim,l[c].lim),y,w;y=u;do y=o.parent(y),f.push(y);while(y&&(l[y].low>h||g>l[y].lim));for(w=y,y=c;(y=o.parent(y))!==w;)p.push(y);return{path:f.concat(p.reverse()),lca:w}}function s(o){var l={},u=0;function c(f){var p=u;e.forEach(o.children(f),c),l[f]={low:p,lim:u++}}return e.forEach(o.children(),c),l}return og}var ag,hk;function t$(){if(hk)return ag;hk=1;var e=ot(),n=fn();ag={run:i,cleanup:u};function i(c){var f=n.addDummyNode(c,"root",{},"_root"),p=o(c),h=e.max(e.values(p))-1,g=2*h+1;c.graph().nestingRoot=f,e.forEach(c.edges(),function(w){c.edge(w).minlen*=g});var y=l(c)+1;e.forEach(c.children(),function(w){s(c,f,g,y,h,p,w)}),c.graph().nodeRankFactor=g}function s(c,f,p,h,g,y,w){var C=c.children(w);if(!C.length){w!==f&&c.setEdge(f,w,{weight:0,minlen:p});return}var _=n.addBorderNode(c,"_bt"),S=n.addBorderNode(c,"_bb"),b=c.node(w);c.setParent(_,w),b.borderTop=_,c.setParent(S,w),b.borderBottom=S,e.forEach(C,function(E){s(c,f,p,h,g,y,E);var N=c.node(E),j=N.borderTop?N.borderTop:E,P=N.borderBottom?N.borderBottom:E,O=N.borderTop?h:2*h,q=j!==P?1:g-y[w]+1;c.setEdge(_,j,{weight:O,minlen:q,nestingEdge:!0}),c.setEdge(P,S,{weight:O,minlen:q,nestingEdge:!0})}),c.parent(w)||c.setEdge(f,_,{weight:0,minlen:g+y[w]})}function o(c){var f={};function p(h,g){var y=c.children(h);y&&y.length&&e.forEach(y,function(w){p(w,g+1)}),f[h]=g}return e.forEach(c.children(),function(h){p(h,1)}),f}function l(c){return e.reduce(c.edges(),function(f,p){return f+c.edge(p).weight},0)}function u(c){var f=c.graph();c.removeNode(f.nestingRoot),delete f.nestingRoot,e.forEach(c.edges(),function(p){var h=c.edge(p);h.nestingEdge&&c.removeEdge(p)})}return ag}var lg,pk;function n$(){if(pk)return lg;pk=1;var e=ot(),n=fn();lg=i;function i(o){function l(u){var c=o.children(u),f=o.node(u);if(c.length&&e.forEach(c,l),e.has(f,"minRank")){f.borderLeft=[],f.borderRight=[];for(var p=f.minRank,h=f.maxRank+1;p<h;++p)s(o,"borderLeft","_bl",u,f,p),s(o,"borderRight","_br",u,f,p)}}e.forEach(o.children(),l)}function s(o,l,u,c,f,p){var h={width:0,height:0,rank:p,borderType:l},g=f[l][p-1],y=n.addDummyNode(o,"border",h,u);f[l][p]=y,o.setParent(y,c),g&&o.setEdge(g,y,{weight:1})}return lg}var ug,mk;function r$(){if(mk)return ug;mk=1;var e=ot();ug={adjust:n,undo:i};function n(p){var h=p.graph().rankdir.toLowerCase();(h==="lr"||h==="rl")&&s(p)}function i(p){var h=p.graph().rankdir.toLowerCase();(h==="bt"||h==="rl")&&l(p),(h==="lr"||h==="rl")&&(c(p),s(p))}function s(p){e.forEach(p.nodes(),function(h){o(p.node(h))}),e.forEach(p.edges(),function(h){o(p.edge(h))})}function o(p){var h=p.width;p.width=p.height,p.height=h}function l(p){e.forEach(p.nodes(),function(h){u(p.node(h))}),e.forEach(p.edges(),function(h){var g=p.edge(h);e.forEach(g.points,u),e.has(g,"y")&&u(g)})}function u(p){p.y=-p.y}function c(p){e.forEach(p.nodes(),function(h){f(p.node(h))}),e.forEach(p.edges(),function(h){var g=p.edge(h);e.forEach(g.points,f),e.has(g,"x")&&f(g)})}function f(p){var h=p.x;p.x=p.y,p.y=h}return ug}var cg,gk;function i$(){if(gk)return cg;gk=1;var e=ot();cg=n;function n(i){var s={},o=e.filter(i.nodes(),function(p){return!i.children(p).length}),l=e.max(e.map(o,function(p){return i.node(p).rank})),u=e.map(e.range(l+1),function(){return[]});function c(p){if(!e.has(s,p)){s[p]=!0;var h=i.node(p);u[h.rank].push(p),e.forEach(i.successors(p),c)}}var f=e.sortBy(o,function(p){return i.node(p).rank});return e.forEach(f,c),u}return cg}var dg,vk;function s$(){if(vk)return dg;vk=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,w){return w})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(s.outEdges(y),function(w){return{pos:u[w.w],weight:s.edge(w).weight}}),"pos")}),!0),f=1;f<l.length;)f<<=1;var p=2*f-1;f-=1;var h=e.map(new Array(p),function(){return 0}),g=0;return e.forEach(c.forEach(function(y){var w=y.pos+f;h[w]+=y.weight;for(var C=0;w>0;)w%2&&(C+=h[w+1]),w=w-1>>1,h[w]+=y.weight;g+=y.weight*C})),g}return dg}var fg,yk;function o$(){if(yk)return fg;yk=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,f){var p=i.edge(f),h=i.node(f.v);return{sum:c.sum+p.weight*h.order,weight:c.weight+p.weight}},{sum:0,weight:0});return{v:o,barycenter:u.sum/u.weight,weight:u.weight}}else return{v:o}})}return fg}var hg,wk;function a$(){if(wk)return hg;wk=1;var e=ot();hg=n;function n(o,l){var u={};e.forEach(o,function(f,p){var h=u[f.v]={indegree:0,in:[],out:[],vs:[f.v],i:p};e.isUndefined(f.barycenter)||(h.barycenter=f.barycenter,h.weight=f.weight)}),e.forEach(l.edges(),function(f){var p=u[f.v],h=u[f.w];!e.isUndefined(p)&&!e.isUndefined(h)&&(h.indegree++,p.out.push(u[f.w]))});var c=e.filter(u,function(f){return!f.indegree});return i(c)}function i(o){var l=[];function u(p){return function(h){h.merged||(e.isUndefined(h.barycenter)||e.isUndefined(p.barycenter)||h.barycenter>=p.barycenter)&&s(p,h)}}function c(p){return function(h){h.in.push(p),--h.indegree===0&&o.push(h)}}for(;o.length;){var f=o.pop();l.push(f),e.forEach(f.in.reverse(),u(f)),e.forEach(f.out,c(f))}return e.map(e.filter(l,function(p){return!p.merged}),function(p){return e.pick(p,["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,xk;function l$(){if(xk)return pg;xk=1;var e=ot(),n=fn();pg=i;function i(l,u){var c=n.partition(l,function(_){return e.has(_,"barycenter")}),f=c.lhs,p=e.sortBy(c.rhs,function(_){return-_.i}),h=[],g=0,y=0,w=0;f.sort(o(!!u)),w=s(h,p,w),e.forEach(f,function(_){w+=_.vs.length,h.push(_.vs),g+=_.barycenter*_.weight,y+=_.weight,w=s(h,p,w)});var C={vs:e.flatten(h,!0)};return y&&(C.barycenter=g/y,C.weight=y),C}function s(l,u,c){for(var f;u.length&&(f=e.last(u)).i<=c;)u.pop(),l.push(f.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,_k;function u$(){if(_k)return mg;_k=1;var e=ot(),n=o$(),i=a$(),s=l$();mg=o;function o(c,f,p,h){var g=c.children(f),y=c.node(f),w=y?y.borderLeft:void 0,C=y?y.borderRight:void 0,_={};w&&(g=e.filter(g,function(P){return P!==w&&P!==C}));var S=n(c,g);e.forEach(S,function(P){if(c.children(P.v).length){var O=o(c,P.v,p,h);_[P.v]=O,e.has(O,"barycenter")&&u(P,O)}});var b=i(S,p);l(b,_);var E=s(b,h);if(w&&(E.vs=e.flatten([w,E.vs,C],!0),c.predecessors(w).length)){var N=c.node(c.predecessors(w)[0]),j=c.node(c.predecessors(C)[0]);e.has(E,"barycenter")||(E.barycenter=0,E.weight=0),E.barycenter=(E.barycenter*E.weight+N.order+j.order)/(E.weight+2),E.weight+=2}return E}function l(c,f){e.forEach(c,function(p){p.vs=e.flatten(p.vs.map(function(h){return f[h]?f[h].vs:h}),!0)})}function u(c,f){e.isUndefined(c.barycenter)?(c.barycenter=f.barycenter,c.weight=f.weight):(c.barycenter=(c.barycenter*c.weight+f.barycenter*f.weight)/(c.weight+f.weight),c.weight+=f.weight)}return mg}var gg,Sk;function c$(){if(Sk)return gg;Sk=1;var e=ot(),n=Qn().Graph;gg=i;function i(o,l,u){var c=s(o),f=new n({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(p){return o.node(p)});return e.forEach(o.nodes(),function(p){var h=o.node(p),g=o.parent(p);(h.rank===l||h.minRank<=l&&l<=h.maxRank)&&(f.setNode(p),f.setParent(p,g||c),e.forEach(o[u](p),function(y){var w=y.v===p?y.w:y.v,C=f.edge(w,p),_=e.isUndefined(C)?0:C.weight;f.setEdge(w,p,{weight:o.edge(y).weight+_})}),e.has(h,"minRank")&&f.setNode(p,{borderLeft:h.borderLeft[l],borderRight:h.borderRight[l]}))}),f}function s(o){for(var l;o.hasNode(l=e.uniqueId("_root")););return l}return gg}var vg,bk;function d$(){if(bk)return vg;bk=1;var e=ot();vg=n;function n(i,s,o){var l={},u;e.forEach(o,function(c){for(var f=i.parent(c),p,h;f;){if(p=i.parent(f),p?(h=l[p],l[p]=f):(h=u,u=f),h&&h!==f){s.setEdge(h,f);return}f=p}})}return vg}var yg,kk;function f$(){if(kk)return yg;kk=1;var e=ot(),n=i$(),i=s$(),s=u$(),o=c$(),l=d$(),u=Qn().Graph,c=fn();yg=f;function f(y){var w=c.maxRank(y),C=p(y,e.range(1,w+1),"inEdges"),_=p(y,e.range(w-1,-1,-1),"outEdges"),S=n(y);g(y,S);for(var b=Number.POSITIVE_INFINITY,E,N=0,j=0;j<4;++N,++j){h(N%2?C:_,N%4>=2),S=c.buildLayerMatrix(y);var P=i(y,S);P<b&&(j=0,E=e.cloneDeep(S),b=P)}g(y,E)}function p(y,w,C){return e.map(w,function(_){return o(y,_,C)})}function h(y,w){var C=new u;e.forEach(y,function(_){var S=_.graph().root,b=s(_,S,C,w);e.forEach(b.vs,function(E,N){_.node(E).order=N}),l(_,C,b.vs)})}function g(y,w){e.forEach(w,function(C){e.forEach(C,function(_,S){y.node(_).order=S})})}return yg}var wg,Ek;function h$(){if(Ek)return wg;Ek=1;var e=ot(),n=Qn().Graph,i=fn();wg={positionX:C,findType1Conflicts:s,findType2Conflicts:o,addConflict:u,hasConflict:c,verticalAlignment:f,horizontalCompaction:p,alignCoordinates:y,findSmallestWidthAlignment:g,balance:w};function s(b,E){var N={};function j(P,O){var q=0,F=0,T=P.length,M=e.last(O);return e.forEach(O,function(B,J){var Z=l(b,B),A=Z?b.node(Z).order:T;(Z||B===M)&&(e.forEach(O.slice(F,J+1),function(H){e.forEach(b.predecessors(H),function(U){var ne=b.node(U),Q=ne.order;(Q<q||A<Q)&&!(ne.dummy&&b.node(H).dummy)&&u(N,U,H)})}),F=J+1,q=A)}),O}return e.reduce(E,j),N}function o(b,E){var N={};function j(O,q,F,T,M){var B;e.forEach(e.range(q,F),function(J){B=O[J],b.node(B).dummy&&e.forEach(b.predecessors(B),function(Z){var A=b.node(Z);A.dummy&&(A.order<T||A.order>M)&&u(N,Z,B)})})}function P(O,q){var F=-1,T,M=0;return e.forEach(q,function(B,J){if(b.node(B).dummy==="border"){var Z=b.predecessors(B);Z.length&&(T=b.node(Z[0]).order,j(q,M,J,F,T),M=J,F=T)}j(q,M,q.length,T,O.length)}),q}return e.reduce(E,P),N}function l(b,E){if(b.node(E).dummy)return e.find(b.predecessors(E),function(N){return b.node(N).dummy})}function u(b,E,N){if(E>N){var j=E;E=N,N=j}var P=b[E];P||(b[E]=P={}),P[N]=!0}function c(b,E,N){if(E>N){var j=E;E=N,N=j}return e.has(b[E],N)}function f(b,E,N,j){var P={},O={},q={};return e.forEach(E,function(F){e.forEach(F,function(T,M){P[T]=T,O[T]=T,q[T]=M})}),e.forEach(E,function(F){var T=-1;e.forEach(F,function(M){var B=j(M);if(B.length){B=e.sortBy(B,function(U){return q[U]});for(var J=(B.length-1)/2,Z=Math.floor(J),A=Math.ceil(J);Z<=A;++Z){var H=B[Z];O[M]===M&&T<q[H]&&!c(N,M,H)&&(O[H]=M,O[M]=P[M]=P[H],T=q[H])}}})}),{root:P,align:O}}function p(b,E,N,j,P){var O={},q=h(b,E,N,P),F=P?"borderLeft":"borderRight";function T(J,Z){for(var A=q.nodes(),H=A.pop(),U={};H;)U[H]?J(H):(U[H]=!0,A.push(H),A=A.concat(Z(H))),H=A.pop()}function M(J){O[J]=q.inEdges(J).reduce(function(Z,A){return Math.max(Z,O[A.v]+q.edge(A))},0)}function B(J){var Z=q.outEdges(J).reduce(function(H,U){return Math.min(H,O[U.w]-q.edge(U))},Number.POSITIVE_INFINITY),A=b.node(J);Z!==Number.POSITIVE_INFINITY&&A.borderType!==F&&(O[J]=Math.max(O[J],Z))}return T(M,q.predecessors.bind(q)),T(B,q.successors.bind(q)),e.forEach(j,function(J){O[J]=O[N[J]]}),O}function h(b,E,N,j){var P=new n,O=b.graph(),q=_(O.nodesep,O.edgesep,j);return e.forEach(E,function(F){var T;e.forEach(F,function(M){var B=N[M];if(P.setNode(B),T){var J=N[T],Z=P.edge(J,B);P.setEdge(J,B,Math.max(q(b,M,T),Z||0))}T=M})}),P}function g(b,E){return e.minBy(e.values(E),function(N){var j=Number.NEGATIVE_INFINITY,P=Number.POSITIVE_INFINITY;return e.forIn(N,function(O,q){var F=S(b,q)/2;j=Math.max(O+F,j),P=Math.min(O-F,P)}),j-P})}function y(b,E){var N=e.values(E),j=e.min(N),P=e.max(N);e.forEach(["u","d"],function(O){e.forEach(["l","r"],function(q){var F=O+q,T=b[F],M;if(T!==E){var B=e.values(T);M=q==="l"?j-e.min(B):P-e.max(B),M&&(b[F]=e.mapValues(T,function(J){return J+M}))}})})}function w(b,E){return e.mapValues(b.ul,function(N,j){if(E)return b[E.toLowerCase()][j];var P=e.sortBy(e.map(b,j));return(P[1]+P[2])/2})}function C(b){var E=i.buildLayerMatrix(b),N=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(F){F==="r"&&(P=e.map(P,function(J){return e.values(J).reverse()}));var T=(q==="u"?b.predecessors:b.successors).bind(b),M=f(b,P,N,T),B=p(b,P,M.root,M.align,F==="r");F==="r"&&(B=e.mapValues(B,function(J){return-J})),j[q+F]=B})});var O=g(b,j);return y(j,O),w(j,b.graph().align)}function _(b,E,N){return function(j,P,O){var q=j.node(P),F=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+=N?M:-M),M=0,T+=(q.dummy?E:b)/2,T+=(F.dummy?E:b)/2,T+=F.width/2,e.has(F,"labelpos"))switch(F.labelpos.toLowerCase()){case"l":M=F.width/2;break;case"r":M=-F.width/2;break}return M&&(T+=N?M:-M),M=0,T}}function S(b,E){return b.node(E).width}return wg}var xg,Nk;function p$(){if(Nk)return xg;Nk=1;var e=ot(),n=fn(),i=h$().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,f=0;e.forEach(u,function(p){var h=e.max(e.map(p,function(g){return l.node(g).height}));e.forEach(p,function(g){l.node(g).y=f+h/2}),f+=h+c})}return xg}var _g,Ck;function m$(){if(Ck)return _g;Ck=1;var e=ot(),n=XL(),i=QL(),s=JL(),o=fn().normalizeRanks,l=e$(),u=fn().removeEmptyRanks,c=t$(),f=n$(),p=r$(),h=f$(),g=p$(),y=fn(),w=Qn().Graph;_g=C;function C($,Y){var ee=Y&&Y.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 _($,Y){Y(" makeSpaceForEdgeLabels",function(){M($)}),Y(" removeSelfEdges",function(){D($)}),Y(" acyclic",function(){n.run($)}),Y(" nestingGraph.run",function(){c.run($)}),Y(" rank",function(){s(y.asNonCompoundGraph($))}),Y(" injectEdgeLabelProxies",function(){B($)}),Y(" removeEmptyRanks",function(){u($)}),Y(" nestingGraph.cleanup",function(){c.cleanup($)}),Y(" normalizeRanks",function(){o($)}),Y(" assignRankMinMax",function(){J($)}),Y(" removeEdgeLabelProxies",function(){Z($)}),Y(" normalize.run",function(){i.run($)}),Y(" parentDummyChains",function(){l($)}),Y(" addBorderSegments",function(){f($)}),Y(" order",function(){h($)}),Y(" insertSelfEdges",function(){G($)}),Y(" adjustCoordinateSystem",function(){p.adjust($)}),Y(" position",function(){g($)}),Y(" positionSelfEdges",function(){k($)}),Y(" removeBorderNodes",function(){Q($)}),Y(" normalize.undo",function(){i.undo($)}),Y(" fixupEdgeLabelCoords",function(){U($)}),Y(" undoCoordinateSystem",function(){p.undo($)}),Y(" translateGraph",function(){A($)}),Y(" assignNodeIntersects",function(){H($)}),Y(" reversePoints",function(){ne($)}),Y(" acyclic.undo",function(){n.undo($)})}function S($,Y){e.forEach($.nodes(),function(ee){var se=$.node(ee),ae=Y.node(ee);se&&(se.x=ae.x,se.y=ae.y,Y.children(ee).length&&(se.width=ae.width,se.height=ae.height))}),e.forEach($.edges(),function(ee){var se=$.edge(ee),ae=Y.edge(ee);se.points=ae.points,e.has(ae,"x")&&(se.x=ae.x,se.y=ae.y)}),$.graph().width=Y.graph().width,$.graph().height=Y.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],E={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},N=["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"},F=["labelpos"];function T($){var Y=new w({multigraph:!0,compound:!0}),ee=oe($.graph());return Y.setGraph(e.merge({},E,L(ee,b),e.pick(ee,N))),e.forEach($.nodes(),function(se){var ae=oe($.node(se));Y.setNode(se,e.defaults(L(ae,j),P)),Y.setParent(se,$.parent(se))}),e.forEach($.edges(),function(se){var ae=oe($.edge(se));Y.setEdge(se,e.merge({},q,L(ae,O),e.pick(ae,F)))}),Y}function M($){var Y=$.graph();Y.ranksep/=2,e.forEach($.edges(),function(ee){var se=$.edge(ee);se.minlen*=2,se.labelpos.toLowerCase()!=="c"&&(Y.rankdir==="TB"||Y.rankdir==="BT"?se.width+=se.labeloffset:se.height+=se.labeloffset)})}function B($){e.forEach($.edges(),function(Y){var ee=$.edge(Y);if(ee.width&&ee.height){var se=$.node(Y.v),ae=$.node(Y.w),pe={rank:(ae.rank-se.rank)/2+se.rank,e:Y};y.addDummyNode($,"edge-proxy",pe,"_ep")}})}function J($){var Y=0;e.forEach($.nodes(),function(ee){var se=$.node(ee);se.borderTop&&(se.minRank=$.node(se.borderTop).rank,se.maxRank=$.node(se.borderBottom).rank,Y=e.max(Y,se.maxRank))}),$.graph().maxRank=Y}function Z($){e.forEach($.nodes(),function(Y){var ee=$.node(Y);ee.dummy==="edge-proxy"&&($.edge(ee.e).labelRank=ee.rank,$.removeNode(Y))})}function A($){var Y=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;Y=Math.min(Y,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)}),Y-=ge,se-=Ae,e.forEach($.nodes(),function(Me){var Pe=$.node(Me);Pe.x-=Y,Pe.y-=se}),e.forEach($.edges(),function(Me){var Pe=$.edge(Me);e.forEach(Pe.points,function(ke){ke.x-=Y,ke.y-=se}),e.has(Pe,"x")&&(Pe.x-=Y),e.has(Pe,"y")&&(Pe.y-=se)}),pe.width=ee-Y+ge,pe.height=ae-se+Ae}function H($){e.forEach($.edges(),function(Y){var ee=$.edge(Y),se=$.node(Y.v),ae=$.node(Y.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(Y){var ee=$.edge(Y);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(Y){var ee=$.edge(Y);ee.reversed&&ee.points.reverse()})}function Q($){e.forEach($.nodes(),function(Y){if($.children(Y).length){var ee=$.node(Y),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(Y){$.node(Y).dummy==="border"&&$.removeNode(Y)})}function D($){e.forEach($.edges(),function(Y){if(Y.v===Y.w){var ee=$.node(Y.v);ee.selfEdges||(ee.selfEdges=[]),ee.selfEdges.push({e:Y,label:$.edge(Y)}),$.removeEdge(Y)}})}function G($){var Y=y.buildLayerMatrix($);e.forEach(Y,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(Y){var ee=$.node(Y);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(Y),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($,Y){return e.mapValues(e.pick($,Y),Number)}function oe($){var Y={};return e.forEach($,function(ee,se){Y[se.toLowerCase()]=ee}),Y}return _g}var Sg,jk;function g$(){if(jk)return Sg;jk=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,f){var p="layer"+f;u.setNode(p,{rank:"same"}),e.reduce(c,function(h,g){return u.setEdge(h,g,{style:"invis"}),g})}),u}return Sg}var bg,Tk;function v$(){return Tk||(Tk=1,bg="0.8.5"),bg}var kg,Rk;function y$(){return Rk||(Rk=1,kg={graphlib:Qn(),layout:m$(),debug:g$(),util:{time:fn().time,notime:fn().notime},version:v$()}),kg}var w$=y$();const Ak=Yg(w$),vi=240,Xi=130,zs=74,pu=72,Ik=zs+pu;function x$(e){let n=vi;for(const i of e.values())n=Math.max(n,i.width);return n}const SC=420,_$=2;function mu(e){var i;return((i=e.data)==null?void 0:i.sessionId)??"_default"}function Mk(e,n){return((n==null?void 0:n.get(e))??0)>0?SC:0}function Pk(e,n){const i=(n==null?void 0:n.get(e))??0;return i>0?6+i*36:0}function S$(e,n,i,s,o,l){const u=new Ak.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)),f=new Set(c);for(const S of c){const b=s.get(S);u.setNode(S,{width:((b==null?void 0:b.width)??vi)+Mk(S,l),height:Math.max((b==null?void 0:b.height)??Xi,Pk(S,l))})}for(const S of n)f.has(S.source)&&f.has(S.target)&&u.setEdge(S.source,S.target);Ak.layout(u);const p=new Map;let h=1/0,g=1/0,y=-1/0,w=-1/0;for(const S of c){const b=u.node(S);if(!b)continue;const E=s.get(S),N=(E==null?void 0:E.width)??vi,j=(E==null?void 0:E.height)??Xi,P=N+Mk(S,l),O=Math.max(j,Pk(S,l)),q=b.x-P/2,F=b.y-O/2;p.set(S,{x:q,y:F}),q<h&&(h=q),F<g&&(g=F),q+N>y&&(y=q+N),F+j>w&&(w=F+j)}if(Number.isFinite(h)&&Number.isFinite(g))for(const[S,b]of p)p.set(S,{x:b.x-h,y:b.y-g});let C=Number.isFinite(y)?y-h:0,_=Number.isFinite(w)?w-g:0;for(const S of e){const b=o.get(S);if(!b)continue;const E=s.get(S);C=Math.max(C,b.x+((E==null?void 0:E.width)??vi)),_=Math.max(_,b.y+((E==null?void 0:E.height)??Xi))}return{positions:p,width:C,height:_}}function b$(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=mu(b),N=c.get(E);N?N.push(b.id):c.set(E,[b.id])}const p=Array.from(c.keys()).sort().map(b=>({sid:b,...S$(c.get(b),n,s,l,o,u)})),h=x$(l),g=i.availableHeight&&i.availableHeight>0?i.availableHeight:Number.POSITIVE_INFINITY,y=b=>{const E=[[]];let N=0;for(const j of p)E.length<b&&N>0&&N+j.height>g&&(E.push([]),N=0),E[E.length-1].push(j),N+=j.height+Ik;return E},w=b=>b.reduce((E,N)=>Math.max(E,N.width),0)+SC;let C=y(i.availableWidth?_$:1);C.length>1&&C.reduce((E,N)=>E+w(N),0)+h*(C.length-1)>(i.availableWidth??0)&&(C=y(1));const _=new Map;let S=0;for(const b of C){let E=0;for(const{positions:N,height:j}of b){for(const[P,O]of N)_.set(P,{x:O.x+S,y:O.y+E});E+=j+Ik}S+=w(b)+h}return e.map(b=>{const E=o.get(b.id);if(E)return{...b,position:E};const N=_.get(b.id);return N?{...b,position:N}:b})}function k$(e,n,i,s){const l=zs+pu,u=60,c=y=>{const w=s.get(y);return{w:(w==null?void 0:w.width)??vi,h:(w==null?void 0:w.height)??Xi}},f=new Map(e.map(y=>[y.id,mu(y)])),p=[],h=e.map(y=>({id:y.id,pos:i.get(y.id)??n.get(y.id)})).filter(y=>y.pos!=null).sort((y,w)=>y.pos.y-w.pos.y||y.pos.x-w.pos.x||y.id.localeCompare(w.id)),g=[];for(const{id:y,pos:w}of h){const{w:C,h:_}=c(y),S=f.get(y)??"_default";if(i.has(y)){p.push({x:w.x,y:w.y,w:C,h:_,sid:S});continue}let b=w.y;for(let E=0;E<p.length+1;E++){const N=p.find(j=>{const P=j.sid===S?24:u,O=j.sid===S?24:l;return w.x<j.x+j.w+P&&j.x<w.x+C+P&&b<j.y+j.h+O&&j.y<b+_+O});if(!N)break;b=N.y+N.h+(N.sid===S?24:l)}b!==w.y&&(n.set(y,{x:w.x,y:b}),g.push(y)),p.push({x:w.x,y:b,w:C,h:_,sid:S})}return g}function E$(e,n,i,s,o){const l=y=>{const w=s.get(y);return{w:(w==null?void 0:w.width)??vi,h:(w==null?void 0:w.height)??Xi}},u=y=>i.get(y)??n.get(y),c=new Map,f=[];for(const y of e){const w=u(y.id);if(!w)continue;const{w:C,h:_}=l(y.id);if(o.has(y.id)&&!i.has(y.id)){const S=mu(y);(c.get(S)??c.set(S,[]).get(S)).push(y)}else f.push({x:w.x,y:w.y,w:C,h:_})}if(c.size===0)return[];const p=zs+pu,h=(y,w,C,_)=>f.some(S=>y<S.x+S.w+zs&&S.x<y+C+zs&&w<S.y+S.h+p&&S.y<w+_+p),g=[];for(const y of[...c.keys()].sort()){const w=c.get(y);let C=1/0,_=1/0,S=-1/0,b=-1/0;for(const F of w){const T=u(F.id),{w:M,h:B}=l(F.id);C=Math.min(C,T.x),_=Math.min(_,T.y),S=Math.max(S,T.x+M),b=Math.max(b,T.y+B)}const E=S-C,N=b-_,j=[...new Set(f.map(F=>Math.round(F.x)))].sort((F,T)=>F-T),P=j.length?j:[C],O=[0,...f.map(F=>F.y+F.h+p)].sort((F,T)=>F-T);let q=null;e:for(const F of P)for(const T of O){if(T>=_)break;if(!h(F,T,E,N)){q={x:F,y:T};break e}}if(q){const F=q.x-C,T=q.y-_;for(const M of w){const B=u(M.id);n.set(M.id,{x:B.x+F,y:B.y+T})}g.push(y)}for(const F of w){const T=u(F.id),{w:M,h:B}=l(F.id);f.push({x:T.x,y:T.y,w:M,h:B})}}return g}function N$(e,n,i,s,o,l=!1){const f=zs+pu+1,p=8,h=1.75,g=200,y=.7,w=.01,C=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=mu(T),B=S.get(M);B?B.push(T):S.set(M,[T])}const b=[],E=new Set,N=new Set,j=o.size===0;for(const T of[...S.keys()].sort()){const M=S.get(T);let B=1/0,J=1/0,Z=-1/0,A=-1/0,H=!1;for(const D of M){const G=_(D.id),{w:k,h:L}=C(D.id);B=Math.min(B,G.x),J=Math.min(J,G.y),Z=Math.max(Z,G.x+k),A=Math.max(A,G.y+L),i.has(D.id)&&(H=!0)}const U=Z-B,ne=A-J;N.add(T);const Q=o.get(T);Q&&(U>Q.w+p||ne>Q.h+p)&&E.add(T),o.set(T,{w:U,h:ne}),b.push({sid:T,members:M.map(D=>D.id),x:B,y:J,w:U,h:ne,anchored:H,mass:1})}for(const T of[...o.keys()])N.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 B=b[T],J=b[M];if(!(B.anchored&&J.anchored)&&Math.abs(B.x+B.w/2-(J.x+J.w/2))<(B.w+J.w)/2+61&&Math.abs(B.y+B.h/2-(J.y+J.h/2))<(B.h+J.h)/2+f){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<g;T++){const M=new Map,B=new Map;let J=0;for(let Z=0;Z<b.length;Z++)for(let A=Z+1;A<b.length;A++){const H=b[Z],U=b[A];if(H.anchored&&U.anchored)continue;const ne=H.x+H.w/2,Q=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+f-Math.abs(Q-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),Y=(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=Y(ne,D,oe),se=Y(Q,G,$),ae=ee!==0,pe=se!==0;if(!ae&&!pe)continue;const ge=ae&&(!pe||k*h<L),[Ae,Oe,Me,Pe]=ge?[ee,k,M,oe]:[se,L,B,$],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),J+=it}for(const Z of b)Z.anchored||(Z.x=Math.max(0,Z.x+(M.get(Z.sid)??0)),Z.y=Math.max(0,Z.y+(B.get(Z.sid)??0)));if(J<w)break}const F=[];for(const T of b){const M=T.x-O.get(T.sid),B=T.y-q.get(T.sid);if(!(Math.abs(M)<1&&Math.abs(B)<1)){for(const J of T.members){if(i.has(J))continue;const Z=n.get(J);Z&&n.set(J,{x:Z.x+M,y:Z.y+B})}F.push(T.sid)}}return F}const C$=600;function Wg(e,n){return!(e.exitAt!=null&&n-e.exitAt>C$||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function j$(e,n){const i=new Set;for(const s of e.agents.values())Wg(s,n)&&i.add(s.id);return i}function T$(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(T$(e,s,i))return!0;return!1}function Hi(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function A$(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}const I$={agent:PP,sessionGroup:VP},M$=420,Cl=18,P$=9e4,O$=200,q$=5*6e4,L$=6,$$=2*6e4,Pv="agent-dag.layout",Ov="agent-dag.viewport",bC="agent-dag.summariesDismissed",kC="agent-dag.sessionListOpen",EC="agent-dag.detailOpen",NC="agent-dag.usagePanelOpen",Ok="agent-dag.accountsPanelOpen",qk="agent-dag.versionNoticeDismissed",Lk={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 D$(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 $k="agent-dag.autoRestart",Dk="agent-dag.bundleReloadedFor";function F$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(kC)==="1"}catch{return!1}}function z$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(kC,e?"1":"0")}catch{}}function B$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(EC)==="1"}catch{return!1}}function U$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(EC,e?"1":"0")}catch{}}function H$(){if(typeof window>"u")return!0;const e=window.localStorage.getItem(NC);try{return e===null?!0:e==="1"}catch{return!0}}function V$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(NC,e?"1":"0")}catch{}}function W$(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(bC);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 Fk(e){if(!(typeof window>"u"))try{const n=Array.from(e),i=n.length>200?n.slice(-200):n;window.localStorage.setItem(bC,JSON.stringify(i))}catch{}}function G$(){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 K$(){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 Y$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Ov,JSON.stringify(e))}catch{}}function zk(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Pv)}catch{}try{window.localStorage.removeItem(Ov)}catch{}}}function X$(e,n){const i=e.agents.get(n);if(!i)return;const s=[];for(const h of e.agents.values())h.sessionId===n&&s.push(h);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(h=>({id:h.id,kind:h.kind,label:h.label,parentId:h.parentId,state:h.state,startedAt:h.startedAt,endedAt:h.endedAt,model:h.model,cwd:h.cwd,usage:h.usage,prompts:h.prompts,tools:h.tools.map(g=>({id:g.id,name:g.name,inputPreview:g.inputPreview,startedAt:g.startedAt,endedAt:g.endedAt,ok:g.ok,errorPreview:g.errorPreview,usage:g.usage}))}))},l=JSON.stringify(o,null,2),u=new Blob([l],{type:"application/json"}),c=URL.createObjectURL(u),f=document.createElement("a"),p=(i.label||"session").replace(/[^a-z0-9._-]/gi,"_");f.href=c,f.download=`agents-deck-${p}-${n.slice(0,8)}.json`,document.body.appendChild(f),f.click(),document.body.removeChild(f),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"},Q$={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 CC(e){return e.startsWith("mcp__")?"mcp":Q$[e]??"other"}function jC(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 Z$(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 J$(e,n,i,s,o,l,u,c,f,p,h,g,y,w,C,_,S,b){const E=[],N=[],j=new Set;if(l)for(const M of e.agents.values())jC(M,l)&&j.add(M.id);for(const M of e.agents.values()){if(!S.has(M.id))continue;const B=l?!j.has(M.id):!1,J=M.exitAt!=null,Z=_!=null&&!_.has(M.id),A=[B?"rf-dim":"",J?"rf-exiting":"",Z?"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:B,onOpenContext:b},className:A,...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%)`,Q=l&&!j.has(M.id)&&!j.has(M.parentId),D=J,G=C.size>0&&(C.has(M.id)||C.has(M.parentId)),k=_!=null&&!_.has(M.id)&&!_.has(M.parentId),L=M.state==="active"?2:1.5,oe=G?L+1.5:L,$=Q||D?.2:k?.12:1,Y=[D?"rf-edge-exiting":"",G?"rf-edge-selected":""].filter(Boolean).join(" ")||void 0;N.push({id:`e:${M.parentId}->${M.id}`,source:M.parentId,target:M.id,animated:(M.state==="active"||G)&&!Q&&!D,type:"smoothstep",style:{stroke:ne,strokeWidth:oe,opacity:$,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:Y})}}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)&&!g.has(M.id));if(O.length>0||y!==w.current){if(O.length>0){const M=b$(E,N,{direction:"LR",pinned:o,measured:u,availableWidth:i,availableHeight:s,lanes:P});for(const B of M)g.has(B.id)||g.set(B.id,B.position);E$(E,g,o,u,new Set(O.map(B=>B.id)))}k$(E,g,o,u),w.current=y}const q=N$(E,g,o,u,c,!p||h);q.length>0&&f(q);for(const M of Array.from(g.keys()))e.agents.has(M)||g.delete(M);if(e.agents.size>0)for(const M of Array.from(o.keys()))e.agents.has(M)||o.delete(M);const F=[];let T=!1;for(const M of E){let B=o.get(M.id)??g.get(M.id);B||(B={x:0,y:0},g.set(M.id,B),T=!0),F.push({...M,position:B})}return T&&(w.current=""),{nodes:F,edges:N}}function e4(){return m.jsx(fv,{children:m.jsx(t4,{})})}function t4(){var ao,va,Wr,Gr;const e=sa(),n=I.useRef(Bg()),[,i]=I.useState(0),s=I.useCallback(()=>i(V=>V+1),[]),[o,l]=I.useState(()=>new Set),[u,c]=I.useState(null),[f,p]=I.useState(null),h=I.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)},[]),g=I.useCallback(()=>{l(new Set),c(null)},[]),[y,w]=I.useState(null),[C,_]=I.useState(null),S=I.useCallback(V=>_(V),[]),b=I.useRef(W$()),[E,N]=I.useState(F$);I.useEffect(()=>{z$(E)},[E]);const[j,P]=I.useState(B$);I.useEffect(()=>{U$(j)},[j]);const[O,q]=I.useState(H$);I.useEffect(()=>{V$(O)},[O]);const[F,T]=I.useState(()=>{try{const V=window.localStorage.getItem(Ok);return V===null?!0:V==="1"}catch{return!0}});I.useEffect(()=>{try{window.localStorage.setItem(Ok,F?"1":"0")}catch{}},[F]);const[M,B]=I.useState(null),[J,Z]=I.useState(!1),[A,H]=I.useState(0),[U,ne]=I.useState(0);I.useEffect(()=>{fetch("/api/sound-hook").then(V=>V.ok?V.json():null).then(V=>{V!=null&&V.ok&&(B(V.enabled===!0),H((V.foreign??[]).filter(K=>K.worksHere).length),ne(typeof V.parked=="number"?V.parked:0))}).catch(()=>{})},[]);const Q=I.useCallback(async()=>{Z(!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&&B(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{Z(!1)}},[M]),[D,G]=I.useState(!1),[k,L]=I.useState(null),[oe,$]=I.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(qk)??""}catch{return""}}),[Y,ee]=I.useState(!1),se=I.useCallback((V=!1)=>{fetch(V?"/api/version?refresh=1":"/api/version").then(K=>K.ok?K.json():null).then(K=>{K&&L(K)}).catch(()=>{})},[]);I.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]),I.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=I.useCallback(()=>{if(!ae)return;const V=oe===pe?"":pe;$(V);try{window.localStorage.setItem(qk,V)}catch{}},[ae,pe,oe]),Oe=((ao=k==null?void 0:k.upgrade)==null?void 0:ao.state)??"idle",Me=I.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}se()},[se]);I.useEffect(()=>{if(Oe!=="running")return;const V=window.setInterval(se,3e3);return()=>window.clearInterval(V)},[Oe,se]);const Pe=I.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=I.useCallback(()=>{N(V=>(V||T(!1),!V))},[]),We=I.useCallback(()=>{T(V=>(V||N(!1),!V))},[]),[ve,ye]=I.useState(!1),[Ge,ut]=I.useState(0),it=I.useRef(null),[Ke,$e]=I.useState(!1),Qe=I.useRef(null),[bt,ct]=I.useState(0),[pt,mt]=I.useState(!1),kt=I.useRef([]),[He,Je]=I.useState(Date.now()),[dt,gt]=I.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem($k)!=="0"}catch{return!0}}),yt=I.useCallback(()=>{gt(V=>{const K=!V;try{window.localStorage.setItem($k,K?"1":"0")}catch{}return K})},[]),[Gt,Pt]=I.useState(!1),[zt,Ln]=I.useState("restart"),[er,bn]=I.useState(null),Bt=I.useRef(!1),Jt=I.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=I.useRef(null);I.useEffect(()=>{let V=!1;for(const ue of n.current.agents.values())if(ue.state==="active"){V=!0;break}const K=Z3({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]),I.useEffect(()=>{let V=null;try{V=window.sessionStorage.getItem(Dk)}catch{return}if(Q3({bundle:"1.33.14",running:k==null?void 0:k.running,lastTried:V})){try{window.sessionStorage.setItem(Dk,(k==null?void 0:k.running)??"")}catch{return}window.location.reload()}},[k==null?void 0:k.running]),I.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=I.useRef(G$()).current;I.useRef(!1);const Tt=I.useRef(new Map($r.positions.filter(([V])=>$r.pins.includes(V)))),hr=I.useRef(null),pr=I.useState(()=>K$())[0],[pn,wi]=I.useState(""),[tr,xi]=I.useState(()=>new Set),[mn,rs]=I.useState(()=>typeof window>"u"?"dark":window.localStorage.getItem("agent-dag.theme")??"dark"),[nr,Dr]=I.useState(!1),mr=I.useRef(null);I.useEffect(()=>{document.documentElement.dataset.theme=mn;try{window.localStorage.setItem("agent-dag.theme",mn)}catch{}},[mn]),I.useEffect(()=>{if(!pr)return;const V=window.setTimeout(()=>{try{e.setViewport(pr,{duration:0})}catch{}},60);return()=>window.clearTimeout(V)},[e,pr]);const Fr=I.useRef(!0),Ot=I.useRef(null);I.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]),I.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]),I.useEffect(()=>{const V=setInterval(()=>{const K=Date.now();Je(K);let ue=yP(n.current,K,P$);gP(n.current,K,O$,q$)&&(ue=!0),vP(n.current,K,L$,$$)&&(ue=!0),ue&&s()},250);return()=>clearInterval(V)},[s]);const _i=I.useRef(null),$n=I.useRef(0),Dn=420,Kt=I.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=I.useRef(""),Si=I.useRef(null),bi=I.useRef(0),gr=I.useCallback(()=>{bi.current=Date.now()},[]),Br="agent-dag.autoFitDisabled",kn=I.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Br)==="1"}catch{return!1}})()),[ki,is]=I.useState(kn.current),et=I.useCallback(()=>{if(!kn.current){kn.current=!0,is(!0);try{window.localStorage.setItem(Br,"1")}catch{}}},[]),Qs=I.useCallback(()=>{kn.current=!1,is(!1);try{window.localStorage.removeItem(Br)}catch{}Kt(400)},[e,Kt]);I.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=Tt.current.get(Ye)??Rt.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=I.useRef(!1),Fn=I.useRef(new Map),yr=I.useRef(0),ss=I.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]=I.useState(0);I.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 Rt=I.useRef(new Map($r.positions)),Yt=I.useRef(""),Ur=I.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=I.useRef(null);I.useEffect(()=>(Ni.current!=null&&window.clearTimeout(Ni.current),Ni.current=window.setTimeout(()=>{Eg(Rt.current,Tt.current)},1500),()=>{Ni.current!=null&&window.clearTimeout(Ni.current)}),[Ur]),I.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=I.useMemo(()=>{if(o.size===0)return null;const V=new Set;for(const K of o){const ue=Z$(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=I.useMemo(()=>j$(n.current,He),[n.current,n.current.lastSeq,He]),Ci=I.useRef(null),[rr,ji]=I.useState({w:0,h:0});I.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=I.useRef(new Map),[fa,Js]=I.useState(!1);I.useEffect(()=>{const V=window.setTimeout(()=>Js(!0),2500);return()=>window.clearTimeout(V)},[]);const[ha,Ti]=I.useState(!1),tn=I.useRef(null),[eo,os]=I.useState(!1),Ve=I.useCallback(()=>{tn.current&&(window.clearTimeout(tn.current),tn.current=null),Ti(!1)},[]),pa=I.useCallback(V=>{V.length!==0&&queueMicrotask(()=>{Ti(!0),tn.current&&window.clearTimeout(tn.current),tn.current=window.setTimeout(()=>Ti(!1),M$+80)})},[]);I.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:ma}=I.useMemo(()=>J$(n.current,He,to,as,Tt.current,pn,Fn.current,gu.current,pa,fa,eo,Rt.current,Ur,Yt,o,Zs,Hr,S),[n.current,n.current.lastSeq,He,to,as,fa,eo,pn,Ur,o,Zs,Hr,S,Ge]),no=I.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+Cl*2,we=fe.maxY-fe.minY+Cl*2;K.push({id:`group:${ue}`,type:"sessionGroup",position:{x:fe.minX-Cl,y:fe.minY-Cl},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=I.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=I.useMemo(()=>{if(!pn)return null;const V=new Set;for(const K of n.current.agents.values())jC(K,pn)&&V.add(K.id);return V},[n.current,n.current.lastSeq,pn]),vn=I.useMemo(()=>{const V=new Set;for(const K of n.current.agents.values())for(const ue of K.tools)V.add(CC(ue.name));return Object.keys(Gg).filter(K=>V.has(K))},[n.current,n.current.lastSeq]);I.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=I.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=I.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=f?Array.from(n.current.agents.values()).flatMap(V=>V.tools).find(V=>V.id===f)??null:null,En=I.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=Bg(),Tt.current.clear(),Fn.current.clear(),Rt.current.clear(),Yt.current="",zk(),g(),s()},[s,g]),io=I.useCallback(()=>{Tt.current.clear(),Rt.current.clear(),Yt.current="",zk(),s(),window.setTimeout(()=>Kt(500),80)},[s,e,Kt]),so=I.useCallback(()=>Kt(500),[Kt]),xr=I.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&&(h(xe.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[xe]})}catch{}$n.current=Date.now()},30))},[gn,u,h,e]);I.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():g();return}if(!ue&&!J3(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,g,xr]);const oo=n.current.agents.size,ga=new Set(Array.from(n.current.agents.values()).map(V=>V.sessionId)).size,qt=I.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 m.jsxs("div",{className:"app",children:[m.jsxs("header",{className:"topbar",children:[m.jsxs("div",{className:"brand",children:[m.jsx("span",{className:"logo"}),"agents-deck",ae?m.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,m.jsx("span",{className:"v-dot","aria-hidden":!0})]}):m.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 ${D$(He-k.checkedAt)}`:""} · click to check now`,children:["v",(k==null?void 0:k.running)??"1.33.14"]})]}),wt&&(()=>{const V=dn(wt.usage,wt.model),K=Math.max(0,((wt.endedAt??He)-wt.startedAt)/1e3),ue=wt.state==="active"?Bl(V.total,K):null,fe=o.size-1;return m.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:[m.jsx("span",{className:`state-pill state-${wt.state}`,children:wt.state==="active"?"live":wt.state}),m.jsx("span",{className:"selected-label",children:wt.label}),V.total>0&&m.jsxs("span",{className:"selected-cost",children:[Be(V.total),ue?m.jsxs("span",{className:"selected-rate",children:[" · ",ue]}):null]}),fe>0&&m.jsxs("span",{className:"selected-extra",children:["+",fe]}),m.jsx("span",{role:"button","aria-label":"Deselect",className:"selected-close",onClick:xe=>{xe.stopPropagation(),g()},children:"×"})]})})(),m.jsxs("div",{className:"actions",children:[m.jsxs("div",{className:"search",children:[m.jsx("span",{className:"search-icon","aria-hidden":!0,children:"⌕"}),m.jsx("input",{ref:mr,type:"text",placeholder:"Search agents, cwd, tools…",value:pn,onChange:V=>wi(V.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),pn?m.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>wi(""),children:"×"}):m.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"})]}),m.jsxs("span",{className:"status",role:"status",children:[m.jsx("span",{className:`pill ${D?"live":"dead"}`,title:D?"Receiving events":"SSE disconnected",children:D?"live":"offline"}),m.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[m.jsx("span",{className:"count",children:ga}),m.jsx("span",{className:"lbl",children:"sessions"})]}),m.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[m.jsx("span",{className:"count",children:oo}),m.jsx("span",{className:"lbl",children:"agents"})]}),m.jsxs("span",{className:"stat",title:"Total hook events received",children:[m.jsx("span",{className:"count",children:n.current.totalEvents}),m.jsx("span",{className:"lbl",children:"events"})]}),qt.sum>0&&m.jsxs("span",{className:"stat",title:`in:${qt.inT.toLocaleString()} out:${qt.outT.toLocaleString()} cache-r:${qt.cacheR.toLocaleString()} cache-c:${qt.cacheC.toLocaleString()}`,children:[m.jsx("span",{className:"count",children:A$(qt.sum)}),m.jsx("span",{className:"lbl",children:"tokens"})]}),nn.length>0&&m.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=>m.jsx("span",{className:"mcp-dot",style:{background:`hsl(${V.hue} 65% 65%)`}},V.server)),nn.length>6&&m.jsxs("span",{className:"mcp-more",children:["+",nn.length-6]}),m.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?Bl(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 m.jsxs("span",{className:"stat",title:fe,children:[m.jsx("span",{className:"count",children:Be(qt.cost.total)}),m.jsxs("span",{className:"lbl",children:["cost",ue?` · ${ue}`:""]})]})})()]}),m.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"}),m.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&&m.jsx("button",{className:`btn icon-btn ${M?"primary":""}`,onClick:V=>{if(V.shiftKey&&U>0){Z(!0),fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restore"})}).then(()=>fetch("/api/sound-hook")).then(K=>K.ok?K.json():null).then(K=>{K!=null&&K.ok&&(B(K.enabled===!0),ne(K.parked??0))}).catch(()=>{}).finally(()=>Z(!1));return}Q()},disabled:J,title:(M?"Sound on turn finish: on — click to remove the hook":"Sound on turn finish: off — click to add a Stop hook")+(A>0?`
63
63
 
64
64
  ${A} sound hook${A>1?"s":""} of your own in settings.json also run${A>1?"":"s"} here.`:"")+(U>0?`
65
65
 
66
- ${U} of your own sound hook${U>1?"s were":" was"} set aside so this switch actually controls the sound. Nothing was deleted — shift-click to put ${U>1?"them":"it"} back.`:""),"aria-label":"Toggle finish sound","aria-pressed":M,children:m.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[m.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),M?m.jsxs(m.Fragment,{children:[m.jsx("path",{d:"M9.8 5.4a2.4 2.4 0 0 1 0 3.2"}),m.jsx("path",{d:"M11.3 3.9a4.6 4.6 0 0 1 0 6.2"})]}):m.jsxs(m.Fragment,{children:[m.jsx("path",{d:"M10 5.6l2.6 2.8"}),m.jsx("path",{d:"M12.6 5.6L10 8.4"})]})]})}),m.jsx("button",{className:`btn icon-btn ${F?"primary":""}`,onClick:We,title:`${F?"Hide":"Show"} accounts (A)`,"aria-label":"Toggle accounts panel",children:m.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[m.jsx("circle",{cx:"7",cy:"4.6",r:"2.4"}),m.jsx("path",{d:"M2.4 12c0-2.3 2.1-3.7 4.6-3.7s4.6 1.4 4.6 3.7"})]})}),m.jsx("button",{className:`btn icon-btn ${E?"primary":""}`,onClick:ke,title:`${E?"Hide":"Show"} session list (L)`,"aria-label":"Toggle session list",children:"☰"}),m.jsx("button",{className:`btn icon-btn ${ve?"primary":""}`,onClick:()=>ye(V=>!V),title:"Usage history — ccusage (H)","aria-label":"Open usage history",children:m.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":!0,children:[m.jsx("line",{x1:"3",y1:"11.5",x2:"3",y2:"7"}),m.jsx("line",{x1:"7",y1:"11.5",x2:"7",y2:"3"}),m.jsx("line",{x1:"11",y1:"11.5",x2:"11",y2:"8.5"})]})}),m.jsx("button",{className:"btn",onClick:io,title:"Auto-arrange — clear pins (R)",children:"Re-layout"}),m.jsx("button",{className:"btn",onClick:En,title:"Clear canvas (C)",children:"Clear"}),m.jsx("button",{className:"btn icon-btn",onClick:()=>rs(V=>V==="dark"?"light":"dark"),title:`Switch to ${mn==="dark"?"light":"dark"} mode (T)`,"aria-label":"Toggle theme",children:mn==="dark"?"☀":"☾"})]})]}),er?m.jsxs("div",{className:"ver-banner done",role:"status",children:[m.jsx("span",{className:"ver-dot"}),m.jsxs("strong",{children:["Restarted — now running v",er,"."]}),m.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):nr&&!D?m.jsxs("div",{className:"conn-banner",role:"alert",children:[m.jsx("span",{className:"conn-dot"}),Gt?zt==="npx"?"Fetching the new version with npx — this can take a minute…":"Restarting agents-deck…":"Lost connection to agents-deck server. Reconnecting…"]}):ge&&ae&&m.jsxs("div",{className:`ver-banner ${ae.kind}`,role:"status",children:[m.jsx("span",{className:"ver-dot"}),ae.kind==="restart"?m.jsxs(m.Fragment,{children:[m.jsxs("strong",{children:["v",ae.to," is installed — this deck still runs v",ae.from,"."]}),k!=null&&k.canRestart?m.jsxs(m.Fragment,{children:[m.jsx("button",{type:"button",className:"ver-act",onClick:()=>Jt(),disabled:Gt,title:"Stop this process and bring it back on the same port. The canvas replays from the event log.",children:Gt?"restarting…":"Restart now"}),m.jsxs("button",{type:"button",className:`ver-auto${dt?" on":""}`,role:"switch","aria-checked":dt,onClick:yt,title:dt?"Restarts on its own once nothing has been running for 30 seconds. Click to require a click instead.":"Only restarts when you click. Click to let it restart itself while idle.",children:[m.jsx("i",{"aria-hidden":!0}),"auto when idle"]})]}):m.jsx("span",{className:"ver-sub",title:"Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.",children:"Restart it to pick up the new code."})]}):m.jsxs(m.Fragment,{children:[m.jsxs("strong",{children:["agents-deck v",ae.to," is out — you are on v",ae.from,"."]}),(k==null?void 0:k.upgradeMode)==="install"&&Oe!=="failed"&&m.jsx("button",{type:"button",className:"ver-act",onClick:Me,disabled:Oe==="running"||Oe==="done",title:`Runs ${((va=k==null?void 0:k.upgrade)==null?void 0:va.command)??"npm install -g agents-deck@latest"} here, then restarts once nothing is running.`,children:Oe==="running"?"installing…":Oe==="done"?"installed":"Update now"}),(k==null?void 0:k.upgradeMode)==="npx"&&(k==null?void 0:k.canRestart)&&m.jsx("button",{type:"button",className:"ver-act",onClick:()=>Jt({upgrade:!0}),disabled:Gt,title:`Runs ${k==null?void 0:k.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`,children:Gt?"fetching…":"Update & restart"}),Oe==="failed"?m.jsxs("span",{className:"ver-sub fail",title:((Wr=k==null?void 0:k.upgrade)==null?void 0:Wr.error)??"",children:["install failed: ",((Gr=k==null?void 0:k.upgrade)==null?void 0:Gr.error)??"unknown error"," — run it yourself:"]}):(k==null?void 0:k.upgradeMode)==="npx"?m.jsx("span",{className:"ver-sub",children:k!=null&&k.canRestart?"npx cannot upgrade in place, so the deck re-runs:":Lk.npx}):k!=null&&k.upgradeBlocked?m.jsx("span",{className:"ver-sub",children:Lk[k.upgradeBlocked]??"cannot install from here"}):null,m.jsxs("button",{type:"button",className:"ver-cmd",onClick:Pe,title:"Copy to clipboard",children:[m.jsx("code",{children:k==null?void 0:k.command}),m.jsx("span",{className:"ver-cmd-hint",children:Y?"copied":"copy"})]})]}),m.jsx("span",{role:"button",tabIndex:0,"aria-label":"Dismiss",className:"ver-close",onClick:Ae,onKeyDown:V=>{(V.key==="Enter"||V.key===" ")&&(V.preventDefault(),Ae())},children:"×"})]}),O&&m.jsx(P3,{state:n.current,now:He,onClose:()=>q(!1)}),F&&m.jsx(Y3,{onClose:()=>T(!1)}),E&&m.jsx(k3,{state:n.current,now:He,selectedIds:o,onSelect:V=>{h(V,!1),window.setTimeout(()=>{try{const K=gn.find(ue=>ue.id===V);K&&e.fitView({padding:.3,duration:500,nodes:[K]}),$n.current=Date.now()}catch{}},60)},onClose:()=>N(!1)}),m.jsxs("div",{className:`canvas-wrap${ha?" bubbling":""}${eo?" dragging-any":""}`,ref:Ci,children:[oo===0&&m.jsx(t4,{live:D,everConnected:nr}),vn.length>1&&m.jsx("div",{ref:it,className:`cat-filter-bar${Ke?" occluded":""}`,role:"toolbar","aria-label":"Filter tools by category",children:vn.map(V=>{const K=tr.has(V);return m.jsxs("button",{type:"button",className:`cat-filter${K?" off":""}`,onClick:()=>ir(V),title:`${K?"Show":"Hide"} ${Kg[V]} tools`,children:[m.jsx("span",{className:"cat-emoji",children:Gg[V]}),m.jsx("span",{className:"cat-name",children:Kg[V]})]},V)})}),m.jsxs(aN,{nodes:ro,edges:ma,nodeTypes:A$,fitView:!pr,fitViewOptions:{padding:.25,duration:400},minZoom:.2,maxZoom:1.6,panOnScroll:!0,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,onNodeClick:(V,K)=>{if(K.type==="sessionGroup"){g();return}h(K.id,V.shiftKey)},onPaneClick:()=>g(),onMoveStart:()=>{Date.now()-$n.current<1200||et()},onMove:(V,K)=>{gr(),Si.current&&window.clearTimeout(Si.current),Si.current=window.setTimeout(()=>K$(K),250)},onNodeDragStart:(V,K)=>{var ue;if(Ve(),vr.current=!0,Qe.current=new Map,os(!0),gr(),et(),K.type==="sessionGroup"){const fe=(ue=K.data)==null?void 0:ue.sessionId,xe=new Map;if(fe)for(const we of gn){const Ie=we.data;(Ie==null?void 0:Ie.sessionId)===fe&&xe.set(we.id,{x:we.position.x,y:we.position.y})}hr.current={start:{x:K.position.x,y:K.position.y},members:xe};return}Tt.current.set(K.id,{x:K.position.x,y:K.position.y})},onNodeDrag:(V,K)=>{var ue;if(gr(),K.type==="sessionGroup"){const fe=hr.current;if(!fe)return;const xe=K.position.x-fe.start.x,we=K.position.y-fe.start.y;for(const[Fe,De]of fe.members){const Ye={x:De.x+xe,y:De.y+we};Tt.current.set(Fe,Ye),Rt.current.set(Fe,Ye)}const Ie=Qe.current;if(Ie){for(const[Fe,De]of fe.members)Ie.set(Fe,{x:De.x+xe,y:De.y+we});Ie.set(K.id,{x:K.position.x,y:K.position.y})}ct(Fe=>Fe+1);return}Tt.current.set(K.id,{x:K.position.x,y:K.position.y}),Rt.current.set(K.id,{x:K.position.x,y:K.position.y}),(ue=Qe.current)==null||ue.set(K.id,{x:K.position.x,y:K.position.y}),ct(fe=>fe+1)},onNodeDragStop:(V,K)=>{if(gr(),vr.current=!1,Qe.current=null,os(!1),ut(ue=>ue+1),K.type==="sessionGroup"){const ue=hr.current;if(ue){const fe=K.position.x-ue.start.x,xe=K.position.y-ue.start.y;for(const[we,Ie]of ue.members){const Fe={x:Ie.x+fe,y:Ie.y+xe};Tt.current.set(we,Fe),Rt.current.set(we,Fe)}}hr.current=null,Eg(Rt.current,Tt.current),ut(fe=>fe+1);return}Tt.current.set(K.id,{x:K.position.x,y:K.position.y}),Rt.current.set(K.id,{x:K.position.x,y:K.position.y}),Eg(Rt.current,Tt.current)},children:[m.jsx(cP,{gap:28,size:1,color:Hi("--grid-line")}),m.jsx(UP,{}),m.jsx(y3,{agents:n.current.agents,visibleAgentIds:Hr,positions:Rt.current,pinned:Tt.current,measured:Fn.current,dimUnmatched:ls,spotlight:Zs,hiddenCategories:tr,now:He,onOpenTool:p}),m.jsx(iP,{showInteractive:!1,children:m.jsx(Ls,{onClick:Qs,title:ki?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view",style:ki?{color:"var(--accent)"}:void 0,children:m.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[m.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),m.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})})}),m.jsx(QM,{zoomable:!0,pannable:!0,nodeColor:V=>{const K=V.data;return K.state==="err"?Hi("--err"):K.state==="active"?Hi("--inflight"):Hi("--ok")},nodeStrokeWidth:2,maskColor:Hi("--minimap-mask"),style:{background:Hi("--panel"),border:`1px solid ${Hi("--line")}`,borderRadius:8}})]})]}),j?m.jsxs("aside",{className:"detail",children:[m.jsx("button",{type:"button",className:"detail-close",title:"Close panel","aria-label":"Close detail panel",onClick:()=>P(!1),children:"×"}),wt?m.jsx(i4,{agent:wt,now:He,onOpenTool:p,onShowSummary:V=>{b.current.has(V)&&(b.current.delete(V),Fk(b.current)),w(V)},onExportSession:V=>Y$(n.current,V)}):m.jsx(r4,{count:oo})]}):m.jsx("button",{type:"button",className:"detail-reopen",title:"Show detail panel","aria-label":"Show detail panel",onClick:()=>P(!0),children:"‹"}),Vr&&m.jsx(DP,{tool:Vr,onClose:()=>p(null)}),ve&&m.jsx(nO,{onClose:()=>ye(!1)}),C&&(()=>{const V=n.current.agents.get(C);return V?m.jsx(RP,{agent:V,onClose:()=>_(null)}):null})(),y&&m.jsx(w3,{state:n.current,sessionId:y,onClose:()=>{b.current.add(y),Fk(b.current),w(null)}})]})}function t4({live:e,everConnected:n}){const i=!e;return m.jsxs("div",{className:"empty-hero",children:[m.jsxs("div",{className:"orbit-stack","aria-hidden":!0,children:[m.jsx("div",{className:"core"}),m.jsxs("div",{className:"orbit r1",children:[m.jsx("span",{className:"dot"}),m.jsx("span",{className:"dot b"})]}),m.jsxs("div",{className:"orbit r2",children:[m.jsx("span",{className:"dot"}),m.jsx("span",{className:"dot b"})]}),m.jsxs("div",{className:"orbit r3",children:[m.jsx("span",{className:"dot"}),m.jsx("span",{className:"dot b"})]})]}),i?m.jsxs(m.Fragment,{children:[m.jsx("h2",{children:n?"Disconnected from server":"Server unreachable"}),m.jsxs("p",{children:["The browser cannot reach ",m.jsx("code",{children:"/events"}),". Check that",m.jsx("code",{children:"agents-deck"})," is still running in your terminal, then this page will resume automatically."]})]}):n4()]})}function n4(){return m.jsxs(m.Fragment,{children:[m.jsx("h2",{children:"Waiting for Claude Code or Codex"}),m.jsxs("p",{children:["Run ",m.jsx("code",{children:"claude"})," or ",m.jsx("code",{children:"codex"})," in any folder. As soon as a session sends an event, a node appears here and grows as subagents fork and tools are called."]}),m.jsxs("p",{className:"hint-row",children:["Not seeing anything? Make sure ",m.jsx("code",{children:"agents-deck"})," is running and that hooks are installed in ",m.jsx("code",{children:"~/.claude/settings.json"})," and"," ",m.jsx("code",{children:"~/.codex/hooks.json"}),". (Codex requires"," ",m.jsx("code",{children:"/hooks"})," trust on first run.)"]})]})}function r4({count:e}){return m.jsxs(m.Fragment,{children:[m.jsx("h3",{children:"Detail"}),e===0?m.jsxs("div",{className:"hint",children:["No data yet. Start a Claude Code or Codex session anywhere on this machine — agents-deck is in ",m.jsx("code",{children:"--all"})," mode and listens to every workspace."]}):m.jsx("div",{className:"empty",children:"Click an agent to see its tools."}),m.jsx("h3",{style:{marginTop:4},children:"Shortcuts"}),m.jsxs("div",{className:"shortcuts",children:[m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"drag"}),m.jsx("span",{children:"move a node"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"/"}),m.jsx("span",{children:"focus search"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"space"}),m.jsx("span",{children:"pause / resume"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"J"}),m.jsx("span",{children:"next agent"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"K"}),m.jsx("span",{children:"previous agent"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"R"}),m.jsx("span",{children:"re-arrange"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"F"}),m.jsx("span",{children:"fit view"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"L"}),m.jsx("span",{children:"session list"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"H"}),m.jsx("span",{children:"usage history"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"U"}),m.jsx("span",{children:"usage panel"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"C"}),m.jsx("span",{children:"clear canvas"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"T"}),m.jsx("span",{children:"toggle theme"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"Esc"}),m.jsx("span",{children:"deselect"})]})]})]})}function i4({agent:e,now:n,onOpenTool:i,onShowSummary:s,onExportSession:o}){const l=(e.endedAt??n)-e.startedAt,u=Math.max(0,Math.floor(l/1e3)),c=u<60?`${u}s`:`${Math.floor(u/60)}m ${String(u%60).padStart(2,"0")}s`,f=dn(e.usage,e.model),p=f.total>0,h=e.usage.inputTokens+e.usage.outputTokens,g=new Map;for(const _ of e.tools){const S=CC(_.name);g.set(S,(g.get(S)??0)+1)}const y=e.tools.filter(_=>_.ok===!1).length,w=e.tools.filter(_=>!_.endedAt).length,C=Array.from(g.entries()).sort((_,S)=>S[1]-_[1]);return m.jsxs(m.Fragment,{children:[m.jsxs("header",{className:"detail-hero",children:[m.jsxs("div",{className:"hero-line",children:[m.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),m.jsx("h2",{className:"hero-title",title:e.cwd??e.label,children:e.label})]}),m.jsxs("div",{className:"hero-meta",children:[m.jsx("span",{className:"hero-meta-item",children:e.kind}),m.jsx("span",{className:"hero-sep",children:"·"}),m.jsx("span",{className:"hero-meta-item",title:`started ${new Date(e.startedAt).toLocaleString()}`,children:c}),e.model&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"hero-sep",children:"·"}),m.jsx("span",{className:"model-chip",title:e.model,children:oa(e.model)})]})]}),p&&m.jsxs("div",{className:"hero-cost",children:[m.jsxs("div",{className:"hero-cost-headline",children:[m.jsx("span",{className:"hero-cost-value",children:Be(f.total)}),m.jsx("span",{className:"hero-cost-label",children:"spend"})]}),m.jsx(s4,{cost:f})]}),m.jsxs("div",{className:"hero-actions",children:[e.kind==="root"&&e.state==="done"&&s&&m.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>s(e.sessionId),title:"Reopen the end-of-session recap modal",children:"Show recap"}),o&&m.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>o(e.sessionId),title:"Download this session as JSON",children:"Export JSON"})]})]}),e.tools.length>0&&m.jsxs("section",{className:"detail-section",children:[m.jsx("h3",{children:"Activity"}),m.jsxs("div",{className:"activity-row",children:[m.jsxs("div",{className:"activity-counters",children:[m.jsxs("span",{className:"ac-item",children:[m.jsx("b",{children:e.toolCount})," calls"]}),w>0&&m.jsxs("span",{className:"ac-item ac-live",children:[m.jsx("b",{children:w})," live"]}),y>0&&m.jsxs("span",{className:"ac-item ac-err",children:[m.jsx("b",{children:y})," err"]})]}),m.jsx("div",{className:"cat-strip",children:C.map(([_,S])=>m.jsxs("span",{className:`cat-chip cat-${_}`,title:`${S} ${Kg[_]} call${S===1?"":"s"}`,children:[m.jsx("span",{className:"cat-emoji",children:Gg[_]}),m.jsx("span",{className:"cat-count",children:S})]},_))})]})]}),h>0&&m.jsxs("section",{className:"detail-section",children:[m.jsx("h3",{children:"Tokens"}),m.jsxs("div",{className:"tokens-grid",children:[m.jsxs("div",{children:[m.jsx("span",{className:"k",children:"in"}),m.jsx("b",{children:e.usage.inputTokens.toLocaleString()})]}),m.jsxs("div",{children:[m.jsx("span",{className:"k",children:"out"}),m.jsx("b",{children:e.usage.outputTokens.toLocaleString()})]}),m.jsxs("div",{children:[m.jsx("span",{className:"k",children:"cache r"}),m.jsx("b",{children:e.usage.cacheReadTokens.toLocaleString()})]}),m.jsxs("div",{children:[m.jsx("span",{className:"k",children:"cache c"}),m.jsx("b",{children:e.usage.cacheCreateTokens.toLocaleString()})]})]})]}),m.jsxs("section",{className:"detail-section",children:[m.jsx("h3",{children:"Identity"}),m.jsxs("div",{children:[e.cwd&&m.jsxs("div",{className:"row",children:[m.jsx("span",{className:"k",children:"cwd"}),m.jsx("span",{className:"v",title:e.cwd,children:e.cwd})]}),m.jsxs("div",{className:"row",children:[m.jsx("span",{className:"k",children:"session"}),m.jsxs("span",{className:"v",children:[e.sessionId.slice(0,12),"…"]})]}),e.parentId&&m.jsxs("div",{className:"row",children:[m.jsx("span",{className:"k",children:"parent"}),m.jsxs("span",{className:"v",children:[e.parentId.slice(0,12),"…"]})]})]})]}),e.prompts.length>0&&m.jsxs("section",{className:"detail-section",children:[m.jsxs("h3",{children:["Prompts ",m.jsx("span",{className:"section-count",children:e.prompts.length})]}),m.jsx("div",{className:"prompts",children:e.prompts.slice().reverse().map((_,S)=>m.jsxs("div",{className:"prompt-entry",children:[m.jsx("div",{className:"prompt-time",children:new Date(_.at).toLocaleTimeString()}),m.jsx("div",{className:"prompt-text",children:_.text})]},S))})]}),m.jsxs("section",{className:"detail-section",children:[m.jsxs("h3",{children:["Tool calls ",m.jsx("span",{className:"section-count",children:e.tools.length})]}),e.tools.length===0&&m.jsx("div",{className:"empty",children:"No tool calls yet."}),m.jsx("div",{children:e.tools.slice().reverse().map(_=>m.jsx(o4,{t:_,now:n,onClick:()=>i(_.id)},_.id))})]})]})}function s4({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 m.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${Be(s)} (${u.toFixed(0)}%)`},o)};return m.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 o4({t:e,now:n,onClick:i}){const s=e.endedAt==null?"inflight":e.ok===!1?"err":"done",o=(e.endedAt??n)-e.startedAt,l=e.endedAt==null?"…":o<1e3?`${o}ms`:`${(o/1e3).toFixed(1)}s`;return m.jsxs("button",{className:"tool clickable",title:e.inputPreview||e.name,onClick:i,children:[m.jsxs("span",{className:"name",children:[m.jsx("span",{className:`status-dot ${s}`}),e.name]}),m.jsx("span",{style:{color:"var(--muted)"},children:l})]})}const a4="1",Bk="agent-dag.schema",l4=["agent-dag.layout","agent-dag.viewport"];function u4(e,n=a4){let i=null;try{i=e.getItem(Bk)}catch{return[]}if(i===n)return[];const s=[];if(i!==null)for(const o of l4)try{e.getItem(o)!==null&&(e.removeItem(o),s.push(o))}catch{}try{e.setItem(Bk,n)}catch{}return s}try{u4(window.localStorage)}catch{}const c4=lT.createRoot(document.getElementById("root"));c4.render(m.jsx(J$,{}));
66
+ ${U} of your own sound hook${U>1?"s were":" was"} set aside so this switch actually controls the sound. Nothing was deleted — shift-click to put ${U>1?"them":"it"} back.`:""),"aria-label":"Toggle finish sound","aria-pressed":M,children:m.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[m.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),M?m.jsxs(m.Fragment,{children:[m.jsx("path",{d:"M9.8 5.4a2.4 2.4 0 0 1 0 3.2"}),m.jsx("path",{d:"M11.3 3.9a4.6 4.6 0 0 1 0 6.2"})]}):m.jsxs(m.Fragment,{children:[m.jsx("path",{d:"M10 5.6l2.6 2.8"}),m.jsx("path",{d:"M12.6 5.6L10 8.4"})]})]})}),m.jsx("button",{className:`btn icon-btn ${F?"primary":""}`,onClick:We,title:`${F?"Hide":"Show"} accounts (A)`,"aria-label":"Toggle accounts panel",children:m.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[m.jsx("circle",{cx:"7",cy:"4.6",r:"2.4"}),m.jsx("path",{d:"M2.4 12c0-2.3 2.1-3.7 4.6-3.7s4.6 1.4 4.6 3.7"})]})}),m.jsx("button",{className:`btn icon-btn ${E?"primary":""}`,onClick:ke,title:`${E?"Hide":"Show"} session list (L)`,"aria-label":"Toggle session list",children:"☰"}),m.jsx("button",{className:`btn icon-btn ${ve?"primary":""}`,onClick:()=>ye(V=>!V),title:"Usage history — ccusage (H)","aria-label":"Open usage history",children:m.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":!0,children:[m.jsx("line",{x1:"3",y1:"11.5",x2:"3",y2:"7"}),m.jsx("line",{x1:"7",y1:"11.5",x2:"7",y2:"3"}),m.jsx("line",{x1:"11",y1:"11.5",x2:"11",y2:"8.5"})]})}),m.jsx("button",{className:"btn",onClick:io,title:"Auto-arrange — clear pins (R)",children:"Re-layout"}),m.jsx("button",{className:"btn",onClick:En,title:"Clear canvas (C)",children:"Clear"}),m.jsx("button",{className:"btn icon-btn",onClick:()=>rs(V=>V==="dark"?"light":"dark"),title:`Switch to ${mn==="dark"?"light":"dark"} mode (T)`,"aria-label":"Toggle theme",children:mn==="dark"?"☀":"☾"})]})]}),er?m.jsxs("div",{className:"ver-banner done",role:"status",children:[m.jsx("span",{className:"ver-dot"}),m.jsxs("strong",{children:["Restarted — now running v",er,"."]}),m.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):nr&&!D?m.jsxs("div",{className:"conn-banner",role:"alert",children:[m.jsx("span",{className:"conn-dot"}),Gt?zt==="npx"?"Fetching the new version with npx — this can take a minute…":"Restarting agents-deck…":"Lost connection to agents-deck server. Reconnecting…"]}):ge&&ae&&m.jsxs("div",{className:`ver-banner ${ae.kind}`,role:"status",children:[m.jsx("span",{className:"ver-dot"}),ae.kind==="restart"?m.jsxs(m.Fragment,{children:[m.jsxs("strong",{children:["v",ae.to," is installed — this deck still runs v",ae.from,"."]}),k!=null&&k.canRestart?m.jsxs(m.Fragment,{children:[m.jsx("button",{type:"button",className:"ver-act",onClick:()=>Jt(),disabled:Gt,title:"Stop this process and bring it back on the same port. The canvas replays from the event log.",children:Gt?"restarting…":"Restart now"}),m.jsxs("button",{type:"button",className:`ver-auto${dt?" on":""}`,role:"switch","aria-checked":dt,onClick:yt,title:dt?"Restarts on its own once nothing has been running for 30 seconds. Click to require a click instead.":"Only restarts when you click. Click to let it restart itself while idle.",children:[m.jsx("i",{"aria-hidden":!0}),"auto when idle"]})]}):m.jsx("span",{className:"ver-sub",title:"Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.",children:"Restart it to pick up the new code."})]}):m.jsxs(m.Fragment,{children:[m.jsxs("strong",{children:["agents-deck v",ae.to," is out — you are on v",ae.from,"."]}),(k==null?void 0:k.upgradeMode)==="install"&&Oe!=="failed"&&m.jsx("button",{type:"button",className:"ver-act",onClick:Me,disabled:Oe==="running"||Oe==="done",title:`Runs ${((va=k==null?void 0:k.upgrade)==null?void 0:va.command)??"npm install -g agents-deck@latest"} here, then restarts once nothing is running.`,children:Oe==="running"?"installing…":Oe==="done"?"installed":"Update now"}),(k==null?void 0:k.upgradeMode)==="npx"&&(k==null?void 0:k.canRestart)&&m.jsx("button",{type:"button",className:"ver-act",onClick:()=>Jt({upgrade:!0}),disabled:Gt,title:`Runs ${k==null?void 0:k.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`,children:Gt?"fetching…":"Update & restart"}),Oe==="failed"?m.jsxs("span",{className:"ver-sub fail",title:((Wr=k==null?void 0:k.upgrade)==null?void 0:Wr.error)??"",children:["install failed: ",((Gr=k==null?void 0:k.upgrade)==null?void 0:Gr.error)??"unknown error"," — run it yourself:"]}):(k==null?void 0:k.upgradeMode)==="npx"?m.jsx("span",{className:"ver-sub",children:k!=null&&k.canRestart?"npx cannot upgrade in place, so the deck re-runs:":Lk.npx}):k!=null&&k.upgradeBlocked?m.jsx("span",{className:"ver-sub",children:Lk[k.upgradeBlocked]??"cannot install from here"}):null,m.jsxs("button",{type:"button",className:"ver-cmd",onClick:Pe,title:"Copy to clipboard",children:[m.jsx("code",{children:k==null?void 0:k.command}),m.jsx("span",{className:"ver-cmd-hint",children:Y?"copied":"copy"})]})]}),m.jsx("span",{role:"button",tabIndex:0,"aria-label":"Dismiss",className:"ver-close",onClick:Ae,onKeyDown:V=>{(V.key==="Enter"||V.key===" ")&&(V.preventDefault(),Ae())},children:"×"})]}),O&&m.jsx(P3,{state:n.current,now:He,onClose:()=>q(!1)}),F&&m.jsx(Y3,{onClose:()=>T(!1)}),E&&m.jsx(k3,{state:n.current,now:He,selectedIds:o,onSelect:V=>{h(V,!1),window.setTimeout(()=>{try{const K=gn.find(ue=>ue.id===V);K&&e.fitView({padding:.3,duration:500,nodes:[K]}),$n.current=Date.now()}catch{}},60)},onClose:()=>N(!1)}),m.jsxs("div",{className:`canvas-wrap${ha?" bubbling":""}${eo?" dragging-any":""}`,ref:Ci,children:[oo===0&&m.jsx(n4,{live:D,everConnected:nr}),vn.length>1&&m.jsx("div",{ref:it,className:`cat-filter-bar${Ke?" occluded":""}`,role:"toolbar","aria-label":"Filter tools by category",children:vn.map(V=>{const K=tr.has(V);return m.jsxs("button",{type:"button",className:`cat-filter${K?" off":""}`,onClick:()=>ir(V),title:`${K?"Show":"Hide"} ${Kg[V]} tools`,children:[m.jsx("span",{className:"cat-emoji",children:Gg[V]}),m.jsx("span",{className:"cat-name",children:Kg[V]})]},V)})}),m.jsxs(aN,{nodes:ro,edges:ma,nodeTypes:I$,fitView:!pr,fitViewOptions:{padding:.25,duration:400},minZoom:.2,maxZoom:1.6,panOnScroll:!0,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,onNodeClick:(V,K)=>{if(K.type==="sessionGroup"){g();return}h(K.id,V.shiftKey)},onPaneClick:()=>g(),onMoveStart:()=>{Date.now()-$n.current<1200||et()},onMove:(V,K)=>{gr(),Si.current&&window.clearTimeout(Si.current),Si.current=window.setTimeout(()=>Y$(K),250)},onNodeDragStart:(V,K)=>{var ue;if(Ve(),vr.current=!0,Qe.current=new Map,os(!0),gr(),et(),K.type==="sessionGroup"){const fe=(ue=K.data)==null?void 0:ue.sessionId,xe=new Map;if(fe)for(const we of gn){const Ie=we.data;(Ie==null?void 0:Ie.sessionId)===fe&&xe.set(we.id,{x:we.position.x,y:we.position.y})}hr.current={start:{x:K.position.x,y:K.position.y},members:xe};return}Tt.current.set(K.id,{x:K.position.x,y:K.position.y})},onNodeDrag:(V,K)=>{var ue;if(gr(),K.type==="sessionGroup"){const fe=hr.current;if(!fe)return;const xe=K.position.x-fe.start.x,we=K.position.y-fe.start.y;for(const[Fe,De]of fe.members){const Ye={x:De.x+xe,y:De.y+we};Tt.current.set(Fe,Ye),Rt.current.set(Fe,Ye)}const Ie=Qe.current;if(Ie){for(const[Fe,De]of fe.members)Ie.set(Fe,{x:De.x+xe,y:De.y+we});Ie.set(K.id,{x:K.position.x,y:K.position.y})}ct(Fe=>Fe+1);return}Tt.current.set(K.id,{x:K.position.x,y:K.position.y}),Rt.current.set(K.id,{x:K.position.x,y:K.position.y}),(ue=Qe.current)==null||ue.set(K.id,{x:K.position.x,y:K.position.y}),ct(fe=>fe+1)},onNodeDragStop:(V,K)=>{if(gr(),vr.current=!1,Qe.current=null,os(!1),ut(ue=>ue+1),K.type==="sessionGroup"){const ue=hr.current;if(ue){const fe=K.position.x-ue.start.x,xe=K.position.y-ue.start.y;for(const[we,Ie]of ue.members){const Fe={x:Ie.x+fe,y:Ie.y+xe};Tt.current.set(we,Fe),Rt.current.set(we,Fe)}}hr.current=null,Eg(Rt.current,Tt.current),ut(fe=>fe+1);return}Tt.current.set(K.id,{x:K.position.x,y:K.position.y}),Rt.current.set(K.id,{x:K.position.x,y:K.position.y}),Eg(Rt.current,Tt.current)},children:[m.jsx(cP,{gap:28,size:1,color:Hi("--grid-line")}),m.jsx(UP,{}),m.jsx(y3,{agents:n.current.agents,visibleAgentIds:Hr,positions:Rt.current,pinned:Tt.current,measured:Fn.current,dimUnmatched:ls,spotlight:Zs,hiddenCategories:tr,now:He,onOpenTool:p}),m.jsx(iP,{showInteractive:!1,children:m.jsx(Ls,{onClick:Qs,title:ki?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view",style:ki?{color:"var(--accent)"}:void 0,children:m.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[m.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),m.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})})}),m.jsx(QM,{zoomable:!0,pannable:!0,nodeColor:V=>{const K=V.data;return K.state==="err"?Hi("--err"):K.state==="active"?Hi("--inflight"):Hi("--ok")},nodeStrokeWidth:2,maskColor:Hi("--minimap-mask"),style:{background:Hi("--panel"),border:`1px solid ${Hi("--line")}`,borderRadius:8}})]})]}),j?m.jsxs("aside",{className:"detail",children:[m.jsx("button",{type:"button",className:"detail-close",title:"Close panel","aria-label":"Close detail panel",onClick:()=>P(!1),children:"×"}),wt?m.jsx(s4,{agent:wt,now:He,onOpenTool:p,onShowSummary:V=>{b.current.has(V)&&(b.current.delete(V),Fk(b.current)),w(V)},onExportSession:V=>X$(n.current,V)}):m.jsx(i4,{count:oo})]}):m.jsx("button",{type:"button",className:"detail-reopen",title:"Show detail panel","aria-label":"Show detail panel",onClick:()=>P(!0),children:"‹"}),Vr&&m.jsx(DP,{tool:Vr,onClose:()=>p(null)}),ve&&m.jsx(rO,{onClose:()=>ye(!1)}),C&&(()=>{const V=n.current.agents.get(C);return V?m.jsx(RP,{agent:V,onClose:()=>_(null)}):null})(),y&&m.jsx(w3,{state:n.current,sessionId:y,onClose:()=>{b.current.add(y),Fk(b.current),w(null)}})]})}function n4({live:e,everConnected:n}){const i=!e;return m.jsxs("div",{className:"empty-hero",children:[m.jsxs("div",{className:"orbit-stack","aria-hidden":!0,children:[m.jsx("div",{className:"core"}),m.jsxs("div",{className:"orbit r1",children:[m.jsx("span",{className:"dot"}),m.jsx("span",{className:"dot b"})]}),m.jsxs("div",{className:"orbit r2",children:[m.jsx("span",{className:"dot"}),m.jsx("span",{className:"dot b"})]}),m.jsxs("div",{className:"orbit r3",children:[m.jsx("span",{className:"dot"}),m.jsx("span",{className:"dot b"})]})]}),i?m.jsxs(m.Fragment,{children:[m.jsx("h2",{children:n?"Disconnected from server":"Server unreachable"}),m.jsxs("p",{children:["The browser cannot reach ",m.jsx("code",{children:"/events"}),". Check that",m.jsx("code",{children:"agents-deck"})," is still running in your terminal, then this page will resume automatically."]})]}):r4()]})}function r4(){return m.jsxs(m.Fragment,{children:[m.jsx("h2",{children:"Waiting for Claude Code or Codex"}),m.jsxs("p",{children:["Run ",m.jsx("code",{children:"claude"})," or ",m.jsx("code",{children:"codex"})," in any folder. As soon as a session sends an event, a node appears here and grows as subagents fork and tools are called."]}),m.jsxs("p",{className:"hint-row",children:["Not seeing anything? Make sure ",m.jsx("code",{children:"agents-deck"})," is running and that hooks are installed in ",m.jsx("code",{children:"~/.claude/settings.json"})," and"," ",m.jsx("code",{children:"~/.codex/hooks.json"}),". (Codex requires"," ",m.jsx("code",{children:"/hooks"})," trust on first run.)"]})]})}function i4({count:e}){return m.jsxs(m.Fragment,{children:[m.jsx("h3",{children:"Detail"}),e===0?m.jsxs("div",{className:"hint",children:["No data yet. Start a Claude Code or Codex session anywhere on this machine — agents-deck is in ",m.jsx("code",{children:"--all"})," mode and listens to every workspace."]}):m.jsx("div",{className:"empty",children:"Click an agent to see its tools."}),m.jsx("h3",{style:{marginTop:4},children:"Shortcuts"}),m.jsxs("div",{className:"shortcuts",children:[m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"drag"}),m.jsx("span",{children:"move a node"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"/"}),m.jsx("span",{children:"focus search"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"space"}),m.jsx("span",{children:"pause / resume"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"J"}),m.jsx("span",{children:"next agent"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"K"}),m.jsx("span",{children:"previous agent"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"R"}),m.jsx("span",{children:"re-arrange"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"F"}),m.jsx("span",{children:"fit view"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"L"}),m.jsx("span",{children:"session list"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"H"}),m.jsx("span",{children:"usage history"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"U"}),m.jsx("span",{children:"usage panel"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"C"}),m.jsx("span",{children:"clear canvas"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"T"}),m.jsx("span",{children:"toggle theme"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"Esc"}),m.jsx("span",{children:"deselect"})]})]})]})}function s4({agent:e,now:n,onOpenTool:i,onShowSummary:s,onExportSession:o}){const l=(e.endedAt??n)-e.startedAt,u=Math.max(0,Math.floor(l/1e3)),c=u<60?`${u}s`:`${Math.floor(u/60)}m ${String(u%60).padStart(2,"0")}s`,f=dn(e.usage,e.model),p=f.total>0,h=e.usage.inputTokens+e.usage.outputTokens,g=new Map;for(const _ of e.tools){const S=CC(_.name);g.set(S,(g.get(S)??0)+1)}const y=e.tools.filter(_=>_.ok===!1).length,w=e.tools.filter(_=>!_.endedAt).length,C=Array.from(g.entries()).sort((_,S)=>S[1]-_[1]);return m.jsxs(m.Fragment,{children:[m.jsxs("header",{className:"detail-hero",children:[m.jsxs("div",{className:"hero-line",children:[m.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),m.jsx("h2",{className:"hero-title",title:e.cwd??e.label,children:e.label})]}),m.jsxs("div",{className:"hero-meta",children:[m.jsx("span",{className:"hero-meta-item",children:e.kind}),m.jsx("span",{className:"hero-sep",children:"·"}),m.jsx("span",{className:"hero-meta-item",title:`started ${new Date(e.startedAt).toLocaleString()}`,children:c}),e.model&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"hero-sep",children:"·"}),m.jsx("span",{className:"model-chip",title:e.model,children:oa(e.model)})]})]}),p&&m.jsxs("div",{className:"hero-cost",children:[m.jsxs("div",{className:"hero-cost-headline",children:[m.jsx("span",{className:"hero-cost-value",children:Be(f.total)}),m.jsx("span",{className:"hero-cost-label",children:"spend"})]}),m.jsx(o4,{cost:f})]}),m.jsxs("div",{className:"hero-actions",children:[e.kind==="root"&&e.state==="done"&&s&&m.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>s(e.sessionId),title:"Reopen the end-of-session recap modal",children:"Show recap"}),o&&m.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>o(e.sessionId),title:"Download this session as JSON",children:"Export JSON"})]})]}),e.tools.length>0&&m.jsxs("section",{className:"detail-section",children:[m.jsx("h3",{children:"Activity"}),m.jsxs("div",{className:"activity-row",children:[m.jsxs("div",{className:"activity-counters",children:[m.jsxs("span",{className:"ac-item",children:[m.jsx("b",{children:e.toolCount})," calls"]}),w>0&&m.jsxs("span",{className:"ac-item ac-live",children:[m.jsx("b",{children:w})," live"]}),y>0&&m.jsxs("span",{className:"ac-item ac-err",children:[m.jsx("b",{children:y})," err"]})]}),m.jsx("div",{className:"cat-strip",children:C.map(([_,S])=>m.jsxs("span",{className:`cat-chip cat-${_}`,title:`${S} ${Kg[_]} call${S===1?"":"s"}`,children:[m.jsx("span",{className:"cat-emoji",children:Gg[_]}),m.jsx("span",{className:"cat-count",children:S})]},_))})]})]}),h>0&&m.jsxs("section",{className:"detail-section",children:[m.jsx("h3",{children:"Tokens"}),m.jsxs("div",{className:"tokens-grid",children:[m.jsxs("div",{children:[m.jsx("span",{className:"k",children:"in"}),m.jsx("b",{children:e.usage.inputTokens.toLocaleString()})]}),m.jsxs("div",{children:[m.jsx("span",{className:"k",children:"out"}),m.jsx("b",{children:e.usage.outputTokens.toLocaleString()})]}),m.jsxs("div",{children:[m.jsx("span",{className:"k",children:"cache r"}),m.jsx("b",{children:e.usage.cacheReadTokens.toLocaleString()})]}),m.jsxs("div",{children:[m.jsx("span",{className:"k",children:"cache c"}),m.jsx("b",{children:e.usage.cacheCreateTokens.toLocaleString()})]})]})]}),m.jsxs("section",{className:"detail-section",children:[m.jsx("h3",{children:"Identity"}),m.jsxs("div",{children:[e.cwd&&m.jsxs("div",{className:"row",children:[m.jsx("span",{className:"k",children:"cwd"}),m.jsx("span",{className:"v",title:e.cwd,children:e.cwd})]}),m.jsxs("div",{className:"row",children:[m.jsx("span",{className:"k",children:"session"}),m.jsxs("span",{className:"v",children:[e.sessionId.slice(0,12),"…"]})]}),e.parentId&&m.jsxs("div",{className:"row",children:[m.jsx("span",{className:"k",children:"parent"}),m.jsxs("span",{className:"v",children:[e.parentId.slice(0,12),"…"]})]})]})]}),e.prompts.length>0&&m.jsxs("section",{className:"detail-section",children:[m.jsxs("h3",{children:["Prompts ",m.jsx("span",{className:"section-count",children:e.prompts.length})]}),m.jsx("div",{className:"prompts",children:e.prompts.slice().reverse().map((_,S)=>m.jsxs("div",{className:"prompt-entry",children:[m.jsx("div",{className:"prompt-time",children:new Date(_.at).toLocaleTimeString()}),m.jsx("div",{className:"prompt-text",children:_.text})]},S))})]}),m.jsxs("section",{className:"detail-section",children:[m.jsxs("h3",{children:["Tool calls ",m.jsx("span",{className:"section-count",children:e.tools.length})]}),e.tools.length===0&&m.jsx("div",{className:"empty",children:"No tool calls yet."}),m.jsx("div",{children:e.tools.slice().reverse().map(_=>m.jsx(a4,{t:_,now:n,onClick:()=>i(_.id)},_.id))})]})]})}function o4({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 m.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${Be(s)} (${u.toFixed(0)}%)`},o)};return m.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 a4({t:e,now:n,onClick:i}){const s=e.endedAt==null?"inflight":e.ok===!1?"err":"done",o=(e.endedAt??n)-e.startedAt,l=e.endedAt==null?"…":o<1e3?`${o}ms`:`${(o/1e3).toFixed(1)}s`;return m.jsxs("button",{className:"tool clickable",title:e.inputPreview||e.name,onClick:i,children:[m.jsxs("span",{className:"name",children:[m.jsx("span",{className:`status-dot ${s}`}),e.name]}),m.jsx("span",{style:{color:"var(--muted)"},children:l})]})}const l4="1",Bk="agent-dag.schema",u4=["agent-dag.layout","agent-dag.viewport"];function c4(e,n=l4){let i=null;try{i=e.getItem(Bk)}catch{return[]}if(i===n)return[];const s=[];if(i!==null)for(const o of u4)try{e.getItem(o)!==null&&(e.removeItem(o),s.push(o))}catch{}try{e.setItem(Bk,n)}catch{}return s}try{c4(window.localStorage)}catch{}const d4=lT.createRoot(document.getElementById("root"));d4.render(m.jsx(e4,{}));