agent-dag 1.33.66 → 1.33.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -56,7 +56,7 @@ Error generating stack: `+w.message+`
|
|
|
56
56
|
*/var sw;function pR(){if(sw)return Wc;sw=1;var e=sa(),n=hR();function r(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var s=typeof Object.is=="function"?Object.is:r,o=n.useSyncExternalStore,l=e.useRef,u=e.useEffect,c=e.useMemo,p=e.useDebugValue;return Wc.useSyncExternalStoreWithSelector=function(h,f,m,y,x){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(!k){if(k=!0,N=O,O=y(O),x!==void 0&&_.hasValue){var L=_.value;if(x(L,O))return j=L}return j=O}if(L=j,s(N,O))return L;var B=y(O);return x!==void 0&&x(L,B)?(N=O,L):(N=O,j=B)}var k=!1,N,j,P=m===void 0?null:m;return[function(){return b(f())},P===null?void 0:function(){return b(P())}]},[f,m,y,x]);var S=o(h,C[0],C[1]);return u(function(){_.hasValue=!0,_.value=S},[S]),p(S),S},Wc}var ow;function mR(){return ow||(ow=1,Vc.exports=pR()),Vc.exports}var gR=mR();const vR=Xg(gR),yR={},aw=e=>{let n;const r=new Set,s=(f,m)=>{const y=typeof f=="function"?f(n):f;if(!Object.is(y,n)){const x=n;n=m??(typeof y!="object"||y===null)?y:Object.assign({},n,y),r.forEach(C=>C(n,x))}},o=()=>n,p={setState:s,getState:o,getInitialState:()=>h,subscribe:f=>(r.add(f),()=>r.delete(f)),destroy:()=>{(yR?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}},h=n=e(s,o,p);return p},wR=e=>e?aw(e):aw,{useDebugValue:xR}=ae,{useSyncExternalStoreWithSelector:_R}=vR,SR=e=>e;function Wk(e,n=SR,r){const s=_R(e.subscribe,e.getState,e.getServerState||e.getInitialState,n,r);return xR(s),s}const lw=(e,n)=>{const r=wR(e),s=(o,l=n)=>Wk(r,o,l);return Object.assign(s,r),s},bR=(e,n)=>e?lw(e,n):lw;function Et(e,n){if(Object.is(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(const[s,o]of e)if(!Object.is(o,n.get(s)))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(const s of e)if(!n.has(s))return!1;return!0}const r=Object.keys(e);if(r.length!==Object.keys(n).length)return!1;for(const s of r)if(!Object.prototype.hasOwnProperty.call(n,s)||!Object.is(e[s],n[s]))return!1;return!0}var kR={value:()=>{}};function Gl(){for(var e=0,n=arguments.length,r={},s;e<n;++e){if(!(s=arguments[e]+"")||s in r||/[\s.]/.test(s))throw new Error("illegal type: "+s);r[s]=[]}return new Al(r)}function Al(e){this._=e}function ER(e,n){return e.trim().split(/^|\s+/).map(function(r){var s="",o=r.indexOf(".");if(o>=0&&(s=r.slice(o+1),r=r.slice(0,o)),r&&!n.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:s}})}Al.prototype=Gl.prototype={constructor:Al,on:function(e,n){var r=this._,s=ER(e+"",r),o,l=-1,u=s.length;if(arguments.length<2){for(;++l<u;)if((o=(e=s[l]).type)&&(o=NR(r[o],e.name)))return o;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++l<u;)if(o=(e=s[l]).type)r[o]=uw(r[o],e.name,n);else if(n==null)for(o in r)r[o]=uw(r[o],e.name,null);return this},copy:function(){var e={},n=this._;for(var r in n)e[r]=n[r].slice();return new Al(e)},call:function(e,n){if((o=arguments.length-2)>0)for(var r=new Array(o),s=0,o,l;s<o;++s)r[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(l=this._[e],s=0,o=l.length;s<o;++s)l[s].value.apply(n,r)},apply:function(e,n,r){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var s=this._[e],o=0,l=s.length;o<l;++o)s[o].value.apply(n,r)}};function NR(e,n){for(var r=0,s=e.length,o;r<s;++r)if((o=e[r]).name===n)return o.value}function uw(e,n,r){for(var s=0,o=e.length;s<o;++s)if(e[s].name===n){e[s]=kR,e=e.slice(0,s).concat(e.slice(s+1));break}return r!=null&&e.push({name:n,value:r}),e}var Cg="http://www.w3.org/1999/xhtml";const cw={svg:"http://www.w3.org/2000/svg",xhtml:Cg,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Yl(e){var n=e+="",r=n.indexOf(":");return r>=0&&(n=e.slice(0,r))!=="xmlns"&&(e=e.slice(r+1)),cw.hasOwnProperty(n)?{space:cw[n],local:e}:e}function CR(e){return function(){var n=this.ownerDocument,r=this.namespaceURI;return r===Cg&&n.documentElement.namespaceURI===Cg?n.createElement(e):n.createElementNS(r,e)}}function jR(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Gk(e){var n=Yl(e);return(n.local?jR:CR)(n)}function RR(){}function Qg(e){return e==null?RR:function(){return this.querySelector(e)}}function TR(e){typeof e!="function"&&(e=Qg(e));for(var n=this._groups,r=n.length,s=new Array(r),o=0;o<r;++o)for(var l=n[o],u=l.length,c=s[o]=new Array(u),p,h,f=0;f<u;++f)(p=l[f])&&(h=e.call(p,p.__data__,f,l))&&("__data__"in p&&(h.__data__=p.__data__),c[f]=h);return new yn(s,this._parents)}function AR(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function IR(){return[]}function Yk(e){return e==null?IR:function(){return this.querySelectorAll(e)}}function MR(e){return function(){return AR(e.apply(this,arguments))}}function PR(e){typeof e=="function"?e=MR(e):e=Yk(e);for(var n=this._groups,r=n.length,s=[],o=[],l=0;l<r;++l)for(var u=n[l],c=u.length,p,h=0;h<c;++h)(p=u[h])&&(s.push(e.call(p,p.__data__,h,u)),o.push(p));return new yn(s,o)}function Kk(e){return function(){return this.matches(e)}}function Xk(e){return function(n){return n.matches(e)}}var OR=Array.prototype.find;function qR(e){return function(){return OR.call(this.children,e)}}function LR(){return this.firstElementChild}function $R(e){return this.select(e==null?LR:qR(typeof e=="function"?e:Xk(e)))}var DR=Array.prototype.filter;function FR(){return Array.from(this.children)}function zR(e){return function(){return DR.call(this.children,e)}}function BR(e){return this.selectAll(e==null?FR:zR(typeof e=="function"?e:Xk(e)))}function UR(e){typeof e!="function"&&(e=Kk(e));for(var n=this._groups,r=n.length,s=new Array(r),o=0;o<r;++o)for(var l=n[o],u=l.length,c=s[o]=[],p,h=0;h<u;++h)(p=l[h])&&e.call(p,p.__data__,h,l)&&c.push(p);return new yn(s,this._parents)}function Qk(e){return new Array(e.length)}function HR(){return new yn(this._enter||this._groups.map(Qk),this._parents)}function Ol(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}Ol.prototype={constructor:Ol,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 VR(e){return function(){return e}}function WR(e,n,r,s,o,l){for(var u=0,c,p=n.length,h=l.length;u<h;++u)(c=n[u])?(c.__data__=l[u],s[u]=c):r[u]=new Ol(e,l[u]);for(;u<p;++u)(c=n[u])&&(o[u]=c)}function GR(e,n,r,s,o,l,u){var c,p,h=new Map,f=n.length,m=l.length,y=new Array(f),x;for(c=0;c<f;++c)(p=n[c])&&(y[c]=x=u.call(p,p.__data__,c,n)+"",h.has(x)?o[c]=p:h.set(x,p));for(c=0;c<m;++c)x=u.call(e,l[c],c,l)+"",(p=h.get(x))?(s[c]=p,p.__data__=l[c],h.delete(x)):r[c]=new Ol(e,l[c]);for(c=0;c<f;++c)(p=n[c])&&h.get(y[c])===p&&(o[c]=p)}function YR(e){return e.__data__}function KR(e,n){if(!arguments.length)return Array.from(this,YR);var r=n?GR:WR,s=this._parents,o=this._groups;typeof e!="function"&&(e=VR(e));for(var l=o.length,u=new Array(l),c=new Array(l),p=new Array(l),h=0;h<l;++h){var f=s[h],m=o[h],y=m.length,x=XR(e.call(f,f&&f.__data__,h,s)),C=x.length,_=c[h]=new Array(C),S=u[h]=new Array(C),b=p[h]=new Array(y);r(f,m,_,S,b,x,n);for(var k=0,N=0,j,P;k<C;++k)if(j=_[k]){for(k>=N&&(N=k+1);!(P=S[N])&&++N<C;);j._next=P||null}}return u=new yn(u,s),u._enter=c,u._exit=p,u}function XR(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function QR(){return new yn(this._exit||this._groups.map(Qk),this._parents)}function ZR(e,n,r){var s=this.enter(),o=this,l=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),n!=null&&(o=n(o),o&&(o=o.selection())),r==null?l.remove():r(l),s&&o?s.merge(o).order():o}function JR(e){for(var n=e.selection?e.selection():e,r=this._groups,s=n._groups,o=r.length,l=s.length,u=Math.min(o,l),c=new Array(o),p=0;p<u;++p)for(var h=r[p],f=s[p],m=h.length,y=c[p]=new Array(m),x,C=0;C<m;++C)(x=h[C]||f[C])&&(y[C]=x);for(;p<o;++p)c[p]=r[p];return new yn(c,this._parents)}function eT(){for(var e=this._groups,n=-1,r=e.length;++n<r;)for(var s=e[n],o=s.length-1,l=s[o],u;--o>=0;)(u=s[o])&&(l&&u.compareDocumentPosition(l)^4&&l.parentNode.insertBefore(u,l),l=u);return this}function tT(e){e||(e=nT);function n(m,y){return m&&y?e(m.__data__,y.__data__):!m-!y}for(var r=this._groups,s=r.length,o=new Array(s),l=0;l<s;++l){for(var u=r[l],c=u.length,p=o[l]=new Array(c),h,f=0;f<c;++f)(h=u[f])&&(p[f]=h);p.sort(n)}return new yn(o,this._parents).order()}function nT(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function rT(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function iT(){return Array.from(this)}function sT(){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var s=e[n],o=0,l=s.length;o<l;++o){var u=s[o];if(u)return u}return null}function oT(){let e=0;for(const n of this)++e;return e}function aT(){return!this.node()}function lT(e){for(var n=this._groups,r=0,s=n.length;r<s;++r)for(var o=n[r],l=0,u=o.length,c;l<u;++l)(c=o[l])&&e.call(c,c.__data__,l,o);return this}function uT(e){return function(){this.removeAttribute(e)}}function cT(e){return function(){this.removeAttributeNS(e.space,e.local)}}function dT(e,n){return function(){this.setAttribute(e,n)}}function fT(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function hT(e,n){return function(){var r=n.apply(this,arguments);r==null?this.removeAttribute(e):this.setAttribute(e,r)}}function pT(e,n){return function(){var r=n.apply(this,arguments);r==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,r)}}function mT(e,n){var r=Yl(e);if(arguments.length<2){var s=this.node();return r.local?s.getAttributeNS(r.space,r.local):s.getAttribute(r)}return this.each((n==null?r.local?cT:uT:typeof n=="function"?r.local?pT:hT:r.local?fT:dT)(r,n))}function Zk(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function gT(e){return function(){this.style.removeProperty(e)}}function vT(e,n,r){return function(){this.style.setProperty(e,n,r)}}function yT(e,n,r){return function(){var s=n.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,r)}}function wT(e,n,r){return arguments.length>1?this.each((n==null?gT:typeof n=="function"?yT:vT)(e,n,r??"")):Gs(this.node(),e)}function Gs(e,n){return e.style.getPropertyValue(n)||Zk(e).getComputedStyle(e,null).getPropertyValue(n)}function xT(e){return function(){delete this[e]}}function _T(e,n){return function(){this[e]=n}}function ST(e,n){return function(){var r=n.apply(this,arguments);r==null?delete this[e]:this[e]=r}}function bT(e,n){return arguments.length>1?this.each((n==null?xT:typeof n=="function"?ST:_T)(e,n)):this.node()[e]}function Jk(e){return e.trim().split(/^|\s+/)}function Zg(e){return e.classList||new eE(e)}function eE(e){this._node=e,this._names=Jk(e.getAttribute("class")||"")}eE.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 tE(e,n){for(var r=Zg(e),s=-1,o=n.length;++s<o;)r.add(n[s])}function nE(e,n){for(var r=Zg(e),s=-1,o=n.length;++s<o;)r.remove(n[s])}function kT(e){return function(){tE(this,e)}}function ET(e){return function(){nE(this,e)}}function NT(e,n){return function(){(n.apply(this,arguments)?tE:nE)(this,e)}}function CT(e,n){var r=Jk(e+"");if(arguments.length<2){for(var s=Zg(this.node()),o=-1,l=r.length;++o<l;)if(!s.contains(r[o]))return!1;return!0}return this.each((typeof n=="function"?NT:n?kT:ET)(r,n))}function jT(){this.textContent=""}function RT(e){return function(){this.textContent=e}}function TT(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function AT(e){return arguments.length?this.each(e==null?jT:(typeof e=="function"?TT:RT)(e)):this.node().textContent}function IT(){this.innerHTML=""}function MT(e){return function(){this.innerHTML=e}}function PT(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function OT(e){return arguments.length?this.each(e==null?IT:(typeof e=="function"?PT:MT)(e)):this.node().innerHTML}function qT(){this.nextSibling&&this.parentNode.appendChild(this)}function LT(){return this.each(qT)}function $T(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function DT(){return this.each($T)}function FT(e){var n=typeof e=="function"?e:Gk(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function zT(){return null}function BT(e,n){var r=typeof e=="function"?e:Gk(e),s=n==null?zT:typeof n=="function"?n:Qg(n);return this.select(function(){return this.insertBefore(r.apply(this,arguments),s.apply(this,arguments)||null)})}function UT(){var e=this.parentNode;e&&e.removeChild(this)}function HT(){return this.each(UT)}function VT(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function WT(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function GT(e){return this.select(e?WT:VT)}function YT(e){return arguments.length?this.property("__data__",e):this.node().__data__}function KT(e){return function(n){e.call(this,n,this.__data__)}}function XT(e){return e.trim().split(/^|\s+/).map(function(n){var r="",s=n.indexOf(".");return s>=0&&(r=n.slice(s+1),n=n.slice(0,s)),{type:n,name:r}})}function QT(e){return function(){var n=this.__on;if(n){for(var r=0,s=-1,o=n.length,l;r<o;++r)l=n[r],(!e.type||l.type===e.type)&&l.name===e.name?this.removeEventListener(l.type,l.listener,l.options):n[++s]=l;++s?n.length=s:delete this.__on}}}function ZT(e,n,r){return function(){var s=this.__on,o,l=KT(n);if(s){for(var u=0,c=s.length;u<c;++u)if((o=s[u]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=l,o.options=r),o.value=n;return}}this.addEventListener(e.type,l,r),o={type:e.type,name:e.name,value:n,listener:l,options:r},s?s.push(o):this.__on=[o]}}function JT(e,n,r){var s=XT(e+""),o,l=s.length,u;if(arguments.length<2){var c=this.node().__on;if(c){for(var p=0,h=c.length,f;p<h;++p)for(o=0,f=c[p];o<l;++o)if((u=s[o]).type===f.type&&u.name===f.name)return f.value}return}for(c=n?ZT:QT,o=0;o<l;++o)this.each(c(s[o],n,r));return this}function rE(e,n,r){var s=Zk(e),o=s.CustomEvent;typeof o=="function"?o=new o(n,r):(o=s.document.createEvent("Event"),r?(o.initEvent(n,r.bubbles,r.cancelable),o.detail=r.detail):o.initEvent(n,!1,!1)),e.dispatchEvent(o)}function e2(e,n){return function(){return rE(this,e,n)}}function t2(e,n){return function(){return rE(this,e,n.apply(this,arguments))}}function n2(e,n){return this.each((typeof n=="function"?t2:e2)(e,n))}function*r2(){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var s=e[n],o=0,l=s.length,u;o<l;++o)(u=s[o])&&(yield u)}var iE=[null];function yn(e,n){this._groups=e,this._parents=n}function oa(){return new yn([[document.documentElement]],iE)}function i2(){return this}yn.prototype=oa.prototype={constructor:yn,select:TR,selectAll:PR,selectChild:$R,selectChildren:BR,filter:UR,data:KR,enter:HR,exit:QR,join:ZR,merge:JR,selection:i2,order:eT,sort:tT,call:rT,nodes:iT,node:sT,size:oT,empty:aT,each:lT,attr:mT,style:wT,property:bT,classed:CT,text:AT,html:OT,raise:LT,lower:DT,append:FT,insert:BT,remove:HT,clone:GT,datum:YT,on:JT,dispatch:n2,[Symbol.iterator]:r2};function In(e){return typeof e=="string"?new yn([[document.querySelector(e)]],[document.documentElement]):new yn([[e]],iE)}function s2(e){let n;for(;n=e.sourceEvent;)e=n;return e}function Kn(e,n){if(e=s2(e),n===void 0&&(n=e.currentTarget),n){var r=n.ownerSVGElement||n;if(r.createSVGPoint){var s=r.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,s=s.matrixTransform(n.getScreenCTM().inverse()),[s.x,s.y]}if(n.getBoundingClientRect){var o=n.getBoundingClientRect();return[e.clientX-o.left-n.clientLeft,e.clientY-o.top-n.clientTop]}}return[e.pageX,e.pageY]}const o2={passive:!1},Xo={capture:!0,passive:!1};function Kc(e){e.stopImmediatePropagation()}function Us(e){e.preventDefault(),e.stopImmediatePropagation()}function sE(e){var n=e.document.documentElement,r=In(e).on("dragstart.drag",Us,Xo);"onselectstart"in n?r.on("selectstart.drag",Us,Xo):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function oE(e,n){var r=e.document.documentElement,s=In(e).on("dragstart.drag",null);n&&(s.on("click.drag",Us,Xo),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in r?s.on("selectstart.drag",null):(r.style.MozUserSelect=r.__noselect,delete r.__noselect)}const gl=e=>()=>e;function jg(e,{sourceEvent:n,subject:r,target:s,identifier:o,active:l,x:u,y:c,dx:p,dy:h,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:r,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:l,enumerable:!0,configurable:!0},x:{value:u,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:f}})}jg.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function a2(e){return!e.ctrlKey&&!e.button}function l2(){return this.parentNode}function u2(e,n){return n??{x:e.x,y:e.y}}function c2(){return navigator.maxTouchPoints||"ontouchstart"in this}function d2(){var e=a2,n=l2,r=u2,s=c2,o={},l=Gl("start","drag","end"),u=0,c,p,h,f,m=0;function y(j){j.on("mousedown.drag",x).filter(s).on("touchstart.drag",S).on("touchmove.drag",b,o2).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(j,P){if(!(f||!e.call(this,j,P))){var O=N(this,n.call(this,j,P),j,P,"mouse");O&&(In(j.view).on("mousemove.drag",C,Xo).on("mouseup.drag",_,Xo),sE(j.view),Kc(j),h=!1,c=j.clientX,p=j.clientY,O("start",j))}}function C(j){if(Us(j),!h){var P=j.clientX-c,O=j.clientY-p;h=P*P+O*O>m}o.mouse("drag",j)}function _(j){In(j.view).on("mousemove.drag mouseup.drag",null),oE(j.view,h),Us(j),o.mouse("end",j)}function S(j,P){if(e.call(this,j,P)){var O=j.changedTouches,L=n.call(this,j,P),B=O.length,T,M;for(T=0;T<B;++T)(M=N(this,L,j,P,O[T].identifier,O[T]))&&(Kc(j),M("start",j,O[T]))}}function b(j){var P=j.changedTouches,O=P.length,L,B;for(L=0;L<O;++L)(B=o[P[L].identifier])&&(Us(j),B("drag",j,P[L]))}function k(j){var P=j.changedTouches,O=P.length,L,B;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),L=0;L<O;++L)(B=o[P[L].identifier])&&(Kc(j),B("end",j,P[L]))}function N(j,P,O,L,B,T){var M=l.copy(),q=Kn(T||O,P),Y,X,I;if((I=r.call(j,new jg("beforestart",{sourceEvent:O,target:y,identifier:B,active:u,x:q[0],y:q[1],dx:0,dy:0,dispatch:M}),L))!=null)return Y=I.x-q[0]||0,X=I.y-q[1]||0,function H(U,ne,J){var F=q,G;switch(U){case"start":o[B]=H,G=u++;break;case"end":delete o[B],--u;case"drag":q=Kn(J||ne,P),G=u;break}M.call(U,j,new jg(U,{sourceEvent:ne,subject:I,target:y,identifier:B,active:G,x:q[0]+Y,y:q[1]+X,dx:q[0]-F[0],dy:q[1]-F[1],dispatch:M}),L)}}return y.filter=function(j){return arguments.length?(e=typeof j=="function"?j:gl(!!j),y):e},y.container=function(j){return arguments.length?(n=typeof j=="function"?j:gl(j),y):n},y.subject=function(j){return arguments.length?(r=typeof j=="function"?j:gl(j),y):r},y.touchable=function(j){return arguments.length?(s=typeof j=="function"?j:gl(!!j),y):s},y.on=function(){var j=l.on.apply(l,arguments);return j===l?y:j},y.clickDistance=function(j){return arguments.length?(m=(j=+j)*j,y):Math.sqrt(m)},y}function Jg(e,n,r){e.prototype=n.prototype=r,r.constructor=e}function aE(e,n){var r=Object.create(e.prototype);for(var s in n)r[s]=n[s];return r}function aa(){}var Qo=.7,ql=1/Qo,Hs="\\s*([+-]?\\d+)\\s*",Zo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",dr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",f2=/^#([0-9a-f]{3,8})$/,h2=new RegExp(`^rgb\\(${Hs},${Hs},${Hs}\\)$`),p2=new RegExp(`^rgb\\(${dr},${dr},${dr}\\)$`),m2=new RegExp(`^rgba\\(${Hs},${Hs},${Hs},${Zo}\\)$`),g2=new RegExp(`^rgba\\(${dr},${dr},${dr},${Zo}\\)$`),v2=new RegExp(`^hsl\\(${Zo},${dr},${dr}\\)$`),y2=new RegExp(`^hsla\\(${Zo},${dr},${dr},${Zo}\\)$`),dw={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};Jg(aa,Jo,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:fw,formatHex:fw,formatHex8:w2,formatHsl:x2,formatRgb:hw,toString:hw});function fw(){return this.rgb().formatHex()}function w2(){return this.rgb().formatHex8()}function x2(){return lE(this).formatHsl()}function hw(){return this.rgb().formatRgb()}function Jo(e){var n,r;return e=(e+"").trim().toLowerCase(),(n=f2.exec(e))?(r=n[1].length,n=parseInt(n[1],16),r===6?pw(n):r===3?new sn(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):r===8?vl(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):r===4?vl(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=h2.exec(e))?new sn(n[1],n[2],n[3],1):(n=p2.exec(e))?new sn(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=m2.exec(e))?vl(n[1],n[2],n[3],n[4]):(n=g2.exec(e))?vl(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=v2.exec(e))?vw(n[1],n[2]/100,n[3]/100,1):(n=y2.exec(e))?vw(n[1],n[2]/100,n[3]/100,n[4]):dw.hasOwnProperty(e)?pw(dw[e]):e==="transparent"?new sn(NaN,NaN,NaN,0):null}function pw(e){return new sn(e>>16&255,e>>8&255,e&255,1)}function vl(e,n,r,s){return s<=0&&(e=n=r=NaN),new sn(e,n,r,s)}function _2(e){return e instanceof aa||(e=Jo(e)),e?(e=e.rgb(),new sn(e.r,e.g,e.b,e.opacity)):new sn}function Rg(e,n,r,s){return arguments.length===1?_2(e):new sn(e,n,r,s??1)}function sn(e,n,r,s){this.r=+e,this.g=+n,this.b=+r,this.opacity=+s}Jg(sn,Rg,aE(aa,{brighter(e){return e=e==null?ql:Math.pow(ql,e),new sn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Qo:Math.pow(Qo,e),new sn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new sn(Xi(this.r),Xi(this.g),Xi(this.b),Ll(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:mw,formatHex:mw,formatHex8:S2,formatRgb:gw,toString:gw}));function mw(){return`#${Yi(this.r)}${Yi(this.g)}${Yi(this.b)}`}function S2(){return`#${Yi(this.r)}${Yi(this.g)}${Yi(this.b)}${Yi((isNaN(this.opacity)?1:this.opacity)*255)}`}function gw(){const e=Ll(this.opacity);return`${e===1?"rgb(":"rgba("}${Xi(this.r)}, ${Xi(this.g)}, ${Xi(this.b)}${e===1?")":`, ${e})`}`}function Ll(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Xi(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Yi(e){return e=Xi(e),(e<16?"0":"")+e.toString(16)}function vw(e,n,r,s){return s<=0?e=n=r=NaN:r<=0||r>=1?e=n=NaN:n<=0&&(e=NaN),new Xn(e,n,r,s)}function lE(e){if(e instanceof Xn)return new Xn(e.h,e.s,e.l,e.opacity);if(e instanceof aa||(e=Jo(e)),!e)return new Xn;if(e instanceof Xn)return e;e=e.rgb();var n=e.r/255,r=e.g/255,s=e.b/255,o=Math.min(n,r,s),l=Math.max(n,r,s),u=NaN,c=l-o,p=(l+o)/2;return c?(n===l?u=(r-s)/c+(r<s)*6:r===l?u=(s-n)/c+2:u=(n-r)/c+4,c/=p<.5?l+o:2-l-o,u*=60):c=p>0&&p<1?0:u,new Xn(u,c,p,e.opacity)}function b2(e,n,r,s){return arguments.length===1?lE(e):new Xn(e,n,r,s??1)}function Xn(e,n,r,s){this.h=+e,this.s=+n,this.l=+r,this.opacity=+s}Jg(Xn,b2,aE(aa,{brighter(e){return e=e==null?ql:Math.pow(ql,e),new Xn(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Qo:Math.pow(Qo,e),new Xn(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,n=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,s=r+(r<.5?r:1-r)*n,o=2*r-s;return new sn(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 Xn(yw(this.h),yl(this.s),yl(this.l),Ll(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=Ll(this.opacity);return`${e===1?"hsl(":"hsla("}${yw(this.h)}, ${yl(this.s)*100}%, ${yl(this.l)*100}%${e===1?")":`, ${e})`}`}}));function yw(e){return e=(e||0)%360,e<0?e+360:e}function yl(e){return Math.max(0,Math.min(1,e||0))}function Xc(e,n,r){return(e<60?n+(r-n)*e/60:e<180?r:e<240?n+(r-n)*(240-e)/60:n)*255}const uE=e=>()=>e;function k2(e,n){return function(r){return e+r*n}}function E2(e,n,r){return e=Math.pow(e,r),n=Math.pow(n,r)-e,r=1/r,function(s){return Math.pow(e+s*n,r)}}function N2(e){return(e=+e)==1?cE:function(n,r){return r-n?E2(n,r,e):uE(isNaN(n)?r:n)}}function cE(e,n){var r=n-e;return r?k2(e,r):uE(isNaN(e)?n:e)}const ww=(function e(n){var r=N2(n);function s(o,l){var u=r((o=Rg(o)).r,(l=Rg(l)).r),c=r(o.g,l.g),p=r(o.b,l.b),h=cE(o.opacity,l.opacity);return function(f){return o.r=u(f),o.g=c(f),o.b=p(f),o.opacity=h(f),o+""}}return s.gamma=e,s})(1);function mi(e,n){return e=+e,n=+n,function(r){return e*(1-r)+n*r}}var Tg=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Qc=new RegExp(Tg.source,"g");function C2(e){return function(){return e}}function j2(e){return function(n){return e(n)+""}}function R2(e,n){var r=Tg.lastIndex=Qc.lastIndex=0,s,o,l,u=-1,c=[],p=[];for(e=e+"",n=n+"";(s=Tg.exec(e))&&(o=Qc.exec(n));)(l=o.index)>r&&(l=n.slice(r,l),c[u]?c[u]+=l:c[++u]=l),(s=s[0])===(o=o[0])?c[u]?c[u]+=o:c[++u]=o:(c[++u]=null,p.push({i:u,x:mi(s,o)})),r=Qc.lastIndex;return r<n.length&&(l=n.slice(r),c[u]?c[u]+=l:c[++u]=l),c.length<2?p[0]?j2(p[0].x):C2(n):(n=p.length,function(h){for(var f=0,m;f<n;++f)c[(m=p[f]).i]=m.x(h);return c.join("")})}var xw=180/Math.PI,Ag={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function dE(e,n,r,s,o,l){var u,c,p;return(u=Math.sqrt(e*e+n*n))&&(e/=u,n/=u),(p=e*r+n*s)&&(r-=e*p,s-=n*p),(c=Math.sqrt(r*r+s*s))&&(r/=c,s/=c,p/=c),e*s<n*r&&(e=-e,n=-n,p=-p,u=-u),{translateX:o,translateY:l,rotate:Math.atan2(n,e)*xw,skewX:Math.atan(p)*xw,scaleX:u,scaleY:c}}var wl;function T2(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?Ag:dE(n.a,n.b,n.c,n.d,n.e,n.f)}function A2(e){return e==null||(wl||(wl=document.createElementNS("http://www.w3.org/2000/svg","g")),wl.setAttribute("transform",e),!(e=wl.transform.baseVal.consolidate()))?Ag:(e=e.matrix,dE(e.a,e.b,e.c,e.d,e.e,e.f))}function fE(e,n,r,s){function o(h){return h.length?h.pop()+" ":""}function l(h,f,m,y,x,C){if(h!==m||f!==y){var _=x.push("translate(",null,n,null,r);C.push({i:_-4,x:mi(h,m)},{i:_-2,x:mi(f,y)})}else(m||y)&&x.push("translate("+m+n+y+r)}function u(h,f,m,y){h!==f?(h-f>180?f+=360:f-h>180&&(h+=360),y.push({i:m.push(o(m)+"rotate(",null,s)-2,x:mi(h,f)})):f&&m.push(o(m)+"rotate("+f+s)}function c(h,f,m,y){h!==f?y.push({i:m.push(o(m)+"skewX(",null,s)-2,x:mi(h,f)}):f&&m.push(o(m)+"skewX("+f+s)}function p(h,f,m,y,x,C){if(h!==m||f!==y){var _=x.push(o(x)+"scale(",null,",",null,")");C.push({i:_-4,x:mi(h,m)},{i:_-2,x:mi(f,y)})}else(m!==1||y!==1)&&x.push(o(x)+"scale("+m+","+y+")")}return function(h,f){var m=[],y=[];return h=e(h),f=e(f),l(h.translateX,h.translateY,f.translateX,f.translateY,m,y),u(h.rotate,f.rotate,m,y),c(h.skewX,f.skewX,m,y),p(h.scaleX,h.scaleY,f.scaleX,f.scaleY,m,y),h=f=null,function(x){for(var C=-1,_=y.length,S;++C<_;)m[(S=y[C]).i]=S.x(x);return m.join("")}}}var I2=fE(T2,"px, ","px)","deg)"),M2=fE(A2,", ",")",")"),P2=1e-12;function _w(e){return((e=Math.exp(e))+1/e)/2}function O2(e){return((e=Math.exp(e))-1/e)/2}function q2(e){return((e=Math.exp(2*e))-1)/(e+1)}const L2=(function e(n,r,s){function o(l,u){var c=l[0],p=l[1],h=l[2],f=u[0],m=u[1],y=u[2],x=f-c,C=m-p,_=x*x+C*C,S,b;if(_<P2)b=Math.log(y/h)/n,S=function(L){return[c+L*x,p+L*C,h*Math.exp(n*L*b)]};else{var k=Math.sqrt(_),N=(y*y-h*h+s*_)/(2*h*r*k),j=(y*y-h*h-s*_)/(2*y*r*k),P=Math.log(Math.sqrt(N*N+1)-N),O=Math.log(Math.sqrt(j*j+1)-j);b=(O-P)/n,S=function(L){var B=L*b,T=_w(P),M=h/(r*k)*(T*q2(n*B+P)-O2(P));return[c+M*x,p+M*C,h*T/_w(n*B+P)]}}return S.duration=b*1e3*n/Math.SQRT2,S}return o.rho=function(l){var u=Math.max(.001,+l),c=u*u,p=c*c;return e(u,c,p)},o})(Math.SQRT2,2,4);var Ys=0,Ho=0,Do=0,hE=1e3,$l,Vo,Dl=0,Ji=0,Kl=0,ea=typeof performance=="object"&&performance.now?performance:Date,pE=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ev(){return Ji||(pE($2),Ji=ea.now()+Kl)}function $2(){Ji=0}function Fl(){this._call=this._time=this._next=null}Fl.prototype=mE.prototype={constructor:Fl,restart:function(e,n,r){if(typeof e!="function")throw new TypeError("callback is not a function");r=(r==null?ev():+r)+(n==null?0:+n),!this._next&&Vo!==this&&(Vo?Vo._next=this:$l=this,Vo=this),this._call=e,this._time=r,Ig()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ig())}};function mE(e,n,r){var s=new Fl;return s.restart(e,n,r),s}function D2(){ev(),++Ys;for(var e=$l,n;e;)(n=Ji-e._time)>=0&&e._call.call(void 0,n),e=e._next;--Ys}function Sw(){Ji=(Dl=ea.now())+Kl,Ys=Ho=0;try{D2()}finally{Ys=0,z2(),Ji=0}}function F2(){var e=ea.now(),n=e-Dl;n>hE&&(Kl-=n,Dl=e)}function z2(){for(var e,n=$l,r,s=1/0;n;)n._call?(s>n._time&&(s=n._time),e=n,n=n._next):(r=n._next,n._next=null,n=e?e._next=r:$l=r);Vo=e,Ig(s)}function Ig(e){if(!Ys){Ho&&(Ho=clearTimeout(Ho));var n=e-Ji;n>24?(e<1/0&&(Ho=setTimeout(Sw,e-ea.now()-Kl)),Do&&(Do=clearInterval(Do))):(Do||(Dl=ea.now(),Do=setInterval(F2,hE)),Ys=1,pE(Sw))}}function bw(e,n,r){var s=new Fl;return n=n==null?0:+n,s.restart(o=>{s.stop(),e(o+n)},n,r),s}var B2=Gl("start","end","cancel","interrupt"),U2=[],gE=0,kw=1,Mg=2,Il=3,Ew=4,Pg=5,Ml=6;function Xl(e,n,r,s,o,l){var u=e.__transition;if(!u)e.__transition={};else if(r in u)return;H2(e,r,{name:n,index:s,group:o,on:B2,tween:U2,time:l.time,delay:l.delay,duration:l.duration,ease:l.ease,timer:null,state:gE})}function tv(e,n){var r=Jn(e,n);if(r.state>gE)throw new Error("too late; already scheduled");return r}function fr(e,n){var r=Jn(e,n);if(r.state>Il)throw new Error("too late; already running");return r}function Jn(e,n){var r=e.__transition;if(!r||!(r=r[n]))throw new Error("transition not found");return r}function H2(e,n,r){var s=e.__transition,o;s[n]=r,r.timer=mE(l,0,r.time);function l(h){r.state=kw,r.timer.restart(u,r.delay,r.time),r.delay<=h&&u(h-r.delay)}function u(h){var f,m,y,x;if(r.state!==kw)return p();for(f in s)if(x=s[f],x.name===r.name){if(x.state===Il)return bw(u);x.state===Ew?(x.state=Ml,x.timer.stop(),x.on.call("interrupt",e,e.__data__,x.index,x.group),delete s[f]):+f<n&&(x.state=Ml,x.timer.stop(),x.on.call("cancel",e,e.__data__,x.index,x.group),delete s[f])}if(bw(function(){r.state===Il&&(r.state=Ew,r.timer.restart(c,r.delay,r.time),c(h))}),r.state=Mg,r.on.call("start",e,e.__data__,r.index,r.group),r.state===Mg){for(r.state=Il,o=new Array(y=r.tween.length),f=0,m=-1;f<y;++f)(x=r.tween[f].value.call(e,e.__data__,r.index,r.group))&&(o[++m]=x);o.length=m+1}}function c(h){for(var f=h<r.duration?r.ease.call(null,h/r.duration):(r.timer.restart(p),r.state=Pg,1),m=-1,y=o.length;++m<y;)o[m].call(e,f);r.state===Pg&&(r.on.call("end",e,e.__data__,r.index,r.group),p())}function p(){r.state=Ml,r.timer.stop(),delete s[n];for(var h in s)return;delete e.__transition}}function Pl(e,n){var r=e.__transition,s,o,l=!0,u;if(r){n=n==null?null:n+"";for(u in r){if((s=r[u]).name!==n){l=!1;continue}o=s.state>Mg&&s.state<Pg,s.state=Ml,s.timer.stop(),s.on.call(o?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete r[u]}l&&delete e.__transition}}function V2(e){return this.each(function(){Pl(this,e)})}function W2(e,n){var r,s;return function(){var o=fr(this,e),l=o.tween;if(l!==r){s=r=l;for(var u=0,c=s.length;u<c;++u)if(s[u].name===n){s=s.slice(),s.splice(u,1);break}}o.tween=s}}function G2(e,n,r){var s,o;if(typeof r!="function")throw new Error;return function(){var l=fr(this,e),u=l.tween;if(u!==s){o=(s=u).slice();for(var c={name:n,value:r},p=0,h=o.length;p<h;++p)if(o[p].name===n){o[p]=c;break}p===h&&o.push(c)}l.tween=o}}function Y2(e,n){var r=this._id;if(e+="",arguments.length<2){for(var s=Jn(this.node(),r).tween,o=0,l=s.length,u;o<l;++o)if((u=s[o]).name===e)return u.value;return null}return this.each((n==null?W2:G2)(r,e,n))}function nv(e,n,r){var s=e._id;return e.each(function(){var o=fr(this,s);(o.value||(o.value={}))[n]=r.apply(this,arguments)}),function(o){return Jn(o,s).value[n]}}function vE(e,n){var r;return(typeof n=="number"?mi:n instanceof Jo?ww:(r=Jo(n))?(n=r,ww):R2)(e,n)}function K2(e){return function(){this.removeAttribute(e)}}function X2(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Q2(e,n,r){var s,o=r+"",l;return function(){var u=this.getAttribute(e);return u===o?null:u===s?l:l=n(s=u,r)}}function Z2(e,n,r){var s,o=r+"",l;return function(){var u=this.getAttributeNS(e.space,e.local);return u===o?null:u===s?l:l=n(s=u,r)}}function J2(e,n,r){var s,o,l;return function(){var u,c=r(this),p;return c==null?void this.removeAttribute(e):(u=this.getAttribute(e),p=c+"",u===p?null:u===s&&p===o?l:(o=p,l=n(s=u,c)))}}function eA(e,n,r){var s,o,l;return function(){var u,c=r(this),p;return c==null?void this.removeAttributeNS(e.space,e.local):(u=this.getAttributeNS(e.space,e.local),p=c+"",u===p?null:u===s&&p===o?l:(o=p,l=n(s=u,c)))}}function tA(e,n){var r=Yl(e),s=r==="transform"?M2:vE;return this.attrTween(e,typeof n=="function"?(r.local?eA:J2)(r,s,nv(this,"attr."+e,n)):n==null?(r.local?X2:K2)(r):(r.local?Z2:Q2)(r,s,n))}function nA(e,n){return function(r){this.setAttribute(e,n.call(this,r))}}function rA(e,n){return function(r){this.setAttributeNS(e.space,e.local,n.call(this,r))}}function iA(e,n){var r,s;function o(){var l=n.apply(this,arguments);return l!==s&&(r=(s=l)&&rA(e,l)),r}return o._value=n,o}function sA(e,n){var r,s;function o(){var l=n.apply(this,arguments);return l!==s&&(r=(s=l)&&nA(e,l)),r}return o._value=n,o}function oA(e,n){var r="attr."+e;if(arguments.length<2)return(r=this.tween(r))&&r._value;if(n==null)return this.tween(r,null);if(typeof n!="function")throw new Error;var s=Yl(e);return this.tween(r,(s.local?iA:sA)(s,n))}function aA(e,n){return function(){tv(this,e).delay=+n.apply(this,arguments)}}function lA(e,n){return n=+n,function(){tv(this,e).delay=n}}function uA(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?aA:lA)(n,e)):Jn(this.node(),n).delay}function cA(e,n){return function(){fr(this,e).duration=+n.apply(this,arguments)}}function dA(e,n){return n=+n,function(){fr(this,e).duration=n}}function fA(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?cA:dA)(n,e)):Jn(this.node(),n).duration}function hA(e,n){if(typeof n!="function")throw new Error;return function(){fr(this,e).ease=n}}function pA(e){var n=this._id;return arguments.length?this.each(hA(n,e)):Jn(this.node(),n).ease}function mA(e,n){return function(){var r=n.apply(this,arguments);if(typeof r!="function")throw new Error;fr(this,e).ease=r}}function gA(e){if(typeof e!="function")throw new Error;return this.each(mA(this._id,e))}function vA(e){typeof e!="function"&&(e=Kk(e));for(var n=this._groups,r=n.length,s=new Array(r),o=0;o<r;++o)for(var l=n[o],u=l.length,c=s[o]=[],p,h=0;h<u;++h)(p=l[h])&&e.call(p,p.__data__,h,l)&&c.push(p);return new Pr(s,this._parents,this._name,this._id)}function yA(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,r=e._groups,s=n.length,o=r.length,l=Math.min(s,o),u=new Array(s),c=0;c<l;++c)for(var p=n[c],h=r[c],f=p.length,m=u[c]=new Array(f),y,x=0;x<f;++x)(y=p[x]||h[x])&&(m[x]=y);for(;c<s;++c)u[c]=n[c];return new Pr(u,this._parents,this._name,this._id)}function wA(e){return(e+"").trim().split(/^|\s+/).every(function(n){var r=n.indexOf(".");return r>=0&&(n=n.slice(0,r)),!n||n==="start"})}function xA(e,n,r){var s,o,l=wA(n)?tv:fr;return function(){var u=l(this,e),c=u.on;c!==s&&(o=(s=c).copy()).on(n,r),u.on=o}}function _A(e,n){var r=this._id;return arguments.length<2?Jn(this.node(),r).on.on(e):this.each(xA(r,e,n))}function SA(e){return function(){var n=this.parentNode;for(var r in this.__transition)if(+r!==e)return;n&&n.removeChild(this)}}function bA(){return this.on("end.remove",SA(this._id))}function kA(e){var n=this._name,r=this._id;typeof e!="function"&&(e=Qg(e));for(var s=this._groups,o=s.length,l=new Array(o),u=0;u<o;++u)for(var c=s[u],p=c.length,h=l[u]=new Array(p),f,m,y=0;y<p;++y)(f=c[y])&&(m=e.call(f,f.__data__,y,c))&&("__data__"in f&&(m.__data__=f.__data__),h[y]=m,Xl(h[y],n,r,y,h,Jn(f,r)));return new Pr(l,this._parents,n,r)}function EA(e){var n=this._name,r=this._id;typeof e!="function"&&(e=Yk(e));for(var s=this._groups,o=s.length,l=[],u=[],c=0;c<o;++c)for(var p=s[c],h=p.length,f,m=0;m<h;++m)if(f=p[m]){for(var y=e.call(f,f.__data__,m,p),x,C=Jn(f,r),_=0,S=y.length;_<S;++_)(x=y[_])&&Xl(x,n,r,_,y,C);l.push(y),u.push(f)}return new Pr(l,u,n,r)}var NA=oa.prototype.constructor;function CA(){return new NA(this._groups,this._parents)}function jA(e,n){var r,s,o;return function(){var l=Gs(this,e),u=(this.style.removeProperty(e),Gs(this,e));return l===u?null:l===r&&u===s?o:o=n(r=l,s=u)}}function yE(e){return function(){this.style.removeProperty(e)}}function RA(e,n,r){var s,o=r+"",l;return function(){var u=Gs(this,e);return u===o?null:u===s?l:l=n(s=u,r)}}function TA(e,n,r){var s,o,l;return function(){var u=Gs(this,e),c=r(this),p=c+"";return c==null&&(p=c=(this.style.removeProperty(e),Gs(this,e))),u===p?null:u===s&&p===o?l:(o=p,l=n(s=u,c))}}function AA(e,n){var r,s,o,l="style."+n,u="end."+l,c;return function(){var p=fr(this,e),h=p.on,f=p.value[l]==null?c||(c=yE(n)):void 0;(h!==r||o!==f)&&(s=(r=h).copy()).on(u,o=f),p.on=s}}function IA(e,n,r){var s=(e+="")=="transform"?I2:vE;return n==null?this.styleTween(e,jA(e,s)).on("end.style."+e,yE(e)):typeof n=="function"?this.styleTween(e,TA(e,s,nv(this,"style."+e,n))).each(AA(this._id,e)):this.styleTween(e,RA(e,s,n),r).on("end.style."+e,null)}function MA(e,n,r){return function(s){this.style.setProperty(e,n.call(this,s),r)}}function PA(e,n,r){var s,o;function l(){var u=n.apply(this,arguments);return u!==o&&(s=(o=u)&&MA(e,u,r)),s}return l._value=n,l}function OA(e,n,r){var s="style."+(e+="");if(arguments.length<2)return(s=this.tween(s))&&s._value;if(n==null)return this.tween(s,null);if(typeof n!="function")throw new Error;return this.tween(s,PA(e,n,r??""))}function qA(e){return function(){this.textContent=e}}function LA(e){return function(){var n=e(this);this.textContent=n??""}}function $A(e){return this.tween("text",typeof e=="function"?LA(nv(this,"text",e)):qA(e==null?"":e+""))}function DA(e){return function(n){this.textContent=e.call(this,n)}}function FA(e){var n,r;function s(){var o=e.apply(this,arguments);return o!==r&&(n=(r=o)&&DA(o)),n}return s._value=e,s}function zA(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,FA(e))}function BA(){for(var e=this._name,n=this._id,r=wE(),s=this._groups,o=s.length,l=0;l<o;++l)for(var u=s[l],c=u.length,p,h=0;h<c;++h)if(p=u[h]){var f=Jn(p,n);Xl(p,e,r,h,u,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new Pr(s,this._parents,e,r)}function UA(){var e,n,r=this,s=r._id,o=r.size();return new Promise(function(l,u){var c={value:u},p={value:function(){--o===0&&l()}};r.each(function(){var h=fr(this,s),f=h.on;f!==e&&(n=(e=f).copy(),n._.cancel.push(c),n._.interrupt.push(c),n._.end.push(p)),h.on=n}),o===0&&l()})}var HA=0;function Pr(e,n,r,s){this._groups=e,this._parents=n,this._name=r,this._id=s}function wE(){return++HA}var Tr=oa.prototype;Pr.prototype={constructor:Pr,select:kA,selectAll:EA,selectChild:Tr.selectChild,selectChildren:Tr.selectChildren,filter:vA,merge:yA,selection:CA,transition:BA,call:Tr.call,nodes:Tr.nodes,node:Tr.node,size:Tr.size,empty:Tr.empty,each:Tr.each,on:_A,attr:tA,attrTween:oA,style:IA,styleTween:OA,text:$A,textTween:zA,remove:bA,tween:Y2,delay:uA,duration:fA,ease:pA,easeVarying:gA,end:UA,[Symbol.iterator]:Tr[Symbol.iterator]};function VA(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var WA={time:null,delay:0,duration:250,ease:VA};function GA(e,n){for(var r;!(r=e.__transition)||!(r=r[n]);)if(!(e=e.parentNode))throw new Error(`transition ${n} not found`);return r}function YA(e){var n,r;e instanceof Pr?(n=e._id,e=e._name):(n=wE(),(r=WA).time=ev(),e=e==null?null:e+"");for(var s=this._groups,o=s.length,l=0;l<o;++l)for(var u=s[l],c=u.length,p,h=0;h<c;++h)(p=u[h])&&Xl(p,e,n,h,u,r||GA(p,n));return new Pr(s,this._parents,e,n)}oa.prototype.interrupt=V2;oa.prototype.transition=YA;const xl=e=>()=>e;function KA(e,{sourceEvent:n,target:r,transform:s,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:o}})}function Ir(e,n,r){this.k=e,this.x=n,this.y=r}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 Fo(e){e.preventDefault(),e.stopImmediatePropagation()}function XA(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function QA(){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 Nw(){return this.__zoom||Mr}function ZA(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function JA(){return navigator.maxTouchPoints||"ontouchstart"in this}function eI(e,n,r){var s=e.invertX(n[0][0])-r[0][0],o=e.invertX(n[1][0])-r[1][0],l=e.invertY(n[0][1])-r[0][1],u=e.invertY(n[1][1])-r[1][1];return e.translate(o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o),u>l?(l+u)/2:Math.min(0,l)||Math.max(0,u))}function xE(){var e=XA,n=QA,r=eI,s=ZA,o=JA,l=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],c=250,p=L2,h=Gl("start","zoom","end"),f,m,y,x=500,C=150,_=0,S=10;function b(I){I.property("__zoom",Nw).on("wheel.zoom",B,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",M).filter(o).on("touchstart.zoom",q).on("touchmove.zoom",Y).on("touchend.zoom touchcancel.zoom",X).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}b.transform=function(I,H,U,ne){var J=I.selection?I.selection():I;J.property("__zoom",Nw),I!==J?P(I,H,U,ne):J.interrupt().each(function(){O(this,arguments).event(ne).start().zoom(null,typeof H=="function"?H.apply(this,arguments):H).end()})},b.scaleBy=function(I,H,U,ne){b.scaleTo(I,function(){var J=this.__zoom.k,F=typeof H=="function"?H.apply(this,arguments):H;return J*F},U,ne)},b.scaleTo=function(I,H,U,ne){b.transform(I,function(){var J=n.apply(this,arguments),F=this.__zoom,G=U==null?j(J):typeof U=="function"?U.apply(this,arguments):U,E=F.invert(G),$=typeof H=="function"?H.apply(this,arguments):H;return r(N(k(F,$),G,E),J,u)},U,ne)},b.translateBy=function(I,H,U,ne){b.transform(I,function(){return r(this.__zoom.translate(typeof H=="function"?H.apply(this,arguments):H,typeof U=="function"?U.apply(this,arguments):U),n.apply(this,arguments),u)},null,ne)},b.translateTo=function(I,H,U,ne,J){b.transform(I,function(){var F=n.apply(this,arguments),G=this.__zoom,E=ne==null?j(F):typeof ne=="function"?ne.apply(this,arguments):ne;return r(Mr.translate(E[0],E[1]).scale(G.k).translate(typeof H=="function"?-H.apply(this,arguments):-H,typeof U=="function"?-U.apply(this,arguments):-U),F,u)},ne,J)};function k(I,H){return H=Math.max(l[0],Math.min(l[1],H)),H===I.k?I:new Ir(H,I.x,I.y)}function N(I,H,U){var ne=H[0]-U[0]*I.k,J=H[1]-U[1]*I.k;return ne===I.x&&J===I.y?I:new Ir(I.k,ne,J)}function j(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function P(I,H,U,ne){I.on("start.zoom",function(){O(this,arguments).event(ne).start()}).on("interrupt.zoom end.zoom",function(){O(this,arguments).event(ne).end()}).tween("zoom",function(){var J=this,F=arguments,G=O(J,F).event(ne),E=n.apply(J,F),$=U==null?j(E):typeof U=="function"?U.apply(J,F):U,se=Math.max(E[1][0]-E[0][0],E[1][1]-E[0][1]),D=J.__zoom,Q=typeof H=="function"?H.apply(J,F):H,ee=p(D.invert($).concat(se/D.k),Q.invert($).concat(se/Q.k));return function(oe){if(oe===1)oe=Q;else{var ue=ee(oe),ge=se/ue[2];oe=new Ir(ge,$[0]-ue[0]*ge,$[1]-ue[1]*ge)}G.zoom(null,oe)}})}function O(I,H,U){return!U&&I.__zooming||new L(I,H)}function L(I,H){this.that=I,this.args=H,this.active=0,this.sourceEvent=null,this.extent=n.apply(I,H),this.taps=0}L.prototype={event:function(I){return I&&(this.sourceEvent=I),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(I,H){return this.mouse&&I!=="mouse"&&(this.mouse[1]=H.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=H.invert(this.touch0[0])),this.touch1&&I!=="touch"&&(this.touch1[1]=H.invert(this.touch1[0])),this.that.__zoom=H,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(I){var H=In(this.that).datum();h.call(I,this.that,new KA(I,{sourceEvent:this.sourceEvent,target:b,transform:this.that.__zoom,dispatch:h}),H)}};function B(I,...H){if(!e.apply(this,arguments))return;var U=O(this,H).event(I),ne=this.__zoom,J=Math.max(l[0],Math.min(l[1],ne.k*Math.pow(2,s.apply(this,arguments)))),F=Kn(I);if(U.wheel)(U.mouse[0][0]!==F[0]||U.mouse[0][1]!==F[1])&&(U.mouse[1]=ne.invert(U.mouse[0]=F)),clearTimeout(U.wheel);else{if(ne.k===J)return;U.mouse=[F,ne.invert(F)],Pl(this),U.start()}Fo(I),U.wheel=setTimeout(G,C),U.zoom("mouse",r(N(k(ne,J),U.mouse[0],U.mouse[1]),U.extent,u));function G(){U.wheel=null,U.end()}}function T(I,...H){if(y||!e.apply(this,arguments))return;var U=I.currentTarget,ne=O(this,H,!0).event(I),J=In(I.view).on("mousemove.zoom",$,!0).on("mouseup.zoom",se,!0),F=Kn(I,U),G=I.clientX,E=I.clientY;sE(I.view),Zc(I),ne.mouse=[F,this.__zoom.invert(F)],Pl(this),ne.start();function $(D){if(Fo(D),!ne.moved){var Q=D.clientX-G,ee=D.clientY-E;ne.moved=Q*Q+ee*ee>_}ne.event(D).zoom("mouse",r(N(ne.that.__zoom,ne.mouse[0]=Kn(D,U),ne.mouse[1]),ne.extent,u))}function se(D){J.on("mousemove.zoom mouseup.zoom",null),oE(D.view,ne.moved),Fo(D),ne.event(D).end()}}function M(I,...H){if(e.apply(this,arguments)){var U=this.__zoom,ne=Kn(I.changedTouches?I.changedTouches[0]:I,this),J=U.invert(ne),F=U.k*(I.shiftKey?.5:2),G=r(N(k(U,F),ne,J),n.apply(this,H),u);Fo(I),c>0?In(this).transition().duration(c).call(P,G,ne,I):In(this).call(b.transform,G,ne,I)}}function q(I,...H){if(e.apply(this,arguments)){var U=I.touches,ne=U.length,J=O(this,H,I.changedTouches.length===ne).event(I),F,G,E,$;for(Zc(I),G=0;G<ne;++G)E=U[G],$=Kn(E,this),$=[$,this.__zoom.invert($),E.identifier],J.touch0?!J.touch1&&J.touch0[2]!==$[2]&&(J.touch1=$,J.taps=0):(J.touch0=$,F=!0,J.taps=1+!!f);f&&(f=clearTimeout(f)),F&&(J.taps<2&&(m=$[0],f=setTimeout(function(){f=null},x)),Pl(this),J.start())}}function Y(I,...H){if(this.__zooming){var U=O(this,H).event(I),ne=I.changedTouches,J=ne.length,F,G,E,$;for(Fo(I),F=0;F<J;++F)G=ne[F],E=Kn(G,this),U.touch0&&U.touch0[2]===G.identifier?U.touch0[0]=E:U.touch1&&U.touch1[2]===G.identifier&&(U.touch1[0]=E);if(G=U.that.__zoom,U.touch1){var se=U.touch0[0],D=U.touch0[1],Q=U.touch1[0],ee=U.touch1[1],oe=(oe=Q[0]-se[0])*oe+(oe=Q[1]-se[1])*oe,ue=(ue=ee[0]-D[0])*ue+(ue=ee[1]-D[1])*ue;G=k(G,Math.sqrt(oe/ue)),E=[(se[0]+Q[0])/2,(se[1]+Q[1])/2],$=[(D[0]+ee[0])/2,(D[1]+ee[1])/2]}else if(U.touch0)E=U.touch0[0],$=U.touch0[1];else return;U.zoom("touch",r(N(G,E,$),U.extent,u))}}function X(I,...H){if(this.__zooming){var U=O(this,H).event(I),ne=I.changedTouches,J=ne.length,F,G;for(Zc(I),y&&clearTimeout(y),y=setTimeout(function(){y=null},x),F=0;F<J;++F)G=ne[F],U.touch0&&U.touch0[2]===G.identifier?delete U.touch0:U.touch1&&U.touch1[2]===G.identifier&&delete U.touch1;if(U.touch1&&!U.touch0&&(U.touch0=U.touch1,delete U.touch1),U.touch0)U.touch0[1]=this.__zoom.invert(U.touch0[0]);else if(U.end(),U.taps===2&&(G=Kn(G,this),Math.hypot(m[0]-G[0],m[1]-G[1])<S)){var E=In(this).on("dblclick.zoom");E&&E.apply(this,arguments)}}}return b.wheelDelta=function(I){return arguments.length?(s=typeof I=="function"?I:xl(+I),b):s},b.filter=function(I){return arguments.length?(e=typeof I=="function"?I:xl(!!I),b):e},b.touchable=function(I){return arguments.length?(o=typeof I=="function"?I:xl(!!I),b):o},b.extent=function(I){return arguments.length?(n=typeof I=="function"?I:xl([[+I[0][0],+I[0][1]],[+I[1][0],+I[1][1]]]),b):n},b.scaleExtent=function(I){return arguments.length?(l[0]=+I[0],l[1]=+I[1],b):[l[0],l[1]]},b.translateExtent=function(I){return arguments.length?(u[0][0]=+I[0][0],u[1][0]=+I[1][0],u[0][1]=+I[0][1],u[1][1]=+I[1][1],b):[[u[0][0],u[0][1]],[u[1][0],u[1][1]]]},b.constrain=function(I){return arguments.length?(r=I,b):r},b.duration=function(I){return arguments.length?(c=+I,b):c},b.interpolate=function(I){return arguments.length?(p=I,b):p},b.on=function(){var I=h.on.apply(h,arguments);return I===h?b:I},b.clickDistance=function(I){return arguments.length?(_=(I=+I)*I,b):Math.sqrt(_)},b.tapDistance=function(I){return arguments.length?(S=+I,b):S},b}var tI=Vk();const Ql=A.createContext(null),nI=Ql.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.`},_E=Or.error001();function Xe(e,n){const r=A.useContext(Ql);if(r===null)throw new Error(_E);return Wk(r,e,n)}const Nt=()=>{const e=A.useContext(Ql);if(e===null)throw new Error(_E);return A.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},rI=e=>e.userSelectionActive?"none":"all";function rv({position:e,children:n,className:r,style:s,...o}){const l=Xe(rI),u=`${e}`.split("-");return ae.createElement("div",{className:Ot(["react-flow__panel",r,...u]),style:{...s,pointerEvents:l},...o},n)}function iI({proOptions:e,position:n="bottom-right"}){return e!=null&&e.hideAttribution?null:ae.createElement(rv,{position:n,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},ae.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const sI=({x:e,y:n,label:r,labelStyle:s={},labelShowBg:o=!0,labelBgStyle:l={},labelBgPadding:u=[2,4],labelBgBorderRadius:c=2,children:p,className:h,...f})=>{const m=A.useRef(null),[y,x]=A.useState({x:0,y:0,width:0,height:0}),C=Ot(["react-flow__edge-textwrapper",h]);return A.useEffect(()=>{if(m.current){const _=m.current.getBBox();x({x:_.x,y:_.y,width:_.width,height:_.height})}},[r]),typeof r>"u"||!r?null:ae.createElement("g",{transform:`translate(${e-y.width/2} ${n-y.height/2})`,className:C,visibility:y.width?"visible":"hidden",...f},o&&ae.createElement("rect",{width:y.width+2*u[0],x:-u[0],y:-u[1],height:y.height+2*u[1],className:"react-flow__edge-textbg",style:l,rx:c,ry:c}),ae.createElement("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:m,style:s},r),p)};var oI=A.memo(sI);const iv=e=>({width:e.offsetWidth,height:e.offsetHeight}),Ks=(e,n=0,r=1)=>Math.min(Math.max(e,n),r),sv=(e={x:0,y:0},n)=>({x:Ks(e.x,n[0][0],n[1][0]),y:Ks(e.y,n[0][1],n[1][1])}),Cw=(e,n,r)=>e<n?Ks(Math.abs(e-n),1,50)/50:e>r?-Ks(Math.abs(e-r),1,50)/50:0,SE=(e,n)=>{const r=Cw(e.x,35,n.width-35)*20,s=Cw(e.y,35,n.height-35)*20;return[r,s]},bE=e=>{var n;return((n=e.getRootNode)==null?void 0:n.call(e))||(window==null?void 0:window.document)},kE=(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)}),ta=({x:e,y:n,width:r,height:s})=>({x:e,y:n,x2:e+r,y2:n+s}),EE=({x:e,y:n,x2:r,y2:s})=>({x:e,y:n,width:r-e,height:s-n}),jw=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),aI=(e,n)=>EE(kE(ta(e),ta(n))),Og=(e,n)=>{const r=Math.max(0,Math.min(e.x+e.width,n.x+n.width)-Math.max(e.x,n.x)),s=Math.max(0,Math.min(e.y+e.height,n.y+n.height)-Math.max(e.y,n.y));return Math.ceil(r*s)},lI=e=>Mn(e.width)&&Mn(e.height)&&Mn(e.x)&&Mn(e.y),Mn=e=>!isNaN(e)&&isFinite(e),pt=Symbol.for("internals"),NE=["Enter"," ","Escape"],uI=(e,n)=>{},cI=e=>"nativeEvent"in e;function qg(e){var o,l;const n=cI(e)?e.nativeEvent:e,r=((l=(o=n.composedPath)==null?void 0:o.call(n))==null?void 0:l[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(r==null?void 0:r.nodeName)||(r==null?void 0:r.hasAttribute("contenteditable"))||!!(r!=null&&r.closest(".nokey"))}const CE=e=>"clientX"in e,yi=(e,n)=>{var l,u;const r=CE(e),s=r?e.clientX:(l=e.touches)==null?void 0:l[0].clientX,o=r?e.clientY:(u=e.touches)==null?void 0:u[0].clientY;return{x:s-((n==null?void 0:n.left)??0),y:o-((n==null?void 0:n.top)??0)}},zl=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},la=({id:e,path:n,labelX:r,labelY:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:y,interactionWidth:x=20})=>ae.createElement(ae.Fragment,null,ae.createElement("path",{id:e,style:f,d:n,fill:"none",className:"react-flow__edge-path",markerEnd:m,markerStart:y}),x&&ae.createElement("path",{d:n,fill:"none",strokeOpacity:0,strokeWidth:x,className:"react-flow__edge-interaction"}),o&&Mn(r)&&Mn(s)?ae.createElement(oI,{x:r,y:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h}):null);la.displayName="BaseEdge";function zo(e,n,r){return r===void 0?r:s=>{const o=n().edges.find(l=>l.id===e);o&&r(s,{...o})}}function jE({sourceX:e,sourceY:n,targetX:r,targetY:s}){const o=Math.abs(r-e)/2,l=r<e?r+o:r-o,u=Math.abs(s-n)/2,c=s<n?s+u:s-u;return[l,c,o,u]}function RE({sourceX:e,sourceY:n,targetX:r,targetY:s,sourceControlX:o,sourceControlY:l,targetControlX:u,targetControlY:c}){const p=e*.125+o*.375+u*.375+r*.125,h=n*.125+l*.375+c*.375+s*.125,f=Math.abs(p-e),m=Math.abs(h-n);return[p,h,f,m]}var es;(function(e){e.Strict="strict",e.Loose="loose"})(es||(es={}));var Ki;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ki||(Ki={}));var na;(function(e){e.Partial="partial",e.Full="full"})(na||(na={}));var vi;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(vi||(vi={}));var Bl;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Bl||(Bl={}));var Ce;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ce||(Ce={}));function Rw({pos:e,x1:n,y1:r,x2:s,y2:o}){return e===Ce.Left||e===Ce.Right?[.5*(n+s),r]:[n,.5*(r+o)]}function TE({sourceX:e,sourceY:n,sourcePosition:r=Ce.Bottom,targetX:s,targetY:o,targetPosition:l=Ce.Top}){const[u,c]=Rw({pos:r,x1:e,y1:n,x2:s,y2:o}),[p,h]=Rw({pos:l,x1:s,y1:o,x2:e,y2:n}),[f,m,y,x]=RE({sourceX:e,sourceY:n,targetX:s,targetY:o,sourceControlX:u,sourceControlY:c,targetControlX:p,targetControlY:h});return[`M${e},${n} C${u},${c} ${p},${h} ${s},${o}`,f,m,y,x]}const ov=A.memo(({sourceX:e,sourceY:n,targetX:r,targetY:s,sourcePosition:o=Ce.Bottom,targetPosition:l=Ce.Top,label:u,labelStyle:c,labelShowBg:p,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:C,interactionWidth:_})=>{const[S,b,k]=TE({sourceX:e,sourceY:n,sourcePosition:o,targetX:r,targetY:s,targetPosition:l});return ae.createElement(la,{path:S,labelX:b,labelY:k,label:u,labelStyle:c,labelShowBg:p,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:C,interactionWidth:_})});ov.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}},dI=({source:e,sourcePosition:n=Ce.Bottom,target:r})=>n===Ce.Left||n===Ce.Right?e.x<r.x?{x:1,y:0}:{x:-1,y:0}:e.y<r.y?{x:0,y:1}:{x:0,y:-1},Aw=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function fI({source:e,sourcePosition:n=Ce.Bottom,target:r,targetPosition:s=Ce.Top,center:o,offset:l}){const u=Tw[n],c=Tw[s],p={x:e.x+u.x*l,y:e.y+u.y*l},h={x:r.x+c.x*l,y:r.y+c.y*l},f=dI({source:p,sourcePosition:n,target:h}),m=f.x!==0?"x":"y",y=f[m];let x=[],C,_;const S={x:0,y:0},b={x:0,y:0},[k,N,j,P]=jE({sourceX:e.x,sourceY:e.y,targetX:r.x,targetY:r.y});if(u[m]*c[m]===-1){C=o.x??k,_=o.y??N;const L=[{x:C,y:p.y},{x:C,y:h.y}],B=[{x:p.x,y:_},{x:h.x,y:_}];u[m]===y?x=m==="x"?L:B:x=m==="x"?B:L}else{const L=[{x:p.x,y:h.y}],B=[{x:h.x,y:p.y}];if(m==="x"?x=u.x===y?B:L:x=u.y===y?L:B,n===s){const X=Math.abs(e[m]-r[m]);if(X<=l){const I=Math.min(l-1,l-X);u[m]===y?S[m]=(p[m]>e[m]?-1:1)*I:b[m]=(h[m]>r[m]?-1:1)*I}}if(n!==s){const X=m==="x"?"y":"x",I=u[m]===c[X],H=p[X]>h[X],U=p[X]<h[X];(u[m]===1&&(!I&&H||I&&U)||u[m]!==1&&(!I&&U||I&&H))&&(x=m==="x"?L:B)}const T={x:p.x+S.x,y:p.y+S.y},M={x:h.x+b.x,y:h.y+b.y},q=Math.max(Math.abs(T.x-x[0].x),Math.abs(M.x-x[0].x)),Y=Math.max(Math.abs(T.y-x[0].y),Math.abs(M.y-x[0].y));q>=Y?(C=(T.x+M.x)/2,_=x[0].y):(C=x[0].x,_=(T.y+M.y)/2)}return[[e,{x:p.x+S.x,y:p.y+S.y},...x,{x:h.x+b.x,y:h.y+b.y},r],C,_,j,P]}function hI(e,n,r,s){const o=Math.min(Aw(e,n)/2,Aw(n,r)/2,s),{x:l,y:u}=n;if(e.x===l&&l===r.x||e.y===u&&u===r.y)return`L${l} ${u}`;if(e.y===u){const h=e.x<r.x?-1:1,f=e.y<r.y?1:-1;return`L ${l+o*h},${u}Q ${l},${u} ${l},${u+o*f}`}const c=e.x<r.x?1:-1,p=e.y<r.y?-1:1;return`L ${l},${u+o*p}Q ${l},${u} ${l+o*c},${u}`}function Lg({sourceX:e,sourceY:n,sourcePosition:r=Ce.Bottom,targetX:s,targetY:o,targetPosition:l=Ce.Top,borderRadius:u=5,centerX:c,centerY:p,offset:h=20}){const[f,m,y,x,C]=fI({source:{x:e,y:n},sourcePosition:r,target:{x:s,y:o},targetPosition:l,center:{x:c,y:p},offset:h});return[f.reduce((S,b,k)=>{let N="";return k>0&&k<f.length-1?N=hI(f[k-1],b,f[k+1],u):N=`${k===0?"M":"L"}${b.x} ${b.y}`,S+=N,S},""),m,y,x,C]}const Zl=A.memo(({sourceX:e,sourceY:n,targetX:r,targetY:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h,style:f,sourcePosition:m=Ce.Bottom,targetPosition:y=Ce.Top,markerEnd:x,markerStart:C,pathOptions:_,interactionWidth:S})=>{const[b,k,N]=Lg({sourceX:e,sourceY:n,sourcePosition:m,targetX:r,targetY:s,targetPosition:y,borderRadius:_==null?void 0:_.borderRadius,offset:_==null?void 0:_.offset});return ae.createElement(la,{path:b,labelX:k,labelY:N,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h,style:f,markerEnd:x,markerStart:C,interactionWidth:S})});Zl.displayName="SmoothStepEdge";const av=A.memo(e=>{var n;return ae.createElement(Zl,{...e,pathOptions:A.useMemo(()=>{var r;return{borderRadius:0,offset:(r=e.pathOptions)==null?void 0:r.offset}},[(n=e.pathOptions)==null?void 0:n.offset])})});av.displayName="StepEdge";function pI({sourceX:e,sourceY:n,targetX:r,targetY:s}){const[o,l,u,c]=jE({sourceX:e,sourceY:n,targetX:r,targetY:s});return[`M ${e},${n}L ${r},${s}`,o,l,u,c]}const lv=A.memo(({sourceX:e,sourceY:n,targetX:r,targetY:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:y,interactionWidth:x})=>{const[C,_,S]=pI({sourceX:e,sourceY:n,targetX:r,targetY:s});return ae.createElement(la,{path:C,labelX:_,labelY:S,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:y,interactionWidth:x})});lv.displayName="StraightEdge";function _l(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function Iw({pos:e,x1:n,y1:r,x2:s,y2:o,c:l}){switch(e){case Ce.Left:return[n-_l(n-s,l),r];case Ce.Right:return[n+_l(s-n,l),r];case Ce.Top:return[n,r-_l(r-o,l)];case Ce.Bottom:return[n,r+_l(o-r,l)]}}function AE({sourceX:e,sourceY:n,sourcePosition:r=Ce.Bottom,targetX:s,targetY:o,targetPosition:l=Ce.Top,curvature:u=.25}){const[c,p]=Iw({pos:r,x1:e,y1:n,x2:s,y2:o,c:u}),[h,f]=Iw({pos:l,x1:s,y1:o,x2:e,y2:n,c:u}),[m,y,x,C]=RE({sourceX:e,sourceY:n,targetX:s,targetY:o,sourceControlX:c,sourceControlY:p,targetControlX:h,targetControlY:f});return[`M${e},${n} C${c},${p} ${h},${f} ${s},${o}`,m,y,x,C]}const Ul=A.memo(({sourceX:e,sourceY:n,targetX:r,targetY:s,sourcePosition:o=Ce.Bottom,targetPosition:l=Ce.Top,label:u,labelStyle:c,labelShowBg:p,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:C,pathOptions:_,interactionWidth:S})=>{const[b,k,N]=AE({sourceX:e,sourceY:n,sourcePosition:o,targetX:r,targetY:s,targetPosition:l,curvature:_==null?void 0:_.curvature});return ae.createElement(la,{path:b,labelX:k,labelY:N,label:u,labelStyle:c,labelShowBg:p,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:C,interactionWidth:S})});Ul.displayName="BezierEdge";const uv=A.createContext(null),mI=uv.Provider;uv.Consumer;const gI=()=>A.useContext(uv),vI=e=>"id"in e&&"source"in e&&"target"in e,yI=({source:e,sourceHandle:n,target:r,targetHandle:s})=>`reactflow__edge-${e}${n||""}-${r}${s||""}`,$g=(e,n)=>typeof e>"u"?"":typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`,wI=(e,n)=>n.some(r=>r.source===e.source&&r.target===e.target&&(r.sourceHandle===e.sourceHandle||!r.sourceHandle&&!e.sourceHandle)&&(r.targetHandle===e.targetHandle||!r.targetHandle&&!e.targetHandle)),xI=(e,n)=>{if(!e.source||!e.target)return n;let r;return vI(e)?r={...e}:r={...e,id:yI(e)},wI(r,n)?n:n.concat(r)},Dg=({x:e,y:n},[r,s,o],l,[u,c])=>{const p={x:(e-r)/o,y:(n-s)/o};return l?{x:u*Math.round(p.x/u),y:c*Math.round(p.y/c)}:p},IE=({x:e,y:n},[r,s,o])=>({x:e*o+r,y:n*o+s}),Qi=(e,n=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const r=(e.width??0)*n[0],s=(e.height??0)*n[1],o={x:e.position.x-r,y:e.position.y-s};return{...o,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-r,y:e.positionAbsolute.y-s}:o}},Jl=(e,n=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const r=e.reduce((s,o)=>{const{x:l,y:u}=Qi(o,n).positionAbsolute;return kE(s,ta({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 EE(r)},ME=(e,n,[r,s,o]=[0,0,1],l=!1,u=!1,c=[0,0])=>{const p={x:(n.x-r)/o,y:(n.y-s)/o,width:n.width/o,height:n.height/o},h=[];return e.forEach(f=>{const{width:m,height:y,selectable:x=!0,hidden:C=!1}=f;if(u&&!x||C)return!1;const{positionAbsolute:_}=Qi(f,c),S={x:_.x,y:_.y,width:m||0,height:y||0},b=Og(p,S),k=typeof m>"u"||typeof y>"u"||m===null||y===null,N=l&&b>0,j=(m||0)*(y||0);(k||N||b>=j||f.dragging)&&h.push(f)}),h},PE=(e,n)=>{const r=e.map(s=>s.id);return n.filter(s=>r.includes(s.source)||r.includes(s.target))},OE=(e,n,r,s,o,l=.1)=>{const u=n/(e.width*(1+l)),c=r/(e.height*(1+l)),p=Math.min(u,c),h=Ks(p,s,o),f=e.x+e.width/2,m=e.y+e.height/2,y=n/2-f*h,x=r/2-m*h;return{x:y,y:x,zoom:h}},Gi=(e,n=0)=>e.transition().duration(n);function Mw(e,n,r,s){return(n[r]||[]).reduce((o,l)=>{var u,c;return`${e.id}-${l.id}-${r}`!==s&&o.push({id:l.id||null,type:r,nodeId:e.id,x:(((u=e.positionAbsolute)==null?void 0:u.x)??0)+l.x+l.width/2,y:(((c=e.positionAbsolute)==null?void 0:c.y)??0)+l.y+l.height/2}),o},[])}function _I(e,n,r,s,o,l){const{x:u,y:c}=yi(e),h=n.elementsFromPoint(u,c).find(C=>C.classList.contains("react-flow__handle"));if(h){const C=h.getAttribute("data-nodeid");if(C){const _=cv(void 0,h),S=h.getAttribute("data-handleid"),b=l({nodeId:C,id:S,type:_});if(b){const k=o.find(N=>N.nodeId===C&&N.type===_&&N.id===S);return{handle:{id:S,type:_,nodeId:C,x:(k==null?void 0:k.x)||r.x,y:(k==null?void 0:k.y)||r.y},validHandleResult:b}}}}let f=[],m=1/0;if(o.forEach(C=>{const _=Math.sqrt((C.x-r.x)**2+(C.y-r.y)**2);if(_<=s){const S=l(C);_<=m&&(_<m?f=[{handle:C,validHandleResult:S}]:_===m&&f.push({handle:C,validHandleResult:S}),m=_)}}),!f.length)return{handle:null,validHandleResult:qE()};if(f.length===1)return f[0];const y=f.some(({validHandleResult:C})=>C.isValid),x=f.some(({handle:C})=>C.type==="target");return f.find(({handle:C,validHandleResult:_})=>x?C.type==="target":y?_.isValid:!0)||f[0]}const SI={source:null,target:null,sourceHandle:null,targetHandle:null},qE=()=>({handleDomNode:null,isValid:!1,connection:SI,endHandle:null});function LE(e,n,r,s,o,l,u){const c=o==="target",p=u.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),h={...qE(),handleDomNode:p};if(p){const f=cv(void 0,p),m=p.getAttribute("data-nodeid"),y=p.getAttribute("data-handleid"),x=p.classList.contains("connectable"),C=p.classList.contains("connectableend"),_={source:c?m:r,sourceHandle:c?y:s,target:c?r:m,targetHandle:c?s:y};h.connection=_,x&&C&&(n===es.Strict?c&&f==="source"||!c&&f==="target":m!==r||y!==s)&&(h.endHandle={nodeId:m,handleId:y,type:f},h.isValid=l(_))}return h}function bI({nodes:e,nodeId:n,handleId:r,handleType:s}){return e.reduce((o,l)=>{if(l[pt]){const{handleBounds:u}=l[pt];let c=[],p=[];u&&(c=Mw(l,u,"source",`${n}-${r}-${s}`),p=Mw(l,u,"target",`${n}-${r}-${s}`)),o.push(...c,...p)}return o},[])}function cv(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 kI(e,n){let r=null;return n?r="valid":e&&!n&&(r="invalid"),r}function $E({event:e,handleId:n,nodeId:r,onConnect:s,isTarget:o,getState:l,setState:u,isValidConnection:c,edgeUpdaterType:p,onReconnectEnd:h}){const f=bE(e.target),{connectionMode:m,domNode:y,autoPanOnConnect:x,connectionRadius:C,onConnectStart:_,panBy:S,getNodes:b,cancelConnection:k}=l();let N=0,j;const{x:P,y:O}=yi(e),L=f==null?void 0:f.elementFromPoint(P,O),B=cv(p,L),T=y==null?void 0:y.getBoundingClientRect();if(!T||!B)return;let M,q=yi(e,T),Y=!1,X=null,I=!1,H=null;const U=bI({nodes:b(),nodeId:r,handleId:n,handleType:B}),ne=()=>{if(!x)return;const[G,E]=SE(q,T);S({x:G,y:E}),N=requestAnimationFrame(ne)};u({connectionPosition:q,connectionStatus:null,connectionNodeId:r,connectionHandleId:n,connectionHandleType:B,connectionStartHandle:{nodeId:r,handleId:n,type:B},connectionEndHandle:null}),_==null||_(e,{nodeId:r,handleId:n,handleType:B});function J(G){const{transform:E}=l();q=yi(G,T);const{handle:$,validHandleResult:se}=_I(G,f,Dg(q,E,!1,[1,1]),C,U,D=>LE(D,m,r,n,o?"target":"source",c,f));if(j=$,Y||(ne(),Y=!0),H=se.handleDomNode,X=se.connection,I=se.isValid,u({connectionPosition:j&&I?IE({x:j.x,y:j.y},E):q,connectionStatus:kI(!!j,I),connectionEndHandle:se.endHandle}),!j&&!I&&!H)return Jc(M);X.source!==X.target&&H&&(Jc(M),M=H,H.classList.add("connecting","react-flow__handle-connecting"),H.classList.toggle("valid",I),H.classList.toggle("react-flow__handle-valid",I))}function F(G){var E,$;(j||H)&&X&&I&&(s==null||s(X)),($=(E=l()).onConnectEnd)==null||$.call(E,G),p&&(h==null||h(G)),Jc(M),k(),cancelAnimationFrame(N),Y=!1,I=!1,X=null,H=null,f.removeEventListener("mousemove",J),f.removeEventListener("mouseup",F),f.removeEventListener("touchmove",J),f.removeEventListener("touchend",F)}f.addEventListener("mousemove",J),f.addEventListener("mouseup",F),f.addEventListener("touchmove",J),f.addEventListener("touchend",F)}const Pw=()=>!0,EI=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),NI=(e,n,r)=>s=>{const{connectionStartHandle:o,connectionEndHandle:l,connectionClickStartHandle:u}=s;return{connecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.handleId)===n&&(o==null?void 0:o.type)===r||(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.handleId)===n&&(l==null?void 0:l.type)===r,clickConnecting:(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.handleId)===n&&(u==null?void 0:u.type)===r}},DE=A.forwardRef(({type:e="source",position:n=Ce.Top,isValidConnection:r,isConnectable:s=!0,isConnectableStart:o=!0,isConnectableEnd:l=!0,id:u,onConnect:c,children:p,className:h,onMouseDown:f,onTouchStart:m,...y},x)=>{var T,M;const C=u||null,_=e==="target",S=Nt(),b=gI(),{connectOnClick:k,noPanClassName:N}=Xe(EI,Et),{connecting:j,clickConnecting:P}=Xe(NI(b,C,e),Et);b||(M=(T=S.getState()).onError)==null||M.call(T,"010",Or.error010());const O=q=>{const{defaultEdgeOptions:Y,onConnect:X,hasDefaultEdges:I}=S.getState(),H={...Y,...q};if(I){const{edges:U,setEdges:ne}=S.getState();ne(xI(H,U))}X==null||X(H),c==null||c(H)},L=q=>{if(!b)return;const Y=CE(q);o&&(Y&&q.button===0||!Y)&&$E({event:q,handleId:C,nodeId:b,onConnect:O,isTarget:_,getState:S.getState,setState:S.setState,isValidConnection:r||S.getState().isValidConnection||Pw}),Y?f==null||f(q):m==null||m(q)},B=q=>{const{onClickConnectStart:Y,onClickConnectEnd:X,connectionClickStartHandle:I,connectionMode:H,isValidConnection:U}=S.getState();if(!b||!I&&!o)return;if(!I){Y==null||Y(q,{nodeId:b,handleId:C,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:b,type:e,handleId:C}});return}const ne=bE(q.target),J=r||U||Pw,{connection:F,isValid:G}=LE({nodeId:b,id:C,type:e},H,I.nodeId,I.handleId||null,I.type,J,ne);G&&O(F),X==null||X(q),S.setState({connectionClickStartHandle:null})};return ae.createElement("div",{"data-handleid":C,"data-nodeid":b,"data-handlepos":n,"data-id":`${b}-${C}-${e}`,className:Ot(["react-flow__handle",`react-flow__handle-${n}`,"nodrag",N,h,{source:!_,target:_,connectable:s,connectablestart:o,connectableend:l,connecting:P,connectionindicator:s&&(o&&!j||l&&j)}]),onMouseDown:L,onTouchStart:L,onClick:k?B:void 0,ref:x,...y},p)});DE.displayName="Handle";var Xs=A.memo(DE);const FE=({data:e,isConnectable:n,targetPosition:r=Ce.Top,sourcePosition:s=Ce.Bottom})=>ae.createElement(ae.Fragment,null,ae.createElement(Xs,{type:"target",position:r,isConnectable:n}),e==null?void 0:e.label,ae.createElement(Xs,{type:"source",position:s,isConnectable:n}));FE.displayName="DefaultNode";var Fg=A.memo(FE);const zE=({data:e,isConnectable:n,sourcePosition:r=Ce.Bottom})=>ae.createElement(ae.Fragment,null,e==null?void 0:e.label,ae.createElement(Xs,{type:"source",position:r,isConnectable:n}));zE.displayName="InputNode";var BE=A.memo(zE);const UE=({data:e,isConnectable:n,targetPosition:r=Ce.Top})=>ae.createElement(ae.Fragment,null,ae.createElement(Xs,{type:"target",position:r,isConnectable:n}),e==null?void 0:e.label);UE.displayName="OutputNode";var HE=A.memo(UE);const dv=()=>null;dv.displayName="GroupNode";const CI=e=>({selectedNodes:e.getNodes().filter(n=>n.selected),selectedEdges:e.edges.filter(n=>n.selected).map(n=>({...n}))}),Sl=e=>e.id;function jI(e,n){return Et(e.selectedNodes.map(Sl),n.selectedNodes.map(Sl))&&Et(e.selectedEdges.map(Sl),n.selectedEdges.map(Sl))}const VE=A.memo(({onSelectionChange:e})=>{const n=Nt(),{selectedNodes:r,selectedEdges:s}=Xe(CI,jI);return A.useEffect(()=>{const o={nodes:r,edges:s};e==null||e(o),n.getState().onSelectionChange.forEach(l=>l(o))},[r,s,e]),null});VE.displayName="SelectionListener";const RI=e=>!!e.onSelectionChange;function TI({onSelectionChange:e}){const n=Xe(RI);return e||n?ae.createElement(VE,{onSelectionChange:e}):null}const AI=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 Ps(e,n){A.useEffect(()=>{typeof e<"u"&&n(e)},[e])}function qe(e,n,r){A.useEffect(()=>{typeof n<"u"&&r({[e]:n})},[n])}const II=({nodes:e,edges:n,defaultNodes:r,defaultEdges:s,onConnect:o,onConnectStart:l,onConnectEnd:u,onClickConnectStart:c,onClickConnectEnd:p,nodesDraggable:h,nodesConnectable:f,nodesFocusable:m,edgesFocusable:y,edgesUpdatable:x,elevateNodesOnSelect:C,minZoom:_,maxZoom:S,nodeExtent:b,onNodesChange:k,onEdgesChange:N,elementsSelectable:j,connectionMode:P,snapGrid:O,snapToGrid:L,translateExtent:B,connectOnClick:T,defaultEdgeOptions:M,fitView:q,fitViewOptions:Y,onNodesDelete:X,onEdgesDelete:I,onNodeDrag:H,onNodeDragStart:U,onNodeDragStop:ne,onSelectionDrag:J,onSelectionDragStart:F,onSelectionDragStop:G,noPanClassName:E,nodeOrigin:$,rfId:se,autoPanOnConnect:D,autoPanOnNodeDrag:Q,onError:ee,connectionRadius:oe,isValidConnection:ue,nodeDragThreshold:ge})=>{const{setNodes:de,setEdges:Ie,setDefaultNodesAndEdges:He,setMinZoom:Pe,setMaxZoom:Ae,setTranslateExtent:ke,setNodeExtent:Ye,reset:ve}=Xe(AI,Et),we=Nt();return A.useEffect(()=>{const Ve=s==null?void 0:s.map(at=>({...at,...M}));return He(r,Ve),()=>{ve()}},[]),qe("defaultEdgeOptions",M,we.setState),qe("connectionMode",P,we.setState),qe("onConnect",o,we.setState),qe("onConnectStart",l,we.setState),qe("onConnectEnd",u,we.setState),qe("onClickConnectStart",c,we.setState),qe("onClickConnectEnd",p,we.setState),qe("nodesDraggable",h,we.setState),qe("nodesConnectable",f,we.setState),qe("nodesFocusable",m,we.setState),qe("edgesFocusable",y,we.setState),qe("edgesUpdatable",x,we.setState),qe("elementsSelectable",j,we.setState),qe("elevateNodesOnSelect",C,we.setState),qe("snapToGrid",L,we.setState),qe("snapGrid",O,we.setState),qe("onNodesChange",k,we.setState),qe("onEdgesChange",N,we.setState),qe("connectOnClick",T,we.setState),qe("fitViewOnInit",q,we.setState),qe("fitViewOnInitOptions",Y,we.setState),qe("onNodesDelete",X,we.setState),qe("onEdgesDelete",I,we.setState),qe("onNodeDrag",H,we.setState),qe("onNodeDragStart",U,we.setState),qe("onNodeDragStop",ne,we.setState),qe("onSelectionDrag",J,we.setState),qe("onSelectionDragStart",F,we.setState),qe("onSelectionDragStop",G,we.setState),qe("noPanClassName",E,we.setState),qe("nodeOrigin",$,we.setState),qe("rfId",se,we.setState),qe("autoPanOnConnect",D,we.setState),qe("autoPanOnNodeDrag",Q,we.setState),qe("onError",ee,we.setState),qe("connectionRadius",oe,we.setState),qe("isValidConnection",ue,we.setState),qe("nodeDragThreshold",ge,we.setState),Ps(e,de),Ps(n,Ie),Ps(_,Pe),Ps(S,Ae),Ps(B,ke),Ps(b,Ye),null},Ow={display:"none"},MI={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},WE="react-flow__node-desc",GE="react-flow__edge-desc",PI="react-flow__aria-live",OI=e=>e.ariaLiveMessage;function qI({rfId:e}){const n=Xe(OI);return ae.createElement("div",{id:`${PI}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:MI},n)}function LI({rfId:e,disableKeyboardA11y:n}){return ae.createElement(ae.Fragment,null,ae.createElement("div",{id:`${WE}-${e}`,style:Ow},"Press enter or space to select a node.",!n&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),ae.createElement("div",{id:`${GE}-${e}`,style:Ow},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!n&&ae.createElement(qI,{rfId:e}))}var ra=(e=null,n={actInsideInputWithModifier:!0})=>{const[r,s]=A.useState(!1),o=A.useRef(!1),l=A.useRef(new Set([])),[u,c]=A.useMemo(()=>{if(e!==null){const h=(Array.isArray(e)?e:[e]).filter(m=>typeof m=="string").map(m=>m.split("+")),f=h.reduce((m,y)=>m.concat(...y),[]);return[h,f]}return[[],[]]},[e]);return A.useEffect(()=>{const p=typeof document<"u"?document:null,h=(n==null?void 0:n.target)||p;if(e!==null){const f=x=>{if(o.current=x.ctrlKey||x.metaKey||x.shiftKey,(!o.current||o.current&&!n.actInsideInputWithModifier)&&qg(x))return!1;const _=Lw(x.code,c);l.current.add(x[_]),qw(u,l.current,!1)&&(x.preventDefault(),s(!0))},m=x=>{if((!o.current||o.current&&!n.actInsideInputWithModifier)&&qg(x))return!1;const _=Lw(x.code,c);qw(u,l.current,!0)?(s(!1),l.current.clear()):l.current.delete(x[_]),x.key==="Meta"&&l.current.clear(),o.current=!1},y=()=>{l.current.clear(),s(!1)};return h==null||h.addEventListener("keydown",f),h==null||h.addEventListener("keyup",m),window.addEventListener("blur",y),()=>{h==null||h.removeEventListener("keydown",f),h==null||h.removeEventListener("keyup",m),window.removeEventListener("blur",y)}}},[e,s]),r};function qw(e,n,r){return e.filter(s=>r||s.length===n.size).some(s=>s.every(o=>n.has(o)))}function Lw(e,n){return n.includes(e)?"code":"key"}function YE(e,n,r,s){var c,p;const o=e.parentNode||e.parentId;if(!o)return r;const l=n.get(o),u=Qi(l,s);return YE(l,n,{x:(r.x??0)+u.x,y:(r.y??0)+u.y,z:(((c=l[pt])==null?void 0:c.z)??0)>(r.z??0)?((p=l[pt])==null?void 0:p.z)??0:r.z??0},s)}function KE(e,n,r){e.forEach(s=>{var l;const o=s.parentNode||s.parentId;if(o&&!e.has(o))throw new Error(`Parent node ${o} not found`);if(o||r!=null&&r[s.id]){const{x:u,y:c,z:p}=YE(s,e,{...s.position,z:((l=s[pt])==null?void 0:l.z)??0},n);s.positionAbsolute={x:u,y:c},s[pt].z=p,r!=null&&r[s.id]&&(s[pt].isParent=!0)}})}function ed(e,n,r,s){const o=new Map,l={},u=s?1e3:0;return e.forEach(c=>{var x;const p=(Mn(c.zIndex)?c.zIndex:0)+(c.selected?u:0),h=n.get(c.id),f={...c,positionAbsolute:{x:c.position.x,y:c.position.y}},m=c.parentNode||c.parentId;m&&(l[m]=!0);const y=(h==null?void 0:h.type)&&(h==null?void 0:h.type)!==c.type;Object.defineProperty(f,pt,{enumerable:!1,value:{handleBounds:y||(x=h==null?void 0:h[pt])==null?void 0:x.handleBounds,z:p}}),o.set(c.id,f)}),KE(o,r,l),o}function XE(e,n={}){const{getNodes:r,width:s,height:o,minZoom:l,maxZoom:u,d3Zoom:c,d3Selection:p,fitViewOnInitDone:h,fitViewOnInit:f,nodeOrigin:m}=e(),y=n.initial&&!h&&f;if(c&&p&&(y||!n.initial)){const C=r().filter(S=>{var k;const b=n.includeHiddenNodes?S.width&&S.height:!S.hidden;return(k=n.nodes)!=null&&k.length?b&&n.nodes.some(N=>N.id===S.id):b}),_=C.every(S=>S.width&&S.height);if(C.length>0&&_){const S=Jl(C,m),{x:b,y:k,zoom:N}=OE(S,s,o,n.minZoom??l,n.maxZoom??u,n.padding??.1),j=Mr.translate(b,k).scale(N);return typeof n.duration=="number"&&n.duration>0?c.transform(Gi(p,n.duration),j):c.transform(p,j),!0}}return!1}function $I(e,n){return e.forEach(r=>{const s=n.get(r.id);s&&n.set(s.id,{...s,[pt]:s[pt],selected:r.selected})}),new Map(n)}function DI(e,n){return n.map(r=>{const s=e.find(o=>o.id===r.id);return s&&(r.selected=s.selected),r})}function bl({changedNodes:e,changedEdges:n,get:r,set:s}){const{nodeInternals:o,edges:l,onNodesChange:u,onEdgesChange:c,hasDefaultNodes:p,hasDefaultEdges:h}=r();e!=null&&e.length&&(p&&s({nodeInternals:$I(e,o)}),u==null||u(e)),n!=null&&n.length&&(h&&s({edges:DI(n,l)}),c==null||c(n))}const Os=()=>{},FI={zoomIn:Os,zoomOut:Os,zoomTo:Os,getZoom:()=>1,setViewport:Os,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Os,fitBounds:Os,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},zI=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),BI=()=>{const e=Nt(),{d3Zoom:n,d3Selection:r}=Xe(zI,Et);return A.useMemo(()=>r&&n?{zoomIn:o=>n.scaleBy(Gi(r,o==null?void 0:o.duration),1.2),zoomOut:o=>n.scaleBy(Gi(r,o==null?void 0:o.duration),1/1.2),zoomTo:(o,l)=>n.scaleTo(Gi(r,l==null?void 0:l.duration),o),getZoom:()=>e.getState().transform[2],setViewport:(o,l)=>{const[u,c,p]=e.getState().transform,h=Mr.translate(o.x??u,o.y??c).scale(o.zoom??p);n.transform(Gi(r,l==null?void 0:l.duration),h)},getViewport:()=>{const[o,l,u]=e.getState().transform;return{x:o,y:l,zoom:u}},fitView:o=>XE(e.getState,o),setCenter:(o,l,u)=>{const{width:c,height:p,maxZoom:h}=e.getState(),f=typeof(u==null?void 0:u.zoom)<"u"?u.zoom:h,m=c/2-o*f,y=p/2-l*f,x=Mr.translate(m,y).scale(f);n.transform(Gi(r,u==null?void 0:u.duration),x)},fitBounds:(o,l)=>{const{width:u,height:c,minZoom:p,maxZoom:h}=e.getState(),{x:f,y:m,zoom:y}=OE(o,u,c,p,h,(l==null?void 0:l.padding)??.1),x=Mr.translate(f,m).scale(y);n.transform(Gi(r,l==null?void 0:l.duration),x)},project:o=>{const{transform:l,snapToGrid:u,snapGrid:c}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),Dg(o,l,u,c)},screenToFlowPosition:o=>{const{transform:l,snapToGrid:u,snapGrid:c,domNode:p}=e.getState();if(!p)return o;const{x:h,y:f}=p.getBoundingClientRect(),m={x:o.x-h,y:o.y-f};return Dg(m,l,u,c)},flowToScreenPosition:o=>{const{transform:l,domNode:u}=e.getState();if(!u)return o;const{x:c,y:p}=u.getBoundingClientRect(),h=IE(o,l);return{x:h.x+c,y:h.y+p}},viewportInitialized:!0}:FI,[n,r])};function ua(){const e=BI(),n=Nt(),r=A.useCallback(()=>n.getState().getNodes().map(_=>({..._})),[]),s=A.useCallback(_=>n.getState().nodeInternals.get(_),[]),o=A.useCallback(()=>{const{edges:_=[]}=n.getState();return _.map(S=>({...S}))},[]),l=A.useCallback(_=>{const{edges:S=[]}=n.getState();return S.find(b=>b.id===_)},[]),u=A.useCallback(_=>{const{getNodes:S,setNodes:b,hasDefaultNodes:k,onNodesChange:N}=n.getState(),j=S(),P=typeof _=="function"?_(j):_;if(k)b(P);else if(N){const O=P.length===0?j.map(L=>({type:"remove",id:L.id})):P.map(L=>({item:L,type:"reset"}));N(O)}},[]),c=A.useCallback(_=>{const{edges:S=[],setEdges:b,hasDefaultEdges:k,onEdgesChange:N}=n.getState(),j=typeof _=="function"?_(S):_;if(k)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)}},[]),p=A.useCallback(_=>{const S=Array.isArray(_)?_:[_],{getNodes:b,setNodes:k,hasDefaultNodes:N,onNodesChange:j}=n.getState();if(N){const O=[...b(),...S];k(O)}else if(j){const P=S.map(O=>({item:O,type:"add"}));j(P)}},[]),h=A.useCallback(_=>{const S=Array.isArray(_)?_:[_],{edges:b=[],setEdges:k,hasDefaultEdges:N,onEdgesChange:j}=n.getState();if(N)k([...b,...S]);else if(j){const P=S.map(O=>({item:O,type:"add"}));j(P)}},[]),f=A.useCallback(()=>{const{getNodes:_,edges:S=[],transform:b}=n.getState(),[k,N,j]=b;return{nodes:_().map(P=>({...P})),edges:S.map(P=>({...P})),viewport:{x:k,y:N,zoom:j}}},[]),m=A.useCallback(({nodes:_,edges:S})=>{const{nodeInternals:b,getNodes:k,edges:N,hasDefaultNodes:j,hasDefaultEdges:P,onNodesDelete:O,onEdgesDelete:L,onNodesChange:B,onEdgesChange:T}=n.getState(),M=(_||[]).map(H=>H.id),q=(S||[]).map(H=>H.id),Y=k().reduce((H,U)=>{const ne=U.parentNode||U.parentId,J=!M.includes(U.id)&&ne&&H.find(G=>G.id===ne);return(typeof U.deletable=="boolean"?U.deletable:!0)&&(M.includes(U.id)||J)&&H.push(U),H},[]),X=N.filter(H=>typeof H.deletable=="boolean"?H.deletable:!0),I=X.filter(H=>q.includes(H.id));if(Y||I){const H=PE(Y,X),U=[...I,...H],ne=U.reduce((J,F)=>(J.includes(F.id)||J.push(F.id),J),[]);if((P||j)&&(P&&n.setState({edges:N.filter(J=>!ne.includes(J.id))}),j&&(Y.forEach(J=>{b.delete(J.id)}),n.setState({nodeInternals:new Map(b)}))),ne.length>0&&(L==null||L(U),T&&T(ne.map(J=>({id:J,type:"remove"})))),Y.length>0&&(O==null||O(Y),B)){const J=Y.map(F=>({id:F.id,type:"remove"}));B(J)}}},[]),y=A.useCallback(_=>{const S=lI(_),b=S?null:n.getState().nodeInternals.get(_.id);return!S&&!b?[null,null,S]:[S?_:jw(b),b,S]},[]),x=A.useCallback((_,S=!0,b)=>{const[k,N,j]=y(_);return k?(b||n.getState().getNodes()).filter(P=>{if(!j&&(P.id===N.id||!P.positionAbsolute))return!1;const O=jw(P),L=Og(O,k);return S&&L>0||L>=k.width*k.height}):[]},[]),C=A.useCallback((_,S,b=!0)=>{const[k]=y(_);if(!k)return!1;const N=Og(k,S);return b&&N>0||N>=k.width*k.height},[]);return A.useMemo(()=>({...e,getNodes:r,getNode:s,getEdges:o,getEdge:l,setNodes:u,setEdges:c,addNodes:p,addEdges:h,toObject:f,deleteElements:m,getIntersectingNodes:x,isNodeIntersecting:C}),[e,r,s,o,l,u,c,p,h,f,m,x,C])}const UI={actInsideInputWithModifier:!1};var HI=({deleteKeyCode:e,multiSelectionKeyCode:n})=>{const r=Nt(),{deleteElements:s}=ua(),o=ra(e,UI),l=ra(n);A.useEffect(()=>{if(o){const{edges:u,getNodes:c}=r.getState(),p=c().filter(f=>f.selected),h=u.filter(f=>f.selected);s({nodes:p,edges:h}),r.setState({nodesSelectionActive:!1})}},[o]),A.useEffect(()=>{r.setState({multiSelectionActive:l})},[l])};function VI(e){const n=Nt();A.useEffect(()=>{let r;const s=()=>{var l,u;if(!e.current)return;const o=iv(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&&(r=new ResizeObserver(()=>s()),r.observe(e.current)),()=>{window.removeEventListener("resize",s),r&&e.current&&r.unobserve(e.current)}},[])}const fv={position:"absolute",width:"100%",height:"100%",top:0,left:0},WI=(e,n)=>e.x!==n.x||e.y!==n.y||e.zoom!==n.k,kl=e=>({x:e.x,y:e.y,zoom:e.k}),qs=(e,n)=>e.target.closest(`.${n}`),$w=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),Dw=e=>{const n=e.ctrlKey&&zl()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n},GI=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),YI=({onMove:e,onMoveStart:n,onMoveEnd:r,onPaneContextMenu:s,zoomOnScroll:o=!0,zoomOnPinch:l=!0,panOnScroll:u=!1,panOnScrollSpeed:c=.5,panOnScrollMode:p=Ki.Free,zoomOnDoubleClick:h=!0,elementsSelectable:f,panOnDrag:m=!0,defaultViewport:y,translateExtent:x,minZoom:C,maxZoom:_,zoomActivationKeyCode:S,preventScrolling:b=!0,children:k,noWheelClassName:N,noPanClassName:j})=>{const P=A.useRef(),O=Nt(),L=A.useRef(!1),B=A.useRef(!1),T=A.useRef(null),M=A.useRef({x:0,y:0,zoom:0}),{d3Zoom:q,d3Selection:Y,d3ZoomHandler:X,userSelectionActive:I}=Xe(GI,Et),H=ra(S),U=A.useRef(0),ne=A.useRef(!1),J=A.useRef();return VI(T),A.useEffect(()=>{if(T.current){const F=T.current.getBoundingClientRect(),G=xE().scaleExtent([C,_]).translateExtent(x),E=In(T.current).call(G),$=Mr.translate(y.x,y.y).scale(Ks(y.zoom,C,_)),se=[[0,0],[F.width,F.height]],D=G.constrain()($,se,x);G.transform(E,D),G.wheelDelta(Dw),O.setState({d3Zoom:G,d3Selection:E,d3ZoomHandler:E.on("wheel.zoom"),transform:[D.x,D.y,D.k],domNode:T.current.closest(".react-flow")})}},[]),A.useEffect(()=>{Y&&q&&(u&&!H&&!I?Y.on("wheel.zoom",F=>{if(qs(F,N))return!1;F.preventDefault(),F.stopImmediatePropagation();const G=Y.property("__zoom").k||1;if(F.ctrlKey&&l){const ue=Kn(F),ge=Dw(F),de=G*Math.pow(2,ge);q.scaleTo(Y,de,ue,F);return}const E=F.deltaMode===1?20:1;let $=p===Ki.Vertical?0:F.deltaX*E,se=p===Ki.Horizontal?0:F.deltaY*E;!zl()&&F.shiftKey&&p!==Ki.Vertical&&($=F.deltaY*E,se=0),q.translateBy(Y,-($/G)*c,-(se/G)*c,{internal:!0});const D=kl(Y.property("__zoom")),{onViewportChangeStart:Q,onViewportChange:ee,onViewportChangeEnd:oe}=O.getState();clearTimeout(J.current),ne.current||(ne.current=!0,n==null||n(F,D),Q==null||Q(D)),ne.current&&(e==null||e(F,D),ee==null||ee(D),J.current=setTimeout(()=>{r==null||r(F,D),oe==null||oe(D),ne.current=!1},150))},{passive:!1}):typeof X<"u"&&Y.on("wheel.zoom",function(F,G){if(!b&&F.type==="wheel"&&!F.ctrlKey||qs(F,N))return null;F.preventDefault(),X.call(this,F,G)},{passive:!1}))},[I,u,p,Y,q,X,H,l,b,N,n,e,r]),A.useEffect(()=>{q&&q.on("start",F=>{var $,se;if(!F.sourceEvent||F.sourceEvent.internal)return null;U.current=($=F.sourceEvent)==null?void 0:$.button;const{onViewportChangeStart:G}=O.getState(),E=kl(F.transform);L.current=!0,M.current=E,((se=F.sourceEvent)==null?void 0:se.type)==="mousedown"&&O.setState({paneDragging:!0}),G==null||G(E),n==null||n(F.sourceEvent,E)})},[q,n]),A.useEffect(()=>{q&&(I&&!L.current?q.on("zoom",null):I||q.on("zoom",F=>{var E;const{onViewportChange:G}=O.getState();if(O.setState({transform:[F.transform.x,F.transform.y,F.transform.k]}),B.current=!!(s&&$w(m,U.current??0)),(e||G)&&!((E=F.sourceEvent)!=null&&E.internal)){const $=kl(F.transform);G==null||G($),e==null||e(F.sourceEvent,$)}}))},[I,q,e,m,s]),A.useEffect(()=>{q&&q.on("end",F=>{if(!F.sourceEvent||F.sourceEvent.internal)return null;const{onViewportChangeEnd:G}=O.getState();if(L.current=!1,O.setState({paneDragging:!1}),s&&$w(m,U.current??0)&&!B.current&&s(F.sourceEvent),B.current=!1,(r||G)&&WI(M.current,F.transform)){const E=kl(F.transform);M.current=E,clearTimeout(P.current),P.current=setTimeout(()=>{G==null||G(E),r==null||r(F.sourceEvent,E)},u?150:0)}})},[q,u,m,r,s]),A.useEffect(()=>{q&&q.filter(F=>{const G=H||o,E=l&&F.ctrlKey;if((m===!0||Array.isArray(m)&&m.includes(1))&&F.button===1&&F.type==="mousedown"&&(qs(F,"react-flow__node")||qs(F,"react-flow__edge")))return!0;if(!m&&!G&&!u&&!h&&!l||I||!h&&F.type==="dblclick"||qs(F,N)&&F.type==="wheel"||qs(F,j)&&(F.type!=="wheel"||u&&F.type==="wheel"&&!H)||!l&&F.ctrlKey&&F.type==="wheel"||!G&&!u&&!E&&F.type==="wheel"||!m&&(F.type==="mousedown"||F.type==="touchstart")||Array.isArray(m)&&!m.includes(F.button)&&F.type==="mousedown")return!1;const $=Array.isArray(m)&&m.includes(F.button)||!F.button||F.button<=1;return(!F.ctrlKey||F.type==="wheel")&&$})},[I,q,o,l,u,h,m,f,H]),ae.createElement("div",{className:"react-flow__renderer",ref:T,style:fv},k)},KI=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function XI(){const{userSelectionActive:e,userSelectionRect:n}=Xe(KI,Et);return e&&n?ae.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:n.width,height:n.height,transform:`translate(${n.x}px, ${n.y}px)`}}):null}function Fw(e,n){const r=n.parentNode||n.parentId,s=e.find(o=>o.id===r);if(s){const o=n.position.x+n.width-s.width,l=n.position.y+n.height-s.height;if(o>0||l>0||n.position.x<0||n.position.y<0){if(s.style={...s.style},s.style.width=s.style.width??s.width,s.style.height=s.style.height??s.height,o>0&&(s.style.width+=o),l>0&&(s.style.height+=l),n.position.x<0){const u=Math.abs(n.position.x);s.position.x=s.position.x-u,s.style.width+=u,n.position.x=0}if(n.position.y<0){const u=Math.abs(n.position.y);s.position.y=s.position.y-u,s.style.height+=u,n.position.y=0}s.width=s.style.width,s.height=s.style.height}}}function QI(e,n){if(e.some(s=>s.type==="reset"))return e.filter(s=>s.type==="reset").map(s=>s.item);const r=e.filter(s=>s.type==="add").map(s=>s.item);return n.reduce((s,o)=>{const l=e.filter(c=>c.id===o.id);if(l.length===0)return s.push(o),s;const u={...o};for(const c of l)if(c)switch(c.type){case"select":{u.selected=c.selected;break}case"position":{typeof c.position<"u"&&(u.position=c.position),typeof c.positionAbsolute<"u"&&(u.positionAbsolute=c.positionAbsolute),typeof c.dragging<"u"&&(u.dragging=c.dragging),u.expandParent&&Fw(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&&Fw(s,u);break}case"remove":return s}return s.push(u),s},r)}function ZI(e,n){return QI(e,n)}const gi=(e,n)=>({id:e,type:"select",selected:n});function Fs(e,n){return e.reduce((r,s)=>{const o=n.includes(s.id);return!s.selected&&o?(s.selected=!0,r.push(gi(s.id,!0))):s.selected&&!o&&(s.selected=!1,r.push(gi(s.id,!1))),r},[])}const td=(e,n)=>r=>{r.target===n.current&&(e==null||e(r))},JI=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),QE=A.memo(({isSelecting:e,selectionMode:n=na.Full,panOnDrag:r,onSelectionStart:s,onSelectionEnd:o,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:c,onPaneMouseEnter:p,onPaneMouseMove:h,onPaneMouseLeave:f,children:m})=>{const y=A.useRef(null),x=Nt(),C=A.useRef(0),_=A.useRef(0),S=A.useRef(),{userSelectionActive:b,elementsSelectable:k,dragging:N}=Xe(JI,Et),j=()=>{x.setState({userSelectionActive:!1,userSelectionRect:null}),C.current=0,_.current=0},P=X=>{l==null||l(X),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},O=X=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){X.preventDefault();return}u==null||u(X)},L=c?X=>c(X):void 0,B=X=>{const{resetSelectedElements:I,domNode:H}=x.getState();if(S.current=H==null?void 0:H.getBoundingClientRect(),!k||!e||X.button!==0||X.target!==y.current||!S.current)return;const{x:U,y:ne}=yi(X,S.current);I(),x.setState({userSelectionRect:{width:0,height:0,startX:U,startY:ne,x:U,y:ne}}),s==null||s(X)},T=X=>{const{userSelectionRect:I,nodeInternals:H,edges:U,transform:ne,onNodesChange:J,onEdgesChange:F,nodeOrigin:G,getNodes:E}=x.getState();if(!e||!S.current||!I)return;x.setState({userSelectionActive:!0,nodesSelectionActive:!1});const $=yi(X,S.current),se=I.startX??0,D=I.startY??0,Q={...I,x:$.x<se?$.x:se,y:$.y<D?$.y:D,width:Math.abs($.x-se),height:Math.abs($.y-D)},ee=E(),oe=ME(H,Q,ne,n===na.Partial,!0,G),ue=PE(oe,U).map(de=>de.id),ge=oe.map(de=>de.id);if(C.current!==ge.length){C.current=ge.length;const de=Fs(ee,ge);de.length&&(J==null||J(de))}if(_.current!==ue.length){_.current=ue.length;const de=Fs(U,ue);de.length&&(F==null||F(de))}x.setState({userSelectionRect:Q})},M=X=>{if(X.button!==0)return;const{userSelectionRect:I}=x.getState();!b&&I&&X.target===y.current&&(P==null||P(X)),x.setState({nodesSelectionActive:C.current>0}),j(),o==null||o(X)},q=X=>{b&&(x.setState({nodesSelectionActive:C.current>0}),o==null||o(X)),j()},Y=k&&(e||b);return ae.createElement("div",{className:Ot(["react-flow__pane",{dragging:N,selection:e}]),onClick:Y?void 0:td(P,y),onContextMenu:td(O,y),onWheel:td(L,y),onMouseEnter:Y?void 0:p,onMouseDown:Y?B:void 0,onMouseMove:Y?T:h,onMouseUp:Y?M:void 0,onMouseLeave:Y?q:f,ref:y,style:fv},m,ae.createElement(XI,null))});QE.displayName="Pane";function ZE(e,n){const r=e.parentNode||e.parentId;if(!r)return!1;const s=n.get(r);return s?s.selected?!0:ZE(s,n):!1}function zw(e,n,r){let s=e;do{if(s!=null&&s.matches(n))return!0;if(s===r.current)return!1;s=s.parentElement}while(s);return!1}function eM(e,n,r,s){return Array.from(e.values()).filter(o=>(o.selected||o.id===s)&&(!o.parentNode||o.parentId||!ZE(o,e))&&(o.draggable||n&&typeof o.draggable>"u")).map(o=>{var l,u;return{id:o.id,position:o.position||{x:0,y:0},positionAbsolute:o.positionAbsolute||{x:0,y:0},distance:{x:r.x-(((l=o.positionAbsolute)==null?void 0:l.x)??0),y:r.y-(((u=o.positionAbsolute)==null?void 0:u.y)??0)},delta:{x:0,y:0},extent:o.extent,parentNode:o.parentNode||o.parentId,parentId:o.parentNode||o.parentId,width:o.width,height:o.height,expandParent:o.expandParent}})}function tM(e,n){return!n||n==="parent"?n:[n[0],[n[1][0]-(e.width||0),n[1][1]-(e.height||0)]]}function JE(e,n,r,s,o=[0,0],l){const u=tM(e,e.extent||s);let c=u;const p=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(p&&e.width&&e.height){const m=r.get(p),{x:y,y:x}=Qi(m,o).positionAbsolute;c=m&&Mn(y)&&Mn(x)&&Mn(m.width)&&Mn(m.height)?[[y+e.width*o[0],x+e.height*o[1]],[y+m.width-e.width+e.width*o[0],x+m.height-e.height+e.height*o[1]]]:c}else l==null||l("005",Or.error005()),c=u;else if(e.extent&&p&&e.extent!=="parent"){const m=r.get(p),{x:y,y:x}=Qi(m,o).positionAbsolute;c=[[e.extent[0][0]+y,e.extent[0][1]+x],[e.extent[1][0]+y,e.extent[1][1]+x]]}let h={x:0,y:0};if(p){const m=r.get(p);h=Qi(m,o).positionAbsolute}const f=c&&c!=="parent"?sv(n,c):n;return{position:{x:f.x-h.x,y:f.y-h.y},positionAbsolute:f}}function nd({nodeId:e,dragItems:n,nodeInternals:r}){const s=n.map(o=>({...r.get(o.id),position:o.position,positionAbsolute:o.positionAbsolute}));return[e?s.find(o=>o.id===e):s[0],s]}const Bw=(e,n,r,s)=>{const o=n.querySelectorAll(e);if(!o||!o.length)return null;const l=Array.from(o),u=n.getBoundingClientRect(),c={x:u.width*s[0],y:u.height*s[1]};return l.map(p=>{const h=p.getBoundingClientRect();return{id:p.getAttribute("data-handleid"),position:p.getAttribute("data-handlepos"),x:(h.left-u.left-c.x)/r,y:(h.top-u.top-c.y)/r,...iv(p)}})};function Bo(e,n,r){return r===void 0?r:s=>{const o=n().nodeInternals.get(e);o&&r(s,{...o})}}function zg({id:e,store:n,unselect:r=!1,nodeRef:s}){const{addSelectedNodes:o,unselectNodesAndEdges:l,multiSelectionActive:u,nodeInternals:c,onError:p}=n.getState(),h=c.get(e);if(!h){p==null||p("012",Or.error012(e));return}n.setState({nodesSelectionActive:!1}),h.selected?(r||h.selected&&u)&&(l({nodes:[h],edges:[]}),requestAnimationFrame(()=>{var f;return(f=s==null?void 0:s.current)==null?void 0:f.blur()})):o([e])}function nM(){const e=Nt();return A.useCallback(({sourceEvent:r})=>{const{transform:s,snapGrid:o,snapToGrid:l}=e.getState(),u=r.touches?r.touches[0].clientX:r.clientX,c=r.touches?r.touches[0].clientY:r.clientY,p={x:(u-s[0])/s[2],y:(c-s[1])/s[2]};return{xSnapped:l?o[0]*Math.round(p.x/o[0]):p.x,ySnapped:l?o[1]*Math.round(p.y/o[1]):p.y,...p}},[])}function rd(e){return(n,r,s)=>e==null?void 0:e(n,s)}function eN({nodeRef:e,disabled:n=!1,noDragClassName:r,handleSelector:s,nodeId:o,isSelectable:l,selectNodesOnDrag:u}){const c=Nt(),[p,h]=A.useState(!1),f=A.useRef([]),m=A.useRef({x:null,y:null}),y=A.useRef(0),x=A.useRef(null),C=A.useRef({x:0,y:0}),_=A.useRef(null),S=A.useRef(!1),b=A.useRef(!1),k=A.useRef(!1),N=nM();return A.useEffect(()=>{if(e!=null&&e.current){const j=In(e.current),P=({x:B,y:T})=>{const{nodeInternals:M,onNodeDrag:q,onSelectionDrag:Y,updateNodePositions:X,nodeExtent:I,snapGrid:H,snapToGrid:U,nodeOrigin:ne,onError:J}=c.getState();m.current={x:B,y:T};let F=!1,G={x:0,y:0,x2:0,y2:0};if(f.current.length>1&&I){const $=Jl(f.current,ne);G=ta($)}if(f.current=f.current.map($=>{const se={x:B-$.distance.x,y:T-$.distance.y};U&&(se.x=H[0]*Math.round(se.x/H[0]),se.y=H[1]*Math.round(se.y/H[1]));const D=[[I[0][0],I[0][1]],[I[1][0],I[1][1]]];f.current.length>1&&I&&!$.extent&&(D[0][0]=$.positionAbsolute.x-G.x+I[0][0],D[1][0]=$.positionAbsolute.x+($.width??0)-G.x2+I[1][0],D[0][1]=$.positionAbsolute.y-G.y+I[0][1],D[1][1]=$.positionAbsolute.y+($.height??0)-G.y2+I[1][1]);const Q=JE($,se,M,D,ne,J);return F=F||$.position.x!==Q.position.x||$.position.y!==Q.position.y,$.position=Q.position,$.positionAbsolute=Q.positionAbsolute,$}),!F)return;X(f.current,!0,!0),h(!0);const E=o?q:rd(Y);if(E&&_.current){const[$,se]=nd({nodeId:o,dragItems:f.current,nodeInternals:M});E(_.current,$,se)}},O=()=>{if(!x.current)return;const[B,T]=SE(C.current,x.current);if(B!==0||T!==0){const{transform:M,panBy:q}=c.getState();m.current.x=(m.current.x??0)-B/M[2],m.current.y=(m.current.y??0)-T/M[2],q({x:B,y:T})&&P(m.current)}y.current=requestAnimationFrame(O)},L=B=>{var ne;const{nodeInternals:T,multiSelectionActive:M,nodesDraggable:q,unselectNodesAndEdges:Y,onNodeDragStart:X,onSelectionDragStart:I}=c.getState();b.current=!0;const H=o?X:rd(I);(!u||!l)&&!M&&o&&((ne=T.get(o))!=null&&ne.selected||Y()),o&&l&&u&&zg({id:o,store:c,nodeRef:e});const U=N(B);if(m.current=U,f.current=eM(T,q,U,o),H&&f.current){const[J,F]=nd({nodeId:o,dragItems:f.current,nodeInternals:T});H(B.sourceEvent,J,F)}};if(n)j.on(".drag",null);else{const B=d2().on("start",T=>{const{domNode:M,nodeDragThreshold:q}=c.getState();q===0&&L(T),k.current=!1;const Y=N(T);m.current=Y,x.current=(M==null?void 0:M.getBoundingClientRect())||null,C.current=yi(T.sourceEvent,x.current)}).on("drag",T=>{var X,I;const M=N(T),{autoPanOnNodeDrag:q,nodeDragThreshold:Y}=c.getState();if(T.sourceEvent.type==="touchmove"&&T.sourceEvent.touches.length>1&&(k.current=!0),!k.current){if(!S.current&&b.current&&q&&(S.current=!0,O()),!b.current){const H=M.xSnapped-(((X=m==null?void 0:m.current)==null?void 0:X.x)??0),U=M.ySnapped-(((I=m==null?void 0:m.current)==null?void 0:I.y)??0);Math.sqrt(H*H+U*U)>Y&&L(T)}(m.current.x!==M.xSnapped||m.current.y!==M.ySnapped)&&f.current&&b.current&&(_.current=T.sourceEvent,C.current=yi(T.sourceEvent,x.current),P(M))}}).on("end",T=>{if(!(!b.current||k.current)&&(h(!1),S.current=!1,b.current=!1,cancelAnimationFrame(y.current),f.current)){const{updateNodePositions:M,nodeInternals:q,onNodeDragStop:Y,onSelectionDragStop:X}=c.getState(),I=o?Y:rd(X);if(M(f.current,!1,!1),I){const[H,U]=nd({nodeId:o,dragItems:f.current,nodeInternals:q});I(T.sourceEvent,H,U)}}}).filter(T=>{const M=T.target;return!T.button&&(!r||!zw(M,`.${r}`,e))&&(!s||zw(M,s,e))});return j.call(B),()=>{j.on(".drag",null)}}}},[e,n,r,s,l,c,o,u,N]),p}function tN(){const e=Nt();return A.useCallback(r=>{const{nodeInternals:s,nodeExtent:o,updateNodePositions:l,getNodes:u,snapToGrid:c,snapGrid:p,onError:h,nodesDraggable:f}=e.getState(),m=u().filter(k=>k.selected&&(k.draggable||f&&typeof k.draggable>"u")),y=c?p[0]:5,x=c?p[1]:5,C=r.isShiftPressed?4:1,_=r.x*y*C,S=r.y*x*C,b=m.map(k=>{if(k.positionAbsolute){const N={x:k.positionAbsolute.x+_,y:k.positionAbsolute.y+S};c&&(N.x=p[0]*Math.round(N.x/p[0]),N.y=p[1]*Math.round(N.y/p[1]));const{positionAbsolute:j,position:P}=JE(k,N,s,o,void 0,h);k.position=P,k.positionAbsolute=j}return k});l(b,!0,!1)},[])}const Vs={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var Uo=e=>{const n=({id:r,type:s,data:o,xPos:l,yPos:u,xPosOrigin:c,yPosOrigin:p,selected:h,onClick:f,onMouseEnter:m,onMouseMove:y,onMouseLeave:x,onContextMenu:C,onDoubleClick:_,style:S,className:b,isDraggable:k,isSelectable:N,isConnectable:j,isFocusable:P,selectNodesOnDrag:O,sourcePosition:L,targetPosition:B,hidden:T,resizeObserver:M,dragHandle:q,zIndex:Y,isParent:X,noDragClassName:I,noPanClassName:H,initialized:U,disableKeyboardA11y:ne,ariaLabel:J,rfId:F,hasHandleBounds:G})=>{const E=Nt(),$=A.useRef(null),se=A.useRef(null),D=A.useRef(L),Q=A.useRef(B),ee=A.useRef(s),oe=N||k||f||m||y||x,ue=tN(),ge=Bo(r,E.getState,m),de=Bo(r,E.getState,y),Ie=Bo(r,E.getState,x),He=Bo(r,E.getState,C),Pe=Bo(r,E.getState,_),Ae=ve=>{const{nodeDragThreshold:we}=E.getState();if(N&&(!O||!k||we>0)&&zg({id:r,store:E,nodeRef:$}),f){const Ve=E.getState().nodeInternals.get(r);Ve&&f(ve,{...Ve})}},ke=ve=>{if(!qg(ve)&&!ne)if(NE.includes(ve.key)&&N){const we=ve.key==="Escape";zg({id:r,store:E,unselect:we,nodeRef:$})}else k&&h&&Object.prototype.hasOwnProperty.call(Vs,ve.key)&&(E.setState({ariaLiveMessage:`Moved selected node ${ve.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~l}, y: ${~~u}`}),ue({x:Vs[ve.key].x,y:Vs[ve.key].y,isShiftPressed:ve.shiftKey}))};A.useEffect(()=>()=>{se.current&&(M==null||M.unobserve(se.current),se.current=null)},[]),A.useEffect(()=>{if($.current&&!T){const ve=$.current;(!U||!G||se.current!==ve)&&(se.current&&(M==null||M.unobserve(se.current)),M==null||M.observe(ve),se.current=ve)}},[T,U,G]),A.useEffect(()=>{const ve=ee.current!==s,we=D.current!==L,Ve=Q.current!==B;$.current&&(ve||we||Ve)&&(ve&&(ee.current=s),we&&(D.current=L),Ve&&(Q.current=B),E.getState().updateNodeDimensions([{id:r,nodeElement:$.current,forceUpdate:!0}]))},[r,s,L,B]);const Ye=eN({nodeRef:$,disabled:T||!k,noDragClassName:I,handleSelector:q,nodeId:r,isSelectable:N,selectNodesOnDrag:O});return T?null:ae.createElement("div",{className:Ot(["react-flow__node",`react-flow__node-${s}`,{[H]:k},b,{selected:h,selectable:N,parent:X,dragging:Ye}]),ref:$,style:{zIndex:Y,transform:`translate(${c}px,${p}px)`,pointerEvents:oe?"all":"none",visibility:U?"visible":"hidden",...S},"data-id":r,"data-testid":`rf__node-${r}`,onMouseEnter:ge,onMouseMove:de,onMouseLeave:Ie,onContextMenu:He,onClick:Ae,onDoubleClick:Pe,onKeyDown:P?ke:void 0,tabIndex:P?0:void 0,role:P?"button":void 0,"aria-describedby":ne?void 0:`${WE}-${F}`,"aria-label":J},ae.createElement(mI,{value:r},ae.createElement(e,{id:r,data:o,type:s,xPos:l,yPos:u,selected:h,isConnectable:j,sourcePosition:L,targetPosition:B,dragging:Ye,dragHandle:q,zIndex:Y})))};return n.displayName="NodeWrapper",A.memo(n)};const rM=e=>{const n=e.getNodes().filter(r=>r.selected);return{...Jl(n,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function iM({onSelectionContextMenu:e,noPanClassName:n,disableKeyboardA11y:r}){const s=Nt(),{width:o,height:l,x:u,y:c,transformString:p,userSelectionActive:h}=Xe(rM,Et),f=tN(),m=A.useRef(null);if(A.useEffect(()=>{var C;r||(C=m.current)==null||C.focus({preventScroll:!0})},[r]),eN({nodeRef:m}),h||!o||!l)return null;const y=e?C=>{const _=s.getState().getNodes().filter(S=>S.selected);e(C,_)}:void 0,x=C=>{Object.prototype.hasOwnProperty.call(Vs,C.key)&&f({x:Vs[C.key].x,y:Vs[C.key].y,isShiftPressed:C.shiftKey})};return ae.createElement("div",{className:Ot(["react-flow__nodesselection","react-flow__container",n]),style:{transform:p}},ae.createElement("div",{ref:m,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:r?void 0:-1,onKeyDown:r?void 0:x,style:{width:o,height:l,top:c,left:u}}))}var sM=A.memo(iM);const oM=e=>e.nodesSelectionActive,nN=({children:e,onPaneClick:n,onPaneMouseEnter:r,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:l,onPaneScroll:u,deleteKeyCode:c,onMove:p,onMoveStart:h,onMoveEnd:f,selectionKeyCode:m,selectionOnDrag:y,selectionMode:x,onSelectionStart:C,onSelectionEnd:_,multiSelectionKeyCode:S,panActivationKeyCode:b,zoomActivationKeyCode:k,elementsSelectable:N,zoomOnScroll:j,zoomOnPinch:P,panOnScroll:O,panOnScrollSpeed:L,panOnScrollMode:B,zoomOnDoubleClick:T,panOnDrag:M,defaultViewport:q,translateExtent:Y,minZoom:X,maxZoom:I,preventScrolling:H,onSelectionContextMenu:U,noWheelClassName:ne,noPanClassName:J,disableKeyboardA11y:F})=>{const G=Xe(oM),E=ra(m),$=ra(b),se=$||M,D=$||O,Q=E||y&&se!==!0;return HI({deleteKeyCode:c,multiSelectionKeyCode:S}),ae.createElement(YI,{onMove:p,onMoveStart:h,onMoveEnd:f,onPaneContextMenu:l,elementsSelectable:N,zoomOnScroll:j,zoomOnPinch:P,panOnScroll:D,panOnScrollSpeed:L,panOnScrollMode:B,zoomOnDoubleClick:T,panOnDrag:!E&&se,defaultViewport:q,translateExtent:Y,minZoom:X,maxZoom:I,zoomActivationKeyCode:k,preventScrolling:H,noWheelClassName:ne,noPanClassName:J},ae.createElement(QE,{onSelectionStart:C,onSelectionEnd:_,onPaneClick:n,onPaneMouseEnter:r,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:l,onPaneScroll:u,panOnDrag:se,isSelecting:!!Q,selectionMode:x},e,G&&ae.createElement(sM,{onSelectionContextMenu:U,noPanClassName:J,disableKeyboardA11y:F})))};nN.displayName="FlowRenderer";var aM=A.memo(nN);function lM(e){return Xe(A.useCallback(r=>e?ME(r.nodeInternals,{x:0,y:0,width:r.width,height:r.height},r.transform,!0):r.getNodes(),[e]))}function uM(e){const n={input:Uo(e.input||BE),default:Uo(e.default||Fg),output:Uo(e.output||HE),group:Uo(e.group||dv)},r={},s=Object.keys(e).filter(o=>!["input","default","output","group"].includes(o)).reduce((o,l)=>(o[l]=Uo(e[l]||Fg),o),r);return{...n,...s}}const cM=({x:e,y:n,width:r,height:s,origin:o})=>!r||!s?{x:e,y:n}:o[0]<0||o[1]<0||o[0]>1||o[1]>1?{x:e,y:n}:{x:e-r*o[0],y:n-s*o[1]},dM=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),rN=e=>{const{nodesDraggable:n,nodesConnectable:r,nodesFocusable:s,elementsSelectable:o,updateNodeDimensions:l,onError:u}=Xe(dM,Et),c=lM(e.onlyRenderVisibleElements),p=A.useRef(),h=A.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const f=new ResizeObserver(m=>{const y=m.map(x=>({id:x.target.getAttribute("data-id"),nodeElement:x.target,forceUpdate:!0}));l(y)});return p.current=f,f},[]);return A.useEffect(()=>()=>{var f;(f=p==null?void 0:p.current)==null||f.disconnect()},[]),ae.createElement("div",{className:"react-flow__nodes",style:fv},c.map(f=>{var P,O,L;let m=f.type||"default";e.nodeTypes[m]||(u==null||u("003",Or.error003(m)),m="default");const y=e.nodeTypes[m]||e.nodeTypes.default,x=!!(f.draggable||n&&typeof f.draggable>"u"),C=!!(f.selectable||o&&typeof f.selectable>"u"),_=!!(f.connectable||r&&typeof f.connectable>"u"),S=!!(f.focusable||s&&typeof f.focusable>"u"),b=e.nodeExtent?sv(f.positionAbsolute,e.nodeExtent):f.positionAbsolute,k=(b==null?void 0:b.x)??0,N=(b==null?void 0:b.y)??0,j=cM({x:k,y:N,width:f.width??0,height:f.height??0,origin:e.nodeOrigin});return ae.createElement(y,{key:f.id,id:f.id,className:f.className,style:f.style,type:m,data:f.data,sourcePosition:f.sourcePosition||Ce.Bottom,targetPosition:f.targetPosition||Ce.Top,hidden:f.hidden,xPos:k,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:!!f.selected,isDraggable:x,isSelectable:C,isConnectable:_,isFocusable:S,resizeObserver:h,dragHandle:f.dragHandle,zIndex:((P=f[pt])==null?void 0:P.z)??0,isParent:!!((O=f[pt])!=null&&O.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!f.width&&!!f.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:f.ariaLabel,hasHandleBounds:!!((L=f[pt])!=null&&L.handleBounds)})}))};rN.displayName="NodeRenderer";var fM=A.memo(rN);const hM=(e,n,r)=>r===Ce.Left?e-n:r===Ce.Right?e+n:e,pM=(e,n,r)=>r===Ce.Top?e-n:r===Ce.Bottom?e+n:e,Uw="react-flow__edgeupdater",Hw=({position:e,centerX:n,centerY:r,radius:s=10,onMouseDown:o,onMouseEnter:l,onMouseOut:u,type:c})=>ae.createElement("circle",{onMouseDown:o,onMouseEnter:l,onMouseOut:u,className:Ot([Uw,`${Uw}-${c}`]),cx:hM(n,s,e),cy:pM(r,s,e),r:s,stroke:"transparent",fill:"transparent"}),mM=()=>!0;var Ls=e=>{const n=({id:r,className:s,type:o,data:l,onClick:u,onEdgeDoubleClick:c,selected:p,animated:h,label:f,labelStyle:m,labelShowBg:y,labelBgStyle:x,labelBgPadding:C,labelBgBorderRadius:_,style:S,source:b,target:k,sourceX:N,sourceY:j,targetX:P,targetY:O,sourcePosition:L,targetPosition:B,elementsSelectable:T,hidden:M,sourceHandleId:q,targetHandleId:Y,onContextMenu:X,onMouseEnter:I,onMouseMove:H,onMouseLeave:U,reconnectRadius:ne,onReconnect:J,onReconnectStart:F,onReconnectEnd:G,markerEnd:E,markerStart:$,rfId:se,ariaLabel:D,isFocusable:Q,isReconnectable:ee,pathOptions:oe,interactionWidth:ue,disableKeyboardA11y:ge})=>{const de=A.useRef(null),[Ie,He]=A.useState(!1),[Pe,Ae]=A.useState(!1),ke=Nt(),Ye=A.useMemo(()=>`url('#${$g($,se)}')`,[$,se]),ve=A.useMemo(()=>`url('#${$g(E,se)}')`,[E,se]);if(M)return null;const we=Ze=>{var Lt;const{edges:yt,addSelectedEdges:Le,unselectNodesAndEdges:wt,multiSelectionActive:Bt}=ke.getState(),Ut=yt.find(Ht=>Ht.id===r);Ut&&(T&&(ke.setState({nodesSelectionActive:!1}),Ut.selected&&Bt?(wt({nodes:[],edges:[Ut]}),(Lt=de.current)==null||Lt.blur()):Le([r])),u&&u(Ze,Ut))},Ve=zo(r,ke.getState,c),at=zo(r,ke.getState,X),lt=zo(r,ke.getState,I),We=zo(r,ke.getState,H),$e=zo(r,ke.getState,U),it=(Ze,yt)=>{if(Ze.button!==0)return;const{edges:Le,isValidConnection:wt}=ke.getState(),Bt=yt?k:b,Ut=(yt?Y:q)||null,Lt=yt?"target":"source",Ht=wt||mM,qn=yt,Ln=Le.find(ln=>ln.id===r);Ae(!0),F==null||F(Ze,Ln,Lt);const wn=ln=>{Ae(!1),G==null||G(ln,Ln,Lt)};$E({event:Ze,handleId:Ut,nodeId:Bt,onConnect:ln=>J==null?void 0:J(Ln,ln),isTarget:qn,getState:ke.getState,setState:ke.setState,isValidConnection:Ht,edgeUpdaterType:Lt,onReconnectEnd:wn})},vt=Ze=>it(Ze,!0),tt=Ze=>it(Ze,!1),qt=()=>He(!0),mt=()=>He(!1),Tt=!T&&!u,At=Ze=>{var yt;if(!ge&&NE.includes(Ze.key)&&T){const{unselectNodesAndEdges:Le,addSelectedEdges:wt,edges:Bt}=ke.getState();Ze.key==="Escape"?((yt=de.current)==null||yt.blur(),Le({edges:[Bt.find(Lt=>Lt.id===r)]})):wt([r])}};return ae.createElement("g",{className:Ot(["react-flow__edge",`react-flow__edge-${o}`,s,{selected:p,animated:h,inactive:Tt,updating:Ie}]),onClick:we,onDoubleClick:Ve,onContextMenu:at,onMouseEnter:lt,onMouseMove:We,onMouseLeave:$e,onKeyDown:Q?At:void 0,tabIndex:Q?0:void 0,role:Q?"button":"img","data-testid":`rf__edge-${r}`,"aria-label":D===null?void 0:D||`Edge from ${b} to ${k}`,"aria-describedby":Q?`${GE}-${se}`:void 0,ref:de},!Pe&&ae.createElement(e,{id:r,source:b,target:k,selected:p,animated:h,label:f,labelStyle:m,labelShowBg:y,labelBgStyle:x,labelBgPadding:C,labelBgBorderRadius:_,data:l,style:S,sourceX:N,sourceY:j,targetX:P,targetY:O,sourcePosition:L,targetPosition:B,sourceHandleId:q,targetHandleId:Y,markerStart:Ye,markerEnd:ve,pathOptions:oe,interactionWidth:ue}),ee&&ae.createElement(ae.Fragment,null,(ee==="source"||ee===!0)&&ae.createElement(Hw,{position:L,centerX:N,centerY:j,radius:ne,onMouseDown:vt,onMouseEnter:qt,onMouseOut:mt,type:"source"}),(ee==="target"||ee===!0)&&ae.createElement(Hw,{position:B,centerX:P,centerY:O,radius:ne,onMouseDown:tt,onMouseEnter:qt,onMouseOut:mt,type:"target"})))};return n.displayName="EdgeWrapper",A.memo(n)};function gM(e){const n={default:Ls(e.default||Ul),straight:Ls(e.bezier||lv),step:Ls(e.step||av),smoothstep:Ls(e.step||Zl),simplebezier:Ls(e.simplebezier||ov)},r={},s=Object.keys(e).filter(o=>!["default","bezier"].includes(o)).reduce((o,l)=>(o[l]=Ls(e[l]||Ul),o),r);return{...n,...s}}function Vw(e,n,r=null){const s=((r==null?void 0:r.x)||0)+n.x,o=((r==null?void 0:r.y)||0)+n.y,l=(r==null?void 0:r.width)||n.width,u=(r==null?void 0:r.height)||n.height;switch(e){case 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 Ww(e,n){return e?e.length===1||!n?e[0]:n&&e.find(r=>r.id===n)||null:null}const vM=(e,n,r,s,o,l)=>{const u=Vw(r,e,n),c=Vw(l,s,o);return{sourceX:u.x,sourceY:u.y,targetX:c.x,targetY:c.y}};function yM({sourcePos:e,targetPos:n,sourceWidth:r,sourceHeight:s,targetWidth:o,targetHeight:l,width:u,height:c,transform:p}){const h={x:Math.min(e.x,n.x),y:Math.min(e.y,n.y),x2:Math.max(e.x+r,n.x+o),y2:Math.max(e.y+s,n.y+l)};h.x===h.x2&&(h.x2+=1),h.y===h.y2&&(h.y2+=1);const f=ta({x:(0-p[0])/p[2],y:(0-p[1])/p[2],width:u/p[2],height:c/p[2]}),m=Math.max(0,Math.min(f.x2,h.x2)-Math.max(f.x,h.x)),y=Math.max(0,Math.min(f.y2,h.y2)-Math.max(f.y,h.y));return Math.ceil(m*y)>0}function Gw(e){var s,o,l,u,c;const n=((s=e==null?void 0:e[pt])==null?void 0:s.handleBounds)||null,r=n&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((o=e==null?void 0:e.positionAbsolute)==null?void 0:o.x)<"u"&&typeof((l=e==null?void 0:e.positionAbsolute)==null?void 0:l.y)<"u";return[{x:((u=e==null?void 0:e.positionAbsolute)==null?void 0:u.x)||0,y:((c=e==null?void 0:e.positionAbsolute)==null?void 0:c.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},n,!!r]}const wM=[{level:0,isMaxLevel:!0,edges:[]}];function xM(e,n,r=!1){let s=-1;const o=e.reduce((u,c)=>{var f,m;const p=Mn(c.zIndex);let h=p?c.zIndex:0;if(r){const y=n.get(c.target),x=n.get(c.source),C=c.selected||(y==null?void 0:y.selected)||(x==null?void 0:x.selected),_=Math.max(((f=x==null?void 0:x[pt])==null?void 0:f.z)||0,((m=y==null?void 0:y[pt])==null?void 0:m.z)||0,1e3);h=(p?c.zIndex:0)+(C?_:0)}return u[h]?u[h].push(c):u[h]=[c],s=h>s?h:s,u},{}),l=Object.entries(o).map(([u,c])=>{const p=+u;return{edges:c,level:p,isMaxLevel:p===s}});return l.length===0?wM:l}function _M(e,n,r){const s=Xe(A.useCallback(o=>e?o.edges.filter(l=>{const u=n.get(l.source),c=n.get(l.target);return(u==null?void 0:u.width)&&(u==null?void 0:u.height)&&(c==null?void 0:c.width)&&(c==null?void 0:c.height)&&yM({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 xM(s,n,r)}const SM=({color:e="none",strokeWidth:n=1})=>ae.createElement("polyline",{style:{stroke:e,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),bM=({color:e="none",strokeWidth:n=1})=>ae.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),Yw={[Bl.Arrow]:SM,[Bl.ArrowClosed]:bM};function kM(e){const n=Nt();return A.useMemo(()=>{var o,l;return Object.prototype.hasOwnProperty.call(Yw,e)?Yw[e]:((l=(o=n.getState()).onError)==null||l.call(o,"009",Or.error009(e)),null)},[e])}const EM=({id:e,type:n,color:r,width:s=12.5,height:o=12.5,markerUnits:l="strokeWidth",strokeWidth:u,orient:c="auto-start-reverse"})=>{const p=kM(n);return p?ae.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:l,orient:c,refX:"0",refY:"0"},ae.createElement(p,{color:r,strokeWidth:u})):null},NM=({defaultColor:e,rfId:n})=>r=>{const s=[];return r.edges.reduce((o,l)=>([l.markerStart,l.markerEnd].forEach(u=>{if(u&&typeof u=="object"){const c=$g(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))},iN=({defaultColor:e,rfId:n})=>{const r=Xe(A.useCallback(NM({defaultColor:e,rfId:n}),[e,n]),(s,o)=>!(s.length!==o.length||s.some((l,u)=>l.id!==o[u].id)));return ae.createElement("defs",null,r.map(s=>ae.createElement(EM,{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})))};iN.displayName="MarkerDefinitions";var CM=A.memo(iN);const jM=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),sN=({defaultMarkerColor:e,onlyRenderVisibleElements:n,elevateEdgesOnSelect:r,rfId:s,edgeTypes:o,noPanClassName:l,onEdgeContextMenu:u,onEdgeMouseEnter:c,onEdgeMouseMove:p,onEdgeMouseLeave:h,onEdgeClick:f,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:x,onReconnectEnd:C,reconnectRadius:_,children:S,disableKeyboardA11y:b})=>{const{edgesFocusable:k,edgesUpdatable:N,elementsSelectable:j,width:P,height:O,connectionMode:L,nodeInternals:B,onError:T}=Xe(jM,Et),M=_M(n,B,r);return P?ae.createElement(ae.Fragment,null,M.map(({level:q,edges:Y,isMaxLevel:X})=>ae.createElement("svg",{key:q,style:{zIndex:q},width:P,height:O,className:"react-flow__edges react-flow__container"},X&&ae.createElement(CM,{defaultColor:e,rfId:s}),ae.createElement("g",null,Y.map(I=>{const[H,U,ne]=Gw(B.get(I.source)),[J,F,G]=Gw(B.get(I.target));if(!ne||!G)return null;let E=I.type||"default";o[E]||(T==null||T("011",Or.error011(E)),E="default");const $=o[E]||o.default,se=L===es.Strict?F.target:(F.target??[]).concat(F.source??[]),D=Ww(U.source,I.sourceHandle),Q=Ww(se,I.targetHandle),ee=(D==null?void 0:D.position)||Ce.Bottom,oe=(Q==null?void 0:Q.position)||Ce.Top,ue=!!(I.focusable||k&&typeof I.focusable>"u"),ge=I.reconnectable||I.updatable,de=typeof y<"u"&&(ge||N&&typeof ge>"u");if(!D||!Q)return T==null||T("008",Or.error008(D,I)),null;const{sourceX:Ie,sourceY:He,targetX:Pe,targetY:Ae}=vM(H,D,ee,J,Q,oe);return ae.createElement($,{key:I.id,id:I.id,className:Ot([I.className,l]),type:E,data:I.data,selected:!!I.selected,animated:!!I.animated,hidden:!!I.hidden,label:I.label,labelStyle:I.labelStyle,labelShowBg:I.labelShowBg,labelBgStyle:I.labelBgStyle,labelBgPadding:I.labelBgPadding,labelBgBorderRadius:I.labelBgBorderRadius,style:I.style,source:I.source,target:I.target,sourceHandleId:I.sourceHandle,targetHandleId:I.targetHandle,markerEnd:I.markerEnd,markerStart:I.markerStart,sourceX:Ie,sourceY:He,targetX:Pe,targetY:Ae,sourcePosition:ee,targetPosition:oe,elementsSelectable:j,onContextMenu:u,onMouseEnter:c,onMouseMove:p,onMouseLeave:h,onClick:f,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:x,onReconnectEnd:C,reconnectRadius:_,rfId:s,ariaLabel:I.ariaLabel,isFocusable:ue,isReconnectable:de,pathOptions:"pathOptions"in I?I.pathOptions:void 0,interactionWidth:I.interactionWidth,disableKeyboardA11y:b})})))),S):null};sN.displayName="EdgeRenderer";var RM=A.memo(sN);const TM=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function AM({children:e}){const n=Xe(TM);return ae.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:n}},e)}function IM(e){const n=ua(),r=A.useRef(!1);A.useEffect(()=>{!r.current&&n.viewportInitialized&&e&&(setTimeout(()=>e(n),1),r.current=!0)},[e,n.viewportInitialized])}const MM={[Ce.Left]:Ce.Right,[Ce.Right]:Ce.Left,[Ce.Top]:Ce.Bottom,[Ce.Bottom]:Ce.Top},oN=({nodeId:e,handleType:n,style:r,type:s=vi.Bezier,CustomComponent:o,connectionStatus:l})=>{var O,L,B;const{fromNode:u,handleId:c,toX:p,toY:h,connectionMode:f}=Xe(A.useCallback(T=>({fromNode:T.nodeInternals.get(e),handleId:T.connectionHandleId,toX:(T.connectionPosition.x-T.transform[0])/T.transform[2],toY:(T.connectionPosition.y-T.transform[1])/T.transform[2],connectionMode:T.connectionMode}),[e]),Et),m=(O=u==null?void 0:u[pt])==null?void 0:O.handleBounds;let y=m==null?void 0:m[n];if(f===es.Loose&&(y=y||(m==null?void 0:m[n==="source"?"target":"source"])),!u||!y)return null;const x=c?y.find(T=>T.id===c):y[0],C=x?x.x+x.width/2:(u.width??0)/2,_=x?x.y+x.height/2:u.height??0,S=(((L=u.positionAbsolute)==null?void 0:L.x)??0)+C,b=(((B=u.positionAbsolute)==null?void 0:B.y)??0)+_,k=x==null?void 0:x.position,N=k?MM[k]:null;if(!k||!N)return null;if(o)return ae.createElement(o,{connectionLineType:s,connectionLineStyle:r,fromNode:u,fromHandle:x,fromX:S,fromY:b,toX:p,toY:h,fromPosition:k,toPosition:N,connectionStatus:l});let j="";const P={sourceX:S,sourceY:b,sourcePosition:k,targetX:p,targetY:h,targetPosition:N};return s===vi.Bezier?[j]=AE(P):s===vi.Step?[j]=Lg({...P,borderRadius:0}):s===vi.SmoothStep?[j]=Lg(P):s===vi.SimpleBezier?[j]=TE(P):j=`M${S},${b} ${p},${h}`,ae.createElement("path",{d:j,fill:"none",className:"react-flow__connection-path",style:r})};oN.displayName="ConnectionLine";const PM=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function OM({containerStyle:e,style:n,type:r,component:s}){const{nodeId:o,handleType:l,nodesConnectable:u,width:c,height:p,connectionStatus:h}=Xe(PM,Et);return!(o&&l&&c&&u)?null:ae.createElement("svg",{style:e,width:c,height:p,className:"react-flow__edges react-flow__connectionline react-flow__container"},ae.createElement("g",{className:Ot(["react-flow__connection",h])},ae.createElement(oN,{nodeId:o,handleType:l,style:n,type:r,CustomComponent:s,connectionStatus:h})))}function Kw(e,n){return A.useRef(null),Nt(),A.useMemo(()=>n(e),[e])}const aN=({nodeTypes:e,edgeTypes:n,onMove:r,onMoveStart:s,onMoveEnd:o,onInit:l,onNodeClick:u,onEdgeClick:c,onNodeDoubleClick:p,onEdgeDoubleClick:h,onNodeMouseEnter:f,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:x,onSelectionContextMenu:C,onSelectionStart:_,onSelectionEnd:S,connectionLineType:b,connectionLineStyle:k,connectionLineComponent:N,connectionLineContainerStyle:j,selectionKeyCode:P,selectionOnDrag:O,selectionMode:L,multiSelectionKeyCode:B,panActivationKeyCode:T,zoomActivationKeyCode:M,deleteKeyCode:q,onlyRenderVisibleElements:Y,elementsSelectable:X,selectNodesOnDrag:I,defaultViewport:H,translateExtent:U,minZoom:ne,maxZoom:J,preventScrolling:F,defaultMarkerColor:G,zoomOnScroll:E,zoomOnPinch:$,panOnScroll:se,panOnScrollSpeed:D,panOnScrollMode:Q,zoomOnDoubleClick:ee,panOnDrag:oe,onPaneClick:ue,onPaneMouseEnter:ge,onPaneMouseMove:de,onPaneMouseLeave:Ie,onPaneScroll:He,onPaneContextMenu:Pe,onEdgeContextMenu:Ae,onEdgeMouseEnter:ke,onEdgeMouseMove:Ye,onEdgeMouseLeave:ve,onReconnect:we,onReconnectStart:Ve,onReconnectEnd:at,reconnectRadius:lt,noDragClassName:We,noWheelClassName:$e,noPanClassName:it,elevateEdgesOnSelect:vt,disableKeyboardA11y:tt,nodeOrigin:qt,nodeExtent:mt,rfId:Tt})=>{const At=Kw(e,uM),Ze=Kw(n,gM);return IM(l),ae.createElement(aM,{onPaneClick:ue,onPaneMouseEnter:ge,onPaneMouseMove:de,onPaneMouseLeave:Ie,onPaneContextMenu:Pe,onPaneScroll:He,deleteKeyCode:q,selectionKeyCode:P,selectionOnDrag:O,selectionMode:L,onSelectionStart:_,onSelectionEnd:S,multiSelectionKeyCode:B,panActivationKeyCode:T,zoomActivationKeyCode:M,elementsSelectable:X,onMove:r,onMoveStart:s,onMoveEnd:o,zoomOnScroll:E,zoomOnPinch:$,zoomOnDoubleClick:ee,panOnScroll:se,panOnScrollSpeed:D,panOnScrollMode:Q,panOnDrag:oe,defaultViewport:H,translateExtent:U,minZoom:ne,maxZoom:J,onSelectionContextMenu:C,preventScrolling:F,noDragClassName:We,noWheelClassName:$e,noPanClassName:it,disableKeyboardA11y:tt},ae.createElement(AM,null,ae.createElement(RM,{edgeTypes:Ze,onEdgeClick:c,onEdgeDoubleClick:h,onlyRenderVisibleElements:Y,onEdgeContextMenu:Ae,onEdgeMouseEnter:ke,onEdgeMouseMove:Ye,onEdgeMouseLeave:ve,onReconnect:we,onReconnectStart:Ve,onReconnectEnd:at,reconnectRadius:lt,defaultMarkerColor:G,noPanClassName:it,elevateEdgesOnSelect:!!vt,disableKeyboardA11y:tt,rfId:Tt},ae.createElement(OM,{style:k,type:b,component:N,containerStyle:j})),ae.createElement("div",{className:"react-flow__edgelabel-renderer"}),ae.createElement(fM,{nodeTypes:At,onNodeClick:u,onNodeDoubleClick:p,onNodeMouseEnter:f,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:x,selectNodesOnDrag:I,onlyRenderVisibleElements:Y,noPanClassName:it,noDragClassName:We,disableKeyboardA11y:tt,nodeOrigin:qt,nodeExtent:mt,rfId:Tt})))};aN.displayName="GraphView";var qM=A.memo(aN);const Bg=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],pi={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:Bg,nodeExtent:Bg,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:es.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:uI,isValidConnection:void 0},LM=()=>bR((e,n)=>({...pi,setNodes:r=>{const{nodeInternals:s,nodeOrigin:o,elevateNodesOnSelect:l}=n();e({nodeInternals:ed(r,s,o,l)})},getNodes:()=>Array.from(n().nodeInternals.values()),setEdges:r=>{const{defaultEdgeOptions:s={}}=n();e({edges:r.map(o=>({...s,...o}))})},setDefaultNodesAndEdges:(r,s)=>{const o=typeof r<"u",l=typeof s<"u",u=o?ed(r,new Map,n().nodeOrigin,n().elevateNodesOnSelect):new Map;e({nodeInternals:u,edges:l?s:[],hasDefaultNodes:o,hasDefaultEdges:l})},updateNodeDimensions:r=>{const{onNodesChange:s,nodeInternals:o,fitViewOnInit:l,fitViewOnInitDone:u,fitViewOnInitOptions:c,domNode:p,nodeOrigin:h}=n(),f=p==null?void 0:p.querySelector(".react-flow__viewport");if(!f)return;const m=window.getComputedStyle(f),{m22:y}=new window.DOMMatrixReadOnly(m.transform),x=r.reduce((_,S)=>{const b=o.get(S.id);if(b!=null&&b.hidden)o.set(b.id,{...b,[pt]:{...b[pt],handleBounds:void 0}});else if(b){const k=iv(S.nodeElement);!!(k.width&&k.height&&(b.width!==k.width||b.height!==k.height||S.forceUpdate))&&(o.set(b.id,{...b,[pt]:{...b[pt],handleBounds:{source:Bw(".source",S.nodeElement,y,h),target:Bw(".target",S.nodeElement,y,h)}},...k}),_.push({id:b.id,type:"dimensions",dimensions:k}))}return _},[]);KE(o,h);const C=u||l&&!u&&XE(n,{initial:!0,...c});e({nodeInternals:new Map(o),fitViewOnInitDone:C}),(x==null?void 0:x.length)>0&&(s==null||s(x))},updateNodePositions:(r,s=!0,o=!1)=>{const{triggerNodeChanges:l}=n(),u=r.map(c=>{const p={id:c.id,type:"position",dragging:o};return s&&(p.positionAbsolute=c.positionAbsolute,p.position=c.position),p});l(u)},triggerNodeChanges:r=>{const{onNodesChange:s,nodeInternals:o,hasDefaultNodes:l,nodeOrigin:u,getNodes:c,elevateNodesOnSelect:p}=n();if(r!=null&&r.length){if(l){const h=ZI(r,c()),f=ed(h,o,u,p);e({nodeInternals:f})}s==null||s(r)}},addSelectedNodes:r=>{const{multiSelectionActive:s,edges:o,getNodes:l}=n();let u,c=null;s?u=r.map(p=>gi(p,!0)):(u=Fs(l(),r),c=Fs(o,[])),bl({changedNodes:u,changedEdges:c,get:n,set:e})},addSelectedEdges:r=>{const{multiSelectionActive:s,edges:o,getNodes:l}=n();let u,c=null;s?u=r.map(p=>gi(p,!0)):(u=Fs(o,r),c=Fs(l(),[])),bl({changedNodes:c,changedEdges:u,get:n,set:e})},unselectNodesAndEdges:({nodes:r,edges:s}={})=>{const{edges:o,getNodes:l}=n(),u=r||l(),c=s||o,p=u.map(f=>(f.selected=!1,gi(f.id,!1))),h=c.map(f=>gi(f.id,!1));bl({changedNodes:p,changedEdges:h,get:n,set:e})},setMinZoom:r=>{const{d3Zoom:s,maxZoom:o}=n();s==null||s.scaleExtent([r,o]),e({minZoom:r})},setMaxZoom:r=>{const{d3Zoom:s,minZoom:o}=n();s==null||s.scaleExtent([o,r]),e({maxZoom:r})},setTranslateExtent:r=>{var s;(s=n().d3Zoom)==null||s.translateExtent(r),e({translateExtent:r})},resetSelectedElements:()=>{const{edges:r,getNodes:s}=n(),l=s().filter(c=>c.selected).map(c=>gi(c.id,!1)),u=r.filter(c=>c.selected).map(c=>gi(c.id,!1));bl({changedNodes:l,changedEdges:u,get:n,set:e})},setNodeExtent:r=>{const{nodeInternals:s}=n();s.forEach(o=>{o.positionAbsolute=sv(o.position,r)}),e({nodeExtent:r,nodeInternals:new Map(s)})},panBy:r=>{const{transform:s,width:o,height:l,d3Zoom:u,d3Selection:c,translateExtent:p}=n();if(!u||!c||!r.x&&!r.y)return!1;const h=Mr.translate(s[0]+r.x,s[1]+r.y).scale(s[2]),f=[[0,0],[o,l]],m=u==null?void 0:u.constrain()(h,f,p);return u.transform(c,m),s[0]!==m.x||s[1]!==m.y||s[2]!==m.k},cancelConnection:()=>e({connectionNodeId:pi.connectionNodeId,connectionHandleId:pi.connectionHandleId,connectionHandleType:pi.connectionHandleType,connectionStatus:pi.connectionStatus,connectionStartHandle:pi.connectionStartHandle,connectionEndHandle:pi.connectionEndHandle}),reset:()=>e({...pi})}),Object.is),hv=({children:e})=>{const n=A.useRef(null);return n.current||(n.current=LM()),ae.createElement(nI,{value:n.current},e)};hv.displayName="ReactFlowProvider";const lN=({children:e})=>A.useContext(Ql)?ae.createElement(ae.Fragment,null,e):ae.createElement(hv,null,e);lN.displayName="ReactFlowWrapper";const $M={input:BE,default:Fg,output:HE,group:dv},DM={default:Ul,straight:lv,step:av,smoothstep:Zl,simplebezier:ov},FM=[0,0],zM=[15,15],BM={x:0,y:0,zoom:1},UM={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},uN=A.forwardRef(({nodes:e,edges:n,defaultNodes:r,defaultEdges:s,className:o,nodeTypes:l=$M,edgeTypes:u=DM,onNodeClick:c,onEdgeClick:p,onInit:h,onMove:f,onMoveStart:m,onMoveEnd:y,onConnect:x,onConnectStart:C,onConnectEnd:_,onClickConnectStart:S,onClickConnectEnd:b,onNodeMouseEnter:k,onNodeMouseMove:N,onNodeMouseLeave:j,onNodeContextMenu:P,onNodeDoubleClick:O,onNodeDragStart:L,onNodeDrag:B,onNodeDragStop:T,onNodesDelete:M,onEdgesDelete:q,onSelectionChange:Y,onSelectionDragStart:X,onSelectionDrag:I,onSelectionDragStop:H,onSelectionContextMenu:U,onSelectionStart:ne,onSelectionEnd:J,connectionMode:F=es.Strict,connectionLineType:G=vi.Bezier,connectionLineStyle:E,connectionLineComponent:$,connectionLineContainerStyle:se,deleteKeyCode:D="Backspace",selectionKeyCode:Q="Shift",selectionOnDrag:ee=!1,selectionMode:oe=na.Full,panActivationKeyCode:ue="Space",multiSelectionKeyCode:ge=zl()?"Meta":"Control",zoomActivationKeyCode:de=zl()?"Meta":"Control",snapToGrid:Ie=!1,snapGrid:He=zM,onlyRenderVisibleElements:Pe=!1,selectNodesOnDrag:Ae=!0,nodesDraggable:ke,nodesConnectable:Ye,nodesFocusable:ve,nodeOrigin:we=FM,edgesFocusable:Ve,edgesUpdatable:at,elementsSelectable:lt,defaultViewport:We=BM,minZoom:$e=.5,maxZoom:it=2,translateExtent:vt=Bg,preventScrolling:tt=!0,nodeExtent:qt,defaultMarkerColor:mt="#b1b1b7",zoomOnScroll:Tt=!0,zoomOnPinch:At=!0,panOnScroll:Ze=!1,panOnScrollSpeed:yt=.5,panOnScrollMode:Le=Ki.Free,zoomOnDoubleClick:wt=!0,panOnDrag:Bt=!0,onPaneClick:Ut,onPaneMouseEnter:Lt,onPaneMouseMove:Ht,onPaneMouseLeave:qn,onPaneScroll:Ln,onPaneContextMenu:wn,children:xn,onEdgeContextMenu:ln,onEdgeDoubleClick:tr,onEdgeMouseEnter:pr,onEdgeMouseMove:Si,onEdgeMouseLeave:$r,onEdgeUpdate:St,onEdgeUpdateStart:mr,onEdgeUpdateEnd:_n,onReconnect:un,onReconnectStart:nr,onReconnectEnd:ss,reconnectRadius:gr=10,edgeUpdaterRadius:Sn=10,onNodesChange:vr,onEdgesChange:Dr,noDragClassName:no="nodrag",noWheelClassName:os="nowheel",noPanClassName:bi="nopan",fitView:cn=!1,fitViewOptions:$n,connectOnClick:as=!0,attributionPosition:Kt,proOptions:Fr,defaultEdgeOptions:zr,elevateNodesOnSelect:ki=!0,elevateEdgesOnSelect:yr=!1,disableKeyboardA11y:Br=!1,autoPanOnConnect:Dn=!0,autoPanOnNodeDrag:Je=!0,connectionRadius:ls=20,isValidConnection:Ur,onError:us,style:rr,id:Fn,nodeDragThreshold:Ei,...Hr},Vt)=>{const Vr=Fn||"1";return ae.createElement("div",{...Hr,style:{...rr,...UM},ref:Vt,className:Ot(["react-flow",o]),"data-testid":"rf__wrapper",id:Fn},ae.createElement(lN,null,ae.createElement(qM,{onInit:h,onMove:f,onMoveStart:m,onMoveEnd:y,onNodeClick:c,onEdgeClick:p,onNodeMouseEnter:k,onNodeMouseMove:N,onNodeMouseLeave:j,onNodeContextMenu:P,onNodeDoubleClick:O,nodeTypes:l,edgeTypes:u,connectionLineType:G,connectionLineStyle:E,connectionLineComponent:$,connectionLineContainerStyle:se,selectionKeyCode:Q,selectionOnDrag:ee,selectionMode:oe,deleteKeyCode:D,multiSelectionKeyCode:ge,panActivationKeyCode:ue,zoomActivationKeyCode:de,onlyRenderVisibleElements:Pe,selectNodesOnDrag:Ae,defaultViewport:We,translateExtent:vt,minZoom:$e,maxZoom:it,preventScrolling:tt,zoomOnScroll:Tt,zoomOnPinch:At,zoomOnDoubleClick:wt,panOnScroll:Ze,panOnScrollSpeed:yt,panOnScrollMode:Le,panOnDrag:Bt,onPaneClick:Ut,onPaneMouseEnter:Lt,onPaneMouseMove:Ht,onPaneMouseLeave:qn,onPaneScroll:Ln,onPaneContextMenu:wn,onSelectionContextMenu:U,onSelectionStart:ne,onSelectionEnd:J,onEdgeContextMenu:ln,onEdgeDoubleClick:tr,onEdgeMouseEnter:pr,onEdgeMouseMove:Si,onEdgeMouseLeave:$r,onReconnect:un??St,onReconnectStart:nr??mr,onReconnectEnd:ss??_n,reconnectRadius:gr??Sn,defaultMarkerColor:mt,noDragClassName:no,noWheelClassName:os,noPanClassName:bi,elevateEdgesOnSelect:yr,rfId:Vr,disableKeyboardA11y:Br,nodeOrigin:we,nodeExtent:qt}),ae.createElement(II,{nodes:e,edges:n,defaultNodes:r,defaultEdges:s,onConnect:x,onConnectStart:C,onConnectEnd:_,onClickConnectStart:S,onClickConnectEnd:b,nodesDraggable:ke,nodesConnectable:Ye,nodesFocusable:ve,edgesFocusable:Ve,edgesUpdatable:at,elementsSelectable:lt,elevateNodesOnSelect:ki,minZoom:$e,maxZoom:it,nodeExtent:qt,onNodesChange:vr,onEdgesChange:Dr,snapToGrid:Ie,snapGrid:He,connectionMode:F,translateExtent:vt,connectOnClick:as,defaultEdgeOptions:zr,fitView:cn,fitViewOptions:$n,onNodesDelete:M,onEdgesDelete:q,onNodeDragStart:L,onNodeDrag:B,onNodeDragStop:T,onSelectionDrag:I,onSelectionDragStart:X,onSelectionDragStop:H,noPanClassName:bi,nodeOrigin:we,rfId:Vr,autoPanOnConnect:Dn,autoPanOnNodeDrag:Je,onError:us,connectionRadius:ls,isValidConnection:Ur,nodeDragThreshold:Ei}),ae.createElement(TI,{onSelectionChange:Y}),xn,ae.createElement(iI,{proOptions:Fr,position:Kt}),ae.createElement(LI,{rfId:Vr,disableKeyboardA11y:Br})))});uN.displayName="ReactFlow";const HM=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function cN(){return Xe(HM,Et)}const dN=({id:e,x:n,y:r,width:s,height:o,style:l,color:u,strokeColor:c,strokeWidth:p,className:h,borderRadius:f,shapeRendering:m,onClick:y,selected:x})=>{const{background:C,backgroundColor:_}=l||{},S=u||C||_;return ae.createElement("rect",{className:Ot(["react-flow__minimap-node",{selected:x},h]),x:n,y:r,rx:f,ry:f,width:s,height:o,fill:S,stroke:c,strokeWidth:p,shapeRendering:m,onClick:y?b=>y(b,e):void 0})};dN.displayName="MiniMapNode";var VM=A.memo(dN);const WM=e=>e.nodeOrigin,GM=e=>e.getNodes().filter(n=>!n.hidden&&n.width&&n.height),id=e=>e instanceof Function?e:()=>e;function YM({nodeStrokeColor:e="transparent",nodeColor:n="#e2e2e2",nodeClassName:r="",nodeBorderRadius:s=5,nodeStrokeWidth:o=2,nodeComponent:l=VM,onClick:u}){const c=Xe(GM,Et),p=Xe(WM),h=id(n),f=id(e),m=id(r),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return ae.createElement(ae.Fragment,null,c.map(x=>{const{x:C,y:_}=Qi(x,p).positionAbsolute;return ae.createElement(l,{key:x.id,x:C,y:_,width:x.width,height:x.height,style:x.style,selected:x.selected,className:m(x),color:h(x),borderRadius:s,strokeColor:f(x),strokeWidth:o,shapeRendering:y,onClick:u,id:x.id})}))}var KM=A.memo(YM);const XM=200,QM=150,ZM=e=>{const n=e.getNodes(),r={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:r,boundingRect:n.length>0?aI(Jl(n,e.nodeOrigin),r):r,rfId:e.rfId}},JM="react-flow__minimap-desc";function fN({style:e,className:n,nodeStrokeColor:r="transparent",nodeColor:s="#e2e2e2",nodeClassName:o="",nodeBorderRadius:l=5,nodeStrokeWidth:u=2,nodeComponent:c,maskColor:p="rgb(240, 240, 240, 0.6)",maskStrokeColor:h="none",maskStrokeWidth:f=1,position:m="bottom-right",onClick:y,onNodeClick:x,pannable:C=!1,zoomable:_=!1,ariaLabel:S="React Flow mini map",inversePan:b=!1,zoomStep:k=10,offsetScale:N=5}){const j=Nt(),P=A.useRef(null),{boundingRect:O,viewBB:L,rfId:B}=Xe(ZM,Et),T=(e==null?void 0:e.width)??XM,M=(e==null?void 0:e.height)??QM,q=O.width/T,Y=O.height/M,X=Math.max(q,Y),I=X*T,H=X*M,U=N*X,ne=O.x-(I-O.width)/2-U,J=O.y-(H-O.height)/2-U,F=I+U*2,G=H+U*2,E=`${JM}-${B}`,$=A.useRef(0);$.current=X,A.useEffect(()=>{if(P.current){const Q=In(P.current),ee=ge=>{const{transform:de,d3Selection:Ie,d3Zoom:He}=j.getState();if(ge.sourceEvent.type!=="wheel"||!Ie||!He)return;const Pe=-ge.sourceEvent.deltaY*(ge.sourceEvent.deltaMode===1?.05:ge.sourceEvent.deltaMode?1:.002)*k,Ae=de[2]*Math.pow(2,Pe);He.scaleTo(Ie,Ae)},oe=ge=>{const{transform:de,d3Selection:Ie,d3Zoom:He,translateExtent:Pe,width:Ae,height:ke}=j.getState();if(ge.sourceEvent.type!=="mousemove"||!Ie||!He)return;const Ye=$.current*Math.max(1,de[2])*(b?-1:1),ve={x:de[0]-ge.sourceEvent.movementX*Ye,y:de[1]-ge.sourceEvent.movementY*Ye},we=[[0,0],[Ae,ke]],Ve=Mr.translate(ve.x,ve.y).scale(de[2]),at=He.constrain()(Ve,we,Pe);He.transform(Ie,at)},ue=xE().on("zoom",C?oe:null).on("zoom.wheel",_?ee:null);return Q.call(ue),()=>{Q.on("zoom",null)}}},[C,_,b,k]);const se=y?Q=>{const ee=Kn(Q);y(Q,{x:ee[0],y:ee[1]})}:void 0,D=x?(Q,ee)=>{const oe=j.getState().nodeInternals.get(ee);x(Q,oe)}:void 0;return ae.createElement(rv,{position:m,style:e,className:Ot(["react-flow__minimap",n]),"data-testid":"rf__minimap"},ae.createElement("svg",{width:T,height:M,viewBox:`${ne} ${J} ${F} ${G}`,role:"img","aria-labelledby":E,ref:P,onClick:se},S&&ae.createElement("title",{id:E},S),ae.createElement(KM,{onClick:D,nodeColor:s,nodeStrokeColor:r,nodeBorderRadius:l,nodeClassName:o,nodeStrokeWidth:u,nodeComponent:c}),ae.createElement("path",{className:"react-flow__minimap-mask",d:`M${ne-U},${J-U}h${F+U*2}v${G+U*2}h${-F-U*2}z
|
|
57
57
|
M${L.x},${L.y}h${L.width}v${L.height}h${-L.width}z`,fill:p,fillRule:"evenodd",stroke:h,strokeWidth:f,pointerEvents:"none"})))}fN.displayName="MiniMap";var eP=A.memo(fN);function tP(){return ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},ae.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function nP(){return ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},ae.createElement("path",{d:"M0 0h32v4.2H0z"}))}function rP(){return ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},ae.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function iP(){return ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ae.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function sP(){return ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ae.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const zs=({children:e,className:n,...r})=>ae.createElement("button",{type:"button",className:Ot(["react-flow__controls-button",n]),...r},e);zs.displayName="ControlButton";const oP=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),hN=({style:e,showZoom:n=!0,showFitView:r=!0,showInteractive:s=!0,fitViewOptions:o,onZoomIn:l,onZoomOut:u,onFitView:c,onInteractiveChange:p,className:h,children:f,position:m="bottom-left"})=>{const y=Nt(),[x,C]=A.useState(!1),{isInteractive:_,minZoomReached:S,maxZoomReached:b}=Xe(oP,Et),{zoomIn:k,zoomOut:N,fitView:j}=ua();if(A.useEffect(()=>{C(!0)},[]),!x)return null;const P=()=>{k(),l==null||l()},O=()=>{N(),u==null||u()},L=()=>{j(o),c==null||c()},B=()=>{y.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),p==null||p(!_)};return ae.createElement(rv,{className:Ot(["react-flow__controls",h]),position:m,style:e,"data-testid":"rf__controls"},n&&ae.createElement(ae.Fragment,null,ae.createElement(zs,{onClick:P,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:b},ae.createElement(tP,null)),ae.createElement(zs,{onClick:O,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:S},ae.createElement(nP,null))),r&&ae.createElement(zs,{className:"react-flow__controls-fitview",onClick:L,title:"fit view","aria-label":"fit view"},ae.createElement(rP,null)),s&&ae.createElement(zs,{className:"react-flow__controls-interactive",onClick:B,title:"toggle interactivity","aria-label":"toggle interactivity"},_?ae.createElement(sP,null):ae.createElement(iP,null)),f)};hN.displayName="Controls";var aP=A.memo(hN),Qn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Qn||(Qn={}));function lP({color:e,dimensions:n,lineWidth:r}){return ae.createElement("path",{stroke:e,strokeWidth:r,d:`M${n[0]/2} 0 V${n[1]} M0 ${n[1]/2} H${n[0]}`})}function uP({color:e,radius:n}){return ae.createElement("circle",{cx:n,cy:n,r:n,fill:e})}const cP={[Qn.Dots]:"#91919a",[Qn.Lines]:"#eee",[Qn.Cross]:"#e2e2e2"},dP={[Qn.Dots]:1,[Qn.Lines]:1,[Qn.Cross]:6},fP=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function pN({id:e,variant:n=Qn.Dots,gap:r=20,size:s,lineWidth:o=1,offset:l=2,color:u,style:c,className:p}){const h=A.useRef(null),{transform:f,patternId:m}=Xe(fP,Et),y=u||cP[n],x=s||dP[n],C=n===Qn.Dots,_=n===Qn.Cross,S=Array.isArray(r)?r:[r,r],b=[S[0]*f[2]||1,S[1]*f[2]||1],k=x*f[2],N=_?[k,k]:b,j=C?[k/l,k/l]:[N[0]/l,N[1]/l];return ae.createElement("svg",{className:Ot(["react-flow__background",p]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:h,"data-testid":"rf__background"},ae.createElement("pattern",{id:m+e,x:f[0]%b[0],y:f[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${j[0]},-${j[1]})`},C?ae.createElement(uP,{color:y,radius:k/l}):ae.createElement(lP,{dimensions:N,color:y,lineWidth:o})),ae.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${m+e})`}))}pN.displayName="Background";var hP=A.memo(pN);function mN(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function gN(e,n=0){if(!e||typeof e!="object"||n>6)return null;const r=e;if(typeof r.input_tokens=="number"||typeof r.output_tokens=="number"||typeof r.cache_read_input_tokens=="number"||typeof r.cache_creation_input_tokens=="number")return{inputTokens:Number(r.input_tokens??0),outputTokens:Number(r.output_tokens??0),cacheReadTokens:Number(r.cache_read_input_tokens??0),cacheCreateTokens:Number(r.cache_creation_input_tokens??0)};for(const s of Object.values(r)){const o=gN(s,n+1);if(o)return o}return null}function pP(e,n){e.inputTokens+=n.inputTokens,e.outputTokens+=n.outputTokens,e.cacheReadTokens+=n.cacheReadTokens,e.cacheCreateTokens+=n.cacheCreateTokens}const mP=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i;function vN(e,n=0){if(!e||typeof e!="object"||n>6)return null;const r=e;if(typeof r.model=="string"&&mP.test(r.model))return r.model;for(const s of Object.values(r)){const o=vN(s,n+1);if(o)return o}return null}function Ug(){return{agents:new Map,toolIndex:new Map,toolOwner:new Map,activeSubagentStack:new Map,lastSeq:0,seqEpoch:null,totalEvents:0}}function wi(e){if(!e)return;const n=e.replace(/\\/g,"/").split("/").filter(Boolean);return n[n.length-1]}function pv(e,n){return`${e}::${n}`}function Hl(e){return e.agent_type??e.subagent_type??"subagent"}function Hg(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function Ko(e,n,r,s){const o=n;let l=e.agents.get(o);return l||(l={id:o,sessionId:n,label:"session",kind:"root",state:"active",startedAt:r,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:s,inFlightTool:null,usage:mN()},e.agents.set(o,l),l)}function yN(e,n,r,s){const o=pv(n,r),l=e.agents.get(o);if(!l)return null;!l.cwd&&s.cwd&&(l.cwd=s.cwd,l.cwdBasename=wi(s.cwd));const u=Hl(s);return u&&(l.label==="subagent"||!l.label)&&(l.label=u),l}function Xw(e,n,r){const s=n.session_id??"unknown",o=Hg(n);if(o){const p=yN(e,s,o,n);if(p)return p}const l=e.activeSubagentStack.get(s),u=l&&l.length>0?l[l.length-1]:null;if(u){const p=e.agents.get(pv(s,u));if(p)return!p.cwd&&n.cwd&&(p.cwd=n.cwd,p.cwdBasename=wi(n.cwd)),p}const c=Ko(e,s,r,!1);return c.synthetic&&(c.synthetic=!1,c.startedAt=r),!c.cwd&&n.cwd&&(c.cwd=n.cwd,c.cwdBasename=wi(n.cwd)),c.label==="session"&&n.cwd&&(c.label=wi(n.cwd)??"session"),c}function gP(e,n,r,s,o){const l=pv(n,r),u=Ko(e,n,o,!0);let c=e.agents.get(l);if(c){!c.cwd&&s.cwd&&(c.cwd=s.cwd,c.cwdBasename=wi(s.cwd));const p=Hl(s);return p&&(c.label==="subagent"||!c.label)&&(c.label=p),c}return c={id:l,sessionId:n,label:Hl(s),kind:"subagent",parentId:u.id,state:"active",startedAt:o,tools:[],prompts:[],cwd:s.cwd,cwdBasename:wi(s.cwd),toolCount:0,childCount:0,inFlightTool:null,usage:mN()},e.agents.set(l,c),u.childCount+=1,c}function vP(e,n,r){const s=e.activeSubagentStack.get(n)??[];s.push(r),e.activeSubagentStack.set(n,s)}function yP(e,n,r){const s=e.activeSubagentStack.get(n);if(s){for(let o=s.length-1;o>=0;o--)if(s[o]===r){s.splice(o,1);break}s.length===0&&e.activeSubagentStack.delete(n)}}function sd(e,n=80){if(e==null)return"";if(typeof e=="string")return e.length>n?e.slice(0,n-1)+"…":e;try{const r=JSON.stringify(e);return r.length>n?r.slice(0,n-1)+"…":r}catch{return String(e)}}function Bs(e){let n=null;for(let r=e.tools.length-1;r>=0;r--){const s=e.tools[r];if(s.endedAt==null){n=s;break}}e.inFlightTool=n}const Qw=200,wP=25;function xP(e,n){const r=n.tools;if(r.length>Qw){const s=r.splice(0,r.length-Qw);let o=!1;for(const l of s)e.toolIndex.delete(l.id)&&(o=!0),e.toolOwner.delete(l.id);o&&Bs(n)}for(let s=r.length-wP-1;s>=0;s--){const o=r[s];if(o.trimmed)break;o.input=void 0,o.response=void 0,o.trimmed=!0}}function _P(e,n,r,s){if(e.agents.size<=r)return!1;const o=[];for(const[u,c]of e.agents)c.state==="done"&&c.endedAt!=null&&n-c.endedAt>s&&o.push({id:u,endedAt:c.endedAt});if(o.length===0)return!1;o.sort((u,c)=>u.endedAt-c.endedAt);let l=0;for(const u of o){if(e.agents.size<=r)break;e.agents.delete(u.id),l++}return l>0}function SP(e,n,r,s){const o=new Map;for(const[h,f]of e.agents){let m=o.get(f.sessionId);m||(m={ids:[],endedAt:0,live:!1},o.set(f.sessionId,m)),m.ids.push(h),f.state==="done"&&f.endedAt!=null?m.endedAt=Math.max(m.endedAt,f.endedAt):m.live=!0}const l=[...o.values()].filter(h=>!h.live&&h.endedAt>0&&n-h.endedAt>s).sort((h,f)=>h.endedAt-f.endedAt);let c=[...o.values()].filter(h=>!h.live).length-r;if(c<=0)return!1;let p=!1;for(const h of l){if(c<=0)break;for(const f of h.ids)e.agents.delete(f);c--,p=!0}return p}function bP(e,n,r){let s=!1;for(const o of e.agents.values()){let l=!1;for(const u of o.tools)u.endedAt==null&&n-u.startedAt>r&&(u.endedAt=u.startedAt+r,u.ok=!1,u.errorPreview="stale (no PostToolUse received)",e.toolIndex.delete(u.id),e.toolOwner.delete(u.id),l=!0,s=!0);l&&Bs(o)}return s}function Zw(e,n){const r=n.epoch??null;if(r!==null&&r!==e.seqEpoch)e.seqEpoch=r,e.lastSeq=0;else if(n.seq<=e.lastSeq)return e;const s=n.payload??{},o=n.receivedAt,l=s.hook_event_name??"Unknown";if(l==="__clear")return{...Ug(),lastSeq:n.seq,seqEpoch:e.seqEpoch};e.totalEvents+=1,e.lastSeq=n.seq;const u=s.session_id??"unknown";if(l==="ModelObserved"){const h=typeof s.model=="string"?s.model:null;if(h){const m=e.agents.get(u);m&&(m.model=h)}const f=s.subagentModels;if(f&&typeof f=="object")for(const[m,y]of Object.entries(f)){if(typeof y!="string")continue;const x=`${u}::${m}`,C=e.agents.get(x);C&&(C.model=y)}return e}if(l==="ContextObserved"){const h=s.context??null;if(h){const f=e.agents.get(u);f&&(f.context={msgsUser:Number(h.msgsUser??0),msgsAssistant:Number(h.msgsAssistant??0),toolUses:Number(h.toolUses??0),toolResults:Number(h.toolResults??0),systemReminders:Number(h.systemReminders??0),currentContextTokens:Number(h.currentContextTokens??0),claudeMdFiles:Array.isArray(h.claudeMdFiles)?h.claudeMdFiles:[]})}return e}if(l==="UsageObserved"){const h=s.usage??null;if(h){const f=e.agents.get(u);f&&(f.usage.inputTokens=Number(h.input_tokens??0),f.usage.outputTokens=Number(h.output_tokens??0),f.usage.cacheReadTokens=Number(h.cache_read_input_tokens??h.cached_input_tokens??0),f.usage.cacheCreateTokens=Number(h.cache_creation_input_tokens??0),typeof h.reasoning_output_tokens=="number"&&(f.usage.reasoningOutputTokens=Number(h.reasoning_output_tokens)))}return e}const c=Xw(e,s,o);c.provider||(c.provider=s.provider==="codex"?"codex":"claude"),typeof s.model_context_window=="number"&&s.model_context_window>0&&(c.contextWindow=s.model_context_window);const p=vN(s);switch(p&&(c.model=p),l){case"SessionStart":{const h=Ko(e,u,o,!1);h.synthetic=!1,h.state="active",h.startedAt=h.startedAt||o,!h.cwd&&s.cwd&&(h.cwd=s.cwd,h.cwdBasename=wi(s.cwd)),h.label==="session"&&s.cwd&&(h.label=wi(s.cwd)??"session");break}case"UserPromptSubmit":{for(const y of e.agents.values())y.sessionId===u&&y.kind==="subagent"&&y.state==="done"&&y.exitAt==null&&y.endedAt!=null&&y.endedAt<o&&(y.exitAt=o);const h=Ko(e,u,o,!1);h.state="active",h.endedAt=void 0,h.exitAt=void 0;const f=Xw(e,s,o);f.state="active",f.exitAt=void 0,f.endedAt=void 0;const m=(typeof s.prompt=="string"?s.prompt:typeof s.message=="string"?s.message:"")??"";m&&(f.prompts.push({at:o,text:m}),f.firstPrompt||(f.firstPrompt=sd(m,120)));break}case"PreToolUse":{const h=s.tool_use_id??`${c.id}:${c.toolCount}`,f={id:h,name:s.tool_name??"?",input:s.tool_input,inputPreview:sd(s.tool_input),agentId:c.id,startedAt:o};c.tools.push(f),c.toolCount+=1,c.state="active",e.toolIndex.set(h,f),e.toolOwner.set(h,c.id),Bs(c),xP(e,c);break}case"PostToolUse":case"PostToolUseFailure":{const h=s.tool_use_id;if(!h)break;let f=e.toolIndex.get(h),m=!1;if(!f)for(const C of e.agents.values()){const _=C.tools.find(S=>S.id===h);if(_){f=_,m=!0;break}}if(!f)break;f.endedAt=o,f.ok=l==="PostToolUse",f.trimmed||(f.response=s.tool_response),l==="PostToolUseFailure"?f.errorPreview=sd(s.tool_response):m&&(f.errorPreview=void 0);const y=gN(s.tool_response);y&&(f.usage=y),e.toolIndex.delete(h);const x=e.toolOwner.get(h)??f.agentId;if(e.toolOwner.delete(h),x){const C=e.agents.get(x);C&&(y&&pP(C.usage,y),Bs(C))}break}case"SubagentStart":{const h=Hg(s);if(!h)break;const f=gP(e,u,h,s,o);f.state="active",f.startedAt=f.startedAt||o,f.exitAt=void 0,f.endedAt=void 0;const m=Hl(s);m&&(f.label=m),vP(e,u,h);break}case"SubagentStop":{const h=Hg(s);if(!h)break;const f=yN(e,u,h,s);if(!f)break;f.state="done",f.endedAt=o,Bs(f),yP(e,u,h);break}case"Stop":case"SessionEnd":{const h=Ko(e,u,o,!1);h.state="done",h.endedAt=o,Bs(h),e.activeSubagentStack.delete(u);break}}return e}function mv(e){let n=5381;for(let r=0;r<e.length;r++)n=(n<<5)+n^e.charCodeAt(r);return Math.abs(n)%360}const kP=Date.UTC(2026,8,1);function EP(){return Date.now()<kP?{input:2,output:10,cacheRead:.2,cacheWrite:2.5}:{input:3,output:15,cacheRead:.3,cacheWrite:3.75}}const NP=[{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:EP()},{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 CP(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function gv(e){if(!e)return null;for(const n of NP)if(n.match.test(e))return n.rates;return null}function on(e,n){const r=gv(n);if(!r)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const l=(CP(n)?Math.max(0,e.inputTokens-e.cacheReadTokens):e.inputTokens)*r.input/1e6,u=e.outputTokens*r.output/1e6,c=e.cacheReadTokens*r.cacheRead/1e6,p=e.cacheCreateTokens*r.cacheWrite/1e6;return{input:l,output:u,cacheRead:c,cacheWrite:p,total:l+u+c+p}}const Jw=2e5,jP=1e6,RP=[/\[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],TP=[{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 wN(e){if(!e)return Jw;for(const n of RP)if(n.test(e))return jP;for(const n of TP)if(n.match.test(e))return n.window;return Jw}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 Vl(e,n){if(e<=0||n<10)return null;const r=e/n,s=r*60;return s>=.01?`${Be(s)}/min`:`${Be(r*3600)}/hr`}function An(e){return e.toLocaleString()}function AP(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function IP({agent:e,onClose:n}){var h;const r=e.context,s=e.usage,o=(r==null?void 0:r.currentContextTokens)??0,l=wN(e.model),u=Math.min(100,o/l*100),c=on(s,e.model),p=s.inputTokens+s.cacheReadTokens+s.cacheCreateTokens;return g.jsx("div",{className:"ctx-modal-backdrop",onClick:n,role:"presentation",children:g.jsxs("div",{className:"ctx-modal",onClick:f=>f.stopPropagation(),role:"dialog","aria-label":"Context breakdown",children:[g.jsxs("header",{className:"ctx-modal-head",children:[g.jsxs("div",{children:[g.jsxs("div",{className:"ctx-modal-title",children:["Context · ",e.label]}),g.jsx("div",{className:"ctx-modal-sub",children:"approximation — CC's /context isn't hook-exposed"})]}),g.jsx("button",{className:"ctx-modal-close",onClick:n,"aria-label":"Close",children:"×"})]}),g.jsxs("section",{className:"ctx-window-row",children:[g.jsx("div",{className:"ctx-window-bar",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(u),children:g.jsx("div",{className:"ctx-window-fill",style:{width:`${u}%`}})}),g.jsxs("div",{className:"ctx-window-meta",children:[g.jsxs("span",{className:"ctx-window-pct",children:[u.toFixed(1),"%"]}),g.jsxs("span",{className:"ctx-window-num",children:[An(o)," / ",An(l)," tok (current turn)"]})]})]}),g.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),g.jsxs("div",{className:"ctx-grid",children:[g.jsx(Yn,{label:"input tokens",val:An(s.inputTokens)}),g.jsx(Yn,{label:"output tokens",val:An(s.outputTokens)}),g.jsx(Yn,{label:"cache reads",val:An(s.cacheReadTokens)}),g.jsx(Yn,{label:"cache writes",val:An(s.cacheCreateTokens)}),g.jsx(Yn,{label:"cumulative total",val:An(p)}),g.jsx(Yn,{label:"estimated cost",val:Be(c.total),accent:!0})]}),g.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),g.jsxs("div",{className:"ctx-grid",children:[g.jsx(Yn,{label:"user messages",val:An((r==null?void 0:r.msgsUser)??0)}),g.jsx(Yn,{label:"assistant messages",val:An((r==null?void 0:r.msgsAssistant)??0)}),g.jsx(Yn,{label:"tool uses",val:An((r==null?void 0:r.toolUses)??0)}),g.jsx(Yn,{label:"tool results",val:An((r==null?void 0:r.toolResults)??0)}),g.jsx(Yn,{label:"system-reminders",val:An((r==null?void 0:r.systemReminders)??0)})]}),g.jsx("h3",{className:"ctx-section-title",children:"CLAUDE.md files in scope"}),(((h=r==null?void 0:r.claudeMdFiles)==null?void 0:h.length)??0)===0?g.jsx("div",{className:"ctx-empty",children:"No CLAUDE.md files found on the path from cwd to ~/.claude."}):g.jsx("ul",{className:"ctx-md-list",children:r.claudeMdFiles.map(f=>g.jsxs("li",{children:[g.jsx("span",{className:"ctx-md-path",title:f.path,children:f.path}),g.jsx("span",{className:"ctx-md-size",children:AP(f.bytes)})]},f.path))})]})})}function Yn({label:e,val:n,accent:r}){return g.jsxs("div",{className:`ctx-row${r?" accent":""}`,children:[g.jsx("span",{className:"ctx-row-label",children:e}),g.jsx("span",{className:"ctx-row-val",children:n})]})}function MP({currentContextTokens:e,modelId:n,size:r=26,onClick:s,title:o}){const l=wN(n),u=Math.min(1,e/l),c=r/2-3,p=r/2,h=2*Math.PI*c,f=h*u,m=u>.9?"var(--err)":u>.7?"var(--inflight)":"var(--accent)";return g.jsx("button",{type:"button",className:"ctx-donut",onClick:s,title:o??`context: ${e.toLocaleString()} / ${l.toLocaleString()} (${(u*100).toFixed(1)}%)`,"aria-label":"Show context breakdown",children:g.jsxs("svg",{width:r,height:r,viewBox:`0 0 ${r} ${r}`,children:[g.jsx("circle",{cx:p,cy:p,r:c,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),g.jsx("circle",{cx:p,cy:p,r:c,stroke:m,strokeWidth:"2.5",fill:"none",strokeDasharray:`${f} ${h-f}`,strokeDashoffset:h/4,strokeLinecap:"round",style:{transition:"stroke-dasharray 400ms ease"}}),g.jsx("text",{x:p,y:p+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(u*100)})]})})}function PP(e,n){const r=gv(n);if(!r)return"no rates for this model";const s=u=>u.toLocaleString(),o=u=>`$${u}/MTok`,l=on(e,n);return[`model: ${n}`,`input ${s(e.inputTokens).padStart(14)} × ${o(r.input).padEnd(11)} = ${Be(l.input)}`,`output ${s(e.outputTokens).padStart(14)} × ${o(r.output).padEnd(11)} = ${Be(l.output)}`,`cache r ${s(e.cacheReadTokens).padStart(14)} × ${o(r.cacheRead).padEnd(11)} = ${Be(l.cacheRead)}`,`cache w ${s(e.cacheCreateTokens).padStart(14)} × ${o(r.cacheWrite).padEnd(11)} = ${Be(l.cacheWrite)}`,"─────────────────────────────────────────",`total = ${Be(l.total)}`].join(`
|
|
58
58
|
`)}function OP(e,n,r){const s=(n??r)-e;if(s<1e3)return`${Math.max(0,s)}ms`;const o=Math.floor(s/1e3);if(o<60)return`${o}s`;const l=Math.floor(o/60),u=o%60;return`${l}m ${String(u).padStart(2,"0")}s`}function qP({data:e,selected:n}){var h;const r=e.now??Date.now(),s=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":"",n?"selected":""].filter(Boolean).join(" "),o=e.tools.filter(f=>!f.endedAt).length,u=`hsl(${mv(e.sessionId)} 70% 60%)`,c=((h=e.context)==null?void 0:h.currentContextTokens)??0,p=e.kind==="root"&&c>0;return g.jsxs("div",{className:s,style:{"--accent":u},children:[g.jsx("span",{className:"accent-stripe"}),g.jsx(Xs,{type:"target",position:Ce.Left,style:{background:"transparent",border:"none"}}),g.jsxs("div",{className:"head",children:[g.jsxs("div",{className:"title",children:[g.jsx(LP,{state:e.state}),g.jsx("span",{className:"label",title:e.cwd,children:e.label}),e.synthetic&&g.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"})]}),g.jsxs("div",{className:"head-right",children:[p&&e.onOpenContext&&g.jsx(MP,{currentContextTokens:c,modelId:e.model,onClick:()=>e.onOpenContext(e.sessionId)}),g.jsx("div",{className:"time",title:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:OP(e.startedAt,e.endedAt,r)})]})]}),g.jsxs("div",{className:"sub",children:[e.kind==="root"?"session":"subagent",e.childCount>0&&g.jsxs("span",{className:"spawn-badge",title:`${e.childCount} subagents spawned`,children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model&&g.jsx("span",{className:"model-chip",title:e.model,children:ca(e.model)})]}),e.tools.length>0&&g.jsx(DP,{tools:e.tools,now:r}),g.jsxs("div",{className:"meta",children:[g.jsxs("span",{children:[g.jsx("b",{children:e.toolCount})," tools"]}),o>0&&g.jsxs("span",{className:"inflight-meta",children:[g.jsx("b",{children:o})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&g.jsxs("span",{className:"tokens-meta",title:`in:${e.usage.inputTokens} out:${e.usage.outputTokens} cache-r:${e.usage.cacheReadTokens} cache-c:${e.usage.cacheCreateTokens}${(e.usage.reasoningOutputTokens??0)>0?` reasoning:${e.usage.reasoningOutputTokens}`:""}`,children:[g.jsx("b",{children:$P(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),e.model&&gv(e.model)&&(()=>{const f=on(e.usage,e.model);if(f.total<=0)return null;const m=Math.max(0,((e.endedAt??r)-e.startedAt)/1e3),y=e.state==="active"?Vl(f.total,m):null,x=PP(e.usage,e.model)+(y?`
|
|
59
|
-
burn: ${y}`:"");return g.jsxs("span",{className:"cost-meta",title:x,children:[g.jsx("b",{children:Be(f.total)}),y&&g.jsx("span",{className:"cost-rate",children:y})]})})()]}),g.jsx(Xs,{type:"source",position:Ce.Right,style:{background:"transparent",border:"none"}})]})}function LP({state:e}){const n=e==="active"?"live":e==="done"?"done":"err";return g.jsx("span",{className:`state-pill state-${e}`,children:n})}function $P(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function DP({tools:e,now:n}){const l=new Array(24).fill(0);let u=0;for(const y of e){const x=n-y.startedAt;if(x<0||x>=6e4)continue;const C=23-Math.floor(x/2500);C>=0&&C<24&&(l[C]+=1,u+=1)}const c=Math.max(1,...l),p=132,h=14,f=p/24,m=c/(2500/1e3);return g.jsxs("div",{className:"tool-spark-row",title:`${u} tool calls in last 60s · peak ${m.toFixed(1)}/s`,children:[g.jsx("svg",{className:"tool-spark",width:p,height:h,viewBox:`0 0 ${p} ${h}`,"aria-hidden":!0,children:l.map((y,x)=>{const C=y===0?1.5:Math.max(1.5,y/c*h),_=x===23&&y>0,b=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return g.jsx("rect",{x:x*f+.4,y:h-C,width:Math.max(.5,f-1),height:C,rx:.8,className:b},x)})}),g.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function ca(e){const n=e.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const o=n[1][0].toUpperCase()+n[1].slice(1).toLowerCase(),l=n[2].replace(/[-_]/g,".");return`${o} ${l}`}const r=e.match(/^gpt[-_](\d+(?:[-_.]\d+)*)[-_]codex\b/i);if(r)return`GPT-${r[1].replace(/[-_]/g,".")} Codex`;const s=e.match(/^gpt[-_](\d+(?:[-_.]\d+)*)/i);return s?`GPT-${s[1].replace(/[-_]/g,".")}`:e}function ex(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function FP(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 zP({tool:e,onClose:n}){A.useEffect(()=>{const s=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]);const r=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return g.jsx("div",{className:"modal-backdrop",onClick:n,role:"dialog","aria-modal":"true",children:g.jsxs("div",{className:"modal",onClick:s=>s.stopPropagation(),children:[g.jsxs("header",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:`status-dot ${r}`}),g.jsx("span",{className:"modal-tool-name",children:e.name}),g.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",children:FP(e)}),g.jsx("button",{className:"btn icon-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),g.jsxs("section",{className:"modal-body",children:[e.trimmed&&g.jsx("div",{className:"modal-section",children:g.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),g.jsxs("div",{className:"modal-section",children:[g.jsx("h4",{children:"Input"}),g.jsx("pre",{children:ex(e.input??e.inputPreview)})]}),g.jsxs("div",{className:"modal-section",children:[g.jsxs("h4",{children:["Response ",r==="err"&&g.jsx("span",{className:"err-tag",children:"error"})]}),g.jsx("pre",{children:e.endedAt==null?"(waiting…)":ex(e.response??e.errorPreview)})]})]})]})})}const El=18,tx=26,BP=12;function UP(e){const n=new Map;for(const o of e.nodeInternals.values()){const l=o.data;if(!(l!=null&&l.sessionId)||l.exitAt!=null||o.width==null||o.height==null)continue;const u=o.position.x,c=o.position.y,p=u+o.width,h=c+o.height,f=n.get(l.sessionId);f?(f.minX=Math.min(f.minX,u),f.minY=Math.min(f.minY,c),f.maxX=Math.max(f.maxX,p),f.maxY=Math.max(f.maxY,h),l.kind==="root"&&(f.label=nx(l)??f.label)):n.set(l.sessionId,{minX:u,minY:c,maxX:p,maxY:h,label:nx(l)??l.sessionId})}const r=new Map;for(const o of n.values())r.set(o.label,(r.get(o.label)??0)+1);const s=[];for(const[o,l]of n){const c=(r.get(l.label)??0)>1?`${l.label} · ${HP(o)}`:l.label;s.push({sessionId:o,label:c,x:l.minX-El,y:l.minY-El-tx,w:l.maxX-l.minX+El*2,h:l.maxY-l.minY+El*2+tx})}return s}function HP(e){const n=e.match(/[a-zA-Z0-9]{4}/);return n?n[0]:e.slice(0,4)}function nx(e){if(e.kind==="root")return e.label}function VP(){const{x:e,y:n,zoom:r}=cN(),s=ua(),o=Xe(UP,WP);if(o.length<=1)return null;const l=u=>{try{const c=s.getNodes().filter(p=>{const h=p.data;return(h==null?void 0:h.sessionId)===u});if(c.length===0)return;s.fitView({padding:.3,duration:500,nodes:c})}catch{}};return g.jsx("div",{className:"session-clusters",children:o.map(u=>{const c=mv(u.sessionId),p={position:"absolute",left:u.x*r+e,top:u.y*r+n,width:u.w*r,height:u.h*r,borderColor:`hsl(${c} 65% 55% / 0.32)`,background:`hsl(${c} 70% 50% / 0.04)`},h={position:"absolute",left:u.x*r+e+16*r,top:(u.y-BP)*r+n,color:`hsl(${c} 70% 78%)`,borderColor:`hsl(${c} 65% 55% / 0.5)`,transform:`scale(${Math.min(1,r)})`,transformOrigin:"left top"};return g.jsxs(ae.Fragment,{children:[g.jsx("div",{className:"cluster-card",style:p,"aria-hidden":!0}),g.jsx("button",{type:"button",className:"cluster-label",style:h,title:`Fit view to ${u.label} · drag the wrapper to move the whole session`,onClick:()=>l(u.sessionId),children:u.label})]},u.sessionId)})})}function WP(e,n){if(e.length!==n.length)return!1;for(let r=0;r<e.length;r++){const s=e[r],o=n[r];if(s.sessionId!==o.sessionId||s.label!==o.label||s.x!==o.x||s.y!==o.y||s.w!==o.w||s.h!==o.h)return!1}return!0}function GP({data:e}){return g.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const xN=600,YP=36,Vg=16,KP=60,XP=6,rx=220,ix=96,QP=28,ZP={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 JP(e){return e.startsWith("mcp__")?"mcp":ZP[e]??"other"}const e3={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 sx(e){return e.startsWith("mcp__")?"🔌":e3[e]??"✨"}const t3={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 _N(e){if(!e)return null;let n=e.trim();if(!n)return null;const r=n.match(/^(?:bash|sh|zsh|fish|powershell|pwsh)(?:\.exe)?\s+(?:-c|-Command|-NoProfile|-NonInteractive|\s)+["']([^"']+)["']/i);if(r)return _N(r[1]);for(;;){const l=n.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!l)break;n=n.slice(l[0].length)}n=n.replace(/^sudo(?:\s+-\S+)*\s+/,""),n=n.replace(/^(?:time|nohup|xargs)\s+/,"");const s=n.match(/^([^\s|;&<>(]+)/);if(!s)return null;let o=s[1];return o=o.replace(/^.*[/\\]/,""),o=o.replace(/\.(exe|cmd|bat|ps1)$/i,""),o||null}function n3(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const n=e;if(typeof n.cmd=="string")return n.cmd;if(typeof n.command=="string")return n.command;if(Array.isArray(n.command)&&n.command.every(r=>typeof r=="string")){const r=n.command;if(/powershell|cmd|bash|sh(\.exe)?$/i.test(r[0]??"")){const s=r.findIndex(o=>/^(-Command|-c)$/i.test(o));if(s>=0&&s+1<r.length)return r[s+1]}return r.join(" ")}return typeof n.script=="string"?n.script:null}const r3=new Set(["Bash","PowerShell","shell","exec_command","shell_command","write_stdin","wait"]),i3=new Set(["shell","exec_command","shell_command","write_stdin","wait","apply_patch","update_plan"]);function s3(e,n){return i3.has(e)||e.startsWith("mcp__")?Math.max(ix,34+n.length*7.5):ix}function o3(e,n){if(!r3.has(e))return null;const r=n3(n);if(!r)return null;const s=_N(r);return s?{emoji:t3[s]??"⚙️",label:s,category:"shell",detail:r}:null}const a3=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),ox={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:"🗄️"},ax={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 l3(e){const r=e.replace(/\\/g,"/").replace(/\/+$/,""),s=r.lastIndexOf("/");return s>=0?r.slice(s+1):r}function u3(e){const n=e.toLowerCase();if(ax[n])return ax[n];if(n.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(n))return"🧪";const r=n.lastIndexOf(".");if(r>0&&r<n.length-1){const s=n.slice(r+1);if(ox[s])return ox[s]}return"📄"}function c3(e,n){if(!n||typeof n!="object")return null;const r=n;if(e==="apply_patch"&&typeof r.patch=="string"){const s=r.patch.match(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/m);return s?s[1].trim():null}return typeof r.file_path=="string"?r.file_path:typeof r.notebook_path=="string"?r.notebook_path:typeof r.path=="string"?r.path:e==="Glob"&&typeof r.pattern=="string"?r.pattern:null}function d3(e,n){if(!a3.has(e))return null;const r=c3(e,n);if(!r)return null;const s=l3(r);return s?{emoji:e==="LS"?"📂":u3(s),label:s,category:"file",detail:r}:null}const SN={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 bN(e){if(!e.startsWith("mcp__"))return null;const n=e.slice(5),r=n.indexOf("__");return r<=0?{server:n,method:""}:{server:n.slice(0,r),method:n.slice(r+2)}}function f3(e){let n=5381;for(let r=0;r<e.length;r++)n=(n<<5)+n^e.charCodeAt(r);return Math.abs(n)%360}function h3(e,n){const r=bN(e);if(!r)return null;const{server:s,method:o}=r;if(!o)return null;const l=SN[s.toLowerCase()];return{emoji:(l==null?void 0:l.emoji)??"🔌",label:o,category:"mcp",detail:l?`${l.name} · ${o}`:`${s} · ${o}`}}function p3(e,n){return o3(e,n)??d3(e,n)??h3(e)}const m3={shell:"Shell",exec_command:"Shell",shell_command:"Shell",write_stdin:"stdin",wait:"wait",apply_patch:"Edit",update_plan:"Plan"};function g3(e){const n=bN(e);if(n){const s=SN[n.server.toLowerCase()];return s?{emoji:s.emoji,label:s.name}:{emoji:"🔌",label:n.server,hue:f3(n.server)}}const r=m3[e];return r?{emoji:sx(e),label:r}:{emoji:sx(e),label:e}}function v3(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function y3(e,n,r){if(r==null)return 1;const s=n-r;return s<0?1:Math.max(0,1-s/xN)}function w3(e,n,r,s,o,l){const u=[];for(const c of e.values()){if(!n.has(c.id)||c.exitAt!=null&&l-c.exitAt>xN)continue;const p=s.get(c.id)??r.get(c.id);if(!p)continue;const h=c.tools.slice(-4);if(h.length===0)continue;const f=c.exitAt??null,m=o.get(c.id),y=Math.max((m==null?void 0:m.width)??rx,rx),x=(m==null?void 0:m.height)??130,C=p.x,_=p.y,S=C+y,b=_+x/2;h.forEach((k,N)=>{const j=N*YP,P=C+y+KP,O=_+XP+j,L=y3(k,l,f),B=k.inputPreview??"",T=v3(k),M=L<.999,q=g3(k.name);u.push({id:k.id,toolId:k.id,agentId:c.id,toolName:k.name,name:q.label,emoji:q.emoji,status:T,category:JP(k.name),mcpHue:q.hue,inputPreview:B,fade:L,fading:M,worldX:P,worldY:O,anchorX:S,anchorY:b,spawnDx:S-P,spawnDy:b-(O+Vg)});const Y=p3(k.name,k.input);if(Y){const X=s3(k.name,q.label),I=P+X+QP,H=O,U=P+X,ne=O+Vg;u.push({id:`sub:${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:Y.label,emoji:Y.emoji,isSub:!0,status:T,category:Y.category,inputPreview:Y.detail??B,fade:L,fading:M,worldX:I,worldY:H,anchorX:U,anchorY:ne,spawnDx:U-I,spawnDy:0})}})}return u}function x3({agents:e,visibleAgentIds:n,positions:r,pinned:s,measured:o,dimUnmatched:l,spotlight:u,hiddenCategories:c,now:p,onOpenTool:h}){const f=w3(e,n,r,s,o,p),m=c&&c.size>0?f.filter(y=>!c.has(y.category)):f;return g.jsx(_3,{bursts:m,dimUnmatched:l,spotlight:u,onOpenTool:h})}function _3({bursts:e,dimUnmatched:n,spotlight:r,onOpenTool:s}){const{x:o,y:l,zoom:u}=cN();return g.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[g.jsx("svg",{className:"tool-bursts-svg",children:e.map(c=>{const p=c.anchorX*u+o,h=c.anchorY*u+l,f=(c.worldX+6)*u+o,m=(c.worldY+Vg)*u+l,y=p+(f-p)*.55,x=n!=null&&!n.has(c.agentId),C=r!=null&&!r.has(c.agentId),_=c.fade*(x||C?.14:1);return g.jsx("path",{d:`M ${p} ${h} Q ${y} ${h}, ${f} ${m}`,className:`tool-conn status-${c.status}${c.fading?" fading":""}`,opacity:_},`l:${c.id}`)})}),e.map(c=>{const p=c.worldX*u+o,h=c.worldY*u+l,f={left:`${p}px`,top:`${h}px`,transform:`scale(${u})`,transformOrigin:"left top","--spawn-dx":`${c.spawnDx}px`,"--spawn-dy":`${c.spawnDy}px`},m=c.isSub?`${c.toolName} · ${c.name}`:c.toolName,y=c.inputPreview?`${m} · ${c.inputPreview}`:m,x=s!=null,C=c.mcpHue!=null?{"--cat-accent":`hsl(${c.mcpHue} 65% 65%)`}:{},_=n!=null&&!n.has(c.agentId),S=r!=null&&!r.has(c.agentId),b=_||S?" dim":"";return g.jsx("div",{className:"tool-burst-wrap",style:f,children:g.jsxs("div",{className:`tool-burst cat-${c.category} status-${c.status}${c.fading?" fading":""}${x?" clickable":""}${c.isSub?" sub":""}${b}`,style:C,title:y,role:x?"button":void 0,tabIndex:x?0:void 0,"aria-label":x?`Open ${c.toolName} ${c.status==="inflight"?"in flight":c.status} — click for details`:void 0,onClick:x?()=>s(c.toolId):void 0,onKeyDown:x?k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),s(c.toolId))}:void 0,children:[g.jsx("span",{className:"tb-emoji",children:c.emoji}),g.jsx("span",{className:"tb-name",children:c.name}),c.status==="inflight"&&g.jsx("span",{className:"tb-spin"}),c.status==="done"&&g.jsx("span",{className:"tb-mark done",children:"✓"}),c.status==="err"&&g.jsx("span",{className:"tb-mark err",children:"×"})]})},c.id)})]})}function S3({state:e,sessionId:n,onClose:r}){const s=A.useMemo(()=>k3(e,n),[e,n]);return s?g.jsx("div",{className:"modal-backdrop",onClick:r,role:"presentation",children:g.jsxs("div",{className:"modal session-summary",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[g.jsxs("div",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),g.jsx("span",{id:"ss-title",className:"modal-tool-name",title:s.cwd??s.sessionId,children:s.label}),g.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.durationLabel}),g.jsx("button",{className:"btn",onClick:r,"aria-label":"Close",children:"×"})]})]}),g.jsxs("div",{className:"modal-body",children:[g.jsxs("section",{className:"ss-hero",children:[g.jsxs("div",{className:"ss-hero-left",children:[g.jsx("div",{className:"ss-cost-label",children:"total spend"}),g.jsx("div",{className:"ss-cost",children:Be(s.cost.total)}),s.modelChips.length>0&&g.jsx("div",{className:"ss-models",children:s.modelChips.map(o=>g.jsx("span",{className:"model-chip",title:o,children:ca(o)},o))})]}),g.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&g.jsxs(g.Fragment,{children:[g.jsx(b3,{cost:s.cost}),g.jsxs("div",{className:"ss-cost-legend",children:[g.jsxs("span",{className:"ssl ssl-in",children:["input ",g.jsx("b",{children:Be(s.cost.input)})]}),g.jsxs("span",{className:"ssl ssl-out",children:["output ",g.jsx("b",{children:Be(s.cost.output)})]}),g.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",g.jsx("b",{children:Be(s.cost.cacheRead)})]}),g.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",g.jsx("b",{children:Be(s.cost.cacheWrite)})]})]})]})})]}),g.jsxs("section",{className:"ss-stats",children:[g.jsx($s,{label:"agents",value:s.agentCount}),g.jsx($s,{label:"subagents",value:s.subagentCount}),g.jsx($s,{label:"tool calls",value:s.toolCount}),g.jsx($s,{label:"prompts",value:s.promptCount}),g.jsx($s,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&g.jsx($s,{label:"errors",value:s.errCount,tone:"err"})]}),s.topTools.length>0&&g.jsxs("section",{className:"modal-section",children:[g.jsx("h4",{children:"Most-used tools"}),g.jsx("div",{className:"ss-top-tools",children:s.topTools.map(([o,l])=>g.jsxs("div",{className:"ss-tt",children:[g.jsx("span",{className:"ss-tt-name",children:o}),g.jsx("span",{className:"ss-tt-bar",children:g.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${l/s.topTools[0][1]*100}%`}})}),g.jsx("span",{className:"ss-tt-count",children:l})]},o))})]}),s.firstPrompt&&g.jsxs("section",{className:"modal-section",children:[g.jsx("h4",{children:"Opening prompt"}),g.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]})]})}):null}function $s({label:e,value:n,tone:r}){return g.jsxs("div",{className:`ss-stat${r?` tone-${r}`:""}`,children:[g.jsx("div",{className:"ss-stat-value",children:n}),g.jsx("div",{className:"ss-stat-label",children:e})]})}function b3({cost:e}){const n=e.total;if(n<=0)return null;const r=(s,o,l)=>{if(s<=0)return null;const u=s/n*100;return g.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${Be(s)} (${u.toFixed(0)}%)`},o)};return g.jsxs("div",{className:"cost-bar cost-bar-lg","aria-label":"Cost breakdown",children:[r(e.input,"cb-input","input"),r(e.output,"cb-output","output"),r(e.cacheRead,"cb-cache-r","cache read"),r(e.cacheWrite,"cb-cache-w","cache write")]})}function k3(e,n){const r=e.agents.get(n);if(!r)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,p=0,h=0,f=0,m=0,y,x=1/0,C=0;for(const N of s){const j=on(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"&&m++,p+=N.prompts.length,!y&&N.prompts.length>0&&(y=N.prompts[0].text),h+=N.usage.inputTokens+N.usage.outputTokens,c+=N.toolCount,x=Math.min(x,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&&f++}const _=Math.max(0,C-x),S=Math.floor(_/1e3),b=S<60?`${S}s`:S<3600?`${Math.floor(S/60)}m ${String(S%60).padStart(2,"0")}s`:`${Math.floor(S/3600)}h ${Math.floor(S%3600/60)}m`,k=Array.from(u.entries()).sort((N,j)=>j[1]-N[1]).slice(0,5);return{sessionId:n,label:r.label||r.cwdBasename||"session",cwd:r.cwd,durationLabel:b,cost:o,modelChips:Array.from(l),agentCount:s.length,subagentCount:m,toolCount:c,promptCount:p,tokensSum:h,errCount:f,topTools:k,firstPrompt:y}}function E3(e,n){const r=[];for(const s of e.agents.values()){if(s.kind!=="root")continue;let o=s.toolCount,l=on(s.usage,s.model).total,u=s.endedAt??s.startedAt;for(const c of e.agents.values()){if(c.sessionId!==s.sessionId||c.kind==="root")continue;o+=c.toolCount,l+=on(c.usage,c.model).total;const p=c.endedAt??c.startedAt;p>u&&(u=p)}r.push({sessionId:s.sessionId,label:s.label||s.cwdBasename||"session",cwdBasename:s.cwdBasename,state:s.state,modelId:s.model,toolCount:o,cost:l,startedAt:s.startedAt,lastActivity:u})}return r.sort((s,o)=>{if(s.state!==o.state){if(s.state==="active")return-1;if(o.state==="active")return 1}return o.lastActivity-s.lastActivity}),r}function N3(e,n,r){const s=(n??r)-e;if(s<1e3)return"<1s";const o=Math.floor(s/1e3);if(o<60)return`${o}s`;const l=Math.floor(o/60);return l<60?`${l}m`:`${Math.floor(l/60)}h ${l%60}m`}function C3({state:e,now:n,selectedIds:r,onSelect:s,onClose:o}){const l=A.useMemo(()=>E3(e),[e,e.lastSeq,n]),u=l.filter(c=>c.state==="active").length;return g.jsxs("aside",{className:"session-list","aria-label":"Sessions",children:[g.jsxs("div",{className:"sl-header",children:[g.jsxs("h3",{children:["Sessions ",g.jsx("span",{className:"sl-count",children:l.length})]}),u>0&&g.jsxs("span",{className:"sl-live-count",children:[u," live"]}),g.jsx("button",{className:"btn icon-btn sl-close",onClick:o,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),g.jsxs("div",{className:"sl-rows",children:[l.length===0&&g.jsx("div",{className:"sl-empty",children:"No sessions yet."}),l.map(c=>{const p=r.has(c.sessionId);return g.jsxs("button",{type:"button",className:`sl-row state-${c.state}${p?" selected":""}`,onClick:()=>s(c.sessionId),title:`Focus ${c.label}`,children:[g.jsx("span",{className:`sl-dot state-${c.state}`,"aria-hidden":!0}),g.jsxs("div",{className:"sl-row-body",children:[g.jsxs("div",{className:"sl-row-head",children:[g.jsx("span",{className:"sl-label",children:c.label}),c.modelId&&g.jsx("span",{className:"model-chip",title:c.modelId,children:ca(c.modelId)})]}),g.jsxs("div",{className:"sl-row-meta",children:[g.jsxs("span",{title:"tool calls",children:[g.jsx("b",{children:c.toolCount})," tools"]}),c.cost>0&&g.jsx("span",{className:"sl-cost",title:"total spend",children:g.jsx("b",{children:Be(c.cost)})}),g.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(c.startedAt).toLocaleString()}`,children:N3(c.startedAt,c.state==="active"?void 0:c.lastActivity,n)})]})]})]},c.sessionId)})]})]})}function lx(e,n){if(!e)return null;const r=n-Math.floor(e/1e3);return r<10?"just now":r<60?`${r}s ago`:r<3600?`${Math.floor(r/60)}m ago`:`${Math.floor(r/3600)}h ago`}function j3(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 R3({cost:e}){const n=e.total;if(n<=0)return null;const r=(s,o,l)=>{if(s<=0)return null;const u=s/n*100;return g.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${Be(s)} (${u.toFixed(0)}%)`},o)};return g.jsxs("div",{className:"cost-bar","aria-label":"Cost breakdown",children:[r(e.input,"cb-input","input"),r(e.output,"cb-output","output"),r(e.cacheRead,"cb-cache-r","cache read"),r(e.cacheWrite,"cb-cache-w","cache write")]})}function T3(e,n){const r=e-n;if(r<=0)return null;const s=Math.floor(r/3600),o=Math.floor(r%3600/60);if(s>23){const l=Math.floor(r/86400),u=Math.floor(r%86400/3600);return`${l}d ${u}h`}return s>0?`${s}h ${o}m`:`${o}m`}function A3(e,n,r,s){const o=Math.max(0,n-s),l=Math.max(0,r-o);if(l<120)return null;const u=Math.min(100,l/r*100),c=e-u;if(Math.abs(c)<3)return{label:"on pace",color:"var(--ok)",expectedPct:u,isDeficit:!1};if(c>0){const p=100-e,h=l>0?e/l:0,f=h>0?p/h:1/0,m={label:`${Math.round(c)}% ahead`,color:"var(--warn)",expectedPct:u,isDeficit:!0};if(f<o&&f<86400){const y=Math.floor(f/3600),x=Math.floor(f%3600/60);m.runsOutIn=y>0?`${y}h ${x}m`:`${x}m`}return m}return{label:`${Math.round(-c)}% reserve`,color:"var(--ok)",expectedPct:u,isDeficit:!1}}function Hi({pct:e,label:n,reset:r,resetAt:s,windowSec:o,limitReached:l,nowSec:u}){const c=Math.min(100,Math.max(0,e)),h=l||c>=90?"var(--err)":c>=70?"var(--warn)":"var(--accent)",f=c===0?"< 1%":`${c}%`,m=c===0?2:c,y=s?T3(s,u):null,x=s&&o?A3(c,s,o,u):null;return g.jsxs("div",{className:"qb-row",children:[g.jsxs("div",{className:"qb-meta",children:[g.jsxs("span",{className:"qb-label",children:[n,l&&g.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),g.jsx("span",{className:"qb-pct",style:{color:h},children:f})]}),g.jsxs("div",{className:"qb-track",children:[g.jsx("div",{className:"qb-fill",style:{width:`${m}%`,background:h,opacity:c===0?.4:1}}),x&&g.jsx("div",{className:"qb-pace-marker",style:{left:`${x.expectedPct}%`,background:x.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(x.expectedPct)}% by now`})]}),g.jsxs("div",{className:"qb-reset-row",children:[y?g.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):r?g.jsxs("span",{className:"qb-reset",children:["resets ",r]}):null,x&&g.jsx("span",{className:"qb-pace",style:{color:x.color},children:x.runsOutIn?`runs out in ${x.runsOutIn}`:x.label})]})]})}const I3=6e4;function M3(){const[e,n]=A.useState(null),[r,s]=A.useState(!1),o=A.useRef(null),l=async(c=!1)=>{c&&s(!0);try{const h=await fetch(c?"/api/quota?refresh=1":"/api/quota");h.ok&&n(await h.json())}catch{}finally{c&&s(!1)}};return A.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),I3),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{quota:e,loading:r,refresh:()=>l(!0)}}function P3(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 kN=6e4;function O3(){const[e,n]=A.useState(null),[r,s]=A.useState(!1),o=A.useRef(null),l=async(c=!1)=>{c&&s(!0);try{const h=await fetch(c?"/api/codex-quota?refresh=1":"/api/codex-quota");h.ok&&n(await h.json())}catch{}finally{c&&s(!1)}};return A.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),kN),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{data:e,loading:r,refresh:()=>l(!0)}}function q3(){const[e,n]=A.useState(null),r=A.useRef(null),s=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return A.useEffect(()=>(s(),r.current=window.setInterval(s,kN),()=>{r.current!=null&&window.clearInterval(r.current)}),[]),{data:e}}function L3({state:e,now:n,onClose:r}){var L,B;const{quota:s,loading:o,refresh:l}=M3(),{data:u,loading:c,refresh:p}=O3(),{data:h}=q3(),[f,m]=A.useState(()=>Math.floor(Date.now()/1e3));A.useEffect(()=>{const T=window.setInterval(()=>m(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(T)},[]);const{byModel:y,totalCost:x,totalTokens:C,burnRate:_}=A.useMemo(()=>{const T=new Map,M={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let q=0,Y=0,X=0,I=0;for(const F of e.agents.values()){const G=F.model??"__unknown__",E=on(F.usage,F.model),$=T.get(G);$?($.inputTokens+=F.usage.inputTokens,$.outputTokens+=F.usage.outputTokens,$.cacheReadTokens+=F.usage.cacheReadTokens,$.cacheCreateTokens+=F.usage.cacheCreateTokens,$.cost.total+=E.total,$.cost.input+=E.input,$.cost.output+=E.output,$.cost.cacheRead+=E.cacheRead,$.cost.cacheWrite+=E.cacheWrite,$.agentCount++):T.set(G,{model:G,inputTokens:F.usage.inputTokens,outputTokens:F.usage.outputTokens,cacheReadTokens:F.usage.cacheReadTokens,cacheCreateTokens:F.usage.cacheCreateTokens,cost:{...E},agentCount:1}),M.total+=E.total,M.input+=E.input,M.output+=E.output,M.cacheRead+=E.cacheRead,M.cacheWrite+=E.cacheWrite,q+=F.usage.inputTokens,Y+=F.usage.outputTokens,X+=F.usage.cacheReadTokens,I+=F.usage.cacheCreateTokens}const H=Array.from(T.values()).sort((F,G)=>G.cost.total-F.cost.total);let U=0,ne=0;for(const F of e.agents.values()){if(F.state!=="active")continue;const G=on(F.usage,F.model);U+=G.total,ne=Math.max(ne,((F.endedAt??n)-F.startedAt)/1e3)}const J=ne>0?Vl(U,ne):null;return{byModel:H,totalCost:M,totalTokens:{in:q,out:Y,cacheR:X,cacheC:I},burnRate:J}},[e,e.lastSeq,n]),S=A.useMemo(()=>{const T=[];for(const M of e.agents.values()){if(M.kind!=="root")continue;let q=on(M.usage,M.model).total,Y=M.usage.inputTokens,X=M.usage.outputTokens;for(const I of e.agents.values())I.sessionId!==M.sessionId||I.kind==="root"||(q+=on(I.usage,I.model).total,Y+=I.usage.inputTokens,X+=I.usage.outputTokens);T.push({sessionId:M.sessionId,label:M.label||M.cwdBasename||"session",state:M.state,cost:q,inputTokens:Y,outputTokens:X})}return T.sort((M,q)=>q.cost-M.cost).slice(0,12)},[e,e.lastSeq]),b=x.total>0,k=C.in+C.out,N=o||c,j=lx(s==null?void 0:s.fetchedAt,f),P=lx(u==null?void 0:u.fetchedAt,f),O=()=>{l(),p()};return g.jsxs("div",{className:"usage-panel","aria-label":"Usage",children:[g.jsxs("div",{className:"up-header",children:[g.jsx("h3",{children:"Usage"}),_&&g.jsx("span",{className:"up-rate",children:_}),g.jsxs("div",{className:"up-header-right",children:[g.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:O,disabled:N,title:"Refresh Claude + Codex quota",children:N?"…":"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn up-close",onClick:r,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h4",{className:"up-section-title",children:["Claude quota",j&&!o&&g.jsx("span",{className:"up-section-age",title:j3(s==null?void 0:s.source),children:j})]}),s!=null&&s.ok?g.jsxs("div",{className:"up-quota-bars",children:[s.session5hPct!=null&&g.jsx(Hi,{label:"5-hour window",pct:s.session5hPct,reset:s.session5hReset,resetAt:s.session5hResetAt,windowSec:s.session5hWindowSec,nowSec:f}),s.week7dPct!=null&&g.jsx(Hi,{label:"7-day window",pct:s.week7dPct,reset:s.week7dReset,resetAt:s.week7dResetAt,windowSec:s.week7dWindowSec,nowSec:f}),s.weekSonnetPct!=null&&g.jsx(Hi,{label:"Sonnet (7d)",pct:s.weekSonnetPct,nowSec:f}),s.weekOpusPct!=null&&g.jsx(Hi,{label:"Opus (7d)",pct:s.weekOpusPct,nowSec:f})]}):(s==null?void 0:s.ok)===!1?g.jsxs("div",{className:"up-quota-na",children:[g.jsx("span",{children:"Quota unavailable."}),g.jsxs("span",{className:"up-quota-hint",children:["Run ",g.jsx("code",{children:"/usage"})," in a claude session, then click ↻"]})]}):g.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h4",{className:"up-section-title",children:["Codex quota",(u==null?void 0:u.ok)&&u.planLabel&&g.jsx("span",{className:"up-plan-badge",children:u.planLabel}),P&&!c&&g.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:P})]}),u!=null&&u.ok?g.jsxs("div",{className:"up-quota-bars",children:[(L=u.windows)==null?void 0:L.map(T=>g.jsx(Hi,{label:T.label,pct:T.pct,reset:T.reset??void 0,resetAt:T.resetAt??void 0,windowSec:T.windowSec??void 0,limitReached:u.limitReached&&T.pct>=100,nowSec:f},T.id)),(B=u.extraWindows)==null?void 0:B.map(T=>g.jsx(Hi,{label:T.label,pct:T.pct,reset:T.reset??void 0,resetAt:T.resetAt??void 0,windowSec:T.windowSec??void 0,nowSec:f},T.id)),u.creditLimit&&g.jsx(Hi,{label:`spend cap · $${Math.round(u.creditLimit.used)} of $${Math.round(u.creditLimit.limit)}`,pct:u.creditLimit.usedPct,reset:u.creditLimit.reset??void 0,resetAt:u.creditLimit.resetAt??void 0,limitReached:u.spendControlReached,nowSec:f}),(h==null?void 0:h.ok)&&h.window7d&&h.window7d.sessionCount>0&&g.jsxs("div",{className:"up-quota-sub",children:[Ar(h.window7d.totalTokens)," tokens · ",h.window7d.sessionCount," session",h.window7d.sessionCount!==1?"s":""," (7d)"]}),u.creditsBalance&&!u.creditsUnlimited&&g.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",u.creditsBalance,u.overageReached&&" · overage limit reached"]}),u.creditsUnlimited&&g.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),u.resetCredits&&u.resetCredits.availableCount>0&&g.jsxs("div",{className:"up-quota-sub up-reset-credits",title:"Redeem in the Codex CLI or ChatGPT — agents-deck only reports them",children:[u.resetCredits.availableCount," rate-limit reset",u.resetCredits.availableCount!==1?"s":""," available",u.resetCredits.nextExpiryAt&&` · expires ${new Date(u.resetCredits.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`]}),u.promo&&g.jsx("div",{className:"up-quota-sub",children:u.promo}),u.partial&&g.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(u==null?void 0:u.ok)===!1?g.jsxs("div",{className:"up-quota-na",children:[g.jsx("span",{children:"Quota unavailable."}),g.jsx("span",{className:"up-quota-hint",children:P3(u.reason)})]}):g.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),b?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"up-total",children:[g.jsx("span",{className:"up-total-value",children:Be(x.total)}),g.jsx("span",{className:"up-total-label",children:"total spend"})]}),g.jsx(R3,{cost:x}),k>0&&g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),Ar(C.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),Ar(C.out)]}),C.cacheR>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache r"}),Ar(C.cacheR)]}),C.cacheC>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache c"}),Ar(C.cacheC)]})]}),y.filter(T=>T.cost.total>0).length>0&&g.jsxs("section",{className:"up-section",children:[g.jsx("h4",{className:"up-section-title",children:"By model"}),g.jsxs("table",{className:"up-table",children:[g.jsx("thead",{children:g.jsxs("tr",{children:[g.jsx("th",{children:"Model"}),g.jsx("th",{children:"Tokens"}),g.jsx("th",{children:"Cost"})]})}),g.jsx("tbody",{children:y.filter(T=>T.cost.total>0).map(T=>g.jsxs("tr",{children:[g.jsx("td",{className:"up-model-name",title:T.model,children:ca(T.model)}),g.jsx("td",{className:"up-num",children:Ar(T.inputTokens+T.outputTokens)}),g.jsx("td",{className:"up-num up-cost-val",children:Be(T.cost.total)})]},T.model))})]})]}),S.filter(T=>T.cost>0).length>0&&g.jsxs("section",{className:"up-section",children:[g.jsx("h4",{className:"up-section-title",children:"By session"}),g.jsx("div",{className:"up-sessions",children:S.filter(T=>T.cost>0).map(T=>g.jsxs("div",{className:"up-session-row",children:[g.jsx("span",{className:`sl-dot state-${T.state}`,"aria-hidden":!0}),g.jsx("span",{className:"up-session-label",children:T.label}),g.jsx("span",{className:"up-session-tokens",children:Ar(T.inputTokens+T.outputTokens)}),g.jsx("span",{className:"up-session-cost",children:Be(T.cost)})]},T.sessionId))})]})]}):k>0?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),Ar(C.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),Ar(C.out)]})]}),g.jsx("div",{className:"up-hint",children:"Cost appears once a known model is detected."})]}):g.jsxs("div",{className:"up-empty",children:["No usage data yet.",g.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const ux=18,$3=1100,Ds=(e,n)=>{const r=Math.sin(e*12.9898+n*78.233)*43758.5453;return r-Math.floor(r)},D3=Array.from({length:ux},(e,n)=>{const r=-72+144*n/(ux-1)+(Ds(n,1)-.5)*9,s=(r-90)*(Math.PI/180),o=(54+32*Math.cos(r*Math.PI/180))*(.74+Ds(n,2)*.52);return{dx:Math.cos(s)*o,dy:Math.sin(s)*o,rot:(n%2?1:-1)*(100+Ds(n,3)*260),delay:Math.round(Ds(n,4)*90),dur:760+Math.round(Ds(n,5)*260),scale:.8+Ds(n,6)*.45,hue:n%4,round:n%3===0}});function cx({anchor:e,lifetimeMs:n=$3}){var l;const[r,s]=A.useState(null),o=typeof window<"u"&&((l=window.matchMedia)==null?void 0:l.call(window,"(prefers-reduced-motion: reduce)").matches);return A.useEffect(()=>{if(o)return;const u=e.current;if(!u)return;const c=u.getBoundingClientRect();s({x:c.left+c.width/2,y:c.top+c.height/2});const p=window.setTimeout(()=>s(null),n);return()=>window.clearTimeout(p)},[e,n,o]),o||!r?null:tI.createPortal(g.jsx("div",{className:"confetti",style:{left:`${r.x}px`,top:`${r.y}px`},"aria-hidden":!0,children:D3.map((u,c)=>g.jsx("span",{className:`confetti-bit${u.round?" round":""}`,"data-hue":u.hue,style:{"--dx":`${u.dx.toFixed(1)}px`,"--dy":`${u.dy.toFixed(1)}px`,"--rot":`${u.rot}deg`,"--s":u.scale.toFixed(2),animationDelay:`${u.delay}ms`,animationDuration:`${u.dur}ms, ${u.dur}ms`}},c))}),document.body)}const EN=new Set(["awaiting_url","awaiting_code","registering"]);function F3(e){return e!=null&&EN.has(e)}function z3(e){return e!=null&&e!=="done"&&!EN.has(e)}const B3="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",U3="the sign-in did not complete";function H3({state:e,serverError:n,localError:r}){const s=e==="idle";return{title:s?"Sign-in ended":"Sign-in failed",message:r||n||(s?B3:U3)}}const V3=1500;async function Nl(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const W3={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?W3[e.reason]??e.reason:null)||(e==null?void 0:e.error)||n,Wg=ae.forwardRef((e,n)=>g.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:n,children:[g.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),g.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));Wg.displayName="SuccessMark";function G3({onClose:e,onChanged:n}){const[r,s]=A.useState("login"),[o,l]=A.useState(null),[u,c]=A.useState(""),[p,h]=A.useState(""),[f,m]=A.useState(!1),[y,x]=A.useState(null),[C,_]=A.useState(null),S=A.useRef(!1),b=A.useRef(null),k=A.useRef(null),N=A.useRef(null),j=A.useCallback(()=>{S.current&&Nl({action:"login-cancel"}).catch(()=>{}),e()},[e]);A.useEffect(()=>{const q=Y=>{Y.key==="Escape"&&j()};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[j]);const P=A.useCallback(async()=>{m(!0),x(null),S.current=!0;const q=await Nl({action:"login"}).catch(()=>null);if(m(!1),!(q!=null&&q.ok)){x(od(q,"could not start the sign-in"));return}l(q)},[]);A.useEffect(()=>{if(!F3(o==null?void 0:o.state))return;const q=window.setInterval(async()=>{try{const Y=await fetch("/api/claude-accounts/login");Y.ok&&l(await Y.json())}catch{}},V3);return()=>window.clearInterval(q)},[o]),A.useEffect(()=>{var q;(o==null?void 0:o.state)==="awaiting_code"&&((q=b.current)==null||q.focus()),(o==null?void 0:o.state)==="done"&&n()},[o==null?void 0:o.state,n]),A.useEffect(()=>{var q;r==="paste"&&((q=k.current)==null||q.focus())},[r]);const O=A.useCallback(async()=>{var Y;m(!0),x(null);const q=await Nl({action:"login-code",code:u}).catch(()=>null);if(m(!1),!(q!=null&&q.ok)){x(od(q,"the code was not accepted")),q!=null&&q.state&&l(q),(Y=b.current)==null||Y.select();return}c(""),l(q)},[u,o]),L=A.useCallback(async()=>{m(!0),x(null);const q=await Nl({action:"import",blob:p}).catch(()=>null);if(m(!1),!(q!=null&&q.ok)){x(od(q,"the import failed"));return}h(""),_({added:q.added===!0,num:q.num??null,email:q.email??null}),n()},[p,n]),B=(o==null?void 0:o.state)==="done"?o.account:null,T=z3(o==null?void 0:o.state)||!!(y&&S.current&&!f),M=H3({state:o==null?void 0:o.state,serverError:o==null?void 0:o.error,localError:y});return g.jsx("div",{className:"modal-backdrop",onClick:j,role:"presentation",children:g.jsxs("div",{className:"modal aa-modal",onClick:q=>q.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[g.jsxs("header",{className:"modal-head",children:[g.jsx("div",{className:"modal-title",children:g.jsxs("span",{className:"aa-tabs",role:"tablist",children:[g.jsx("button",{type:"button",role:"tab","aria-selected":r==="login",className:`aa-tab${r==="login"?" on":""}`,onClick:()=>s("login"),children:"Sign in"}),g.jsx("button",{type:"button",role:"tab","aria-selected":r==="paste",className:`aa-tab${r==="paste"?" on":""}`,onClick:()=>s("paste"),children:"Paste a share"})]})}),g.jsx("div",{className:"modal-actions",children:g.jsx("button",{type:"button",className:"btn icon-btn",onClick:j,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),g.jsx("section",{className:"modal-body aa-body",children:r==="login"?B?g.jsxs("div",{className:"aa-done",children:[g.jsx(Wg,{ref:N}),g.jsx(cx,{anchor:N}),g.jsx("h4",{children:B.added?`Account ${B.num} added`:"Credentials refreshed"}),g.jsxs("p",{className:"aa-note",children:[g.jsx("strong",{children:B.email}),B.added?" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),g.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"})]}):(o==null?void 0:o.state)==="awaiting_code"||(o==null?void 0:o.state)==="registering"?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"1 · Approve in the browser"}),g.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),g.jsx("a",{className:"aa-link",href:o.url??"#",target:"_blank",rel:"noreferrer noopener",children:o.url})]}),g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"2 · Paste the code it gives you"}),g.jsxs("div",{className:"aa-field",children:[g.jsx("input",{ref:b,type:"text",value:u,onChange:q=>c(q.target.value),onKeyDown:q=>{q.key==="Enter"&&u.trim()&&!f&&O()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:o.state==="registering"}),g.jsx("button",{type:"button",className:"btn primary",disabled:f||!u.trim()||o.state==="registering",onClick:O,children:o.state==="registering"?"registering…":"Continue"})]}),(y||o.error)&&g.jsx("p",{className:"aa-err",children:y??o.error}),g.jsx("p",{className:"aa-note",children:"The code goes straight to the claude CLI on this machine. It is never stored or sent anywhere else."})]})]}):T?g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:M.title}),g.jsx("p",{className:"aa-err",children:M.message}),g.jsx("button",{type:"button",className:"btn",onClick:()=>{S.current=!1,l(null),x(null),P()},children:"Try again"})]}):f||S.current?g.jsx("div",{className:"aa-step",children:g.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):g.jsxs("div",{className:"aa-step aa-primer",children:[g.jsx("h4",{children:"Sign in to Anthropic"}),g.jsx("p",{className:"aa-note",children:"Opens a browser tab where you approve the sign-in, then asks for the code it shows you. claude-swap records the account when it completes, and the account you are using now stays active."}),g.jsx("div",{className:"aa-actions",children:g.jsx("button",{type:"button",className:"btn primary",onClick:P,disabled:f,children:"Open the sign-in page"})})]}):C?g.jsxs("div",{className:"aa-done",children:[g.jsx(Wg,{ref:N}),C.added&&g.jsx(cx,{anchor:N}),g.jsx("h4",{children:C.added?`Account ${C.num} imported`:"Already here"}),g.jsx("p",{className:"aa-note",children:C.added?g.jsxs(g.Fragment,{children:[C.email?g.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."}),g.jsxs("div",{className:"aa-actions",children:[g.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"}),g.jsx("button",{type:"button",className:"btn",onClick:()=>_(null),children:"Import another"})]})]}):g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"Paste an account shared from another deck"}),g.jsxs("div",{className:"aa-field",children:[g.jsx("input",{ref:k,type:"text",value:p,onChange:q=>h(q.target.value),onKeyDown:q=>{q.key==="Enter"&&p.trim()&&!f&&L()},placeholder:"ccdeck1:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),g.jsx("button",{type:"button",className:"btn primary",disabled:f||!p.trim(),onClick:L,children:f?"importing…":"Import"})]}),y&&g.jsx("p",{className:"aa-err",children:y}),g.jsxs("p",{className:"aa-note",children:["Use ",g.jsx("strong",{children:"share"})," on an account in the other deck. A share carries a live login and expires ten minutes after it is made."]})]})})]})})}const Y3=15e3,K3=[70,80,85,90,95];function X3(e,n){const r=e-n;if(r<=0)return null;const s=Math.floor(r/86400),o=Math.floor(r%86400/3600),l=Math.floor(r%3600/60);return s>0?`${s}d ${o}h`:o>0?`${o}h ${l}m`:`${l}m`}function dx(e,n){const r=n-Math.floor(e/1e3);return r<60?"just now":r<3600?`${Math.floor(r/60)}m ago`:r<86400?`${Math.floor(r/3600)}h ago`:`${Math.floor(r/86400)}d ago`}function Q3(e,n){if(!e)return"";const r=Math.floor(e/1e3)-n;return r<=0?" · due":r<60?` · next in ${r}s`:` · next in ${Math.round(r/60)}m`}function Z3(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 J3({lane:e,nowSec:n}){const r=Math.min(100,Math.max(0,e.pct)),s=r>=90?"var(--err)":r>=70?"var(--warn)":"var(--accent)",o=e.resetAt?X3(e.resetAt,n):null;return g.jsxs("div",{className:"ap-lane",children:[g.jsx("span",{className:"ap-lane-label",children:e.label}),g.jsx("div",{className:"ap-lane-track",children:g.jsx("div",{className:"ap-lane-fill",style:{width:`${r===0?1.5:r}%`,background:s,opacity:r===0?.4:1}})}),g.jsxs("span",{className:"ap-lane-pct",style:{color:s},children:[r,"%"]}),g.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}function eO(e){const n=e.map(s=>s.num),r=n.length?Math.max(...n):0;return[...new Set([...n,r+1])].sort((s,o)=>s-o)}async function tO(e){var r;let n=!1;try{n=await Promise.race([((r=navigator.clipboard)==null?void 0:r.writeText(e).then(()=>!0))??Promise.resolve(!1),new Promise(s=>window.setTimeout(()=>s(!1),500))])}catch{n=!1}if(n)return!0;try{const s=document.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(s),s.select(),n=document.execCommand("copy"),s.remove()}catch{n=!1}return n}function nO(e,n){const r=Math.round(e/1e3)-n;return r<=0?{text:"expired",tone:"gone"}:r<60?{text:`expires in ${r}s`,tone:"soon"}:{text:`expires in ${Math.round(r/60)}m`,tone:"ok"}}function rO({onClose:e}){var J,F,G;const[n,r]=A.useState(null),[s,o]=A.useState(null),[l,u]=A.useState(null),[c,p]=A.useState(null),[h,f]=A.useState(null),[m,y]=A.useState(()=>Math.floor(Date.now()/1e3)),x=A.useRef(null),[C,_]=A.useState(null),[S,b]=A.useState(!1),[k,N]=A.useState(""),[j,P]=A.useState(null),[O,L]=A.useState(null),[B,T]=A.useState(!1),M=A.useCallback(async(E=!1)=>{try{const[$,se]=await Promise.all([fetch(`/api/claude-accounts${E?"?refresh=1":""}`),fetch("/api/cswap-auto")]);$.ok&&r(await $.json()),se.ok&&o(await se.json())}catch{}},[]),q=A.useCallback(async(E,$)=>{u($),f(null);try{const D=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)})).json().catch(()=>null);return D!=null&&D.ok||f((D==null?void 0:D.detail)||(D==null?void 0:D.reason)||"command failed"),D}catch{return f("server unreachable"),null}finally{u(null)}},[]),Y=A.useCallback(async(E,$)=>{u($),f(null);try{const D=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)})).json().catch(()=>null);return D!=null&&D.ok||f((D==null?void 0:D.detail)||(D==null?void 0:D.reason)||"command failed"),D}catch{return f("server unreachable"),null}finally{u(null)}},[]);A.useEffect(()=>(M(!0),x.current=window.setInterval(()=>M(!1),Y3),()=>{x.current!=null&&window.clearInterval(x.current)}),[M]),A.useEffect(()=>{const E=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(E)},[]);const X=((J=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:J.value)??"90",I=(F=n==null?void 0:n.accounts)==null?void 0:F.find(E=>E.active),H=I!=null&&I.lanes.length?Math.max(...I.lanes.map(E=>E.pct)):null,U=H!=null&&H>=Number(X)-15,ne=async E=>{p(E),f(null);try{const se=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:E})})).json().catch(()=>null);se!=null&&se.ok||f((se==null?void 0:se.output)||(se==null?void 0:se.reason)||"switch failed"),await M(!0)}catch{f("server unreachable")}finally{p(null)}};return g.jsxs("div",{className:"accounts-panel","aria-label":"Claude accounts",children:[g.jsxs("div",{className:"ap-header",children:[g.jsx("h3",{children:"Accounts"}),g.jsxs("div",{className:"ap-header-right",children:[g.jsx("button",{type:"button",className:"btn ap-add",onClick:()=>b(!0),title:"Sign in to another Claude account, or paste one shared from another deck",children:"+"}),g.jsx("button",{type:"button",className:"btn ap-refresh",onClick:()=>M(!0),title:"Reload from claude-swap",children:"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),n==null?g.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?g.jsxs(g.Fragment,{children:[(G=n.accounts)==null?void 0:G.map(E=>g.jsxs("div",{className:`ap-account${E.active?" active":""}${E.disabled?" disabled":""}`,children:[g.jsxs("div",{className:"ap-account-head",children:[g.jsx("span",{className:"ap-num",children:E.num}),E.alias&&g.jsx("span",{className:"ap-alias",children:E.alias}),g.jsx("span",{className:"ap-email",title:E.org??void 0,children:E.email}),g.jsx("button",{type:"button",className:`ap-more${C===E.num?" on":""}`,"aria-label":`Manage account ${E.num}`,"aria-expanded":C===E.num,title:"Share, rename, move, remove",onClick:()=>{_(C===E.num?null:E.num),N(E.alias??""),P(null),L(null),T(!1)},children:"⋯"}),E.active?g.jsx("span",{className:"ap-badge-active",children:"● active"}):g.jsx("button",{type:"button",className:"btn ap-switch",disabled:c!=null||E.disabled,onClick:()=>ne(E.num),title:E.disabled?"Held out of rotation":`Switch to ${E.alias??E.email}`,children:c===E.num?"…":"switch"})]}),E.lanes.length>0?E.lanes.map($=>g.jsx(J3,{lane:$,nowSec:m},$.id)):g.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),g.jsxs("div",{className:"ap-meta",children:[E.error&&(()=>{const $=Z3(E.error);return g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"ap-err",title:$.hint,children:$.text}),$.fixable&&g.jsx("button",{type:"button",className:"ap-fix",onClick:()=>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))&&!E.active&&g.jsx("button",{type:"button",className:"ap-rotate",disabled:l!=null,onClick:()=>q({action:"account",account:E.num,enabled:E.disabled},`rot-${E.num}`).then(()=>M(!0)),title:E.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:E.disabled?"held out":"in rotation"}),E.fetchedAt?g.jsxs("span",{className:`ap-age${E.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 ",dx(E.fetchedAt,m),Q3(E.nextAt,m)]}):g.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),C===E.num&&g.jsxs("div",{className:"ap-manage",children:[g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("span",{className:"ap-manage-label",children:"name"}),g.jsx("input",{className:"ap-manage-input",type:"text",value:k,onChange:$=>N($.target.value),onKeyDown:$=>{$.key==="Enter"&&Y({action:"alias",account:E.num,alias:k},`alias-${E.num}`).then(()=>M(!0))},placeholder:"no alias",spellCheck:!1,"aria-label":`Alias for account ${E.num}`}),g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null||k.trim()===(E.alias??""),onClick:()=>Y({action:"alias",account:E.num,alias:k},`alias-${E.num}`).then(()=>M(!0)),title:"A short name to show instead of the email",children:"save"})]}),g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("span",{className:"ap-manage-label",children:"slot"}),g.jsx("span",{className:"ap-field",children:g.jsx("select",{"aria-label":`Slot for account ${E.num}`,value:String(E.num),disabled:l!=null,onChange:$=>Y({action:"move",account:E.num,slot:Number($.target.value)},`move-${E.num}`).then(()=>M(!0)),children:eO(n.accounts??[]).map($=>g.jsx("option",{value:$,children:$},$))})}),g.jsx("span",{className:"ap-manage-hint",children:"rotation order"})]}),g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,title:"Copy this account to another agents-deck. The share carries a live login and expires in 10 minutes.",onClick:async()=>{T(!1);const $=await Y({action:"share",account:E.num},`share-${E.num}`);$!=null&&$.ok&&L({num:E.num,blob:$.blob,expiresAt:$.expiresAt})},children:"share…"}),g.jsx("button",{type:"button",className:`ap-manage-btn danger${j===E.num?" armed":""}`,disabled:l!=null,title:j===E.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(j!==E.num){P(E.num),window.setTimeout(()=>P($=>$===E.num?null:$),4e3);return}P(null),Y({action:"remove",account:E.num},`rm-${E.num}`).then(()=>{_(null),M(!0)})},children:j===E.num?"confirm remove":"remove"})]}),(O==null?void 0:O.num)===E.num&&(()=>{const $=nO(O.expiresAt,m),se=$.tone==="gone";return g.jsxs("div",{className:`ap-share${se?" expired":""}`,children:[g.jsx("code",{className:"ap-share-blob",children:O.blob}),g.jsxs("div",{className:"ap-share-foot",children:[g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,onClick:async()=>{if(se){T(!1);const D=await Y({action:"share",account:E.num},`share-${E.num}`);D!=null&&D.ok&&L({num:E.num,blob:D.blob,expiresAt:D.expiresAt});return}await tO(O.blob)&&(T(!0),window.setTimeout(()=>T(!1),1800))},children:se?"make a new share":B?"copied":"copy"}),g.jsxs("span",{className:"ap-manage-hint",children:["carries a live login · ",g.jsx("span",{className:`ap-share-expiry ${$.tone}`,children:$.text})]})]})]})})()]})]},E.num)),(s==null?void 0:s.ok)&&g.jsxs("div",{className:"ap-auto",children:[g.jsxs("div",{className:"ap-auto-head",children:[g.jsx("span",{className:"ap-auto-title",children:"Auto-switch"}),g.jsxs("span",{className:"ap-auto-ctl",children:[H!=null&&g.jsxs("span",{className:`ap-auto-now${U?" near":""}`,children:[Math.round(H),"%"]}),g.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:g.jsx("select",{"aria-label":"Switch threshold",value:X,disabled:l!=null,onChange:E=>q({action:"setting",key:"autoswitch.threshold",value:E.target.value},"threshold").then(()=>M(!0)),children:K3.map(E=>g.jsxs("option",{value:E,children:[E,"%"]},E))})}),g.jsxs("button",{type:"button",className:`ap-auto-state toggle${s.enabled?" live":""}`,role:"switch","aria-checked":s.enabled,disabled:l!=null,onClick:()=>q({action:"enable",enabled:!s.enabled},"enable").then(()=>M(!0)),title:s.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[g.jsx("i",{className:s.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),s.enabled?"on":"off"]})]})]}),s.external&&g.jsxs("p",{className:"ap-auto-note",children:[g.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",g.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",s.enabled?" — this toggle takes over when you stop it.":"."]}),s.lastTick&&g.jsx("div",{className:"ap-auto-foot",children:g.jsxs("span",{className:"ap-auto-result",children:["checked ",dx(s.lastTick.at,m)]})})]}),h&&g.jsx("div",{className:"ap-failure",children:h}),g.jsx("p",{className:"ap-footnote",title:"Anthropic's usage endpoint allows roughly 28–30 requests per hour per account, shared by every tool on this machine — polling it from here would rate-limit your account. So the deck never fetches: it asks claude-swap to collect while this panel is open, at most once every three minutes, and claude-swap decides whether that touches the network at all.",children:"Collected by claude-swap while this panel is open."})]}):g.jsx("div",{className:"ap-empty",children:n.reason==="no_cswap"?g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"claude-swap isn't installed."}),g.jsx("span",{className:"ap-hint",children:"This panel reads the account store claude-swap keeps — without it there is nothing to show. It is a separate tool, published on PyPI, so it does not come with this package."}),n.hint&&g.jsx("code",{className:"ap-cmd",children:n.hint}),g.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",g.jsx("strong",{children:"+"})," button above."]})]}):n.reason==="no_accounts"?g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"No accounts added yet."}),g.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",g.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"Couldn't read the account store."}),g.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",n.reason?` (${n.reason})`:"","."]})]})}),S&&g.jsx(G3,{onClose:()=>b(!1),onChanged:()=>M(!0)})]})}const iO=3e4;function sO({bundle:e,running:n,lastTried:r}){return!n||e===n?!1:r!==n}function oO(e){const n=e.thresholdMs??iO;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 aO(e){return e.ctrlKey||e.metaKey||e.altKey}function ad(e,n){if(n.size!==0)for(const r of Array.from(e.keys()))n.has(r)||e.delete(r)}function lO(e){const n=new Set;for(const r of e)n.add(r.id),n.add(`group:${r.sessionId}`);return n}const uO=40,cO=120;function dO(e,n){let r=null,s=0,o=Number.NEGATIVE_INFINITY;const l=()=>{r=null,o=n.now(),e()},u=()=>{r!=null&&(n.clearTimeout(r),r=null)},c=(p,h,f)=>{if(r!=null){if(s<=p)return;u()}const m=Math.min(f,Math.max(0,p-h));s=p,r=n.setTimeout(l,m)};return{live(p=uO){const h=n.now(),f=Math.max(o+p,h);if(f<=h){u(),l();return}c(f,h,p)},replay(p=cO){u(),s=n.now()+p,r=n.setTimeout(l,p)},flush(){u(),l()},cancel(){u()}}}function fO(){let e=!1,n=[];return{get paused(){return e},get size(){return n.length},accept(r){return e?(n.push(r),!1):!0},setPaused(r){if(e=r,r||n.length===0)return[];const s=n;return n=[],s}}}function hO(){let e=0;return{begin(){const n=++e;return()=>n===e},cancel(){e++}}}function pO(e,n=new Date){return new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}function Vi(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 fx(e){return e.replace(/^anthropic\./,"").replace(/^claude-/,"").replace(/-\d{8}$/,"")}function Cl(e){const n=e.toLowerCase();return n.includes("opus")?"#c4b5fd":n.includes("sonnet")?"#7dd3fc":n.includes("haiku")?"#86efac":n.includes("gpt-5")||n.includes("gpt5")?"#fcd34d":n.includes("gpt")?"#fca5a5":n.includes("gemini")?"#a5b4fc":n.includes("codex")?"#fdba74":"#94a3b8"}const mO=[7,14,30,90];function gO(e){const[n,r]=A.useState(null),[s,o]=A.useState(!1),l=A.useRef(hO()).current,u=(c=!1)=>{const p=l.begin();o(!0);const f=`/api/ccusage?since=${pO(e)}${c?"&refresh=1":""}`;fetch(f).then(m=>m.json()).then(m=>{p()&&r(m)}).catch(()=>{p()&&r({ok:!1,error:"request failed"})}).finally(()=>{p()&&o(!1)})};return A.useEffect(()=>(u(!1),()=>l.cancel()),[e]),{data:n,loading:s,reload:()=>u(!0)}}function vO({onClose:e}){var b,k;const[n,r]=A.useState(30),[s,o]=A.useState(null),{data:l,loading:u,reload:c}=gO(n);A.useEffect(()=>{const N=j=>{j.key==="Escape"&&e()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e]);const p=l!=null&&l.ok?l.days??[]:[],h=A.useMemo(()=>p.reduce((N,j)=>Math.max(N,j.totalCost),0),[p]),{totalCost:f,totalTok:m,inOut:y,cacheRead:x,modelCosts:C}=A.useMemo(()=>{let N=0,j=0,P=0,O=0;const L=new Map;for(const B of p){N+=B.totalCost,j+=B.totalTokens,P+=B.inputTokens+B.outputTokens,O+=B.cacheReadTokens;for(const T of B.modelBreakdowns)L.set(T.modelName,(L.get(T.modelName)??0)+T.cost)}return{totalCost:N,totalTok:j,inOut:P,cacheRead:O,modelCosts:L}},[p]),_=A.useMemo(()=>Array.from(C.entries()).sort((N,j)=>j[1]-N[1]),[C]),S=s?p.find(N=>N.period===s)??null:null;return g.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:g.jsxs("div",{className:"uh-modal",onClick:N=>N.stopPropagation(),role:"dialog","aria-label":"Usage history",children:[g.jsxs("header",{className:"uh-head",children:[g.jsxs("div",{className:"uh-titlewrap",children:[g.jsx("div",{className:"uh-title",children:"Usage history"}),g.jsx("div",{className:"uh-sub",children:"via ccusage · local Claude / Codex logs"})]}),g.jsx("div",{className:"uh-range",role:"tablist","aria-label":"Range",children:mO.map(N=>g.jsxs("button",{role:"tab","aria-selected":n===N,className:`uh-range-btn${n===N?" on":""}`,onClick:()=>{r(N),o(null)},children:[N,"d"]},N))}),g.jsx("button",{className:"btn icon-btn uh-reload",onClick:c,title:"Re-run ccusage","aria-label":"Reload",children:"↻"}),g.jsx("button",{className:"uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),u&&p.length===0?g.jsx("div",{className:"uh-status",children:"running ccusage… (first run downloads the package)"}):l&&!l.ok?g.jsxs("div",{className:"uh-status uh-err",children:["ccusage failed: ",l.error]}):p.length===0?g.jsx("div",{className:"uh-status",children:"no usage in this range"}):g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"uh-totals",children:[g.jsx(jl,{label:"total cost",val:Be(f),accent:!0}),g.jsx(jl,{label:"tokens",val:Vi(m)}),g.jsx(jl,{label:"input+output",val:Vi(y)}),g.jsx(jl,{label:"cache reads",val:Vi(x)})]}),g.jsx("div",{className:"uh-chart",role:"img","aria-label":"Daily cost by model",children:p.map(N=>{const j=h>0?N.totalCost/h*100:0,P=N.period===s;return g.jsxs("button",{className:`uh-bar-col${P?" sel":""}`,onClick:()=>o(P?null:N.period),title:`${N.period} · ${Be(N.totalCost)}`,style:{flexBasis:`${100/p.length}%`},children:[g.jsx("div",{className:"uh-bar",style:{height:`${Math.max(j,N.totalCost>0?2:0)}%`},children:N.modelBreakdowns.slice().sort((O,L)=>L.cost-O.cost).map(O=>{const L=N.totalCost>0?O.cost/N.totalCost*100:0;return g.jsx("div",{className:"uh-bar-seg",style:{height:`${L}%`,background:Cl(O.modelName)}},O.modelName)})}),g.jsx("span",{className:"uh-bar-label",children:N.period.slice(5)})]},N.period)})}),g.jsx("div",{className:"uh-legend",children:_.map(([N,j])=>g.jsxs("span",{className:"uh-legend-item",children:[g.jsx("span",{className:"uh-legend-dot",style:{background:Cl(N)}}),fx(N)," ",g.jsx("span",{className:"uh-legend-cost",children:Be(j)})]},N))}),S&&g.jsxs("div",{className:"uh-detail",children:[g.jsxs("div",{className:"uh-detail-head",children:[g.jsx("span",{className:"uh-detail-date",children:S.period}),g.jsx("span",{className:"uh-detail-cost",children:Be(S.totalCost)}),(k=(b=S.metadata)==null?void 0:b.agents)!=null&&k.length?g.jsx("span",{className:"uh-detail-agents",children:S.metadata.agents.join(" · ")}):null]}),g.jsxs("div",{className:"uh-detail-mini",children:[g.jsx(Rl,{label:"input",val:Vi(S.inputTokens)}),g.jsx(Rl,{label:"output",val:Vi(S.outputTokens)}),g.jsx(Rl,{label:"cache write",val:Vi(S.cacheCreationTokens)}),g.jsx(Rl,{label:"cache read",val:Vi(S.cacheReadTokens)})]}),g.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 g.jsxs("div",{className:"uh-model-row",children:[g.jsxs("span",{className:"uh-model-name",children:[g.jsx("span",{className:"uh-legend-dot",style:{background:Cl(N.modelName)}}),fx(N.modelName)]}),g.jsx("span",{className:"uh-model-bar",children:g.jsx("span",{className:"uh-model-bar-fill",style:{width:`${j}%`,background:Cl(N.modelName)}})}),g.jsx("span",{className:"uh-model-cost",children:Be(N.cost)})]},N.modelName)})})]})]})]})})}function jl({label:e,val:n,accent:r}){return g.jsxs("div",{className:"uh-stat",children:[g.jsx("span",{className:`uh-stat-val${r?" accent":""}`,children:n}),g.jsx("span",{className:"uh-stat-label",children:e})]})}function Rl({label:e,val:n}){return g.jsxs("div",{className:"uh-ministat",children:[g.jsx("span",{className:"uh-ministat-val",children:n}),g.jsx("span",{className:"uh-ministat-label",children:e})]})}function vv(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 ld,hx;function yO(){if(hx)return ld;hx=1;function e(){this.__data__=[],this.size=0}return ld=e,ld}var ud,px;function Qs(){if(px)return ud;px=1;function e(n,r){return n===r||n!==n&&r!==r}return ud=e,ud}var cd,mx;function eu(){if(mx)return cd;mx=1;var e=Qs();function n(r,s){for(var o=r.length;o--;)if(e(r[o][0],s))return o;return-1}return cd=n,cd}var dd,gx;function wO(){if(gx)return dd;gx=1;var e=eu(),n=Array.prototype,r=n.splice;function s(o){var l=this.__data__,u=e(l,o);if(u<0)return!1;var c=l.length-1;return u==c?l.pop():r.call(l,u,1),--this.size,!0}return dd=s,dd}var fd,vx;function xO(){if(vx)return fd;vx=1;var e=eu();function n(r){var s=this.__data__,o=e(s,r);return o<0?void 0:s[o][1]}return fd=n,fd}var hd,yx;function _O(){if(yx)return hd;yx=1;var e=eu();function n(r){return e(this.__data__,r)>-1}return hd=n,hd}var pd,wx;function SO(){if(wx)return pd;wx=1;var e=eu();function n(r,s){var o=this.__data__,l=e(o,r);return l<0?(++this.size,o.push([r,s])):o[l][1]=s,this}return pd=n,pd}var md,xx;function tu(){if(xx)return md;xx=1;var e=yO(),n=wO(),r=xO(),s=_O(),o=SO();function l(u){var c=-1,p=u==null?0:u.length;for(this.clear();++c<p;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=s,l.prototype.set=o,md=l,md}var gd,_x;function bO(){if(_x)return gd;_x=1;var e=tu();function n(){this.__data__=new e,this.size=0}return gd=n,gd}var vd,Sx;function kO(){if(Sx)return vd;Sx=1;function e(n){var r=this.__data__,s=r.delete(n);return this.size=r.size,s}return vd=e,vd}var yd,bx;function EO(){if(bx)return yd;bx=1;function e(n){return this.__data__.get(n)}return yd=e,yd}var wd,kx;function NO(){if(kx)return wd;kx=1;function e(n){return this.__data__.has(n)}return wd=e,wd}var xd,Ex;function NN(){if(Ex)return xd;Ex=1;var e=typeof pl=="object"&&pl&&pl.Object===Object&&pl;return xd=e,xd}var _d,Nx;function er(){if(Nx)return _d;Nx=1;var e=NN(),n=typeof self=="object"&&self&&self.Object===Object&&self,r=e||n||Function("return this")();return _d=r,_d}var Sd,Cx;function Zs(){if(Cx)return Sd;Cx=1;var e=er(),n=e.Symbol;return Sd=n,Sd}var bd,jx;function CO(){if(jx)return bd;jx=1;var e=Zs(),n=Object.prototype,r=n.hasOwnProperty,s=n.toString,o=e?e.toStringTag:void 0;function l(u){var c=r.call(u,o),p=u[o];try{u[o]=void 0;var h=!0}catch{}var f=s.call(u);return h&&(c?u[o]=p:delete u[o]),f}return bd=l,bd}var kd,Rx;function jO(){if(Rx)return kd;Rx=1;var e=Object.prototype,n=e.toString;function r(s){return n.call(s)}return kd=r,kd}var Ed,Tx;function ts(){if(Tx)return Ed;Tx=1;var e=Zs(),n=CO(),r=jO(),s="[object Null]",o="[object Undefined]",l=e?e.toStringTag:void 0;function u(c){return c==null?c===void 0?o:s:l&&l in Object(c)?n(c):r(c)}return Ed=u,Ed}var Nd,Ax;function Pn(){if(Ax)return Nd;Ax=1;function e(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}return Nd=e,Nd}var Cd,Ix;function da(){if(Ix)return Cd;Ix=1;var e=ts(),n=Pn(),r="[object AsyncFunction]",s="[object Function]",o="[object GeneratorFunction]",l="[object Proxy]";function u(c){if(!n(c))return!1;var p=e(c);return p==s||p==o||p==r||p==l}return Cd=u,Cd}var jd,Mx;function RO(){if(Mx)return jd;Mx=1;var e=er(),n=e["__core-js_shared__"];return jd=n,jd}var Rd,Px;function TO(){if(Px)return Rd;Px=1;var e=RO(),n=(function(){var s=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""})();function r(s){return!!n&&n in s}return Rd=r,Rd}var Td,Ox;function CN(){if(Ox)return Td;Ox=1;var e=Function.prototype,n=e.toString;function r(s){if(s!=null){try{return n.call(s)}catch{}try{return s+""}catch{}}return""}return Td=r,Td}var Ad,qx;function AO(){if(qx)return Ad;qx=1;var e=da(),n=TO(),r=Pn(),s=CN(),o=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,p=u.toString,h=c.hasOwnProperty,f=RegExp("^"+p.call(h).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!r(y)||n(y))return!1;var x=e(y)?f:l;return x.test(s(y))}return Ad=m,Ad}var Id,Lx;function IO(){if(Lx)return Id;Lx=1;function e(n,r){return n==null?void 0:n[r]}return Id=e,Id}var Md,$x;function ns(){if($x)return Md;$x=1;var e=AO(),n=IO();function r(s,o){var l=n(s,o);return e(l)?l:void 0}return Md=r,Md}var Pd,Dx;function yv(){if(Dx)return Pd;Dx=1;var e=ns(),n=er(),r=e(n,"Map");return Pd=r,Pd}var Od,Fx;function nu(){if(Fx)return Od;Fx=1;var e=ns(),n=e(Object,"create");return Od=n,Od}var qd,zx;function MO(){if(zx)return qd;zx=1;var e=nu();function n(){this.__data__=e?e(null):{},this.size=0}return qd=n,qd}var Ld,Bx;function PO(){if(Bx)return Ld;Bx=1;function e(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}return Ld=e,Ld}var $d,Ux;function OO(){if(Ux)return $d;Ux=1;var e=nu(),n="__lodash_hash_undefined__",r=Object.prototype,s=r.hasOwnProperty;function o(l){var u=this.__data__;if(e){var c=u[l];return c===n?void 0:c}return s.call(u,l)?u[l]:void 0}return $d=o,$d}var Dd,Hx;function qO(){if(Hx)return Dd;Hx=1;var e=nu(),n=Object.prototype,r=n.hasOwnProperty;function s(o){var l=this.__data__;return e?l[o]!==void 0:r.call(l,o)}return Dd=s,Dd}var Fd,Vx;function LO(){if(Vx)return Fd;Vx=1;var e=nu(),n="__lodash_hash_undefined__";function r(s,o){var l=this.__data__;return this.size+=this.has(s)?0:1,l[s]=e&&o===void 0?n:o,this}return Fd=r,Fd}var zd,Wx;function $O(){if(Wx)return zd;Wx=1;var e=MO(),n=PO(),r=OO(),s=qO(),o=LO();function l(u){var c=-1,p=u==null?0:u.length;for(this.clear();++c<p;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=s,l.prototype.set=o,zd=l,zd}var Bd,Gx;function DO(){if(Gx)return Bd;Gx=1;var e=$O(),n=tu(),r=yv();function s(){this.size=0,this.__data__={hash:new e,map:new(r||n),string:new e}}return Bd=s,Bd}var Ud,Yx;function FO(){if(Yx)return Ud;Yx=1;function e(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}return Ud=e,Ud}var Hd,Kx;function ru(){if(Kx)return Hd;Kx=1;var e=FO();function n(r,s){var o=r.__data__;return e(s)?o[typeof s=="string"?"string":"hash"]:o.map}return Hd=n,Hd}var Vd,Xx;function zO(){if(Xx)return Vd;Xx=1;var e=ru();function n(r){var s=e(this,r).delete(r);return this.size-=s?1:0,s}return Vd=n,Vd}var Wd,Qx;function BO(){if(Qx)return Wd;Qx=1;var e=ru();function n(r){return e(this,r).get(r)}return Wd=n,Wd}var Gd,Zx;function UO(){if(Zx)return Gd;Zx=1;var e=ru();function n(r){return e(this,r).has(r)}return Gd=n,Gd}var Yd,Jx;function HO(){if(Jx)return Yd;Jx=1;var e=ru();function n(r,s){var o=e(this,r),l=o.size;return o.set(r,s),this.size+=o.size==l?0:1,this}return Yd=n,Yd}var Kd,e_;function wv(){if(e_)return Kd;e_=1;var e=DO(),n=zO(),r=BO(),s=UO(),o=HO();function l(u){var c=-1,p=u==null?0:u.length;for(this.clear();++c<p;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=s,l.prototype.set=o,Kd=l,Kd}var Xd,t_;function VO(){if(t_)return Xd;t_=1;var e=tu(),n=yv(),r=wv(),s=200;function o(l,u){var c=this.__data__;if(c instanceof e){var p=c.__data__;if(!n||p.length<s-1)return p.push([l,u]),this.size=++c.size,this;c=this.__data__=new r(p)}return c.set(l,u),this.size=c.size,this}return Xd=o,Xd}var Qd,n_;function iu(){if(n_)return Qd;n_=1;var e=tu(),n=bO(),r=kO(),s=EO(),o=NO(),l=VO();function u(c){var p=this.__data__=new e(c);this.size=p.size}return u.prototype.clear=n,u.prototype.delete=r,u.prototype.get=s,u.prototype.has=o,u.prototype.set=l,Qd=u,Qd}var Zd,r_;function xv(){if(r_)return Zd;r_=1;function e(n,r){for(var s=-1,o=n==null?0:n.length;++s<o&&r(n[s],s,n)!==!1;);return n}return Zd=e,Zd}var Jd,i_;function jN(){if(i_)return Jd;i_=1;var e=ns(),n=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return Jd=n,Jd}var ef,s_;function su(){if(s_)return ef;s_=1;var e=jN();function n(r,s,o){s=="__proto__"&&e?e(r,s,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[s]=o}return ef=n,ef}var tf,o_;function ou(){if(o_)return tf;o_=1;var e=su(),n=Qs(),r=Object.prototype,s=r.hasOwnProperty;function o(l,u,c){var p=l[u];(!(s.call(l,u)&&n(p,c))||c===void 0&&!(u in l))&&e(l,u,c)}return tf=o,tf}var nf,a_;function fa(){if(a_)return nf;a_=1;var e=ou(),n=su();function r(s,o,l,u){var c=!l;l||(l={});for(var p=-1,h=o.length;++p<h;){var f=o[p],m=u?u(l[f],s[f],f,l,s):void 0;m===void 0&&(m=s[f]),c?n(l,f,m):e(l,f,m)}return l}return nf=r,nf}var rf,l_;function WO(){if(l_)return rf;l_=1;function e(n,r){for(var s=-1,o=Array(n);++s<n;)o[s]=r(s);return o}return rf=e,rf}var sf,u_;function hr(){if(u_)return sf;u_=1;function e(n){return n!=null&&typeof n=="object"}return sf=e,sf}var of,c_;function GO(){if(c_)return of;c_=1;var e=ts(),n=hr(),r="[object Arguments]";function s(o){return n(o)&&e(o)==r}return of=s,of}var af,d_;function ha(){if(d_)return af;d_=1;var e=GO(),n=hr(),r=Object.prototype,s=r.hasOwnProperty,o=r.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(u){return n(u)&&s.call(u,"callee")&&!o.call(u,"callee")};return af=l,af}var lf,f_;function _t(){if(f_)return lf;f_=1;var e=Array.isArray;return lf=e,lf}var Wo={exports:{}},uf,h_;function YO(){if(h_)return uf;h_=1;function e(){return!1}return uf=e,uf}Wo.exports;var p_;function Js(){return p_||(p_=1,(function(e,n){var r=er(),s=YO(),o=n&&!n.nodeType&&n,l=o&&!0&&e&&!e.nodeType&&e,u=l&&l.exports===o,c=u?r.Buffer:void 0,p=c?c.isBuffer:void 0,h=p||s;e.exports=h})(Wo,Wo.exports)),Wo.exports}var cf,m_;function au(){if(m_)return cf;m_=1;var e=9007199254740991,n=/^(?:0|[1-9]\d*)$/;function r(s,o){var l=typeof s;return o=o??e,!!o&&(l=="number"||l!="symbol"&&n.test(s))&&s>-1&&s%1==0&&s<o}return cf=r,cf}var df,g_;function _v(){if(g_)return df;g_=1;var e=9007199254740991;function n(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return df=n,df}var ff,v_;function KO(){if(v_)return ff;v_=1;var e=ts(),n=_v(),r=hr(),s="[object Arguments]",o="[object Array]",l="[object Boolean]",u="[object Date]",c="[object Error]",p="[object Function]",h="[object Map]",f="[object Number]",m="[object Object]",y="[object RegExp]",x="[object Set]",C="[object String]",_="[object WeakMap]",S="[object ArrayBuffer]",b="[object DataView]",k="[object Float32Array]",N="[object Float64Array]",j="[object Int8Array]",P="[object Int16Array]",O="[object Int32Array]",L="[object Uint8Array]",B="[object Uint8ClampedArray]",T="[object Uint16Array]",M="[object Uint32Array]",q={};q[k]=q[N]=q[j]=q[P]=q[O]=q[L]=q[B]=q[T]=q[M]=!0,q[s]=q[o]=q[S]=q[l]=q[b]=q[u]=q[c]=q[p]=q[h]=q[f]=q[m]=q[y]=q[x]=q[C]=q[_]=!1;function Y(X){return r(X)&&n(X.length)&&!!q[e(X)]}return ff=Y,ff}var hf,y_;function lu(){if(y_)return hf;y_=1;function e(n){return function(r){return n(r)}}return hf=e,hf}var Go={exports:{}};Go.exports;var w_;function Sv(){return w_||(w_=1,(function(e,n){var r=NN(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,u=l&&r.process,c=(function(){try{var p=o&&o.require&&o.require("util").types;return p||u&&u.binding&&u.binding("util")}catch{}})();e.exports=c})(Go,Go.exports)),Go.exports}var pf,x_;function pa(){if(x_)return pf;x_=1;var e=KO(),n=lu(),r=Sv(),s=r&&r.isTypedArray,o=s?n(s):e;return pf=o,pf}var mf,__;function RN(){if(__)return mf;__=1;var e=WO(),n=ha(),r=_t(),s=Js(),o=au(),l=pa(),u=Object.prototype,c=u.hasOwnProperty;function p(h,f){var m=r(h),y=!m&&n(h),x=!m&&!y&&s(h),C=!m&&!y&&!x&&l(h),_=m||y||x||C,S=_?e(h.length,String):[],b=S.length;for(var k in h)(f||c.call(h,k))&&!(_&&(k=="length"||x&&(k=="offset"||k=="parent")||C&&(k=="buffer"||k=="byteLength"||k=="byteOffset")||o(k,b)))&&S.push(k);return S}return mf=p,mf}var gf,S_;function uu(){if(S_)return gf;S_=1;var e=Object.prototype;function n(r){var s=r&&r.constructor,o=typeof s=="function"&&s.prototype||e;return r===o}return gf=n,gf}var vf,b_;function TN(){if(b_)return vf;b_=1;function e(n,r){return function(s){return n(r(s))}}return vf=e,vf}var yf,k_;function XO(){if(k_)return yf;k_=1;var e=TN(),n=e(Object.keys,Object);return yf=n,yf}var wf,E_;function bv(){if(E_)return wf;E_=1;var e=uu(),n=XO(),r=Object.prototype,s=r.hasOwnProperty;function o(l){if(!e(l))return n(l);var u=[];for(var c in Object(l))s.call(l,c)&&c!="constructor"&&u.push(c);return u}return wf=o,wf}var xf,N_;function qr(){if(N_)return xf;N_=1;var e=da(),n=_v();function r(s){return s!=null&&n(s.length)&&!e(s)}return xf=r,xf}var _f,C_;function _i(){if(C_)return _f;C_=1;var e=RN(),n=bv(),r=qr();function s(o){return r(o)?e(o):n(o)}return _f=s,_f}var Sf,j_;function QO(){if(j_)return Sf;j_=1;var e=fa(),n=_i();function r(s,o){return s&&e(o,n(o),s)}return Sf=r,Sf}var bf,R_;function ZO(){if(R_)return bf;R_=1;function e(n){var r=[];if(n!=null)for(var s in Object(n))r.push(s);return r}return bf=e,bf}var kf,T_;function JO(){if(T_)return kf;T_=1;var e=Pn(),n=uu(),r=ZO(),s=Object.prototype,o=s.hasOwnProperty;function l(u){if(!e(u))return r(u);var c=n(u),p=[];for(var h in u)h=="constructor"&&(c||!o.call(u,h))||p.push(h);return p}return kf=l,kf}var Ef,A_;function rs(){if(A_)return Ef;A_=1;var e=RN(),n=JO(),r=qr();function s(o){return r(o)?e(o,!0):n(o)}return Ef=s,Ef}var Nf,I_;function eq(){if(I_)return Nf;I_=1;var e=fa(),n=rs();function r(s,o){return s&&e(o,n(o),s)}return Nf=r,Nf}var Yo={exports:{}};Yo.exports;var M_;function AN(){return M_||(M_=1,(function(e,n){var r=er(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,u=l?r.Buffer:void 0,c=u?u.allocUnsafe:void 0;function p(h,f){if(f)return h.slice();var m=h.length,y=c?c(m):new h.constructor(m);return h.copy(y),y}e.exports=p})(Yo,Yo.exports)),Yo.exports}var Cf,P_;function IN(){if(P_)return Cf;P_=1;function e(n,r){var s=-1,o=n.length;for(r||(r=Array(o));++s<o;)r[s]=n[s];return r}return Cf=e,Cf}var jf,O_;function MN(){if(O_)return jf;O_=1;function e(n,r){for(var s=-1,o=n==null?0:n.length,l=0,u=[];++s<o;){var c=n[s];r(c,s,n)&&(u[l++]=c)}return u}return jf=e,jf}var Rf,q_;function PN(){if(q_)return Rf;q_=1;function e(){return[]}return Rf=e,Rf}var Tf,L_;function kv(){if(L_)return Tf;L_=1;var e=MN(),n=PN(),r=Object.prototype,s=r.propertyIsEnumerable,o=Object.getOwnPropertySymbols,l=o?function(u){return u==null?[]:(u=Object(u),e(o(u),function(c){return s.call(u,c)}))}:n;return Tf=l,Tf}var Af,$_;function tq(){if($_)return Af;$_=1;var e=fa(),n=kv();function r(s,o){return e(s,n(s),o)}return Af=r,Af}var If,D_;function Ev(){if(D_)return If;D_=1;function e(n,r){for(var s=-1,o=r.length,l=n.length;++s<o;)n[l+s]=r[s];return n}return If=e,If}var Mf,F_;function cu(){if(F_)return Mf;F_=1;var e=TN(),n=e(Object.getPrototypeOf,Object);return Mf=n,Mf}var Pf,z_;function ON(){if(z_)return Pf;z_=1;var e=Ev(),n=cu(),r=kv(),s=PN(),o=Object.getOwnPropertySymbols,l=o?function(u){for(var c=[];u;)e(c,r(u)),u=n(u);return c}:s;return Pf=l,Pf}var Of,B_;function nq(){if(B_)return Of;B_=1;var e=fa(),n=ON();function r(s,o){return e(s,n(s),o)}return Of=r,Of}var qf,U_;function qN(){if(U_)return qf;U_=1;var e=Ev(),n=_t();function r(s,o,l){var u=o(s);return n(s)?u:e(u,l(s))}return qf=r,qf}var Lf,H_;function LN(){if(H_)return Lf;H_=1;var e=qN(),n=kv(),r=_i();function s(o){return e(o,r,n)}return Lf=s,Lf}var $f,V_;function rq(){if(V_)return $f;V_=1;var e=qN(),n=ON(),r=rs();function s(o){return e(o,r,n)}return $f=s,$f}var Df,W_;function iq(){if(W_)return Df;W_=1;var e=ns(),n=er(),r=e(n,"DataView");return Df=r,Df}var Ff,G_;function sq(){if(G_)return Ff;G_=1;var e=ns(),n=er(),r=e(n,"Promise");return Ff=r,Ff}var zf,Y_;function $N(){if(Y_)return zf;Y_=1;var e=ns(),n=er(),r=e(n,"Set");return zf=r,zf}var Bf,K_;function oq(){if(K_)return Bf;K_=1;var e=ns(),n=er(),r=e(n,"WeakMap");return Bf=r,Bf}var Uf,X_;function eo(){if(X_)return Uf;X_=1;var e=iq(),n=yv(),r=sq(),s=$N(),o=oq(),l=ts(),u=CN(),c="[object Map]",p="[object Object]",h="[object Promise]",f="[object Set]",m="[object WeakMap]",y="[object DataView]",x=u(e),C=u(n),_=u(r),S=u(s),b=u(o),k=l;return(e&&k(new e(new ArrayBuffer(1)))!=y||n&&k(new n)!=c||r&&k(r.resolve())!=h||s&&k(new s)!=f||o&&k(new o)!=m)&&(k=function(N){var j=l(N),P=j==p?N.constructor:void 0,O=P?u(P):"";if(O)switch(O){case x:return y;case C:return c;case _:return h;case S:return f;case b:return m}return j}),Uf=k,Uf}var Hf,Q_;function aq(){if(Q_)return Hf;Q_=1;var e=Object.prototype,n=e.hasOwnProperty;function r(s){var o=s.length,l=new s.constructor(o);return o&&typeof s[0]=="string"&&n.call(s,"index")&&(l.index=s.index,l.input=s.input),l}return Hf=r,Hf}var Vf,Z_;function DN(){if(Z_)return Vf;Z_=1;var e=er(),n=e.Uint8Array;return Vf=n,Vf}var Wf,J_;function Nv(){if(J_)return Wf;J_=1;var e=DN();function n(r){var s=new r.constructor(r.byteLength);return new e(s).set(new e(r)),s}return Wf=n,Wf}var Gf,e1;function lq(){if(e1)return Gf;e1=1;var e=Nv();function n(r,s){var o=s?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.byteLength)}return Gf=n,Gf}var Yf,t1;function uq(){if(t1)return Yf;t1=1;var e=/\w*$/;function n(r){var s=new r.constructor(r.source,e.exec(r));return s.lastIndex=r.lastIndex,s}return Yf=n,Yf}var Kf,n1;function cq(){if(n1)return Kf;n1=1;var e=Zs(),n=e?e.prototype:void 0,r=n?n.valueOf:void 0;function s(o){return r?Object(r.call(o)):{}}return Kf=s,Kf}var Xf,r1;function FN(){if(r1)return Xf;r1=1;var e=Nv();function n(r,s){var o=s?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.length)}return Xf=n,Xf}var Qf,i1;function dq(){if(i1)return Qf;i1=1;var e=Nv(),n=lq(),r=uq(),s=cq(),o=FN(),l="[object Boolean]",u="[object Date]",c="[object Map]",p="[object Number]",h="[object RegExp]",f="[object Set]",m="[object String]",y="[object Symbol]",x="[object ArrayBuffer]",C="[object DataView]",_="[object Float32Array]",S="[object Float64Array]",b="[object Int8Array]",k="[object Int16Array]",N="[object Int32Array]",j="[object Uint8Array]",P="[object Uint8ClampedArray]",O="[object Uint16Array]",L="[object Uint32Array]";function B(T,M,q){var Y=T.constructor;switch(M){case x:return e(T);case l:case u:return new Y(+T);case C:return n(T,q);case _:case S:case b:case k:case N:case j:case P:case O:case L:return o(T,q);case c:return new Y;case p:case m:return new Y(T);case h:return r(T);case f:return new Y;case y:return s(T)}}return Qf=B,Qf}var Zf,s1;function zN(){if(s1)return Zf;s1=1;var e=Pn(),n=Object.create,r=(function(){function s(){}return function(o){if(!e(o))return{};if(n)return n(o);s.prototype=o;var l=new s;return s.prototype=void 0,l}})();return Zf=r,Zf}var Jf,o1;function BN(){if(o1)return Jf;o1=1;var e=zN(),n=cu(),r=uu();function s(o){return typeof o.constructor=="function"&&!r(o)?e(n(o)):{}}return Jf=s,Jf}var eh,a1;function fq(){if(a1)return eh;a1=1;var e=eo(),n=hr(),r="[object Map]";function s(o){return n(o)&&e(o)==r}return eh=s,eh}var th,l1;function hq(){if(l1)return th;l1=1;var e=fq(),n=lu(),r=Sv(),s=r&&r.isMap,o=s?n(s):e;return th=o,th}var nh,u1;function pq(){if(u1)return nh;u1=1;var e=eo(),n=hr(),r="[object Set]";function s(o){return n(o)&&e(o)==r}return nh=s,nh}var rh,c1;function mq(){if(c1)return rh;c1=1;var e=pq(),n=lu(),r=Sv(),s=r&&r.isSet,o=s?n(s):e;return rh=o,rh}var ih,d1;function UN(){if(d1)return ih;d1=1;var e=iu(),n=xv(),r=ou(),s=QO(),o=eq(),l=AN(),u=IN(),c=tq(),p=nq(),h=LN(),f=rq(),m=eo(),y=aq(),x=dq(),C=BN(),_=_t(),S=Js(),b=hq(),k=Pn(),N=mq(),j=_i(),P=rs(),O=1,L=2,B=4,T="[object Arguments]",M="[object Array]",q="[object Boolean]",Y="[object Date]",X="[object Error]",I="[object Function]",H="[object GeneratorFunction]",U="[object Map]",ne="[object Number]",J="[object Object]",F="[object RegExp]",G="[object Set]",E="[object String]",$="[object Symbol]",se="[object WeakMap]",D="[object ArrayBuffer]",Q="[object DataView]",ee="[object Float32Array]",oe="[object Float64Array]",ue="[object Int8Array]",ge="[object Int16Array]",de="[object Int32Array]",Ie="[object Uint8Array]",He="[object Uint8ClampedArray]",Pe="[object Uint16Array]",Ae="[object Uint32Array]",ke={};ke[T]=ke[M]=ke[D]=ke[Q]=ke[q]=ke[Y]=ke[ee]=ke[oe]=ke[ue]=ke[ge]=ke[de]=ke[U]=ke[ne]=ke[J]=ke[F]=ke[G]=ke[E]=ke[$]=ke[Ie]=ke[He]=ke[Pe]=ke[Ae]=!0,ke[X]=ke[I]=ke[se]=!1;function Ye(ve,we,Ve,at,lt,We){var $e,it=we&O,vt=we&L,tt=we&B;if(Ve&&($e=lt?Ve(ve,at,lt,We):Ve(ve)),$e!==void 0)return $e;if(!k(ve))return ve;var qt=_(ve);if(qt){if($e=y(ve),!it)return u(ve,$e)}else{var mt=m(ve),Tt=mt==I||mt==H;if(S(ve))return l(ve,it);if(mt==J||mt==T||Tt&&!lt){if($e=vt||Tt?{}:C(ve),!it)return vt?p(ve,o($e,ve)):c(ve,s($e,ve))}else{if(!ke[mt])return lt?ve:{};$e=x(ve,mt,it)}}We||(We=new e);var At=We.get(ve);if(At)return At;We.set(ve,$e),N(ve)?ve.forEach(function(Le){$e.add(Ye(Le,we,Ve,Le,ve,We))}):b(ve)&&ve.forEach(function(Le,wt){$e.set(wt,Ye(Le,we,Ve,wt,ve,We))});var Ze=tt?vt?f:h:vt?P:j,yt=qt?void 0:Ze(ve);return n(yt||ve,function(Le,wt){yt&&(wt=Le,Le=ve[wt]),r($e,wt,Ye(Le,we,Ve,wt,ve,We))}),$e}return ih=Ye,ih}var sh,f1;function gq(){if(f1)return sh;f1=1;var e=UN(),n=4;function r(s){return e(s,n)}return sh=r,sh}var oh,h1;function Cv(){if(h1)return oh;h1=1;function e(n){return function(){return n}}return oh=e,oh}var ah,p1;function vq(){if(p1)return ah;p1=1;function e(n){return function(r,s,o){for(var l=-1,u=Object(r),c=o(r),p=c.length;p--;){var h=c[n?p:++l];if(s(u[h],h,u)===!1)break}return r}}return ah=e,ah}var lh,m1;function jv(){if(m1)return lh;m1=1;var e=vq(),n=e();return lh=n,lh}var uh,g1;function Rv(){if(g1)return uh;g1=1;var e=jv(),n=_i();function r(s,o){return s&&e(s,o,n)}return uh=r,uh}var ch,v1;function yq(){if(v1)return ch;v1=1;var e=qr();function n(r,s){return function(o,l){if(o==null)return o;if(!e(o))return r(o,l);for(var u=o.length,c=s?u:-1,p=Object(o);(s?c--:++c<u)&&l(p[c],c,p)!==!1;);return o}}return ch=n,ch}var dh,y1;function du(){if(y1)return dh;y1=1;var e=Rv(),n=yq(),r=n(e);return dh=r,dh}var fh,w1;function is(){if(w1)return fh;w1=1;function e(n){return n}return fh=e,fh}var hh,x1;function HN(){if(x1)return hh;x1=1;var e=is();function n(r){return typeof r=="function"?r:e}return hh=n,hh}var ph,_1;function VN(){if(_1)return ph;_1=1;var e=xv(),n=du(),r=HN(),s=_t();function o(l,u){var c=s(l)?e:n;return c(l,r(u))}return ph=o,ph}var mh,S1;function WN(){return S1||(S1=1,mh=VN()),mh}var gh,b1;function wq(){if(b1)return gh;b1=1;var e=du();function n(r,s){var o=[];return e(r,function(l,u,c){s(l,u,c)&&o.push(l)}),o}return gh=n,gh}var vh,k1;function xq(){if(k1)return vh;k1=1;var e="__lodash_hash_undefined__";function n(r){return this.__data__.set(r,e),this}return vh=n,vh}var yh,E1;function _q(){if(E1)return yh;E1=1;function e(n){return this.__data__.has(n)}return yh=e,yh}var wh,N1;function GN(){if(N1)return wh;N1=1;var e=wv(),n=xq(),r=_q();function s(o){var l=-1,u=o==null?0:o.length;for(this.__data__=new e;++l<u;)this.add(o[l])}return s.prototype.add=s.prototype.push=n,s.prototype.has=r,wh=s,wh}var xh,C1;function Sq(){if(C1)return xh;C1=1;function e(n,r){for(var s=-1,o=n==null?0:n.length;++s<o;)if(r(n[s],s,n))return!0;return!1}return xh=e,xh}var _h,j1;function YN(){if(j1)return _h;j1=1;function e(n,r){return n.has(r)}return _h=e,_h}var Sh,R1;function KN(){if(R1)return Sh;R1=1;var e=GN(),n=Sq(),r=YN(),s=1,o=2;function l(u,c,p,h,f,m){var y=p&s,x=u.length,C=c.length;if(x!=C&&!(y&&C>x))return!1;var _=m.get(u),S=m.get(c);if(_&&S)return _==c&&S==u;var b=-1,k=!0,N=p&o?new e:void 0;for(m.set(u,c),m.set(c,u);++b<x;){var j=u[b],P=c[b];if(h)var O=y?h(P,j,b,c,u,m):h(j,P,b,u,c,m);if(O!==void 0){if(O)continue;k=!1;break}if(N){if(!n(c,function(L,B){if(!r(N,B)&&(j===L||f(j,L,p,h,m)))return N.push(B)})){k=!1;break}}else if(!(j===P||f(j,P,p,h,m))){k=!1;break}}return m.delete(u),m.delete(c),k}return Sh=l,Sh}var bh,T1;function bq(){if(T1)return bh;T1=1;function e(n){var r=-1,s=Array(n.size);return n.forEach(function(o,l){s[++r]=[l,o]}),s}return bh=e,bh}var kh,A1;function Tv(){if(A1)return kh;A1=1;function e(n){var r=-1,s=Array(n.size);return n.forEach(function(o){s[++r]=o}),s}return kh=e,kh}var Eh,I1;function kq(){if(I1)return Eh;I1=1;var e=Zs(),n=DN(),r=Qs(),s=KN(),o=bq(),l=Tv(),u=1,c=2,p="[object Boolean]",h="[object Date]",f="[object Error]",m="[object Map]",y="[object Number]",x="[object RegExp]",C="[object Set]",_="[object String]",S="[object Symbol]",b="[object ArrayBuffer]",k="[object DataView]",N=e?e.prototype:void 0,j=N?N.valueOf:void 0;function P(O,L,B,T,M,q,Y){switch(B){case k:if(O.byteLength!=L.byteLength||O.byteOffset!=L.byteOffset)return!1;O=O.buffer,L=L.buffer;case b:return!(O.byteLength!=L.byteLength||!q(new n(O),new n(L)));case p:case h:case y:return r(+O,+L);case f:return O.name==L.name&&O.message==L.message;case x:case _:return O==L+"";case m:var X=o;case C:var I=T&u;if(X||(X=l),O.size!=L.size&&!I)return!1;var H=Y.get(O);if(H)return H==L;T|=c,Y.set(O,L);var U=s(X(O),X(L),T,M,q,Y);return Y.delete(O),U;case S:if(j)return j.call(O)==j.call(L)}return!1}return Eh=P,Eh}var Nh,M1;function Eq(){if(M1)return Nh;M1=1;var e=LN(),n=1,r=Object.prototype,s=r.hasOwnProperty;function o(l,u,c,p,h,f){var m=c&n,y=e(l),x=y.length,C=e(u),_=C.length;if(x!=_&&!m)return!1;for(var S=x;S--;){var b=y[S];if(!(m?b in u:s.call(u,b)))return!1}var k=f.get(l),N=f.get(u);if(k&&N)return k==u&&N==l;var j=!0;f.set(l,u),f.set(u,l);for(var P=m;++S<x;){b=y[S];var O=l[b],L=u[b];if(p)var B=m?p(L,O,b,u,l,f):p(O,L,b,l,u,f);if(!(B===void 0?O===L||h(O,L,c,p,f):B)){j=!1;break}P||(P=b=="constructor")}if(j&&!P){var T=l.constructor,M=u.constructor;T!=M&&"constructor"in l&&"constructor"in u&&!(typeof T=="function"&&T instanceof T&&typeof M=="function"&&M instanceof M)&&(j=!1)}return f.delete(l),f.delete(u),j}return Nh=o,Nh}var Ch,P1;function Nq(){if(P1)return Ch;P1=1;var e=iu(),n=KN(),r=kq(),s=Eq(),o=eo(),l=_t(),u=Js(),c=pa(),p=1,h="[object Arguments]",f="[object Array]",m="[object Object]",y=Object.prototype,x=y.hasOwnProperty;function C(_,S,b,k,N,j){var P=l(_),O=l(S),L=P?f:o(_),B=O?f:o(S);L=L==h?m:L,B=B==h?m:B;var T=L==m,M=B==m,q=L==B;if(q&&u(_)){if(!u(S))return!1;P=!0,T=!1}if(q&&!T)return j||(j=new e),P||c(_)?n(_,S,b,k,N,j):r(_,S,L,b,k,N,j);if(!(b&p)){var Y=T&&x.call(_,"__wrapped__"),X=M&&x.call(S,"__wrapped__");if(Y||X){var I=Y?_.value():_,H=X?S.value():S;return j||(j=new e),N(I,H,b,k,j)}}return q?(j||(j=new e),s(_,S,b,k,N,j)):!1}return Ch=C,Ch}var jh,O1;function XN(){if(O1)return jh;O1=1;var e=Nq(),n=hr();function r(s,o,l,u,c){return s===o?!0:s==null||o==null||!n(s)&&!n(o)?s!==s&&o!==o:e(s,o,l,u,r,c)}return jh=r,jh}var Rh,q1;function Cq(){if(q1)return Rh;q1=1;var e=iu(),n=XN(),r=1,s=2;function o(l,u,c,p){var h=c.length,f=h,m=!p;if(l==null)return!f;for(l=Object(l);h--;){var y=c[h];if(m&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++h<f;){y=c[h];var x=y[0],C=l[x],_=y[1];if(m&&y[2]){if(C===void 0&&!(x in l))return!1}else{var S=new e;if(p)var b=p(C,_,x,l,u,S);if(!(b===void 0?n(_,C,r|s,p,S):b))return!1}}return!0}return Rh=o,Rh}var Th,L1;function QN(){if(L1)return Th;L1=1;var e=Pn();function n(r){return r===r&&!e(r)}return Th=n,Th}var Ah,$1;function jq(){if($1)return Ah;$1=1;var e=QN(),n=_i();function r(s){for(var o=n(s),l=o.length;l--;){var u=o[l],c=s[u];o[l]=[u,c,e(c)]}return o}return Ah=r,Ah}var Ih,D1;function ZN(){if(D1)return Ih;D1=1;function e(n,r){return function(s){return s==null?!1:s[n]===r&&(r!==void 0||n in Object(s))}}return Ih=e,Ih}var Mh,F1;function Rq(){if(F1)return Mh;F1=1;var e=Cq(),n=jq(),r=ZN();function s(o){var l=n(o);return l.length==1&&l[0][2]?r(l[0][0],l[0][1]):function(u){return u===o||e(u,o,l)}}return Mh=s,Mh}var Ph,z1;function to(){if(z1)return Ph;z1=1;var e=ts(),n=hr(),r="[object Symbol]";function s(o){return typeof o=="symbol"||n(o)&&e(o)==r}return Ph=s,Ph}var Oh,B1;function Av(){if(B1)return Oh;B1=1;var e=_t(),n=to(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function o(l,u){if(e(l))return!1;var c=typeof l;return c=="number"||c=="symbol"||c=="boolean"||l==null||n(l)?!0:s.test(l)||!r.test(l)||u!=null&&l in Object(u)}return Oh=o,Oh}var qh,U1;function Tq(){if(U1)return qh;U1=1;var e=wv(),n="Expected a function";function r(s,o){if(typeof s!="function"||o!=null&&typeof o!="function")throw new TypeError(n);var l=function(){var u=arguments,c=o?o.apply(this,u):u[0],p=l.cache;if(p.has(c))return p.get(c);var h=s.apply(this,u);return l.cache=p.set(c,h)||p,h};return l.cache=new(r.Cache||e),l}return r.Cache=e,qh=r,qh}var Lh,H1;function Aq(){if(H1)return Lh;H1=1;var e=Tq(),n=500;function r(s){var o=e(s,function(u){return l.size===n&&l.clear(),u}),l=o.cache;return o}return Lh=r,Lh}var $h,V1;function Iq(){if(V1)return $h;V1=1;var e=Aq(),n=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,s=e(function(o){var l=[];return o.charCodeAt(0)===46&&l.push(""),o.replace(n,function(u,c,p,h){l.push(p?h.replace(r,"$1"):c||u)}),l});return $h=s,$h}var Dh,W1;function fu(){if(W1)return Dh;W1=1;function e(n,r){for(var s=-1,o=n==null?0:n.length,l=Array(o);++s<o;)l[s]=r(n[s],s,n);return l}return Dh=e,Dh}var Fh,G1;function Mq(){if(G1)return Fh;G1=1;var e=Zs(),n=fu(),r=_t(),s=to(),o=e?e.prototype:void 0,l=o?o.toString:void 0;function u(c){if(typeof c=="string")return c;if(r(c))return n(c,u)+"";if(s(c))return l?l.call(c):"";var p=c+"";return p=="0"&&1/c==-1/0?"-0":p}return Fh=u,Fh}var zh,Y1;function JN(){if(Y1)return zh;Y1=1;var e=Mq();function n(r){return r==null?"":e(r)}return zh=n,zh}var Bh,K1;function hu(){if(K1)return Bh;K1=1;var e=_t(),n=Av(),r=Iq(),s=JN();function o(l,u){return e(l)?l:n(l,u)?[l]:r(s(l))}return Bh=o,Bh}var Uh,X1;function ma(){if(X1)return Uh;X1=1;var e=to();function n(r){if(typeof r=="string"||e(r))return r;var s=r+"";return s=="0"&&1/r==-1/0?"-0":s}return Uh=n,Uh}var Hh,Q1;function pu(){if(Q1)return Hh;Q1=1;var e=hu(),n=ma();function r(s,o){o=e(o,s);for(var l=0,u=o.length;s!=null&&l<u;)s=s[n(o[l++])];return l&&l==u?s:void 0}return Hh=r,Hh}var Vh,Z1;function Pq(){if(Z1)return Vh;Z1=1;var e=pu();function n(r,s,o){var l=r==null?void 0:e(r,s);return l===void 0?o:l}return Vh=n,Vh}var Wh,J1;function Oq(){if(J1)return Wh;J1=1;function e(n,r){return n!=null&&r in Object(n)}return Wh=e,Wh}var Gh,eS;function eC(){if(eS)return Gh;eS=1;var e=hu(),n=ha(),r=_t(),s=au(),o=_v(),l=ma();function u(c,p,h){p=e(p,c);for(var f=-1,m=p.length,y=!1;++f<m;){var x=l(p[f]);if(!(y=c!=null&&h(c,x)))break;c=c[x]}return y||++f!=m?y:(m=c==null?0:c.length,!!m&&o(m)&&s(x,m)&&(r(c)||n(c)))}return Gh=u,Gh}var Yh,tS;function tC(){if(tS)return Yh;tS=1;var e=Oq(),n=eC();function r(s,o){return s!=null&&n(s,o,e)}return Yh=r,Yh}var Kh,nS;function qq(){if(nS)return Kh;nS=1;var e=XN(),n=Pq(),r=tC(),s=Av(),o=QN(),l=ZN(),u=ma(),c=1,p=2;function h(f,m){return s(f)&&o(m)?l(u(f),m):function(y){var x=n(y,f);return x===void 0&&x===m?r(y,f):e(m,x,c|p)}}return Kh=h,Kh}var Xh,rS;function nC(){if(rS)return Xh;rS=1;function e(n){return function(r){return r==null?void 0:r[n]}}return Xh=e,Xh}var Qh,iS;function Lq(){if(iS)return Qh;iS=1;var e=pu();function n(r){return function(s){return e(s,r)}}return Qh=n,Qh}var Zh,sS;function $q(){if(sS)return Zh;sS=1;var e=nC(),n=Lq(),r=Av(),s=ma();function o(l){return r(l)?e(s(l)):n(l)}return Zh=o,Zh}var Jh,oS;function Lr(){if(oS)return Jh;oS=1;var e=Rq(),n=qq(),r=is(),s=_t(),o=$q();function l(u){return typeof u=="function"?u:u==null?r:typeof u=="object"?s(u)?n(u[0],u[1]):e(u):o(u)}return Jh=l,Jh}var ep,aS;function rC(){if(aS)return ep;aS=1;var e=MN(),n=wq(),r=Lr(),s=_t();function o(l,u){var c=s(l)?e:n;return c(l,r(u,3))}return ep=o,ep}var tp,lS;function Dq(){if(lS)return tp;lS=1;var e=Object.prototype,n=e.hasOwnProperty;function r(s,o){return s!=null&&n.call(s,o)}return tp=r,tp}var np,uS;function iC(){if(uS)return np;uS=1;var e=Dq(),n=eC();function r(s,o){return s!=null&&n(s,o,e)}return np=r,np}var rp,cS;function Fq(){if(cS)return rp;cS=1;var e=bv(),n=eo(),r=ha(),s=_t(),o=qr(),l=Js(),u=uu(),c=pa(),p="[object Map]",h="[object Set]",f=Object.prototype,m=f.hasOwnProperty;function y(x){if(x==null)return!0;if(o(x)&&(s(x)||typeof x=="string"||typeof x.splice=="function"||l(x)||c(x)||r(x)))return!x.length;var C=n(x);if(C==p||C==h)return!x.size;if(u(x))return!e(x).length;for(var _ in x)if(m.call(x,_))return!1;return!0}return rp=y,rp}var ip,dS;function sC(){if(dS)return ip;dS=1;function e(n){return n===void 0}return ip=e,ip}var sp,fS;function oC(){if(fS)return sp;fS=1;var e=du(),n=qr();function r(s,o){var l=-1,u=n(s)?Array(s.length):[];return e(s,function(c,p,h){u[++l]=o(c,p,h)}),u}return sp=r,sp}var op,hS;function aC(){if(hS)return op;hS=1;var e=fu(),n=Lr(),r=oC(),s=_t();function o(l,u){var c=s(l)?e:r;return c(l,n(u,3))}return op=o,op}var ap,pS;function zq(){if(pS)return ap;pS=1;function e(n,r,s,o){var l=-1,u=n==null?0:n.length;for(o&&u&&(s=n[++l]);++l<u;)s=r(s,n[l],l,n);return s}return ap=e,ap}var lp,mS;function Bq(){if(mS)return lp;mS=1;function e(n,r,s,o,l){return l(n,function(u,c,p){s=o?(o=!1,u):r(s,u,c,p)}),s}return lp=e,lp}var up,gS;function lC(){if(gS)return up;gS=1;var e=zq(),n=du(),r=Lr(),s=Bq(),o=_t();function l(u,c,p){var h=o(u)?e:s,f=arguments.length<3;return h(u,r(c,4),p,f,n)}return up=l,up}var cp,vS;function Uq(){if(vS)return cp;vS=1;var e=ts(),n=_t(),r=hr(),s="[object String]";function o(l){return typeof l=="string"||!n(l)&&r(l)&&e(l)==s}return cp=o,cp}var dp,yS;function Hq(){if(yS)return dp;yS=1;var e=nC(),n=e("length");return dp=n,dp}var fp,wS;function Vq(){if(wS)return fp;wS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+r+s,l="\\ufe0e\\ufe0f",u="\\u200d",c=RegExp("["+u+e+o+l+"]");function p(h){return c.test(h)}return fp=p,fp}var hp,xS;function Wq(){if(xS)return hp;xS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+r+s,l="\\ufe0e\\ufe0f",u="["+e+"]",c="["+o+"]",p="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+p+")",f="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",x="\\u200d",C=h+"?",_="["+l+"]?",S="(?:"+x+"(?:"+[f,m,y].join("|")+")"+_+C+")*",b=_+C+S,k="(?:"+[f+c+"?",c,m,y,u].join("|")+")",N=RegExp(p+"(?="+p+")|"+k+b,"g");function j(P){for(var O=N.lastIndex=0;N.test(P);)++O;return O}return hp=j,hp}var pp,_S;function Gq(){if(_S)return pp;_S=1;var e=Hq(),n=Vq(),r=Wq();function s(o){return n(o)?r(o):e(o)}return pp=s,pp}var mp,SS;function Yq(){if(SS)return mp;SS=1;var e=bv(),n=eo(),r=qr(),s=Uq(),o=Gq(),l="[object Map]",u="[object Set]";function c(p){if(p==null)return 0;if(r(p))return s(p)?o(p):p.length;var h=n(p);return h==l||h==u?p.size:e(p).length}return mp=c,mp}var gp,bS;function Kq(){if(bS)return gp;bS=1;var e=xv(),n=zN(),r=Rv(),s=Lr(),o=cu(),l=_t(),u=Js(),c=da(),p=Pn(),h=pa();function f(m,y,x){var C=l(m),_=C||u(m)||h(m);if(y=s(y,4),x==null){var S=m&&m.constructor;_?x=C?new S:[]:p(m)?x=c(S)?n(o(m)):{}:x={}}return(_?e:r)(m,function(b,k,N){return y(x,b,k,N)}),x}return gp=f,gp}var vp,kS;function Xq(){if(kS)return vp;kS=1;var e=Zs(),n=ha(),r=_t(),s=e?e.isConcatSpreadable:void 0;function o(l){return r(l)||n(l)||!!(s&&l&&l[s])}return vp=o,vp}var yp,ES;function Iv(){if(ES)return yp;ES=1;var e=Ev(),n=Xq();function r(s,o,l,u,c){var p=-1,h=s.length;for(l||(l=n),c||(c=[]);++p<h;){var f=s[p];o>0&&l(f)?o>1?r(f,o-1,l,u,c):e(c,f):u||(c[c.length]=f)}return c}return yp=r,yp}var wp,NS;function Qq(){if(NS)return wp;NS=1;function e(n,r,s){switch(s.length){case 0:return n.call(r);case 1:return n.call(r,s[0]);case 2:return n.call(r,s[0],s[1]);case 3:return n.call(r,s[0],s[1],s[2])}return n.apply(r,s)}return wp=e,wp}var xp,CS;function uC(){if(CS)return xp;CS=1;var e=Qq(),n=Math.max;function r(s,o,l){return o=n(o===void 0?s.length-1:o,0),function(){for(var u=arguments,c=-1,p=n(u.length-o,0),h=Array(p);++c<p;)h[c]=u[o+c];c=-1;for(var f=Array(o+1);++c<o;)f[c]=u[c];return f[o]=l(h),e(s,this,f)}}return xp=r,xp}var _p,jS;function Zq(){if(jS)return _p;jS=1;var e=Cv(),n=jN(),r=is(),s=n?function(o,l){return n(o,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:r;return _p=s,_p}var Sp,RS;function Jq(){if(RS)return Sp;RS=1;var e=800,n=16,r=Date.now;function s(o){var l=0,u=0;return function(){var c=r(),p=n-(c-u);if(u=c,p>0){if(++l>=e)return arguments[0]}else l=0;return o.apply(void 0,arguments)}}return Sp=s,Sp}var bp,TS;function cC(){if(TS)return bp;TS=1;var e=Zq(),n=Jq(),r=n(e);return bp=r,bp}var kp,AS;function mu(){if(AS)return kp;AS=1;var e=is(),n=uC(),r=cC();function s(o,l){return r(n(o,l,e),o+"")}return kp=s,kp}var Ep,IS;function dC(){if(IS)return Ep;IS=1;function e(n,r,s,o){for(var l=n.length,u=s+(o?1:-1);o?u--:++u<l;)if(r(n[u],u,n))return u;return-1}return Ep=e,Ep}var Np,MS;function eL(){if(MS)return Np;MS=1;function e(n){return n!==n}return Np=e,Np}var Cp,PS;function tL(){if(PS)return Cp;PS=1;function e(n,r,s){for(var o=s-1,l=n.length;++o<l;)if(n[o]===r)return o;return-1}return Cp=e,Cp}var jp,OS;function nL(){if(OS)return jp;OS=1;var e=dC(),n=eL(),r=tL();function s(o,l,u){return l===l?r(o,l,u):e(o,n,u)}return jp=s,jp}var Rp,qS;function rL(){if(qS)return Rp;qS=1;var e=nL();function n(r,s){var o=r==null?0:r.length;return!!o&&e(r,s,0)>-1}return Rp=n,Rp}var Tp,LS;function iL(){if(LS)return Tp;LS=1;function e(n,r,s){for(var o=-1,l=n==null?0:n.length;++o<l;)if(s(r,n[o]))return!0;return!1}return Tp=e,Tp}var Ap,$S;function sL(){if($S)return Ap;$S=1;function e(){}return Ap=e,Ap}var Ip,DS;function oL(){if(DS)return Ip;DS=1;var e=$N(),n=sL(),r=Tv(),s=1/0,o=e&&1/r(new e([,-0]))[1]==s?function(l){return new e(l)}:n;return Ip=o,Ip}var Mp,FS;function aL(){if(FS)return Mp;FS=1;var e=GN(),n=rL(),r=iL(),s=YN(),o=oL(),l=Tv(),u=200;function c(p,h,f){var m=-1,y=n,x=p.length,C=!0,_=[],S=_;if(f)C=!1,y=r;else if(x>=u){var b=h?null:o(p);if(b)return l(b);C=!1,y=s,S=new e}else S=h?[]:_;e:for(;++m<x;){var k=p[m],N=h?h(k):k;if(k=f||k!==0?k:0,C&&N===N){for(var j=S.length;j--;)if(S[j]===N)continue e;h&&S.push(N),_.push(k)}else y(S,N,f)||(S!==_&&S.push(N),_.push(k))}return _}return Mp=c,Mp}var Pp,zS;function fC(){if(zS)return Pp;zS=1;var e=qr(),n=hr();function r(s){return n(s)&&e(s)}return Pp=r,Pp}var Op,BS;function lL(){if(BS)return Op;BS=1;var e=Iv(),n=mu(),r=aL(),s=fC(),o=n(function(l){return r(e(l,1,s,!0))});return Op=o,Op}var qp,US;function uL(){if(US)return qp;US=1;var e=fu();function n(r,s){return e(s,function(o){return r[o]})}return qp=n,qp}var Lp,HS;function hC(){if(HS)return Lp;HS=1;var e=uL(),n=_i();function r(s){return s==null?[]:e(s,n(s))}return Lp=r,Lp}var $p,VS;function On(){if(VS)return $p;VS=1;var e;if(typeof vv=="function")try{e={clone:gq(),constant:Cv(),each:WN(),filter:rC(),has:iC(),isArray:_t(),isEmpty:Fq(),isFunction:da(),isUndefined:sC(),keys:_i(),map:aC(),reduce:lC(),size:Yq(),transform:Kq(),union:lL(),values:hC()}}catch{}return e||(e=window._),$p=e,$p}var Dp,WS;function Mv(){if(WS)return Dp;WS=1;var e=On();Dp=o;var n="\0",r="\0",s="";function o(f){this._isDirected=e.has(f,"directed")?f.directed:!0,this._isMultigraph=e.has(f,"multigraph")?f.multigraph:!1,this._isCompound=e.has(f,"compound")?f.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[r]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(f){return this._label=f,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultNodeLabelFn=f,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var f=this;return e.filter(this.nodes(),function(m){return e.isEmpty(f._in[m])})},o.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(m){return e.isEmpty(f._out[m])})},o.prototype.setNodes=function(f,m){var y=arguments,x=this;return e.each(f,function(C){y.length>1?x.setNode(C,m):x.setNode(C)}),this},o.prototype.setNode=function(f,m){return e.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=m),this):(this._nodes[f]=arguments.length>1?m:this._defaultNodeLabelFn(f),this._isCompound&&(this._parent[f]=r,this._children[f]={},this._children[r][f]=!0),this._in[f]={},this._preds[f]={},this._out[f]={},this._sucs[f]={},++this._nodeCount,this)},o.prototype.node=function(f){return this._nodes[f]},o.prototype.hasNode=function(f){return e.has(this._nodes,f)},o.prototype.removeNode=function(f){var m=this;if(e.has(this._nodes,f)){var y=function(x){m.removeEdge(m._edgeObjs[x])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(x){m.setParent(x)}),delete this._children[f]),e.each(e.keys(this._in[f]),y),delete this._in[f],delete this._preds[f],e.each(e.keys(this._out[f]),y),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},o.prototype.setParent=function(f,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(m))m=r;else{m+="";for(var y=m;!e.isUndefined(y);y=this.parent(y))if(y===f)throw new Error("Setting "+m+" as parent of "+f+" would create a cycle");this.setNode(m)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=m,this._children[m][f]=!0,this},o.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},o.prototype.parent=function(f){if(this._isCompound){var m=this._parent[f];if(m!==r)return m}},o.prototype.children=function(f){if(e.isUndefined(f)&&(f=r),this._isCompound){var m=this._children[f];if(m)return e.keys(m)}else{if(f===r)return this.nodes();if(this.hasNode(f))return[]}},o.prototype.predecessors=function(f){var m=this._preds[f];if(m)return e.keys(m)},o.prototype.successors=function(f){var m=this._sucs[f];if(m)return e.keys(m)},o.prototype.neighbors=function(f){var m=this.predecessors(f);if(m)return e.union(m,this.successors(f))},o.prototype.isLeaf=function(f){var m;return this.isDirected()?m=this.successors(f):m=this.neighbors(f),m.length===0},o.prototype.filterNodes=function(f){var m=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});m.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,S){f(S)&&m.setNode(S,_)}),e.each(this._edgeObjs,function(_){m.hasNode(_.v)&&m.hasNode(_.w)&&m.setEdge(_,y.edge(_))});var x={};function C(_){var S=y.parent(_);return S===void 0||m.hasNode(S)?(x[_]=S,S):S in x?x[S]:C(S)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,C(_))}),m},o.prototype.setDefaultEdgeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultEdgeLabelFn=f,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(f,m){var y=this,x=arguments;return e.reduce(f,function(C,_){return x.length>1?y.setEdge(C,_,m):y.setEdge(C,_),_}),this},o.prototype.setEdge=function(){var f,m,y,x,C=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(f=_.v,m=_.w,y=_.name,arguments.length===2&&(x=arguments[1],C=!0)):(f=_,m=arguments[1],y=arguments[3],arguments.length>2&&(x=arguments[2],C=!0)),f=""+f,m=""+m,e.isUndefined(y)||(y=""+y);var S=c(this._isDirected,f,m,y);if(e.has(this._edgeLabels,S))return C&&(this._edgeLabels[S]=x),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(m),this._edgeLabels[S]=C?x:this._defaultEdgeLabelFn(f,m,y);var b=p(this._isDirected,f,m,y);return f=b.v,m=b.w,Object.freeze(b),this._edgeObjs[S]=b,l(this._preds[m],f),l(this._sucs[f],m),this._in[m][S]=b,this._out[f][S]=b,this._edgeCount++,this},o.prototype.edge=function(f,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,m,y);return this._edgeLabels[x]},o.prototype.hasEdge=function(f,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,m,y);return e.has(this._edgeLabels,x)},o.prototype.removeEdge=function(f,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,m,y),C=this._edgeObjs[x];return C&&(f=C.v,m=C.w,delete this._edgeLabels[x],delete this._edgeObjs[x],u(this._preds[m],f),u(this._sucs[f],m),delete this._in[m][x],delete this._out[f][x],this._edgeCount--),this},o.prototype.inEdges=function(f,m){var y=this._in[f];if(y){var x=e.values(y);return m?e.filter(x,function(C){return C.v===m}):x}},o.prototype.outEdges=function(f,m){var y=this._out[f];if(y){var x=e.values(y);return m?e.filter(x,function(C){return C.w===m}):x}},o.prototype.nodeEdges=function(f,m){var y=this.inEdges(f,m);if(y)return y.concat(this.outEdges(f,m))};function l(f,m){f[m]?f[m]++:f[m]=1}function u(f,m){--f[m]||delete f[m]}function c(f,m,y,x){var C=""+m,_=""+y;if(!f&&C>_){var S=C;C=_,_=S}return C+s+_+s+(e.isUndefined(x)?n:x)}function p(f,m,y,x){var C=""+m,_=""+y;if(!f&&C>_){var S=C;C=_,_=S}var b={v:C,w:_};return x&&(b.name=x),b}function h(f,m){return c(f,m.v,m.w,m.name)}return Dp}var Fp,GS;function cL(){return GS||(GS=1,Fp="2.1.8"),Fp}var zp,YS;function dL(){return YS||(YS=1,zp={Graph:Mv(),version:cL()}),zp}var Bp,KS;function fL(){if(KS)return Bp;KS=1;var e=On(),n=Mv();Bp={write:r,read:l};function r(u){var c={options:{directed:u.isDirected(),multigraph:u.isMultigraph(),compound:u.isCompound()},nodes:s(u),edges:o(u)};return e.isUndefined(u.graph())||(c.value=e.clone(u.graph())),c}function s(u){return e.map(u.nodes(),function(c){var p=u.node(c),h=u.parent(c),f={v:c};return e.isUndefined(p)||(f.value=p),e.isUndefined(h)||(f.parent=h),f})}function o(u){return e.map(u.edges(),function(c){var p=u.edge(c),h={v:c.v,w:c.w};return e.isUndefined(c.name)||(h.name=c.name),e.isUndefined(p)||(h.value=p),h})}function l(u){var c=new n(u.options).setGraph(u.value);return e.each(u.nodes,function(p){c.setNode(p.v,p.value),p.parent&&c.setParent(p.v,p.parent)}),e.each(u.edges,function(p){c.setEdge({v:p.v,w:p.w,name:p.name},p.value)}),c}return Bp}var Up,XS;function hL(){if(XS)return Up;XS=1;var e=On();Up=n;function n(r){var s={},o=[],l;function u(c){e.has(s,c)||(s[c]=!0,l.push(c),e.each(r.successors(c),u),e.each(r.predecessors(c),u))}return e.each(r.nodes(),function(c){l=[],u(c),l.length&&o.push(l)}),o}return Up}var Hp,QS;function pC(){if(QS)return Hp;QS=1;var e=On();Hp=n;function n(){this._arr=[],this._keyIndices={}}return n.prototype.size=function(){return this._arr.length},n.prototype.keys=function(){return this._arr.map(function(r){return r.key})},n.prototype.has=function(r){return e.has(this._keyIndices,r)},n.prototype.priority=function(r){var s=this._keyIndices[r];if(s!==void 0)return this._arr[s].priority},n.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},n.prototype.add=function(r,s){var o=this._keyIndices;if(r=String(r),!e.has(o,r)){var l=this._arr,u=l.length;return o[r]=u,l.push({key:r,priority:s}),this._decrease(u),!0}return!1},n.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key},n.prototype.decrease=function(r,s){var o=this._keyIndices[r];if(s>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[o].priority+" New: "+s);this._arr[o].priority=s,this._decrease(o)},n.prototype._heapify=function(r){var s=this._arr,o=2*r,l=o+1,u=r;o<s.length&&(u=s[o].priority<s[u].priority?o:u,l<s.length&&(u=s[l].priority<s[u].priority?l:u),u!==r&&(this._swap(r,u),this._heapify(u)))},n.prototype._decrease=function(r){for(var s=this._arr,o=s[r].priority,l;r!==0&&(l=r>>1,!(s[l].priority<o));)this._swap(r,l),r=l},n.prototype._swap=function(r,s){var o=this._arr,l=this._keyIndices,u=o[r],c=o[s];o[r]=c,o[s]=u,l[c.key]=r,l[u.key]=s},Hp}var Vp,ZS;function mC(){if(ZS)return Vp;ZS=1;var e=On(),n=pC();Vp=s;var r=e.constant(1);function s(l,u,c,p){return o(l,String(u),c||r,p||function(h){return l.outEdges(h)})}function o(l,u,c,p){var h={},f=new n,m,y,x=function(C){var _=C.v!==m?C.v:C.w,S=h[_],b=c(C),k=y.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+C+" Weight: "+b);k<S.distance&&(S.distance=k,S.predecessor=m,f.decrease(_,k))};for(l.nodes().forEach(function(C){var _=C===u?0:Number.POSITIVE_INFINITY;h[C]={distance:_},f.add(C,_)});f.size()>0&&(m=f.removeMin(),y=h[m],y.distance!==Number.POSITIVE_INFINITY);)p(m).forEach(x);return h}return Vp}var Wp,JS;function pL(){if(JS)return Wp;JS=1;var e=mC(),n=On();Wp=r;function r(s,o,l){return n.transform(s.nodes(),function(u,c){u[c]=e(s,c,o,l)},{})}return Wp}var Gp,eb;function gC(){if(eb)return Gp;eb=1;var e=On();Gp=n;function n(r){var s=0,o=[],l={},u=[];function c(p){var h=l[p]={onStack:!0,lowlink:s,index:s++};if(o.push(p),r.successors(p).forEach(function(y){e.has(l,y)?l[y].onStack&&(h.lowlink=Math.min(h.lowlink,l[y].index)):(c(y),h.lowlink=Math.min(h.lowlink,l[y].lowlink))}),h.lowlink===h.index){var f=[],m;do m=o.pop(),l[m].onStack=!1,f.push(m);while(p!==m);u.push(f)}}return r.nodes().forEach(function(p){e.has(l,p)||c(p)}),u}return Gp}var Yp,tb;function mL(){if(tb)return Yp;tb=1;var e=On(),n=gC();Yp=r;function r(s){return e.filter(n(s),function(o){return o.length>1||o.length===1&&s.hasEdge(o[0],o[0])})}return Yp}var Kp,nb;function gL(){if(nb)return Kp;nb=1;var e=On();Kp=r;var n=e.constant(1);function r(o,l,u){return s(o,l||n,u||function(c){return o.outEdges(c)})}function s(o,l,u){var c={},p=o.nodes();return p.forEach(function(h){c[h]={},c[h][h]={distance:0},p.forEach(function(f){h!==f&&(c[h][f]={distance:Number.POSITIVE_INFINITY})}),u(h).forEach(function(f){var m=f.v===h?f.w:f.v,y=l(f);c[h][m]={distance:y,predecessor:h}})}),p.forEach(function(h){var f=c[h];p.forEach(function(m){var y=c[m];p.forEach(function(x){var C=y[h],_=f[x],S=y[x],b=C.distance+_.distance;b<S.distance&&(S.distance=b,S.predecessor=_.predecessor)})})}),c}return Kp}var Xp,rb;function vC(){if(rb)return Xp;rb=1;var e=On();Xp=n,n.CycleException=r;function n(s){var o={},l={},u=[];function c(p){if(e.has(l,p))throw new r;e.has(o,p)||(l[p]=!0,o[p]=!0,e.each(s.predecessors(p),c),delete l[p],u.push(p))}if(e.each(s.sinks(),c),e.size(o)!==s.nodeCount())throw new r;return u}function r(){}return r.prototype=new Error,Xp}var Qp,ib;function vL(){if(ib)return Qp;ib=1;var e=vC();Qp=n;function n(r){try{e(r)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return Qp}var Zp,sb;function yC(){if(sb)return Zp;sb=1;var e=On();Zp=n;function n(s,o,l){e.isArray(o)||(o=[o]);var u=(s.isDirected()?s.successors:s.neighbors).bind(s),c=[],p={};return e.each(o,function(h){if(!s.hasNode(h))throw new Error("Graph does not have node: "+h);r(s,h,l==="post",p,u,c)}),c}function r(s,o,l,u,c,p){e.has(u,o)||(u[o]=!0,l||p.push(o),e.each(c(o),function(h){r(s,h,l,u,c,p)}),l&&p.push(o))}return Zp}var Jp,ob;function yL(){if(ob)return Jp;ob=1;var e=yC();Jp=n;function n(r,s){return e(r,s,"post")}return Jp}var em,ab;function wL(){if(ab)return em;ab=1;var e=yC();em=n;function n(r,s){return e(r,s,"pre")}return em}var tm,lb;function xL(){if(lb)return tm;lb=1;var e=On(),n=Mv(),r=pC();tm=s;function s(o,l){var u=new n,c={},p=new r,h;function f(y){var x=y.v===h?y.w:y.v,C=p.priority(x);if(C!==void 0){var _=l(y);_<C&&(c[x]=h,p.decrease(x,_))}}if(o.nodeCount()===0)return u;e.each(o.nodes(),function(y){p.add(y,Number.POSITIVE_INFINITY),u.setNode(y)}),p.decrease(o.nodes()[0],0);for(var m=!1;p.size()>0;){if(h=p.removeMin(),e.has(c,h))u.setEdge(h,c[h]);else{if(m)throw new Error("Input graph is not connected: "+o);m=!0}o.nodeEdges(h).forEach(f)}return u}return tm}var nm,ub;function _L(){return ub||(ub=1,nm={components:hL(),dijkstra:mC(),dijkstraAll:pL(),findCycles:mL(),floydWarshall:gL(),isAcyclic:vL(),postorder:yL(),preorder:wL(),prim:xL(),tarjan:gC(),topsort:vC()}),nm}var rm,cb;function SL(){if(cb)return rm;cb=1;var e=dL();return rm={Graph:e.Graph,json:fL(),alg:_L(),version:e.version},rm}var im,db;function Zn(){if(db)return im;db=1;var e;if(typeof vv=="function")try{e=SL()}catch{}return e||(e=window.graphlib),im=e,im}var sm,fb;function bL(){if(fb)return sm;fb=1;var e=UN(),n=1,r=4;function s(o){return e(o,n|r)}return sm=s,sm}var om,hb;function gu(){if(hb)return om;hb=1;var e=Qs(),n=qr(),r=au(),s=Pn();function o(l,u,c){if(!s(c))return!1;var p=typeof u;return(p=="number"?n(c)&&r(u,c.length):p=="string"&&u in c)?e(c[u],l):!1}return om=o,om}var am,pb;function kL(){if(pb)return am;pb=1;var e=mu(),n=Qs(),r=gu(),s=rs(),o=Object.prototype,l=o.hasOwnProperty,u=e(function(c,p){c=Object(c);var h=-1,f=p.length,m=f>2?p[2]:void 0;for(m&&r(p[0],p[1],m)&&(f=1);++h<f;)for(var y=p[h],x=s(y),C=-1,_=x.length;++C<_;){var S=x[C],b=c[S];(b===void 0||n(b,o[S])&&!l.call(c,S))&&(c[S]=y[S])}return c});return am=u,am}var lm,mb;function EL(){if(mb)return lm;mb=1;var e=Lr(),n=qr(),r=_i();function s(o){return function(l,u,c){var p=Object(l);if(!n(l)){var h=e(u,3);l=r(l),u=function(m){return h(p[m],m,p)}}var f=o(l,u,c);return f>-1?p[h?l[f]:f]:void 0}}return lm=s,lm}var um,gb;function NL(){if(gb)return um;gb=1;var e=/\s/;function n(r){for(var s=r.length;s--&&e.test(r.charAt(s)););return s}return um=n,um}var cm,vb;function CL(){if(vb)return cm;vb=1;var e=NL(),n=/^\s+/;function r(s){return s&&s.slice(0,e(s)+1).replace(n,"")}return cm=r,cm}var dm,yb;function jL(){if(yb)return dm;yb=1;var e=CL(),n=Pn(),r=to(),s=NaN,o=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;function p(h){if(typeof h=="number")return h;if(r(h))return s;if(n(h)){var f=typeof h.valueOf=="function"?h.valueOf():h;h=n(f)?f+"":f}if(typeof h!="string")return h===0?h:+h;h=e(h);var m=l.test(h);return m||u.test(h)?c(h.slice(2),m?2:8):o.test(h)?s:+h}return dm=p,dm}var fm,wb;function wC(){if(wb)return fm;wb=1;var e=jL(),n=1/0,r=17976931348623157e292;function s(o){if(!o)return o===0?o:0;if(o=e(o),o===n||o===-n){var l=o<0?-1:1;return l*r}return o===o?o:0}return fm=s,fm}var hm,xb;function RL(){if(xb)return hm;xb=1;var e=wC();function n(r){var s=e(r),o=s%1;return s===s?o?s-o:s:0}return hm=n,hm}var pm,_b;function TL(){if(_b)return pm;_b=1;var e=dC(),n=Lr(),r=RL(),s=Math.max;function o(l,u,c){var p=l==null?0:l.length;if(!p)return-1;var h=c==null?0:r(c);return h<0&&(h=s(p+h,0)),e(l,n(u,3),h)}return pm=o,pm}var mm,Sb;function AL(){if(Sb)return mm;Sb=1;var e=EL(),n=TL(),r=e(n);return mm=r,mm}var gm,bb;function xC(){if(bb)return gm;bb=1;var e=Iv();function n(r){var s=r==null?0:r.length;return s?e(r,1):[]}return gm=n,gm}var vm,kb;function IL(){if(kb)return vm;kb=1;var e=jv(),n=HN(),r=rs();function s(o,l){return o==null?o:e(o,n(l),r)}return vm=s,vm}var ym,Eb;function ML(){if(Eb)return ym;Eb=1;function e(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}return ym=e,ym}var wm,Nb;function PL(){if(Nb)return wm;Nb=1;var e=su(),n=Rv(),r=Lr();function s(o,l){var u={};return l=r(l,3),n(o,function(c,p,h){e(u,p,l(c,p,h))}),u}return wm=s,wm}var xm,Cb;function Pv(){if(Cb)return xm;Cb=1;var e=to();function n(r,s,o){for(var l=-1,u=r.length;++l<u;){var c=r[l],p=s(c);if(p!=null&&(h===void 0?p===p&&!e(p):o(p,h)))var h=p,f=c}return f}return xm=n,xm}var _m,jb;function OL(){if(jb)return _m;jb=1;function e(n,r){return n>r}return _m=e,_m}var Sm,Rb;function qL(){if(Rb)return Sm;Rb=1;var e=Pv(),n=OL(),r=is();function s(o){return o&&o.length?e(o,r,n):void 0}return Sm=s,Sm}var bm,Tb;function _C(){if(Tb)return bm;Tb=1;var e=su(),n=Qs();function r(s,o,l){(l!==void 0&&!n(s[o],l)||l===void 0&&!(o in s))&&e(s,o,l)}return bm=r,bm}var km,Ab;function LL(){if(Ab)return km;Ab=1;var e=ts(),n=cu(),r=hr(),s="[object Object]",o=Function.prototype,l=Object.prototype,u=o.toString,c=l.hasOwnProperty,p=u.call(Object);function h(f){if(!r(f)||e(f)!=s)return!1;var m=n(f);if(m===null)return!0;var y=c.call(m,"constructor")&&m.constructor;return typeof y=="function"&&y instanceof y&&u.call(y)==p}return km=h,km}var Em,Ib;function SC(){if(Ib)return Em;Ib=1;function e(n,r){if(!(r==="constructor"&&typeof n[r]=="function")&&r!="__proto__")return n[r]}return Em=e,Em}var Nm,Mb;function $L(){if(Mb)return Nm;Mb=1;var e=fa(),n=rs();function r(s){return e(s,n(s))}return Nm=r,Nm}var Cm,Pb;function DL(){if(Pb)return Cm;Pb=1;var e=_C(),n=AN(),r=FN(),s=IN(),o=BN(),l=ha(),u=_t(),c=fC(),p=Js(),h=da(),f=Pn(),m=LL(),y=pa(),x=SC(),C=$L();function _(S,b,k,N,j,P,O){var L=x(S,k),B=x(b,k),T=O.get(B);if(T){e(S,k,T);return}var M=P?P(L,B,k+"",S,b,O):void 0,q=M===void 0;if(q){var Y=u(B),X=!Y&&p(B),I=!Y&&!X&&y(B);M=B,Y||X||I?u(L)?M=L:c(L)?M=s(L):X?(q=!1,M=n(B,!0)):I?(q=!1,M=r(B,!0)):M=[]:m(B)||l(B)?(M=L,l(L)?M=C(L):(!f(L)||h(L))&&(M=o(B))):q=!1}q&&(O.set(B,M),j(M,B,N,P,O),O.delete(B)),e(S,k,M)}return Cm=_,Cm}var jm,Ob;function FL(){if(Ob)return jm;Ob=1;var e=iu(),n=_C(),r=jv(),s=DL(),o=Pn(),l=rs(),u=SC();function c(p,h,f,m,y){p!==h&&r(h,function(x,C){if(y||(y=new e),o(x))s(p,h,C,f,c,m,y);else{var _=m?m(u(p,C),x,C+"",p,h,y):void 0;_===void 0&&(_=x),n(p,C,_)}},l)}return jm=c,jm}var Rm,qb;function zL(){if(qb)return Rm;qb=1;var e=mu(),n=gu();function r(s){return e(function(o,l){var u=-1,c=l.length,p=c>1?l[c-1]:void 0,h=c>2?l[2]:void 0;for(p=s.length>3&&typeof p=="function"?(c--,p):void 0,h&&n(l[0],l[1],h)&&(p=c<3?void 0:p,c=1),o=Object(o);++u<c;){var f=l[u];f&&s(o,f,u,p)}return o})}return Rm=r,Rm}var Tm,Lb;function BL(){if(Lb)return Tm;Lb=1;var e=FL(),n=zL(),r=n(function(s,o,l){e(s,o,l)});return Tm=r,Tm}var Am,$b;function bC(){if($b)return Am;$b=1;function e(n,r){return n<r}return Am=e,Am}var Im,Db;function UL(){if(Db)return Im;Db=1;var e=Pv(),n=bC(),r=is();function s(o){return o&&o.length?e(o,r,n):void 0}return Im=s,Im}var Mm,Fb;function HL(){if(Fb)return Mm;Fb=1;var e=Pv(),n=Lr(),r=bC();function s(o,l){return o&&o.length?e(o,n(l,2),r):void 0}return Mm=s,Mm}var Pm,zb;function VL(){if(zb)return Pm;zb=1;var e=er(),n=function(){return e.Date.now()};return Pm=n,Pm}var Om,Bb;function WL(){if(Bb)return Om;Bb=1;var e=ou(),n=hu(),r=au(),s=Pn(),o=ma();function l(u,c,p,h){if(!s(u))return u;c=n(c,u);for(var f=-1,m=c.length,y=m-1,x=u;x!=null&&++f<m;){var C=o(c[f]),_=p;if(C==="__proto__"||C==="constructor"||C==="prototype")return u;if(f!=y){var S=x[C];_=h?h(S,C,x):void 0,_===void 0&&(_=s(S)?S:r(c[f+1])?[]:{})}e(x,C,_),x=x[C]}return u}return Om=l,Om}var qm,Ub;function GL(){if(Ub)return qm;Ub=1;var e=pu(),n=WL(),r=hu();function s(o,l,u){for(var c=-1,p=l.length,h={};++c<p;){var f=l[c],m=e(o,f);u(m,f)&&n(h,r(f,o),m)}return h}return qm=s,qm}var Lm,Hb;function YL(){if(Hb)return Lm;Hb=1;var e=GL(),n=tC();function r(s,o){return e(s,o,function(l,u){return n(s,u)})}return Lm=r,Lm}var $m,Vb;function KL(){if(Vb)return $m;Vb=1;var e=xC(),n=uC(),r=cC();function s(o){return r(n(o,void 0,e),o+"")}return $m=s,$m}var Dm,Wb;function XL(){if(Wb)return Dm;Wb=1;var e=YL(),n=KL(),r=n(function(s,o){return s==null?{}:e(s,o)});return Dm=r,Dm}var Fm,Gb;function QL(){if(Gb)return Fm;Gb=1;var e=Math.ceil,n=Math.max;function r(s,o,l,u){for(var c=-1,p=n(e((o-s)/(l||1)),0),h=Array(p);p--;)h[u?p:++c]=s,s+=l;return h}return Fm=r,Fm}var zm,Yb;function ZL(){if(Yb)return zm;Yb=1;var e=QL(),n=gu(),r=wC();function s(o){return function(l,u,c){return c&&typeof c!="number"&&n(l,u,c)&&(u=c=void 0),l=r(l),u===void 0?(u=l,l=0):u=r(u),c=c===void 0?l<u?1:-1:r(c),e(l,u,c,o)}}return zm=s,zm}var Bm,Kb;function JL(){if(Kb)return Bm;Kb=1;var e=ZL(),n=e();return Bm=n,Bm}var Um,Xb;function e$(){if(Xb)return Um;Xb=1;function e(n,r){var s=n.length;for(n.sort(r);s--;)n[s]=n[s].value;return n}return Um=e,Um}var Hm,Qb;function t$(){if(Qb)return Hm;Qb=1;var e=to();function n(r,s){if(r!==s){var o=r!==void 0,l=r===null,u=r===r,c=e(r),p=s!==void 0,h=s===null,f=s===s,m=e(s);if(!h&&!m&&!c&&r>s||c&&p&&f&&!h&&!m||l&&p&&f||!o&&f||!u)return 1;if(!l&&!c&&!m&&r<s||m&&o&&u&&!l&&!c||h&&o&&u||!p&&u||!f)return-1}return 0}return Hm=n,Hm}var Vm,Zb;function n$(){if(Zb)return Vm;Zb=1;var e=t$();function n(r,s,o){for(var l=-1,u=r.criteria,c=s.criteria,p=u.length,h=o.length;++l<p;){var f=e(u[l],c[l]);if(f){if(l>=h)return f;var m=o[l];return f*(m=="desc"?-1:1)}}return r.index-s.index}return Vm=n,Vm}var Wm,Jb;function r$(){if(Jb)return Wm;Jb=1;var e=fu(),n=pu(),r=Lr(),s=oC(),o=e$(),l=lu(),u=n$(),c=is(),p=_t();function h(f,m,y){m.length?m=e(m,function(_){return p(_)?function(S){return n(S,_.length===1?_[0]:_)}:_}):m=[c];var x=-1;m=e(m,l(r));var C=s(f,function(_,S,b){var k=e(m,function(N){return N(_)});return{criteria:k,index:++x,value:_}});return o(C,function(_,S){return u(_,S,y)})}return Wm=h,Wm}var Gm,ek;function i$(){if(ek)return Gm;ek=1;var e=Iv(),n=r$(),r=mu(),s=gu(),o=r(function(l,u){if(l==null)return[];var c=u.length;return c>1&&s(l,u[0],u[1])?u=[]:c>2&&s(u[0],u[1],u[2])&&(u=[u[0]]),n(l,e(u,1),[])});return Gm=o,Gm}var Ym,tk;function s$(){if(tk)return Ym;tk=1;var e=JN(),n=0;function r(s){var o=++n;return e(s)+o}return Ym=r,Ym}var Km,nk;function o$(){if(nk)return Km;nk=1;function e(n,r,s){for(var o=-1,l=n.length,u=r.length,c={};++o<l;){var p=o<u?r[o]:void 0;s(c,n[o],p)}return c}return Km=e,Km}var Xm,rk;function a$(){if(rk)return Xm;rk=1;var e=ou(),n=o$();function r(s,o){return n(s||[],o||[],e)}return Xm=r,Xm}var Qm,ik;function ot(){if(ik)return Qm;ik=1;var e;if(typeof vv=="function")try{e={cloneDeep:bL(),constant:Cv(),defaults:kL(),each:WN(),filter:rC(),find:AL(),flatten:xC(),forEach:VN(),forIn:IL(),has:iC(),isUndefined:sC(),last:ML(),map:aC(),mapValues:PL(),max:qL(),merge:BL(),min:UL(),minBy:HL(),now:VL(),pick:XL(),range:JL(),reduce:lC(),sortBy:i$(),uniqueId:s$(),values:hC(),zipObject:a$()}}catch{}return e||(e=window._),Qm=e,Qm}var Zm,sk;function l$(){if(sk)return Zm;sk=1,Zm=e;function e(){var s={};s._next=s._prev=s,this._sentinel=s}e.prototype.dequeue=function(){var s=this._sentinel,o=s._prev;if(o!==s)return n(o),o},e.prototype.enqueue=function(s){var o=this._sentinel;s._prev&&s._next&&n(s),s._next=o._next,o._next._prev=s,o._next=s,s._prev=o},e.prototype.toString=function(){for(var s=[],o=this._sentinel,l=o._prev;l!==o;)s.push(JSON.stringify(l,r)),l=l._prev;return"["+s.join(", ")+"]"};function n(s){s._prev._next=s._next,s._next._prev=s._prev,delete s._next,delete s._prev}function r(s,o){if(s!=="_next"&&s!=="_prev")return o}return Zm}var Jm,ok;function u$(){if(ok)return Jm;ok=1;var e=ot(),n=Zn().Graph,r=l$();Jm=o;var s=e.constant(1);function o(h,f){if(h.nodeCount()<=1)return[];var m=c(h,f||s),y=l(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(x){return h.outEdges(x.v,x.w)}),!0)}function l(h,f,m){for(var y=[],x=f[f.length-1],C=f[0],_;h.nodeCount();){for(;_=C.dequeue();)u(h,f,m,_);for(;_=x.dequeue();)u(h,f,m,_);if(h.nodeCount()){for(var S=f.length-2;S>0;--S)if(_=f[S].dequeue(),_){y=y.concat(u(h,f,m,_,!0));break}}}return y}function u(h,f,m,y,x){var C=x?[]:void 0;return e.forEach(h.inEdges(y.v),function(_){var S=h.edge(_),b=h.node(_.v);x&&C.push({v:_.v,w:_.w}),b.out-=S,p(f,m,b)}),e.forEach(h.outEdges(y.v),function(_){var S=h.edge(_),b=_.w,k=h.node(b);k.in-=S,p(f,m,k)}),h.removeNode(y.v),C}function c(h,f){var m=new n,y=0,x=0;e.forEach(h.nodes(),function(S){m.setNode(S,{v:S,in:0,out:0})}),e.forEach(h.edges(),function(S){var b=m.edge(S.v,S.w)||0,k=f(S),N=b+k;m.setEdge(S.v,S.w,N),x=Math.max(x,m.node(S.v).out+=k),y=Math.max(y,m.node(S.w).in+=k)});var C=e.range(x+y+3).map(function(){return new r}),_=y+1;return e.forEach(m.nodes(),function(S){p(C,_,m.node(S))}),{graph:m,buckets:C,zeroIdx:_}}function p(h,f,m){m.out?m.in?h[m.out-m.in+f].enqueue(m):h[h.length-1].enqueue(m):h[0].enqueue(m)}return Jm}var eg,ak;function c$(){if(ak)return eg;ak=1;var e=ot(),n=u$();eg={run:r,undo:o};function r(l){var u=l.graph().acyclicer==="greedy"?n(l,c(l)):s(l);e.forEach(u,function(p){var h=l.edge(p);l.removeEdge(p),h.forwardName=p.name,h.reversed=!0,l.setEdge(p.w,p.v,h,e.uniqueId("rev"))});function c(p){return function(h){return p.edge(h).weight}}}function s(l){var u=[],c={},p={};function h(f){e.has(p,f)||(p[f]=!0,c[f]=!0,e.forEach(l.outEdges(f),function(m){e.has(c,m.w)?u.push(m):h(m.w)}),delete c[f])}return e.forEach(l.nodes(),h),u}function o(l){e.forEach(l.edges(),function(u){var c=l.edge(u);if(c.reversed){l.removeEdge(u);var p=c.forwardName;delete c.reversed,delete c.forwardName,l.setEdge(u.w,u.v,c,p)}})}return eg}var tg,lk;function an(){if(lk)return tg;lk=1;var e=ot(),n=Zn().Graph;tg={addDummyNode:r,simplify:s,asNonCompoundGraph:o,successorWeights:l,predecessorWeights:u,intersectRect:c,buildLayerMatrix:p,normalizeRanks:h,removeEmptyRanks:f,addBorderNode:m,maxRank:y,partition:x,time:C,notime:_};function r(S,b,k,N){var j;do j=e.uniqueId(N);while(S.hasNode(j));return k.dummy=b,S.setNode(j,k),j}function s(S){var b=new n().setGraph(S.graph());return e.forEach(S.nodes(),function(k){b.setNode(k,S.node(k))}),e.forEach(S.edges(),function(k){var N=b.edge(k.v,k.w)||{weight:0,minlen:1},j=S.edge(k);b.setEdge(k.v,k.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(k){S.children(k).length||b.setNode(k,S.node(k))}),e.forEach(S.edges(),function(k){b.setEdge(k,S.edge(k))}),b}function l(S){var b=e.map(S.nodes(),function(k){var N={};return e.forEach(S.outEdges(k),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(k){var N={};return e.forEach(S.inEdges(k),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 k=S.x,N=S.y,j=b.x-k,P=b.y-N,O=S.width/2,L=S.height/2;if(!j&&!P)throw new Error("Not possible to find intersection inside of the rectangle");var B,T;return Math.abs(P)*O>Math.abs(j)*L?(P<0&&(L=-L),B=L*j/P,T=L):(j<0&&(O=-O),B=O,T=O*P/j),{x:k+B,y:N+T}}function p(S){var b=e.map(e.range(y(S)+1),function(){return[]});return e.forEach(S.nodes(),function(k){var N=S.node(k),j=N.rank;e.isUndefined(j)||(b[j][N.order]=k)}),b}function h(S){var b=e.min(e.map(S.nodes(),function(k){return S.node(k).rank}));e.forEach(S.nodes(),function(k){var N=S.node(k);e.has(N,"rank")&&(N.rank-=b)})}function f(S){var b=e.min(e.map(S.nodes(),function(P){return S.node(P).rank})),k=[];e.forEach(S.nodes(),function(P){var O=S.node(P).rank-b;k[O]||(k[O]=[]),k[O].push(P)});var N=0,j=S.graph().nodeRankFactor;e.forEach(k,function(P,O){e.isUndefined(P)&&O%j!==0?--N:N&&e.forEach(P,function(L){S.node(L).rank+=N})})}function m(S,b,k,N){var j={width:0,height:0};return arguments.length>=4&&(j.rank=k,j.order=N),r(S,"border",j,b)}function y(S){return e.max(e.map(S.nodes(),function(b){var k=S.node(b).rank;if(!e.isUndefined(k))return k}))}function x(S,b){var k={lhs:[],rhs:[]};return e.forEach(S,function(N){b(N)?k.lhs.push(N):k.rhs.push(N)}),k}function C(S,b){var k=e.now();try{return b()}finally{console.log(S+" time: "+(e.now()-k)+"ms")}}function _(S,b){return b()}return tg}var ng,uk;function d$(){if(uk)return ng;uk=1;var e=ot(),n=an();ng={run:r,undo:o};function r(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(u){s(l,u)})}function s(l,u){var c=u.v,p=l.node(c).rank,h=u.w,f=l.node(h).rank,m=u.name,y=l.edge(u),x=y.labelRank;if(f!==p+1){l.removeEdge(u);var C,_,S;for(S=0,++p;p<f;++S,++p)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:u,rank:p},C=n.addDummyNode(l,"edge",_,"_d"),p===x&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),l.setEdge(c,C,{weight:y.weight},m),S===0&&l.graph().dummyChains.push(C),c=C;l.setEdge(c,h,{weight:y.weight},m)}}function o(l){e.forEach(l.graph().dummyChains,function(u){var c=l.node(u),p=c.edgeLabel,h;for(l.setEdge(c.edgeObj,p);c.dummy;)h=l.successors(u)[0],l.removeNode(u),p.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(p.x=c.x,p.y=c.y,p.width=c.width,p.height=c.height),u=h,c=l.node(u)})}return ng}var rg,ck;function Wl(){if(ck)return rg;ck=1;var e=ot();rg={longestPath:n,slack:r};function n(s){var o={};function l(u){var c=s.node(u);if(e.has(o,u))return c.rank;o[u]=!0;var p=e.min(e.map(s.outEdges(u),function(h){return l(h.w)-s.edge(h).minlen}));return(p===Number.POSITIVE_INFINITY||p===void 0||p===null)&&(p=0),c.rank=p}e.forEach(s.sources(),l)}function r(s,o){return s.node(o.w).rank-s.node(o.v).rank-s.edge(o).minlen}return rg}var ig,dk;function kC(){if(dk)return ig;dk=1;var e=ot(),n=Zn().Graph,r=Wl().slack;ig=s;function s(c){var p=new n({directed:!1}),h=c.nodes()[0],f=c.nodeCount();p.setNode(h,{});for(var m,y;o(p,c)<f;)m=l(p,c),y=p.hasNode(m.v)?r(c,m):-r(c,m),u(p,c,y);return p}function o(c,p){function h(f){e.forEach(p.nodeEdges(f),function(m){var y=m.v,x=f===y?m.w:y;!c.hasNode(x)&&!r(p,m)&&(c.setNode(x,{}),c.setEdge(f,x,{}),h(x))})}return e.forEach(c.nodes(),h),c.nodeCount()}function l(c,p){return e.minBy(p.edges(),function(h){if(c.hasNode(h.v)!==c.hasNode(h.w))return r(p,h)})}function u(c,p,h){e.forEach(c.nodes(),function(f){p.node(f).rank+=h})}return ig}var sg,fk;function f$(){if(fk)return sg;fk=1;var e=ot(),n=kC(),r=Wl().slack,s=Wl().longestPath,o=Zn().alg.preorder,l=Zn().alg.postorder,u=an().simplify;sg=c,c.initLowLimValues=m,c.initCutValues=p,c.calcCutValue=f,c.leaveEdge=x,c.enterEdge=C,c.exchangeEdges=_;function c(N){N=u(N),s(N);var j=n(N);m(j),p(j,N);for(var P,O;P=x(j);)O=C(j,N,P),_(j,N,P,O)}function p(N,j){var P=l(N,N.nodes());P=P.slice(0,P.length-1),e.forEach(P,function(O){h(N,j,O)})}function h(N,j,P){var O=N.node(P),L=O.parent;N.edge(P,L).cutvalue=f(N,j,P)}function f(N,j,P){var O=N.node(P),L=O.parent,B=!0,T=j.edge(P,L),M=0;return T||(B=!1,T=j.edge(L,P)),M=T.weight,e.forEach(j.nodeEdges(P),function(q){var Y=q.v===P,X=Y?q.w:q.v;if(X!==L){var I=Y===B,H=j.edge(q).weight;if(M+=I?H:-H,b(N,P,X)){var U=N.edge(P,X).cutvalue;M+=I?-U:U}}}),M}function m(N,j){arguments.length<2&&(j=N.nodes()[0]),y(N,{},1,j)}function y(N,j,P,O,L){var B=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=B,T.lim=P++,L?T.parent=L:delete T.parent,P}function x(N){return e.find(N.edges(),function(j){return N.edge(j).cutvalue<0})}function C(N,j,P){var O=P.v,L=P.w;j.hasEdge(O,L)||(O=P.w,L=P.v);var B=N.node(O),T=N.node(L),M=B,q=!1;B.lim>T.lim&&(M=T,q=!0);var Y=e.filter(j.edges(),function(X){return q===k(N,N.node(X.v),M)&&q!==k(N,N.node(X.w),M)});return e.minBy(Y,function(X){return r(j,X)})}function _(N,j,P,O){var L=P.v,B=P.w;N.removeEdge(L,B),N.setEdge(O.v,O.w,{}),m(N),p(N,j),S(N,j)}function S(N,j){var P=e.find(N.nodes(),function(L){return!j.node(L).parent}),O=o(N,P);O=O.slice(1),e.forEach(O,function(L){var B=N.node(L).parent,T=j.edge(L,B),M=!1;T||(T=j.edge(B,L),M=!0),j.node(L).rank=j.node(B).rank+(M?T.minlen:-T.minlen)})}function b(N,j,P){return N.hasEdge(j,P)}function k(N,j,P){return P.low<=j.lim&&j.lim<=P.lim}return sg}var og,hk;function h$(){if(hk)return og;hk=1;var e=Wl(),n=e.longestPath,r=kC(),s=f$();og=o;function o(p){switch(p.graph().ranker){case"network-simplex":c(p);break;case"tight-tree":u(p);break;case"longest-path":l(p);break;default:c(p)}}var l=n;function u(p){n(p),r(p)}function c(p){s(p)}return og}var ag,pk;function p$(){if(pk)return ag;pk=1;var e=ot();ag=n;function n(o){var l=s(o);e.forEach(o.graph().dummyChains,function(u){for(var c=o.node(u),p=c.edgeObj,h=r(o,l,p.v,p.w),f=h.path,m=h.lca,y=0,x=f[y],C=!0;u!==p.w;){if(c=o.node(u),C){for(;(x=f[y])!==m&&o.node(x).maxRank<c.rank;)y++;x===m&&(C=!1)}if(!C){for(;y<f.length-1&&o.node(x=f[y+1]).minRank<=c.rank;)y++;x=f[y]}o.setParent(u,x),u=o.successors(u)[0]}})}function r(o,l,u,c){var p=[],h=[],f=Math.min(l[u].low,l[c].low),m=Math.max(l[u].lim,l[c].lim),y,x;y=u;do y=o.parent(y),p.push(y);while(y&&(l[y].low>f||m>l[y].lim));for(x=y,y=c;(y=o.parent(y))!==x;)h.push(y);return{path:p.concat(h.reverse()),lca:x}}function s(o){var l={},u=0;function c(p){var h=u;e.forEach(o.children(p),c),l[p]={low:h,lim:u++}}return e.forEach(o.children(),c),l}return ag}var lg,mk;function m$(){if(mk)return lg;mk=1;var e=ot(),n=an();lg={run:r,cleanup:u};function r(c){var p=n.addDummyNode(c,"root",{},"_root"),h=o(c),f=e.max(e.values(h))-1,m=2*f+1;c.graph().nestingRoot=p,e.forEach(c.edges(),function(x){c.edge(x).minlen*=m});var y=l(c)+1;e.forEach(c.children(),function(x){s(c,p,m,y,f,h,x)}),c.graph().nodeRankFactor=m}function s(c,p,h,f,m,y,x){var C=c.children(x);if(!C.length){x!==p&&c.setEdge(p,x,{weight:0,minlen:h});return}var _=n.addBorderNode(c,"_bt"),S=n.addBorderNode(c,"_bb"),b=c.node(x);c.setParent(_,x),b.borderTop=_,c.setParent(S,x),b.borderBottom=S,e.forEach(C,function(k){s(c,p,h,f,m,y,k);var N=c.node(k),j=N.borderTop?N.borderTop:k,P=N.borderBottom?N.borderBottom:k,O=N.borderTop?f:2*f,L=j!==P?1:m-y[x]+1;c.setEdge(_,j,{weight:O,minlen:L,nestingEdge:!0}),c.setEdge(P,S,{weight:O,minlen:L,nestingEdge:!0})}),c.parent(x)||c.setEdge(p,_,{weight:0,minlen:m+y[x]})}function o(c){var p={};function h(f,m){var y=c.children(f);y&&y.length&&e.forEach(y,function(x){h(x,m+1)}),p[f]=m}return e.forEach(c.children(),function(f){h(f,1)}),p}function l(c){return e.reduce(c.edges(),function(p,h){return p+c.edge(h).weight},0)}function u(c){var p=c.graph();c.removeNode(p.nestingRoot),delete p.nestingRoot,e.forEach(c.edges(),function(h){var f=c.edge(h);f.nestingEdge&&c.removeEdge(h)})}return lg}var ug,gk;function g$(){if(gk)return ug;gk=1;var e=ot(),n=an();ug=r;function r(o){function l(u){var c=o.children(u),p=o.node(u);if(c.length&&e.forEach(c,l),e.has(p,"minRank")){p.borderLeft=[],p.borderRight=[];for(var h=p.minRank,f=p.maxRank+1;h<f;++h)s(o,"borderLeft","_bl",u,p,h),s(o,"borderRight","_br",u,p,h)}}e.forEach(o.children(),l)}function s(o,l,u,c,p,h){var f={width:0,height:0,rank:h,borderType:l},m=p[l][h-1],y=n.addDummyNode(o,"border",f,u);p[l][h]=y,o.setParent(y,c),m&&o.setEdge(m,y,{weight:1})}return ug}var cg,vk;function v$(){if(vk)return cg;vk=1;var e=ot();cg={adjust:n,undo:r};function n(h){var f=h.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&s(h)}function r(h){var f=h.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&l(h),(f==="lr"||f==="rl")&&(c(h),s(h))}function s(h){e.forEach(h.nodes(),function(f){o(h.node(f))}),e.forEach(h.edges(),function(f){o(h.edge(f))})}function o(h){var f=h.width;h.width=h.height,h.height=f}function l(h){e.forEach(h.nodes(),function(f){u(h.node(f))}),e.forEach(h.edges(),function(f){var m=h.edge(f);e.forEach(m.points,u),e.has(m,"y")&&u(m)})}function u(h){h.y=-h.y}function c(h){e.forEach(h.nodes(),function(f){p(h.node(f))}),e.forEach(h.edges(),function(f){var m=h.edge(f);e.forEach(m.points,p),e.has(m,"x")&&p(m)})}function p(h){var f=h.x;h.x=h.y,h.y=f}return cg}var dg,yk;function y$(){if(yk)return dg;yk=1;var e=ot();dg=n;function n(r){var s={},o=e.filter(r.nodes(),function(h){return!r.children(h).length}),l=e.max(e.map(o,function(h){return r.node(h).rank})),u=e.map(e.range(l+1),function(){return[]});function c(h){if(!e.has(s,h)){s[h]=!0;var f=r.node(h);u[f.rank].push(h),e.forEach(r.successors(h),c)}}var p=e.sortBy(o,function(h){return r.node(h).rank});return e.forEach(p,c),u}return dg}var fg,wk;function w$(){if(wk)return fg;wk=1;var e=ot();fg=n;function n(s,o){for(var l=0,u=1;u<o.length;++u)l+=r(s,o[u-1],o[u]);return l}function r(s,o,l){for(var u=e.zipObject(l,e.map(l,function(y,x){return x})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(s.outEdges(y),function(x){return{pos:u[x.w],weight:s.edge(x).weight}}),"pos")}),!0),p=1;p<l.length;)p<<=1;var h=2*p-1;p-=1;var f=e.map(new Array(h),function(){return 0}),m=0;return e.forEach(c.forEach(function(y){var x=y.pos+p;f[x]+=y.weight;for(var C=0;x>0;)x%2&&(C+=f[x+1]),x=x-1>>1,f[x]+=y.weight;m+=y.weight*C})),m}return fg}var hg,xk;function x$(){if(xk)return hg;xk=1;var e=ot();hg=n;function n(r,s){return e.map(s,function(o){var l=r.inEdges(o);if(l.length){var u=e.reduce(l,function(c,p){var h=r.edge(p),f=r.node(p.v);return{sum:c.sum+h.weight*f.order,weight:c.weight+h.weight}},{sum:0,weight:0});return{v:o,barycenter:u.sum/u.weight,weight:u.weight}}else return{v:o}})}return hg}var pg,_k;function _$(){if(_k)return pg;_k=1;var e=ot();pg=n;function n(o,l){var u={};e.forEach(o,function(p,h){var f=u[p.v]={indegree:0,in:[],out:[],vs:[p.v],i:h};e.isUndefined(p.barycenter)||(f.barycenter=p.barycenter,f.weight=p.weight)}),e.forEach(l.edges(),function(p){var h=u[p.v],f=u[p.w];!e.isUndefined(h)&&!e.isUndefined(f)&&(f.indegree++,h.out.push(u[p.w]))});var c=e.filter(u,function(p){return!p.indegree});return r(c)}function r(o){var l=[];function u(h){return function(f){f.merged||(e.isUndefined(f.barycenter)||e.isUndefined(h.barycenter)||f.barycenter>=h.barycenter)&&s(h,f)}}function c(h){return function(f){f.in.push(h),--f.indegree===0&&o.push(f)}}for(;o.length;){var p=o.pop();l.push(p),e.forEach(p.in.reverse(),u(p)),e.forEach(p.out,c(p))}return e.map(e.filter(l,function(h){return!h.merged}),function(h){return e.pick(h,["vs","i","barycenter","weight"])})}function s(o,l){var u=0,c=0;o.weight&&(u+=o.barycenter*o.weight,c+=o.weight),l.weight&&(u+=l.barycenter*l.weight,c+=l.weight),o.vs=l.vs.concat(o.vs),o.barycenter=u/c,o.weight=c,o.i=Math.min(l.i,o.i),l.merged=!0}return pg}var mg,Sk;function S$(){if(Sk)return mg;Sk=1;var e=ot(),n=an();mg=r;function r(l,u){var c=n.partition(l,function(_){return e.has(_,"barycenter")}),p=c.lhs,h=e.sortBy(c.rhs,function(_){return-_.i}),f=[],m=0,y=0,x=0;p.sort(o(!!u)),x=s(f,h,x),e.forEach(p,function(_){x+=_.vs.length,f.push(_.vs),m+=_.barycenter*_.weight,y+=_.weight,x=s(f,h,x)});var C={vs:e.flatten(f,!0)};return y&&(C.barycenter=m/y,C.weight=y),C}function s(l,u,c){for(var p;u.length&&(p=e.last(u)).i<=c;)u.pop(),l.push(p.vs),c++;return c}function o(l){return function(u,c){return u.barycenter<c.barycenter?-1:u.barycenter>c.barycenter?1:l?c.i-u.i:u.i-c.i}}return mg}var gg,bk;function b$(){if(bk)return gg;bk=1;var e=ot(),n=x$(),r=_$(),s=S$();gg=o;function o(c,p,h,f){var m=c.children(p),y=c.node(p),x=y?y.borderLeft:void 0,C=y?y.borderRight:void 0,_={};x&&(m=e.filter(m,function(P){return P!==x&&P!==C}));var S=n(c,m);e.forEach(S,function(P){if(c.children(P.v).length){var O=o(c,P.v,h,f);_[P.v]=O,e.has(O,"barycenter")&&u(P,O)}});var b=r(S,h);l(b,_);var k=s(b,f);if(x&&(k.vs=e.flatten([x,k.vs,C],!0),c.predecessors(x).length)){var N=c.node(c.predecessors(x)[0]),j=c.node(c.predecessors(C)[0]);e.has(k,"barycenter")||(k.barycenter=0,k.weight=0),k.barycenter=(k.barycenter*k.weight+N.order+j.order)/(k.weight+2),k.weight+=2}return k}function l(c,p){e.forEach(c,function(h){h.vs=e.flatten(h.vs.map(function(f){return p[f]?p[f].vs:f}),!0)})}function u(c,p){e.isUndefined(c.barycenter)?(c.barycenter=p.barycenter,c.weight=p.weight):(c.barycenter=(c.barycenter*c.weight+p.barycenter*p.weight)/(c.weight+p.weight),c.weight+=p.weight)}return gg}var vg,kk;function k$(){if(kk)return vg;kk=1;var e=ot(),n=Zn().Graph;vg=r;function r(o,l,u){var c=s(o),p=new n({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(h){return o.node(h)});return e.forEach(o.nodes(),function(h){var f=o.node(h),m=o.parent(h);(f.rank===l||f.minRank<=l&&l<=f.maxRank)&&(p.setNode(h),p.setParent(h,m||c),e.forEach(o[u](h),function(y){var x=y.v===h?y.w:y.v,C=p.edge(x,h),_=e.isUndefined(C)?0:C.weight;p.setEdge(x,h,{weight:o.edge(y).weight+_})}),e.has(f,"minRank")&&p.setNode(h,{borderLeft:f.borderLeft[l],borderRight:f.borderRight[l]}))}),p}function s(o){for(var l;o.hasNode(l=e.uniqueId("_root")););return l}return vg}var yg,Ek;function E$(){if(Ek)return yg;Ek=1;var e=ot();yg=n;function n(r,s,o){var l={},u;e.forEach(o,function(c){for(var p=r.parent(c),h,f;p;){if(h=r.parent(p),h?(f=l[h],l[h]=p):(f=u,u=p),f&&f!==p){s.setEdge(f,p);return}p=h}})}return yg}var wg,Nk;function N$(){if(Nk)return wg;Nk=1;var e=ot(),n=y$(),r=w$(),s=b$(),o=k$(),l=E$(),u=Zn().Graph,c=an();wg=p;function p(y){var x=c.maxRank(y),C=h(y,e.range(1,x+1),"inEdges"),_=h(y,e.range(x-1,-1,-1),"outEdges"),S=n(y);m(y,S);for(var b=Number.POSITIVE_INFINITY,k,N=0,j=0;j<4;++N,++j){f(N%2?C:_,N%4>=2),S=c.buildLayerMatrix(y);var P=r(y,S);P<b&&(j=0,k=e.cloneDeep(S),b=P)}m(y,k)}function h(y,x,C){return e.map(x,function(_){return o(y,_,C)})}function f(y,x){var C=new u;e.forEach(y,function(_){var S=_.graph().root,b=s(_,S,C,x);e.forEach(b.vs,function(k,N){_.node(k).order=N}),l(_,C,b.vs)})}function m(y,x){e.forEach(x,function(C){e.forEach(C,function(_,S){y.node(_).order=S})})}return wg}var xg,Ck;function C$(){if(Ck)return xg;Ck=1;var e=ot(),n=Zn().Graph,r=an();xg={positionX:C,findType1Conflicts:s,findType2Conflicts:o,addConflict:u,hasConflict:c,verticalAlignment:p,horizontalCompaction:h,alignCoordinates:y,findSmallestWidthAlignment:m,balance:x};function s(b,k){var N={};function j(P,O){var L=0,B=0,T=P.length,M=e.last(O);return e.forEach(O,function(q,Y){var X=l(b,q),I=X?b.node(X).order:T;(X||q===M)&&(e.forEach(O.slice(B,Y+1),function(H){e.forEach(b.predecessors(H),function(U){var ne=b.node(U),J=ne.order;(J<L||I<J)&&!(ne.dummy&&b.node(H).dummy)&&u(N,U,H)})}),B=Y+1,L=I)}),O}return e.reduce(k,j),N}function o(b,k){var N={};function j(O,L,B,T,M){var q;e.forEach(e.range(L,B),function(Y){q=O[Y],b.node(q).dummy&&e.forEach(b.predecessors(q),function(X){var I=b.node(X);I.dummy&&(I.order<T||I.order>M)&&u(N,X,q)})})}function P(O,L){var B=-1,T,M=0;return e.forEach(L,function(q,Y){if(b.node(q).dummy==="border"){var X=b.predecessors(q);X.length&&(T=b.node(X[0]).order,j(L,M,Y,B,T),M=Y,B=T)}j(L,M,L.length,T,O.length)}),L}return e.reduce(k,P),N}function l(b,k){if(b.node(k).dummy)return e.find(b.predecessors(k),function(N){return b.node(N).dummy})}function u(b,k,N){if(k>N){var j=k;k=N,N=j}var P=b[k];P||(b[k]=P={}),P[N]=!0}function c(b,k,N){if(k>N){var j=k;k=N,N=j}return e.has(b[k],N)}function p(b,k,N,j){var P={},O={},L={};return e.forEach(k,function(B){e.forEach(B,function(T,M){P[T]=T,O[T]=T,L[T]=M})}),e.forEach(k,function(B){var T=-1;e.forEach(B,function(M){var q=j(M);if(q.length){q=e.sortBy(q,function(U){return L[U]});for(var Y=(q.length-1)/2,X=Math.floor(Y),I=Math.ceil(Y);X<=I;++X){var H=q[X];O[M]===M&&T<L[H]&&!c(N,M,H)&&(O[H]=M,O[M]=P[M]=P[H],T=L[H])}}})}),{root:P,align:O}}function h(b,k,N,j,P){var O={},L=f(b,k,N,P),B=P?"borderLeft":"borderRight";function T(Y,X){for(var I=L.nodes(),H=I.pop(),U={};H;)U[H]?Y(H):(U[H]=!0,I.push(H),I=I.concat(X(H))),H=I.pop()}function M(Y){O[Y]=L.inEdges(Y).reduce(function(X,I){return Math.max(X,O[I.v]+L.edge(I))},0)}function q(Y){var X=L.outEdges(Y).reduce(function(H,U){return Math.min(H,O[U.w]-L.edge(U))},Number.POSITIVE_INFINITY),I=b.node(Y);X!==Number.POSITIVE_INFINITY&&I.borderType!==B&&(O[Y]=Math.max(O[Y],X))}return T(M,L.predecessors.bind(L)),T(q,L.successors.bind(L)),e.forEach(j,function(Y){O[Y]=O[N[Y]]}),O}function f(b,k,N,j){var P=new n,O=b.graph(),L=_(O.nodesep,O.edgesep,j);return e.forEach(k,function(B){var T;e.forEach(B,function(M){var q=N[M];if(P.setNode(q),T){var Y=N[T],X=P.edge(Y,q);P.setEdge(Y,q,Math.max(L(b,M,T),X||0))}T=M})}),P}function m(b,k){return e.minBy(e.values(k),function(N){var j=Number.NEGATIVE_INFINITY,P=Number.POSITIVE_INFINITY;return e.forIn(N,function(O,L){var B=S(b,L)/2;j=Math.max(O+B,j),P=Math.min(O-B,P)}),j-P})}function y(b,k){var N=e.values(k),j=e.min(N),P=e.max(N);e.forEach(["u","d"],function(O){e.forEach(["l","r"],function(L){var B=O+L,T=b[B],M;if(T!==k){var q=e.values(T);M=L==="l"?j-e.min(q):P-e.max(q),M&&(b[B]=e.mapValues(T,function(Y){return Y+M}))}})})}function x(b,k){return e.mapValues(b.ul,function(N,j){if(k)return b[k.toLowerCase()][j];var P=e.sortBy(e.map(b,j));return(P[1]+P[2])/2})}function C(b){var k=r.buildLayerMatrix(b),N=e.merge(s(b,k),o(b,k)),j={},P;e.forEach(["u","d"],function(L){P=L==="u"?k:e.values(k).reverse(),e.forEach(["l","r"],function(B){B==="r"&&(P=e.map(P,function(Y){return e.values(Y).reverse()}));var T=(L==="u"?b.predecessors:b.successors).bind(b),M=p(b,P,N,T),q=h(b,P,M.root,M.align,B==="r");B==="r"&&(q=e.mapValues(q,function(Y){return-Y})),j[L+B]=q})});var O=m(b,j);return y(j,O),x(j,b.graph().align)}function _(b,k,N){return function(j,P,O){var L=j.node(P),B=j.node(O),T=0,M;if(T+=L.width/2,e.has(L,"labelpos"))switch(L.labelpos.toLowerCase()){case"l":M=-L.width/2;break;case"r":M=L.width/2;break}if(M&&(T+=N?M:-M),M=0,T+=(L.dummy?k:b)/2,T+=(B.dummy?k:b)/2,T+=B.width/2,e.has(B,"labelpos"))switch(B.labelpos.toLowerCase()){case"l":M=B.width/2;break;case"r":M=-B.width/2;break}return M&&(T+=N?M:-M),M=0,T}}function S(b,k){return b.node(k).width}return xg}var _g,jk;function j$(){if(jk)return _g;jk=1;var e=ot(),n=an(),r=C$().positionX;_g=s;function s(l){l=n.asNonCompoundGraph(l),o(l),e.forEach(r(l),function(u,c){l.node(c).x=u})}function o(l){var u=n.buildLayerMatrix(l),c=l.graph().ranksep,p=0;e.forEach(u,function(h){var f=e.max(e.map(h,function(m){return l.node(m).height}));e.forEach(h,function(m){l.node(m).y=p+f/2}),p+=f+c})}return _g}var Sg,Rk;function R$(){if(Rk)return Sg;Rk=1;var e=ot(),n=c$(),r=d$(),s=h$(),o=an().normalizeRanks,l=p$(),u=an().removeEmptyRanks,c=m$(),p=g$(),h=v$(),f=N$(),m=j$(),y=an(),x=Zn().Graph;Sg=C;function C(D,Q){var ee=Q&&Q.debugTiming?y.time:y.notime;ee("layout",function(){var oe=ee(" buildLayoutGraph",function(){return T(D)});ee(" runLayout",function(){_(oe,ee)}),ee(" updateInputGraph",function(){S(D,oe)})})}function _(D,Q){Q(" makeSpaceForEdgeLabels",function(){M(D)}),Q(" removeSelfEdges",function(){F(D)}),Q(" acyclic",function(){n.run(D)}),Q(" nestingGraph.run",function(){c.run(D)}),Q(" rank",function(){s(y.asNonCompoundGraph(D))}),Q(" injectEdgeLabelProxies",function(){q(D)}),Q(" removeEmptyRanks",function(){u(D)}),Q(" nestingGraph.cleanup",function(){c.cleanup(D)}),Q(" normalizeRanks",function(){o(D)}),Q(" assignRankMinMax",function(){Y(D)}),Q(" removeEdgeLabelProxies",function(){X(D)}),Q(" normalize.run",function(){r.run(D)}),Q(" parentDummyChains",function(){l(D)}),Q(" addBorderSegments",function(){p(D)}),Q(" order",function(){f(D)}),Q(" insertSelfEdges",function(){G(D)}),Q(" adjustCoordinateSystem",function(){h.adjust(D)}),Q(" position",function(){m(D)}),Q(" positionSelfEdges",function(){E(D)}),Q(" removeBorderNodes",function(){J(D)}),Q(" normalize.undo",function(){r.undo(D)}),Q(" fixupEdgeLabelCoords",function(){U(D)}),Q(" undoCoordinateSystem",function(){h.undo(D)}),Q(" translateGraph",function(){I(D)}),Q(" assignNodeIntersects",function(){H(D)}),Q(" reversePoints",function(){ne(D)}),Q(" acyclic.undo",function(){n.undo(D)})}function S(D,Q){e.forEach(D.nodes(),function(ee){var oe=D.node(ee),ue=Q.node(ee);oe&&(oe.x=ue.x,oe.y=ue.y,Q.children(ee).length&&(oe.width=ue.width,oe.height=ue.height))}),e.forEach(D.edges(),function(ee){var oe=D.edge(ee),ue=Q.edge(ee);oe.points=ue.points,e.has(ue,"x")&&(oe.x=ue.x,oe.y=ue.y)}),D.graph().width=Q.graph().width,D.graph().height=Q.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],k={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"],L={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},B=["labelpos"];function T(D){var Q=new x({multigraph:!0,compound:!0}),ee=se(D.graph());return Q.setGraph(e.merge({},k,$(ee,b),e.pick(ee,N))),e.forEach(D.nodes(),function(oe){var ue=se(D.node(oe));Q.setNode(oe,e.defaults($(ue,j),P)),Q.setParent(oe,D.parent(oe))}),e.forEach(D.edges(),function(oe){var ue=se(D.edge(oe));Q.setEdge(oe,e.merge({},L,$(ue,O),e.pick(ue,B)))}),Q}function M(D){var Q=D.graph();Q.ranksep/=2,e.forEach(D.edges(),function(ee){var oe=D.edge(ee);oe.minlen*=2,oe.labelpos.toLowerCase()!=="c"&&(Q.rankdir==="TB"||Q.rankdir==="BT"?oe.width+=oe.labeloffset:oe.height+=oe.labeloffset)})}function q(D){e.forEach(D.edges(),function(Q){var ee=D.edge(Q);if(ee.width&&ee.height){var oe=D.node(Q.v),ue=D.node(Q.w),ge={rank:(ue.rank-oe.rank)/2+oe.rank,e:Q};y.addDummyNode(D,"edge-proxy",ge,"_ep")}})}function Y(D){var Q=0;e.forEach(D.nodes(),function(ee){var oe=D.node(ee);oe.borderTop&&(oe.minRank=D.node(oe.borderTop).rank,oe.maxRank=D.node(oe.borderBottom).rank,Q=e.max(Q,oe.maxRank))}),D.graph().maxRank=Q}function X(D){e.forEach(D.nodes(),function(Q){var ee=D.node(Q);ee.dummy==="edge-proxy"&&(D.edge(ee.e).labelRank=ee.rank,D.removeNode(Q))})}function I(D){var Q=Number.POSITIVE_INFINITY,ee=0,oe=Number.POSITIVE_INFINITY,ue=0,ge=D.graph(),de=ge.marginx||0,Ie=ge.marginy||0;function He(Pe){var Ae=Pe.x,ke=Pe.y,Ye=Pe.width,ve=Pe.height;Q=Math.min(Q,Ae-Ye/2),ee=Math.max(ee,Ae+Ye/2),oe=Math.min(oe,ke-ve/2),ue=Math.max(ue,ke+ve/2)}e.forEach(D.nodes(),function(Pe){He(D.node(Pe))}),e.forEach(D.edges(),function(Pe){var Ae=D.edge(Pe);e.has(Ae,"x")&&He(Ae)}),Q-=de,oe-=Ie,e.forEach(D.nodes(),function(Pe){var Ae=D.node(Pe);Ae.x-=Q,Ae.y-=oe}),e.forEach(D.edges(),function(Pe){var Ae=D.edge(Pe);e.forEach(Ae.points,function(ke){ke.x-=Q,ke.y-=oe}),e.has(Ae,"x")&&(Ae.x-=Q),e.has(Ae,"y")&&(Ae.y-=oe)}),ge.width=ee-Q+de,ge.height=ue-oe+Ie}function H(D){e.forEach(D.edges(),function(Q){var ee=D.edge(Q),oe=D.node(Q.v),ue=D.node(Q.w),ge,de;ee.points?(ge=ee.points[0],de=ee.points[ee.points.length-1]):(ee.points=[],ge=ue,de=oe),ee.points.unshift(y.intersectRect(oe,ge)),ee.points.push(y.intersectRect(ue,de))})}function U(D){e.forEach(D.edges(),function(Q){var ee=D.edge(Q);if(e.has(ee,"x"))switch((ee.labelpos==="l"||ee.labelpos==="r")&&(ee.width-=ee.labeloffset),ee.labelpos){case"l":ee.x-=ee.width/2+ee.labeloffset;break;case"r":ee.x+=ee.width/2+ee.labeloffset;break}})}function ne(D){e.forEach(D.edges(),function(Q){var ee=D.edge(Q);ee.reversed&&ee.points.reverse()})}function J(D){e.forEach(D.nodes(),function(Q){if(D.children(Q).length){var ee=D.node(Q),oe=D.node(ee.borderTop),ue=D.node(ee.borderBottom),ge=D.node(e.last(ee.borderLeft)),de=D.node(e.last(ee.borderRight));ee.width=Math.abs(de.x-ge.x),ee.height=Math.abs(ue.y-oe.y),ee.x=ge.x+ee.width/2,ee.y=oe.y+ee.height/2}}),e.forEach(D.nodes(),function(Q){D.node(Q).dummy==="border"&&D.removeNode(Q)})}function F(D){e.forEach(D.edges(),function(Q){if(Q.v===Q.w){var ee=D.node(Q.v);ee.selfEdges||(ee.selfEdges=[]),ee.selfEdges.push({e:Q,label:D.edge(Q)}),D.removeEdge(Q)}})}function G(D){var Q=y.buildLayerMatrix(D);e.forEach(Q,function(ee){var oe=0;e.forEach(ee,function(ue,ge){var de=D.node(ue);de.order=ge+oe,e.forEach(de.selfEdges,function(Ie){y.addDummyNode(D,"selfedge",{width:Ie.label.width,height:Ie.label.height,rank:de.rank,order:ge+ ++oe,e:Ie.e,label:Ie.label},"_se")}),delete de.selfEdges})})}function E(D){e.forEach(D.nodes(),function(Q){var ee=D.node(Q);if(ee.dummy==="selfedge"){var oe=D.node(ee.e.v),ue=oe.x+oe.width/2,ge=oe.y,de=ee.x-ue,Ie=oe.height/2;D.setEdge(ee.e,ee.label),D.removeNode(Q),ee.label.points=[{x:ue+2*de/3,y:ge-Ie},{x:ue+5*de/6,y:ge-Ie},{x:ue+de,y:ge},{x:ue+5*de/6,y:ge+Ie},{x:ue+2*de/3,y:ge+Ie}],ee.label.x=ee.x,ee.label.y=ee.y}})}function $(D,Q){return e.mapValues(e.pick(D,Q),Number)}function se(D){var Q={};return e.forEach(D,function(ee,oe){Q[oe.toLowerCase()]=ee}),Q}return Sg}var bg,Tk;function T$(){if(Tk)return bg;Tk=1;var e=ot(),n=an(),r=Zn().Graph;bg={debugOrdering:s};function s(o){var l=n.buildLayerMatrix(o),u=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(c){u.setNode(c,{label:c}),u.setParent(c,"layer"+o.node(c).rank)}),e.forEach(o.edges(),function(c){u.setEdge(c.v,c.w,{},c.name)}),e.forEach(l,function(c,p){var h="layer"+p;u.setNode(h,{rank:"same"}),e.reduce(c,function(f,m){return u.setEdge(f,m,{style:"invis"}),m})}),u}return bg}var kg,Ak;function A$(){return Ak||(Ak=1,kg="0.8.5"),kg}var Eg,Ik;function I$(){return Ik||(Ik=1,Eg={graphlib:Zn(),layout:R$(),debug:T$(),util:{time:an().time,notime:an().notime},version:A$()}),Eg}var M$=I$();const Mk=Xg(M$),xi=240,Zi=130,Ws=74,vu=72,Pk=Ws+vu;function P$(e){let n=xi;for(const r of e.values())n=Math.max(n,r.width);return n}const EC=420,O$=2;function ia(e){var r;return((r=e.data)==null?void 0:r.sessionId)??"_default"}function Ok(e,n){return((n==null?void 0:n.get(e))??0)>0?EC:0}function qk(e,n){const r=(n==null?void 0:n.get(e))??0;return r>0?6+r*36:0}function q$(e,n,r,s,o,l){const u=new Mk.graphlib.Graph;u.setDefaultEdgeLabel(()=>({})),u.setGraph({rankdir:r,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const c=e.filter(b=>!o.has(b)),p=new Set(c);for(const b of c){const k=s.get(b);u.setNode(b,{width:((k==null?void 0:k.width)??xi)+Ok(b,l),height:Math.max((k==null?void 0:k.height)??Zi,qk(b,l))})}for(const b of n)p.has(b.source)&&p.has(b.target)&&u.setEdge(b.source,b.target);Mk.layout(u);const h=new Map;let f=1/0,m=1/0,y=-1/0,x=-1/0;for(const b of c){const k=u.node(b);if(!k)continue;const N=s.get(b),j=(N==null?void 0:N.width)??xi,P=(N==null?void 0:N.height)??Zi,O=j+Ok(b,l),L=Math.max(P,qk(b,l)),B=k.x-O/2,T=k.y-L/2;h.set(b,{x:B,y:T}),B<f&&(f=B),T<m&&(m=T),B+j>y&&(y=B+j),T+P>x&&(x=T+P)}if(Number.isFinite(f)&&Number.isFinite(m))for(const[b,k]of h)h.set(b,{x:k.x-f,y:k.y-m});const C=Number.isFinite(y)?y-f:0,_=Number.isFinite(x)?x-m:0;let S=null;for(const b of e){const k=o.get(b);if(!k)continue;const N=s.get(b),j=(N==null?void 0:N.width)??xi,P=(N==null?void 0:N.height)??Zi;S=S===null?{minX:k.x,minY:k.y,maxX:k.x+j,maxY:k.y+P}:{minX:Math.min(S.minX,k.x),minY:Math.min(S.minY,k.y),maxX:Math.max(S.maxX,k.x+j),maxY:Math.max(S.maxY,k.y+P)}}return{positions:h,width:C,height:_,pinnedBox:S}}function L$(e,n,r={}){const s=r.direction??"LR",o=r.pinned??new Map,l=r.measured??new Map,u=r.lanes,c=new Map;for(const b of e){const k=ia(b),N=c.get(k);N?N.push(b.id):c.set(k,[b.id])}const h=Array.from(c.keys()).sort().map(b=>({sid:b,...q$(c.get(b),n,s,l,o,u)})),f=P$(l),m=r.availableHeight&&r.availableHeight>0?r.availableHeight:Number.POSITIVE_INFINITY,y=b=>{const k=[[]];let N=0;for(const j of h)k.length<b&&N>0&&N+j.height>m&&(k.push([]),N=0),k[k.length-1].push(j),N+=j.height+Pk;return k},x=b=>b.reduce((k,N)=>Math.max(k,N.width),0)+EC;let C=y(r.availableWidth?O$:1);C.length>1&&C.reduce((k,N)=>k+x(N),0)+f*(C.length-1)>(r.availableWidth??0)&&(C=y(1));const _=new Map;let S=0;for(const b of C){const k=x(b);let N=0;for(const{positions:j,height:P,pinnedBox:O}of b){for(const[B,T]of j)_.set(B,{x:T.x+S,y:T.y+N});let L=N+P;O&&O.maxY>L&&O.minX<S+k&&S<O.maxX&&(L=O.maxY),N=L+Pk}S+=k+f}return e.map(b=>{const k=o.get(b.id);if(k)return{...b,position:k};const N=_.get(b.id);return N?{...b,position:N}:b})}function $$(e,n,r,s){const l=Ws+vu,u=60,c=y=>{const x=s.get(y);return{w:(x==null?void 0:x.width)??xi,h:(x==null?void 0:x.height)??Zi}},p=new Map(e.map(y=>[y.id,ia(y)])),h=[],f=e.map(y=>({id:y.id,pos:r.get(y.id)??n.get(y.id)})).filter(y=>y.pos!=null).sort((y,x)=>y.pos.y-x.pos.y||y.pos.x-x.pos.x||y.id.localeCompare(x.id)),m=[];for(const{id:y,pos:x}of f){const{w:C,h:_}=c(y),S=p.get(y)??"_default";if(r.has(y)){h.push({x:x.x,y:x.y,w:C,h:_,sid:S});continue}let b=x.y;for(let k=0;k<h.length+1;k++){const N=h.find(j=>{const P=j.sid===S?24:u,O=j.sid===S?24:l;return x.x<j.x+j.w+P&&j.x<x.x+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!==x.y&&(n.set(y,{x:x.x,y:b}),m.push(y)),h.push({x:x.x,y:b,w:C,h:_,sid:S})}return m}function D$(e,n,r,s,o){const l=C=>{const _=s.get(C);return{w:(_==null?void 0:_.width)??xi,h:(_==null?void 0:_.height)??Zi}},u=C=>r.get(C)??n.get(C),c=new Map;for(const C of e){if(!u(C.id))continue;const _=ia(C),S=c.get(_);S?S.push(C):c.set(_,[C])}const p=new Set;for(const[C,_]of c)_.every(S=>o.has(S.id)&&!r.has(S.id))&&p.add(C);const h=new Map,f=[];for(const C of e){const _=u(C.id);if(!_)continue;const{w:S,h:b}=l(C.id),k=ia(C);p.has(k)?(h.get(k)??h.set(k,[]).get(k)).push(C):f.push({x:_.x,y:_.y,w:S,h:b})}if(h.size===0)return[];const m=Ws+vu,y=(C,_,S,b)=>f.some(k=>C<k.x+k.w+Ws&&k.x<C+S+Ws&&_<k.y+k.h+m&&k.y<_+b+m),x=[];for(const C of[...h.keys()].sort()){const _=h.get(C);let S=1/0,b=1/0,k=-1/0,N=-1/0;for(const M of _){const q=u(M.id),{w:Y,h:X}=l(M.id);S=Math.min(S,q.x),b=Math.min(b,q.y),k=Math.max(k,q.x+Y),N=Math.max(N,q.y+X)}const j=k-S,P=N-b,O=[...new Set(f.map(M=>Math.round(M.x)))].sort((M,q)=>M-q),L=O.length?O:[S],B=[0,...f.map(M=>M.y+M.h+m)].sort((M,q)=>M-q);let T=null;e:for(const M of L)for(const q of B){if(q>=b)break;if(!y(M,q,j,P)){T={x:M,y:q};break e}}if(T){const M=T.x-S,q=T.y-b;for(const Y of _){const X=u(Y.id);n.set(Y.id,{x:X.x+M,y:X.y+q})}x.push(C)}for(const M of _){const q=u(M.id),{w:Y,h:X}=l(M.id);f.push({x:q.x,y:q.y,w:Y,h:X})}}return x}function F$(e,n,r,s,o,l=!1){const p=Ws+vu+1,h=8,f=1.75,m=200,y=.7,x=.01,C=T=>{const M=s.get(T);return{w:(M==null?void 0:M.width)??xi,h:(M==null?void 0:M.height)??Zi}},_=T=>r.get(T)??n.get(T),S=new Map;for(const T of e){if(!_(T.id))continue;const M=ia(T),q=S.get(M);q?q.push(T):S.set(M,[T])}const b=[],k=new Set,N=new Set,j=o.size===0;for(const T of[...S.keys()].sort()){const M=S.get(T);let q=1/0,Y=1/0,X=-1/0,I=-1/0,H=!1;for(const F of M){const G=_(F.id),{w:E,h:$}=C(F.id);q=Math.min(q,G.x),Y=Math.min(Y,G.y),X=Math.max(X,G.x+E),I=Math.max(I,G.y+$),r.has(F.id)&&(H=!0)}const U=X-q,ne=I-Y;N.add(T);const J=o.get(T);J&&(U>J.w+h||ne>J.h+h)&&k.add(T),o.set(T,{w:U,h:ne}),b.push({sid:T,members:M.map(F=>F.id),x:q,y:Y,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 q=b[T],Y=b[M];if(!(q.anchored&&Y.anchored)&&Math.abs(q.x+q.w/2-(Y.x+Y.w/2))<(q.w+Y.w)/2+61&&Math.abs(q.y+q.h/2-(Y.y+Y.h/2))<(q.h+Y.h)/2+p){P=!0;break}}if(k.size===0&&!P)return[];if(k.size>0)for(const T of b)k.has(T.sid)&&(T.mass=8);else for(const T of b)T.mass=Math.max(1,T.w*T.h/(xi*Zi));const O=new Map(b.map(T=>[T.sid,T.x])),L=new Map(b.map(T=>[T.sid,T.y]));for(let T=0;T<m;T++){const M=new Map,q=new Map;let Y=0;for(let X=0;X<b.length;X++)for(let I=X+1;I<b.length;I++){const H=b[X],U=b[I];if(H.anchored&&U.anchored)continue;const ne=H.x+H.w/2,J=H.y+H.h/2,F=U.x+U.w/2,G=U.y+U.h/2,E=(H.w+U.w)/2+61-Math.abs(ne-F),$=(H.h+U.h)/2+p-Math.abs(J-G);if(E<=0||$<=0)continue;const se=(We,$e)=>!We.anchored&&!($e<0&&We.x<=0),D=(We,$e)=>!We.anchored&&!($e<0&&We.y<=0),Q=(We,$e,it)=>{const vt=We===$e,tt=vt?H.sid<U.sid?-1:1:Math.sign(We-$e);return it(H,tt)||it(U,-tt)?tt:vt&&(it(H,-tt)||it(U,tt))?-tt:0},ee=Q(ne,F,se),oe=Q(J,G,D),ue=ee!==0,ge=oe!==0;if(!ue&&!ge)continue;const de=ue&&(!ge||E*f<$),[Ie,He,Pe,Ae]=de?[ee,E,M,se]:[oe,$,q,D],ke=Ae(H,Ie),Ye=Ae(U,-Ie),ve=H.mass,we=U.mass,Ve=ke?Ye?we/(ve+we):1:0,at=Ye?ke?ve/(ve+we):1:0,lt=He*y;Pe.set(H.sid,(Pe.get(H.sid)??0)+Ie*lt*Ve),Pe.set(U.sid,(Pe.get(U.sid)??0)-Ie*lt*at),Y+=lt}for(const X of b)X.anchored||(X.x=Math.max(0,X.x+(M.get(X.sid)??0)),X.y=Math.max(0,X.y+(q.get(X.sid)??0)));if(Y<x)break}const B=[];for(const T of b){const M=T.x-O.get(T.sid),q=T.y-L.get(T.sid);if(!(Math.abs(M)<1&&Math.abs(q)<1)){for(const Y of T.members){if(r.has(Y))continue;const X=n.get(Y);X&&n.set(Y,{x:X.x+M,y:X.y+q})}B.push(T.sid)}}return B}const z$=600;function Gg(e,n){return!(e.exitAt!=null&&n-e.exitAt>z$||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function B$(e,n){const r=new Set;for(const s of e.agents.values())Gg(s,n)&&r.add(s.id);return r}function U$(e,n,r=0){return e.right+r>n.left&&e.left-r<n.right&&e.bottom+r>n.top&&e.top-r<n.bottom}function H$(e,n,r=0){if(!e)return!1;for(const s of n)if(U$(e,s,r))return!0;return!1}function Wi(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function V$(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}const W$={agent:qP,sessionGroup:GP},G$=420,Tl=18,Y$=9e4,K$=200,X$=5*6e4,Q$=6,Z$=2*6e4,Ov="agent-dag.layout",qv="agent-dag.viewport",NC="agent-dag.summariesDismissed",CC="agent-dag.sessionListOpen",jC="agent-dag.detailOpen",RC="agent-dag.usagePanelOpen",Lk="agent-dag.accountsPanelOpen",$k="agent-dag.versionNoticeDismissed",J$=15*6e4,Dk={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 e4(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 Fk="agent-dag.autoRestart",zk="agent-dag.bundleReloadedFor";function t4(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(CC)==="1"}catch{return!1}}function n4(e){if(!(typeof window>"u"))try{window.localStorage.setItem(CC,e?"1":"0")}catch{}}function r4(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(jC)==="1"}catch{return!1}}function i4(e){if(!(typeof window>"u"))try{window.localStorage.setItem(jC,e?"1":"0")}catch{}}function s4(){if(typeof window>"u")return!0;const e=window.localStorage.getItem(RC);try{return e===null?!0:e==="1"}catch{return!0}}function o4(e){if(!(typeof window>"u"))try{window.localStorage.setItem(RC,e?"1":"0")}catch{}}function a4(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(NC);if(!e)return new Set;const n=JSON.parse(e);return new Set(Array.isArray(n)?n.filter(r=>typeof r=="string"):[])}catch{return new Set}}function Bk(e){if(!(typeof window>"u"))try{const n=Array.from(e),r=n.length>200?n.slice(-200):n;window.localStorage.setItem(NC,JSON.stringify(r))}catch{}}function l4(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(Ov);if(!n)return e;const r=JSON.parse(n);if(!("v"in r)){const o=Object.entries(r).filter(([,l])=>l&&typeof l.x=="number"&&typeof l.y=="number");return{positions:o,pins:o.map(([l])=>l)}}return{positions:Object.entries(r.positions??{}).filter(([,o])=>o&&typeof o.x=="number"&&typeof o.y=="number"),pins:Array.isArray(r.pins)?r.pins:[]}}catch{return e}}function Ng(e,n){if(!(typeof window>"u"))try{const r={};for(const[s,o]of e)r[s]=o;for(const[s,o]of n)r[s]=o;window.localStorage.setItem(Ov,JSON.stringify({v:2,positions:r,pins:Array.from(n.keys())}))}catch{}}function u4(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(qv);if(!e)return null;const n=JSON.parse(e);return typeof(n==null?void 0:n.x)!="number"||typeof(n==null?void 0:n.y)!="number"||typeof(n==null?void 0:n.zoom)!="number"?null:n}catch{return null}}function c4(e){if(!(typeof window>"u"))try{window.localStorage.setItem(qv,JSON.stringify(e))}catch{}}function Uk(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Ov)}catch{}try{window.localStorage.removeItem(qv)}catch{}}}function d4(e,n){const r=e.agents.get(n);if(!r)return;const s=[];for(const f of e.agents.values())f.sessionId===n&&s.push(f);const o={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:n,label:r.label,cwd:r.cwd,startedAt:r.startedAt,endedAt:r.endedAt,model:r.model,agents:s.map(f=>({id:f.id,kind:f.kind,label:f.label,parentId:f.parentId,state:f.state,startedAt:f.startedAt,endedAt:f.endedAt,model:f.model,cwd:f.cwd,usage:f.usage,prompts:f.prompts,tools:f.tools.map(m=>({id:m.id,name:m.name,inputPreview:m.inputPreview,startedAt:m.startedAt,endedAt:m.endedAt,ok:m.ok,errorPreview:m.errorPreview,usage:m.usage}))}))},l=JSON.stringify(o,null,2),u=new Blob([l],{type:"application/json"}),c=URL.createObjectURL(u),p=document.createElement("a"),h=(r.label||"session").replace(/[^a-z0-9._-]/gi,"_");p.href=c,p.download=`agents-deck-${h}-${n.slice(0,8)}.json`,document.body.appendChild(p),p.click(),document.body.removeChild(p),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const Yg={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"},f4={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 TC(e){return e.startsWith("mcp__")?"mcp":f4[e]??"other"}function AC(e,n){var s,o,l;if(!n)return!0;const r=n.toLowerCase();if(e.label.toLowerCase().includes(r)||(s=e.cwd)!=null&&s.toLowerCase().includes(r)||(o=e.cwdBasename)!=null&&o.toLowerCase().includes(r)||e.sessionId.toLowerCase().includes(r)||(l=e.firstPrompt)!=null&&l.toLowerCase().includes(r))return!0;for(const u of e.tools)if(u.name.toLowerCase().includes(r))return!0;return!1}function h4(e,n){if(!n)return null;const r=new Set([n]);let s=n;for(;s;){const l=e.agents.get(s);if(!(l!=null&&l.parentId)||r.has(l.parentId))break;r.add(l.parentId),s=l.parentId}let o=!0;for(;o;){o=!1;for(const l of e.agents.values())l.parentId&&r.has(l.parentId)&&!r.has(l.id)&&(r.add(l.id),o=!0)}return r}function p4(e,n,r,s,o,l,u,c,p,h,f,m,y,x,C,_,S,b){const k=[],N=[],j=new Set;if(l)for(const M of e.agents.values())AC(M,l)&&j.add(M.id);for(const M of e.agents.values()){if(!S.has(M.id))continue;const q=l?!j.has(M.id):!1,Y=M.exitAt!=null,X=_!=null&&!_.has(M.id),I=[q?"rf-dim":"",Y?"rf-exiting":"",X?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,H=u.get(M.id);if(k.push({id:M.id,type:"agent",position:{x:0,y:0},data:{...M,now:n,dim:q,onOpenContext:b},className:I,...H?{width:H.width,height:H.height}:null}),M.parentId&&S.has(M.parentId)){const U=mv(M.sessionId),ne=M.state==="active"?`hsl(${U} 80% 72%)`:`hsl(${U} 50% 55%)`,J=l&&!j.has(M.id)&&!j.has(M.parentId),F=Y,G=C.size>0&&(C.has(M.id)||C.has(M.parentId)),E=_!=null&&!_.has(M.id)&&!_.has(M.parentId),$=M.state==="active"?2:1.5,se=G?$+1.5:$,D=J||F?.2:E?.12:1,Q=[F?"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)&&!J&&!F,type:"smoothstep",style:{stroke:ne,strokeWidth:se,opacity:D,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:Q})}}const P=new Map;for(const M of e.agents.values())M.tools.length>0&&P.set(M.id,Math.min(4,M.tools.length));const O=k.filter(M=>!o.has(M.id)&&!m.has(M.id));if(O.length>0||y!==x.current){if(O.length>0){const M=L$(k,N,{direction:"LR",pinned:o,measured:u,availableWidth:r,availableHeight:s,lanes:P});for(const q of M)m.has(q.id)||m.set(q.id,q.position);D$(k,m,o,u,new Set(O.map(q=>q.id)))}$$(k,m,o,u),x.current=y}const L=F$(k,m,o,u,c,!h||f);L.length>0&&p(L),ad(m,e.agents),ad(o,e.agents),ad(u,lO(e.agents.values()));const B=[];let T=!1;for(const M of k){let q=o.get(M.id)??m.get(M.id);q||(q={x:0,y:0},m.set(M.id,q),T=!0),B.push({...M,position:q})}return T&&(x.current=""),{nodes:B,edges:N}}function m4(){return g.jsx(hv,{children:g.jsx(g4,{})})}function g4(){var Kr,Xr,_r,Ti;const e=ua(),n=A.useRef(Ug()),[,r]=A.useState(0),s=A.useCallback(()=>r(W=>W+1),[]),[o,l]=A.useState(()=>new Set),[u,c]=A.useState(null),[p,h]=A.useState(null),f=A.useCallback((W,K)=>{l(le=>{if(!K)return new Set([W]);const ce=new Set(le);return ce.has(W)?ce.delete(W):ce.add(W),ce}),c(le=>K&&le===W?le:W)},[]),m=A.useCallback(()=>{l(new Set),c(null)},[]),[y,x]=A.useState(null),[C,_]=A.useState(null),S=A.useCallback(W=>_(W),[]),b=A.useRef(a4()),[k,N]=A.useState(t4);A.useEffect(()=>{n4(k)},[k]);const[j,P]=A.useState(r4);A.useEffect(()=>{i4(j)},[j]);const[O,L]=A.useState(s4);A.useEffect(()=>{o4(O)},[O]);const[B,T]=A.useState(()=>{try{const W=window.localStorage.getItem(Lk);return W===null?!0:W==="1"}catch{return!0}});A.useEffect(()=>{try{window.localStorage.setItem(Lk,B?"1":"0")}catch{}},[B]);const[M,q]=A.useState(null),[Y,X]=A.useState(!1),[I,H]=A.useState(0),[U,ne]=A.useState(0);A.useEffect(()=>{fetch("/api/sound-hook").then(W=>W.ok?W.json():null).then(W=>{W!=null&&W.ok&&(q(W.enabled===!0),H((W.foreign??[]).filter(K=>K.worksHere).length),ne(typeof W.parked=="number"?W.parked:0))}).catch(()=>{})},[]);const J=A.useCallback(async()=>{X(!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&&q(K.enabled===!0),fetch("/api/sound-hook").then(le=>le.ok?le.json():null).then(le=>{le!=null&&le.ok&&(H((le.foreign??[]).filter(ce=>ce.worksHere).length),ne(typeof le.parked=="number"?le.parked:0))}).catch(()=>{})}catch{}finally{X(!1)}},[M]),[F,G]=A.useState(!1),[E,$]=A.useState(null),[se,D]=A.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem($k)??""}catch{return""}}),[Q,ee]=A.useState(!1),oe=A.useRef(0),ue=A.useCallback((W=!1)=>{W&&(oe.current=Date.now()),fetch(W?"/api/version?refresh=1":"/api/version").then(K=>K.ok?K.json():null).then(K=>{K&&$(K)}).catch(()=>{})},[]),ge=A.useCallback(()=>{ue(Date.now()-oe.current>=J$)},[ue]);A.useEffect(()=>{ue();const W=window.setInterval(ge,5*6e4),K=()=>{document.visibilityState==="visible"&&ge()};return document.addEventListener("visibilitychange",K),()=>{window.clearInterval(W),document.removeEventListener("visibilitychange",K)}},[ue,ge]),A.useEffect(()=>{F&&ue()},[F,ue]);const de=(E==null?void 0:E.notice)??null,Ie=de?`${de.kind}:${de.to}`:"",He=de!=null&&se!==Ie,Pe=A.useCallback(()=>{if(!de)return;const W=se===Ie?"":Ie;D(W);try{window.localStorage.setItem($k,W)}catch{}},[de,Ie,se]),Ae=((Kr=E==null?void 0:E.upgrade)==null?void 0:Kr.state)??"idle",ke=A.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}ue()},[ue]);A.useEffect(()=>{if(Ae!=="running")return;const W=window.setInterval(ue,3e3);return()=>window.clearInterval(W)},[Ae,ue]);const Ye=A.useCallback(async()=>{var le;const W=E==null?void 0:E.command;if(!W)return;let K=!1;try{K=await Promise.race([((le=navigator.clipboard)==null?void 0:le.writeText(W).then(()=>!0))??Promise.resolve(!1),new Promise(ce=>window.setTimeout(()=>ce(!1),500))])}catch{K=!1}if(!K)try{const ce=document.createElement("textarea");ce.value=W,ce.setAttribute("readonly",""),ce.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(ce),ce.select(),K=document.execCommand("copy"),ce.remove()}catch{K=!1}K&&(ee(!0),window.setTimeout(()=>ee(!1),1600))},[E==null?void 0:E.command]),ve=A.useCallback(()=>{N(W=>(W||T(!1),!W))},[]),we=A.useCallback(()=>{T(W=>(W||N(!1),!W))},[]),[Ve,at]=A.useState(!1),[lt,We]=A.useState(0),$e=A.useRef(null),[it,vt]=A.useState(!1),tt=A.useRef(null),[qt,mt]=A.useState(0),Tt=A.useRef(fO()),[At,Ze]=A.useState(!1),yt=A.useCallback(()=>{const W=Tt.current,K=W.setPaused(!W.paused);for(const le of K)n.current=Zw(n.current,le);Ze(W.paused)},[]),[Le,wt]=A.useState(Date.now()),[Bt,Ut]=A.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(Fk)!=="0"}catch{return!0}}),Lt=A.useCallback(()=>{Ut(W=>{const K=!W;try{window.localStorage.setItem(Fk,K?"1":"0")}catch{}return K})},[]),[Ht,qn]=A.useState(!1),[Ln,wn]=A.useState("restart"),[xn,ln]=A.useState(null),tr=A.useRef(!1),pr=A.useCallback(async W=>{if(tr.current)return;const K=(W==null?void 0:W.upgrade)===!0;tr.current=!0,wn(K?"npx":"restart"),qn(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(de==null?void 0:de.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:K})})}catch{}window.setTimeout(()=>{if(tr.current){tr.current=!1,qn(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},K?18e4:3e4)},[de==null?void 0:de.to]),Si=A.useRef(null);A.useEffect(()=>{let W=!1;for(const le of n.current.agents.values())if(le.state==="active"){W=!0;break}const K=oO({enabled:Bt,kind:de==null?void 0:de.kind,canRestart:(E==null?void 0:E.canRestart)===!0,busy:W,idleSince:Si.current,now:Le});Si.current=K.idleSince,K.restart&&pr()},[Bt,de==null?void 0:de.kind,E==null?void 0:E.canRestart,Le,pr]),A.useEffect(()=>{let W=null;try{W=window.sessionStorage.getItem(zk)}catch{return}if(sO({bundle:"1.33.66",running:E==null?void 0:E.running,lastTried:W})){try{window.sessionStorage.setItem(zk,(E==null?void 0:E.running)??"")}catch{return}window.location.reload()}},[E==null?void 0:E.running]),A.useEffect(()=>{const W=E==null?void 0:E.running;if(!W)return;let K=null;try{K=window.sessionStorage.getItem("agent-dag.restartPending")}catch{return}if(K==null||K&&K!==W)return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}tr.current=!1,qn(!1),ln(W);const le=window.setTimeout(()=>ln(null),6e3);return()=>window.clearTimeout(le)},[E==null?void 0:E.running]);const $r=A.useRef(l4()).current;A.useRef(!1);const St=A.useRef(new Map($r.positions.filter(([W])=>$r.pins.includes(W)))),mr=A.useRef(null),_n=A.useState(()=>u4())[0],[un,nr]=A.useState(""),[ss,gr]=A.useState(()=>new Set),[Sn,vr]=A.useState(()=>typeof window>"u"?"dark":window.localStorage.getItem("agent-dag.theme")??"dark"),[Dr,no]=A.useState(!1),os=A.useRef(null);A.useEffect(()=>{document.documentElement.dataset.theme=Sn;try{window.localStorage.setItem("agent-dag.theme",Sn)}catch{}},[Sn]),A.useEffect(()=>{if(!_n)return;const W=window.setTimeout(()=>{try{e.setViewport(_n,{duration:0})}catch{}},60);return()=>window.clearTimeout(W)},[e,_n]);const bi=A.useRef(!0);A.useEffect(()=>{const W=new EventSource("/events"),K=dO(s,{now:()=>Date.now(),setTimeout:(le,ce)=>window.setTimeout(le,ce),clearTimeout:le=>window.clearTimeout(le)});return W.addEventListener("open",()=>{G(!0),no(!0)}),W.addEventListener("error",()=>G(!1)),W.addEventListener("replay-end",()=>{bi.current=!1,K.flush()}),W.addEventListener("hook",le=>{try{const ce=JSON.parse(le.data);if(!Tt.current.accept(ce))return;n.current=Zw(n.current,ce),ce.replay===!0||bi.current||Date.now()-ce.receivedAt>3e4?K.replay():K.live()}catch{}}),()=>{W.close(),K.cancel()}},[s]),A.useEffect(()=>{const W=setInterval(()=>{const K=Date.now();wt(K);let le=bP(n.current,K,Y$);_P(n.current,K,K$,X$)&&(le=!0),SP(n.current,K,Q$,Z$)&&(le=!0),le&&s()},250);return()=>clearInterval(W)},[s]);const cn=A.useRef(null),$n=A.useRef(0),as=420,Kt=A.useCallback((W=500)=>{try{const _e=document.querySelector(".canvas-wrap"),Te=Array.from(document.querySelectorAll(".react-flow__node")).filter(ft=>ft.offsetWidth>0);if(!_e||Te.length===0)return;const De=_e.getBoundingClientRect(),Ge=e.getViewport();if(!Number.isFinite(Ge.zoom)||Ge.zoom<=0)return;const Ke=ft=>(ft-De.left-Ge.x)/Ge.zoom,Qe=ft=>(ft-De.top-Ge.y)/Ge.zoom,Wt=Te.map(ft=>ft.getBoundingClientRect()),Qr=Math.min(...Wt.map(ft=>Ke(ft.left))),It=Math.max(...Wt.map(ft=>Ke(ft.right))),kn=Math.min(...Wt.map(ft=>Qe(ft.top))),Ai=Math.max(...Wt.map(ft=>Qe(ft.bottom))),Zr=It-Qr,hs=Ai-kn;if(!(Zr>0&&hs>0))return;const pn=Math.max(.2,Math.min(1,(De.width-160)/(Zr+as)*.86,(De.height-160)/hs*.86));e.setViewport({x:80-Qr*pn,y:Math.max(80,(De.height-hs*pn)/2)-kn*pn,zoom:pn},{duration:W}),$n.current=Date.now(),window.setTimeout(()=>{try{const ft={x:80-Qr*pn,y:Math.max(80,(De.height-hs*pn)/2)-kn*pn,zoom:pn},Jr=e.getViewport();(Math.abs(Jr.zoom-pn)>.01||Math.abs(Jr.x-ft.x)>2)&&e.setViewport(ft,{duration:0})}catch{}},W+60)}catch{}},[e]),Fr=A.useRef(""),zr=A.useRef(null),ki=A.useRef(0),yr=A.useCallback(()=>{ki.current=Date.now()},[]),Br="agent-dag.autoFitDisabled",Dn=A.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Br)==="1"}catch{return!1}})()),[Je,ls]=A.useState(Dn.current),Ur=A.useCallback(()=>{if(!Dn.current){Dn.current=!0,ls(!0);try{window.localStorage.setItem(Br,"1")}catch{}}},[]),us=A.useCallback(()=>{Dn.current=!1,ls(!1);try{window.localStorage.removeItem(Br)}catch{}Kt(400)},[e,Kt]);A.useEffect(()=>{const W=setInterval(()=>{if(Dn.current||Date.now()-ki.current<800)return;const K=n.current,le=Date.now(),ce=[];for(const Ke of K.agents.values())Gg(Ke,le)&&ce.push({id:Ke.id});if(ce.length===0)return;const ye=e.getViewport(),_e=window.innerWidth-360,Te=window.innerHeight-52;let De=!1,Ge=!1;for(const{id:Ke}of ce){const Qe=Fn.current.get(Ke),Wt=St.current.get(Ke)??Xt.current.get(Ke);if(!Qe||!Wt)continue;Ge=!0;const Qr=Wt.x*ye.zoom+ye.x,It=Wt.y*ye.zoom+ye.y,kn=(Wt.x+Qe.width)*ye.zoom+ye.x,Ai=(Wt.y+Qe.height)*ye.zoom+ye.y;if(kn>0&&Qr<_e&&Ai>0&&It<Te){De=!0;break}}Ge&&!De&&Kt(600)},1500);return()=>clearInterval(W)},[e]);const rr=A.useRef(!1),Fn=A.useRef(new Map),Ei=A.useRef(0),Hr=A.useCallback(W=>{const K=Fn.current;let le=!1;for(const ce of W.nodeInternals.values()){const ye=ce.width,_e=ce.height;if(ye==null||_e==null)continue;const Te=K.get(ce.id);Te?(Math.abs(Te.height-_e)>4||Math.abs(Te.width-ye)>4)&&(K.set(ce.id,{width:ye,height:_e}),le=!0):(K.set(ce.id,{width:ye,height:_e}),le=!0)}return le&&(Ei.current+=1),Ei.current},[]),Vt=Xe(Hr),[Vr,dn]=A.useState(0);A.useEffect(()=>{let W=0;const K=()=>{const ce=Fn.current;let ye=!1;for(const _e of document.querySelectorAll(".react-flow__node[data-id]")){const Te=_e.getAttribute("data-id");if(!Te)continue;const De=_e.offsetWidth,Ge=_e.offsetHeight;if(!De||!Ge)continue;const Ke=ce.get(Te);(!Ke||Math.abs(Ke.width-De)>4||Math.abs(Ke.height-Ge)>4)&&(ce.set(Te,{width:De,height:Ge}),ye=!0)}ye&&dn(_e=>_e+1)};if(rr.current)return;let le=0;return document.visibilityState==="hidden"?le=window.setTimeout(K,32):W=requestAnimationFrame(K),()=>{cancelAnimationFrame(W),window.clearTimeout(le)}});const Xt=A.useRef(new Map($r.positions)),ro=A.useRef(""),Wr=A.useMemo(()=>{const W=[];for(const K of n.current.agents.values())Gg(K,Le)&&W.push(K.id+(K.parentId?`>${K.parentId}`:""));return W.sort(),`${W.join("|")}#sv${Vt}.${Vr}`},[n.current,n.current.lastSeq,Le,Vt,Vr]),ir=A.useRef(null);A.useEffect(()=>(ir.current!=null&&window.clearTimeout(ir.current),ir.current=window.setTimeout(()=>{Ng(Xt.current,St.current)},1500),()=>{ir.current!=null&&window.clearTimeout(ir.current)}),[Wr]),A.useEffect(()=>{if(Fr.current===Wr)return;const W=Fr.current;if(Fr.current=Wr,!W||Dn.current)return;Date.now()-$n.current>1200&&Kt(400),cn.current&&window.clearTimeout(cn.current),cn.current=window.setTimeout(()=>{Dn.current||Kt(500)},280)},[Wr,e,Kt]);const Gr=A.useMemo(()=>{if(o.size===0)return null;const W=new Set;for(const K of o){const le=h4(n.current,K);if(le)for(const ce of le)W.add(ce)}return W.size>0?W:null},[n.current,n.current.lastSeq,o]),wr=A.useMemo(()=>B$(n.current,Le),[n.current,n.current.lastSeq,Le]),Ni=A.useRef(null),[cs,ga]=A.useState({w:0,h:0});A.useEffect(()=>{const W=Ni.current;if(!W||typeof ResizeObserver>"u")return;const K=new ResizeObserver(le=>{var ye;const ce=(ye=le[0])==null?void 0:ye.contentRect;ce&&ga(_e=>Math.abs(_e.w-ce.width)>40||Math.abs(_e.h-ce.height)>40?{w:ce.width,h:ce.height}:_e)});return K.observe(W),ga({w:W.clientWidth,h:W.clientHeight}),()=>K.disconnect()},[]);const io=A.useRef(new Map),[so,oo]=A.useState(!1);A.useEffect(()=>{const W=window.setTimeout(()=>oo(!0),2500);return()=>window.clearTimeout(W)},[]);const[Ci,ao]=A.useState(!1),bn=A.useRef(null),[Fe,lo]=A.useState(!1),va=A.useCallback(()=>{bn.current&&(window.clearTimeout(bn.current),bn.current=null),ao(!1)},[]),uo=A.useCallback(W=>{W.length!==0&&queueMicrotask(()=>{ao(!0),bn.current&&window.clearTimeout(bn.current),bn.current=window.setTimeout(()=>ao(!1),G$+80)})},[]);A.useEffect(()=>()=>{bn.current&&window.clearTimeout(bn.current)},[]);const co=cs.w>0?cs.w*.92:0,fo=cs.h>0?cs.h:0,{nodes:fn,edges:ho}=A.useMemo(()=>p4(n.current,Le,co,fo,St.current,un,Fn.current,io.current,uo,so,Fe,Xt.current,Wr,ro,o,Gr,wr,S),[n.current,n.current.lastSeq,Le,co,fo,so,Fe,un,Wr,o,Gr,wr,S,lt]),ji=A.useMemo(()=>{const W=new Map;for(const le of fn){const ce=le.data;if(!(ce!=null&&ce.sessionId)||ce.exitAt!=null)continue;const ye=le.width,_e=le.height;if(ye==null||_e==null)continue;const Te=le.position.x,De=le.position.y,Ge=Te+ye,Ke=De+_e,Qe=W.get(ce.sessionId);Qe?(Qe.minX=Math.min(Qe.minX,Te),Qe.minY=Math.min(Qe.minY,De),Qe.maxX=Math.max(Qe.maxX,Ge),Qe.maxY=Math.max(Qe.maxY,Ke)):W.set(ce.sessionId,{minX:Te,minY:De,maxX:Ge,maxY:Ke})}const K=[];for(const[le,ce]of W){const ye=ce.maxX-ce.minX+Tl*2,_e=ce.maxY-ce.minY+Tl*2;K.push({id:`group:${le}`,type:"sessionGroup",position:{x:ce.minX-Tl,y:ce.minY-Tl},data:{sessionId:le,w:ye,h:_e},width:ye,height:_e,style:{width:ye,height:_e},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return K},[fn,Le]),sr=A.useMemo(()=>{const W=[...ji,...fn],K=tt.current;return!K||K.size===0?W:W.map(le=>{const ce=K.get(le.id);return ce?{...le,position:ce}:le})},[ji,fn,qt]),or=A.useMemo(()=>{if(!un)return null;const W=new Set;for(const K of n.current.agents.values())AC(K,un)&&W.add(K.id);return W},[n.current,n.current.lastSeq,un]),hn=A.useMemo(()=>{const W=new Set;for(const K of n.current.agents.values())for(const le of K.tools)W.add(TC(le.name));return Object.keys(Yg).filter(K=>W.has(K))},[n.current,n.current.lastSeq]);A.useEffect(()=>{if(hn.length<=1){vt(!1);return}let W=0;const K=()=>{const le=$e.current;if(le&&!document.hidden){const ce=le.getBoundingClientRect(),ye=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Te=>Te.getBoundingClientRect()),_e=H$(ce,ye,8);vt(Te=>Te===_e?Te:_e)}W=window.setTimeout(K,300)};return K(),()=>window.clearTimeout(W)},[hn.length]);const zn=A.useMemo(()=>{const W=new Map;for(const le of n.current.agents.values())for(const ce of le.tools){if(!ce.name.startsWith("mcp__"))continue;const ye=ce.name.slice(5),_e=ye.indexOf("__"),Te=_e>0?ye.slice(0,_e):ye;W.set(Te,(W.get(Te)??0)+1)}const K=[];for(const[le,ce]of W){let ye=5381;for(let _e=0;_e<le.length;_e++)ye=(ye<<5)+ye^le.charCodeAt(_e);K.push({server:le,count:ce,hue:Math.abs(ye)%360})}return K.sort((le,ce)=>ce.count-le.count),K},[n.current,n.current.lastSeq]),Ri=A.useCallback(W=>{gr(K=>{const le=new Set(K);return le.has(W)?le.delete(W):le.add(W),le})},[]),ut=u?n.current.agents.get(u):null,ya=p?Array.from(n.current.agents.values()).flatMap(W=>W.tools).find(W=>W.id===p)??null:null,ds=A.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=Ug(),St.current.clear(),Fn.current.clear(),Xt.current.clear(),ro.current="",Uk(),m(),s()},[s,m]),xr=A.useCallback(()=>{St.current.clear(),Xt.current.clear(),ro.current="",Uk(),s(),window.setTimeout(()=>Kt(500),80)},[s,e,Kt]),wa=A.useCallback(()=>Kt(500),[Kt]),fs=A.useCallback(W=>{if(fn.length===0)return;const K=fn.slice().sort((_e,Te)=>_e.position.y-Te.position.y||_e.position.x-Te.position.x),le=u?K.findIndex(_e=>_e.id===u):-1;let ce;le===-1?ce=W===1?0:K.length-1:ce=(le+W+K.length)%K.length;const ye=K[ce];ye&&(f(ye.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[ye]})}catch{}$n.current=Date.now()},30))},[fn,u,f,e]);A.useEffect(()=>{const W=K=>{var ce,ye;const le=((ce=K.target)==null?void 0:ce.tagName)==="INPUT";if(K.key==="Escape"){le?K.target.blur():m();return}if(!le&&!aO(K)){if(K.key==="/"){K.preventDefault(),(ye=os.current)==null||ye.focus();return}K.key===" "&&(K.preventDefault(),yt()),(K.key==="c"||K.key==="C")&&ds(),(K.key==="r"||K.key==="R")&&xr(),(K.key==="f"||K.key==="F")&&wa(),(K.key==="l"||K.key==="L")&&ve(),(K.key==="h"||K.key==="H")&&at(_e=>!_e),(K.key==="u"||K.key==="U")&&L(_e=>!_e),(K.key==="a"||K.key==="A")&&we(),(K.key==="j"||K.key==="J")&&fs(1),(K.key==="k"||K.key==="K")&&fs(-1),(K.key==="t"||K.key==="T")&&vr(_e=>_e==="dark"?"light":"dark")}};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[ds,xr,wa,m,fs,yt]);const Yr=n.current.agents.size,xa=new Set(Array.from(n.current.agents.values()).map(W=>W.sessionId)).size,Qt=A.useMemo(()=>{let W=0,K=0,le=0,ce=0,ye=0,_e=0,Te=0,De=0,Ge=0;for(const Ke of n.current.agents.values()){W+=Ke.usage.inputTokens,K+=Ke.usage.outputTokens,le+=Ke.usage.cacheReadTokens,ce+=Ke.usage.cacheCreateTokens;const Qe=on(Ke.usage,Ke.model);ye+=Qe.total,_e+=Qe.input,Te+=Qe.output,De+=Qe.cacheRead,Ge+=Qe.cacheWrite}return{inT:W,outT:K,cacheR:le,cacheC:ce,sum:W+K,cost:{total:ye,input:_e,output:Te,cacheRead:De,cacheWrite:Ge}}},[n.current,n.current.lastSeq]);return g.jsxs("div",{className:"app",children:[g.jsxs("header",{className:"topbar",children:[g.jsxs("div",{className:"brand",children:[g.jsx("span",{className:"logo"}),"agents-deck",de?g.jsxs("button",{type:"button",className:"v stale",onClick:Pe,title:de.kind==="restart"?`Running v${de.from}; v${de.to} is installed on disk. Restart to pick it up.`:`Running v${de.from}; v${de.to} is on npm.`,children:["v",de.from,g.jsx("span",{className:"v-dot","aria-hidden":!0})]}):g.jsxs("button",{type:"button",className:"v",onClick:()=>ue(!0),title:E!=null&&E.checkDisabled?"Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1).":`${E!=null&&E.latest?`npm has v${E.latest}`:"npm not reached yet"}${E!=null&&E.checkedAt?` · checked ${e4(Le-E.checkedAt)}`:""} · click to check now`,children:["v",(E==null?void 0:E.running)??"1.33.66"]})]}),ut&&(()=>{const W=on(ut.usage,ut.model),K=Math.max(0,((ut.endedAt??Le)-ut.startedAt)/1e3),le=ut.state==="active"?Vl(W.total,K):null,ce=o.size-1;return g.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${ut.label}`,onClick:()=>{try{const ye=fn.find(_e=>_e.id===ut.id);ye&&e.fitView({padding:.35,duration:500,nodes:[ye]}),$n.current=Date.now()}catch{}},children:[g.jsx("span",{className:`state-pill state-${ut.state}`,children:ut.state==="active"?"live":ut.state}),g.jsx("span",{className:"selected-label",children:ut.label}),W.total>0&&g.jsxs("span",{className:"selected-cost",children:[Be(W.total),le?g.jsxs("span",{className:"selected-rate",children:[" · ",le]}):null]}),ce>0&&g.jsxs("span",{className:"selected-extra",children:["+",ce]}),g.jsx("span",{role:"button","aria-label":"Deselect",className:"selected-close",onClick:ye=>{ye.stopPropagation(),m()},children:"×"})]})})(),g.jsxs("div",{className:"actions",children:[g.jsxs("div",{className:"search",children:[g.jsx("span",{className:"search-icon","aria-hidden":!0,children:"⌕"}),g.jsx("input",{ref:os,type:"text",placeholder:"Search agents, cwd, tools…",value:un,onChange:W=>nr(W.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),un?g.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>nr(""),children:"×"}):g.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"})]}),g.jsxs("span",{className:"status",role:"status",children:[g.jsx("span",{className:`pill ${F?"live":"dead"}`,title:F?"Receiving events":"SSE disconnected",children:F?"live":"offline"}),g.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[g.jsx("span",{className:"count",children:xa}),g.jsx("span",{className:"lbl",children:"sessions"})]}),g.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[g.jsx("span",{className:"count",children:Yr}),g.jsx("span",{className:"lbl",children:"agents"})]}),g.jsxs("span",{className:"stat",title:"Total hook events received",children:[g.jsx("span",{className:"count",children:n.current.totalEvents}),g.jsx("span",{className:"lbl",children:"events"})]}),Qt.sum>0&&g.jsxs("span",{className:"stat",title:`in:${Qt.inT.toLocaleString()} out:${Qt.outT.toLocaleString()} cache-r:${Qt.cacheR.toLocaleString()} cache-c:${Qt.cacheC.toLocaleString()}`,children:[g.jsx("span",{className:"count",children:V$(Qt.sum)}),g.jsx("span",{className:"lbl",children:"tokens"})]}),zn.length>0&&g.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
|
|
59
|
+
burn: ${y}`:"");return g.jsxs("span",{className:"cost-meta",title:x,children:[g.jsx("b",{children:Be(f.total)}),y&&g.jsx("span",{className:"cost-rate",children:y})]})})()]}),g.jsx(Xs,{type:"source",position:Ce.Right,style:{background:"transparent",border:"none"}})]})}function LP({state:e}){const n=e==="active"?"live":e==="done"?"done":"err";return g.jsx("span",{className:`state-pill state-${e}`,children:n})}function $P(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function DP({tools:e,now:n}){const l=new Array(24).fill(0);let u=0;for(const y of e){const x=n-y.startedAt;if(x<0||x>=6e4)continue;const C=23-Math.floor(x/2500);C>=0&&C<24&&(l[C]+=1,u+=1)}const c=Math.max(1,...l),p=132,h=14,f=p/24,m=c/(2500/1e3);return g.jsxs("div",{className:"tool-spark-row",title:`${u} tool calls in last 60s · peak ${m.toFixed(1)}/s`,children:[g.jsx("svg",{className:"tool-spark",width:p,height:h,viewBox:`0 0 ${p} ${h}`,"aria-hidden":!0,children:l.map((y,x)=>{const C=y===0?1.5:Math.max(1.5,y/c*h),_=x===23&&y>0,b=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return g.jsx("rect",{x:x*f+.4,y:h-C,width:Math.max(.5,f-1),height:C,rx:.8,className:b},x)})}),g.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function ca(e){const n=e.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const o=n[1][0].toUpperCase()+n[1].slice(1).toLowerCase(),l=n[2].replace(/[-_]/g,".");return`${o} ${l}`}const r=e.match(/^gpt[-_](\d+(?:[-_.]\d+)*)[-_]codex\b/i);if(r)return`GPT-${r[1].replace(/[-_]/g,".")} Codex`;const s=e.match(/^gpt[-_](\d+(?:[-_.]\d+)*)/i);return s?`GPT-${s[1].replace(/[-_]/g,".")}`:e}function ex(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function FP(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 zP({tool:e,onClose:n}){A.useEffect(()=>{const s=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]);const r=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return g.jsx("div",{className:"modal-backdrop",onClick:n,role:"dialog","aria-modal":"true",children:g.jsxs("div",{className:"modal",onClick:s=>s.stopPropagation(),children:[g.jsxs("header",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:`status-dot ${r}`}),g.jsx("span",{className:"modal-tool-name",children:e.name}),g.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",children:FP(e)}),g.jsx("button",{className:"btn icon-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),g.jsxs("section",{className:"modal-body",children:[e.trimmed&&g.jsx("div",{className:"modal-section",children:g.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),g.jsxs("div",{className:"modal-section",children:[g.jsx("h4",{children:"Input"}),g.jsx("pre",{children:ex(e.input??e.inputPreview)})]}),g.jsxs("div",{className:"modal-section",children:[g.jsxs("h4",{children:["Response ",r==="err"&&g.jsx("span",{className:"err-tag",children:"error"})]}),g.jsx("pre",{children:e.endedAt==null?"(waiting…)":ex(e.response??e.errorPreview)})]})]})]})})}const El=18,tx=26,BP=12;function UP(e){const n=new Map;for(const o of e.nodeInternals.values()){const l=o.data;if(!(l!=null&&l.sessionId)||l.exitAt!=null||o.width==null||o.height==null)continue;const u=o.position.x,c=o.position.y,p=u+o.width,h=c+o.height,f=n.get(l.sessionId);f?(f.minX=Math.min(f.minX,u),f.minY=Math.min(f.minY,c),f.maxX=Math.max(f.maxX,p),f.maxY=Math.max(f.maxY,h),l.kind==="root"&&(f.label=nx(l)??f.label)):n.set(l.sessionId,{minX:u,minY:c,maxX:p,maxY:h,label:nx(l)??l.sessionId})}const r=new Map;for(const o of n.values())r.set(o.label,(r.get(o.label)??0)+1);const s=[];for(const[o,l]of n){const c=(r.get(l.label)??0)>1?`${l.label} · ${HP(o)}`:l.label;s.push({sessionId:o,label:c,x:l.minX-El,y:l.minY-El-tx,w:l.maxX-l.minX+El*2,h:l.maxY-l.minY+El*2+tx})}return s}function HP(e){const n=e.match(/[a-zA-Z0-9]{4}/);return n?n[0]:e.slice(0,4)}function nx(e){if(e.kind==="root")return e.label}function VP(){const{x:e,y:n,zoom:r}=cN(),s=ua(),o=Xe(UP,WP);if(o.length<=1)return null;const l=u=>{try{const c=s.getNodes().filter(p=>{const h=p.data;return(h==null?void 0:h.sessionId)===u});if(c.length===0)return;s.fitView({padding:.3,duration:500,nodes:c})}catch{}};return g.jsx("div",{className:"session-clusters",children:o.map(u=>{const c=mv(u.sessionId),p={position:"absolute",left:u.x*r+e,top:u.y*r+n,width:u.w*r,height:u.h*r,borderColor:`hsl(${c} 65% 55% / 0.32)`,background:`hsl(${c} 70% 50% / 0.04)`},h={position:"absolute",left:u.x*r+e+16*r,top:(u.y-BP)*r+n,color:`hsl(${c} 70% 78%)`,borderColor:`hsl(${c} 65% 55% / 0.5)`,transform:`scale(${Math.min(1,r)})`,transformOrigin:"left top"};return g.jsxs(ae.Fragment,{children:[g.jsx("div",{className:"cluster-card",style:p,"aria-hidden":!0}),g.jsx("button",{type:"button",className:"cluster-label",style:h,title:`Fit view to ${u.label} · drag the wrapper to move the whole session`,onClick:()=>l(u.sessionId),children:u.label})]},u.sessionId)})})}function WP(e,n){if(e.length!==n.length)return!1;for(let r=0;r<e.length;r++){const s=e[r],o=n[r];if(s.sessionId!==o.sessionId||s.label!==o.label||s.x!==o.x||s.y!==o.y||s.w!==o.w||s.h!==o.h)return!1}return!0}function GP({data:e}){return g.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const xN=600,YP=36,Vg=16,KP=60,XP=6,rx=220,ix=96,QP=28,ZP={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 JP(e){return e.startsWith("mcp__")?"mcp":ZP[e]??"other"}const e3={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 sx(e){return e.startsWith("mcp__")?"🔌":e3[e]??"✨"}const t3={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 _N(e){if(!e)return null;let n=e.trim();if(!n)return null;const r=n.match(/^(?:bash|sh|zsh|fish|powershell|pwsh)(?:\.exe)?\s+(?:-c|-Command|-NoProfile|-NonInteractive|\s)+["']([^"']+)["']/i);if(r)return _N(r[1]);for(;;){const l=n.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!l)break;n=n.slice(l[0].length)}n=n.replace(/^sudo(?:\s+-\S+)*\s+/,""),n=n.replace(/^(?:time|nohup|xargs)\s+/,"");const s=n.match(/^([^\s|;&<>(]+)/);if(!s)return null;let o=s[1];return o=o.replace(/^.*[/\\]/,""),o=o.replace(/\.(exe|cmd|bat|ps1)$/i,""),o||null}function n3(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const n=e;if(typeof n.cmd=="string")return n.cmd;if(typeof n.command=="string")return n.command;if(Array.isArray(n.command)&&n.command.every(r=>typeof r=="string")){const r=n.command;if(/powershell|cmd|bash|sh(\.exe)?$/i.test(r[0]??"")){const s=r.findIndex(o=>/^(-Command|-c)$/i.test(o));if(s>=0&&s+1<r.length)return r[s+1]}return r.join(" ")}return typeof n.script=="string"?n.script:null}const r3=new Set(["Bash","PowerShell","shell","exec_command","shell_command","write_stdin","wait"]),i3=new Set(["shell","exec_command","shell_command","write_stdin","wait","apply_patch","update_plan"]);function s3(e,n){return i3.has(e)||e.startsWith("mcp__")?Math.max(ix,34+n.length*7.5):ix}function o3(e,n){if(!r3.has(e))return null;const r=n3(n);if(!r)return null;const s=_N(r);return s?{emoji:t3[s]??"⚙️",label:s,category:"shell",detail:r}:null}const a3=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),ox={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:"🗄️"},ax={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 l3(e){const r=e.replace(/\\/g,"/").replace(/\/+$/,""),s=r.lastIndexOf("/");return s>=0?r.slice(s+1):r}function u3(e){const n=e.toLowerCase();if(ax[n])return ax[n];if(n.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(n))return"🧪";const r=n.lastIndexOf(".");if(r>0&&r<n.length-1){const s=n.slice(r+1);if(ox[s])return ox[s]}return"📄"}function c3(e,n){if(!n||typeof n!="object")return null;const r=n;if(e==="apply_patch"&&typeof r.patch=="string"){const s=r.patch.match(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/m);return s?s[1].trim():null}return typeof r.file_path=="string"?r.file_path:typeof r.notebook_path=="string"?r.notebook_path:typeof r.path=="string"?r.path:e==="Glob"&&typeof r.pattern=="string"?r.pattern:null}function d3(e,n){if(!a3.has(e))return null;const r=c3(e,n);if(!r)return null;const s=l3(r);return s?{emoji:e==="LS"?"📂":u3(s),label:s,category:"file",detail:r}:null}const SN={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 bN(e){if(!e.startsWith("mcp__"))return null;const n=e.slice(5),r=n.indexOf("__");return r<=0?{server:n,method:""}:{server:n.slice(0,r),method:n.slice(r+2)}}function f3(e){let n=5381;for(let r=0;r<e.length;r++)n=(n<<5)+n^e.charCodeAt(r);return Math.abs(n)%360}function h3(e,n){const r=bN(e);if(!r)return null;const{server:s,method:o}=r;if(!o)return null;const l=SN[s.toLowerCase()];return{emoji:(l==null?void 0:l.emoji)??"🔌",label:o,category:"mcp",detail:l?`${l.name} · ${o}`:`${s} · ${o}`}}function p3(e,n){return o3(e,n)??d3(e,n)??h3(e)}const m3={shell:"Shell",exec_command:"Shell",shell_command:"Shell",write_stdin:"stdin",wait:"wait",apply_patch:"Edit",update_plan:"Plan"};function g3(e){const n=bN(e);if(n){const s=SN[n.server.toLowerCase()];return s?{emoji:s.emoji,label:s.name}:{emoji:"🔌",label:n.server,hue:f3(n.server)}}const r=m3[e];return r?{emoji:sx(e),label:r}:{emoji:sx(e),label:e}}function v3(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function y3(e,n,r){if(r==null)return 1;const s=n-r;return s<0?1:Math.max(0,1-s/xN)}function w3(e,n,r,s,o,l){const u=[];for(const c of e.values()){if(!n.has(c.id)||c.exitAt!=null&&l-c.exitAt>xN)continue;const p=s.get(c.id)??r.get(c.id);if(!p)continue;const h=c.tools.slice(-4);if(h.length===0)continue;const f=c.exitAt??null,m=o.get(c.id),y=Math.max((m==null?void 0:m.width)??rx,rx),x=(m==null?void 0:m.height)??130,C=p.x,_=p.y,S=C+y,b=_+x/2;h.forEach((k,N)=>{const j=N*YP,P=C+y+KP,O=_+XP+j,L=y3(k,l,f),B=k.inputPreview??"",T=v3(k),M=L<.999,q=g3(k.name);u.push({id:k.id,toolId:k.id,agentId:c.id,toolName:k.name,name:q.label,emoji:q.emoji,status:T,category:JP(k.name),mcpHue:q.hue,inputPreview:B,fade:L,fading:M,worldX:P,worldY:O,anchorX:S,anchorY:b,spawnDx:S-P,spawnDy:b-(O+Vg)});const Y=p3(k.name,k.input);if(Y){const X=s3(k.name,q.label),I=P+X+QP,H=O,U=P+X,ne=O+Vg;u.push({id:`sub:${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:Y.label,emoji:Y.emoji,isSub:!0,status:T,category:Y.category,inputPreview:Y.detail??B,fade:L,fading:M,worldX:I,worldY:H,anchorX:U,anchorY:ne,spawnDx:U-I,spawnDy:0})}})}return u}function x3({agents:e,visibleAgentIds:n,positions:r,pinned:s,measured:o,dimUnmatched:l,spotlight:u,hiddenCategories:c,now:p,onOpenTool:h}){const f=w3(e,n,r,s,o,p),m=c&&c.size>0?f.filter(y=>!c.has(y.category)):f;return g.jsx(_3,{bursts:m,dimUnmatched:l,spotlight:u,onOpenTool:h})}function _3({bursts:e,dimUnmatched:n,spotlight:r,onOpenTool:s}){const{x:o,y:l,zoom:u}=cN();return g.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[g.jsx("svg",{className:"tool-bursts-svg",children:e.map(c=>{const p=c.anchorX*u+o,h=c.anchorY*u+l,f=(c.worldX+6)*u+o,m=(c.worldY+Vg)*u+l,y=p+(f-p)*.55,x=n!=null&&!n.has(c.agentId),C=r!=null&&!r.has(c.agentId),_=c.fade*(x||C?.14:1);return g.jsx("path",{d:`M ${p} ${h} Q ${y} ${h}, ${f} ${m}`,className:`tool-conn status-${c.status}${c.fading?" fading":""}`,opacity:_},`l:${c.id}`)})}),e.map(c=>{const p=c.worldX*u+o,h=c.worldY*u+l,f={left:`${p}px`,top:`${h}px`,transform:`scale(${u})`,transformOrigin:"left top","--spawn-dx":`${c.spawnDx}px`,"--spawn-dy":`${c.spawnDy}px`},m=c.isSub?`${c.toolName} · ${c.name}`:c.toolName,y=c.inputPreview?`${m} · ${c.inputPreview}`:m,x=s!=null,C=c.mcpHue!=null?{"--cat-accent":`hsl(${c.mcpHue} 65% 65%)`}:{},_=n!=null&&!n.has(c.agentId),S=r!=null&&!r.has(c.agentId),b=_||S?" dim":"";return g.jsx("div",{className:"tool-burst-wrap",style:f,children:g.jsxs("div",{className:`tool-burst cat-${c.category} status-${c.status}${c.fading?" fading":""}${x?" clickable":""}${c.isSub?" sub":""}${b}`,style:C,title:y,role:x?"button":void 0,tabIndex:x?0:void 0,"aria-label":x?`Open ${c.toolName} ${c.status==="inflight"?"in flight":c.status} — click for details`:void 0,onClick:x?()=>s(c.toolId):void 0,onKeyDown:x?k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),s(c.toolId))}:void 0,children:[g.jsx("span",{className:"tb-emoji",children:c.emoji}),g.jsx("span",{className:"tb-name",children:c.name}),c.status==="inflight"&&g.jsx("span",{className:"tb-spin"}),c.status==="done"&&g.jsx("span",{className:"tb-mark done",children:"✓"}),c.status==="err"&&g.jsx("span",{className:"tb-mark err",children:"×"})]})},c.id)})]})}function S3({state:e,sessionId:n,onClose:r}){const s=A.useMemo(()=>k3(e,n),[e,n]);return s?g.jsx("div",{className:"modal-backdrop",onClick:r,role:"presentation",children:g.jsxs("div",{className:"modal session-summary",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[g.jsxs("div",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),g.jsx("span",{id:"ss-title",className:"modal-tool-name",title:s.cwd??s.sessionId,children:s.label}),g.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.durationLabel}),g.jsx("button",{className:"btn",onClick:r,"aria-label":"Close",children:"×"})]})]}),g.jsxs("div",{className:"modal-body",children:[g.jsxs("section",{className:"ss-hero",children:[g.jsxs("div",{className:"ss-hero-left",children:[g.jsx("div",{className:"ss-cost-label",children:"total spend"}),g.jsx("div",{className:"ss-cost",children:Be(s.cost.total)}),s.modelChips.length>0&&g.jsx("div",{className:"ss-models",children:s.modelChips.map(o=>g.jsx("span",{className:"model-chip",title:o,children:ca(o)},o))})]}),g.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&g.jsxs(g.Fragment,{children:[g.jsx(b3,{cost:s.cost}),g.jsxs("div",{className:"ss-cost-legend",children:[g.jsxs("span",{className:"ssl ssl-in",children:["input ",g.jsx("b",{children:Be(s.cost.input)})]}),g.jsxs("span",{className:"ssl ssl-out",children:["output ",g.jsx("b",{children:Be(s.cost.output)})]}),g.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",g.jsx("b",{children:Be(s.cost.cacheRead)})]}),g.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",g.jsx("b",{children:Be(s.cost.cacheWrite)})]})]})]})})]}),g.jsxs("section",{className:"ss-stats",children:[g.jsx($s,{label:"agents",value:s.agentCount}),g.jsx($s,{label:"subagents",value:s.subagentCount}),g.jsx($s,{label:"tool calls",value:s.toolCount}),g.jsx($s,{label:"prompts",value:s.promptCount}),g.jsx($s,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&g.jsx($s,{label:"errors",value:s.errCount,tone:"err"})]}),s.topTools.length>0&&g.jsxs("section",{className:"modal-section",children:[g.jsx("h4",{children:"Most-used tools"}),g.jsx("div",{className:"ss-top-tools",children:s.topTools.map(([o,l])=>g.jsxs("div",{className:"ss-tt",children:[g.jsx("span",{className:"ss-tt-name",children:o}),g.jsx("span",{className:"ss-tt-bar",children:g.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${l/s.topTools[0][1]*100}%`}})}),g.jsx("span",{className:"ss-tt-count",children:l})]},o))})]}),s.firstPrompt&&g.jsxs("section",{className:"modal-section",children:[g.jsx("h4",{children:"Opening prompt"}),g.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]})]})}):null}function $s({label:e,value:n,tone:r}){return g.jsxs("div",{className:`ss-stat${r?` tone-${r}`:""}`,children:[g.jsx("div",{className:"ss-stat-value",children:n}),g.jsx("div",{className:"ss-stat-label",children:e})]})}function b3({cost:e}){const n=e.total;if(n<=0)return null;const r=(s,o,l)=>{if(s<=0)return null;const u=s/n*100;return g.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${Be(s)} (${u.toFixed(0)}%)`},o)};return g.jsxs("div",{className:"cost-bar cost-bar-lg","aria-label":"Cost breakdown",children:[r(e.input,"cb-input","input"),r(e.output,"cb-output","output"),r(e.cacheRead,"cb-cache-r","cache read"),r(e.cacheWrite,"cb-cache-w","cache write")]})}function k3(e,n){const r=e.agents.get(n);if(!r)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,p=0,h=0,f=0,m=0,y,x=1/0,C=0;for(const N of s){const j=on(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"&&m++,p+=N.prompts.length,!y&&N.prompts.length>0&&(y=N.prompts[0].text),h+=N.usage.inputTokens+N.usage.outputTokens,c+=N.toolCount,x=Math.min(x,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&&f++}const _=Math.max(0,C-x),S=Math.floor(_/1e3),b=S<60?`${S}s`:S<3600?`${Math.floor(S/60)}m ${String(S%60).padStart(2,"0")}s`:`${Math.floor(S/3600)}h ${Math.floor(S%3600/60)}m`,k=Array.from(u.entries()).sort((N,j)=>j[1]-N[1]).slice(0,5);return{sessionId:n,label:r.label||r.cwdBasename||"session",cwd:r.cwd,durationLabel:b,cost:o,modelChips:Array.from(l),agentCount:s.length,subagentCount:m,toolCount:c,promptCount:p,tokensSum:h,errCount:f,topTools:k,firstPrompt:y}}function E3(e,n){const r=[];for(const s of e.agents.values()){if(s.kind!=="root")continue;let o=s.toolCount,l=on(s.usage,s.model).total,u=s.endedAt??s.startedAt;for(const c of e.agents.values()){if(c.sessionId!==s.sessionId||c.kind==="root")continue;o+=c.toolCount,l+=on(c.usage,c.model).total;const p=c.endedAt??c.startedAt;p>u&&(u=p)}r.push({sessionId:s.sessionId,label:s.label||s.cwdBasename||"session",cwdBasename:s.cwdBasename,state:s.state,modelId:s.model,toolCount:o,cost:l,startedAt:s.startedAt,lastActivity:u})}return r.sort((s,o)=>{if(s.state!==o.state){if(s.state==="active")return-1;if(o.state==="active")return 1}return o.lastActivity-s.lastActivity}),r}function N3(e,n,r){const s=(n??r)-e;if(s<1e3)return"<1s";const o=Math.floor(s/1e3);if(o<60)return`${o}s`;const l=Math.floor(o/60);return l<60?`${l}m`:`${Math.floor(l/60)}h ${l%60}m`}function C3({state:e,now:n,selectedIds:r,onSelect:s,onClose:o}){const l=A.useMemo(()=>E3(e),[e,e.lastSeq,n]),u=l.filter(c=>c.state==="active").length;return g.jsxs("aside",{className:"session-list","aria-label":"Sessions",children:[g.jsxs("div",{className:"sl-header",children:[g.jsxs("h3",{children:["Sessions ",g.jsx("span",{className:"sl-count",children:l.length})]}),u>0&&g.jsxs("span",{className:"sl-live-count",children:[u," live"]}),g.jsx("button",{className:"btn icon-btn sl-close",onClick:o,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),g.jsxs("div",{className:"sl-rows",children:[l.length===0&&g.jsx("div",{className:"sl-empty",children:"No sessions yet."}),l.map(c=>{const p=r.has(c.sessionId);return g.jsxs("button",{type:"button",className:`sl-row state-${c.state}${p?" selected":""}`,onClick:()=>s(c.sessionId),title:`Focus ${c.label}`,children:[g.jsx("span",{className:`sl-dot state-${c.state}`,"aria-hidden":!0}),g.jsxs("div",{className:"sl-row-body",children:[g.jsxs("div",{className:"sl-row-head",children:[g.jsx("span",{className:"sl-label",children:c.label}),c.modelId&&g.jsx("span",{className:"model-chip",title:c.modelId,children:ca(c.modelId)})]}),g.jsxs("div",{className:"sl-row-meta",children:[g.jsxs("span",{title:"tool calls",children:[g.jsx("b",{children:c.toolCount})," tools"]}),c.cost>0&&g.jsx("span",{className:"sl-cost",title:"total spend",children:g.jsx("b",{children:Be(c.cost)})}),g.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(c.startedAt).toLocaleString()}`,children:N3(c.startedAt,c.state==="active"?void 0:c.lastActivity,n)})]})]})]},c.sessionId)})]})]})}function lx(e,n){if(!e)return null;const r=n-Math.floor(e/1e3);return r<10?"just now":r<60?`${r}s ago`:r<3600?`${Math.floor(r/60)}m ago`:`${Math.floor(r/3600)}h ago`}function j3(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 R3({cost:e}){const n=e.total;if(n<=0)return null;const r=(s,o,l)=>{if(s<=0)return null;const u=s/n*100;return g.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${Be(s)} (${u.toFixed(0)}%)`},o)};return g.jsxs("div",{className:"cost-bar","aria-label":"Cost breakdown",children:[r(e.input,"cb-input","input"),r(e.output,"cb-output","output"),r(e.cacheRead,"cb-cache-r","cache read"),r(e.cacheWrite,"cb-cache-w","cache write")]})}function T3(e,n){const r=e-n;if(r<=0)return null;const s=Math.floor(r/3600),o=Math.floor(r%3600/60);if(s>23){const l=Math.floor(r/86400),u=Math.floor(r%86400/3600);return`${l}d ${u}h`}return s>0?`${s}h ${o}m`:`${o}m`}function A3(e,n,r,s){const o=Math.max(0,n-s),l=Math.max(0,r-o);if(l<120)return null;const u=Math.min(100,l/r*100),c=e-u;if(Math.abs(c)<3)return{label:"on pace",color:"var(--ok)",expectedPct:u,isDeficit:!1};if(c>0){const p=100-e,h=l>0?e/l:0,f=h>0?p/h:1/0,m={label:`${Math.round(c)}% ahead`,color:"var(--warn)",expectedPct:u,isDeficit:!0};if(f<o&&f<86400){const y=Math.floor(f/3600),x=Math.floor(f%3600/60);m.runsOutIn=y>0?`${y}h ${x}m`:`${x}m`}return m}return{label:`${Math.round(-c)}% reserve`,color:"var(--ok)",expectedPct:u,isDeficit:!1}}function Hi({pct:e,label:n,reset:r,resetAt:s,windowSec:o,limitReached:l,nowSec:u}){const c=Math.min(100,Math.max(0,e)),h=l||c>=90?"var(--err)":c>=70?"var(--warn)":"var(--accent)",f=c===0?"< 1%":`${c}%`,m=c===0?2:c,y=s?T3(s,u):null,x=s&&o?A3(c,s,o,u):null;return g.jsxs("div",{className:"qb-row",children:[g.jsxs("div",{className:"qb-meta",children:[g.jsxs("span",{className:"qb-label",children:[n,l&&g.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),g.jsx("span",{className:"qb-pct",style:{color:h},children:f})]}),g.jsxs("div",{className:"qb-track",children:[g.jsx("div",{className:"qb-fill",style:{width:`${m}%`,background:h,opacity:c===0?.4:1}}),x&&g.jsx("div",{className:"qb-pace-marker",style:{left:`${x.expectedPct}%`,background:x.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(x.expectedPct)}% by now`})]}),g.jsxs("div",{className:"qb-reset-row",children:[y?g.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):r?g.jsxs("span",{className:"qb-reset",children:["resets ",r]}):null,x&&g.jsx("span",{className:"qb-pace",style:{color:x.color},children:x.runsOutIn?`runs out in ${x.runsOutIn}`:x.label})]})]})}const I3=6e4;function M3(){const[e,n]=A.useState(null),[r,s]=A.useState(!1),o=A.useRef(null),l=async(c=!1)=>{c&&s(!0);try{const h=await fetch(c?"/api/quota?refresh=1":"/api/quota");h.ok&&n(await h.json())}catch{}finally{c&&s(!1)}};return A.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),I3),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{quota:e,loading:r,refresh:()=>l(!0)}}function P3(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 kN=6e4;function O3(){const[e,n]=A.useState(null),[r,s]=A.useState(!1),o=A.useRef(null),l=async(c=!1)=>{c&&s(!0);try{const h=await fetch(c?"/api/codex-quota?refresh=1":"/api/codex-quota");h.ok&&n(await h.json())}catch{}finally{c&&s(!1)}};return A.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),kN),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{data:e,loading:r,refresh:()=>l(!0)}}function q3(){const[e,n]=A.useState(null),r=A.useRef(null),s=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return A.useEffect(()=>(s(),r.current=window.setInterval(s,kN),()=>{r.current!=null&&window.clearInterval(r.current)}),[]),{data:e}}function L3({state:e,now:n,onClose:r}){var L,B;const{quota:s,loading:o,refresh:l}=M3(),{data:u,loading:c,refresh:p}=O3(),{data:h}=q3(),[f,m]=A.useState(()=>Math.floor(Date.now()/1e3));A.useEffect(()=>{const T=window.setInterval(()=>m(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(T)},[]);const{byModel:y,totalCost:x,totalTokens:C,burnRate:_}=A.useMemo(()=>{const T=new Map,M={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let q=0,Y=0,X=0,I=0;for(const F of e.agents.values()){const G=F.model??"__unknown__",E=on(F.usage,F.model),$=T.get(G);$?($.inputTokens+=F.usage.inputTokens,$.outputTokens+=F.usage.outputTokens,$.cacheReadTokens+=F.usage.cacheReadTokens,$.cacheCreateTokens+=F.usage.cacheCreateTokens,$.cost.total+=E.total,$.cost.input+=E.input,$.cost.output+=E.output,$.cost.cacheRead+=E.cacheRead,$.cost.cacheWrite+=E.cacheWrite,$.agentCount++):T.set(G,{model:G,inputTokens:F.usage.inputTokens,outputTokens:F.usage.outputTokens,cacheReadTokens:F.usage.cacheReadTokens,cacheCreateTokens:F.usage.cacheCreateTokens,cost:{...E},agentCount:1}),M.total+=E.total,M.input+=E.input,M.output+=E.output,M.cacheRead+=E.cacheRead,M.cacheWrite+=E.cacheWrite,q+=F.usage.inputTokens,Y+=F.usage.outputTokens,X+=F.usage.cacheReadTokens,I+=F.usage.cacheCreateTokens}const H=Array.from(T.values()).sort((F,G)=>G.cost.total-F.cost.total);let U=0,ne=0;for(const F of e.agents.values()){if(F.state!=="active")continue;const G=on(F.usage,F.model);U+=G.total,ne=Math.max(ne,((F.endedAt??n)-F.startedAt)/1e3)}const J=ne>0?Vl(U,ne):null;return{byModel:H,totalCost:M,totalTokens:{in:q,out:Y,cacheR:X,cacheC:I},burnRate:J}},[e,e.lastSeq,n]),S=A.useMemo(()=>{const T=[];for(const M of e.agents.values()){if(M.kind!=="root")continue;let q=on(M.usage,M.model).total,Y=M.usage.inputTokens,X=M.usage.outputTokens;for(const I of e.agents.values())I.sessionId!==M.sessionId||I.kind==="root"||(q+=on(I.usage,I.model).total,Y+=I.usage.inputTokens,X+=I.usage.outputTokens);T.push({sessionId:M.sessionId,label:M.label||M.cwdBasename||"session",state:M.state,cost:q,inputTokens:Y,outputTokens:X})}return T.sort((M,q)=>q.cost-M.cost).slice(0,12)},[e,e.lastSeq]),b=x.total>0,k=C.in+C.out,N=o||c,j=lx(s==null?void 0:s.fetchedAt,f),P=lx(u==null?void 0:u.fetchedAt,f),O=()=>{l(),p()};return g.jsxs("div",{className:"usage-panel","aria-label":"Usage",children:[g.jsxs("div",{className:"up-header",children:[g.jsx("h3",{children:"Usage"}),_&&g.jsx("span",{className:"up-rate",children:_}),g.jsxs("div",{className:"up-header-right",children:[g.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:O,disabled:N,title:"Refresh Claude + Codex quota",children:N?"…":"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn up-close",onClick:r,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h4",{className:"up-section-title",children:["Claude quota",j&&!o&&g.jsx("span",{className:"up-section-age",title:j3(s==null?void 0:s.source),children:j})]}),s!=null&&s.ok?g.jsxs("div",{className:"up-quota-bars",children:[s.session5hPct!=null&&g.jsx(Hi,{label:"5-hour window",pct:s.session5hPct,reset:s.session5hReset,resetAt:s.session5hResetAt,windowSec:s.session5hWindowSec,nowSec:f}),s.week7dPct!=null&&g.jsx(Hi,{label:"7-day window",pct:s.week7dPct,reset:s.week7dReset,resetAt:s.week7dResetAt,windowSec:s.week7dWindowSec,nowSec:f}),s.weekSonnetPct!=null&&g.jsx(Hi,{label:"Sonnet (7d)",pct:s.weekSonnetPct,nowSec:f}),s.weekOpusPct!=null&&g.jsx(Hi,{label:"Opus (7d)",pct:s.weekOpusPct,nowSec:f})]}):(s==null?void 0:s.ok)===!1?g.jsxs("div",{className:"up-quota-na",children:[g.jsx("span",{children:"Quota unavailable."}),g.jsxs("span",{className:"up-quota-hint",children:["Run ",g.jsx("code",{children:"/usage"})," in a claude session, then click ↻"]})]}):g.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h4",{className:"up-section-title",children:["Codex quota",(u==null?void 0:u.ok)&&u.planLabel&&g.jsx("span",{className:"up-plan-badge",children:u.planLabel}),P&&!c&&g.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:P})]}),u!=null&&u.ok?g.jsxs("div",{className:"up-quota-bars",children:[(L=u.windows)==null?void 0:L.map(T=>g.jsx(Hi,{label:T.label,pct:T.pct,reset:T.reset??void 0,resetAt:T.resetAt??void 0,windowSec:T.windowSec??void 0,limitReached:u.limitReached&&T.pct>=100,nowSec:f},T.id)),(B=u.extraWindows)==null?void 0:B.map(T=>g.jsx(Hi,{label:T.label,pct:T.pct,reset:T.reset??void 0,resetAt:T.resetAt??void 0,windowSec:T.windowSec??void 0,nowSec:f},T.id)),u.creditLimit&&g.jsx(Hi,{label:`spend cap · $${Math.round(u.creditLimit.used)} of $${Math.round(u.creditLimit.limit)}`,pct:u.creditLimit.usedPct,reset:u.creditLimit.reset??void 0,resetAt:u.creditLimit.resetAt??void 0,limitReached:u.spendControlReached,nowSec:f}),(h==null?void 0:h.ok)&&h.window7d&&h.window7d.sessionCount>0&&g.jsxs("div",{className:"up-quota-sub",children:[Ar(h.window7d.totalTokens)," tokens · ",h.window7d.sessionCount," session",h.window7d.sessionCount!==1?"s":""," (7d)"]}),u.creditsBalance&&!u.creditsUnlimited&&g.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",u.creditsBalance,u.overageReached&&" · overage limit reached"]}),u.creditsUnlimited&&g.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),u.resetCredits&&u.resetCredits.availableCount>0&&g.jsxs("div",{className:"up-quota-sub up-reset-credits",title:"Redeem in the Codex CLI or ChatGPT — agents-deck only reports them",children:[u.resetCredits.availableCount," rate-limit reset",u.resetCredits.availableCount!==1?"s":""," available",u.resetCredits.nextExpiryAt&&` · expires ${new Date(u.resetCredits.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`]}),u.promo&&g.jsx("div",{className:"up-quota-sub",children:u.promo}),u.partial&&g.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(u==null?void 0:u.ok)===!1?g.jsxs("div",{className:"up-quota-na",children:[g.jsx("span",{children:"Quota unavailable."}),g.jsx("span",{className:"up-quota-hint",children:P3(u.reason)})]}):g.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),b?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"up-total",children:[g.jsx("span",{className:"up-total-value",children:Be(x.total)}),g.jsx("span",{className:"up-total-label",children:"total spend"})]}),g.jsx(R3,{cost:x}),k>0&&g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),Ar(C.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),Ar(C.out)]}),C.cacheR>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache r"}),Ar(C.cacheR)]}),C.cacheC>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache c"}),Ar(C.cacheC)]})]}),y.filter(T=>T.cost.total>0).length>0&&g.jsxs("section",{className:"up-section",children:[g.jsx("h4",{className:"up-section-title",children:"By model"}),g.jsxs("table",{className:"up-table",children:[g.jsx("thead",{children:g.jsxs("tr",{children:[g.jsx("th",{children:"Model"}),g.jsx("th",{children:"Tokens"}),g.jsx("th",{children:"Cost"})]})}),g.jsx("tbody",{children:y.filter(T=>T.cost.total>0).map(T=>g.jsxs("tr",{children:[g.jsx("td",{className:"up-model-name",title:T.model,children:ca(T.model)}),g.jsx("td",{className:"up-num",children:Ar(T.inputTokens+T.outputTokens)}),g.jsx("td",{className:"up-num up-cost-val",children:Be(T.cost.total)})]},T.model))})]})]}),S.filter(T=>T.cost>0).length>0&&g.jsxs("section",{className:"up-section",children:[g.jsx("h4",{className:"up-section-title",children:"By session"}),g.jsx("div",{className:"up-sessions",children:S.filter(T=>T.cost>0).map(T=>g.jsxs("div",{className:"up-session-row",children:[g.jsx("span",{className:`sl-dot state-${T.state}`,"aria-hidden":!0}),g.jsx("span",{className:"up-session-label",children:T.label}),g.jsx("span",{className:"up-session-tokens",children:Ar(T.inputTokens+T.outputTokens)}),g.jsx("span",{className:"up-session-cost",children:Be(T.cost)})]},T.sessionId))})]})]}):k>0?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),Ar(C.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),Ar(C.out)]})]}),g.jsx("div",{className:"up-hint",children:"Cost appears once a known model is detected."})]}):g.jsxs("div",{className:"up-empty",children:["No usage data yet.",g.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const ux=18,$3=1100,Ds=(e,n)=>{const r=Math.sin(e*12.9898+n*78.233)*43758.5453;return r-Math.floor(r)},D3=Array.from({length:ux},(e,n)=>{const r=-72+144*n/(ux-1)+(Ds(n,1)-.5)*9,s=(r-90)*(Math.PI/180),o=(54+32*Math.cos(r*Math.PI/180))*(.74+Ds(n,2)*.52);return{dx:Math.cos(s)*o,dy:Math.sin(s)*o,rot:(n%2?1:-1)*(100+Ds(n,3)*260),delay:Math.round(Ds(n,4)*90),dur:760+Math.round(Ds(n,5)*260),scale:.8+Ds(n,6)*.45,hue:n%4,round:n%3===0}});function cx({anchor:e,lifetimeMs:n=$3}){var l;const[r,s]=A.useState(null),o=typeof window<"u"&&((l=window.matchMedia)==null?void 0:l.call(window,"(prefers-reduced-motion: reduce)").matches);return A.useEffect(()=>{if(o)return;const u=e.current;if(!u)return;const c=u.getBoundingClientRect();s({x:c.left+c.width/2,y:c.top+c.height/2});const p=window.setTimeout(()=>s(null),n);return()=>window.clearTimeout(p)},[e,n,o]),o||!r?null:tI.createPortal(g.jsx("div",{className:"confetti",style:{left:`${r.x}px`,top:`${r.y}px`},"aria-hidden":!0,children:D3.map((u,c)=>g.jsx("span",{className:`confetti-bit${u.round?" round":""}`,"data-hue":u.hue,style:{"--dx":`${u.dx.toFixed(1)}px`,"--dy":`${u.dy.toFixed(1)}px`,"--rot":`${u.rot}deg`,"--s":u.scale.toFixed(2),animationDelay:`${u.delay}ms`,animationDuration:`${u.dur}ms, ${u.dur}ms`}},c))}),document.body)}const EN=new Set(["awaiting_url","awaiting_code","registering"]);function F3(e){return e!=null&&EN.has(e)}function z3(e){return e!=null&&e!=="done"&&!EN.has(e)}const B3="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",U3="the sign-in did not complete";function H3({state:e,serverError:n,localError:r}){const s=e==="idle";return{title:s?"Sign-in ended":"Sign-in failed",message:r||n||(s?B3:U3)}}const V3=1500;async function Nl(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const W3={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?W3[e.reason]??e.reason:null)||(e==null?void 0:e.error)||n,Wg=ae.forwardRef((e,n)=>g.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:n,children:[g.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),g.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));Wg.displayName="SuccessMark";function G3({onClose:e,onChanged:n}){const[r,s]=A.useState("login"),[o,l]=A.useState(null),[u,c]=A.useState(""),[p,h]=A.useState(""),[f,m]=A.useState(!1),[y,x]=A.useState(null),[C,_]=A.useState(null),S=A.useRef(!1),b=A.useRef(null),k=A.useRef(null),N=A.useRef(null),j=A.useCallback(()=>{S.current&&Nl({action:"login-cancel"}).catch(()=>{}),e()},[e]);A.useEffect(()=>{const q=Y=>{Y.key==="Escape"&&j()};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[j]);const P=A.useCallback(async()=>{m(!0),x(null),S.current=!0;const q=await Nl({action:"login"}).catch(()=>null);if(m(!1),!(q!=null&&q.ok)){x(od(q,"could not start the sign-in"));return}l(q)},[]);A.useEffect(()=>{if(!F3(o==null?void 0:o.state))return;const q=window.setInterval(async()=>{try{const Y=await fetch("/api/claude-accounts/login");Y.ok&&l(await Y.json())}catch{}},V3);return()=>window.clearInterval(q)},[o]),A.useEffect(()=>{var q;(o==null?void 0:o.state)==="awaiting_code"&&((q=b.current)==null||q.focus()),(o==null?void 0:o.state)==="done"&&n()},[o==null?void 0:o.state,n]),A.useEffect(()=>{var q;r==="paste"&&((q=k.current)==null||q.focus())},[r]);const O=A.useCallback(async()=>{var Y;m(!0),x(null);const q=await Nl({action:"login-code",code:u}).catch(()=>null);if(m(!1),!(q!=null&&q.ok)){x(od(q,"the code was not accepted")),q!=null&&q.state&&l(q),(Y=b.current)==null||Y.select();return}c(""),l(q)},[u,o]),L=A.useCallback(async()=>{m(!0),x(null);const q=await Nl({action:"import",blob:p}).catch(()=>null);if(m(!1),!(q!=null&&q.ok)){x(od(q,"the import failed"));return}h(""),_({added:q.added===!0,num:q.num??null,email:q.email??null}),n()},[p,n]),B=(o==null?void 0:o.state)==="done"?o.account:null,T=z3(o==null?void 0:o.state)||!!(y&&S.current&&!f),M=H3({state:o==null?void 0:o.state,serverError:o==null?void 0:o.error,localError:y});return g.jsx("div",{className:"modal-backdrop",onClick:j,role:"presentation",children:g.jsxs("div",{className:"modal aa-modal",onClick:q=>q.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[g.jsxs("header",{className:"modal-head",children:[g.jsx("div",{className:"modal-title",children:g.jsxs("span",{className:"aa-tabs",role:"tablist",children:[g.jsx("button",{type:"button",role:"tab","aria-selected":r==="login",className:`aa-tab${r==="login"?" on":""}`,onClick:()=>s("login"),children:"Sign in"}),g.jsx("button",{type:"button",role:"tab","aria-selected":r==="paste",className:`aa-tab${r==="paste"?" on":""}`,onClick:()=>s("paste"),children:"Paste a share"})]})}),g.jsx("div",{className:"modal-actions",children:g.jsx("button",{type:"button",className:"btn icon-btn",onClick:j,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),g.jsx("section",{className:"modal-body aa-body",children:r==="login"?B?g.jsxs("div",{className:"aa-done",children:[g.jsx(Wg,{ref:N}),g.jsx(cx,{anchor:N}),g.jsx("h4",{children:B.added?`Account ${B.num} added`:"Credentials refreshed"}),g.jsxs("p",{className:"aa-note",children:[g.jsx("strong",{children:B.email}),B.added?" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),g.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"})]}):(o==null?void 0:o.state)==="awaiting_code"||(o==null?void 0:o.state)==="registering"?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"1 · Approve in the browser"}),g.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),g.jsx("a",{className:"aa-link",href:o.url??"#",target:"_blank",rel:"noreferrer noopener",children:o.url})]}),g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"2 · Paste the code it gives you"}),g.jsxs("div",{className:"aa-field",children:[g.jsx("input",{ref:b,type:"text",value:u,onChange:q=>c(q.target.value),onKeyDown:q=>{q.key==="Enter"&&u.trim()&&!f&&O()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:o.state==="registering"}),g.jsx("button",{type:"button",className:"btn primary",disabled:f||!u.trim()||o.state==="registering",onClick:O,children:o.state==="registering"?"registering…":"Continue"})]}),(y||o.error)&&g.jsx("p",{className:"aa-err",children:y??o.error}),g.jsx("p",{className:"aa-note",children:"The code goes straight to the claude CLI on this machine. It is never stored or sent anywhere else."})]})]}):T?g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:M.title}),g.jsx("p",{className:"aa-err",children:M.message}),g.jsx("button",{type:"button",className:"btn",onClick:()=>{S.current=!1,l(null),x(null),P()},children:"Try again"})]}):f||S.current?g.jsx("div",{className:"aa-step",children:g.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):g.jsxs("div",{className:"aa-step aa-primer",children:[g.jsx("h4",{children:"Sign in to Anthropic"}),g.jsx("p",{className:"aa-note",children:"Opens a browser tab where you approve the sign-in, then asks for the code it shows you. claude-swap records the account when it completes, and the account you are using now stays active."}),g.jsx("div",{className:"aa-actions",children:g.jsx("button",{type:"button",className:"btn primary",onClick:P,disabled:f,children:"Open the sign-in page"})})]}):C?g.jsxs("div",{className:"aa-done",children:[g.jsx(Wg,{ref:N}),C.added&&g.jsx(cx,{anchor:N}),g.jsx("h4",{children:C.added?`Account ${C.num} imported`:"Already here"}),g.jsx("p",{className:"aa-note",children:C.added?g.jsxs(g.Fragment,{children:[C.email?g.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."}),g.jsxs("div",{className:"aa-actions",children:[g.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"}),g.jsx("button",{type:"button",className:"btn",onClick:()=>_(null),children:"Import another"})]})]}):g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"Paste an account shared from another deck"}),g.jsxs("div",{className:"aa-field",children:[g.jsx("input",{ref:k,type:"text",value:p,onChange:q=>h(q.target.value),onKeyDown:q=>{q.key==="Enter"&&p.trim()&&!f&&L()},placeholder:"ccdeck1:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),g.jsx("button",{type:"button",className:"btn primary",disabled:f||!p.trim(),onClick:L,children:f?"importing…":"Import"})]}),y&&g.jsx("p",{className:"aa-err",children:y}),g.jsxs("p",{className:"aa-note",children:["Use ",g.jsx("strong",{children:"share"})," on an account in the other deck. A share carries a live login and expires ten minutes after it is made."]})]})})]})})}const Y3=15e3,K3=[70,80,85,90,95];function X3(e,n){const r=e-n;if(r<=0)return null;const s=Math.floor(r/86400),o=Math.floor(r%86400/3600),l=Math.floor(r%3600/60);return s>0?`${s}d ${o}h`:o>0?`${o}h ${l}m`:`${l}m`}function dx(e,n){const r=n-Math.floor(e/1e3);return r<60?"just now":r<3600?`${Math.floor(r/60)}m ago`:r<86400?`${Math.floor(r/3600)}h ago`:`${Math.floor(r/86400)}d ago`}function Q3(e,n){if(!e)return"";const r=Math.floor(e/1e3)-n;return r<=0?" · due":r<60?` · next in ${r}s`:` · next in ${Math.round(r/60)}m`}function Z3(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 J3({lane:e,nowSec:n}){const r=Math.min(100,Math.max(0,e.pct)),s=r>=90?"var(--err)":r>=70?"var(--warn)":"var(--accent)",o=e.resetAt?X3(e.resetAt,n):null;return g.jsxs("div",{className:"ap-lane",children:[g.jsx("span",{className:"ap-lane-label",children:e.label}),g.jsx("div",{className:"ap-lane-track",children:g.jsx("div",{className:"ap-lane-fill",style:{width:`${r===0?1.5:r}%`,background:s,opacity:r===0?.4:1}})}),g.jsxs("span",{className:"ap-lane-pct",style:{color:s},children:[r,"%"]}),g.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}function eO(e){const n=e.map(s=>s.num),r=n.length?Math.max(...n):0;return[...new Set([...n,r+1])].sort((s,o)=>s-o)}async function tO(e){var r;let n=!1;try{n=await Promise.race([((r=navigator.clipboard)==null?void 0:r.writeText(e).then(()=>!0))??Promise.resolve(!1),new Promise(s=>window.setTimeout(()=>s(!1),500))])}catch{n=!1}if(n)return!0;try{const s=document.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(s),s.select(),n=document.execCommand("copy"),s.remove()}catch{n=!1}return n}function nO(e,n){const r=Math.round(e/1e3)-n;return r<=0?{text:"expired",tone:"gone"}:r<60?{text:`expires in ${r}s`,tone:"soon"}:{text:`expires in ${Math.round(r/60)}m`,tone:"ok"}}function rO({onClose:e}){var J,F,G;const[n,r]=A.useState(null),[s,o]=A.useState(null),[l,u]=A.useState(null),[c,p]=A.useState(null),[h,f]=A.useState(null),[m,y]=A.useState(()=>Math.floor(Date.now()/1e3)),x=A.useRef(null),[C,_]=A.useState(null),[S,b]=A.useState(!1),[k,N]=A.useState(""),[j,P]=A.useState(null),[O,L]=A.useState(null),[B,T]=A.useState(!1),M=A.useCallback(async(E=!1)=>{try{const[$,se]=await Promise.all([fetch(`/api/claude-accounts${E?"?refresh=1":""}`),fetch("/api/cswap-auto")]);$.ok&&r(await $.json()),se.ok&&o(await se.json())}catch{}},[]),q=A.useCallback(async(E,$)=>{u($),f(null);try{const D=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)})).json().catch(()=>null);return D!=null&&D.ok||f((D==null?void 0:D.detail)||(D==null?void 0:D.reason)||"command failed"),D}catch{return f("server unreachable"),null}finally{u(null)}},[]),Y=A.useCallback(async(E,$)=>{u($),f(null);try{const D=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)})).json().catch(()=>null);return D!=null&&D.ok||f((D==null?void 0:D.detail)||(D==null?void 0:D.reason)||"command failed"),D}catch{return f("server unreachable"),null}finally{u(null)}},[]);A.useEffect(()=>(M(!0),x.current=window.setInterval(()=>M(!1),Y3),()=>{x.current!=null&&window.clearInterval(x.current)}),[M]),A.useEffect(()=>{const E=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(E)},[]);const X=((J=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:J.value)??"90",I=(F=n==null?void 0:n.accounts)==null?void 0:F.find(E=>E.active),H=I!=null&&I.lanes.length?Math.max(...I.lanes.map(E=>E.pct)):null,U=H!=null&&H>=Number(X)-15,ne=async E=>{p(E),f(null);try{const se=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:E})})).json().catch(()=>null);se!=null&&se.ok||f((se==null?void 0:se.output)||(se==null?void 0:se.reason)||"switch failed"),await M(!0)}catch{f("server unreachable")}finally{p(null)}};return g.jsxs("div",{className:"accounts-panel","aria-label":"Claude accounts",children:[g.jsxs("div",{className:"ap-header",children:[g.jsx("h3",{children:"Accounts"}),g.jsxs("div",{className:"ap-header-right",children:[g.jsx("button",{type:"button",className:"btn ap-add",onClick:()=>b(!0),title:"Sign in to another Claude account, or paste one shared from another deck",children:"+"}),g.jsx("button",{type:"button",className:"btn ap-refresh",onClick:()=>M(!0),title:"Reload from claude-swap",children:"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),n==null?g.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?g.jsxs(g.Fragment,{children:[(G=n.accounts)==null?void 0:G.map(E=>g.jsxs("div",{className:`ap-account${E.active?" active":""}${E.disabled?" disabled":""}`,children:[g.jsxs("div",{className:"ap-account-head",children:[g.jsx("span",{className:"ap-num",children:E.num}),E.alias&&g.jsx("span",{className:"ap-alias",children:E.alias}),g.jsx("span",{className:"ap-email",title:E.org??void 0,children:E.email}),g.jsx("button",{type:"button",className:`ap-more${C===E.num?" on":""}`,"aria-label":`Manage account ${E.num}`,"aria-expanded":C===E.num,title:"Share, rename, move, remove",onClick:()=>{_(C===E.num?null:E.num),N(E.alias??""),P(null),L(null),T(!1)},children:"⋯"}),E.active?g.jsx("span",{className:"ap-badge-active",children:"● active"}):g.jsx("button",{type:"button",className:"btn ap-switch",disabled:c!=null||E.disabled,onClick:()=>ne(E.num),title:E.disabled?"Held out of rotation":`Switch to ${E.alias??E.email}`,children:c===E.num?"…":"switch"})]}),E.lanes.length>0?E.lanes.map($=>g.jsx(J3,{lane:$,nowSec:m},$.id)):g.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),g.jsxs("div",{className:"ap-meta",children:[E.error&&(()=>{const $=Z3(E.error);return g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"ap-err",title:$.hint,children:$.text}),$.fixable&&g.jsx("button",{type:"button",className:"ap-fix",onClick:()=>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))&&!E.active&&g.jsx("button",{type:"button",className:"ap-rotate",disabled:l!=null,onClick:()=>q({action:"account",account:E.num,enabled:E.disabled},`rot-${E.num}`).then(()=>M(!0)),title:E.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:E.disabled?"held out":"in rotation"}),E.fetchedAt?g.jsxs("span",{className:`ap-age${E.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 ",dx(E.fetchedAt,m),Q3(E.nextAt,m)]}):g.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),C===E.num&&g.jsxs("div",{className:"ap-manage",children:[g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("span",{className:"ap-manage-label",children:"name"}),g.jsx("input",{className:"ap-manage-input",type:"text",value:k,onChange:$=>N($.target.value),onKeyDown:$=>{$.key==="Enter"&&Y({action:"alias",account:E.num,alias:k},`alias-${E.num}`).then(()=>M(!0))},placeholder:"no alias",spellCheck:!1,"aria-label":`Alias for account ${E.num}`}),g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null||k.trim()===(E.alias??""),onClick:()=>Y({action:"alias",account:E.num,alias:k},`alias-${E.num}`).then(()=>M(!0)),title:"A short name to show instead of the email",children:"save"})]}),g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("span",{className:"ap-manage-label",children:"slot"}),g.jsx("span",{className:"ap-field",children:g.jsx("select",{"aria-label":`Slot for account ${E.num}`,value:String(E.num),disabled:l!=null,onChange:$=>Y({action:"move",account:E.num,slot:Number($.target.value)},`move-${E.num}`).then(()=>M(!0)),children:eO(n.accounts??[]).map($=>g.jsx("option",{value:$,children:$},$))})}),g.jsx("span",{className:"ap-manage-hint",children:"rotation order"})]}),g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,title:"Copy this account to another agents-deck. The share carries a live login and expires in 10 minutes.",onClick:async()=>{T(!1);const $=await Y({action:"share",account:E.num},`share-${E.num}`);$!=null&&$.ok&&L({num:E.num,blob:$.blob,expiresAt:$.expiresAt})},children:"share…"}),g.jsx("button",{type:"button",className:`ap-manage-btn danger${j===E.num?" armed":""}`,disabled:l!=null,title:j===E.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(j!==E.num){P(E.num),window.setTimeout(()=>P($=>$===E.num?null:$),4e3);return}P(null),Y({action:"remove",account:E.num},`rm-${E.num}`).then(()=>{_(null),M(!0)})},children:j===E.num?"confirm remove":"remove"})]}),(O==null?void 0:O.num)===E.num&&(()=>{const $=nO(O.expiresAt,m),se=$.tone==="gone";return g.jsxs("div",{className:`ap-share${se?" expired":""}`,children:[g.jsx("code",{className:"ap-share-blob",children:O.blob}),g.jsxs("div",{className:"ap-share-foot",children:[g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,onClick:async()=>{if(se){T(!1);const D=await Y({action:"share",account:E.num},`share-${E.num}`);D!=null&&D.ok&&L({num:E.num,blob:D.blob,expiresAt:D.expiresAt});return}await tO(O.blob)&&(T(!0),window.setTimeout(()=>T(!1),1800))},children:se?"make a new share":B?"copied":"copy"}),g.jsxs("span",{className:"ap-manage-hint",children:["carries a live login · ",g.jsx("span",{className:`ap-share-expiry ${$.tone}`,children:$.text})]})]})]})})()]})]},E.num)),(s==null?void 0:s.ok)&&g.jsxs("div",{className:"ap-auto",children:[g.jsxs("div",{className:"ap-auto-head",children:[g.jsx("span",{className:"ap-auto-title",children:"Auto-switch"}),g.jsxs("span",{className:"ap-auto-ctl",children:[H!=null&&g.jsxs("span",{className:`ap-auto-now${U?" near":""}`,children:[Math.round(H),"%"]}),g.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:g.jsx("select",{"aria-label":"Switch threshold",value:X,disabled:l!=null,onChange:E=>q({action:"setting",key:"autoswitch.threshold",value:E.target.value},"threshold").then(()=>M(!0)),children:K3.map(E=>g.jsxs("option",{value:E,children:[E,"%"]},E))})}),g.jsxs("button",{type:"button",className:`ap-auto-state toggle${s.enabled?" live":""}`,role:"switch","aria-checked":s.enabled,disabled:l!=null,onClick:()=>q({action:"enable",enabled:!s.enabled},"enable").then(()=>M(!0)),title:s.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[g.jsx("i",{className:s.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),s.enabled?"on":"off"]})]})]}),s.external&&g.jsxs("p",{className:"ap-auto-note",children:[g.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",g.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",s.enabled?" — this toggle takes over when you stop it.":"."]}),s.lastTick&&g.jsx("div",{className:"ap-auto-foot",children:g.jsxs("span",{className:"ap-auto-result",children:["checked ",dx(s.lastTick.at,m)]})})]}),h&&g.jsx("div",{className:"ap-failure",children:h}),g.jsx("p",{className:"ap-footnote",title:"Anthropic's usage endpoint allows roughly 28–30 requests per hour per account, shared by every tool on this machine — polling it from here would rate-limit your account. So the deck never fetches: it asks claude-swap to collect while this panel is open, at most once every three minutes, and claude-swap decides whether that touches the network at all.",children:"Collected by claude-swap while this panel is open."})]}):g.jsx("div",{className:"ap-empty",children:n.reason==="no_cswap"?g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"claude-swap isn't installed."}),g.jsx("span",{className:"ap-hint",children:"This panel reads the account store claude-swap keeps — without it there is nothing to show. It is a separate tool, published on PyPI, so it does not come with this package."}),n.hint&&g.jsx("code",{className:"ap-cmd",children:n.hint}),g.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",g.jsx("strong",{children:"+"})," button above."]})]}):n.reason==="no_accounts"?g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"No accounts added yet."}),g.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",g.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"Couldn't read the account store."}),g.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",n.reason?` (${n.reason})`:"","."]})]})}),S&&g.jsx(G3,{onClose:()=>b(!1),onChanged:()=>M(!0)})]})}const iO=3e4;function sO({bundle:e,running:n,lastTried:r}){return!n||e===n?!1:r!==n}function oO(e){const n=e.thresholdMs??iO;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 aO(e){return e.ctrlKey||e.metaKey||e.altKey}function ad(e,n){if(n.size!==0)for(const r of Array.from(e.keys()))n.has(r)||e.delete(r)}function lO(e){const n=new Set;for(const r of e)n.add(r.id),n.add(`group:${r.sessionId}`);return n}const uO=40,cO=120;function dO(e,n){let r=null,s=0,o=Number.NEGATIVE_INFINITY;const l=()=>{r=null,o=n.now(),e()},u=()=>{r!=null&&(n.clearTimeout(r),r=null)},c=(p,h,f)=>{if(r!=null){if(s<=p)return;u()}const m=Math.min(f,Math.max(0,p-h));s=p,r=n.setTimeout(l,m)};return{live(p=uO){const h=n.now(),f=Math.max(o+p,h);if(f<=h){u(),l();return}c(f,h,p)},replay(p=cO){u(),s=n.now()+p,r=n.setTimeout(l,p)},flush(){u(),l()},cancel(){u()}}}function fO(){let e=!1,n=[];return{get paused(){return e},get size(){return n.length},accept(r){return e?(n.push(r),!1):!0},setPaused(r){if(e=r,r||n.length===0)return[];const s=n;return n=[],s}}}function hO(){let e=0;return{begin(){const n=++e;return()=>n===e},cancel(){e++}}}function pO(e,n=new Date){return new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}function Vi(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 fx(e){return e.replace(/^anthropic\./,"").replace(/^claude-/,"").replace(/-\d{8}$/,"")}function Cl(e){const n=e.toLowerCase();return n.includes("opus")?"#c4b5fd":n.includes("sonnet")?"#7dd3fc":n.includes("haiku")?"#86efac":n.includes("gpt-5")||n.includes("gpt5")?"#fcd34d":n.includes("gpt")?"#fca5a5":n.includes("gemini")?"#a5b4fc":n.includes("codex")?"#fdba74":"#94a3b8"}const mO=[7,14,30,90];function gO(e){const[n,r]=A.useState(null),[s,o]=A.useState(!1),l=A.useRef(hO()).current,u=(c=!1)=>{const p=l.begin();o(!0);const f=`/api/ccusage?since=${pO(e)}${c?"&refresh=1":""}`;fetch(f).then(m=>m.json()).then(m=>{p()&&r(m)}).catch(()=>{p()&&r({ok:!1,error:"request failed"})}).finally(()=>{p()&&o(!1)})};return A.useEffect(()=>(u(!1),()=>l.cancel()),[e]),{data:n,loading:s,reload:()=>u(!0)}}function vO({onClose:e}){var b,k;const[n,r]=A.useState(30),[s,o]=A.useState(null),{data:l,loading:u,reload:c}=gO(n);A.useEffect(()=>{const N=j=>{j.key==="Escape"&&e()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e]);const p=l!=null&&l.ok?l.days??[]:[],h=A.useMemo(()=>p.reduce((N,j)=>Math.max(N,j.totalCost),0),[p]),{totalCost:f,totalTok:m,inOut:y,cacheRead:x,modelCosts:C}=A.useMemo(()=>{let N=0,j=0,P=0,O=0;const L=new Map;for(const B of p){N+=B.totalCost,j+=B.totalTokens,P+=B.inputTokens+B.outputTokens,O+=B.cacheReadTokens;for(const T of B.modelBreakdowns)L.set(T.modelName,(L.get(T.modelName)??0)+T.cost)}return{totalCost:N,totalTok:j,inOut:P,cacheRead:O,modelCosts:L}},[p]),_=A.useMemo(()=>Array.from(C.entries()).sort((N,j)=>j[1]-N[1]),[C]),S=s?p.find(N=>N.period===s)??null:null;return g.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:g.jsxs("div",{className:"uh-modal",onClick:N=>N.stopPropagation(),role:"dialog","aria-label":"Usage history",children:[g.jsxs("header",{className:"uh-head",children:[g.jsxs("div",{className:"uh-titlewrap",children:[g.jsx("div",{className:"uh-title",children:"Usage history"}),g.jsx("div",{className:"uh-sub",children:"via ccusage · local Claude / Codex logs"})]}),g.jsx("div",{className:"uh-range",role:"tablist","aria-label":"Range",children:mO.map(N=>g.jsxs("button",{role:"tab","aria-selected":n===N,className:`uh-range-btn${n===N?" on":""}`,onClick:()=>{r(N),o(null)},children:[N,"d"]},N))}),g.jsx("button",{className:"btn icon-btn uh-reload",onClick:c,title:"Re-run ccusage","aria-label":"Reload",children:"↻"}),g.jsx("button",{className:"uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),u&&p.length===0?g.jsx("div",{className:"uh-status",children:"running ccusage… (first run downloads the package)"}):l&&!l.ok?g.jsxs("div",{className:"uh-status uh-err",children:["ccusage failed: ",l.error]}):p.length===0?g.jsx("div",{className:"uh-status",children:"no usage in this range"}):g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"uh-totals",children:[g.jsx(jl,{label:"total cost",val:Be(f),accent:!0}),g.jsx(jl,{label:"tokens",val:Vi(m)}),g.jsx(jl,{label:"input+output",val:Vi(y)}),g.jsx(jl,{label:"cache reads",val:Vi(x)})]}),g.jsx("div",{className:"uh-chart",role:"img","aria-label":"Daily cost by model",children:p.map(N=>{const j=h>0?N.totalCost/h*100:0,P=N.period===s;return g.jsxs("button",{className:`uh-bar-col${P?" sel":""}`,onClick:()=>o(P?null:N.period),title:`${N.period} · ${Be(N.totalCost)}`,style:{flexBasis:`${100/p.length}%`},children:[g.jsx("div",{className:"uh-bar",style:{height:`${Math.max(j,N.totalCost>0?2:0)}%`},children:N.modelBreakdowns.slice().sort((O,L)=>L.cost-O.cost).map(O=>{const L=N.totalCost>0?O.cost/N.totalCost*100:0;return g.jsx("div",{className:"uh-bar-seg",style:{height:`${L}%`,background:Cl(O.modelName)}},O.modelName)})}),g.jsx("span",{className:"uh-bar-label",children:N.period.slice(5)})]},N.period)})}),g.jsx("div",{className:"uh-legend",children:_.map(([N,j])=>g.jsxs("span",{className:"uh-legend-item",children:[g.jsx("span",{className:"uh-legend-dot",style:{background:Cl(N)}}),fx(N)," ",g.jsx("span",{className:"uh-legend-cost",children:Be(j)})]},N))}),S&&g.jsxs("div",{className:"uh-detail",children:[g.jsxs("div",{className:"uh-detail-head",children:[g.jsx("span",{className:"uh-detail-date",children:S.period}),g.jsx("span",{className:"uh-detail-cost",children:Be(S.totalCost)}),(k=(b=S.metadata)==null?void 0:b.agents)!=null&&k.length?g.jsx("span",{className:"uh-detail-agents",children:S.metadata.agents.join(" · ")}):null]}),g.jsxs("div",{className:"uh-detail-mini",children:[g.jsx(Rl,{label:"input",val:Vi(S.inputTokens)}),g.jsx(Rl,{label:"output",val:Vi(S.outputTokens)}),g.jsx(Rl,{label:"cache write",val:Vi(S.cacheCreationTokens)}),g.jsx(Rl,{label:"cache read",val:Vi(S.cacheReadTokens)})]}),g.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 g.jsxs("div",{className:"uh-model-row",children:[g.jsxs("span",{className:"uh-model-name",children:[g.jsx("span",{className:"uh-legend-dot",style:{background:Cl(N.modelName)}}),fx(N.modelName)]}),g.jsx("span",{className:"uh-model-bar",children:g.jsx("span",{className:"uh-model-bar-fill",style:{width:`${j}%`,background:Cl(N.modelName)}})}),g.jsx("span",{className:"uh-model-cost",children:Be(N.cost)})]},N.modelName)})})]})]})]})})}function jl({label:e,val:n,accent:r}){return g.jsxs("div",{className:"uh-stat",children:[g.jsx("span",{className:`uh-stat-val${r?" accent":""}`,children:n}),g.jsx("span",{className:"uh-stat-label",children:e})]})}function Rl({label:e,val:n}){return g.jsxs("div",{className:"uh-ministat",children:[g.jsx("span",{className:"uh-ministat-val",children:n}),g.jsx("span",{className:"uh-ministat-label",children:e})]})}function vv(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 ld,hx;function yO(){if(hx)return ld;hx=1;function e(){this.__data__=[],this.size=0}return ld=e,ld}var ud,px;function Qs(){if(px)return ud;px=1;function e(n,r){return n===r||n!==n&&r!==r}return ud=e,ud}var cd,mx;function eu(){if(mx)return cd;mx=1;var e=Qs();function n(r,s){for(var o=r.length;o--;)if(e(r[o][0],s))return o;return-1}return cd=n,cd}var dd,gx;function wO(){if(gx)return dd;gx=1;var e=eu(),n=Array.prototype,r=n.splice;function s(o){var l=this.__data__,u=e(l,o);if(u<0)return!1;var c=l.length-1;return u==c?l.pop():r.call(l,u,1),--this.size,!0}return dd=s,dd}var fd,vx;function xO(){if(vx)return fd;vx=1;var e=eu();function n(r){var s=this.__data__,o=e(s,r);return o<0?void 0:s[o][1]}return fd=n,fd}var hd,yx;function _O(){if(yx)return hd;yx=1;var e=eu();function n(r){return e(this.__data__,r)>-1}return hd=n,hd}var pd,wx;function SO(){if(wx)return pd;wx=1;var e=eu();function n(r,s){var o=this.__data__,l=e(o,r);return l<0?(++this.size,o.push([r,s])):o[l][1]=s,this}return pd=n,pd}var md,xx;function tu(){if(xx)return md;xx=1;var e=yO(),n=wO(),r=xO(),s=_O(),o=SO();function l(u){var c=-1,p=u==null?0:u.length;for(this.clear();++c<p;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=s,l.prototype.set=o,md=l,md}var gd,_x;function bO(){if(_x)return gd;_x=1;var e=tu();function n(){this.__data__=new e,this.size=0}return gd=n,gd}var vd,Sx;function kO(){if(Sx)return vd;Sx=1;function e(n){var r=this.__data__,s=r.delete(n);return this.size=r.size,s}return vd=e,vd}var yd,bx;function EO(){if(bx)return yd;bx=1;function e(n){return this.__data__.get(n)}return yd=e,yd}var wd,kx;function NO(){if(kx)return wd;kx=1;function e(n){return this.__data__.has(n)}return wd=e,wd}var xd,Ex;function NN(){if(Ex)return xd;Ex=1;var e=typeof pl=="object"&&pl&&pl.Object===Object&&pl;return xd=e,xd}var _d,Nx;function er(){if(Nx)return _d;Nx=1;var e=NN(),n=typeof self=="object"&&self&&self.Object===Object&&self,r=e||n||Function("return this")();return _d=r,_d}var Sd,Cx;function Zs(){if(Cx)return Sd;Cx=1;var e=er(),n=e.Symbol;return Sd=n,Sd}var bd,jx;function CO(){if(jx)return bd;jx=1;var e=Zs(),n=Object.prototype,r=n.hasOwnProperty,s=n.toString,o=e?e.toStringTag:void 0;function l(u){var c=r.call(u,o),p=u[o];try{u[o]=void 0;var h=!0}catch{}var f=s.call(u);return h&&(c?u[o]=p:delete u[o]),f}return bd=l,bd}var kd,Rx;function jO(){if(Rx)return kd;Rx=1;var e=Object.prototype,n=e.toString;function r(s){return n.call(s)}return kd=r,kd}var Ed,Tx;function ts(){if(Tx)return Ed;Tx=1;var e=Zs(),n=CO(),r=jO(),s="[object Null]",o="[object Undefined]",l=e?e.toStringTag:void 0;function u(c){return c==null?c===void 0?o:s:l&&l in Object(c)?n(c):r(c)}return Ed=u,Ed}var Nd,Ax;function Pn(){if(Ax)return Nd;Ax=1;function e(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}return Nd=e,Nd}var Cd,Ix;function da(){if(Ix)return Cd;Ix=1;var e=ts(),n=Pn(),r="[object AsyncFunction]",s="[object Function]",o="[object GeneratorFunction]",l="[object Proxy]";function u(c){if(!n(c))return!1;var p=e(c);return p==s||p==o||p==r||p==l}return Cd=u,Cd}var jd,Mx;function RO(){if(Mx)return jd;Mx=1;var e=er(),n=e["__core-js_shared__"];return jd=n,jd}var Rd,Px;function TO(){if(Px)return Rd;Px=1;var e=RO(),n=(function(){var s=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""})();function r(s){return!!n&&n in s}return Rd=r,Rd}var Td,Ox;function CN(){if(Ox)return Td;Ox=1;var e=Function.prototype,n=e.toString;function r(s){if(s!=null){try{return n.call(s)}catch{}try{return s+""}catch{}}return""}return Td=r,Td}var Ad,qx;function AO(){if(qx)return Ad;qx=1;var e=da(),n=TO(),r=Pn(),s=CN(),o=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,p=u.toString,h=c.hasOwnProperty,f=RegExp("^"+p.call(h).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!r(y)||n(y))return!1;var x=e(y)?f:l;return x.test(s(y))}return Ad=m,Ad}var Id,Lx;function IO(){if(Lx)return Id;Lx=1;function e(n,r){return n==null?void 0:n[r]}return Id=e,Id}var Md,$x;function ns(){if($x)return Md;$x=1;var e=AO(),n=IO();function r(s,o){var l=n(s,o);return e(l)?l:void 0}return Md=r,Md}var Pd,Dx;function yv(){if(Dx)return Pd;Dx=1;var e=ns(),n=er(),r=e(n,"Map");return Pd=r,Pd}var Od,Fx;function nu(){if(Fx)return Od;Fx=1;var e=ns(),n=e(Object,"create");return Od=n,Od}var qd,zx;function MO(){if(zx)return qd;zx=1;var e=nu();function n(){this.__data__=e?e(null):{},this.size=0}return qd=n,qd}var Ld,Bx;function PO(){if(Bx)return Ld;Bx=1;function e(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}return Ld=e,Ld}var $d,Ux;function OO(){if(Ux)return $d;Ux=1;var e=nu(),n="__lodash_hash_undefined__",r=Object.prototype,s=r.hasOwnProperty;function o(l){var u=this.__data__;if(e){var c=u[l];return c===n?void 0:c}return s.call(u,l)?u[l]:void 0}return $d=o,$d}var Dd,Hx;function qO(){if(Hx)return Dd;Hx=1;var e=nu(),n=Object.prototype,r=n.hasOwnProperty;function s(o){var l=this.__data__;return e?l[o]!==void 0:r.call(l,o)}return Dd=s,Dd}var Fd,Vx;function LO(){if(Vx)return Fd;Vx=1;var e=nu(),n="__lodash_hash_undefined__";function r(s,o){var l=this.__data__;return this.size+=this.has(s)?0:1,l[s]=e&&o===void 0?n:o,this}return Fd=r,Fd}var zd,Wx;function $O(){if(Wx)return zd;Wx=1;var e=MO(),n=PO(),r=OO(),s=qO(),o=LO();function l(u){var c=-1,p=u==null?0:u.length;for(this.clear();++c<p;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=s,l.prototype.set=o,zd=l,zd}var Bd,Gx;function DO(){if(Gx)return Bd;Gx=1;var e=$O(),n=tu(),r=yv();function s(){this.size=0,this.__data__={hash:new e,map:new(r||n),string:new e}}return Bd=s,Bd}var Ud,Yx;function FO(){if(Yx)return Ud;Yx=1;function e(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}return Ud=e,Ud}var Hd,Kx;function ru(){if(Kx)return Hd;Kx=1;var e=FO();function n(r,s){var o=r.__data__;return e(s)?o[typeof s=="string"?"string":"hash"]:o.map}return Hd=n,Hd}var Vd,Xx;function zO(){if(Xx)return Vd;Xx=1;var e=ru();function n(r){var s=e(this,r).delete(r);return this.size-=s?1:0,s}return Vd=n,Vd}var Wd,Qx;function BO(){if(Qx)return Wd;Qx=1;var e=ru();function n(r){return e(this,r).get(r)}return Wd=n,Wd}var Gd,Zx;function UO(){if(Zx)return Gd;Zx=1;var e=ru();function n(r){return e(this,r).has(r)}return Gd=n,Gd}var Yd,Jx;function HO(){if(Jx)return Yd;Jx=1;var e=ru();function n(r,s){var o=e(this,r),l=o.size;return o.set(r,s),this.size+=o.size==l?0:1,this}return Yd=n,Yd}var Kd,e_;function wv(){if(e_)return Kd;e_=1;var e=DO(),n=zO(),r=BO(),s=UO(),o=HO();function l(u){var c=-1,p=u==null?0:u.length;for(this.clear();++c<p;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=s,l.prototype.set=o,Kd=l,Kd}var Xd,t_;function VO(){if(t_)return Xd;t_=1;var e=tu(),n=yv(),r=wv(),s=200;function o(l,u){var c=this.__data__;if(c instanceof e){var p=c.__data__;if(!n||p.length<s-1)return p.push([l,u]),this.size=++c.size,this;c=this.__data__=new r(p)}return c.set(l,u),this.size=c.size,this}return Xd=o,Xd}var Qd,n_;function iu(){if(n_)return Qd;n_=1;var e=tu(),n=bO(),r=kO(),s=EO(),o=NO(),l=VO();function u(c){var p=this.__data__=new e(c);this.size=p.size}return u.prototype.clear=n,u.prototype.delete=r,u.prototype.get=s,u.prototype.has=o,u.prototype.set=l,Qd=u,Qd}var Zd,r_;function xv(){if(r_)return Zd;r_=1;function e(n,r){for(var s=-1,o=n==null?0:n.length;++s<o&&r(n[s],s,n)!==!1;);return n}return Zd=e,Zd}var Jd,i_;function jN(){if(i_)return Jd;i_=1;var e=ns(),n=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return Jd=n,Jd}var ef,s_;function su(){if(s_)return ef;s_=1;var e=jN();function n(r,s,o){s=="__proto__"&&e?e(r,s,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[s]=o}return ef=n,ef}var tf,o_;function ou(){if(o_)return tf;o_=1;var e=su(),n=Qs(),r=Object.prototype,s=r.hasOwnProperty;function o(l,u,c){var p=l[u];(!(s.call(l,u)&&n(p,c))||c===void 0&&!(u in l))&&e(l,u,c)}return tf=o,tf}var nf,a_;function fa(){if(a_)return nf;a_=1;var e=ou(),n=su();function r(s,o,l,u){var c=!l;l||(l={});for(var p=-1,h=o.length;++p<h;){var f=o[p],m=u?u(l[f],s[f],f,l,s):void 0;m===void 0&&(m=s[f]),c?n(l,f,m):e(l,f,m)}return l}return nf=r,nf}var rf,l_;function WO(){if(l_)return rf;l_=1;function e(n,r){for(var s=-1,o=Array(n);++s<n;)o[s]=r(s);return o}return rf=e,rf}var sf,u_;function hr(){if(u_)return sf;u_=1;function e(n){return n!=null&&typeof n=="object"}return sf=e,sf}var of,c_;function GO(){if(c_)return of;c_=1;var e=ts(),n=hr(),r="[object Arguments]";function s(o){return n(o)&&e(o)==r}return of=s,of}var af,d_;function ha(){if(d_)return af;d_=1;var e=GO(),n=hr(),r=Object.prototype,s=r.hasOwnProperty,o=r.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(u){return n(u)&&s.call(u,"callee")&&!o.call(u,"callee")};return af=l,af}var lf,f_;function _t(){if(f_)return lf;f_=1;var e=Array.isArray;return lf=e,lf}var Wo={exports:{}},uf,h_;function YO(){if(h_)return uf;h_=1;function e(){return!1}return uf=e,uf}Wo.exports;var p_;function Js(){return p_||(p_=1,(function(e,n){var r=er(),s=YO(),o=n&&!n.nodeType&&n,l=o&&!0&&e&&!e.nodeType&&e,u=l&&l.exports===o,c=u?r.Buffer:void 0,p=c?c.isBuffer:void 0,h=p||s;e.exports=h})(Wo,Wo.exports)),Wo.exports}var cf,m_;function au(){if(m_)return cf;m_=1;var e=9007199254740991,n=/^(?:0|[1-9]\d*)$/;function r(s,o){var l=typeof s;return o=o??e,!!o&&(l=="number"||l!="symbol"&&n.test(s))&&s>-1&&s%1==0&&s<o}return cf=r,cf}var df,g_;function _v(){if(g_)return df;g_=1;var e=9007199254740991;function n(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return df=n,df}var ff,v_;function KO(){if(v_)return ff;v_=1;var e=ts(),n=_v(),r=hr(),s="[object Arguments]",o="[object Array]",l="[object Boolean]",u="[object Date]",c="[object Error]",p="[object Function]",h="[object Map]",f="[object Number]",m="[object Object]",y="[object RegExp]",x="[object Set]",C="[object String]",_="[object WeakMap]",S="[object ArrayBuffer]",b="[object DataView]",k="[object Float32Array]",N="[object Float64Array]",j="[object Int8Array]",P="[object Int16Array]",O="[object Int32Array]",L="[object Uint8Array]",B="[object Uint8ClampedArray]",T="[object Uint16Array]",M="[object Uint32Array]",q={};q[k]=q[N]=q[j]=q[P]=q[O]=q[L]=q[B]=q[T]=q[M]=!0,q[s]=q[o]=q[S]=q[l]=q[b]=q[u]=q[c]=q[p]=q[h]=q[f]=q[m]=q[y]=q[x]=q[C]=q[_]=!1;function Y(X){return r(X)&&n(X.length)&&!!q[e(X)]}return ff=Y,ff}var hf,y_;function lu(){if(y_)return hf;y_=1;function e(n){return function(r){return n(r)}}return hf=e,hf}var Go={exports:{}};Go.exports;var w_;function Sv(){return w_||(w_=1,(function(e,n){var r=NN(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,u=l&&r.process,c=(function(){try{var p=o&&o.require&&o.require("util").types;return p||u&&u.binding&&u.binding("util")}catch{}})();e.exports=c})(Go,Go.exports)),Go.exports}var pf,x_;function pa(){if(x_)return pf;x_=1;var e=KO(),n=lu(),r=Sv(),s=r&&r.isTypedArray,o=s?n(s):e;return pf=o,pf}var mf,__;function RN(){if(__)return mf;__=1;var e=WO(),n=ha(),r=_t(),s=Js(),o=au(),l=pa(),u=Object.prototype,c=u.hasOwnProperty;function p(h,f){var m=r(h),y=!m&&n(h),x=!m&&!y&&s(h),C=!m&&!y&&!x&&l(h),_=m||y||x||C,S=_?e(h.length,String):[],b=S.length;for(var k in h)(f||c.call(h,k))&&!(_&&(k=="length"||x&&(k=="offset"||k=="parent")||C&&(k=="buffer"||k=="byteLength"||k=="byteOffset")||o(k,b)))&&S.push(k);return S}return mf=p,mf}var gf,S_;function uu(){if(S_)return gf;S_=1;var e=Object.prototype;function n(r){var s=r&&r.constructor,o=typeof s=="function"&&s.prototype||e;return r===o}return gf=n,gf}var vf,b_;function TN(){if(b_)return vf;b_=1;function e(n,r){return function(s){return n(r(s))}}return vf=e,vf}var yf,k_;function XO(){if(k_)return yf;k_=1;var e=TN(),n=e(Object.keys,Object);return yf=n,yf}var wf,E_;function bv(){if(E_)return wf;E_=1;var e=uu(),n=XO(),r=Object.prototype,s=r.hasOwnProperty;function o(l){if(!e(l))return n(l);var u=[];for(var c in Object(l))s.call(l,c)&&c!="constructor"&&u.push(c);return u}return wf=o,wf}var xf,N_;function qr(){if(N_)return xf;N_=1;var e=da(),n=_v();function r(s){return s!=null&&n(s.length)&&!e(s)}return xf=r,xf}var _f,C_;function _i(){if(C_)return _f;C_=1;var e=RN(),n=bv(),r=qr();function s(o){return r(o)?e(o):n(o)}return _f=s,_f}var Sf,j_;function QO(){if(j_)return Sf;j_=1;var e=fa(),n=_i();function r(s,o){return s&&e(o,n(o),s)}return Sf=r,Sf}var bf,R_;function ZO(){if(R_)return bf;R_=1;function e(n){var r=[];if(n!=null)for(var s in Object(n))r.push(s);return r}return bf=e,bf}var kf,T_;function JO(){if(T_)return kf;T_=1;var e=Pn(),n=uu(),r=ZO(),s=Object.prototype,o=s.hasOwnProperty;function l(u){if(!e(u))return r(u);var c=n(u),p=[];for(var h in u)h=="constructor"&&(c||!o.call(u,h))||p.push(h);return p}return kf=l,kf}var Ef,A_;function rs(){if(A_)return Ef;A_=1;var e=RN(),n=JO(),r=qr();function s(o){return r(o)?e(o,!0):n(o)}return Ef=s,Ef}var Nf,I_;function eq(){if(I_)return Nf;I_=1;var e=fa(),n=rs();function r(s,o){return s&&e(o,n(o),s)}return Nf=r,Nf}var Yo={exports:{}};Yo.exports;var M_;function AN(){return M_||(M_=1,(function(e,n){var r=er(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,u=l?r.Buffer:void 0,c=u?u.allocUnsafe:void 0;function p(h,f){if(f)return h.slice();var m=h.length,y=c?c(m):new h.constructor(m);return h.copy(y),y}e.exports=p})(Yo,Yo.exports)),Yo.exports}var Cf,P_;function IN(){if(P_)return Cf;P_=1;function e(n,r){var s=-1,o=n.length;for(r||(r=Array(o));++s<o;)r[s]=n[s];return r}return Cf=e,Cf}var jf,O_;function MN(){if(O_)return jf;O_=1;function e(n,r){for(var s=-1,o=n==null?0:n.length,l=0,u=[];++s<o;){var c=n[s];r(c,s,n)&&(u[l++]=c)}return u}return jf=e,jf}var Rf,q_;function PN(){if(q_)return Rf;q_=1;function e(){return[]}return Rf=e,Rf}var Tf,L_;function kv(){if(L_)return Tf;L_=1;var e=MN(),n=PN(),r=Object.prototype,s=r.propertyIsEnumerable,o=Object.getOwnPropertySymbols,l=o?function(u){return u==null?[]:(u=Object(u),e(o(u),function(c){return s.call(u,c)}))}:n;return Tf=l,Tf}var Af,$_;function tq(){if($_)return Af;$_=1;var e=fa(),n=kv();function r(s,o){return e(s,n(s),o)}return Af=r,Af}var If,D_;function Ev(){if(D_)return If;D_=1;function e(n,r){for(var s=-1,o=r.length,l=n.length;++s<o;)n[l+s]=r[s];return n}return If=e,If}var Mf,F_;function cu(){if(F_)return Mf;F_=1;var e=TN(),n=e(Object.getPrototypeOf,Object);return Mf=n,Mf}var Pf,z_;function ON(){if(z_)return Pf;z_=1;var e=Ev(),n=cu(),r=kv(),s=PN(),o=Object.getOwnPropertySymbols,l=o?function(u){for(var c=[];u;)e(c,r(u)),u=n(u);return c}:s;return Pf=l,Pf}var Of,B_;function nq(){if(B_)return Of;B_=1;var e=fa(),n=ON();function r(s,o){return e(s,n(s),o)}return Of=r,Of}var qf,U_;function qN(){if(U_)return qf;U_=1;var e=Ev(),n=_t();function r(s,o,l){var u=o(s);return n(s)?u:e(u,l(s))}return qf=r,qf}var Lf,H_;function LN(){if(H_)return Lf;H_=1;var e=qN(),n=kv(),r=_i();function s(o){return e(o,r,n)}return Lf=s,Lf}var $f,V_;function rq(){if(V_)return $f;V_=1;var e=qN(),n=ON(),r=rs();function s(o){return e(o,r,n)}return $f=s,$f}var Df,W_;function iq(){if(W_)return Df;W_=1;var e=ns(),n=er(),r=e(n,"DataView");return Df=r,Df}var Ff,G_;function sq(){if(G_)return Ff;G_=1;var e=ns(),n=er(),r=e(n,"Promise");return Ff=r,Ff}var zf,Y_;function $N(){if(Y_)return zf;Y_=1;var e=ns(),n=er(),r=e(n,"Set");return zf=r,zf}var Bf,K_;function oq(){if(K_)return Bf;K_=1;var e=ns(),n=er(),r=e(n,"WeakMap");return Bf=r,Bf}var Uf,X_;function eo(){if(X_)return Uf;X_=1;var e=iq(),n=yv(),r=sq(),s=$N(),o=oq(),l=ts(),u=CN(),c="[object Map]",p="[object Object]",h="[object Promise]",f="[object Set]",m="[object WeakMap]",y="[object DataView]",x=u(e),C=u(n),_=u(r),S=u(s),b=u(o),k=l;return(e&&k(new e(new ArrayBuffer(1)))!=y||n&&k(new n)!=c||r&&k(r.resolve())!=h||s&&k(new s)!=f||o&&k(new o)!=m)&&(k=function(N){var j=l(N),P=j==p?N.constructor:void 0,O=P?u(P):"";if(O)switch(O){case x:return y;case C:return c;case _:return h;case S:return f;case b:return m}return j}),Uf=k,Uf}var Hf,Q_;function aq(){if(Q_)return Hf;Q_=1;var e=Object.prototype,n=e.hasOwnProperty;function r(s){var o=s.length,l=new s.constructor(o);return o&&typeof s[0]=="string"&&n.call(s,"index")&&(l.index=s.index,l.input=s.input),l}return Hf=r,Hf}var Vf,Z_;function DN(){if(Z_)return Vf;Z_=1;var e=er(),n=e.Uint8Array;return Vf=n,Vf}var Wf,J_;function Nv(){if(J_)return Wf;J_=1;var e=DN();function n(r){var s=new r.constructor(r.byteLength);return new e(s).set(new e(r)),s}return Wf=n,Wf}var Gf,e1;function lq(){if(e1)return Gf;e1=1;var e=Nv();function n(r,s){var o=s?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.byteLength)}return Gf=n,Gf}var Yf,t1;function uq(){if(t1)return Yf;t1=1;var e=/\w*$/;function n(r){var s=new r.constructor(r.source,e.exec(r));return s.lastIndex=r.lastIndex,s}return Yf=n,Yf}var Kf,n1;function cq(){if(n1)return Kf;n1=1;var e=Zs(),n=e?e.prototype:void 0,r=n?n.valueOf:void 0;function s(o){return r?Object(r.call(o)):{}}return Kf=s,Kf}var Xf,r1;function FN(){if(r1)return Xf;r1=1;var e=Nv();function n(r,s){var o=s?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.length)}return Xf=n,Xf}var Qf,i1;function dq(){if(i1)return Qf;i1=1;var e=Nv(),n=lq(),r=uq(),s=cq(),o=FN(),l="[object Boolean]",u="[object Date]",c="[object Map]",p="[object Number]",h="[object RegExp]",f="[object Set]",m="[object String]",y="[object Symbol]",x="[object ArrayBuffer]",C="[object DataView]",_="[object Float32Array]",S="[object Float64Array]",b="[object Int8Array]",k="[object Int16Array]",N="[object Int32Array]",j="[object Uint8Array]",P="[object Uint8ClampedArray]",O="[object Uint16Array]",L="[object Uint32Array]";function B(T,M,q){var Y=T.constructor;switch(M){case x:return e(T);case l:case u:return new Y(+T);case C:return n(T,q);case _:case S:case b:case k:case N:case j:case P:case O:case L:return o(T,q);case c:return new Y;case p:case m:return new Y(T);case h:return r(T);case f:return new Y;case y:return s(T)}}return Qf=B,Qf}var Zf,s1;function zN(){if(s1)return Zf;s1=1;var e=Pn(),n=Object.create,r=(function(){function s(){}return function(o){if(!e(o))return{};if(n)return n(o);s.prototype=o;var l=new s;return s.prototype=void 0,l}})();return Zf=r,Zf}var Jf,o1;function BN(){if(o1)return Jf;o1=1;var e=zN(),n=cu(),r=uu();function s(o){return typeof o.constructor=="function"&&!r(o)?e(n(o)):{}}return Jf=s,Jf}var eh,a1;function fq(){if(a1)return eh;a1=1;var e=eo(),n=hr(),r="[object Map]";function s(o){return n(o)&&e(o)==r}return eh=s,eh}var th,l1;function hq(){if(l1)return th;l1=1;var e=fq(),n=lu(),r=Sv(),s=r&&r.isMap,o=s?n(s):e;return th=o,th}var nh,u1;function pq(){if(u1)return nh;u1=1;var e=eo(),n=hr(),r="[object Set]";function s(o){return n(o)&&e(o)==r}return nh=s,nh}var rh,c1;function mq(){if(c1)return rh;c1=1;var e=pq(),n=lu(),r=Sv(),s=r&&r.isSet,o=s?n(s):e;return rh=o,rh}var ih,d1;function UN(){if(d1)return ih;d1=1;var e=iu(),n=xv(),r=ou(),s=QO(),o=eq(),l=AN(),u=IN(),c=tq(),p=nq(),h=LN(),f=rq(),m=eo(),y=aq(),x=dq(),C=BN(),_=_t(),S=Js(),b=hq(),k=Pn(),N=mq(),j=_i(),P=rs(),O=1,L=2,B=4,T="[object Arguments]",M="[object Array]",q="[object Boolean]",Y="[object Date]",X="[object Error]",I="[object Function]",H="[object GeneratorFunction]",U="[object Map]",ne="[object Number]",J="[object Object]",F="[object RegExp]",G="[object Set]",E="[object String]",$="[object Symbol]",se="[object WeakMap]",D="[object ArrayBuffer]",Q="[object DataView]",ee="[object Float32Array]",oe="[object Float64Array]",ue="[object Int8Array]",ge="[object Int16Array]",de="[object Int32Array]",Ie="[object Uint8Array]",He="[object Uint8ClampedArray]",Pe="[object Uint16Array]",Ae="[object Uint32Array]",ke={};ke[T]=ke[M]=ke[D]=ke[Q]=ke[q]=ke[Y]=ke[ee]=ke[oe]=ke[ue]=ke[ge]=ke[de]=ke[U]=ke[ne]=ke[J]=ke[F]=ke[G]=ke[E]=ke[$]=ke[Ie]=ke[He]=ke[Pe]=ke[Ae]=!0,ke[X]=ke[I]=ke[se]=!1;function Ye(ve,we,Ve,at,lt,We){var $e,it=we&O,vt=we&L,tt=we&B;if(Ve&&($e=lt?Ve(ve,at,lt,We):Ve(ve)),$e!==void 0)return $e;if(!k(ve))return ve;var qt=_(ve);if(qt){if($e=y(ve),!it)return u(ve,$e)}else{var mt=m(ve),Tt=mt==I||mt==H;if(S(ve))return l(ve,it);if(mt==J||mt==T||Tt&&!lt){if($e=vt||Tt?{}:C(ve),!it)return vt?p(ve,o($e,ve)):c(ve,s($e,ve))}else{if(!ke[mt])return lt?ve:{};$e=x(ve,mt,it)}}We||(We=new e);var At=We.get(ve);if(At)return At;We.set(ve,$e),N(ve)?ve.forEach(function(Le){$e.add(Ye(Le,we,Ve,Le,ve,We))}):b(ve)&&ve.forEach(function(Le,wt){$e.set(wt,Ye(Le,we,Ve,wt,ve,We))});var Ze=tt?vt?f:h:vt?P:j,yt=qt?void 0:Ze(ve);return n(yt||ve,function(Le,wt){yt&&(wt=Le,Le=ve[wt]),r($e,wt,Ye(Le,we,Ve,wt,ve,We))}),$e}return ih=Ye,ih}var sh,f1;function gq(){if(f1)return sh;f1=1;var e=UN(),n=4;function r(s){return e(s,n)}return sh=r,sh}var oh,h1;function Cv(){if(h1)return oh;h1=1;function e(n){return function(){return n}}return oh=e,oh}var ah,p1;function vq(){if(p1)return ah;p1=1;function e(n){return function(r,s,o){for(var l=-1,u=Object(r),c=o(r),p=c.length;p--;){var h=c[n?p:++l];if(s(u[h],h,u)===!1)break}return r}}return ah=e,ah}var lh,m1;function jv(){if(m1)return lh;m1=1;var e=vq(),n=e();return lh=n,lh}var uh,g1;function Rv(){if(g1)return uh;g1=1;var e=jv(),n=_i();function r(s,o){return s&&e(s,o,n)}return uh=r,uh}var ch,v1;function yq(){if(v1)return ch;v1=1;var e=qr();function n(r,s){return function(o,l){if(o==null)return o;if(!e(o))return r(o,l);for(var u=o.length,c=s?u:-1,p=Object(o);(s?c--:++c<u)&&l(p[c],c,p)!==!1;);return o}}return ch=n,ch}var dh,y1;function du(){if(y1)return dh;y1=1;var e=Rv(),n=yq(),r=n(e);return dh=r,dh}var fh,w1;function is(){if(w1)return fh;w1=1;function e(n){return n}return fh=e,fh}var hh,x1;function HN(){if(x1)return hh;x1=1;var e=is();function n(r){return typeof r=="function"?r:e}return hh=n,hh}var ph,_1;function VN(){if(_1)return ph;_1=1;var e=xv(),n=du(),r=HN(),s=_t();function o(l,u){var c=s(l)?e:n;return c(l,r(u))}return ph=o,ph}var mh,S1;function WN(){return S1||(S1=1,mh=VN()),mh}var gh,b1;function wq(){if(b1)return gh;b1=1;var e=du();function n(r,s){var o=[];return e(r,function(l,u,c){s(l,u,c)&&o.push(l)}),o}return gh=n,gh}var vh,k1;function xq(){if(k1)return vh;k1=1;var e="__lodash_hash_undefined__";function n(r){return this.__data__.set(r,e),this}return vh=n,vh}var yh,E1;function _q(){if(E1)return yh;E1=1;function e(n){return this.__data__.has(n)}return yh=e,yh}var wh,N1;function GN(){if(N1)return wh;N1=1;var e=wv(),n=xq(),r=_q();function s(o){var l=-1,u=o==null?0:o.length;for(this.__data__=new e;++l<u;)this.add(o[l])}return s.prototype.add=s.prototype.push=n,s.prototype.has=r,wh=s,wh}var xh,C1;function Sq(){if(C1)return xh;C1=1;function e(n,r){for(var s=-1,o=n==null?0:n.length;++s<o;)if(r(n[s],s,n))return!0;return!1}return xh=e,xh}var _h,j1;function YN(){if(j1)return _h;j1=1;function e(n,r){return n.has(r)}return _h=e,_h}var Sh,R1;function KN(){if(R1)return Sh;R1=1;var e=GN(),n=Sq(),r=YN(),s=1,o=2;function l(u,c,p,h,f,m){var y=p&s,x=u.length,C=c.length;if(x!=C&&!(y&&C>x))return!1;var _=m.get(u),S=m.get(c);if(_&&S)return _==c&&S==u;var b=-1,k=!0,N=p&o?new e:void 0;for(m.set(u,c),m.set(c,u);++b<x;){var j=u[b],P=c[b];if(h)var O=y?h(P,j,b,c,u,m):h(j,P,b,u,c,m);if(O!==void 0){if(O)continue;k=!1;break}if(N){if(!n(c,function(L,B){if(!r(N,B)&&(j===L||f(j,L,p,h,m)))return N.push(B)})){k=!1;break}}else if(!(j===P||f(j,P,p,h,m))){k=!1;break}}return m.delete(u),m.delete(c),k}return Sh=l,Sh}var bh,T1;function bq(){if(T1)return bh;T1=1;function e(n){var r=-1,s=Array(n.size);return n.forEach(function(o,l){s[++r]=[l,o]}),s}return bh=e,bh}var kh,A1;function Tv(){if(A1)return kh;A1=1;function e(n){var r=-1,s=Array(n.size);return n.forEach(function(o){s[++r]=o}),s}return kh=e,kh}var Eh,I1;function kq(){if(I1)return Eh;I1=1;var e=Zs(),n=DN(),r=Qs(),s=KN(),o=bq(),l=Tv(),u=1,c=2,p="[object Boolean]",h="[object Date]",f="[object Error]",m="[object Map]",y="[object Number]",x="[object RegExp]",C="[object Set]",_="[object String]",S="[object Symbol]",b="[object ArrayBuffer]",k="[object DataView]",N=e?e.prototype:void 0,j=N?N.valueOf:void 0;function P(O,L,B,T,M,q,Y){switch(B){case k:if(O.byteLength!=L.byteLength||O.byteOffset!=L.byteOffset)return!1;O=O.buffer,L=L.buffer;case b:return!(O.byteLength!=L.byteLength||!q(new n(O),new n(L)));case p:case h:case y:return r(+O,+L);case f:return O.name==L.name&&O.message==L.message;case x:case _:return O==L+"";case m:var X=o;case C:var I=T&u;if(X||(X=l),O.size!=L.size&&!I)return!1;var H=Y.get(O);if(H)return H==L;T|=c,Y.set(O,L);var U=s(X(O),X(L),T,M,q,Y);return Y.delete(O),U;case S:if(j)return j.call(O)==j.call(L)}return!1}return Eh=P,Eh}var Nh,M1;function Eq(){if(M1)return Nh;M1=1;var e=LN(),n=1,r=Object.prototype,s=r.hasOwnProperty;function o(l,u,c,p,h,f){var m=c&n,y=e(l),x=y.length,C=e(u),_=C.length;if(x!=_&&!m)return!1;for(var S=x;S--;){var b=y[S];if(!(m?b in u:s.call(u,b)))return!1}var k=f.get(l),N=f.get(u);if(k&&N)return k==u&&N==l;var j=!0;f.set(l,u),f.set(u,l);for(var P=m;++S<x;){b=y[S];var O=l[b],L=u[b];if(p)var B=m?p(L,O,b,u,l,f):p(O,L,b,l,u,f);if(!(B===void 0?O===L||h(O,L,c,p,f):B)){j=!1;break}P||(P=b=="constructor")}if(j&&!P){var T=l.constructor,M=u.constructor;T!=M&&"constructor"in l&&"constructor"in u&&!(typeof T=="function"&&T instanceof T&&typeof M=="function"&&M instanceof M)&&(j=!1)}return f.delete(l),f.delete(u),j}return Nh=o,Nh}var Ch,P1;function Nq(){if(P1)return Ch;P1=1;var e=iu(),n=KN(),r=kq(),s=Eq(),o=eo(),l=_t(),u=Js(),c=pa(),p=1,h="[object Arguments]",f="[object Array]",m="[object Object]",y=Object.prototype,x=y.hasOwnProperty;function C(_,S,b,k,N,j){var P=l(_),O=l(S),L=P?f:o(_),B=O?f:o(S);L=L==h?m:L,B=B==h?m:B;var T=L==m,M=B==m,q=L==B;if(q&&u(_)){if(!u(S))return!1;P=!0,T=!1}if(q&&!T)return j||(j=new e),P||c(_)?n(_,S,b,k,N,j):r(_,S,L,b,k,N,j);if(!(b&p)){var Y=T&&x.call(_,"__wrapped__"),X=M&&x.call(S,"__wrapped__");if(Y||X){var I=Y?_.value():_,H=X?S.value():S;return j||(j=new e),N(I,H,b,k,j)}}return q?(j||(j=new e),s(_,S,b,k,N,j)):!1}return Ch=C,Ch}var jh,O1;function XN(){if(O1)return jh;O1=1;var e=Nq(),n=hr();function r(s,o,l,u,c){return s===o?!0:s==null||o==null||!n(s)&&!n(o)?s!==s&&o!==o:e(s,o,l,u,r,c)}return jh=r,jh}var Rh,q1;function Cq(){if(q1)return Rh;q1=1;var e=iu(),n=XN(),r=1,s=2;function o(l,u,c,p){var h=c.length,f=h,m=!p;if(l==null)return!f;for(l=Object(l);h--;){var y=c[h];if(m&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++h<f;){y=c[h];var x=y[0],C=l[x],_=y[1];if(m&&y[2]){if(C===void 0&&!(x in l))return!1}else{var S=new e;if(p)var b=p(C,_,x,l,u,S);if(!(b===void 0?n(_,C,r|s,p,S):b))return!1}}return!0}return Rh=o,Rh}var Th,L1;function QN(){if(L1)return Th;L1=1;var e=Pn();function n(r){return r===r&&!e(r)}return Th=n,Th}var Ah,$1;function jq(){if($1)return Ah;$1=1;var e=QN(),n=_i();function r(s){for(var o=n(s),l=o.length;l--;){var u=o[l],c=s[u];o[l]=[u,c,e(c)]}return o}return Ah=r,Ah}var Ih,D1;function ZN(){if(D1)return Ih;D1=1;function e(n,r){return function(s){return s==null?!1:s[n]===r&&(r!==void 0||n in Object(s))}}return Ih=e,Ih}var Mh,F1;function Rq(){if(F1)return Mh;F1=1;var e=Cq(),n=jq(),r=ZN();function s(o){var l=n(o);return l.length==1&&l[0][2]?r(l[0][0],l[0][1]):function(u){return u===o||e(u,o,l)}}return Mh=s,Mh}var Ph,z1;function to(){if(z1)return Ph;z1=1;var e=ts(),n=hr(),r="[object Symbol]";function s(o){return typeof o=="symbol"||n(o)&&e(o)==r}return Ph=s,Ph}var Oh,B1;function Av(){if(B1)return Oh;B1=1;var e=_t(),n=to(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function o(l,u){if(e(l))return!1;var c=typeof l;return c=="number"||c=="symbol"||c=="boolean"||l==null||n(l)?!0:s.test(l)||!r.test(l)||u!=null&&l in Object(u)}return Oh=o,Oh}var qh,U1;function Tq(){if(U1)return qh;U1=1;var e=wv(),n="Expected a function";function r(s,o){if(typeof s!="function"||o!=null&&typeof o!="function")throw new TypeError(n);var l=function(){var u=arguments,c=o?o.apply(this,u):u[0],p=l.cache;if(p.has(c))return p.get(c);var h=s.apply(this,u);return l.cache=p.set(c,h)||p,h};return l.cache=new(r.Cache||e),l}return r.Cache=e,qh=r,qh}var Lh,H1;function Aq(){if(H1)return Lh;H1=1;var e=Tq(),n=500;function r(s){var o=e(s,function(u){return l.size===n&&l.clear(),u}),l=o.cache;return o}return Lh=r,Lh}var $h,V1;function Iq(){if(V1)return $h;V1=1;var e=Aq(),n=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,s=e(function(o){var l=[];return o.charCodeAt(0)===46&&l.push(""),o.replace(n,function(u,c,p,h){l.push(p?h.replace(r,"$1"):c||u)}),l});return $h=s,$h}var Dh,W1;function fu(){if(W1)return Dh;W1=1;function e(n,r){for(var s=-1,o=n==null?0:n.length,l=Array(o);++s<o;)l[s]=r(n[s],s,n);return l}return Dh=e,Dh}var Fh,G1;function Mq(){if(G1)return Fh;G1=1;var e=Zs(),n=fu(),r=_t(),s=to(),o=e?e.prototype:void 0,l=o?o.toString:void 0;function u(c){if(typeof c=="string")return c;if(r(c))return n(c,u)+"";if(s(c))return l?l.call(c):"";var p=c+"";return p=="0"&&1/c==-1/0?"-0":p}return Fh=u,Fh}var zh,Y1;function JN(){if(Y1)return zh;Y1=1;var e=Mq();function n(r){return r==null?"":e(r)}return zh=n,zh}var Bh,K1;function hu(){if(K1)return Bh;K1=1;var e=_t(),n=Av(),r=Iq(),s=JN();function o(l,u){return e(l)?l:n(l,u)?[l]:r(s(l))}return Bh=o,Bh}var Uh,X1;function ma(){if(X1)return Uh;X1=1;var e=to();function n(r){if(typeof r=="string"||e(r))return r;var s=r+"";return s=="0"&&1/r==-1/0?"-0":s}return Uh=n,Uh}var Hh,Q1;function pu(){if(Q1)return Hh;Q1=1;var e=hu(),n=ma();function r(s,o){o=e(o,s);for(var l=0,u=o.length;s!=null&&l<u;)s=s[n(o[l++])];return l&&l==u?s:void 0}return Hh=r,Hh}var Vh,Z1;function Pq(){if(Z1)return Vh;Z1=1;var e=pu();function n(r,s,o){var l=r==null?void 0:e(r,s);return l===void 0?o:l}return Vh=n,Vh}var Wh,J1;function Oq(){if(J1)return Wh;J1=1;function e(n,r){return n!=null&&r in Object(n)}return Wh=e,Wh}var Gh,eS;function eC(){if(eS)return Gh;eS=1;var e=hu(),n=ha(),r=_t(),s=au(),o=_v(),l=ma();function u(c,p,h){p=e(p,c);for(var f=-1,m=p.length,y=!1;++f<m;){var x=l(p[f]);if(!(y=c!=null&&h(c,x)))break;c=c[x]}return y||++f!=m?y:(m=c==null?0:c.length,!!m&&o(m)&&s(x,m)&&(r(c)||n(c)))}return Gh=u,Gh}var Yh,tS;function tC(){if(tS)return Yh;tS=1;var e=Oq(),n=eC();function r(s,o){return s!=null&&n(s,o,e)}return Yh=r,Yh}var Kh,nS;function qq(){if(nS)return Kh;nS=1;var e=XN(),n=Pq(),r=tC(),s=Av(),o=QN(),l=ZN(),u=ma(),c=1,p=2;function h(f,m){return s(f)&&o(m)?l(u(f),m):function(y){var x=n(y,f);return x===void 0&&x===m?r(y,f):e(m,x,c|p)}}return Kh=h,Kh}var Xh,rS;function nC(){if(rS)return Xh;rS=1;function e(n){return function(r){return r==null?void 0:r[n]}}return Xh=e,Xh}var Qh,iS;function Lq(){if(iS)return Qh;iS=1;var e=pu();function n(r){return function(s){return e(s,r)}}return Qh=n,Qh}var Zh,sS;function $q(){if(sS)return Zh;sS=1;var e=nC(),n=Lq(),r=Av(),s=ma();function o(l){return r(l)?e(s(l)):n(l)}return Zh=o,Zh}var Jh,oS;function Lr(){if(oS)return Jh;oS=1;var e=Rq(),n=qq(),r=is(),s=_t(),o=$q();function l(u){return typeof u=="function"?u:u==null?r:typeof u=="object"?s(u)?n(u[0],u[1]):e(u):o(u)}return Jh=l,Jh}var ep,aS;function rC(){if(aS)return ep;aS=1;var e=MN(),n=wq(),r=Lr(),s=_t();function o(l,u){var c=s(l)?e:n;return c(l,r(u,3))}return ep=o,ep}var tp,lS;function Dq(){if(lS)return tp;lS=1;var e=Object.prototype,n=e.hasOwnProperty;function r(s,o){return s!=null&&n.call(s,o)}return tp=r,tp}var np,uS;function iC(){if(uS)return np;uS=1;var e=Dq(),n=eC();function r(s,o){return s!=null&&n(s,o,e)}return np=r,np}var rp,cS;function Fq(){if(cS)return rp;cS=1;var e=bv(),n=eo(),r=ha(),s=_t(),o=qr(),l=Js(),u=uu(),c=pa(),p="[object Map]",h="[object Set]",f=Object.prototype,m=f.hasOwnProperty;function y(x){if(x==null)return!0;if(o(x)&&(s(x)||typeof x=="string"||typeof x.splice=="function"||l(x)||c(x)||r(x)))return!x.length;var C=n(x);if(C==p||C==h)return!x.size;if(u(x))return!e(x).length;for(var _ in x)if(m.call(x,_))return!1;return!0}return rp=y,rp}var ip,dS;function sC(){if(dS)return ip;dS=1;function e(n){return n===void 0}return ip=e,ip}var sp,fS;function oC(){if(fS)return sp;fS=1;var e=du(),n=qr();function r(s,o){var l=-1,u=n(s)?Array(s.length):[];return e(s,function(c,p,h){u[++l]=o(c,p,h)}),u}return sp=r,sp}var op,hS;function aC(){if(hS)return op;hS=1;var e=fu(),n=Lr(),r=oC(),s=_t();function o(l,u){var c=s(l)?e:r;return c(l,n(u,3))}return op=o,op}var ap,pS;function zq(){if(pS)return ap;pS=1;function e(n,r,s,o){var l=-1,u=n==null?0:n.length;for(o&&u&&(s=n[++l]);++l<u;)s=r(s,n[l],l,n);return s}return ap=e,ap}var lp,mS;function Bq(){if(mS)return lp;mS=1;function e(n,r,s,o,l){return l(n,function(u,c,p){s=o?(o=!1,u):r(s,u,c,p)}),s}return lp=e,lp}var up,gS;function lC(){if(gS)return up;gS=1;var e=zq(),n=du(),r=Lr(),s=Bq(),o=_t();function l(u,c,p){var h=o(u)?e:s,f=arguments.length<3;return h(u,r(c,4),p,f,n)}return up=l,up}var cp,vS;function Uq(){if(vS)return cp;vS=1;var e=ts(),n=_t(),r=hr(),s="[object String]";function o(l){return typeof l=="string"||!n(l)&&r(l)&&e(l)==s}return cp=o,cp}var dp,yS;function Hq(){if(yS)return dp;yS=1;var e=nC(),n=e("length");return dp=n,dp}var fp,wS;function Vq(){if(wS)return fp;wS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+r+s,l="\\ufe0e\\ufe0f",u="\\u200d",c=RegExp("["+u+e+o+l+"]");function p(h){return c.test(h)}return fp=p,fp}var hp,xS;function Wq(){if(xS)return hp;xS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+r+s,l="\\ufe0e\\ufe0f",u="["+e+"]",c="["+o+"]",p="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+p+")",f="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",x="\\u200d",C=h+"?",_="["+l+"]?",S="(?:"+x+"(?:"+[f,m,y].join("|")+")"+_+C+")*",b=_+C+S,k="(?:"+[f+c+"?",c,m,y,u].join("|")+")",N=RegExp(p+"(?="+p+")|"+k+b,"g");function j(P){for(var O=N.lastIndex=0;N.test(P);)++O;return O}return hp=j,hp}var pp,_S;function Gq(){if(_S)return pp;_S=1;var e=Hq(),n=Vq(),r=Wq();function s(o){return n(o)?r(o):e(o)}return pp=s,pp}var mp,SS;function Yq(){if(SS)return mp;SS=1;var e=bv(),n=eo(),r=qr(),s=Uq(),o=Gq(),l="[object Map]",u="[object Set]";function c(p){if(p==null)return 0;if(r(p))return s(p)?o(p):p.length;var h=n(p);return h==l||h==u?p.size:e(p).length}return mp=c,mp}var gp,bS;function Kq(){if(bS)return gp;bS=1;var e=xv(),n=zN(),r=Rv(),s=Lr(),o=cu(),l=_t(),u=Js(),c=da(),p=Pn(),h=pa();function f(m,y,x){var C=l(m),_=C||u(m)||h(m);if(y=s(y,4),x==null){var S=m&&m.constructor;_?x=C?new S:[]:p(m)?x=c(S)?n(o(m)):{}:x={}}return(_?e:r)(m,function(b,k,N){return y(x,b,k,N)}),x}return gp=f,gp}var vp,kS;function Xq(){if(kS)return vp;kS=1;var e=Zs(),n=ha(),r=_t(),s=e?e.isConcatSpreadable:void 0;function o(l){return r(l)||n(l)||!!(s&&l&&l[s])}return vp=o,vp}var yp,ES;function Iv(){if(ES)return yp;ES=1;var e=Ev(),n=Xq();function r(s,o,l,u,c){var p=-1,h=s.length;for(l||(l=n),c||(c=[]);++p<h;){var f=s[p];o>0&&l(f)?o>1?r(f,o-1,l,u,c):e(c,f):u||(c[c.length]=f)}return c}return yp=r,yp}var wp,NS;function Qq(){if(NS)return wp;NS=1;function e(n,r,s){switch(s.length){case 0:return n.call(r);case 1:return n.call(r,s[0]);case 2:return n.call(r,s[0],s[1]);case 3:return n.call(r,s[0],s[1],s[2])}return n.apply(r,s)}return wp=e,wp}var xp,CS;function uC(){if(CS)return xp;CS=1;var e=Qq(),n=Math.max;function r(s,o,l){return o=n(o===void 0?s.length-1:o,0),function(){for(var u=arguments,c=-1,p=n(u.length-o,0),h=Array(p);++c<p;)h[c]=u[o+c];c=-1;for(var f=Array(o+1);++c<o;)f[c]=u[c];return f[o]=l(h),e(s,this,f)}}return xp=r,xp}var _p,jS;function Zq(){if(jS)return _p;jS=1;var e=Cv(),n=jN(),r=is(),s=n?function(o,l){return n(o,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:r;return _p=s,_p}var Sp,RS;function Jq(){if(RS)return Sp;RS=1;var e=800,n=16,r=Date.now;function s(o){var l=0,u=0;return function(){var c=r(),p=n-(c-u);if(u=c,p>0){if(++l>=e)return arguments[0]}else l=0;return o.apply(void 0,arguments)}}return Sp=s,Sp}var bp,TS;function cC(){if(TS)return bp;TS=1;var e=Zq(),n=Jq(),r=n(e);return bp=r,bp}var kp,AS;function mu(){if(AS)return kp;AS=1;var e=is(),n=uC(),r=cC();function s(o,l){return r(n(o,l,e),o+"")}return kp=s,kp}var Ep,IS;function dC(){if(IS)return Ep;IS=1;function e(n,r,s,o){for(var l=n.length,u=s+(o?1:-1);o?u--:++u<l;)if(r(n[u],u,n))return u;return-1}return Ep=e,Ep}var Np,MS;function eL(){if(MS)return Np;MS=1;function e(n){return n!==n}return Np=e,Np}var Cp,PS;function tL(){if(PS)return Cp;PS=1;function e(n,r,s){for(var o=s-1,l=n.length;++o<l;)if(n[o]===r)return o;return-1}return Cp=e,Cp}var jp,OS;function nL(){if(OS)return jp;OS=1;var e=dC(),n=eL(),r=tL();function s(o,l,u){return l===l?r(o,l,u):e(o,n,u)}return jp=s,jp}var Rp,qS;function rL(){if(qS)return Rp;qS=1;var e=nL();function n(r,s){var o=r==null?0:r.length;return!!o&&e(r,s,0)>-1}return Rp=n,Rp}var Tp,LS;function iL(){if(LS)return Tp;LS=1;function e(n,r,s){for(var o=-1,l=n==null?0:n.length;++o<l;)if(s(r,n[o]))return!0;return!1}return Tp=e,Tp}var Ap,$S;function sL(){if($S)return Ap;$S=1;function e(){}return Ap=e,Ap}var Ip,DS;function oL(){if(DS)return Ip;DS=1;var e=$N(),n=sL(),r=Tv(),s=1/0,o=e&&1/r(new e([,-0]))[1]==s?function(l){return new e(l)}:n;return Ip=o,Ip}var Mp,FS;function aL(){if(FS)return Mp;FS=1;var e=GN(),n=rL(),r=iL(),s=YN(),o=oL(),l=Tv(),u=200;function c(p,h,f){var m=-1,y=n,x=p.length,C=!0,_=[],S=_;if(f)C=!1,y=r;else if(x>=u){var b=h?null:o(p);if(b)return l(b);C=!1,y=s,S=new e}else S=h?[]:_;e:for(;++m<x;){var k=p[m],N=h?h(k):k;if(k=f||k!==0?k:0,C&&N===N){for(var j=S.length;j--;)if(S[j]===N)continue e;h&&S.push(N),_.push(k)}else y(S,N,f)||(S!==_&&S.push(N),_.push(k))}return _}return Mp=c,Mp}var Pp,zS;function fC(){if(zS)return Pp;zS=1;var e=qr(),n=hr();function r(s){return n(s)&&e(s)}return Pp=r,Pp}var Op,BS;function lL(){if(BS)return Op;BS=1;var e=Iv(),n=mu(),r=aL(),s=fC(),o=n(function(l){return r(e(l,1,s,!0))});return Op=o,Op}var qp,US;function uL(){if(US)return qp;US=1;var e=fu();function n(r,s){return e(s,function(o){return r[o]})}return qp=n,qp}var Lp,HS;function hC(){if(HS)return Lp;HS=1;var e=uL(),n=_i();function r(s){return s==null?[]:e(s,n(s))}return Lp=r,Lp}var $p,VS;function On(){if(VS)return $p;VS=1;var e;if(typeof vv=="function")try{e={clone:gq(),constant:Cv(),each:WN(),filter:rC(),has:iC(),isArray:_t(),isEmpty:Fq(),isFunction:da(),isUndefined:sC(),keys:_i(),map:aC(),reduce:lC(),size:Yq(),transform:Kq(),union:lL(),values:hC()}}catch{}return e||(e=window._),$p=e,$p}var Dp,WS;function Mv(){if(WS)return Dp;WS=1;var e=On();Dp=o;var n="\0",r="\0",s="";function o(f){this._isDirected=e.has(f,"directed")?f.directed:!0,this._isMultigraph=e.has(f,"multigraph")?f.multigraph:!1,this._isCompound=e.has(f,"compound")?f.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[r]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(f){return this._label=f,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultNodeLabelFn=f,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var f=this;return e.filter(this.nodes(),function(m){return e.isEmpty(f._in[m])})},o.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(m){return e.isEmpty(f._out[m])})},o.prototype.setNodes=function(f,m){var y=arguments,x=this;return e.each(f,function(C){y.length>1?x.setNode(C,m):x.setNode(C)}),this},o.prototype.setNode=function(f,m){return e.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=m),this):(this._nodes[f]=arguments.length>1?m:this._defaultNodeLabelFn(f),this._isCompound&&(this._parent[f]=r,this._children[f]={},this._children[r][f]=!0),this._in[f]={},this._preds[f]={},this._out[f]={},this._sucs[f]={},++this._nodeCount,this)},o.prototype.node=function(f){return this._nodes[f]},o.prototype.hasNode=function(f){return e.has(this._nodes,f)},o.prototype.removeNode=function(f){var m=this;if(e.has(this._nodes,f)){var y=function(x){m.removeEdge(m._edgeObjs[x])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(x){m.setParent(x)}),delete this._children[f]),e.each(e.keys(this._in[f]),y),delete this._in[f],delete this._preds[f],e.each(e.keys(this._out[f]),y),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},o.prototype.setParent=function(f,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(m))m=r;else{m+="";for(var y=m;!e.isUndefined(y);y=this.parent(y))if(y===f)throw new Error("Setting "+m+" as parent of "+f+" would create a cycle");this.setNode(m)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=m,this._children[m][f]=!0,this},o.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},o.prototype.parent=function(f){if(this._isCompound){var m=this._parent[f];if(m!==r)return m}},o.prototype.children=function(f){if(e.isUndefined(f)&&(f=r),this._isCompound){var m=this._children[f];if(m)return e.keys(m)}else{if(f===r)return this.nodes();if(this.hasNode(f))return[]}},o.prototype.predecessors=function(f){var m=this._preds[f];if(m)return e.keys(m)},o.prototype.successors=function(f){var m=this._sucs[f];if(m)return e.keys(m)},o.prototype.neighbors=function(f){var m=this.predecessors(f);if(m)return e.union(m,this.successors(f))},o.prototype.isLeaf=function(f){var m;return this.isDirected()?m=this.successors(f):m=this.neighbors(f),m.length===0},o.prototype.filterNodes=function(f){var m=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});m.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,S){f(S)&&m.setNode(S,_)}),e.each(this._edgeObjs,function(_){m.hasNode(_.v)&&m.hasNode(_.w)&&m.setEdge(_,y.edge(_))});var x={};function C(_){var S=y.parent(_);return S===void 0||m.hasNode(S)?(x[_]=S,S):S in x?x[S]:C(S)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,C(_))}),m},o.prototype.setDefaultEdgeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultEdgeLabelFn=f,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(f,m){var y=this,x=arguments;return e.reduce(f,function(C,_){return x.length>1?y.setEdge(C,_,m):y.setEdge(C,_),_}),this},o.prototype.setEdge=function(){var f,m,y,x,C=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(f=_.v,m=_.w,y=_.name,arguments.length===2&&(x=arguments[1],C=!0)):(f=_,m=arguments[1],y=arguments[3],arguments.length>2&&(x=arguments[2],C=!0)),f=""+f,m=""+m,e.isUndefined(y)||(y=""+y);var S=c(this._isDirected,f,m,y);if(e.has(this._edgeLabels,S))return C&&(this._edgeLabels[S]=x),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(m),this._edgeLabels[S]=C?x:this._defaultEdgeLabelFn(f,m,y);var b=p(this._isDirected,f,m,y);return f=b.v,m=b.w,Object.freeze(b),this._edgeObjs[S]=b,l(this._preds[m],f),l(this._sucs[f],m),this._in[m][S]=b,this._out[f][S]=b,this._edgeCount++,this},o.prototype.edge=function(f,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,m,y);return this._edgeLabels[x]},o.prototype.hasEdge=function(f,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,m,y);return e.has(this._edgeLabels,x)},o.prototype.removeEdge=function(f,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,m,y),C=this._edgeObjs[x];return C&&(f=C.v,m=C.w,delete this._edgeLabels[x],delete this._edgeObjs[x],u(this._preds[m],f),u(this._sucs[f],m),delete this._in[m][x],delete this._out[f][x],this._edgeCount--),this},o.prototype.inEdges=function(f,m){var y=this._in[f];if(y){var x=e.values(y);return m?e.filter(x,function(C){return C.v===m}):x}},o.prototype.outEdges=function(f,m){var y=this._out[f];if(y){var x=e.values(y);return m?e.filter(x,function(C){return C.w===m}):x}},o.prototype.nodeEdges=function(f,m){var y=this.inEdges(f,m);if(y)return y.concat(this.outEdges(f,m))};function l(f,m){f[m]?f[m]++:f[m]=1}function u(f,m){--f[m]||delete f[m]}function c(f,m,y,x){var C=""+m,_=""+y;if(!f&&C>_){var S=C;C=_,_=S}return C+s+_+s+(e.isUndefined(x)?n:x)}function p(f,m,y,x){var C=""+m,_=""+y;if(!f&&C>_){var S=C;C=_,_=S}var b={v:C,w:_};return x&&(b.name=x),b}function h(f,m){return c(f,m.v,m.w,m.name)}return Dp}var Fp,GS;function cL(){return GS||(GS=1,Fp="2.1.8"),Fp}var zp,YS;function dL(){return YS||(YS=1,zp={Graph:Mv(),version:cL()}),zp}var Bp,KS;function fL(){if(KS)return Bp;KS=1;var e=On(),n=Mv();Bp={write:r,read:l};function r(u){var c={options:{directed:u.isDirected(),multigraph:u.isMultigraph(),compound:u.isCompound()},nodes:s(u),edges:o(u)};return e.isUndefined(u.graph())||(c.value=e.clone(u.graph())),c}function s(u){return e.map(u.nodes(),function(c){var p=u.node(c),h=u.parent(c),f={v:c};return e.isUndefined(p)||(f.value=p),e.isUndefined(h)||(f.parent=h),f})}function o(u){return e.map(u.edges(),function(c){var p=u.edge(c),h={v:c.v,w:c.w};return e.isUndefined(c.name)||(h.name=c.name),e.isUndefined(p)||(h.value=p),h})}function l(u){var c=new n(u.options).setGraph(u.value);return e.each(u.nodes,function(p){c.setNode(p.v,p.value),p.parent&&c.setParent(p.v,p.parent)}),e.each(u.edges,function(p){c.setEdge({v:p.v,w:p.w,name:p.name},p.value)}),c}return Bp}var Up,XS;function hL(){if(XS)return Up;XS=1;var e=On();Up=n;function n(r){var s={},o=[],l;function u(c){e.has(s,c)||(s[c]=!0,l.push(c),e.each(r.successors(c),u),e.each(r.predecessors(c),u))}return e.each(r.nodes(),function(c){l=[],u(c),l.length&&o.push(l)}),o}return Up}var Hp,QS;function pC(){if(QS)return Hp;QS=1;var e=On();Hp=n;function n(){this._arr=[],this._keyIndices={}}return n.prototype.size=function(){return this._arr.length},n.prototype.keys=function(){return this._arr.map(function(r){return r.key})},n.prototype.has=function(r){return e.has(this._keyIndices,r)},n.prototype.priority=function(r){var s=this._keyIndices[r];if(s!==void 0)return this._arr[s].priority},n.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},n.prototype.add=function(r,s){var o=this._keyIndices;if(r=String(r),!e.has(o,r)){var l=this._arr,u=l.length;return o[r]=u,l.push({key:r,priority:s}),this._decrease(u),!0}return!1},n.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key},n.prototype.decrease=function(r,s){var o=this._keyIndices[r];if(s>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[o].priority+" New: "+s);this._arr[o].priority=s,this._decrease(o)},n.prototype._heapify=function(r){var s=this._arr,o=2*r,l=o+1,u=r;o<s.length&&(u=s[o].priority<s[u].priority?o:u,l<s.length&&(u=s[l].priority<s[u].priority?l:u),u!==r&&(this._swap(r,u),this._heapify(u)))},n.prototype._decrease=function(r){for(var s=this._arr,o=s[r].priority,l;r!==0&&(l=r>>1,!(s[l].priority<o));)this._swap(r,l),r=l},n.prototype._swap=function(r,s){var o=this._arr,l=this._keyIndices,u=o[r],c=o[s];o[r]=c,o[s]=u,l[c.key]=r,l[u.key]=s},Hp}var Vp,ZS;function mC(){if(ZS)return Vp;ZS=1;var e=On(),n=pC();Vp=s;var r=e.constant(1);function s(l,u,c,p){return o(l,String(u),c||r,p||function(h){return l.outEdges(h)})}function o(l,u,c,p){var h={},f=new n,m,y,x=function(C){var _=C.v!==m?C.v:C.w,S=h[_],b=c(C),k=y.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+C+" Weight: "+b);k<S.distance&&(S.distance=k,S.predecessor=m,f.decrease(_,k))};for(l.nodes().forEach(function(C){var _=C===u?0:Number.POSITIVE_INFINITY;h[C]={distance:_},f.add(C,_)});f.size()>0&&(m=f.removeMin(),y=h[m],y.distance!==Number.POSITIVE_INFINITY);)p(m).forEach(x);return h}return Vp}var Wp,JS;function pL(){if(JS)return Wp;JS=1;var e=mC(),n=On();Wp=r;function r(s,o,l){return n.transform(s.nodes(),function(u,c){u[c]=e(s,c,o,l)},{})}return Wp}var Gp,eb;function gC(){if(eb)return Gp;eb=1;var e=On();Gp=n;function n(r){var s=0,o=[],l={},u=[];function c(p){var h=l[p]={onStack:!0,lowlink:s,index:s++};if(o.push(p),r.successors(p).forEach(function(y){e.has(l,y)?l[y].onStack&&(h.lowlink=Math.min(h.lowlink,l[y].index)):(c(y),h.lowlink=Math.min(h.lowlink,l[y].lowlink))}),h.lowlink===h.index){var f=[],m;do m=o.pop(),l[m].onStack=!1,f.push(m);while(p!==m);u.push(f)}}return r.nodes().forEach(function(p){e.has(l,p)||c(p)}),u}return Gp}var Yp,tb;function mL(){if(tb)return Yp;tb=1;var e=On(),n=gC();Yp=r;function r(s){return e.filter(n(s),function(o){return o.length>1||o.length===1&&s.hasEdge(o[0],o[0])})}return Yp}var Kp,nb;function gL(){if(nb)return Kp;nb=1;var e=On();Kp=r;var n=e.constant(1);function r(o,l,u){return s(o,l||n,u||function(c){return o.outEdges(c)})}function s(o,l,u){var c={},p=o.nodes();return p.forEach(function(h){c[h]={},c[h][h]={distance:0},p.forEach(function(f){h!==f&&(c[h][f]={distance:Number.POSITIVE_INFINITY})}),u(h).forEach(function(f){var m=f.v===h?f.w:f.v,y=l(f);c[h][m]={distance:y,predecessor:h}})}),p.forEach(function(h){var f=c[h];p.forEach(function(m){var y=c[m];p.forEach(function(x){var C=y[h],_=f[x],S=y[x],b=C.distance+_.distance;b<S.distance&&(S.distance=b,S.predecessor=_.predecessor)})})}),c}return Kp}var Xp,rb;function vC(){if(rb)return Xp;rb=1;var e=On();Xp=n,n.CycleException=r;function n(s){var o={},l={},u=[];function c(p){if(e.has(l,p))throw new r;e.has(o,p)||(l[p]=!0,o[p]=!0,e.each(s.predecessors(p),c),delete l[p],u.push(p))}if(e.each(s.sinks(),c),e.size(o)!==s.nodeCount())throw new r;return u}function r(){}return r.prototype=new Error,Xp}var Qp,ib;function vL(){if(ib)return Qp;ib=1;var e=vC();Qp=n;function n(r){try{e(r)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return Qp}var Zp,sb;function yC(){if(sb)return Zp;sb=1;var e=On();Zp=n;function n(s,o,l){e.isArray(o)||(o=[o]);var u=(s.isDirected()?s.successors:s.neighbors).bind(s),c=[],p={};return e.each(o,function(h){if(!s.hasNode(h))throw new Error("Graph does not have node: "+h);r(s,h,l==="post",p,u,c)}),c}function r(s,o,l,u,c,p){e.has(u,o)||(u[o]=!0,l||p.push(o),e.each(c(o),function(h){r(s,h,l,u,c,p)}),l&&p.push(o))}return Zp}var Jp,ob;function yL(){if(ob)return Jp;ob=1;var e=yC();Jp=n;function n(r,s){return e(r,s,"post")}return Jp}var em,ab;function wL(){if(ab)return em;ab=1;var e=yC();em=n;function n(r,s){return e(r,s,"pre")}return em}var tm,lb;function xL(){if(lb)return tm;lb=1;var e=On(),n=Mv(),r=pC();tm=s;function s(o,l){var u=new n,c={},p=new r,h;function f(y){var x=y.v===h?y.w:y.v,C=p.priority(x);if(C!==void 0){var _=l(y);_<C&&(c[x]=h,p.decrease(x,_))}}if(o.nodeCount()===0)return u;e.each(o.nodes(),function(y){p.add(y,Number.POSITIVE_INFINITY),u.setNode(y)}),p.decrease(o.nodes()[0],0);for(var m=!1;p.size()>0;){if(h=p.removeMin(),e.has(c,h))u.setEdge(h,c[h]);else{if(m)throw new Error("Input graph is not connected: "+o);m=!0}o.nodeEdges(h).forEach(f)}return u}return tm}var nm,ub;function _L(){return ub||(ub=1,nm={components:hL(),dijkstra:mC(),dijkstraAll:pL(),findCycles:mL(),floydWarshall:gL(),isAcyclic:vL(),postorder:yL(),preorder:wL(),prim:xL(),tarjan:gC(),topsort:vC()}),nm}var rm,cb;function SL(){if(cb)return rm;cb=1;var e=dL();return rm={Graph:e.Graph,json:fL(),alg:_L(),version:e.version},rm}var im,db;function Zn(){if(db)return im;db=1;var e;if(typeof vv=="function")try{e=SL()}catch{}return e||(e=window.graphlib),im=e,im}var sm,fb;function bL(){if(fb)return sm;fb=1;var e=UN(),n=1,r=4;function s(o){return e(o,n|r)}return sm=s,sm}var om,hb;function gu(){if(hb)return om;hb=1;var e=Qs(),n=qr(),r=au(),s=Pn();function o(l,u,c){if(!s(c))return!1;var p=typeof u;return(p=="number"?n(c)&&r(u,c.length):p=="string"&&u in c)?e(c[u],l):!1}return om=o,om}var am,pb;function kL(){if(pb)return am;pb=1;var e=mu(),n=Qs(),r=gu(),s=rs(),o=Object.prototype,l=o.hasOwnProperty,u=e(function(c,p){c=Object(c);var h=-1,f=p.length,m=f>2?p[2]:void 0;for(m&&r(p[0],p[1],m)&&(f=1);++h<f;)for(var y=p[h],x=s(y),C=-1,_=x.length;++C<_;){var S=x[C],b=c[S];(b===void 0||n(b,o[S])&&!l.call(c,S))&&(c[S]=y[S])}return c});return am=u,am}var lm,mb;function EL(){if(mb)return lm;mb=1;var e=Lr(),n=qr(),r=_i();function s(o){return function(l,u,c){var p=Object(l);if(!n(l)){var h=e(u,3);l=r(l),u=function(m){return h(p[m],m,p)}}var f=o(l,u,c);return f>-1?p[h?l[f]:f]:void 0}}return lm=s,lm}var um,gb;function NL(){if(gb)return um;gb=1;var e=/\s/;function n(r){for(var s=r.length;s--&&e.test(r.charAt(s)););return s}return um=n,um}var cm,vb;function CL(){if(vb)return cm;vb=1;var e=NL(),n=/^\s+/;function r(s){return s&&s.slice(0,e(s)+1).replace(n,"")}return cm=r,cm}var dm,yb;function jL(){if(yb)return dm;yb=1;var e=CL(),n=Pn(),r=to(),s=NaN,o=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;function p(h){if(typeof h=="number")return h;if(r(h))return s;if(n(h)){var f=typeof h.valueOf=="function"?h.valueOf():h;h=n(f)?f+"":f}if(typeof h!="string")return h===0?h:+h;h=e(h);var m=l.test(h);return m||u.test(h)?c(h.slice(2),m?2:8):o.test(h)?s:+h}return dm=p,dm}var fm,wb;function wC(){if(wb)return fm;wb=1;var e=jL(),n=1/0,r=17976931348623157e292;function s(o){if(!o)return o===0?o:0;if(o=e(o),o===n||o===-n){var l=o<0?-1:1;return l*r}return o===o?o:0}return fm=s,fm}var hm,xb;function RL(){if(xb)return hm;xb=1;var e=wC();function n(r){var s=e(r),o=s%1;return s===s?o?s-o:s:0}return hm=n,hm}var pm,_b;function TL(){if(_b)return pm;_b=1;var e=dC(),n=Lr(),r=RL(),s=Math.max;function o(l,u,c){var p=l==null?0:l.length;if(!p)return-1;var h=c==null?0:r(c);return h<0&&(h=s(p+h,0)),e(l,n(u,3),h)}return pm=o,pm}var mm,Sb;function AL(){if(Sb)return mm;Sb=1;var e=EL(),n=TL(),r=e(n);return mm=r,mm}var gm,bb;function xC(){if(bb)return gm;bb=1;var e=Iv();function n(r){var s=r==null?0:r.length;return s?e(r,1):[]}return gm=n,gm}var vm,kb;function IL(){if(kb)return vm;kb=1;var e=jv(),n=HN(),r=rs();function s(o,l){return o==null?o:e(o,n(l),r)}return vm=s,vm}var ym,Eb;function ML(){if(Eb)return ym;Eb=1;function e(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}return ym=e,ym}var wm,Nb;function PL(){if(Nb)return wm;Nb=1;var e=su(),n=Rv(),r=Lr();function s(o,l){var u={};return l=r(l,3),n(o,function(c,p,h){e(u,p,l(c,p,h))}),u}return wm=s,wm}var xm,Cb;function Pv(){if(Cb)return xm;Cb=1;var e=to();function n(r,s,o){for(var l=-1,u=r.length;++l<u;){var c=r[l],p=s(c);if(p!=null&&(h===void 0?p===p&&!e(p):o(p,h)))var h=p,f=c}return f}return xm=n,xm}var _m,jb;function OL(){if(jb)return _m;jb=1;function e(n,r){return n>r}return _m=e,_m}var Sm,Rb;function qL(){if(Rb)return Sm;Rb=1;var e=Pv(),n=OL(),r=is();function s(o){return o&&o.length?e(o,r,n):void 0}return Sm=s,Sm}var bm,Tb;function _C(){if(Tb)return bm;Tb=1;var e=su(),n=Qs();function r(s,o,l){(l!==void 0&&!n(s[o],l)||l===void 0&&!(o in s))&&e(s,o,l)}return bm=r,bm}var km,Ab;function LL(){if(Ab)return km;Ab=1;var e=ts(),n=cu(),r=hr(),s="[object Object]",o=Function.prototype,l=Object.prototype,u=o.toString,c=l.hasOwnProperty,p=u.call(Object);function h(f){if(!r(f)||e(f)!=s)return!1;var m=n(f);if(m===null)return!0;var y=c.call(m,"constructor")&&m.constructor;return typeof y=="function"&&y instanceof y&&u.call(y)==p}return km=h,km}var Em,Ib;function SC(){if(Ib)return Em;Ib=1;function e(n,r){if(!(r==="constructor"&&typeof n[r]=="function")&&r!="__proto__")return n[r]}return Em=e,Em}var Nm,Mb;function $L(){if(Mb)return Nm;Mb=1;var e=fa(),n=rs();function r(s){return e(s,n(s))}return Nm=r,Nm}var Cm,Pb;function DL(){if(Pb)return Cm;Pb=1;var e=_C(),n=AN(),r=FN(),s=IN(),o=BN(),l=ha(),u=_t(),c=fC(),p=Js(),h=da(),f=Pn(),m=LL(),y=pa(),x=SC(),C=$L();function _(S,b,k,N,j,P,O){var L=x(S,k),B=x(b,k),T=O.get(B);if(T){e(S,k,T);return}var M=P?P(L,B,k+"",S,b,O):void 0,q=M===void 0;if(q){var Y=u(B),X=!Y&&p(B),I=!Y&&!X&&y(B);M=B,Y||X||I?u(L)?M=L:c(L)?M=s(L):X?(q=!1,M=n(B,!0)):I?(q=!1,M=r(B,!0)):M=[]:m(B)||l(B)?(M=L,l(L)?M=C(L):(!f(L)||h(L))&&(M=o(B))):q=!1}q&&(O.set(B,M),j(M,B,N,P,O),O.delete(B)),e(S,k,M)}return Cm=_,Cm}var jm,Ob;function FL(){if(Ob)return jm;Ob=1;var e=iu(),n=_C(),r=jv(),s=DL(),o=Pn(),l=rs(),u=SC();function c(p,h,f,m,y){p!==h&&r(h,function(x,C){if(y||(y=new e),o(x))s(p,h,C,f,c,m,y);else{var _=m?m(u(p,C),x,C+"",p,h,y):void 0;_===void 0&&(_=x),n(p,C,_)}},l)}return jm=c,jm}var Rm,qb;function zL(){if(qb)return Rm;qb=1;var e=mu(),n=gu();function r(s){return e(function(o,l){var u=-1,c=l.length,p=c>1?l[c-1]:void 0,h=c>2?l[2]:void 0;for(p=s.length>3&&typeof p=="function"?(c--,p):void 0,h&&n(l[0],l[1],h)&&(p=c<3?void 0:p,c=1),o=Object(o);++u<c;){var f=l[u];f&&s(o,f,u,p)}return o})}return Rm=r,Rm}var Tm,Lb;function BL(){if(Lb)return Tm;Lb=1;var e=FL(),n=zL(),r=n(function(s,o,l){e(s,o,l)});return Tm=r,Tm}var Am,$b;function bC(){if($b)return Am;$b=1;function e(n,r){return n<r}return Am=e,Am}var Im,Db;function UL(){if(Db)return Im;Db=1;var e=Pv(),n=bC(),r=is();function s(o){return o&&o.length?e(o,r,n):void 0}return Im=s,Im}var Mm,Fb;function HL(){if(Fb)return Mm;Fb=1;var e=Pv(),n=Lr(),r=bC();function s(o,l){return o&&o.length?e(o,n(l,2),r):void 0}return Mm=s,Mm}var Pm,zb;function VL(){if(zb)return Pm;zb=1;var e=er(),n=function(){return e.Date.now()};return Pm=n,Pm}var Om,Bb;function WL(){if(Bb)return Om;Bb=1;var e=ou(),n=hu(),r=au(),s=Pn(),o=ma();function l(u,c,p,h){if(!s(u))return u;c=n(c,u);for(var f=-1,m=c.length,y=m-1,x=u;x!=null&&++f<m;){var C=o(c[f]),_=p;if(C==="__proto__"||C==="constructor"||C==="prototype")return u;if(f!=y){var S=x[C];_=h?h(S,C,x):void 0,_===void 0&&(_=s(S)?S:r(c[f+1])?[]:{})}e(x,C,_),x=x[C]}return u}return Om=l,Om}var qm,Ub;function GL(){if(Ub)return qm;Ub=1;var e=pu(),n=WL(),r=hu();function s(o,l,u){for(var c=-1,p=l.length,h={};++c<p;){var f=l[c],m=e(o,f);u(m,f)&&n(h,r(f,o),m)}return h}return qm=s,qm}var Lm,Hb;function YL(){if(Hb)return Lm;Hb=1;var e=GL(),n=tC();function r(s,o){return e(s,o,function(l,u){return n(s,u)})}return Lm=r,Lm}var $m,Vb;function KL(){if(Vb)return $m;Vb=1;var e=xC(),n=uC(),r=cC();function s(o){return r(n(o,void 0,e),o+"")}return $m=s,$m}var Dm,Wb;function XL(){if(Wb)return Dm;Wb=1;var e=YL(),n=KL(),r=n(function(s,o){return s==null?{}:e(s,o)});return Dm=r,Dm}var Fm,Gb;function QL(){if(Gb)return Fm;Gb=1;var e=Math.ceil,n=Math.max;function r(s,o,l,u){for(var c=-1,p=n(e((o-s)/(l||1)),0),h=Array(p);p--;)h[u?p:++c]=s,s+=l;return h}return Fm=r,Fm}var zm,Yb;function ZL(){if(Yb)return zm;Yb=1;var e=QL(),n=gu(),r=wC();function s(o){return function(l,u,c){return c&&typeof c!="number"&&n(l,u,c)&&(u=c=void 0),l=r(l),u===void 0?(u=l,l=0):u=r(u),c=c===void 0?l<u?1:-1:r(c),e(l,u,c,o)}}return zm=s,zm}var Bm,Kb;function JL(){if(Kb)return Bm;Kb=1;var e=ZL(),n=e();return Bm=n,Bm}var Um,Xb;function e$(){if(Xb)return Um;Xb=1;function e(n,r){var s=n.length;for(n.sort(r);s--;)n[s]=n[s].value;return n}return Um=e,Um}var Hm,Qb;function t$(){if(Qb)return Hm;Qb=1;var e=to();function n(r,s){if(r!==s){var o=r!==void 0,l=r===null,u=r===r,c=e(r),p=s!==void 0,h=s===null,f=s===s,m=e(s);if(!h&&!m&&!c&&r>s||c&&p&&f&&!h&&!m||l&&p&&f||!o&&f||!u)return 1;if(!l&&!c&&!m&&r<s||m&&o&&u&&!l&&!c||h&&o&&u||!p&&u||!f)return-1}return 0}return Hm=n,Hm}var Vm,Zb;function n$(){if(Zb)return Vm;Zb=1;var e=t$();function n(r,s,o){for(var l=-1,u=r.criteria,c=s.criteria,p=u.length,h=o.length;++l<p;){var f=e(u[l],c[l]);if(f){if(l>=h)return f;var m=o[l];return f*(m=="desc"?-1:1)}}return r.index-s.index}return Vm=n,Vm}var Wm,Jb;function r$(){if(Jb)return Wm;Jb=1;var e=fu(),n=pu(),r=Lr(),s=oC(),o=e$(),l=lu(),u=n$(),c=is(),p=_t();function h(f,m,y){m.length?m=e(m,function(_){return p(_)?function(S){return n(S,_.length===1?_[0]:_)}:_}):m=[c];var x=-1;m=e(m,l(r));var C=s(f,function(_,S,b){var k=e(m,function(N){return N(_)});return{criteria:k,index:++x,value:_}});return o(C,function(_,S){return u(_,S,y)})}return Wm=h,Wm}var Gm,ek;function i$(){if(ek)return Gm;ek=1;var e=Iv(),n=r$(),r=mu(),s=gu(),o=r(function(l,u){if(l==null)return[];var c=u.length;return c>1&&s(l,u[0],u[1])?u=[]:c>2&&s(u[0],u[1],u[2])&&(u=[u[0]]),n(l,e(u,1),[])});return Gm=o,Gm}var Ym,tk;function s$(){if(tk)return Ym;tk=1;var e=JN(),n=0;function r(s){var o=++n;return e(s)+o}return Ym=r,Ym}var Km,nk;function o$(){if(nk)return Km;nk=1;function e(n,r,s){for(var o=-1,l=n.length,u=r.length,c={};++o<l;){var p=o<u?r[o]:void 0;s(c,n[o],p)}return c}return Km=e,Km}var Xm,rk;function a$(){if(rk)return Xm;rk=1;var e=ou(),n=o$();function r(s,o){return n(s||[],o||[],e)}return Xm=r,Xm}var Qm,ik;function ot(){if(ik)return Qm;ik=1;var e;if(typeof vv=="function")try{e={cloneDeep:bL(),constant:Cv(),defaults:kL(),each:WN(),filter:rC(),find:AL(),flatten:xC(),forEach:VN(),forIn:IL(),has:iC(),isUndefined:sC(),last:ML(),map:aC(),mapValues:PL(),max:qL(),merge:BL(),min:UL(),minBy:HL(),now:VL(),pick:XL(),range:JL(),reduce:lC(),sortBy:i$(),uniqueId:s$(),values:hC(),zipObject:a$()}}catch{}return e||(e=window._),Qm=e,Qm}var Zm,sk;function l$(){if(sk)return Zm;sk=1,Zm=e;function e(){var s={};s._next=s._prev=s,this._sentinel=s}e.prototype.dequeue=function(){var s=this._sentinel,o=s._prev;if(o!==s)return n(o),o},e.prototype.enqueue=function(s){var o=this._sentinel;s._prev&&s._next&&n(s),s._next=o._next,o._next._prev=s,o._next=s,s._prev=o},e.prototype.toString=function(){for(var s=[],o=this._sentinel,l=o._prev;l!==o;)s.push(JSON.stringify(l,r)),l=l._prev;return"["+s.join(", ")+"]"};function n(s){s._prev._next=s._next,s._next._prev=s._prev,delete s._next,delete s._prev}function r(s,o){if(s!=="_next"&&s!=="_prev")return o}return Zm}var Jm,ok;function u$(){if(ok)return Jm;ok=1;var e=ot(),n=Zn().Graph,r=l$();Jm=o;var s=e.constant(1);function o(h,f){if(h.nodeCount()<=1)return[];var m=c(h,f||s),y=l(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(x){return h.outEdges(x.v,x.w)}),!0)}function l(h,f,m){for(var y=[],x=f[f.length-1],C=f[0],_;h.nodeCount();){for(;_=C.dequeue();)u(h,f,m,_);for(;_=x.dequeue();)u(h,f,m,_);if(h.nodeCount()){for(var S=f.length-2;S>0;--S)if(_=f[S].dequeue(),_){y=y.concat(u(h,f,m,_,!0));break}}}return y}function u(h,f,m,y,x){var C=x?[]:void 0;return e.forEach(h.inEdges(y.v),function(_){var S=h.edge(_),b=h.node(_.v);x&&C.push({v:_.v,w:_.w}),b.out-=S,p(f,m,b)}),e.forEach(h.outEdges(y.v),function(_){var S=h.edge(_),b=_.w,k=h.node(b);k.in-=S,p(f,m,k)}),h.removeNode(y.v),C}function c(h,f){var m=new n,y=0,x=0;e.forEach(h.nodes(),function(S){m.setNode(S,{v:S,in:0,out:0})}),e.forEach(h.edges(),function(S){var b=m.edge(S.v,S.w)||0,k=f(S),N=b+k;m.setEdge(S.v,S.w,N),x=Math.max(x,m.node(S.v).out+=k),y=Math.max(y,m.node(S.w).in+=k)});var C=e.range(x+y+3).map(function(){return new r}),_=y+1;return e.forEach(m.nodes(),function(S){p(C,_,m.node(S))}),{graph:m,buckets:C,zeroIdx:_}}function p(h,f,m){m.out?m.in?h[m.out-m.in+f].enqueue(m):h[h.length-1].enqueue(m):h[0].enqueue(m)}return Jm}var eg,ak;function c$(){if(ak)return eg;ak=1;var e=ot(),n=u$();eg={run:r,undo:o};function r(l){var u=l.graph().acyclicer==="greedy"?n(l,c(l)):s(l);e.forEach(u,function(p){var h=l.edge(p);l.removeEdge(p),h.forwardName=p.name,h.reversed=!0,l.setEdge(p.w,p.v,h,e.uniqueId("rev"))});function c(p){return function(h){return p.edge(h).weight}}}function s(l){var u=[],c={},p={};function h(f){e.has(p,f)||(p[f]=!0,c[f]=!0,e.forEach(l.outEdges(f),function(m){e.has(c,m.w)?u.push(m):h(m.w)}),delete c[f])}return e.forEach(l.nodes(),h),u}function o(l){e.forEach(l.edges(),function(u){var c=l.edge(u);if(c.reversed){l.removeEdge(u);var p=c.forwardName;delete c.reversed,delete c.forwardName,l.setEdge(u.w,u.v,c,p)}})}return eg}var tg,lk;function an(){if(lk)return tg;lk=1;var e=ot(),n=Zn().Graph;tg={addDummyNode:r,simplify:s,asNonCompoundGraph:o,successorWeights:l,predecessorWeights:u,intersectRect:c,buildLayerMatrix:p,normalizeRanks:h,removeEmptyRanks:f,addBorderNode:m,maxRank:y,partition:x,time:C,notime:_};function r(S,b,k,N){var j;do j=e.uniqueId(N);while(S.hasNode(j));return k.dummy=b,S.setNode(j,k),j}function s(S){var b=new n().setGraph(S.graph());return e.forEach(S.nodes(),function(k){b.setNode(k,S.node(k))}),e.forEach(S.edges(),function(k){var N=b.edge(k.v,k.w)||{weight:0,minlen:1},j=S.edge(k);b.setEdge(k.v,k.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(k){S.children(k).length||b.setNode(k,S.node(k))}),e.forEach(S.edges(),function(k){b.setEdge(k,S.edge(k))}),b}function l(S){var b=e.map(S.nodes(),function(k){var N={};return e.forEach(S.outEdges(k),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(k){var N={};return e.forEach(S.inEdges(k),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 k=S.x,N=S.y,j=b.x-k,P=b.y-N,O=S.width/2,L=S.height/2;if(!j&&!P)throw new Error("Not possible to find intersection inside of the rectangle");var B,T;return Math.abs(P)*O>Math.abs(j)*L?(P<0&&(L=-L),B=L*j/P,T=L):(j<0&&(O=-O),B=O,T=O*P/j),{x:k+B,y:N+T}}function p(S){var b=e.map(e.range(y(S)+1),function(){return[]});return e.forEach(S.nodes(),function(k){var N=S.node(k),j=N.rank;e.isUndefined(j)||(b[j][N.order]=k)}),b}function h(S){var b=e.min(e.map(S.nodes(),function(k){return S.node(k).rank}));e.forEach(S.nodes(),function(k){var N=S.node(k);e.has(N,"rank")&&(N.rank-=b)})}function f(S){var b=e.min(e.map(S.nodes(),function(P){return S.node(P).rank})),k=[];e.forEach(S.nodes(),function(P){var O=S.node(P).rank-b;k[O]||(k[O]=[]),k[O].push(P)});var N=0,j=S.graph().nodeRankFactor;e.forEach(k,function(P,O){e.isUndefined(P)&&O%j!==0?--N:N&&e.forEach(P,function(L){S.node(L).rank+=N})})}function m(S,b,k,N){var j={width:0,height:0};return arguments.length>=4&&(j.rank=k,j.order=N),r(S,"border",j,b)}function y(S){return e.max(e.map(S.nodes(),function(b){var k=S.node(b).rank;if(!e.isUndefined(k))return k}))}function x(S,b){var k={lhs:[],rhs:[]};return e.forEach(S,function(N){b(N)?k.lhs.push(N):k.rhs.push(N)}),k}function C(S,b){var k=e.now();try{return b()}finally{console.log(S+" time: "+(e.now()-k)+"ms")}}function _(S,b){return b()}return tg}var ng,uk;function d$(){if(uk)return ng;uk=1;var e=ot(),n=an();ng={run:r,undo:o};function r(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(u){s(l,u)})}function s(l,u){var c=u.v,p=l.node(c).rank,h=u.w,f=l.node(h).rank,m=u.name,y=l.edge(u),x=y.labelRank;if(f!==p+1){l.removeEdge(u);var C,_,S;for(S=0,++p;p<f;++S,++p)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:u,rank:p},C=n.addDummyNode(l,"edge",_,"_d"),p===x&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),l.setEdge(c,C,{weight:y.weight},m),S===0&&l.graph().dummyChains.push(C),c=C;l.setEdge(c,h,{weight:y.weight},m)}}function o(l){e.forEach(l.graph().dummyChains,function(u){var c=l.node(u),p=c.edgeLabel,h;for(l.setEdge(c.edgeObj,p);c.dummy;)h=l.successors(u)[0],l.removeNode(u),p.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(p.x=c.x,p.y=c.y,p.width=c.width,p.height=c.height),u=h,c=l.node(u)})}return ng}var rg,ck;function Wl(){if(ck)return rg;ck=1;var e=ot();rg={longestPath:n,slack:r};function n(s){var o={};function l(u){var c=s.node(u);if(e.has(o,u))return c.rank;o[u]=!0;var p=e.min(e.map(s.outEdges(u),function(h){return l(h.w)-s.edge(h).minlen}));return(p===Number.POSITIVE_INFINITY||p===void 0||p===null)&&(p=0),c.rank=p}e.forEach(s.sources(),l)}function r(s,o){return s.node(o.w).rank-s.node(o.v).rank-s.edge(o).minlen}return rg}var ig,dk;function kC(){if(dk)return ig;dk=1;var e=ot(),n=Zn().Graph,r=Wl().slack;ig=s;function s(c){var p=new n({directed:!1}),h=c.nodes()[0],f=c.nodeCount();p.setNode(h,{});for(var m,y;o(p,c)<f;)m=l(p,c),y=p.hasNode(m.v)?r(c,m):-r(c,m),u(p,c,y);return p}function o(c,p){function h(f){e.forEach(p.nodeEdges(f),function(m){var y=m.v,x=f===y?m.w:y;!c.hasNode(x)&&!r(p,m)&&(c.setNode(x,{}),c.setEdge(f,x,{}),h(x))})}return e.forEach(c.nodes(),h),c.nodeCount()}function l(c,p){return e.minBy(p.edges(),function(h){if(c.hasNode(h.v)!==c.hasNode(h.w))return r(p,h)})}function u(c,p,h){e.forEach(c.nodes(),function(f){p.node(f).rank+=h})}return ig}var sg,fk;function f$(){if(fk)return sg;fk=1;var e=ot(),n=kC(),r=Wl().slack,s=Wl().longestPath,o=Zn().alg.preorder,l=Zn().alg.postorder,u=an().simplify;sg=c,c.initLowLimValues=m,c.initCutValues=p,c.calcCutValue=f,c.leaveEdge=x,c.enterEdge=C,c.exchangeEdges=_;function c(N){N=u(N),s(N);var j=n(N);m(j),p(j,N);for(var P,O;P=x(j);)O=C(j,N,P),_(j,N,P,O)}function p(N,j){var P=l(N,N.nodes());P=P.slice(0,P.length-1),e.forEach(P,function(O){h(N,j,O)})}function h(N,j,P){var O=N.node(P),L=O.parent;N.edge(P,L).cutvalue=f(N,j,P)}function f(N,j,P){var O=N.node(P),L=O.parent,B=!0,T=j.edge(P,L),M=0;return T||(B=!1,T=j.edge(L,P)),M=T.weight,e.forEach(j.nodeEdges(P),function(q){var Y=q.v===P,X=Y?q.w:q.v;if(X!==L){var I=Y===B,H=j.edge(q).weight;if(M+=I?H:-H,b(N,P,X)){var U=N.edge(P,X).cutvalue;M+=I?-U:U}}}),M}function m(N,j){arguments.length<2&&(j=N.nodes()[0]),y(N,{},1,j)}function y(N,j,P,O,L){var B=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=B,T.lim=P++,L?T.parent=L:delete T.parent,P}function x(N){return e.find(N.edges(),function(j){return N.edge(j).cutvalue<0})}function C(N,j,P){var O=P.v,L=P.w;j.hasEdge(O,L)||(O=P.w,L=P.v);var B=N.node(O),T=N.node(L),M=B,q=!1;B.lim>T.lim&&(M=T,q=!0);var Y=e.filter(j.edges(),function(X){return q===k(N,N.node(X.v),M)&&q!==k(N,N.node(X.w),M)});return e.minBy(Y,function(X){return r(j,X)})}function _(N,j,P,O){var L=P.v,B=P.w;N.removeEdge(L,B),N.setEdge(O.v,O.w,{}),m(N),p(N,j),S(N,j)}function S(N,j){var P=e.find(N.nodes(),function(L){return!j.node(L).parent}),O=o(N,P);O=O.slice(1),e.forEach(O,function(L){var B=N.node(L).parent,T=j.edge(L,B),M=!1;T||(T=j.edge(B,L),M=!0),j.node(L).rank=j.node(B).rank+(M?T.minlen:-T.minlen)})}function b(N,j,P){return N.hasEdge(j,P)}function k(N,j,P){return P.low<=j.lim&&j.lim<=P.lim}return sg}var og,hk;function h$(){if(hk)return og;hk=1;var e=Wl(),n=e.longestPath,r=kC(),s=f$();og=o;function o(p){switch(p.graph().ranker){case"network-simplex":c(p);break;case"tight-tree":u(p);break;case"longest-path":l(p);break;default:c(p)}}var l=n;function u(p){n(p),r(p)}function c(p){s(p)}return og}var ag,pk;function p$(){if(pk)return ag;pk=1;var e=ot();ag=n;function n(o){var l=s(o);e.forEach(o.graph().dummyChains,function(u){for(var c=o.node(u),p=c.edgeObj,h=r(o,l,p.v,p.w),f=h.path,m=h.lca,y=0,x=f[y],C=!0;u!==p.w;){if(c=o.node(u),C){for(;(x=f[y])!==m&&o.node(x).maxRank<c.rank;)y++;x===m&&(C=!1)}if(!C){for(;y<f.length-1&&o.node(x=f[y+1]).minRank<=c.rank;)y++;x=f[y]}o.setParent(u,x),u=o.successors(u)[0]}})}function r(o,l,u,c){var p=[],h=[],f=Math.min(l[u].low,l[c].low),m=Math.max(l[u].lim,l[c].lim),y,x;y=u;do y=o.parent(y),p.push(y);while(y&&(l[y].low>f||m>l[y].lim));for(x=y,y=c;(y=o.parent(y))!==x;)h.push(y);return{path:p.concat(h.reverse()),lca:x}}function s(o){var l={},u=0;function c(p){var h=u;e.forEach(o.children(p),c),l[p]={low:h,lim:u++}}return e.forEach(o.children(),c),l}return ag}var lg,mk;function m$(){if(mk)return lg;mk=1;var e=ot(),n=an();lg={run:r,cleanup:u};function r(c){var p=n.addDummyNode(c,"root",{},"_root"),h=o(c),f=e.max(e.values(h))-1,m=2*f+1;c.graph().nestingRoot=p,e.forEach(c.edges(),function(x){c.edge(x).minlen*=m});var y=l(c)+1;e.forEach(c.children(),function(x){s(c,p,m,y,f,h,x)}),c.graph().nodeRankFactor=m}function s(c,p,h,f,m,y,x){var C=c.children(x);if(!C.length){x!==p&&c.setEdge(p,x,{weight:0,minlen:h});return}var _=n.addBorderNode(c,"_bt"),S=n.addBorderNode(c,"_bb"),b=c.node(x);c.setParent(_,x),b.borderTop=_,c.setParent(S,x),b.borderBottom=S,e.forEach(C,function(k){s(c,p,h,f,m,y,k);var N=c.node(k),j=N.borderTop?N.borderTop:k,P=N.borderBottom?N.borderBottom:k,O=N.borderTop?f:2*f,L=j!==P?1:m-y[x]+1;c.setEdge(_,j,{weight:O,minlen:L,nestingEdge:!0}),c.setEdge(P,S,{weight:O,minlen:L,nestingEdge:!0})}),c.parent(x)||c.setEdge(p,_,{weight:0,minlen:m+y[x]})}function o(c){var p={};function h(f,m){var y=c.children(f);y&&y.length&&e.forEach(y,function(x){h(x,m+1)}),p[f]=m}return e.forEach(c.children(),function(f){h(f,1)}),p}function l(c){return e.reduce(c.edges(),function(p,h){return p+c.edge(h).weight},0)}function u(c){var p=c.graph();c.removeNode(p.nestingRoot),delete p.nestingRoot,e.forEach(c.edges(),function(h){var f=c.edge(h);f.nestingEdge&&c.removeEdge(h)})}return lg}var ug,gk;function g$(){if(gk)return ug;gk=1;var e=ot(),n=an();ug=r;function r(o){function l(u){var c=o.children(u),p=o.node(u);if(c.length&&e.forEach(c,l),e.has(p,"minRank")){p.borderLeft=[],p.borderRight=[];for(var h=p.minRank,f=p.maxRank+1;h<f;++h)s(o,"borderLeft","_bl",u,p,h),s(o,"borderRight","_br",u,p,h)}}e.forEach(o.children(),l)}function s(o,l,u,c,p,h){var f={width:0,height:0,rank:h,borderType:l},m=p[l][h-1],y=n.addDummyNode(o,"border",f,u);p[l][h]=y,o.setParent(y,c),m&&o.setEdge(m,y,{weight:1})}return ug}var cg,vk;function v$(){if(vk)return cg;vk=1;var e=ot();cg={adjust:n,undo:r};function n(h){var f=h.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&s(h)}function r(h){var f=h.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&l(h),(f==="lr"||f==="rl")&&(c(h),s(h))}function s(h){e.forEach(h.nodes(),function(f){o(h.node(f))}),e.forEach(h.edges(),function(f){o(h.edge(f))})}function o(h){var f=h.width;h.width=h.height,h.height=f}function l(h){e.forEach(h.nodes(),function(f){u(h.node(f))}),e.forEach(h.edges(),function(f){var m=h.edge(f);e.forEach(m.points,u),e.has(m,"y")&&u(m)})}function u(h){h.y=-h.y}function c(h){e.forEach(h.nodes(),function(f){p(h.node(f))}),e.forEach(h.edges(),function(f){var m=h.edge(f);e.forEach(m.points,p),e.has(m,"x")&&p(m)})}function p(h){var f=h.x;h.x=h.y,h.y=f}return cg}var dg,yk;function y$(){if(yk)return dg;yk=1;var e=ot();dg=n;function n(r){var s={},o=e.filter(r.nodes(),function(h){return!r.children(h).length}),l=e.max(e.map(o,function(h){return r.node(h).rank})),u=e.map(e.range(l+1),function(){return[]});function c(h){if(!e.has(s,h)){s[h]=!0;var f=r.node(h);u[f.rank].push(h),e.forEach(r.successors(h),c)}}var p=e.sortBy(o,function(h){return r.node(h).rank});return e.forEach(p,c),u}return dg}var fg,wk;function w$(){if(wk)return fg;wk=1;var e=ot();fg=n;function n(s,o){for(var l=0,u=1;u<o.length;++u)l+=r(s,o[u-1],o[u]);return l}function r(s,o,l){for(var u=e.zipObject(l,e.map(l,function(y,x){return x})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(s.outEdges(y),function(x){return{pos:u[x.w],weight:s.edge(x).weight}}),"pos")}),!0),p=1;p<l.length;)p<<=1;var h=2*p-1;p-=1;var f=e.map(new Array(h),function(){return 0}),m=0;return e.forEach(c.forEach(function(y){var x=y.pos+p;f[x]+=y.weight;for(var C=0;x>0;)x%2&&(C+=f[x+1]),x=x-1>>1,f[x]+=y.weight;m+=y.weight*C})),m}return fg}var hg,xk;function x$(){if(xk)return hg;xk=1;var e=ot();hg=n;function n(r,s){return e.map(s,function(o){var l=r.inEdges(o);if(l.length){var u=e.reduce(l,function(c,p){var h=r.edge(p),f=r.node(p.v);return{sum:c.sum+h.weight*f.order,weight:c.weight+h.weight}},{sum:0,weight:0});return{v:o,barycenter:u.sum/u.weight,weight:u.weight}}else return{v:o}})}return hg}var pg,_k;function _$(){if(_k)return pg;_k=1;var e=ot();pg=n;function n(o,l){var u={};e.forEach(o,function(p,h){var f=u[p.v]={indegree:0,in:[],out:[],vs:[p.v],i:h};e.isUndefined(p.barycenter)||(f.barycenter=p.barycenter,f.weight=p.weight)}),e.forEach(l.edges(),function(p){var h=u[p.v],f=u[p.w];!e.isUndefined(h)&&!e.isUndefined(f)&&(f.indegree++,h.out.push(u[p.w]))});var c=e.filter(u,function(p){return!p.indegree});return r(c)}function r(o){var l=[];function u(h){return function(f){f.merged||(e.isUndefined(f.barycenter)||e.isUndefined(h.barycenter)||f.barycenter>=h.barycenter)&&s(h,f)}}function c(h){return function(f){f.in.push(h),--f.indegree===0&&o.push(f)}}for(;o.length;){var p=o.pop();l.push(p),e.forEach(p.in.reverse(),u(p)),e.forEach(p.out,c(p))}return e.map(e.filter(l,function(h){return!h.merged}),function(h){return e.pick(h,["vs","i","barycenter","weight"])})}function s(o,l){var u=0,c=0;o.weight&&(u+=o.barycenter*o.weight,c+=o.weight),l.weight&&(u+=l.barycenter*l.weight,c+=l.weight),o.vs=l.vs.concat(o.vs),o.barycenter=u/c,o.weight=c,o.i=Math.min(l.i,o.i),l.merged=!0}return pg}var mg,Sk;function S$(){if(Sk)return mg;Sk=1;var e=ot(),n=an();mg=r;function r(l,u){var c=n.partition(l,function(_){return e.has(_,"barycenter")}),p=c.lhs,h=e.sortBy(c.rhs,function(_){return-_.i}),f=[],m=0,y=0,x=0;p.sort(o(!!u)),x=s(f,h,x),e.forEach(p,function(_){x+=_.vs.length,f.push(_.vs),m+=_.barycenter*_.weight,y+=_.weight,x=s(f,h,x)});var C={vs:e.flatten(f,!0)};return y&&(C.barycenter=m/y,C.weight=y),C}function s(l,u,c){for(var p;u.length&&(p=e.last(u)).i<=c;)u.pop(),l.push(p.vs),c++;return c}function o(l){return function(u,c){return u.barycenter<c.barycenter?-1:u.barycenter>c.barycenter?1:l?c.i-u.i:u.i-c.i}}return mg}var gg,bk;function b$(){if(bk)return gg;bk=1;var e=ot(),n=x$(),r=_$(),s=S$();gg=o;function o(c,p,h,f){var m=c.children(p),y=c.node(p),x=y?y.borderLeft:void 0,C=y?y.borderRight:void 0,_={};x&&(m=e.filter(m,function(P){return P!==x&&P!==C}));var S=n(c,m);e.forEach(S,function(P){if(c.children(P.v).length){var O=o(c,P.v,h,f);_[P.v]=O,e.has(O,"barycenter")&&u(P,O)}});var b=r(S,h);l(b,_);var k=s(b,f);if(x&&(k.vs=e.flatten([x,k.vs,C],!0),c.predecessors(x).length)){var N=c.node(c.predecessors(x)[0]),j=c.node(c.predecessors(C)[0]);e.has(k,"barycenter")||(k.barycenter=0,k.weight=0),k.barycenter=(k.barycenter*k.weight+N.order+j.order)/(k.weight+2),k.weight+=2}return k}function l(c,p){e.forEach(c,function(h){h.vs=e.flatten(h.vs.map(function(f){return p[f]?p[f].vs:f}),!0)})}function u(c,p){e.isUndefined(c.barycenter)?(c.barycenter=p.barycenter,c.weight=p.weight):(c.barycenter=(c.barycenter*c.weight+p.barycenter*p.weight)/(c.weight+p.weight),c.weight+=p.weight)}return gg}var vg,kk;function k$(){if(kk)return vg;kk=1;var e=ot(),n=Zn().Graph;vg=r;function r(o,l,u){var c=s(o),p=new n({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(h){return o.node(h)});return e.forEach(o.nodes(),function(h){var f=o.node(h),m=o.parent(h);(f.rank===l||f.minRank<=l&&l<=f.maxRank)&&(p.setNode(h),p.setParent(h,m||c),e.forEach(o[u](h),function(y){var x=y.v===h?y.w:y.v,C=p.edge(x,h),_=e.isUndefined(C)?0:C.weight;p.setEdge(x,h,{weight:o.edge(y).weight+_})}),e.has(f,"minRank")&&p.setNode(h,{borderLeft:f.borderLeft[l],borderRight:f.borderRight[l]}))}),p}function s(o){for(var l;o.hasNode(l=e.uniqueId("_root")););return l}return vg}var yg,Ek;function E$(){if(Ek)return yg;Ek=1;var e=ot();yg=n;function n(r,s,o){var l={},u;e.forEach(o,function(c){for(var p=r.parent(c),h,f;p;){if(h=r.parent(p),h?(f=l[h],l[h]=p):(f=u,u=p),f&&f!==p){s.setEdge(f,p);return}p=h}})}return yg}var wg,Nk;function N$(){if(Nk)return wg;Nk=1;var e=ot(),n=y$(),r=w$(),s=b$(),o=k$(),l=E$(),u=Zn().Graph,c=an();wg=p;function p(y){var x=c.maxRank(y),C=h(y,e.range(1,x+1),"inEdges"),_=h(y,e.range(x-1,-1,-1),"outEdges"),S=n(y);m(y,S);for(var b=Number.POSITIVE_INFINITY,k,N=0,j=0;j<4;++N,++j){f(N%2?C:_,N%4>=2),S=c.buildLayerMatrix(y);var P=r(y,S);P<b&&(j=0,k=e.cloneDeep(S),b=P)}m(y,k)}function h(y,x,C){return e.map(x,function(_){return o(y,_,C)})}function f(y,x){var C=new u;e.forEach(y,function(_){var S=_.graph().root,b=s(_,S,C,x);e.forEach(b.vs,function(k,N){_.node(k).order=N}),l(_,C,b.vs)})}function m(y,x){e.forEach(x,function(C){e.forEach(C,function(_,S){y.node(_).order=S})})}return wg}var xg,Ck;function C$(){if(Ck)return xg;Ck=1;var e=ot(),n=Zn().Graph,r=an();xg={positionX:C,findType1Conflicts:s,findType2Conflicts:o,addConflict:u,hasConflict:c,verticalAlignment:p,horizontalCompaction:h,alignCoordinates:y,findSmallestWidthAlignment:m,balance:x};function s(b,k){var N={};function j(P,O){var L=0,B=0,T=P.length,M=e.last(O);return e.forEach(O,function(q,Y){var X=l(b,q),I=X?b.node(X).order:T;(X||q===M)&&(e.forEach(O.slice(B,Y+1),function(H){e.forEach(b.predecessors(H),function(U){var ne=b.node(U),J=ne.order;(J<L||I<J)&&!(ne.dummy&&b.node(H).dummy)&&u(N,U,H)})}),B=Y+1,L=I)}),O}return e.reduce(k,j),N}function o(b,k){var N={};function j(O,L,B,T,M){var q;e.forEach(e.range(L,B),function(Y){q=O[Y],b.node(q).dummy&&e.forEach(b.predecessors(q),function(X){var I=b.node(X);I.dummy&&(I.order<T||I.order>M)&&u(N,X,q)})})}function P(O,L){var B=-1,T,M=0;return e.forEach(L,function(q,Y){if(b.node(q).dummy==="border"){var X=b.predecessors(q);X.length&&(T=b.node(X[0]).order,j(L,M,Y,B,T),M=Y,B=T)}j(L,M,L.length,T,O.length)}),L}return e.reduce(k,P),N}function l(b,k){if(b.node(k).dummy)return e.find(b.predecessors(k),function(N){return b.node(N).dummy})}function u(b,k,N){if(k>N){var j=k;k=N,N=j}var P=b[k];P||(b[k]=P={}),P[N]=!0}function c(b,k,N){if(k>N){var j=k;k=N,N=j}return e.has(b[k],N)}function p(b,k,N,j){var P={},O={},L={};return e.forEach(k,function(B){e.forEach(B,function(T,M){P[T]=T,O[T]=T,L[T]=M})}),e.forEach(k,function(B){var T=-1;e.forEach(B,function(M){var q=j(M);if(q.length){q=e.sortBy(q,function(U){return L[U]});for(var Y=(q.length-1)/2,X=Math.floor(Y),I=Math.ceil(Y);X<=I;++X){var H=q[X];O[M]===M&&T<L[H]&&!c(N,M,H)&&(O[H]=M,O[M]=P[M]=P[H],T=L[H])}}})}),{root:P,align:O}}function h(b,k,N,j,P){var O={},L=f(b,k,N,P),B=P?"borderLeft":"borderRight";function T(Y,X){for(var I=L.nodes(),H=I.pop(),U={};H;)U[H]?Y(H):(U[H]=!0,I.push(H),I=I.concat(X(H))),H=I.pop()}function M(Y){O[Y]=L.inEdges(Y).reduce(function(X,I){return Math.max(X,O[I.v]+L.edge(I))},0)}function q(Y){var X=L.outEdges(Y).reduce(function(H,U){return Math.min(H,O[U.w]-L.edge(U))},Number.POSITIVE_INFINITY),I=b.node(Y);X!==Number.POSITIVE_INFINITY&&I.borderType!==B&&(O[Y]=Math.max(O[Y],X))}return T(M,L.predecessors.bind(L)),T(q,L.successors.bind(L)),e.forEach(j,function(Y){O[Y]=O[N[Y]]}),O}function f(b,k,N,j){var P=new n,O=b.graph(),L=_(O.nodesep,O.edgesep,j);return e.forEach(k,function(B){var T;e.forEach(B,function(M){var q=N[M];if(P.setNode(q),T){var Y=N[T],X=P.edge(Y,q);P.setEdge(Y,q,Math.max(L(b,M,T),X||0))}T=M})}),P}function m(b,k){return e.minBy(e.values(k),function(N){var j=Number.NEGATIVE_INFINITY,P=Number.POSITIVE_INFINITY;return e.forIn(N,function(O,L){var B=S(b,L)/2;j=Math.max(O+B,j),P=Math.min(O-B,P)}),j-P})}function y(b,k){var N=e.values(k),j=e.min(N),P=e.max(N);e.forEach(["u","d"],function(O){e.forEach(["l","r"],function(L){var B=O+L,T=b[B],M;if(T!==k){var q=e.values(T);M=L==="l"?j-e.min(q):P-e.max(q),M&&(b[B]=e.mapValues(T,function(Y){return Y+M}))}})})}function x(b,k){return e.mapValues(b.ul,function(N,j){if(k)return b[k.toLowerCase()][j];var P=e.sortBy(e.map(b,j));return(P[1]+P[2])/2})}function C(b){var k=r.buildLayerMatrix(b),N=e.merge(s(b,k),o(b,k)),j={},P;e.forEach(["u","d"],function(L){P=L==="u"?k:e.values(k).reverse(),e.forEach(["l","r"],function(B){B==="r"&&(P=e.map(P,function(Y){return e.values(Y).reverse()}));var T=(L==="u"?b.predecessors:b.successors).bind(b),M=p(b,P,N,T),q=h(b,P,M.root,M.align,B==="r");B==="r"&&(q=e.mapValues(q,function(Y){return-Y})),j[L+B]=q})});var O=m(b,j);return y(j,O),x(j,b.graph().align)}function _(b,k,N){return function(j,P,O){var L=j.node(P),B=j.node(O),T=0,M;if(T+=L.width/2,e.has(L,"labelpos"))switch(L.labelpos.toLowerCase()){case"l":M=-L.width/2;break;case"r":M=L.width/2;break}if(M&&(T+=N?M:-M),M=0,T+=(L.dummy?k:b)/2,T+=(B.dummy?k:b)/2,T+=B.width/2,e.has(B,"labelpos"))switch(B.labelpos.toLowerCase()){case"l":M=B.width/2;break;case"r":M=-B.width/2;break}return M&&(T+=N?M:-M),M=0,T}}function S(b,k){return b.node(k).width}return xg}var _g,jk;function j$(){if(jk)return _g;jk=1;var e=ot(),n=an(),r=C$().positionX;_g=s;function s(l){l=n.asNonCompoundGraph(l),o(l),e.forEach(r(l),function(u,c){l.node(c).x=u})}function o(l){var u=n.buildLayerMatrix(l),c=l.graph().ranksep,p=0;e.forEach(u,function(h){var f=e.max(e.map(h,function(m){return l.node(m).height}));e.forEach(h,function(m){l.node(m).y=p+f/2}),p+=f+c})}return _g}var Sg,Rk;function R$(){if(Rk)return Sg;Rk=1;var e=ot(),n=c$(),r=d$(),s=h$(),o=an().normalizeRanks,l=p$(),u=an().removeEmptyRanks,c=m$(),p=g$(),h=v$(),f=N$(),m=j$(),y=an(),x=Zn().Graph;Sg=C;function C(D,Q){var ee=Q&&Q.debugTiming?y.time:y.notime;ee("layout",function(){var oe=ee(" buildLayoutGraph",function(){return T(D)});ee(" runLayout",function(){_(oe,ee)}),ee(" updateInputGraph",function(){S(D,oe)})})}function _(D,Q){Q(" makeSpaceForEdgeLabels",function(){M(D)}),Q(" removeSelfEdges",function(){F(D)}),Q(" acyclic",function(){n.run(D)}),Q(" nestingGraph.run",function(){c.run(D)}),Q(" rank",function(){s(y.asNonCompoundGraph(D))}),Q(" injectEdgeLabelProxies",function(){q(D)}),Q(" removeEmptyRanks",function(){u(D)}),Q(" nestingGraph.cleanup",function(){c.cleanup(D)}),Q(" normalizeRanks",function(){o(D)}),Q(" assignRankMinMax",function(){Y(D)}),Q(" removeEdgeLabelProxies",function(){X(D)}),Q(" normalize.run",function(){r.run(D)}),Q(" parentDummyChains",function(){l(D)}),Q(" addBorderSegments",function(){p(D)}),Q(" order",function(){f(D)}),Q(" insertSelfEdges",function(){G(D)}),Q(" adjustCoordinateSystem",function(){h.adjust(D)}),Q(" position",function(){m(D)}),Q(" positionSelfEdges",function(){E(D)}),Q(" removeBorderNodes",function(){J(D)}),Q(" normalize.undo",function(){r.undo(D)}),Q(" fixupEdgeLabelCoords",function(){U(D)}),Q(" undoCoordinateSystem",function(){h.undo(D)}),Q(" translateGraph",function(){I(D)}),Q(" assignNodeIntersects",function(){H(D)}),Q(" reversePoints",function(){ne(D)}),Q(" acyclic.undo",function(){n.undo(D)})}function S(D,Q){e.forEach(D.nodes(),function(ee){var oe=D.node(ee),ue=Q.node(ee);oe&&(oe.x=ue.x,oe.y=ue.y,Q.children(ee).length&&(oe.width=ue.width,oe.height=ue.height))}),e.forEach(D.edges(),function(ee){var oe=D.edge(ee),ue=Q.edge(ee);oe.points=ue.points,e.has(ue,"x")&&(oe.x=ue.x,oe.y=ue.y)}),D.graph().width=Q.graph().width,D.graph().height=Q.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],k={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"],L={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},B=["labelpos"];function T(D){var Q=new x({multigraph:!0,compound:!0}),ee=se(D.graph());return Q.setGraph(e.merge({},k,$(ee,b),e.pick(ee,N))),e.forEach(D.nodes(),function(oe){var ue=se(D.node(oe));Q.setNode(oe,e.defaults($(ue,j),P)),Q.setParent(oe,D.parent(oe))}),e.forEach(D.edges(),function(oe){var ue=se(D.edge(oe));Q.setEdge(oe,e.merge({},L,$(ue,O),e.pick(ue,B)))}),Q}function M(D){var Q=D.graph();Q.ranksep/=2,e.forEach(D.edges(),function(ee){var oe=D.edge(ee);oe.minlen*=2,oe.labelpos.toLowerCase()!=="c"&&(Q.rankdir==="TB"||Q.rankdir==="BT"?oe.width+=oe.labeloffset:oe.height+=oe.labeloffset)})}function q(D){e.forEach(D.edges(),function(Q){var ee=D.edge(Q);if(ee.width&&ee.height){var oe=D.node(Q.v),ue=D.node(Q.w),ge={rank:(ue.rank-oe.rank)/2+oe.rank,e:Q};y.addDummyNode(D,"edge-proxy",ge,"_ep")}})}function Y(D){var Q=0;e.forEach(D.nodes(),function(ee){var oe=D.node(ee);oe.borderTop&&(oe.minRank=D.node(oe.borderTop).rank,oe.maxRank=D.node(oe.borderBottom).rank,Q=e.max(Q,oe.maxRank))}),D.graph().maxRank=Q}function X(D){e.forEach(D.nodes(),function(Q){var ee=D.node(Q);ee.dummy==="edge-proxy"&&(D.edge(ee.e).labelRank=ee.rank,D.removeNode(Q))})}function I(D){var Q=Number.POSITIVE_INFINITY,ee=0,oe=Number.POSITIVE_INFINITY,ue=0,ge=D.graph(),de=ge.marginx||0,Ie=ge.marginy||0;function He(Pe){var Ae=Pe.x,ke=Pe.y,Ye=Pe.width,ve=Pe.height;Q=Math.min(Q,Ae-Ye/2),ee=Math.max(ee,Ae+Ye/2),oe=Math.min(oe,ke-ve/2),ue=Math.max(ue,ke+ve/2)}e.forEach(D.nodes(),function(Pe){He(D.node(Pe))}),e.forEach(D.edges(),function(Pe){var Ae=D.edge(Pe);e.has(Ae,"x")&&He(Ae)}),Q-=de,oe-=Ie,e.forEach(D.nodes(),function(Pe){var Ae=D.node(Pe);Ae.x-=Q,Ae.y-=oe}),e.forEach(D.edges(),function(Pe){var Ae=D.edge(Pe);e.forEach(Ae.points,function(ke){ke.x-=Q,ke.y-=oe}),e.has(Ae,"x")&&(Ae.x-=Q),e.has(Ae,"y")&&(Ae.y-=oe)}),ge.width=ee-Q+de,ge.height=ue-oe+Ie}function H(D){e.forEach(D.edges(),function(Q){var ee=D.edge(Q),oe=D.node(Q.v),ue=D.node(Q.w),ge,de;ee.points?(ge=ee.points[0],de=ee.points[ee.points.length-1]):(ee.points=[],ge=ue,de=oe),ee.points.unshift(y.intersectRect(oe,ge)),ee.points.push(y.intersectRect(ue,de))})}function U(D){e.forEach(D.edges(),function(Q){var ee=D.edge(Q);if(e.has(ee,"x"))switch((ee.labelpos==="l"||ee.labelpos==="r")&&(ee.width-=ee.labeloffset),ee.labelpos){case"l":ee.x-=ee.width/2+ee.labeloffset;break;case"r":ee.x+=ee.width/2+ee.labeloffset;break}})}function ne(D){e.forEach(D.edges(),function(Q){var ee=D.edge(Q);ee.reversed&&ee.points.reverse()})}function J(D){e.forEach(D.nodes(),function(Q){if(D.children(Q).length){var ee=D.node(Q),oe=D.node(ee.borderTop),ue=D.node(ee.borderBottom),ge=D.node(e.last(ee.borderLeft)),de=D.node(e.last(ee.borderRight));ee.width=Math.abs(de.x-ge.x),ee.height=Math.abs(ue.y-oe.y),ee.x=ge.x+ee.width/2,ee.y=oe.y+ee.height/2}}),e.forEach(D.nodes(),function(Q){D.node(Q).dummy==="border"&&D.removeNode(Q)})}function F(D){e.forEach(D.edges(),function(Q){if(Q.v===Q.w){var ee=D.node(Q.v);ee.selfEdges||(ee.selfEdges=[]),ee.selfEdges.push({e:Q,label:D.edge(Q)}),D.removeEdge(Q)}})}function G(D){var Q=y.buildLayerMatrix(D);e.forEach(Q,function(ee){var oe=0;e.forEach(ee,function(ue,ge){var de=D.node(ue);de.order=ge+oe,e.forEach(de.selfEdges,function(Ie){y.addDummyNode(D,"selfedge",{width:Ie.label.width,height:Ie.label.height,rank:de.rank,order:ge+ ++oe,e:Ie.e,label:Ie.label},"_se")}),delete de.selfEdges})})}function E(D){e.forEach(D.nodes(),function(Q){var ee=D.node(Q);if(ee.dummy==="selfedge"){var oe=D.node(ee.e.v),ue=oe.x+oe.width/2,ge=oe.y,de=ee.x-ue,Ie=oe.height/2;D.setEdge(ee.e,ee.label),D.removeNode(Q),ee.label.points=[{x:ue+2*de/3,y:ge-Ie},{x:ue+5*de/6,y:ge-Ie},{x:ue+de,y:ge},{x:ue+5*de/6,y:ge+Ie},{x:ue+2*de/3,y:ge+Ie}],ee.label.x=ee.x,ee.label.y=ee.y}})}function $(D,Q){return e.mapValues(e.pick(D,Q),Number)}function se(D){var Q={};return e.forEach(D,function(ee,oe){Q[oe.toLowerCase()]=ee}),Q}return Sg}var bg,Tk;function T$(){if(Tk)return bg;Tk=1;var e=ot(),n=an(),r=Zn().Graph;bg={debugOrdering:s};function s(o){var l=n.buildLayerMatrix(o),u=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(c){u.setNode(c,{label:c}),u.setParent(c,"layer"+o.node(c).rank)}),e.forEach(o.edges(),function(c){u.setEdge(c.v,c.w,{},c.name)}),e.forEach(l,function(c,p){var h="layer"+p;u.setNode(h,{rank:"same"}),e.reduce(c,function(f,m){return u.setEdge(f,m,{style:"invis"}),m})}),u}return bg}var kg,Ak;function A$(){return Ak||(Ak=1,kg="0.8.5"),kg}var Eg,Ik;function I$(){return Ik||(Ik=1,Eg={graphlib:Zn(),layout:R$(),debug:T$(),util:{time:an().time,notime:an().notime},version:A$()}),Eg}var M$=I$();const Mk=Xg(M$),xi=240,Zi=130,Ws=74,vu=72,Pk=Ws+vu;function P$(e){let n=xi;for(const r of e.values())n=Math.max(n,r.width);return n}const EC=420,O$=2;function ia(e){var r;return((r=e.data)==null?void 0:r.sessionId)??"_default"}function Ok(e,n){return((n==null?void 0:n.get(e))??0)>0?EC:0}function qk(e,n){const r=(n==null?void 0:n.get(e))??0;return r>0?6+r*36:0}function q$(e,n,r,s,o,l){const u=new Mk.graphlib.Graph;u.setDefaultEdgeLabel(()=>({})),u.setGraph({rankdir:r,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const c=e.filter(b=>!o.has(b)),p=new Set(c);for(const b of c){const k=s.get(b);u.setNode(b,{width:((k==null?void 0:k.width)??xi)+Ok(b,l),height:Math.max((k==null?void 0:k.height)??Zi,qk(b,l))})}for(const b of n)p.has(b.source)&&p.has(b.target)&&u.setEdge(b.source,b.target);Mk.layout(u);const h=new Map;let f=1/0,m=1/0,y=-1/0,x=-1/0;for(const b of c){const k=u.node(b);if(!k)continue;const N=s.get(b),j=(N==null?void 0:N.width)??xi,P=(N==null?void 0:N.height)??Zi,O=j+Ok(b,l),L=Math.max(P,qk(b,l)),B=k.x-O/2,T=k.y-L/2;h.set(b,{x:B,y:T}),B<f&&(f=B),T<m&&(m=T),B+j>y&&(y=B+j),T+P>x&&(x=T+P)}if(Number.isFinite(f)&&Number.isFinite(m))for(const[b,k]of h)h.set(b,{x:k.x-f,y:k.y-m});const C=Number.isFinite(y)?y-f:0,_=Number.isFinite(x)?x-m:0;let S=null;for(const b of e){const k=o.get(b);if(!k)continue;const N=s.get(b),j=(N==null?void 0:N.width)??xi,P=(N==null?void 0:N.height)??Zi;S=S===null?{minX:k.x,minY:k.y,maxX:k.x+j,maxY:k.y+P}:{minX:Math.min(S.minX,k.x),minY:Math.min(S.minY,k.y),maxX:Math.max(S.maxX,k.x+j),maxY:Math.max(S.maxY,k.y+P)}}return{positions:h,width:C,height:_,pinnedBox:S}}function L$(e,n,r={}){const s=r.direction??"LR",o=r.pinned??new Map,l=r.measured??new Map,u=r.lanes,c=new Map;for(const b of e){const k=ia(b),N=c.get(k);N?N.push(b.id):c.set(k,[b.id])}const h=Array.from(c.keys()).sort().map(b=>({sid:b,...q$(c.get(b),n,s,l,o,u)})),f=P$(l),m=r.availableHeight&&r.availableHeight>0?r.availableHeight:Number.POSITIVE_INFINITY,y=b=>{const k=[[]];let N=0;for(const j of h)k.length<b&&N>0&&N+j.height>m&&(k.push([]),N=0),k[k.length-1].push(j),N+=j.height+Pk;return k},x=b=>b.reduce((k,N)=>Math.max(k,N.width),0)+EC;let C=y(r.availableWidth?O$:1);C.length>1&&C.reduce((k,N)=>k+x(N),0)+f*(C.length-1)>(r.availableWidth??0)&&(C=y(1));const _=new Map;let S=0;for(const b of C){const k=x(b);let N=0;for(const{positions:j,height:P,pinnedBox:O}of b){for(const[B,T]of j)_.set(B,{x:T.x+S,y:T.y+N});let L=N+P;O&&O.maxY>L&&O.minX<S+k&&S<O.maxX&&(L=O.maxY),N=L+Pk}S+=k+f}return e.map(b=>{const k=o.get(b.id);if(k)return{...b,position:k};const N=_.get(b.id);return N?{...b,position:N}:b})}function $$(e,n,r,s){const l=Ws+vu,u=60,c=y=>{const x=s.get(y);return{w:(x==null?void 0:x.width)??xi,h:(x==null?void 0:x.height)??Zi}},p=new Map(e.map(y=>[y.id,ia(y)])),h=[],f=e.map(y=>({id:y.id,pos:r.get(y.id)??n.get(y.id)})).filter(y=>y.pos!=null).sort((y,x)=>y.pos.y-x.pos.y||y.pos.x-x.pos.x||y.id.localeCompare(x.id)),m=[];for(const{id:y,pos:x}of f){const{w:C,h:_}=c(y),S=p.get(y)??"_default";if(r.has(y)){h.push({x:x.x,y:x.y,w:C,h:_,sid:S});continue}let b=x.y;for(let k=0;k<h.length+1;k++){const N=h.find(j=>{const P=j.sid===S?24:u,O=j.sid===S?24:l;return x.x<j.x+j.w+P&&j.x<x.x+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!==x.y&&(n.set(y,{x:x.x,y:b}),m.push(y)),h.push({x:x.x,y:b,w:C,h:_,sid:S})}return m}function D$(e,n,r,s,o){const l=C=>{const _=s.get(C);return{w:(_==null?void 0:_.width)??xi,h:(_==null?void 0:_.height)??Zi}},u=C=>r.get(C)??n.get(C),c=new Map;for(const C of e){if(!u(C.id))continue;const _=ia(C),S=c.get(_);S?S.push(C):c.set(_,[C])}const p=new Set;for(const[C,_]of c)_.every(S=>o.has(S.id)&&!r.has(S.id))&&p.add(C);const h=new Map,f=[];for(const C of e){const _=u(C.id);if(!_)continue;const{w:S,h:b}=l(C.id),k=ia(C);p.has(k)?(h.get(k)??h.set(k,[]).get(k)).push(C):f.push({x:_.x,y:_.y,w:S,h:b})}if(h.size===0)return[];const m=Ws+vu,y=(C,_,S,b)=>f.some(k=>C<k.x+k.w+Ws&&k.x<C+S+Ws&&_<k.y+k.h+m&&k.y<_+b+m),x=[];for(const C of[...h.keys()].sort()){const _=h.get(C);let S=1/0,b=1/0,k=-1/0,N=-1/0;for(const M of _){const q=u(M.id),{w:Y,h:X}=l(M.id);S=Math.min(S,q.x),b=Math.min(b,q.y),k=Math.max(k,q.x+Y),N=Math.max(N,q.y+X)}const j=k-S,P=N-b,O=[...new Set(f.map(M=>Math.round(M.x)))].sort((M,q)=>M-q),L=O.length?O:[S],B=[0,...f.map(M=>M.y+M.h+m)].sort((M,q)=>M-q);let T=null;e:for(const M of L)for(const q of B){if(q>=b)break;if(!y(M,q,j,P)){T={x:M,y:q};break e}}if(T){const M=T.x-S,q=T.y-b;for(const Y of _){const X=u(Y.id);n.set(Y.id,{x:X.x+M,y:X.y+q})}x.push(C)}for(const M of _){const q=u(M.id),{w:Y,h:X}=l(M.id);f.push({x:q.x,y:q.y,w:Y,h:X})}}return x}function F$(e,n,r,s,o,l=!1){const p=Ws+vu+1,h=8,f=1.75,m=200,y=.7,x=.01,C=T=>{const M=s.get(T);return{w:(M==null?void 0:M.width)??xi,h:(M==null?void 0:M.height)??Zi}},_=T=>r.get(T)??n.get(T),S=new Map;for(const T of e){if(!_(T.id))continue;const M=ia(T),q=S.get(M);q?q.push(T):S.set(M,[T])}const b=[],k=new Set,N=new Set,j=o.size===0;for(const T of[...S.keys()].sort()){const M=S.get(T);let q=1/0,Y=1/0,X=-1/0,I=-1/0,H=!1;for(const F of M){const G=_(F.id),{w:E,h:$}=C(F.id);q=Math.min(q,G.x),Y=Math.min(Y,G.y),X=Math.max(X,G.x+E),I=Math.max(I,G.y+$),r.has(F.id)&&(H=!0)}const U=X-q,ne=I-Y;N.add(T);const J=o.get(T);J&&(U>J.w+h||ne>J.h+h)&&k.add(T),o.set(T,{w:U,h:ne}),b.push({sid:T,members:M.map(F=>F.id),x:q,y:Y,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 q=b[T],Y=b[M];if(!(q.anchored&&Y.anchored)&&Math.abs(q.x+q.w/2-(Y.x+Y.w/2))<(q.w+Y.w)/2+61&&Math.abs(q.y+q.h/2-(Y.y+Y.h/2))<(q.h+Y.h)/2+p){P=!0;break}}if(k.size===0&&!P)return[];if(k.size>0)for(const T of b)k.has(T.sid)&&(T.mass=8);else for(const T of b)T.mass=Math.max(1,T.w*T.h/(xi*Zi));const O=new Map(b.map(T=>[T.sid,T.x])),L=new Map(b.map(T=>[T.sid,T.y]));for(let T=0;T<m;T++){const M=new Map,q=new Map;let Y=0;for(let X=0;X<b.length;X++)for(let I=X+1;I<b.length;I++){const H=b[X],U=b[I];if(H.anchored&&U.anchored)continue;const ne=H.x+H.w/2,J=H.y+H.h/2,F=U.x+U.w/2,G=U.y+U.h/2,E=(H.w+U.w)/2+61-Math.abs(ne-F),$=(H.h+U.h)/2+p-Math.abs(J-G);if(E<=0||$<=0)continue;const se=(We,$e)=>!We.anchored&&!($e<0&&We.x<=0),D=(We,$e)=>!We.anchored&&!($e<0&&We.y<=0),Q=(We,$e,it)=>{const vt=We===$e,tt=vt?H.sid<U.sid?-1:1:Math.sign(We-$e);return it(H,tt)||it(U,-tt)?tt:vt&&(it(H,-tt)||it(U,tt))?-tt:0},ee=Q(ne,F,se),oe=Q(J,G,D),ue=ee!==0,ge=oe!==0;if(!ue&&!ge)continue;const de=ue&&(!ge||E*f<$),[Ie,He,Pe,Ae]=de?[ee,E,M,se]:[oe,$,q,D],ke=Ae(H,Ie),Ye=Ae(U,-Ie),ve=H.mass,we=U.mass,Ve=ke?Ye?we/(ve+we):1:0,at=Ye?ke?ve/(ve+we):1:0,lt=He*y;Pe.set(H.sid,(Pe.get(H.sid)??0)+Ie*lt*Ve),Pe.set(U.sid,(Pe.get(U.sid)??0)-Ie*lt*at),Y+=lt}for(const X of b)X.anchored||(X.x=Math.max(0,X.x+(M.get(X.sid)??0)),X.y=Math.max(0,X.y+(q.get(X.sid)??0)));if(Y<x)break}const B=[];for(const T of b){const M=T.x-O.get(T.sid),q=T.y-L.get(T.sid);if(!(Math.abs(M)<1&&Math.abs(q)<1)){for(const Y of T.members){if(r.has(Y))continue;const X=n.get(Y);X&&n.set(Y,{x:X.x+M,y:X.y+q})}B.push(T.sid)}}return B}const z$=600;function Gg(e,n){return!(e.exitAt!=null&&n-e.exitAt>z$||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function B$(e,n){const r=new Set;for(const s of e.agents.values())Gg(s,n)&&r.add(s.id);return r}function U$(e,n,r=0){return e.right+r>n.left&&e.left-r<n.right&&e.bottom+r>n.top&&e.top-r<n.bottom}function H$(e,n,r=0){if(!e)return!1;for(const s of n)if(U$(e,s,r))return!0;return!1}function Wi(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function V$(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}const W$={agent:qP,sessionGroup:GP},G$=420,Tl=18,Y$=9e4,K$=200,X$=5*6e4,Q$=6,Z$=2*6e4,Ov="agent-dag.layout",qv="agent-dag.viewport",NC="agent-dag.summariesDismissed",CC="agent-dag.sessionListOpen",jC="agent-dag.detailOpen",RC="agent-dag.usagePanelOpen",Lk="agent-dag.accountsPanelOpen",$k="agent-dag.versionNoticeDismissed",J$=15*6e4,Dk={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 e4(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 Fk="agent-dag.autoRestart",zk="agent-dag.bundleReloadedFor";function t4(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(CC)==="1"}catch{return!1}}function n4(e){if(!(typeof window>"u"))try{window.localStorage.setItem(CC,e?"1":"0")}catch{}}function r4(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(jC)==="1"}catch{return!1}}function i4(e){if(!(typeof window>"u"))try{window.localStorage.setItem(jC,e?"1":"0")}catch{}}function s4(){if(typeof window>"u")return!0;const e=window.localStorage.getItem(RC);try{return e===null?!0:e==="1"}catch{return!0}}function o4(e){if(!(typeof window>"u"))try{window.localStorage.setItem(RC,e?"1":"0")}catch{}}function a4(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(NC);if(!e)return new Set;const n=JSON.parse(e);return new Set(Array.isArray(n)?n.filter(r=>typeof r=="string"):[])}catch{return new Set}}function Bk(e){if(!(typeof window>"u"))try{const n=Array.from(e),r=n.length>200?n.slice(-200):n;window.localStorage.setItem(NC,JSON.stringify(r))}catch{}}function l4(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(Ov);if(!n)return e;const r=JSON.parse(n);if(!("v"in r)){const o=Object.entries(r).filter(([,l])=>l&&typeof l.x=="number"&&typeof l.y=="number");return{positions:o,pins:o.map(([l])=>l)}}return{positions:Object.entries(r.positions??{}).filter(([,o])=>o&&typeof o.x=="number"&&typeof o.y=="number"),pins:Array.isArray(r.pins)?r.pins:[]}}catch{return e}}function Ng(e,n){if(!(typeof window>"u"))try{const r={};for(const[s,o]of e)r[s]=o;for(const[s,o]of n)r[s]=o;window.localStorage.setItem(Ov,JSON.stringify({v:2,positions:r,pins:Array.from(n.keys())}))}catch{}}function u4(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(qv);if(!e)return null;const n=JSON.parse(e);return typeof(n==null?void 0:n.x)!="number"||typeof(n==null?void 0:n.y)!="number"||typeof(n==null?void 0:n.zoom)!="number"?null:n}catch{return null}}function c4(e){if(!(typeof window>"u"))try{window.localStorage.setItem(qv,JSON.stringify(e))}catch{}}function Uk(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Ov)}catch{}try{window.localStorage.removeItem(qv)}catch{}}}function d4(e,n){const r=e.agents.get(n);if(!r)return;const s=[];for(const f of e.agents.values())f.sessionId===n&&s.push(f);const o={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:n,label:r.label,cwd:r.cwd,startedAt:r.startedAt,endedAt:r.endedAt,model:r.model,agents:s.map(f=>({id:f.id,kind:f.kind,label:f.label,parentId:f.parentId,state:f.state,startedAt:f.startedAt,endedAt:f.endedAt,model:f.model,cwd:f.cwd,usage:f.usage,prompts:f.prompts,tools:f.tools.map(m=>({id:m.id,name:m.name,inputPreview:m.inputPreview,startedAt:m.startedAt,endedAt:m.endedAt,ok:m.ok,errorPreview:m.errorPreview,usage:m.usage}))}))},l=JSON.stringify(o,null,2),u=new Blob([l],{type:"application/json"}),c=URL.createObjectURL(u),p=document.createElement("a"),h=(r.label||"session").replace(/[^a-z0-9._-]/gi,"_");p.href=c,p.download=`agents-deck-${h}-${n.slice(0,8)}.json`,document.body.appendChild(p),p.click(),document.body.removeChild(p),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const Yg={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"},f4={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 TC(e){return e.startsWith("mcp__")?"mcp":f4[e]??"other"}function AC(e,n){var s,o,l;if(!n)return!0;const r=n.toLowerCase();if(e.label.toLowerCase().includes(r)||(s=e.cwd)!=null&&s.toLowerCase().includes(r)||(o=e.cwdBasename)!=null&&o.toLowerCase().includes(r)||e.sessionId.toLowerCase().includes(r)||(l=e.firstPrompt)!=null&&l.toLowerCase().includes(r))return!0;for(const u of e.tools)if(u.name.toLowerCase().includes(r))return!0;return!1}function h4(e,n){if(!n)return null;const r=new Set([n]);let s=n;for(;s;){const l=e.agents.get(s);if(!(l!=null&&l.parentId)||r.has(l.parentId))break;r.add(l.parentId),s=l.parentId}let o=!0;for(;o;){o=!1;for(const l of e.agents.values())l.parentId&&r.has(l.parentId)&&!r.has(l.id)&&(r.add(l.id),o=!0)}return r}function p4(e,n,r,s,o,l,u,c,p,h,f,m,y,x,C,_,S,b){const k=[],N=[],j=new Set;if(l)for(const M of e.agents.values())AC(M,l)&&j.add(M.id);for(const M of e.agents.values()){if(!S.has(M.id))continue;const q=l?!j.has(M.id):!1,Y=M.exitAt!=null,X=_!=null&&!_.has(M.id),I=[q?"rf-dim":"",Y?"rf-exiting":"",X?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,H=u.get(M.id);if(k.push({id:M.id,type:"agent",position:{x:0,y:0},data:{...M,now:n,dim:q,onOpenContext:b},className:I,...H?{width:H.width,height:H.height}:null}),M.parentId&&S.has(M.parentId)){const U=mv(M.sessionId),ne=M.state==="active"?`hsl(${U} 80% 72%)`:`hsl(${U} 50% 55%)`,J=l&&!j.has(M.id)&&!j.has(M.parentId),F=Y,G=C.size>0&&(C.has(M.id)||C.has(M.parentId)),E=_!=null&&!_.has(M.id)&&!_.has(M.parentId),$=M.state==="active"?2:1.5,se=G?$+1.5:$,D=J||F?.2:E?.12:1,Q=[F?"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)&&!J&&!F,type:"smoothstep",style:{stroke:ne,strokeWidth:se,opacity:D,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:Q})}}const P=new Map;for(const M of e.agents.values())M.tools.length>0&&P.set(M.id,Math.min(4,M.tools.length));const O=k.filter(M=>!o.has(M.id)&&!m.has(M.id));if(O.length>0||y!==x.current){if(O.length>0){const M=L$(k,N,{direction:"LR",pinned:o,measured:u,availableWidth:r,availableHeight:s,lanes:P});for(const q of M)m.has(q.id)||m.set(q.id,q.position);D$(k,m,o,u,new Set(O.map(q=>q.id)))}$$(k,m,o,u),x.current=y}const L=F$(k,m,o,u,c,!h||f);L.length>0&&p(L),ad(m,e.agents),ad(o,e.agents),ad(u,lO(e.agents.values()));const B=[];let T=!1;for(const M of k){let q=o.get(M.id)??m.get(M.id);q||(q={x:0,y:0},m.set(M.id,q),T=!0),B.push({...M,position:q})}return T&&(x.current=""),{nodes:B,edges:N}}function m4(){return g.jsx(hv,{children:g.jsx(g4,{})})}function g4(){var Kr,Xr,_r,Ti;const e=ua(),n=A.useRef(Ug()),[,r]=A.useState(0),s=A.useCallback(()=>r(W=>W+1),[]),[o,l]=A.useState(()=>new Set),[u,c]=A.useState(null),[p,h]=A.useState(null),f=A.useCallback((W,K)=>{l(le=>{if(!K)return new Set([W]);const ce=new Set(le);return ce.has(W)?ce.delete(W):ce.add(W),ce}),c(le=>K&&le===W?le:W)},[]),m=A.useCallback(()=>{l(new Set),c(null)},[]),[y,x]=A.useState(null),[C,_]=A.useState(null),S=A.useCallback(W=>_(W),[]),b=A.useRef(a4()),[k,N]=A.useState(t4);A.useEffect(()=>{n4(k)},[k]);const[j,P]=A.useState(r4);A.useEffect(()=>{i4(j)},[j]);const[O,L]=A.useState(s4);A.useEffect(()=>{o4(O)},[O]);const[B,T]=A.useState(()=>{try{const W=window.localStorage.getItem(Lk);return W===null?!0:W==="1"}catch{return!0}});A.useEffect(()=>{try{window.localStorage.setItem(Lk,B?"1":"0")}catch{}},[B]);const[M,q]=A.useState(null),[Y,X]=A.useState(!1),[I,H]=A.useState(0),[U,ne]=A.useState(0);A.useEffect(()=>{fetch("/api/sound-hook").then(W=>W.ok?W.json():null).then(W=>{W!=null&&W.ok&&(q(W.enabled===!0),H((W.foreign??[]).filter(K=>K.worksHere).length),ne(typeof W.parked=="number"?W.parked:0))}).catch(()=>{})},[]);const J=A.useCallback(async()=>{X(!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&&q(K.enabled===!0),fetch("/api/sound-hook").then(le=>le.ok?le.json():null).then(le=>{le!=null&&le.ok&&(H((le.foreign??[]).filter(ce=>ce.worksHere).length),ne(typeof le.parked=="number"?le.parked:0))}).catch(()=>{})}catch{}finally{X(!1)}},[M]),[F,G]=A.useState(!1),[E,$]=A.useState(null),[se,D]=A.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem($k)??""}catch{return""}}),[Q,ee]=A.useState(!1),oe=A.useRef(0),ue=A.useCallback((W=!1)=>{W&&(oe.current=Date.now()),fetch(W?"/api/version?refresh=1":"/api/version").then(K=>K.ok?K.json():null).then(K=>{K&&$(K)}).catch(()=>{})},[]),ge=A.useCallback(()=>{ue(Date.now()-oe.current>=J$)},[ue]);A.useEffect(()=>{ue();const W=window.setInterval(ge,5*6e4),K=()=>{document.visibilityState==="visible"&&ge()};return document.addEventListener("visibilitychange",K),()=>{window.clearInterval(W),document.removeEventListener("visibilitychange",K)}},[ue,ge]),A.useEffect(()=>{F&&ue()},[F,ue]);const de=(E==null?void 0:E.notice)??null,Ie=de?`${de.kind}:${de.to}`:"",He=de!=null&&se!==Ie,Pe=A.useCallback(()=>{if(!de)return;const W=se===Ie?"":Ie;D(W);try{window.localStorage.setItem($k,W)}catch{}},[de,Ie,se]),Ae=((Kr=E==null?void 0:E.upgrade)==null?void 0:Kr.state)??"idle",ke=A.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}ue()},[ue]);A.useEffect(()=>{if(Ae!=="running")return;const W=window.setInterval(ue,3e3);return()=>window.clearInterval(W)},[Ae,ue]);const Ye=A.useCallback(async()=>{var le;const W=E==null?void 0:E.command;if(!W)return;let K=!1;try{K=await Promise.race([((le=navigator.clipboard)==null?void 0:le.writeText(W).then(()=>!0))??Promise.resolve(!1),new Promise(ce=>window.setTimeout(()=>ce(!1),500))])}catch{K=!1}if(!K)try{const ce=document.createElement("textarea");ce.value=W,ce.setAttribute("readonly",""),ce.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(ce),ce.select(),K=document.execCommand("copy"),ce.remove()}catch{K=!1}K&&(ee(!0),window.setTimeout(()=>ee(!1),1600))},[E==null?void 0:E.command]),ve=A.useCallback(()=>{N(W=>(W||T(!1),!W))},[]),we=A.useCallback(()=>{T(W=>(W||N(!1),!W))},[]),[Ve,at]=A.useState(!1),[lt,We]=A.useState(0),$e=A.useRef(null),[it,vt]=A.useState(!1),tt=A.useRef(null),[qt,mt]=A.useState(0),Tt=A.useRef(fO()),[At,Ze]=A.useState(!1),yt=A.useCallback(()=>{const W=Tt.current,K=W.setPaused(!W.paused);for(const le of K)n.current=Zw(n.current,le);Ze(W.paused)},[]),[Le,wt]=A.useState(Date.now()),[Bt,Ut]=A.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(Fk)!=="0"}catch{return!0}}),Lt=A.useCallback(()=>{Ut(W=>{const K=!W;try{window.localStorage.setItem(Fk,K?"1":"0")}catch{}return K})},[]),[Ht,qn]=A.useState(!1),[Ln,wn]=A.useState("restart"),[xn,ln]=A.useState(null),tr=A.useRef(!1),pr=A.useCallback(async W=>{if(tr.current)return;const K=(W==null?void 0:W.upgrade)===!0;tr.current=!0,wn(K?"npx":"restart"),qn(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(de==null?void 0:de.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:K})})}catch{}window.setTimeout(()=>{if(tr.current){tr.current=!1,qn(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},K?18e4:3e4)},[de==null?void 0:de.to]),Si=A.useRef(null);A.useEffect(()=>{let W=!1;for(const le of n.current.agents.values())if(le.state==="active"){W=!0;break}const K=oO({enabled:Bt,kind:de==null?void 0:de.kind,canRestart:(E==null?void 0:E.canRestart)===!0,busy:W,idleSince:Si.current,now:Le});Si.current=K.idleSince,K.restart&&pr()},[Bt,de==null?void 0:de.kind,E==null?void 0:E.canRestart,Le,pr]),A.useEffect(()=>{let W=null;try{W=window.sessionStorage.getItem(zk)}catch{return}if(sO({bundle:"1.33.67",running:E==null?void 0:E.running,lastTried:W})){try{window.sessionStorage.setItem(zk,(E==null?void 0:E.running)??"")}catch{return}window.location.reload()}},[E==null?void 0:E.running]),A.useEffect(()=>{const W=E==null?void 0:E.running;if(!W)return;let K=null;try{K=window.sessionStorage.getItem("agent-dag.restartPending")}catch{return}if(K==null||K&&K!==W)return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}tr.current=!1,qn(!1),ln(W);const le=window.setTimeout(()=>ln(null),6e3);return()=>window.clearTimeout(le)},[E==null?void 0:E.running]);const $r=A.useRef(l4()).current;A.useRef(!1);const St=A.useRef(new Map($r.positions.filter(([W])=>$r.pins.includes(W)))),mr=A.useRef(null),_n=A.useState(()=>u4())[0],[un,nr]=A.useState(""),[ss,gr]=A.useState(()=>new Set),[Sn,vr]=A.useState(()=>typeof window>"u"?"dark":window.localStorage.getItem("agent-dag.theme")??"dark"),[Dr,no]=A.useState(!1),os=A.useRef(null);A.useEffect(()=>{document.documentElement.dataset.theme=Sn;try{window.localStorage.setItem("agent-dag.theme",Sn)}catch{}},[Sn]),A.useEffect(()=>{if(!_n)return;const W=window.setTimeout(()=>{try{e.setViewport(_n,{duration:0})}catch{}},60);return()=>window.clearTimeout(W)},[e,_n]);const bi=A.useRef(!0);A.useEffect(()=>{const W=new EventSource("/events"),K=dO(s,{now:()=>Date.now(),setTimeout:(le,ce)=>window.setTimeout(le,ce),clearTimeout:le=>window.clearTimeout(le)});return W.addEventListener("open",()=>{G(!0),no(!0)}),W.addEventListener("error",()=>G(!1)),W.addEventListener("replay-end",()=>{bi.current=!1,K.flush()}),W.addEventListener("hook",le=>{try{const ce=JSON.parse(le.data);if(!Tt.current.accept(ce))return;n.current=Zw(n.current,ce),ce.replay===!0||bi.current||Date.now()-ce.receivedAt>3e4?K.replay():K.live()}catch{}}),()=>{W.close(),K.cancel()}},[s]),A.useEffect(()=>{const W=setInterval(()=>{const K=Date.now();wt(K);let le=bP(n.current,K,Y$);_P(n.current,K,K$,X$)&&(le=!0),SP(n.current,K,Q$,Z$)&&(le=!0),le&&s()},250);return()=>clearInterval(W)},[s]);const cn=A.useRef(null),$n=A.useRef(0),as=420,Kt=A.useCallback((W=500)=>{try{const _e=document.querySelector(".canvas-wrap"),Te=Array.from(document.querySelectorAll(".react-flow__node")).filter(ft=>ft.offsetWidth>0);if(!_e||Te.length===0)return;const De=_e.getBoundingClientRect(),Ge=e.getViewport();if(!Number.isFinite(Ge.zoom)||Ge.zoom<=0)return;const Ke=ft=>(ft-De.left-Ge.x)/Ge.zoom,Qe=ft=>(ft-De.top-Ge.y)/Ge.zoom,Wt=Te.map(ft=>ft.getBoundingClientRect()),Qr=Math.min(...Wt.map(ft=>Ke(ft.left))),It=Math.max(...Wt.map(ft=>Ke(ft.right))),kn=Math.min(...Wt.map(ft=>Qe(ft.top))),Ai=Math.max(...Wt.map(ft=>Qe(ft.bottom))),Zr=It-Qr,hs=Ai-kn;if(!(Zr>0&&hs>0))return;const pn=Math.max(.2,Math.min(1,(De.width-160)/(Zr+as)*.86,(De.height-160)/hs*.86));e.setViewport({x:80-Qr*pn,y:Math.max(80,(De.height-hs*pn)/2)-kn*pn,zoom:pn},{duration:W}),$n.current=Date.now(),window.setTimeout(()=>{try{const ft={x:80-Qr*pn,y:Math.max(80,(De.height-hs*pn)/2)-kn*pn,zoom:pn},Jr=e.getViewport();(Math.abs(Jr.zoom-pn)>.01||Math.abs(Jr.x-ft.x)>2)&&e.setViewport(ft,{duration:0})}catch{}},W+60)}catch{}},[e]),Fr=A.useRef(""),zr=A.useRef(null),ki=A.useRef(0),yr=A.useCallback(()=>{ki.current=Date.now()},[]),Br="agent-dag.autoFitDisabled",Dn=A.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Br)==="1"}catch{return!1}})()),[Je,ls]=A.useState(Dn.current),Ur=A.useCallback(()=>{if(!Dn.current){Dn.current=!0,ls(!0);try{window.localStorage.setItem(Br,"1")}catch{}}},[]),us=A.useCallback(()=>{Dn.current=!1,ls(!1);try{window.localStorage.removeItem(Br)}catch{}Kt(400)},[e,Kt]);A.useEffect(()=>{const W=setInterval(()=>{if(Dn.current||Date.now()-ki.current<800)return;const K=n.current,le=Date.now(),ce=[];for(const Ke of K.agents.values())Gg(Ke,le)&&ce.push({id:Ke.id});if(ce.length===0)return;const ye=e.getViewport(),_e=window.innerWidth-360,Te=window.innerHeight-52;let De=!1,Ge=!1;for(const{id:Ke}of ce){const Qe=Fn.current.get(Ke),Wt=St.current.get(Ke)??Xt.current.get(Ke);if(!Qe||!Wt)continue;Ge=!0;const Qr=Wt.x*ye.zoom+ye.x,It=Wt.y*ye.zoom+ye.y,kn=(Wt.x+Qe.width)*ye.zoom+ye.x,Ai=(Wt.y+Qe.height)*ye.zoom+ye.y;if(kn>0&&Qr<_e&&Ai>0&&It<Te){De=!0;break}}Ge&&!De&&Kt(600)},1500);return()=>clearInterval(W)},[e]);const rr=A.useRef(!1),Fn=A.useRef(new Map),Ei=A.useRef(0),Hr=A.useCallback(W=>{const K=Fn.current;let le=!1;for(const ce of W.nodeInternals.values()){const ye=ce.width,_e=ce.height;if(ye==null||_e==null)continue;const Te=K.get(ce.id);Te?(Math.abs(Te.height-_e)>4||Math.abs(Te.width-ye)>4)&&(K.set(ce.id,{width:ye,height:_e}),le=!0):(K.set(ce.id,{width:ye,height:_e}),le=!0)}return le&&(Ei.current+=1),Ei.current},[]),Vt=Xe(Hr),[Vr,dn]=A.useState(0);A.useEffect(()=>{let W=0;const K=()=>{const ce=Fn.current;let ye=!1;for(const _e of document.querySelectorAll(".react-flow__node[data-id]")){const Te=_e.getAttribute("data-id");if(!Te)continue;const De=_e.offsetWidth,Ge=_e.offsetHeight;if(!De||!Ge)continue;const Ke=ce.get(Te);(!Ke||Math.abs(Ke.width-De)>4||Math.abs(Ke.height-Ge)>4)&&(ce.set(Te,{width:De,height:Ge}),ye=!0)}ye&&dn(_e=>_e+1)};if(rr.current)return;let le=0;return document.visibilityState==="hidden"?le=window.setTimeout(K,32):W=requestAnimationFrame(K),()=>{cancelAnimationFrame(W),window.clearTimeout(le)}});const Xt=A.useRef(new Map($r.positions)),ro=A.useRef(""),Wr=A.useMemo(()=>{const W=[];for(const K of n.current.agents.values())Gg(K,Le)&&W.push(K.id+(K.parentId?`>${K.parentId}`:""));return W.sort(),`${W.join("|")}#sv${Vt}.${Vr}`},[n.current,n.current.lastSeq,Le,Vt,Vr]),ir=A.useRef(null);A.useEffect(()=>(ir.current!=null&&window.clearTimeout(ir.current),ir.current=window.setTimeout(()=>{Ng(Xt.current,St.current)},1500),()=>{ir.current!=null&&window.clearTimeout(ir.current)}),[Wr]),A.useEffect(()=>{if(Fr.current===Wr)return;const W=Fr.current;if(Fr.current=Wr,!W||Dn.current)return;Date.now()-$n.current>1200&&Kt(400),cn.current&&window.clearTimeout(cn.current),cn.current=window.setTimeout(()=>{Dn.current||Kt(500)},280)},[Wr,e,Kt]);const Gr=A.useMemo(()=>{if(o.size===0)return null;const W=new Set;for(const K of o){const le=h4(n.current,K);if(le)for(const ce of le)W.add(ce)}return W.size>0?W:null},[n.current,n.current.lastSeq,o]),wr=A.useMemo(()=>B$(n.current,Le),[n.current,n.current.lastSeq,Le]),Ni=A.useRef(null),[cs,ga]=A.useState({w:0,h:0});A.useEffect(()=>{const W=Ni.current;if(!W||typeof ResizeObserver>"u")return;const K=new ResizeObserver(le=>{var ye;const ce=(ye=le[0])==null?void 0:ye.contentRect;ce&&ga(_e=>Math.abs(_e.w-ce.width)>40||Math.abs(_e.h-ce.height)>40?{w:ce.width,h:ce.height}:_e)});return K.observe(W),ga({w:W.clientWidth,h:W.clientHeight}),()=>K.disconnect()},[]);const io=A.useRef(new Map),[so,oo]=A.useState(!1);A.useEffect(()=>{const W=window.setTimeout(()=>oo(!0),2500);return()=>window.clearTimeout(W)},[]);const[Ci,ao]=A.useState(!1),bn=A.useRef(null),[Fe,lo]=A.useState(!1),va=A.useCallback(()=>{bn.current&&(window.clearTimeout(bn.current),bn.current=null),ao(!1)},[]),uo=A.useCallback(W=>{W.length!==0&&queueMicrotask(()=>{ao(!0),bn.current&&window.clearTimeout(bn.current),bn.current=window.setTimeout(()=>ao(!1),G$+80)})},[]);A.useEffect(()=>()=>{bn.current&&window.clearTimeout(bn.current)},[]);const co=cs.w>0?cs.w*.92:0,fo=cs.h>0?cs.h:0,{nodes:fn,edges:ho}=A.useMemo(()=>p4(n.current,Le,co,fo,St.current,un,Fn.current,io.current,uo,so,Fe,Xt.current,Wr,ro,o,Gr,wr,S),[n.current,n.current.lastSeq,Le,co,fo,so,Fe,un,Wr,o,Gr,wr,S,lt]),ji=A.useMemo(()=>{const W=new Map;for(const le of fn){const ce=le.data;if(!(ce!=null&&ce.sessionId)||ce.exitAt!=null)continue;const ye=le.width,_e=le.height;if(ye==null||_e==null)continue;const Te=le.position.x,De=le.position.y,Ge=Te+ye,Ke=De+_e,Qe=W.get(ce.sessionId);Qe?(Qe.minX=Math.min(Qe.minX,Te),Qe.minY=Math.min(Qe.minY,De),Qe.maxX=Math.max(Qe.maxX,Ge),Qe.maxY=Math.max(Qe.maxY,Ke)):W.set(ce.sessionId,{minX:Te,minY:De,maxX:Ge,maxY:Ke})}const K=[];for(const[le,ce]of W){const ye=ce.maxX-ce.minX+Tl*2,_e=ce.maxY-ce.minY+Tl*2;K.push({id:`group:${le}`,type:"sessionGroup",position:{x:ce.minX-Tl,y:ce.minY-Tl},data:{sessionId:le,w:ye,h:_e},width:ye,height:_e,style:{width:ye,height:_e},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return K},[fn,Le]),sr=A.useMemo(()=>{const W=[...ji,...fn],K=tt.current;return!K||K.size===0?W:W.map(le=>{const ce=K.get(le.id);return ce?{...le,position:ce}:le})},[ji,fn,qt]),or=A.useMemo(()=>{if(!un)return null;const W=new Set;for(const K of n.current.agents.values())AC(K,un)&&W.add(K.id);return W},[n.current,n.current.lastSeq,un]),hn=A.useMemo(()=>{const W=new Set;for(const K of n.current.agents.values())for(const le of K.tools)W.add(TC(le.name));return Object.keys(Yg).filter(K=>W.has(K))},[n.current,n.current.lastSeq]);A.useEffect(()=>{if(hn.length<=1){vt(!1);return}let W=0;const K=()=>{const le=$e.current;if(le&&!document.hidden){const ce=le.getBoundingClientRect(),ye=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Te=>Te.getBoundingClientRect()),_e=H$(ce,ye,8);vt(Te=>Te===_e?Te:_e)}W=window.setTimeout(K,300)};return K(),()=>window.clearTimeout(W)},[hn.length]);const zn=A.useMemo(()=>{const W=new Map;for(const le of n.current.agents.values())for(const ce of le.tools){if(!ce.name.startsWith("mcp__"))continue;const ye=ce.name.slice(5),_e=ye.indexOf("__"),Te=_e>0?ye.slice(0,_e):ye;W.set(Te,(W.get(Te)??0)+1)}const K=[];for(const[le,ce]of W){let ye=5381;for(let _e=0;_e<le.length;_e++)ye=(ye<<5)+ye^le.charCodeAt(_e);K.push({server:le,count:ce,hue:Math.abs(ye)%360})}return K.sort((le,ce)=>ce.count-le.count),K},[n.current,n.current.lastSeq]),Ri=A.useCallback(W=>{gr(K=>{const le=new Set(K);return le.has(W)?le.delete(W):le.add(W),le})},[]),ut=u?n.current.agents.get(u):null,ya=p?Array.from(n.current.agents.values()).flatMap(W=>W.tools).find(W=>W.id===p)??null:null,ds=A.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=Ug(),St.current.clear(),Fn.current.clear(),Xt.current.clear(),ro.current="",Uk(),m(),s()},[s,m]),xr=A.useCallback(()=>{St.current.clear(),Xt.current.clear(),ro.current="",Uk(),s(),window.setTimeout(()=>Kt(500),80)},[s,e,Kt]),wa=A.useCallback(()=>Kt(500),[Kt]),fs=A.useCallback(W=>{if(fn.length===0)return;const K=fn.slice().sort((_e,Te)=>_e.position.y-Te.position.y||_e.position.x-Te.position.x),le=u?K.findIndex(_e=>_e.id===u):-1;let ce;le===-1?ce=W===1?0:K.length-1:ce=(le+W+K.length)%K.length;const ye=K[ce];ye&&(f(ye.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[ye]})}catch{}$n.current=Date.now()},30))},[fn,u,f,e]);A.useEffect(()=>{const W=K=>{var ce,ye;const le=((ce=K.target)==null?void 0:ce.tagName)==="INPUT";if(K.key==="Escape"){le?K.target.blur():m();return}if(!le&&!aO(K)){if(K.key==="/"){K.preventDefault(),(ye=os.current)==null||ye.focus();return}K.key===" "&&(K.preventDefault(),yt()),(K.key==="c"||K.key==="C")&&ds(),(K.key==="r"||K.key==="R")&&xr(),(K.key==="f"||K.key==="F")&&wa(),(K.key==="l"||K.key==="L")&&ve(),(K.key==="h"||K.key==="H")&&at(_e=>!_e),(K.key==="u"||K.key==="U")&&L(_e=>!_e),(K.key==="a"||K.key==="A")&&we(),(K.key==="j"||K.key==="J")&&fs(1),(K.key==="k"||K.key==="K")&&fs(-1),(K.key==="t"||K.key==="T")&&vr(_e=>_e==="dark"?"light":"dark")}};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[ds,xr,wa,m,fs,yt]);const Yr=n.current.agents.size,xa=new Set(Array.from(n.current.agents.values()).map(W=>W.sessionId)).size,Qt=A.useMemo(()=>{let W=0,K=0,le=0,ce=0,ye=0,_e=0,Te=0,De=0,Ge=0;for(const Ke of n.current.agents.values()){W+=Ke.usage.inputTokens,K+=Ke.usage.outputTokens,le+=Ke.usage.cacheReadTokens,ce+=Ke.usage.cacheCreateTokens;const Qe=on(Ke.usage,Ke.model);ye+=Qe.total,_e+=Qe.input,Te+=Qe.output,De+=Qe.cacheRead,Ge+=Qe.cacheWrite}return{inT:W,outT:K,cacheR:le,cacheC:ce,sum:W+K,cost:{total:ye,input:_e,output:Te,cacheRead:De,cacheWrite:Ge}}},[n.current,n.current.lastSeq]);return g.jsxs("div",{className:"app",children:[g.jsxs("header",{className:"topbar",children:[g.jsxs("div",{className:"brand",children:[g.jsx("span",{className:"logo"}),"agents-deck",de?g.jsxs("button",{type:"button",className:"v stale",onClick:Pe,title:de.kind==="restart"?`Running v${de.from}; v${de.to} is installed on disk. Restart to pick it up.`:`Running v${de.from}; v${de.to} is on npm.`,children:["v",de.from,g.jsx("span",{className:"v-dot","aria-hidden":!0})]}):g.jsxs("button",{type:"button",className:"v",onClick:()=>ue(!0),title:E!=null&&E.checkDisabled?"Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1).":`${E!=null&&E.latest?`npm has v${E.latest}`:"npm not reached yet"}${E!=null&&E.checkedAt?` · checked ${e4(Le-E.checkedAt)}`:""} · click to check now`,children:["v",(E==null?void 0:E.running)??"1.33.67"]})]}),ut&&(()=>{const W=on(ut.usage,ut.model),K=Math.max(0,((ut.endedAt??Le)-ut.startedAt)/1e3),le=ut.state==="active"?Vl(W.total,K):null,ce=o.size-1;return g.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${ut.label}`,onClick:()=>{try{const ye=fn.find(_e=>_e.id===ut.id);ye&&e.fitView({padding:.35,duration:500,nodes:[ye]}),$n.current=Date.now()}catch{}},children:[g.jsx("span",{className:`state-pill state-${ut.state}`,children:ut.state==="active"?"live":ut.state}),g.jsx("span",{className:"selected-label",children:ut.label}),W.total>0&&g.jsxs("span",{className:"selected-cost",children:[Be(W.total),le?g.jsxs("span",{className:"selected-rate",children:[" · ",le]}):null]}),ce>0&&g.jsxs("span",{className:"selected-extra",children:["+",ce]}),g.jsx("span",{role:"button","aria-label":"Deselect",className:"selected-close",onClick:ye=>{ye.stopPropagation(),m()},children:"×"})]})})(),g.jsxs("div",{className:"actions",children:[g.jsxs("div",{className:"search",children:[g.jsx("span",{className:"search-icon","aria-hidden":!0,children:"⌕"}),g.jsx("input",{ref:os,type:"text",placeholder:"Search agents, cwd, tools…",value:un,onChange:W=>nr(W.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),un?g.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>nr(""),children:"×"}):g.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"})]}),g.jsxs("span",{className:"status",role:"status",children:[g.jsx("span",{className:`pill ${F?"live":"dead"}`,title:F?"Receiving events":"SSE disconnected",children:F?"live":"offline"}),g.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[g.jsx("span",{className:"count",children:xa}),g.jsx("span",{className:"lbl",children:"sessions"})]}),g.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[g.jsx("span",{className:"count",children:Yr}),g.jsx("span",{className:"lbl",children:"agents"})]}),g.jsxs("span",{className:"stat",title:"Total hook events received",children:[g.jsx("span",{className:"count",children:n.current.totalEvents}),g.jsx("span",{className:"lbl",children:"events"})]}),Qt.sum>0&&g.jsxs("span",{className:"stat",title:`in:${Qt.inT.toLocaleString()} out:${Qt.outT.toLocaleString()} cache-r:${Qt.cacheR.toLocaleString()} cache-c:${Qt.cacheC.toLocaleString()}`,children:[g.jsx("span",{className:"count",children:V$(Qt.sum)}),g.jsx("span",{className:"lbl",children:"tokens"})]}),zn.length>0&&g.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
|
|
60
60
|
${zn.map(W=>` ${W.server}: ${W.count} call${W.count===1?"":"s"}`).join(`
|
|
61
61
|
`)}`,children:[zn.slice(0,6).map(W=>g.jsx("span",{className:"mcp-dot",style:{background:`hsl(${W.hue} 65% 65%)`}},W.server)),zn.length>6&&g.jsxs("span",{className:"mcp-more",children:["+",zn.length-6]}),g.jsx("span",{className:"lbl",children:"mcp"})]}),Qt.cost.total>0&&(()=>{let W=0,K=0;for(const ye of n.current.agents.values()){if(ye.state!=="active")continue;const _e=on(ye.usage,ye.model);W+=_e.total,K=Math.max(K,((ye.endedAt??Le)-ye.startedAt)/1e3)}const le=K>0?Vl(W,K):null,ce=`input ${Be(Qt.cost.input)} + output ${Be(Qt.cost.output)} + cache r ${Be(Qt.cost.cacheRead)} + cache w ${Be(Qt.cost.cacheWrite)}${le?`
|
|
62
62
|
active burn: ${le}`:""}`;return g.jsxs("span",{className:"stat",title:ce,children:[g.jsx("span",{className:"count",children:Be(Qt.cost.total)}),g.jsxs("span",{className:"lbl",children:["cost",le?` · ${le}`:""]})]})})()]}),g.jsx("button",{className:`btn ${At?"warn":""}`,onClick:yt,title:"Pause/resume live updates (Space)",children:At?`Resume${Tt.current.size?` · ${Tt.current.size}`:""}`:"Pause"}),g.jsx("button",{className:`btn icon-btn ${O?"primary":""}`,onClick:()=>L(W=>!W),title:`${O?"Hide":"Show"} usage panel (U)`,"aria-label":"Toggle usage panel",children:"$"}),M!==null&&g.jsx("button",{className:`btn icon-btn ${M?"primary":""}`,onClick:W=>{if(W.shiftKey&&U>0){X(!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&&(q(K.enabled===!0),ne(K.parked??0))}).catch(()=>{}).finally(()=>X(!1));return}J()},disabled:Y,title:(M?"Sound on turn finish: on — click to remove the hook":"Sound on turn finish: off — click to add a Stop hook")+(I>0?`
|