agent-dag 1.33.0 → 1.33.1

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: `+x.message+`
56
56
  */var tw;function nR(){if(tw)return Hc;tw=1;var e=Qo(),n=tR();function i(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var s=typeof Object.is=="function"?Object.is:i,o=n.useSyncExternalStore,l=e.useRef,u=e.useEffect,c=e.useMemo,f=e.useDebugValue;return Hc.useSyncExternalStoreWithSelector=function(h,p,m,y,w){var j=l(null);if(j.current===null){var _={hasValue:!1,value:null};j.current=_}else _=j.current;j=c(function(){function b(O){if(!E){if(E=!0,N=O,O=y(O),w!==void 0&&_.hasValue){var P=_.value;if(w(P,O))return C=P}return C=O}if(P=C,s(N,O))return P;var z=y(O);return w!==void 0&&w(P,z)?(N=O,P):(N=O,C=z)}var E=!1,N,C,I=m===void 0?null:m;return[function(){return b(p())},I===null?void 0:function(){return b(I())}]},[p,m,y,w]);var S=o(h,j[0],j[1]);return u(function(){_.hasValue=!0,_.value=S},[S]),f(S),S},Hc}var nw;function rR(){return nw||(nw=1,Uc.exports=nR()),Uc.exports}var iR=rR();const sR=Wg(iR),oR={},rw=e=>{let n;const i=new Set,s=(p,m)=>{const y=typeof p=="function"?p(n):p;if(!Object.is(y,n)){const w=n;n=m??(typeof y!="object"||y===null)?y:Object.assign({},n,y),i.forEach(j=>j(n,w))}},o=()=>n,f={setState:s,getState:o,getInitialState:()=>h,subscribe:p=>(i.add(p),()=>i.delete(p)),destroy:()=>{(oR?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),i.clear()}},h=n=e(s,o,f);return f},aR=e=>e?rw(e):rw,{useDebugValue:lR}=le,{useSyncExternalStoreWithSelector:uR}=sR,cR=e=>e;function Ok(e,n=cR,i){const s=uR(e.subscribe,e.getState,e.getServerState||e.getInitialState,n,i);return lR(s),s}const iw=(e,n)=>{const i=aR(e),s=(o,l=n)=>Ok(i,o,l);return Object.assign(s,i),s},dR=(e,n)=>e?iw(e,n):iw;function Ct(e,n){if(Object.is(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(const[s,o]of e)if(!Object.is(o,n.get(s)))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(const s of e)if(!n.has(s))return!1;return!0}const i=Object.keys(e);if(i.length!==Object.keys(n).length)return!1;for(const s of i)if(!Object.prototype.hasOwnProperty.call(n,s)||!Object.is(e[s],n[s]))return!1;return!0}var fR={value:()=>{}};function Fl(){for(var e=0,n=arguments.length,i={},s;e<n;++e){if(!(s=arguments[e]+"")||s in i||/[\s.]/.test(s))throw new Error("illegal type: "+s);i[s]=[]}return new kl(i)}function kl(e){this._=e}function hR(e,n){return e.trim().split(/^|\s+/).map(function(i){var s="",o=i.indexOf(".");if(o>=0&&(s=i.slice(o+1),i=i.slice(0,o)),i&&!n.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:s}})}kl.prototype=Fl.prototype={constructor:kl,on:function(e,n){var i=this._,s=hR(e+"",i),o,l=-1,u=s.length;if(arguments.length<2){for(;++l<u;)if((o=(e=s[l]).type)&&(o=pR(i[o],e.name)))return o;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++l<u;)if(o=(e=s[l]).type)i[o]=sw(i[o],e.name,n);else if(n==null)for(o in i)i[o]=sw(i[o],e.name,null);return this},copy:function(){var e={},n=this._;for(var i in n)e[i]=n[i].slice();return new kl(e)},call:function(e,n){if((o=arguments.length-2)>0)for(var i=new Array(o),s=0,o,l;s<o;++s)i[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(l=this._[e],s=0,o=l.length;s<o;++s)l[s].value.apply(n,i)},apply:function(e,n,i){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var s=this._[e],o=0,l=s.length;o<l;++o)s[o].value.apply(n,i)}};function pR(e,n){for(var i=0,s=e.length,o;i<s;++i)if((o=e[i]).name===n)return o.value}function sw(e,n,i){for(var s=0,o=e.length;s<o;++s)if(e[s].name===n){e[s]=fR,e=e.slice(0,s).concat(e.slice(s+1));break}return i!=null&&e.push({name:n,value:i}),e}var kg="http://www.w3.org/1999/xhtml";const ow={svg:"http://www.w3.org/2000/svg",xhtml:kg,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function zl(e){var n=e+="",i=n.indexOf(":");return i>=0&&(n=e.slice(0,i))!=="xmlns"&&(e=e.slice(i+1)),ow.hasOwnProperty(n)?{space:ow[n],local:e}:e}function mR(e){return function(){var n=this.ownerDocument,i=this.namespaceURI;return i===kg&&n.documentElement.namespaceURI===kg?n.createElement(e):n.createElementNS(i,e)}}function gR(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function qk(e){var n=zl(e);return(n.local?gR:mR)(n)}function vR(){}function Gg(e){return e==null?vR:function(){return this.querySelector(e)}}function yR(e){typeof e!="function"&&(e=Gg(e));for(var n=this._groups,i=n.length,s=new Array(i),o=0;o<i;++o)for(var l=n[o],u=l.length,c=s[o]=new Array(u),f,h,p=0;p<u;++p)(f=l[p])&&(h=e.call(f,f.__data__,p,l))&&("__data__"in f&&(h.__data__=f.__data__),c[p]=h);return new yn(s,this._parents)}function wR(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function xR(){return[]}function Lk(e){return e==null?xR:function(){return this.querySelectorAll(e)}}function _R(e){return function(){return wR(e.apply(this,arguments))}}function SR(e){typeof e=="function"?e=_R(e):e=Lk(e);for(var n=this._groups,i=n.length,s=[],o=[],l=0;l<i;++l)for(var u=n[l],c=u.length,f,h=0;h<c;++h)(f=u[h])&&(s.push(e.call(f,f.__data__,h,u)),o.push(f));return new yn(s,o)}function $k(e){return function(){return this.matches(e)}}function Dk(e){return function(n){return n.matches(e)}}var bR=Array.prototype.find;function kR(e){return function(){return bR.call(this.children,e)}}function ER(){return this.firstElementChild}function NR(e){return this.select(e==null?ER:kR(typeof e=="function"?e:Dk(e)))}var CR=Array.prototype.filter;function jR(){return Array.from(this.children)}function RR(e){return function(){return CR.call(this.children,e)}}function TR(e){return this.selectAll(e==null?jR:RR(typeof e=="function"?e:Dk(e)))}function AR(e){typeof e!="function"&&(e=$k(e));for(var n=this._groups,i=n.length,s=new Array(i),o=0;o<i;++o)for(var l=n[o],u=l.length,c=s[o]=[],f,h=0;h<u;++h)(f=l[h])&&e.call(f,f.__data__,h,l)&&c.push(f);return new yn(s,this._parents)}function Fk(e){return new Array(e.length)}function IR(){return new yn(this._enter||this._groups.map(Fk),this._parents)}function jl(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}jl.prototype={constructor:jl,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 MR(e){return function(){return e}}function PR(e,n,i,s,o,l){for(var u=0,c,f=n.length,h=l.length;u<h;++u)(c=n[u])?(c.__data__=l[u],s[u]=c):i[u]=new jl(e,l[u]);for(;u<f;++u)(c=n[u])&&(o[u]=c)}function OR(e,n,i,s,o,l,u){var c,f,h=new Map,p=n.length,m=l.length,y=new Array(p),w;for(c=0;c<p;++c)(f=n[c])&&(y[c]=w=u.call(f,f.__data__,c,n)+"",h.has(w)?o[c]=f:h.set(w,f));for(c=0;c<m;++c)w=u.call(e,l[c],c,l)+"",(f=h.get(w))?(s[c]=f,f.__data__=l[c],h.delete(w)):i[c]=new jl(e,l[c]);for(c=0;c<p;++c)(f=n[c])&&h.get(y[c])===f&&(o[c]=f)}function qR(e){return e.__data__}function LR(e,n){if(!arguments.length)return Array.from(this,qR);var i=n?OR:PR,s=this._parents,o=this._groups;typeof e!="function"&&(e=MR(e));for(var l=o.length,u=new Array(l),c=new Array(l),f=new Array(l),h=0;h<l;++h){var p=s[h],m=o[h],y=m.length,w=$R(e.call(p,p&&p.__data__,h,s)),j=w.length,_=c[h]=new Array(j),S=u[h]=new Array(j),b=f[h]=new Array(y);i(p,m,_,S,b,w,n);for(var E=0,N=0,C,I;E<j;++E)if(C=_[E]){for(E>=N&&(N=E+1);!(I=S[N])&&++N<j;);C._next=I||null}}return u=new yn(u,s),u._enter=c,u._exit=f,u}function $R(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function DR(){return new yn(this._exit||this._groups.map(Fk),this._parents)}function FR(e,n,i){var s=this.enter(),o=this,l=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),n!=null&&(o=n(o),o&&(o=o.selection())),i==null?l.remove():i(l),s&&o?s.merge(o).order():o}function zR(e){for(var n=e.selection?e.selection():e,i=this._groups,s=n._groups,o=i.length,l=s.length,u=Math.min(o,l),c=new Array(o),f=0;f<u;++f)for(var h=i[f],p=s[f],m=h.length,y=c[f]=new Array(m),w,j=0;j<m;++j)(w=h[j]||p[j])&&(y[j]=w);for(;f<o;++f)c[f]=i[f];return new yn(c,this._parents)}function BR(){for(var e=this._groups,n=-1,i=e.length;++n<i;)for(var s=e[n],o=s.length-1,l=s[o],u;--o>=0;)(u=s[o])&&(l&&u.compareDocumentPosition(l)^4&&l.parentNode.insertBefore(u,l),l=u);return this}function UR(e){e||(e=HR);function n(m,y){return m&&y?e(m.__data__,y.__data__):!m-!y}for(var i=this._groups,s=i.length,o=new Array(s),l=0;l<s;++l){for(var u=i[l],c=u.length,f=o[l]=new Array(c),h,p=0;p<c;++p)(h=u[p])&&(f[p]=h);f.sort(n)}return new yn(o,this._parents).order()}function HR(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function VR(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function WR(){return Array.from(this)}function GR(){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var s=e[n],o=0,l=s.length;o<l;++o){var u=s[o];if(u)return u}return null}function YR(){let e=0;for(const n of this)++e;return e}function KR(){return!this.node()}function XR(e){for(var n=this._groups,i=0,s=n.length;i<s;++i)for(var o=n[i],l=0,u=o.length,c;l<u;++l)(c=o[l])&&e.call(c,c.__data__,l,o);return this}function QR(e){return function(){this.removeAttribute(e)}}function ZR(e){return function(){this.removeAttributeNS(e.space,e.local)}}function JR(e,n){return function(){this.setAttribute(e,n)}}function eT(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function tT(e,n){return function(){var i=n.apply(this,arguments);i==null?this.removeAttribute(e):this.setAttribute(e,i)}}function nT(e,n){return function(){var i=n.apply(this,arguments);i==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,i)}}function rT(e,n){var i=zl(e);if(arguments.length<2){var s=this.node();return i.local?s.getAttributeNS(i.space,i.local):s.getAttribute(i)}return this.each((n==null?i.local?ZR:QR:typeof n=="function"?i.local?nT:tT:i.local?eT:JR)(i,n))}function zk(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function iT(e){return function(){this.style.removeProperty(e)}}function sT(e,n,i){return function(){this.style.setProperty(e,n,i)}}function oT(e,n,i){return function(){var s=n.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,i)}}function aT(e,n,i){return arguments.length>1?this.each((n==null?iT:typeof n=="function"?oT:sT)(e,n,i??"")):Fs(this.node(),e)}function Fs(e,n){return e.style.getPropertyValue(n)||zk(e).getComputedStyle(e,null).getPropertyValue(n)}function lT(e){return function(){delete this[e]}}function uT(e,n){return function(){this[e]=n}}function cT(e,n){return function(){var i=n.apply(this,arguments);i==null?delete this[e]:this[e]=i}}function dT(e,n){return arguments.length>1?this.each((n==null?lT:typeof n=="function"?cT:uT)(e,n)):this.node()[e]}function Bk(e){return e.trim().split(/^|\s+/)}function Yg(e){return e.classList||new Uk(e)}function Uk(e){this._node=e,this._names=Bk(e.getAttribute("class")||"")}Uk.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 Hk(e,n){for(var i=Yg(e),s=-1,o=n.length;++s<o;)i.add(n[s])}function Vk(e,n){for(var i=Yg(e),s=-1,o=n.length;++s<o;)i.remove(n[s])}function fT(e){return function(){Hk(this,e)}}function hT(e){return function(){Vk(this,e)}}function pT(e,n){return function(){(n.apply(this,arguments)?Hk:Vk)(this,e)}}function mT(e,n){var i=Bk(e+"");if(arguments.length<2){for(var s=Yg(this.node()),o=-1,l=i.length;++o<l;)if(!s.contains(i[o]))return!1;return!0}return this.each((typeof n=="function"?pT:n?fT:hT)(i,n))}function gT(){this.textContent=""}function vT(e){return function(){this.textContent=e}}function yT(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function wT(e){return arguments.length?this.each(e==null?gT:(typeof e=="function"?yT:vT)(e)):this.node().textContent}function xT(){this.innerHTML=""}function _T(e){return function(){this.innerHTML=e}}function ST(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function bT(e){return arguments.length?this.each(e==null?xT:(typeof e=="function"?ST:_T)(e)):this.node().innerHTML}function kT(){this.nextSibling&&this.parentNode.appendChild(this)}function ET(){return this.each(kT)}function NT(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function CT(){return this.each(NT)}function jT(e){var n=typeof e=="function"?e:qk(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function RT(){return null}function TT(e,n){var i=typeof e=="function"?e:qk(e),s=n==null?RT:typeof n=="function"?n:Gg(n);return this.select(function(){return this.insertBefore(i.apply(this,arguments),s.apply(this,arguments)||null)})}function AT(){var e=this.parentNode;e&&e.removeChild(this)}function IT(){return this.each(AT)}function MT(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function PT(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function OT(e){return this.select(e?PT:MT)}function qT(e){return arguments.length?this.property("__data__",e):this.node().__data__}function LT(e){return function(n){e.call(this,n,this.__data__)}}function $T(e){return e.trim().split(/^|\s+/).map(function(n){var i="",s=n.indexOf(".");return s>=0&&(i=n.slice(s+1),n=n.slice(0,s)),{type:n,name:i}})}function DT(e){return function(){var n=this.__on;if(n){for(var i=0,s=-1,o=n.length,l;i<o;++i)l=n[i],(!e.type||l.type===e.type)&&l.name===e.name?this.removeEventListener(l.type,l.listener,l.options):n[++s]=l;++s?n.length=s:delete this.__on}}}function FT(e,n,i){return function(){var s=this.__on,o,l=LT(n);if(s){for(var u=0,c=s.length;u<c;++u)if((o=s[u]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=l,o.options=i),o.value=n;return}}this.addEventListener(e.type,l,i),o={type:e.type,name:e.name,value:n,listener:l,options:i},s?s.push(o):this.__on=[o]}}function zT(e,n,i){var s=$T(e+""),o,l=s.length,u;if(arguments.length<2){var c=this.node().__on;if(c){for(var f=0,h=c.length,p;f<h;++f)for(o=0,p=c[f];o<l;++o)if((u=s[o]).type===p.type&&u.name===p.name)return p.value}return}for(c=n?FT:DT,o=0;o<l;++o)this.each(c(s[o],n,i));return this}function Wk(e,n,i){var s=zk(e),o=s.CustomEvent;typeof o=="function"?o=new o(n,i):(o=s.document.createEvent("Event"),i?(o.initEvent(n,i.bubbles,i.cancelable),o.detail=i.detail):o.initEvent(n,!1,!1)),e.dispatchEvent(o)}function BT(e,n){return function(){return Wk(this,e,n)}}function UT(e,n){return function(){return Wk(this,e,n.apply(this,arguments))}}function HT(e,n){return this.each((typeof n=="function"?UT:BT)(e,n))}function*VT(){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var s=e[n],o=0,l=s.length,u;o<l;++o)(u=s[o])&&(yield u)}var Gk=[null];function yn(e,n){this._groups=e,this._parents=n}function Zo(){return new yn([[document.documentElement]],Gk)}function WT(){return this}yn.prototype=Zo.prototype={constructor:yn,select:yR,selectAll:SR,selectChild:NR,selectChildren:TR,filter:AR,data:LR,enter:IR,exit:DR,join:FR,merge:zR,selection:WT,order:BR,sort:UR,call:VR,nodes:WR,node:GR,size:YR,empty:KR,each:XR,attr:rT,style:aT,property:dT,classed:mT,text:wT,html:bT,raise:ET,lower:CT,append:jT,insert:TT,remove:IT,clone:OT,datum:qT,on:zT,dispatch:HT,[Symbol.iterator]:VT};function Mn(e){return typeof e=="string"?new yn([[document.querySelector(e)]],[document.documentElement]):new yn([[e]],Gk)}function GT(e){let n;for(;n=e.sourceEvent;)e=n;return e}function Kn(e,n){if(e=GT(e),n===void 0&&(n=e.currentTarget),n){var i=n.ownerSVGElement||n;if(i.createSVGPoint){var s=i.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,s=s.matrixTransform(n.getScreenCTM().inverse()),[s.x,s.y]}if(n.getBoundingClientRect){var o=n.getBoundingClientRect();return[e.clientX-o.left-n.clientLeft,e.clientY-o.top-n.clientTop]}}return[e.pageX,e.pageY]}const YT={passive:!1},Uo={capture:!0,passive:!1};function Gc(e){e.stopImmediatePropagation()}function qs(e){e.preventDefault(),e.stopImmediatePropagation()}function Yk(e){var n=e.document.documentElement,i=Mn(e).on("dragstart.drag",qs,Uo);"onselectstart"in n?i.on("selectstart.drag",qs,Uo):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function Kk(e,n){var i=e.document.documentElement,s=Mn(e).on("dragstart.drag",null);n&&(s.on("click.drag",qs,Uo),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in i?s.on("selectstart.drag",null):(i.style.MozUserSelect=i.__noselect,delete i.__noselect)}const ul=e=>()=>e;function Eg(e,{sourceEvent:n,subject:i,target:s,identifier:o,active:l,x:u,y:c,dx:f,dy:h,dispatch:p}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:i,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:l,enumerable:!0,configurable:!0},x:{value:u,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:f,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:p}})}Eg.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function KT(e){return!e.ctrlKey&&!e.button}function XT(){return this.parentNode}function QT(e,n){return n??{x:e.x,y:e.y}}function ZT(){return navigator.maxTouchPoints||"ontouchstart"in this}function JT(){var e=KT,n=XT,i=QT,s=ZT,o={},l=Fl("start","drag","end"),u=0,c,f,h,p,m=0;function y(C){C.on("mousedown.drag",w).filter(s).on("touchstart.drag",S).on("touchmove.drag",b,YT).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function w(C,I){if(!(p||!e.call(this,C,I))){var O=N(this,n.call(this,C,I),C,I,"mouse");O&&(Mn(C.view).on("mousemove.drag",j,Uo).on("mouseup.drag",_,Uo),Yk(C.view),Gc(C),h=!1,c=C.clientX,f=C.clientY,O("start",C))}}function j(C){if(qs(C),!h){var I=C.clientX-c,O=C.clientY-f;h=I*I+O*O>m}o.mouse("drag",C)}function _(C){Mn(C.view).on("mousemove.drag mouseup.drag",null),Kk(C.view,h),qs(C),o.mouse("end",C)}function S(C,I){if(e.call(this,C,I)){var O=C.changedTouches,P=n.call(this,C,I),z=O.length,T,q;for(T=0;T<z;++T)(q=N(this,P,C,I,O[T].identifier,O[T]))&&(Gc(C),q("start",C,O[T]))}}function b(C){var I=C.changedTouches,O=I.length,P,z;for(P=0;P<O;++P)(z=o[I[P].identifier])&&(qs(C),z("drag",C,I[P]))}function E(C){var I=C.changedTouches,O=I.length,P,z;for(p&&clearTimeout(p),p=setTimeout(function(){p=null},500),P=0;P<O;++P)(z=o[I[P].identifier])&&(Gc(C),z("end",C,I[P]))}function N(C,I,O,P,z,T){var q=l.copy(),B=Kn(T||O,I),Z,Q,A;if((A=i.call(C,new Eg("beforestart",{sourceEvent:O,target:y,identifier:z,active:u,x:B[0],y:B[1],dx:0,dy:0,dispatch:q}),P))!=null)return Z=A.x-B[0]||0,Q=A.y-B[1]||0,function H(U,ne,Y){var L=B,G;switch(U){case"start":o[z]=H,G=u++;break;case"end":delete o[z],--u;case"drag":B=Kn(Y||ne,I),G=u;break}q.call(U,C,new Eg(U,{sourceEvent:ne,subject:A,target:y,identifier:z,active:G,x:B[0]+Z,y:B[1]+Q,dx:B[0]-L[0],dy:B[1]-L[1],dispatch:q}),P)}}return y.filter=function(C){return arguments.length?(e=typeof C=="function"?C:ul(!!C),y):e},y.container=function(C){return arguments.length?(n=typeof C=="function"?C:ul(C),y):n},y.subject=function(C){return arguments.length?(i=typeof C=="function"?C:ul(C),y):i},y.touchable=function(C){return arguments.length?(s=typeof C=="function"?C:ul(!!C),y):s},y.on=function(){var C=l.on.apply(l,arguments);return C===l?y:C},y.clickDistance=function(C){return arguments.length?(m=(C=+C)*C,y):Math.sqrt(m)},y}function Kg(e,n,i){e.prototype=n.prototype=i,i.constructor=e}function Xk(e,n){var i=Object.create(e.prototype);for(var s in n)i[s]=n[s];return i}function Jo(){}var Ho=.7,Rl=1/Ho,Ls="\\s*([+-]?\\d+)\\s*",Vo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ur="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",e2=/^#([0-9a-f]{3,8})$/,t2=new RegExp(`^rgb\\(${Ls},${Ls},${Ls}\\)$`),n2=new RegExp(`^rgb\\(${ur},${ur},${ur}\\)$`),r2=new RegExp(`^rgba\\(${Ls},${Ls},${Ls},${Vo}\\)$`),i2=new RegExp(`^rgba\\(${ur},${ur},${ur},${Vo}\\)$`),s2=new RegExp(`^hsl\\(${Vo},${ur},${ur}\\)$`),o2=new RegExp(`^hsla\\(${Vo},${ur},${ur},${Vo}\\)$`),aw={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};Kg(Jo,Wo,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:lw,formatHex:lw,formatHex8:a2,formatHsl:l2,formatRgb:uw,toString:uw});function lw(){return this.rgb().formatHex()}function a2(){return this.rgb().formatHex8()}function l2(){return Qk(this).formatHsl()}function uw(){return this.rgb().formatRgb()}function Wo(e){var n,i;return e=(e+"").trim().toLowerCase(),(n=e2.exec(e))?(i=n[1].length,n=parseInt(n[1],16),i===6?cw(n):i===3?new dn(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):i===8?cl(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):i===4?cl(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|n&240,((n&15)<<4|n&15)/255):null):(n=t2.exec(e))?new dn(n[1],n[2],n[3],1):(n=n2.exec(e))?new dn(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=r2.exec(e))?cl(n[1],n[2],n[3],n[4]):(n=i2.exec(e))?cl(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=s2.exec(e))?hw(n[1],n[2]/100,n[3]/100,1):(n=o2.exec(e))?hw(n[1],n[2]/100,n[3]/100,n[4]):aw.hasOwnProperty(e)?cw(aw[e]):e==="transparent"?new dn(NaN,NaN,NaN,0):null}function cw(e){return new dn(e>>16&255,e>>8&255,e&255,1)}function cl(e,n,i,s){return s<=0&&(e=n=i=NaN),new dn(e,n,i,s)}function u2(e){return e instanceof Jo||(e=Wo(e)),e?(e=e.rgb(),new dn(e.r,e.g,e.b,e.opacity)):new dn}function Ng(e,n,i,s){return arguments.length===1?u2(e):new dn(e,n,i,s??1)}function dn(e,n,i,s){this.r=+e,this.g=+n,this.b=+i,this.opacity=+s}Kg(dn,Ng,Xk(Jo,{brighter(e){return e=e==null?Rl:Math.pow(Rl,e),new dn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ho:Math.pow(Ho,e),new dn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new dn(Hi(this.r),Hi(this.g),Hi(this.b),Tl(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:dw,formatHex:dw,formatHex8:c2,formatRgb:fw,toString:fw}));function dw(){return`#${Bi(this.r)}${Bi(this.g)}${Bi(this.b)}`}function c2(){return`#${Bi(this.r)}${Bi(this.g)}${Bi(this.b)}${Bi((isNaN(this.opacity)?1:this.opacity)*255)}`}function fw(){const e=Tl(this.opacity);return`${e===1?"rgb(":"rgba("}${Hi(this.r)}, ${Hi(this.g)}, ${Hi(this.b)}${e===1?")":`, ${e})`}`}function Tl(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Hi(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Bi(e){return e=Hi(e),(e<16?"0":"")+e.toString(16)}function hw(e,n,i,s){return s<=0?e=n=i=NaN:i<=0||i>=1?e=n=NaN:n<=0&&(e=NaN),new Xn(e,n,i,s)}function Qk(e){if(e instanceof Xn)return new Xn(e.h,e.s,e.l,e.opacity);if(e instanceof Jo||(e=Wo(e)),!e)return new Xn;if(e instanceof Xn)return e;e=e.rgb();var n=e.r/255,i=e.g/255,s=e.b/255,o=Math.min(n,i,s),l=Math.max(n,i,s),u=NaN,c=l-o,f=(l+o)/2;return c?(n===l?u=(i-s)/c+(i<s)*6:i===l?u=(s-n)/c+2:u=(n-i)/c+4,c/=f<.5?l+o:2-l-o,u*=60):c=f>0&&f<1?0:u,new Xn(u,c,f,e.opacity)}function d2(e,n,i,s){return arguments.length===1?Qk(e):new Xn(e,n,i,s??1)}function Xn(e,n,i,s){this.h=+e,this.s=+n,this.l=+i,this.opacity=+s}Kg(Xn,d2,Xk(Jo,{brighter(e){return e=e==null?Rl:Math.pow(Rl,e),new Xn(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ho:Math.pow(Ho,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,i=this.l,s=i+(i<.5?i:1-i)*n,o=2*i-s;return new dn(Yc(e>=240?e-240:e+120,o,s),Yc(e,o,s),Yc(e<120?e+240:e-120,o,s),this.opacity)},clamp(){return new Xn(pw(this.h),dl(this.s),dl(this.l),Tl(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=Tl(this.opacity);return`${e===1?"hsl(":"hsla("}${pw(this.h)}, ${dl(this.s)*100}%, ${dl(this.l)*100}%${e===1?")":`, ${e})`}`}}));function pw(e){return e=(e||0)%360,e<0?e+360:e}function dl(e){return Math.max(0,Math.min(1,e||0))}function Yc(e,n,i){return(e<60?n+(i-n)*e/60:e<180?i:e<240?n+(i-n)*(240-e)/60:n)*255}const Zk=e=>()=>e;function f2(e,n){return function(i){return e+i*n}}function h2(e,n,i){return e=Math.pow(e,i),n=Math.pow(n,i)-e,i=1/i,function(s){return Math.pow(e+s*n,i)}}function p2(e){return(e=+e)==1?Jk:function(n,i){return i-n?h2(n,i,e):Zk(isNaN(n)?i:n)}}function Jk(e,n){var i=n-e;return i?f2(e,i):Zk(isNaN(e)?n:e)}const mw=(function e(n){var i=p2(n);function s(o,l){var u=i((o=Ng(o)).r,(l=Ng(l)).r),c=i(o.g,l.g),f=i(o.b,l.b),h=Jk(o.opacity,l.opacity);return function(p){return o.r=u(p),o.g=c(p),o.b=f(p),o.opacity=h(p),o+""}}return s.gamma=e,s})(1);function li(e,n){return e=+e,n=+n,function(i){return e*(1-i)+n*i}}var Cg=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Kc=new RegExp(Cg.source,"g");function m2(e){return function(){return e}}function g2(e){return function(n){return e(n)+""}}function v2(e,n){var i=Cg.lastIndex=Kc.lastIndex=0,s,o,l,u=-1,c=[],f=[];for(e=e+"",n=n+"";(s=Cg.exec(e))&&(o=Kc.exec(n));)(l=o.index)>i&&(l=n.slice(i,l),c[u]?c[u]+=l:c[++u]=l),(s=s[0])===(o=o[0])?c[u]?c[u]+=o:c[++u]=o:(c[++u]=null,f.push({i:u,x:li(s,o)})),i=Kc.lastIndex;return i<n.length&&(l=n.slice(i),c[u]?c[u]+=l:c[++u]=l),c.length<2?f[0]?g2(f[0].x):m2(n):(n=f.length,function(h){for(var p=0,m;p<n;++p)c[(m=f[p]).i]=m.x(h);return c.join("")})}var gw=180/Math.PI,jg={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function eE(e,n,i,s,o,l){var u,c,f;return(u=Math.sqrt(e*e+n*n))&&(e/=u,n/=u),(f=e*i+n*s)&&(i-=e*f,s-=n*f),(c=Math.sqrt(i*i+s*s))&&(i/=c,s/=c,f/=c),e*s<n*i&&(e=-e,n=-n,f=-f,u=-u),{translateX:o,translateY:l,rotate:Math.atan2(n,e)*gw,skewX:Math.atan(f)*gw,scaleX:u,scaleY:c}}var fl;function y2(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?jg:eE(n.a,n.b,n.c,n.d,n.e,n.f)}function w2(e){return e==null||(fl||(fl=document.createElementNS("http://www.w3.org/2000/svg","g")),fl.setAttribute("transform",e),!(e=fl.transform.baseVal.consolidate()))?jg:(e=e.matrix,eE(e.a,e.b,e.c,e.d,e.e,e.f))}function tE(e,n,i,s){function o(h){return h.length?h.pop()+" ":""}function l(h,p,m,y,w,j){if(h!==m||p!==y){var _=w.push("translate(",null,n,null,i);j.push({i:_-4,x:li(h,m)},{i:_-2,x:li(p,y)})}else(m||y)&&w.push("translate("+m+n+y+i)}function u(h,p,m,y){h!==p?(h-p>180?p+=360:p-h>180&&(h+=360),y.push({i:m.push(o(m)+"rotate(",null,s)-2,x:li(h,p)})):p&&m.push(o(m)+"rotate("+p+s)}function c(h,p,m,y){h!==p?y.push({i:m.push(o(m)+"skewX(",null,s)-2,x:li(h,p)}):p&&m.push(o(m)+"skewX("+p+s)}function f(h,p,m,y,w,j){if(h!==m||p!==y){var _=w.push(o(w)+"scale(",null,",",null,")");j.push({i:_-4,x:li(h,m)},{i:_-2,x:li(p,y)})}else(m!==1||y!==1)&&w.push(o(w)+"scale("+m+","+y+")")}return function(h,p){var m=[],y=[];return h=e(h),p=e(p),l(h.translateX,h.translateY,p.translateX,p.translateY,m,y),u(h.rotate,p.rotate,m,y),c(h.skewX,p.skewX,m,y),f(h.scaleX,h.scaleY,p.scaleX,p.scaleY,m,y),h=p=null,function(w){for(var j=-1,_=y.length,S;++j<_;)m[(S=y[j]).i]=S.x(w);return m.join("")}}}var x2=tE(y2,"px, ","px)","deg)"),_2=tE(w2,", ",")",")"),S2=1e-12;function vw(e){return((e=Math.exp(e))+1/e)/2}function b2(e){return((e=Math.exp(e))-1/e)/2}function k2(e){return((e=Math.exp(2*e))-1)/(e+1)}const E2=(function e(n,i,s){function o(l,u){var c=l[0],f=l[1],h=l[2],p=u[0],m=u[1],y=u[2],w=p-c,j=m-f,_=w*w+j*j,S,b;if(_<S2)b=Math.log(y/h)/n,S=function(P){return[c+P*w,f+P*j,h*Math.exp(n*P*b)]};else{var E=Math.sqrt(_),N=(y*y-h*h+s*_)/(2*h*i*E),C=(y*y-h*h-s*_)/(2*y*i*E),I=Math.log(Math.sqrt(N*N+1)-N),O=Math.log(Math.sqrt(C*C+1)-C);b=(O-I)/n,S=function(P){var z=P*b,T=vw(I),q=h/(i*E)*(T*k2(n*z+I)-b2(I));return[c+q*w,f+q*j,h*T/vw(n*z+I)]}}return S.duration=b*1e3*n/Math.SQRT2,S}return o.rho=function(l){var u=Math.max(.001,+l),c=u*u,f=c*c;return e(u,c,f)},o})(Math.SQRT2,2,4);var zs=0,qo=0,Ao=0,nE=1e3,Al,Lo,Il=0,Gi=0,Bl=0,Go=typeof performance=="object"&&performance.now?performance:Date,rE=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Xg(){return Gi||(rE(N2),Gi=Go.now()+Bl)}function N2(){Gi=0}function Ml(){this._call=this._time=this._next=null}Ml.prototype=iE.prototype={constructor:Ml,restart:function(e,n,i){if(typeof e!="function")throw new TypeError("callback is not a function");i=(i==null?Xg():+i)+(n==null?0:+n),!this._next&&Lo!==this&&(Lo?Lo._next=this:Al=this,Lo=this),this._call=e,this._time=i,Rg()},stop:function(){this._call&&(this._call=null,this._time=1/0,Rg())}};function iE(e,n,i){var s=new Ml;return s.restart(e,n,i),s}function C2(){Xg(),++zs;for(var e=Al,n;e;)(n=Gi-e._time)>=0&&e._call.call(void 0,n),e=e._next;--zs}function yw(){Gi=(Il=Go.now())+Bl,zs=qo=0;try{C2()}finally{zs=0,R2(),Gi=0}}function j2(){var e=Go.now(),n=e-Il;n>nE&&(Bl-=n,Il=e)}function R2(){for(var e,n=Al,i,s=1/0;n;)n._call?(s>n._time&&(s=n._time),e=n,n=n._next):(i=n._next,n._next=null,n=e?e._next=i:Al=i);Lo=e,Rg(s)}function Rg(e){if(!zs){qo&&(qo=clearTimeout(qo));var n=e-Gi;n>24?(e<1/0&&(qo=setTimeout(yw,e-Go.now()-Bl)),Ao&&(Ao=clearInterval(Ao))):(Ao||(Il=Go.now(),Ao=setInterval(j2,nE)),zs=1,rE(yw))}}function ww(e,n,i){var s=new Ml;return n=n==null?0:+n,s.restart(o=>{s.stop(),e(o+n)},n,i),s}var T2=Fl("start","end","cancel","interrupt"),A2=[],sE=0,xw=1,Tg=2,El=3,_w=4,Ag=5,Nl=6;function Ul(e,n,i,s,o,l){var u=e.__transition;if(!u)e.__transition={};else if(i in u)return;I2(e,i,{name:n,index:s,group:o,on:T2,tween:A2,time:l.time,delay:l.delay,duration:l.duration,ease:l.ease,timer:null,state:sE})}function Qg(e,n){var i=Jn(e,n);if(i.state>sE)throw new Error("too late; already scheduled");return i}function cr(e,n){var i=Jn(e,n);if(i.state>El)throw new Error("too late; already running");return i}function Jn(e,n){var i=e.__transition;if(!i||!(i=i[n]))throw new Error("transition not found");return i}function I2(e,n,i){var s=e.__transition,o;s[n]=i,i.timer=iE(l,0,i.time);function l(h){i.state=xw,i.timer.restart(u,i.delay,i.time),i.delay<=h&&u(h-i.delay)}function u(h){var p,m,y,w;if(i.state!==xw)return f();for(p in s)if(w=s[p],w.name===i.name){if(w.state===El)return ww(u);w.state===_w?(w.state=Nl,w.timer.stop(),w.on.call("interrupt",e,e.__data__,w.index,w.group),delete s[p]):+p<n&&(w.state=Nl,w.timer.stop(),w.on.call("cancel",e,e.__data__,w.index,w.group),delete s[p])}if(ww(function(){i.state===El&&(i.state=_w,i.timer.restart(c,i.delay,i.time),c(h))}),i.state=Tg,i.on.call("start",e,e.__data__,i.index,i.group),i.state===Tg){for(i.state=El,o=new Array(y=i.tween.length),p=0,m=-1;p<y;++p)(w=i.tween[p].value.call(e,e.__data__,i.index,i.group))&&(o[++m]=w);o.length=m+1}}function c(h){for(var p=h<i.duration?i.ease.call(null,h/i.duration):(i.timer.restart(f),i.state=Ag,1),m=-1,y=o.length;++m<y;)o[m].call(e,p);i.state===Ag&&(i.on.call("end",e,e.__data__,i.index,i.group),f())}function f(){i.state=Nl,i.timer.stop(),delete s[n];for(var h in s)return;delete e.__transition}}function Cl(e,n){var i=e.__transition,s,o,l=!0,u;if(i){n=n==null?null:n+"";for(u in i){if((s=i[u]).name!==n){l=!1;continue}o=s.state>Tg&&s.state<Ag,s.state=Nl,s.timer.stop(),s.on.call(o?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete i[u]}l&&delete e.__transition}}function M2(e){return this.each(function(){Cl(this,e)})}function P2(e,n){var i,s;return function(){var o=cr(this,e),l=o.tween;if(l!==i){s=i=l;for(var u=0,c=s.length;u<c;++u)if(s[u].name===n){s=s.slice(),s.splice(u,1);break}}o.tween=s}}function O2(e,n,i){var s,o;if(typeof i!="function")throw new Error;return function(){var l=cr(this,e),u=l.tween;if(u!==s){o=(s=u).slice();for(var c={name:n,value:i},f=0,h=o.length;f<h;++f)if(o[f].name===n){o[f]=c;break}f===h&&o.push(c)}l.tween=o}}function q2(e,n){var i=this._id;if(e+="",arguments.length<2){for(var s=Jn(this.node(),i).tween,o=0,l=s.length,u;o<l;++o)if((u=s[o]).name===e)return u.value;return null}return this.each((n==null?P2:O2)(i,e,n))}function Zg(e,n,i){var s=e._id;return e.each(function(){var o=cr(this,s);(o.value||(o.value={}))[n]=i.apply(this,arguments)}),function(o){return Jn(o,s).value[n]}}function oE(e,n){var i;return(typeof n=="number"?li:n instanceof Wo?mw:(i=Wo(n))?(n=i,mw):v2)(e,n)}function L2(e){return function(){this.removeAttribute(e)}}function $2(e){return function(){this.removeAttributeNS(e.space,e.local)}}function D2(e,n,i){var s,o=i+"",l;return function(){var u=this.getAttribute(e);return u===o?null:u===s?l:l=n(s=u,i)}}function F2(e,n,i){var s,o=i+"",l;return function(){var u=this.getAttributeNS(e.space,e.local);return u===o?null:u===s?l:l=n(s=u,i)}}function z2(e,n,i){var s,o,l;return function(){var u,c=i(this),f;return c==null?void this.removeAttribute(e):(u=this.getAttribute(e),f=c+"",u===f?null:u===s&&f===o?l:(o=f,l=n(s=u,c)))}}function B2(e,n,i){var s,o,l;return function(){var u,c=i(this),f;return c==null?void this.removeAttributeNS(e.space,e.local):(u=this.getAttributeNS(e.space,e.local),f=c+"",u===f?null:u===s&&f===o?l:(o=f,l=n(s=u,c)))}}function U2(e,n){var i=zl(e),s=i==="transform"?_2:oE;return this.attrTween(e,typeof n=="function"?(i.local?B2:z2)(i,s,Zg(this,"attr."+e,n)):n==null?(i.local?$2:L2)(i):(i.local?F2:D2)(i,s,n))}function H2(e,n){return function(i){this.setAttribute(e,n.call(this,i))}}function V2(e,n){return function(i){this.setAttributeNS(e.space,e.local,n.call(this,i))}}function W2(e,n){var i,s;function o(){var l=n.apply(this,arguments);return l!==s&&(i=(s=l)&&V2(e,l)),i}return o._value=n,o}function G2(e,n){var i,s;function o(){var l=n.apply(this,arguments);return l!==s&&(i=(s=l)&&H2(e,l)),i}return o._value=n,o}function Y2(e,n){var i="attr."+e;if(arguments.length<2)return(i=this.tween(i))&&i._value;if(n==null)return this.tween(i,null);if(typeof n!="function")throw new Error;var s=zl(e);return this.tween(i,(s.local?W2:G2)(s,n))}function K2(e,n){return function(){Qg(this,e).delay=+n.apply(this,arguments)}}function X2(e,n){return n=+n,function(){Qg(this,e).delay=n}}function Q2(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?K2:X2)(n,e)):Jn(this.node(),n).delay}function Z2(e,n){return function(){cr(this,e).duration=+n.apply(this,arguments)}}function J2(e,n){return n=+n,function(){cr(this,e).duration=n}}function eA(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?Z2:J2)(n,e)):Jn(this.node(),n).duration}function tA(e,n){if(typeof n!="function")throw new Error;return function(){cr(this,e).ease=n}}function nA(e){var n=this._id;return arguments.length?this.each(tA(n,e)):Jn(this.node(),n).ease}function rA(e,n){return function(){var i=n.apply(this,arguments);if(typeof i!="function")throw new Error;cr(this,e).ease=i}}function iA(e){if(typeof e!="function")throw new Error;return this.each(rA(this._id,e))}function sA(e){typeof e!="function"&&(e=$k(e));for(var n=this._groups,i=n.length,s=new Array(i),o=0;o<i;++o)for(var l=n[o],u=l.length,c=s[o]=[],f,h=0;h<u;++h)(f=l[h])&&e.call(f,f.__data__,h,l)&&c.push(f);return new Tr(s,this._parents,this._name,this._id)}function oA(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,i=e._groups,s=n.length,o=i.length,l=Math.min(s,o),u=new Array(s),c=0;c<l;++c)for(var f=n[c],h=i[c],p=f.length,m=u[c]=new Array(p),y,w=0;w<p;++w)(y=f[w]||h[w])&&(m[w]=y);for(;c<s;++c)u[c]=n[c];return new Tr(u,this._parents,this._name,this._id)}function aA(e){return(e+"").trim().split(/^|\s+/).every(function(n){var i=n.indexOf(".");return i>=0&&(n=n.slice(0,i)),!n||n==="start"})}function lA(e,n,i){var s,o,l=aA(n)?Qg:cr;return function(){var u=l(this,e),c=u.on;c!==s&&(o=(s=c).copy()).on(n,i),u.on=o}}function uA(e,n){var i=this._id;return arguments.length<2?Jn(this.node(),i).on.on(e):this.each(lA(i,e,n))}function cA(e){return function(){var n=this.parentNode;for(var i in this.__transition)if(+i!==e)return;n&&n.removeChild(this)}}function dA(){return this.on("end.remove",cA(this._id))}function fA(e){var n=this._name,i=this._id;typeof e!="function"&&(e=Gg(e));for(var s=this._groups,o=s.length,l=new Array(o),u=0;u<o;++u)for(var c=s[u],f=c.length,h=l[u]=new Array(f),p,m,y=0;y<f;++y)(p=c[y])&&(m=e.call(p,p.__data__,y,c))&&("__data__"in p&&(m.__data__=p.__data__),h[y]=m,Ul(h[y],n,i,y,h,Jn(p,i)));return new Tr(l,this._parents,n,i)}function hA(e){var n=this._name,i=this._id;typeof e!="function"&&(e=Lk(e));for(var s=this._groups,o=s.length,l=[],u=[],c=0;c<o;++c)for(var f=s[c],h=f.length,p,m=0;m<h;++m)if(p=f[m]){for(var y=e.call(p,p.__data__,m,f),w,j=Jn(p,i),_=0,S=y.length;_<S;++_)(w=y[_])&&Ul(w,n,i,_,y,j);l.push(y),u.push(p)}return new Tr(l,u,n,i)}var pA=Zo.prototype.constructor;function mA(){return new pA(this._groups,this._parents)}function gA(e,n){var i,s,o;return function(){var l=Fs(this,e),u=(this.style.removeProperty(e),Fs(this,e));return l===u?null:l===i&&u===s?o:o=n(i=l,s=u)}}function aE(e){return function(){this.style.removeProperty(e)}}function vA(e,n,i){var s,o=i+"",l;return function(){var u=Fs(this,e);return u===o?null:u===s?l:l=n(s=u,i)}}function yA(e,n,i){var s,o,l;return function(){var u=Fs(this,e),c=i(this),f=c+"";return c==null&&(f=c=(this.style.removeProperty(e),Fs(this,e))),u===f?null:u===s&&f===o?l:(o=f,l=n(s=u,c))}}function wA(e,n){var i,s,o,l="style."+n,u="end."+l,c;return function(){var f=cr(this,e),h=f.on,p=f.value[l]==null?c||(c=aE(n)):void 0;(h!==i||o!==p)&&(s=(i=h).copy()).on(u,o=p),f.on=s}}function xA(e,n,i){var s=(e+="")=="transform"?x2:oE;return n==null?this.styleTween(e,gA(e,s)).on("end.style."+e,aE(e)):typeof n=="function"?this.styleTween(e,yA(e,s,Zg(this,"style."+e,n))).each(wA(this._id,e)):this.styleTween(e,vA(e,s,n),i).on("end.style."+e,null)}function _A(e,n,i){return function(s){this.style.setProperty(e,n.call(this,s),i)}}function SA(e,n,i){var s,o;function l(){var u=n.apply(this,arguments);return u!==o&&(s=(o=u)&&_A(e,u,i)),s}return l._value=n,l}function bA(e,n,i){var s="style."+(e+="");if(arguments.length<2)return(s=this.tween(s))&&s._value;if(n==null)return this.tween(s,null);if(typeof n!="function")throw new Error;return this.tween(s,SA(e,n,i??""))}function kA(e){return function(){this.textContent=e}}function EA(e){return function(){var n=e(this);this.textContent=n??""}}function NA(e){return this.tween("text",typeof e=="function"?EA(Zg(this,"text",e)):kA(e==null?"":e+""))}function CA(e){return function(n){this.textContent=e.call(this,n)}}function jA(e){var n,i;function s(){var o=e.apply(this,arguments);return o!==i&&(n=(i=o)&&CA(o)),n}return s._value=e,s}function RA(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,jA(e))}function TA(){for(var e=this._name,n=this._id,i=lE(),s=this._groups,o=s.length,l=0;l<o;++l)for(var u=s[l],c=u.length,f,h=0;h<c;++h)if(f=u[h]){var p=Jn(f,n);Ul(f,e,i,h,u,{time:p.time+p.delay+p.duration,delay:0,duration:p.duration,ease:p.ease})}return new Tr(s,this._parents,e,i)}function AA(){var e,n,i=this,s=i._id,o=i.size();return new Promise(function(l,u){var c={value:u},f={value:function(){--o===0&&l()}};i.each(function(){var h=cr(this,s),p=h.on;p!==e&&(n=(e=p).copy(),n._.cancel.push(c),n._.interrupt.push(c),n._.end.push(f)),h.on=n}),o===0&&l()})}var IA=0;function Tr(e,n,i,s){this._groups=e,this._parents=n,this._name=i,this._id=s}function lE(){return++IA}var Nr=Zo.prototype;Tr.prototype={constructor:Tr,select:fA,selectAll:hA,selectChild:Nr.selectChild,selectChildren:Nr.selectChildren,filter:sA,merge:oA,selection:mA,transition:TA,call:Nr.call,nodes:Nr.nodes,node:Nr.node,size:Nr.size,empty:Nr.empty,each:Nr.each,on:uA,attr:U2,attrTween:Y2,style:xA,styleTween:bA,text:NA,textTween:RA,remove:dA,tween:q2,delay:Q2,duration:eA,ease:nA,easeVarying:iA,end:AA,[Symbol.iterator]:Nr[Symbol.iterator]};function MA(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var PA={time:null,delay:0,duration:250,ease:MA};function OA(e,n){for(var i;!(i=e.__transition)||!(i=i[n]);)if(!(e=e.parentNode))throw new Error(`transition ${n} not found`);return i}function qA(e){var n,i;e instanceof Tr?(n=e._id,e=e._name):(n=lE(),(i=PA).time=Xg(),e=e==null?null:e+"");for(var s=this._groups,o=s.length,l=0;l<o;++l)for(var u=s[l],c=u.length,f,h=0;h<c;++h)(f=u[h])&&Ul(f,e,n,h,u,i||OA(f,n));return new Tr(s,this._parents,e,n)}Zo.prototype.interrupt=M2;Zo.prototype.transition=qA;const hl=e=>()=>e;function LA(e,{sourceEvent:n,target:i,transform:s,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:o}})}function jr(e,n,i){this.k=e,this.x=n,this.y=i}jr.prototype={constructor:jr,scale:function(e){return e===1?this:new jr(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new jr(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 Rr=new jr(1,0,0);jr.prototype;function Xc(e){e.stopImmediatePropagation()}function Io(e){e.preventDefault(),e.stopImmediatePropagation()}function $A(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function DA(){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 Sw(){return this.__zoom||Rr}function FA(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function zA(){return navigator.maxTouchPoints||"ontouchstart"in this}function BA(e,n,i){var s=e.invertX(n[0][0])-i[0][0],o=e.invertX(n[1][0])-i[1][0],l=e.invertY(n[0][1])-i[0][1],u=e.invertY(n[1][1])-i[1][1];return e.translate(o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o),u>l?(l+u)/2:Math.min(0,l)||Math.max(0,u))}function uE(){var e=$A,n=DA,i=BA,s=FA,o=zA,l=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],c=250,f=E2,h=Fl("start","zoom","end"),p,m,y,w=500,j=150,_=0,S=10;function b(A){A.property("__zoom",Sw).on("wheel.zoom",z,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",q).filter(o).on("touchstart.zoom",B).on("touchmove.zoom",Z).on("touchend.zoom touchcancel.zoom",Q).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}b.transform=function(A,H,U,ne){var Y=A.selection?A.selection():A;Y.property("__zoom",Sw),A!==Y?I(A,H,U,ne):Y.interrupt().each(function(){O(this,arguments).event(ne).start().zoom(null,typeof H=="function"?H.apply(this,arguments):H).end()})},b.scaleBy=function(A,H,U,ne){b.scaleTo(A,function(){var Y=this.__zoom.k,L=typeof H=="function"?H.apply(this,arguments):H;return Y*L},U,ne)},b.scaleTo=function(A,H,U,ne){b.transform(A,function(){var Y=n.apply(this,arguments),L=this.__zoom,G=U==null?C(Y):typeof U=="function"?U.apply(this,arguments):U,k=L.invert(G),$=typeof H=="function"?H.apply(this,arguments):H;return i(N(E(L,$),G,k),Y,u)},U,ne)},b.translateBy=function(A,H,U,ne){b.transform(A,function(){return i(this.__zoom.translate(typeof H=="function"?H.apply(this,arguments):H,typeof U=="function"?U.apply(this,arguments):U),n.apply(this,arguments),u)},null,ne)},b.translateTo=function(A,H,U,ne,Y){b.transform(A,function(){var L=n.apply(this,arguments),G=this.__zoom,k=ne==null?C(L):typeof ne=="function"?ne.apply(this,arguments):ne;return i(Rr.translate(k[0],k[1]).scale(G.k).translate(typeof H=="function"?-H.apply(this,arguments):-H,typeof U=="function"?-U.apply(this,arguments):-U),L,u)},ne,Y)};function E(A,H){return H=Math.max(l[0],Math.min(l[1],H)),H===A.k?A:new jr(H,A.x,A.y)}function N(A,H,U){var ne=H[0]-U[0]*A.k,Y=H[1]-U[1]*A.k;return ne===A.x&&Y===A.y?A:new jr(A.k,ne,Y)}function C(A){return[(+A[0][0]+ +A[1][0])/2,(+A[0][1]+ +A[1][1])/2]}function I(A,H,U,ne){A.on("start.zoom",function(){O(this,arguments).event(ne).start()}).on("interrupt.zoom end.zoom",function(){O(this,arguments).event(ne).end()}).tween("zoom",function(){var Y=this,L=arguments,G=O(Y,L).event(ne),k=n.apply(Y,L),$=U==null?C(k):typeof U=="function"?U.apply(Y,L):U,oe=Math.max(k[1][0]-k[0][0],k[1][1]-k[0][1]),D=Y.__zoom,X=typeof H=="function"?H.apply(Y,L):H,ee=f(D.invert($).concat(oe/D.k),X.invert($).concat(oe/X.k));return function(se){if(se===1)se=X;else{var ae=ee(se),pe=oe/ae[2];se=new jr(pe,$[0]-ae[0]*pe,$[1]-ae[1]*pe)}G.zoom(null,se)}})}function O(A,H,U){return!U&&A.__zooming||new P(A,H)}function P(A,H){this.that=A,this.args=H,this.active=0,this.sourceEvent=null,this.extent=n.apply(A,H),this.taps=0}P.prototype={event:function(A){return A&&(this.sourceEvent=A),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(A,H){return this.mouse&&A!=="mouse"&&(this.mouse[1]=H.invert(this.mouse[0])),this.touch0&&A!=="touch"&&(this.touch0[1]=H.invert(this.touch0[0])),this.touch1&&A!=="touch"&&(this.touch1[1]=H.invert(this.touch1[0])),this.that.__zoom=H,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(A){var H=Mn(this.that).datum();h.call(A,this.that,new LA(A,{sourceEvent:this.sourceEvent,target:b,transform:this.that.__zoom,dispatch:h}),H)}};function z(A,...H){if(!e.apply(this,arguments))return;var U=O(this,H).event(A),ne=this.__zoom,Y=Math.max(l[0],Math.min(l[1],ne.k*Math.pow(2,s.apply(this,arguments)))),L=Kn(A);if(U.wheel)(U.mouse[0][0]!==L[0]||U.mouse[0][1]!==L[1])&&(U.mouse[1]=ne.invert(U.mouse[0]=L)),clearTimeout(U.wheel);else{if(ne.k===Y)return;U.mouse=[L,ne.invert(L)],Cl(this),U.start()}Io(A),U.wheel=setTimeout(G,j),U.zoom("mouse",i(N(E(ne,Y),U.mouse[0],U.mouse[1]),U.extent,u));function G(){U.wheel=null,U.end()}}function T(A,...H){if(y||!e.apply(this,arguments))return;var U=A.currentTarget,ne=O(this,H,!0).event(A),Y=Mn(A.view).on("mousemove.zoom",$,!0).on("mouseup.zoom",oe,!0),L=Kn(A,U),G=A.clientX,k=A.clientY;Yk(A.view),Xc(A),ne.mouse=[L,this.__zoom.invert(L)],Cl(this),ne.start();function $(D){if(Io(D),!ne.moved){var X=D.clientX-G,ee=D.clientY-k;ne.moved=X*X+ee*ee>_}ne.event(D).zoom("mouse",i(N(ne.that.__zoom,ne.mouse[0]=Kn(D,U),ne.mouse[1]),ne.extent,u))}function oe(D){Y.on("mousemove.zoom mouseup.zoom",null),Kk(D.view,ne.moved),Io(D),ne.event(D).end()}}function q(A,...H){if(e.apply(this,arguments)){var U=this.__zoom,ne=Kn(A.changedTouches?A.changedTouches[0]:A,this),Y=U.invert(ne),L=U.k*(A.shiftKey?.5:2),G=i(N(E(U,L),ne,Y),n.apply(this,H),u);Io(A),c>0?Mn(this).transition().duration(c).call(I,G,ne,A):Mn(this).call(b.transform,G,ne,A)}}function B(A,...H){if(e.apply(this,arguments)){var U=A.touches,ne=U.length,Y=O(this,H,A.changedTouches.length===ne).event(A),L,G,k,$;for(Xc(A),G=0;G<ne;++G)k=U[G],$=Kn(k,this),$=[$,this.__zoom.invert($),k.identifier],Y.touch0?!Y.touch1&&Y.touch0[2]!==$[2]&&(Y.touch1=$,Y.taps=0):(Y.touch0=$,L=!0,Y.taps=1+!!p);p&&(p=clearTimeout(p)),L&&(Y.taps<2&&(m=$[0],p=setTimeout(function(){p=null},w)),Cl(this),Y.start())}}function Z(A,...H){if(this.__zooming){var U=O(this,H).event(A),ne=A.changedTouches,Y=ne.length,L,G,k,$;for(Io(A),L=0;L<Y;++L)G=ne[L],k=Kn(G,this),U.touch0&&U.touch0[2]===G.identifier?U.touch0[0]=k:U.touch1&&U.touch1[2]===G.identifier&&(U.touch1[0]=k);if(G=U.that.__zoom,U.touch1){var oe=U.touch0[0],D=U.touch0[1],X=U.touch1[0],ee=U.touch1[1],se=(se=X[0]-oe[0])*se+(se=X[1]-oe[1])*se,ae=(ae=ee[0]-D[0])*ae+(ae=ee[1]-D[1])*ae;G=E(G,Math.sqrt(se/ae)),k=[(oe[0]+X[0])/2,(oe[1]+X[1])/2],$=[(D[0]+ee[0])/2,(D[1]+ee[1])/2]}else if(U.touch0)k=U.touch0[0],$=U.touch0[1];else return;U.zoom("touch",i(N(G,k,$),U.extent,u))}}function Q(A,...H){if(this.__zooming){var U=O(this,H).event(A),ne=A.changedTouches,Y=ne.length,L,G;for(Xc(A),y&&clearTimeout(y),y=setTimeout(function(){y=null},w),L=0;L<Y;++L)G=ne[L],U.touch0&&U.touch0[2]===G.identifier?delete U.touch0:U.touch1&&U.touch1[2]===G.identifier&&delete U.touch1;if(U.touch1&&!U.touch0&&(U.touch0=U.touch1,delete U.touch1),U.touch0)U.touch0[1]=this.__zoom.invert(U.touch0[0]);else if(U.end(),U.taps===2&&(G=Kn(G,this),Math.hypot(m[0]-G[0],m[1]-G[1])<S)){var k=Mn(this).on("dblclick.zoom");k&&k.apply(this,arguments)}}}return b.wheelDelta=function(A){return arguments.length?(s=typeof A=="function"?A:hl(+A),b):s},b.filter=function(A){return arguments.length?(e=typeof A=="function"?A:hl(!!A),b):e},b.touchable=function(A){return arguments.length?(o=typeof A=="function"?A:hl(!!A),b):o},b.extent=function(A){return arguments.length?(n=typeof A=="function"?A:hl([[+A[0][0],+A[0][1]],[+A[1][0],+A[1][1]]]),b):n},b.scaleExtent=function(A){return arguments.length?(l[0]=+A[0],l[1]=+A[1],b):[l[0],l[1]]},b.translateExtent=function(A){return arguments.length?(u[0][0]=+A[0][0],u[1][0]=+A[1][0],u[0][1]=+A[0][1],u[1][1]=+A[1][1],b):[[u[0][0],u[0][1]],[u[1][0],u[1][1]]]},b.constrain=function(A){return arguments.length?(i=A,b):i},b.duration=function(A){return arguments.length?(c=+A,b):c},b.interpolate=function(A){return arguments.length?(f=A,b):f},b.on=function(){var A=h.on.apply(h,arguments);return A===h?b:A},b.clickDistance=function(A){return arguments.length?(_=(A=+A)*A,b):Math.sqrt(_)},b.tapDistance=function(A){return arguments.length?(S=+A,b):S},b}Pk();const Hl=M.createContext(null),UA=Hl.Provider,Ar={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.`},cE=Ar.error001();function Xe(e,n){const i=M.useContext(Hl);if(i===null)throw new Error(cE);return Ok(i,e,n)}const jt=()=>{const e=M.useContext(Hl);if(e===null)throw new Error(cE);return M.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},HA=e=>e.userSelectionActive?"none":"all";function Jg({position:e,children:n,className:i,style:s,...o}){const l=Xe(HA),u=`${e}`.split("-");return le.createElement("div",{className:Dt(["react-flow__panel",i,...u]),style:{...s,pointerEvents:l},...o},n)}function VA({proOptions:e,position:n="bottom-right"}){return e!=null&&e.hideAttribution?null:le.createElement(Jg,{position:n,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},le.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const WA=({x:e,y:n,label:i,labelStyle:s={},labelShowBg:o=!0,labelBgStyle:l={},labelBgPadding:u=[2,4],labelBgBorderRadius:c=2,children:f,className:h,...p})=>{const m=M.useRef(null),[y,w]=M.useState({x:0,y:0,width:0,height:0}),j=Dt(["react-flow__edge-textwrapper",h]);return M.useEffect(()=>{if(m.current){const _=m.current.getBBox();w({x:_.x,y:_.y,width:_.width,height:_.height})}},[i]),typeof i>"u"||!i?null:le.createElement("g",{transform:`translate(${e-y.width/2} ${n-y.height/2})`,className:j,visibility:y.width?"visible":"hidden",...p},o&&le.createElement("rect",{width:y.width+2*u[0],x:-u[0],y:-u[1],height:y.height+2*u[1],className:"react-flow__edge-textbg",style:l,rx:c,ry:c}),le.createElement("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:m,style:s},i),f)};var GA=M.memo(WA);const ev=e=>({width:e.offsetWidth,height:e.offsetHeight}),Bs=(e,n=0,i=1)=>Math.min(Math.max(e,n),i),tv=(e={x:0,y:0},n)=>({x:Bs(e.x,n[0][0],n[1][0]),y:Bs(e.y,n[0][1],n[1][1])}),bw=(e,n,i)=>e<n?Bs(Math.abs(e-n),1,50)/50:e>i?-Bs(Math.abs(e-i),1,50)/50:0,dE=(e,n)=>{const i=bw(e.x,35,n.width-35)*20,s=bw(e.y,35,n.height-35)*20;return[i,s]},fE=e=>{var n;return((n=e.getRootNode)==null?void 0:n.call(e))||(window==null?void 0:window.document)},hE=(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)}),Yo=({x:e,y:n,width:i,height:s})=>({x:e,y:n,x2:e+i,y2:n+s}),pE=({x:e,y:n,x2:i,y2:s})=>({x:e,y:n,width:i-e,height:s-n}),kw=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),YA=(e,n)=>pE(hE(Yo(e),Yo(n))),Ig=(e,n)=>{const i=Math.max(0,Math.min(e.x+e.width,n.x+n.width)-Math.max(e.x,n.x)),s=Math.max(0,Math.min(e.y+e.height,n.y+n.height)-Math.max(e.y,n.y));return Math.ceil(i*s)},KA=e=>Pn(e.width)&&Pn(e.height)&&Pn(e.x)&&Pn(e.y),Pn=e=>!isNaN(e)&&isFinite(e),pt=Symbol.for("internals"),mE=["Enter"," ","Escape"],XA=(e,n)=>{},QA=e=>"nativeEvent"in e;function Mg(e){var o,l;const n=QA(e)?e.nativeEvent:e,i=((l=(o=n.composedPath)==null?void 0:o.call(n))==null?void 0:l[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(i==null?void 0:i.nodeName)||(i==null?void 0:i.hasAttribute("contenteditable"))||!!(i!=null&&i.closest(".nokey"))}const gE=e=>"clientX"in e,di=(e,n)=>{var l,u;const i=gE(e),s=i?e.clientX:(l=e.touches)==null?void 0:l[0].clientX,o=i?e.clientY:(u=e.touches)==null?void 0:u[0].clientY;return{x:s-((n==null?void 0:n.left)??0),y:o-((n==null?void 0:n.top)??0)}},Pl=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},ea=({id:e,path:n,labelX:i,labelY:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:m,markerStart:y,interactionWidth:w=20})=>le.createElement(le.Fragment,null,le.createElement("path",{id:e,style:p,d:n,fill:"none",className:"react-flow__edge-path",markerEnd:m,markerStart:y}),w&&le.createElement("path",{d:n,fill:"none",strokeOpacity:0,strokeWidth:w,className:"react-flow__edge-interaction"}),o&&Pn(i)&&Pn(s)?le.createElement(GA,{x:i,y:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:h}):null);ea.displayName="BaseEdge";function Mo(e,n,i){return i===void 0?i:s=>{const o=n().edges.find(l=>l.id===e);o&&i(s,{...o})}}function vE({sourceX:e,sourceY:n,targetX:i,targetY:s}){const o=Math.abs(i-e)/2,l=i<e?i+o:i-o,u=Math.abs(s-n)/2,c=s<n?s+u:s-u;return[l,c,o,u]}function yE({sourceX:e,sourceY:n,targetX:i,targetY:s,sourceControlX:o,sourceControlY:l,targetControlX:u,targetControlY:c}){const f=e*.125+o*.375+u*.375+i*.125,h=n*.125+l*.375+c*.375+s*.125,p=Math.abs(f-e),m=Math.abs(h-n);return[f,h,p,m]}var Yi;(function(e){e.Strict="strict",e.Loose="loose"})(Yi||(Yi={}));var Ui;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ui||(Ui={}));var Ko;(function(e){e.Partial="partial",e.Full="full"})(Ko||(Ko={}));var ci;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ci||(ci={}));var Ol;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ol||(Ol={}));var Ce;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ce||(Ce={}));function Ew({pos:e,x1:n,y1:i,x2:s,y2:o}){return e===Ce.Left||e===Ce.Right?[.5*(n+s),i]:[n,.5*(i+o)]}function wE({sourceX:e,sourceY:n,sourcePosition:i=Ce.Bottom,targetX:s,targetY:o,targetPosition:l=Ce.Top}){const[u,c]=Ew({pos:i,x1:e,y1:n,x2:s,y2:o}),[f,h]=Ew({pos:l,x1:s,y1:o,x2:e,y2:n}),[p,m,y,w]=yE({sourceX:e,sourceY:n,targetX:s,targetY:o,sourceControlX:u,sourceControlY:c,targetControlX:f,targetControlY:h});return[`M${e},${n} C${u},${c} ${f},${h} ${s},${o}`,p,m,y,w]}const nv=M.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,sourcePosition:o=Ce.Bottom,targetPosition:l=Ce.Top,label:u,labelStyle:c,labelShowBg:f,labelBgStyle:h,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:w,markerStart:j,interactionWidth:_})=>{const[S,b,E]=wE({sourceX:e,sourceY:n,sourcePosition:o,targetX:i,targetY:s,targetPosition:l});return le.createElement(ea,{path:S,labelX:b,labelY:E,label:u,labelStyle:c,labelShowBg:f,labelBgStyle:h,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:w,markerStart:j,interactionWidth:_})});nv.displayName="SimpleBezierEdge";const Nw={[Ce.Left]:{x:-1,y:0},[Ce.Right]:{x:1,y:0},[Ce.Top]:{x:0,y:-1},[Ce.Bottom]:{x:0,y:1}},ZA=({source:e,sourcePosition:n=Ce.Bottom,target:i})=>n===Ce.Left||n===Ce.Right?e.x<i.x?{x:1,y:0}:{x:-1,y:0}:e.y<i.y?{x:0,y:1}:{x:0,y:-1},Cw=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function JA({source:e,sourcePosition:n=Ce.Bottom,target:i,targetPosition:s=Ce.Top,center:o,offset:l}){const u=Nw[n],c=Nw[s],f={x:e.x+u.x*l,y:e.y+u.y*l},h={x:i.x+c.x*l,y:i.y+c.y*l},p=ZA({source:f,sourcePosition:n,target:h}),m=p.x!==0?"x":"y",y=p[m];let w=[],j,_;const S={x:0,y:0},b={x:0,y:0},[E,N,C,I]=vE({sourceX:e.x,sourceY:e.y,targetX:i.x,targetY:i.y});if(u[m]*c[m]===-1){j=o.x??E,_=o.y??N;const P=[{x:j,y:f.y},{x:j,y:h.y}],z=[{x:f.x,y:_},{x:h.x,y:_}];u[m]===y?w=m==="x"?P:z:w=m==="x"?z:P}else{const P=[{x:f.x,y:h.y}],z=[{x:h.x,y:f.y}];if(m==="x"?w=u.x===y?z:P:w=u.y===y?P:z,n===s){const Q=Math.abs(e[m]-i[m]);if(Q<=l){const A=Math.min(l-1,l-Q);u[m]===y?S[m]=(f[m]>e[m]?-1:1)*A:b[m]=(h[m]>i[m]?-1:1)*A}}if(n!==s){const Q=m==="x"?"y":"x",A=u[m]===c[Q],H=f[Q]>h[Q],U=f[Q]<h[Q];(u[m]===1&&(!A&&H||A&&U)||u[m]!==1&&(!A&&U||A&&H))&&(w=m==="x"?P:z)}const T={x:f.x+S.x,y:f.y+S.y},q={x:h.x+b.x,y:h.y+b.y},B=Math.max(Math.abs(T.x-w[0].x),Math.abs(q.x-w[0].x)),Z=Math.max(Math.abs(T.y-w[0].y),Math.abs(q.y-w[0].y));B>=Z?(j=(T.x+q.x)/2,_=w[0].y):(j=w[0].x,_=(T.y+q.y)/2)}return[[e,{x:f.x+S.x,y:f.y+S.y},...w,{x:h.x+b.x,y:h.y+b.y},i],j,_,C,I]}function eI(e,n,i,s){const o=Math.min(Cw(e,n)/2,Cw(n,i)/2,s),{x:l,y:u}=n;if(e.x===l&&l===i.x||e.y===u&&u===i.y)return`L${l} ${u}`;if(e.y===u){const h=e.x<i.x?-1:1,p=e.y<i.y?1:-1;return`L ${l+o*h},${u}Q ${l},${u} ${l},${u+o*p}`}const c=e.x<i.x?1:-1,f=e.y<i.y?-1:1;return`L ${l},${u+o*f}Q ${l},${u} ${l+o*c},${u}`}function Pg({sourceX:e,sourceY:n,sourcePosition:i=Ce.Bottom,targetX:s,targetY:o,targetPosition:l=Ce.Top,borderRadius:u=5,centerX:c,centerY:f,offset:h=20}){const[p,m,y,w,j]=JA({source:{x:e,y:n},sourcePosition:i,target:{x:s,y:o},targetPosition:l,center:{x:c,y:f},offset:h});return[p.reduce((S,b,E)=>{let N="";return E>0&&E<p.length-1?N=eI(p[E-1],b,p[E+1],u):N=`${E===0?"M":"L"}${b.x} ${b.y}`,S+=N,S},""),m,y,w,j]}const Vl=M.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:h,style:p,sourcePosition:m=Ce.Bottom,targetPosition:y=Ce.Top,markerEnd:w,markerStart:j,pathOptions:_,interactionWidth:S})=>{const[b,E,N]=Pg({sourceX:e,sourceY:n,sourcePosition:m,targetX:i,targetY:s,targetPosition:y,borderRadius:_==null?void 0:_.borderRadius,offset:_==null?void 0:_.offset});return le.createElement(ea,{path:b,labelX:E,labelY:N,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:w,markerStart:j,interactionWidth:S})});Vl.displayName="SmoothStepEdge";const rv=M.memo(e=>{var n;return le.createElement(Vl,{...e,pathOptions:M.useMemo(()=>{var i;return{borderRadius:0,offset:(i=e.pathOptions)==null?void 0:i.offset}},[(n=e.pathOptions)==null?void 0:n.offset])})});rv.displayName="StepEdge";function tI({sourceX:e,sourceY:n,targetX:i,targetY:s}){const[o,l,u,c]=vE({sourceX:e,sourceY:n,targetX:i,targetY:s});return[`M ${e},${n}L ${i},${s}`,o,l,u,c]}const iv=M.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:m,markerStart:y,interactionWidth:w})=>{const[j,_,S]=tI({sourceX:e,sourceY:n,targetX:i,targetY:s});return le.createElement(ea,{path:j,labelX:_,labelY:S,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:m,markerStart:y,interactionWidth:w})});iv.displayName="StraightEdge";function pl(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function jw({pos:e,x1:n,y1:i,x2:s,y2:o,c:l}){switch(e){case Ce.Left:return[n-pl(n-s,l),i];case Ce.Right:return[n+pl(s-n,l),i];case Ce.Top:return[n,i-pl(i-o,l)];case Ce.Bottom:return[n,i+pl(o-i,l)]}}function xE({sourceX:e,sourceY:n,sourcePosition:i=Ce.Bottom,targetX:s,targetY:o,targetPosition:l=Ce.Top,curvature:u=.25}){const[c,f]=jw({pos:i,x1:e,y1:n,x2:s,y2:o,c:u}),[h,p]=jw({pos:l,x1:s,y1:o,x2:e,y2:n,c:u}),[m,y,w,j]=yE({sourceX:e,sourceY:n,targetX:s,targetY:o,sourceControlX:c,sourceControlY:f,targetControlX:h,targetControlY:p});return[`M${e},${n} C${c},${f} ${h},${p} ${s},${o}`,m,y,w,j]}const ql=M.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,sourcePosition:o=Ce.Bottom,targetPosition:l=Ce.Top,label:u,labelStyle:c,labelShowBg:f,labelBgStyle:h,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:w,markerStart:j,pathOptions:_,interactionWidth:S})=>{const[b,E,N]=xE({sourceX:e,sourceY:n,sourcePosition:o,targetX:i,targetY:s,targetPosition:l,curvature:_==null?void 0:_.curvature});return le.createElement(ea,{path:b,labelX:E,labelY:N,label:u,labelStyle:c,labelShowBg:f,labelBgStyle:h,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:w,markerStart:j,interactionWidth:S})});ql.displayName="BezierEdge";const sv=M.createContext(null),nI=sv.Provider;sv.Consumer;const rI=()=>M.useContext(sv),iI=e=>"id"in e&&"source"in e&&"target"in e,sI=({source:e,sourceHandle:n,target:i,targetHandle:s})=>`reactflow__edge-${e}${n||""}-${i}${s||""}`,Og=(e,n)=>typeof e>"u"?"":typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`,oI=(e,n)=>n.some(i=>i.source===e.source&&i.target===e.target&&(i.sourceHandle===e.sourceHandle||!i.sourceHandle&&!e.sourceHandle)&&(i.targetHandle===e.targetHandle||!i.targetHandle&&!e.targetHandle)),aI=(e,n)=>{if(!e.source||!e.target)return n;let i;return iI(e)?i={...e}:i={...e,id:sI(e)},oI(i,n)?n:n.concat(i)},qg=({x:e,y:n},[i,s,o],l,[u,c])=>{const f={x:(e-i)/o,y:(n-s)/o};return l?{x:u*Math.round(f.x/u),y:c*Math.round(f.y/c)}:f},_E=({x:e,y:n},[i,s,o])=>({x:e*o+i,y:n*o+s}),Vi=(e,n=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const i=(e.width??0)*n[0],s=(e.height??0)*n[1],o={x:e.position.x-i,y:e.position.y-s};return{...o,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-i,y:e.positionAbsolute.y-s}:o}},Wl=(e,n=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const i=e.reduce((s,o)=>{const{x:l,y:u}=Vi(o,n).positionAbsolute;return hE(s,Yo({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 pE(i)},SE=(e,n,[i,s,o]=[0,0,1],l=!1,u=!1,c=[0,0])=>{const f={x:(n.x-i)/o,y:(n.y-s)/o,width:n.width/o,height:n.height/o},h=[];return e.forEach(p=>{const{width:m,height:y,selectable:w=!0,hidden:j=!1}=p;if(u&&!w||j)return!1;const{positionAbsolute:_}=Vi(p,c),S={x:_.x,y:_.y,width:m||0,height:y||0},b=Ig(f,S),E=typeof m>"u"||typeof y>"u"||m===null||y===null,N=l&&b>0,C=(m||0)*(y||0);(E||N||b>=C||p.dragging)&&h.push(p)}),h},bE=(e,n)=>{const i=e.map(s=>s.id);return n.filter(s=>i.includes(s.source)||i.includes(s.target))},kE=(e,n,i,s,o,l=.1)=>{const u=n/(e.width*(1+l)),c=i/(e.height*(1+l)),f=Math.min(u,c),h=Bs(f,s,o),p=e.x+e.width/2,m=e.y+e.height/2,y=n/2-p*h,w=i/2-m*h;return{x:y,y:w,zoom:h}},zi=(e,n=0)=>e.transition().duration(n);function Rw(e,n,i,s){return(n[i]||[]).reduce((o,l)=>{var u,c;return`${e.id}-${l.id}-${i}`!==s&&o.push({id:l.id||null,type:i,nodeId:e.id,x:(((u=e.positionAbsolute)==null?void 0:u.x)??0)+l.x+l.width/2,y:(((c=e.positionAbsolute)==null?void 0:c.y)??0)+l.y+l.height/2}),o},[])}function lI(e,n,i,s,o,l){const{x:u,y:c}=di(e),h=n.elementsFromPoint(u,c).find(j=>j.classList.contains("react-flow__handle"));if(h){const j=h.getAttribute("data-nodeid");if(j){const _=ov(void 0,h),S=h.getAttribute("data-handleid"),b=l({nodeId:j,id:S,type:_});if(b){const E=o.find(N=>N.nodeId===j&&N.type===_&&N.id===S);return{handle:{id:S,type:_,nodeId:j,x:(E==null?void 0:E.x)||i.x,y:(E==null?void 0:E.y)||i.y},validHandleResult:b}}}}let p=[],m=1/0;if(o.forEach(j=>{const _=Math.sqrt((j.x-i.x)**2+(j.y-i.y)**2);if(_<=s){const S=l(j);_<=m&&(_<m?p=[{handle:j,validHandleResult:S}]:_===m&&p.push({handle:j,validHandleResult:S}),m=_)}}),!p.length)return{handle:null,validHandleResult:EE()};if(p.length===1)return p[0];const y=p.some(({validHandleResult:j})=>j.isValid),w=p.some(({handle:j})=>j.type==="target");return p.find(({handle:j,validHandleResult:_})=>w?j.type==="target":y?_.isValid:!0)||p[0]}const uI={source:null,target:null,sourceHandle:null,targetHandle:null},EE=()=>({handleDomNode:null,isValid:!1,connection:uI,endHandle:null});function NE(e,n,i,s,o,l,u){const c=o==="target",f=u.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),h={...EE(),handleDomNode:f};if(f){const p=ov(void 0,f),m=f.getAttribute("data-nodeid"),y=f.getAttribute("data-handleid"),w=f.classList.contains("connectable"),j=f.classList.contains("connectableend"),_={source:c?m:i,sourceHandle:c?y:s,target:c?i:m,targetHandle:c?s:y};h.connection=_,w&&j&&(n===Yi.Strict?c&&p==="source"||!c&&p==="target":m!==i||y!==s)&&(h.endHandle={nodeId:m,handleId:y,type:p},h.isValid=l(_))}return h}function cI({nodes:e,nodeId:n,handleId:i,handleType:s}){return e.reduce((o,l)=>{if(l[pt]){const{handleBounds:u}=l[pt];let c=[],f=[];u&&(c=Rw(l,u,"source",`${n}-${i}-${s}`),f=Rw(l,u,"target",`${n}-${i}-${s}`)),o.push(...c,...f)}return o},[])}function ov(e,n){return e||(n!=null&&n.classList.contains("target")?"target":n!=null&&n.classList.contains("source")?"source":null)}function Qc(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function dI(e,n){let i=null;return n?i="valid":e&&!n&&(i="invalid"),i}function CE({event:e,handleId:n,nodeId:i,onConnect:s,isTarget:o,getState:l,setState:u,isValidConnection:c,edgeUpdaterType:f,onReconnectEnd:h}){const p=fE(e.target),{connectionMode:m,domNode:y,autoPanOnConnect:w,connectionRadius:j,onConnectStart:_,panBy:S,getNodes:b,cancelConnection:E}=l();let N=0,C;const{x:I,y:O}=di(e),P=p==null?void 0:p.elementFromPoint(I,O),z=ov(f,P),T=y==null?void 0:y.getBoundingClientRect();if(!T||!z)return;let q,B=di(e,T),Z=!1,Q=null,A=!1,H=null;const U=cI({nodes:b(),nodeId:i,handleId:n,handleType:z}),ne=()=>{if(!w)return;const[G,k]=dE(B,T);S({x:G,y:k}),N=requestAnimationFrame(ne)};u({connectionPosition:B,connectionStatus:null,connectionNodeId:i,connectionHandleId:n,connectionHandleType:z,connectionStartHandle:{nodeId:i,handleId:n,type:z},connectionEndHandle:null}),_==null||_(e,{nodeId:i,handleId:n,handleType:z});function Y(G){const{transform:k}=l();B=di(G,T);const{handle:$,validHandleResult:oe}=lI(G,p,qg(B,k,!1,[1,1]),j,U,D=>NE(D,m,i,n,o?"target":"source",c,p));if(C=$,Z||(ne(),Z=!0),H=oe.handleDomNode,Q=oe.connection,A=oe.isValid,u({connectionPosition:C&&A?_E({x:C.x,y:C.y},k):B,connectionStatus:dI(!!C,A),connectionEndHandle:oe.endHandle}),!C&&!A&&!H)return Qc(q);Q.source!==Q.target&&H&&(Qc(q),q=H,H.classList.add("connecting","react-flow__handle-connecting"),H.classList.toggle("valid",A),H.classList.toggle("react-flow__handle-valid",A))}function L(G){var k,$;(C||H)&&Q&&A&&(s==null||s(Q)),($=(k=l()).onConnectEnd)==null||$.call(k,G),f&&(h==null||h(G)),Qc(q),E(),cancelAnimationFrame(N),Z=!1,A=!1,Q=null,H=null,p.removeEventListener("mousemove",Y),p.removeEventListener("mouseup",L),p.removeEventListener("touchmove",Y),p.removeEventListener("touchend",L)}p.addEventListener("mousemove",Y),p.addEventListener("mouseup",L),p.addEventListener("touchmove",Y),p.addEventListener("touchend",L)}const Tw=()=>!0,fI=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),hI=(e,n,i)=>s=>{const{connectionStartHandle:o,connectionEndHandle:l,connectionClickStartHandle:u}=s;return{connecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.handleId)===n&&(o==null?void 0:o.type)===i||(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.handleId)===n&&(l==null?void 0:l.type)===i,clickConnecting:(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.handleId)===n&&(u==null?void 0:u.type)===i}},jE=M.forwardRef(({type:e="source",position:n=Ce.Top,isValidConnection:i,isConnectable:s=!0,isConnectableStart:o=!0,isConnectableEnd:l=!0,id:u,onConnect:c,children:f,className:h,onMouseDown:p,onTouchStart:m,...y},w)=>{var T,q;const j=u||null,_=e==="target",S=jt(),b=rI(),{connectOnClick:E,noPanClassName:N}=Xe(fI,Ct),{connecting:C,clickConnecting:I}=Xe(hI(b,j,e),Ct);b||(q=(T=S.getState()).onError)==null||q.call(T,"010",Ar.error010());const O=B=>{const{defaultEdgeOptions:Z,onConnect:Q,hasDefaultEdges:A}=S.getState(),H={...Z,...B};if(A){const{edges:U,setEdges:ne}=S.getState();ne(aI(H,U))}Q==null||Q(H),c==null||c(H)},P=B=>{if(!b)return;const Z=gE(B);o&&(Z&&B.button===0||!Z)&&CE({event:B,handleId:j,nodeId:b,onConnect:O,isTarget:_,getState:S.getState,setState:S.setState,isValidConnection:i||S.getState().isValidConnection||Tw}),Z?p==null||p(B):m==null||m(B)},z=B=>{const{onClickConnectStart:Z,onClickConnectEnd:Q,connectionClickStartHandle:A,connectionMode:H,isValidConnection:U}=S.getState();if(!b||!A&&!o)return;if(!A){Z==null||Z(B,{nodeId:b,handleId:j,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:b,type:e,handleId:j}});return}const ne=fE(B.target),Y=i||U||Tw,{connection:L,isValid:G}=NE({nodeId:b,id:j,type:e},H,A.nodeId,A.handleId||null,A.type,Y,ne);G&&O(L),Q==null||Q(B),S.setState({connectionClickStartHandle:null})};return le.createElement("div",{"data-handleid":j,"data-nodeid":b,"data-handlepos":n,"data-id":`${b}-${j}-${e}`,className:Dt(["react-flow__handle",`react-flow__handle-${n}`,"nodrag",N,h,{source:!_,target:_,connectable:s,connectablestart:o,connectableend:l,connecting:I,connectionindicator:s&&(o&&!C||l&&C)}]),onMouseDown:P,onTouchStart:P,onClick:E?z:void 0,ref:w,...y},f)});jE.displayName="Handle";var Us=M.memo(jE);const RE=({data:e,isConnectable:n,targetPosition:i=Ce.Top,sourcePosition:s=Ce.Bottom})=>le.createElement(le.Fragment,null,le.createElement(Us,{type:"target",position:i,isConnectable:n}),e==null?void 0:e.label,le.createElement(Us,{type:"source",position:s,isConnectable:n}));RE.displayName="DefaultNode";var Lg=M.memo(RE);const TE=({data:e,isConnectable:n,sourcePosition:i=Ce.Bottom})=>le.createElement(le.Fragment,null,e==null?void 0:e.label,le.createElement(Us,{type:"source",position:i,isConnectable:n}));TE.displayName="InputNode";var AE=M.memo(TE);const IE=({data:e,isConnectable:n,targetPosition:i=Ce.Top})=>le.createElement(le.Fragment,null,le.createElement(Us,{type:"target",position:i,isConnectable:n}),e==null?void 0:e.label);IE.displayName="OutputNode";var ME=M.memo(IE);const av=()=>null;av.displayName="GroupNode";const pI=e=>({selectedNodes:e.getNodes().filter(n=>n.selected),selectedEdges:e.edges.filter(n=>n.selected).map(n=>({...n}))}),ml=e=>e.id;function mI(e,n){return Ct(e.selectedNodes.map(ml),n.selectedNodes.map(ml))&&Ct(e.selectedEdges.map(ml),n.selectedEdges.map(ml))}const PE=M.memo(({onSelectionChange:e})=>{const n=jt(),{selectedNodes:i,selectedEdges:s}=Xe(pI,mI);return M.useEffect(()=>{const o={nodes:i,edges:s};e==null||e(o),n.getState().onSelectionChange.forEach(l=>l(o))},[i,s,e]),null});PE.displayName="SelectionListener";const gI=e=>!!e.onSelectionChange;function vI({onSelectionChange:e}){const n=Xe(gI);return e||n?le.createElement(PE,{onSelectionChange:e}):null}const yI=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function Rs(e,n){M.useEffect(()=>{typeof e<"u"&&n(e)},[e])}function Le(e,n,i){M.useEffect(()=>{typeof n<"u"&&i({[e]:n})},[n])}const wI=({nodes:e,edges:n,defaultNodes:i,defaultEdges:s,onConnect:o,onConnectStart:l,onConnectEnd:u,onClickConnectStart:c,onClickConnectEnd:f,nodesDraggable:h,nodesConnectable:p,nodesFocusable:m,edgesFocusable:y,edgesUpdatable:w,elevateNodesOnSelect:j,minZoom:_,maxZoom:S,nodeExtent:b,onNodesChange:E,onEdgesChange:N,elementsSelectable:C,connectionMode:I,snapGrid:O,snapToGrid:P,translateExtent:z,connectOnClick:T,defaultEdgeOptions:q,fitView:B,fitViewOptions:Z,onNodesDelete:Q,onEdgesDelete:A,onNodeDrag:H,onNodeDragStart:U,onNodeDragStop:ne,onSelectionDrag:Y,onSelectionDragStart:L,onSelectionDragStop:G,noPanClassName:k,nodeOrigin:$,rfId:oe,autoPanOnConnect:D,autoPanOnNodeDrag:X,onError:ee,connectionRadius:se,isValidConnection:ae,nodeDragThreshold:pe})=>{const{setNodes:ge,setEdges:Ae,setDefaultNodesAndEdges:Oe,setMinZoom:Ie,setMaxZoom:Me,setTranslateExtent:ke,setNodeExtent:He,reset:ve}=Xe(yI,Ct),ye=jt();return M.useEffect(()=>{const Ve=s==null?void 0:s.map(ft=>({...ft,...q}));return Oe(i,Ve),()=>{ve()}},[]),Le("defaultEdgeOptions",q,ye.setState),Le("connectionMode",I,ye.setState),Le("onConnect",o,ye.setState),Le("onConnectStart",l,ye.setState),Le("onConnectEnd",u,ye.setState),Le("onClickConnectStart",c,ye.setState),Le("onClickConnectEnd",f,ye.setState),Le("nodesDraggable",h,ye.setState),Le("nodesConnectable",p,ye.setState),Le("nodesFocusable",m,ye.setState),Le("edgesFocusable",y,ye.setState),Le("edgesUpdatable",w,ye.setState),Le("elementsSelectable",C,ye.setState),Le("elevateNodesOnSelect",j,ye.setState),Le("snapToGrid",P,ye.setState),Le("snapGrid",O,ye.setState),Le("onNodesChange",E,ye.setState),Le("onEdgesChange",N,ye.setState),Le("connectOnClick",T,ye.setState),Le("fitViewOnInit",B,ye.setState),Le("fitViewOnInitOptions",Z,ye.setState),Le("onNodesDelete",Q,ye.setState),Le("onEdgesDelete",A,ye.setState),Le("onNodeDrag",H,ye.setState),Le("onNodeDragStart",U,ye.setState),Le("onNodeDragStop",ne,ye.setState),Le("onSelectionDrag",Y,ye.setState),Le("onSelectionDragStart",L,ye.setState),Le("onSelectionDragStop",G,ye.setState),Le("noPanClassName",k,ye.setState),Le("nodeOrigin",$,ye.setState),Le("rfId",oe,ye.setState),Le("autoPanOnConnect",D,ye.setState),Le("autoPanOnNodeDrag",X,ye.setState),Le("onError",ee,ye.setState),Le("connectionRadius",se,ye.setState),Le("isValidConnection",ae,ye.setState),Le("nodeDragThreshold",pe,ye.setState),Rs(e,ge),Rs(n,Ae),Rs(_,Ie),Rs(S,Me),Rs(z,ke),Rs(b,He),null},Aw={display:"none"},xI={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},OE="react-flow__node-desc",qE="react-flow__edge-desc",_I="react-flow__aria-live",SI=e=>e.ariaLiveMessage;function bI({rfId:e}){const n=Xe(SI);return le.createElement("div",{id:`${_I}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:xI},n)}function kI({rfId:e,disableKeyboardA11y:n}){return le.createElement(le.Fragment,null,le.createElement("div",{id:`${OE}-${e}`,style:Aw},"Press enter or space to select a node.",!n&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),le.createElement("div",{id:`${qE}-${e}`,style:Aw},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!n&&le.createElement(bI,{rfId:e}))}var Xo=(e=null,n={actInsideInputWithModifier:!0})=>{const[i,s]=M.useState(!1),o=M.useRef(!1),l=M.useRef(new Set([])),[u,c]=M.useMemo(()=>{if(e!==null){const h=(Array.isArray(e)?e:[e]).filter(m=>typeof m=="string").map(m=>m.split("+")),p=h.reduce((m,y)=>m.concat(...y),[]);return[h,p]}return[[],[]]},[e]);return M.useEffect(()=>{const f=typeof document<"u"?document:null,h=(n==null?void 0:n.target)||f;if(e!==null){const p=w=>{if(o.current=w.ctrlKey||w.metaKey||w.shiftKey,(!o.current||o.current&&!n.actInsideInputWithModifier)&&Mg(w))return!1;const _=Mw(w.code,c);l.current.add(w[_]),Iw(u,l.current,!1)&&(w.preventDefault(),s(!0))},m=w=>{if((!o.current||o.current&&!n.actInsideInputWithModifier)&&Mg(w))return!1;const _=Mw(w.code,c);Iw(u,l.current,!0)?(s(!1),l.current.clear()):l.current.delete(w[_]),w.key==="Meta"&&l.current.clear(),o.current=!1},y=()=>{l.current.clear(),s(!1)};return h==null||h.addEventListener("keydown",p),h==null||h.addEventListener("keyup",m),window.addEventListener("blur",y),()=>{h==null||h.removeEventListener("keydown",p),h==null||h.removeEventListener("keyup",m),window.removeEventListener("blur",y)}}},[e,s]),i};function Iw(e,n,i){return e.filter(s=>i||s.length===n.size).some(s=>s.every(o=>n.has(o)))}function Mw(e,n){return n.includes(e)?"code":"key"}function LE(e,n,i,s){var c,f;const o=e.parentNode||e.parentId;if(!o)return i;const l=n.get(o),u=Vi(l,s);return LE(l,n,{x:(i.x??0)+u.x,y:(i.y??0)+u.y,z:(((c=l[pt])==null?void 0:c.z)??0)>(i.z??0)?((f=l[pt])==null?void 0:f.z)??0:i.z??0},s)}function $E(e,n,i){e.forEach(s=>{var l;const o=s.parentNode||s.parentId;if(o&&!e.has(o))throw new Error(`Parent node ${o} not found`);if(o||i!=null&&i[s.id]){const{x:u,y:c,z:f}=LE(s,e,{...s.position,z:((l=s[pt])==null?void 0:l.z)??0},n);s.positionAbsolute={x:u,y:c},s[pt].z=f,i!=null&&i[s.id]&&(s[pt].isParent=!0)}})}function Zc(e,n,i,s){const o=new Map,l={},u=s?1e3:0;return e.forEach(c=>{var w;const f=(Pn(c.zIndex)?c.zIndex:0)+(c.selected?u:0),h=n.get(c.id),p={...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(p,pt,{enumerable:!1,value:{handleBounds:y||(w=h==null?void 0:h[pt])==null?void 0:w.handleBounds,z:f}}),o.set(c.id,p)}),$E(o,i,l),o}function DE(e,n={}){const{getNodes:i,width:s,height:o,minZoom:l,maxZoom:u,d3Zoom:c,d3Selection:f,fitViewOnInitDone:h,fitViewOnInit:p,nodeOrigin:m}=e(),y=n.initial&&!h&&p;if(c&&f&&(y||!n.initial)){const j=i().filter(S=>{var E;const b=n.includeHiddenNodes?S.width&&S.height:!S.hidden;return(E=n.nodes)!=null&&E.length?b&&n.nodes.some(N=>N.id===S.id):b}),_=j.every(S=>S.width&&S.height);if(j.length>0&&_){const S=Wl(j,m),{x:b,y:E,zoom:N}=kE(S,s,o,n.minZoom??l,n.maxZoom??u,n.padding??.1),C=Rr.translate(b,E).scale(N);return typeof n.duration=="number"&&n.duration>0?c.transform(zi(f,n.duration),C):c.transform(f,C),!0}}return!1}function EI(e,n){return e.forEach(i=>{const s=n.get(i.id);s&&n.set(s.id,{...s,[pt]:s[pt],selected:i.selected})}),new Map(n)}function NI(e,n){return n.map(i=>{const s=e.find(o=>o.id===i.id);return s&&(i.selected=s.selected),i})}function gl({changedNodes:e,changedEdges:n,get:i,set:s}){const{nodeInternals:o,edges:l,onNodesChange:u,onEdgesChange:c,hasDefaultNodes:f,hasDefaultEdges:h}=i();e!=null&&e.length&&(f&&s({nodeInternals:EI(e,o)}),u==null||u(e)),n!=null&&n.length&&(h&&s({edges:NI(n,l)}),c==null||c(n))}const Ts=()=>{},CI={zoomIn:Ts,zoomOut:Ts,zoomTo:Ts,getZoom:()=>1,setViewport:Ts,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Ts,fitBounds:Ts,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},jI=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),RI=()=>{const e=jt(),{d3Zoom:n,d3Selection:i}=Xe(jI,Ct);return M.useMemo(()=>i&&n?{zoomIn:o=>n.scaleBy(zi(i,o==null?void 0:o.duration),1.2),zoomOut:o=>n.scaleBy(zi(i,o==null?void 0:o.duration),1/1.2),zoomTo:(o,l)=>n.scaleTo(zi(i,l==null?void 0:l.duration),o),getZoom:()=>e.getState().transform[2],setViewport:(o,l)=>{const[u,c,f]=e.getState().transform,h=Rr.translate(o.x??u,o.y??c).scale(o.zoom??f);n.transform(zi(i,l==null?void 0:l.duration),h)},getViewport:()=>{const[o,l,u]=e.getState().transform;return{x:o,y:l,zoom:u}},fitView:o=>DE(e.getState,o),setCenter:(o,l,u)=>{const{width:c,height:f,maxZoom:h}=e.getState(),p=typeof(u==null?void 0:u.zoom)<"u"?u.zoom:h,m=c/2-o*p,y=f/2-l*p,w=Rr.translate(m,y).scale(p);n.transform(zi(i,u==null?void 0:u.duration),w)},fitBounds:(o,l)=>{const{width:u,height:c,minZoom:f,maxZoom:h}=e.getState(),{x:p,y:m,zoom:y}=kE(o,u,c,f,h,(l==null?void 0:l.padding)??.1),w=Rr.translate(p,m).scale(y);n.transform(zi(i,l==null?void 0:l.duration),w)},project:o=>{const{transform:l,snapToGrid:u,snapGrid:c}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),qg(o,l,u,c)},screenToFlowPosition:o=>{const{transform:l,snapToGrid:u,snapGrid:c,domNode:f}=e.getState();if(!f)return o;const{x:h,y:p}=f.getBoundingClientRect(),m={x:o.x-h,y:o.y-p};return qg(m,l,u,c)},flowToScreenPosition:o=>{const{transform:l,domNode:u}=e.getState();if(!u)return o;const{x:c,y:f}=u.getBoundingClientRect(),h=_E(o,l);return{x:h.x+c,y:h.y+f}},viewportInitialized:!0}:CI,[n,i])};function ta(){const e=RI(),n=jt(),i=M.useCallback(()=>n.getState().getNodes().map(_=>({..._})),[]),s=M.useCallback(_=>n.getState().nodeInternals.get(_),[]),o=M.useCallback(()=>{const{edges:_=[]}=n.getState();return _.map(S=>({...S}))},[]),l=M.useCallback(_=>{const{edges:S=[]}=n.getState();return S.find(b=>b.id===_)},[]),u=M.useCallback(_=>{const{getNodes:S,setNodes:b,hasDefaultNodes:E,onNodesChange:N}=n.getState(),C=S(),I=typeof _=="function"?_(C):_;if(E)b(I);else if(N){const O=I.length===0?C.map(P=>({type:"remove",id:P.id})):I.map(P=>({item:P,type:"reset"}));N(O)}},[]),c=M.useCallback(_=>{const{edges:S=[],setEdges:b,hasDefaultEdges:E,onEdgesChange:N}=n.getState(),C=typeof _=="function"?_(S):_;if(E)b(C);else if(N){const I=C.length===0?S.map(O=>({type:"remove",id:O.id})):C.map(O=>({item:O,type:"reset"}));N(I)}},[]),f=M.useCallback(_=>{const S=Array.isArray(_)?_:[_],{getNodes:b,setNodes:E,hasDefaultNodes:N,onNodesChange:C}=n.getState();if(N){const O=[...b(),...S];E(O)}else if(C){const I=S.map(O=>({item:O,type:"add"}));C(I)}},[]),h=M.useCallback(_=>{const S=Array.isArray(_)?_:[_],{edges:b=[],setEdges:E,hasDefaultEdges:N,onEdgesChange:C}=n.getState();if(N)E([...b,...S]);else if(C){const I=S.map(O=>({item:O,type:"add"}));C(I)}},[]),p=M.useCallback(()=>{const{getNodes:_,edges:S=[],transform:b}=n.getState(),[E,N,C]=b;return{nodes:_().map(I=>({...I})),edges:S.map(I=>({...I})),viewport:{x:E,y:N,zoom:C}}},[]),m=M.useCallback(({nodes:_,edges:S})=>{const{nodeInternals:b,getNodes:E,edges:N,hasDefaultNodes:C,hasDefaultEdges:I,onNodesDelete:O,onEdgesDelete:P,onNodesChange:z,onEdgesChange:T}=n.getState(),q=(_||[]).map(H=>H.id),B=(S||[]).map(H=>H.id),Z=E().reduce((H,U)=>{const ne=U.parentNode||U.parentId,Y=!q.includes(U.id)&&ne&&H.find(G=>G.id===ne);return(typeof U.deletable=="boolean"?U.deletable:!0)&&(q.includes(U.id)||Y)&&H.push(U),H},[]),Q=N.filter(H=>typeof H.deletable=="boolean"?H.deletable:!0),A=Q.filter(H=>B.includes(H.id));if(Z||A){const H=bE(Z,Q),U=[...A,...H],ne=U.reduce((Y,L)=>(Y.includes(L.id)||Y.push(L.id),Y),[]);if((I||C)&&(I&&n.setState({edges:N.filter(Y=>!ne.includes(Y.id))}),C&&(Z.forEach(Y=>{b.delete(Y.id)}),n.setState({nodeInternals:new Map(b)}))),ne.length>0&&(P==null||P(U),T&&T(ne.map(Y=>({id:Y,type:"remove"})))),Z.length>0&&(O==null||O(Z),z)){const Y=Z.map(L=>({id:L.id,type:"remove"}));z(Y)}}},[]),y=M.useCallback(_=>{const S=KA(_),b=S?null:n.getState().nodeInternals.get(_.id);return!S&&!b?[null,null,S]:[S?_:kw(b),b,S]},[]),w=M.useCallback((_,S=!0,b)=>{const[E,N,C]=y(_);return E?(b||n.getState().getNodes()).filter(I=>{if(!C&&(I.id===N.id||!I.positionAbsolute))return!1;const O=kw(I),P=Ig(O,E);return S&&P>0||P>=E.width*E.height}):[]},[]),j=M.useCallback((_,S,b=!0)=>{const[E]=y(_);if(!E)return!1;const N=Ig(E,S);return b&&N>0||N>=E.width*E.height},[]);return M.useMemo(()=>({...e,getNodes:i,getNode:s,getEdges:o,getEdge:l,setNodes:u,setEdges:c,addNodes:f,addEdges:h,toObject:p,deleteElements:m,getIntersectingNodes:w,isNodeIntersecting:j}),[e,i,s,o,l,u,c,f,h,p,m,w,j])}const TI={actInsideInputWithModifier:!1};var AI=({deleteKeyCode:e,multiSelectionKeyCode:n})=>{const i=jt(),{deleteElements:s}=ta(),o=Xo(e,TI),l=Xo(n);M.useEffect(()=>{if(o){const{edges:u,getNodes:c}=i.getState(),f=c().filter(p=>p.selected),h=u.filter(p=>p.selected);s({nodes:f,edges:h}),i.setState({nodesSelectionActive:!1})}},[o]),M.useEffect(()=>{i.setState({multiSelectionActive:l})},[l])};function II(e){const n=jt();M.useEffect(()=>{let i;const s=()=>{var l,u;if(!e.current)return;const o=ev(e.current);(o.height===0||o.width===0)&&((u=(l=n.getState()).onError)==null||u.call(l,"004",Ar.error004())),n.setState({width:o.width||500,height:o.height||500})};return s(),window.addEventListener("resize",s),e.current&&(i=new ResizeObserver(()=>s()),i.observe(e.current)),()=>{window.removeEventListener("resize",s),i&&e.current&&i.unobserve(e.current)}},[])}const lv={position:"absolute",width:"100%",height:"100%",top:0,left:0},MI=(e,n)=>e.x!==n.x||e.y!==n.y||e.zoom!==n.k,vl=e=>({x:e.x,y:e.y,zoom:e.k}),As=(e,n)=>e.target.closest(`.${n}`),Pw=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),Ow=e=>{const n=e.ctrlKey&&Pl()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n},PI=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),OI=({onMove:e,onMoveStart:n,onMoveEnd:i,onPaneContextMenu:s,zoomOnScroll:o=!0,zoomOnPinch:l=!0,panOnScroll:u=!1,panOnScrollSpeed:c=.5,panOnScrollMode:f=Ui.Free,zoomOnDoubleClick:h=!0,elementsSelectable:p,panOnDrag:m=!0,defaultViewport:y,translateExtent:w,minZoom:j,maxZoom:_,zoomActivationKeyCode:S,preventScrolling:b=!0,children:E,noWheelClassName:N,noPanClassName:C})=>{const I=M.useRef(),O=jt(),P=M.useRef(!1),z=M.useRef(!1),T=M.useRef(null),q=M.useRef({x:0,y:0,zoom:0}),{d3Zoom:B,d3Selection:Z,d3ZoomHandler:Q,userSelectionActive:A}=Xe(PI,Ct),H=Xo(S),U=M.useRef(0),ne=M.useRef(!1),Y=M.useRef();return II(T),M.useEffect(()=>{if(T.current){const L=T.current.getBoundingClientRect(),G=uE().scaleExtent([j,_]).translateExtent(w),k=Mn(T.current).call(G),$=Rr.translate(y.x,y.y).scale(Bs(y.zoom,j,_)),oe=[[0,0],[L.width,L.height]],D=G.constrain()($,oe,w);G.transform(k,D),G.wheelDelta(Ow),O.setState({d3Zoom:G,d3Selection:k,d3ZoomHandler:k.on("wheel.zoom"),transform:[D.x,D.y,D.k],domNode:T.current.closest(".react-flow")})}},[]),M.useEffect(()=>{Z&&B&&(u&&!H&&!A?Z.on("wheel.zoom",L=>{if(As(L,N))return!1;L.preventDefault(),L.stopImmediatePropagation();const G=Z.property("__zoom").k||1;if(L.ctrlKey&&l){const ae=Kn(L),pe=Ow(L),ge=G*Math.pow(2,pe);B.scaleTo(Z,ge,ae,L);return}const k=L.deltaMode===1?20:1;let $=f===Ui.Vertical?0:L.deltaX*k,oe=f===Ui.Horizontal?0:L.deltaY*k;!Pl()&&L.shiftKey&&f!==Ui.Vertical&&($=L.deltaY*k,oe=0),B.translateBy(Z,-($/G)*c,-(oe/G)*c,{internal:!0});const D=vl(Z.property("__zoom")),{onViewportChangeStart:X,onViewportChange:ee,onViewportChangeEnd:se}=O.getState();clearTimeout(Y.current),ne.current||(ne.current=!0,n==null||n(L,D),X==null||X(D)),ne.current&&(e==null||e(L,D),ee==null||ee(D),Y.current=setTimeout(()=>{i==null||i(L,D),se==null||se(D),ne.current=!1},150))},{passive:!1}):typeof Q<"u"&&Z.on("wheel.zoom",function(L,G){if(!b&&L.type==="wheel"&&!L.ctrlKey||As(L,N))return null;L.preventDefault(),Q.call(this,L,G)},{passive:!1}))},[A,u,f,Z,B,Q,H,l,b,N,n,e,i]),M.useEffect(()=>{B&&B.on("start",L=>{var $,oe;if(!L.sourceEvent||L.sourceEvent.internal)return null;U.current=($=L.sourceEvent)==null?void 0:$.button;const{onViewportChangeStart:G}=O.getState(),k=vl(L.transform);P.current=!0,q.current=k,((oe=L.sourceEvent)==null?void 0:oe.type)==="mousedown"&&O.setState({paneDragging:!0}),G==null||G(k),n==null||n(L.sourceEvent,k)})},[B,n]),M.useEffect(()=>{B&&(A&&!P.current?B.on("zoom",null):A||B.on("zoom",L=>{var k;const{onViewportChange:G}=O.getState();if(O.setState({transform:[L.transform.x,L.transform.y,L.transform.k]}),z.current=!!(s&&Pw(m,U.current??0)),(e||G)&&!((k=L.sourceEvent)!=null&&k.internal)){const $=vl(L.transform);G==null||G($),e==null||e(L.sourceEvent,$)}}))},[A,B,e,m,s]),M.useEffect(()=>{B&&B.on("end",L=>{if(!L.sourceEvent||L.sourceEvent.internal)return null;const{onViewportChangeEnd:G}=O.getState();if(P.current=!1,O.setState({paneDragging:!1}),s&&Pw(m,U.current??0)&&!z.current&&s(L.sourceEvent),z.current=!1,(i||G)&&MI(q.current,L.transform)){const k=vl(L.transform);q.current=k,clearTimeout(I.current),I.current=setTimeout(()=>{G==null||G(k),i==null||i(L.sourceEvent,k)},u?150:0)}})},[B,u,m,i,s]),M.useEffect(()=>{B&&B.filter(L=>{const G=H||o,k=l&&L.ctrlKey;if((m===!0||Array.isArray(m)&&m.includes(1))&&L.button===1&&L.type==="mousedown"&&(As(L,"react-flow__node")||As(L,"react-flow__edge")))return!0;if(!m&&!G&&!u&&!h&&!l||A||!h&&L.type==="dblclick"||As(L,N)&&L.type==="wheel"||As(L,C)&&(L.type!=="wheel"||u&&L.type==="wheel"&&!H)||!l&&L.ctrlKey&&L.type==="wheel"||!G&&!u&&!k&&L.type==="wheel"||!m&&(L.type==="mousedown"||L.type==="touchstart")||Array.isArray(m)&&!m.includes(L.button)&&L.type==="mousedown")return!1;const $=Array.isArray(m)&&m.includes(L.button)||!L.button||L.button<=1;return(!L.ctrlKey||L.type==="wheel")&&$})},[A,B,o,l,u,h,m,p,H]),le.createElement("div",{className:"react-flow__renderer",ref:T,style:lv},E)},qI=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function LI(){const{userSelectionActive:e,userSelectionRect:n}=Xe(qI,Ct);return e&&n?le.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:n.width,height:n.height,transform:`translate(${n.x}px, ${n.y}px)`}}):null}function qw(e,n){const i=n.parentNode||n.parentId,s=e.find(o=>o.id===i);if(s){const o=n.position.x+n.width-s.width,l=n.position.y+n.height-s.height;if(o>0||l>0||n.position.x<0||n.position.y<0){if(s.style={...s.style},s.style.width=s.style.width??s.width,s.style.height=s.style.height??s.height,o>0&&(s.style.width+=o),l>0&&(s.style.height+=l),n.position.x<0){const u=Math.abs(n.position.x);s.position.x=s.position.x-u,s.style.width+=u,n.position.x=0}if(n.position.y<0){const u=Math.abs(n.position.y);s.position.y=s.position.y-u,s.style.height+=u,n.position.y=0}s.width=s.style.width,s.height=s.style.height}}}function $I(e,n){if(e.some(s=>s.type==="reset"))return e.filter(s=>s.type==="reset").map(s=>s.item);const i=e.filter(s=>s.type==="add").map(s=>s.item);return n.reduce((s,o)=>{const l=e.filter(c=>c.id===o.id);if(l.length===0)return s.push(o),s;const u={...o};for(const c of l)if(c)switch(c.type){case"select":{u.selected=c.selected;break}case"position":{typeof c.position<"u"&&(u.position=c.position),typeof c.positionAbsolute<"u"&&(u.positionAbsolute=c.positionAbsolute),typeof c.dragging<"u"&&(u.dragging=c.dragging),u.expandParent&&qw(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&&qw(s,u);break}case"remove":return s}return s.push(u),s},i)}function DI(e,n){return $I(e,n)}const ui=(e,n)=>({id:e,type:"select",selected:n});function Ps(e,n){return e.reduce((i,s)=>{const o=n.includes(s.id);return!s.selected&&o?(s.selected=!0,i.push(ui(s.id,!0))):s.selected&&!o&&(s.selected=!1,i.push(ui(s.id,!1))),i},[])}const Jc=(e,n)=>i=>{i.target===n.current&&(e==null||e(i))},FI=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),FE=M.memo(({isSelecting:e,selectionMode:n=Ko.Full,panOnDrag:i,onSelectionStart:s,onSelectionEnd:o,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:c,onPaneMouseEnter:f,onPaneMouseMove:h,onPaneMouseLeave:p,children:m})=>{const y=M.useRef(null),w=jt(),j=M.useRef(0),_=M.useRef(0),S=M.useRef(),{userSelectionActive:b,elementsSelectable:E,dragging:N}=Xe(FI,Ct),C=()=>{w.setState({userSelectionActive:!1,userSelectionRect:null}),j.current=0,_.current=0},I=Q=>{l==null||l(Q),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},O=Q=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){Q.preventDefault();return}u==null||u(Q)},P=c?Q=>c(Q):void 0,z=Q=>{const{resetSelectedElements:A,domNode:H}=w.getState();if(S.current=H==null?void 0:H.getBoundingClientRect(),!E||!e||Q.button!==0||Q.target!==y.current||!S.current)return;const{x:U,y:ne}=di(Q,S.current);A(),w.setState({userSelectionRect:{width:0,height:0,startX:U,startY:ne,x:U,y:ne}}),s==null||s(Q)},T=Q=>{const{userSelectionRect:A,nodeInternals:H,edges:U,transform:ne,onNodesChange:Y,onEdgesChange:L,nodeOrigin:G,getNodes:k}=w.getState();if(!e||!S.current||!A)return;w.setState({userSelectionActive:!0,nodesSelectionActive:!1});const $=di(Q,S.current),oe=A.startX??0,D=A.startY??0,X={...A,x:$.x<oe?$.x:oe,y:$.y<D?$.y:D,width:Math.abs($.x-oe),height:Math.abs($.y-D)},ee=k(),se=SE(H,X,ne,n===Ko.Partial,!0,G),ae=bE(se,U).map(ge=>ge.id),pe=se.map(ge=>ge.id);if(j.current!==pe.length){j.current=pe.length;const ge=Ps(ee,pe);ge.length&&(Y==null||Y(ge))}if(_.current!==ae.length){_.current=ae.length;const ge=Ps(U,ae);ge.length&&(L==null||L(ge))}w.setState({userSelectionRect:X})},q=Q=>{if(Q.button!==0)return;const{userSelectionRect:A}=w.getState();!b&&A&&Q.target===y.current&&(I==null||I(Q)),w.setState({nodesSelectionActive:j.current>0}),C(),o==null||o(Q)},B=Q=>{b&&(w.setState({nodesSelectionActive:j.current>0}),o==null||o(Q)),C()},Z=E&&(e||b);return le.createElement("div",{className:Dt(["react-flow__pane",{dragging:N,selection:e}]),onClick:Z?void 0:Jc(I,y),onContextMenu:Jc(O,y),onWheel:Jc(P,y),onMouseEnter:Z?void 0:f,onMouseDown:Z?z:void 0,onMouseMove:Z?T:h,onMouseUp:Z?q:void 0,onMouseLeave:Z?B:p,ref:y,style:lv},m,le.createElement(LI,null))});FE.displayName="Pane";function zE(e,n){const i=e.parentNode||e.parentId;if(!i)return!1;const s=n.get(i);return s?s.selected?!0:zE(s,n):!1}function Lw(e,n,i){let s=e;do{if(s!=null&&s.matches(n))return!0;if(s===i.current)return!1;s=s.parentElement}while(s);return!1}function zI(e,n,i,s){return Array.from(e.values()).filter(o=>(o.selected||o.id===s)&&(!o.parentNode||o.parentId||!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:i.x-(((l=o.positionAbsolute)==null?void 0:l.x)??0),y:i.y-(((u=o.positionAbsolute)==null?void 0:u.y)??0)},delta:{x:0,y:0},extent:o.extent,parentNode:o.parentNode||o.parentId,parentId:o.parentNode||o.parentId,width:o.width,height:o.height,expandParent:o.expandParent}})}function BI(e,n){return!n||n==="parent"?n:[n[0],[n[1][0]-(e.width||0),n[1][1]-(e.height||0)]]}function BE(e,n,i,s,o=[0,0],l){const u=BI(e,e.extent||s);let c=u;const f=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(f&&e.width&&e.height){const m=i.get(f),{x:y,y:w}=Vi(m,o).positionAbsolute;c=m&&Pn(y)&&Pn(w)&&Pn(m.width)&&Pn(m.height)?[[y+e.width*o[0],w+e.height*o[1]],[y+m.width-e.width+e.width*o[0],w+m.height-e.height+e.height*o[1]]]:c}else l==null||l("005",Ar.error005()),c=u;else if(e.extent&&f&&e.extent!=="parent"){const m=i.get(f),{x:y,y:w}=Vi(m,o).positionAbsolute;c=[[e.extent[0][0]+y,e.extent[0][1]+w],[e.extent[1][0]+y,e.extent[1][1]+w]]}let h={x:0,y:0};if(f){const m=i.get(f);h=Vi(m,o).positionAbsolute}const p=c&&c!=="parent"?tv(n,c):n;return{position:{x:p.x-h.x,y:p.y-h.y},positionAbsolute:p}}function ed({nodeId:e,dragItems:n,nodeInternals:i}){const s=n.map(o=>({...i.get(o.id),position:o.position,positionAbsolute:o.positionAbsolute}));return[e?s.find(o=>o.id===e):s[0],s]}const $w=(e,n,i,s)=>{const o=n.querySelectorAll(e);if(!o||!o.length)return null;const l=Array.from(o),u=n.getBoundingClientRect(),c={x:u.width*s[0],y:u.height*s[1]};return l.map(f=>{const h=f.getBoundingClientRect();return{id:f.getAttribute("data-handleid"),position:f.getAttribute("data-handlepos"),x:(h.left-u.left-c.x)/i,y:(h.top-u.top-c.y)/i,...ev(f)}})};function Po(e,n,i){return i===void 0?i:s=>{const o=n().nodeInternals.get(e);o&&i(s,{...o})}}function $g({id:e,store:n,unselect:i=!1,nodeRef:s}){const{addSelectedNodes:o,unselectNodesAndEdges:l,multiSelectionActive:u,nodeInternals:c,onError:f}=n.getState(),h=c.get(e);if(!h){f==null||f("012",Ar.error012(e));return}n.setState({nodesSelectionActive:!1}),h.selected?(i||h.selected&&u)&&(l({nodes:[h],edges:[]}),requestAnimationFrame(()=>{var p;return(p=s==null?void 0:s.current)==null?void 0:p.blur()})):o([e])}function UI(){const e=jt();return M.useCallback(({sourceEvent:i})=>{const{transform:s,snapGrid:o,snapToGrid:l}=e.getState(),u=i.touches?i.touches[0].clientX:i.clientX,c=i.touches?i.touches[0].clientY:i.clientY,f={x:(u-s[0])/s[2],y:(c-s[1])/s[2]};return{xSnapped:l?o[0]*Math.round(f.x/o[0]):f.x,ySnapped:l?o[1]*Math.round(f.y/o[1]):f.y,...f}},[])}function td(e){return(n,i,s)=>e==null?void 0:e(n,s)}function UE({nodeRef:e,disabled:n=!1,noDragClassName:i,handleSelector:s,nodeId:o,isSelectable:l,selectNodesOnDrag:u}){const c=jt(),[f,h]=M.useState(!1),p=M.useRef([]),m=M.useRef({x:null,y:null}),y=M.useRef(0),w=M.useRef(null),j=M.useRef({x:0,y:0}),_=M.useRef(null),S=M.useRef(!1),b=M.useRef(!1),E=M.useRef(!1),N=UI();return M.useEffect(()=>{if(e!=null&&e.current){const C=Mn(e.current),I=({x:z,y:T})=>{const{nodeInternals:q,onNodeDrag:B,onSelectionDrag:Z,updateNodePositions:Q,nodeExtent:A,snapGrid:H,snapToGrid:U,nodeOrigin:ne,onError:Y}=c.getState();m.current={x:z,y:T};let L=!1,G={x:0,y:0,x2:0,y2:0};if(p.current.length>1&&A){const $=Wl(p.current,ne);G=Yo($)}if(p.current=p.current.map($=>{const oe={x:z-$.distance.x,y:T-$.distance.y};U&&(oe.x=H[0]*Math.round(oe.x/H[0]),oe.y=H[1]*Math.round(oe.y/H[1]));const D=[[A[0][0],A[0][1]],[A[1][0],A[1][1]]];p.current.length>1&&A&&!$.extent&&(D[0][0]=$.positionAbsolute.x-G.x+A[0][0],D[1][0]=$.positionAbsolute.x+($.width??0)-G.x2+A[1][0],D[0][1]=$.positionAbsolute.y-G.y+A[0][1],D[1][1]=$.positionAbsolute.y+($.height??0)-G.y2+A[1][1]);const X=BE($,oe,q,D,ne,Y);return L=L||$.position.x!==X.position.x||$.position.y!==X.position.y,$.position=X.position,$.positionAbsolute=X.positionAbsolute,$}),!L)return;Q(p.current,!0,!0),h(!0);const k=o?B:td(Z);if(k&&_.current){const[$,oe]=ed({nodeId:o,dragItems:p.current,nodeInternals:q});k(_.current,$,oe)}},O=()=>{if(!w.current)return;const[z,T]=dE(j.current,w.current);if(z!==0||T!==0){const{transform:q,panBy:B}=c.getState();m.current.x=(m.current.x??0)-z/q[2],m.current.y=(m.current.y??0)-T/q[2],B({x:z,y:T})&&I(m.current)}y.current=requestAnimationFrame(O)},P=z=>{var ne;const{nodeInternals:T,multiSelectionActive:q,nodesDraggable:B,unselectNodesAndEdges:Z,onNodeDragStart:Q,onSelectionDragStart:A}=c.getState();b.current=!0;const H=o?Q:td(A);(!u||!l)&&!q&&o&&((ne=T.get(o))!=null&&ne.selected||Z()),o&&l&&u&&$g({id:o,store:c,nodeRef:e});const U=N(z);if(m.current=U,p.current=zI(T,B,U,o),H&&p.current){const[Y,L]=ed({nodeId:o,dragItems:p.current,nodeInternals:T});H(z.sourceEvent,Y,L)}};if(n)C.on(".drag",null);else{const z=JT().on("start",T=>{const{domNode:q,nodeDragThreshold:B}=c.getState();B===0&&P(T),E.current=!1;const Z=N(T);m.current=Z,w.current=(q==null?void 0:q.getBoundingClientRect())||null,j.current=di(T.sourceEvent,w.current)}).on("drag",T=>{var Q,A;const q=N(T),{autoPanOnNodeDrag:B,nodeDragThreshold:Z}=c.getState();if(T.sourceEvent.type==="touchmove"&&T.sourceEvent.touches.length>1&&(E.current=!0),!E.current){if(!S.current&&b.current&&B&&(S.current=!0,O()),!b.current){const H=q.xSnapped-(((Q=m==null?void 0:m.current)==null?void 0:Q.x)??0),U=q.ySnapped-(((A=m==null?void 0:m.current)==null?void 0:A.y)??0);Math.sqrt(H*H+U*U)>Z&&P(T)}(m.current.x!==q.xSnapped||m.current.y!==q.ySnapped)&&p.current&&b.current&&(_.current=T.sourceEvent,j.current=di(T.sourceEvent,w.current),I(q))}}).on("end",T=>{if(!(!b.current||E.current)&&(h(!1),S.current=!1,b.current=!1,cancelAnimationFrame(y.current),p.current)){const{updateNodePositions:q,nodeInternals:B,onNodeDragStop:Z,onSelectionDragStop:Q}=c.getState(),A=o?Z:td(Q);if(q(p.current,!1,!1),A){const[H,U]=ed({nodeId:o,dragItems:p.current,nodeInternals:B});A(T.sourceEvent,H,U)}}}).filter(T=>{const q=T.target;return!T.button&&(!i||!Lw(q,`.${i}`,e))&&(!s||Lw(q,s,e))});return C.call(z),()=>{C.on(".drag",null)}}}},[e,n,i,s,l,c,o,u,N]),f}function HE(){const e=jt();return M.useCallback(i=>{const{nodeInternals:s,nodeExtent:o,updateNodePositions:l,getNodes:u,snapToGrid:c,snapGrid:f,onError:h,nodesDraggable:p}=e.getState(),m=u().filter(E=>E.selected&&(E.draggable||p&&typeof E.draggable>"u")),y=c?f[0]:5,w=c?f[1]:5,j=i.isShiftPressed?4:1,_=i.x*y*j,S=i.y*w*j,b=m.map(E=>{if(E.positionAbsolute){const N={x:E.positionAbsolute.x+_,y:E.positionAbsolute.y+S};c&&(N.x=f[0]*Math.round(N.x/f[0]),N.y=f[1]*Math.round(N.y/f[1]));const{positionAbsolute:C,position:I}=BE(E,N,s,o,void 0,h);E.position=I,E.positionAbsolute=C}return E});l(b,!0,!1)},[])}const $s={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var Oo=e=>{const n=({id:i,type:s,data:o,xPos:l,yPos:u,xPosOrigin:c,yPosOrigin:f,selected:h,onClick:p,onMouseEnter:m,onMouseMove:y,onMouseLeave:w,onContextMenu:j,onDoubleClick:_,style:S,className:b,isDraggable:E,isSelectable:N,isConnectable:C,isFocusable:I,selectNodesOnDrag:O,sourcePosition:P,targetPosition:z,hidden:T,resizeObserver:q,dragHandle:B,zIndex:Z,isParent:Q,noDragClassName:A,noPanClassName:H,initialized:U,disableKeyboardA11y:ne,ariaLabel:Y,rfId:L,hasHandleBounds:G})=>{const k=jt(),$=M.useRef(null),oe=M.useRef(null),D=M.useRef(P),X=M.useRef(z),ee=M.useRef(s),se=N||E||p||m||y||w,ae=HE(),pe=Po(i,k.getState,m),ge=Po(i,k.getState,y),Ae=Po(i,k.getState,w),Oe=Po(i,k.getState,j),Ie=Po(i,k.getState,_),Me=ve=>{const{nodeDragThreshold:ye}=k.getState();if(N&&(!O||!E||ye>0)&&$g({id:i,store:k,nodeRef:$}),p){const Ve=k.getState().nodeInternals.get(i);Ve&&p(ve,{...Ve})}},ke=ve=>{if(!Mg(ve)&&!ne)if(mE.includes(ve.key)&&N){const ye=ve.key==="Escape";$g({id:i,store:k,unselect:ye,nodeRef:$})}else E&&h&&Object.prototype.hasOwnProperty.call($s,ve.key)&&(k.setState({ariaLiveMessage:`Moved selected node ${ve.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~l}, y: ${~~u}`}),ae({x:$s[ve.key].x,y:$s[ve.key].y,isShiftPressed:ve.shiftKey}))};M.useEffect(()=>()=>{oe.current&&(q==null||q.unobserve(oe.current),oe.current=null)},[]),M.useEffect(()=>{if($.current&&!T){const ve=$.current;(!U||!G||oe.current!==ve)&&(oe.current&&(q==null||q.unobserve(oe.current)),q==null||q.observe(ve),oe.current=ve)}},[T,U,G]),M.useEffect(()=>{const ve=ee.current!==s,ye=D.current!==P,Ve=X.current!==z;$.current&&(ve||ye||Ve)&&(ve&&(ee.current=s),ye&&(D.current=P),Ve&&(X.current=z),k.getState().updateNodeDimensions([{id:i,nodeElement:$.current,forceUpdate:!0}]))},[i,s,P,z]);const He=UE({nodeRef:$,disabled:T||!E,noDragClassName:A,handleSelector:B,nodeId:i,isSelectable:N,selectNodesOnDrag:O});return T?null:le.createElement("div",{className:Dt(["react-flow__node",`react-flow__node-${s}`,{[H]:E},b,{selected:h,selectable:N,parent:Q,dragging:He}]),ref:$,style:{zIndex:Z,transform:`translate(${c}px,${f}px)`,pointerEvents:se?"all":"none",visibility:U?"visible":"hidden",...S},"data-id":i,"data-testid":`rf__node-${i}`,onMouseEnter:pe,onMouseMove:ge,onMouseLeave:Ae,onContextMenu:Oe,onClick:Me,onDoubleClick:Ie,onKeyDown:I?ke:void 0,tabIndex:I?0:void 0,role:I?"button":void 0,"aria-describedby":ne?void 0:`${OE}-${L}`,"aria-label":Y},le.createElement(nI,{value:i},le.createElement(e,{id:i,data:o,type:s,xPos:l,yPos:u,selected:h,isConnectable:C,sourcePosition:P,targetPosition:z,dragging:He,dragHandle:B,zIndex:Z})))};return n.displayName="NodeWrapper",M.memo(n)};const HI=e=>{const n=e.getNodes().filter(i=>i.selected);return{...Wl(n,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function VI({onSelectionContextMenu:e,noPanClassName:n,disableKeyboardA11y:i}){const s=jt(),{width:o,height:l,x:u,y:c,transformString:f,userSelectionActive:h}=Xe(HI,Ct),p=HE(),m=M.useRef(null);if(M.useEffect(()=>{var j;i||(j=m.current)==null||j.focus({preventScroll:!0})},[i]),UE({nodeRef:m}),h||!o||!l)return null;const y=e?j=>{const _=s.getState().getNodes().filter(S=>S.selected);e(j,_)}:void 0,w=j=>{Object.prototype.hasOwnProperty.call($s,j.key)&&p({x:$s[j.key].x,y:$s[j.key].y,isShiftPressed:j.shiftKey})};return le.createElement("div",{className:Dt(["react-flow__nodesselection","react-flow__container",n]),style:{transform:f}},le.createElement("div",{ref:m,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:i?void 0:-1,onKeyDown:i?void 0:w,style:{width:o,height:l,top:c,left:u}}))}var WI=M.memo(VI);const GI=e=>e.nodesSelectionActive,VE=({children:e,onPaneClick:n,onPaneMouseEnter:i,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:l,onPaneScroll:u,deleteKeyCode:c,onMove:f,onMoveStart:h,onMoveEnd:p,selectionKeyCode:m,selectionOnDrag:y,selectionMode:w,onSelectionStart:j,onSelectionEnd:_,multiSelectionKeyCode:S,panActivationKeyCode:b,zoomActivationKeyCode:E,elementsSelectable:N,zoomOnScroll:C,zoomOnPinch:I,panOnScroll:O,panOnScrollSpeed:P,panOnScrollMode:z,zoomOnDoubleClick:T,panOnDrag:q,defaultViewport:B,translateExtent:Z,minZoom:Q,maxZoom:A,preventScrolling:H,onSelectionContextMenu:U,noWheelClassName:ne,noPanClassName:Y,disableKeyboardA11y:L})=>{const G=Xe(GI),k=Xo(m),$=Xo(b),oe=$||q,D=$||O,X=k||y&&oe!==!0;return AI({deleteKeyCode:c,multiSelectionKeyCode:S}),le.createElement(OI,{onMove:f,onMoveStart:h,onMoveEnd:p,onPaneContextMenu:l,elementsSelectable:N,zoomOnScroll:C,zoomOnPinch:I,panOnScroll:D,panOnScrollSpeed:P,panOnScrollMode:z,zoomOnDoubleClick:T,panOnDrag:!k&&oe,defaultViewport:B,translateExtent:Z,minZoom:Q,maxZoom:A,zoomActivationKeyCode:E,preventScrolling:H,noWheelClassName:ne,noPanClassName:Y},le.createElement(FE,{onSelectionStart:j,onSelectionEnd:_,onPaneClick:n,onPaneMouseEnter:i,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:l,onPaneScroll:u,panOnDrag:oe,isSelecting:!!X,selectionMode:w},e,G&&le.createElement(WI,{onSelectionContextMenu:U,noPanClassName:Y,disableKeyboardA11y:L})))};VE.displayName="FlowRenderer";var YI=M.memo(VE);function KI(e){return Xe(M.useCallback(i=>e?SE(i.nodeInternals,{x:0,y:0,width:i.width,height:i.height},i.transform,!0):i.getNodes(),[e]))}function XI(e){const n={input:Oo(e.input||AE),default:Oo(e.default||Lg),output:Oo(e.output||ME),group:Oo(e.group||av)},i={},s=Object.keys(e).filter(o=>!["input","default","output","group"].includes(o)).reduce((o,l)=>(o[l]=Oo(e[l]||Lg),o),i);return{...n,...s}}const QI=({x:e,y:n,width:i,height:s,origin:o})=>!i||!s?{x:e,y:n}:o[0]<0||o[1]<0||o[0]>1||o[1]>1?{x:e,y:n}:{x:e-i*o[0],y:n-s*o[1]},ZI=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),WE=e=>{const{nodesDraggable:n,nodesConnectable:i,nodesFocusable:s,elementsSelectable:o,updateNodeDimensions:l,onError:u}=Xe(ZI,Ct),c=KI(e.onlyRenderVisibleElements),f=M.useRef(),h=M.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const p=new ResizeObserver(m=>{const y=m.map(w=>({id:w.target.getAttribute("data-id"),nodeElement:w.target,forceUpdate:!0}));l(y)});return f.current=p,p},[]);return M.useEffect(()=>()=>{var p;(p=f==null?void 0:f.current)==null||p.disconnect()},[]),le.createElement("div",{className:"react-flow__nodes",style:lv},c.map(p=>{var I,O,P;let m=p.type||"default";e.nodeTypes[m]||(u==null||u("003",Ar.error003(m)),m="default");const y=e.nodeTypes[m]||e.nodeTypes.default,w=!!(p.draggable||n&&typeof p.draggable>"u"),j=!!(p.selectable||o&&typeof p.selectable>"u"),_=!!(p.connectable||i&&typeof p.connectable>"u"),S=!!(p.focusable||s&&typeof p.focusable>"u"),b=e.nodeExtent?tv(p.positionAbsolute,e.nodeExtent):p.positionAbsolute,E=(b==null?void 0:b.x)??0,N=(b==null?void 0:b.y)??0,C=QI({x:E,y:N,width:p.width??0,height:p.height??0,origin:e.nodeOrigin});return le.createElement(y,{key:p.id,id:p.id,className:p.className,style:p.style,type:m,data:p.data,sourcePosition:p.sourcePosition||Ce.Bottom,targetPosition:p.targetPosition||Ce.Top,hidden:p.hidden,xPos:E,yPos:N,xPosOrigin:C.x,yPosOrigin:C.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!p.selected,isDraggable:w,isSelectable:j,isConnectable:_,isFocusable:S,resizeObserver:h,dragHandle:p.dragHandle,zIndex:((I=p[pt])==null?void 0:I.z)??0,isParent:!!((O=p[pt])!=null&&O.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!p.width&&!!p.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:p.ariaLabel,hasHandleBounds:!!((P=p[pt])!=null&&P.handleBounds)})}))};WE.displayName="NodeRenderer";var JI=M.memo(WE);const eM=(e,n,i)=>i===Ce.Left?e-n:i===Ce.Right?e+n:e,tM=(e,n,i)=>i===Ce.Top?e-n:i===Ce.Bottom?e+n:e,Dw="react-flow__edgeupdater",Fw=({position:e,centerX:n,centerY:i,radius:s=10,onMouseDown:o,onMouseEnter:l,onMouseOut:u,type:c})=>le.createElement("circle",{onMouseDown:o,onMouseEnter:l,onMouseOut:u,className:Dt([Dw,`${Dw}-${c}`]),cx:eM(n,s,e),cy:tM(i,s,e),r:s,stroke:"transparent",fill:"transparent"}),nM=()=>!0;var Is=e=>{const n=({id:i,className:s,type:o,data:l,onClick:u,onEdgeDoubleClick:c,selected:f,animated:h,label:p,labelStyle:m,labelShowBg:y,labelBgStyle:w,labelBgPadding:j,labelBgBorderRadius:_,style:S,source:b,target:E,sourceX:N,sourceY:C,targetX:I,targetY:O,sourcePosition:P,targetPosition:z,elementsSelectable:T,hidden:q,sourceHandleId:B,targetHandleId:Z,onContextMenu:Q,onMouseEnter:A,onMouseMove:H,onMouseLeave:U,reconnectRadius:ne,onReconnect:Y,onReconnectStart:L,onReconnectEnd:G,markerEnd:k,markerStart:$,rfId:oe,ariaLabel:D,isFocusable:X,isReconnectable:ee,pathOptions:se,interactionWidth:ae,disableKeyboardA11y:pe})=>{const ge=M.useRef(null),[Ae,Oe]=M.useState(!1),[Ie,Me]=M.useState(!1),ke=jt(),He=M.useMemo(()=>`url('#${Og($,oe)}')`,[$,oe]),ve=M.useMemo(()=>`url('#${Og(k,oe)}')`,[k,oe]);if(q)return null;const ye=tt=>{var Tt;const{edges:xt,addSelectedEdges:lt,unselectNodesAndEdges:mt,multiSelectionActive:wn}=ke.getState(),bt=xt.find(xn=>xn.id===i);bt&&(T&&(ke.setState({nodesSelectionActive:!1}),bt.selected&&wn?(mt({nodes:[],edges:[bt]}),(Tt=ge.current)==null||Tt.blur()):lt([i])),u&&u(tt,bt))},Ve=Mo(i,ke.getState,c),ft=Mo(i,ke.getState,Q),Qe=Mo(i,ke.getState,A),We=Mo(i,ke.getState,H),$e=Mo(i,ke.getState,U),Ke=(tt,xt)=>{if(tt.button!==0)return;const{edges:lt,isValidConnection:mt}=ke.getState(),wn=xt?E:b,bt=(xt?Z:B)||null,Tt=xt?"target":"source",xn=mt||nM,Ln=xt,ut=lt.find(At=>At.id===i);Me(!0),L==null||L(tt,ut,Tt);const Yt=At=>{Me(!1),G==null||G(At,ut,Tt)};CE({event:tt,handleId:bt,nodeId:wn,onConnect:At=>Y==null?void 0:Y(ut,At),isTarget:Ln,getState:ke.getState,setState:ke.setState,isValidConnection:xn,edgeUpdaterType:Tt,onReconnectEnd:Yt})},yt=tt=>Ke(tt,!0),et=tt=>Ke(tt,!1),Ge=()=>Oe(!0),wt=()=>Oe(!1),Rt=!T&&!u,Ft=tt=>{var xt;if(!pe&&mE.includes(tt.key)&&T){const{unselectNodesAndEdges:lt,addSelectedEdges:mt,edges:wn}=ke.getState();tt.key==="Escape"?((xt=ge.current)==null||xt.blur(),lt({edges:[wn.find(Tt=>Tt.id===i)]})):mt([i])}};return le.createElement("g",{className:Dt(["react-flow__edge",`react-flow__edge-${o}`,s,{selected:f,animated:h,inactive:Rt,updating:Ae}]),onClick:ye,onDoubleClick:Ve,onContextMenu:ft,onMouseEnter:Qe,onMouseMove:We,onMouseLeave:$e,onKeyDown:X?Ft:void 0,tabIndex:X?0:void 0,role:X?"button":"img","data-testid":`rf__edge-${i}`,"aria-label":D===null?void 0:D||`Edge from ${b} to ${E}`,"aria-describedby":X?`${qE}-${oe}`:void 0,ref:ge},!Ie&&le.createElement(e,{id:i,source:b,target:E,selected:f,animated:h,label:p,labelStyle:m,labelShowBg:y,labelBgStyle:w,labelBgPadding:j,labelBgBorderRadius:_,data:l,style:S,sourceX:N,sourceY:C,targetX:I,targetY:O,sourcePosition:P,targetPosition:z,sourceHandleId:B,targetHandleId:Z,markerStart:He,markerEnd:ve,pathOptions:se,interactionWidth:ae}),ee&&le.createElement(le.Fragment,null,(ee==="source"||ee===!0)&&le.createElement(Fw,{position:P,centerX:N,centerY:C,radius:ne,onMouseDown:yt,onMouseEnter:Ge,onMouseOut:wt,type:"source"}),(ee==="target"||ee===!0)&&le.createElement(Fw,{position:z,centerX:I,centerY:O,radius:ne,onMouseDown:et,onMouseEnter:Ge,onMouseOut:wt,type:"target"})))};return n.displayName="EdgeWrapper",M.memo(n)};function rM(e){const n={default:Is(e.default||ql),straight:Is(e.bezier||iv),step:Is(e.step||rv),smoothstep:Is(e.step||Vl),simplebezier:Is(e.simplebezier||nv)},i={},s=Object.keys(e).filter(o=>!["default","bezier"].includes(o)).reduce((o,l)=>(o[l]=Is(e[l]||ql),o),i);return{...n,...s}}function zw(e,n,i=null){const s=((i==null?void 0:i.x)||0)+n.x,o=((i==null?void 0:i.y)||0)+n.y,l=(i==null?void 0:i.width)||n.width,u=(i==null?void 0:i.height)||n.height;switch(e){case Ce.Top:return{x:s+l/2,y:o};case Ce.Right:return{x:s+l,y:o+u/2};case Ce.Bottom:return{x:s+l/2,y:o+u};case Ce.Left:return{x:s,y:o+u/2}}}function Bw(e,n){return e?e.length===1||!n?e[0]:n&&e.find(i=>i.id===n)||null:null}const iM=(e,n,i,s,o,l)=>{const u=zw(i,e,n),c=zw(l,s,o);return{sourceX:u.x,sourceY:u.y,targetX:c.x,targetY:c.y}};function sM({sourcePos:e,targetPos:n,sourceWidth:i,sourceHeight:s,targetWidth:o,targetHeight:l,width:u,height:c,transform:f}){const h={x:Math.min(e.x,n.x),y:Math.min(e.y,n.y),x2:Math.max(e.x+i,n.x+o),y2:Math.max(e.y+s,n.y+l)};h.x===h.x2&&(h.x2+=1),h.y===h.y2&&(h.y2+=1);const p=Yo({x:(0-f[0])/f[2],y:(0-f[1])/f[2],width:u/f[2],height:c/f[2]}),m=Math.max(0,Math.min(p.x2,h.x2)-Math.max(p.x,h.x)),y=Math.max(0,Math.min(p.y2,h.y2)-Math.max(p.y,h.y));return Math.ceil(m*y)>0}function Uw(e){var s,o,l,u,c;const n=((s=e==null?void 0:e[pt])==null?void 0:s.handleBounds)||null,i=n&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((o=e==null?void 0:e.positionAbsolute)==null?void 0:o.x)<"u"&&typeof((l=e==null?void 0:e.positionAbsolute)==null?void 0:l.y)<"u";return[{x:((u=e==null?void 0:e.positionAbsolute)==null?void 0:u.x)||0,y:((c=e==null?void 0:e.positionAbsolute)==null?void 0:c.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},n,!!i]}const oM=[{level:0,isMaxLevel:!0,edges:[]}];function aM(e,n,i=!1){let s=-1;const o=e.reduce((u,c)=>{var p,m;const f=Pn(c.zIndex);let h=f?c.zIndex:0;if(i){const y=n.get(c.target),w=n.get(c.source),j=c.selected||(y==null?void 0:y.selected)||(w==null?void 0:w.selected),_=Math.max(((p=w==null?void 0:w[pt])==null?void 0:p.z)||0,((m=y==null?void 0:y[pt])==null?void 0:m.z)||0,1e3);h=(f?c.zIndex:0)+(j?_: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 f=+u;return{edges:c,level:f,isMaxLevel:f===s}});return l.length===0?oM:l}function lM(e,n,i){const s=Xe(M.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)&&sM({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 aM(s,n,i)}const uM=({color:e="none",strokeWidth:n=1})=>le.createElement("polyline",{style:{stroke:e,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),cM=({color:e="none",strokeWidth:n=1})=>le.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),Hw={[Ol.Arrow]:uM,[Ol.ArrowClosed]:cM};function dM(e){const n=jt();return M.useMemo(()=>{var o,l;return Object.prototype.hasOwnProperty.call(Hw,e)?Hw[e]:((l=(o=n.getState()).onError)==null||l.call(o,"009",Ar.error009(e)),null)},[e])}const fM=({id:e,type:n,color:i,width:s=12.5,height:o=12.5,markerUnits:l="strokeWidth",strokeWidth:u,orient:c="auto-start-reverse"})=>{const f=dM(n);return f?le.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:l,orient:c,refX:"0",refY:"0"},le.createElement(f,{color:i,strokeWidth:u})):null},hM=({defaultColor:e,rfId:n})=>i=>{const s=[];return i.edges.reduce((o,l)=>([l.markerStart,l.markerEnd].forEach(u=>{if(u&&typeof u=="object"){const c=Og(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))},GE=({defaultColor:e,rfId:n})=>{const i=Xe(M.useCallback(hM({defaultColor:e,rfId:n}),[e,n]),(s,o)=>!(s.length!==o.length||s.some((l,u)=>l.id!==o[u].id)));return le.createElement("defs",null,i.map(s=>le.createElement(fM,{id:s.id,key:s.id,type:s.type,color:s.color,width:s.width,height:s.height,markerUnits:s.markerUnits,strokeWidth:s.strokeWidth,orient:s.orient})))};GE.displayName="MarkerDefinitions";var pM=M.memo(GE);const mM=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}),YE=({defaultMarkerColor:e,onlyRenderVisibleElements:n,elevateEdgesOnSelect:i,rfId:s,edgeTypes:o,noPanClassName:l,onEdgeContextMenu:u,onEdgeMouseEnter:c,onEdgeMouseMove:f,onEdgeMouseLeave:h,onEdgeClick:p,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:w,onReconnectEnd:j,reconnectRadius:_,children:S,disableKeyboardA11y:b})=>{const{edgesFocusable:E,edgesUpdatable:N,elementsSelectable:C,width:I,height:O,connectionMode:P,nodeInternals:z,onError:T}=Xe(mM,Ct),q=lM(n,z,i);return I?le.createElement(le.Fragment,null,q.map(({level:B,edges:Z,isMaxLevel:Q})=>le.createElement("svg",{key:B,style:{zIndex:B},width:I,height:O,className:"react-flow__edges react-flow__container"},Q&&le.createElement(pM,{defaultColor:e,rfId:s}),le.createElement("g",null,Z.map(A=>{const[H,U,ne]=Uw(z.get(A.source)),[Y,L,G]=Uw(z.get(A.target));if(!ne||!G)return null;let k=A.type||"default";o[k]||(T==null||T("011",Ar.error011(k)),k="default");const $=o[k]||o.default,oe=P===Yi.Strict?L.target:(L.target??[]).concat(L.source??[]),D=Bw(U.source,A.sourceHandle),X=Bw(oe,A.targetHandle),ee=(D==null?void 0:D.position)||Ce.Bottom,se=(X==null?void 0:X.position)||Ce.Top,ae=!!(A.focusable||E&&typeof A.focusable>"u"),pe=A.reconnectable||A.updatable,ge=typeof y<"u"&&(pe||N&&typeof pe>"u");if(!D||!X)return T==null||T("008",Ar.error008(D,A)),null;const{sourceX:Ae,sourceY:Oe,targetX:Ie,targetY:Me}=iM(H,D,ee,Y,X,se);return le.createElement($,{key:A.id,id:A.id,className:Dt([A.className,l]),type:k,data:A.data,selected:!!A.selected,animated:!!A.animated,hidden:!!A.hidden,label:A.label,labelStyle:A.labelStyle,labelShowBg:A.labelShowBg,labelBgStyle:A.labelBgStyle,labelBgPadding:A.labelBgPadding,labelBgBorderRadius:A.labelBgBorderRadius,style:A.style,source:A.source,target:A.target,sourceHandleId:A.sourceHandle,targetHandleId:A.targetHandle,markerEnd:A.markerEnd,markerStart:A.markerStart,sourceX:Ae,sourceY:Oe,targetX:Ie,targetY:Me,sourcePosition:ee,targetPosition:se,elementsSelectable:C,onContextMenu:u,onMouseEnter:c,onMouseMove:f,onMouseLeave:h,onClick:p,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:w,onReconnectEnd:j,reconnectRadius:_,rfId:s,ariaLabel:A.ariaLabel,isFocusable:ae,isReconnectable:ge,pathOptions:"pathOptions"in A?A.pathOptions:void 0,interactionWidth:A.interactionWidth,disableKeyboardA11y:b})})))),S):null};YE.displayName="EdgeRenderer";var gM=M.memo(YE);const vM=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function yM({children:e}){const n=Xe(vM);return le.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:n}},e)}function wM(e){const n=ta(),i=M.useRef(!1);M.useEffect(()=>{!i.current&&n.viewportInitialized&&e&&(setTimeout(()=>e(n),1),i.current=!0)},[e,n.viewportInitialized])}const xM={[Ce.Left]:Ce.Right,[Ce.Right]:Ce.Left,[Ce.Top]:Ce.Bottom,[Ce.Bottom]:Ce.Top},KE=({nodeId:e,handleType:n,style:i,type:s=ci.Bezier,CustomComponent:o,connectionStatus:l})=>{var O,P,z;const{fromNode:u,handleId:c,toX:f,toY:h,connectionMode:p}=Xe(M.useCallback(T=>({fromNode:T.nodeInternals.get(e),handleId:T.connectionHandleId,toX:(T.connectionPosition.x-T.transform[0])/T.transform[2],toY:(T.connectionPosition.y-T.transform[1])/T.transform[2],connectionMode:T.connectionMode}),[e]),Ct),m=(O=u==null?void 0:u[pt])==null?void 0:O.handleBounds;let y=m==null?void 0:m[n];if(p===Yi.Loose&&(y=y||(m==null?void 0:m[n==="source"?"target":"source"])),!u||!y)return null;const w=c?y.find(T=>T.id===c):y[0],j=w?w.x+w.width/2:(u.width??0)/2,_=w?w.y+w.height/2:u.height??0,S=(((P=u.positionAbsolute)==null?void 0:P.x)??0)+j,b=(((z=u.positionAbsolute)==null?void 0:z.y)??0)+_,E=w==null?void 0:w.position,N=E?xM[E]:null;if(!E||!N)return null;if(o)return le.createElement(o,{connectionLineType:s,connectionLineStyle:i,fromNode:u,fromHandle:w,fromX:S,fromY:b,toX:f,toY:h,fromPosition:E,toPosition:N,connectionStatus:l});let C="";const I={sourceX:S,sourceY:b,sourcePosition:E,targetX:f,targetY:h,targetPosition:N};return s===ci.Bezier?[C]=xE(I):s===ci.Step?[C]=Pg({...I,borderRadius:0}):s===ci.SmoothStep?[C]=Pg(I):s===ci.SimpleBezier?[C]=wE(I):C=`M${S},${b} ${f},${h}`,le.createElement("path",{d:C,fill:"none",className:"react-flow__connection-path",style:i})};KE.displayName="ConnectionLine";const _M=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function SM({containerStyle:e,style:n,type:i,component:s}){const{nodeId:o,handleType:l,nodesConnectable:u,width:c,height:f,connectionStatus:h}=Xe(_M,Ct);return!(o&&l&&c&&u)?null:le.createElement("svg",{style:e,width:c,height:f,className:"react-flow__edges react-flow__connectionline react-flow__container"},le.createElement("g",{className:Dt(["react-flow__connection",h])},le.createElement(KE,{nodeId:o,handleType:l,style:n,type:i,CustomComponent:s,connectionStatus:h})))}function Vw(e,n){return M.useRef(null),jt(),M.useMemo(()=>n(e),[e])}const XE=({nodeTypes:e,edgeTypes:n,onMove:i,onMoveStart:s,onMoveEnd:o,onInit:l,onNodeClick:u,onEdgeClick:c,onNodeDoubleClick:f,onEdgeDoubleClick:h,onNodeMouseEnter:p,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:w,onSelectionContextMenu:j,onSelectionStart:_,onSelectionEnd:S,connectionLineType:b,connectionLineStyle:E,connectionLineComponent:N,connectionLineContainerStyle:C,selectionKeyCode:I,selectionOnDrag:O,selectionMode:P,multiSelectionKeyCode:z,panActivationKeyCode:T,zoomActivationKeyCode:q,deleteKeyCode:B,onlyRenderVisibleElements:Z,elementsSelectable:Q,selectNodesOnDrag:A,defaultViewport:H,translateExtent:U,minZoom:ne,maxZoom:Y,preventScrolling:L,defaultMarkerColor:G,zoomOnScroll:k,zoomOnPinch:$,panOnScroll:oe,panOnScrollSpeed:D,panOnScrollMode:X,zoomOnDoubleClick:ee,panOnDrag:se,onPaneClick:ae,onPaneMouseEnter:pe,onPaneMouseMove:ge,onPaneMouseLeave:Ae,onPaneScroll:Oe,onPaneContextMenu:Ie,onEdgeContextMenu:Me,onEdgeMouseEnter:ke,onEdgeMouseMove:He,onEdgeMouseLeave:ve,onReconnect:ye,onReconnectStart:Ve,onReconnectEnd:ft,reconnectRadius:Qe,noDragClassName:We,noWheelClassName:$e,noPanClassName:Ke,elevateEdgesOnSelect:yt,disableKeyboardA11y:et,nodeOrigin:Ge,nodeExtent:wt,rfId:Rt})=>{const Ft=Vw(e,XI),tt=Vw(n,rM);return wM(l),le.createElement(YI,{onPaneClick:ae,onPaneMouseEnter:pe,onPaneMouseMove:ge,onPaneMouseLeave:Ae,onPaneContextMenu:Ie,onPaneScroll:Oe,deleteKeyCode:B,selectionKeyCode:I,selectionOnDrag:O,selectionMode:P,onSelectionStart:_,onSelectionEnd:S,multiSelectionKeyCode:z,panActivationKeyCode:T,zoomActivationKeyCode:q,elementsSelectable:Q,onMove:i,onMoveStart:s,onMoveEnd:o,zoomOnScroll:k,zoomOnPinch:$,zoomOnDoubleClick:ee,panOnScroll:oe,panOnScrollSpeed:D,panOnScrollMode:X,panOnDrag:se,defaultViewport:H,translateExtent:U,minZoom:ne,maxZoom:Y,onSelectionContextMenu:j,preventScrolling:L,noDragClassName:We,noWheelClassName:$e,noPanClassName:Ke,disableKeyboardA11y:et},le.createElement(yM,null,le.createElement(gM,{edgeTypes:tt,onEdgeClick:c,onEdgeDoubleClick:h,onlyRenderVisibleElements:Z,onEdgeContextMenu:Me,onEdgeMouseEnter:ke,onEdgeMouseMove:He,onEdgeMouseLeave:ve,onReconnect:ye,onReconnectStart:Ve,onReconnectEnd:ft,reconnectRadius:Qe,defaultMarkerColor:G,noPanClassName:Ke,elevateEdgesOnSelect:!!yt,disableKeyboardA11y:et,rfId:Rt},le.createElement(SM,{style:E,type:b,component:N,containerStyle:C})),le.createElement("div",{className:"react-flow__edgelabel-renderer"}),le.createElement(JI,{nodeTypes:Ft,onNodeClick:u,onNodeDoubleClick:f,onNodeMouseEnter:p,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:w,selectNodesOnDrag:A,onlyRenderVisibleElements:Z,noPanClassName:Ke,noDragClassName:We,disableKeyboardA11y:et,nodeOrigin:Ge,nodeExtent:wt,rfId:Rt})))};XE.displayName="GraphView";var bM=M.memo(XE);const Dg=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ai={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:Dg,nodeExtent:Dg,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Yi.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:XA,isValidConnection:void 0},kM=()=>dR((e,n)=>({...ai,setNodes:i=>{const{nodeInternals:s,nodeOrigin:o,elevateNodesOnSelect:l}=n();e({nodeInternals:Zc(i,s,o,l)})},getNodes:()=>Array.from(n().nodeInternals.values()),setEdges:i=>{const{defaultEdgeOptions:s={}}=n();e({edges:i.map(o=>({...s,...o}))})},setDefaultNodesAndEdges:(i,s)=>{const o=typeof i<"u",l=typeof s<"u",u=o?Zc(i,new Map,n().nodeOrigin,n().elevateNodesOnSelect):new Map;e({nodeInternals:u,edges:l?s:[],hasDefaultNodes:o,hasDefaultEdges:l})},updateNodeDimensions:i=>{const{onNodesChange:s,nodeInternals:o,fitViewOnInit:l,fitViewOnInitDone:u,fitViewOnInitOptions:c,domNode:f,nodeOrigin:h}=n(),p=f==null?void 0:f.querySelector(".react-flow__viewport");if(!p)return;const m=window.getComputedStyle(p),{m22:y}=new window.DOMMatrixReadOnly(m.transform),w=i.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 E=ev(S.nodeElement);!!(E.width&&E.height&&(b.width!==E.width||b.height!==E.height||S.forceUpdate))&&(o.set(b.id,{...b,[pt]:{...b[pt],handleBounds:{source:$w(".source",S.nodeElement,y,h),target:$w(".target",S.nodeElement,y,h)}},...E}),_.push({id:b.id,type:"dimensions",dimensions:E}))}return _},[]);$E(o,h);const j=u||l&&!u&&DE(n,{initial:!0,...c});e({nodeInternals:new Map(o),fitViewOnInitDone:j}),(w==null?void 0:w.length)>0&&(s==null||s(w))},updateNodePositions:(i,s=!0,o=!1)=>{const{triggerNodeChanges:l}=n(),u=i.map(c=>{const f={id:c.id,type:"position",dragging:o};return s&&(f.positionAbsolute=c.positionAbsolute,f.position=c.position),f});l(u)},triggerNodeChanges:i=>{const{onNodesChange:s,nodeInternals:o,hasDefaultNodes:l,nodeOrigin:u,getNodes:c,elevateNodesOnSelect:f}=n();if(i!=null&&i.length){if(l){const h=DI(i,c()),p=Zc(h,o,u,f);e({nodeInternals:p})}s==null||s(i)}},addSelectedNodes:i=>{const{multiSelectionActive:s,edges:o,getNodes:l}=n();let u,c=null;s?u=i.map(f=>ui(f,!0)):(u=Ps(l(),i),c=Ps(o,[])),gl({changedNodes:u,changedEdges:c,get:n,set:e})},addSelectedEdges:i=>{const{multiSelectionActive:s,edges:o,getNodes:l}=n();let u,c=null;s?u=i.map(f=>ui(f,!0)):(u=Ps(o,i),c=Ps(l(),[])),gl({changedNodes:c,changedEdges:u,get:n,set:e})},unselectNodesAndEdges:({nodes:i,edges:s}={})=>{const{edges:o,getNodes:l}=n(),u=i||l(),c=s||o,f=u.map(p=>(p.selected=!1,ui(p.id,!1))),h=c.map(p=>ui(p.id,!1));gl({changedNodes:f,changedEdges:h,get:n,set:e})},setMinZoom:i=>{const{d3Zoom:s,maxZoom:o}=n();s==null||s.scaleExtent([i,o]),e({minZoom:i})},setMaxZoom:i=>{const{d3Zoom:s,minZoom:o}=n();s==null||s.scaleExtent([o,i]),e({maxZoom:i})},setTranslateExtent:i=>{var s;(s=n().d3Zoom)==null||s.translateExtent(i),e({translateExtent:i})},resetSelectedElements:()=>{const{edges:i,getNodes:s}=n(),l=s().filter(c=>c.selected).map(c=>ui(c.id,!1)),u=i.filter(c=>c.selected).map(c=>ui(c.id,!1));gl({changedNodes:l,changedEdges:u,get:n,set:e})},setNodeExtent:i=>{const{nodeInternals:s}=n();s.forEach(o=>{o.positionAbsolute=tv(o.position,i)}),e({nodeExtent:i,nodeInternals:new Map(s)})},panBy:i=>{const{transform:s,width:o,height:l,d3Zoom:u,d3Selection:c,translateExtent:f}=n();if(!u||!c||!i.x&&!i.y)return!1;const h=Rr.translate(s[0]+i.x,s[1]+i.y).scale(s[2]),p=[[0,0],[o,l]],m=u==null?void 0:u.constrain()(h,p,f);return u.transform(c,m),s[0]!==m.x||s[1]!==m.y||s[2]!==m.k},cancelConnection:()=>e({connectionNodeId:ai.connectionNodeId,connectionHandleId:ai.connectionHandleId,connectionHandleType:ai.connectionHandleType,connectionStatus:ai.connectionStatus,connectionStartHandle:ai.connectionStartHandle,connectionEndHandle:ai.connectionEndHandle}),reset:()=>e({...ai})}),Object.is),uv=({children:e})=>{const n=M.useRef(null);return n.current||(n.current=kM()),le.createElement(UA,{value:n.current},e)};uv.displayName="ReactFlowProvider";const QE=({children:e})=>M.useContext(Hl)?le.createElement(le.Fragment,null,e):le.createElement(uv,null,e);QE.displayName="ReactFlowWrapper";const EM={input:AE,default:Lg,output:ME,group:av},NM={default:ql,straight:iv,step:rv,smoothstep:Vl,simplebezier:nv},CM=[0,0],jM=[15,15],RM={x:0,y:0,zoom:1},TM={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},ZE=M.forwardRef(({nodes:e,edges:n,defaultNodes:i,defaultEdges:s,className:o,nodeTypes:l=EM,edgeTypes:u=NM,onNodeClick:c,onEdgeClick:f,onInit:h,onMove:p,onMoveStart:m,onMoveEnd:y,onConnect:w,onConnectStart:j,onConnectEnd:_,onClickConnectStart:S,onClickConnectEnd:b,onNodeMouseEnter:E,onNodeMouseMove:N,onNodeMouseLeave:C,onNodeContextMenu:I,onNodeDoubleClick:O,onNodeDragStart:P,onNodeDrag:z,onNodeDragStop:T,onNodesDelete:q,onEdgesDelete:B,onSelectionChange:Z,onSelectionDragStart:Q,onSelectionDrag:A,onSelectionDragStop:H,onSelectionContextMenu:U,onSelectionStart:ne,onSelectionEnd:Y,connectionMode:L=Yi.Strict,connectionLineType:G=ci.Bezier,connectionLineStyle:k,connectionLineComponent:$,connectionLineContainerStyle:oe,deleteKeyCode:D="Backspace",selectionKeyCode:X="Shift",selectionOnDrag:ee=!1,selectionMode:se=Ko.Full,panActivationKeyCode:ae="Space",multiSelectionKeyCode:pe=Pl()?"Meta":"Control",zoomActivationKeyCode:ge=Pl()?"Meta":"Control",snapToGrid:Ae=!1,snapGrid:Oe=jM,onlyRenderVisibleElements:Ie=!1,selectNodesOnDrag:Me=!0,nodesDraggable:ke,nodesConnectable:He,nodesFocusable:ve,nodeOrigin:ye=CM,edgesFocusable:Ve,edgesUpdatable:ft,elementsSelectable:Qe,defaultViewport:We=RM,minZoom:$e=.5,maxZoom:Ke=2,translateExtent:yt=Dg,preventScrolling:et=!0,nodeExtent:Ge,defaultMarkerColor:wt="#b1b1b7",zoomOnScroll:Rt=!0,zoomOnPinch:Ft=!0,panOnScroll:tt=!1,panOnScrollSpeed:xt=.5,panOnScrollMode:lt=Ui.Free,zoomOnDoubleClick:mt=!0,panOnDrag:wn=!0,onPaneClick:bt,onPaneMouseEnter:Tt,onPaneMouseMove:xn,onPaneMouseLeave:Ln,onPaneScroll:ut,onPaneContextMenu:Yt,children:Qt,onEdgeContextMenu:At,onEdgeDoubleClick:mi,onEdgeMouseEnter:gi,onEdgeMouseMove:Ji,onEdgeMouseLeave:tr,onEdgeUpdate:Pr,onEdgeUpdateStart:vi,onEdgeUpdateEnd:fr,onReconnect:Or,onReconnectStart:nr,onReconnectEnd:qt,reconnectRadius:$n=10,edgeUpdaterRadius:pn=10,onNodesChange:qr,onEdgesChange:zt,noDragClassName:yi="nodrag",noWheelClassName:wi="nowheel",noPanClassName:xi="nopan",fitView:Zt=!1,fitViewOptions:Lr,connectOnClick:_n=!0,attributionPosition:es,proOptions:_i,defaultEdgeOptions:Si,elevateNodesOnSelect:ts=!0,elevateEdgesOnSelect:$r=!1,disableKeyboardA11y:Dn=!1,autoPanOnConnect:ns=!0,autoPanOnNodeDrag:rt=!0,connectionRadius:rs=20,isValidConnection:Dr,onError:is,style:kt,id:Fr,nodeDragThreshold:Fn,...Sn},Bt)=>{const hr=Fr||"1";return le.createElement("div",{...Sn,style:{...kt,...TM},ref:Bt,className:Dt(["react-flow",o]),"data-testid":"rf__wrapper",id:Fr},le.createElement(QE,null,le.createElement(bM,{onInit:h,onMove:p,onMoveStart:m,onMoveEnd:y,onNodeClick:c,onEdgeClick:f,onNodeMouseEnter:E,onNodeMouseMove:N,onNodeMouseLeave:C,onNodeContextMenu:I,onNodeDoubleClick:O,nodeTypes:l,edgeTypes:u,connectionLineType:G,connectionLineStyle:k,connectionLineComponent:$,connectionLineContainerStyle:oe,selectionKeyCode:X,selectionOnDrag:ee,selectionMode:se,deleteKeyCode:D,multiSelectionKeyCode:pe,panActivationKeyCode:ae,zoomActivationKeyCode:ge,onlyRenderVisibleElements:Ie,selectNodesOnDrag:Me,defaultViewport:We,translateExtent:yt,minZoom:$e,maxZoom:Ke,preventScrolling:et,zoomOnScroll:Rt,zoomOnPinch:Ft,zoomOnDoubleClick:mt,panOnScroll:tt,panOnScrollSpeed:xt,panOnScrollMode:lt,panOnDrag:wn,onPaneClick:bt,onPaneMouseEnter:Tt,onPaneMouseMove:xn,onPaneMouseLeave:Ln,onPaneScroll:ut,onPaneContextMenu:Yt,onSelectionContextMenu:U,onSelectionStart:ne,onSelectionEnd:Y,onEdgeContextMenu:At,onEdgeDoubleClick:mi,onEdgeMouseEnter:gi,onEdgeMouseMove:Ji,onEdgeMouseLeave:tr,onReconnect:Or??Pr,onReconnectStart:nr??vi,onReconnectEnd:qt??fr,reconnectRadius:$n??pn,defaultMarkerColor:wt,noDragClassName:yi,noWheelClassName:wi,noPanClassName:xi,elevateEdgesOnSelect:$r,rfId:hr,disableKeyboardA11y:Dn,nodeOrigin:ye,nodeExtent:Ge}),le.createElement(wI,{nodes:e,edges:n,defaultNodes:i,defaultEdges:s,onConnect:w,onConnectStart:j,onConnectEnd:_,onClickConnectStart:S,onClickConnectEnd:b,nodesDraggable:ke,nodesConnectable:He,nodesFocusable:ve,edgesFocusable:Ve,edgesUpdatable:ft,elementsSelectable:Qe,elevateNodesOnSelect:ts,minZoom:$e,maxZoom:Ke,nodeExtent:Ge,onNodesChange:qr,onEdgesChange:zt,snapToGrid:Ae,snapGrid:Oe,connectionMode:L,translateExtent:yt,connectOnClick:_n,defaultEdgeOptions:Si,fitView:Zt,fitViewOptions:Lr,onNodesDelete:q,onEdgesDelete:B,onNodeDragStart:P,onNodeDrag:z,onNodeDragStop:T,onSelectionDrag:A,onSelectionDragStart:Q,onSelectionDragStop:H,noPanClassName:xi,nodeOrigin:ye,rfId:hr,autoPanOnConnect:ns,autoPanOnNodeDrag:rt,onError:is,connectionRadius:rs,isValidConnection:Dr,nodeDragThreshold:Fn}),le.createElement(vI,{onSelectionChange:Z}),Qt,le.createElement(VA,{proOptions:_i,position:es}),le.createElement(kI,{rfId:hr,disableKeyboardA11y:Dn})))});ZE.displayName="ReactFlow";const AM=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function JE(){return Xe(AM,Ct)}const eN=({id:e,x:n,y:i,width:s,height:o,style:l,color:u,strokeColor:c,strokeWidth:f,className:h,borderRadius:p,shapeRendering:m,onClick:y,selected:w})=>{const{background:j,backgroundColor:_}=l||{},S=u||j||_;return le.createElement("rect",{className:Dt(["react-flow__minimap-node",{selected:w},h]),x:n,y:i,rx:p,ry:p,width:s,height:o,fill:S,stroke:c,strokeWidth:f,shapeRendering:m,onClick:y?b=>y(b,e):void 0})};eN.displayName="MiniMapNode";var IM=M.memo(eN);const MM=e=>e.nodeOrigin,PM=e=>e.getNodes().filter(n=>!n.hidden&&n.width&&n.height),nd=e=>e instanceof Function?e:()=>e;function OM({nodeStrokeColor:e="transparent",nodeColor:n="#e2e2e2",nodeClassName:i="",nodeBorderRadius:s=5,nodeStrokeWidth:o=2,nodeComponent:l=IM,onClick:u}){const c=Xe(PM,Ct),f=Xe(MM),h=nd(n),p=nd(e),m=nd(i),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return le.createElement(le.Fragment,null,c.map(w=>{const{x:j,y:_}=Vi(w,f).positionAbsolute;return le.createElement(l,{key:w.id,x:j,y:_,width:w.width,height:w.height,style:w.style,selected:w.selected,className:m(w),color:h(w),borderRadius:s,strokeColor:p(w),strokeWidth:o,shapeRendering:y,onClick:u,id:w.id})}))}var qM=M.memo(OM);const LM=200,$M=150,DM=e=>{const n=e.getNodes(),i={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:i,boundingRect:n.length>0?YA(Wl(n,e.nodeOrigin),i):i,rfId:e.rfId}},FM="react-flow__minimap-desc";function tN({style:e,className:n,nodeStrokeColor:i="transparent",nodeColor:s="#e2e2e2",nodeClassName:o="",nodeBorderRadius:l=5,nodeStrokeWidth:u=2,nodeComponent:c,maskColor:f="rgb(240, 240, 240, 0.6)",maskStrokeColor:h="none",maskStrokeWidth:p=1,position:m="bottom-right",onClick:y,onNodeClick:w,pannable:j=!1,zoomable:_=!1,ariaLabel:S="React Flow mini map",inversePan:b=!1,zoomStep:E=10,offsetScale:N=5}){const C=jt(),I=M.useRef(null),{boundingRect:O,viewBB:P,rfId:z}=Xe(DM,Ct),T=(e==null?void 0:e.width)??LM,q=(e==null?void 0:e.height)??$M,B=O.width/T,Z=O.height/q,Q=Math.max(B,Z),A=Q*T,H=Q*q,U=N*Q,ne=O.x-(A-O.width)/2-U,Y=O.y-(H-O.height)/2-U,L=A+U*2,G=H+U*2,k=`${FM}-${z}`,$=M.useRef(0);$.current=Q,M.useEffect(()=>{if(I.current){const X=Mn(I.current),ee=pe=>{const{transform:ge,d3Selection:Ae,d3Zoom:Oe}=C.getState();if(pe.sourceEvent.type!=="wheel"||!Ae||!Oe)return;const Ie=-pe.sourceEvent.deltaY*(pe.sourceEvent.deltaMode===1?.05:pe.sourceEvent.deltaMode?1:.002)*E,Me=ge[2]*Math.pow(2,Ie);Oe.scaleTo(Ae,Me)},se=pe=>{const{transform:ge,d3Selection:Ae,d3Zoom:Oe,translateExtent:Ie,width:Me,height:ke}=C.getState();if(pe.sourceEvent.type!=="mousemove"||!Ae||!Oe)return;const He=$.current*Math.max(1,ge[2])*(b?-1:1),ve={x:ge[0]-pe.sourceEvent.movementX*He,y:ge[1]-pe.sourceEvent.movementY*He},ye=[[0,0],[Me,ke]],Ve=Rr.translate(ve.x,ve.y).scale(ge[2]),ft=Oe.constrain()(Ve,ye,Ie);Oe.transform(Ae,ft)},ae=uE().on("zoom",j?se:null).on("zoom.wheel",_?ee:null);return X.call(ae),()=>{X.on("zoom",null)}}},[j,_,b,E]);const oe=y?X=>{const ee=Kn(X);y(X,{x:ee[0],y:ee[1]})}:void 0,D=w?(X,ee)=>{const se=C.getState().nodeInternals.get(ee);w(X,se)}:void 0;return le.createElement(Jg,{position:m,style:e,className:Dt(["react-flow__minimap",n]),"data-testid":"rf__minimap"},le.createElement("svg",{width:T,height:q,viewBox:`${ne} ${Y} ${L} ${G}`,role:"img","aria-labelledby":k,ref:I,onClick:oe},S&&le.createElement("title",{id:k},S),le.createElement(qM,{onClick:D,nodeColor:s,nodeStrokeColor:i,nodeBorderRadius:l,nodeClassName:o,nodeStrokeWidth:u,nodeComponent:c}),le.createElement("path",{className:"react-flow__minimap-mask",d:`M${ne-U},${Y-U}h${L+U*2}v${G+U*2}h${-L-U*2}z
57
57
  M${P.x},${P.y}h${P.width}v${P.height}h${-P.width}z`,fill:f,fillRule:"evenodd",stroke:h,strokeWidth:p,pointerEvents:"none"})))}tN.displayName="MiniMap";var zM=M.memo(tN);function BM(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},le.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function UM(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},le.createElement("path",{d:"M0 0h32v4.2H0z"}))}function HM(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},le.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function VM(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},le.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function WM(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},le.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const Os=({children:e,className:n,...i})=>le.createElement("button",{type:"button",className:Dt(["react-flow__controls-button",n]),...i},e);Os.displayName="ControlButton";const GM=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),nN=({style:e,showZoom:n=!0,showFitView:i=!0,showInteractive:s=!0,fitViewOptions:o,onZoomIn:l,onZoomOut:u,onFitView:c,onInteractiveChange:f,className:h,children:p,position:m="bottom-left"})=>{const y=jt(),[w,j]=M.useState(!1),{isInteractive:_,minZoomReached:S,maxZoomReached:b}=Xe(GM,Ct),{zoomIn:E,zoomOut:N,fitView:C}=ta();if(M.useEffect(()=>{j(!0)},[]),!w)return null;const I=()=>{E(),l==null||l()},O=()=>{N(),u==null||u()},P=()=>{C(o),c==null||c()},z=()=>{y.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),f==null||f(!_)};return le.createElement(Jg,{className:Dt(["react-flow__controls",h]),position:m,style:e,"data-testid":"rf__controls"},n&&le.createElement(le.Fragment,null,le.createElement(Os,{onClick:I,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:b},le.createElement(BM,null)),le.createElement(Os,{onClick:O,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:S},le.createElement(UM,null))),i&&le.createElement(Os,{className:"react-flow__controls-fitview",onClick:P,title:"fit view","aria-label":"fit view"},le.createElement(HM,null)),s&&le.createElement(Os,{className:"react-flow__controls-interactive",onClick:z,title:"toggle interactivity","aria-label":"toggle interactivity"},_?le.createElement(WM,null):le.createElement(VM,null)),p)};nN.displayName="Controls";var YM=M.memo(nN),Qn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Qn||(Qn={}));function KM({color:e,dimensions:n,lineWidth:i}){return le.createElement("path",{stroke:e,strokeWidth:i,d:`M${n[0]/2} 0 V${n[1]} M0 ${n[1]/2} H${n[0]}`})}function XM({color:e,radius:n}){return le.createElement("circle",{cx:n,cy:n,r:n,fill:e})}const QM={[Qn.Dots]:"#91919a",[Qn.Lines]:"#eee",[Qn.Cross]:"#e2e2e2"},ZM={[Qn.Dots]:1,[Qn.Lines]:1,[Qn.Cross]:6},JM=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function rN({id:e,variant:n=Qn.Dots,gap:i=20,size:s,lineWidth:o=1,offset:l=2,color:u,style:c,className:f}){const h=M.useRef(null),{transform:p,patternId:m}=Xe(JM,Ct),y=u||QM[n],w=s||ZM[n],j=n===Qn.Dots,_=n===Qn.Cross,S=Array.isArray(i)?i:[i,i],b=[S[0]*p[2]||1,S[1]*p[2]||1],E=w*p[2],N=_?[E,E]:b,C=j?[E/l,E/l]:[N[0]/l,N[1]/l];return le.createElement("svg",{className:Dt(["react-flow__background",f]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:h,"data-testid":"rf__background"},le.createElement("pattern",{id:m+e,x:p[0]%b[0],y:p[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`},j?le.createElement(XM,{color:y,radius:E/l}):le.createElement(KM,{dimensions:N,color:y,lineWidth:o})),le.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${m+e})`}))}rN.displayName="Background";var eP=M.memo(rN);function iN(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function sN(e,n=0){if(!e||typeof e!="object"||n>6)return null;const i=e;if(typeof i.input_tokens=="number"||typeof i.output_tokens=="number"||typeof i.cache_read_input_tokens=="number"||typeof i.cache_creation_input_tokens=="number")return{inputTokens:Number(i.input_tokens??0),outputTokens:Number(i.output_tokens??0),cacheReadTokens:Number(i.cache_read_input_tokens??0),cacheCreateTokens:Number(i.cache_creation_input_tokens??0)};for(const s of Object.values(i)){const o=sN(s,n+1);if(o)return o}return null}function tP(e,n){e.inputTokens+=n.inputTokens,e.outputTokens+=n.outputTokens,e.cacheReadTokens+=n.cacheReadTokens,e.cacheCreateTokens+=n.cacheCreateTokens}const nP=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i;function oN(e,n=0){if(!e||typeof e!="object"||n>6)return null;const i=e;if(typeof i.model=="string"&&nP.test(i.model))return i.model;for(const s of Object.values(i)){const o=oN(s,n+1);if(o)return o}return null}function Fg(){return{agents:new Map,toolIndex:new Map,toolOwner:new Map,activeSubagentStack:new Map,lastSeq:0,totalEvents:0}}function fi(e){if(!e)return;const n=e.replace(/\\/g,"/").split("/").filter(Boolean);return n[n.length-1]}function cv(e,n){return`${e}::${n}`}function Ll(e){return e.agent_type??e.subagent_type??"subagent"}function zg(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function Bo(e,n,i,s){const o=n;let l=e.agents.get(o);return l||(l={id:o,sessionId:n,label:"session",kind:"root",state:"active",startedAt:i,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:s,inFlightTool:null,usage:iN()},e.agents.set(o,l),l)}function aN(e,n,i,s){const o=cv(n,i),l=e.agents.get(o);if(!l)return null;!l.cwd&&s.cwd&&(l.cwd=s.cwd,l.cwdBasename=fi(s.cwd));const u=Ll(s);return u&&(l.label==="subagent"||!l.label)&&(l.label=u),l}function Ww(e,n,i){const s=n.session_id??"unknown",o=zg(n);if(o){const f=aN(e,s,o,n);if(f)return f}const l=e.activeSubagentStack.get(s),u=l&&l.length>0?l[l.length-1]:null;if(u){const f=e.agents.get(cv(s,u));if(f)return!f.cwd&&n.cwd&&(f.cwd=n.cwd,f.cwdBasename=fi(n.cwd)),f}const c=Bo(e,s,i,!1);return c.synthetic&&(c.synthetic=!1,c.startedAt=i),!c.cwd&&n.cwd&&(c.cwd=n.cwd,c.cwdBasename=fi(n.cwd)),c.label==="session"&&n.cwd&&(c.label=fi(n.cwd)??"session"),c}function rP(e,n,i,s,o){const l=cv(n,i),u=Bo(e,n,o,!0);let c=e.agents.get(l);if(c){!c.cwd&&s.cwd&&(c.cwd=s.cwd,c.cwdBasename=fi(s.cwd));const f=Ll(s);return f&&(c.label==="subagent"||!c.label)&&(c.label=f),c}return c={id:l,sessionId:n,label:Ll(s),kind:"subagent",parentId:u.id,state:"active",startedAt:o,tools:[],prompts:[],cwd:s.cwd,cwdBasename:fi(s.cwd),toolCount:0,childCount:0,inFlightTool:null,usage:iN()},e.agents.set(l,c),u.childCount+=1,c}function iP(e,n,i){const s=e.activeSubagentStack.get(n)??[];s.push(i),e.activeSubagentStack.set(n,s)}function sP(e,n,i){const s=e.activeSubagentStack.get(n);if(s){for(let o=s.length-1;o>=0;o--)if(s[o]===i){s.splice(o,1);break}s.length===0&&e.activeSubagentStack.delete(n)}}function rd(e,n=80){if(e==null)return"";if(typeof e=="string")return e.length>n?e.slice(0,n-1)+"…":e;try{const i=JSON.stringify(e);return i.length>n?i.slice(0,n-1)+"…":i}catch{return String(e)}}function $o(e){let n=null;for(let i=e.tools.length-1;i>=0;i--){const s=e.tools[i];if(s.endedAt==null){n=s;break}}e.inFlightTool=n}function oP(e,n,i,s){if(e.agents.size<=i)return!1;const o=[];for(const[u,c]of e.agents)c.state==="done"&&c.endedAt!=null&&n-c.endedAt>s&&o.push({id:u,endedAt:c.endedAt});if(o.length===0)return!1;o.sort((u,c)=>u.endedAt-c.endedAt);let l=0;for(const u of o){if(e.agents.size<=i)break;e.agents.delete(u.id),l++}return l>0}function aP(e,n,i,s){const o=new Map;for(const[h,p]of e.agents){let m=o.get(p.sessionId);m||(m={ids:[],endedAt:0,live:!1},o.set(p.sessionId,m)),m.ids.push(h),p.state==="done"&&p.endedAt!=null?m.endedAt=Math.max(m.endedAt,p.endedAt):m.live=!0}const l=[...o.values()].filter(h=>!h.live&&h.endedAt>0&&n-h.endedAt>s).sort((h,p)=>h.endedAt-p.endedAt);let c=[...o.values()].filter(h=>!h.live).length-i;if(c<=0)return!1;let f=!1;for(const h of l){if(c<=0)break;for(const p of h.ids)e.agents.delete(p);c--,f=!0}return f}function lP(e,n,i){let s=!1;for(const o of e.agents.values()){let l=!1;for(const u of o.tools)u.endedAt==null&&n-u.startedAt>i&&(u.endedAt=u.startedAt+i,u.ok=!1,u.errorPreview="stale (no PostToolUse received)",e.toolIndex.delete(u.id),e.toolOwner.delete(u.id),l=!0,s=!0);l&&$o(o)}return s}function Gw(e,n){if(n.seq<=e.lastSeq)return e;const i=n.payload??{},s=n.receivedAt,o=i.hook_event_name??"Unknown";if(o==="__clear")return{...Fg(),lastSeq:n.seq};e.totalEvents+=1,e.lastSeq=n.seq;const l=i.session_id??"unknown";if(o==="ModelObserved"){const f=typeof i.model=="string"?i.model:null;if(f){const p=e.agents.get(l);p&&(p.model=f)}const h=i.subagentModels;if(h&&typeof h=="object")for(const[p,m]of Object.entries(h)){if(typeof m!="string")continue;const y=`${l}::${p}`,w=e.agents.get(y);w&&(w.model=m)}return e}if(o==="ContextObserved"){const f=i.context??null;if(f){const h=e.agents.get(l);h&&(h.context={msgsUser:Number(f.msgsUser??0),msgsAssistant:Number(f.msgsAssistant??0),toolUses:Number(f.toolUses??0),toolResults:Number(f.toolResults??0),systemReminders:Number(f.systemReminders??0),currentContextTokens:Number(f.currentContextTokens??0),claudeMdFiles:Array.isArray(f.claudeMdFiles)?f.claudeMdFiles:[]})}return e}if(o==="UsageObserved"){const f=i.usage??null;if(f){const h=e.agents.get(l);h&&(h.usage.inputTokens=Number(f.input_tokens??0),h.usage.outputTokens=Number(f.output_tokens??0),h.usage.cacheReadTokens=Number(f.cache_read_input_tokens??f.cached_input_tokens??0),h.usage.cacheCreateTokens=Number(f.cache_creation_input_tokens??0),typeof f.reasoning_output_tokens=="number"&&(h.usage.reasoningOutputTokens=Number(f.reasoning_output_tokens)))}return e}const u=Ww(e,i,s);u.provider||(u.provider=i.provider==="codex"?"codex":"claude"),typeof i.model_context_window=="number"&&i.model_context_window>0&&(u.contextWindow=i.model_context_window);const c=oN(i);switch(c&&(u.model=c),o){case"SessionStart":{const f=Bo(e,l,s,!1);f.synthetic=!1,f.state="active",f.startedAt=f.startedAt||s,!f.cwd&&i.cwd&&(f.cwd=i.cwd,f.cwdBasename=fi(i.cwd)),f.label==="session"&&i.cwd&&(f.label=fi(i.cwd)??"session");break}case"UserPromptSubmit":{for(const m of e.agents.values())m.sessionId===l&&m.kind==="subagent"&&m.state==="done"&&m.exitAt==null&&m.endedAt!=null&&m.endedAt<s&&(m.exitAt=s);const f=Bo(e,l,s,!1);f.state="active",f.endedAt=void 0,f.exitAt=void 0;const h=Ww(e,i,s);h.state="active",h.exitAt=void 0,h.endedAt=void 0;const p=(typeof i.prompt=="string"?i.prompt:typeof i.message=="string"?i.message:"")??"";p&&(h.prompts.push({at:s,text:p}),h.firstPrompt||(h.firstPrompt=rd(p,120)));break}case"PreToolUse":{const f=i.tool_use_id??`${u.id}:${u.toolCount}`,h={id:f,name:i.tool_name??"?",input:i.tool_input,inputPreview:rd(i.tool_input),agentId:u.id,startedAt:s};u.tools.push(h),u.toolCount+=1,u.state="active",e.toolIndex.set(f,h),e.toolOwner.set(f,u.id),$o(u);break}case"PostToolUse":case"PostToolUseFailure":{const f=i.tool_use_id;if(!f)break;let h=e.toolIndex.get(f),p=!1;if(!h)for(const w of e.agents.values()){const j=w.tools.find(_=>_.id===f);if(j){h=j,p=!0;break}}if(!h)break;h.endedAt=s,h.ok=o==="PostToolUse",h.response=i.tool_response,o==="PostToolUseFailure"?h.errorPreview=rd(i.tool_response):p&&(h.errorPreview=void 0);const m=sN(i.tool_response);m&&(h.usage=m),e.toolIndex.delete(f);const y=e.toolOwner.get(f)??h.agentId;if(e.toolOwner.delete(f),y){const w=e.agents.get(y);w&&(m&&tP(w.usage,m),$o(w))}break}case"SubagentStart":{const f=zg(i);if(!f)break;const h=rP(e,l,f,i,s);h.state="active",h.startedAt=h.startedAt||s,h.exitAt=void 0,h.endedAt=void 0;const p=Ll(i);p&&(h.label=p),iP(e,l,f);break}case"SubagentStop":{const f=zg(i);if(!f)break;const h=aN(e,l,f,i);if(!h)break;h.state="done",h.endedAt=s,$o(h),sP(e,l,f);break}case"Stop":case"SessionEnd":{const f=Bo(e,l,s,!1);f.state="done",f.endedAt=s,$o(f);break}}return e}function dv(e){let n=5381;for(let i=0;i<e.length;i++)n=(n<<5)+n^e.charCodeAt(i);return Math.abs(n)%360}const uP=Date.UTC(2026,8,1);function cP(){return Date.now()<uP?{input:2,output:10,cacheRead:.2,cacheWrite:2.5}:{input:3,output:15,cacheRead:.3,cacheWrite:3.75}}const dP=[{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:cP()},{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 fP(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function fv(e){if(!e)return null;for(const n of dP)if(n.match.test(e))return n.rates;return null}const hP=272e3,pP=/^gpt[-_]5[-_.](?:6(?![-_]cyber)|5|4)/i;function mP(e,n){return!e||n<=hP?{input:1,output:1}:pP.test(e)?{input:2,output:1.5}:{input:1,output:1}}function fn(e,n){const i=fv(n);if(!i)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const s=fP(n),o=s?Math.max(0,e.inputTokens-e.cacheReadTokens):e.inputTokens,l=s?mP(n,e.inputTokens):{input:1,output:1},u=o*i.input*l.input/1e6,c=e.outputTokens*i.output*l.output/1e6,f=e.cacheReadTokens*i.cacheRead*l.input/1e6,h=e.cacheCreateTokens*i.cacheWrite*l.input/1e6;return{input:u,output:c,cacheRead:f,cacheWrite:h,total:u+c+f+h}}const Yw=2e5,gP=1e6,vP=[/\[1m\]/i,/^claude[-_]opus[-_]5\b/i,/^claude[-_]sonnet[-_]5\b/i,/^claude[-_]opus[-_]4[-_.](?:5|6|7|8)\b/i,/^claude[-_]sonnet[-_]4[-_.]6\b/i,/^claude[-_](fable|mythos)[-_]5\b/i],yP=[{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 lN(e){if(!e)return Yw;for(const n of vP)if(n.test(e))return gP;for(const n of yP)if(n.match.test(e))return n.window;return Yw}function Fe(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 $l(e,n){if(e<=0||n<10)return null;const i=e/n,s=i*60;return s>=.01?`${Fe(s)}/min`:`${Fe(i*3600)}/hr`}function In(e){return e.toLocaleString()}function wP(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function xP({agent:e,onClose:n}){var h;const i=e.context,s=e.usage,o=(i==null?void 0:i.currentContextTokens)??0,l=lN(e.model),u=Math.min(100,o/l*100),c=fn(s,e.model),f=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:p=>p.stopPropagation(),role:"dialog","aria-label":"Context breakdown",children:[g.jsxs("header",{className:"ctx-modal-head",children:[g.jsxs("div",{children:[g.jsxs("div",{className:"ctx-modal-title",children:["Context · ",e.label]}),g.jsx("div",{className:"ctx-modal-sub",children:"approximation — CC's /context isn't hook-exposed"})]}),g.jsx("button",{className:"ctx-modal-close",onClick:n,"aria-label":"Close",children:"×"})]}),g.jsxs("section",{className:"ctx-window-row",children:[g.jsx("div",{className:"ctx-window-bar",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(u),children:g.jsx("div",{className:"ctx-window-fill",style:{width:`${u}%`}})}),g.jsxs("div",{className:"ctx-window-meta",children:[g.jsxs("span",{className:"ctx-window-pct",children:[u.toFixed(1),"%"]}),g.jsxs("span",{className:"ctx-window-num",children:[In(o)," / ",In(l)," tok (current turn)"]})]})]}),g.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),g.jsxs("div",{className:"ctx-grid",children:[g.jsx(Yn,{label:"input tokens",val:In(s.inputTokens)}),g.jsx(Yn,{label:"output tokens",val:In(s.outputTokens)}),g.jsx(Yn,{label:"cache reads",val:In(s.cacheReadTokens)}),g.jsx(Yn,{label:"cache writes",val:In(s.cacheCreateTokens)}),g.jsx(Yn,{label:"cumulative total",val:In(f)}),g.jsx(Yn,{label:"estimated cost",val:Fe(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:In((i==null?void 0:i.msgsUser)??0)}),g.jsx(Yn,{label:"assistant messages",val:In((i==null?void 0:i.msgsAssistant)??0)}),g.jsx(Yn,{label:"tool uses",val:In((i==null?void 0:i.toolUses)??0)}),g.jsx(Yn,{label:"tool results",val:In((i==null?void 0:i.toolResults)??0)}),g.jsx(Yn,{label:"system-reminders",val:In((i==null?void 0:i.systemReminders)??0)})]}),g.jsx("h3",{className:"ctx-section-title",children:"CLAUDE.md files in scope"}),(((h=i==null?void 0:i.claudeMdFiles)==null?void 0:h.length)??0)===0?g.jsx("div",{className:"ctx-empty",children:"No CLAUDE.md files found on the path from cwd to ~/.claude."}):g.jsx("ul",{className:"ctx-md-list",children:i.claudeMdFiles.map(p=>g.jsxs("li",{children:[g.jsx("span",{className:"ctx-md-path",title:p.path,children:p.path}),g.jsx("span",{className:"ctx-md-size",children:wP(p.bytes)})]},p.path))})]})})}function Yn({label:e,val:n,accent:i}){return g.jsxs("div",{className:`ctx-row${i?" accent":""}`,children:[g.jsx("span",{className:"ctx-row-label",children:e}),g.jsx("span",{className:"ctx-row-val",children:n})]})}function _P({currentContextTokens:e,modelId:n,size:i=26,onClick:s,title:o}){const l=lN(n),u=Math.min(1,e/l),c=i/2-3,f=i/2,h=2*Math.PI*c,p=h*u,m=u>.9?"var(--err)":u>.7?"var(--inflight)":"var(--accent)";return g.jsx("button",{type:"button",className:"ctx-donut",onClick:s,title:o??`context: ${e.toLocaleString()} / ${l.toLocaleString()} (${(u*100).toFixed(1)}%)`,"aria-label":"Show context breakdown",children:g.jsxs("svg",{width:i,height:i,viewBox:`0 0 ${i} ${i}`,children:[g.jsx("circle",{cx:f,cy:f,r:c,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),g.jsx("circle",{cx:f,cy:f,r:c,stroke:m,strokeWidth:"2.5",fill:"none",strokeDasharray:`${p} ${h-p}`,strokeDashoffset:h/4,strokeLinecap:"round",style:{transition:"stroke-dasharray 400ms ease"}}),g.jsx("text",{x:f,y:f+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(u*100)})]})})}function SP(e,n){const i=fv(n);if(!i)return"no rates for this model";const s=u=>u.toLocaleString(),o=u=>`$${u}/MTok`,l=fn(e,n);return[`model: ${n}`,`input ${s(e.inputTokens).padStart(14)} × ${o(i.input).padEnd(11)} = ${Fe(l.input)}`,`output ${s(e.outputTokens).padStart(14)} × ${o(i.output).padEnd(11)} = ${Fe(l.output)}`,`cache r ${s(e.cacheReadTokens).padStart(14)} × ${o(i.cacheRead).padEnd(11)} = ${Fe(l.cacheRead)}`,`cache w ${s(e.cacheCreateTokens).padStart(14)} × ${o(i.cacheWrite).padEnd(11)} = ${Fe(l.cacheWrite)}`,"─────────────────────────────────────────",`total = ${Fe(l.total)}`].join(`
58
58
  `)}function bP(e,n,i){const s=(n??i)-e;if(s<1e3)return`${Math.max(0,s)}ms`;const o=Math.floor(s/1e3);if(o<60)return`${o}s`;const l=Math.floor(o/60),u=o%60;return`${l}m ${String(u).padStart(2,"0")}s`}function kP({data:e,selected:n}){var h;const i=e.now??Date.now(),s=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":"",n?"selected":""].filter(Boolean).join(" "),o=e.tools.filter(p=>!p.endedAt).length,u=`hsl(${dv(e.sessionId)} 70% 60%)`,c=((h=e.context)==null?void 0:h.currentContextTokens)??0,f=e.kind==="root"&&c>0;return g.jsxs("div",{className:s,style:{"--accent":u},children:[g.jsx("span",{className:"accent-stripe"}),g.jsx(Us,{type:"target",position:Ce.Left,style:{background:"transparent",border:"none"}}),g.jsxs("div",{className:"head",children:[g.jsxs("div",{className:"title",children:[g.jsx(EP,{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:[f&&e.onOpenContext&&g.jsx(_P,{currentContextTokens:c,modelId:e.model,onClick:()=>e.onOpenContext(e.sessionId)}),g.jsx("div",{className:"time",title:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:bP(e.startedAt,e.endedAt,i)})]})]}),g.jsxs("div",{className:"sub",children:[e.kind==="root"?"session":"subagent",e.childCount>0&&g.jsxs("span",{className:"spawn-badge",title:`${e.childCount} subagents spawned`,children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model&&g.jsx("span",{className:"model-chip",title:e.model,children:na(e.model)})]}),e.tools.length>0&&g.jsx(CP,{tools:e.tools,now:i}),g.jsxs("div",{className:"meta",children:[g.jsxs("span",{children:[g.jsx("b",{children:e.toolCount})," tools"]}),o>0&&g.jsxs("span",{className:"inflight-meta",children:[g.jsx("b",{children:o})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&g.jsxs("span",{className:"tokens-meta",title:`in:${e.usage.inputTokens} out:${e.usage.outputTokens} cache-r:${e.usage.cacheReadTokens} cache-c:${e.usage.cacheCreateTokens}${(e.usage.reasoningOutputTokens??0)>0?` reasoning:${e.usage.reasoningOutputTokens}`:""}`,children:[g.jsx("b",{children:NP(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),e.model&&fv(e.model)&&(()=>{const p=fn(e.usage,e.model);if(p.total<=0)return null;const m=Math.max(0,((e.endedAt??i)-e.startedAt)/1e3),y=e.state==="active"?$l(p.total,m):null,w=SP(e.usage,e.model)+(y?`
59
- burn: ${y}`:"");return g.jsxs("span",{className:"cost-meta",title:w,children:[g.jsx("b",{children:Fe(p.total)}),y&&g.jsx("span",{className:"cost-rate",children:y})]})})()]}),g.jsx(Us,{type:"source",position:Ce.Right,style:{background:"transparent",border:"none"}})]})}function EP({state:e}){const n=e==="active"?"live":e==="done"?"done":"err";return g.jsx("span",{className:`state-pill state-${e}`,children:n})}function NP(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function CP({tools:e,now:n}){const l=new Array(24).fill(0);let u=0;for(const y of e){const w=n-y.startedAt;if(w<0||w>=6e4)continue;const j=23-Math.floor(w/2500);j>=0&&j<24&&(l[j]+=1,u+=1)}const c=Math.max(1,...l),f=132,h=14,p=f/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:f,height:h,viewBox:`0 0 ${f} ${h}`,"aria-hidden":!0,children:l.map((y,w)=>{const j=y===0?1.5:Math.max(1.5,y/c*h),_=w===23&&y>0,b=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return g.jsx("rect",{x:w*p+.4,y:h-j,width:Math.max(.5,p-1),height:j,rx:.8,className:b},w)})}),g.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function na(e){const n=e.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const o=n[1][0].toUpperCase()+n[1].slice(1).toLowerCase(),l=n[2].replace(/[-_]/g,".");return`${o} ${l}`}const i=e.match(/^gpt[-_](\d+(?:[-_.]\d+)*)[-_]codex\b/i);if(i)return`GPT-${i[1].replace(/[-_]/g,".")} Codex`;const s=e.match(/^gpt[-_](\d+(?:[-_.]\d+)*)/i);return s?`GPT-${s[1].replace(/[-_]/g,".")}`:e}function Kw(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function jP(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 RP({tool:e,onClose:n}){M.useEffect(()=>{const s=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]);const i=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return g.jsx("div",{className:"modal-backdrop",onClick:n,role:"dialog","aria-modal":"true",children:g.jsxs("div",{className:"modal",onClick:s=>s.stopPropagation(),children:[g.jsxs("header",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:`status-dot ${i}`}),g.jsx("span",{className:"modal-tool-name",children:e.name}),g.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",children:jP(e)}),g.jsx("button",{className:"btn icon-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),g.jsxs("section",{className:"modal-body",children:[g.jsxs("div",{className:"modal-section",children:[g.jsx("h4",{children:"Input"}),g.jsx("pre",{children:Kw(e.input??e.inputPreview)})]}),g.jsxs("div",{className:"modal-section",children:[g.jsxs("h4",{children:["Response ",i==="err"&&g.jsx("span",{className:"err-tag",children:"error"})]}),g.jsx("pre",{children:e.endedAt==null?"(waiting…)":Kw(e.response??e.errorPreview)})]})]})]})})}const yl=18,Xw=26,TP=12;function AP(e){const n=new Map;for(const o of e.nodeInternals.values()){const l=o.data;if(!(l!=null&&l.sessionId)||l.exitAt!=null||o.width==null||o.height==null)continue;const u=o.position.x,c=o.position.y,f=u+o.width,h=c+o.height,p=n.get(l.sessionId);p?(p.minX=Math.min(p.minX,u),p.minY=Math.min(p.minY,c),p.maxX=Math.max(p.maxX,f),p.maxY=Math.max(p.maxY,h),l.kind==="root"&&(p.label=Qw(l)??p.label)):n.set(l.sessionId,{minX:u,minY:c,maxX:f,maxY:h,label:Qw(l)??l.sessionId})}const i=new Map;for(const o of n.values())i.set(o.label,(i.get(o.label)??0)+1);const s=[];for(const[o,l]of n){const c=(i.get(l.label)??0)>1?`${l.label} · ${IP(o)}`:l.label;s.push({sessionId:o,label:c,x:l.minX-yl,y:l.minY-yl-Xw,w:l.maxX-l.minX+yl*2,h:l.maxY-l.minY+yl*2+Xw})}return s}function IP(e){const n=e.match(/[a-zA-Z0-9]{4}/);return n?n[0]:e.slice(0,4)}function Qw(e){if(e.kind==="root")return e.label}function MP(){const{x:e,y:n,zoom:i}=JE(),s=ta(),o=Xe(AP,PP);if(o.length<=1)return null;const l=u=>{try{const c=s.getNodes().filter(f=>{const h=f.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=dv(u.sessionId),f={position:"absolute",left:u.x*i+e,top:u.y*i+n,width:u.w*i,height:u.h*i,borderColor:`hsl(${c} 65% 55% / 0.32)`,background:`hsl(${c} 70% 50% / 0.04)`},h={position:"absolute",left:u.x*i+e+16*i,top:(u.y-TP)*i+n,color:`hsl(${c} 70% 78%)`,borderColor:`hsl(${c} 65% 55% / 0.5)`,transform:`scale(${Math.min(1,i)})`,transformOrigin:"left top"};return g.jsxs(le.Fragment,{children:[g.jsx("div",{className:"cluster-card",style:f,"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 PP(e,n){if(e.length!==n.length)return!1;for(let i=0;i<e.length;i++){const s=e[i],o=n[i];if(s.sessionId!==o.sessionId||s.label!==o.label||s.x!==o.x||s.y!==o.y||s.w!==o.w||s.h!==o.h)return!1}return!0}function OP({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 uN=600,qP=36,Bg=16,LP=60,$P=6,Zw=220,Jw=96,DP=28,FP={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 zP(e){return e.startsWith("mcp__")?"mcp":FP[e]??"other"}const BP={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 ex(e){return e.startsWith("mcp__")?"🔌":BP[e]??"✨"}const UP={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 cN(e){if(!e)return null;let n=e.trim();if(!n)return null;const i=n.match(/^(?:bash|sh|zsh|fish|powershell|pwsh)(?:\.exe)?\s+(?:-c|-Command|-NoProfile|-NonInteractive|\s)+["']([^"']+)["']/i);if(i)return cN(i[1]);for(;;){const l=n.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!l)break;n=n.slice(l[0].length)}n=n.replace(/^sudo(?:\s+-\S+)*\s+/,""),n=n.replace(/^(?:time|nohup|xargs)\s+/,"");const s=n.match(/^([^\s|;&<>(]+)/);if(!s)return null;let o=s[1];return o=o.replace(/^.*[/\\]/,""),o=o.replace(/\.(exe|cmd|bat|ps1)$/i,""),o||null}function HP(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const n=e;if(typeof n.cmd=="string")return n.cmd;if(typeof n.command=="string")return n.command;if(Array.isArray(n.command)&&n.command.every(i=>typeof i=="string")){const i=n.command;if(/powershell|cmd|bash|sh(\.exe)?$/i.test(i[0]??"")){const s=i.findIndex(o=>/^(-Command|-c)$/i.test(o));if(s>=0&&s+1<i.length)return i[s+1]}return i.join(" ")}return typeof n.script=="string"?n.script:null}const VP=new Set(["Bash","PowerShell","shell","exec_command","shell_command","write_stdin","wait"]),WP=new Set(["shell","exec_command","shell_command","write_stdin","wait","apply_patch","update_plan"]);function GP(e,n){return WP.has(e)?Math.max(Jw,34+n.length*7.5):Jw}function YP(e,n){if(!VP.has(e))return null;const i=HP(n);if(!i)return null;const s=cN(i);return s?{emoji:UP[s]??"⚙️",label:s,category:"shell",detail:i}:null}const KP=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),tx={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:"🗄️"},nx={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 XP(e){const i=e.replace(/\\/g,"/").replace(/\/+$/,""),s=i.lastIndexOf("/");return s>=0?i.slice(s+1):i}function QP(e){const n=e.toLowerCase();if(nx[n])return nx[n];if(n.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(n))return"🧪";const i=n.lastIndexOf(".");if(i>0&&i<n.length-1){const s=n.slice(i+1);if(tx[s])return tx[s]}return"📄"}function ZP(e,n){if(!n||typeof n!="object")return null;const i=n;if(e==="apply_patch"&&typeof i.patch=="string"){const s=i.patch.match(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/m);return s?s[1].trim():null}return typeof i.file_path=="string"?i.file_path:typeof i.notebook_path=="string"?i.notebook_path:typeof i.path=="string"?i.path:e==="Glob"&&typeof i.pattern=="string"?i.pattern:null}function JP(e,n){if(!KP.has(e))return null;const i=ZP(e,n);if(!i)return null;const s=XP(i);return s?{emoji:e==="LS"?"📂":QP(s),label:s,category:"file",detail:i}:null}const dN={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 fN(e){if(!e.startsWith("mcp__"))return null;const n=e.slice(5),i=n.indexOf("__");return i<=0?{server:n,method:""}:{server:n.slice(0,i),method:n.slice(i+2)}}function e3(e){let n=5381;for(let i=0;i<e.length;i++)n=(n<<5)+n^e.charCodeAt(i);return Math.abs(n)%360}function t3(e,n){const i=fN(e);if(!i)return null;const{server:s,method:o}=i;if(!o)return null;const l=dN[s.toLowerCase()];return{emoji:(l==null?void 0:l.emoji)??"🔌",label:o,category:"mcp",detail:l?`${l.name} · ${o}`:`${s} · ${o}`}}function n3(e,n){return YP(e,n)??JP(e,n)??t3(e)}const r3={shell:"Shell",exec_command:"Shell",shell_command:"Shell",write_stdin:"stdin",wait:"wait",apply_patch:"Edit",update_plan:"Plan"};function i3(e){const n=fN(e);if(n){const s=dN[n.server.toLowerCase()];return s?{emoji:s.emoji,label:s.name}:{emoji:"🔌",label:n.server,hue:e3(n.server)}}const i=r3[e];return i?{emoji:ex(e),label:i}:{emoji:ex(e),label:e}}function s3(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function o3(e,n,i){if(i==null)return 1;const s=n-i;return s<0?1:Math.max(0,1-s/uN)}function a3(e,n,i,s,o,l){const u=[];for(const c of e.values()){if(!n.has(c.id)||c.exitAt!=null&&l-c.exitAt>uN)continue;const f=s.get(c.id)??i.get(c.id);if(!f)continue;const h=c.tools.slice(-4);if(h.length===0)continue;const p=c.exitAt??null,m=o.get(c.id),y=Math.max((m==null?void 0:m.width)??Zw,Zw),w=(m==null?void 0:m.height)??130,j=f.x,_=f.y,S=j+y,b=_+w/2;h.forEach((E,N)=>{const C=N*qP,I=j+y+LP,O=_+$P+C,P=o3(E,l,p),z=E.inputPreview??"",T=s3(E),q=P<.999,B=i3(E.name);u.push({id:E.id,toolId:E.id,agentId:c.id,toolName:E.name,name:B.label,emoji:B.emoji,status:T,category:zP(E.name),mcpHue:B.hue,inputPreview:z,fade:P,fading:q,worldX:I,worldY:O,anchorX:S,anchorY:b,spawnDx:S-I,spawnDy:b-(O+Bg)});const Z=n3(E.name,E.input);if(Z){const Q=GP(E.name,B.label),A=I+Q+DP,H=O,U=I+Q,ne=O+Bg;u.push({id:`sub:${E.id}`,toolId:E.id,agentId:c.id,toolName:E.name,name:Z.label,emoji:Z.emoji,isSub:!0,status:T,category:Z.category,inputPreview:Z.detail??z,fade:P,fading:q,worldX:A,worldY:H,anchorX:U,anchorY:ne,spawnDx:U-A,spawnDy:0})}})}return u}function l3({agents:e,visibleAgentIds:n,positions:i,pinned:s,measured:o,dimUnmatched:l,spotlight:u,hiddenCategories:c,now:f,onOpenTool:h}){const{x:p,y:m,zoom:y}=JE(),w=a3(e,n,i,s,o,f),j=c&&c.size>0?w.filter(_=>!c.has(_.category)):w;return g.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[g.jsx("svg",{className:"tool-bursts-svg",children:j.map(_=>{const S=_.anchorX*y+p,b=_.anchorY*y+m,E=(_.worldX+6)*y+p,N=(_.worldY+Bg)*y+m,C=S+(E-S)*.55,I=l!=null&&!l.has(_.agentId),O=u!=null&&!u.has(_.agentId),P=_.fade*(I||O?.14:1);return g.jsx("path",{d:`M ${S} ${b} Q ${C} ${b}, ${E} ${N}`,className:`tool-conn status-${_.status}${_.fading?" fading":""}`,opacity:P},`l:${_.id}`)})}),j.map(_=>{const S=_.worldX*y+p,b=_.worldY*y+m,E={left:`${S}px`,top:`${b}px`,transform:`scale(${y})`,transformOrigin:"left top","--spawn-dx":`${_.spawnDx}px`,"--spawn-dy":`${_.spawnDy}px`},N=_.isSub?`${_.toolName} · ${_.name}`:_.toolName,C=_.inputPreview?`${N} · ${_.inputPreview}`:N,I=h!=null,O=_.mcpHue!=null?{"--cat-accent":`hsl(${_.mcpHue} 65% 65%)`}:{},P=l!=null&&!l.has(_.agentId),z=u!=null&&!u.has(_.agentId),T=P||z?" dim":"";return g.jsx("div",{className:"tool-burst-wrap",style:E,children:g.jsxs("div",{className:`tool-burst cat-${_.category} status-${_.status}${_.fading?" fading":""}${I?" clickable":""}${_.isSub?" sub":""}${T}`,style:O,title:C,role:I?"button":void 0,tabIndex:I?0:void 0,"aria-label":I?`Open ${_.toolName} ${_.status==="inflight"?"in flight":_.status} — click for details`:void 0,onClick:I?()=>h(_.toolId):void 0,onKeyDown:I?q=>{(q.key==="Enter"||q.key===" ")&&(q.preventDefault(),h(_.toolId))}:void 0,children:[g.jsx("span",{className:"tb-emoji",children:_.emoji}),g.jsx("span",{className:"tb-name",children:_.name}),_.status==="inflight"&&g.jsx("span",{className:"tb-spin"}),_.status==="done"&&g.jsx("span",{className:"tb-mark done",children:"✓"}),_.status==="err"&&g.jsx("span",{className:"tb-mark err",children:"×"})]})},_.id)})]})}function u3({state:e,sessionId:n,onClose:i}){const s=M.useMemo(()=>d3(e,n),[e,n]);return s?g.jsx("div",{className:"modal-backdrop",onClick:i,role:"presentation",children:g.jsxs("div",{className:"modal session-summary",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[g.jsxs("div",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),g.jsx("span",{id:"ss-title",className:"modal-tool-name",title:s.cwd??s.sessionId,children:s.label}),g.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.durationLabel}),g.jsx("button",{className:"btn",onClick:i,"aria-label":"Close",children:"×"})]})]}),g.jsxs("div",{className:"modal-body",children:[g.jsxs("section",{className:"ss-hero",children:[g.jsxs("div",{className:"ss-hero-left",children:[g.jsx("div",{className:"ss-cost-label",children:"total spend"}),g.jsx("div",{className:"ss-cost",children:Fe(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:na(o)},o))})]}),g.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&g.jsxs(g.Fragment,{children:[g.jsx(c3,{cost:s.cost}),g.jsxs("div",{className:"ss-cost-legend",children:[g.jsxs("span",{className:"ssl ssl-in",children:["input ",g.jsx("b",{children:Fe(s.cost.input)})]}),g.jsxs("span",{className:"ssl ssl-out",children:["output ",g.jsx("b",{children:Fe(s.cost.output)})]}),g.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",g.jsx("b",{children:Fe(s.cost.cacheRead)})]}),g.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",g.jsx("b",{children:Fe(s.cost.cacheWrite)})]})]})]})})]}),g.jsxs("section",{className:"ss-stats",children:[g.jsx(Ms,{label:"agents",value:s.agentCount}),g.jsx(Ms,{label:"subagents",value:s.subagentCount}),g.jsx(Ms,{label:"tool calls",value:s.toolCount}),g.jsx(Ms,{label:"prompts",value:s.promptCount}),g.jsx(Ms,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&g.jsx(Ms,{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 Ms({label:e,value:n,tone:i}){return g.jsxs("div",{className:`ss-stat${i?` tone-${i}`:""}`,children:[g.jsx("div",{className:"ss-stat-value",children:n}),g.jsx("div",{className:"ss-stat-label",children:e})]})}function c3({cost:e}){const n=e.total;if(n<=0)return null;const i=(s,o,l)=>{if(s<=0)return null;const u=s/n*100;return g.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${Fe(s)} (${u.toFixed(0)}%)`},o)};return g.jsxs("div",{className:"cost-bar cost-bar-lg","aria-label":"Cost breakdown",children:[i(e.input,"cb-input","input"),i(e.output,"cb-output","output"),i(e.cacheRead,"cb-cache-r","cache read"),i(e.cacheWrite,"cb-cache-w","cache write")]})}function d3(e,n){const i=e.agents.get(n);if(!i)return null;const s=[];for(const N of e.agents.values())N.sessionId===n&&s.push(N);if(s.length===0)return null;const o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},l=new Set,u=new Map;let c=0,f=0,h=0,p=0,m=0,y,w=1/0,j=0;for(const N of s){const C=fn(N.usage,N.model);o.input+=C.input,o.output+=C.output,o.cacheRead+=C.cacheRead,o.cacheWrite+=C.cacheWrite,o.total+=C.total,N.model&&l.add(N.model),N.kind==="subagent"&&m++,f+=N.prompts.length,!y&&N.prompts.length>0&&(y=N.prompts[0].text),h+=N.usage.inputTokens+N.usage.outputTokens,c+=N.tools.length,w=Math.min(w,N.startedAt),j=Math.max(j,N.endedAt??Date.now());for(const I of N.tools)u.set(I.name,(u.get(I.name)??0)+1),I.ok===!1&&p++}const _=Math.max(0,j-w),S=Math.floor(_/1e3),b=S<60?`${S}s`:S<3600?`${Math.floor(S/60)}m ${String(S%60).padStart(2,"0")}s`:`${Math.floor(S/3600)}h ${Math.floor(S%3600/60)}m`,E=Array.from(u.entries()).sort((N,C)=>C[1]-N[1]).slice(0,5);return{sessionId:n,label:i.label||i.cwdBasename||"session",cwd:i.cwd,durationLabel:b,cost:o,modelChips:Array.from(l),agentCount:s.length,subagentCount:m,toolCount:c,promptCount:f,tokensSum:h,errCount:p,topTools:E,firstPrompt:y}}function f3(e,n){const i=[];for(const s of e.agents.values()){if(s.kind!=="root")continue;let o=s.tools.length,l=fn(s.usage,s.model).total,u=s.endedAt??s.startedAt;for(const c of e.agents.values()){if(c.sessionId!==s.sessionId||c.kind==="root")continue;o+=c.tools.length,l+=fn(c.usage,c.model).total;const f=c.endedAt??c.startedAt;f>u&&(u=f)}i.push({sessionId:s.sessionId,label:s.label||s.cwdBasename||"session",cwdBasename:s.cwdBasename,state:s.state,modelId:s.model,toolCount:o,cost:l,startedAt:s.startedAt,lastActivity:u})}return i.sort((s,o)=>{if(s.state!==o.state){if(s.state==="active")return-1;if(o.state==="active")return 1}return o.lastActivity-s.lastActivity}),i}function h3(e,n,i){const s=(n??i)-e;if(s<1e3)return"<1s";const o=Math.floor(s/1e3);if(o<60)return`${o}s`;const l=Math.floor(o/60);return l<60?`${l}m`:`${Math.floor(l/60)}h ${l%60}m`}function p3({state:e,now:n,selectedIds:i,onSelect:s,onClose:o}){const l=M.useMemo(()=>f3(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 f=i.has(c.sessionId);return g.jsxs("button",{type:"button",className:`sl-row state-${c.state}${f?" 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:na(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:Fe(c.cost)})}),g.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(c.startedAt).toLocaleString()}`,children:h3(c.startedAt,c.state==="active"?void 0:c.lastActivity,n)})]})]})]},c.sessionId)})]})]})}function rx(e,n){if(!e)return null;const i=n-Math.floor(e/1e3);return i<10?"just now":i<60?`${i}s ago`:i<3600?`${Math.floor(i/60)}m ago`:`${Math.floor(i/3600)}h ago`}function m3(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 Cr(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function g3({cost:e}){const n=e.total;if(n<=0)return null;const i=(s,o,l)=>{if(s<=0)return null;const u=s/n*100;return g.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${Fe(s)} (${u.toFixed(0)}%)`},o)};return g.jsxs("div",{className:"cost-bar","aria-label":"Cost breakdown",children:[i(e.input,"cb-input","input"),i(e.output,"cb-output","output"),i(e.cacheRead,"cb-cache-r","cache read"),i(e.cacheWrite,"cb-cache-w","cache write")]})}function v3(e,n){const i=e-n;if(i<=0)return null;const s=Math.floor(i/3600),o=Math.floor(i%3600/60);if(s>23){const l=Math.floor(i/86400),u=Math.floor(i%86400/3600);return`${l}d ${u}h`}return s>0?`${s}h ${o}m`:`${o}m`}function y3(e,n,i,s){const o=Math.max(0,n-s),l=Math.max(0,i-o);if(l<120)return null;const u=Math.min(100,l/i*100),c=e-u;if(Math.abs(c)<3)return{label:"on pace",color:"var(--ok)",expectedPct:u,isDeficit:!1};if(c>0){const f=100-e,h=l>0?e/l:0,p=h>0?f/h:1/0,m={label:`${Math.round(c)}% ahead`,color:"var(--warn)",expectedPct:u,isDeficit:!0};if(p<o&&p<86400){const y=Math.floor(p/3600),w=Math.floor(p%3600/60);m.runsOutIn=y>0?`${y}h ${w}m`:`${w}m`}return m}return{label:`${Math.round(-c)}% reserve`,color:"var(--ok)",expectedPct:u,isDeficit:!1}}function $i({pct:e,label:n,reset:i,resetAt:s,windowSec:o,limitReached:l,nowSec:u}){const c=Math.min(100,Math.max(0,e)),h=l||c>=90?"var(--err)":c>=70?"var(--warn)":"var(--accent)",p=c===0?"< 1%":`${c}%`,m=c===0?2:c,y=s?v3(s,u):null,w=s&&o?y3(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:p})]}),g.jsxs("div",{className:"qb-track",children:[g.jsx("div",{className:"qb-fill",style:{width:`${m}%`,background:h,opacity:c===0?.4:1}}),w&&g.jsx("div",{className:"qb-pace-marker",style:{left:`${w.expectedPct}%`,background:w.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(w.expectedPct)}% by now`})]}),g.jsxs("div",{className:"qb-reset-row",children:[y?g.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):i?g.jsxs("span",{className:"qb-reset",children:["resets ",i]}):null,w&&g.jsx("span",{className:"qb-pace",style:{color:w.color},children:w.runsOutIn?`runs out in ${w.runsOutIn}`:w.label})]})]})}const w3=6e4;function x3(){const[e,n]=M.useState(null),[i,s]=M.useState(!1),o=M.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 M.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),w3),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{quota:e,loading:i,refresh:()=>l(!0)}}function _3(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 hN=6e4;function S3(){const[e,n]=M.useState(null),[i,s]=M.useState(!1),o=M.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 M.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),hN),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{data:e,loading:i,refresh:()=>l(!0)}}function b3(){const[e,n]=M.useState(null),i=M.useRef(null),s=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return M.useEffect(()=>(s(),i.current=window.setInterval(s,hN),()=>{i.current!=null&&window.clearInterval(i.current)}),[]),{data:e}}function k3({state:e,now:n,onClose:i}){var P,z;const{quota:s,loading:o,refresh:l}=x3(),{data:u,loading:c,refresh:f}=S3(),{data:h}=b3(),[p,m]=M.useState(()=>Math.floor(Date.now()/1e3));M.useEffect(()=>{const T=window.setInterval(()=>m(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(T)},[]);const{byModel:y,totalCost:w,totalTokens:j,burnRate:_}=M.useMemo(()=>{const T=new Map,q={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let B=0,Z=0,Q=0,A=0;for(const L of e.agents.values()){const G=L.model??"__unknown__",k=fn(L.usage,L.model),$=T.get(G);$?($.inputTokens+=L.usage.inputTokens,$.outputTokens+=L.usage.outputTokens,$.cacheReadTokens+=L.usage.cacheReadTokens,$.cacheCreateTokens+=L.usage.cacheCreateTokens,$.cost.total+=k.total,$.cost.input+=k.input,$.cost.output+=k.output,$.cost.cacheRead+=k.cacheRead,$.cost.cacheWrite+=k.cacheWrite,$.agentCount++):T.set(G,{model:G,inputTokens:L.usage.inputTokens,outputTokens:L.usage.outputTokens,cacheReadTokens:L.usage.cacheReadTokens,cacheCreateTokens:L.usage.cacheCreateTokens,cost:{...k},agentCount:1}),q.total+=k.total,q.input+=k.input,q.output+=k.output,q.cacheRead+=k.cacheRead,q.cacheWrite+=k.cacheWrite,B+=L.usage.inputTokens,Z+=L.usage.outputTokens,Q+=L.usage.cacheReadTokens,A+=L.usage.cacheCreateTokens}const H=Array.from(T.values()).sort((L,G)=>G.cost.total-L.cost.total);let U=0,ne=0;for(const L of e.agents.values()){if(L.state!=="active")continue;const G=fn(L.usage,L.model);U+=G.total,ne=Math.max(ne,((L.endedAt??n)-L.startedAt)/1e3)}const Y=ne>0?$l(U,ne):null;return{byModel:H,totalCost:q,totalTokens:{in:B,out:Z,cacheR:Q,cacheC:A},burnRate:Y}},[e,e.lastSeq,n]),S=M.useMemo(()=>{const T=[];for(const q of e.agents.values()){if(q.kind!=="root")continue;let B=fn(q.usage,q.model).total,Z=q.usage.inputTokens,Q=q.usage.outputTokens;for(const A of e.agents.values())A.sessionId!==q.sessionId||A.kind==="root"||(B+=fn(A.usage,A.model).total,Z+=A.usage.inputTokens,Q+=A.usage.outputTokens);T.push({sessionId:q.sessionId,label:q.label||q.cwdBasename||"session",state:q.state,cost:B,inputTokens:Z,outputTokens:Q})}return T.sort((q,B)=>B.cost-q.cost).slice(0,12)},[e,e.lastSeq]),b=w.total>0,E=j.in+j.out,N=o||c,C=rx(s==null?void 0:s.fetchedAt,p),I=rx(u==null?void 0:u.fetchedAt,p),O=()=>{l(),f()};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:i,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h4",{className:"up-section-title",children:["Claude quota",C&&!o&&g.jsx("span",{className:"up-section-age",title:m3(s==null?void 0:s.source),children:C})]}),s!=null&&s.ok?g.jsxs("div",{className:"up-quota-bars",children:[s.session5hPct!=null&&g.jsx($i,{label:"5-hour window",pct:s.session5hPct,reset:s.session5hReset,resetAt:s.session5hResetAt,windowSec:s.session5hWindowSec,nowSec:p}),s.week7dPct!=null&&g.jsx($i,{label:"7-day window",pct:s.week7dPct,reset:s.week7dReset,resetAt:s.week7dResetAt,windowSec:s.week7dWindowSec,nowSec:p}),s.weekSonnetPct!=null&&g.jsx($i,{label:"Sonnet (7d)",pct:s.weekSonnetPct,nowSec:p}),s.weekOpusPct!=null&&g.jsx($i,{label:"Opus (7d)",pct:s.weekOpusPct,nowSec:p})]}):(s==null?void 0:s.ok)===!1?g.jsxs("div",{className:"up-quota-na",children:[g.jsx("span",{children:"Quota unavailable."}),g.jsxs("span",{className:"up-quota-hint",children:["Run ",g.jsx("code",{children:"/usage"})," in a claude session, then click ↻"]})]}):g.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h4",{className:"up-section-title",children:["Codex quota",(u==null?void 0:u.ok)&&u.planLabel&&g.jsx("span",{className:"up-plan-badge",children:u.planLabel}),I&&!c&&g.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:I})]}),u!=null&&u.ok?g.jsxs("div",{className:"up-quota-bars",children:[(P=u.windows)==null?void 0:P.map(T=>g.jsx($i,{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:p},T.id)),(z=u.extraWindows)==null?void 0:z.map(T=>g.jsx($i,{label:T.label,pct:T.pct,reset:T.reset??void 0,resetAt:T.resetAt??void 0,windowSec:T.windowSec??void 0,nowSec:p},T.id)),u.creditLimit&&g.jsx($i,{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:p}),(h==null?void 0:h.ok)&&h.window7d&&h.window7d.sessionCount>0&&g.jsxs("div",{className:"up-quota-sub",children:[Cr(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:_3(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:Fe(w.total)}),g.jsx("span",{className:"up-total-label",children:"total spend"})]}),g.jsx(g3,{cost:w}),E>0&&g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),Cr(j.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),Cr(j.out)]}),j.cacheR>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache r"}),Cr(j.cacheR)]}),j.cacheC>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache c"}),Cr(j.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:na(T.model)}),g.jsx("td",{className:"up-num",children:Cr(T.inputTokens+T.outputTokens)}),g.jsx("td",{className:"up-num up-cost-val",children:Fe(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:Cr(T.inputTokens+T.outputTokens)}),g.jsx("span",{className:"up-session-cost",children:Fe(T.cost)})]},T.sessionId))})]})]}):E>0?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),Cr(j.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),Cr(j.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 E3=1500;async function wl(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const N3={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"},id=(e,n)=>(e==null?void 0:e.detail)||(e!=null&&e.reason?N3[e.reason]??e.reason:null)||n;function C3({onClose:e,onChanged:n}){const[i,s]=M.useState("login"),[o,l]=M.useState(null),[u,c]=M.useState(""),[f,h]=M.useState(""),[p,m]=M.useState(!1),[y,w]=M.useState(null),[j,_]=M.useState(null),S=M.useRef(!1),b=M.useRef(null),E=M.useCallback(()=>{S.current&&wl({action:"login-cancel"}).catch(()=>{}),e()},[e]);M.useEffect(()=>{const P=z=>{z.key==="Escape"&&E()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[E]);const N=M.useCallback(async()=>{m(!0),w(null),S.current=!0;const P=await wl({action:"login"}).catch(()=>null);if(m(!1),!(P!=null&&P.ok)){w(id(P,"could not start the sign-in"));return}l(P)},[]);M.useEffect(()=>{i!=="login"||S.current||N()},[i,N]),M.useEffect(()=>{if(!o||o.state==="done"||o.state==="failed")return;const P=window.setInterval(async()=>{try{const z=await fetch("/api/claude-accounts/login");z.ok&&l(await z.json())}catch{}},E3);return()=>window.clearInterval(P)},[o]),M.useEffect(()=>{var P;(o==null?void 0:o.state)==="awaiting_code"&&((P=b.current)==null||P.focus()),(o==null?void 0:o.state)==="done"&&n()},[o==null?void 0:o.state,n]);const C=M.useCallback(async()=>{var z;m(!0),w(null);const P=await wl({action:"login-code",code:u}).catch(()=>null);if(m(!1),!(P!=null&&P.ok)){w(id(P,"the code was not accepted")),P!=null&&P.state&&l(P),(z=b.current)==null||z.select();return}c(""),l(P)},[u,o]),I=M.useCallback(async()=>{m(!0),w(null);const P=await wl({action:"import",blob:f}).catch(()=>null);if(m(!1),!(P!=null&&P.ok)){w(id(P,"the import failed"));return}h(""),_({added:P.added===!0,num:P.num??null}),n()},[f,n]),O=(o==null?void 0:o.state)==="done"?o.account:null;return g.jsx("div",{className:"modal-backdrop",onClick:E,role:"presentation",children:g.jsxs("div",{className:"modal aa-modal",onClick:P=>P.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[g.jsxs("header",{className:"modal-head",children:[g.jsx("div",{className:"modal-title",children:g.jsxs("span",{className:"aa-tabs",role:"tablist",children:[g.jsx("button",{type:"button",role:"tab","aria-selected":i==="login",className:`aa-tab${i==="login"?" on":""}`,onClick:()=>s("login"),children:"Sign in"}),g.jsx("button",{type:"button",role:"tab","aria-selected":i==="paste",className:`aa-tab${i==="paste"?" on":""}`,onClick:()=>s("paste"),children:"Paste a share"})]})}),g.jsx("div",{className:"modal-actions",children:g.jsx("button",{type:"button",className:"btn icon-btn",onClick:E,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),g.jsx("section",{className:"modal-body aa-body",children:i==="login"?O?g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:O.added?`Added account ${O.num}`:"Credentials refreshed"}),g.jsxs("p",{className:"aa-note",children:[O.email,O.added?" is now 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:P=>c(P.target.value),onKeyDown:P=>{P.key==="Enter"&&u.trim()&&!p&&C()},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:p||!u.trim()||o.state==="registering",onClick:C,children:o.state==="registering"?"registering…":"Continue"})]}),(y||o.error)&&g.jsx("p",{className:"aa-err",children:y??o.error}),g.jsx("p",{className:"aa-note",children:"The code goes straight to the claude CLI on this machine. It is never stored or sent anywhere else."})]})]}):(o==null?void 0:o.state)==="failed"||y?g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"Sign-in failed"}),g.jsx("p",{className:"aa-err",children:y??(o==null?void 0:o.error)}),g.jsx("button",{type:"button",className:"btn",onClick:()=>{S.current=!1,l(null),w(null),N()},children:"Try again"})]}):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",children:[g.jsx("h4",{children:"Paste an account shared from another deck"}),g.jsxs("div",{className:"aa-field",children:[g.jsx("input",{type:"text",value:f,onChange:P=>h(P.target.value),onKeyDown:P=>{P.key==="Enter"&&f.trim()&&!p&&I()},placeholder:"ccdeck1:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),g.jsx("button",{type:"button",className:"btn primary",disabled:p||!f.trim(),onClick:I,children:p?"importing…":"Import"})]}),j&&g.jsx("p",{className:"aa-note",children:j.added?`Added account ${j.num}.`:"That account was already here, so nothing changed."}),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 j3=15e3,R3=[70,80,85,90,95];function T3(e,n){const i=e-n;if(i<=0)return null;const s=Math.floor(i/86400),o=Math.floor(i%86400/3600),l=Math.floor(i%3600/60);return s>0?`${s}d ${o}h`:o>0?`${o}h ${l}m`:`${l}m`}function ix(e,n){const i=n-Math.floor(e/1e3);return i<60?"just now":i<3600?`${Math.floor(i/60)}m ago`:i<86400?`${Math.floor(i/3600)}h ago`:`${Math.floor(i/86400)}d ago`}function A3(e,n){if(!e)return"";const i=Math.floor(e/1e3)-n;return i<=0?" · due":i<60?` · next in ${i}s`:` · next in ${Math.round(i/60)}m`}function I3(e){return e==="http-429"?"rate limited":e==="http-401"?"re-login needed":e==="timeout"?"timed out":e==="network"?"unreachable":e}function M3({lane:e,nowSec:n}){const i=Math.min(100,Math.max(0,e.pct)),s=i>=90?"var(--err)":i>=70?"var(--warn)":"var(--accent)",o=e.resetAt?T3(e.resetAt,n):null;return g.jsxs("div",{className:"ap-lane",children:[g.jsx("span",{className:"ap-lane-label",children:e.label}),g.jsx("div",{className:"ap-lane-track",children:g.jsx("div",{className:"ap-lane-fill",style:{width:`${i===0?1.5:i}%`,background:s,opacity:i===0?.4:1}})}),g.jsxs("span",{className:"ap-lane-pct",style:{color:s},children:[i,"%"]}),g.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}function P3(e){const n=e.map(s=>s.num),i=n.length?Math.max(...n):0;return[...new Set([...n,i+1])].sort((s,o)=>s-o)}function O3(e,n){const i=Math.round(e/1e3)-n;return i<=0?"expired":i<60?`expires in ${i}s`:`expires in ${Math.round(i/60)}m`}function q3({onClose:e}){var Y,L,G;const[n,i]=M.useState(null),[s,o]=M.useState(null),[l,u]=M.useState(null),[c,f]=M.useState(null),[h,p]=M.useState(null),[m,y]=M.useState(()=>Math.floor(Date.now()/1e3)),w=M.useRef(null),[j,_]=M.useState(null),[S,b]=M.useState(!1),[E,N]=M.useState(""),[C,I]=M.useState(null),[O,P]=M.useState(null),[z,T]=M.useState(!1),q=M.useCallback(async(k=!1)=>{try{const[$,oe]=await Promise.all([fetch(`/api/claude-accounts${k?"?refresh=1":""}`),fetch("/api/cswap-auto")]);$.ok&&i(await $.json()),oe.ok&&o(await oe.json())}catch{}},[]),B=M.useCallback(async(k,$)=>{u($),p(null);try{const D=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)})).json().catch(()=>null);return D!=null&&D.ok||p((D==null?void 0:D.detail)||(D==null?void 0:D.reason)||"command failed"),D}catch{return p("server unreachable"),null}finally{u(null)}},[]),Z=M.useCallback(async(k,$)=>{u($),p(null);try{const D=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)})).json().catch(()=>null);return D!=null&&D.ok||p((D==null?void 0:D.detail)||(D==null?void 0:D.reason)||"command failed"),D}catch{return p("server unreachable"),null}finally{u(null)}},[]);M.useEffect(()=>(q(!0),w.current=window.setInterval(()=>q(!1),j3),()=>{w.current!=null&&window.clearInterval(w.current)}),[q]),M.useEffect(()=>{const k=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(k)},[]);const Q=((Y=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:Y.value)??"90",A=(L=n==null?void 0:n.accounts)==null?void 0:L.find(k=>k.active),H=A!=null&&A.lanes.length?Math.max(...A.lanes.map(k=>k.pct)):null,U=H!=null&&H>=Number(Q)-15,ne=async k=>{f(k),p(null);try{const oe=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:k})})).json().catch(()=>null);oe!=null&&oe.ok||p((oe==null?void 0:oe.output)||(oe==null?void 0:oe.reason)||"switch failed"),await q(!0)}catch{p("server unreachable")}finally{f(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:()=>q(!0),title:"Reload from claude-swap",children:"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),n==null?g.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?g.jsxs(g.Fragment,{children:[(G=n.accounts)==null?void 0:G.map(k=>g.jsxs("div",{className:`ap-account${k.active?" active":""}${k.disabled?" disabled":""}`,children:[g.jsxs("div",{className:"ap-account-head",children:[g.jsx("span",{className:"ap-num",children:k.num}),k.alias&&g.jsx("span",{className:"ap-alias",children:k.alias}),g.jsx("span",{className:"ap-email",title:k.org??void 0,children:k.email}),g.jsx("button",{type:"button",className:`ap-more${j===k.num?" on":""}`,"aria-label":`Manage account ${k.num}`,"aria-expanded":j===k.num,title:"Share, rename, move, remove",onClick:()=>{_(j===k.num?null:k.num),N(k.alias??""),I(null),P(null),T(!1)},children:"⋯"}),k.active?g.jsx("span",{className:"ap-badge-active",children:"● active"}):g.jsx("button",{type:"button",className:"btn ap-switch",disabled:c!=null||k.disabled,onClick:()=>ne(k.num),title:k.disabled?"Held out of rotation":`Switch to ${k.alias??k.email}`,children:c===k.num?"…":"switch"})]}),k.lanes.length>0?k.lanes.map($=>g.jsx(M3,{lane:$,nowSec:m},$.id)):g.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),g.jsxs("div",{className:"ap-meta",children:[k.error&&g.jsx("span",{className:"ap-err",children:I3(k.error)}),((s==null?void 0:s.enabled)||(s==null?void 0:s.external))&&!k.active&&g.jsx("button",{type:"button",className:"ap-rotate",disabled:l!=null,onClick:()=>B({action:"account",account:k.num,enabled:k.disabled},`rot-${k.num}`).then(()=>q(!0)),title:k.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:k.disabled?"held out":"in rotation"}),k.fetchedAt?g.jsxs("span",{className:`ap-age${k.stale?" ap-stale":""}`,title:"When claude-swap last read this account's usage, and when it plans to read it again. It sets that interval itself — 3 minutes at the fastest, wider while an account is recovering from a rate limit — and every surface, including `cswap watch`, follows the same plan.",children:["collected ",ix(k.fetchedAt,m),A3(k.nextAt,m)]}):g.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),j===k.num&&g.jsxs("div",{className:"ap-manage",children:[g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("span",{className:"ap-manage-label",children:"name"}),g.jsx("input",{className:"ap-manage-input",type:"text",value:E,onChange:$=>N($.target.value),onKeyDown:$=>{$.key==="Enter"&&Z({action:"alias",account:k.num,alias:E},`alias-${k.num}`).then(()=>q(!0))},placeholder:"no alias",spellCheck:!1,"aria-label":`Alias for account ${k.num}`}),g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null||E.trim()===(k.alias??""),onClick:()=>Z({action:"alias",account:k.num,alias:E},`alias-${k.num}`).then(()=>q(!0)),title:"A short name to show instead of the email",children:"save"})]}),g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("span",{className:"ap-manage-label",children:"slot"}),g.jsx("span",{className:"ap-field",children:g.jsx("select",{"aria-label":`Slot for account ${k.num}`,value:String(k.num),disabled:l!=null,onChange:$=>Z({action:"move",account:k.num,slot:Number($.target.value)},`move-${k.num}`).then(()=>q(!0)),children:P3(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 Z({action:"share",account:k.num},`share-${k.num}`);$!=null&&$.ok&&P({num:k.num,blob:$.blob,expiresAt:$.expiresAt})},children:"share…"}),g.jsx("button",{type:"button",className:`ap-manage-btn danger${C===k.num?" armed":""}`,disabled:l!=null,title:C===k.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(C!==k.num){I(k.num),window.setTimeout(()=>I($=>$===k.num?null:$),4e3);return}I(null),Z({action:"remove",account:k.num},`rm-${k.num}`).then(()=>{_(null),q(!0)})},children:C===k.num?"confirm remove":"remove"})]}),(O==null?void 0:O.num)===k.num&&g.jsxs("div",{className:"ap-share",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",onClick:async()=>{try{await navigator.clipboard.writeText(O.blob),T(!0)}catch{}},children:z?"copied":"copy"}),g.jsxs("span",{className:"ap-manage-hint",children:["carries a live login · ",O3(O.expiresAt,m)]})]})]})]})]},k.num)),(s==null?void 0:s.ok)&&g.jsxs("div",{className:"ap-auto",children:[g.jsxs("div",{className:"ap-auto-head",children:[g.jsx("span",{className:"ap-auto-title",children:"Auto-switch"}),g.jsxs("span",{className:"ap-auto-ctl",children:[H!=null&&g.jsxs("span",{className:`ap-auto-now${U?" near":""}`,children:[Math.round(H),"%"]}),g.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:g.jsx("select",{"aria-label":"Switch threshold",value:Q,disabled:l!=null,onChange:k=>B({action:"setting",key:"autoswitch.threshold",value:k.target.value},"threshold").then(()=>q(!0)),children:R3.map(k=>g.jsxs("option",{value:k,children:[k,"%"]},k))})}),g.jsxs("button",{type:"button",className:`ap-auto-state toggle${s.enabled?" live":""}`,role:"switch","aria-checked":s.enabled,disabled:l!=null,onClick:()=>B({action:"enable",enabled:!s.enabled},"enable").then(()=>q(!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 ",ix(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(C3,{onClose:()=>b(!1),onChanged:()=>q(!0)})]})}const L3=3e4;function $3({bundle:e,running:n,lastTried:i}){return!n||e===n?!1:i!==n}function D3(e){const n=e.thresholdMs??L3;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 Di(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 sx(e){return e.replace(/^anthropic\./,"").replace(/^claude-/,"").replace(/-\d{8}$/,"")}function xl(e){const n=e.toLowerCase();return n.includes("opus")?"#c4b5fd":n.includes("sonnet")?"#7dd3fc":n.includes("haiku")?"#86efac":n.includes("gpt-5")||n.includes("gpt5")?"#fcd34d":n.includes("gpt")?"#fca5a5":n.includes("gemini")?"#a5b4fc":n.includes("codex")?"#fdba74":"#94a3b8"}function F3(e){return new Date(Date.now()-(e-1)*864e5).toISOString().slice(0,10).replace(/-/g,"")}const z3=[7,14,30,90];function B3(e){const[n,i]=M.useState(null),[s,o]=M.useState(!1),l=(u=!1)=>{o(!0);const f=`/api/ccusage?since=${F3(e)}${u?"&refresh=1":""}`;fetch(f).then(h=>h.json()).then(i).catch(()=>i({ok:!1,error:"request failed"})).finally(()=>o(!1))};return M.useEffect(()=>{l(!1)},[e]),{data:n,loading:s,reload:()=>l(!0)}}function U3({onClose:e}){var b,E;const[n,i]=M.useState(30),[s,o]=M.useState(null),{data:l,loading:u,reload:c}=B3(n);M.useEffect(()=>{const N=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e]);const f=l!=null&&l.ok?l.days??[]:[],h=M.useMemo(()=>f.reduce((N,C)=>Math.max(N,C.totalCost),0),[f]),{totalCost:p,totalTok:m,inOut:y,cacheRead:w,modelCosts:j}=M.useMemo(()=>{let N=0,C=0,I=0,O=0;const P=new Map;for(const z of f){N+=z.totalCost,C+=z.totalTokens,I+=z.inputTokens+z.outputTokens,O+=z.cacheReadTokens;for(const T of z.modelBreakdowns)P.set(T.modelName,(P.get(T.modelName)??0)+T.cost)}return{totalCost:N,totalTok:C,inOut:I,cacheRead:O,modelCosts:P}},[f]),_=M.useMemo(()=>Array.from(j.entries()).sort((N,C)=>C[1]-N[1]),[j]),S=s?f.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:z3.map(N=>g.jsxs("button",{role:"tab","aria-selected":n===N,className:`uh-range-btn${n===N?" on":""}`,onClick:()=>{i(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&&f.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]}):f.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(_l,{label:"total cost",val:Fe(p),accent:!0}),g.jsx(_l,{label:"tokens",val:Di(m)}),g.jsx(_l,{label:"input+output",val:Di(y)}),g.jsx(_l,{label:"cache reads",val:Di(w)})]}),g.jsx("div",{className:"uh-chart",role:"img","aria-label":"Daily cost by model",children:f.map(N=>{const C=h>0?N.totalCost/h*100:0,I=N.period===s;return g.jsxs("button",{className:`uh-bar-col${I?" sel":""}`,onClick:()=>o(I?null:N.period),title:`${N.period} · ${Fe(N.totalCost)}`,style:{flexBasis:`${100/f.length}%`},children:[g.jsx("div",{className:"uh-bar",style:{height:`${Math.max(C,N.totalCost>0?2:0)}%`},children:N.modelBreakdowns.slice().sort((O,P)=>P.cost-O.cost).map(O=>{const P=N.totalCost>0?O.cost/N.totalCost*100:0;return g.jsx("div",{className:"uh-bar-seg",style:{height:`${P}%`,background:xl(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,C])=>g.jsxs("span",{className:"uh-legend-item",children:[g.jsx("span",{className:"uh-legend-dot",style:{background:xl(N)}}),sx(N)," ",g.jsx("span",{className:"uh-legend-cost",children:Fe(C)})]},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:Fe(S.totalCost)}),(E=(b=S.metadata)==null?void 0:b.agents)!=null&&E.length?g.jsx("span",{className:"uh-detail-agents",children:S.metadata.agents.join(" · ")}):null]}),g.jsxs("div",{className:"uh-detail-mini",children:[g.jsx(Sl,{label:"input",val:Di(S.inputTokens)}),g.jsx(Sl,{label:"output",val:Di(S.outputTokens)}),g.jsx(Sl,{label:"cache write",val:Di(S.cacheCreationTokens)}),g.jsx(Sl,{label:"cache read",val:Di(S.cacheReadTokens)})]}),g.jsx("div",{className:"uh-detail-models",children:S.modelBreakdowns.slice().sort((N,C)=>C.cost-N.cost).map(N=>{const C=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:xl(N.modelName)}}),sx(N.modelName)]}),g.jsx("span",{className:"uh-model-bar",children:g.jsx("span",{className:"uh-model-bar-fill",style:{width:`${C}%`,background:xl(N.modelName)}})}),g.jsx("span",{className:"uh-model-cost",children:Fe(N.cost)})]},N.modelName)})})]})]})]})})}function _l({label:e,val:n,accent:i}){return g.jsxs("div",{className:"uh-stat",children:[g.jsx("span",{className:`uh-stat-val${i?" accent":""}`,children:n}),g.jsx("span",{className:"uh-stat-label",children:e})]})}function Sl({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 hv(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 sd,ox;function H3(){if(ox)return sd;ox=1;function e(){this.__data__=[],this.size=0}return sd=e,sd}var od,ax;function Hs(){if(ax)return od;ax=1;function e(n,i){return n===i||n!==n&&i!==i}return od=e,od}var ad,lx;function Gl(){if(lx)return ad;lx=1;var e=Hs();function n(i,s){for(var o=i.length;o--;)if(e(i[o][0],s))return o;return-1}return ad=n,ad}var ld,ux;function V3(){if(ux)return ld;ux=1;var e=Gl(),n=Array.prototype,i=n.splice;function s(o){var l=this.__data__,u=e(l,o);if(u<0)return!1;var c=l.length-1;return u==c?l.pop():i.call(l,u,1),--this.size,!0}return ld=s,ld}var ud,cx;function W3(){if(cx)return ud;cx=1;var e=Gl();function n(i){var s=this.__data__,o=e(s,i);return o<0?void 0:s[o][1]}return ud=n,ud}var cd,dx;function G3(){if(dx)return cd;dx=1;var e=Gl();function n(i){return e(this.__data__,i)>-1}return cd=n,cd}var dd,fx;function Y3(){if(fx)return dd;fx=1;var e=Gl();function n(i,s){var o=this.__data__,l=e(o,i);return l<0?(++this.size,o.push([i,s])):o[l][1]=s,this}return dd=n,dd}var fd,hx;function Yl(){if(hx)return fd;hx=1;var e=H3(),n=V3(),i=W3(),s=G3(),o=Y3();function l(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=i,l.prototype.has=s,l.prototype.set=o,fd=l,fd}var hd,px;function K3(){if(px)return hd;px=1;var e=Yl();function n(){this.__data__=new e,this.size=0}return hd=n,hd}var pd,mx;function X3(){if(mx)return pd;mx=1;function e(n){var i=this.__data__,s=i.delete(n);return this.size=i.size,s}return pd=e,pd}var md,gx;function Q3(){if(gx)return md;gx=1;function e(n){return this.__data__.get(n)}return md=e,md}var gd,vx;function Z3(){if(vx)return gd;vx=1;function e(n){return this.__data__.has(n)}return gd=e,gd}var vd,yx;function pN(){if(yx)return vd;yx=1;var e=typeof al=="object"&&al&&al.Object===Object&&al;return vd=e,vd}var yd,wx;function er(){if(wx)return yd;wx=1;var e=pN(),n=typeof self=="object"&&self&&self.Object===Object&&self,i=e||n||Function("return this")();return yd=i,yd}var wd,xx;function Vs(){if(xx)return wd;xx=1;var e=er(),n=e.Symbol;return wd=n,wd}var xd,_x;function J3(){if(_x)return xd;_x=1;var e=Vs(),n=Object.prototype,i=n.hasOwnProperty,s=n.toString,o=e?e.toStringTag:void 0;function l(u){var c=i.call(u,o),f=u[o];try{u[o]=void 0;var h=!0}catch{}var p=s.call(u);return h&&(c?u[o]=f:delete u[o]),p}return xd=l,xd}var _d,Sx;function eO(){if(Sx)return _d;Sx=1;var e=Object.prototype,n=e.toString;function i(s){return n.call(s)}return _d=i,_d}var Sd,bx;function Ki(){if(bx)return Sd;bx=1;var e=Vs(),n=J3(),i=eO(),s="[object Null]",o="[object Undefined]",l=e?e.toStringTag:void 0;function u(c){return c==null?c===void 0?o:s:l&&l in Object(c)?n(c):i(c)}return Sd=u,Sd}var bd,kx;function On(){if(kx)return bd;kx=1;function e(n){var i=typeof n;return n!=null&&(i=="object"||i=="function")}return bd=e,bd}var kd,Ex;function ra(){if(Ex)return kd;Ex=1;var e=Ki(),n=On(),i="[object AsyncFunction]",s="[object Function]",o="[object GeneratorFunction]",l="[object Proxy]";function u(c){if(!n(c))return!1;var f=e(c);return f==s||f==o||f==i||f==l}return kd=u,kd}var Ed,Nx;function tO(){if(Nx)return Ed;Nx=1;var e=er(),n=e["__core-js_shared__"];return Ed=n,Ed}var Nd,Cx;function nO(){if(Cx)return Nd;Cx=1;var e=tO(),n=(function(){var s=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""})();function i(s){return!!n&&n in s}return Nd=i,Nd}var Cd,jx;function mN(){if(jx)return Cd;jx=1;var e=Function.prototype,n=e.toString;function i(s){if(s!=null){try{return n.call(s)}catch{}try{return s+""}catch{}}return""}return Cd=i,Cd}var jd,Rx;function rO(){if(Rx)return jd;Rx=1;var e=ra(),n=nO(),i=On(),s=mN(),o=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,f=u.toString,h=c.hasOwnProperty,p=RegExp("^"+f.call(h).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!i(y)||n(y))return!1;var w=e(y)?p:l;return w.test(s(y))}return jd=m,jd}var Rd,Tx;function iO(){if(Tx)return Rd;Tx=1;function e(n,i){return n==null?void 0:n[i]}return Rd=e,Rd}var Td,Ax;function Xi(){if(Ax)return Td;Ax=1;var e=rO(),n=iO();function i(s,o){var l=n(s,o);return e(l)?l:void 0}return Td=i,Td}var Ad,Ix;function pv(){if(Ix)return Ad;Ix=1;var e=Xi(),n=er(),i=e(n,"Map");return Ad=i,Ad}var Id,Mx;function Kl(){if(Mx)return Id;Mx=1;var e=Xi(),n=e(Object,"create");return Id=n,Id}var Md,Px;function sO(){if(Px)return Md;Px=1;var e=Kl();function n(){this.__data__=e?e(null):{},this.size=0}return Md=n,Md}var Pd,Ox;function oO(){if(Ox)return Pd;Ox=1;function e(n){var i=this.has(n)&&delete this.__data__[n];return this.size-=i?1:0,i}return Pd=e,Pd}var Od,qx;function aO(){if(qx)return Od;qx=1;var e=Kl(),n="__lodash_hash_undefined__",i=Object.prototype,s=i.hasOwnProperty;function o(l){var u=this.__data__;if(e){var c=u[l];return c===n?void 0:c}return s.call(u,l)?u[l]:void 0}return Od=o,Od}var qd,Lx;function lO(){if(Lx)return qd;Lx=1;var e=Kl(),n=Object.prototype,i=n.hasOwnProperty;function s(o){var l=this.__data__;return e?l[o]!==void 0:i.call(l,o)}return qd=s,qd}var Ld,$x;function uO(){if($x)return Ld;$x=1;var e=Kl(),n="__lodash_hash_undefined__";function i(s,o){var l=this.__data__;return this.size+=this.has(s)?0:1,l[s]=e&&o===void 0?n:o,this}return Ld=i,Ld}var $d,Dx;function cO(){if(Dx)return $d;Dx=1;var e=sO(),n=oO(),i=aO(),s=lO(),o=uO();function l(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=i,l.prototype.has=s,l.prototype.set=o,$d=l,$d}var Dd,Fx;function dO(){if(Fx)return Dd;Fx=1;var e=cO(),n=Yl(),i=pv();function s(){this.size=0,this.__data__={hash:new e,map:new(i||n),string:new e}}return Dd=s,Dd}var Fd,zx;function fO(){if(zx)return Fd;zx=1;function e(n){var i=typeof n;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?n!=="__proto__":n===null}return Fd=e,Fd}var zd,Bx;function Xl(){if(Bx)return zd;Bx=1;var e=fO();function n(i,s){var o=i.__data__;return e(s)?o[typeof s=="string"?"string":"hash"]:o.map}return zd=n,zd}var Bd,Ux;function hO(){if(Ux)return Bd;Ux=1;var e=Xl();function n(i){var s=e(this,i).delete(i);return this.size-=s?1:0,s}return Bd=n,Bd}var Ud,Hx;function pO(){if(Hx)return Ud;Hx=1;var e=Xl();function n(i){return e(this,i).get(i)}return Ud=n,Ud}var Hd,Vx;function mO(){if(Vx)return Hd;Vx=1;var e=Xl();function n(i){return e(this,i).has(i)}return Hd=n,Hd}var Vd,Wx;function gO(){if(Wx)return Vd;Wx=1;var e=Xl();function n(i,s){var o=e(this,i),l=o.size;return o.set(i,s),this.size+=o.size==l?0:1,this}return Vd=n,Vd}var Wd,Gx;function mv(){if(Gx)return Wd;Gx=1;var e=dO(),n=hO(),i=pO(),s=mO(),o=gO();function l(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=i,l.prototype.has=s,l.prototype.set=o,Wd=l,Wd}var Gd,Yx;function vO(){if(Yx)return Gd;Yx=1;var e=Yl(),n=pv(),i=mv(),s=200;function o(l,u){var c=this.__data__;if(c instanceof e){var f=c.__data__;if(!n||f.length<s-1)return f.push([l,u]),this.size=++c.size,this;c=this.__data__=new i(f)}return c.set(l,u),this.size=c.size,this}return Gd=o,Gd}var Yd,Kx;function Ql(){if(Kx)return Yd;Kx=1;var e=Yl(),n=K3(),i=X3(),s=Q3(),o=Z3(),l=vO();function u(c){var f=this.__data__=new e(c);this.size=f.size}return u.prototype.clear=n,u.prototype.delete=i,u.prototype.get=s,u.prototype.has=o,u.prototype.set=l,Yd=u,Yd}var Kd,Xx;function gv(){if(Xx)return Kd;Xx=1;function e(n,i){for(var s=-1,o=n==null?0:n.length;++s<o&&i(n[s],s,n)!==!1;);return n}return Kd=e,Kd}var Xd,Qx;function gN(){if(Qx)return Xd;Qx=1;var e=Xi(),n=(function(){try{var i=e(Object,"defineProperty");return i({},"",{}),i}catch{}})();return Xd=n,Xd}var Qd,Zx;function Zl(){if(Zx)return Qd;Zx=1;var e=gN();function n(i,s,o){s=="__proto__"&&e?e(i,s,{configurable:!0,enumerable:!0,value:o,writable:!0}):i[s]=o}return Qd=n,Qd}var Zd,Jx;function Jl(){if(Jx)return Zd;Jx=1;var e=Zl(),n=Hs(),i=Object.prototype,s=i.hasOwnProperty;function o(l,u,c){var f=l[u];(!(s.call(l,u)&&n(f,c))||c===void 0&&!(u in l))&&e(l,u,c)}return Zd=o,Zd}var Jd,e_;function ia(){if(e_)return Jd;e_=1;var e=Jl(),n=Zl();function i(s,o,l,u){var c=!l;l||(l={});for(var f=-1,h=o.length;++f<h;){var p=o[f],m=u?u(l[p],s[p],p,l,s):void 0;m===void 0&&(m=s[p]),c?n(l,p,m):e(l,p,m)}return l}return Jd=i,Jd}var ef,t_;function yO(){if(t_)return ef;t_=1;function e(n,i){for(var s=-1,o=Array(n);++s<n;)o[s]=i(s);return o}return ef=e,ef}var tf,n_;function dr(){if(n_)return tf;n_=1;function e(n){return n!=null&&typeof n=="object"}return tf=e,tf}var nf,r_;function wO(){if(r_)return nf;r_=1;var e=Ki(),n=dr(),i="[object Arguments]";function s(o){return n(o)&&e(o)==i}return nf=s,nf}var rf,i_;function sa(){if(i_)return rf;i_=1;var e=wO(),n=dr(),i=Object.prototype,s=i.hasOwnProperty,o=i.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(u){return n(u)&&s.call(u,"callee")&&!o.call(u,"callee")};return rf=l,rf}var sf,s_;function St(){if(s_)return sf;s_=1;var e=Array.isArray;return sf=e,sf}var Do={exports:{}},of,o_;function xO(){if(o_)return of;o_=1;function e(){return!1}return of=e,of}Do.exports;var a_;function Ws(){return a_||(a_=1,(function(e,n){var i=er(),s=xO(),o=n&&!n.nodeType&&n,l=o&&!0&&e&&!e.nodeType&&e,u=l&&l.exports===o,c=u?i.Buffer:void 0,f=c?c.isBuffer:void 0,h=f||s;e.exports=h})(Do,Do.exports)),Do.exports}var af,l_;function eu(){if(l_)return af;l_=1;var e=9007199254740991,n=/^(?:0|[1-9]\d*)$/;function i(s,o){var l=typeof s;return o=o??e,!!o&&(l=="number"||l!="symbol"&&n.test(s))&&s>-1&&s%1==0&&s<o}return af=i,af}var lf,u_;function vv(){if(u_)return lf;u_=1;var e=9007199254740991;function n(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=e}return lf=n,lf}var uf,c_;function _O(){if(c_)return uf;c_=1;var e=Ki(),n=vv(),i=dr(),s="[object Arguments]",o="[object Array]",l="[object Boolean]",u="[object Date]",c="[object Error]",f="[object Function]",h="[object Map]",p="[object Number]",m="[object Object]",y="[object RegExp]",w="[object Set]",j="[object String]",_="[object WeakMap]",S="[object ArrayBuffer]",b="[object DataView]",E="[object Float32Array]",N="[object Float64Array]",C="[object Int8Array]",I="[object Int16Array]",O="[object Int32Array]",P="[object Uint8Array]",z="[object Uint8ClampedArray]",T="[object Uint16Array]",q="[object Uint32Array]",B={};B[E]=B[N]=B[C]=B[I]=B[O]=B[P]=B[z]=B[T]=B[q]=!0,B[s]=B[o]=B[S]=B[l]=B[b]=B[u]=B[c]=B[f]=B[h]=B[p]=B[m]=B[y]=B[w]=B[j]=B[_]=!1;function Z(Q){return i(Q)&&n(Q.length)&&!!B[e(Q)]}return uf=Z,uf}var cf,d_;function tu(){if(d_)return cf;d_=1;function e(n){return function(i){return n(i)}}return cf=e,cf}var Fo={exports:{}};Fo.exports;var f_;function yv(){return f_||(f_=1,(function(e,n){var i=pN(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,u=l&&i.process,c=(function(){try{var f=o&&o.require&&o.require("util").types;return f||u&&u.binding&&u.binding("util")}catch{}})();e.exports=c})(Fo,Fo.exports)),Fo.exports}var df,h_;function oa(){if(h_)return df;h_=1;var e=_O(),n=tu(),i=yv(),s=i&&i.isTypedArray,o=s?n(s):e;return df=o,df}var ff,p_;function vN(){if(p_)return ff;p_=1;var e=yO(),n=sa(),i=St(),s=Ws(),o=eu(),l=oa(),u=Object.prototype,c=u.hasOwnProperty;function f(h,p){var m=i(h),y=!m&&n(h),w=!m&&!y&&s(h),j=!m&&!y&&!w&&l(h),_=m||y||w||j,S=_?e(h.length,String):[],b=S.length;for(var E in h)(p||c.call(h,E))&&!(_&&(E=="length"||w&&(E=="offset"||E=="parent")||j&&(E=="buffer"||E=="byteLength"||E=="byteOffset")||o(E,b)))&&S.push(E);return S}return ff=f,ff}var hf,m_;function nu(){if(m_)return hf;m_=1;var e=Object.prototype;function n(i){var s=i&&i.constructor,o=typeof s=="function"&&s.prototype||e;return i===o}return hf=n,hf}var pf,g_;function yN(){if(g_)return pf;g_=1;function e(n,i){return function(s){return n(i(s))}}return pf=e,pf}var mf,v_;function SO(){if(v_)return mf;v_=1;var e=yN(),n=e(Object.keys,Object);return mf=n,mf}var gf,y_;function wv(){if(y_)return gf;y_=1;var e=nu(),n=SO(),i=Object.prototype,s=i.hasOwnProperty;function o(l){if(!e(l))return n(l);var u=[];for(var c in Object(l))s.call(l,c)&&c!="constructor"&&u.push(c);return u}return gf=o,gf}var vf,w_;function Ir(){if(w_)return vf;w_=1;var e=ra(),n=vv();function i(s){return s!=null&&n(s.length)&&!e(s)}return vf=i,vf}var yf,x_;function pi(){if(x_)return yf;x_=1;var e=vN(),n=wv(),i=Ir();function s(o){return i(o)?e(o):n(o)}return yf=s,yf}var wf,__;function bO(){if(__)return wf;__=1;var e=ia(),n=pi();function i(s,o){return s&&e(o,n(o),s)}return wf=i,wf}var xf,S_;function kO(){if(S_)return xf;S_=1;function e(n){var i=[];if(n!=null)for(var s in Object(n))i.push(s);return i}return xf=e,xf}var _f,b_;function EO(){if(b_)return _f;b_=1;var e=On(),n=nu(),i=kO(),s=Object.prototype,o=s.hasOwnProperty;function l(u){if(!e(u))return i(u);var c=n(u),f=[];for(var h in u)h=="constructor"&&(c||!o.call(u,h))||f.push(h);return f}return _f=l,_f}var Sf,k_;function Qi(){if(k_)return Sf;k_=1;var e=vN(),n=EO(),i=Ir();function s(o){return i(o)?e(o,!0):n(o)}return Sf=s,Sf}var bf,E_;function NO(){if(E_)return bf;E_=1;var e=ia(),n=Qi();function i(s,o){return s&&e(o,n(o),s)}return bf=i,bf}var zo={exports:{}};zo.exports;var N_;function wN(){return N_||(N_=1,(function(e,n){var i=er(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,u=l?i.Buffer:void 0,c=u?u.allocUnsafe:void 0;function f(h,p){if(p)return h.slice();var m=h.length,y=c?c(m):new h.constructor(m);return h.copy(y),y}e.exports=f})(zo,zo.exports)),zo.exports}var kf,C_;function xN(){if(C_)return kf;C_=1;function e(n,i){var s=-1,o=n.length;for(i||(i=Array(o));++s<o;)i[s]=n[s];return i}return kf=e,kf}var Ef,j_;function _N(){if(j_)return Ef;j_=1;function e(n,i){for(var s=-1,o=n==null?0:n.length,l=0,u=[];++s<o;){var c=n[s];i(c,s,n)&&(u[l++]=c)}return u}return Ef=e,Ef}var Nf,R_;function SN(){if(R_)return Nf;R_=1;function e(){return[]}return Nf=e,Nf}var Cf,T_;function xv(){if(T_)return Cf;T_=1;var e=_N(),n=SN(),i=Object.prototype,s=i.propertyIsEnumerable,o=Object.getOwnPropertySymbols,l=o?function(u){return u==null?[]:(u=Object(u),e(o(u),function(c){return s.call(u,c)}))}:n;return Cf=l,Cf}var jf,A_;function CO(){if(A_)return jf;A_=1;var e=ia(),n=xv();function i(s,o){return e(s,n(s),o)}return jf=i,jf}var Rf,I_;function _v(){if(I_)return Rf;I_=1;function e(n,i){for(var s=-1,o=i.length,l=n.length;++s<o;)n[l+s]=i[s];return n}return Rf=e,Rf}var Tf,M_;function ru(){if(M_)return Tf;M_=1;var e=yN(),n=e(Object.getPrototypeOf,Object);return Tf=n,Tf}var Af,P_;function bN(){if(P_)return Af;P_=1;var e=_v(),n=ru(),i=xv(),s=SN(),o=Object.getOwnPropertySymbols,l=o?function(u){for(var c=[];u;)e(c,i(u)),u=n(u);return c}:s;return Af=l,Af}var If,O_;function jO(){if(O_)return If;O_=1;var e=ia(),n=bN();function i(s,o){return e(s,n(s),o)}return If=i,If}var Mf,q_;function kN(){if(q_)return Mf;q_=1;var e=_v(),n=St();function i(s,o,l){var u=o(s);return n(s)?u:e(u,l(s))}return Mf=i,Mf}var Pf,L_;function EN(){if(L_)return Pf;L_=1;var e=kN(),n=xv(),i=pi();function s(o){return e(o,i,n)}return Pf=s,Pf}var Of,$_;function RO(){if($_)return Of;$_=1;var e=kN(),n=bN(),i=Qi();function s(o){return e(o,i,n)}return Of=s,Of}var qf,D_;function TO(){if(D_)return qf;D_=1;var e=Xi(),n=er(),i=e(n,"DataView");return qf=i,qf}var Lf,F_;function AO(){if(F_)return Lf;F_=1;var e=Xi(),n=er(),i=e(n,"Promise");return Lf=i,Lf}var $f,z_;function NN(){if(z_)return $f;z_=1;var e=Xi(),n=er(),i=e(n,"Set");return $f=i,$f}var Df,B_;function IO(){if(B_)return Df;B_=1;var e=Xi(),n=er(),i=e(n,"WeakMap");return Df=i,Df}var Ff,U_;function Gs(){if(U_)return Ff;U_=1;var e=TO(),n=pv(),i=AO(),s=NN(),o=IO(),l=Ki(),u=mN(),c="[object Map]",f="[object Object]",h="[object Promise]",p="[object Set]",m="[object WeakMap]",y="[object DataView]",w=u(e),j=u(n),_=u(i),S=u(s),b=u(o),E=l;return(e&&E(new e(new ArrayBuffer(1)))!=y||n&&E(new n)!=c||i&&E(i.resolve())!=h||s&&E(new s)!=p||o&&E(new o)!=m)&&(E=function(N){var C=l(N),I=C==f?N.constructor:void 0,O=I?u(I):"";if(O)switch(O){case w:return y;case j:return c;case _:return h;case S:return p;case b:return m}return C}),Ff=E,Ff}var zf,H_;function MO(){if(H_)return zf;H_=1;var e=Object.prototype,n=e.hasOwnProperty;function i(s){var o=s.length,l=new s.constructor(o);return o&&typeof s[0]=="string"&&n.call(s,"index")&&(l.index=s.index,l.input=s.input),l}return zf=i,zf}var Bf,V_;function CN(){if(V_)return Bf;V_=1;var e=er(),n=e.Uint8Array;return Bf=n,Bf}var Uf,W_;function Sv(){if(W_)return Uf;W_=1;var e=CN();function n(i){var s=new i.constructor(i.byteLength);return new e(s).set(new e(i)),s}return Uf=n,Uf}var Hf,G_;function PO(){if(G_)return Hf;G_=1;var e=Sv();function n(i,s){var o=s?e(i.buffer):i.buffer;return new i.constructor(o,i.byteOffset,i.byteLength)}return Hf=n,Hf}var Vf,Y_;function OO(){if(Y_)return Vf;Y_=1;var e=/\w*$/;function n(i){var s=new i.constructor(i.source,e.exec(i));return s.lastIndex=i.lastIndex,s}return Vf=n,Vf}var Wf,K_;function qO(){if(K_)return Wf;K_=1;var e=Vs(),n=e?e.prototype:void 0,i=n?n.valueOf:void 0;function s(o){return i?Object(i.call(o)):{}}return Wf=s,Wf}var Gf,X_;function jN(){if(X_)return Gf;X_=1;var e=Sv();function n(i,s){var o=s?e(i.buffer):i.buffer;return new i.constructor(o,i.byteOffset,i.length)}return Gf=n,Gf}var Yf,Q_;function LO(){if(Q_)return Yf;Q_=1;var e=Sv(),n=PO(),i=OO(),s=qO(),o=jN(),l="[object Boolean]",u="[object Date]",c="[object Map]",f="[object Number]",h="[object RegExp]",p="[object Set]",m="[object String]",y="[object Symbol]",w="[object ArrayBuffer]",j="[object DataView]",_="[object Float32Array]",S="[object Float64Array]",b="[object Int8Array]",E="[object Int16Array]",N="[object Int32Array]",C="[object Uint8Array]",I="[object Uint8ClampedArray]",O="[object Uint16Array]",P="[object Uint32Array]";function z(T,q,B){var Z=T.constructor;switch(q){case w:return e(T);case l:case u:return new Z(+T);case j:return n(T,B);case _:case S:case b:case E:case N:case C:case I:case O:case P:return o(T,B);case c:return new Z;case f:case m:return new Z(T);case h:return i(T);case p:return new Z;case y:return s(T)}}return Yf=z,Yf}var Kf,Z_;function RN(){if(Z_)return Kf;Z_=1;var e=On(),n=Object.create,i=(function(){function s(){}return function(o){if(!e(o))return{};if(n)return n(o);s.prototype=o;var l=new s;return s.prototype=void 0,l}})();return Kf=i,Kf}var Xf,J_;function TN(){if(J_)return Xf;J_=1;var e=RN(),n=ru(),i=nu();function s(o){return typeof o.constructor=="function"&&!i(o)?e(n(o)):{}}return Xf=s,Xf}var Qf,e1;function $O(){if(e1)return Qf;e1=1;var e=Gs(),n=dr(),i="[object Map]";function s(o){return n(o)&&e(o)==i}return Qf=s,Qf}var Zf,t1;function DO(){if(t1)return Zf;t1=1;var e=$O(),n=tu(),i=yv(),s=i&&i.isMap,o=s?n(s):e;return Zf=o,Zf}var Jf,n1;function FO(){if(n1)return Jf;n1=1;var e=Gs(),n=dr(),i="[object Set]";function s(o){return n(o)&&e(o)==i}return Jf=s,Jf}var eh,r1;function zO(){if(r1)return eh;r1=1;var e=FO(),n=tu(),i=yv(),s=i&&i.isSet,o=s?n(s):e;return eh=o,eh}var th,i1;function AN(){if(i1)return th;i1=1;var e=Ql(),n=gv(),i=Jl(),s=bO(),o=NO(),l=wN(),u=xN(),c=CO(),f=jO(),h=EN(),p=RO(),m=Gs(),y=MO(),w=LO(),j=TN(),_=St(),S=Ws(),b=DO(),E=On(),N=zO(),C=pi(),I=Qi(),O=1,P=2,z=4,T="[object Arguments]",q="[object Array]",B="[object Boolean]",Z="[object Date]",Q="[object Error]",A="[object Function]",H="[object GeneratorFunction]",U="[object Map]",ne="[object Number]",Y="[object Object]",L="[object RegExp]",G="[object Set]",k="[object String]",$="[object Symbol]",oe="[object WeakMap]",D="[object ArrayBuffer]",X="[object DataView]",ee="[object Float32Array]",se="[object Float64Array]",ae="[object Int8Array]",pe="[object Int16Array]",ge="[object Int32Array]",Ae="[object Uint8Array]",Oe="[object Uint8ClampedArray]",Ie="[object Uint16Array]",Me="[object Uint32Array]",ke={};ke[T]=ke[q]=ke[D]=ke[X]=ke[B]=ke[Z]=ke[ee]=ke[se]=ke[ae]=ke[pe]=ke[ge]=ke[U]=ke[ne]=ke[Y]=ke[L]=ke[G]=ke[k]=ke[$]=ke[Ae]=ke[Oe]=ke[Ie]=ke[Me]=!0,ke[Q]=ke[A]=ke[oe]=!1;function He(ve,ye,Ve,ft,Qe,We){var $e,Ke=ye&O,yt=ye&P,et=ye&z;if(Ve&&($e=Qe?Ve(ve,ft,Qe,We):Ve(ve)),$e!==void 0)return $e;if(!E(ve))return ve;var Ge=_(ve);if(Ge){if($e=y(ve),!Ke)return u(ve,$e)}else{var wt=m(ve),Rt=wt==A||wt==H;if(S(ve))return l(ve,Ke);if(wt==Y||wt==T||Rt&&!Qe){if($e=yt||Rt?{}:j(ve),!Ke)return yt?f(ve,o($e,ve)):c(ve,s($e,ve))}else{if(!ke[wt])return Qe?ve:{};$e=w(ve,wt,Ke)}}We||(We=new e);var Ft=We.get(ve);if(Ft)return Ft;We.set(ve,$e),N(ve)?ve.forEach(function(lt){$e.add(He(lt,ye,Ve,lt,ve,We))}):b(ve)&&ve.forEach(function(lt,mt){$e.set(mt,He(lt,ye,Ve,mt,ve,We))});var tt=et?yt?p:h:yt?I:C,xt=Ge?void 0:tt(ve);return n(xt||ve,function(lt,mt){xt&&(mt=lt,lt=ve[mt]),i($e,mt,He(lt,ye,Ve,mt,ve,We))}),$e}return th=He,th}var nh,s1;function BO(){if(s1)return nh;s1=1;var e=AN(),n=4;function i(s){return e(s,n)}return nh=i,nh}var rh,o1;function bv(){if(o1)return rh;o1=1;function e(n){return function(){return n}}return rh=e,rh}var ih,a1;function UO(){if(a1)return ih;a1=1;function e(n){return function(i,s,o){for(var l=-1,u=Object(i),c=o(i),f=c.length;f--;){var h=c[n?f:++l];if(s(u[h],h,u)===!1)break}return i}}return ih=e,ih}var sh,l1;function kv(){if(l1)return sh;l1=1;var e=UO(),n=e();return sh=n,sh}var oh,u1;function Ev(){if(u1)return oh;u1=1;var e=kv(),n=pi();function i(s,o){return s&&e(s,o,n)}return oh=i,oh}var ah,c1;function HO(){if(c1)return ah;c1=1;var e=Ir();function n(i,s){return function(o,l){if(o==null)return o;if(!e(o))return i(o,l);for(var u=o.length,c=s?u:-1,f=Object(o);(s?c--:++c<u)&&l(f[c],c,f)!==!1;);return o}}return ah=n,ah}var lh,d1;function iu(){if(d1)return lh;d1=1;var e=Ev(),n=HO(),i=n(e);return lh=i,lh}var uh,f1;function Zi(){if(f1)return uh;f1=1;function e(n){return n}return uh=e,uh}var ch,h1;function IN(){if(h1)return ch;h1=1;var e=Zi();function n(i){return typeof i=="function"?i:e}return ch=n,ch}var dh,p1;function MN(){if(p1)return dh;p1=1;var e=gv(),n=iu(),i=IN(),s=St();function o(l,u){var c=s(l)?e:n;return c(l,i(u))}return dh=o,dh}var fh,m1;function PN(){return m1||(m1=1,fh=MN()),fh}var hh,g1;function VO(){if(g1)return hh;g1=1;var e=iu();function n(i,s){var o=[];return e(i,function(l,u,c){s(l,u,c)&&o.push(l)}),o}return hh=n,hh}var ph,v1;function WO(){if(v1)return ph;v1=1;var e="__lodash_hash_undefined__";function n(i){return this.__data__.set(i,e),this}return ph=n,ph}var mh,y1;function GO(){if(y1)return mh;y1=1;function e(n){return this.__data__.has(n)}return mh=e,mh}var gh,w1;function ON(){if(w1)return gh;w1=1;var e=mv(),n=WO(),i=GO();function s(o){var l=-1,u=o==null?0:o.length;for(this.__data__=new e;++l<u;)this.add(o[l])}return s.prototype.add=s.prototype.push=n,s.prototype.has=i,gh=s,gh}var vh,x1;function YO(){if(x1)return vh;x1=1;function e(n,i){for(var s=-1,o=n==null?0:n.length;++s<o;)if(i(n[s],s,n))return!0;return!1}return vh=e,vh}var yh,_1;function qN(){if(_1)return yh;_1=1;function e(n,i){return n.has(i)}return yh=e,yh}var wh,S1;function LN(){if(S1)return wh;S1=1;var e=ON(),n=YO(),i=qN(),s=1,o=2;function l(u,c,f,h,p,m){var y=f&s,w=u.length,j=c.length;if(w!=j&&!(y&&j>w))return!1;var _=m.get(u),S=m.get(c);if(_&&S)return _==c&&S==u;var b=-1,E=!0,N=f&o?new e:void 0;for(m.set(u,c),m.set(c,u);++b<w;){var C=u[b],I=c[b];if(h)var O=y?h(I,C,b,c,u,m):h(C,I,b,u,c,m);if(O!==void 0){if(O)continue;E=!1;break}if(N){if(!n(c,function(P,z){if(!i(N,z)&&(C===P||p(C,P,f,h,m)))return N.push(z)})){E=!1;break}}else if(!(C===I||p(C,I,f,h,m))){E=!1;break}}return m.delete(u),m.delete(c),E}return wh=l,wh}var xh,b1;function KO(){if(b1)return xh;b1=1;function e(n){var i=-1,s=Array(n.size);return n.forEach(function(o,l){s[++i]=[l,o]}),s}return xh=e,xh}var _h,k1;function Nv(){if(k1)return _h;k1=1;function e(n){var i=-1,s=Array(n.size);return n.forEach(function(o){s[++i]=o}),s}return _h=e,_h}var Sh,E1;function XO(){if(E1)return Sh;E1=1;var e=Vs(),n=CN(),i=Hs(),s=LN(),o=KO(),l=Nv(),u=1,c=2,f="[object Boolean]",h="[object Date]",p="[object Error]",m="[object Map]",y="[object Number]",w="[object RegExp]",j="[object Set]",_="[object String]",S="[object Symbol]",b="[object ArrayBuffer]",E="[object DataView]",N=e?e.prototype:void 0,C=N?N.valueOf:void 0;function I(O,P,z,T,q,B,Z){switch(z){case E:if(O.byteLength!=P.byteLength||O.byteOffset!=P.byteOffset)return!1;O=O.buffer,P=P.buffer;case b:return!(O.byteLength!=P.byteLength||!B(new n(O),new n(P)));case f:case h:case y:return i(+O,+P);case p:return O.name==P.name&&O.message==P.message;case w:case _:return O==P+"";case m:var Q=o;case j:var A=T&u;if(Q||(Q=l),O.size!=P.size&&!A)return!1;var H=Z.get(O);if(H)return H==P;T|=c,Z.set(O,P);var U=s(Q(O),Q(P),T,q,B,Z);return Z.delete(O),U;case S:if(C)return C.call(O)==C.call(P)}return!1}return Sh=I,Sh}var bh,N1;function QO(){if(N1)return bh;N1=1;var e=EN(),n=1,i=Object.prototype,s=i.hasOwnProperty;function o(l,u,c,f,h,p){var m=c&n,y=e(l),w=y.length,j=e(u),_=j.length;if(w!=_&&!m)return!1;for(var S=w;S--;){var b=y[S];if(!(m?b in u:s.call(u,b)))return!1}var E=p.get(l),N=p.get(u);if(E&&N)return E==u&&N==l;var C=!0;p.set(l,u),p.set(u,l);for(var I=m;++S<w;){b=y[S];var O=l[b],P=u[b];if(f)var z=m?f(P,O,b,u,l,p):f(O,P,b,l,u,p);if(!(z===void 0?O===P||h(O,P,c,f,p):z)){C=!1;break}I||(I=b=="constructor")}if(C&&!I){var T=l.constructor,q=u.constructor;T!=q&&"constructor"in l&&"constructor"in u&&!(typeof T=="function"&&T instanceof T&&typeof q=="function"&&q instanceof q)&&(C=!1)}return p.delete(l),p.delete(u),C}return bh=o,bh}var kh,C1;function ZO(){if(C1)return kh;C1=1;var e=Ql(),n=LN(),i=XO(),s=QO(),o=Gs(),l=St(),u=Ws(),c=oa(),f=1,h="[object Arguments]",p="[object Array]",m="[object Object]",y=Object.prototype,w=y.hasOwnProperty;function j(_,S,b,E,N,C){var I=l(_),O=l(S),P=I?p:o(_),z=O?p:o(S);P=P==h?m:P,z=z==h?m:z;var T=P==m,q=z==m,B=P==z;if(B&&u(_)){if(!u(S))return!1;I=!0,T=!1}if(B&&!T)return C||(C=new e),I||c(_)?n(_,S,b,E,N,C):i(_,S,P,b,E,N,C);if(!(b&f)){var Z=T&&w.call(_,"__wrapped__"),Q=q&&w.call(S,"__wrapped__");if(Z||Q){var A=Z?_.value():_,H=Q?S.value():S;return C||(C=new e),N(A,H,b,E,C)}}return B?(C||(C=new e),s(_,S,b,E,N,C)):!1}return kh=j,kh}var Eh,j1;function $N(){if(j1)return Eh;j1=1;var e=ZO(),n=dr();function i(s,o,l,u,c){return s===o?!0:s==null||o==null||!n(s)&&!n(o)?s!==s&&o!==o:e(s,o,l,u,i,c)}return Eh=i,Eh}var Nh,R1;function JO(){if(R1)return Nh;R1=1;var e=Ql(),n=$N(),i=1,s=2;function o(l,u,c,f){var h=c.length,p=h,m=!f;if(l==null)return!p;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<p;){y=c[h];var w=y[0],j=l[w],_=y[1];if(m&&y[2]){if(j===void 0&&!(w in l))return!1}else{var S=new e;if(f)var b=f(j,_,w,l,u,S);if(!(b===void 0?n(_,j,i|s,f,S):b))return!1}}return!0}return Nh=o,Nh}var Ch,T1;function DN(){if(T1)return Ch;T1=1;var e=On();function n(i){return i===i&&!e(i)}return Ch=n,Ch}var jh,A1;function eq(){if(A1)return jh;A1=1;var e=DN(),n=pi();function i(s){for(var o=n(s),l=o.length;l--;){var u=o[l],c=s[u];o[l]=[u,c,e(c)]}return o}return jh=i,jh}var Rh,I1;function FN(){if(I1)return Rh;I1=1;function e(n,i){return function(s){return s==null?!1:s[n]===i&&(i!==void 0||n in Object(s))}}return Rh=e,Rh}var Th,M1;function tq(){if(M1)return Th;M1=1;var e=JO(),n=eq(),i=FN();function s(o){var l=n(o);return l.length==1&&l[0][2]?i(l[0][0],l[0][1]):function(u){return u===o||e(u,o,l)}}return Th=s,Th}var Ah,P1;function Ys(){if(P1)return Ah;P1=1;var e=Ki(),n=dr(),i="[object Symbol]";function s(o){return typeof o=="symbol"||n(o)&&e(o)==i}return Ah=s,Ah}var Ih,O1;function Cv(){if(O1)return Ih;O1=1;var e=St(),n=Ys(),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function o(l,u){if(e(l))return!1;var c=typeof l;return c=="number"||c=="symbol"||c=="boolean"||l==null||n(l)?!0:s.test(l)||!i.test(l)||u!=null&&l in Object(u)}return Ih=o,Ih}var Mh,q1;function nq(){if(q1)return Mh;q1=1;var e=mv(),n="Expected a function";function i(s,o){if(typeof s!="function"||o!=null&&typeof o!="function")throw new TypeError(n);var l=function(){var u=arguments,c=o?o.apply(this,u):u[0],f=l.cache;if(f.has(c))return f.get(c);var h=s.apply(this,u);return l.cache=f.set(c,h)||f,h};return l.cache=new(i.Cache||e),l}return i.Cache=e,Mh=i,Mh}var Ph,L1;function rq(){if(L1)return Ph;L1=1;var e=nq(),n=500;function i(s){var o=e(s,function(u){return l.size===n&&l.clear(),u}),l=o.cache;return o}return Ph=i,Ph}var Oh,$1;function iq(){if($1)return Oh;$1=1;var e=rq(),n=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,s=e(function(o){var l=[];return o.charCodeAt(0)===46&&l.push(""),o.replace(n,function(u,c,f,h){l.push(f?h.replace(i,"$1"):c||u)}),l});return Oh=s,Oh}var qh,D1;function su(){if(D1)return qh;D1=1;function e(n,i){for(var s=-1,o=n==null?0:n.length,l=Array(o);++s<o;)l[s]=i(n[s],s,n);return l}return qh=e,qh}var Lh,F1;function sq(){if(F1)return Lh;F1=1;var e=Vs(),n=su(),i=St(),s=Ys(),o=e?e.prototype:void 0,l=o?o.toString:void 0;function u(c){if(typeof c=="string")return c;if(i(c))return n(c,u)+"";if(s(c))return l?l.call(c):"";var f=c+"";return f=="0"&&1/c==-1/0?"-0":f}return Lh=u,Lh}var $h,z1;function zN(){if(z1)return $h;z1=1;var e=sq();function n(i){return i==null?"":e(i)}return $h=n,$h}var Dh,B1;function ou(){if(B1)return Dh;B1=1;var e=St(),n=Cv(),i=iq(),s=zN();function o(l,u){return e(l)?l:n(l,u)?[l]:i(s(l))}return Dh=o,Dh}var Fh,U1;function aa(){if(U1)return Fh;U1=1;var e=Ys();function n(i){if(typeof i=="string"||e(i))return i;var s=i+"";return s=="0"&&1/i==-1/0?"-0":s}return Fh=n,Fh}var zh,H1;function au(){if(H1)return zh;H1=1;var e=ou(),n=aa();function i(s,o){o=e(o,s);for(var l=0,u=o.length;s!=null&&l<u;)s=s[n(o[l++])];return l&&l==u?s:void 0}return zh=i,zh}var Bh,V1;function oq(){if(V1)return Bh;V1=1;var e=au();function n(i,s,o){var l=i==null?void 0:e(i,s);return l===void 0?o:l}return Bh=n,Bh}var Uh,W1;function aq(){if(W1)return Uh;W1=1;function e(n,i){return n!=null&&i in Object(n)}return Uh=e,Uh}var Hh,G1;function BN(){if(G1)return Hh;G1=1;var e=ou(),n=sa(),i=St(),s=eu(),o=vv(),l=aa();function u(c,f,h){f=e(f,c);for(var p=-1,m=f.length,y=!1;++p<m;){var w=l(f[p]);if(!(y=c!=null&&h(c,w)))break;c=c[w]}return y||++p!=m?y:(m=c==null?0:c.length,!!m&&o(m)&&s(w,m)&&(i(c)||n(c)))}return Hh=u,Hh}var Vh,Y1;function UN(){if(Y1)return Vh;Y1=1;var e=aq(),n=BN();function i(s,o){return s!=null&&n(s,o,e)}return Vh=i,Vh}var Wh,K1;function lq(){if(K1)return Wh;K1=1;var e=$N(),n=oq(),i=UN(),s=Cv(),o=DN(),l=FN(),u=aa(),c=1,f=2;function h(p,m){return s(p)&&o(m)?l(u(p),m):function(y){var w=n(y,p);return w===void 0&&w===m?i(y,p):e(m,w,c|f)}}return Wh=h,Wh}var Gh,X1;function HN(){if(X1)return Gh;X1=1;function e(n){return function(i){return i==null?void 0:i[n]}}return Gh=e,Gh}var Yh,Q1;function uq(){if(Q1)return Yh;Q1=1;var e=au();function n(i){return function(s){return e(s,i)}}return Yh=n,Yh}var Kh,Z1;function cq(){if(Z1)return Kh;Z1=1;var e=HN(),n=uq(),i=Cv(),s=aa();function o(l){return i(l)?e(s(l)):n(l)}return Kh=o,Kh}var Xh,J1;function Mr(){if(J1)return Xh;J1=1;var e=tq(),n=lq(),i=Zi(),s=St(),o=cq();function l(u){return typeof u=="function"?u:u==null?i:typeof u=="object"?s(u)?n(u[0],u[1]):e(u):o(u)}return Xh=l,Xh}var Qh,eS;function VN(){if(eS)return Qh;eS=1;var e=_N(),n=VO(),i=Mr(),s=St();function o(l,u){var c=s(l)?e:n;return c(l,i(u,3))}return Qh=o,Qh}var Zh,tS;function dq(){if(tS)return Zh;tS=1;var e=Object.prototype,n=e.hasOwnProperty;function i(s,o){return s!=null&&n.call(s,o)}return Zh=i,Zh}var Jh,nS;function WN(){if(nS)return Jh;nS=1;var e=dq(),n=BN();function i(s,o){return s!=null&&n(s,o,e)}return Jh=i,Jh}var ep,rS;function fq(){if(rS)return ep;rS=1;var e=wv(),n=Gs(),i=sa(),s=St(),o=Ir(),l=Ws(),u=nu(),c=oa(),f="[object Map]",h="[object Set]",p=Object.prototype,m=p.hasOwnProperty;function y(w){if(w==null)return!0;if(o(w)&&(s(w)||typeof w=="string"||typeof w.splice=="function"||l(w)||c(w)||i(w)))return!w.length;var j=n(w);if(j==f||j==h)return!w.size;if(u(w))return!e(w).length;for(var _ in w)if(m.call(w,_))return!1;return!0}return ep=y,ep}var tp,iS;function GN(){if(iS)return tp;iS=1;function e(n){return n===void 0}return tp=e,tp}var np,sS;function YN(){if(sS)return np;sS=1;var e=iu(),n=Ir();function i(s,o){var l=-1,u=n(s)?Array(s.length):[];return e(s,function(c,f,h){u[++l]=o(c,f,h)}),u}return np=i,np}var rp,oS;function KN(){if(oS)return rp;oS=1;var e=su(),n=Mr(),i=YN(),s=St();function o(l,u){var c=s(l)?e:i;return c(l,n(u,3))}return rp=o,rp}var ip,aS;function hq(){if(aS)return ip;aS=1;function e(n,i,s,o){var l=-1,u=n==null?0:n.length;for(o&&u&&(s=n[++l]);++l<u;)s=i(s,n[l],l,n);return s}return ip=e,ip}var sp,lS;function pq(){if(lS)return sp;lS=1;function e(n,i,s,o,l){return l(n,function(u,c,f){s=o?(o=!1,u):i(s,u,c,f)}),s}return sp=e,sp}var op,uS;function XN(){if(uS)return op;uS=1;var e=hq(),n=iu(),i=Mr(),s=pq(),o=St();function l(u,c,f){var h=o(u)?e:s,p=arguments.length<3;return h(u,i(c,4),f,p,n)}return op=l,op}var ap,cS;function mq(){if(cS)return ap;cS=1;var e=Ki(),n=St(),i=dr(),s="[object String]";function o(l){return typeof l=="string"||!n(l)&&i(l)&&e(l)==s}return ap=o,ap}var lp,dS;function gq(){if(dS)return lp;dS=1;var e=HN(),n=e("length");return lp=n,lp}var up,fS;function vq(){if(fS)return up;fS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",i="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+i+s,l="\\ufe0e\\ufe0f",u="\\u200d",c=RegExp("["+u+e+o+l+"]");function f(h){return c.test(h)}return up=f,up}var cp,hS;function yq(){if(hS)return cp;hS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",i="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+i+s,l="\\ufe0e\\ufe0f",u="["+e+"]",c="["+o+"]",f="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+f+")",p="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",j=h+"?",_="["+l+"]?",S="(?:"+w+"(?:"+[p,m,y].join("|")+")"+_+j+")*",b=_+j+S,E="(?:"+[p+c+"?",c,m,y,u].join("|")+")",N=RegExp(f+"(?="+f+")|"+E+b,"g");function C(I){for(var O=N.lastIndex=0;N.test(I);)++O;return O}return cp=C,cp}var dp,pS;function wq(){if(pS)return dp;pS=1;var e=gq(),n=vq(),i=yq();function s(o){return n(o)?i(o):e(o)}return dp=s,dp}var fp,mS;function xq(){if(mS)return fp;mS=1;var e=wv(),n=Gs(),i=Ir(),s=mq(),o=wq(),l="[object Map]",u="[object Set]";function c(f){if(f==null)return 0;if(i(f))return s(f)?o(f):f.length;var h=n(f);return h==l||h==u?f.size:e(f).length}return fp=c,fp}var hp,gS;function _q(){if(gS)return hp;gS=1;var e=gv(),n=RN(),i=Ev(),s=Mr(),o=ru(),l=St(),u=Ws(),c=ra(),f=On(),h=oa();function p(m,y,w){var j=l(m),_=j||u(m)||h(m);if(y=s(y,4),w==null){var S=m&&m.constructor;_?w=j?new S:[]:f(m)?w=c(S)?n(o(m)):{}:w={}}return(_?e:i)(m,function(b,E,N){return y(w,b,E,N)}),w}return hp=p,hp}var pp,vS;function Sq(){if(vS)return pp;vS=1;var e=Vs(),n=sa(),i=St(),s=e?e.isConcatSpreadable:void 0;function o(l){return i(l)||n(l)||!!(s&&l&&l[s])}return pp=o,pp}var mp,yS;function jv(){if(yS)return mp;yS=1;var e=_v(),n=Sq();function i(s,o,l,u,c){var f=-1,h=s.length;for(l||(l=n),c||(c=[]);++f<h;){var p=s[f];o>0&&l(p)?o>1?i(p,o-1,l,u,c):e(c,p):u||(c[c.length]=p)}return c}return mp=i,mp}var gp,wS;function bq(){if(wS)return gp;wS=1;function e(n,i,s){switch(s.length){case 0:return n.call(i);case 1:return n.call(i,s[0]);case 2:return n.call(i,s[0],s[1]);case 3:return n.call(i,s[0],s[1],s[2])}return n.apply(i,s)}return gp=e,gp}var vp,xS;function QN(){if(xS)return vp;xS=1;var e=bq(),n=Math.max;function i(s,o,l){return o=n(o===void 0?s.length-1:o,0),function(){for(var u=arguments,c=-1,f=n(u.length-o,0),h=Array(f);++c<f;)h[c]=u[o+c];c=-1;for(var p=Array(o+1);++c<o;)p[c]=u[c];return p[o]=l(h),e(s,this,p)}}return vp=i,vp}var yp,_S;function kq(){if(_S)return yp;_S=1;var e=bv(),n=gN(),i=Zi(),s=n?function(o,l){return n(o,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:i;return yp=s,yp}var wp,SS;function Eq(){if(SS)return wp;SS=1;var e=800,n=16,i=Date.now;function s(o){var l=0,u=0;return function(){var c=i(),f=n-(c-u);if(u=c,f>0){if(++l>=e)return arguments[0]}else l=0;return o.apply(void 0,arguments)}}return wp=s,wp}var xp,bS;function ZN(){if(bS)return xp;bS=1;var e=kq(),n=Eq(),i=n(e);return xp=i,xp}var _p,kS;function lu(){if(kS)return _p;kS=1;var e=Zi(),n=QN(),i=ZN();function s(o,l){return i(n(o,l,e),o+"")}return _p=s,_p}var Sp,ES;function JN(){if(ES)return Sp;ES=1;function e(n,i,s,o){for(var l=n.length,u=s+(o?1:-1);o?u--:++u<l;)if(i(n[u],u,n))return u;return-1}return Sp=e,Sp}var bp,NS;function Nq(){if(NS)return bp;NS=1;function e(n){return n!==n}return bp=e,bp}var kp,CS;function Cq(){if(CS)return kp;CS=1;function e(n,i,s){for(var o=s-1,l=n.length;++o<l;)if(n[o]===i)return o;return-1}return kp=e,kp}var Ep,jS;function jq(){if(jS)return Ep;jS=1;var e=JN(),n=Nq(),i=Cq();function s(o,l,u){return l===l?i(o,l,u):e(o,n,u)}return Ep=s,Ep}var Np,RS;function Rq(){if(RS)return Np;RS=1;var e=jq();function n(i,s){var o=i==null?0:i.length;return!!o&&e(i,s,0)>-1}return Np=n,Np}var Cp,TS;function Tq(){if(TS)return Cp;TS=1;function e(n,i,s){for(var o=-1,l=n==null?0:n.length;++o<l;)if(s(i,n[o]))return!0;return!1}return Cp=e,Cp}var jp,AS;function Aq(){if(AS)return jp;AS=1;function e(){}return jp=e,jp}var Rp,IS;function Iq(){if(IS)return Rp;IS=1;var e=NN(),n=Aq(),i=Nv(),s=1/0,o=e&&1/i(new e([,-0]))[1]==s?function(l){return new e(l)}:n;return Rp=o,Rp}var Tp,MS;function Mq(){if(MS)return Tp;MS=1;var e=ON(),n=Rq(),i=Tq(),s=qN(),o=Iq(),l=Nv(),u=200;function c(f,h,p){var m=-1,y=n,w=f.length,j=!0,_=[],S=_;if(p)j=!1,y=i;else if(w>=u){var b=h?null:o(f);if(b)return l(b);j=!1,y=s,S=new e}else S=h?[]:_;e:for(;++m<w;){var E=f[m],N=h?h(E):E;if(E=p||E!==0?E:0,j&&N===N){for(var C=S.length;C--;)if(S[C]===N)continue e;h&&S.push(N),_.push(E)}else y(S,N,p)||(S!==_&&S.push(N),_.push(E))}return _}return Tp=c,Tp}var Ap,PS;function eC(){if(PS)return Ap;PS=1;var e=Ir(),n=dr();function i(s){return n(s)&&e(s)}return Ap=i,Ap}var Ip,OS;function Pq(){if(OS)return Ip;OS=1;var e=jv(),n=lu(),i=Mq(),s=eC(),o=n(function(l){return i(e(l,1,s,!0))});return Ip=o,Ip}var Mp,qS;function Oq(){if(qS)return Mp;qS=1;var e=su();function n(i,s){return e(s,function(o){return i[o]})}return Mp=n,Mp}var Pp,LS;function tC(){if(LS)return Pp;LS=1;var e=Oq(),n=pi();function i(s){return s==null?[]:e(s,n(s))}return Pp=i,Pp}var Op,$S;function qn(){if($S)return Op;$S=1;var e;if(typeof hv=="function")try{e={clone:BO(),constant:bv(),each:PN(),filter:VN(),has:WN(),isArray:St(),isEmpty:fq(),isFunction:ra(),isUndefined:GN(),keys:pi(),map:KN(),reduce:XN(),size:xq(),transform:_q(),union:Pq(),values:tC()}}catch{}return e||(e=window._),Op=e,Op}var qp,DS;function Rv(){if(DS)return qp;DS=1;var e=qn();qp=o;var n="\0",i="\0",s="";function o(p){this._isDirected=e.has(p,"directed")?p.directed:!0,this._isMultigraph=e.has(p,"multigraph")?p.multigraph:!1,this._isCompound=e.has(p,"compound")?p.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[i]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(p){return this._label=p,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(p){return e.isFunction(p)||(p=e.constant(p)),this._defaultNodeLabelFn=p,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var p=this;return e.filter(this.nodes(),function(m){return e.isEmpty(p._in[m])})},o.prototype.sinks=function(){var p=this;return e.filter(this.nodes(),function(m){return e.isEmpty(p._out[m])})},o.prototype.setNodes=function(p,m){var y=arguments,w=this;return e.each(p,function(j){y.length>1?w.setNode(j,m):w.setNode(j)}),this},o.prototype.setNode=function(p,m){return e.has(this._nodes,p)?(arguments.length>1&&(this._nodes[p]=m),this):(this._nodes[p]=arguments.length>1?m:this._defaultNodeLabelFn(p),this._isCompound&&(this._parent[p]=i,this._children[p]={},this._children[i][p]=!0),this._in[p]={},this._preds[p]={},this._out[p]={},this._sucs[p]={},++this._nodeCount,this)},o.prototype.node=function(p){return this._nodes[p]},o.prototype.hasNode=function(p){return e.has(this._nodes,p)},o.prototype.removeNode=function(p){var m=this;if(e.has(this._nodes,p)){var y=function(w){m.removeEdge(m._edgeObjs[w])};delete this._nodes[p],this._isCompound&&(this._removeFromParentsChildList(p),delete this._parent[p],e.each(this.children(p),function(w){m.setParent(w)}),delete this._children[p]),e.each(e.keys(this._in[p]),y),delete this._in[p],delete this._preds[p],e.each(e.keys(this._out[p]),y),delete this._out[p],delete this._sucs[p],--this._nodeCount}return this},o.prototype.setParent=function(p,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(m))m=i;else{m+="";for(var y=m;!e.isUndefined(y);y=this.parent(y))if(y===p)throw new Error("Setting "+m+" as parent of "+p+" would create a cycle");this.setNode(m)}return this.setNode(p),this._removeFromParentsChildList(p),this._parent[p]=m,this._children[m][p]=!0,this},o.prototype._removeFromParentsChildList=function(p){delete this._children[this._parent[p]][p]},o.prototype.parent=function(p){if(this._isCompound){var m=this._parent[p];if(m!==i)return m}},o.prototype.children=function(p){if(e.isUndefined(p)&&(p=i),this._isCompound){var m=this._children[p];if(m)return e.keys(m)}else{if(p===i)return this.nodes();if(this.hasNode(p))return[]}},o.prototype.predecessors=function(p){var m=this._preds[p];if(m)return e.keys(m)},o.prototype.successors=function(p){var m=this._sucs[p];if(m)return e.keys(m)},o.prototype.neighbors=function(p){var m=this.predecessors(p);if(m)return e.union(m,this.successors(p))},o.prototype.isLeaf=function(p){var m;return this.isDirected()?m=this.successors(p):m=this.neighbors(p),m.length===0},o.prototype.filterNodes=function(p){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){p(S)&&m.setNode(S,_)}),e.each(this._edgeObjs,function(_){m.hasNode(_.v)&&m.hasNode(_.w)&&m.setEdge(_,y.edge(_))});var w={};function j(_){var S=y.parent(_);return S===void 0||m.hasNode(S)?(w[_]=S,S):S in w?w[S]:j(S)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,j(_))}),m},o.prototype.setDefaultEdgeLabel=function(p){return e.isFunction(p)||(p=e.constant(p)),this._defaultEdgeLabelFn=p,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(p,m){var y=this,w=arguments;return e.reduce(p,function(j,_){return w.length>1?y.setEdge(j,_,m):y.setEdge(j,_),_}),this},o.prototype.setEdge=function(){var p,m,y,w,j=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(p=_.v,m=_.w,y=_.name,arguments.length===2&&(w=arguments[1],j=!0)):(p=_,m=arguments[1],y=arguments[3],arguments.length>2&&(w=arguments[2],j=!0)),p=""+p,m=""+m,e.isUndefined(y)||(y=""+y);var S=c(this._isDirected,p,m,y);if(e.has(this._edgeLabels,S))return j&&(this._edgeLabels[S]=w),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(p),this.setNode(m),this._edgeLabels[S]=j?w:this._defaultEdgeLabelFn(p,m,y);var b=f(this._isDirected,p,m,y);return p=b.v,m=b.w,Object.freeze(b),this._edgeObjs[S]=b,l(this._preds[m],p),l(this._sucs[p],m),this._in[m][S]=b,this._out[p][S]=b,this._edgeCount++,this},o.prototype.edge=function(p,m,y){var w=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y);return this._edgeLabels[w]},o.prototype.hasEdge=function(p,m,y){var w=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y);return e.has(this._edgeLabels,w)},o.prototype.removeEdge=function(p,m,y){var w=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y),j=this._edgeObjs[w];return j&&(p=j.v,m=j.w,delete this._edgeLabels[w],delete this._edgeObjs[w],u(this._preds[m],p),u(this._sucs[p],m),delete this._in[m][w],delete this._out[p][w],this._edgeCount--),this},o.prototype.inEdges=function(p,m){var y=this._in[p];if(y){var w=e.values(y);return m?e.filter(w,function(j){return j.v===m}):w}},o.prototype.outEdges=function(p,m){var y=this._out[p];if(y){var w=e.values(y);return m?e.filter(w,function(j){return j.w===m}):w}},o.prototype.nodeEdges=function(p,m){var y=this.inEdges(p,m);if(y)return y.concat(this.outEdges(p,m))};function l(p,m){p[m]?p[m]++:p[m]=1}function u(p,m){--p[m]||delete p[m]}function c(p,m,y,w){var j=""+m,_=""+y;if(!p&&j>_){var S=j;j=_,_=S}return j+s+_+s+(e.isUndefined(w)?n:w)}function f(p,m,y,w){var j=""+m,_=""+y;if(!p&&j>_){var S=j;j=_,_=S}var b={v:j,w:_};return w&&(b.name=w),b}function h(p,m){return c(p,m.v,m.w,m.name)}return qp}var Lp,FS;function qq(){return FS||(FS=1,Lp="2.1.8"),Lp}var $p,zS;function Lq(){return zS||(zS=1,$p={Graph:Rv(),version:qq()}),$p}var Dp,BS;function $q(){if(BS)return Dp;BS=1;var e=qn(),n=Rv();Dp={write:i,read:l};function i(u){var c={options:{directed:u.isDirected(),multigraph:u.isMultigraph(),compound:u.isCompound()},nodes:s(u),edges:o(u)};return e.isUndefined(u.graph())||(c.value=e.clone(u.graph())),c}function s(u){return e.map(u.nodes(),function(c){var f=u.node(c),h=u.parent(c),p={v:c};return e.isUndefined(f)||(p.value=f),e.isUndefined(h)||(p.parent=h),p})}function o(u){return e.map(u.edges(),function(c){var f=u.edge(c),h={v:c.v,w:c.w};return e.isUndefined(c.name)||(h.name=c.name),e.isUndefined(f)||(h.value=f),h})}function l(u){var c=new n(u.options).setGraph(u.value);return e.each(u.nodes,function(f){c.setNode(f.v,f.value),f.parent&&c.setParent(f.v,f.parent)}),e.each(u.edges,function(f){c.setEdge({v:f.v,w:f.w,name:f.name},f.value)}),c}return Dp}var Fp,US;function Dq(){if(US)return Fp;US=1;var e=qn();Fp=n;function n(i){var s={},o=[],l;function u(c){e.has(s,c)||(s[c]=!0,l.push(c),e.each(i.successors(c),u),e.each(i.predecessors(c),u))}return e.each(i.nodes(),function(c){l=[],u(c),l.length&&o.push(l)}),o}return Fp}var zp,HS;function nC(){if(HS)return zp;HS=1;var e=qn();zp=n;function n(){this._arr=[],this._keyIndices={}}return n.prototype.size=function(){return this._arr.length},n.prototype.keys=function(){return this._arr.map(function(i){return i.key})},n.prototype.has=function(i){return e.has(this._keyIndices,i)},n.prototype.priority=function(i){var s=this._keyIndices[i];if(s!==void 0)return this._arr[s].priority},n.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},n.prototype.add=function(i,s){var o=this._keyIndices;if(i=String(i),!e.has(o,i)){var l=this._arr,u=l.length;return o[i]=u,l.push({key:i,priority:s}),this._decrease(u),!0}return!1},n.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var i=this._arr.pop();return delete this._keyIndices[i.key],this._heapify(0),i.key},n.prototype.decrease=function(i,s){var o=this._keyIndices[i];if(s>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+i+" Old: "+this._arr[o].priority+" New: "+s);this._arr[o].priority=s,this._decrease(o)},n.prototype._heapify=function(i){var s=this._arr,o=2*i,l=o+1,u=i;o<s.length&&(u=s[o].priority<s[u].priority?o:u,l<s.length&&(u=s[l].priority<s[u].priority?l:u),u!==i&&(this._swap(i,u),this._heapify(u)))},n.prototype._decrease=function(i){for(var s=this._arr,o=s[i].priority,l;i!==0&&(l=i>>1,!(s[l].priority<o));)this._swap(i,l),i=l},n.prototype._swap=function(i,s){var o=this._arr,l=this._keyIndices,u=o[i],c=o[s];o[i]=c,o[s]=u,l[c.key]=i,l[u.key]=s},zp}var Bp,VS;function rC(){if(VS)return Bp;VS=1;var e=qn(),n=nC();Bp=s;var i=e.constant(1);function s(l,u,c,f){return o(l,String(u),c||i,f||function(h){return l.outEdges(h)})}function o(l,u,c,f){var h={},p=new n,m,y,w=function(j){var _=j.v!==m?j.v:j.w,S=h[_],b=c(j),E=y.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+j+" Weight: "+b);E<S.distance&&(S.distance=E,S.predecessor=m,p.decrease(_,E))};for(l.nodes().forEach(function(j){var _=j===u?0:Number.POSITIVE_INFINITY;h[j]={distance:_},p.add(j,_)});p.size()>0&&(m=p.removeMin(),y=h[m],y.distance!==Number.POSITIVE_INFINITY);)f(m).forEach(w);return h}return Bp}var Up,WS;function Fq(){if(WS)return Up;WS=1;var e=rC(),n=qn();Up=i;function i(s,o,l){return n.transform(s.nodes(),function(u,c){u[c]=e(s,c,o,l)},{})}return Up}var Hp,GS;function iC(){if(GS)return Hp;GS=1;var e=qn();Hp=n;function n(i){var s=0,o=[],l={},u=[];function c(f){var h=l[f]={onStack:!0,lowlink:s,index:s++};if(o.push(f),i.successors(f).forEach(function(y){e.has(l,y)?l[y].onStack&&(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 p=[],m;do m=o.pop(),l[m].onStack=!1,p.push(m);while(f!==m);u.push(p)}}return i.nodes().forEach(function(f){e.has(l,f)||c(f)}),u}return Hp}var Vp,YS;function zq(){if(YS)return Vp;YS=1;var e=qn(),n=iC();Vp=i;function i(s){return e.filter(n(s),function(o){return o.length>1||o.length===1&&s.hasEdge(o[0],o[0])})}return Vp}var Wp,KS;function Bq(){if(KS)return Wp;KS=1;var e=qn();Wp=i;var n=e.constant(1);function i(o,l,u){return s(o,l||n,u||function(c){return o.outEdges(c)})}function s(o,l,u){var c={},f=o.nodes();return f.forEach(function(h){c[h]={},c[h][h]={distance:0},f.forEach(function(p){h!==p&&(c[h][p]={distance:Number.POSITIVE_INFINITY})}),u(h).forEach(function(p){var m=p.v===h?p.w:p.v,y=l(p);c[h][m]={distance:y,predecessor:h}})}),f.forEach(function(h){var p=c[h];f.forEach(function(m){var y=c[m];f.forEach(function(w){var j=y[h],_=p[w],S=y[w],b=j.distance+_.distance;b<S.distance&&(S.distance=b,S.predecessor=_.predecessor)})})}),c}return Wp}var Gp,XS;function sC(){if(XS)return Gp;XS=1;var e=qn();Gp=n,n.CycleException=i;function n(s){var o={},l={},u=[];function c(f){if(e.has(l,f))throw new i;e.has(o,f)||(l[f]=!0,o[f]=!0,e.each(s.predecessors(f),c),delete l[f],u.push(f))}if(e.each(s.sinks(),c),e.size(o)!==s.nodeCount())throw new i;return u}function i(){}return i.prototype=new Error,Gp}var Yp,QS;function Uq(){if(QS)return Yp;QS=1;var e=sC();Yp=n;function n(i){try{e(i)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return Yp}var Kp,ZS;function oC(){if(ZS)return Kp;ZS=1;var e=qn();Kp=n;function n(s,o,l){e.isArray(o)||(o=[o]);var u=(s.isDirected()?s.successors:s.neighbors).bind(s),c=[],f={};return e.each(o,function(h){if(!s.hasNode(h))throw new Error("Graph does not have node: "+h);i(s,h,l==="post",f,u,c)}),c}function i(s,o,l,u,c,f){e.has(u,o)||(u[o]=!0,l||f.push(o),e.each(c(o),function(h){i(s,h,l,u,c,f)}),l&&f.push(o))}return Kp}var Xp,JS;function Hq(){if(JS)return Xp;JS=1;var e=oC();Xp=n;function n(i,s){return e(i,s,"post")}return Xp}var Qp,eb;function Vq(){if(eb)return Qp;eb=1;var e=oC();Qp=n;function n(i,s){return e(i,s,"pre")}return Qp}var Zp,tb;function Wq(){if(tb)return Zp;tb=1;var e=qn(),n=Rv(),i=nC();Zp=s;function s(o,l){var u=new n,c={},f=new i,h;function p(y){var w=y.v===h?y.w:y.v,j=f.priority(w);if(j!==void 0){var _=l(y);_<j&&(c[w]=h,f.decrease(w,_))}}if(o.nodeCount()===0)return u;e.each(o.nodes(),function(y){f.add(y,Number.POSITIVE_INFINITY),u.setNode(y)}),f.decrease(o.nodes()[0],0);for(var m=!1;f.size()>0;){if(h=f.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(p)}return u}return Zp}var Jp,nb;function Gq(){return nb||(nb=1,Jp={components:Dq(),dijkstra:rC(),dijkstraAll:Fq(),findCycles:zq(),floydWarshall:Bq(),isAcyclic:Uq(),postorder:Hq(),preorder:Vq(),prim:Wq(),tarjan:iC(),topsort:sC()}),Jp}var em,rb;function Yq(){if(rb)return em;rb=1;var e=Lq();return em={Graph:e.Graph,json:$q(),alg:Gq(),version:e.version},em}var tm,ib;function Zn(){if(ib)return tm;ib=1;var e;if(typeof hv=="function")try{e=Yq()}catch{}return e||(e=window.graphlib),tm=e,tm}var nm,sb;function Kq(){if(sb)return nm;sb=1;var e=AN(),n=1,i=4;function s(o){return e(o,n|i)}return nm=s,nm}var rm,ob;function uu(){if(ob)return rm;ob=1;var e=Hs(),n=Ir(),i=eu(),s=On();function o(l,u,c){if(!s(c))return!1;var f=typeof u;return(f=="number"?n(c)&&i(u,c.length):f=="string"&&u in c)?e(c[u],l):!1}return rm=o,rm}var im,ab;function Xq(){if(ab)return im;ab=1;var e=lu(),n=Hs(),i=uu(),s=Qi(),o=Object.prototype,l=o.hasOwnProperty,u=e(function(c,f){c=Object(c);var h=-1,p=f.length,m=p>2?f[2]:void 0;for(m&&i(f[0],f[1],m)&&(p=1);++h<p;)for(var y=f[h],w=s(y),j=-1,_=w.length;++j<_;){var S=w[j],b=c[S];(b===void 0||n(b,o[S])&&!l.call(c,S))&&(c[S]=y[S])}return c});return im=u,im}var sm,lb;function Qq(){if(lb)return sm;lb=1;var e=Mr(),n=Ir(),i=pi();function s(o){return function(l,u,c){var f=Object(l);if(!n(l)){var h=e(u,3);l=i(l),u=function(m){return h(f[m],m,f)}}var p=o(l,u,c);return p>-1?f[h?l[p]:p]:void 0}}return sm=s,sm}var om,ub;function Zq(){if(ub)return om;ub=1;var e=/\s/;function n(i){for(var s=i.length;s--&&e.test(i.charAt(s)););return s}return om=n,om}var am,cb;function Jq(){if(cb)return am;cb=1;var e=Zq(),n=/^\s+/;function i(s){return s&&s.slice(0,e(s)+1).replace(n,"")}return am=i,am}var lm,db;function eL(){if(db)return lm;db=1;var e=Jq(),n=On(),i=Ys(),s=NaN,o=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;function f(h){if(typeof h=="number")return h;if(i(h))return s;if(n(h)){var p=typeof h.valueOf=="function"?h.valueOf():h;h=n(p)?p+"":p}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 lm=f,lm}var um,fb;function aC(){if(fb)return um;fb=1;var e=eL(),n=1/0,i=17976931348623157e292;function s(o){if(!o)return o===0?o:0;if(o=e(o),o===n||o===-n){var l=o<0?-1:1;return l*i}return o===o?o:0}return um=s,um}var cm,hb;function tL(){if(hb)return cm;hb=1;var e=aC();function n(i){var s=e(i),o=s%1;return s===s?o?s-o:s:0}return cm=n,cm}var dm,pb;function nL(){if(pb)return dm;pb=1;var e=JN(),n=Mr(),i=tL(),s=Math.max;function o(l,u,c){var f=l==null?0:l.length;if(!f)return-1;var h=c==null?0:i(c);return h<0&&(h=s(f+h,0)),e(l,n(u,3),h)}return dm=o,dm}var fm,mb;function rL(){if(mb)return fm;mb=1;var e=Qq(),n=nL(),i=e(n);return fm=i,fm}var hm,gb;function lC(){if(gb)return hm;gb=1;var e=jv();function n(i){var s=i==null?0:i.length;return s?e(i,1):[]}return hm=n,hm}var pm,vb;function iL(){if(vb)return pm;vb=1;var e=kv(),n=IN(),i=Qi();function s(o,l){return o==null?o:e(o,n(l),i)}return pm=s,pm}var mm,yb;function sL(){if(yb)return mm;yb=1;function e(n){var i=n==null?0:n.length;return i?n[i-1]:void 0}return mm=e,mm}var gm,wb;function oL(){if(wb)return gm;wb=1;var e=Zl(),n=Ev(),i=Mr();function s(o,l){var u={};return l=i(l,3),n(o,function(c,f,h){e(u,f,l(c,f,h))}),u}return gm=s,gm}var vm,xb;function Tv(){if(xb)return vm;xb=1;var e=Ys();function n(i,s,o){for(var l=-1,u=i.length;++l<u;){var c=i[l],f=s(c);if(f!=null&&(h===void 0?f===f&&!e(f):o(f,h)))var h=f,p=c}return p}return vm=n,vm}var ym,_b;function aL(){if(_b)return ym;_b=1;function e(n,i){return n>i}return ym=e,ym}var wm,Sb;function lL(){if(Sb)return wm;Sb=1;var e=Tv(),n=aL(),i=Zi();function s(o){return o&&o.length?e(o,i,n):void 0}return wm=s,wm}var xm,bb;function uC(){if(bb)return xm;bb=1;var e=Zl(),n=Hs();function i(s,o,l){(l!==void 0&&!n(s[o],l)||l===void 0&&!(o in s))&&e(s,o,l)}return xm=i,xm}var _m,kb;function uL(){if(kb)return _m;kb=1;var e=Ki(),n=ru(),i=dr(),s="[object Object]",o=Function.prototype,l=Object.prototype,u=o.toString,c=l.hasOwnProperty,f=u.call(Object);function h(p){if(!i(p)||e(p)!=s)return!1;var m=n(p);if(m===null)return!0;var y=c.call(m,"constructor")&&m.constructor;return typeof y=="function"&&y instanceof y&&u.call(y)==f}return _m=h,_m}var Sm,Eb;function cC(){if(Eb)return Sm;Eb=1;function e(n,i){if(!(i==="constructor"&&typeof n[i]=="function")&&i!="__proto__")return n[i]}return Sm=e,Sm}var bm,Nb;function cL(){if(Nb)return bm;Nb=1;var e=ia(),n=Qi();function i(s){return e(s,n(s))}return bm=i,bm}var km,Cb;function dL(){if(Cb)return km;Cb=1;var e=uC(),n=wN(),i=jN(),s=xN(),o=TN(),l=sa(),u=St(),c=eC(),f=Ws(),h=ra(),p=On(),m=uL(),y=oa(),w=cC(),j=cL();function _(S,b,E,N,C,I,O){var P=w(S,E),z=w(b,E),T=O.get(z);if(T){e(S,E,T);return}var q=I?I(P,z,E+"",S,b,O):void 0,B=q===void 0;if(B){var Z=u(z),Q=!Z&&f(z),A=!Z&&!Q&&y(z);q=z,Z||Q||A?u(P)?q=P:c(P)?q=s(P):Q?(B=!1,q=n(z,!0)):A?(B=!1,q=i(z,!0)):q=[]:m(z)||l(z)?(q=P,l(P)?q=j(P):(!p(P)||h(P))&&(q=o(z))):B=!1}B&&(O.set(z,q),C(q,z,N,I,O),O.delete(z)),e(S,E,q)}return km=_,km}var Em,jb;function fL(){if(jb)return Em;jb=1;var e=Ql(),n=uC(),i=kv(),s=dL(),o=On(),l=Qi(),u=cC();function c(f,h,p,m,y){f!==h&&i(h,function(w,j){if(y||(y=new e),o(w))s(f,h,j,p,c,m,y);else{var _=m?m(u(f,j),w,j+"",f,h,y):void 0;_===void 0&&(_=w),n(f,j,_)}},l)}return Em=c,Em}var Nm,Rb;function hL(){if(Rb)return Nm;Rb=1;var e=lu(),n=uu();function i(s){return e(function(o,l){var u=-1,c=l.length,f=c>1?l[c-1]:void 0,h=c>2?l[2]:void 0;for(f=s.length>3&&typeof f=="function"?(c--,f):void 0,h&&n(l[0],l[1],h)&&(f=c<3?void 0:f,c=1),o=Object(o);++u<c;){var p=l[u];p&&s(o,p,u,f)}return o})}return Nm=i,Nm}var Cm,Tb;function pL(){if(Tb)return Cm;Tb=1;var e=fL(),n=hL(),i=n(function(s,o,l){e(s,o,l)});return Cm=i,Cm}var jm,Ab;function dC(){if(Ab)return jm;Ab=1;function e(n,i){return n<i}return jm=e,jm}var Rm,Ib;function mL(){if(Ib)return Rm;Ib=1;var e=Tv(),n=dC(),i=Zi();function s(o){return o&&o.length?e(o,i,n):void 0}return Rm=s,Rm}var Tm,Mb;function gL(){if(Mb)return Tm;Mb=1;var e=Tv(),n=Mr(),i=dC();function s(o,l){return o&&o.length?e(o,n(l,2),i):void 0}return Tm=s,Tm}var Am,Pb;function vL(){if(Pb)return Am;Pb=1;var e=er(),n=function(){return e.Date.now()};return Am=n,Am}var Im,Ob;function yL(){if(Ob)return Im;Ob=1;var e=Jl(),n=ou(),i=eu(),s=On(),o=aa();function l(u,c,f,h){if(!s(u))return u;c=n(c,u);for(var p=-1,m=c.length,y=m-1,w=u;w!=null&&++p<m;){var j=o(c[p]),_=f;if(j==="__proto__"||j==="constructor"||j==="prototype")return u;if(p!=y){var S=w[j];_=h?h(S,j,w):void 0,_===void 0&&(_=s(S)?S:i(c[p+1])?[]:{})}e(w,j,_),w=w[j]}return u}return Im=l,Im}var Mm,qb;function wL(){if(qb)return Mm;qb=1;var e=au(),n=yL(),i=ou();function s(o,l,u){for(var c=-1,f=l.length,h={};++c<f;){var p=l[c],m=e(o,p);u(m,p)&&n(h,i(p,o),m)}return h}return Mm=s,Mm}var Pm,Lb;function xL(){if(Lb)return Pm;Lb=1;var e=wL(),n=UN();function i(s,o){return e(s,o,function(l,u){return n(s,u)})}return Pm=i,Pm}var Om,$b;function _L(){if($b)return Om;$b=1;var e=lC(),n=QN(),i=ZN();function s(o){return i(n(o,void 0,e),o+"")}return Om=s,Om}var qm,Db;function SL(){if(Db)return qm;Db=1;var e=xL(),n=_L(),i=n(function(s,o){return s==null?{}:e(s,o)});return qm=i,qm}var Lm,Fb;function bL(){if(Fb)return Lm;Fb=1;var e=Math.ceil,n=Math.max;function i(s,o,l,u){for(var c=-1,f=n(e((o-s)/(l||1)),0),h=Array(f);f--;)h[u?f:++c]=s,s+=l;return h}return Lm=i,Lm}var $m,zb;function kL(){if(zb)return $m;zb=1;var e=bL(),n=uu(),i=aC();function s(o){return function(l,u,c){return c&&typeof c!="number"&&n(l,u,c)&&(u=c=void 0),l=i(l),u===void 0?(u=l,l=0):u=i(u),c=c===void 0?l<u?1:-1:i(c),e(l,u,c,o)}}return $m=s,$m}var Dm,Bb;function EL(){if(Bb)return Dm;Bb=1;var e=kL(),n=e();return Dm=n,Dm}var Fm,Ub;function NL(){if(Ub)return Fm;Ub=1;function e(n,i){var s=n.length;for(n.sort(i);s--;)n[s]=n[s].value;return n}return Fm=e,Fm}var zm,Hb;function CL(){if(Hb)return zm;Hb=1;var e=Ys();function n(i,s){if(i!==s){var o=i!==void 0,l=i===null,u=i===i,c=e(i),f=s!==void 0,h=s===null,p=s===s,m=e(s);if(!h&&!m&&!c&&i>s||c&&f&&p&&!h&&!m||l&&f&&p||!o&&p||!u)return 1;if(!l&&!c&&!m&&i<s||m&&o&&u&&!l&&!c||h&&o&&u||!f&&u||!p)return-1}return 0}return zm=n,zm}var Bm,Vb;function jL(){if(Vb)return Bm;Vb=1;var e=CL();function n(i,s,o){for(var l=-1,u=i.criteria,c=s.criteria,f=u.length,h=o.length;++l<f;){var p=e(u[l],c[l]);if(p){if(l>=h)return p;var m=o[l];return p*(m=="desc"?-1:1)}}return i.index-s.index}return Bm=n,Bm}var Um,Wb;function RL(){if(Wb)return Um;Wb=1;var e=su(),n=au(),i=Mr(),s=YN(),o=NL(),l=tu(),u=jL(),c=Zi(),f=St();function h(p,m,y){m.length?m=e(m,function(_){return f(_)?function(S){return n(S,_.length===1?_[0]:_)}:_}):m=[c];var w=-1;m=e(m,l(i));var j=s(p,function(_,S,b){var E=e(m,function(N){return N(_)});return{criteria:E,index:++w,value:_}});return o(j,function(_,S){return u(_,S,y)})}return Um=h,Um}var Hm,Gb;function TL(){if(Gb)return Hm;Gb=1;var e=jv(),n=RL(),i=lu(),s=uu(),o=i(function(l,u){if(l==null)return[];var c=u.length;return c>1&&s(l,u[0],u[1])?u=[]:c>2&&s(u[0],u[1],u[2])&&(u=[u[0]]),n(l,e(u,1),[])});return Hm=o,Hm}var Vm,Yb;function AL(){if(Yb)return Vm;Yb=1;var e=zN(),n=0;function i(s){var o=++n;return e(s)+o}return Vm=i,Vm}var Wm,Kb;function IL(){if(Kb)return Wm;Kb=1;function e(n,i,s){for(var o=-1,l=n.length,u=i.length,c={};++o<l;){var f=o<u?i[o]:void 0;s(c,n[o],f)}return c}return Wm=e,Wm}var Gm,Xb;function ML(){if(Xb)return Gm;Xb=1;var e=Jl(),n=IL();function i(s,o){return n(s||[],o||[],e)}return Gm=i,Gm}var Ym,Qb;function at(){if(Qb)return Ym;Qb=1;var e;if(typeof hv=="function")try{e={cloneDeep:Kq(),constant:bv(),defaults:Xq(),each:PN(),filter:VN(),find:rL(),flatten:lC(),forEach:MN(),forIn:iL(),has:WN(),isUndefined:GN(),last:sL(),map:KN(),mapValues:oL(),max:lL(),merge:pL(),min:mL(),minBy:gL(),now:vL(),pick:SL(),range:EL(),reduce:XN(),sortBy:TL(),uniqueId:AL(),values:tC(),zipObject:ML()}}catch{}return e||(e=window._),Ym=e,Ym}var Km,Zb;function PL(){if(Zb)return Km;Zb=1,Km=e;function e(){var s={};s._next=s._prev=s,this._sentinel=s}e.prototype.dequeue=function(){var s=this._sentinel,o=s._prev;if(o!==s)return n(o),o},e.prototype.enqueue=function(s){var o=this._sentinel;s._prev&&s._next&&n(s),s._next=o._next,o._next._prev=s,o._next=s,s._prev=o},e.prototype.toString=function(){for(var s=[],o=this._sentinel,l=o._prev;l!==o;)s.push(JSON.stringify(l,i)),l=l._prev;return"["+s.join(", ")+"]"};function n(s){s._prev._next=s._next,s._next._prev=s._prev,delete s._next,delete s._prev}function i(s,o){if(s!=="_next"&&s!=="_prev")return o}return Km}var Xm,Jb;function OL(){if(Jb)return Xm;Jb=1;var e=at(),n=Zn().Graph,i=PL();Xm=o;var s=e.constant(1);function o(h,p){if(h.nodeCount()<=1)return[];var m=c(h,p||s),y=l(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(w){return h.outEdges(w.v,w.w)}),!0)}function l(h,p,m){for(var y=[],w=p[p.length-1],j=p[0],_;h.nodeCount();){for(;_=j.dequeue();)u(h,p,m,_);for(;_=w.dequeue();)u(h,p,m,_);if(h.nodeCount()){for(var S=p.length-2;S>0;--S)if(_=p[S].dequeue(),_){y=y.concat(u(h,p,m,_,!0));break}}}return y}function u(h,p,m,y,w){var j=w?[]:void 0;return e.forEach(h.inEdges(y.v),function(_){var S=h.edge(_),b=h.node(_.v);w&&j.push({v:_.v,w:_.w}),b.out-=S,f(p,m,b)}),e.forEach(h.outEdges(y.v),function(_){var S=h.edge(_),b=_.w,E=h.node(b);E.in-=S,f(p,m,E)}),h.removeNode(y.v),j}function c(h,p){var m=new n,y=0,w=0;e.forEach(h.nodes(),function(S){m.setNode(S,{v:S,in:0,out:0})}),e.forEach(h.edges(),function(S){var b=m.edge(S.v,S.w)||0,E=p(S),N=b+E;m.setEdge(S.v,S.w,N),w=Math.max(w,m.node(S.v).out+=E),y=Math.max(y,m.node(S.w).in+=E)});var j=e.range(w+y+3).map(function(){return new i}),_=y+1;return e.forEach(m.nodes(),function(S){f(j,_,m.node(S))}),{graph:m,buckets:j,zeroIdx:_}}function f(h,p,m){m.out?m.in?h[m.out-m.in+p].enqueue(m):h[h.length-1].enqueue(m):h[0].enqueue(m)}return Xm}var Qm,ek;function qL(){if(ek)return Qm;ek=1;var e=at(),n=OL();Qm={run:i,undo:o};function i(l){var u=l.graph().acyclicer==="greedy"?n(l,c(l)):s(l);e.forEach(u,function(f){var h=l.edge(f);l.removeEdge(f),h.forwardName=f.name,h.reversed=!0,l.setEdge(f.w,f.v,h,e.uniqueId("rev"))});function c(f){return function(h){return f.edge(h).weight}}}function s(l){var u=[],c={},f={};function h(p){e.has(f,p)||(f[p]=!0,c[p]=!0,e.forEach(l.outEdges(p),function(m){e.has(c,m.w)?u.push(m):h(m.w)}),delete c[p])}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 f=c.forwardName;delete c.reversed,delete c.forwardName,l.setEdge(u.w,u.v,c,f)}})}return Qm}var Zm,tk;function hn(){if(tk)return Zm;tk=1;var e=at(),n=Zn().Graph;Zm={addDummyNode:i,simplify:s,asNonCompoundGraph:o,successorWeights:l,predecessorWeights:u,intersectRect:c,buildLayerMatrix:f,normalizeRanks:h,removeEmptyRanks:p,addBorderNode:m,maxRank:y,partition:w,time:j,notime:_};function i(S,b,E,N){var C;do C=e.uniqueId(N);while(S.hasNode(C));return E.dummy=b,S.setNode(C,E),C}function s(S){var b=new n().setGraph(S.graph());return e.forEach(S.nodes(),function(E){b.setNode(E,S.node(E))}),e.forEach(S.edges(),function(E){var N=b.edge(E.v,E.w)||{weight:0,minlen:1},C=S.edge(E);b.setEdge(E.v,E.w,{weight:N.weight+C.weight,minlen:Math.max(N.minlen,C.minlen)})}),b}function o(S){var b=new n({multigraph:S.isMultigraph()}).setGraph(S.graph());return e.forEach(S.nodes(),function(E){S.children(E).length||b.setNode(E,S.node(E))}),e.forEach(S.edges(),function(E){b.setEdge(E,S.edge(E))}),b}function l(S){var b=e.map(S.nodes(),function(E){var N={};return e.forEach(S.outEdges(E),function(C){N[C.w]=(N[C.w]||0)+S.edge(C).weight}),N});return e.zipObject(S.nodes(),b)}function u(S){var b=e.map(S.nodes(),function(E){var N={};return e.forEach(S.inEdges(E),function(C){N[C.v]=(N[C.v]||0)+S.edge(C).weight}),N});return e.zipObject(S.nodes(),b)}function c(S,b){var E=S.x,N=S.y,C=b.x-E,I=b.y-N,O=S.width/2,P=S.height/2;if(!C&&!I)throw new Error("Not possible to find intersection inside of the rectangle");var z,T;return Math.abs(I)*O>Math.abs(C)*P?(I<0&&(P=-P),z=P*C/I,T=P):(C<0&&(O=-O),z=O,T=O*I/C),{x:E+z,y:N+T}}function f(S){var b=e.map(e.range(y(S)+1),function(){return[]});return e.forEach(S.nodes(),function(E){var N=S.node(E),C=N.rank;e.isUndefined(C)||(b[C][N.order]=E)}),b}function h(S){var b=e.min(e.map(S.nodes(),function(E){return S.node(E).rank}));e.forEach(S.nodes(),function(E){var N=S.node(E);e.has(N,"rank")&&(N.rank-=b)})}function p(S){var b=e.min(e.map(S.nodes(),function(I){return S.node(I).rank})),E=[];e.forEach(S.nodes(),function(I){var O=S.node(I).rank-b;E[O]||(E[O]=[]),E[O].push(I)});var N=0,C=S.graph().nodeRankFactor;e.forEach(E,function(I,O){e.isUndefined(I)&&O%C!==0?--N:N&&e.forEach(I,function(P){S.node(P).rank+=N})})}function m(S,b,E,N){var C={width:0,height:0};return arguments.length>=4&&(C.rank=E,C.order=N),i(S,"border",C,b)}function y(S){return e.max(e.map(S.nodes(),function(b){var E=S.node(b).rank;if(!e.isUndefined(E))return E}))}function w(S,b){var E={lhs:[],rhs:[]};return e.forEach(S,function(N){b(N)?E.lhs.push(N):E.rhs.push(N)}),E}function j(S,b){var E=e.now();try{return b()}finally{console.log(S+" time: "+(e.now()-E)+"ms")}}function _(S,b){return b()}return Zm}var Jm,nk;function LL(){if(nk)return Jm;nk=1;var e=at(),n=hn();Jm={run:i,undo:o};function i(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(u){s(l,u)})}function s(l,u){var c=u.v,f=l.node(c).rank,h=u.w,p=l.node(h).rank,m=u.name,y=l.edge(u),w=y.labelRank;if(p!==f+1){l.removeEdge(u);var j,_,S;for(S=0,++f;f<p;++S,++f)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:u,rank:f},j=n.addDummyNode(l,"edge",_,"_d"),f===w&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),l.setEdge(c,j,{weight:y.weight},m),S===0&&l.graph().dummyChains.push(j),c=j;l.setEdge(c,h,{weight:y.weight},m)}}function o(l){e.forEach(l.graph().dummyChains,function(u){var c=l.node(u),f=c.edgeLabel,h;for(l.setEdge(c.edgeObj,f);c.dummy;)h=l.successors(u)[0],l.removeNode(u),f.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(f.x=c.x,f.y=c.y,f.width=c.width,f.height=c.height),u=h,c=l.node(u)})}return Jm}var eg,rk;function Dl(){if(rk)return eg;rk=1;var e=at();eg={longestPath:n,slack:i};function n(s){var o={};function l(u){var c=s.node(u);if(e.has(o,u))return c.rank;o[u]=!0;var f=e.min(e.map(s.outEdges(u),function(h){return l(h.w)-s.edge(h).minlen}));return(f===Number.POSITIVE_INFINITY||f===void 0||f===null)&&(f=0),c.rank=f}e.forEach(s.sources(),l)}function i(s,o){return s.node(o.w).rank-s.node(o.v).rank-s.edge(o).minlen}return eg}var tg,ik;function fC(){if(ik)return tg;ik=1;var e=at(),n=Zn().Graph,i=Dl().slack;tg=s;function s(c){var f=new n({directed:!1}),h=c.nodes()[0],p=c.nodeCount();f.setNode(h,{});for(var m,y;o(f,c)<p;)m=l(f,c),y=f.hasNode(m.v)?i(c,m):-i(c,m),u(f,c,y);return f}function o(c,f){function h(p){e.forEach(f.nodeEdges(p),function(m){var y=m.v,w=p===y?m.w:y;!c.hasNode(w)&&!i(f,m)&&(c.setNode(w,{}),c.setEdge(p,w,{}),h(w))})}return e.forEach(c.nodes(),h),c.nodeCount()}function l(c,f){return e.minBy(f.edges(),function(h){if(c.hasNode(h.v)!==c.hasNode(h.w))return i(f,h)})}function u(c,f,h){e.forEach(c.nodes(),function(p){f.node(p).rank+=h})}return tg}var ng,sk;function $L(){if(sk)return ng;sk=1;var e=at(),n=fC(),i=Dl().slack,s=Dl().longestPath,o=Zn().alg.preorder,l=Zn().alg.postorder,u=hn().simplify;ng=c,c.initLowLimValues=m,c.initCutValues=f,c.calcCutValue=p,c.leaveEdge=w,c.enterEdge=j,c.exchangeEdges=_;function c(N){N=u(N),s(N);var C=n(N);m(C),f(C,N);for(var I,O;I=w(C);)O=j(C,N,I),_(C,N,I,O)}function f(N,C){var I=l(N,N.nodes());I=I.slice(0,I.length-1),e.forEach(I,function(O){h(N,C,O)})}function h(N,C,I){var O=N.node(I),P=O.parent;N.edge(I,P).cutvalue=p(N,C,I)}function p(N,C,I){var O=N.node(I),P=O.parent,z=!0,T=C.edge(I,P),q=0;return T||(z=!1,T=C.edge(P,I)),q=T.weight,e.forEach(C.nodeEdges(I),function(B){var Z=B.v===I,Q=Z?B.w:B.v;if(Q!==P){var A=Z===z,H=C.edge(B).weight;if(q+=A?H:-H,b(N,I,Q)){var U=N.edge(I,Q).cutvalue;q+=A?-U:U}}}),q}function m(N,C){arguments.length<2&&(C=N.nodes()[0]),y(N,{},1,C)}function y(N,C,I,O,P){var z=I,T=N.node(O);return C[O]=!0,e.forEach(N.neighbors(O),function(q){e.has(C,q)||(I=y(N,C,I,q,O))}),T.low=z,T.lim=I++,P?T.parent=P:delete T.parent,I}function w(N){return e.find(N.edges(),function(C){return N.edge(C).cutvalue<0})}function j(N,C,I){var O=I.v,P=I.w;C.hasEdge(O,P)||(O=I.w,P=I.v);var z=N.node(O),T=N.node(P),q=z,B=!1;z.lim>T.lim&&(q=T,B=!0);var Z=e.filter(C.edges(),function(Q){return B===E(N,N.node(Q.v),q)&&B!==E(N,N.node(Q.w),q)});return e.minBy(Z,function(Q){return i(C,Q)})}function _(N,C,I,O){var P=I.v,z=I.w;N.removeEdge(P,z),N.setEdge(O.v,O.w,{}),m(N),f(N,C),S(N,C)}function S(N,C){var I=e.find(N.nodes(),function(P){return!C.node(P).parent}),O=o(N,I);O=O.slice(1),e.forEach(O,function(P){var z=N.node(P).parent,T=C.edge(P,z),q=!1;T||(T=C.edge(z,P),q=!0),C.node(P).rank=C.node(z).rank+(q?T.minlen:-T.minlen)})}function b(N,C,I){return N.hasEdge(C,I)}function E(N,C,I){return I.low<=C.lim&&C.lim<=I.lim}return ng}var rg,ok;function DL(){if(ok)return rg;ok=1;var e=Dl(),n=e.longestPath,i=fC(),s=$L();rg=o;function o(f){switch(f.graph().ranker){case"network-simplex":c(f);break;case"tight-tree":u(f);break;case"longest-path":l(f);break;default:c(f)}}var l=n;function u(f){n(f),i(f)}function c(f){s(f)}return rg}var ig,ak;function FL(){if(ak)return ig;ak=1;var e=at();ig=n;function n(o){var l=s(o);e.forEach(o.graph().dummyChains,function(u){for(var c=o.node(u),f=c.edgeObj,h=i(o,l,f.v,f.w),p=h.path,m=h.lca,y=0,w=p[y],j=!0;u!==f.w;){if(c=o.node(u),j){for(;(w=p[y])!==m&&o.node(w).maxRank<c.rank;)y++;w===m&&(j=!1)}if(!j){for(;y<p.length-1&&o.node(w=p[y+1]).minRank<=c.rank;)y++;w=p[y]}o.setParent(u,w),u=o.successors(u)[0]}})}function i(o,l,u,c){var f=[],h=[],p=Math.min(l[u].low,l[c].low),m=Math.max(l[u].lim,l[c].lim),y,w;y=u;do y=o.parent(y),f.push(y);while(y&&(l[y].low>p||m>l[y].lim));for(w=y,y=c;(y=o.parent(y))!==w;)h.push(y);return{path:f.concat(h.reverse()),lca:w}}function s(o){var l={},u=0;function c(f){var h=u;e.forEach(o.children(f),c),l[f]={low:h,lim:u++}}return e.forEach(o.children(),c),l}return ig}var sg,lk;function zL(){if(lk)return sg;lk=1;var e=at(),n=hn();sg={run:i,cleanup:u};function i(c){var f=n.addDummyNode(c,"root",{},"_root"),h=o(c),p=e.max(e.values(h))-1,m=2*p+1;c.graph().nestingRoot=f,e.forEach(c.edges(),function(w){c.edge(w).minlen*=m});var y=l(c)+1;e.forEach(c.children(),function(w){s(c,f,m,y,p,h,w)}),c.graph().nodeRankFactor=m}function s(c,f,h,p,m,y,w){var j=c.children(w);if(!j.length){w!==f&&c.setEdge(f,w,{weight:0,minlen:h});return}var _=n.addBorderNode(c,"_bt"),S=n.addBorderNode(c,"_bb"),b=c.node(w);c.setParent(_,w),b.borderTop=_,c.setParent(S,w),b.borderBottom=S,e.forEach(j,function(E){s(c,f,h,p,m,y,E);var N=c.node(E),C=N.borderTop?N.borderTop:E,I=N.borderBottom?N.borderBottom:E,O=N.borderTop?p:2*p,P=C!==I?1:m-y[w]+1;c.setEdge(_,C,{weight:O,minlen:P,nestingEdge:!0}),c.setEdge(I,S,{weight:O,minlen:P,nestingEdge:!0})}),c.parent(w)||c.setEdge(f,_,{weight:0,minlen:m+y[w]})}function o(c){var f={};function h(p,m){var y=c.children(p);y&&y.length&&e.forEach(y,function(w){h(w,m+1)}),f[p]=m}return e.forEach(c.children(),function(p){h(p,1)}),f}function l(c){return e.reduce(c.edges(),function(f,h){return f+c.edge(h).weight},0)}function u(c){var f=c.graph();c.removeNode(f.nestingRoot),delete f.nestingRoot,e.forEach(c.edges(),function(h){var p=c.edge(h);p.nestingEdge&&c.removeEdge(h)})}return sg}var og,uk;function BL(){if(uk)return og;uk=1;var e=at(),n=hn();og=i;function i(o){function l(u){var c=o.children(u),f=o.node(u);if(c.length&&e.forEach(c,l),e.has(f,"minRank")){f.borderLeft=[],f.borderRight=[];for(var h=f.minRank,p=f.maxRank+1;h<p;++h)s(o,"borderLeft","_bl",u,f,h),s(o,"borderRight","_br",u,f,h)}}e.forEach(o.children(),l)}function s(o,l,u,c,f,h){var p={width:0,height:0,rank:h,borderType:l},m=f[l][h-1],y=n.addDummyNode(o,"border",p,u);f[l][h]=y,o.setParent(y,c),m&&o.setEdge(m,y,{weight:1})}return og}var ag,ck;function UL(){if(ck)return ag;ck=1;var e=at();ag={adjust:n,undo:i};function n(h){var p=h.graph().rankdir.toLowerCase();(p==="lr"||p==="rl")&&s(h)}function i(h){var p=h.graph().rankdir.toLowerCase();(p==="bt"||p==="rl")&&l(h),(p==="lr"||p==="rl")&&(c(h),s(h))}function s(h){e.forEach(h.nodes(),function(p){o(h.node(p))}),e.forEach(h.edges(),function(p){o(h.edge(p))})}function o(h){var p=h.width;h.width=h.height,h.height=p}function l(h){e.forEach(h.nodes(),function(p){u(h.node(p))}),e.forEach(h.edges(),function(p){var m=h.edge(p);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(p){f(h.node(p))}),e.forEach(h.edges(),function(p){var m=h.edge(p);e.forEach(m.points,f),e.has(m,"x")&&f(m)})}function f(h){var p=h.x;h.x=h.y,h.y=p}return ag}var lg,dk;function HL(){if(dk)return lg;dk=1;var e=at();lg=n;function n(i){var s={},o=e.filter(i.nodes(),function(h){return!i.children(h).length}),l=e.max(e.map(o,function(h){return i.node(h).rank})),u=e.map(e.range(l+1),function(){return[]});function c(h){if(!e.has(s,h)){s[h]=!0;var p=i.node(h);u[p.rank].push(h),e.forEach(i.successors(h),c)}}var f=e.sortBy(o,function(h){return i.node(h).rank});return e.forEach(f,c),u}return lg}var ug,fk;function VL(){if(fk)return ug;fk=1;var e=at();ug=n;function n(s,o){for(var l=0,u=1;u<o.length;++u)l+=i(s,o[u-1],o[u]);return l}function i(s,o,l){for(var u=e.zipObject(l,e.map(l,function(y,w){return w})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(s.outEdges(y),function(w){return{pos:u[w.w],weight:s.edge(w).weight}}),"pos")}),!0),f=1;f<l.length;)f<<=1;var h=2*f-1;f-=1;var p=e.map(new Array(h),function(){return 0}),m=0;return e.forEach(c.forEach(function(y){var w=y.pos+f;p[w]+=y.weight;for(var j=0;w>0;)w%2&&(j+=p[w+1]),w=w-1>>1,p[w]+=y.weight;m+=y.weight*j})),m}return ug}var cg,hk;function WL(){if(hk)return cg;hk=1;var e=at();cg=n;function n(i,s){return e.map(s,function(o){var l=i.inEdges(o);if(l.length){var u=e.reduce(l,function(c,f){var h=i.edge(f),p=i.node(f.v);return{sum:c.sum+h.weight*p.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 cg}var dg,pk;function GL(){if(pk)return dg;pk=1;var e=at();dg=n;function n(o,l){var u={};e.forEach(o,function(f,h){var p=u[f.v]={indegree:0,in:[],out:[],vs:[f.v],i:h};e.isUndefined(f.barycenter)||(p.barycenter=f.barycenter,p.weight=f.weight)}),e.forEach(l.edges(),function(f){var h=u[f.v],p=u[f.w];!e.isUndefined(h)&&!e.isUndefined(p)&&(p.indegree++,h.out.push(u[f.w]))});var c=e.filter(u,function(f){return!f.indegree});return i(c)}function i(o){var l=[];function u(h){return function(p){p.merged||(e.isUndefined(p.barycenter)||e.isUndefined(h.barycenter)||p.barycenter>=h.barycenter)&&s(h,p)}}function c(h){return function(p){p.in.push(h),--p.indegree===0&&o.push(p)}}for(;o.length;){var f=o.pop();l.push(f),e.forEach(f.in.reverse(),u(f)),e.forEach(f.out,c(f))}return e.map(e.filter(l,function(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 dg}var fg,mk;function YL(){if(mk)return fg;mk=1;var e=at(),n=hn();fg=i;function i(l,u){var c=n.partition(l,function(_){return e.has(_,"barycenter")}),f=c.lhs,h=e.sortBy(c.rhs,function(_){return-_.i}),p=[],m=0,y=0,w=0;f.sort(o(!!u)),w=s(p,h,w),e.forEach(f,function(_){w+=_.vs.length,p.push(_.vs),m+=_.barycenter*_.weight,y+=_.weight,w=s(p,h,w)});var j={vs:e.flatten(p,!0)};return y&&(j.barycenter=m/y,j.weight=y),j}function s(l,u,c){for(var f;u.length&&(f=e.last(u)).i<=c;)u.pop(),l.push(f.vs),c++;return c}function o(l){return function(u,c){return u.barycenter<c.barycenter?-1:u.barycenter>c.barycenter?1:l?c.i-u.i:u.i-c.i}}return fg}var hg,gk;function KL(){if(gk)return hg;gk=1;var e=at(),n=WL(),i=GL(),s=YL();hg=o;function o(c,f,h,p){var m=c.children(f),y=c.node(f),w=y?y.borderLeft:void 0,j=y?y.borderRight:void 0,_={};w&&(m=e.filter(m,function(I){return I!==w&&I!==j}));var S=n(c,m);e.forEach(S,function(I){if(c.children(I.v).length){var O=o(c,I.v,h,p);_[I.v]=O,e.has(O,"barycenter")&&u(I,O)}});var b=i(S,h);l(b,_);var E=s(b,p);if(w&&(E.vs=e.flatten([w,E.vs,j],!0),c.predecessors(w).length)){var N=c.node(c.predecessors(w)[0]),C=c.node(c.predecessors(j)[0]);e.has(E,"barycenter")||(E.barycenter=0,E.weight=0),E.barycenter=(E.barycenter*E.weight+N.order+C.order)/(E.weight+2),E.weight+=2}return E}function l(c,f){e.forEach(c,function(h){h.vs=e.flatten(h.vs.map(function(p){return f[p]?f[p].vs:p}),!0)})}function u(c,f){e.isUndefined(c.barycenter)?(c.barycenter=f.barycenter,c.weight=f.weight):(c.barycenter=(c.barycenter*c.weight+f.barycenter*f.weight)/(c.weight+f.weight),c.weight+=f.weight)}return hg}var pg,vk;function XL(){if(vk)return pg;vk=1;var e=at(),n=Zn().Graph;pg=i;function i(o,l,u){var c=s(o),f=new n({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(h){return o.node(h)});return e.forEach(o.nodes(),function(h){var p=o.node(h),m=o.parent(h);(p.rank===l||p.minRank<=l&&l<=p.maxRank)&&(f.setNode(h),f.setParent(h,m||c),e.forEach(o[u](h),function(y){var w=y.v===h?y.w:y.v,j=f.edge(w,h),_=e.isUndefined(j)?0:j.weight;f.setEdge(w,h,{weight:o.edge(y).weight+_})}),e.has(p,"minRank")&&f.setNode(h,{borderLeft:p.borderLeft[l],borderRight:p.borderRight[l]}))}),f}function s(o){for(var l;o.hasNode(l=e.uniqueId("_root")););return l}return pg}var mg,yk;function QL(){if(yk)return mg;yk=1;var e=at();mg=n;function n(i,s,o){var l={},u;e.forEach(o,function(c){for(var f=i.parent(c),h,p;f;){if(h=i.parent(f),h?(p=l[h],l[h]=f):(p=u,u=f),p&&p!==f){s.setEdge(p,f);return}f=h}})}return mg}var gg,wk;function ZL(){if(wk)return gg;wk=1;var e=at(),n=HL(),i=VL(),s=KL(),o=XL(),l=QL(),u=Zn().Graph,c=hn();gg=f;function f(y){var w=c.maxRank(y),j=h(y,e.range(1,w+1),"inEdges"),_=h(y,e.range(w-1,-1,-1),"outEdges"),S=n(y);m(y,S);for(var b=Number.POSITIVE_INFINITY,E,N=0,C=0;C<4;++N,++C){p(N%2?j:_,N%4>=2),S=c.buildLayerMatrix(y);var I=i(y,S);I<b&&(C=0,E=e.cloneDeep(S),b=I)}m(y,E)}function h(y,w,j){return e.map(w,function(_){return o(y,_,j)})}function p(y,w){var j=new u;e.forEach(y,function(_){var S=_.graph().root,b=s(_,S,j,w);e.forEach(b.vs,function(E,N){_.node(E).order=N}),l(_,j,b.vs)})}function m(y,w){e.forEach(w,function(j){e.forEach(j,function(_,S){y.node(_).order=S})})}return gg}var vg,xk;function JL(){if(xk)return vg;xk=1;var e=at(),n=Zn().Graph,i=hn();vg={positionX:j,findType1Conflicts:s,findType2Conflicts:o,addConflict:u,hasConflict:c,verticalAlignment:f,horizontalCompaction:h,alignCoordinates:y,findSmallestWidthAlignment:m,balance:w};function s(b,E){var N={};function C(I,O){var P=0,z=0,T=I.length,q=e.last(O);return e.forEach(O,function(B,Z){var Q=l(b,B),A=Q?b.node(Q).order:T;(Q||B===q)&&(e.forEach(O.slice(z,Z+1),function(H){e.forEach(b.predecessors(H),function(U){var ne=b.node(U),Y=ne.order;(Y<P||A<Y)&&!(ne.dummy&&b.node(H).dummy)&&u(N,U,H)})}),z=Z+1,P=A)}),O}return e.reduce(E,C),N}function o(b,E){var N={};function C(O,P,z,T,q){var B;e.forEach(e.range(P,z),function(Z){B=O[Z],b.node(B).dummy&&e.forEach(b.predecessors(B),function(Q){var A=b.node(Q);A.dummy&&(A.order<T||A.order>q)&&u(N,Q,B)})})}function I(O,P){var z=-1,T,q=0;return e.forEach(P,function(B,Z){if(b.node(B).dummy==="border"){var Q=b.predecessors(B);Q.length&&(T=b.node(Q[0]).order,C(P,q,Z,z,T),q=Z,z=T)}C(P,q,P.length,T,O.length)}),P}return e.reduce(E,I),N}function l(b,E){if(b.node(E).dummy)return e.find(b.predecessors(E),function(N){return b.node(N).dummy})}function u(b,E,N){if(E>N){var C=E;E=N,N=C}var I=b[E];I||(b[E]=I={}),I[N]=!0}function c(b,E,N){if(E>N){var C=E;E=N,N=C}return e.has(b[E],N)}function f(b,E,N,C){var I={},O={},P={};return e.forEach(E,function(z){e.forEach(z,function(T,q){I[T]=T,O[T]=T,P[T]=q})}),e.forEach(E,function(z){var T=-1;e.forEach(z,function(q){var B=C(q);if(B.length){B=e.sortBy(B,function(U){return P[U]});for(var Z=(B.length-1)/2,Q=Math.floor(Z),A=Math.ceil(Z);Q<=A;++Q){var H=B[Q];O[q]===q&&T<P[H]&&!c(N,q,H)&&(O[H]=q,O[q]=I[q]=I[H],T=P[H])}}})}),{root:I,align:O}}function h(b,E,N,C,I){var O={},P=p(b,E,N,I),z=I?"borderLeft":"borderRight";function T(Z,Q){for(var A=P.nodes(),H=A.pop(),U={};H;)U[H]?Z(H):(U[H]=!0,A.push(H),A=A.concat(Q(H))),H=A.pop()}function q(Z){O[Z]=P.inEdges(Z).reduce(function(Q,A){return Math.max(Q,O[A.v]+P.edge(A))},0)}function B(Z){var Q=P.outEdges(Z).reduce(function(H,U){return Math.min(H,O[U.w]-P.edge(U))},Number.POSITIVE_INFINITY),A=b.node(Z);Q!==Number.POSITIVE_INFINITY&&A.borderType!==z&&(O[Z]=Math.max(O[Z],Q))}return T(q,P.predecessors.bind(P)),T(B,P.successors.bind(P)),e.forEach(C,function(Z){O[Z]=O[N[Z]]}),O}function p(b,E,N,C){var I=new n,O=b.graph(),P=_(O.nodesep,O.edgesep,C);return e.forEach(E,function(z){var T;e.forEach(z,function(q){var B=N[q];if(I.setNode(B),T){var Z=N[T],Q=I.edge(Z,B);I.setEdge(Z,B,Math.max(P(b,q,T),Q||0))}T=q})}),I}function m(b,E){return e.minBy(e.values(E),function(N){var C=Number.NEGATIVE_INFINITY,I=Number.POSITIVE_INFINITY;return e.forIn(N,function(O,P){var z=S(b,P)/2;C=Math.max(O+z,C),I=Math.min(O-z,I)}),C-I})}function y(b,E){var N=e.values(E),C=e.min(N),I=e.max(N);e.forEach(["u","d"],function(O){e.forEach(["l","r"],function(P){var z=O+P,T=b[z],q;if(T!==E){var B=e.values(T);q=P==="l"?C-e.min(B):I-e.max(B),q&&(b[z]=e.mapValues(T,function(Z){return Z+q}))}})})}function w(b,E){return e.mapValues(b.ul,function(N,C){if(E)return b[E.toLowerCase()][C];var I=e.sortBy(e.map(b,C));return(I[1]+I[2])/2})}function j(b){var E=i.buildLayerMatrix(b),N=e.merge(s(b,E),o(b,E)),C={},I;e.forEach(["u","d"],function(P){I=P==="u"?E:e.values(E).reverse(),e.forEach(["l","r"],function(z){z==="r"&&(I=e.map(I,function(Z){return e.values(Z).reverse()}));var T=(P==="u"?b.predecessors:b.successors).bind(b),q=f(b,I,N,T),B=h(b,I,q.root,q.align,z==="r");z==="r"&&(B=e.mapValues(B,function(Z){return-Z})),C[P+z]=B})});var O=m(b,C);return y(C,O),w(C,b.graph().align)}function _(b,E,N){return function(C,I,O){var P=C.node(I),z=C.node(O),T=0,q;if(T+=P.width/2,e.has(P,"labelpos"))switch(P.labelpos.toLowerCase()){case"l":q=-P.width/2;break;case"r":q=P.width/2;break}if(q&&(T+=N?q:-q),q=0,T+=(P.dummy?E:b)/2,T+=(z.dummy?E:b)/2,T+=z.width/2,e.has(z,"labelpos"))switch(z.labelpos.toLowerCase()){case"l":q=z.width/2;break;case"r":q=-z.width/2;break}return q&&(T+=N?q:-q),q=0,T}}function S(b,E){return b.node(E).width}return vg}var yg,_k;function e$(){if(_k)return yg;_k=1;var e=at(),n=hn(),i=JL().positionX;yg=s;function s(l){l=n.asNonCompoundGraph(l),o(l),e.forEach(i(l),function(u,c){l.node(c).x=u})}function o(l){var u=n.buildLayerMatrix(l),c=l.graph().ranksep,f=0;e.forEach(u,function(h){var p=e.max(e.map(h,function(m){return l.node(m).height}));e.forEach(h,function(m){l.node(m).y=f+p/2}),f+=p+c})}return yg}var wg,Sk;function t$(){if(Sk)return wg;Sk=1;var e=at(),n=qL(),i=LL(),s=DL(),o=hn().normalizeRanks,l=FL(),u=hn().removeEmptyRanks,c=zL(),f=BL(),h=UL(),p=ZL(),m=e$(),y=hn(),w=Zn().Graph;wg=j;function j(D,X){var ee=X&&X.debugTiming?y.time:y.notime;ee("layout",function(){var se=ee(" buildLayoutGraph",function(){return T(D)});ee(" runLayout",function(){_(se,ee)}),ee(" updateInputGraph",function(){S(D,se)})})}function _(D,X){X(" makeSpaceForEdgeLabels",function(){q(D)}),X(" removeSelfEdges",function(){L(D)}),X(" acyclic",function(){n.run(D)}),X(" nestingGraph.run",function(){c.run(D)}),X(" rank",function(){s(y.asNonCompoundGraph(D))}),X(" injectEdgeLabelProxies",function(){B(D)}),X(" removeEmptyRanks",function(){u(D)}),X(" nestingGraph.cleanup",function(){c.cleanup(D)}),X(" normalizeRanks",function(){o(D)}),X(" assignRankMinMax",function(){Z(D)}),X(" removeEdgeLabelProxies",function(){Q(D)}),X(" normalize.run",function(){i.run(D)}),X(" parentDummyChains",function(){l(D)}),X(" addBorderSegments",function(){f(D)}),X(" order",function(){p(D)}),X(" insertSelfEdges",function(){G(D)}),X(" adjustCoordinateSystem",function(){h.adjust(D)}),X(" position",function(){m(D)}),X(" positionSelfEdges",function(){k(D)}),X(" removeBorderNodes",function(){Y(D)}),X(" normalize.undo",function(){i.undo(D)}),X(" fixupEdgeLabelCoords",function(){U(D)}),X(" undoCoordinateSystem",function(){h.undo(D)}),X(" translateGraph",function(){A(D)}),X(" assignNodeIntersects",function(){H(D)}),X(" reversePoints",function(){ne(D)}),X(" acyclic.undo",function(){n.undo(D)})}function S(D,X){e.forEach(D.nodes(),function(ee){var se=D.node(ee),ae=X.node(ee);se&&(se.x=ae.x,se.y=ae.y,X.children(ee).length&&(se.width=ae.width,se.height=ae.height))}),e.forEach(D.edges(),function(ee){var se=D.edge(ee),ae=X.edge(ee);se.points=ae.points,e.has(ae,"x")&&(se.x=ae.x,se.y=ae.y)}),D.graph().width=X.graph().width,D.graph().height=X.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],E={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},N=["acyclicer","ranker","rankdir","align"],C=["width","height"],I={width:0,height:0},O=["minlen","weight","width","height","labeloffset"],P={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},z=["labelpos"];function T(D){var X=new w({multigraph:!0,compound:!0}),ee=oe(D.graph());return X.setGraph(e.merge({},E,$(ee,b),e.pick(ee,N))),e.forEach(D.nodes(),function(se){var ae=oe(D.node(se));X.setNode(se,e.defaults($(ae,C),I)),X.setParent(se,D.parent(se))}),e.forEach(D.edges(),function(se){var ae=oe(D.edge(se));X.setEdge(se,e.merge({},P,$(ae,O),e.pick(ae,z)))}),X}function q(D){var X=D.graph();X.ranksep/=2,e.forEach(D.edges(),function(ee){var se=D.edge(ee);se.minlen*=2,se.labelpos.toLowerCase()!=="c"&&(X.rankdir==="TB"||X.rankdir==="BT"?se.width+=se.labeloffset:se.height+=se.labeloffset)})}function B(D){e.forEach(D.edges(),function(X){var ee=D.edge(X);if(ee.width&&ee.height){var se=D.node(X.v),ae=D.node(X.w),pe={rank:(ae.rank-se.rank)/2+se.rank,e:X};y.addDummyNode(D,"edge-proxy",pe,"_ep")}})}function Z(D){var X=0;e.forEach(D.nodes(),function(ee){var se=D.node(ee);se.borderTop&&(se.minRank=D.node(se.borderTop).rank,se.maxRank=D.node(se.borderBottom).rank,X=e.max(X,se.maxRank))}),D.graph().maxRank=X}function Q(D){e.forEach(D.nodes(),function(X){var ee=D.node(X);ee.dummy==="edge-proxy"&&(D.edge(ee.e).labelRank=ee.rank,D.removeNode(X))})}function A(D){var X=Number.POSITIVE_INFINITY,ee=0,se=Number.POSITIVE_INFINITY,ae=0,pe=D.graph(),ge=pe.marginx||0,Ae=pe.marginy||0;function Oe(Ie){var Me=Ie.x,ke=Ie.y,He=Ie.width,ve=Ie.height;X=Math.min(X,Me-He/2),ee=Math.max(ee,Me+He/2),se=Math.min(se,ke-ve/2),ae=Math.max(ae,ke+ve/2)}e.forEach(D.nodes(),function(Ie){Oe(D.node(Ie))}),e.forEach(D.edges(),function(Ie){var Me=D.edge(Ie);e.has(Me,"x")&&Oe(Me)}),X-=ge,se-=Ae,e.forEach(D.nodes(),function(Ie){var Me=D.node(Ie);Me.x-=X,Me.y-=se}),e.forEach(D.edges(),function(Ie){var Me=D.edge(Ie);e.forEach(Me.points,function(ke){ke.x-=X,ke.y-=se}),e.has(Me,"x")&&(Me.x-=X),e.has(Me,"y")&&(Me.y-=se)}),pe.width=ee-X+ge,pe.height=ae-se+Ae}function H(D){e.forEach(D.edges(),function(X){var ee=D.edge(X),se=D.node(X.v),ae=D.node(X.w),pe,ge;ee.points?(pe=ee.points[0],ge=ee.points[ee.points.length-1]):(ee.points=[],pe=ae,ge=se),ee.points.unshift(y.intersectRect(se,pe)),ee.points.push(y.intersectRect(ae,ge))})}function U(D){e.forEach(D.edges(),function(X){var ee=D.edge(X);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(X){var ee=D.edge(X);ee.reversed&&ee.points.reverse()})}function Y(D){e.forEach(D.nodes(),function(X){if(D.children(X).length){var ee=D.node(X),se=D.node(ee.borderTop),ae=D.node(ee.borderBottom),pe=D.node(e.last(ee.borderLeft)),ge=D.node(e.last(ee.borderRight));ee.width=Math.abs(ge.x-pe.x),ee.height=Math.abs(ae.y-se.y),ee.x=pe.x+ee.width/2,ee.y=se.y+ee.height/2}}),e.forEach(D.nodes(),function(X){D.node(X).dummy==="border"&&D.removeNode(X)})}function L(D){e.forEach(D.edges(),function(X){if(X.v===X.w){var ee=D.node(X.v);ee.selfEdges||(ee.selfEdges=[]),ee.selfEdges.push({e:X,label:D.edge(X)}),D.removeEdge(X)}})}function G(D){var X=y.buildLayerMatrix(D);e.forEach(X,function(ee){var se=0;e.forEach(ee,function(ae,pe){var ge=D.node(ae);ge.order=pe+se,e.forEach(ge.selfEdges,function(Ae){y.addDummyNode(D,"selfedge",{width:Ae.label.width,height:Ae.label.height,rank:ge.rank,order:pe+ ++se,e:Ae.e,label:Ae.label},"_se")}),delete ge.selfEdges})})}function k(D){e.forEach(D.nodes(),function(X){var ee=D.node(X);if(ee.dummy==="selfedge"){var se=D.node(ee.e.v),ae=se.x+se.width/2,pe=se.y,ge=ee.x-ae,Ae=se.height/2;D.setEdge(ee.e,ee.label),D.removeNode(X),ee.label.points=[{x:ae+2*ge/3,y:pe-Ae},{x:ae+5*ge/6,y:pe-Ae},{x:ae+ge,y:pe},{x:ae+5*ge/6,y:pe+Ae},{x:ae+2*ge/3,y:pe+Ae}],ee.label.x=ee.x,ee.label.y=ee.y}})}function $(D,X){return e.mapValues(e.pick(D,X),Number)}function oe(D){var X={};return e.forEach(D,function(ee,se){X[se.toLowerCase()]=ee}),X}return wg}var xg,bk;function n$(){if(bk)return xg;bk=1;var e=at(),n=hn(),i=Zn().Graph;xg={debugOrdering:s};function s(o){var l=n.buildLayerMatrix(o),u=new i({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(c){u.setNode(c,{label:c}),u.setParent(c,"layer"+o.node(c).rank)}),e.forEach(o.edges(),function(c){u.setEdge(c.v,c.w,{},c.name)}),e.forEach(l,function(c,f){var h="layer"+f;u.setNode(h,{rank:"same"}),e.reduce(c,function(p,m){return u.setEdge(p,m,{style:"invis"}),m})}),u}return xg}var _g,kk;function r$(){return kk||(kk=1,_g="0.8.5"),_g}var Sg,Ek;function i$(){return Ek||(Ek=1,Sg={graphlib:Zn(),layout:t$(),debug:n$(),util:{time:hn().time,notime:hn().notime},version:r$()}),Sg}var s$=i$();const Nk=Wg(s$),hi=240,Wi=130,Ds=74,cu=72,Ck=Ds+cu;function o$(e){let n=hi;for(const i of e.values())n=Math.max(n,i.width);return n}const a$=420,l$=2;function du(e){var i;return((i=e.data)==null?void 0:i.sessionId)??"_default"}function u$(e,n,i,s,o){const l=new Nk.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:i,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const u=e.filter(_=>!o.has(_)),c=new Set(u);for(const _ of u){const S=s.get(_);l.setNode(_,{width:(S==null?void 0:S.width)??hi,height:(S==null?void 0:S.height)??Wi})}for(const _ of n)c.has(_.source)&&c.has(_.target)&&l.setEdge(_.source,_.target);Nk.layout(l);const f=new Map;let h=1/0,p=1/0,m=-1/0,y=-1/0;for(const _ of u){const S=l.node(_);if(!S)continue;const b=s.get(_),E=(b==null?void 0:b.width)??hi,N=(b==null?void 0:b.height)??Wi,C=S.x-E/2,I=S.y-N/2;f.set(_,{x:C,y:I}),C<h&&(h=C),I<p&&(p=I),C+E>m&&(m=C+E),I+N>y&&(y=I+N)}if(Number.isFinite(h)&&Number.isFinite(p))for(const[_,S]of f)f.set(_,{x:S.x-h,y:S.y-p});let w=Number.isFinite(m)?m-h:0,j=Number.isFinite(y)?y-p:0;for(const _ of e){const S=o.get(_);if(!S)continue;const b=s.get(_);w=Math.max(w,S.x+((b==null?void 0:b.width)??hi)),j=Math.max(j,S.y+((b==null?void 0:b.height)??Wi))}return{positions:f,width:w,height:j}}function c$(e,n,i={}){const s=i.direction??"LR",o=i.pinned??new Map,l=i.measured??new Map,u=new Map;for(const S of e){const b=du(S),E=u.get(b);E?E.push(S.id):u.set(b,[S.id])}const f=Array.from(u.keys()).sort().map(S=>({sid:S,...u$(u.get(S),n,s,l,o)})),h=o$(l),p=i.availableHeight&&i.availableHeight>0?i.availableHeight:Number.POSITIVE_INFINITY,m=S=>{const b=[[]];let E=0;for(const N of f)b.length<S&&E>0&&E+N.height>p&&(b.push([]),E=0),b[b.length-1].push(N),E+=N.height+Ck;return b},y=S=>S.reduce((b,E)=>Math.max(b,E.width),0)+a$;let w=m(i.availableWidth?l$:1);w.length>1&&w.reduce((b,E)=>b+y(E),0)+h*(w.length-1)>(i.availableWidth??0)&&(w=m(1));const j=new Map;let _=0;for(const S of w){let b=0;for(const{positions:E,height:N}of S){for(const[C,I]of E)j.set(C,{x:I.x+_,y:I.y+b});b+=N+Ck}_+=y(S)+h}return e.map(S=>{const b=o.get(S.id);if(b)return{...S,position:b};const E=j.get(S.id);return E?{...S,position:E}:S})}function d$(e,n,i,s){const l=Ds+cu,u=60,c=y=>{const w=s.get(y);return{w:(w==null?void 0:w.width)??hi,h:(w==null?void 0:w.height)??Wi}},f=new Map(e.map(y=>[y.id,du(y)])),h=[],p=e.map(y=>({id:y.id,pos:i.get(y.id)??n.get(y.id)})).filter(y=>y.pos!=null).sort((y,w)=>y.pos.y-w.pos.y||y.pos.x-w.pos.x||y.id.localeCompare(w.id)),m=[];for(const{id:y,pos:w}of p){const{w:j,h:_}=c(y),S=f.get(y)??"_default";if(i.has(y)){h.push({x:w.x,y:w.y,w:j,h:_,sid:S});continue}let b=w.y;for(let E=0;E<h.length+1;E++){const N=h.find(C=>{const I=C.sid===S?24:u,O=C.sid===S?24:l;return w.x<C.x+C.w+I&&C.x<w.x+j+I&&b<C.y+C.h+O&&C.y<b+_+O});if(!N)break;b=N.y+N.h+(N.sid===S?24:l)}b!==w.y&&(n.set(y,{x:w.x,y:b}),m.push(y)),h.push({x:w.x,y:b,w:j,h:_,sid:S})}return m}function f$(e,n,i,s,o){const l=y=>{const w=s.get(y);return{w:(w==null?void 0:w.width)??hi,h:(w==null?void 0:w.height)??Wi}},u=y=>i.get(y)??n.get(y),c=new Map,f=[];for(const y of e){const w=u(y.id);if(!w)continue;const{w:j,h:_}=l(y.id);if(o.has(y.id)&&!i.has(y.id)){const S=du(y);(c.get(S)??c.set(S,[]).get(S)).push(y)}else f.push({x:w.x,y:w.y,w:j,h:_})}if(c.size===0)return[];const h=Ds+cu,p=(y,w,j,_)=>f.some(S=>y<S.x+S.w+Ds&&S.x<y+j+Ds&&w<S.y+S.h+h&&S.y<w+_+h),m=[];for(const y of[...c.keys()].sort()){const w=c.get(y);let j=1/0,_=1/0,S=-1/0,b=-1/0;for(const z of w){const T=u(z.id),{w:q,h:B}=l(z.id);j=Math.min(j,T.x),_=Math.min(_,T.y),S=Math.max(S,T.x+q),b=Math.max(b,T.y+B)}const E=S-j,N=b-_,C=[...new Set(f.map(z=>Math.round(z.x)))].sort((z,T)=>z-T),I=C.length?C:[j],O=[0,...f.map(z=>z.y+z.h+h)].sort((z,T)=>z-T);let P=null;e:for(const z of I)for(const T of O){if(T>=_)break;if(!p(z,T,E,N)){P={x:z,y:T};break e}}if(P){const z=P.x-j,T=P.y-_;for(const q of w){const B=u(q.id);n.set(q.id,{x:B.x+z,y:B.y+T})}m.push(y)}for(const z of w){const T=u(z.id),{w:q,h:B}=l(z.id);f.push({x:T.x,y:T.y,w:q,h:B})}}return m}function h$(e,n,i,s,o,l=!1){const f=Ds+cu+1,h=8,p=1.75,m=200,y=.7,w=.01,j=T=>{const q=s.get(T);return{w:(q==null?void 0:q.width)??hi,h:(q==null?void 0:q.height)??Wi}},_=T=>i.get(T)??n.get(T),S=new Map;for(const T of e){if(!_(T.id))continue;const q=du(T),B=S.get(q);B?B.push(T):S.set(q,[T])}const b=[],E=new Set,N=new Set,C=o.size===0;for(const T of[...S.keys()].sort()){const q=S.get(T);let B=1/0,Z=1/0,Q=-1/0,A=-1/0,H=!1;for(const L of q){const G=_(L.id),{w:k,h:$}=j(L.id);B=Math.min(B,G.x),Z=Math.min(Z,G.y),Q=Math.max(Q,G.x+k),A=Math.max(A,G.y+$),i.has(L.id)&&(H=!0)}const U=Q-B,ne=A-Z;N.add(T);const Y=o.get(T);Y&&(U>Y.w+h||ne>Y.h+h)&&E.add(T),o.set(T,{w:U,h:ne}),b.push({sid:T,members:q.map(L=>L.id),x:B,y:Z,w:U,h:ne,anchored:H,mass:1})}for(const T of[...o.keys()])N.has(T)||o.delete(T);if(l||C)return[];let I=!1;for(let T=0;T<b.length&&!I;T++)for(let q=T+1;q<b.length;q++){const B=b[T],Z=b[q];if(!(B.anchored&&Z.anchored)&&Math.abs(B.x+B.w/2-(Z.x+Z.w/2))<(B.w+Z.w)/2+61&&Math.abs(B.y+B.h/2-(Z.y+Z.h/2))<(B.h+Z.h)/2+f){I=!0;break}}if(E.size===0&&!I)return[];if(E.size>0)for(const T of b)E.has(T.sid)&&(T.mass=8);else for(const T of b)T.mass=Math.max(1,T.w*T.h/(hi*Wi));const O=new Map(b.map(T=>[T.sid,T.x])),P=new Map(b.map(T=>[T.sid,T.y]));for(let T=0;T<m;T++){const q=new Map,B=new Map;let Z=0;for(let Q=0;Q<b.length;Q++)for(let A=Q+1;A<b.length;A++){const H=b[Q],U=b[A];if(H.anchored&&U.anchored)continue;const ne=H.x+H.w/2,Y=H.y+H.h/2,L=U.x+U.w/2,G=U.y+U.h/2,k=(H.w+U.w)/2+61-Math.abs(ne-L),$=(H.h+U.h)/2+f-Math.abs(Y-G);if(k<=0||$<=0)continue;const oe=(We,$e)=>!We.anchored&&!($e<0&&We.x<=0),D=(We,$e)=>!We.anchored&&!($e<0&&We.y<=0),X=(We,$e,Ke)=>{const yt=We===$e,et=yt?H.sid<U.sid?-1:1:Math.sign(We-$e);return Ke(H,et)||Ke(U,-et)?et:yt&&(Ke(H,-et)||Ke(U,et))?-et:0},ee=X(ne,L,oe),se=X(Y,G,D),ae=ee!==0,pe=se!==0;if(!ae&&!pe)continue;const ge=ae&&(!pe||k*p<$),[Ae,Oe,Ie,Me]=ge?[ee,k,q,oe]:[se,$,B,D],ke=Me(H,Ae),He=Me(U,-Ae),ve=H.mass,ye=U.mass,Ve=ke?He?ye/(ve+ye):1:0,ft=He?ke?ve/(ve+ye):1:0,Qe=Oe*y;Ie.set(H.sid,(Ie.get(H.sid)??0)+Ae*Qe*Ve),Ie.set(U.sid,(Ie.get(U.sid)??0)-Ae*Qe*ft),Z+=Qe}for(const Q of b)Q.anchored||(Q.x=Math.max(0,Q.x+(q.get(Q.sid)??0)),Q.y=Math.max(0,Q.y+(B.get(Q.sid)??0)));if(Z<w)break}const z=[];for(const T of b){const q=T.x-O.get(T.sid),B=T.y-P.get(T.sid);if(!(Math.abs(q)<1&&Math.abs(B)<1)){for(const Z of T.members){if(i.has(Z))continue;const Q=n.get(Z);Q&&n.set(Z,{x:Q.x+q,y:Q.y+B})}z.push(T.sid)}}return z}const p$=600;function Ug(e,n){return!(e.exitAt!=null&&n-e.exitAt>p$||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function m$(e,n){const i=new Set;for(const s of e.agents.values())Ug(s,n)&&i.add(s.id);return i}function Fi(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function g$(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}const v$={agent:kP,sessionGroup:OP},y$=420,bl=18,w$=9e4,x$=200,_$=5*6e4,S$=6,b$=2*6e4,Av="agent-dag.layout",Iv="agent-dag.viewport",hC="agent-dag.summariesDismissed",pC="agent-dag.sessionListOpen",mC="agent-dag.detailOpen",gC="agent-dag.usagePanelOpen",jk="agent-dag.accountsPanelOpen",Rk="agent-dag.versionNoticeDismissed",k$={git_checkout:"this deck runs from a git checkout — pull instead",npx:"npx runs from a cache that cannot be upgraded in place",not_writable:"the install directory is not writable by this user",opted_out:"installs are off (AGENTS_DECK_NO_INSTALL=1)"},Tk="agent-dag.autoRestart",Ak="agent-dag.bundleReloadedFor";function E$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(pC)==="1"}catch{return!1}}function N$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(pC,e?"1":"0")}catch{}}function C$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(mC)==="1"}catch{return!1}}function j$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(mC,e?"1":"0")}catch{}}function R$(){if(typeof window>"u")return!0;const e=window.localStorage.getItem(gC);try{return e===null?!0:e==="1"}catch{return!0}}function T$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(gC,e?"1":"0")}catch{}}function A$(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(hC);if(!e)return new Set;const n=JSON.parse(e);return new Set(Array.isArray(n)?n.filter(i=>typeof i=="string"):[])}catch{return new Set}}function Ik(e){if(!(typeof window>"u"))try{const n=Array.from(e),i=n.length>200?n.slice(-200):n;window.localStorage.setItem(hC,JSON.stringify(i))}catch{}}function I$(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(Av);if(!n)return e;const i=JSON.parse(n);if(!("v"in i)){const o=Object.entries(i).filter(([,l])=>l&&typeof l.x=="number"&&typeof l.y=="number");return{positions:o,pins:o.map(([l])=>l)}}return{positions:Object.entries(i.positions??{}).filter(([,o])=>o&&typeof o.x=="number"&&typeof o.y=="number"),pins:Array.isArray(i.pins)?i.pins:[]}}catch{return e}}function bg(e,n){if(!(typeof window>"u"))try{const i={};for(const[s,o]of e)i[s]=o;for(const[s,o]of n)i[s]=o;window.localStorage.setItem(Av,JSON.stringify({v:2,positions:i,pins:Array.from(n.keys())}))}catch{}}function M$(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Iv);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 P$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Iv,JSON.stringify(e))}catch{}}function Mk(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Av)}catch{}try{window.localStorage.removeItem(Iv)}catch{}}}function O$(e,n){const i=e.agents.get(n);if(!i)return;const s=[];for(const p of e.agents.values())p.sessionId===n&&s.push(p);const o={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:n,label:i.label,cwd:i.cwd,startedAt:i.startedAt,endedAt:i.endedAt,model:i.model,agents:s.map(p=>({id:p.id,kind:p.kind,label:p.label,parentId:p.parentId,state:p.state,startedAt:p.startedAt,endedAt:p.endedAt,model:p.model,cwd:p.cwd,usage:p.usage,prompts:p.prompts,tools:p.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),f=document.createElement("a"),h=(i.label||"session").replace(/[^a-z0-9._-]/gi,"_");f.href=c,f.download=`agents-deck-${h}-${n.slice(0,8)}.json`,document.body.appendChild(f),f.click(),document.body.removeChild(f),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const Hg={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Vg={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},q$={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",shell:"shell",exec_command:"shell",shell_command:"shell",write_stdin:"shell",wait:"shell",apply_patch:"file",update_plan:"task",WebFetch:"web",WebSearch:"web",Task:"agent",Agent:"agent",TodoWrite:"task",TaskCreate:"task",TaskUpdate:"task",TaskList:"task",TaskGet:"task",TaskOutput:"task",TaskStop:"task",EnterPlanMode:"plan",ExitPlanMode:"plan",AskUserQuestion:"plan",Skill:"plan",Workflow:"plan"};function vC(e){return e.startsWith("mcp__")?"mcp":q$[e]??"other"}function yC(e,n){var s,o,l;if(!n)return!0;const i=n.toLowerCase();if(e.label.toLowerCase().includes(i)||(s=e.cwd)!=null&&s.toLowerCase().includes(i)||(o=e.cwdBasename)!=null&&o.toLowerCase().includes(i)||e.sessionId.toLowerCase().includes(i)||(l=e.firstPrompt)!=null&&l.toLowerCase().includes(i))return!0;for(const u of e.tools)if(u.name.toLowerCase().includes(i))return!0;return!1}function L$(e,n){if(!n)return null;const i=new Set([n]);let s=n;for(;s;){const l=e.agents.get(s);if(!(l!=null&&l.parentId)||i.has(l.parentId))break;i.add(l.parentId),s=l.parentId}let o=!0;for(;o;){o=!1;for(const l of e.agents.values())l.parentId&&i.has(l.parentId)&&!i.has(l.id)&&(i.add(l.id),o=!0)}return i}function $$(e,n,i,s,o,l,u,c,f,h,p,m,y,w,j,_,S,b){const E=[],N=[],C=new Set;if(l)for(const T of e.agents.values())yC(T,l)&&C.add(T.id);for(const T of e.agents.values()){if(!S.has(T.id))continue;const q=l?!C.has(T.id):!1,B=T.exitAt!=null,Z=_!=null&&!_.has(T.id),Q=[q?"rf-dim":"",B?"rf-exiting":"",Z?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,A=u.get(T.id);if(E.push({id:T.id,type:"agent",position:{x:0,y:0},data:{...T,now:n,dim:q,onOpenContext:b},className:Q,...A?{width:A.width,height:A.height}:null}),T.parentId&&S.has(T.parentId)){const H=dv(T.sessionId),U=T.state==="active"?`hsl(${H} 80% 72%)`:`hsl(${H} 50% 55%)`,ne=l&&!C.has(T.id)&&!C.has(T.parentId),Y=B,L=j.size>0&&(j.has(T.id)||j.has(T.parentId)),G=_!=null&&!_.has(T.id)&&!_.has(T.parentId),k=T.state==="active"?2:1.5,$=L?k+1.5:k,oe=ne||Y?.2:G?.12:1,D=[Y?"rf-edge-exiting":"",L?"rf-edge-selected":""].filter(Boolean).join(" ")||void 0;N.push({id:`e:${T.parentId}->${T.id}`,source:T.parentId,target:T.id,animated:(T.state==="active"||L)&&!ne&&!Y,type:"smoothstep",style:{stroke:U,strokeWidth:$,opacity:oe,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:D})}}const I=E.filter(T=>!o.has(T.id)&&!m.has(T.id));if(I.length>0||y!==w.current){if(I.length>0){const T=c$(E,N,{direction:"LR",pinned:o,measured:u,availableWidth:i,availableHeight:s});for(const q of T)m.has(q.id)||m.set(q.id,q.position);f$(E,m,o,u,new Set(I.map(q=>q.id)))}d$(E,m,o,u),w.current=y}const O=h$(E,m,o,u,c,!h||p);O.length>0&&f(O);for(const T of Array.from(m.keys()))e.agents.has(T)||m.delete(T);if(e.agents.size>0)for(const T of Array.from(o.keys()))e.agents.has(T)||o.delete(T);const P=[];let z=!1;for(const T of E){let q=o.get(T.id)??m.get(T.id);q||(q={x:0,y:0},m.set(T.id,q),z=!0),P.push({...T,position:q})}return z&&(w.current=""),{nodes:P,edges:N}}function D$(){return g.jsx(uv,{children:g.jsx(F$,{})})}function F$(){var eo,Hr,ha,to;const e=ta(),n=M.useRef(Fg()),[,i]=M.useState(0),s=M.useCallback(()=>i(W=>W+1),[]),[o,l]=M.useState(()=>new Set),[u,c]=M.useState(null),[f,h]=M.useState(null),p=M.useCallback((W,J)=>{l(ue=>{if(!J)return new Set([W]);const fe=new Set(ue);return fe.has(W)?fe.delete(W):fe.add(W),fe}),c(ue=>J&&ue===W?ue:W)},[]),m=M.useCallback(()=>{l(new Set),c(null)},[]),[y,w]=M.useState(null),[j,_]=M.useState(null),S=M.useCallback(W=>_(W),[]),b=M.useRef(A$()),[E,N]=M.useState(E$);M.useEffect(()=>{N$(E)},[E]);const[C,I]=M.useState(C$);M.useEffect(()=>{j$(C)},[C]);const[O,P]=M.useState(R$);M.useEffect(()=>{T$(O)},[O]);const[z,T]=M.useState(()=>{try{const W=window.localStorage.getItem(jk);return W===null?!0:W==="1"}catch{return!0}});M.useEffect(()=>{try{window.localStorage.setItem(jk,z?"1":"0")}catch{}},[z]);const[q,B]=M.useState(null),[Z,Q]=M.useState(!1),[A,H]=M.useState(0),[U,ne]=M.useState(0);M.useEffect(()=>{fetch("/api/sound-hook").then(W=>W.ok?W.json():null).then(W=>{W!=null&&W.ok&&(B(W.enabled===!0),H((W.foreign??[]).filter(J=>J.worksHere).length),ne(typeof W.parked=="number"?W.parked:0))}).catch(()=>{})},[]);const Y=M.useCallback(async()=>{Q(!0);try{const J=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!q})})).json().catch(()=>null);J!=null&&J.ok&&B(J.enabled===!0),fetch("/api/sound-hook").then(ue=>ue.ok?ue.json():null).then(ue=>{ue!=null&&ue.ok&&(H((ue.foreign??[]).filter(fe=>fe.worksHere).length),ne(typeof ue.parked=="number"?ue.parked:0))}).catch(()=>{})}catch{}finally{Q(!1)}},[q]),[L,G]=M.useState(!1),[k,$]=M.useState(null),[oe,D]=M.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(Rk)??""}catch{return""}}),[X,ee]=M.useState(!1),se=M.useCallback(()=>{fetch("/api/version").then(W=>W.ok?W.json():null).then(W=>{W&&$(W)}).catch(()=>{})},[]);M.useEffect(()=>{se();const W=window.setInterval(se,5*6e4),J=()=>{document.visibilityState==="visible"&&se()};return document.addEventListener("visibilitychange",J),()=>{window.clearInterval(W),document.removeEventListener("visibilitychange",J)}},[se]),M.useEffect(()=>{L&&se()},[L,se]);const ae=(k==null?void 0:k.notice)??null,pe=ae?`${ae.kind}:${ae.to}`:"",ge=ae!=null&&oe!==pe,Ae=M.useCallback(()=>{if(!ae)return;const W=oe===pe?"":pe;D(W);try{window.localStorage.setItem(Rk,W)}catch{}},[ae,pe,oe]),Oe=((eo=k==null?void 0:k.upgrade)==null?void 0:eo.state)??"idle",Ie=M.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}se()},[se]);M.useEffect(()=>{if(Oe!=="running")return;const W=window.setInterval(se,3e3);return()=>window.clearInterval(W)},[Oe,se]);const Me=M.useCallback(async()=>{var ue;const W=k==null?void 0:k.command;if(!W)return;let J=!1;try{J=await Promise.race([((ue=navigator.clipboard)==null?void 0:ue.writeText(W).then(()=>!0))??Promise.resolve(!1),new Promise(fe=>window.setTimeout(()=>fe(!1),500))])}catch{J=!1}if(!J)try{const fe=document.createElement("textarea");fe.value=W,fe.setAttribute("readonly",""),fe.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(fe),fe.select(),J=document.execCommand("copy"),fe.remove()}catch{J=!1}J&&(ee(!0),window.setTimeout(()=>ee(!1),1600))},[k==null?void 0:k.command]),ke=M.useCallback(()=>{N(W=>(W||T(!1),!W))},[]),He=M.useCallback(()=>{T(W=>(W||N(!1),!W))},[]),[ve,ye]=M.useState(!1),[Ve,ft]=M.useState(0),Qe=M.useRef(null),[We,$e]=M.useState(0),[Ke,yt]=M.useState(!1),et=M.useRef([]),[Ge,wt]=M.useState(Date.now()),[Rt,Ft]=M.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(Tk)!=="0"}catch{return!0}}),tt=M.useCallback(()=>{Ft(W=>{const J=!W;try{window.localStorage.setItem(Tk,J?"1":"0")}catch{}return J})},[]),[xt,lt]=M.useState(!1),[mt,wn]=M.useState(null),bt=M.useRef(!1),Tt=M.useCallback(async()=>{if(!bt.current){bt.current=!0,lt(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(ae==null?void 0:ae.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST"})}catch{}window.setTimeout(()=>{if(bt.current){bt.current=!1,lt(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},3e4)}},[ae==null?void 0:ae.to]),xn=M.useRef(null);M.useEffect(()=>{let W=!1;for(const ue of n.current.agents.values())if(ue.state==="active"){W=!0;break}const J=D3({enabled:Rt,kind:ae==null?void 0:ae.kind,canRestart:(k==null?void 0:k.canRestart)===!0,busy:W,idleSince:xn.current,now:Ge});xn.current=J.idleSince,J.restart&&Tt()},[Rt,ae==null?void 0:ae.kind,k==null?void 0:k.canRestart,Ge,Tt]),M.useEffect(()=>{let W=null;try{W=window.sessionStorage.getItem(Ak)}catch{return}if($3({bundle:"1.33.0",running:k==null?void 0:k.running,lastTried:W})){try{window.sessionStorage.setItem(Ak,(k==null?void 0:k.running)??"")}catch{return}window.location.reload()}},[k==null?void 0:k.running]),M.useEffect(()=>{const W=k==null?void 0:k.running;if(!W)return;let J=null;try{J=window.sessionStorage.getItem("agent-dag.restartPending")}catch{return}if(J==null||J&&J!==W)return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}bt.current=!1,lt(!1),wn(W);const ue=window.setTimeout(()=>wn(null),6e3);return()=>window.clearTimeout(ue)},[k==null?void 0:k.running]);const Ln=M.useRef(I$()).current;M.useRef(!1);const ut=M.useRef(new Map(Ln.positions.filter(([W])=>Ln.pins.includes(W)))),Yt=M.useRef(null),Qt=M.useState(()=>M$())[0],[At,mi]=M.useState(""),[gi,Ji]=M.useState(()=>new Set),[tr,Pr]=M.useState(()=>typeof window>"u"?"dark":window.localStorage.getItem("agent-dag.theme")??"dark"),[vi,fr]=M.useState(!1),Or=M.useRef(null);M.useEffect(()=>{document.documentElement.dataset.theme=tr;try{window.localStorage.setItem("agent-dag.theme",tr)}catch{}},[tr]),M.useEffect(()=>{if(!Qt)return;const W=window.setTimeout(()=>{try{e.setViewport(Qt,{duration:0})}catch{}},60);return()=>window.clearTimeout(W)},[e,Qt]);const nr=M.useRef(!0),qt=M.useRef(null);M.useEffect(()=>{const W=new EventSource("/events");return W.addEventListener("open",()=>{G(!0),fr(!0)}),W.addEventListener("error",()=>G(!1)),W.addEventListener("replay-end",()=>{nr.current=!1,qt.current!=null&&(window.clearTimeout(qt.current),qt.current=null),s()}),W.addEventListener("hook",J=>{try{const ue=JSON.parse(J.data);if(Ke){et.current.push(ue);return}n.current=Gw(n.current,ue),ue.replay===!0||nr.current||Date.now()-ue.receivedAt>3e4?(qt.current!=null&&window.clearTimeout(qt.current),qt.current=window.setTimeout(()=>{qt.current=null,s()},120)):(qt.current!=null&&(window.clearTimeout(qt.current),qt.current=null),s())}catch{}}),()=>{W.close(),qt.current!=null&&(window.clearTimeout(qt.current),qt.current=null)}},[Ke,s]),M.useEffect(()=>{if(!Ke&&et.current.length!==0){for(const W of et.current)n.current=Gw(n.current,W);et.current.length=0,s()}},[Ke,s]),M.useEffect(()=>{const W=setInterval(()=>{const J=Date.now();wt(J);let ue=lP(n.current,J,w$);oP(n.current,J,x$,_$)&&(ue=!0),aP(n.current,J,S$,b$)&&(ue=!0),ue&&s()},250);return()=>clearInterval(W)},[s]);const $n=M.useRef(null),pn=M.useRef(0),qr=420,zt=M.useCallback((W=500)=>{try{const xe=document.querySelector(".canvas-wrap"),Pe=Array.from(document.querySelectorAll(".react-flow__node")).filter(gt=>gt.offsetWidth>0);if(!xe||Pe.length===0)return;const ze=xe.getBoundingClientRect(),Ze=e.getViewport();if(!Number.isFinite(Ze.zoom)||Ze.zoom<=0)return;const Ye=gt=>(gt-ze.left-Ze.x)/Ze.zoom,Je=gt=>(gt-ze.top-Ze.y)/Ze.zoom,nn=Pe.map(gt=>gt.getBoundingClientRect()),Vr=Math.min(...nn.map(gt=>Ye(gt.left))),En=Math.max(...nn.map(gt=>Ye(gt.right))),gr=Math.min(...nn.map(gt=>Je(gt.top))),Wr=Math.max(...nn.map(gt=>Je(gt.bottom))),no=En-Vr,vr=Wr-gr;if(!(no>0&&vr>0))return;const rn=Math.max(.2,Math.min(1,(ze.width-160)/(no+qr)*.86,(ze.height-160)/vr*.86));e.setViewport({x:80-Vr*rn,y:Math.max(80,(ze.height-vr*rn)/2)-gr*rn,zoom:rn},{duration:W}),pn.current=Date.now(),window.setTimeout(()=>{try{const gt={x:80-Vr*rn,y:Math.max(80,(ze.height-vr*rn)/2)-gr*rn,zoom:rn},Ut=e.getViewport();(Math.abs(Ut.zoom-rn)>.01||Math.abs(Ut.x-gt.x)>2)&&e.setViewport(gt,{duration:0})}catch{}},W+60)}catch{}},[e]),yi=M.useRef(""),wi=M.useRef(null),xi=M.useRef(0),Zt=M.useCallback(()=>{xi.current=Date.now()},[]),Lr="agent-dag.autoFitDisabled",_n=M.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Lr)==="1"}catch{return!1}})()),[es,_i]=M.useState(_n.current),Si=M.useCallback(()=>{if(!_n.current){_n.current=!0,_i(!0);try{window.localStorage.setItem(Lr,"1")}catch{}}},[]),ts=M.useCallback(()=>{_n.current=!1,_i(!1);try{window.localStorage.removeItem(Lr)}catch{}zt(400)},[e,zt]);M.useEffect(()=>{const W=setInterval(()=>{if(_n.current||Date.now()-xi.current<800)return;const J=n.current,ue=Date.now(),fe=[];for(const Ye of J.agents.values())Ug(Ye,ue)&&fe.push({id:Ye.id});if(fe.length===0)return;const we=e.getViewport(),xe=window.innerWidth-360,Pe=window.innerHeight-52;let ze=!1,Ze=!1;for(const{id:Ye}of fe){const Je=Dn.current.get(Ye),nn=ut.current.get(Ye)??kt.current.get(Ye);if(!Je||!nn)continue;Ze=!0;const Vr=nn.x*we.zoom+we.x,En=nn.y*we.zoom+we.y,gr=(nn.x+Je.width)*we.zoom+we.x,Wr=(nn.y+Je.height)*we.zoom+we.y;if(gr>0&&Vr<xe&&Wr>0&&En<Pe){ze=!0;break}}Ze&&!ze&&zt(600)},1500);return()=>clearInterval(W)},[e]);const $r=M.useRef(!1),Dn=M.useRef(new Map),ns=M.useRef(0),rt=M.useCallback(W=>{const J=Dn.current;let ue=!1;for(const fe of W.nodeInternals.values()){const we=fe.width,xe=fe.height;if(we==null||xe==null)continue;const Pe=J.get(fe.id);Pe?(Math.abs(Pe.height-xe)>4||Math.abs(Pe.width-we)>4)&&(J.set(fe.id,{width:we,height:xe}),ue=!0):(J.set(fe.id,{width:we,height:xe}),ue=!0)}return ue&&(ns.current+=1),ns.current},[]),rs=Xe(rt),[Dr,is]=M.useState(0);M.useEffect(()=>{let W=0;const J=()=>{const fe=Dn.current;let we=!1;for(const xe of document.querySelectorAll(".react-flow__node[data-id]")){const Pe=xe.getAttribute("data-id");if(!Pe)continue;const ze=xe.offsetWidth,Ze=xe.offsetHeight;if(!ze||!Ze)continue;const Ye=fe.get(Pe);(!Ye||Math.abs(Ye.width-ze)>4||Math.abs(Ye.height-Ze)>4)&&(fe.set(Pe,{width:ze,height:Ze}),we=!0)}we&&is(xe=>xe+1)};if($r.current)return;let ue=0;return document.visibilityState==="hidden"?ue=window.setTimeout(J,32):W=requestAnimationFrame(J),()=>{cancelAnimationFrame(W),window.clearTimeout(ue)}});const kt=M.useRef(new Map(Ln.positions)),Fr=M.useRef(""),Fn=M.useMemo(()=>{const W=[];for(const J of n.current.agents.values())Ug(J,Ge)&&W.push(J.id+(J.parentId?`>${J.parentId}`:""));return W.sort(),`${W.join("|")}#sv${rs}.${Dr}`},[n.current,n.current.lastSeq,Ge,rs,Dr]),Sn=M.useRef(null);M.useEffect(()=>(Sn.current!=null&&window.clearTimeout(Sn.current),Sn.current=window.setTimeout(()=>{bg(kt.current,ut.current)},1500),()=>{Sn.current!=null&&window.clearTimeout(Sn.current)}),[Fn]),M.useEffect(()=>{if(yi.current===Fn)return;const W=yi.current;if(yi.current=Fn,!W||_n.current)return;Date.now()-pn.current>1200&&zt(400),$n.current&&window.clearTimeout($n.current),$n.current=window.setTimeout(()=>{_n.current||zt(500)},280)},[Fn,e,zt]);const Bt=M.useMemo(()=>{if(o.size===0)return null;const W=new Set;for(const J of o){const ue=L$(n.current,J);if(ue)for(const fe of ue)W.add(fe)}return W.size>0?W:null},[n.current,n.current.lastSeq,o]),hr=M.useMemo(()=>m$(n.current,Ge),[n.current,n.current.lastSeq,Ge]),Jt=M.useRef(null),[ss,la]=M.useState({w:0,h:0});M.useEffect(()=>{const W=Jt.current;if(!W||typeof ResizeObserver>"u")return;const J=new ResizeObserver(ue=>{var we;const fe=(we=ue[0])==null?void 0:we.contentRect;fe&&la(xe=>Math.abs(xe.w-fe.width)>40||Math.abs(xe.h-fe.height)>40?{w:fe.width,h:fe.height}:xe)});return J.observe(W),la({w:W.clientWidth,h:W.clientHeight}),()=>J.disconnect()},[]);const fu=M.useRef(new Map),[bi,os]=M.useState(!1);M.useEffect(()=>{const W=window.setTimeout(()=>os(!0),2500);return()=>window.clearTimeout(W)},[]);const[ki,zr]=M.useState(!1),rr=M.useRef(null),[Ks,as]=M.useState(!1),ua=M.useCallback(()=>{rr.current&&(window.clearTimeout(rr.current),rr.current=null),zr(!1)},[]),Xs=M.useCallback(W=>{W.length!==0&&queueMicrotask(()=>{zr(!0),rr.current&&window.clearTimeout(rr.current),rr.current=window.setTimeout(()=>zr(!1),y$+80)})},[]);M.useEffect(()=>()=>{rr.current&&window.clearTimeout(rr.current)},[]);const Br=ss.w>0?ss.w*.92:0,ca=ss.h>0?ss.h:0,{nodes:en,edges:Ue}=M.useMemo(()=>$$(n.current,Ge,Br,ca,ut.current,At,Dn.current,fu.current,Xs,bi,Ks,kt.current,Fn,Fr,o,Bt,hr,S),[n.current,n.current.lastSeq,Ge,Br,ca,bi,Ks,At,Fn,o,Bt,hr,S,Ve]),Qs=M.useMemo(()=>{const W=new Map;for(const ue of en){const fe=ue.data;if(!(fe!=null&&fe.sessionId)||fe.exitAt!=null)continue;const we=ue.width,xe=ue.height;if(we==null||xe==null)continue;const Pe=ue.position.x,ze=ue.position.y,Ze=Pe+we,Ye=ze+xe,Je=W.get(fe.sessionId);Je?(Je.minX=Math.min(Je.minX,Pe),Je.minY=Math.min(Je.minY,ze),Je.maxX=Math.max(Je.maxX,Ze),Je.maxY=Math.max(Je.maxY,Ye)):W.set(fe.sessionId,{minX:Pe,minY:ze,maxX:Ze,maxY:Ye})}const J=[];for(const[ue,fe]of W){const we=fe.maxX-fe.minX+bl*2,xe=fe.maxY-fe.minY+bl*2;J.push({id:`group:${ue}`,type:"sessionGroup",position:{x:fe.minX-bl,y:fe.minY-bl},data:{sessionId:ue,w:we,h:xe},width:we,height:xe,style:{width:we,height:xe},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return J},[en,Ge]),da=M.useMemo(()=>{const W=[...Qs,...en],J=Qe.current;return!J||J.size===0?W:W.map(ue=>{const fe=J.get(ue.id);return fe?{...ue,position:fe}:ue})},[Qs,en,We]),Zs=M.useMemo(()=>{if(!At)return null;const W=new Set;for(const J of n.current.agents.values())yC(J,At)&&W.add(J.id);return W},[n.current,n.current.lastSeq,At]),Js=M.useMemo(()=>{const W=new Set;for(const J of n.current.agents.values())for(const ue of J.tools)W.add(vC(ue.name));return Object.keys(Hg).filter(J=>W.has(J))},[n.current,n.current.lastSeq]),Ur=M.useMemo(()=>{const W=new Map;for(const ue of n.current.agents.values())for(const fe of ue.tools){if(!fe.name.startsWith("mcp__"))continue;const we=fe.name.slice(5),xe=we.indexOf("__"),Pe=xe>0?we.slice(0,xe):we;W.set(Pe,(W.get(Pe)??0)+1)}const J=[];for(const[ue,fe]of W){let we=5381;for(let xe=0;xe<ue.length;xe++)we=(we<<5)+we^ue.charCodeAt(xe);J.push({server:ue,count:fe,hue:Math.abs(we)%360})}return J.sort((ue,fe)=>fe.count-ue.count),J},[n.current,n.current.lastSeq]),fa=M.useCallback(W=>{Ji(J=>{const ue=new Set(J);return ue.has(W)?ue.delete(W):ue.add(W),ue})},[]),It=u?n.current.agents.get(u):null,Ei=f?Array.from(n.current.agents.values()).flatMap(W=>W.tools).find(W=>W.id===f)??null:null,bn=M.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=Fg(),ut.current.clear(),Dn.current.clear(),kt.current.clear(),Fr.current="",Mk(),m(),s()},[s,m]),kn=M.useCallback(()=>{ut.current.clear(),kt.current.clear(),Fr.current="",Mk(),s(),window.setTimeout(()=>zt(500),80)},[s,e,zt]),zn=M.useCallback(()=>zt(500),[zt]),pr=M.useCallback(W=>{if(en.length===0)return;const J=en.slice().sort((xe,Pe)=>xe.position.y-Pe.position.y||xe.position.x-Pe.position.x),ue=u?J.findIndex(xe=>xe.id===u):-1;let fe;ue===-1?fe=W===1?0:J.length-1:fe=(ue+W+J.length)%J.length;const we=J[fe];we&&(p(we.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[we]})}catch{}pn.current=Date.now()},30))},[en,u,p,e]);M.useEffect(()=>{const W=J=>{var fe,we;const ue=((fe=J.target)==null?void 0:fe.tagName)==="INPUT";if(J.key==="Escape"){ue?J.target.blur():m();return}if(!ue){if(J.key==="/"){J.preventDefault(),(we=Or.current)==null||we.focus();return}J.key===" "&&(J.preventDefault(),yt(xe=>!xe)),(J.key==="c"||J.key==="C")&&bn(),(J.key==="r"||J.key==="R")&&kn(),(J.key==="f"||J.key==="F")&&zn(),(J.key==="l"||J.key==="L")&&ke(),(J.key==="h"||J.key==="H")&&ye(xe=>!xe),(J.key==="u"||J.key==="U")&&P(xe=>!xe),(J.key==="a"||J.key==="A")&&He(),(J.key==="j"||J.key==="J")&&pr(1),(J.key==="k"||J.key==="K")&&pr(-1),(J.key==="t"||J.key==="T")&&Pr(xe=>xe==="dark"?"light":"dark")}};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[bn,kn,zn,m,pr]);const mr=n.current.agents.size,ir=new Set(Array.from(n.current.agents.values()).map(W=>W.sessionId)).size,tn=M.useMemo(()=>{let W=0,J=0,ue=0,fe=0,we=0,xe=0,Pe=0,ze=0,Ze=0;for(const Ye of n.current.agents.values()){W+=Ye.usage.inputTokens,J+=Ye.usage.outputTokens,ue+=Ye.usage.cacheReadTokens,fe+=Ye.usage.cacheCreateTokens;const Je=fn(Ye.usage,Ye.model);we+=Je.total,xe+=Je.input,Pe+=Je.output,ze+=Je.cacheRead,Ze+=Je.cacheWrite}return{inT:W,outT:J,cacheR:ue,cacheC:fe,sum:W+J,cost:{total:we,input:xe,output:Pe,cacheRead:ze,cacheWrite:Ze}}},[n.current,n.current.lastSeq]);return g.jsxs("div",{className:"app",children:[g.jsxs("header",{className:"topbar",children:[g.jsxs("div",{className:"brand",children:[g.jsx("span",{className:"logo"}),"agents-deck",ae?g.jsxs("button",{type:"button",className:"v stale",onClick:Ae,title:ae.kind==="restart"?`Running v${ae.from}; v${ae.to} is installed on disk. Restart to pick it up.`:`Running v${ae.from}; v${ae.to} is on npm.`,children:["v",ae.from,g.jsx("span",{className:"v-dot","aria-hidden":!0})]}):g.jsxs("span",{className:"v",children:["v",(k==null?void 0:k.running)??"1.33.0"]})]}),It&&(()=>{const W=fn(It.usage,It.model),J=Math.max(0,((It.endedAt??Ge)-It.startedAt)/1e3),ue=It.state==="active"?$l(W.total,J):null,fe=o.size-1;return g.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${It.label}`,onClick:()=>{try{const we=en.find(xe=>xe.id===It.id);we&&e.fitView({padding:.35,duration:500,nodes:[we]}),pn.current=Date.now()}catch{}},children:[g.jsx("span",{className:`state-pill state-${It.state}`,children:It.state==="active"?"live":It.state}),g.jsx("span",{className:"selected-label",children:It.label}),W.total>0&&g.jsxs("span",{className:"selected-cost",children:[Fe(W.total),ue?g.jsxs("span",{className:"selected-rate",children:[" · ",ue]}):null]}),fe>0&&g.jsxs("span",{className:"selected-extra",children:["+",fe]}),g.jsx("span",{role:"button","aria-label":"Deselect",className:"selected-close",onClick:we=>{we.stopPropagation(),m()},children:"×"})]})})(),g.jsxs("div",{className:"actions",children:[g.jsxs("div",{className:"search",children:[g.jsx("span",{className:"search-icon","aria-hidden":!0,children:"⌕"}),g.jsx("input",{ref:Or,type:"text",placeholder:"Search agents, cwd, tools…",value:At,onChange:W=>mi(W.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),At?g.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>mi(""),children:"×"}):g.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"})]}),g.jsxs("span",{className:"status",role:"status",children:[g.jsx("span",{className:`pill ${L?"live":"dead"}`,title:L?"Receiving events":"SSE disconnected",children:L?"live":"offline"}),g.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[g.jsx("span",{className:"count",children:ir}),g.jsx("span",{className:"lbl",children:"sessions"})]}),g.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[g.jsx("span",{className:"count",children:mr}),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"})]}),tn.sum>0&&g.jsxs("span",{className:"stat",title:`in:${tn.inT.toLocaleString()} out:${tn.outT.toLocaleString()} cache-r:${tn.cacheR.toLocaleString()} cache-c:${tn.cacheC.toLocaleString()}`,children:[g.jsx("span",{className:"count",children:g$(tn.sum)}),g.jsx("span",{className:"lbl",children:"tokens"})]}),Ur.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:w,children:[g.jsx("b",{children:Fe(p.total)}),y&&g.jsx("span",{className:"cost-rate",children:y})]})})()]}),g.jsx(Us,{type:"source",position:Ce.Right,style:{background:"transparent",border:"none"}})]})}function EP({state:e}){const n=e==="active"?"live":e==="done"?"done":"err";return g.jsx("span",{className:`state-pill state-${e}`,children:n})}function NP(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function CP({tools:e,now:n}){const l=new Array(24).fill(0);let u=0;for(const y of e){const w=n-y.startedAt;if(w<0||w>=6e4)continue;const j=23-Math.floor(w/2500);j>=0&&j<24&&(l[j]+=1,u+=1)}const c=Math.max(1,...l),f=132,h=14,p=f/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:f,height:h,viewBox:`0 0 ${f} ${h}`,"aria-hidden":!0,children:l.map((y,w)=>{const j=y===0?1.5:Math.max(1.5,y/c*h),_=w===23&&y>0,b=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return g.jsx("rect",{x:w*p+.4,y:h-j,width:Math.max(.5,p-1),height:j,rx:.8,className:b},w)})}),g.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function na(e){const n=e.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const o=n[1][0].toUpperCase()+n[1].slice(1).toLowerCase(),l=n[2].replace(/[-_]/g,".");return`${o} ${l}`}const i=e.match(/^gpt[-_](\d+(?:[-_.]\d+)*)[-_]codex\b/i);if(i)return`GPT-${i[1].replace(/[-_]/g,".")} Codex`;const s=e.match(/^gpt[-_](\d+(?:[-_.]\d+)*)/i);return s?`GPT-${s[1].replace(/[-_]/g,".")}`:e}function Kw(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function jP(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 RP({tool:e,onClose:n}){M.useEffect(()=>{const s=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]);const i=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return g.jsx("div",{className:"modal-backdrop",onClick:n,role:"dialog","aria-modal":"true",children:g.jsxs("div",{className:"modal",onClick:s=>s.stopPropagation(),children:[g.jsxs("header",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:`status-dot ${i}`}),g.jsx("span",{className:"modal-tool-name",children:e.name}),g.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",children:jP(e)}),g.jsx("button",{className:"btn icon-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),g.jsxs("section",{className:"modal-body",children:[g.jsxs("div",{className:"modal-section",children:[g.jsx("h4",{children:"Input"}),g.jsx("pre",{children:Kw(e.input??e.inputPreview)})]}),g.jsxs("div",{className:"modal-section",children:[g.jsxs("h4",{children:["Response ",i==="err"&&g.jsx("span",{className:"err-tag",children:"error"})]}),g.jsx("pre",{children:e.endedAt==null?"(waiting…)":Kw(e.response??e.errorPreview)})]})]})]})})}const yl=18,Xw=26,TP=12;function AP(e){const n=new Map;for(const o of e.nodeInternals.values()){const l=o.data;if(!(l!=null&&l.sessionId)||l.exitAt!=null||o.width==null||o.height==null)continue;const u=o.position.x,c=o.position.y,f=u+o.width,h=c+o.height,p=n.get(l.sessionId);p?(p.minX=Math.min(p.minX,u),p.minY=Math.min(p.minY,c),p.maxX=Math.max(p.maxX,f),p.maxY=Math.max(p.maxY,h),l.kind==="root"&&(p.label=Qw(l)??p.label)):n.set(l.sessionId,{minX:u,minY:c,maxX:f,maxY:h,label:Qw(l)??l.sessionId})}const i=new Map;for(const o of n.values())i.set(o.label,(i.get(o.label)??0)+1);const s=[];for(const[o,l]of n){const c=(i.get(l.label)??0)>1?`${l.label} · ${IP(o)}`:l.label;s.push({sessionId:o,label:c,x:l.minX-yl,y:l.minY-yl-Xw,w:l.maxX-l.minX+yl*2,h:l.maxY-l.minY+yl*2+Xw})}return s}function IP(e){const n=e.match(/[a-zA-Z0-9]{4}/);return n?n[0]:e.slice(0,4)}function Qw(e){if(e.kind==="root")return e.label}function MP(){const{x:e,y:n,zoom:i}=JE(),s=ta(),o=Xe(AP,PP);if(o.length<=1)return null;const l=u=>{try{const c=s.getNodes().filter(f=>{const h=f.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=dv(u.sessionId),f={position:"absolute",left:u.x*i+e,top:u.y*i+n,width:u.w*i,height:u.h*i,borderColor:`hsl(${c} 65% 55% / 0.32)`,background:`hsl(${c} 70% 50% / 0.04)`},h={position:"absolute",left:u.x*i+e+16*i,top:(u.y-TP)*i+n,color:`hsl(${c} 70% 78%)`,borderColor:`hsl(${c} 65% 55% / 0.5)`,transform:`scale(${Math.min(1,i)})`,transformOrigin:"left top"};return g.jsxs(le.Fragment,{children:[g.jsx("div",{className:"cluster-card",style:f,"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 PP(e,n){if(e.length!==n.length)return!1;for(let i=0;i<e.length;i++){const s=e[i],o=n[i];if(s.sessionId!==o.sessionId||s.label!==o.label||s.x!==o.x||s.y!==o.y||s.w!==o.w||s.h!==o.h)return!1}return!0}function OP({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 uN=600,qP=36,Bg=16,LP=60,$P=6,Zw=220,Jw=96,DP=28,FP={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 zP(e){return e.startsWith("mcp__")?"mcp":FP[e]??"other"}const BP={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 ex(e){return e.startsWith("mcp__")?"🔌":BP[e]??"✨"}const UP={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 cN(e){if(!e)return null;let n=e.trim();if(!n)return null;const i=n.match(/^(?:bash|sh|zsh|fish|powershell|pwsh)(?:\.exe)?\s+(?:-c|-Command|-NoProfile|-NonInteractive|\s)+["']([^"']+)["']/i);if(i)return cN(i[1]);for(;;){const l=n.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!l)break;n=n.slice(l[0].length)}n=n.replace(/^sudo(?:\s+-\S+)*\s+/,""),n=n.replace(/^(?:time|nohup|xargs)\s+/,"");const s=n.match(/^([^\s|;&<>(]+)/);if(!s)return null;let o=s[1];return o=o.replace(/^.*[/\\]/,""),o=o.replace(/\.(exe|cmd|bat|ps1)$/i,""),o||null}function HP(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const n=e;if(typeof n.cmd=="string")return n.cmd;if(typeof n.command=="string")return n.command;if(Array.isArray(n.command)&&n.command.every(i=>typeof i=="string")){const i=n.command;if(/powershell|cmd|bash|sh(\.exe)?$/i.test(i[0]??"")){const s=i.findIndex(o=>/^(-Command|-c)$/i.test(o));if(s>=0&&s+1<i.length)return i[s+1]}return i.join(" ")}return typeof n.script=="string"?n.script:null}const VP=new Set(["Bash","PowerShell","shell","exec_command","shell_command","write_stdin","wait"]),WP=new Set(["shell","exec_command","shell_command","write_stdin","wait","apply_patch","update_plan"]);function GP(e,n){return WP.has(e)?Math.max(Jw,34+n.length*7.5):Jw}function YP(e,n){if(!VP.has(e))return null;const i=HP(n);if(!i)return null;const s=cN(i);return s?{emoji:UP[s]??"⚙️",label:s,category:"shell",detail:i}:null}const KP=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),tx={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:"🗄️"},nx={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 XP(e){const i=e.replace(/\\/g,"/").replace(/\/+$/,""),s=i.lastIndexOf("/");return s>=0?i.slice(s+1):i}function QP(e){const n=e.toLowerCase();if(nx[n])return nx[n];if(n.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(n))return"🧪";const i=n.lastIndexOf(".");if(i>0&&i<n.length-1){const s=n.slice(i+1);if(tx[s])return tx[s]}return"📄"}function ZP(e,n){if(!n||typeof n!="object")return null;const i=n;if(e==="apply_patch"&&typeof i.patch=="string"){const s=i.patch.match(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/m);return s?s[1].trim():null}return typeof i.file_path=="string"?i.file_path:typeof i.notebook_path=="string"?i.notebook_path:typeof i.path=="string"?i.path:e==="Glob"&&typeof i.pattern=="string"?i.pattern:null}function JP(e,n){if(!KP.has(e))return null;const i=ZP(e,n);if(!i)return null;const s=XP(i);return s?{emoji:e==="LS"?"📂":QP(s),label:s,category:"file",detail:i}:null}const dN={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 fN(e){if(!e.startsWith("mcp__"))return null;const n=e.slice(5),i=n.indexOf("__");return i<=0?{server:n,method:""}:{server:n.slice(0,i),method:n.slice(i+2)}}function e3(e){let n=5381;for(let i=0;i<e.length;i++)n=(n<<5)+n^e.charCodeAt(i);return Math.abs(n)%360}function t3(e,n){const i=fN(e);if(!i)return null;const{server:s,method:o}=i;if(!o)return null;const l=dN[s.toLowerCase()];return{emoji:(l==null?void 0:l.emoji)??"🔌",label:o,category:"mcp",detail:l?`${l.name} · ${o}`:`${s} · ${o}`}}function n3(e,n){return YP(e,n)??JP(e,n)??t3(e)}const r3={shell:"Shell",exec_command:"Shell",shell_command:"Shell",write_stdin:"stdin",wait:"wait",apply_patch:"Edit",update_plan:"Plan"};function i3(e){const n=fN(e);if(n){const s=dN[n.server.toLowerCase()];return s?{emoji:s.emoji,label:s.name}:{emoji:"🔌",label:n.server,hue:e3(n.server)}}const i=r3[e];return i?{emoji:ex(e),label:i}:{emoji:ex(e),label:e}}function s3(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function o3(e,n,i){if(i==null)return 1;const s=n-i;return s<0?1:Math.max(0,1-s/uN)}function a3(e,n,i,s,o,l){const u=[];for(const c of e.values()){if(!n.has(c.id)||c.exitAt!=null&&l-c.exitAt>uN)continue;const f=s.get(c.id)??i.get(c.id);if(!f)continue;const h=c.tools.slice(-4);if(h.length===0)continue;const p=c.exitAt??null,m=o.get(c.id),y=Math.max((m==null?void 0:m.width)??Zw,Zw),w=(m==null?void 0:m.height)??130,j=f.x,_=f.y,S=j+y,b=_+w/2;h.forEach((E,N)=>{const C=N*qP,I=j+y+LP,O=_+$P+C,P=o3(E,l,p),z=E.inputPreview??"",T=s3(E),q=P<.999,B=i3(E.name);u.push({id:E.id,toolId:E.id,agentId:c.id,toolName:E.name,name:B.label,emoji:B.emoji,status:T,category:zP(E.name),mcpHue:B.hue,inputPreview:z,fade:P,fading:q,worldX:I,worldY:O,anchorX:S,anchorY:b,spawnDx:S-I,spawnDy:b-(O+Bg)});const Z=n3(E.name,E.input);if(Z){const Q=GP(E.name,B.label),A=I+Q+DP,H=O,U=I+Q,ne=O+Bg;u.push({id:`sub:${E.id}`,toolId:E.id,agentId:c.id,toolName:E.name,name:Z.label,emoji:Z.emoji,isSub:!0,status:T,category:Z.category,inputPreview:Z.detail??z,fade:P,fading:q,worldX:A,worldY:H,anchorX:U,anchorY:ne,spawnDx:U-A,spawnDy:0})}})}return u}function l3({agents:e,visibleAgentIds:n,positions:i,pinned:s,measured:o,dimUnmatched:l,spotlight:u,hiddenCategories:c,now:f,onOpenTool:h}){const{x:p,y:m,zoom:y}=JE(),w=a3(e,n,i,s,o,f),j=c&&c.size>0?w.filter(_=>!c.has(_.category)):w;return g.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[g.jsx("svg",{className:"tool-bursts-svg",children:j.map(_=>{const S=_.anchorX*y+p,b=_.anchorY*y+m,E=(_.worldX+6)*y+p,N=(_.worldY+Bg)*y+m,C=S+(E-S)*.55,I=l!=null&&!l.has(_.agentId),O=u!=null&&!u.has(_.agentId),P=_.fade*(I||O?.14:1);return g.jsx("path",{d:`M ${S} ${b} Q ${C} ${b}, ${E} ${N}`,className:`tool-conn status-${_.status}${_.fading?" fading":""}`,opacity:P},`l:${_.id}`)})}),j.map(_=>{const S=_.worldX*y+p,b=_.worldY*y+m,E={left:`${S}px`,top:`${b}px`,transform:`scale(${y})`,transformOrigin:"left top","--spawn-dx":`${_.spawnDx}px`,"--spawn-dy":`${_.spawnDy}px`},N=_.isSub?`${_.toolName} · ${_.name}`:_.toolName,C=_.inputPreview?`${N} · ${_.inputPreview}`:N,I=h!=null,O=_.mcpHue!=null?{"--cat-accent":`hsl(${_.mcpHue} 65% 65%)`}:{},P=l!=null&&!l.has(_.agentId),z=u!=null&&!u.has(_.agentId),T=P||z?" dim":"";return g.jsx("div",{className:"tool-burst-wrap",style:E,children:g.jsxs("div",{className:`tool-burst cat-${_.category} status-${_.status}${_.fading?" fading":""}${I?" clickable":""}${_.isSub?" sub":""}${T}`,style:O,title:C,role:I?"button":void 0,tabIndex:I?0:void 0,"aria-label":I?`Open ${_.toolName} ${_.status==="inflight"?"in flight":_.status} — click for details`:void 0,onClick:I?()=>h(_.toolId):void 0,onKeyDown:I?q=>{(q.key==="Enter"||q.key===" ")&&(q.preventDefault(),h(_.toolId))}:void 0,children:[g.jsx("span",{className:"tb-emoji",children:_.emoji}),g.jsx("span",{className:"tb-name",children:_.name}),_.status==="inflight"&&g.jsx("span",{className:"tb-spin"}),_.status==="done"&&g.jsx("span",{className:"tb-mark done",children:"✓"}),_.status==="err"&&g.jsx("span",{className:"tb-mark err",children:"×"})]})},_.id)})]})}function u3({state:e,sessionId:n,onClose:i}){const s=M.useMemo(()=>d3(e,n),[e,n]);return s?g.jsx("div",{className:"modal-backdrop",onClick:i,role:"presentation",children:g.jsxs("div",{className:"modal session-summary",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[g.jsxs("div",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),g.jsx("span",{id:"ss-title",className:"modal-tool-name",title:s.cwd??s.sessionId,children:s.label}),g.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.durationLabel}),g.jsx("button",{className:"btn",onClick:i,"aria-label":"Close",children:"×"})]})]}),g.jsxs("div",{className:"modal-body",children:[g.jsxs("section",{className:"ss-hero",children:[g.jsxs("div",{className:"ss-hero-left",children:[g.jsx("div",{className:"ss-cost-label",children:"total spend"}),g.jsx("div",{className:"ss-cost",children:Fe(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:na(o)},o))})]}),g.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&g.jsxs(g.Fragment,{children:[g.jsx(c3,{cost:s.cost}),g.jsxs("div",{className:"ss-cost-legend",children:[g.jsxs("span",{className:"ssl ssl-in",children:["input ",g.jsx("b",{children:Fe(s.cost.input)})]}),g.jsxs("span",{className:"ssl ssl-out",children:["output ",g.jsx("b",{children:Fe(s.cost.output)})]}),g.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",g.jsx("b",{children:Fe(s.cost.cacheRead)})]}),g.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",g.jsx("b",{children:Fe(s.cost.cacheWrite)})]})]})]})})]}),g.jsxs("section",{className:"ss-stats",children:[g.jsx(Ms,{label:"agents",value:s.agentCount}),g.jsx(Ms,{label:"subagents",value:s.subagentCount}),g.jsx(Ms,{label:"tool calls",value:s.toolCount}),g.jsx(Ms,{label:"prompts",value:s.promptCount}),g.jsx(Ms,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&g.jsx(Ms,{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 Ms({label:e,value:n,tone:i}){return g.jsxs("div",{className:`ss-stat${i?` tone-${i}`:""}`,children:[g.jsx("div",{className:"ss-stat-value",children:n}),g.jsx("div",{className:"ss-stat-label",children:e})]})}function c3({cost:e}){const n=e.total;if(n<=0)return null;const i=(s,o,l)=>{if(s<=0)return null;const u=s/n*100;return g.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${Fe(s)} (${u.toFixed(0)}%)`},o)};return g.jsxs("div",{className:"cost-bar cost-bar-lg","aria-label":"Cost breakdown",children:[i(e.input,"cb-input","input"),i(e.output,"cb-output","output"),i(e.cacheRead,"cb-cache-r","cache read"),i(e.cacheWrite,"cb-cache-w","cache write")]})}function d3(e,n){const i=e.agents.get(n);if(!i)return null;const s=[];for(const N of e.agents.values())N.sessionId===n&&s.push(N);if(s.length===0)return null;const o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},l=new Set,u=new Map;let c=0,f=0,h=0,p=0,m=0,y,w=1/0,j=0;for(const N of s){const C=fn(N.usage,N.model);o.input+=C.input,o.output+=C.output,o.cacheRead+=C.cacheRead,o.cacheWrite+=C.cacheWrite,o.total+=C.total,N.model&&l.add(N.model),N.kind==="subagent"&&m++,f+=N.prompts.length,!y&&N.prompts.length>0&&(y=N.prompts[0].text),h+=N.usage.inputTokens+N.usage.outputTokens,c+=N.tools.length,w=Math.min(w,N.startedAt),j=Math.max(j,N.endedAt??Date.now());for(const I of N.tools)u.set(I.name,(u.get(I.name)??0)+1),I.ok===!1&&p++}const _=Math.max(0,j-w),S=Math.floor(_/1e3),b=S<60?`${S}s`:S<3600?`${Math.floor(S/60)}m ${String(S%60).padStart(2,"0")}s`:`${Math.floor(S/3600)}h ${Math.floor(S%3600/60)}m`,E=Array.from(u.entries()).sort((N,C)=>C[1]-N[1]).slice(0,5);return{sessionId:n,label:i.label||i.cwdBasename||"session",cwd:i.cwd,durationLabel:b,cost:o,modelChips:Array.from(l),agentCount:s.length,subagentCount:m,toolCount:c,promptCount:f,tokensSum:h,errCount:p,topTools:E,firstPrompt:y}}function f3(e,n){const i=[];for(const s of e.agents.values()){if(s.kind!=="root")continue;let o=s.tools.length,l=fn(s.usage,s.model).total,u=s.endedAt??s.startedAt;for(const c of e.agents.values()){if(c.sessionId!==s.sessionId||c.kind==="root")continue;o+=c.tools.length,l+=fn(c.usage,c.model).total;const f=c.endedAt??c.startedAt;f>u&&(u=f)}i.push({sessionId:s.sessionId,label:s.label||s.cwdBasename||"session",cwdBasename:s.cwdBasename,state:s.state,modelId:s.model,toolCount:o,cost:l,startedAt:s.startedAt,lastActivity:u})}return i.sort((s,o)=>{if(s.state!==o.state){if(s.state==="active")return-1;if(o.state==="active")return 1}return o.lastActivity-s.lastActivity}),i}function h3(e,n,i){const s=(n??i)-e;if(s<1e3)return"<1s";const o=Math.floor(s/1e3);if(o<60)return`${o}s`;const l=Math.floor(o/60);return l<60?`${l}m`:`${Math.floor(l/60)}h ${l%60}m`}function p3({state:e,now:n,selectedIds:i,onSelect:s,onClose:o}){const l=M.useMemo(()=>f3(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 f=i.has(c.sessionId);return g.jsxs("button",{type:"button",className:`sl-row state-${c.state}${f?" 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:na(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:Fe(c.cost)})}),g.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(c.startedAt).toLocaleString()}`,children:h3(c.startedAt,c.state==="active"?void 0:c.lastActivity,n)})]})]})]},c.sessionId)})]})]})}function rx(e,n){if(!e)return null;const i=n-Math.floor(e/1e3);return i<10?"just now":i<60?`${i}s ago`:i<3600?`${Math.floor(i/60)}m ago`:`${Math.floor(i/3600)}h ago`}function m3(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 Cr(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function g3({cost:e}){const n=e.total;if(n<=0)return null;const i=(s,o,l)=>{if(s<=0)return null;const u=s/n*100;return g.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${Fe(s)} (${u.toFixed(0)}%)`},o)};return g.jsxs("div",{className:"cost-bar","aria-label":"Cost breakdown",children:[i(e.input,"cb-input","input"),i(e.output,"cb-output","output"),i(e.cacheRead,"cb-cache-r","cache read"),i(e.cacheWrite,"cb-cache-w","cache write")]})}function v3(e,n){const i=e-n;if(i<=0)return null;const s=Math.floor(i/3600),o=Math.floor(i%3600/60);if(s>23){const l=Math.floor(i/86400),u=Math.floor(i%86400/3600);return`${l}d ${u}h`}return s>0?`${s}h ${o}m`:`${o}m`}function y3(e,n,i,s){const o=Math.max(0,n-s),l=Math.max(0,i-o);if(l<120)return null;const u=Math.min(100,l/i*100),c=e-u;if(Math.abs(c)<3)return{label:"on pace",color:"var(--ok)",expectedPct:u,isDeficit:!1};if(c>0){const f=100-e,h=l>0?e/l:0,p=h>0?f/h:1/0,m={label:`${Math.round(c)}% ahead`,color:"var(--warn)",expectedPct:u,isDeficit:!0};if(p<o&&p<86400){const y=Math.floor(p/3600),w=Math.floor(p%3600/60);m.runsOutIn=y>0?`${y}h ${w}m`:`${w}m`}return m}return{label:`${Math.round(-c)}% reserve`,color:"var(--ok)",expectedPct:u,isDeficit:!1}}function $i({pct:e,label:n,reset:i,resetAt:s,windowSec:o,limitReached:l,nowSec:u}){const c=Math.min(100,Math.max(0,e)),h=l||c>=90?"var(--err)":c>=70?"var(--warn)":"var(--accent)",p=c===0?"< 1%":`${c}%`,m=c===0?2:c,y=s?v3(s,u):null,w=s&&o?y3(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:p})]}),g.jsxs("div",{className:"qb-track",children:[g.jsx("div",{className:"qb-fill",style:{width:`${m}%`,background:h,opacity:c===0?.4:1}}),w&&g.jsx("div",{className:"qb-pace-marker",style:{left:`${w.expectedPct}%`,background:w.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(w.expectedPct)}% by now`})]}),g.jsxs("div",{className:"qb-reset-row",children:[y?g.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):i?g.jsxs("span",{className:"qb-reset",children:["resets ",i]}):null,w&&g.jsx("span",{className:"qb-pace",style:{color:w.color},children:w.runsOutIn?`runs out in ${w.runsOutIn}`:w.label})]})]})}const w3=6e4;function x3(){const[e,n]=M.useState(null),[i,s]=M.useState(!1),o=M.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 M.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),w3),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{quota:e,loading:i,refresh:()=>l(!0)}}function _3(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 hN=6e4;function S3(){const[e,n]=M.useState(null),[i,s]=M.useState(!1),o=M.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 M.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),hN),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{data:e,loading:i,refresh:()=>l(!0)}}function b3(){const[e,n]=M.useState(null),i=M.useRef(null),s=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return M.useEffect(()=>(s(),i.current=window.setInterval(s,hN),()=>{i.current!=null&&window.clearInterval(i.current)}),[]),{data:e}}function k3({state:e,now:n,onClose:i}){var P,z;const{quota:s,loading:o,refresh:l}=x3(),{data:u,loading:c,refresh:f}=S3(),{data:h}=b3(),[p,m]=M.useState(()=>Math.floor(Date.now()/1e3));M.useEffect(()=>{const T=window.setInterval(()=>m(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(T)},[]);const{byModel:y,totalCost:w,totalTokens:j,burnRate:_}=M.useMemo(()=>{const T=new Map,q={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let B=0,Z=0,Q=0,A=0;for(const L of e.agents.values()){const G=L.model??"__unknown__",k=fn(L.usage,L.model),$=T.get(G);$?($.inputTokens+=L.usage.inputTokens,$.outputTokens+=L.usage.outputTokens,$.cacheReadTokens+=L.usage.cacheReadTokens,$.cacheCreateTokens+=L.usage.cacheCreateTokens,$.cost.total+=k.total,$.cost.input+=k.input,$.cost.output+=k.output,$.cost.cacheRead+=k.cacheRead,$.cost.cacheWrite+=k.cacheWrite,$.agentCount++):T.set(G,{model:G,inputTokens:L.usage.inputTokens,outputTokens:L.usage.outputTokens,cacheReadTokens:L.usage.cacheReadTokens,cacheCreateTokens:L.usage.cacheCreateTokens,cost:{...k},agentCount:1}),q.total+=k.total,q.input+=k.input,q.output+=k.output,q.cacheRead+=k.cacheRead,q.cacheWrite+=k.cacheWrite,B+=L.usage.inputTokens,Z+=L.usage.outputTokens,Q+=L.usage.cacheReadTokens,A+=L.usage.cacheCreateTokens}const H=Array.from(T.values()).sort((L,G)=>G.cost.total-L.cost.total);let U=0,ne=0;for(const L of e.agents.values()){if(L.state!=="active")continue;const G=fn(L.usage,L.model);U+=G.total,ne=Math.max(ne,((L.endedAt??n)-L.startedAt)/1e3)}const Y=ne>0?$l(U,ne):null;return{byModel:H,totalCost:q,totalTokens:{in:B,out:Z,cacheR:Q,cacheC:A},burnRate:Y}},[e,e.lastSeq,n]),S=M.useMemo(()=>{const T=[];for(const q of e.agents.values()){if(q.kind!=="root")continue;let B=fn(q.usage,q.model).total,Z=q.usage.inputTokens,Q=q.usage.outputTokens;for(const A of e.agents.values())A.sessionId!==q.sessionId||A.kind==="root"||(B+=fn(A.usage,A.model).total,Z+=A.usage.inputTokens,Q+=A.usage.outputTokens);T.push({sessionId:q.sessionId,label:q.label||q.cwdBasename||"session",state:q.state,cost:B,inputTokens:Z,outputTokens:Q})}return T.sort((q,B)=>B.cost-q.cost).slice(0,12)},[e,e.lastSeq]),b=w.total>0,E=j.in+j.out,N=o||c,C=rx(s==null?void 0:s.fetchedAt,p),I=rx(u==null?void 0:u.fetchedAt,p),O=()=>{l(),f()};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:i,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h4",{className:"up-section-title",children:["Claude quota",C&&!o&&g.jsx("span",{className:"up-section-age",title:m3(s==null?void 0:s.source),children:C})]}),s!=null&&s.ok?g.jsxs("div",{className:"up-quota-bars",children:[s.session5hPct!=null&&g.jsx($i,{label:"5-hour window",pct:s.session5hPct,reset:s.session5hReset,resetAt:s.session5hResetAt,windowSec:s.session5hWindowSec,nowSec:p}),s.week7dPct!=null&&g.jsx($i,{label:"7-day window",pct:s.week7dPct,reset:s.week7dReset,resetAt:s.week7dResetAt,windowSec:s.week7dWindowSec,nowSec:p}),s.weekSonnetPct!=null&&g.jsx($i,{label:"Sonnet (7d)",pct:s.weekSonnetPct,nowSec:p}),s.weekOpusPct!=null&&g.jsx($i,{label:"Opus (7d)",pct:s.weekOpusPct,nowSec:p})]}):(s==null?void 0:s.ok)===!1?g.jsxs("div",{className:"up-quota-na",children:[g.jsx("span",{children:"Quota unavailable."}),g.jsxs("span",{className:"up-quota-hint",children:["Run ",g.jsx("code",{children:"/usage"})," in a claude session, then click ↻"]})]}):g.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h4",{className:"up-section-title",children:["Codex quota",(u==null?void 0:u.ok)&&u.planLabel&&g.jsx("span",{className:"up-plan-badge",children:u.planLabel}),I&&!c&&g.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:I})]}),u!=null&&u.ok?g.jsxs("div",{className:"up-quota-bars",children:[(P=u.windows)==null?void 0:P.map(T=>g.jsx($i,{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:p},T.id)),(z=u.extraWindows)==null?void 0:z.map(T=>g.jsx($i,{label:T.label,pct:T.pct,reset:T.reset??void 0,resetAt:T.resetAt??void 0,windowSec:T.windowSec??void 0,nowSec:p},T.id)),u.creditLimit&&g.jsx($i,{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:p}),(h==null?void 0:h.ok)&&h.window7d&&h.window7d.sessionCount>0&&g.jsxs("div",{className:"up-quota-sub",children:[Cr(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:_3(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:Fe(w.total)}),g.jsx("span",{className:"up-total-label",children:"total spend"})]}),g.jsx(g3,{cost:w}),E>0&&g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),Cr(j.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),Cr(j.out)]}),j.cacheR>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache r"}),Cr(j.cacheR)]}),j.cacheC>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache c"}),Cr(j.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:na(T.model)}),g.jsx("td",{className:"up-num",children:Cr(T.inputTokens+T.outputTokens)}),g.jsx("td",{className:"up-num up-cost-val",children:Fe(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:Cr(T.inputTokens+T.outputTokens)}),g.jsx("span",{className:"up-session-cost",children:Fe(T.cost)})]},T.sessionId))})]})]}):E>0?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),Cr(j.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),Cr(j.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 E3=1500;async function wl(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const N3={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"},id=(e,n)=>(e==null?void 0:e.detail)||(e!=null&&e.reason?N3[e.reason]??e.reason:null)||n;function C3({onClose:e,onChanged:n}){const[i,s]=M.useState("login"),[o,l]=M.useState(null),[u,c]=M.useState(""),[f,h]=M.useState(""),[p,m]=M.useState(!1),[y,w]=M.useState(null),[j,_]=M.useState(null),S=M.useRef(!1),b=M.useRef(null),E=M.useCallback(()=>{S.current&&wl({action:"login-cancel"}).catch(()=>{}),e()},[e]);M.useEffect(()=>{const P=z=>{z.key==="Escape"&&E()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[E]);const N=M.useCallback(async()=>{m(!0),w(null),S.current=!0;const P=await wl({action:"login"}).catch(()=>null);if(m(!1),!(P!=null&&P.ok)){w(id(P,"could not start the sign-in"));return}l(P)},[]);M.useEffect(()=>{i!=="login"||S.current||N()},[i,N]),M.useEffect(()=>{if(!o||o.state==="done"||o.state==="failed")return;const P=window.setInterval(async()=>{try{const z=await fetch("/api/claude-accounts/login");z.ok&&l(await z.json())}catch{}},E3);return()=>window.clearInterval(P)},[o]),M.useEffect(()=>{var P;(o==null?void 0:o.state)==="awaiting_code"&&((P=b.current)==null||P.focus()),(o==null?void 0:o.state)==="done"&&n()},[o==null?void 0:o.state,n]);const C=M.useCallback(async()=>{var z;m(!0),w(null);const P=await wl({action:"login-code",code:u}).catch(()=>null);if(m(!1),!(P!=null&&P.ok)){w(id(P,"the code was not accepted")),P!=null&&P.state&&l(P),(z=b.current)==null||z.select();return}c(""),l(P)},[u,o]),I=M.useCallback(async()=>{m(!0),w(null);const P=await wl({action:"import",blob:f}).catch(()=>null);if(m(!1),!(P!=null&&P.ok)){w(id(P,"the import failed"));return}h(""),_({added:P.added===!0,num:P.num??null}),n()},[f,n]),O=(o==null?void 0:o.state)==="done"?o.account:null;return g.jsx("div",{className:"modal-backdrop",onClick:E,role:"presentation",children:g.jsxs("div",{className:"modal aa-modal",onClick:P=>P.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[g.jsxs("header",{className:"modal-head",children:[g.jsx("div",{className:"modal-title",children:g.jsxs("span",{className:"aa-tabs",role:"tablist",children:[g.jsx("button",{type:"button",role:"tab","aria-selected":i==="login",className:`aa-tab${i==="login"?" on":""}`,onClick:()=>s("login"),children:"Sign in"}),g.jsx("button",{type:"button",role:"tab","aria-selected":i==="paste",className:`aa-tab${i==="paste"?" on":""}`,onClick:()=>s("paste"),children:"Paste a share"})]})}),g.jsx("div",{className:"modal-actions",children:g.jsx("button",{type:"button",className:"btn icon-btn",onClick:E,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),g.jsx("section",{className:"modal-body aa-body",children:i==="login"?O?g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:O.added?`Added account ${O.num}`:"Credentials refreshed"}),g.jsxs("p",{className:"aa-note",children:[O.email,O.added?" is now 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:P=>c(P.target.value),onKeyDown:P=>{P.key==="Enter"&&u.trim()&&!p&&C()},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:p||!u.trim()||o.state==="registering",onClick:C,children:o.state==="registering"?"registering…":"Continue"})]}),(y||o.error)&&g.jsx("p",{className:"aa-err",children:y??o.error}),g.jsx("p",{className:"aa-note",children:"The code goes straight to the claude CLI on this machine. It is never stored or sent anywhere else."})]})]}):(o==null?void 0:o.state)==="failed"||y?g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"Sign-in failed"}),g.jsx("p",{className:"aa-err",children:y??(o==null?void 0:o.error)}),g.jsx("button",{type:"button",className:"btn",onClick:()=>{S.current=!1,l(null),w(null),N()},children:"Try again"})]}):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",children:[g.jsx("h4",{children:"Paste an account shared from another deck"}),g.jsxs("div",{className:"aa-field",children:[g.jsx("input",{type:"text",value:f,onChange:P=>h(P.target.value),onKeyDown:P=>{P.key==="Enter"&&f.trim()&&!p&&I()},placeholder:"ccdeck1:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),g.jsx("button",{type:"button",className:"btn primary",disabled:p||!f.trim(),onClick:I,children:p?"importing…":"Import"})]}),j&&g.jsx("p",{className:"aa-note",children:j.added?`Added account ${j.num}.`:"That account was already here, so nothing changed."}),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 j3=15e3,R3=[70,80,85,90,95];function T3(e,n){const i=e-n;if(i<=0)return null;const s=Math.floor(i/86400),o=Math.floor(i%86400/3600),l=Math.floor(i%3600/60);return s>0?`${s}d ${o}h`:o>0?`${o}h ${l}m`:`${l}m`}function ix(e,n){const i=n-Math.floor(e/1e3);return i<60?"just now":i<3600?`${Math.floor(i/60)}m ago`:i<86400?`${Math.floor(i/3600)}h ago`:`${Math.floor(i/86400)}d ago`}function A3(e,n){if(!e)return"";const i=Math.floor(e/1e3)-n;return i<=0?" · due":i<60?` · next in ${i}s`:` · next in ${Math.round(i/60)}m`}function I3(e){return e==="http-429"?"rate limited":e==="http-401"?"re-login needed":e==="timeout"?"timed out":e==="network"?"unreachable":e}function M3({lane:e,nowSec:n}){const i=Math.min(100,Math.max(0,e.pct)),s=i>=90?"var(--err)":i>=70?"var(--warn)":"var(--accent)",o=e.resetAt?T3(e.resetAt,n):null;return g.jsxs("div",{className:"ap-lane",children:[g.jsx("span",{className:"ap-lane-label",children:e.label}),g.jsx("div",{className:"ap-lane-track",children:g.jsx("div",{className:"ap-lane-fill",style:{width:`${i===0?1.5:i}%`,background:s,opacity:i===0?.4:1}})}),g.jsxs("span",{className:"ap-lane-pct",style:{color:s},children:[i,"%"]}),g.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}function P3(e){const n=e.map(s=>s.num),i=n.length?Math.max(...n):0;return[...new Set([...n,i+1])].sort((s,o)=>s-o)}function O3(e,n){const i=Math.round(e/1e3)-n;return i<=0?"expired":i<60?`expires in ${i}s`:`expires in ${Math.round(i/60)}m`}function q3({onClose:e}){var Y,L,G;const[n,i]=M.useState(null),[s,o]=M.useState(null),[l,u]=M.useState(null),[c,f]=M.useState(null),[h,p]=M.useState(null),[m,y]=M.useState(()=>Math.floor(Date.now()/1e3)),w=M.useRef(null),[j,_]=M.useState(null),[S,b]=M.useState(!1),[E,N]=M.useState(""),[C,I]=M.useState(null),[O,P]=M.useState(null),[z,T]=M.useState(!1),q=M.useCallback(async(k=!1)=>{try{const[$,oe]=await Promise.all([fetch(`/api/claude-accounts${k?"?refresh=1":""}`),fetch("/api/cswap-auto")]);$.ok&&i(await $.json()),oe.ok&&o(await oe.json())}catch{}},[]),B=M.useCallback(async(k,$)=>{u($),p(null);try{const D=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)})).json().catch(()=>null);return D!=null&&D.ok||p((D==null?void 0:D.detail)||(D==null?void 0:D.reason)||"command failed"),D}catch{return p("server unreachable"),null}finally{u(null)}},[]),Z=M.useCallback(async(k,$)=>{u($),p(null);try{const D=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)})).json().catch(()=>null);return D!=null&&D.ok||p((D==null?void 0:D.detail)||(D==null?void 0:D.reason)||"command failed"),D}catch{return p("server unreachable"),null}finally{u(null)}},[]);M.useEffect(()=>(q(!0),w.current=window.setInterval(()=>q(!1),j3),()=>{w.current!=null&&window.clearInterval(w.current)}),[q]),M.useEffect(()=>{const k=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(k)},[]);const Q=((Y=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:Y.value)??"90",A=(L=n==null?void 0:n.accounts)==null?void 0:L.find(k=>k.active),H=A!=null&&A.lanes.length?Math.max(...A.lanes.map(k=>k.pct)):null,U=H!=null&&H>=Number(Q)-15,ne=async k=>{f(k),p(null);try{const oe=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:k})})).json().catch(()=>null);oe!=null&&oe.ok||p((oe==null?void 0:oe.output)||(oe==null?void 0:oe.reason)||"switch failed"),await q(!0)}catch{p("server unreachable")}finally{f(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:()=>q(!0),title:"Reload from claude-swap",children:"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),n==null?g.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?g.jsxs(g.Fragment,{children:[(G=n.accounts)==null?void 0:G.map(k=>g.jsxs("div",{className:`ap-account${k.active?" active":""}${k.disabled?" disabled":""}`,children:[g.jsxs("div",{className:"ap-account-head",children:[g.jsx("span",{className:"ap-num",children:k.num}),k.alias&&g.jsx("span",{className:"ap-alias",children:k.alias}),g.jsx("span",{className:"ap-email",title:k.org??void 0,children:k.email}),g.jsx("button",{type:"button",className:`ap-more${j===k.num?" on":""}`,"aria-label":`Manage account ${k.num}`,"aria-expanded":j===k.num,title:"Share, rename, move, remove",onClick:()=>{_(j===k.num?null:k.num),N(k.alias??""),I(null),P(null),T(!1)},children:"⋯"}),k.active?g.jsx("span",{className:"ap-badge-active",children:"● active"}):g.jsx("button",{type:"button",className:"btn ap-switch",disabled:c!=null||k.disabled,onClick:()=>ne(k.num),title:k.disabled?"Held out of rotation":`Switch to ${k.alias??k.email}`,children:c===k.num?"…":"switch"})]}),k.lanes.length>0?k.lanes.map($=>g.jsx(M3,{lane:$,nowSec:m},$.id)):g.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),g.jsxs("div",{className:"ap-meta",children:[k.error&&g.jsx("span",{className:"ap-err",children:I3(k.error)}),((s==null?void 0:s.enabled)||(s==null?void 0:s.external))&&!k.active&&g.jsx("button",{type:"button",className:"ap-rotate",disabled:l!=null,onClick:()=>B({action:"account",account:k.num,enabled:k.disabled},`rot-${k.num}`).then(()=>q(!0)),title:k.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:k.disabled?"held out":"in rotation"}),k.fetchedAt?g.jsxs("span",{className:`ap-age${k.stale?" ap-stale":""}`,title:"When claude-swap last read this account's usage, and when it plans to read it again. It sets that interval itself — 3 minutes at the fastest, wider while an account is recovering from a rate limit — and every surface, including `cswap watch`, follows the same plan.",children:["collected ",ix(k.fetchedAt,m),A3(k.nextAt,m)]}):g.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),j===k.num&&g.jsxs("div",{className:"ap-manage",children:[g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("span",{className:"ap-manage-label",children:"name"}),g.jsx("input",{className:"ap-manage-input",type:"text",value:E,onChange:$=>N($.target.value),onKeyDown:$=>{$.key==="Enter"&&Z({action:"alias",account:k.num,alias:E},`alias-${k.num}`).then(()=>q(!0))},placeholder:"no alias",spellCheck:!1,"aria-label":`Alias for account ${k.num}`}),g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null||E.trim()===(k.alias??""),onClick:()=>Z({action:"alias",account:k.num,alias:E},`alias-${k.num}`).then(()=>q(!0)),title:"A short name to show instead of the email",children:"save"})]}),g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("span",{className:"ap-manage-label",children:"slot"}),g.jsx("span",{className:"ap-field",children:g.jsx("select",{"aria-label":`Slot for account ${k.num}`,value:String(k.num),disabled:l!=null,onChange:$=>Z({action:"move",account:k.num,slot:Number($.target.value)},`move-${k.num}`).then(()=>q(!0)),children:P3(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 Z({action:"share",account:k.num},`share-${k.num}`);$!=null&&$.ok&&P({num:k.num,blob:$.blob,expiresAt:$.expiresAt})},children:"share…"}),g.jsx("button",{type:"button",className:`ap-manage-btn danger${C===k.num?" armed":""}`,disabled:l!=null,title:C===k.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(C!==k.num){I(k.num),window.setTimeout(()=>I($=>$===k.num?null:$),4e3);return}I(null),Z({action:"remove",account:k.num},`rm-${k.num}`).then(()=>{_(null),q(!0)})},children:C===k.num?"confirm remove":"remove"})]}),(O==null?void 0:O.num)===k.num&&g.jsxs("div",{className:"ap-share",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",onClick:async()=>{try{await navigator.clipboard.writeText(O.blob),T(!0)}catch{}},children:z?"copied":"copy"}),g.jsxs("span",{className:"ap-manage-hint",children:["carries a live login · ",O3(O.expiresAt,m)]})]})]})]})]},k.num)),(s==null?void 0:s.ok)&&g.jsxs("div",{className:"ap-auto",children:[g.jsxs("div",{className:"ap-auto-head",children:[g.jsx("span",{className:"ap-auto-title",children:"Auto-switch"}),g.jsxs("span",{className:"ap-auto-ctl",children:[H!=null&&g.jsxs("span",{className:`ap-auto-now${U?" near":""}`,children:[Math.round(H),"%"]}),g.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:g.jsx("select",{"aria-label":"Switch threshold",value:Q,disabled:l!=null,onChange:k=>B({action:"setting",key:"autoswitch.threshold",value:k.target.value},"threshold").then(()=>q(!0)),children:R3.map(k=>g.jsxs("option",{value:k,children:[k,"%"]},k))})}),g.jsxs("button",{type:"button",className:`ap-auto-state toggle${s.enabled?" live":""}`,role:"switch","aria-checked":s.enabled,disabled:l!=null,onClick:()=>B({action:"enable",enabled:!s.enabled},"enable").then(()=>q(!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 ",ix(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(C3,{onClose:()=>b(!1),onChanged:()=>q(!0)})]})}const L3=3e4;function $3({bundle:e,running:n,lastTried:i}){return!n||e===n?!1:i!==n}function D3(e){const n=e.thresholdMs??L3;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 Di(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 sx(e){return e.replace(/^anthropic\./,"").replace(/^claude-/,"").replace(/-\d{8}$/,"")}function xl(e){const n=e.toLowerCase();return n.includes("opus")?"#c4b5fd":n.includes("sonnet")?"#7dd3fc":n.includes("haiku")?"#86efac":n.includes("gpt-5")||n.includes("gpt5")?"#fcd34d":n.includes("gpt")?"#fca5a5":n.includes("gemini")?"#a5b4fc":n.includes("codex")?"#fdba74":"#94a3b8"}function F3(e){return new Date(Date.now()-(e-1)*864e5).toISOString().slice(0,10).replace(/-/g,"")}const z3=[7,14,30,90];function B3(e){const[n,i]=M.useState(null),[s,o]=M.useState(!1),l=(u=!1)=>{o(!0);const f=`/api/ccusage?since=${F3(e)}${u?"&refresh=1":""}`;fetch(f).then(h=>h.json()).then(i).catch(()=>i({ok:!1,error:"request failed"})).finally(()=>o(!1))};return M.useEffect(()=>{l(!1)},[e]),{data:n,loading:s,reload:()=>l(!0)}}function U3({onClose:e}){var b,E;const[n,i]=M.useState(30),[s,o]=M.useState(null),{data:l,loading:u,reload:c}=B3(n);M.useEffect(()=>{const N=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e]);const f=l!=null&&l.ok?l.days??[]:[],h=M.useMemo(()=>f.reduce((N,C)=>Math.max(N,C.totalCost),0),[f]),{totalCost:p,totalTok:m,inOut:y,cacheRead:w,modelCosts:j}=M.useMemo(()=>{let N=0,C=0,I=0,O=0;const P=new Map;for(const z of f){N+=z.totalCost,C+=z.totalTokens,I+=z.inputTokens+z.outputTokens,O+=z.cacheReadTokens;for(const T of z.modelBreakdowns)P.set(T.modelName,(P.get(T.modelName)??0)+T.cost)}return{totalCost:N,totalTok:C,inOut:I,cacheRead:O,modelCosts:P}},[f]),_=M.useMemo(()=>Array.from(j.entries()).sort((N,C)=>C[1]-N[1]),[j]),S=s?f.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:z3.map(N=>g.jsxs("button",{role:"tab","aria-selected":n===N,className:`uh-range-btn${n===N?" on":""}`,onClick:()=>{i(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&&f.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]}):f.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(_l,{label:"total cost",val:Fe(p),accent:!0}),g.jsx(_l,{label:"tokens",val:Di(m)}),g.jsx(_l,{label:"input+output",val:Di(y)}),g.jsx(_l,{label:"cache reads",val:Di(w)})]}),g.jsx("div",{className:"uh-chart",role:"img","aria-label":"Daily cost by model",children:f.map(N=>{const C=h>0?N.totalCost/h*100:0,I=N.period===s;return g.jsxs("button",{className:`uh-bar-col${I?" sel":""}`,onClick:()=>o(I?null:N.period),title:`${N.period} · ${Fe(N.totalCost)}`,style:{flexBasis:`${100/f.length}%`},children:[g.jsx("div",{className:"uh-bar",style:{height:`${Math.max(C,N.totalCost>0?2:0)}%`},children:N.modelBreakdowns.slice().sort((O,P)=>P.cost-O.cost).map(O=>{const P=N.totalCost>0?O.cost/N.totalCost*100:0;return g.jsx("div",{className:"uh-bar-seg",style:{height:`${P}%`,background:xl(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,C])=>g.jsxs("span",{className:"uh-legend-item",children:[g.jsx("span",{className:"uh-legend-dot",style:{background:xl(N)}}),sx(N)," ",g.jsx("span",{className:"uh-legend-cost",children:Fe(C)})]},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:Fe(S.totalCost)}),(E=(b=S.metadata)==null?void 0:b.agents)!=null&&E.length?g.jsx("span",{className:"uh-detail-agents",children:S.metadata.agents.join(" · ")}):null]}),g.jsxs("div",{className:"uh-detail-mini",children:[g.jsx(Sl,{label:"input",val:Di(S.inputTokens)}),g.jsx(Sl,{label:"output",val:Di(S.outputTokens)}),g.jsx(Sl,{label:"cache write",val:Di(S.cacheCreationTokens)}),g.jsx(Sl,{label:"cache read",val:Di(S.cacheReadTokens)})]}),g.jsx("div",{className:"uh-detail-models",children:S.modelBreakdowns.slice().sort((N,C)=>C.cost-N.cost).map(N=>{const C=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:xl(N.modelName)}}),sx(N.modelName)]}),g.jsx("span",{className:"uh-model-bar",children:g.jsx("span",{className:"uh-model-bar-fill",style:{width:`${C}%`,background:xl(N.modelName)}})}),g.jsx("span",{className:"uh-model-cost",children:Fe(N.cost)})]},N.modelName)})})]})]})]})})}function _l({label:e,val:n,accent:i}){return g.jsxs("div",{className:"uh-stat",children:[g.jsx("span",{className:`uh-stat-val${i?" accent":""}`,children:n}),g.jsx("span",{className:"uh-stat-label",children:e})]})}function Sl({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 hv(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 sd,ox;function H3(){if(ox)return sd;ox=1;function e(){this.__data__=[],this.size=0}return sd=e,sd}var od,ax;function Hs(){if(ax)return od;ax=1;function e(n,i){return n===i||n!==n&&i!==i}return od=e,od}var ad,lx;function Gl(){if(lx)return ad;lx=1;var e=Hs();function n(i,s){for(var o=i.length;o--;)if(e(i[o][0],s))return o;return-1}return ad=n,ad}var ld,ux;function V3(){if(ux)return ld;ux=1;var e=Gl(),n=Array.prototype,i=n.splice;function s(o){var l=this.__data__,u=e(l,o);if(u<0)return!1;var c=l.length-1;return u==c?l.pop():i.call(l,u,1),--this.size,!0}return ld=s,ld}var ud,cx;function W3(){if(cx)return ud;cx=1;var e=Gl();function n(i){var s=this.__data__,o=e(s,i);return o<0?void 0:s[o][1]}return ud=n,ud}var cd,dx;function G3(){if(dx)return cd;dx=1;var e=Gl();function n(i){return e(this.__data__,i)>-1}return cd=n,cd}var dd,fx;function Y3(){if(fx)return dd;fx=1;var e=Gl();function n(i,s){var o=this.__data__,l=e(o,i);return l<0?(++this.size,o.push([i,s])):o[l][1]=s,this}return dd=n,dd}var fd,hx;function Yl(){if(hx)return fd;hx=1;var e=H3(),n=V3(),i=W3(),s=G3(),o=Y3();function l(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=i,l.prototype.has=s,l.prototype.set=o,fd=l,fd}var hd,px;function K3(){if(px)return hd;px=1;var e=Yl();function n(){this.__data__=new e,this.size=0}return hd=n,hd}var pd,mx;function X3(){if(mx)return pd;mx=1;function e(n){var i=this.__data__,s=i.delete(n);return this.size=i.size,s}return pd=e,pd}var md,gx;function Q3(){if(gx)return md;gx=1;function e(n){return this.__data__.get(n)}return md=e,md}var gd,vx;function Z3(){if(vx)return gd;vx=1;function e(n){return this.__data__.has(n)}return gd=e,gd}var vd,yx;function pN(){if(yx)return vd;yx=1;var e=typeof al=="object"&&al&&al.Object===Object&&al;return vd=e,vd}var yd,wx;function er(){if(wx)return yd;wx=1;var e=pN(),n=typeof self=="object"&&self&&self.Object===Object&&self,i=e||n||Function("return this")();return yd=i,yd}var wd,xx;function Vs(){if(xx)return wd;xx=1;var e=er(),n=e.Symbol;return wd=n,wd}var xd,_x;function J3(){if(_x)return xd;_x=1;var e=Vs(),n=Object.prototype,i=n.hasOwnProperty,s=n.toString,o=e?e.toStringTag:void 0;function l(u){var c=i.call(u,o),f=u[o];try{u[o]=void 0;var h=!0}catch{}var p=s.call(u);return h&&(c?u[o]=f:delete u[o]),p}return xd=l,xd}var _d,Sx;function eO(){if(Sx)return _d;Sx=1;var e=Object.prototype,n=e.toString;function i(s){return n.call(s)}return _d=i,_d}var Sd,bx;function Ki(){if(bx)return Sd;bx=1;var e=Vs(),n=J3(),i=eO(),s="[object Null]",o="[object Undefined]",l=e?e.toStringTag:void 0;function u(c){return c==null?c===void 0?o:s:l&&l in Object(c)?n(c):i(c)}return Sd=u,Sd}var bd,kx;function On(){if(kx)return bd;kx=1;function e(n){var i=typeof n;return n!=null&&(i=="object"||i=="function")}return bd=e,bd}var kd,Ex;function ra(){if(Ex)return kd;Ex=1;var e=Ki(),n=On(),i="[object AsyncFunction]",s="[object Function]",o="[object GeneratorFunction]",l="[object Proxy]";function u(c){if(!n(c))return!1;var f=e(c);return f==s||f==o||f==i||f==l}return kd=u,kd}var Ed,Nx;function tO(){if(Nx)return Ed;Nx=1;var e=er(),n=e["__core-js_shared__"];return Ed=n,Ed}var Nd,Cx;function nO(){if(Cx)return Nd;Cx=1;var e=tO(),n=(function(){var s=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""})();function i(s){return!!n&&n in s}return Nd=i,Nd}var Cd,jx;function mN(){if(jx)return Cd;jx=1;var e=Function.prototype,n=e.toString;function i(s){if(s!=null){try{return n.call(s)}catch{}try{return s+""}catch{}}return""}return Cd=i,Cd}var jd,Rx;function rO(){if(Rx)return jd;Rx=1;var e=ra(),n=nO(),i=On(),s=mN(),o=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,f=u.toString,h=c.hasOwnProperty,p=RegExp("^"+f.call(h).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!i(y)||n(y))return!1;var w=e(y)?p:l;return w.test(s(y))}return jd=m,jd}var Rd,Tx;function iO(){if(Tx)return Rd;Tx=1;function e(n,i){return n==null?void 0:n[i]}return Rd=e,Rd}var Td,Ax;function Xi(){if(Ax)return Td;Ax=1;var e=rO(),n=iO();function i(s,o){var l=n(s,o);return e(l)?l:void 0}return Td=i,Td}var Ad,Ix;function pv(){if(Ix)return Ad;Ix=1;var e=Xi(),n=er(),i=e(n,"Map");return Ad=i,Ad}var Id,Mx;function Kl(){if(Mx)return Id;Mx=1;var e=Xi(),n=e(Object,"create");return Id=n,Id}var Md,Px;function sO(){if(Px)return Md;Px=1;var e=Kl();function n(){this.__data__=e?e(null):{},this.size=0}return Md=n,Md}var Pd,Ox;function oO(){if(Ox)return Pd;Ox=1;function e(n){var i=this.has(n)&&delete this.__data__[n];return this.size-=i?1:0,i}return Pd=e,Pd}var Od,qx;function aO(){if(qx)return Od;qx=1;var e=Kl(),n="__lodash_hash_undefined__",i=Object.prototype,s=i.hasOwnProperty;function o(l){var u=this.__data__;if(e){var c=u[l];return c===n?void 0:c}return s.call(u,l)?u[l]:void 0}return Od=o,Od}var qd,Lx;function lO(){if(Lx)return qd;Lx=1;var e=Kl(),n=Object.prototype,i=n.hasOwnProperty;function s(o){var l=this.__data__;return e?l[o]!==void 0:i.call(l,o)}return qd=s,qd}var Ld,$x;function uO(){if($x)return Ld;$x=1;var e=Kl(),n="__lodash_hash_undefined__";function i(s,o){var l=this.__data__;return this.size+=this.has(s)?0:1,l[s]=e&&o===void 0?n:o,this}return Ld=i,Ld}var $d,Dx;function cO(){if(Dx)return $d;Dx=1;var e=sO(),n=oO(),i=aO(),s=lO(),o=uO();function l(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=i,l.prototype.has=s,l.prototype.set=o,$d=l,$d}var Dd,Fx;function dO(){if(Fx)return Dd;Fx=1;var e=cO(),n=Yl(),i=pv();function s(){this.size=0,this.__data__={hash:new e,map:new(i||n),string:new e}}return Dd=s,Dd}var Fd,zx;function fO(){if(zx)return Fd;zx=1;function e(n){var i=typeof n;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?n!=="__proto__":n===null}return Fd=e,Fd}var zd,Bx;function Xl(){if(Bx)return zd;Bx=1;var e=fO();function n(i,s){var o=i.__data__;return e(s)?o[typeof s=="string"?"string":"hash"]:o.map}return zd=n,zd}var Bd,Ux;function hO(){if(Ux)return Bd;Ux=1;var e=Xl();function n(i){var s=e(this,i).delete(i);return this.size-=s?1:0,s}return Bd=n,Bd}var Ud,Hx;function pO(){if(Hx)return Ud;Hx=1;var e=Xl();function n(i){return e(this,i).get(i)}return Ud=n,Ud}var Hd,Vx;function mO(){if(Vx)return Hd;Vx=1;var e=Xl();function n(i){return e(this,i).has(i)}return Hd=n,Hd}var Vd,Wx;function gO(){if(Wx)return Vd;Wx=1;var e=Xl();function n(i,s){var o=e(this,i),l=o.size;return o.set(i,s),this.size+=o.size==l?0:1,this}return Vd=n,Vd}var Wd,Gx;function mv(){if(Gx)return Wd;Gx=1;var e=dO(),n=hO(),i=pO(),s=mO(),o=gO();function l(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=i,l.prototype.has=s,l.prototype.set=o,Wd=l,Wd}var Gd,Yx;function vO(){if(Yx)return Gd;Yx=1;var e=Yl(),n=pv(),i=mv(),s=200;function o(l,u){var c=this.__data__;if(c instanceof e){var f=c.__data__;if(!n||f.length<s-1)return f.push([l,u]),this.size=++c.size,this;c=this.__data__=new i(f)}return c.set(l,u),this.size=c.size,this}return Gd=o,Gd}var Yd,Kx;function Ql(){if(Kx)return Yd;Kx=1;var e=Yl(),n=K3(),i=X3(),s=Q3(),o=Z3(),l=vO();function u(c){var f=this.__data__=new e(c);this.size=f.size}return u.prototype.clear=n,u.prototype.delete=i,u.prototype.get=s,u.prototype.has=o,u.prototype.set=l,Yd=u,Yd}var Kd,Xx;function gv(){if(Xx)return Kd;Xx=1;function e(n,i){for(var s=-1,o=n==null?0:n.length;++s<o&&i(n[s],s,n)!==!1;);return n}return Kd=e,Kd}var Xd,Qx;function gN(){if(Qx)return Xd;Qx=1;var e=Xi(),n=(function(){try{var i=e(Object,"defineProperty");return i({},"",{}),i}catch{}})();return Xd=n,Xd}var Qd,Zx;function Zl(){if(Zx)return Qd;Zx=1;var e=gN();function n(i,s,o){s=="__proto__"&&e?e(i,s,{configurable:!0,enumerable:!0,value:o,writable:!0}):i[s]=o}return Qd=n,Qd}var Zd,Jx;function Jl(){if(Jx)return Zd;Jx=1;var e=Zl(),n=Hs(),i=Object.prototype,s=i.hasOwnProperty;function o(l,u,c){var f=l[u];(!(s.call(l,u)&&n(f,c))||c===void 0&&!(u in l))&&e(l,u,c)}return Zd=o,Zd}var Jd,e_;function ia(){if(e_)return Jd;e_=1;var e=Jl(),n=Zl();function i(s,o,l,u){var c=!l;l||(l={});for(var f=-1,h=o.length;++f<h;){var p=o[f],m=u?u(l[p],s[p],p,l,s):void 0;m===void 0&&(m=s[p]),c?n(l,p,m):e(l,p,m)}return l}return Jd=i,Jd}var ef,t_;function yO(){if(t_)return ef;t_=1;function e(n,i){for(var s=-1,o=Array(n);++s<n;)o[s]=i(s);return o}return ef=e,ef}var tf,n_;function dr(){if(n_)return tf;n_=1;function e(n){return n!=null&&typeof n=="object"}return tf=e,tf}var nf,r_;function wO(){if(r_)return nf;r_=1;var e=Ki(),n=dr(),i="[object Arguments]";function s(o){return n(o)&&e(o)==i}return nf=s,nf}var rf,i_;function sa(){if(i_)return rf;i_=1;var e=wO(),n=dr(),i=Object.prototype,s=i.hasOwnProperty,o=i.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(u){return n(u)&&s.call(u,"callee")&&!o.call(u,"callee")};return rf=l,rf}var sf,s_;function St(){if(s_)return sf;s_=1;var e=Array.isArray;return sf=e,sf}var Do={exports:{}},of,o_;function xO(){if(o_)return of;o_=1;function e(){return!1}return of=e,of}Do.exports;var a_;function Ws(){return a_||(a_=1,(function(e,n){var i=er(),s=xO(),o=n&&!n.nodeType&&n,l=o&&!0&&e&&!e.nodeType&&e,u=l&&l.exports===o,c=u?i.Buffer:void 0,f=c?c.isBuffer:void 0,h=f||s;e.exports=h})(Do,Do.exports)),Do.exports}var af,l_;function eu(){if(l_)return af;l_=1;var e=9007199254740991,n=/^(?:0|[1-9]\d*)$/;function i(s,o){var l=typeof s;return o=o??e,!!o&&(l=="number"||l!="symbol"&&n.test(s))&&s>-1&&s%1==0&&s<o}return af=i,af}var lf,u_;function vv(){if(u_)return lf;u_=1;var e=9007199254740991;function n(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=e}return lf=n,lf}var uf,c_;function _O(){if(c_)return uf;c_=1;var e=Ki(),n=vv(),i=dr(),s="[object Arguments]",o="[object Array]",l="[object Boolean]",u="[object Date]",c="[object Error]",f="[object Function]",h="[object Map]",p="[object Number]",m="[object Object]",y="[object RegExp]",w="[object Set]",j="[object String]",_="[object WeakMap]",S="[object ArrayBuffer]",b="[object DataView]",E="[object Float32Array]",N="[object Float64Array]",C="[object Int8Array]",I="[object Int16Array]",O="[object Int32Array]",P="[object Uint8Array]",z="[object Uint8ClampedArray]",T="[object Uint16Array]",q="[object Uint32Array]",B={};B[E]=B[N]=B[C]=B[I]=B[O]=B[P]=B[z]=B[T]=B[q]=!0,B[s]=B[o]=B[S]=B[l]=B[b]=B[u]=B[c]=B[f]=B[h]=B[p]=B[m]=B[y]=B[w]=B[j]=B[_]=!1;function Z(Q){return i(Q)&&n(Q.length)&&!!B[e(Q)]}return uf=Z,uf}var cf,d_;function tu(){if(d_)return cf;d_=1;function e(n){return function(i){return n(i)}}return cf=e,cf}var Fo={exports:{}};Fo.exports;var f_;function yv(){return f_||(f_=1,(function(e,n){var i=pN(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,u=l&&i.process,c=(function(){try{var f=o&&o.require&&o.require("util").types;return f||u&&u.binding&&u.binding("util")}catch{}})();e.exports=c})(Fo,Fo.exports)),Fo.exports}var df,h_;function oa(){if(h_)return df;h_=1;var e=_O(),n=tu(),i=yv(),s=i&&i.isTypedArray,o=s?n(s):e;return df=o,df}var ff,p_;function vN(){if(p_)return ff;p_=1;var e=yO(),n=sa(),i=St(),s=Ws(),o=eu(),l=oa(),u=Object.prototype,c=u.hasOwnProperty;function f(h,p){var m=i(h),y=!m&&n(h),w=!m&&!y&&s(h),j=!m&&!y&&!w&&l(h),_=m||y||w||j,S=_?e(h.length,String):[],b=S.length;for(var E in h)(p||c.call(h,E))&&!(_&&(E=="length"||w&&(E=="offset"||E=="parent")||j&&(E=="buffer"||E=="byteLength"||E=="byteOffset")||o(E,b)))&&S.push(E);return S}return ff=f,ff}var hf,m_;function nu(){if(m_)return hf;m_=1;var e=Object.prototype;function n(i){var s=i&&i.constructor,o=typeof s=="function"&&s.prototype||e;return i===o}return hf=n,hf}var pf,g_;function yN(){if(g_)return pf;g_=1;function e(n,i){return function(s){return n(i(s))}}return pf=e,pf}var mf,v_;function SO(){if(v_)return mf;v_=1;var e=yN(),n=e(Object.keys,Object);return mf=n,mf}var gf,y_;function wv(){if(y_)return gf;y_=1;var e=nu(),n=SO(),i=Object.prototype,s=i.hasOwnProperty;function o(l){if(!e(l))return n(l);var u=[];for(var c in Object(l))s.call(l,c)&&c!="constructor"&&u.push(c);return u}return gf=o,gf}var vf,w_;function Ir(){if(w_)return vf;w_=1;var e=ra(),n=vv();function i(s){return s!=null&&n(s.length)&&!e(s)}return vf=i,vf}var yf,x_;function pi(){if(x_)return yf;x_=1;var e=vN(),n=wv(),i=Ir();function s(o){return i(o)?e(o):n(o)}return yf=s,yf}var wf,__;function bO(){if(__)return wf;__=1;var e=ia(),n=pi();function i(s,o){return s&&e(o,n(o),s)}return wf=i,wf}var xf,S_;function kO(){if(S_)return xf;S_=1;function e(n){var i=[];if(n!=null)for(var s in Object(n))i.push(s);return i}return xf=e,xf}var _f,b_;function EO(){if(b_)return _f;b_=1;var e=On(),n=nu(),i=kO(),s=Object.prototype,o=s.hasOwnProperty;function l(u){if(!e(u))return i(u);var c=n(u),f=[];for(var h in u)h=="constructor"&&(c||!o.call(u,h))||f.push(h);return f}return _f=l,_f}var Sf,k_;function Qi(){if(k_)return Sf;k_=1;var e=vN(),n=EO(),i=Ir();function s(o){return i(o)?e(o,!0):n(o)}return Sf=s,Sf}var bf,E_;function NO(){if(E_)return bf;E_=1;var e=ia(),n=Qi();function i(s,o){return s&&e(o,n(o),s)}return bf=i,bf}var zo={exports:{}};zo.exports;var N_;function wN(){return N_||(N_=1,(function(e,n){var i=er(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,u=l?i.Buffer:void 0,c=u?u.allocUnsafe:void 0;function f(h,p){if(p)return h.slice();var m=h.length,y=c?c(m):new h.constructor(m);return h.copy(y),y}e.exports=f})(zo,zo.exports)),zo.exports}var kf,C_;function xN(){if(C_)return kf;C_=1;function e(n,i){var s=-1,o=n.length;for(i||(i=Array(o));++s<o;)i[s]=n[s];return i}return kf=e,kf}var Ef,j_;function _N(){if(j_)return Ef;j_=1;function e(n,i){for(var s=-1,o=n==null?0:n.length,l=0,u=[];++s<o;){var c=n[s];i(c,s,n)&&(u[l++]=c)}return u}return Ef=e,Ef}var Nf,R_;function SN(){if(R_)return Nf;R_=1;function e(){return[]}return Nf=e,Nf}var Cf,T_;function xv(){if(T_)return Cf;T_=1;var e=_N(),n=SN(),i=Object.prototype,s=i.propertyIsEnumerable,o=Object.getOwnPropertySymbols,l=o?function(u){return u==null?[]:(u=Object(u),e(o(u),function(c){return s.call(u,c)}))}:n;return Cf=l,Cf}var jf,A_;function CO(){if(A_)return jf;A_=1;var e=ia(),n=xv();function i(s,o){return e(s,n(s),o)}return jf=i,jf}var Rf,I_;function _v(){if(I_)return Rf;I_=1;function e(n,i){for(var s=-1,o=i.length,l=n.length;++s<o;)n[l+s]=i[s];return n}return Rf=e,Rf}var Tf,M_;function ru(){if(M_)return Tf;M_=1;var e=yN(),n=e(Object.getPrototypeOf,Object);return Tf=n,Tf}var Af,P_;function bN(){if(P_)return Af;P_=1;var e=_v(),n=ru(),i=xv(),s=SN(),o=Object.getOwnPropertySymbols,l=o?function(u){for(var c=[];u;)e(c,i(u)),u=n(u);return c}:s;return Af=l,Af}var If,O_;function jO(){if(O_)return If;O_=1;var e=ia(),n=bN();function i(s,o){return e(s,n(s),o)}return If=i,If}var Mf,q_;function kN(){if(q_)return Mf;q_=1;var e=_v(),n=St();function i(s,o,l){var u=o(s);return n(s)?u:e(u,l(s))}return Mf=i,Mf}var Pf,L_;function EN(){if(L_)return Pf;L_=1;var e=kN(),n=xv(),i=pi();function s(o){return e(o,i,n)}return Pf=s,Pf}var Of,$_;function RO(){if($_)return Of;$_=1;var e=kN(),n=bN(),i=Qi();function s(o){return e(o,i,n)}return Of=s,Of}var qf,D_;function TO(){if(D_)return qf;D_=1;var e=Xi(),n=er(),i=e(n,"DataView");return qf=i,qf}var Lf,F_;function AO(){if(F_)return Lf;F_=1;var e=Xi(),n=er(),i=e(n,"Promise");return Lf=i,Lf}var $f,z_;function NN(){if(z_)return $f;z_=1;var e=Xi(),n=er(),i=e(n,"Set");return $f=i,$f}var Df,B_;function IO(){if(B_)return Df;B_=1;var e=Xi(),n=er(),i=e(n,"WeakMap");return Df=i,Df}var Ff,U_;function Gs(){if(U_)return Ff;U_=1;var e=TO(),n=pv(),i=AO(),s=NN(),o=IO(),l=Ki(),u=mN(),c="[object Map]",f="[object Object]",h="[object Promise]",p="[object Set]",m="[object WeakMap]",y="[object DataView]",w=u(e),j=u(n),_=u(i),S=u(s),b=u(o),E=l;return(e&&E(new e(new ArrayBuffer(1)))!=y||n&&E(new n)!=c||i&&E(i.resolve())!=h||s&&E(new s)!=p||o&&E(new o)!=m)&&(E=function(N){var C=l(N),I=C==f?N.constructor:void 0,O=I?u(I):"";if(O)switch(O){case w:return y;case j:return c;case _:return h;case S:return p;case b:return m}return C}),Ff=E,Ff}var zf,H_;function MO(){if(H_)return zf;H_=1;var e=Object.prototype,n=e.hasOwnProperty;function i(s){var o=s.length,l=new s.constructor(o);return o&&typeof s[0]=="string"&&n.call(s,"index")&&(l.index=s.index,l.input=s.input),l}return zf=i,zf}var Bf,V_;function CN(){if(V_)return Bf;V_=1;var e=er(),n=e.Uint8Array;return Bf=n,Bf}var Uf,W_;function Sv(){if(W_)return Uf;W_=1;var e=CN();function n(i){var s=new i.constructor(i.byteLength);return new e(s).set(new e(i)),s}return Uf=n,Uf}var Hf,G_;function PO(){if(G_)return Hf;G_=1;var e=Sv();function n(i,s){var o=s?e(i.buffer):i.buffer;return new i.constructor(o,i.byteOffset,i.byteLength)}return Hf=n,Hf}var Vf,Y_;function OO(){if(Y_)return Vf;Y_=1;var e=/\w*$/;function n(i){var s=new i.constructor(i.source,e.exec(i));return s.lastIndex=i.lastIndex,s}return Vf=n,Vf}var Wf,K_;function qO(){if(K_)return Wf;K_=1;var e=Vs(),n=e?e.prototype:void 0,i=n?n.valueOf:void 0;function s(o){return i?Object(i.call(o)):{}}return Wf=s,Wf}var Gf,X_;function jN(){if(X_)return Gf;X_=1;var e=Sv();function n(i,s){var o=s?e(i.buffer):i.buffer;return new i.constructor(o,i.byteOffset,i.length)}return Gf=n,Gf}var Yf,Q_;function LO(){if(Q_)return Yf;Q_=1;var e=Sv(),n=PO(),i=OO(),s=qO(),o=jN(),l="[object Boolean]",u="[object Date]",c="[object Map]",f="[object Number]",h="[object RegExp]",p="[object Set]",m="[object String]",y="[object Symbol]",w="[object ArrayBuffer]",j="[object DataView]",_="[object Float32Array]",S="[object Float64Array]",b="[object Int8Array]",E="[object Int16Array]",N="[object Int32Array]",C="[object Uint8Array]",I="[object Uint8ClampedArray]",O="[object Uint16Array]",P="[object Uint32Array]";function z(T,q,B){var Z=T.constructor;switch(q){case w:return e(T);case l:case u:return new Z(+T);case j:return n(T,B);case _:case S:case b:case E:case N:case C:case I:case O:case P:return o(T,B);case c:return new Z;case f:case m:return new Z(T);case h:return i(T);case p:return new Z;case y:return s(T)}}return Yf=z,Yf}var Kf,Z_;function RN(){if(Z_)return Kf;Z_=1;var e=On(),n=Object.create,i=(function(){function s(){}return function(o){if(!e(o))return{};if(n)return n(o);s.prototype=o;var l=new s;return s.prototype=void 0,l}})();return Kf=i,Kf}var Xf,J_;function TN(){if(J_)return Xf;J_=1;var e=RN(),n=ru(),i=nu();function s(o){return typeof o.constructor=="function"&&!i(o)?e(n(o)):{}}return Xf=s,Xf}var Qf,e1;function $O(){if(e1)return Qf;e1=1;var e=Gs(),n=dr(),i="[object Map]";function s(o){return n(o)&&e(o)==i}return Qf=s,Qf}var Zf,t1;function DO(){if(t1)return Zf;t1=1;var e=$O(),n=tu(),i=yv(),s=i&&i.isMap,o=s?n(s):e;return Zf=o,Zf}var Jf,n1;function FO(){if(n1)return Jf;n1=1;var e=Gs(),n=dr(),i="[object Set]";function s(o){return n(o)&&e(o)==i}return Jf=s,Jf}var eh,r1;function zO(){if(r1)return eh;r1=1;var e=FO(),n=tu(),i=yv(),s=i&&i.isSet,o=s?n(s):e;return eh=o,eh}var th,i1;function AN(){if(i1)return th;i1=1;var e=Ql(),n=gv(),i=Jl(),s=bO(),o=NO(),l=wN(),u=xN(),c=CO(),f=jO(),h=EN(),p=RO(),m=Gs(),y=MO(),w=LO(),j=TN(),_=St(),S=Ws(),b=DO(),E=On(),N=zO(),C=pi(),I=Qi(),O=1,P=2,z=4,T="[object Arguments]",q="[object Array]",B="[object Boolean]",Z="[object Date]",Q="[object Error]",A="[object Function]",H="[object GeneratorFunction]",U="[object Map]",ne="[object Number]",Y="[object Object]",L="[object RegExp]",G="[object Set]",k="[object String]",$="[object Symbol]",oe="[object WeakMap]",D="[object ArrayBuffer]",X="[object DataView]",ee="[object Float32Array]",se="[object Float64Array]",ae="[object Int8Array]",pe="[object Int16Array]",ge="[object Int32Array]",Ae="[object Uint8Array]",Oe="[object Uint8ClampedArray]",Ie="[object Uint16Array]",Me="[object Uint32Array]",ke={};ke[T]=ke[q]=ke[D]=ke[X]=ke[B]=ke[Z]=ke[ee]=ke[se]=ke[ae]=ke[pe]=ke[ge]=ke[U]=ke[ne]=ke[Y]=ke[L]=ke[G]=ke[k]=ke[$]=ke[Ae]=ke[Oe]=ke[Ie]=ke[Me]=!0,ke[Q]=ke[A]=ke[oe]=!1;function He(ve,ye,Ve,ft,Qe,We){var $e,Ke=ye&O,yt=ye&P,et=ye&z;if(Ve&&($e=Qe?Ve(ve,ft,Qe,We):Ve(ve)),$e!==void 0)return $e;if(!E(ve))return ve;var Ge=_(ve);if(Ge){if($e=y(ve),!Ke)return u(ve,$e)}else{var wt=m(ve),Rt=wt==A||wt==H;if(S(ve))return l(ve,Ke);if(wt==Y||wt==T||Rt&&!Qe){if($e=yt||Rt?{}:j(ve),!Ke)return yt?f(ve,o($e,ve)):c(ve,s($e,ve))}else{if(!ke[wt])return Qe?ve:{};$e=w(ve,wt,Ke)}}We||(We=new e);var Ft=We.get(ve);if(Ft)return Ft;We.set(ve,$e),N(ve)?ve.forEach(function(lt){$e.add(He(lt,ye,Ve,lt,ve,We))}):b(ve)&&ve.forEach(function(lt,mt){$e.set(mt,He(lt,ye,Ve,mt,ve,We))});var tt=et?yt?p:h:yt?I:C,xt=Ge?void 0:tt(ve);return n(xt||ve,function(lt,mt){xt&&(mt=lt,lt=ve[mt]),i($e,mt,He(lt,ye,Ve,mt,ve,We))}),$e}return th=He,th}var nh,s1;function BO(){if(s1)return nh;s1=1;var e=AN(),n=4;function i(s){return e(s,n)}return nh=i,nh}var rh,o1;function bv(){if(o1)return rh;o1=1;function e(n){return function(){return n}}return rh=e,rh}var ih,a1;function UO(){if(a1)return ih;a1=1;function e(n){return function(i,s,o){for(var l=-1,u=Object(i),c=o(i),f=c.length;f--;){var h=c[n?f:++l];if(s(u[h],h,u)===!1)break}return i}}return ih=e,ih}var sh,l1;function kv(){if(l1)return sh;l1=1;var e=UO(),n=e();return sh=n,sh}var oh,u1;function Ev(){if(u1)return oh;u1=1;var e=kv(),n=pi();function i(s,o){return s&&e(s,o,n)}return oh=i,oh}var ah,c1;function HO(){if(c1)return ah;c1=1;var e=Ir();function n(i,s){return function(o,l){if(o==null)return o;if(!e(o))return i(o,l);for(var u=o.length,c=s?u:-1,f=Object(o);(s?c--:++c<u)&&l(f[c],c,f)!==!1;);return o}}return ah=n,ah}var lh,d1;function iu(){if(d1)return lh;d1=1;var e=Ev(),n=HO(),i=n(e);return lh=i,lh}var uh,f1;function Zi(){if(f1)return uh;f1=1;function e(n){return n}return uh=e,uh}var ch,h1;function IN(){if(h1)return ch;h1=1;var e=Zi();function n(i){return typeof i=="function"?i:e}return ch=n,ch}var dh,p1;function MN(){if(p1)return dh;p1=1;var e=gv(),n=iu(),i=IN(),s=St();function o(l,u){var c=s(l)?e:n;return c(l,i(u))}return dh=o,dh}var fh,m1;function PN(){return m1||(m1=1,fh=MN()),fh}var hh,g1;function VO(){if(g1)return hh;g1=1;var e=iu();function n(i,s){var o=[];return e(i,function(l,u,c){s(l,u,c)&&o.push(l)}),o}return hh=n,hh}var ph,v1;function WO(){if(v1)return ph;v1=1;var e="__lodash_hash_undefined__";function n(i){return this.__data__.set(i,e),this}return ph=n,ph}var mh,y1;function GO(){if(y1)return mh;y1=1;function e(n){return this.__data__.has(n)}return mh=e,mh}var gh,w1;function ON(){if(w1)return gh;w1=1;var e=mv(),n=WO(),i=GO();function s(o){var l=-1,u=o==null?0:o.length;for(this.__data__=new e;++l<u;)this.add(o[l])}return s.prototype.add=s.prototype.push=n,s.prototype.has=i,gh=s,gh}var vh,x1;function YO(){if(x1)return vh;x1=1;function e(n,i){for(var s=-1,o=n==null?0:n.length;++s<o;)if(i(n[s],s,n))return!0;return!1}return vh=e,vh}var yh,_1;function qN(){if(_1)return yh;_1=1;function e(n,i){return n.has(i)}return yh=e,yh}var wh,S1;function LN(){if(S1)return wh;S1=1;var e=ON(),n=YO(),i=qN(),s=1,o=2;function l(u,c,f,h,p,m){var y=f&s,w=u.length,j=c.length;if(w!=j&&!(y&&j>w))return!1;var _=m.get(u),S=m.get(c);if(_&&S)return _==c&&S==u;var b=-1,E=!0,N=f&o?new e:void 0;for(m.set(u,c),m.set(c,u);++b<w;){var C=u[b],I=c[b];if(h)var O=y?h(I,C,b,c,u,m):h(C,I,b,u,c,m);if(O!==void 0){if(O)continue;E=!1;break}if(N){if(!n(c,function(P,z){if(!i(N,z)&&(C===P||p(C,P,f,h,m)))return N.push(z)})){E=!1;break}}else if(!(C===I||p(C,I,f,h,m))){E=!1;break}}return m.delete(u),m.delete(c),E}return wh=l,wh}var xh,b1;function KO(){if(b1)return xh;b1=1;function e(n){var i=-1,s=Array(n.size);return n.forEach(function(o,l){s[++i]=[l,o]}),s}return xh=e,xh}var _h,k1;function Nv(){if(k1)return _h;k1=1;function e(n){var i=-1,s=Array(n.size);return n.forEach(function(o){s[++i]=o}),s}return _h=e,_h}var Sh,E1;function XO(){if(E1)return Sh;E1=1;var e=Vs(),n=CN(),i=Hs(),s=LN(),o=KO(),l=Nv(),u=1,c=2,f="[object Boolean]",h="[object Date]",p="[object Error]",m="[object Map]",y="[object Number]",w="[object RegExp]",j="[object Set]",_="[object String]",S="[object Symbol]",b="[object ArrayBuffer]",E="[object DataView]",N=e?e.prototype:void 0,C=N?N.valueOf:void 0;function I(O,P,z,T,q,B,Z){switch(z){case E:if(O.byteLength!=P.byteLength||O.byteOffset!=P.byteOffset)return!1;O=O.buffer,P=P.buffer;case b:return!(O.byteLength!=P.byteLength||!B(new n(O),new n(P)));case f:case h:case y:return i(+O,+P);case p:return O.name==P.name&&O.message==P.message;case w:case _:return O==P+"";case m:var Q=o;case j:var A=T&u;if(Q||(Q=l),O.size!=P.size&&!A)return!1;var H=Z.get(O);if(H)return H==P;T|=c,Z.set(O,P);var U=s(Q(O),Q(P),T,q,B,Z);return Z.delete(O),U;case S:if(C)return C.call(O)==C.call(P)}return!1}return Sh=I,Sh}var bh,N1;function QO(){if(N1)return bh;N1=1;var e=EN(),n=1,i=Object.prototype,s=i.hasOwnProperty;function o(l,u,c,f,h,p){var m=c&n,y=e(l),w=y.length,j=e(u),_=j.length;if(w!=_&&!m)return!1;for(var S=w;S--;){var b=y[S];if(!(m?b in u:s.call(u,b)))return!1}var E=p.get(l),N=p.get(u);if(E&&N)return E==u&&N==l;var C=!0;p.set(l,u),p.set(u,l);for(var I=m;++S<w;){b=y[S];var O=l[b],P=u[b];if(f)var z=m?f(P,O,b,u,l,p):f(O,P,b,l,u,p);if(!(z===void 0?O===P||h(O,P,c,f,p):z)){C=!1;break}I||(I=b=="constructor")}if(C&&!I){var T=l.constructor,q=u.constructor;T!=q&&"constructor"in l&&"constructor"in u&&!(typeof T=="function"&&T instanceof T&&typeof q=="function"&&q instanceof q)&&(C=!1)}return p.delete(l),p.delete(u),C}return bh=o,bh}var kh,C1;function ZO(){if(C1)return kh;C1=1;var e=Ql(),n=LN(),i=XO(),s=QO(),o=Gs(),l=St(),u=Ws(),c=oa(),f=1,h="[object Arguments]",p="[object Array]",m="[object Object]",y=Object.prototype,w=y.hasOwnProperty;function j(_,S,b,E,N,C){var I=l(_),O=l(S),P=I?p:o(_),z=O?p:o(S);P=P==h?m:P,z=z==h?m:z;var T=P==m,q=z==m,B=P==z;if(B&&u(_)){if(!u(S))return!1;I=!0,T=!1}if(B&&!T)return C||(C=new e),I||c(_)?n(_,S,b,E,N,C):i(_,S,P,b,E,N,C);if(!(b&f)){var Z=T&&w.call(_,"__wrapped__"),Q=q&&w.call(S,"__wrapped__");if(Z||Q){var A=Z?_.value():_,H=Q?S.value():S;return C||(C=new e),N(A,H,b,E,C)}}return B?(C||(C=new e),s(_,S,b,E,N,C)):!1}return kh=j,kh}var Eh,j1;function $N(){if(j1)return Eh;j1=1;var e=ZO(),n=dr();function i(s,o,l,u,c){return s===o?!0:s==null||o==null||!n(s)&&!n(o)?s!==s&&o!==o:e(s,o,l,u,i,c)}return Eh=i,Eh}var Nh,R1;function JO(){if(R1)return Nh;R1=1;var e=Ql(),n=$N(),i=1,s=2;function o(l,u,c,f){var h=c.length,p=h,m=!f;if(l==null)return!p;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<p;){y=c[h];var w=y[0],j=l[w],_=y[1];if(m&&y[2]){if(j===void 0&&!(w in l))return!1}else{var S=new e;if(f)var b=f(j,_,w,l,u,S);if(!(b===void 0?n(_,j,i|s,f,S):b))return!1}}return!0}return Nh=o,Nh}var Ch,T1;function DN(){if(T1)return Ch;T1=1;var e=On();function n(i){return i===i&&!e(i)}return Ch=n,Ch}var jh,A1;function eq(){if(A1)return jh;A1=1;var e=DN(),n=pi();function i(s){for(var o=n(s),l=o.length;l--;){var u=o[l],c=s[u];o[l]=[u,c,e(c)]}return o}return jh=i,jh}var Rh,I1;function FN(){if(I1)return Rh;I1=1;function e(n,i){return function(s){return s==null?!1:s[n]===i&&(i!==void 0||n in Object(s))}}return Rh=e,Rh}var Th,M1;function tq(){if(M1)return Th;M1=1;var e=JO(),n=eq(),i=FN();function s(o){var l=n(o);return l.length==1&&l[0][2]?i(l[0][0],l[0][1]):function(u){return u===o||e(u,o,l)}}return Th=s,Th}var Ah,P1;function Ys(){if(P1)return Ah;P1=1;var e=Ki(),n=dr(),i="[object Symbol]";function s(o){return typeof o=="symbol"||n(o)&&e(o)==i}return Ah=s,Ah}var Ih,O1;function Cv(){if(O1)return Ih;O1=1;var e=St(),n=Ys(),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function o(l,u){if(e(l))return!1;var c=typeof l;return c=="number"||c=="symbol"||c=="boolean"||l==null||n(l)?!0:s.test(l)||!i.test(l)||u!=null&&l in Object(u)}return Ih=o,Ih}var Mh,q1;function nq(){if(q1)return Mh;q1=1;var e=mv(),n="Expected a function";function i(s,o){if(typeof s!="function"||o!=null&&typeof o!="function")throw new TypeError(n);var l=function(){var u=arguments,c=o?o.apply(this,u):u[0],f=l.cache;if(f.has(c))return f.get(c);var h=s.apply(this,u);return l.cache=f.set(c,h)||f,h};return l.cache=new(i.Cache||e),l}return i.Cache=e,Mh=i,Mh}var Ph,L1;function rq(){if(L1)return Ph;L1=1;var e=nq(),n=500;function i(s){var o=e(s,function(u){return l.size===n&&l.clear(),u}),l=o.cache;return o}return Ph=i,Ph}var Oh,$1;function iq(){if($1)return Oh;$1=1;var e=rq(),n=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,s=e(function(o){var l=[];return o.charCodeAt(0)===46&&l.push(""),o.replace(n,function(u,c,f,h){l.push(f?h.replace(i,"$1"):c||u)}),l});return Oh=s,Oh}var qh,D1;function su(){if(D1)return qh;D1=1;function e(n,i){for(var s=-1,o=n==null?0:n.length,l=Array(o);++s<o;)l[s]=i(n[s],s,n);return l}return qh=e,qh}var Lh,F1;function sq(){if(F1)return Lh;F1=1;var e=Vs(),n=su(),i=St(),s=Ys(),o=e?e.prototype:void 0,l=o?o.toString:void 0;function u(c){if(typeof c=="string")return c;if(i(c))return n(c,u)+"";if(s(c))return l?l.call(c):"";var f=c+"";return f=="0"&&1/c==-1/0?"-0":f}return Lh=u,Lh}var $h,z1;function zN(){if(z1)return $h;z1=1;var e=sq();function n(i){return i==null?"":e(i)}return $h=n,$h}var Dh,B1;function ou(){if(B1)return Dh;B1=1;var e=St(),n=Cv(),i=iq(),s=zN();function o(l,u){return e(l)?l:n(l,u)?[l]:i(s(l))}return Dh=o,Dh}var Fh,U1;function aa(){if(U1)return Fh;U1=1;var e=Ys();function n(i){if(typeof i=="string"||e(i))return i;var s=i+"";return s=="0"&&1/i==-1/0?"-0":s}return Fh=n,Fh}var zh,H1;function au(){if(H1)return zh;H1=1;var e=ou(),n=aa();function i(s,o){o=e(o,s);for(var l=0,u=o.length;s!=null&&l<u;)s=s[n(o[l++])];return l&&l==u?s:void 0}return zh=i,zh}var Bh,V1;function oq(){if(V1)return Bh;V1=1;var e=au();function n(i,s,o){var l=i==null?void 0:e(i,s);return l===void 0?o:l}return Bh=n,Bh}var Uh,W1;function aq(){if(W1)return Uh;W1=1;function e(n,i){return n!=null&&i in Object(n)}return Uh=e,Uh}var Hh,G1;function BN(){if(G1)return Hh;G1=1;var e=ou(),n=sa(),i=St(),s=eu(),o=vv(),l=aa();function u(c,f,h){f=e(f,c);for(var p=-1,m=f.length,y=!1;++p<m;){var w=l(f[p]);if(!(y=c!=null&&h(c,w)))break;c=c[w]}return y||++p!=m?y:(m=c==null?0:c.length,!!m&&o(m)&&s(w,m)&&(i(c)||n(c)))}return Hh=u,Hh}var Vh,Y1;function UN(){if(Y1)return Vh;Y1=1;var e=aq(),n=BN();function i(s,o){return s!=null&&n(s,o,e)}return Vh=i,Vh}var Wh,K1;function lq(){if(K1)return Wh;K1=1;var e=$N(),n=oq(),i=UN(),s=Cv(),o=DN(),l=FN(),u=aa(),c=1,f=2;function h(p,m){return s(p)&&o(m)?l(u(p),m):function(y){var w=n(y,p);return w===void 0&&w===m?i(y,p):e(m,w,c|f)}}return Wh=h,Wh}var Gh,X1;function HN(){if(X1)return Gh;X1=1;function e(n){return function(i){return i==null?void 0:i[n]}}return Gh=e,Gh}var Yh,Q1;function uq(){if(Q1)return Yh;Q1=1;var e=au();function n(i){return function(s){return e(s,i)}}return Yh=n,Yh}var Kh,Z1;function cq(){if(Z1)return Kh;Z1=1;var e=HN(),n=uq(),i=Cv(),s=aa();function o(l){return i(l)?e(s(l)):n(l)}return Kh=o,Kh}var Xh,J1;function Mr(){if(J1)return Xh;J1=1;var e=tq(),n=lq(),i=Zi(),s=St(),o=cq();function l(u){return typeof u=="function"?u:u==null?i:typeof u=="object"?s(u)?n(u[0],u[1]):e(u):o(u)}return Xh=l,Xh}var Qh,eS;function VN(){if(eS)return Qh;eS=1;var e=_N(),n=VO(),i=Mr(),s=St();function o(l,u){var c=s(l)?e:n;return c(l,i(u,3))}return Qh=o,Qh}var Zh,tS;function dq(){if(tS)return Zh;tS=1;var e=Object.prototype,n=e.hasOwnProperty;function i(s,o){return s!=null&&n.call(s,o)}return Zh=i,Zh}var Jh,nS;function WN(){if(nS)return Jh;nS=1;var e=dq(),n=BN();function i(s,o){return s!=null&&n(s,o,e)}return Jh=i,Jh}var ep,rS;function fq(){if(rS)return ep;rS=1;var e=wv(),n=Gs(),i=sa(),s=St(),o=Ir(),l=Ws(),u=nu(),c=oa(),f="[object Map]",h="[object Set]",p=Object.prototype,m=p.hasOwnProperty;function y(w){if(w==null)return!0;if(o(w)&&(s(w)||typeof w=="string"||typeof w.splice=="function"||l(w)||c(w)||i(w)))return!w.length;var j=n(w);if(j==f||j==h)return!w.size;if(u(w))return!e(w).length;for(var _ in w)if(m.call(w,_))return!1;return!0}return ep=y,ep}var tp,iS;function GN(){if(iS)return tp;iS=1;function e(n){return n===void 0}return tp=e,tp}var np,sS;function YN(){if(sS)return np;sS=1;var e=iu(),n=Ir();function i(s,o){var l=-1,u=n(s)?Array(s.length):[];return e(s,function(c,f,h){u[++l]=o(c,f,h)}),u}return np=i,np}var rp,oS;function KN(){if(oS)return rp;oS=1;var e=su(),n=Mr(),i=YN(),s=St();function o(l,u){var c=s(l)?e:i;return c(l,n(u,3))}return rp=o,rp}var ip,aS;function hq(){if(aS)return ip;aS=1;function e(n,i,s,o){var l=-1,u=n==null?0:n.length;for(o&&u&&(s=n[++l]);++l<u;)s=i(s,n[l],l,n);return s}return ip=e,ip}var sp,lS;function pq(){if(lS)return sp;lS=1;function e(n,i,s,o,l){return l(n,function(u,c,f){s=o?(o=!1,u):i(s,u,c,f)}),s}return sp=e,sp}var op,uS;function XN(){if(uS)return op;uS=1;var e=hq(),n=iu(),i=Mr(),s=pq(),o=St();function l(u,c,f){var h=o(u)?e:s,p=arguments.length<3;return h(u,i(c,4),f,p,n)}return op=l,op}var ap,cS;function mq(){if(cS)return ap;cS=1;var e=Ki(),n=St(),i=dr(),s="[object String]";function o(l){return typeof l=="string"||!n(l)&&i(l)&&e(l)==s}return ap=o,ap}var lp,dS;function gq(){if(dS)return lp;dS=1;var e=HN(),n=e("length");return lp=n,lp}var up,fS;function vq(){if(fS)return up;fS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",i="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+i+s,l="\\ufe0e\\ufe0f",u="\\u200d",c=RegExp("["+u+e+o+l+"]");function f(h){return c.test(h)}return up=f,up}var cp,hS;function yq(){if(hS)return cp;hS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",i="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+i+s,l="\\ufe0e\\ufe0f",u="["+e+"]",c="["+o+"]",f="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+f+")",p="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",j=h+"?",_="["+l+"]?",S="(?:"+w+"(?:"+[p,m,y].join("|")+")"+_+j+")*",b=_+j+S,E="(?:"+[p+c+"?",c,m,y,u].join("|")+")",N=RegExp(f+"(?="+f+")|"+E+b,"g");function C(I){for(var O=N.lastIndex=0;N.test(I);)++O;return O}return cp=C,cp}var dp,pS;function wq(){if(pS)return dp;pS=1;var e=gq(),n=vq(),i=yq();function s(o){return n(o)?i(o):e(o)}return dp=s,dp}var fp,mS;function xq(){if(mS)return fp;mS=1;var e=wv(),n=Gs(),i=Ir(),s=mq(),o=wq(),l="[object Map]",u="[object Set]";function c(f){if(f==null)return 0;if(i(f))return s(f)?o(f):f.length;var h=n(f);return h==l||h==u?f.size:e(f).length}return fp=c,fp}var hp,gS;function _q(){if(gS)return hp;gS=1;var e=gv(),n=RN(),i=Ev(),s=Mr(),o=ru(),l=St(),u=Ws(),c=ra(),f=On(),h=oa();function p(m,y,w){var j=l(m),_=j||u(m)||h(m);if(y=s(y,4),w==null){var S=m&&m.constructor;_?w=j?new S:[]:f(m)?w=c(S)?n(o(m)):{}:w={}}return(_?e:i)(m,function(b,E,N){return y(w,b,E,N)}),w}return hp=p,hp}var pp,vS;function Sq(){if(vS)return pp;vS=1;var e=Vs(),n=sa(),i=St(),s=e?e.isConcatSpreadable:void 0;function o(l){return i(l)||n(l)||!!(s&&l&&l[s])}return pp=o,pp}var mp,yS;function jv(){if(yS)return mp;yS=1;var e=_v(),n=Sq();function i(s,o,l,u,c){var f=-1,h=s.length;for(l||(l=n),c||(c=[]);++f<h;){var p=s[f];o>0&&l(p)?o>1?i(p,o-1,l,u,c):e(c,p):u||(c[c.length]=p)}return c}return mp=i,mp}var gp,wS;function bq(){if(wS)return gp;wS=1;function e(n,i,s){switch(s.length){case 0:return n.call(i);case 1:return n.call(i,s[0]);case 2:return n.call(i,s[0],s[1]);case 3:return n.call(i,s[0],s[1],s[2])}return n.apply(i,s)}return gp=e,gp}var vp,xS;function QN(){if(xS)return vp;xS=1;var e=bq(),n=Math.max;function i(s,o,l){return o=n(o===void 0?s.length-1:o,0),function(){for(var u=arguments,c=-1,f=n(u.length-o,0),h=Array(f);++c<f;)h[c]=u[o+c];c=-1;for(var p=Array(o+1);++c<o;)p[c]=u[c];return p[o]=l(h),e(s,this,p)}}return vp=i,vp}var yp,_S;function kq(){if(_S)return yp;_S=1;var e=bv(),n=gN(),i=Zi(),s=n?function(o,l){return n(o,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:i;return yp=s,yp}var wp,SS;function Eq(){if(SS)return wp;SS=1;var e=800,n=16,i=Date.now;function s(o){var l=0,u=0;return function(){var c=i(),f=n-(c-u);if(u=c,f>0){if(++l>=e)return arguments[0]}else l=0;return o.apply(void 0,arguments)}}return wp=s,wp}var xp,bS;function ZN(){if(bS)return xp;bS=1;var e=kq(),n=Eq(),i=n(e);return xp=i,xp}var _p,kS;function lu(){if(kS)return _p;kS=1;var e=Zi(),n=QN(),i=ZN();function s(o,l){return i(n(o,l,e),o+"")}return _p=s,_p}var Sp,ES;function JN(){if(ES)return Sp;ES=1;function e(n,i,s,o){for(var l=n.length,u=s+(o?1:-1);o?u--:++u<l;)if(i(n[u],u,n))return u;return-1}return Sp=e,Sp}var bp,NS;function Nq(){if(NS)return bp;NS=1;function e(n){return n!==n}return bp=e,bp}var kp,CS;function Cq(){if(CS)return kp;CS=1;function e(n,i,s){for(var o=s-1,l=n.length;++o<l;)if(n[o]===i)return o;return-1}return kp=e,kp}var Ep,jS;function jq(){if(jS)return Ep;jS=1;var e=JN(),n=Nq(),i=Cq();function s(o,l,u){return l===l?i(o,l,u):e(o,n,u)}return Ep=s,Ep}var Np,RS;function Rq(){if(RS)return Np;RS=1;var e=jq();function n(i,s){var o=i==null?0:i.length;return!!o&&e(i,s,0)>-1}return Np=n,Np}var Cp,TS;function Tq(){if(TS)return Cp;TS=1;function e(n,i,s){for(var o=-1,l=n==null?0:n.length;++o<l;)if(s(i,n[o]))return!0;return!1}return Cp=e,Cp}var jp,AS;function Aq(){if(AS)return jp;AS=1;function e(){}return jp=e,jp}var Rp,IS;function Iq(){if(IS)return Rp;IS=1;var e=NN(),n=Aq(),i=Nv(),s=1/0,o=e&&1/i(new e([,-0]))[1]==s?function(l){return new e(l)}:n;return Rp=o,Rp}var Tp,MS;function Mq(){if(MS)return Tp;MS=1;var e=ON(),n=Rq(),i=Tq(),s=qN(),o=Iq(),l=Nv(),u=200;function c(f,h,p){var m=-1,y=n,w=f.length,j=!0,_=[],S=_;if(p)j=!1,y=i;else if(w>=u){var b=h?null:o(f);if(b)return l(b);j=!1,y=s,S=new e}else S=h?[]:_;e:for(;++m<w;){var E=f[m],N=h?h(E):E;if(E=p||E!==0?E:0,j&&N===N){for(var C=S.length;C--;)if(S[C]===N)continue e;h&&S.push(N),_.push(E)}else y(S,N,p)||(S!==_&&S.push(N),_.push(E))}return _}return Tp=c,Tp}var Ap,PS;function eC(){if(PS)return Ap;PS=1;var e=Ir(),n=dr();function i(s){return n(s)&&e(s)}return Ap=i,Ap}var Ip,OS;function Pq(){if(OS)return Ip;OS=1;var e=jv(),n=lu(),i=Mq(),s=eC(),o=n(function(l){return i(e(l,1,s,!0))});return Ip=o,Ip}var Mp,qS;function Oq(){if(qS)return Mp;qS=1;var e=su();function n(i,s){return e(s,function(o){return i[o]})}return Mp=n,Mp}var Pp,LS;function tC(){if(LS)return Pp;LS=1;var e=Oq(),n=pi();function i(s){return s==null?[]:e(s,n(s))}return Pp=i,Pp}var Op,$S;function qn(){if($S)return Op;$S=1;var e;if(typeof hv=="function")try{e={clone:BO(),constant:bv(),each:PN(),filter:VN(),has:WN(),isArray:St(),isEmpty:fq(),isFunction:ra(),isUndefined:GN(),keys:pi(),map:KN(),reduce:XN(),size:xq(),transform:_q(),union:Pq(),values:tC()}}catch{}return e||(e=window._),Op=e,Op}var qp,DS;function Rv(){if(DS)return qp;DS=1;var e=qn();qp=o;var n="\0",i="\0",s="";function o(p){this._isDirected=e.has(p,"directed")?p.directed:!0,this._isMultigraph=e.has(p,"multigraph")?p.multigraph:!1,this._isCompound=e.has(p,"compound")?p.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[i]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(p){return this._label=p,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(p){return e.isFunction(p)||(p=e.constant(p)),this._defaultNodeLabelFn=p,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var p=this;return e.filter(this.nodes(),function(m){return e.isEmpty(p._in[m])})},o.prototype.sinks=function(){var p=this;return e.filter(this.nodes(),function(m){return e.isEmpty(p._out[m])})},o.prototype.setNodes=function(p,m){var y=arguments,w=this;return e.each(p,function(j){y.length>1?w.setNode(j,m):w.setNode(j)}),this},o.prototype.setNode=function(p,m){return e.has(this._nodes,p)?(arguments.length>1&&(this._nodes[p]=m),this):(this._nodes[p]=arguments.length>1?m:this._defaultNodeLabelFn(p),this._isCompound&&(this._parent[p]=i,this._children[p]={},this._children[i][p]=!0),this._in[p]={},this._preds[p]={},this._out[p]={},this._sucs[p]={},++this._nodeCount,this)},o.prototype.node=function(p){return this._nodes[p]},o.prototype.hasNode=function(p){return e.has(this._nodes,p)},o.prototype.removeNode=function(p){var m=this;if(e.has(this._nodes,p)){var y=function(w){m.removeEdge(m._edgeObjs[w])};delete this._nodes[p],this._isCompound&&(this._removeFromParentsChildList(p),delete this._parent[p],e.each(this.children(p),function(w){m.setParent(w)}),delete this._children[p]),e.each(e.keys(this._in[p]),y),delete this._in[p],delete this._preds[p],e.each(e.keys(this._out[p]),y),delete this._out[p],delete this._sucs[p],--this._nodeCount}return this},o.prototype.setParent=function(p,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(m))m=i;else{m+="";for(var y=m;!e.isUndefined(y);y=this.parent(y))if(y===p)throw new Error("Setting "+m+" as parent of "+p+" would create a cycle");this.setNode(m)}return this.setNode(p),this._removeFromParentsChildList(p),this._parent[p]=m,this._children[m][p]=!0,this},o.prototype._removeFromParentsChildList=function(p){delete this._children[this._parent[p]][p]},o.prototype.parent=function(p){if(this._isCompound){var m=this._parent[p];if(m!==i)return m}},o.prototype.children=function(p){if(e.isUndefined(p)&&(p=i),this._isCompound){var m=this._children[p];if(m)return e.keys(m)}else{if(p===i)return this.nodes();if(this.hasNode(p))return[]}},o.prototype.predecessors=function(p){var m=this._preds[p];if(m)return e.keys(m)},o.prototype.successors=function(p){var m=this._sucs[p];if(m)return e.keys(m)},o.prototype.neighbors=function(p){var m=this.predecessors(p);if(m)return e.union(m,this.successors(p))},o.prototype.isLeaf=function(p){var m;return this.isDirected()?m=this.successors(p):m=this.neighbors(p),m.length===0},o.prototype.filterNodes=function(p){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){p(S)&&m.setNode(S,_)}),e.each(this._edgeObjs,function(_){m.hasNode(_.v)&&m.hasNode(_.w)&&m.setEdge(_,y.edge(_))});var w={};function j(_){var S=y.parent(_);return S===void 0||m.hasNode(S)?(w[_]=S,S):S in w?w[S]:j(S)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,j(_))}),m},o.prototype.setDefaultEdgeLabel=function(p){return e.isFunction(p)||(p=e.constant(p)),this._defaultEdgeLabelFn=p,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(p,m){var y=this,w=arguments;return e.reduce(p,function(j,_){return w.length>1?y.setEdge(j,_,m):y.setEdge(j,_),_}),this},o.prototype.setEdge=function(){var p,m,y,w,j=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(p=_.v,m=_.w,y=_.name,arguments.length===2&&(w=arguments[1],j=!0)):(p=_,m=arguments[1],y=arguments[3],arguments.length>2&&(w=arguments[2],j=!0)),p=""+p,m=""+m,e.isUndefined(y)||(y=""+y);var S=c(this._isDirected,p,m,y);if(e.has(this._edgeLabels,S))return j&&(this._edgeLabels[S]=w),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(p),this.setNode(m),this._edgeLabels[S]=j?w:this._defaultEdgeLabelFn(p,m,y);var b=f(this._isDirected,p,m,y);return p=b.v,m=b.w,Object.freeze(b),this._edgeObjs[S]=b,l(this._preds[m],p),l(this._sucs[p],m),this._in[m][S]=b,this._out[p][S]=b,this._edgeCount++,this},o.prototype.edge=function(p,m,y){var w=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y);return this._edgeLabels[w]},o.prototype.hasEdge=function(p,m,y){var w=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y);return e.has(this._edgeLabels,w)},o.prototype.removeEdge=function(p,m,y){var w=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y),j=this._edgeObjs[w];return j&&(p=j.v,m=j.w,delete this._edgeLabels[w],delete this._edgeObjs[w],u(this._preds[m],p),u(this._sucs[p],m),delete this._in[m][w],delete this._out[p][w],this._edgeCount--),this},o.prototype.inEdges=function(p,m){var y=this._in[p];if(y){var w=e.values(y);return m?e.filter(w,function(j){return j.v===m}):w}},o.prototype.outEdges=function(p,m){var y=this._out[p];if(y){var w=e.values(y);return m?e.filter(w,function(j){return j.w===m}):w}},o.prototype.nodeEdges=function(p,m){var y=this.inEdges(p,m);if(y)return y.concat(this.outEdges(p,m))};function l(p,m){p[m]?p[m]++:p[m]=1}function u(p,m){--p[m]||delete p[m]}function c(p,m,y,w){var j=""+m,_=""+y;if(!p&&j>_){var S=j;j=_,_=S}return j+s+_+s+(e.isUndefined(w)?n:w)}function f(p,m,y,w){var j=""+m,_=""+y;if(!p&&j>_){var S=j;j=_,_=S}var b={v:j,w:_};return w&&(b.name=w),b}function h(p,m){return c(p,m.v,m.w,m.name)}return qp}var Lp,FS;function qq(){return FS||(FS=1,Lp="2.1.8"),Lp}var $p,zS;function Lq(){return zS||(zS=1,$p={Graph:Rv(),version:qq()}),$p}var Dp,BS;function $q(){if(BS)return Dp;BS=1;var e=qn(),n=Rv();Dp={write:i,read:l};function i(u){var c={options:{directed:u.isDirected(),multigraph:u.isMultigraph(),compound:u.isCompound()},nodes:s(u),edges:o(u)};return e.isUndefined(u.graph())||(c.value=e.clone(u.graph())),c}function s(u){return e.map(u.nodes(),function(c){var f=u.node(c),h=u.parent(c),p={v:c};return e.isUndefined(f)||(p.value=f),e.isUndefined(h)||(p.parent=h),p})}function o(u){return e.map(u.edges(),function(c){var f=u.edge(c),h={v:c.v,w:c.w};return e.isUndefined(c.name)||(h.name=c.name),e.isUndefined(f)||(h.value=f),h})}function l(u){var c=new n(u.options).setGraph(u.value);return e.each(u.nodes,function(f){c.setNode(f.v,f.value),f.parent&&c.setParent(f.v,f.parent)}),e.each(u.edges,function(f){c.setEdge({v:f.v,w:f.w,name:f.name},f.value)}),c}return Dp}var Fp,US;function Dq(){if(US)return Fp;US=1;var e=qn();Fp=n;function n(i){var s={},o=[],l;function u(c){e.has(s,c)||(s[c]=!0,l.push(c),e.each(i.successors(c),u),e.each(i.predecessors(c),u))}return e.each(i.nodes(),function(c){l=[],u(c),l.length&&o.push(l)}),o}return Fp}var zp,HS;function nC(){if(HS)return zp;HS=1;var e=qn();zp=n;function n(){this._arr=[],this._keyIndices={}}return n.prototype.size=function(){return this._arr.length},n.prototype.keys=function(){return this._arr.map(function(i){return i.key})},n.prototype.has=function(i){return e.has(this._keyIndices,i)},n.prototype.priority=function(i){var s=this._keyIndices[i];if(s!==void 0)return this._arr[s].priority},n.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},n.prototype.add=function(i,s){var o=this._keyIndices;if(i=String(i),!e.has(o,i)){var l=this._arr,u=l.length;return o[i]=u,l.push({key:i,priority:s}),this._decrease(u),!0}return!1},n.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var i=this._arr.pop();return delete this._keyIndices[i.key],this._heapify(0),i.key},n.prototype.decrease=function(i,s){var o=this._keyIndices[i];if(s>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+i+" Old: "+this._arr[o].priority+" New: "+s);this._arr[o].priority=s,this._decrease(o)},n.prototype._heapify=function(i){var s=this._arr,o=2*i,l=o+1,u=i;o<s.length&&(u=s[o].priority<s[u].priority?o:u,l<s.length&&(u=s[l].priority<s[u].priority?l:u),u!==i&&(this._swap(i,u),this._heapify(u)))},n.prototype._decrease=function(i){for(var s=this._arr,o=s[i].priority,l;i!==0&&(l=i>>1,!(s[l].priority<o));)this._swap(i,l),i=l},n.prototype._swap=function(i,s){var o=this._arr,l=this._keyIndices,u=o[i],c=o[s];o[i]=c,o[s]=u,l[c.key]=i,l[u.key]=s},zp}var Bp,VS;function rC(){if(VS)return Bp;VS=1;var e=qn(),n=nC();Bp=s;var i=e.constant(1);function s(l,u,c,f){return o(l,String(u),c||i,f||function(h){return l.outEdges(h)})}function o(l,u,c,f){var h={},p=new n,m,y,w=function(j){var _=j.v!==m?j.v:j.w,S=h[_],b=c(j),E=y.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+j+" Weight: "+b);E<S.distance&&(S.distance=E,S.predecessor=m,p.decrease(_,E))};for(l.nodes().forEach(function(j){var _=j===u?0:Number.POSITIVE_INFINITY;h[j]={distance:_},p.add(j,_)});p.size()>0&&(m=p.removeMin(),y=h[m],y.distance!==Number.POSITIVE_INFINITY);)f(m).forEach(w);return h}return Bp}var Up,WS;function Fq(){if(WS)return Up;WS=1;var e=rC(),n=qn();Up=i;function i(s,o,l){return n.transform(s.nodes(),function(u,c){u[c]=e(s,c,o,l)},{})}return Up}var Hp,GS;function iC(){if(GS)return Hp;GS=1;var e=qn();Hp=n;function n(i){var s=0,o=[],l={},u=[];function c(f){var h=l[f]={onStack:!0,lowlink:s,index:s++};if(o.push(f),i.successors(f).forEach(function(y){e.has(l,y)?l[y].onStack&&(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 p=[],m;do m=o.pop(),l[m].onStack=!1,p.push(m);while(f!==m);u.push(p)}}return i.nodes().forEach(function(f){e.has(l,f)||c(f)}),u}return Hp}var Vp,YS;function zq(){if(YS)return Vp;YS=1;var e=qn(),n=iC();Vp=i;function i(s){return e.filter(n(s),function(o){return o.length>1||o.length===1&&s.hasEdge(o[0],o[0])})}return Vp}var Wp,KS;function Bq(){if(KS)return Wp;KS=1;var e=qn();Wp=i;var n=e.constant(1);function i(o,l,u){return s(o,l||n,u||function(c){return o.outEdges(c)})}function s(o,l,u){var c={},f=o.nodes();return f.forEach(function(h){c[h]={},c[h][h]={distance:0},f.forEach(function(p){h!==p&&(c[h][p]={distance:Number.POSITIVE_INFINITY})}),u(h).forEach(function(p){var m=p.v===h?p.w:p.v,y=l(p);c[h][m]={distance:y,predecessor:h}})}),f.forEach(function(h){var p=c[h];f.forEach(function(m){var y=c[m];f.forEach(function(w){var j=y[h],_=p[w],S=y[w],b=j.distance+_.distance;b<S.distance&&(S.distance=b,S.predecessor=_.predecessor)})})}),c}return Wp}var Gp,XS;function sC(){if(XS)return Gp;XS=1;var e=qn();Gp=n,n.CycleException=i;function n(s){var o={},l={},u=[];function c(f){if(e.has(l,f))throw new i;e.has(o,f)||(l[f]=!0,o[f]=!0,e.each(s.predecessors(f),c),delete l[f],u.push(f))}if(e.each(s.sinks(),c),e.size(o)!==s.nodeCount())throw new i;return u}function i(){}return i.prototype=new Error,Gp}var Yp,QS;function Uq(){if(QS)return Yp;QS=1;var e=sC();Yp=n;function n(i){try{e(i)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return Yp}var Kp,ZS;function oC(){if(ZS)return Kp;ZS=1;var e=qn();Kp=n;function n(s,o,l){e.isArray(o)||(o=[o]);var u=(s.isDirected()?s.successors:s.neighbors).bind(s),c=[],f={};return e.each(o,function(h){if(!s.hasNode(h))throw new Error("Graph does not have node: "+h);i(s,h,l==="post",f,u,c)}),c}function i(s,o,l,u,c,f){e.has(u,o)||(u[o]=!0,l||f.push(o),e.each(c(o),function(h){i(s,h,l,u,c,f)}),l&&f.push(o))}return Kp}var Xp,JS;function Hq(){if(JS)return Xp;JS=1;var e=oC();Xp=n;function n(i,s){return e(i,s,"post")}return Xp}var Qp,eb;function Vq(){if(eb)return Qp;eb=1;var e=oC();Qp=n;function n(i,s){return e(i,s,"pre")}return Qp}var Zp,tb;function Wq(){if(tb)return Zp;tb=1;var e=qn(),n=Rv(),i=nC();Zp=s;function s(o,l){var u=new n,c={},f=new i,h;function p(y){var w=y.v===h?y.w:y.v,j=f.priority(w);if(j!==void 0){var _=l(y);_<j&&(c[w]=h,f.decrease(w,_))}}if(o.nodeCount()===0)return u;e.each(o.nodes(),function(y){f.add(y,Number.POSITIVE_INFINITY),u.setNode(y)}),f.decrease(o.nodes()[0],0);for(var m=!1;f.size()>0;){if(h=f.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(p)}return u}return Zp}var Jp,nb;function Gq(){return nb||(nb=1,Jp={components:Dq(),dijkstra:rC(),dijkstraAll:Fq(),findCycles:zq(),floydWarshall:Bq(),isAcyclic:Uq(),postorder:Hq(),preorder:Vq(),prim:Wq(),tarjan:iC(),topsort:sC()}),Jp}var em,rb;function Yq(){if(rb)return em;rb=1;var e=Lq();return em={Graph:e.Graph,json:$q(),alg:Gq(),version:e.version},em}var tm,ib;function Zn(){if(ib)return tm;ib=1;var e;if(typeof hv=="function")try{e=Yq()}catch{}return e||(e=window.graphlib),tm=e,tm}var nm,sb;function Kq(){if(sb)return nm;sb=1;var e=AN(),n=1,i=4;function s(o){return e(o,n|i)}return nm=s,nm}var rm,ob;function uu(){if(ob)return rm;ob=1;var e=Hs(),n=Ir(),i=eu(),s=On();function o(l,u,c){if(!s(c))return!1;var f=typeof u;return(f=="number"?n(c)&&i(u,c.length):f=="string"&&u in c)?e(c[u],l):!1}return rm=o,rm}var im,ab;function Xq(){if(ab)return im;ab=1;var e=lu(),n=Hs(),i=uu(),s=Qi(),o=Object.prototype,l=o.hasOwnProperty,u=e(function(c,f){c=Object(c);var h=-1,p=f.length,m=p>2?f[2]:void 0;for(m&&i(f[0],f[1],m)&&(p=1);++h<p;)for(var y=f[h],w=s(y),j=-1,_=w.length;++j<_;){var S=w[j],b=c[S];(b===void 0||n(b,o[S])&&!l.call(c,S))&&(c[S]=y[S])}return c});return im=u,im}var sm,lb;function Qq(){if(lb)return sm;lb=1;var e=Mr(),n=Ir(),i=pi();function s(o){return function(l,u,c){var f=Object(l);if(!n(l)){var h=e(u,3);l=i(l),u=function(m){return h(f[m],m,f)}}var p=o(l,u,c);return p>-1?f[h?l[p]:p]:void 0}}return sm=s,sm}var om,ub;function Zq(){if(ub)return om;ub=1;var e=/\s/;function n(i){for(var s=i.length;s--&&e.test(i.charAt(s)););return s}return om=n,om}var am,cb;function Jq(){if(cb)return am;cb=1;var e=Zq(),n=/^\s+/;function i(s){return s&&s.slice(0,e(s)+1).replace(n,"")}return am=i,am}var lm,db;function eL(){if(db)return lm;db=1;var e=Jq(),n=On(),i=Ys(),s=NaN,o=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;function f(h){if(typeof h=="number")return h;if(i(h))return s;if(n(h)){var p=typeof h.valueOf=="function"?h.valueOf():h;h=n(p)?p+"":p}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 lm=f,lm}var um,fb;function aC(){if(fb)return um;fb=1;var e=eL(),n=1/0,i=17976931348623157e292;function s(o){if(!o)return o===0?o:0;if(o=e(o),o===n||o===-n){var l=o<0?-1:1;return l*i}return o===o?o:0}return um=s,um}var cm,hb;function tL(){if(hb)return cm;hb=1;var e=aC();function n(i){var s=e(i),o=s%1;return s===s?o?s-o:s:0}return cm=n,cm}var dm,pb;function nL(){if(pb)return dm;pb=1;var e=JN(),n=Mr(),i=tL(),s=Math.max;function o(l,u,c){var f=l==null?0:l.length;if(!f)return-1;var h=c==null?0:i(c);return h<0&&(h=s(f+h,0)),e(l,n(u,3),h)}return dm=o,dm}var fm,mb;function rL(){if(mb)return fm;mb=1;var e=Qq(),n=nL(),i=e(n);return fm=i,fm}var hm,gb;function lC(){if(gb)return hm;gb=1;var e=jv();function n(i){var s=i==null?0:i.length;return s?e(i,1):[]}return hm=n,hm}var pm,vb;function iL(){if(vb)return pm;vb=1;var e=kv(),n=IN(),i=Qi();function s(o,l){return o==null?o:e(o,n(l),i)}return pm=s,pm}var mm,yb;function sL(){if(yb)return mm;yb=1;function e(n){var i=n==null?0:n.length;return i?n[i-1]:void 0}return mm=e,mm}var gm,wb;function oL(){if(wb)return gm;wb=1;var e=Zl(),n=Ev(),i=Mr();function s(o,l){var u={};return l=i(l,3),n(o,function(c,f,h){e(u,f,l(c,f,h))}),u}return gm=s,gm}var vm,xb;function Tv(){if(xb)return vm;xb=1;var e=Ys();function n(i,s,o){for(var l=-1,u=i.length;++l<u;){var c=i[l],f=s(c);if(f!=null&&(h===void 0?f===f&&!e(f):o(f,h)))var h=f,p=c}return p}return vm=n,vm}var ym,_b;function aL(){if(_b)return ym;_b=1;function e(n,i){return n>i}return ym=e,ym}var wm,Sb;function lL(){if(Sb)return wm;Sb=1;var e=Tv(),n=aL(),i=Zi();function s(o){return o&&o.length?e(o,i,n):void 0}return wm=s,wm}var xm,bb;function uC(){if(bb)return xm;bb=1;var e=Zl(),n=Hs();function i(s,o,l){(l!==void 0&&!n(s[o],l)||l===void 0&&!(o in s))&&e(s,o,l)}return xm=i,xm}var _m,kb;function uL(){if(kb)return _m;kb=1;var e=Ki(),n=ru(),i=dr(),s="[object Object]",o=Function.prototype,l=Object.prototype,u=o.toString,c=l.hasOwnProperty,f=u.call(Object);function h(p){if(!i(p)||e(p)!=s)return!1;var m=n(p);if(m===null)return!0;var y=c.call(m,"constructor")&&m.constructor;return typeof y=="function"&&y instanceof y&&u.call(y)==f}return _m=h,_m}var Sm,Eb;function cC(){if(Eb)return Sm;Eb=1;function e(n,i){if(!(i==="constructor"&&typeof n[i]=="function")&&i!="__proto__")return n[i]}return Sm=e,Sm}var bm,Nb;function cL(){if(Nb)return bm;Nb=1;var e=ia(),n=Qi();function i(s){return e(s,n(s))}return bm=i,bm}var km,Cb;function dL(){if(Cb)return km;Cb=1;var e=uC(),n=wN(),i=jN(),s=xN(),o=TN(),l=sa(),u=St(),c=eC(),f=Ws(),h=ra(),p=On(),m=uL(),y=oa(),w=cC(),j=cL();function _(S,b,E,N,C,I,O){var P=w(S,E),z=w(b,E),T=O.get(z);if(T){e(S,E,T);return}var q=I?I(P,z,E+"",S,b,O):void 0,B=q===void 0;if(B){var Z=u(z),Q=!Z&&f(z),A=!Z&&!Q&&y(z);q=z,Z||Q||A?u(P)?q=P:c(P)?q=s(P):Q?(B=!1,q=n(z,!0)):A?(B=!1,q=i(z,!0)):q=[]:m(z)||l(z)?(q=P,l(P)?q=j(P):(!p(P)||h(P))&&(q=o(z))):B=!1}B&&(O.set(z,q),C(q,z,N,I,O),O.delete(z)),e(S,E,q)}return km=_,km}var Em,jb;function fL(){if(jb)return Em;jb=1;var e=Ql(),n=uC(),i=kv(),s=dL(),o=On(),l=Qi(),u=cC();function c(f,h,p,m,y){f!==h&&i(h,function(w,j){if(y||(y=new e),o(w))s(f,h,j,p,c,m,y);else{var _=m?m(u(f,j),w,j+"",f,h,y):void 0;_===void 0&&(_=w),n(f,j,_)}},l)}return Em=c,Em}var Nm,Rb;function hL(){if(Rb)return Nm;Rb=1;var e=lu(),n=uu();function i(s){return e(function(o,l){var u=-1,c=l.length,f=c>1?l[c-1]:void 0,h=c>2?l[2]:void 0;for(f=s.length>3&&typeof f=="function"?(c--,f):void 0,h&&n(l[0],l[1],h)&&(f=c<3?void 0:f,c=1),o=Object(o);++u<c;){var p=l[u];p&&s(o,p,u,f)}return o})}return Nm=i,Nm}var Cm,Tb;function pL(){if(Tb)return Cm;Tb=1;var e=fL(),n=hL(),i=n(function(s,o,l){e(s,o,l)});return Cm=i,Cm}var jm,Ab;function dC(){if(Ab)return jm;Ab=1;function e(n,i){return n<i}return jm=e,jm}var Rm,Ib;function mL(){if(Ib)return Rm;Ib=1;var e=Tv(),n=dC(),i=Zi();function s(o){return o&&o.length?e(o,i,n):void 0}return Rm=s,Rm}var Tm,Mb;function gL(){if(Mb)return Tm;Mb=1;var e=Tv(),n=Mr(),i=dC();function s(o,l){return o&&o.length?e(o,n(l,2),i):void 0}return Tm=s,Tm}var Am,Pb;function vL(){if(Pb)return Am;Pb=1;var e=er(),n=function(){return e.Date.now()};return Am=n,Am}var Im,Ob;function yL(){if(Ob)return Im;Ob=1;var e=Jl(),n=ou(),i=eu(),s=On(),o=aa();function l(u,c,f,h){if(!s(u))return u;c=n(c,u);for(var p=-1,m=c.length,y=m-1,w=u;w!=null&&++p<m;){var j=o(c[p]),_=f;if(j==="__proto__"||j==="constructor"||j==="prototype")return u;if(p!=y){var S=w[j];_=h?h(S,j,w):void 0,_===void 0&&(_=s(S)?S:i(c[p+1])?[]:{})}e(w,j,_),w=w[j]}return u}return Im=l,Im}var Mm,qb;function wL(){if(qb)return Mm;qb=1;var e=au(),n=yL(),i=ou();function s(o,l,u){for(var c=-1,f=l.length,h={};++c<f;){var p=l[c],m=e(o,p);u(m,p)&&n(h,i(p,o),m)}return h}return Mm=s,Mm}var Pm,Lb;function xL(){if(Lb)return Pm;Lb=1;var e=wL(),n=UN();function i(s,o){return e(s,o,function(l,u){return n(s,u)})}return Pm=i,Pm}var Om,$b;function _L(){if($b)return Om;$b=1;var e=lC(),n=QN(),i=ZN();function s(o){return i(n(o,void 0,e),o+"")}return Om=s,Om}var qm,Db;function SL(){if(Db)return qm;Db=1;var e=xL(),n=_L(),i=n(function(s,o){return s==null?{}:e(s,o)});return qm=i,qm}var Lm,Fb;function bL(){if(Fb)return Lm;Fb=1;var e=Math.ceil,n=Math.max;function i(s,o,l,u){for(var c=-1,f=n(e((o-s)/(l||1)),0),h=Array(f);f--;)h[u?f:++c]=s,s+=l;return h}return Lm=i,Lm}var $m,zb;function kL(){if(zb)return $m;zb=1;var e=bL(),n=uu(),i=aC();function s(o){return function(l,u,c){return c&&typeof c!="number"&&n(l,u,c)&&(u=c=void 0),l=i(l),u===void 0?(u=l,l=0):u=i(u),c=c===void 0?l<u?1:-1:i(c),e(l,u,c,o)}}return $m=s,$m}var Dm,Bb;function EL(){if(Bb)return Dm;Bb=1;var e=kL(),n=e();return Dm=n,Dm}var Fm,Ub;function NL(){if(Ub)return Fm;Ub=1;function e(n,i){var s=n.length;for(n.sort(i);s--;)n[s]=n[s].value;return n}return Fm=e,Fm}var zm,Hb;function CL(){if(Hb)return zm;Hb=1;var e=Ys();function n(i,s){if(i!==s){var o=i!==void 0,l=i===null,u=i===i,c=e(i),f=s!==void 0,h=s===null,p=s===s,m=e(s);if(!h&&!m&&!c&&i>s||c&&f&&p&&!h&&!m||l&&f&&p||!o&&p||!u)return 1;if(!l&&!c&&!m&&i<s||m&&o&&u&&!l&&!c||h&&o&&u||!f&&u||!p)return-1}return 0}return zm=n,zm}var Bm,Vb;function jL(){if(Vb)return Bm;Vb=1;var e=CL();function n(i,s,o){for(var l=-1,u=i.criteria,c=s.criteria,f=u.length,h=o.length;++l<f;){var p=e(u[l],c[l]);if(p){if(l>=h)return p;var m=o[l];return p*(m=="desc"?-1:1)}}return i.index-s.index}return Bm=n,Bm}var Um,Wb;function RL(){if(Wb)return Um;Wb=1;var e=su(),n=au(),i=Mr(),s=YN(),o=NL(),l=tu(),u=jL(),c=Zi(),f=St();function h(p,m,y){m.length?m=e(m,function(_){return f(_)?function(S){return n(S,_.length===1?_[0]:_)}:_}):m=[c];var w=-1;m=e(m,l(i));var j=s(p,function(_,S,b){var E=e(m,function(N){return N(_)});return{criteria:E,index:++w,value:_}});return o(j,function(_,S){return u(_,S,y)})}return Um=h,Um}var Hm,Gb;function TL(){if(Gb)return Hm;Gb=1;var e=jv(),n=RL(),i=lu(),s=uu(),o=i(function(l,u){if(l==null)return[];var c=u.length;return c>1&&s(l,u[0],u[1])?u=[]:c>2&&s(u[0],u[1],u[2])&&(u=[u[0]]),n(l,e(u,1),[])});return Hm=o,Hm}var Vm,Yb;function AL(){if(Yb)return Vm;Yb=1;var e=zN(),n=0;function i(s){var o=++n;return e(s)+o}return Vm=i,Vm}var Wm,Kb;function IL(){if(Kb)return Wm;Kb=1;function e(n,i,s){for(var o=-1,l=n.length,u=i.length,c={};++o<l;){var f=o<u?i[o]:void 0;s(c,n[o],f)}return c}return Wm=e,Wm}var Gm,Xb;function ML(){if(Xb)return Gm;Xb=1;var e=Jl(),n=IL();function i(s,o){return n(s||[],o||[],e)}return Gm=i,Gm}var Ym,Qb;function at(){if(Qb)return Ym;Qb=1;var e;if(typeof hv=="function")try{e={cloneDeep:Kq(),constant:bv(),defaults:Xq(),each:PN(),filter:VN(),find:rL(),flatten:lC(),forEach:MN(),forIn:iL(),has:WN(),isUndefined:GN(),last:sL(),map:KN(),mapValues:oL(),max:lL(),merge:pL(),min:mL(),minBy:gL(),now:vL(),pick:SL(),range:EL(),reduce:XN(),sortBy:TL(),uniqueId:AL(),values:tC(),zipObject:ML()}}catch{}return e||(e=window._),Ym=e,Ym}var Km,Zb;function PL(){if(Zb)return Km;Zb=1,Km=e;function e(){var s={};s._next=s._prev=s,this._sentinel=s}e.prototype.dequeue=function(){var s=this._sentinel,o=s._prev;if(o!==s)return n(o),o},e.prototype.enqueue=function(s){var o=this._sentinel;s._prev&&s._next&&n(s),s._next=o._next,o._next._prev=s,o._next=s,s._prev=o},e.prototype.toString=function(){for(var s=[],o=this._sentinel,l=o._prev;l!==o;)s.push(JSON.stringify(l,i)),l=l._prev;return"["+s.join(", ")+"]"};function n(s){s._prev._next=s._next,s._next._prev=s._prev,delete s._next,delete s._prev}function i(s,o){if(s!=="_next"&&s!=="_prev")return o}return Km}var Xm,Jb;function OL(){if(Jb)return Xm;Jb=1;var e=at(),n=Zn().Graph,i=PL();Xm=o;var s=e.constant(1);function o(h,p){if(h.nodeCount()<=1)return[];var m=c(h,p||s),y=l(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(w){return h.outEdges(w.v,w.w)}),!0)}function l(h,p,m){for(var y=[],w=p[p.length-1],j=p[0],_;h.nodeCount();){for(;_=j.dequeue();)u(h,p,m,_);for(;_=w.dequeue();)u(h,p,m,_);if(h.nodeCount()){for(var S=p.length-2;S>0;--S)if(_=p[S].dequeue(),_){y=y.concat(u(h,p,m,_,!0));break}}}return y}function u(h,p,m,y,w){var j=w?[]:void 0;return e.forEach(h.inEdges(y.v),function(_){var S=h.edge(_),b=h.node(_.v);w&&j.push({v:_.v,w:_.w}),b.out-=S,f(p,m,b)}),e.forEach(h.outEdges(y.v),function(_){var S=h.edge(_),b=_.w,E=h.node(b);E.in-=S,f(p,m,E)}),h.removeNode(y.v),j}function c(h,p){var m=new n,y=0,w=0;e.forEach(h.nodes(),function(S){m.setNode(S,{v:S,in:0,out:0})}),e.forEach(h.edges(),function(S){var b=m.edge(S.v,S.w)||0,E=p(S),N=b+E;m.setEdge(S.v,S.w,N),w=Math.max(w,m.node(S.v).out+=E),y=Math.max(y,m.node(S.w).in+=E)});var j=e.range(w+y+3).map(function(){return new i}),_=y+1;return e.forEach(m.nodes(),function(S){f(j,_,m.node(S))}),{graph:m,buckets:j,zeroIdx:_}}function f(h,p,m){m.out?m.in?h[m.out-m.in+p].enqueue(m):h[h.length-1].enqueue(m):h[0].enqueue(m)}return Xm}var Qm,ek;function qL(){if(ek)return Qm;ek=1;var e=at(),n=OL();Qm={run:i,undo:o};function i(l){var u=l.graph().acyclicer==="greedy"?n(l,c(l)):s(l);e.forEach(u,function(f){var h=l.edge(f);l.removeEdge(f),h.forwardName=f.name,h.reversed=!0,l.setEdge(f.w,f.v,h,e.uniqueId("rev"))});function c(f){return function(h){return f.edge(h).weight}}}function s(l){var u=[],c={},f={};function h(p){e.has(f,p)||(f[p]=!0,c[p]=!0,e.forEach(l.outEdges(p),function(m){e.has(c,m.w)?u.push(m):h(m.w)}),delete c[p])}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 f=c.forwardName;delete c.reversed,delete c.forwardName,l.setEdge(u.w,u.v,c,f)}})}return Qm}var Zm,tk;function hn(){if(tk)return Zm;tk=1;var e=at(),n=Zn().Graph;Zm={addDummyNode:i,simplify:s,asNonCompoundGraph:o,successorWeights:l,predecessorWeights:u,intersectRect:c,buildLayerMatrix:f,normalizeRanks:h,removeEmptyRanks:p,addBorderNode:m,maxRank:y,partition:w,time:j,notime:_};function i(S,b,E,N){var C;do C=e.uniqueId(N);while(S.hasNode(C));return E.dummy=b,S.setNode(C,E),C}function s(S){var b=new n().setGraph(S.graph());return e.forEach(S.nodes(),function(E){b.setNode(E,S.node(E))}),e.forEach(S.edges(),function(E){var N=b.edge(E.v,E.w)||{weight:0,minlen:1},C=S.edge(E);b.setEdge(E.v,E.w,{weight:N.weight+C.weight,minlen:Math.max(N.minlen,C.minlen)})}),b}function o(S){var b=new n({multigraph:S.isMultigraph()}).setGraph(S.graph());return e.forEach(S.nodes(),function(E){S.children(E).length||b.setNode(E,S.node(E))}),e.forEach(S.edges(),function(E){b.setEdge(E,S.edge(E))}),b}function l(S){var b=e.map(S.nodes(),function(E){var N={};return e.forEach(S.outEdges(E),function(C){N[C.w]=(N[C.w]||0)+S.edge(C).weight}),N});return e.zipObject(S.nodes(),b)}function u(S){var b=e.map(S.nodes(),function(E){var N={};return e.forEach(S.inEdges(E),function(C){N[C.v]=(N[C.v]||0)+S.edge(C).weight}),N});return e.zipObject(S.nodes(),b)}function c(S,b){var E=S.x,N=S.y,C=b.x-E,I=b.y-N,O=S.width/2,P=S.height/2;if(!C&&!I)throw new Error("Not possible to find intersection inside of the rectangle");var z,T;return Math.abs(I)*O>Math.abs(C)*P?(I<0&&(P=-P),z=P*C/I,T=P):(C<0&&(O=-O),z=O,T=O*I/C),{x:E+z,y:N+T}}function f(S){var b=e.map(e.range(y(S)+1),function(){return[]});return e.forEach(S.nodes(),function(E){var N=S.node(E),C=N.rank;e.isUndefined(C)||(b[C][N.order]=E)}),b}function h(S){var b=e.min(e.map(S.nodes(),function(E){return S.node(E).rank}));e.forEach(S.nodes(),function(E){var N=S.node(E);e.has(N,"rank")&&(N.rank-=b)})}function p(S){var b=e.min(e.map(S.nodes(),function(I){return S.node(I).rank})),E=[];e.forEach(S.nodes(),function(I){var O=S.node(I).rank-b;E[O]||(E[O]=[]),E[O].push(I)});var N=0,C=S.graph().nodeRankFactor;e.forEach(E,function(I,O){e.isUndefined(I)&&O%C!==0?--N:N&&e.forEach(I,function(P){S.node(P).rank+=N})})}function m(S,b,E,N){var C={width:0,height:0};return arguments.length>=4&&(C.rank=E,C.order=N),i(S,"border",C,b)}function y(S){return e.max(e.map(S.nodes(),function(b){var E=S.node(b).rank;if(!e.isUndefined(E))return E}))}function w(S,b){var E={lhs:[],rhs:[]};return e.forEach(S,function(N){b(N)?E.lhs.push(N):E.rhs.push(N)}),E}function j(S,b){var E=e.now();try{return b()}finally{console.log(S+" time: "+(e.now()-E)+"ms")}}function _(S,b){return b()}return Zm}var Jm,nk;function LL(){if(nk)return Jm;nk=1;var e=at(),n=hn();Jm={run:i,undo:o};function i(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(u){s(l,u)})}function s(l,u){var c=u.v,f=l.node(c).rank,h=u.w,p=l.node(h).rank,m=u.name,y=l.edge(u),w=y.labelRank;if(p!==f+1){l.removeEdge(u);var j,_,S;for(S=0,++f;f<p;++S,++f)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:u,rank:f},j=n.addDummyNode(l,"edge",_,"_d"),f===w&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),l.setEdge(c,j,{weight:y.weight},m),S===0&&l.graph().dummyChains.push(j),c=j;l.setEdge(c,h,{weight:y.weight},m)}}function o(l){e.forEach(l.graph().dummyChains,function(u){var c=l.node(u),f=c.edgeLabel,h;for(l.setEdge(c.edgeObj,f);c.dummy;)h=l.successors(u)[0],l.removeNode(u),f.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(f.x=c.x,f.y=c.y,f.width=c.width,f.height=c.height),u=h,c=l.node(u)})}return Jm}var eg,rk;function Dl(){if(rk)return eg;rk=1;var e=at();eg={longestPath:n,slack:i};function n(s){var o={};function l(u){var c=s.node(u);if(e.has(o,u))return c.rank;o[u]=!0;var f=e.min(e.map(s.outEdges(u),function(h){return l(h.w)-s.edge(h).minlen}));return(f===Number.POSITIVE_INFINITY||f===void 0||f===null)&&(f=0),c.rank=f}e.forEach(s.sources(),l)}function i(s,o){return s.node(o.w).rank-s.node(o.v).rank-s.edge(o).minlen}return eg}var tg,ik;function fC(){if(ik)return tg;ik=1;var e=at(),n=Zn().Graph,i=Dl().slack;tg=s;function s(c){var f=new n({directed:!1}),h=c.nodes()[0],p=c.nodeCount();f.setNode(h,{});for(var m,y;o(f,c)<p;)m=l(f,c),y=f.hasNode(m.v)?i(c,m):-i(c,m),u(f,c,y);return f}function o(c,f){function h(p){e.forEach(f.nodeEdges(p),function(m){var y=m.v,w=p===y?m.w:y;!c.hasNode(w)&&!i(f,m)&&(c.setNode(w,{}),c.setEdge(p,w,{}),h(w))})}return e.forEach(c.nodes(),h),c.nodeCount()}function l(c,f){return e.minBy(f.edges(),function(h){if(c.hasNode(h.v)!==c.hasNode(h.w))return i(f,h)})}function u(c,f,h){e.forEach(c.nodes(),function(p){f.node(p).rank+=h})}return tg}var ng,sk;function $L(){if(sk)return ng;sk=1;var e=at(),n=fC(),i=Dl().slack,s=Dl().longestPath,o=Zn().alg.preorder,l=Zn().alg.postorder,u=hn().simplify;ng=c,c.initLowLimValues=m,c.initCutValues=f,c.calcCutValue=p,c.leaveEdge=w,c.enterEdge=j,c.exchangeEdges=_;function c(N){N=u(N),s(N);var C=n(N);m(C),f(C,N);for(var I,O;I=w(C);)O=j(C,N,I),_(C,N,I,O)}function f(N,C){var I=l(N,N.nodes());I=I.slice(0,I.length-1),e.forEach(I,function(O){h(N,C,O)})}function h(N,C,I){var O=N.node(I),P=O.parent;N.edge(I,P).cutvalue=p(N,C,I)}function p(N,C,I){var O=N.node(I),P=O.parent,z=!0,T=C.edge(I,P),q=0;return T||(z=!1,T=C.edge(P,I)),q=T.weight,e.forEach(C.nodeEdges(I),function(B){var Z=B.v===I,Q=Z?B.w:B.v;if(Q!==P){var A=Z===z,H=C.edge(B).weight;if(q+=A?H:-H,b(N,I,Q)){var U=N.edge(I,Q).cutvalue;q+=A?-U:U}}}),q}function m(N,C){arguments.length<2&&(C=N.nodes()[0]),y(N,{},1,C)}function y(N,C,I,O,P){var z=I,T=N.node(O);return C[O]=!0,e.forEach(N.neighbors(O),function(q){e.has(C,q)||(I=y(N,C,I,q,O))}),T.low=z,T.lim=I++,P?T.parent=P:delete T.parent,I}function w(N){return e.find(N.edges(),function(C){return N.edge(C).cutvalue<0})}function j(N,C,I){var O=I.v,P=I.w;C.hasEdge(O,P)||(O=I.w,P=I.v);var z=N.node(O),T=N.node(P),q=z,B=!1;z.lim>T.lim&&(q=T,B=!0);var Z=e.filter(C.edges(),function(Q){return B===E(N,N.node(Q.v),q)&&B!==E(N,N.node(Q.w),q)});return e.minBy(Z,function(Q){return i(C,Q)})}function _(N,C,I,O){var P=I.v,z=I.w;N.removeEdge(P,z),N.setEdge(O.v,O.w,{}),m(N),f(N,C),S(N,C)}function S(N,C){var I=e.find(N.nodes(),function(P){return!C.node(P).parent}),O=o(N,I);O=O.slice(1),e.forEach(O,function(P){var z=N.node(P).parent,T=C.edge(P,z),q=!1;T||(T=C.edge(z,P),q=!0),C.node(P).rank=C.node(z).rank+(q?T.minlen:-T.minlen)})}function b(N,C,I){return N.hasEdge(C,I)}function E(N,C,I){return I.low<=C.lim&&C.lim<=I.lim}return ng}var rg,ok;function DL(){if(ok)return rg;ok=1;var e=Dl(),n=e.longestPath,i=fC(),s=$L();rg=o;function o(f){switch(f.graph().ranker){case"network-simplex":c(f);break;case"tight-tree":u(f);break;case"longest-path":l(f);break;default:c(f)}}var l=n;function u(f){n(f),i(f)}function c(f){s(f)}return rg}var ig,ak;function FL(){if(ak)return ig;ak=1;var e=at();ig=n;function n(o){var l=s(o);e.forEach(o.graph().dummyChains,function(u){for(var c=o.node(u),f=c.edgeObj,h=i(o,l,f.v,f.w),p=h.path,m=h.lca,y=0,w=p[y],j=!0;u!==f.w;){if(c=o.node(u),j){for(;(w=p[y])!==m&&o.node(w).maxRank<c.rank;)y++;w===m&&(j=!1)}if(!j){for(;y<p.length-1&&o.node(w=p[y+1]).minRank<=c.rank;)y++;w=p[y]}o.setParent(u,w),u=o.successors(u)[0]}})}function i(o,l,u,c){var f=[],h=[],p=Math.min(l[u].low,l[c].low),m=Math.max(l[u].lim,l[c].lim),y,w;y=u;do y=o.parent(y),f.push(y);while(y&&(l[y].low>p||m>l[y].lim));for(w=y,y=c;(y=o.parent(y))!==w;)h.push(y);return{path:f.concat(h.reverse()),lca:w}}function s(o){var l={},u=0;function c(f){var h=u;e.forEach(o.children(f),c),l[f]={low:h,lim:u++}}return e.forEach(o.children(),c),l}return ig}var sg,lk;function zL(){if(lk)return sg;lk=1;var e=at(),n=hn();sg={run:i,cleanup:u};function i(c){var f=n.addDummyNode(c,"root",{},"_root"),h=o(c),p=e.max(e.values(h))-1,m=2*p+1;c.graph().nestingRoot=f,e.forEach(c.edges(),function(w){c.edge(w).minlen*=m});var y=l(c)+1;e.forEach(c.children(),function(w){s(c,f,m,y,p,h,w)}),c.graph().nodeRankFactor=m}function s(c,f,h,p,m,y,w){var j=c.children(w);if(!j.length){w!==f&&c.setEdge(f,w,{weight:0,minlen:h});return}var _=n.addBorderNode(c,"_bt"),S=n.addBorderNode(c,"_bb"),b=c.node(w);c.setParent(_,w),b.borderTop=_,c.setParent(S,w),b.borderBottom=S,e.forEach(j,function(E){s(c,f,h,p,m,y,E);var N=c.node(E),C=N.borderTop?N.borderTop:E,I=N.borderBottom?N.borderBottom:E,O=N.borderTop?p:2*p,P=C!==I?1:m-y[w]+1;c.setEdge(_,C,{weight:O,minlen:P,nestingEdge:!0}),c.setEdge(I,S,{weight:O,minlen:P,nestingEdge:!0})}),c.parent(w)||c.setEdge(f,_,{weight:0,minlen:m+y[w]})}function o(c){var f={};function h(p,m){var y=c.children(p);y&&y.length&&e.forEach(y,function(w){h(w,m+1)}),f[p]=m}return e.forEach(c.children(),function(p){h(p,1)}),f}function l(c){return e.reduce(c.edges(),function(f,h){return f+c.edge(h).weight},0)}function u(c){var f=c.graph();c.removeNode(f.nestingRoot),delete f.nestingRoot,e.forEach(c.edges(),function(h){var p=c.edge(h);p.nestingEdge&&c.removeEdge(h)})}return sg}var og,uk;function BL(){if(uk)return og;uk=1;var e=at(),n=hn();og=i;function i(o){function l(u){var c=o.children(u),f=o.node(u);if(c.length&&e.forEach(c,l),e.has(f,"minRank")){f.borderLeft=[],f.borderRight=[];for(var h=f.minRank,p=f.maxRank+1;h<p;++h)s(o,"borderLeft","_bl",u,f,h),s(o,"borderRight","_br",u,f,h)}}e.forEach(o.children(),l)}function s(o,l,u,c,f,h){var p={width:0,height:0,rank:h,borderType:l},m=f[l][h-1],y=n.addDummyNode(o,"border",p,u);f[l][h]=y,o.setParent(y,c),m&&o.setEdge(m,y,{weight:1})}return og}var ag,ck;function UL(){if(ck)return ag;ck=1;var e=at();ag={adjust:n,undo:i};function n(h){var p=h.graph().rankdir.toLowerCase();(p==="lr"||p==="rl")&&s(h)}function i(h){var p=h.graph().rankdir.toLowerCase();(p==="bt"||p==="rl")&&l(h),(p==="lr"||p==="rl")&&(c(h),s(h))}function s(h){e.forEach(h.nodes(),function(p){o(h.node(p))}),e.forEach(h.edges(),function(p){o(h.edge(p))})}function o(h){var p=h.width;h.width=h.height,h.height=p}function l(h){e.forEach(h.nodes(),function(p){u(h.node(p))}),e.forEach(h.edges(),function(p){var m=h.edge(p);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(p){f(h.node(p))}),e.forEach(h.edges(),function(p){var m=h.edge(p);e.forEach(m.points,f),e.has(m,"x")&&f(m)})}function f(h){var p=h.x;h.x=h.y,h.y=p}return ag}var lg,dk;function HL(){if(dk)return lg;dk=1;var e=at();lg=n;function n(i){var s={},o=e.filter(i.nodes(),function(h){return!i.children(h).length}),l=e.max(e.map(o,function(h){return i.node(h).rank})),u=e.map(e.range(l+1),function(){return[]});function c(h){if(!e.has(s,h)){s[h]=!0;var p=i.node(h);u[p.rank].push(h),e.forEach(i.successors(h),c)}}var f=e.sortBy(o,function(h){return i.node(h).rank});return e.forEach(f,c),u}return lg}var ug,fk;function VL(){if(fk)return ug;fk=1;var e=at();ug=n;function n(s,o){for(var l=0,u=1;u<o.length;++u)l+=i(s,o[u-1],o[u]);return l}function i(s,o,l){for(var u=e.zipObject(l,e.map(l,function(y,w){return w})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(s.outEdges(y),function(w){return{pos:u[w.w],weight:s.edge(w).weight}}),"pos")}),!0),f=1;f<l.length;)f<<=1;var h=2*f-1;f-=1;var p=e.map(new Array(h),function(){return 0}),m=0;return e.forEach(c.forEach(function(y){var w=y.pos+f;p[w]+=y.weight;for(var j=0;w>0;)w%2&&(j+=p[w+1]),w=w-1>>1,p[w]+=y.weight;m+=y.weight*j})),m}return ug}var cg,hk;function WL(){if(hk)return cg;hk=1;var e=at();cg=n;function n(i,s){return e.map(s,function(o){var l=i.inEdges(o);if(l.length){var u=e.reduce(l,function(c,f){var h=i.edge(f),p=i.node(f.v);return{sum:c.sum+h.weight*p.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 cg}var dg,pk;function GL(){if(pk)return dg;pk=1;var e=at();dg=n;function n(o,l){var u={};e.forEach(o,function(f,h){var p=u[f.v]={indegree:0,in:[],out:[],vs:[f.v],i:h};e.isUndefined(f.barycenter)||(p.barycenter=f.barycenter,p.weight=f.weight)}),e.forEach(l.edges(),function(f){var h=u[f.v],p=u[f.w];!e.isUndefined(h)&&!e.isUndefined(p)&&(p.indegree++,h.out.push(u[f.w]))});var c=e.filter(u,function(f){return!f.indegree});return i(c)}function i(o){var l=[];function u(h){return function(p){p.merged||(e.isUndefined(p.barycenter)||e.isUndefined(h.barycenter)||p.barycenter>=h.barycenter)&&s(h,p)}}function c(h){return function(p){p.in.push(h),--p.indegree===0&&o.push(p)}}for(;o.length;){var f=o.pop();l.push(f),e.forEach(f.in.reverse(),u(f)),e.forEach(f.out,c(f))}return e.map(e.filter(l,function(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 dg}var fg,mk;function YL(){if(mk)return fg;mk=1;var e=at(),n=hn();fg=i;function i(l,u){var c=n.partition(l,function(_){return e.has(_,"barycenter")}),f=c.lhs,h=e.sortBy(c.rhs,function(_){return-_.i}),p=[],m=0,y=0,w=0;f.sort(o(!!u)),w=s(p,h,w),e.forEach(f,function(_){w+=_.vs.length,p.push(_.vs),m+=_.barycenter*_.weight,y+=_.weight,w=s(p,h,w)});var j={vs:e.flatten(p,!0)};return y&&(j.barycenter=m/y,j.weight=y),j}function s(l,u,c){for(var f;u.length&&(f=e.last(u)).i<=c;)u.pop(),l.push(f.vs),c++;return c}function o(l){return function(u,c){return u.barycenter<c.barycenter?-1:u.barycenter>c.barycenter?1:l?c.i-u.i:u.i-c.i}}return fg}var hg,gk;function KL(){if(gk)return hg;gk=1;var e=at(),n=WL(),i=GL(),s=YL();hg=o;function o(c,f,h,p){var m=c.children(f),y=c.node(f),w=y?y.borderLeft:void 0,j=y?y.borderRight:void 0,_={};w&&(m=e.filter(m,function(I){return I!==w&&I!==j}));var S=n(c,m);e.forEach(S,function(I){if(c.children(I.v).length){var O=o(c,I.v,h,p);_[I.v]=O,e.has(O,"barycenter")&&u(I,O)}});var b=i(S,h);l(b,_);var E=s(b,p);if(w&&(E.vs=e.flatten([w,E.vs,j],!0),c.predecessors(w).length)){var N=c.node(c.predecessors(w)[0]),C=c.node(c.predecessors(j)[0]);e.has(E,"barycenter")||(E.barycenter=0,E.weight=0),E.barycenter=(E.barycenter*E.weight+N.order+C.order)/(E.weight+2),E.weight+=2}return E}function l(c,f){e.forEach(c,function(h){h.vs=e.flatten(h.vs.map(function(p){return f[p]?f[p].vs:p}),!0)})}function u(c,f){e.isUndefined(c.barycenter)?(c.barycenter=f.barycenter,c.weight=f.weight):(c.barycenter=(c.barycenter*c.weight+f.barycenter*f.weight)/(c.weight+f.weight),c.weight+=f.weight)}return hg}var pg,vk;function XL(){if(vk)return pg;vk=1;var e=at(),n=Zn().Graph;pg=i;function i(o,l,u){var c=s(o),f=new n({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(h){return o.node(h)});return e.forEach(o.nodes(),function(h){var p=o.node(h),m=o.parent(h);(p.rank===l||p.minRank<=l&&l<=p.maxRank)&&(f.setNode(h),f.setParent(h,m||c),e.forEach(o[u](h),function(y){var w=y.v===h?y.w:y.v,j=f.edge(w,h),_=e.isUndefined(j)?0:j.weight;f.setEdge(w,h,{weight:o.edge(y).weight+_})}),e.has(p,"minRank")&&f.setNode(h,{borderLeft:p.borderLeft[l],borderRight:p.borderRight[l]}))}),f}function s(o){for(var l;o.hasNode(l=e.uniqueId("_root")););return l}return pg}var mg,yk;function QL(){if(yk)return mg;yk=1;var e=at();mg=n;function n(i,s,o){var l={},u;e.forEach(o,function(c){for(var f=i.parent(c),h,p;f;){if(h=i.parent(f),h?(p=l[h],l[h]=f):(p=u,u=f),p&&p!==f){s.setEdge(p,f);return}f=h}})}return mg}var gg,wk;function ZL(){if(wk)return gg;wk=1;var e=at(),n=HL(),i=VL(),s=KL(),o=XL(),l=QL(),u=Zn().Graph,c=hn();gg=f;function f(y){var w=c.maxRank(y),j=h(y,e.range(1,w+1),"inEdges"),_=h(y,e.range(w-1,-1,-1),"outEdges"),S=n(y);m(y,S);for(var b=Number.POSITIVE_INFINITY,E,N=0,C=0;C<4;++N,++C){p(N%2?j:_,N%4>=2),S=c.buildLayerMatrix(y);var I=i(y,S);I<b&&(C=0,E=e.cloneDeep(S),b=I)}m(y,E)}function h(y,w,j){return e.map(w,function(_){return o(y,_,j)})}function p(y,w){var j=new u;e.forEach(y,function(_){var S=_.graph().root,b=s(_,S,j,w);e.forEach(b.vs,function(E,N){_.node(E).order=N}),l(_,j,b.vs)})}function m(y,w){e.forEach(w,function(j){e.forEach(j,function(_,S){y.node(_).order=S})})}return gg}var vg,xk;function JL(){if(xk)return vg;xk=1;var e=at(),n=Zn().Graph,i=hn();vg={positionX:j,findType1Conflicts:s,findType2Conflicts:o,addConflict:u,hasConflict:c,verticalAlignment:f,horizontalCompaction:h,alignCoordinates:y,findSmallestWidthAlignment:m,balance:w};function s(b,E){var N={};function C(I,O){var P=0,z=0,T=I.length,q=e.last(O);return e.forEach(O,function(B,Z){var Q=l(b,B),A=Q?b.node(Q).order:T;(Q||B===q)&&(e.forEach(O.slice(z,Z+1),function(H){e.forEach(b.predecessors(H),function(U){var ne=b.node(U),Y=ne.order;(Y<P||A<Y)&&!(ne.dummy&&b.node(H).dummy)&&u(N,U,H)})}),z=Z+1,P=A)}),O}return e.reduce(E,C),N}function o(b,E){var N={};function C(O,P,z,T,q){var B;e.forEach(e.range(P,z),function(Z){B=O[Z],b.node(B).dummy&&e.forEach(b.predecessors(B),function(Q){var A=b.node(Q);A.dummy&&(A.order<T||A.order>q)&&u(N,Q,B)})})}function I(O,P){var z=-1,T,q=0;return e.forEach(P,function(B,Z){if(b.node(B).dummy==="border"){var Q=b.predecessors(B);Q.length&&(T=b.node(Q[0]).order,C(P,q,Z,z,T),q=Z,z=T)}C(P,q,P.length,T,O.length)}),P}return e.reduce(E,I),N}function l(b,E){if(b.node(E).dummy)return e.find(b.predecessors(E),function(N){return b.node(N).dummy})}function u(b,E,N){if(E>N){var C=E;E=N,N=C}var I=b[E];I||(b[E]=I={}),I[N]=!0}function c(b,E,N){if(E>N){var C=E;E=N,N=C}return e.has(b[E],N)}function f(b,E,N,C){var I={},O={},P={};return e.forEach(E,function(z){e.forEach(z,function(T,q){I[T]=T,O[T]=T,P[T]=q})}),e.forEach(E,function(z){var T=-1;e.forEach(z,function(q){var B=C(q);if(B.length){B=e.sortBy(B,function(U){return P[U]});for(var Z=(B.length-1)/2,Q=Math.floor(Z),A=Math.ceil(Z);Q<=A;++Q){var H=B[Q];O[q]===q&&T<P[H]&&!c(N,q,H)&&(O[H]=q,O[q]=I[q]=I[H],T=P[H])}}})}),{root:I,align:O}}function h(b,E,N,C,I){var O={},P=p(b,E,N,I),z=I?"borderLeft":"borderRight";function T(Z,Q){for(var A=P.nodes(),H=A.pop(),U={};H;)U[H]?Z(H):(U[H]=!0,A.push(H),A=A.concat(Q(H))),H=A.pop()}function q(Z){O[Z]=P.inEdges(Z).reduce(function(Q,A){return Math.max(Q,O[A.v]+P.edge(A))},0)}function B(Z){var Q=P.outEdges(Z).reduce(function(H,U){return Math.min(H,O[U.w]-P.edge(U))},Number.POSITIVE_INFINITY),A=b.node(Z);Q!==Number.POSITIVE_INFINITY&&A.borderType!==z&&(O[Z]=Math.max(O[Z],Q))}return T(q,P.predecessors.bind(P)),T(B,P.successors.bind(P)),e.forEach(C,function(Z){O[Z]=O[N[Z]]}),O}function p(b,E,N,C){var I=new n,O=b.graph(),P=_(O.nodesep,O.edgesep,C);return e.forEach(E,function(z){var T;e.forEach(z,function(q){var B=N[q];if(I.setNode(B),T){var Z=N[T],Q=I.edge(Z,B);I.setEdge(Z,B,Math.max(P(b,q,T),Q||0))}T=q})}),I}function m(b,E){return e.minBy(e.values(E),function(N){var C=Number.NEGATIVE_INFINITY,I=Number.POSITIVE_INFINITY;return e.forIn(N,function(O,P){var z=S(b,P)/2;C=Math.max(O+z,C),I=Math.min(O-z,I)}),C-I})}function y(b,E){var N=e.values(E),C=e.min(N),I=e.max(N);e.forEach(["u","d"],function(O){e.forEach(["l","r"],function(P){var z=O+P,T=b[z],q;if(T!==E){var B=e.values(T);q=P==="l"?C-e.min(B):I-e.max(B),q&&(b[z]=e.mapValues(T,function(Z){return Z+q}))}})})}function w(b,E){return e.mapValues(b.ul,function(N,C){if(E)return b[E.toLowerCase()][C];var I=e.sortBy(e.map(b,C));return(I[1]+I[2])/2})}function j(b){var E=i.buildLayerMatrix(b),N=e.merge(s(b,E),o(b,E)),C={},I;e.forEach(["u","d"],function(P){I=P==="u"?E:e.values(E).reverse(),e.forEach(["l","r"],function(z){z==="r"&&(I=e.map(I,function(Z){return e.values(Z).reverse()}));var T=(P==="u"?b.predecessors:b.successors).bind(b),q=f(b,I,N,T),B=h(b,I,q.root,q.align,z==="r");z==="r"&&(B=e.mapValues(B,function(Z){return-Z})),C[P+z]=B})});var O=m(b,C);return y(C,O),w(C,b.graph().align)}function _(b,E,N){return function(C,I,O){var P=C.node(I),z=C.node(O),T=0,q;if(T+=P.width/2,e.has(P,"labelpos"))switch(P.labelpos.toLowerCase()){case"l":q=-P.width/2;break;case"r":q=P.width/2;break}if(q&&(T+=N?q:-q),q=0,T+=(P.dummy?E:b)/2,T+=(z.dummy?E:b)/2,T+=z.width/2,e.has(z,"labelpos"))switch(z.labelpos.toLowerCase()){case"l":q=z.width/2;break;case"r":q=-z.width/2;break}return q&&(T+=N?q:-q),q=0,T}}function S(b,E){return b.node(E).width}return vg}var yg,_k;function e$(){if(_k)return yg;_k=1;var e=at(),n=hn(),i=JL().positionX;yg=s;function s(l){l=n.asNonCompoundGraph(l),o(l),e.forEach(i(l),function(u,c){l.node(c).x=u})}function o(l){var u=n.buildLayerMatrix(l),c=l.graph().ranksep,f=0;e.forEach(u,function(h){var p=e.max(e.map(h,function(m){return l.node(m).height}));e.forEach(h,function(m){l.node(m).y=f+p/2}),f+=p+c})}return yg}var wg,Sk;function t$(){if(Sk)return wg;Sk=1;var e=at(),n=qL(),i=LL(),s=DL(),o=hn().normalizeRanks,l=FL(),u=hn().removeEmptyRanks,c=zL(),f=BL(),h=UL(),p=ZL(),m=e$(),y=hn(),w=Zn().Graph;wg=j;function j(D,X){var ee=X&&X.debugTiming?y.time:y.notime;ee("layout",function(){var se=ee(" buildLayoutGraph",function(){return T(D)});ee(" runLayout",function(){_(se,ee)}),ee(" updateInputGraph",function(){S(D,se)})})}function _(D,X){X(" makeSpaceForEdgeLabels",function(){q(D)}),X(" removeSelfEdges",function(){L(D)}),X(" acyclic",function(){n.run(D)}),X(" nestingGraph.run",function(){c.run(D)}),X(" rank",function(){s(y.asNonCompoundGraph(D))}),X(" injectEdgeLabelProxies",function(){B(D)}),X(" removeEmptyRanks",function(){u(D)}),X(" nestingGraph.cleanup",function(){c.cleanup(D)}),X(" normalizeRanks",function(){o(D)}),X(" assignRankMinMax",function(){Z(D)}),X(" removeEdgeLabelProxies",function(){Q(D)}),X(" normalize.run",function(){i.run(D)}),X(" parentDummyChains",function(){l(D)}),X(" addBorderSegments",function(){f(D)}),X(" order",function(){p(D)}),X(" insertSelfEdges",function(){G(D)}),X(" adjustCoordinateSystem",function(){h.adjust(D)}),X(" position",function(){m(D)}),X(" positionSelfEdges",function(){k(D)}),X(" removeBorderNodes",function(){Y(D)}),X(" normalize.undo",function(){i.undo(D)}),X(" fixupEdgeLabelCoords",function(){U(D)}),X(" undoCoordinateSystem",function(){h.undo(D)}),X(" translateGraph",function(){A(D)}),X(" assignNodeIntersects",function(){H(D)}),X(" reversePoints",function(){ne(D)}),X(" acyclic.undo",function(){n.undo(D)})}function S(D,X){e.forEach(D.nodes(),function(ee){var se=D.node(ee),ae=X.node(ee);se&&(se.x=ae.x,se.y=ae.y,X.children(ee).length&&(se.width=ae.width,se.height=ae.height))}),e.forEach(D.edges(),function(ee){var se=D.edge(ee),ae=X.edge(ee);se.points=ae.points,e.has(ae,"x")&&(se.x=ae.x,se.y=ae.y)}),D.graph().width=X.graph().width,D.graph().height=X.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],E={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},N=["acyclicer","ranker","rankdir","align"],C=["width","height"],I={width:0,height:0},O=["minlen","weight","width","height","labeloffset"],P={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},z=["labelpos"];function T(D){var X=new w({multigraph:!0,compound:!0}),ee=oe(D.graph());return X.setGraph(e.merge({},E,$(ee,b),e.pick(ee,N))),e.forEach(D.nodes(),function(se){var ae=oe(D.node(se));X.setNode(se,e.defaults($(ae,C),I)),X.setParent(se,D.parent(se))}),e.forEach(D.edges(),function(se){var ae=oe(D.edge(se));X.setEdge(se,e.merge({},P,$(ae,O),e.pick(ae,z)))}),X}function q(D){var X=D.graph();X.ranksep/=2,e.forEach(D.edges(),function(ee){var se=D.edge(ee);se.minlen*=2,se.labelpos.toLowerCase()!=="c"&&(X.rankdir==="TB"||X.rankdir==="BT"?se.width+=se.labeloffset:se.height+=se.labeloffset)})}function B(D){e.forEach(D.edges(),function(X){var ee=D.edge(X);if(ee.width&&ee.height){var se=D.node(X.v),ae=D.node(X.w),pe={rank:(ae.rank-se.rank)/2+se.rank,e:X};y.addDummyNode(D,"edge-proxy",pe,"_ep")}})}function Z(D){var X=0;e.forEach(D.nodes(),function(ee){var se=D.node(ee);se.borderTop&&(se.minRank=D.node(se.borderTop).rank,se.maxRank=D.node(se.borderBottom).rank,X=e.max(X,se.maxRank))}),D.graph().maxRank=X}function Q(D){e.forEach(D.nodes(),function(X){var ee=D.node(X);ee.dummy==="edge-proxy"&&(D.edge(ee.e).labelRank=ee.rank,D.removeNode(X))})}function A(D){var X=Number.POSITIVE_INFINITY,ee=0,se=Number.POSITIVE_INFINITY,ae=0,pe=D.graph(),ge=pe.marginx||0,Ae=pe.marginy||0;function Oe(Ie){var Me=Ie.x,ke=Ie.y,He=Ie.width,ve=Ie.height;X=Math.min(X,Me-He/2),ee=Math.max(ee,Me+He/2),se=Math.min(se,ke-ve/2),ae=Math.max(ae,ke+ve/2)}e.forEach(D.nodes(),function(Ie){Oe(D.node(Ie))}),e.forEach(D.edges(),function(Ie){var Me=D.edge(Ie);e.has(Me,"x")&&Oe(Me)}),X-=ge,se-=Ae,e.forEach(D.nodes(),function(Ie){var Me=D.node(Ie);Me.x-=X,Me.y-=se}),e.forEach(D.edges(),function(Ie){var Me=D.edge(Ie);e.forEach(Me.points,function(ke){ke.x-=X,ke.y-=se}),e.has(Me,"x")&&(Me.x-=X),e.has(Me,"y")&&(Me.y-=se)}),pe.width=ee-X+ge,pe.height=ae-se+Ae}function H(D){e.forEach(D.edges(),function(X){var ee=D.edge(X),se=D.node(X.v),ae=D.node(X.w),pe,ge;ee.points?(pe=ee.points[0],ge=ee.points[ee.points.length-1]):(ee.points=[],pe=ae,ge=se),ee.points.unshift(y.intersectRect(se,pe)),ee.points.push(y.intersectRect(ae,ge))})}function U(D){e.forEach(D.edges(),function(X){var ee=D.edge(X);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(X){var ee=D.edge(X);ee.reversed&&ee.points.reverse()})}function Y(D){e.forEach(D.nodes(),function(X){if(D.children(X).length){var ee=D.node(X),se=D.node(ee.borderTop),ae=D.node(ee.borderBottom),pe=D.node(e.last(ee.borderLeft)),ge=D.node(e.last(ee.borderRight));ee.width=Math.abs(ge.x-pe.x),ee.height=Math.abs(ae.y-se.y),ee.x=pe.x+ee.width/2,ee.y=se.y+ee.height/2}}),e.forEach(D.nodes(),function(X){D.node(X).dummy==="border"&&D.removeNode(X)})}function L(D){e.forEach(D.edges(),function(X){if(X.v===X.w){var ee=D.node(X.v);ee.selfEdges||(ee.selfEdges=[]),ee.selfEdges.push({e:X,label:D.edge(X)}),D.removeEdge(X)}})}function G(D){var X=y.buildLayerMatrix(D);e.forEach(X,function(ee){var se=0;e.forEach(ee,function(ae,pe){var ge=D.node(ae);ge.order=pe+se,e.forEach(ge.selfEdges,function(Ae){y.addDummyNode(D,"selfedge",{width:Ae.label.width,height:Ae.label.height,rank:ge.rank,order:pe+ ++se,e:Ae.e,label:Ae.label},"_se")}),delete ge.selfEdges})})}function k(D){e.forEach(D.nodes(),function(X){var ee=D.node(X);if(ee.dummy==="selfedge"){var se=D.node(ee.e.v),ae=se.x+se.width/2,pe=se.y,ge=ee.x-ae,Ae=se.height/2;D.setEdge(ee.e,ee.label),D.removeNode(X),ee.label.points=[{x:ae+2*ge/3,y:pe-Ae},{x:ae+5*ge/6,y:pe-Ae},{x:ae+ge,y:pe},{x:ae+5*ge/6,y:pe+Ae},{x:ae+2*ge/3,y:pe+Ae}],ee.label.x=ee.x,ee.label.y=ee.y}})}function $(D,X){return e.mapValues(e.pick(D,X),Number)}function oe(D){var X={};return e.forEach(D,function(ee,se){X[se.toLowerCase()]=ee}),X}return wg}var xg,bk;function n$(){if(bk)return xg;bk=1;var e=at(),n=hn(),i=Zn().Graph;xg={debugOrdering:s};function s(o){var l=n.buildLayerMatrix(o),u=new i({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(c){u.setNode(c,{label:c}),u.setParent(c,"layer"+o.node(c).rank)}),e.forEach(o.edges(),function(c){u.setEdge(c.v,c.w,{},c.name)}),e.forEach(l,function(c,f){var h="layer"+f;u.setNode(h,{rank:"same"}),e.reduce(c,function(p,m){return u.setEdge(p,m,{style:"invis"}),m})}),u}return xg}var _g,kk;function r$(){return kk||(kk=1,_g="0.8.5"),_g}var Sg,Ek;function i$(){return Ek||(Ek=1,Sg={graphlib:Zn(),layout:t$(),debug:n$(),util:{time:hn().time,notime:hn().notime},version:r$()}),Sg}var s$=i$();const Nk=Wg(s$),hi=240,Wi=130,Ds=74,cu=72,Ck=Ds+cu;function o$(e){let n=hi;for(const i of e.values())n=Math.max(n,i.width);return n}const a$=420,l$=2;function du(e){var i;return((i=e.data)==null?void 0:i.sessionId)??"_default"}function u$(e,n,i,s,o){const l=new Nk.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:i,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const u=e.filter(_=>!o.has(_)),c=new Set(u);for(const _ of u){const S=s.get(_);l.setNode(_,{width:(S==null?void 0:S.width)??hi,height:(S==null?void 0:S.height)??Wi})}for(const _ of n)c.has(_.source)&&c.has(_.target)&&l.setEdge(_.source,_.target);Nk.layout(l);const f=new Map;let h=1/0,p=1/0,m=-1/0,y=-1/0;for(const _ of u){const S=l.node(_);if(!S)continue;const b=s.get(_),E=(b==null?void 0:b.width)??hi,N=(b==null?void 0:b.height)??Wi,C=S.x-E/2,I=S.y-N/2;f.set(_,{x:C,y:I}),C<h&&(h=C),I<p&&(p=I),C+E>m&&(m=C+E),I+N>y&&(y=I+N)}if(Number.isFinite(h)&&Number.isFinite(p))for(const[_,S]of f)f.set(_,{x:S.x-h,y:S.y-p});let w=Number.isFinite(m)?m-h:0,j=Number.isFinite(y)?y-p:0;for(const _ of e){const S=o.get(_);if(!S)continue;const b=s.get(_);w=Math.max(w,S.x+((b==null?void 0:b.width)??hi)),j=Math.max(j,S.y+((b==null?void 0:b.height)??Wi))}return{positions:f,width:w,height:j}}function c$(e,n,i={}){const s=i.direction??"LR",o=i.pinned??new Map,l=i.measured??new Map,u=new Map;for(const S of e){const b=du(S),E=u.get(b);E?E.push(S.id):u.set(b,[S.id])}const f=Array.from(u.keys()).sort().map(S=>({sid:S,...u$(u.get(S),n,s,l,o)})),h=o$(l),p=i.availableHeight&&i.availableHeight>0?i.availableHeight:Number.POSITIVE_INFINITY,m=S=>{const b=[[]];let E=0;for(const N of f)b.length<S&&E>0&&E+N.height>p&&(b.push([]),E=0),b[b.length-1].push(N),E+=N.height+Ck;return b},y=S=>S.reduce((b,E)=>Math.max(b,E.width),0)+a$;let w=m(i.availableWidth?l$:1);w.length>1&&w.reduce((b,E)=>b+y(E),0)+h*(w.length-1)>(i.availableWidth??0)&&(w=m(1));const j=new Map;let _=0;for(const S of w){let b=0;for(const{positions:E,height:N}of S){for(const[C,I]of E)j.set(C,{x:I.x+_,y:I.y+b});b+=N+Ck}_+=y(S)+h}return e.map(S=>{const b=o.get(S.id);if(b)return{...S,position:b};const E=j.get(S.id);return E?{...S,position:E}:S})}function d$(e,n,i,s){const l=Ds+cu,u=60,c=y=>{const w=s.get(y);return{w:(w==null?void 0:w.width)??hi,h:(w==null?void 0:w.height)??Wi}},f=new Map(e.map(y=>[y.id,du(y)])),h=[],p=e.map(y=>({id:y.id,pos:i.get(y.id)??n.get(y.id)})).filter(y=>y.pos!=null).sort((y,w)=>y.pos.y-w.pos.y||y.pos.x-w.pos.x||y.id.localeCompare(w.id)),m=[];for(const{id:y,pos:w}of p){const{w:j,h:_}=c(y),S=f.get(y)??"_default";if(i.has(y)){h.push({x:w.x,y:w.y,w:j,h:_,sid:S});continue}let b=w.y;for(let E=0;E<h.length+1;E++){const N=h.find(C=>{const I=C.sid===S?24:u,O=C.sid===S?24:l;return w.x<C.x+C.w+I&&C.x<w.x+j+I&&b<C.y+C.h+O&&C.y<b+_+O});if(!N)break;b=N.y+N.h+(N.sid===S?24:l)}b!==w.y&&(n.set(y,{x:w.x,y:b}),m.push(y)),h.push({x:w.x,y:b,w:j,h:_,sid:S})}return m}function f$(e,n,i,s,o){const l=y=>{const w=s.get(y);return{w:(w==null?void 0:w.width)??hi,h:(w==null?void 0:w.height)??Wi}},u=y=>i.get(y)??n.get(y),c=new Map,f=[];for(const y of e){const w=u(y.id);if(!w)continue;const{w:j,h:_}=l(y.id);if(o.has(y.id)&&!i.has(y.id)){const S=du(y);(c.get(S)??c.set(S,[]).get(S)).push(y)}else f.push({x:w.x,y:w.y,w:j,h:_})}if(c.size===0)return[];const h=Ds+cu,p=(y,w,j,_)=>f.some(S=>y<S.x+S.w+Ds&&S.x<y+j+Ds&&w<S.y+S.h+h&&S.y<w+_+h),m=[];for(const y of[...c.keys()].sort()){const w=c.get(y);let j=1/0,_=1/0,S=-1/0,b=-1/0;for(const z of w){const T=u(z.id),{w:q,h:B}=l(z.id);j=Math.min(j,T.x),_=Math.min(_,T.y),S=Math.max(S,T.x+q),b=Math.max(b,T.y+B)}const E=S-j,N=b-_,C=[...new Set(f.map(z=>Math.round(z.x)))].sort((z,T)=>z-T),I=C.length?C:[j],O=[0,...f.map(z=>z.y+z.h+h)].sort((z,T)=>z-T);let P=null;e:for(const z of I)for(const T of O){if(T>=_)break;if(!p(z,T,E,N)){P={x:z,y:T};break e}}if(P){const z=P.x-j,T=P.y-_;for(const q of w){const B=u(q.id);n.set(q.id,{x:B.x+z,y:B.y+T})}m.push(y)}for(const z of w){const T=u(z.id),{w:q,h:B}=l(z.id);f.push({x:T.x,y:T.y,w:q,h:B})}}return m}function h$(e,n,i,s,o,l=!1){const f=Ds+cu+1,h=8,p=1.75,m=200,y=.7,w=.01,j=T=>{const q=s.get(T);return{w:(q==null?void 0:q.width)??hi,h:(q==null?void 0:q.height)??Wi}},_=T=>i.get(T)??n.get(T),S=new Map;for(const T of e){if(!_(T.id))continue;const q=du(T),B=S.get(q);B?B.push(T):S.set(q,[T])}const b=[],E=new Set,N=new Set,C=o.size===0;for(const T of[...S.keys()].sort()){const q=S.get(T);let B=1/0,Z=1/0,Q=-1/0,A=-1/0,H=!1;for(const L of q){const G=_(L.id),{w:k,h:$}=j(L.id);B=Math.min(B,G.x),Z=Math.min(Z,G.y),Q=Math.max(Q,G.x+k),A=Math.max(A,G.y+$),i.has(L.id)&&(H=!0)}const U=Q-B,ne=A-Z;N.add(T);const Y=o.get(T);Y&&(U>Y.w+h||ne>Y.h+h)&&E.add(T),o.set(T,{w:U,h:ne}),b.push({sid:T,members:q.map(L=>L.id),x:B,y:Z,w:U,h:ne,anchored:H,mass:1})}for(const T of[...o.keys()])N.has(T)||o.delete(T);if(l||C)return[];let I=!1;for(let T=0;T<b.length&&!I;T++)for(let q=T+1;q<b.length;q++){const B=b[T],Z=b[q];if(!(B.anchored&&Z.anchored)&&Math.abs(B.x+B.w/2-(Z.x+Z.w/2))<(B.w+Z.w)/2+61&&Math.abs(B.y+B.h/2-(Z.y+Z.h/2))<(B.h+Z.h)/2+f){I=!0;break}}if(E.size===0&&!I)return[];if(E.size>0)for(const T of b)E.has(T.sid)&&(T.mass=8);else for(const T of b)T.mass=Math.max(1,T.w*T.h/(hi*Wi));const O=new Map(b.map(T=>[T.sid,T.x])),P=new Map(b.map(T=>[T.sid,T.y]));for(let T=0;T<m;T++){const q=new Map,B=new Map;let Z=0;for(let Q=0;Q<b.length;Q++)for(let A=Q+1;A<b.length;A++){const H=b[Q],U=b[A];if(H.anchored&&U.anchored)continue;const ne=H.x+H.w/2,Y=H.y+H.h/2,L=U.x+U.w/2,G=U.y+U.h/2,k=(H.w+U.w)/2+61-Math.abs(ne-L),$=(H.h+U.h)/2+f-Math.abs(Y-G);if(k<=0||$<=0)continue;const oe=(We,$e)=>!We.anchored&&!($e<0&&We.x<=0),D=(We,$e)=>!We.anchored&&!($e<0&&We.y<=0),X=(We,$e,Ke)=>{const yt=We===$e,et=yt?H.sid<U.sid?-1:1:Math.sign(We-$e);return Ke(H,et)||Ke(U,-et)?et:yt&&(Ke(H,-et)||Ke(U,et))?-et:0},ee=X(ne,L,oe),se=X(Y,G,D),ae=ee!==0,pe=se!==0;if(!ae&&!pe)continue;const ge=ae&&(!pe||k*p<$),[Ae,Oe,Ie,Me]=ge?[ee,k,q,oe]:[se,$,B,D],ke=Me(H,Ae),He=Me(U,-Ae),ve=H.mass,ye=U.mass,Ve=ke?He?ye/(ve+ye):1:0,ft=He?ke?ve/(ve+ye):1:0,Qe=Oe*y;Ie.set(H.sid,(Ie.get(H.sid)??0)+Ae*Qe*Ve),Ie.set(U.sid,(Ie.get(U.sid)??0)-Ae*Qe*ft),Z+=Qe}for(const Q of b)Q.anchored||(Q.x=Math.max(0,Q.x+(q.get(Q.sid)??0)),Q.y=Math.max(0,Q.y+(B.get(Q.sid)??0)));if(Z<w)break}const z=[];for(const T of b){const q=T.x-O.get(T.sid),B=T.y-P.get(T.sid);if(!(Math.abs(q)<1&&Math.abs(B)<1)){for(const Z of T.members){if(i.has(Z))continue;const Q=n.get(Z);Q&&n.set(Z,{x:Q.x+q,y:Q.y+B})}z.push(T.sid)}}return z}const p$=600;function Ug(e,n){return!(e.exitAt!=null&&n-e.exitAt>p$||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function m$(e,n){const i=new Set;for(const s of e.agents.values())Ug(s,n)&&i.add(s.id);return i}function Fi(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function g$(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}const v$={agent:kP,sessionGroup:OP},y$=420,bl=18,w$=9e4,x$=200,_$=5*6e4,S$=6,b$=2*6e4,Av="agent-dag.layout",Iv="agent-dag.viewport",hC="agent-dag.summariesDismissed",pC="agent-dag.sessionListOpen",mC="agent-dag.detailOpen",gC="agent-dag.usagePanelOpen",jk="agent-dag.accountsPanelOpen",Rk="agent-dag.versionNoticeDismissed",k$={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — run:",not_writable:"the install directory is not writable by this user — run:",opted_out:"installs are off (AGENTS_DECK_NO_INSTALL=1) — run:"},Tk="agent-dag.autoRestart",Ak="agent-dag.bundleReloadedFor";function E$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(pC)==="1"}catch{return!1}}function N$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(pC,e?"1":"0")}catch{}}function C$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(mC)==="1"}catch{return!1}}function j$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(mC,e?"1":"0")}catch{}}function R$(){if(typeof window>"u")return!0;const e=window.localStorage.getItem(gC);try{return e===null?!0:e==="1"}catch{return!0}}function T$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(gC,e?"1":"0")}catch{}}function A$(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(hC);if(!e)return new Set;const n=JSON.parse(e);return new Set(Array.isArray(n)?n.filter(i=>typeof i=="string"):[])}catch{return new Set}}function Ik(e){if(!(typeof window>"u"))try{const n=Array.from(e),i=n.length>200?n.slice(-200):n;window.localStorage.setItem(hC,JSON.stringify(i))}catch{}}function I$(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(Av);if(!n)return e;const i=JSON.parse(n);if(!("v"in i)){const o=Object.entries(i).filter(([,l])=>l&&typeof l.x=="number"&&typeof l.y=="number");return{positions:o,pins:o.map(([l])=>l)}}return{positions:Object.entries(i.positions??{}).filter(([,o])=>o&&typeof o.x=="number"&&typeof o.y=="number"),pins:Array.isArray(i.pins)?i.pins:[]}}catch{return e}}function bg(e,n){if(!(typeof window>"u"))try{const i={};for(const[s,o]of e)i[s]=o;for(const[s,o]of n)i[s]=o;window.localStorage.setItem(Av,JSON.stringify({v:2,positions:i,pins:Array.from(n.keys())}))}catch{}}function M$(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Iv);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 P$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Iv,JSON.stringify(e))}catch{}}function Mk(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Av)}catch{}try{window.localStorage.removeItem(Iv)}catch{}}}function O$(e,n){const i=e.agents.get(n);if(!i)return;const s=[];for(const p of e.agents.values())p.sessionId===n&&s.push(p);const o={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:n,label:i.label,cwd:i.cwd,startedAt:i.startedAt,endedAt:i.endedAt,model:i.model,agents:s.map(p=>({id:p.id,kind:p.kind,label:p.label,parentId:p.parentId,state:p.state,startedAt:p.startedAt,endedAt:p.endedAt,model:p.model,cwd:p.cwd,usage:p.usage,prompts:p.prompts,tools:p.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),f=document.createElement("a"),h=(i.label||"session").replace(/[^a-z0-9._-]/gi,"_");f.href=c,f.download=`agents-deck-${h}-${n.slice(0,8)}.json`,document.body.appendChild(f),f.click(),document.body.removeChild(f),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const Hg={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Vg={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},q$={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",shell:"shell",exec_command:"shell",shell_command:"shell",write_stdin:"shell",wait:"shell",apply_patch:"file",update_plan:"task",WebFetch:"web",WebSearch:"web",Task:"agent",Agent:"agent",TodoWrite:"task",TaskCreate:"task",TaskUpdate:"task",TaskList:"task",TaskGet:"task",TaskOutput:"task",TaskStop:"task",EnterPlanMode:"plan",ExitPlanMode:"plan",AskUserQuestion:"plan",Skill:"plan",Workflow:"plan"};function vC(e){return e.startsWith("mcp__")?"mcp":q$[e]??"other"}function yC(e,n){var s,o,l;if(!n)return!0;const i=n.toLowerCase();if(e.label.toLowerCase().includes(i)||(s=e.cwd)!=null&&s.toLowerCase().includes(i)||(o=e.cwdBasename)!=null&&o.toLowerCase().includes(i)||e.sessionId.toLowerCase().includes(i)||(l=e.firstPrompt)!=null&&l.toLowerCase().includes(i))return!0;for(const u of e.tools)if(u.name.toLowerCase().includes(i))return!0;return!1}function L$(e,n){if(!n)return null;const i=new Set([n]);let s=n;for(;s;){const l=e.agents.get(s);if(!(l!=null&&l.parentId)||i.has(l.parentId))break;i.add(l.parentId),s=l.parentId}let o=!0;for(;o;){o=!1;for(const l of e.agents.values())l.parentId&&i.has(l.parentId)&&!i.has(l.id)&&(i.add(l.id),o=!0)}return i}function $$(e,n,i,s,o,l,u,c,f,h,p,m,y,w,j,_,S,b){const E=[],N=[],C=new Set;if(l)for(const T of e.agents.values())yC(T,l)&&C.add(T.id);for(const T of e.agents.values()){if(!S.has(T.id))continue;const q=l?!C.has(T.id):!1,B=T.exitAt!=null,Z=_!=null&&!_.has(T.id),Q=[q?"rf-dim":"",B?"rf-exiting":"",Z?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,A=u.get(T.id);if(E.push({id:T.id,type:"agent",position:{x:0,y:0},data:{...T,now:n,dim:q,onOpenContext:b},className:Q,...A?{width:A.width,height:A.height}:null}),T.parentId&&S.has(T.parentId)){const H=dv(T.sessionId),U=T.state==="active"?`hsl(${H} 80% 72%)`:`hsl(${H} 50% 55%)`,ne=l&&!C.has(T.id)&&!C.has(T.parentId),Y=B,L=j.size>0&&(j.has(T.id)||j.has(T.parentId)),G=_!=null&&!_.has(T.id)&&!_.has(T.parentId),k=T.state==="active"?2:1.5,$=L?k+1.5:k,oe=ne||Y?.2:G?.12:1,D=[Y?"rf-edge-exiting":"",L?"rf-edge-selected":""].filter(Boolean).join(" ")||void 0;N.push({id:`e:${T.parentId}->${T.id}`,source:T.parentId,target:T.id,animated:(T.state==="active"||L)&&!ne&&!Y,type:"smoothstep",style:{stroke:U,strokeWidth:$,opacity:oe,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:D})}}const I=E.filter(T=>!o.has(T.id)&&!m.has(T.id));if(I.length>0||y!==w.current){if(I.length>0){const T=c$(E,N,{direction:"LR",pinned:o,measured:u,availableWidth:i,availableHeight:s});for(const q of T)m.has(q.id)||m.set(q.id,q.position);f$(E,m,o,u,new Set(I.map(q=>q.id)))}d$(E,m,o,u),w.current=y}const O=h$(E,m,o,u,c,!h||p);O.length>0&&f(O);for(const T of Array.from(m.keys()))e.agents.has(T)||m.delete(T);if(e.agents.size>0)for(const T of Array.from(o.keys()))e.agents.has(T)||o.delete(T);const P=[];let z=!1;for(const T of E){let q=o.get(T.id)??m.get(T.id);q||(q={x:0,y:0},m.set(T.id,q),z=!0),P.push({...T,position:q})}return z&&(w.current=""),{nodes:P,edges:N}}function D$(){return g.jsx(uv,{children:g.jsx(F$,{})})}function F$(){var eo,Hr,ha,to;const e=ta(),n=M.useRef(Fg()),[,i]=M.useState(0),s=M.useCallback(()=>i(W=>W+1),[]),[o,l]=M.useState(()=>new Set),[u,c]=M.useState(null),[f,h]=M.useState(null),p=M.useCallback((W,J)=>{l(ue=>{if(!J)return new Set([W]);const fe=new Set(ue);return fe.has(W)?fe.delete(W):fe.add(W),fe}),c(ue=>J&&ue===W?ue:W)},[]),m=M.useCallback(()=>{l(new Set),c(null)},[]),[y,w]=M.useState(null),[j,_]=M.useState(null),S=M.useCallback(W=>_(W),[]),b=M.useRef(A$()),[E,N]=M.useState(E$);M.useEffect(()=>{N$(E)},[E]);const[C,I]=M.useState(C$);M.useEffect(()=>{j$(C)},[C]);const[O,P]=M.useState(R$);M.useEffect(()=>{T$(O)},[O]);const[z,T]=M.useState(()=>{try{const W=window.localStorage.getItem(jk);return W===null?!0:W==="1"}catch{return!0}});M.useEffect(()=>{try{window.localStorage.setItem(jk,z?"1":"0")}catch{}},[z]);const[q,B]=M.useState(null),[Z,Q]=M.useState(!1),[A,H]=M.useState(0),[U,ne]=M.useState(0);M.useEffect(()=>{fetch("/api/sound-hook").then(W=>W.ok?W.json():null).then(W=>{W!=null&&W.ok&&(B(W.enabled===!0),H((W.foreign??[]).filter(J=>J.worksHere).length),ne(typeof W.parked=="number"?W.parked:0))}).catch(()=>{})},[]);const Y=M.useCallback(async()=>{Q(!0);try{const J=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!q})})).json().catch(()=>null);J!=null&&J.ok&&B(J.enabled===!0),fetch("/api/sound-hook").then(ue=>ue.ok?ue.json():null).then(ue=>{ue!=null&&ue.ok&&(H((ue.foreign??[]).filter(fe=>fe.worksHere).length),ne(typeof ue.parked=="number"?ue.parked:0))}).catch(()=>{})}catch{}finally{Q(!1)}},[q]),[L,G]=M.useState(!1),[k,$]=M.useState(null),[oe,D]=M.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(Rk)??""}catch{return""}}),[X,ee]=M.useState(!1),se=M.useCallback(()=>{fetch("/api/version").then(W=>W.ok?W.json():null).then(W=>{W&&$(W)}).catch(()=>{})},[]);M.useEffect(()=>{se();const W=window.setInterval(se,5*6e4),J=()=>{document.visibilityState==="visible"&&se()};return document.addEventListener("visibilitychange",J),()=>{window.clearInterval(W),document.removeEventListener("visibilitychange",J)}},[se]),M.useEffect(()=>{L&&se()},[L,se]);const ae=(k==null?void 0:k.notice)??null,pe=ae?`${ae.kind}:${ae.to}`:"",ge=ae!=null&&oe!==pe,Ae=M.useCallback(()=>{if(!ae)return;const W=oe===pe?"":pe;D(W);try{window.localStorage.setItem(Rk,W)}catch{}},[ae,pe,oe]),Oe=((eo=k==null?void 0:k.upgrade)==null?void 0:eo.state)??"idle",Ie=M.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}se()},[se]);M.useEffect(()=>{if(Oe!=="running")return;const W=window.setInterval(se,3e3);return()=>window.clearInterval(W)},[Oe,se]);const Me=M.useCallback(async()=>{var ue;const W=k==null?void 0:k.command;if(!W)return;let J=!1;try{J=await Promise.race([((ue=navigator.clipboard)==null?void 0:ue.writeText(W).then(()=>!0))??Promise.resolve(!1),new Promise(fe=>window.setTimeout(()=>fe(!1),500))])}catch{J=!1}if(!J)try{const fe=document.createElement("textarea");fe.value=W,fe.setAttribute("readonly",""),fe.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(fe),fe.select(),J=document.execCommand("copy"),fe.remove()}catch{J=!1}J&&(ee(!0),window.setTimeout(()=>ee(!1),1600))},[k==null?void 0:k.command]),ke=M.useCallback(()=>{N(W=>(W||T(!1),!W))},[]),He=M.useCallback(()=>{T(W=>(W||N(!1),!W))},[]),[ve,ye]=M.useState(!1),[Ve,ft]=M.useState(0),Qe=M.useRef(null),[We,$e]=M.useState(0),[Ke,yt]=M.useState(!1),et=M.useRef([]),[Ge,wt]=M.useState(Date.now()),[Rt,Ft]=M.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(Tk)!=="0"}catch{return!0}}),tt=M.useCallback(()=>{Ft(W=>{const J=!W;try{window.localStorage.setItem(Tk,J?"1":"0")}catch{}return J})},[]),[xt,lt]=M.useState(!1),[mt,wn]=M.useState(null),bt=M.useRef(!1),Tt=M.useCallback(async()=>{if(!bt.current){bt.current=!0,lt(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(ae==null?void 0:ae.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST"})}catch{}window.setTimeout(()=>{if(bt.current){bt.current=!1,lt(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},3e4)}},[ae==null?void 0:ae.to]),xn=M.useRef(null);M.useEffect(()=>{let W=!1;for(const ue of n.current.agents.values())if(ue.state==="active"){W=!0;break}const J=D3({enabled:Rt,kind:ae==null?void 0:ae.kind,canRestart:(k==null?void 0:k.canRestart)===!0,busy:W,idleSince:xn.current,now:Ge});xn.current=J.idleSince,J.restart&&Tt()},[Rt,ae==null?void 0:ae.kind,k==null?void 0:k.canRestart,Ge,Tt]),M.useEffect(()=>{let W=null;try{W=window.sessionStorage.getItem(Ak)}catch{return}if($3({bundle:"1.33.1",running:k==null?void 0:k.running,lastTried:W})){try{window.sessionStorage.setItem(Ak,(k==null?void 0:k.running)??"")}catch{return}window.location.reload()}},[k==null?void 0:k.running]),M.useEffect(()=>{const W=k==null?void 0:k.running;if(!W)return;let J=null;try{J=window.sessionStorage.getItem("agent-dag.restartPending")}catch{return}if(J==null||J&&J!==W)return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}bt.current=!1,lt(!1),wn(W);const ue=window.setTimeout(()=>wn(null),6e3);return()=>window.clearTimeout(ue)},[k==null?void 0:k.running]);const Ln=M.useRef(I$()).current;M.useRef(!1);const ut=M.useRef(new Map(Ln.positions.filter(([W])=>Ln.pins.includes(W)))),Yt=M.useRef(null),Qt=M.useState(()=>M$())[0],[At,mi]=M.useState(""),[gi,Ji]=M.useState(()=>new Set),[tr,Pr]=M.useState(()=>typeof window>"u"?"dark":window.localStorage.getItem("agent-dag.theme")??"dark"),[vi,fr]=M.useState(!1),Or=M.useRef(null);M.useEffect(()=>{document.documentElement.dataset.theme=tr;try{window.localStorage.setItem("agent-dag.theme",tr)}catch{}},[tr]),M.useEffect(()=>{if(!Qt)return;const W=window.setTimeout(()=>{try{e.setViewport(Qt,{duration:0})}catch{}},60);return()=>window.clearTimeout(W)},[e,Qt]);const nr=M.useRef(!0),qt=M.useRef(null);M.useEffect(()=>{const W=new EventSource("/events");return W.addEventListener("open",()=>{G(!0),fr(!0)}),W.addEventListener("error",()=>G(!1)),W.addEventListener("replay-end",()=>{nr.current=!1,qt.current!=null&&(window.clearTimeout(qt.current),qt.current=null),s()}),W.addEventListener("hook",J=>{try{const ue=JSON.parse(J.data);if(Ke){et.current.push(ue);return}n.current=Gw(n.current,ue),ue.replay===!0||nr.current||Date.now()-ue.receivedAt>3e4?(qt.current!=null&&window.clearTimeout(qt.current),qt.current=window.setTimeout(()=>{qt.current=null,s()},120)):(qt.current!=null&&(window.clearTimeout(qt.current),qt.current=null),s())}catch{}}),()=>{W.close(),qt.current!=null&&(window.clearTimeout(qt.current),qt.current=null)}},[Ke,s]),M.useEffect(()=>{if(!Ke&&et.current.length!==0){for(const W of et.current)n.current=Gw(n.current,W);et.current.length=0,s()}},[Ke,s]),M.useEffect(()=>{const W=setInterval(()=>{const J=Date.now();wt(J);let ue=lP(n.current,J,w$);oP(n.current,J,x$,_$)&&(ue=!0),aP(n.current,J,S$,b$)&&(ue=!0),ue&&s()},250);return()=>clearInterval(W)},[s]);const $n=M.useRef(null),pn=M.useRef(0),qr=420,zt=M.useCallback((W=500)=>{try{const xe=document.querySelector(".canvas-wrap"),Pe=Array.from(document.querySelectorAll(".react-flow__node")).filter(gt=>gt.offsetWidth>0);if(!xe||Pe.length===0)return;const ze=xe.getBoundingClientRect(),Ze=e.getViewport();if(!Number.isFinite(Ze.zoom)||Ze.zoom<=0)return;const Ye=gt=>(gt-ze.left-Ze.x)/Ze.zoom,Je=gt=>(gt-ze.top-Ze.y)/Ze.zoom,nn=Pe.map(gt=>gt.getBoundingClientRect()),Vr=Math.min(...nn.map(gt=>Ye(gt.left))),En=Math.max(...nn.map(gt=>Ye(gt.right))),gr=Math.min(...nn.map(gt=>Je(gt.top))),Wr=Math.max(...nn.map(gt=>Je(gt.bottom))),no=En-Vr,vr=Wr-gr;if(!(no>0&&vr>0))return;const rn=Math.max(.2,Math.min(1,(ze.width-160)/(no+qr)*.86,(ze.height-160)/vr*.86));e.setViewport({x:80-Vr*rn,y:Math.max(80,(ze.height-vr*rn)/2)-gr*rn,zoom:rn},{duration:W}),pn.current=Date.now(),window.setTimeout(()=>{try{const gt={x:80-Vr*rn,y:Math.max(80,(ze.height-vr*rn)/2)-gr*rn,zoom:rn},Ut=e.getViewport();(Math.abs(Ut.zoom-rn)>.01||Math.abs(Ut.x-gt.x)>2)&&e.setViewport(gt,{duration:0})}catch{}},W+60)}catch{}},[e]),yi=M.useRef(""),wi=M.useRef(null),xi=M.useRef(0),Zt=M.useCallback(()=>{xi.current=Date.now()},[]),Lr="agent-dag.autoFitDisabled",_n=M.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Lr)==="1"}catch{return!1}})()),[es,_i]=M.useState(_n.current),Si=M.useCallback(()=>{if(!_n.current){_n.current=!0,_i(!0);try{window.localStorage.setItem(Lr,"1")}catch{}}},[]),ts=M.useCallback(()=>{_n.current=!1,_i(!1);try{window.localStorage.removeItem(Lr)}catch{}zt(400)},[e,zt]);M.useEffect(()=>{const W=setInterval(()=>{if(_n.current||Date.now()-xi.current<800)return;const J=n.current,ue=Date.now(),fe=[];for(const Ye of J.agents.values())Ug(Ye,ue)&&fe.push({id:Ye.id});if(fe.length===0)return;const we=e.getViewport(),xe=window.innerWidth-360,Pe=window.innerHeight-52;let ze=!1,Ze=!1;for(const{id:Ye}of fe){const Je=Dn.current.get(Ye),nn=ut.current.get(Ye)??kt.current.get(Ye);if(!Je||!nn)continue;Ze=!0;const Vr=nn.x*we.zoom+we.x,En=nn.y*we.zoom+we.y,gr=(nn.x+Je.width)*we.zoom+we.x,Wr=(nn.y+Je.height)*we.zoom+we.y;if(gr>0&&Vr<xe&&Wr>0&&En<Pe){ze=!0;break}}Ze&&!ze&&zt(600)},1500);return()=>clearInterval(W)},[e]);const $r=M.useRef(!1),Dn=M.useRef(new Map),ns=M.useRef(0),rt=M.useCallback(W=>{const J=Dn.current;let ue=!1;for(const fe of W.nodeInternals.values()){const we=fe.width,xe=fe.height;if(we==null||xe==null)continue;const Pe=J.get(fe.id);Pe?(Math.abs(Pe.height-xe)>4||Math.abs(Pe.width-we)>4)&&(J.set(fe.id,{width:we,height:xe}),ue=!0):(J.set(fe.id,{width:we,height:xe}),ue=!0)}return ue&&(ns.current+=1),ns.current},[]),rs=Xe(rt),[Dr,is]=M.useState(0);M.useEffect(()=>{let W=0;const J=()=>{const fe=Dn.current;let we=!1;for(const xe of document.querySelectorAll(".react-flow__node[data-id]")){const Pe=xe.getAttribute("data-id");if(!Pe)continue;const ze=xe.offsetWidth,Ze=xe.offsetHeight;if(!ze||!Ze)continue;const Ye=fe.get(Pe);(!Ye||Math.abs(Ye.width-ze)>4||Math.abs(Ye.height-Ze)>4)&&(fe.set(Pe,{width:ze,height:Ze}),we=!0)}we&&is(xe=>xe+1)};if($r.current)return;let ue=0;return document.visibilityState==="hidden"?ue=window.setTimeout(J,32):W=requestAnimationFrame(J),()=>{cancelAnimationFrame(W),window.clearTimeout(ue)}});const kt=M.useRef(new Map(Ln.positions)),Fr=M.useRef(""),Fn=M.useMemo(()=>{const W=[];for(const J of n.current.agents.values())Ug(J,Ge)&&W.push(J.id+(J.parentId?`>${J.parentId}`:""));return W.sort(),`${W.join("|")}#sv${rs}.${Dr}`},[n.current,n.current.lastSeq,Ge,rs,Dr]),Sn=M.useRef(null);M.useEffect(()=>(Sn.current!=null&&window.clearTimeout(Sn.current),Sn.current=window.setTimeout(()=>{bg(kt.current,ut.current)},1500),()=>{Sn.current!=null&&window.clearTimeout(Sn.current)}),[Fn]),M.useEffect(()=>{if(yi.current===Fn)return;const W=yi.current;if(yi.current=Fn,!W||_n.current)return;Date.now()-pn.current>1200&&zt(400),$n.current&&window.clearTimeout($n.current),$n.current=window.setTimeout(()=>{_n.current||zt(500)},280)},[Fn,e,zt]);const Bt=M.useMemo(()=>{if(o.size===0)return null;const W=new Set;for(const J of o){const ue=L$(n.current,J);if(ue)for(const fe of ue)W.add(fe)}return W.size>0?W:null},[n.current,n.current.lastSeq,o]),hr=M.useMemo(()=>m$(n.current,Ge),[n.current,n.current.lastSeq,Ge]),Jt=M.useRef(null),[ss,la]=M.useState({w:0,h:0});M.useEffect(()=>{const W=Jt.current;if(!W||typeof ResizeObserver>"u")return;const J=new ResizeObserver(ue=>{var we;const fe=(we=ue[0])==null?void 0:we.contentRect;fe&&la(xe=>Math.abs(xe.w-fe.width)>40||Math.abs(xe.h-fe.height)>40?{w:fe.width,h:fe.height}:xe)});return J.observe(W),la({w:W.clientWidth,h:W.clientHeight}),()=>J.disconnect()},[]);const fu=M.useRef(new Map),[bi,os]=M.useState(!1);M.useEffect(()=>{const W=window.setTimeout(()=>os(!0),2500);return()=>window.clearTimeout(W)},[]);const[ki,zr]=M.useState(!1),rr=M.useRef(null),[Ks,as]=M.useState(!1),ua=M.useCallback(()=>{rr.current&&(window.clearTimeout(rr.current),rr.current=null),zr(!1)},[]),Xs=M.useCallback(W=>{W.length!==0&&queueMicrotask(()=>{zr(!0),rr.current&&window.clearTimeout(rr.current),rr.current=window.setTimeout(()=>zr(!1),y$+80)})},[]);M.useEffect(()=>()=>{rr.current&&window.clearTimeout(rr.current)},[]);const Br=ss.w>0?ss.w*.92:0,ca=ss.h>0?ss.h:0,{nodes:en,edges:Ue}=M.useMemo(()=>$$(n.current,Ge,Br,ca,ut.current,At,Dn.current,fu.current,Xs,bi,Ks,kt.current,Fn,Fr,o,Bt,hr,S),[n.current,n.current.lastSeq,Ge,Br,ca,bi,Ks,At,Fn,o,Bt,hr,S,Ve]),Qs=M.useMemo(()=>{const W=new Map;for(const ue of en){const fe=ue.data;if(!(fe!=null&&fe.sessionId)||fe.exitAt!=null)continue;const we=ue.width,xe=ue.height;if(we==null||xe==null)continue;const Pe=ue.position.x,ze=ue.position.y,Ze=Pe+we,Ye=ze+xe,Je=W.get(fe.sessionId);Je?(Je.minX=Math.min(Je.minX,Pe),Je.minY=Math.min(Je.minY,ze),Je.maxX=Math.max(Je.maxX,Ze),Je.maxY=Math.max(Je.maxY,Ye)):W.set(fe.sessionId,{minX:Pe,minY:ze,maxX:Ze,maxY:Ye})}const J=[];for(const[ue,fe]of W){const we=fe.maxX-fe.minX+bl*2,xe=fe.maxY-fe.minY+bl*2;J.push({id:`group:${ue}`,type:"sessionGroup",position:{x:fe.minX-bl,y:fe.minY-bl},data:{sessionId:ue,w:we,h:xe},width:we,height:xe,style:{width:we,height:xe},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return J},[en,Ge]),da=M.useMemo(()=>{const W=[...Qs,...en],J=Qe.current;return!J||J.size===0?W:W.map(ue=>{const fe=J.get(ue.id);return fe?{...ue,position:fe}:ue})},[Qs,en,We]),Zs=M.useMemo(()=>{if(!At)return null;const W=new Set;for(const J of n.current.agents.values())yC(J,At)&&W.add(J.id);return W},[n.current,n.current.lastSeq,At]),Js=M.useMemo(()=>{const W=new Set;for(const J of n.current.agents.values())for(const ue of J.tools)W.add(vC(ue.name));return Object.keys(Hg).filter(J=>W.has(J))},[n.current,n.current.lastSeq]),Ur=M.useMemo(()=>{const W=new Map;for(const ue of n.current.agents.values())for(const fe of ue.tools){if(!fe.name.startsWith("mcp__"))continue;const we=fe.name.slice(5),xe=we.indexOf("__"),Pe=xe>0?we.slice(0,xe):we;W.set(Pe,(W.get(Pe)??0)+1)}const J=[];for(const[ue,fe]of W){let we=5381;for(let xe=0;xe<ue.length;xe++)we=(we<<5)+we^ue.charCodeAt(xe);J.push({server:ue,count:fe,hue:Math.abs(we)%360})}return J.sort((ue,fe)=>fe.count-ue.count),J},[n.current,n.current.lastSeq]),fa=M.useCallback(W=>{Ji(J=>{const ue=new Set(J);return ue.has(W)?ue.delete(W):ue.add(W),ue})},[]),It=u?n.current.agents.get(u):null,Ei=f?Array.from(n.current.agents.values()).flatMap(W=>W.tools).find(W=>W.id===f)??null:null,bn=M.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=Fg(),ut.current.clear(),Dn.current.clear(),kt.current.clear(),Fr.current="",Mk(),m(),s()},[s,m]),kn=M.useCallback(()=>{ut.current.clear(),kt.current.clear(),Fr.current="",Mk(),s(),window.setTimeout(()=>zt(500),80)},[s,e,zt]),zn=M.useCallback(()=>zt(500),[zt]),pr=M.useCallback(W=>{if(en.length===0)return;const J=en.slice().sort((xe,Pe)=>xe.position.y-Pe.position.y||xe.position.x-Pe.position.x),ue=u?J.findIndex(xe=>xe.id===u):-1;let fe;ue===-1?fe=W===1?0:J.length-1:fe=(ue+W+J.length)%J.length;const we=J[fe];we&&(p(we.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[we]})}catch{}pn.current=Date.now()},30))},[en,u,p,e]);M.useEffect(()=>{const W=J=>{var fe,we;const ue=((fe=J.target)==null?void 0:fe.tagName)==="INPUT";if(J.key==="Escape"){ue?J.target.blur():m();return}if(!ue){if(J.key==="/"){J.preventDefault(),(we=Or.current)==null||we.focus();return}J.key===" "&&(J.preventDefault(),yt(xe=>!xe)),(J.key==="c"||J.key==="C")&&bn(),(J.key==="r"||J.key==="R")&&kn(),(J.key==="f"||J.key==="F")&&zn(),(J.key==="l"||J.key==="L")&&ke(),(J.key==="h"||J.key==="H")&&ye(xe=>!xe),(J.key==="u"||J.key==="U")&&P(xe=>!xe),(J.key==="a"||J.key==="A")&&He(),(J.key==="j"||J.key==="J")&&pr(1),(J.key==="k"||J.key==="K")&&pr(-1),(J.key==="t"||J.key==="T")&&Pr(xe=>xe==="dark"?"light":"dark")}};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[bn,kn,zn,m,pr]);const mr=n.current.agents.size,ir=new Set(Array.from(n.current.agents.values()).map(W=>W.sessionId)).size,tn=M.useMemo(()=>{let W=0,J=0,ue=0,fe=0,we=0,xe=0,Pe=0,ze=0,Ze=0;for(const Ye of n.current.agents.values()){W+=Ye.usage.inputTokens,J+=Ye.usage.outputTokens,ue+=Ye.usage.cacheReadTokens,fe+=Ye.usage.cacheCreateTokens;const Je=fn(Ye.usage,Ye.model);we+=Je.total,xe+=Je.input,Pe+=Je.output,ze+=Je.cacheRead,Ze+=Je.cacheWrite}return{inT:W,outT:J,cacheR:ue,cacheC:fe,sum:W+J,cost:{total:we,input:xe,output:Pe,cacheRead:ze,cacheWrite:Ze}}},[n.current,n.current.lastSeq]);return g.jsxs("div",{className:"app",children:[g.jsxs("header",{className:"topbar",children:[g.jsxs("div",{className:"brand",children:[g.jsx("span",{className:"logo"}),"agents-deck",ae?g.jsxs("button",{type:"button",className:"v stale",onClick:Ae,title:ae.kind==="restart"?`Running v${ae.from}; v${ae.to} is installed on disk. Restart to pick it up.`:`Running v${ae.from}; v${ae.to} is on npm.`,children:["v",ae.from,g.jsx("span",{className:"v-dot","aria-hidden":!0})]}):g.jsxs("span",{className:"v",children:["v",(k==null?void 0:k.running)??"1.33.1"]})]}),It&&(()=>{const W=fn(It.usage,It.model),J=Math.max(0,((It.endedAt??Ge)-It.startedAt)/1e3),ue=It.state==="active"?$l(W.total,J):null,fe=o.size-1;return g.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${It.label}`,onClick:()=>{try{const we=en.find(xe=>xe.id===It.id);we&&e.fitView({padding:.35,duration:500,nodes:[we]}),pn.current=Date.now()}catch{}},children:[g.jsx("span",{className:`state-pill state-${It.state}`,children:It.state==="active"?"live":It.state}),g.jsx("span",{className:"selected-label",children:It.label}),W.total>0&&g.jsxs("span",{className:"selected-cost",children:[Fe(W.total),ue?g.jsxs("span",{className:"selected-rate",children:[" · ",ue]}):null]}),fe>0&&g.jsxs("span",{className:"selected-extra",children:["+",fe]}),g.jsx("span",{role:"button","aria-label":"Deselect",className:"selected-close",onClick:we=>{we.stopPropagation(),m()},children:"×"})]})})(),g.jsxs("div",{className:"actions",children:[g.jsxs("div",{className:"search",children:[g.jsx("span",{className:"search-icon","aria-hidden":!0,children:"⌕"}),g.jsx("input",{ref:Or,type:"text",placeholder:"Search agents, cwd, tools…",value:At,onChange:W=>mi(W.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),At?g.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>mi(""),children:"×"}):g.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"})]}),g.jsxs("span",{className:"status",role:"status",children:[g.jsx("span",{className:`pill ${L?"live":"dead"}`,title:L?"Receiving events":"SSE disconnected",children:L?"live":"offline"}),g.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[g.jsx("span",{className:"count",children:ir}),g.jsx("span",{className:"lbl",children:"sessions"})]}),g.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[g.jsx("span",{className:"count",children:mr}),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"})]}),tn.sum>0&&g.jsxs("span",{className:"stat",title:`in:${tn.inT.toLocaleString()} out:${tn.outT.toLocaleString()} cache-r:${tn.cacheR.toLocaleString()} cache-c:${tn.cacheC.toLocaleString()}`,children:[g.jsx("span",{className:"count",children:g$(tn.sum)}),g.jsx("span",{className:"lbl",children:"tokens"})]}),Ur.length>0&&g.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
60
60
  ${Ur.map(W=>` ${W.server}: ${W.count} call${W.count===1?"":"s"}`).join(`
61
61
  `)}`,children:[Ur.slice(0,6).map(W=>g.jsx("span",{className:"mcp-dot",style:{background:`hsl(${W.hue} 65% 65%)`}},W.server)),Ur.length>6&&g.jsxs("span",{className:"mcp-more",children:["+",Ur.length-6]}),g.jsx("span",{className:"lbl",children:"mcp"})]}),tn.cost.total>0&&(()=>{let W=0,J=0;for(const we of n.current.agents.values()){if(we.state!=="active")continue;const xe=fn(we.usage,we.model);W+=xe.total,J=Math.max(J,((we.endedAt??Ge)-we.startedAt)/1e3)}const ue=J>0?$l(W,J):null,fe=`input ${Fe(tn.cost.input)} + output ${Fe(tn.cost.output)} + cache r ${Fe(tn.cost.cacheRead)} + cache w ${Fe(tn.cost.cacheWrite)}${ue?`
62
62
  active burn: ${ue}`:""}`;return g.jsxs("span",{className:"stat",title:fe,children:[g.jsx("span",{className:"count",children:Fe(tn.cost.total)}),g.jsxs("span",{className:"lbl",children:["cost",ue?` · ${ue}`:""]})]})})()]}),g.jsx("button",{className:`btn ${Ke?"warn":""}`,onClick:()=>yt(W=>!W),title:"Pause/resume live updates (Space)",children:Ke?`Resume${et.current.length?` · ${et.current.length}`:""}`:"Pause"}),g.jsx("button",{className:`btn icon-btn ${O?"primary":""}`,onClick:()=>P(W=>!W),title:`${O?"Hide":"Show"} usage panel (U)`,"aria-label":"Toggle usage panel",children:"$"}),q!==null&&g.jsx("button",{className:`btn icon-btn ${q?"primary":""}`,onClick:W=>{if(W.shiftKey&&U>0){Q(!0),fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restore"})}).then(()=>fetch("/api/sound-hook")).then(J=>J.ok?J.json():null).then(J=>{J!=null&&J.ok&&(B(J.enabled===!0),ne(J.parked??0))}).catch(()=>{}).finally(()=>Q(!1));return}Y()},disabled:Z,title:(q?"Sound on turn finish: on — click to remove the hook":"Sound on turn finish: off — click to add a Stop hook")+(A>0?`