agent-dag 3.2.0 → 3.2.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.
@@ -54,25 +54,31 @@ Error generating stack: `+x.message+`
54
54
  * This source code is licensed under the MIT license found in the
55
55
  * LICENSE file in the root directory of this source tree.
56
56
  */var Qx;function BA(){if(Qx)return Af;Qx=1;var e=cl(),t=zA();function n(p,f){return p===f&&(p!==0||1/p===1/f)||p!==p&&f!==f}var s=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,a=e.useRef,l=e.useEffect,u=e.useMemo,h=e.useDebugValue;return Af.useSyncExternalStoreWithSelector=function(p,f,g,y,w){var S=a(null);if(S.current===null){var b={hasValue:!1,value:null};S.current=b}else b=S.current;S=u(function(){function k(P){if(!N){if(N=!0,j=P,P=y(P),w!==void 0&&b.hasValue){var I=b.value;if(w(I,P))return T=I}return T=P}if(I=T,s(j,P))return I;var F=y(P);return w!==void 0&&w(I,F)?(j=P,I):(j=P,T=F)}var N=!1,j,T,M=g===void 0?null:g;return[function(){return k(f())},M===null?void 0:function(){return k(M())}]},[f,g,y,w]);var _=o(p,S[0],S[1]);return l(function(){b.hasValue=!0,b.value=_},[_]),h(_),_},Af}var Zx;function UA(){return Zx||(Zx=1,Rf.exports=BA()),Rf.exports}var WA=UA();const HA=Vy(WA),GA={},Jx=e=>{let t;const n=new Set,s=(f,g)=>{const y=typeof f=="function"?f(t):f;if(!Object.is(y,t)){const w=t;t=g??(typeof y!="object"||y===null)?y:Object.assign({},t,y),n.forEach(S=>S(t,w))}},o=()=>t,h={setState:s,getState:o,getInitialState:()=>p,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(GA?"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."),n.clear()}},p=t=e(s,o,h);return h},VA=e=>e?Jx(e):Jx,{useDebugValue:YA}=ue,{useSyncExternalStoreWithSelector:KA}=HA,XA=e=>e;function bj(e,t=XA,n){const s=KA(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return YA(s),s}const eb=(e,t)=>{const n=VA(e),s=(o,a=t)=>bj(n,o,a);return Object.assign(s,n),s},QA=(e,t)=>e?eb(e,t):eb;function $t(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[s,o]of e)if(!Object.is(o,t.get(s)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const s of e)if(!t.has(s))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const s of n)if(!Object.prototype.hasOwnProperty.call(t,s)||!Object.is(e[s],t[s]))return!1;return!0}var ZA={value:()=>{}};function ku(){for(var e=0,t=arguments.length,n={},s;e<t;++e){if(!(s=arguments[e]+"")||s in n||/[\s.]/.test(s))throw new Error("illegal type: "+s);n[s]=[]}return new eu(n)}function eu(e){this._=e}function JA(e,t){return e.trim().split(/^|\s+/).map(function(n){var s="",o=n.indexOf(".");if(o>=0&&(s=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:s}})}eu.prototype=ku.prototype={constructor:eu,on:function(e,t){var n=this._,s=JA(e+"",n),o,a=-1,l=s.length;if(arguments.length<2){for(;++a<l;)if((o=(e=s[a]).type)&&(o=e2(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++a<l;)if(o=(e=s[a]).type)n[o]=tb(n[o],e.name,t);else if(t==null)for(o in n)n[o]=tb(n[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new eu(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var n=new Array(o),s=0,o,a;s<o;++s)n[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],s=0,o=a.length;s<o;++s)a[s].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var s=this._[e],o=0,a=s.length;o<a;++o)s[o].value.apply(t,n)}};function e2(e,t){for(var n=0,s=e.length,o;n<s;++n)if((o=e[n]).name===t)return o.value}function tb(e,t,n){for(var s=0,o=e.length;s<o;++s)if(e[s].name===t){e[s]=ZA,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var my="http://www.w3.org/1999/xhtml";const nb={svg:"http://www.w3.org/2000/svg",xhtml:my,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Su(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),nb.hasOwnProperty(t)?{space:nb[t],local:e}:e}function t2(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===my&&t.documentElement.namespaceURI===my?t.createElement(e):t.createElementNS(n,e)}}function n2(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function _j(e){var t=Su(e);return(t.local?n2:t2)(t)}function r2(){}function Yy(e){return e==null?r2:function(){return this.querySelector(e)}}function s2(e){typeof e!="function"&&(e=Yy(e));for(var t=this._groups,n=t.length,s=new Array(n),o=0;o<n;++o)for(var a=t[o],l=a.length,u=s[o]=new Array(l),h,p,f=0;f<l;++f)(h=a[f])&&(p=e.call(h,h.__data__,f,a))&&("__data__"in h&&(p.__data__=h.__data__),u[f]=p);return new _n(s,this._parents)}function i2(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function o2(){return[]}function kj(e){return e==null?o2:function(){return this.querySelectorAll(e)}}function a2(e){return function(){return i2(e.apply(this,arguments))}}function l2(e){typeof e=="function"?e=a2(e):e=kj(e);for(var t=this._groups,n=t.length,s=[],o=[],a=0;a<n;++a)for(var l=t[a],u=l.length,h,p=0;p<u;++p)(h=l[p])&&(s.push(e.call(h,h.__data__,p,l)),o.push(h));return new _n(s,o)}function Sj(e){return function(){return this.matches(e)}}function Nj(e){return function(t){return t.matches(e)}}var c2=Array.prototype.find;function u2(e){return function(){return c2.call(this.children,e)}}function d2(){return this.firstElementChild}function f2(e){return this.select(e==null?d2:u2(typeof e=="function"?e:Nj(e)))}var h2=Array.prototype.filter;function p2(){return Array.from(this.children)}function m2(e){return function(){return h2.call(this.children,e)}}function g2(e){return this.selectAll(e==null?p2:m2(typeof e=="function"?e:Nj(e)))}function v2(e){typeof e!="function"&&(e=Sj(e));for(var t=this._groups,n=t.length,s=new Array(n),o=0;o<n;++o)for(var a=t[o],l=a.length,u=s[o]=[],h,p=0;p<l;++p)(h=a[p])&&e.call(h,h.__data__,p,a)&&u.push(h);return new _n(s,this._parents)}function Ej(e){return new Array(e.length)}function y2(){return new _n(this._enter||this._groups.map(Ej),this._parents)}function ou(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}ou.prototype={constructor:ou,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function w2(e){return function(){return e}}function x2(e,t,n,s,o,a){for(var l=0,u,h=t.length,p=a.length;l<p;++l)(u=t[l])?(u.__data__=a[l],s[l]=u):n[l]=new ou(e,a[l]);for(;l<h;++l)(u=t[l])&&(o[l]=u)}function b2(e,t,n,s,o,a,l){var u,h,p=new Map,f=t.length,g=a.length,y=new Array(f),w;for(u=0;u<f;++u)(h=t[u])&&(y[u]=w=l.call(h,h.__data__,u,t)+"",p.has(w)?o[u]=h:p.set(w,h));for(u=0;u<g;++u)w=l.call(e,a[u],u,a)+"",(h=p.get(w))?(s[u]=h,h.__data__=a[u],p.delete(w)):n[u]=new ou(e,a[u]);for(u=0;u<f;++u)(h=t[u])&&p.get(y[u])===h&&(o[u]=h)}function _2(e){return e.__data__}function k2(e,t){if(!arguments.length)return Array.from(this,_2);var n=t?b2:x2,s=this._parents,o=this._groups;typeof e!="function"&&(e=w2(e));for(var a=o.length,l=new Array(a),u=new Array(a),h=new Array(a),p=0;p<a;++p){var f=s[p],g=o[p],y=g.length,w=S2(e.call(f,f&&f.__data__,p,s)),S=w.length,b=u[p]=new Array(S),_=l[p]=new Array(S),k=h[p]=new Array(y);n(f,g,b,_,k,w,t);for(var N=0,j=0,T,M;N<S;++N)if(T=b[N]){for(N>=j&&(j=N+1);!(M=_[j])&&++j<S;);T._next=M||null}}return l=new _n(l,s),l._enter=u,l._exit=h,l}function S2(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function N2(){return new _n(this._exit||this._groups.map(Ej),this._parents)}function E2(e,t,n){var s=this.enter(),o=this,a=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),t!=null&&(o=t(o),o&&(o=o.selection())),n==null?a.remove():n(a),s&&o?s.merge(o).order():o}function j2(e){for(var t=e.selection?e.selection():e,n=this._groups,s=t._groups,o=n.length,a=s.length,l=Math.min(o,a),u=new Array(o),h=0;h<l;++h)for(var p=n[h],f=s[h],g=p.length,y=u[h]=new Array(g),w,S=0;S<g;++S)(w=p[S]||f[S])&&(y[S]=w);for(;h<o;++h)u[h]=n[h];return new _n(u,this._parents)}function C2(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var s=e[t],o=s.length-1,a=s[o],l;--o>=0;)(l=s[o])&&(a&&l.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(l,a),a=l);return this}function T2(e){e||(e=R2);function t(g,y){return g&&y?e(g.__data__,y.__data__):!g-!y}for(var n=this._groups,s=n.length,o=new Array(s),a=0;a<s;++a){for(var l=n[a],u=l.length,h=o[a]=new Array(u),p,f=0;f<u;++f)(p=l[f])&&(h[f]=p);h.sort(t)}return new _n(o,this._parents).order()}function R2(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function A2(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function M2(){return Array.from(this)}function I2(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],o=0,a=s.length;o<a;++o){var l=s[o];if(l)return l}return null}function O2(){let e=0;for(const t of this)++e;return e}function P2(){return!this.node()}function $2(e){for(var t=this._groups,n=0,s=t.length;n<s;++n)for(var o=t[n],a=0,l=o.length,u;a<l;++a)(u=o[a])&&e.call(u,u.__data__,a,o);return this}function L2(e){return function(){this.removeAttribute(e)}}function q2(e){return function(){this.removeAttributeNS(e.space,e.local)}}function D2(e,t){return function(){this.setAttribute(e,t)}}function F2(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function z2(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function B2(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function U2(e,t){var n=Su(e);if(arguments.length<2){var s=this.node();return n.local?s.getAttributeNS(n.space,n.local):s.getAttribute(n)}return this.each((t==null?n.local?q2:L2:typeof t=="function"?n.local?B2:z2:n.local?F2:D2)(n,t))}function jj(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function W2(e){return function(){this.style.removeProperty(e)}}function H2(e,t,n){return function(){this.style.setProperty(e,t,n)}}function G2(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function V2(e,t,n){return arguments.length>1?this.each((t==null?W2:typeof t=="function"?G2:H2)(e,t,n??"")):Oo(this.node(),e)}function Oo(e,t){return e.style.getPropertyValue(t)||jj(e).getComputedStyle(e,null).getPropertyValue(t)}function Y2(e){return function(){delete this[e]}}function K2(e,t){return function(){this[e]=t}}function X2(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Q2(e,t){return arguments.length>1?this.each((t==null?Y2:typeof t=="function"?X2:K2)(e,t)):this.node()[e]}function Cj(e){return e.trim().split(/^|\s+/)}function Ky(e){return e.classList||new Tj(e)}function Tj(e){this._node=e,this._names=Cj(e.getAttribute("class")||"")}Tj.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Rj(e,t){for(var n=Ky(e),s=-1,o=t.length;++s<o;)n.add(t[s])}function Aj(e,t){for(var n=Ky(e),s=-1,o=t.length;++s<o;)n.remove(t[s])}function Z2(e){return function(){Rj(this,e)}}function J2(e){return function(){Aj(this,e)}}function eM(e,t){return function(){(t.apply(this,arguments)?Rj:Aj)(this,e)}}function tM(e,t){var n=Cj(e+"");if(arguments.length<2){for(var s=Ky(this.node()),o=-1,a=n.length;++o<a;)if(!s.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?eM:t?Z2:J2)(n,t))}function nM(){this.textContent=""}function rM(e){return function(){this.textContent=e}}function sM(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function iM(e){return arguments.length?this.each(e==null?nM:(typeof e=="function"?sM:rM)(e)):this.node().textContent}function oM(){this.innerHTML=""}function aM(e){return function(){this.innerHTML=e}}function lM(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function cM(e){return arguments.length?this.each(e==null?oM:(typeof e=="function"?lM:aM)(e)):this.node().innerHTML}function uM(){this.nextSibling&&this.parentNode.appendChild(this)}function dM(){return this.each(uM)}function fM(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function hM(){return this.each(fM)}function pM(e){var t=typeof e=="function"?e:_j(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function mM(){return null}function gM(e,t){var n=typeof e=="function"?e:_j(e),s=t==null?mM:typeof t=="function"?t:Yy(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function vM(){var e=this.parentNode;e&&e.removeChild(this)}function yM(){return this.each(vM)}function wM(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function xM(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function bM(e){return this.select(e?xM:wM)}function _M(e){return arguments.length?this.property("__data__",e):this.node().__data__}function kM(e){return function(t){e.call(this,t,this.__data__)}}function SM(e){return e.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");return s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),{type:t,name:n}})}function NM(e){return function(){var t=this.__on;if(t){for(var n=0,s=-1,o=t.length,a;n<o;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++s]=a;++s?t.length=s:delete this.__on}}}function EM(e,t,n){return function(){var s=this.__on,o,a=kM(t);if(s){for(var l=0,u=s.length;l<u;++l)if((o=s[l]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=a,o.options=n),o.value=t;return}}this.addEventListener(e.type,a,n),o={type:e.type,name:e.name,value:t,listener:a,options:n},s?s.push(o):this.__on=[o]}}function jM(e,t,n){var s=SM(e+""),o,a=s.length,l;if(arguments.length<2){var u=this.node().__on;if(u){for(var h=0,p=u.length,f;h<p;++h)for(o=0,f=u[h];o<a;++o)if((l=s[o]).type===f.type&&l.name===f.name)return f.value}return}for(u=t?EM:NM,o=0;o<a;++o)this.each(u(s[o],t,n));return this}function Mj(e,t,n){var s=jj(e),o=s.CustomEvent;typeof o=="function"?o=new o(t,n):(o=s.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function CM(e,t){return function(){return Mj(this,e,t)}}function TM(e,t){return function(){return Mj(this,e,t.apply(this,arguments))}}function RM(e,t){return this.each((typeof t=="function"?TM:CM)(e,t))}function*AM(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],o=0,a=s.length,l;o<a;++o)(l=s[o])&&(yield l)}var Ij=[null];function _n(e,t){this._groups=e,this._parents=t}function ul(){return new _n([[document.documentElement]],Ij)}function MM(){return this}_n.prototype=ul.prototype={constructor:_n,select:s2,selectAll:l2,selectChild:f2,selectChildren:g2,filter:v2,data:k2,enter:y2,exit:N2,join:E2,merge:j2,selection:MM,order:C2,sort:T2,call:A2,nodes:M2,node:I2,size:O2,empty:P2,each:$2,attr:U2,style:V2,property:Q2,classed:tM,text:iM,html:cM,raise:dM,lower:hM,append:pM,insert:gM,remove:yM,clone:bM,datum:_M,on:jM,dispatch:RM,[Symbol.iterator]:AM};function $n(e){return typeof e=="string"?new _n([[document.querySelector(e)]],[document.documentElement]):new _n([[e]],Ij)}function IM(e){let t;for(;t=e.sourceEvent;)e=t;return e}function rr(e,t){if(e=IM(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var s=n.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,s=s.matrixTransform(t.getScreenCTM().inverse()),[s.x,s.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const OM={passive:!1},Qa={capture:!0,passive:!1};function Of(e){e.stopImmediatePropagation()}function Co(e){e.preventDefault(),e.stopImmediatePropagation()}function Oj(e){var t=e.document.documentElement,n=$n(e).on("dragstart.drag",Co,Qa);"onselectstart"in t?n.on("selectstart.drag",Co,Qa):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Pj(e,t){var n=e.document.documentElement,s=$n(e).on("dragstart.drag",null);t&&(s.on("click.drag",Co,Qa),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in n?s.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Pc=e=>()=>e;function gy(e,{sourceEvent:t,subject:n,target:s,identifier:o,active:a,x:l,y:u,dx:h,dy:p,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:l,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:h,enumerable:!0,configurable:!0},dy:{value:p,enumerable:!0,configurable:!0},_:{value:f}})}gy.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function PM(e){return!e.ctrlKey&&!e.button}function $M(){return this.parentNode}function LM(e,t){return t??{x:e.x,y:e.y}}function qM(){return navigator.maxTouchPoints||"ontouchstart"in this}function DM(){var e=PM,t=$M,n=LM,s=qM,o={},a=ku("start","drag","end"),l=0,u,h,p,f,g=0;function y(T){T.on("mousedown.drag",w).filter(s).on("touchstart.drag",_).on("touchmove.drag",k,OM).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function w(T,M){if(!(f||!e.call(this,T,M))){var P=j(this,t.call(this,T,M),T,M,"mouse");P&&($n(T.view).on("mousemove.drag",S,Qa).on("mouseup.drag",b,Qa),Oj(T.view),Of(T),p=!1,u=T.clientX,h=T.clientY,P("start",T))}}function S(T){if(Co(T),!p){var M=T.clientX-u,P=T.clientY-h;p=M*M+P*P>g}o.mouse("drag",T)}function b(T){$n(T.view).on("mousemove.drag mouseup.drag",null),Pj(T.view,p),Co(T),o.mouse("end",T)}function _(T,M){if(e.call(this,T,M)){var P=T.changedTouches,I=t.call(this,T,M),F=P.length,O,A;for(O=0;O<F;++O)(A=j(this,I,T,M,P[O].identifier,P[O]))&&(Of(T),A("start",T,P[O]))}}function k(T){var M=T.changedTouches,P=M.length,I,F;for(I=0;I<P;++I)(F=o[M[I].identifier])&&(Co(T),F("drag",T,M[I]))}function N(T){var M=T.changedTouches,P=M.length,I,F;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),I=0;I<P;++I)(F=o[M[I].identifier])&&(Of(T),F("end",T,M[I]))}function j(T,M,P,I,F,O){var A=a.copy(),D=rr(O||P,M),H,K,C;if((C=n.call(T,new gy("beforestart",{sourceEvent:P,target:y,identifier:F,active:l,x:D[0],y:D[1],dx:0,dy:0,dispatch:A}),I))!=null)return H=C.x-D[0]||0,K=C.y-D[1]||0,function X(B,ne,J){var W=D,Q;switch(B){case"start":o[F]=X,Q=l++;break;case"end":delete o[F],--l;case"drag":D=rr(J||ne,M),Q=l;break}A.call(B,T,new gy(B,{sourceEvent:ne,subject:C,target:y,identifier:F,active:Q,x:D[0]+H,y:D[1]+K,dx:D[0]-W[0],dy:D[1]-W[1],dispatch:A}),I)}}return y.filter=function(T){return arguments.length?(e=typeof T=="function"?T:Pc(!!T),y):e},y.container=function(T){return arguments.length?(t=typeof T=="function"?T:Pc(T),y):t},y.subject=function(T){return arguments.length?(n=typeof T=="function"?T:Pc(T),y):n},y.touchable=function(T){return arguments.length?(s=typeof T=="function"?T:Pc(!!T),y):s},y.on=function(){var T=a.on.apply(a,arguments);return T===a?y:T},y.clickDistance=function(T){return arguments.length?(g=(T=+T)*T,y):Math.sqrt(g)},y}function Xy(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function $j(e,t){var n=Object.create(e.prototype);for(var s in t)n[s]=t[s];return n}function dl(){}var Za=.7,au=1/Za,To="\\s*([+-]?\\d+)\\s*",Ja="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Sr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",FM=/^#([0-9a-f]{3,8})$/,zM=new RegExp(`^rgb\\(${To},${To},${To}\\)$`),BM=new RegExp(`^rgb\\(${Sr},${Sr},${Sr}\\)$`),UM=new RegExp(`^rgba\\(${To},${To},${To},${Ja}\\)$`),WM=new RegExp(`^rgba\\(${Sr},${Sr},${Sr},${Ja}\\)$`),HM=new RegExp(`^hsl\\(${Ja},${Sr},${Sr}\\)$`),GM=new RegExp(`^hsla\\(${Ja},${Sr},${Sr},${Ja}\\)$`),rb={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};Xy(dl,el,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:sb,formatHex:sb,formatHex8:VM,formatHsl:YM,formatRgb:ib,toString:ib});function sb(){return this.rgb().formatHex()}function VM(){return this.rgb().formatHex8()}function YM(){return Lj(this).formatHsl()}function ib(){return this.rgb().formatRgb()}function el(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=FM.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?ob(t):n===3?new hn(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?$c(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?$c(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=zM.exec(e))?new hn(t[1],t[2],t[3],1):(t=BM.exec(e))?new hn(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=UM.exec(e))?$c(t[1],t[2],t[3],t[4]):(t=WM.exec(e))?$c(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=HM.exec(e))?cb(t[1],t[2]/100,t[3]/100,1):(t=GM.exec(e))?cb(t[1],t[2]/100,t[3]/100,t[4]):rb.hasOwnProperty(e)?ob(rb[e]):e==="transparent"?new hn(NaN,NaN,NaN,0):null}function ob(e){return new hn(e>>16&255,e>>8&255,e&255,1)}function $c(e,t,n,s){return s<=0&&(e=t=n=NaN),new hn(e,t,n,s)}function KM(e){return e instanceof dl||(e=el(e)),e?(e=e.rgb(),new hn(e.r,e.g,e.b,e.opacity)):new hn}function vy(e,t,n,s){return arguments.length===1?KM(e):new hn(e,t,n,s??1)}function hn(e,t,n,s){this.r=+e,this.g=+t,this.b=+n,this.opacity=+s}Xy(hn,vy,$j(dl,{brighter(e){return e=e==null?au:Math.pow(au,e),new hn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Za:Math.pow(Za,e),new hn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new hn(gi(this.r),gi(this.g),gi(this.b),lu(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:ab,formatHex:ab,formatHex8:XM,formatRgb:lb,toString:lb}));function ab(){return`#${pi(this.r)}${pi(this.g)}${pi(this.b)}`}function XM(){return`#${pi(this.r)}${pi(this.g)}${pi(this.b)}${pi((isNaN(this.opacity)?1:this.opacity)*255)}`}function lb(){const e=lu(this.opacity);return`${e===1?"rgb(":"rgba("}${gi(this.r)}, ${gi(this.g)}, ${gi(this.b)}${e===1?")":`, ${e})`}`}function lu(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function gi(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function pi(e){return e=gi(e),(e<16?"0":"")+e.toString(16)}function cb(e,t,n,s){return s<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new sr(e,t,n,s)}function Lj(e){if(e instanceof sr)return new sr(e.h,e.s,e.l,e.opacity);if(e instanceof dl||(e=el(e)),!e)return new sr;if(e instanceof sr)return e;e=e.rgb();var t=e.r/255,n=e.g/255,s=e.b/255,o=Math.min(t,n,s),a=Math.max(t,n,s),l=NaN,u=a-o,h=(a+o)/2;return u?(t===a?l=(n-s)/u+(n<s)*6:n===a?l=(s-t)/u+2:l=(t-n)/u+4,u/=h<.5?a+o:2-a-o,l*=60):u=h>0&&h<1?0:l,new sr(l,u,h,e.opacity)}function QM(e,t,n,s){return arguments.length===1?Lj(e):new sr(e,t,n,s??1)}function sr(e,t,n,s){this.h=+e,this.s=+t,this.l=+n,this.opacity=+s}Xy(sr,QM,$j(dl,{brighter(e){return e=e==null?au:Math.pow(au,e),new sr(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Za:Math.pow(Za,e),new sr(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,s=n+(n<.5?n:1-n)*t,o=2*n-s;return new hn(Pf(e>=240?e-240:e+120,o,s),Pf(e,o,s),Pf(e<120?e+240:e-120,o,s),this.opacity)},clamp(){return new sr(ub(this.h),Lc(this.s),Lc(this.l),lu(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=lu(this.opacity);return`${e===1?"hsl(":"hsla("}${ub(this.h)}, ${Lc(this.s)*100}%, ${Lc(this.l)*100}%${e===1?")":`, ${e})`}`}}));function ub(e){return e=(e||0)%360,e<0?e+360:e}function Lc(e){return Math.max(0,Math.min(1,e||0))}function Pf(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const qj=e=>()=>e;function ZM(e,t){return function(n){return e+n*t}}function JM(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(s){return Math.pow(e+s*t,n)}}function eI(e){return(e=+e)==1?Dj:function(t,n){return n-t?JM(t,n,e):qj(isNaN(t)?n:t)}}function Dj(e,t){var n=t-e;return n?ZM(e,n):qj(isNaN(e)?t:e)}const db=(function e(t){var n=eI(t);function s(o,a){var l=n((o=vy(o)).r,(a=vy(a)).r),u=n(o.g,a.g),h=n(o.b,a.b),p=Dj(o.opacity,a.opacity);return function(f){return o.r=l(f),o.g=u(f),o.b=h(f),o.opacity=p(f),o+""}}return s.gamma=e,s})(1);function js(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var yy=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,$f=new RegExp(yy.source,"g");function tI(e){return function(){return e}}function nI(e){return function(t){return e(t)+""}}function rI(e,t){var n=yy.lastIndex=$f.lastIndex=0,s,o,a,l=-1,u=[],h=[];for(e=e+"",t=t+"";(s=yy.exec(e))&&(o=$f.exec(t));)(a=o.index)>n&&(a=t.slice(n,a),u[l]?u[l]+=a:u[++l]=a),(s=s[0])===(o=o[0])?u[l]?u[l]+=o:u[++l]=o:(u[++l]=null,h.push({i:l,x:js(s,o)})),n=$f.lastIndex;return n<t.length&&(a=t.slice(n),u[l]?u[l]+=a:u[++l]=a),u.length<2?h[0]?nI(h[0].x):tI(t):(t=h.length,function(p){for(var f=0,g;f<t;++f)u[(g=h[f]).i]=g.x(p);return u.join("")})}var fb=180/Math.PI,wy={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Fj(e,t,n,s,o,a){var l,u,h;return(l=Math.sqrt(e*e+t*t))&&(e/=l,t/=l),(h=e*n+t*s)&&(n-=e*h,s-=t*h),(u=Math.sqrt(n*n+s*s))&&(n/=u,s/=u,h/=u),e*s<t*n&&(e=-e,t=-t,h=-h,l=-l),{translateX:o,translateY:a,rotate:Math.atan2(t,e)*fb,skewX:Math.atan(h)*fb,scaleX:l,scaleY:u}}var qc;function sI(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?wy:Fj(t.a,t.b,t.c,t.d,t.e,t.f)}function iI(e){return e==null||(qc||(qc=document.createElementNS("http://www.w3.org/2000/svg","g")),qc.setAttribute("transform",e),!(e=qc.transform.baseVal.consolidate()))?wy:(e=e.matrix,Fj(e.a,e.b,e.c,e.d,e.e,e.f))}function zj(e,t,n,s){function o(p){return p.length?p.pop()+" ":""}function a(p,f,g,y,w,S){if(p!==g||f!==y){var b=w.push("translate(",null,t,null,n);S.push({i:b-4,x:js(p,g)},{i:b-2,x:js(f,y)})}else(g||y)&&w.push("translate("+g+t+y+n)}function l(p,f,g,y){p!==f?(p-f>180?f+=360:f-p>180&&(p+=360),y.push({i:g.push(o(g)+"rotate(",null,s)-2,x:js(p,f)})):f&&g.push(o(g)+"rotate("+f+s)}function u(p,f,g,y){p!==f?y.push({i:g.push(o(g)+"skewX(",null,s)-2,x:js(p,f)}):f&&g.push(o(g)+"skewX("+f+s)}function h(p,f,g,y,w,S){if(p!==g||f!==y){var b=w.push(o(w)+"scale(",null,",",null,")");S.push({i:b-4,x:js(p,g)},{i:b-2,x:js(f,y)})}else(g!==1||y!==1)&&w.push(o(w)+"scale("+g+","+y+")")}return function(p,f){var g=[],y=[];return p=e(p),f=e(f),a(p.translateX,p.translateY,f.translateX,f.translateY,g,y),l(p.rotate,f.rotate,g,y),u(p.skewX,f.skewX,g,y),h(p.scaleX,p.scaleY,f.scaleX,f.scaleY,g,y),p=f=null,function(w){for(var S=-1,b=y.length,_;++S<b;)g[(_=y[S]).i]=_.x(w);return g.join("")}}}var oI=zj(sI,"px, ","px)","deg)"),aI=zj(iI,", ",")",")"),lI=1e-12;function hb(e){return((e=Math.exp(e))+1/e)/2}function cI(e){return((e=Math.exp(e))-1/e)/2}function uI(e){return((e=Math.exp(2*e))-1)/(e+1)}const dI=(function e(t,n,s){function o(a,l){var u=a[0],h=a[1],p=a[2],f=l[0],g=l[1],y=l[2],w=f-u,S=g-h,b=w*w+S*S,_,k;if(b<lI)k=Math.log(y/p)/t,_=function(I){return[u+I*w,h+I*S,p*Math.exp(t*I*k)]};else{var N=Math.sqrt(b),j=(y*y-p*p+s*b)/(2*p*n*N),T=(y*y-p*p-s*b)/(2*y*n*N),M=Math.log(Math.sqrt(j*j+1)-j),P=Math.log(Math.sqrt(T*T+1)-T);k=(P-M)/t,_=function(I){var F=I*k,O=hb(M),A=p/(n*N)*(O*uI(t*F+M)-cI(M));return[u+A*w,h+A*S,p*O/hb(t*F+M)]}}return _.duration=k*1e3*t/Math.SQRT2,_}return o.rho=function(a){var l=Math.max(.001,+a),u=l*l,h=u*u;return e(l,u,h)},o})(Math.SQRT2,2,4);var Po=0,Wa=0,$a=0,Bj=1e3,cu,Ha,uu=0,yi=0,Nu=0,tl=typeof performance=="object"&&performance.now?performance:Date,Uj=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Qy(){return yi||(Uj(fI),yi=tl.now()+Nu)}function fI(){yi=0}function du(){this._call=this._time=this._next=null}du.prototype=Wj.prototype={constructor:du,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Qy():+n)+(t==null?0:+t),!this._next&&Ha!==this&&(Ha?Ha._next=this:cu=this,Ha=this),this._call=e,this._time=n,xy()},stop:function(){this._call&&(this._call=null,this._time=1/0,xy())}};function Wj(e,t,n){var s=new du;return s.restart(e,t,n),s}function hI(){Qy(),++Po;for(var e=cu,t;e;)(t=yi-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Po}function pb(){yi=(uu=tl.now())+Nu,Po=Wa=0;try{hI()}finally{Po=0,mI(),yi=0}}function pI(){var e=tl.now(),t=e-uu;t>Bj&&(Nu-=t,uu=e)}function mI(){for(var e,t=cu,n,s=1/0;t;)t._call?(s>t._time&&(s=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:cu=n);Ha=e,xy(s)}function xy(e){if(!Po){Wa&&(Wa=clearTimeout(Wa));var t=e-yi;t>24?(e<1/0&&(Wa=setTimeout(pb,e-tl.now()-Nu)),$a&&($a=clearInterval($a))):($a||(uu=tl.now(),$a=setInterval(pI,Bj)),Po=1,Uj(pb))}}function mb(e,t,n){var s=new du;return t=t==null?0:+t,s.restart(o=>{s.stop(),e(o+t)},t,n),s}var gI=ku("start","end","cancel","interrupt"),vI=[],Hj=0,gb=1,by=2,tu=3,vb=4,_y=5,nu=6;function Eu(e,t,n,s,o,a){var l=e.__transition;if(!l)e.__transition={};else if(n in l)return;yI(e,n,{name:t,index:s,group:o,on:gI,tween:vI,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:Hj})}function Zy(e,t){var n=cr(e,t);if(n.state>Hj)throw new Error("too late; already scheduled");return n}function Nr(e,t){var n=cr(e,t);if(n.state>tu)throw new Error("too late; already running");return n}function cr(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function yI(e,t,n){var s=e.__transition,o;s[t]=n,n.timer=Wj(a,0,n.time);function a(p){n.state=gb,n.timer.restart(l,n.delay,n.time),n.delay<=p&&l(p-n.delay)}function l(p){var f,g,y,w;if(n.state!==gb)return h();for(f in s)if(w=s[f],w.name===n.name){if(w.state===tu)return mb(l);w.state===vb?(w.state=nu,w.timer.stop(),w.on.call("interrupt",e,e.__data__,w.index,w.group),delete s[f]):+f<t&&(w.state=nu,w.timer.stop(),w.on.call("cancel",e,e.__data__,w.index,w.group),delete s[f])}if(mb(function(){n.state===tu&&(n.state=vb,n.timer.restart(u,n.delay,n.time),u(p))}),n.state=by,n.on.call("start",e,e.__data__,n.index,n.group),n.state===by){for(n.state=tu,o=new Array(y=n.tween.length),f=0,g=-1;f<y;++f)(w=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(o[++g]=w);o.length=g+1}}function u(p){for(var f=p<n.duration?n.ease.call(null,p/n.duration):(n.timer.restart(h),n.state=_y,1),g=-1,y=o.length;++g<y;)o[g].call(e,f);n.state===_y&&(n.on.call("end",e,e.__data__,n.index,n.group),h())}function h(){n.state=nu,n.timer.stop(),delete s[t];for(var p in s)return;delete e.__transition}}function ru(e,t){var n=e.__transition,s,o,a=!0,l;if(n){t=t==null?null:t+"";for(l in n){if((s=n[l]).name!==t){a=!1;continue}o=s.state>by&&s.state<_y,s.state=nu,s.timer.stop(),s.on.call(o?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[l]}a&&delete e.__transition}}function wI(e){return this.each(function(){ru(this,e)})}function xI(e,t){var n,s;return function(){var o=Nr(this,e),a=o.tween;if(a!==n){s=n=a;for(var l=0,u=s.length;l<u;++l)if(s[l].name===t){s=s.slice(),s.splice(l,1);break}}o.tween=s}}function bI(e,t,n){var s,o;if(typeof n!="function")throw new Error;return function(){var a=Nr(this,e),l=a.tween;if(l!==s){o=(s=l).slice();for(var u={name:t,value:n},h=0,p=o.length;h<p;++h)if(o[h].name===t){o[h]=u;break}h===p&&o.push(u)}a.tween=o}}function _I(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=cr(this.node(),n).tween,o=0,a=s.length,l;o<a;++o)if((l=s[o]).name===e)return l.value;return null}return this.each((t==null?xI:bI)(n,e,t))}function Jy(e,t,n){var s=e._id;return e.each(function(){var o=Nr(this,s);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return cr(o,s).value[t]}}function Gj(e,t){var n;return(typeof t=="number"?js:t instanceof el?db:(n=el(t))?(t=n,db):rI)(e,t)}function kI(e){return function(){this.removeAttribute(e)}}function SI(e){return function(){this.removeAttributeNS(e.space,e.local)}}function NI(e,t,n){var s,o=n+"",a;return function(){var l=this.getAttribute(e);return l===o?null:l===s?a:a=t(s=l,n)}}function EI(e,t,n){var s,o=n+"",a;return function(){var l=this.getAttributeNS(e.space,e.local);return l===o?null:l===s?a:a=t(s=l,n)}}function jI(e,t,n){var s,o,a;return function(){var l,u=n(this),h;return u==null?void this.removeAttribute(e):(l=this.getAttribute(e),h=u+"",l===h?null:l===s&&h===o?a:(o=h,a=t(s=l,u)))}}function CI(e,t,n){var s,o,a;return function(){var l,u=n(this),h;return u==null?void this.removeAttributeNS(e.space,e.local):(l=this.getAttributeNS(e.space,e.local),h=u+"",l===h?null:l===s&&h===o?a:(o=h,a=t(s=l,u)))}}function TI(e,t){var n=Su(e),s=n==="transform"?aI:Gj;return this.attrTween(e,typeof t=="function"?(n.local?CI:jI)(n,s,Jy(this,"attr."+e,t)):t==null?(n.local?SI:kI)(n):(n.local?EI:NI)(n,s,t))}function RI(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function AI(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function MI(e,t){var n,s;function o(){var a=t.apply(this,arguments);return a!==s&&(n=(s=a)&&AI(e,a)),n}return o._value=t,o}function II(e,t){var n,s;function o(){var a=t.apply(this,arguments);return a!==s&&(n=(s=a)&&RI(e,a)),n}return o._value=t,o}function OI(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var s=Su(e);return this.tween(n,(s.local?MI:II)(s,t))}function PI(e,t){return function(){Zy(this,e).delay=+t.apply(this,arguments)}}function $I(e,t){return t=+t,function(){Zy(this,e).delay=t}}function LI(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?PI:$I)(t,e)):cr(this.node(),t).delay}function qI(e,t){return function(){Nr(this,e).duration=+t.apply(this,arguments)}}function DI(e,t){return t=+t,function(){Nr(this,e).duration=t}}function FI(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?qI:DI)(t,e)):cr(this.node(),t).duration}function zI(e,t){if(typeof t!="function")throw new Error;return function(){Nr(this,e).ease=t}}function BI(e){var t=this._id;return arguments.length?this.each(zI(t,e)):cr(this.node(),t).ease}function UI(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Nr(this,e).ease=n}}function WI(e){if(typeof e!="function")throw new Error;return this.each(UI(this._id,e))}function HI(e){typeof e!="function"&&(e=Sj(e));for(var t=this._groups,n=t.length,s=new Array(n),o=0;o<n;++o)for(var a=t[o],l=a.length,u=s[o]=[],h,p=0;p<l;++p)(h=a[p])&&e.call(h,h.__data__,p,a)&&u.push(h);return new Kr(s,this._parents,this._name,this._id)}function GI(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,s=t.length,o=n.length,a=Math.min(s,o),l=new Array(s),u=0;u<a;++u)for(var h=t[u],p=n[u],f=h.length,g=l[u]=new Array(f),y,w=0;w<f;++w)(y=h[w]||p[w])&&(g[w]=y);for(;u<s;++u)l[u]=t[u];return new Kr(l,this._parents,this._name,this._id)}function VI(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function YI(e,t,n){var s,o,a=VI(t)?Zy:Nr;return function(){var l=a(this,e),u=l.on;u!==s&&(o=(s=u).copy()).on(t,n),l.on=o}}function KI(e,t){var n=this._id;return arguments.length<2?cr(this.node(),n).on.on(e):this.each(YI(n,e,t))}function XI(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function QI(){return this.on("end.remove",XI(this._id))}function ZI(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Yy(e));for(var s=this._groups,o=s.length,a=new Array(o),l=0;l<o;++l)for(var u=s[l],h=u.length,p=a[l]=new Array(h),f,g,y=0;y<h;++y)(f=u[y])&&(g=e.call(f,f.__data__,y,u))&&("__data__"in f&&(g.__data__=f.__data__),p[y]=g,Eu(p[y],t,n,y,p,cr(f,n)));return new Kr(a,this._parents,t,n)}function JI(e){var t=this._name,n=this._id;typeof e!="function"&&(e=kj(e));for(var s=this._groups,o=s.length,a=[],l=[],u=0;u<o;++u)for(var h=s[u],p=h.length,f,g=0;g<p;++g)if(f=h[g]){for(var y=e.call(f,f.__data__,g,h),w,S=cr(f,n),b=0,_=y.length;b<_;++b)(w=y[b])&&Eu(w,t,n,b,y,S);a.push(y),l.push(f)}return new Kr(a,l,t,n)}var eO=ul.prototype.constructor;function tO(){return new eO(this._groups,this._parents)}function nO(e,t){var n,s,o;return function(){var a=Oo(this,e),l=(this.style.removeProperty(e),Oo(this,e));return a===l?null:a===n&&l===s?o:o=t(n=a,s=l)}}function Vj(e){return function(){this.style.removeProperty(e)}}function rO(e,t,n){var s,o=n+"",a;return function(){var l=Oo(this,e);return l===o?null:l===s?a:a=t(s=l,n)}}function sO(e,t,n){var s,o,a;return function(){var l=Oo(this,e),u=n(this),h=u+"";return u==null&&(h=u=(this.style.removeProperty(e),Oo(this,e))),l===h?null:l===s&&h===o?a:(o=h,a=t(s=l,u))}}function iO(e,t){var n,s,o,a="style."+t,l="end."+a,u;return function(){var h=Nr(this,e),p=h.on,f=h.value[a]==null?u||(u=Vj(t)):void 0;(p!==n||o!==f)&&(s=(n=p).copy()).on(l,o=f),h.on=s}}function oO(e,t,n){var s=(e+="")=="transform"?oI:Gj;return t==null?this.styleTween(e,nO(e,s)).on("end.style."+e,Vj(e)):typeof t=="function"?this.styleTween(e,sO(e,s,Jy(this,"style."+e,t))).each(iO(this._id,e)):this.styleTween(e,rO(e,s,t),n).on("end.style."+e,null)}function aO(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function lO(e,t,n){var s,o;function a(){var l=t.apply(this,arguments);return l!==o&&(s=(o=l)&&aO(e,l,n)),s}return a._value=t,a}function cO(e,t,n){var s="style."+(e+="");if(arguments.length<2)return(s=this.tween(s))&&s._value;if(t==null)return this.tween(s,null);if(typeof t!="function")throw new Error;return this.tween(s,lO(e,t,n??""))}function uO(e){return function(){this.textContent=e}}function dO(e){return function(){var t=e(this);this.textContent=t??""}}function fO(e){return this.tween("text",typeof e=="function"?dO(Jy(this,"text",e)):uO(e==null?"":e+""))}function hO(e){return function(t){this.textContent=e.call(this,t)}}function pO(e){var t,n;function s(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&hO(o)),t}return s._value=e,s}function mO(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,pO(e))}function gO(){for(var e=this._name,t=this._id,n=Yj(),s=this._groups,o=s.length,a=0;a<o;++a)for(var l=s[a],u=l.length,h,p=0;p<u;++p)if(h=l[p]){var f=cr(h,t);Eu(h,e,n,p,l,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new Kr(s,this._parents,e,n)}function vO(){var e,t,n=this,s=n._id,o=n.size();return new Promise(function(a,l){var u={value:l},h={value:function(){--o===0&&a()}};n.each(function(){var p=Nr(this,s),f=p.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(u),t._.interrupt.push(u),t._.end.push(h)),p.on=t}),o===0&&a()})}var yO=0;function Kr(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function Yj(){return++yO}var Gr=ul.prototype;Kr.prototype={constructor:Kr,select:ZI,selectAll:JI,selectChild:Gr.selectChild,selectChildren:Gr.selectChildren,filter:HI,merge:GI,selection:tO,transition:gO,call:Gr.call,nodes:Gr.nodes,node:Gr.node,size:Gr.size,empty:Gr.empty,each:Gr.each,on:KI,attr:TI,attrTween:OI,style:oO,styleTween:cO,text:fO,textTween:mO,remove:QI,tween:_I,delay:LI,duration:FI,ease:BI,easeVarying:WI,end:vO,[Symbol.iterator]:Gr[Symbol.iterator]};function wO(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var xO={time:null,delay:0,duration:250,ease:wO};function bO(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function _O(e){var t,n;e instanceof Kr?(t=e._id,e=e._name):(t=Yj(),(n=xO).time=Qy(),e=e==null?null:e+"");for(var s=this._groups,o=s.length,a=0;a<o;++a)for(var l=s[a],u=l.length,h,p=0;p<u;++p)(h=l[p])&&Eu(h,e,t,p,l,n||bO(h,t));return new Kr(s,this._parents,e,t)}ul.prototype.interrupt=wI;ul.prototype.transition=_O;const Dc=e=>()=>e;function kO(e,{sourceEvent:t,target:n,transform:s,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:o}})}function Vr(e,t,n){this.k=e,this.x=t,this.y=n}Vr.prototype={constructor:Vr,scale:function(e){return e===1?this:new Vr(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Vr(this.k,this.x+this.k*e,this.y+this.k*t)},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 Yr=new Vr(1,0,0);Vr.prototype;function Lf(e){e.stopImmediatePropagation()}function La(e){e.preventDefault(),e.stopImmediatePropagation()}function SO(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function NO(){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 yb(){return this.__zoom||Yr}function EO(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function jO(){return navigator.maxTouchPoints||"ontouchstart"in this}function CO(e,t,n){var s=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],l=e.invertY(t[1][1])-n[1][1];return e.translate(o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o),l>a?(a+l)/2:Math.min(0,a)||Math.max(0,l))}function Kj(){var e=SO,t=NO,n=CO,s=EO,o=jO,a=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],u=250,h=dI,p=ku("start","zoom","end"),f,g,y,w=500,S=150,b=0,_=10;function k(C){C.property("__zoom",yb).on("wheel.zoom",F,{passive:!1}).on("mousedown.zoom",O).on("dblclick.zoom",A).filter(o).on("touchstart.zoom",D).on("touchmove.zoom",H).on("touchend.zoom touchcancel.zoom",K).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}k.transform=function(C,X,B,ne){var J=C.selection?C.selection():C;J.property("__zoom",yb),C!==J?M(C,X,B,ne):J.interrupt().each(function(){P(this,arguments).event(ne).start().zoom(null,typeof X=="function"?X.apply(this,arguments):X).end()})},k.scaleBy=function(C,X,B,ne){k.scaleTo(C,function(){var J=this.__zoom.k,W=typeof X=="function"?X.apply(this,arguments):X;return J*W},B,ne)},k.scaleTo=function(C,X,B,ne){k.transform(C,function(){var J=t.apply(this,arguments),W=this.__zoom,Q=B==null?T(J):typeof B=="function"?B.apply(this,arguments):B,$=W.invert(Q),G=typeof X=="function"?X.apply(this,arguments):X;return n(j(N(W,G),Q,$),J,l)},B,ne)},k.translateBy=function(C,X,B,ne){k.transform(C,function(){return n(this.__zoom.translate(typeof X=="function"?X.apply(this,arguments):X,typeof B=="function"?B.apply(this,arguments):B),t.apply(this,arguments),l)},null,ne)},k.translateTo=function(C,X,B,ne,J){k.transform(C,function(){var W=t.apply(this,arguments),Q=this.__zoom,$=ne==null?T(W):typeof ne=="function"?ne.apply(this,arguments):ne;return n(Yr.translate($[0],$[1]).scale(Q.k).translate(typeof X=="function"?-X.apply(this,arguments):-X,typeof B=="function"?-B.apply(this,arguments):-B),W,l)},ne,J)};function N(C,X){return X=Math.max(a[0],Math.min(a[1],X)),X===C.k?C:new Vr(X,C.x,C.y)}function j(C,X,B){var ne=X[0]-B[0]*C.k,J=X[1]-B[1]*C.k;return ne===C.x&&J===C.y?C:new Vr(C.k,ne,J)}function T(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function M(C,X,B,ne){C.on("start.zoom",function(){P(this,arguments).event(ne).start()}).on("interrupt.zoom end.zoom",function(){P(this,arguments).event(ne).end()}).tween("zoom",function(){var J=this,W=arguments,Q=P(J,W).event(ne),$=t.apply(J,W),G=B==null?T($):typeof B=="function"?B.apply(J,W):B,Y=Math.max($[1][0]-$[0][0],$[1][1]-$[0][1]),L=J.__zoom,q=typeof X=="function"?X.apply(J,W):X,Z=h(L.invert(G).concat(Y/L.k),q.invert(G).concat(Y/q.k));return function(se){if(se===1)se=q;else{var fe=Z(se),he=Y/fe[2];se=new Vr(he,G[0]-fe[0]*he,G[1]-fe[1]*he)}Q.zoom(null,se)}})}function P(C,X,B){return!B&&C.__zooming||new I(C,X)}function I(C,X){this.that=C,this.args=X,this.active=0,this.sourceEvent=null,this.extent=t.apply(C,X),this.taps=0}I.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,X){return this.mouse&&C!=="mouse"&&(this.mouse[1]=X.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=X.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=X.invert(this.touch1[0])),this.that.__zoom=X,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var X=$n(this.that).datum();p.call(C,this.that,new kO(C,{sourceEvent:this.sourceEvent,target:k,transform:this.that.__zoom,dispatch:p}),X)}};function F(C,...X){if(!e.apply(this,arguments))return;var B=P(this,X).event(C),ne=this.__zoom,J=Math.max(a[0],Math.min(a[1],ne.k*Math.pow(2,s.apply(this,arguments)))),W=rr(C);if(B.wheel)(B.mouse[0][0]!==W[0]||B.mouse[0][1]!==W[1])&&(B.mouse[1]=ne.invert(B.mouse[0]=W)),clearTimeout(B.wheel);else{if(ne.k===J)return;B.mouse=[W,ne.invert(W)],ru(this),B.start()}La(C),B.wheel=setTimeout(Q,S),B.zoom("mouse",n(j(N(ne,J),B.mouse[0],B.mouse[1]),B.extent,l));function Q(){B.wheel=null,B.end()}}function O(C,...X){if(y||!e.apply(this,arguments))return;var B=C.currentTarget,ne=P(this,X,!0).event(C),J=$n(C.view).on("mousemove.zoom",G,!0).on("mouseup.zoom",Y,!0),W=rr(C,B),Q=C.clientX,$=C.clientY;Oj(C.view),Lf(C),ne.mouse=[W,this.__zoom.invert(W)],ru(this),ne.start();function G(L){if(La(L),!ne.moved){var q=L.clientX-Q,Z=L.clientY-$;ne.moved=q*q+Z*Z>b}ne.event(L).zoom("mouse",n(j(ne.that.__zoom,ne.mouse[0]=rr(L,B),ne.mouse[1]),ne.extent,l))}function Y(L){J.on("mousemove.zoom mouseup.zoom",null),Pj(L.view,ne.moved),La(L),ne.event(L).end()}}function A(C,...X){if(e.apply(this,arguments)){var B=this.__zoom,ne=rr(C.changedTouches?C.changedTouches[0]:C,this),J=B.invert(ne),W=B.k*(C.shiftKey?.5:2),Q=n(j(N(B,W),ne,J),t.apply(this,X),l);La(C),u>0?$n(this).transition().duration(u).call(M,Q,ne,C):$n(this).call(k.transform,Q,ne,C)}}function D(C,...X){if(e.apply(this,arguments)){var B=C.touches,ne=B.length,J=P(this,X,C.changedTouches.length===ne).event(C),W,Q,$,G;for(Lf(C),Q=0;Q<ne;++Q)$=B[Q],G=rr($,this),G=[G,this.__zoom.invert(G),$.identifier],J.touch0?!J.touch1&&J.touch0[2]!==G[2]&&(J.touch1=G,J.taps=0):(J.touch0=G,W=!0,J.taps=1+!!f);f&&(f=clearTimeout(f)),W&&(J.taps<2&&(g=G[0],f=setTimeout(function(){f=null},w)),ru(this),J.start())}}function H(C,...X){if(this.__zooming){var B=P(this,X).event(C),ne=C.changedTouches,J=ne.length,W,Q,$,G;for(La(C),W=0;W<J;++W)Q=ne[W],$=rr(Q,this),B.touch0&&B.touch0[2]===Q.identifier?B.touch0[0]=$:B.touch1&&B.touch1[2]===Q.identifier&&(B.touch1[0]=$);if(Q=B.that.__zoom,B.touch1){var Y=B.touch0[0],L=B.touch0[1],q=B.touch1[0],Z=B.touch1[1],se=(se=q[0]-Y[0])*se+(se=q[1]-Y[1])*se,fe=(fe=Z[0]-L[0])*fe+(fe=Z[1]-L[1])*fe;Q=N(Q,Math.sqrt(se/fe)),$=[(Y[0]+q[0])/2,(Y[1]+q[1])/2],G=[(L[0]+Z[0])/2,(L[1]+Z[1])/2]}else if(B.touch0)$=B.touch0[0],G=B.touch0[1];else return;B.zoom("touch",n(j(Q,$,G),B.extent,l))}}function K(C,...X){if(this.__zooming){var B=P(this,X).event(C),ne=C.changedTouches,J=ne.length,W,Q;for(Lf(C),y&&clearTimeout(y),y=setTimeout(function(){y=null},w),W=0;W<J;++W)Q=ne[W],B.touch0&&B.touch0[2]===Q.identifier?delete B.touch0:B.touch1&&B.touch1[2]===Q.identifier&&delete B.touch1;if(B.touch1&&!B.touch0&&(B.touch0=B.touch1,delete B.touch1),B.touch0)B.touch0[1]=this.__zoom.invert(B.touch0[0]);else if(B.end(),B.taps===2&&(Q=rr(Q,this),Math.hypot(g[0]-Q[0],g[1]-Q[1])<_)){var $=$n(this).on("dblclick.zoom");$&&$.apply(this,arguments)}}}return k.wheelDelta=function(C){return arguments.length?(s=typeof C=="function"?C:Dc(+C),k):s},k.filter=function(C){return arguments.length?(e=typeof C=="function"?C:Dc(!!C),k):e},k.touchable=function(C){return arguments.length?(o=typeof C=="function"?C:Dc(!!C),k):o},k.extent=function(C){return arguments.length?(t=typeof C=="function"?C:Dc([[+C[0][0],+C[0][1]],[+C[1][0],+C[1][1]]]),k):t},k.scaleExtent=function(C){return arguments.length?(a[0]=+C[0],a[1]=+C[1],k):[a[0],a[1]]},k.translateExtent=function(C){return arguments.length?(l[0][0]=+C[0][0],l[1][0]=+C[1][0],l[0][1]=+C[0][1],l[1][1]=+C[1][1],k):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},k.constrain=function(C){return arguments.length?(n=C,k):n},k.duration=function(C){return arguments.length?(u=+C,k):u},k.interpolate=function(C){return arguments.length?(h=C,k):h},k.on=function(){var C=p.on.apply(p,arguments);return C===p?k:C},k.clickDistance=function(C){return arguments.length?(b=(C=+C)*C,k):Math.sqrt(b)},k.tapDistance=function(C){return arguments.length?(_=+C,k):_},k}var ew=xj();const ju=E.createContext(null),TO=ju.Provider,Xr={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,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.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.`},Xj=Xr.error001();function rt(e,t){const n=E.useContext(ju);if(n===null)throw new Error(Xj);return bj(n,e,t)}const Tt=()=>{const e=E.useContext(ju);if(e===null)throw new Error(Xj);return E.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},RO=e=>e.userSelectionActive?"none":"all";function tw({position:e,children:t,className:n,style:s,...o}){const a=rt(RO),l=`${e}`.split("-");return ue.createElement("div",{className:Ht(["react-flow__panel",n,...l]),style:{...s,pointerEvents:a},...o},t)}function AO({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:ue.createElement(tw,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},ue.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const MO=({x:e,y:t,label:n,labelStyle:s={},labelShowBg:o=!0,labelBgStyle:a={},labelBgPadding:l=[2,4],labelBgBorderRadius:u=2,children:h,className:p,...f})=>{const g=E.useRef(null),[y,w]=E.useState({x:0,y:0,width:0,height:0}),S=Ht(["react-flow__edge-textwrapper",p]);return E.useEffect(()=>{if(g.current){const b=g.current.getBBox();w({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),typeof n>"u"||!n?null:ue.createElement("g",{transform:`translate(${e-y.width/2} ${t-y.height/2})`,className:S,visibility:y.width?"visible":"hidden",...f},o&&ue.createElement("rect",{width:y.width+2*l[0],x:-l[0],y:-l[1],height:y.height+2*l[1],className:"react-flow__edge-textbg",style:a,rx:u,ry:u}),ue.createElement("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:g,style:s},n),h)};var IO=E.memo(MO);const nw=e=>({width:e.offsetWidth,height:e.offsetHeight}),$o=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),rw=(e={x:0,y:0},t)=>({x:$o(e.x,t[0][0],t[1][0]),y:$o(e.y,t[0][1],t[1][1])}),wb=(e,t,n)=>e<t?$o(Math.abs(e-t),1,50)/50:e>n?-$o(Math.abs(e-n),1,50)/50:0,Qj=(e,t)=>{const n=wb(e.x,35,t.width-35)*20,s=wb(e.y,35,t.height-35)*20;return[n,s]},Zj=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Jj=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),nl=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),eC=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),xb=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),OO=(e,t)=>eC(Jj(nl(e),nl(t))),ky=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),s=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*s)},PO=e=>Ln(e.width)&&Ln(e.height)&&Ln(e.x)&&Ln(e.y),Ln=e=>!isNaN(e)&&isFinite(e),Nt=Symbol.for("internals"),tC=["Enter"," ","Escape"],$O=(e,t)=>{},LO=e=>"nativeEvent"in e;function Sy(e){var o,a;const t=LO(e)?e.nativeEvent:e,n=((a=(o=t.composedPath)==null?void 0:o.call(t))==null?void 0:a[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const nC=e=>"clientX"in e,Rs=(e,t)=>{var a,l;const n=nC(e),s=n?e.clientX:(a=e.touches)==null?void 0:a[0].clientX,o=n?e.clientY:(l=e.touches)==null?void 0:l[0].clientY;return{x:s-((t==null?void 0:t.left)??0),y:o-((t==null?void 0:t.top)??0)}},fu=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},fl=({id:e,path:t,labelX:n,labelY:s,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:u,labelBgPadding:h,labelBgBorderRadius:p,style:f,markerEnd:g,markerStart:y,interactionWidth:w=20})=>ue.createElement(ue.Fragment,null,ue.createElement("path",{id:e,style:f,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:g,markerStart:y}),w&&ue.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:w,className:"react-flow__edge-interaction"}),o&&Ln(n)&&Ln(s)?ue.createElement(IO,{x:n,y:s,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:u,labelBgPadding:h,labelBgBorderRadius:p}):null);fl.displayName="BaseEdge";function qa(e,t,n){return n===void 0?n:s=>{const o=t().edges.find(a=>a.id===e);o&&n(s,{...o})}}function rC({sourceX:e,sourceY:t,targetX:n,targetY:s}){const o=Math.abs(n-e)/2,a=n<e?n+o:n-o,l=Math.abs(s-t)/2,u=s<t?s+l:s-l;return[a,u,o,l]}function sC({sourceX:e,sourceY:t,targetX:n,targetY:s,sourceControlX:o,sourceControlY:a,targetControlX:l,targetControlY:u}){const h=e*.125+o*.375+l*.375+n*.125,p=t*.125+a*.375+u*.375+s*.125,f=Math.abs(h-e),g=Math.abs(p-t);return[h,p,f,g]}var wi;(function(e){e.Strict="strict",e.Loose="loose"})(wi||(wi={}));var mi;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(mi||(mi={}));var rl;(function(e){e.Partial="partial",e.Full="full"})(rl||(rl={}));var Ts;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ts||(Ts={}));var hu;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(hu||(hu={}));var Oe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Oe||(Oe={}));function bb({pos:e,x1:t,y1:n,x2:s,y2:o}){return e===Oe.Left||e===Oe.Right?[.5*(t+s),n]:[t,.5*(n+o)]}function iC({sourceX:e,sourceY:t,sourcePosition:n=Oe.Bottom,targetX:s,targetY:o,targetPosition:a=Oe.Top}){const[l,u]=bb({pos:n,x1:e,y1:t,x2:s,y2:o}),[h,p]=bb({pos:a,x1:s,y1:o,x2:e,y2:t}),[f,g,y,w]=sC({sourceX:e,sourceY:t,targetX:s,targetY:o,sourceControlX:l,sourceControlY:u,targetControlX:h,targetControlY:p});return[`M${e},${t} C${l},${u} ${h},${p} ${s},${o}`,f,g,y,w]}const sw=E.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:o=Oe.Bottom,targetPosition:a=Oe.Top,label:l,labelStyle:u,labelShowBg:h,labelBgStyle:p,labelBgPadding:f,labelBgBorderRadius:g,style:y,markerEnd:w,markerStart:S,interactionWidth:b})=>{const[_,k,N]=iC({sourceX:e,sourceY:t,sourcePosition:o,targetX:n,targetY:s,targetPosition:a});return ue.createElement(fl,{path:_,labelX:k,labelY:N,label:l,labelStyle:u,labelShowBg:h,labelBgStyle:p,labelBgPadding:f,labelBgBorderRadius:g,style:y,markerEnd:w,markerStart:S,interactionWidth:b})});sw.displayName="SimpleBezierEdge";const _b={[Oe.Left]:{x:-1,y:0},[Oe.Right]:{x:1,y:0},[Oe.Top]:{x:0,y:-1},[Oe.Bottom]:{x:0,y:1}},qO=({source:e,sourcePosition:t=Oe.Bottom,target:n})=>t===Oe.Left||t===Oe.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},kb=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function DO({source:e,sourcePosition:t=Oe.Bottom,target:n,targetPosition:s=Oe.Top,center:o,offset:a}){const l=_b[t],u=_b[s],h={x:e.x+l.x*a,y:e.y+l.y*a},p={x:n.x+u.x*a,y:n.y+u.y*a},f=qO({source:h,sourcePosition:t,target:p}),g=f.x!==0?"x":"y",y=f[g];let w=[],S,b;const _={x:0,y:0},k={x:0,y:0},[N,j,T,M]=rC({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[g]*u[g]===-1){S=o.x??N,b=o.y??j;const I=[{x:S,y:h.y},{x:S,y:p.y}],F=[{x:h.x,y:b},{x:p.x,y:b}];l[g]===y?w=g==="x"?I:F:w=g==="x"?F:I}else{const I=[{x:h.x,y:p.y}],F=[{x:p.x,y:h.y}];if(g==="x"?w=l.x===y?F:I:w=l.y===y?I:F,t===s){const K=Math.abs(e[g]-n[g]);if(K<=a){const C=Math.min(a-1,a-K);l[g]===y?_[g]=(h[g]>e[g]?-1:1)*C:k[g]=(p[g]>n[g]?-1:1)*C}}if(t!==s){const K=g==="x"?"y":"x",C=l[g]===u[K],X=h[K]>p[K],B=h[K]<p[K];(l[g]===1&&(!C&&X||C&&B)||l[g]!==1&&(!C&&B||C&&X))&&(w=g==="x"?I:F)}const O={x:h.x+_.x,y:h.y+_.y},A={x:p.x+k.x,y:p.y+k.y},D=Math.max(Math.abs(O.x-w[0].x),Math.abs(A.x-w[0].x)),H=Math.max(Math.abs(O.y-w[0].y),Math.abs(A.y-w[0].y));D>=H?(S=(O.x+A.x)/2,b=w[0].y):(S=w[0].x,b=(O.y+A.y)/2)}return[[e,{x:h.x+_.x,y:h.y+_.y},...w,{x:p.x+k.x,y:p.y+k.y},n],S,b,T,M]}function FO(e,t,n,s){const o=Math.min(kb(e,t)/2,kb(t,n)/2,s),{x:a,y:l}=t;if(e.x===a&&a===n.x||e.y===l&&l===n.y)return`L${a} ${l}`;if(e.y===l){const p=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${a+o*p},${l}Q ${a},${l} ${a},${l+o*f}`}const u=e.x<n.x?1:-1,h=e.y<n.y?-1:1;return`L ${a},${l+o*h}Q ${a},${l} ${a+o*u},${l}`}function Ny({sourceX:e,sourceY:t,sourcePosition:n=Oe.Bottom,targetX:s,targetY:o,targetPosition:a=Oe.Top,borderRadius:l=5,centerX:u,centerY:h,offset:p=20}){const[f,g,y,w,S]=DO({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:o},targetPosition:a,center:{x:u,y:h},offset:p});return[f.reduce((_,k,N)=>{let j="";return N>0&&N<f.length-1?j=FO(f[N-1],k,f[N+1],l):j=`${N===0?"M":"L"}${k.x} ${k.y}`,_+=j,_},""),g,y,w,S]}const Cu=E.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:u,labelBgPadding:h,labelBgBorderRadius:p,style:f,sourcePosition:g=Oe.Bottom,targetPosition:y=Oe.Top,markerEnd:w,markerStart:S,pathOptions:b,interactionWidth:_})=>{const[k,N,j]=Ny({sourceX:e,sourceY:t,sourcePosition:g,targetX:n,targetY:s,targetPosition:y,borderRadius:b==null?void 0:b.borderRadius,offset:b==null?void 0:b.offset});return ue.createElement(fl,{path:k,labelX:N,labelY:j,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:u,labelBgPadding:h,labelBgBorderRadius:p,style:f,markerEnd:w,markerStart:S,interactionWidth:_})});Cu.displayName="SmoothStepEdge";const iw=E.memo(e=>{var t;return ue.createElement(Cu,{...e,pathOptions:E.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});iw.displayName="StepEdge";function zO({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[o,a,l,u]=rC({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,o,a,l,u]}const ow=E.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:u,labelBgPadding:h,labelBgBorderRadius:p,style:f,markerEnd:g,markerStart:y,interactionWidth:w})=>{const[S,b,_]=zO({sourceX:e,sourceY:t,targetX:n,targetY:s});return ue.createElement(fl,{path:S,labelX:b,labelY:_,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:u,labelBgPadding:h,labelBgBorderRadius:p,style:f,markerEnd:g,markerStart:y,interactionWidth:w})});ow.displayName="StraightEdge";function Fc(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Sb({pos:e,x1:t,y1:n,x2:s,y2:o,c:a}){switch(e){case Oe.Left:return[t-Fc(t-s,a),n];case Oe.Right:return[t+Fc(s-t,a),n];case Oe.Top:return[t,n-Fc(n-o,a)];case Oe.Bottom:return[t,n+Fc(o-n,a)]}}function oC({sourceX:e,sourceY:t,sourcePosition:n=Oe.Bottom,targetX:s,targetY:o,targetPosition:a=Oe.Top,curvature:l=.25}){const[u,h]=Sb({pos:n,x1:e,y1:t,x2:s,y2:o,c:l}),[p,f]=Sb({pos:a,x1:s,y1:o,x2:e,y2:t,c:l}),[g,y,w,S]=sC({sourceX:e,sourceY:t,targetX:s,targetY:o,sourceControlX:u,sourceControlY:h,targetControlX:p,targetControlY:f});return[`M${e},${t} C${u},${h} ${p},${f} ${s},${o}`,g,y,w,S]}const pu=E.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:o=Oe.Bottom,targetPosition:a=Oe.Top,label:l,labelStyle:u,labelShowBg:h,labelBgStyle:p,labelBgPadding:f,labelBgBorderRadius:g,style:y,markerEnd:w,markerStart:S,pathOptions:b,interactionWidth:_})=>{const[k,N,j]=oC({sourceX:e,sourceY:t,sourcePosition:o,targetX:n,targetY:s,targetPosition:a,curvature:b==null?void 0:b.curvature});return ue.createElement(fl,{path:k,labelX:N,labelY:j,label:l,labelStyle:u,labelShowBg:h,labelBgStyle:p,labelBgPadding:f,labelBgBorderRadius:g,style:y,markerEnd:w,markerStart:S,interactionWidth:_})});pu.displayName="BezierEdge";const aw=E.createContext(null),BO=aw.Provider;aw.Consumer;const UO=()=>E.useContext(aw),WO=e=>"id"in e&&"source"in e&&"target"in e,HO=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`reactflow__edge-${e}${t||""}-${n}${s||""}`,Ey=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`,GO=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),VO=(e,t)=>{if(!e.source||!e.target)return t;let n;return WO(e)?n={...e}:n={...e,id:HO(e)},GO(n,t)?t:t.concat(n)},jy=({x:e,y:t},[n,s,o],a,[l,u])=>{const h={x:(e-n)/o,y:(t-s)/o};return a?{x:l*Math.round(h.x/l),y:u*Math.round(h.y/u)}:h},aC=({x:e,y:t},[n,s,o])=>({x:e*o+n,y:t*o+s}),vi=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],s=(e.height??0)*t[1],o={x:e.position.x-n,y:e.position.y-s};return{...o,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-s}:o}},Tu=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((s,o)=>{const{x:a,y:l}=vi(o,t).positionAbsolute;return Jj(s,nl({x:a,y:l,width:o.width||0,height:o.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return eC(n)},lC=(e,t,[n,s,o]=[0,0,1],a=!1,l=!1,u=[0,0])=>{const h={x:(t.x-n)/o,y:(t.y-s)/o,width:t.width/o,height:t.height/o},p=[];return e.forEach(f=>{const{width:g,height:y,selectable:w=!0,hidden:S=!1}=f;if(l&&!w||S)return!1;const{positionAbsolute:b}=vi(f,u),_={x:b.x,y:b.y,width:g||0,height:y||0},k=ky(h,_),N=typeof g>"u"||typeof y>"u"||g===null||y===null,j=a&&k>0,T=(g||0)*(y||0);(N||j||k>=T||f.dragging)&&p.push(f)}),p},cC=(e,t)=>{const n=e.map(s=>s.id);return t.filter(s=>n.includes(s.source)||n.includes(s.target))},uC=(e,t,n,s,o,a=.1)=>{const l=t/(e.width*(1+a)),u=n/(e.height*(1+a)),h=Math.min(l,u),p=$o(h,s,o),f=e.x+e.width/2,g=e.y+e.height/2,y=t/2-f*p,w=n/2-g*p;return{x:y,y:w,zoom:p}},di=(e,t=0)=>e.transition().duration(t);function Nb(e,t,n,s){return(t[n]||[]).reduce((o,a)=>{var l,u;return`${e.id}-${a.id}-${n}`!==s&&o.push({id:a.id||null,type:n,nodeId:e.id,x:(((l=e.positionAbsolute)==null?void 0:l.x)??0)+a.x+a.width/2,y:(((u=e.positionAbsolute)==null?void 0:u.y)??0)+a.y+a.height/2}),o},[])}function YO(e,t,n,s,o,a){const{x:l,y:u}=Rs(e),p=t.elementsFromPoint(l,u).find(S=>S.classList.contains("react-flow__handle"));if(p){const S=p.getAttribute("data-nodeid");if(S){const b=lw(void 0,p),_=p.getAttribute("data-handleid"),k=a({nodeId:S,id:_,type:b});if(k){const N=o.find(j=>j.nodeId===S&&j.type===b&&j.id===_);return{handle:{id:_,type:b,nodeId:S,x:(N==null?void 0:N.x)||n.x,y:(N==null?void 0:N.y)||n.y},validHandleResult:k}}}}let f=[],g=1/0;if(o.forEach(S=>{const b=Math.sqrt((S.x-n.x)**2+(S.y-n.y)**2);if(b<=s){const _=a(S);b<=g&&(b<g?f=[{handle:S,validHandleResult:_}]:b===g&&f.push({handle:S,validHandleResult:_}),g=b)}}),!f.length)return{handle:null,validHandleResult:dC()};if(f.length===1)return f[0];const y=f.some(({validHandleResult:S})=>S.isValid),w=f.some(({handle:S})=>S.type==="target");return f.find(({handle:S,validHandleResult:b})=>w?S.type==="target":y?b.isValid:!0)||f[0]}const KO={source:null,target:null,sourceHandle:null,targetHandle:null},dC=()=>({handleDomNode:null,isValid:!1,connection:KO,endHandle:null});function fC(e,t,n,s,o,a,l){const u=o==="target",h=l.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),p={...dC(),handleDomNode:h};if(h){const f=lw(void 0,h),g=h.getAttribute("data-nodeid"),y=h.getAttribute("data-handleid"),w=h.classList.contains("connectable"),S=h.classList.contains("connectableend"),b={source:u?g:n,sourceHandle:u?y:s,target:u?n:g,targetHandle:u?s:y};p.connection=b,w&&S&&(t===wi.Strict?u&&f==="source"||!u&&f==="target":g!==n||y!==s)&&(p.endHandle={nodeId:g,handleId:y,type:f},p.isValid=a(b))}return p}function XO({nodes:e,nodeId:t,handleId:n,handleType:s}){return e.reduce((o,a)=>{if(a[Nt]){const{handleBounds:l}=a[Nt];let u=[],h=[];l&&(u=Nb(a,l,"source",`${t}-${n}-${s}`),h=Nb(a,l,"target",`${t}-${n}-${s}`)),o.push(...u,...h)}return o},[])}function lw(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function qf(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function QO(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function hC({event:e,handleId:t,nodeId:n,onConnect:s,isTarget:o,getState:a,setState:l,isValidConnection:u,edgeUpdaterType:h,onReconnectEnd:p}){const f=Zj(e.target),{connectionMode:g,domNode:y,autoPanOnConnect:w,connectionRadius:S,onConnectStart:b,panBy:_,getNodes:k,cancelConnection:N}=a();let j=0,T;const{x:M,y:P}=Rs(e),I=f==null?void 0:f.elementFromPoint(M,P),F=lw(h,I),O=y==null?void 0:y.getBoundingClientRect();if(!O||!F)return;let A,D=Rs(e,O),H=!1,K=null,C=!1,X=null;const B=XO({nodes:k(),nodeId:n,handleId:t,handleType:F}),ne=()=>{if(!w)return;const[Q,$]=Qj(D,O);_({x:Q,y:$}),j=requestAnimationFrame(ne)};l({connectionPosition:D,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:F,connectionStartHandle:{nodeId:n,handleId:t,type:F},connectionEndHandle:null}),b==null||b(e,{nodeId:n,handleId:t,handleType:F});function J(Q){const{transform:$}=a();D=Rs(Q,O);const{handle:G,validHandleResult:Y}=YO(Q,f,jy(D,$,!1,[1,1]),S,B,L=>fC(L,g,n,t,o?"target":"source",u,f));if(T=G,H||(ne(),H=!0),X=Y.handleDomNode,K=Y.connection,C=Y.isValid,l({connectionPosition:T&&C?aC({x:T.x,y:T.y},$):D,connectionStatus:QO(!!T,C),connectionEndHandle:Y.endHandle}),!T&&!C&&!X)return qf(A);K.source!==K.target&&X&&(qf(A),A=X,X.classList.add("connecting","react-flow__handle-connecting"),X.classList.toggle("valid",C),X.classList.toggle("react-flow__handle-valid",C))}function W(Q){var $,G;(T||X)&&K&&C&&(s==null||s(K)),(G=($=a()).onConnectEnd)==null||G.call($,Q),h&&(p==null||p(Q)),qf(A),N(),cancelAnimationFrame(j),H=!1,C=!1,K=null,X=null,f.removeEventListener("mousemove",J),f.removeEventListener("mouseup",W),f.removeEventListener("touchmove",J),f.removeEventListener("touchend",W)}f.addEventListener("mousemove",J),f.addEventListener("mouseup",W),f.addEventListener("touchmove",J),f.addEventListener("touchend",W)}const Eb=()=>!0,ZO=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),JO=(e,t,n)=>s=>{const{connectionStartHandle:o,connectionEndHandle:a,connectionClickStartHandle:l}=s;return{connecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.handleId)===t&&(o==null?void 0:o.type)===n||(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.handleId)===t&&(a==null?void 0:a.type)===n,clickConnecting:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.handleId)===t&&(l==null?void 0:l.type)===n}},pC=E.forwardRef(({type:e="source",position:t=Oe.Top,isValidConnection:n,isConnectable:s=!0,isConnectableStart:o=!0,isConnectableEnd:a=!0,id:l,onConnect:u,children:h,className:p,onMouseDown:f,onTouchStart:g,...y},w)=>{var O,A;const S=l||null,b=e==="target",_=Tt(),k=UO(),{connectOnClick:N,noPanClassName:j}=rt(ZO,$t),{connecting:T,clickConnecting:M}=rt(JO(k,S,e),$t);k||(A=(O=_.getState()).onError)==null||A.call(O,"010",Xr.error010());const P=D=>{const{defaultEdgeOptions:H,onConnect:K,hasDefaultEdges:C}=_.getState(),X={...H,...D};if(C){const{edges:B,setEdges:ne}=_.getState();ne(VO(X,B))}K==null||K(X),u==null||u(X)},I=D=>{if(!k)return;const H=nC(D);o&&(H&&D.button===0||!H)&&hC({event:D,handleId:S,nodeId:k,onConnect:P,isTarget:b,getState:_.getState,setState:_.setState,isValidConnection:n||_.getState().isValidConnection||Eb}),H?f==null||f(D):g==null||g(D)},F=D=>{const{onClickConnectStart:H,onClickConnectEnd:K,connectionClickStartHandle:C,connectionMode:X,isValidConnection:B}=_.getState();if(!k||!C&&!o)return;if(!C){H==null||H(D,{nodeId:k,handleId:S,handleType:e}),_.setState({connectionClickStartHandle:{nodeId:k,type:e,handleId:S}});return}const ne=Zj(D.target),J=n||B||Eb,{connection:W,isValid:Q}=fC({nodeId:k,id:S,type:e},X,C.nodeId,C.handleId||null,C.type,J,ne);Q&&P(W),K==null||K(D),_.setState({connectionClickStartHandle:null})};return ue.createElement("div",{"data-handleid":S,"data-nodeid":k,"data-handlepos":t,"data-id":`${k}-${S}-${e}`,className:Ht(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",j,p,{source:!b,target:b,connectable:s,connectablestart:o,connectableend:a,connecting:M,connectionindicator:s&&(o&&!T||a&&T)}]),onMouseDown:I,onTouchStart:I,onClick:N?F:void 0,ref:w,...y},h)});pC.displayName="Handle";var Lo=E.memo(pC);const mC=({data:e,isConnectable:t,targetPosition:n=Oe.Top,sourcePosition:s=Oe.Bottom})=>ue.createElement(ue.Fragment,null,ue.createElement(Lo,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,ue.createElement(Lo,{type:"source",position:s,isConnectable:t}));mC.displayName="DefaultNode";var Cy=E.memo(mC);const gC=({data:e,isConnectable:t,sourcePosition:n=Oe.Bottom})=>ue.createElement(ue.Fragment,null,e==null?void 0:e.label,ue.createElement(Lo,{type:"source",position:n,isConnectable:t}));gC.displayName="InputNode";var vC=E.memo(gC);const yC=({data:e,isConnectable:t,targetPosition:n=Oe.Top})=>ue.createElement(ue.Fragment,null,ue.createElement(Lo,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);yC.displayName="OutputNode";var wC=E.memo(yC);const cw=()=>null;cw.displayName="GroupNode";const eP=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),zc=e=>e.id;function tP(e,t){return $t(e.selectedNodes.map(zc),t.selectedNodes.map(zc))&&$t(e.selectedEdges.map(zc),t.selectedEdges.map(zc))}const xC=E.memo(({onSelectionChange:e})=>{const t=Tt(),{selectedNodes:n,selectedEdges:s}=rt(eP,tP);return E.useEffect(()=>{const o={nodes:n,edges:s};e==null||e(o),t.getState().onSelectionChange.forEach(a=>a(o))},[n,s,e]),null});xC.displayName="SelectionListener";const nP=e=>!!e.onSelectionChange;function rP({onSelectionChange:e}){const t=rt(nP);return e||t?ue.createElement(xC,{onSelectionChange:e}):null}const sP=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 yo(e,t){E.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function Ge(e,t,n){E.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const iP=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:o,onConnectStart:a,onConnectEnd:l,onClickConnectStart:u,onClickConnectEnd:h,nodesDraggable:p,nodesConnectable:f,nodesFocusable:g,edgesFocusable:y,edgesUpdatable:w,elevateNodesOnSelect:S,minZoom:b,maxZoom:_,nodeExtent:k,onNodesChange:N,onEdgesChange:j,elementsSelectable:T,connectionMode:M,snapGrid:P,snapToGrid:I,translateExtent:F,connectOnClick:O,defaultEdgeOptions:A,fitView:D,fitViewOptions:H,onNodesDelete:K,onEdgesDelete:C,onNodeDrag:X,onNodeDragStart:B,onNodeDragStop:ne,onSelectionDrag:J,onSelectionDragStart:W,onSelectionDragStop:Q,noPanClassName:$,nodeOrigin:G,rfId:Y,autoPanOnConnect:L,autoPanOnNodeDrag:q,onError:Z,connectionRadius:se,isValidConnection:fe,nodeDragThreshold:he})=>{const{setNodes:ye,setEdges:Re,setDefaultNodesAndEdges:Ue,setMinZoom:De,setMaxZoom:Ie,setTranslateExtent:ke,setNodeExtent:ce,reset:xe}=rt(sP,$t),we=Tt();return E.useEffect(()=>{const Ye=s==null?void 0:s.map(yt=>({...yt,...A}));return Ue(n,Ye),()=>{xe()}},[]),Ge("defaultEdgeOptions",A,we.setState),Ge("connectionMode",M,we.setState),Ge("onConnect",o,we.setState),Ge("onConnectStart",a,we.setState),Ge("onConnectEnd",l,we.setState),Ge("onClickConnectStart",u,we.setState),Ge("onClickConnectEnd",h,we.setState),Ge("nodesDraggable",p,we.setState),Ge("nodesConnectable",f,we.setState),Ge("nodesFocusable",g,we.setState),Ge("edgesFocusable",y,we.setState),Ge("edgesUpdatable",w,we.setState),Ge("elementsSelectable",T,we.setState),Ge("elevateNodesOnSelect",S,we.setState),Ge("snapToGrid",I,we.setState),Ge("snapGrid",P,we.setState),Ge("onNodesChange",N,we.setState),Ge("onEdgesChange",j,we.setState),Ge("connectOnClick",O,we.setState),Ge("fitViewOnInit",D,we.setState),Ge("fitViewOnInitOptions",H,we.setState),Ge("onNodesDelete",K,we.setState),Ge("onEdgesDelete",C,we.setState),Ge("onNodeDrag",X,we.setState),Ge("onNodeDragStart",B,we.setState),Ge("onNodeDragStop",ne,we.setState),Ge("onSelectionDrag",J,we.setState),Ge("onSelectionDragStart",W,we.setState),Ge("onSelectionDragStop",Q,we.setState),Ge("noPanClassName",$,we.setState),Ge("nodeOrigin",G,we.setState),Ge("rfId",Y,we.setState),Ge("autoPanOnConnect",L,we.setState),Ge("autoPanOnNodeDrag",q,we.setState),Ge("onError",Z,we.setState),Ge("connectionRadius",se,we.setState),Ge("isValidConnection",fe,we.setState),Ge("nodeDragThreshold",he,we.setState),yo(e,ye),yo(t,Re),yo(b,De),yo(_,Ie),yo(F,ke),yo(k,ce),null},jb={display:"none"},oP={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},bC="react-flow__node-desc",_C="react-flow__edge-desc",aP="react-flow__aria-live",lP=e=>e.ariaLiveMessage;function cP({rfId:e}){const t=rt(lP);return ue.createElement("div",{id:`${aP}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:oP},t)}function uP({rfId:e,disableKeyboardA11y:t}){return ue.createElement(ue.Fragment,null,ue.createElement("div",{id:`${bC}-${e}`,style:jb},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),ue.createElement("div",{id:`${_C}-${e}`,style:jb},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&ue.createElement(cP,{rfId:e}))}var sl=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,s]=E.useState(!1),o=E.useRef(!1),a=E.useRef(new Set([])),[l,u]=E.useMemo(()=>{if(e!==null){const p=(Array.isArray(e)?e:[e]).filter(g=>typeof g=="string").map(g=>g.split("+")),f=p.reduce((g,y)=>g.concat(...y),[]);return[p,f]}return[[],[]]},[e]);return E.useEffect(()=>{const h=typeof document<"u"?document:null,p=(t==null?void 0:t.target)||h;if(e!==null){const f=w=>{if(o.current=w.ctrlKey||w.metaKey||w.shiftKey,(!o.current||o.current&&!t.actInsideInputWithModifier)&&Sy(w))return!1;const b=Tb(w.code,u);a.current.add(w[b]),Cb(l,a.current,!1)&&(w.preventDefault(),s(!0))},g=w=>{if((!o.current||o.current&&!t.actInsideInputWithModifier)&&Sy(w))return!1;const b=Tb(w.code,u);Cb(l,a.current,!0)?(s(!1),a.current.clear()):a.current.delete(w[b]),w.key==="Meta"&&a.current.clear(),o.current=!1},y=()=>{a.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",f),p==null||p.addEventListener("keyup",g),window.addEventListener("blur",y),()=>{p==null||p.removeEventListener("keydown",f),p==null||p.removeEventListener("keyup",g),window.removeEventListener("blur",y)}}},[e,s]),n};function Cb(e,t,n){return e.filter(s=>n||s.length===t.size).some(s=>s.every(o=>t.has(o)))}function Tb(e,t){return t.includes(e)?"code":"key"}function kC(e,t,n,s){var u,h;const o=e.parentNode||e.parentId;if(!o)return n;const a=t.get(o),l=vi(a,s);return kC(a,t,{x:(n.x??0)+l.x,y:(n.y??0)+l.y,z:(((u=a[Nt])==null?void 0:u.z)??0)>(n.z??0)?((h=a[Nt])==null?void 0:h.z)??0:n.z??0},s)}function SC(e,t,n){e.forEach(s=>{var a;const o=s.parentNode||s.parentId;if(o&&!e.has(o))throw new Error(`Parent node ${o} not found`);if(o||n!=null&&n[s.id]){const{x:l,y:u,z:h}=kC(s,e,{...s.position,z:((a=s[Nt])==null?void 0:a.z)??0},t);s.positionAbsolute={x:l,y:u},s[Nt].z=h,n!=null&&n[s.id]&&(s[Nt].isParent=!0)}})}function Df(e,t,n,s){const o=new Map,a={},l=s?1e3:0;return e.forEach(u=>{var w;const h=(Ln(u.zIndex)?u.zIndex:0)+(u.selected?l:0),p=t.get(u.id),f={...u,positionAbsolute:{x:u.position.x,y:u.position.y}},g=u.parentNode||u.parentId;g&&(a[g]=!0);const y=(p==null?void 0:p.type)&&(p==null?void 0:p.type)!==u.type;Object.defineProperty(f,Nt,{enumerable:!1,value:{handleBounds:y||(w=p==null?void 0:p[Nt])==null?void 0:w.handleBounds,z:h}}),o.set(u.id,f)}),SC(o,n,a),o}function NC(e,t={}){const{getNodes:n,width:s,height:o,minZoom:a,maxZoom:l,d3Zoom:u,d3Selection:h,fitViewOnInitDone:p,fitViewOnInit:f,nodeOrigin:g}=e(),y=t.initial&&!p&&f;if(u&&h&&(y||!t.initial)){const S=n().filter(_=>{var N;const k=t.includeHiddenNodes?_.width&&_.height:!_.hidden;return(N=t.nodes)!=null&&N.length?k&&t.nodes.some(j=>j.id===_.id):k}),b=S.every(_=>_.width&&_.height);if(S.length>0&&b){const _=Tu(S,g),{x:k,y:N,zoom:j}=uC(_,s,o,t.minZoom??a,t.maxZoom??l,t.padding??.1),T=Yr.translate(k,N).scale(j);return typeof t.duration=="number"&&t.duration>0?u.transform(di(h,t.duration),T):u.transform(h,T),!0}}return!1}function dP(e,t){return e.forEach(n=>{const s=t.get(n.id);s&&t.set(s.id,{...s,[Nt]:s[Nt],selected:n.selected})}),new Map(t)}function fP(e,t){return t.map(n=>{const s=e.find(o=>o.id===n.id);return s&&(n.selected=s.selected),n})}function Bc({changedNodes:e,changedEdges:t,get:n,set:s}){const{nodeInternals:o,edges:a,onNodesChange:l,onEdgesChange:u,hasDefaultNodes:h,hasDefaultEdges:p}=n();e!=null&&e.length&&(h&&s({nodeInternals:dP(e,o)}),l==null||l(e)),t!=null&&t.length&&(p&&s({edges:fP(t,a)}),u==null||u(t))}const wo=()=>{},hP={zoomIn:wo,zoomOut:wo,zoomTo:wo,getZoom:()=>1,setViewport:wo,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:wo,fitBounds:wo,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},pP=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),mP=()=>{const e=Tt(),{d3Zoom:t,d3Selection:n}=rt(pP,$t);return E.useMemo(()=>n&&t?{zoomIn:o=>t.scaleBy(di(n,o==null?void 0:o.duration),1.2),zoomOut:o=>t.scaleBy(di(n,o==null?void 0:o.duration),1/1.2),zoomTo:(o,a)=>t.scaleTo(di(n,a==null?void 0:a.duration),o),getZoom:()=>e.getState().transform[2],setViewport:(o,a)=>{const[l,u,h]=e.getState().transform,p=Yr.translate(o.x??l,o.y??u).scale(o.zoom??h);t.transform(di(n,a==null?void 0:a.duration),p)},getViewport:()=>{const[o,a,l]=e.getState().transform;return{x:o,y:a,zoom:l}},fitView:o=>NC(e.getState,o),setCenter:(o,a,l)=>{const{width:u,height:h,maxZoom:p}=e.getState(),f=typeof(l==null?void 0:l.zoom)<"u"?l.zoom:p,g=u/2-o*f,y=h/2-a*f,w=Yr.translate(g,y).scale(f);t.transform(di(n,l==null?void 0:l.duration),w)},fitBounds:(o,a)=>{const{width:l,height:u,minZoom:h,maxZoom:p}=e.getState(),{x:f,y:g,zoom:y}=uC(o,l,u,h,p,(a==null?void 0:a.padding)??.1),w=Yr.translate(f,g).scale(y);t.transform(di(n,a==null?void 0:a.duration),w)},project:o=>{const{transform:a,snapToGrid:l,snapGrid:u}=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"),jy(o,a,l,u)},screenToFlowPosition:o=>{const{transform:a,snapToGrid:l,snapGrid:u,domNode:h}=e.getState();if(!h)return o;const{x:p,y:f}=h.getBoundingClientRect(),g={x:o.x-p,y:o.y-f};return jy(g,a,l,u)},flowToScreenPosition:o=>{const{transform:a,domNode:l}=e.getState();if(!l)return o;const{x:u,y:h}=l.getBoundingClientRect(),p=aC(o,a);return{x:p.x+u,y:p.y+h}},viewportInitialized:!0}:hP,[t,n])};function hl(){const e=mP(),t=Tt(),n=E.useCallback(()=>t.getState().getNodes().map(b=>({...b})),[]),s=E.useCallback(b=>t.getState().nodeInternals.get(b),[]),o=E.useCallback(()=>{const{edges:b=[]}=t.getState();return b.map(_=>({..._}))},[]),a=E.useCallback(b=>{const{edges:_=[]}=t.getState();return _.find(k=>k.id===b)},[]),l=E.useCallback(b=>{const{getNodes:_,setNodes:k,hasDefaultNodes:N,onNodesChange:j}=t.getState(),T=_(),M=typeof b=="function"?b(T):b;if(N)k(M);else if(j){const P=M.length===0?T.map(I=>({type:"remove",id:I.id})):M.map(I=>({item:I,type:"reset"}));j(P)}},[]),u=E.useCallback(b=>{const{edges:_=[],setEdges:k,hasDefaultEdges:N,onEdgesChange:j}=t.getState(),T=typeof b=="function"?b(_):b;if(N)k(T);else if(j){const M=T.length===0?_.map(P=>({type:"remove",id:P.id})):T.map(P=>({item:P,type:"reset"}));j(M)}},[]),h=E.useCallback(b=>{const _=Array.isArray(b)?b:[b],{getNodes:k,setNodes:N,hasDefaultNodes:j,onNodesChange:T}=t.getState();if(j){const P=[...k(),..._];N(P)}else if(T){const M=_.map(P=>({item:P,type:"add"}));T(M)}},[]),p=E.useCallback(b=>{const _=Array.isArray(b)?b:[b],{edges:k=[],setEdges:N,hasDefaultEdges:j,onEdgesChange:T}=t.getState();if(j)N([...k,..._]);else if(T){const M=_.map(P=>({item:P,type:"add"}));T(M)}},[]),f=E.useCallback(()=>{const{getNodes:b,edges:_=[],transform:k}=t.getState(),[N,j,T]=k;return{nodes:b().map(M=>({...M})),edges:_.map(M=>({...M})),viewport:{x:N,y:j,zoom:T}}},[]),g=E.useCallback(({nodes:b,edges:_})=>{const{nodeInternals:k,getNodes:N,edges:j,hasDefaultNodes:T,hasDefaultEdges:M,onNodesDelete:P,onEdgesDelete:I,onNodesChange:F,onEdgesChange:O}=t.getState(),A=(b||[]).map(X=>X.id),D=(_||[]).map(X=>X.id),H=N().reduce((X,B)=>{const ne=B.parentNode||B.parentId,J=!A.includes(B.id)&&ne&&X.find(Q=>Q.id===ne);return(typeof B.deletable=="boolean"?B.deletable:!0)&&(A.includes(B.id)||J)&&X.push(B),X},[]),K=j.filter(X=>typeof X.deletable=="boolean"?X.deletable:!0),C=K.filter(X=>D.includes(X.id));if(H||C){const X=cC(H,K),B=[...C,...X],ne=B.reduce((J,W)=>(J.includes(W.id)||J.push(W.id),J),[]);if((M||T)&&(M&&t.setState({edges:j.filter(J=>!ne.includes(J.id))}),T&&(H.forEach(J=>{k.delete(J.id)}),t.setState({nodeInternals:new Map(k)}))),ne.length>0&&(I==null||I(B),O&&O(ne.map(J=>({id:J,type:"remove"})))),H.length>0&&(P==null||P(H),F)){const J=H.map(W=>({id:W.id,type:"remove"}));F(J)}}},[]),y=E.useCallback(b=>{const _=PO(b),k=_?null:t.getState().nodeInternals.get(b.id);return!_&&!k?[null,null,_]:[_?b:xb(k),k,_]},[]),w=E.useCallback((b,_=!0,k)=>{const[N,j,T]=y(b);return N?(k||t.getState().getNodes()).filter(M=>{if(!T&&(M.id===j.id||!M.positionAbsolute))return!1;const P=xb(M),I=ky(P,N);return _&&I>0||I>=N.width*N.height}):[]},[]),S=E.useCallback((b,_,k=!0)=>{const[N]=y(b);if(!N)return!1;const j=ky(N,_);return k&&j>0||j>=N.width*N.height},[]);return E.useMemo(()=>({...e,getNodes:n,getNode:s,getEdges:o,getEdge:a,setNodes:l,setEdges:u,addNodes:h,addEdges:p,toObject:f,deleteElements:g,getIntersectingNodes:w,isNodeIntersecting:S}),[e,n,s,o,a,l,u,h,p,f,g,w,S])}const gP={actInsideInputWithModifier:!1};var vP=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=Tt(),{deleteElements:s}=hl(),o=sl(e,gP),a=sl(t);E.useEffect(()=>{if(o){const{edges:l,getNodes:u}=n.getState(),h=u().filter(f=>f.selected),p=l.filter(f=>f.selected);s({nodes:h,edges:p}),n.setState({nodesSelectionActive:!1})}},[o]),E.useEffect(()=>{n.setState({multiSelectionActive:a})},[a])};function yP(e){const t=Tt();E.useEffect(()=>{let n;const s=()=>{var a,l;if(!e.current)return;const o=nw(e.current);(o.height===0||o.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",Xr.error004())),t.setState({width:o.width||500,height:o.height||500})};return s(),window.addEventListener("resize",s),e.current&&(n=new ResizeObserver(()=>s()),n.observe(e.current)),()=>{window.removeEventListener("resize",s),n&&e.current&&n.unobserve(e.current)}},[])}const uw={position:"absolute",width:"100%",height:"100%",top:0,left:0},wP=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Uc=e=>({x:e.x,y:e.y,zoom:e.k}),xo=(e,t)=>e.target.closest(`.${t}`),Rb=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Ab=e=>{const t=e.ctrlKey&&fu()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},xP=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),bP=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:s,zoomOnScroll:o=!0,zoomOnPinch:a=!0,panOnScroll:l=!1,panOnScrollSpeed:u=.5,panOnScrollMode:h=mi.Free,zoomOnDoubleClick:p=!0,elementsSelectable:f,panOnDrag:g=!0,defaultViewport:y,translateExtent:w,minZoom:S,maxZoom:b,zoomActivationKeyCode:_,preventScrolling:k=!0,children:N,noWheelClassName:j,noPanClassName:T})=>{const M=E.useRef(),P=Tt(),I=E.useRef(!1),F=E.useRef(!1),O=E.useRef(null),A=E.useRef({x:0,y:0,zoom:0}),{d3Zoom:D,d3Selection:H,d3ZoomHandler:K,userSelectionActive:C}=rt(xP,$t),X=sl(_),B=E.useRef(0),ne=E.useRef(!1),J=E.useRef();return yP(O),E.useEffect(()=>{if(O.current){const W=O.current.getBoundingClientRect(),Q=Kj().scaleExtent([S,b]).translateExtent(w),$=$n(O.current).call(Q),G=Yr.translate(y.x,y.y).scale($o(y.zoom,S,b)),Y=[[0,0],[W.width,W.height]],L=Q.constrain()(G,Y,w);Q.transform($,L),Q.wheelDelta(Ab),P.setState({d3Zoom:Q,d3Selection:$,d3ZoomHandler:$.on("wheel.zoom"),transform:[L.x,L.y,L.k],domNode:O.current.closest(".react-flow")})}},[]),E.useEffect(()=>{H&&D&&(l&&!X&&!C?H.on("wheel.zoom",W=>{if(xo(W,j))return!1;W.preventDefault(),W.stopImmediatePropagation();const Q=H.property("__zoom").k||1;if(W.ctrlKey&&a){const fe=rr(W),he=Ab(W),ye=Q*Math.pow(2,he);D.scaleTo(H,ye,fe,W);return}const $=W.deltaMode===1?20:1;let G=h===mi.Vertical?0:W.deltaX*$,Y=h===mi.Horizontal?0:W.deltaY*$;!fu()&&W.shiftKey&&h!==mi.Vertical&&(G=W.deltaY*$,Y=0),D.translateBy(H,-(G/Q)*u,-(Y/Q)*u,{internal:!0});const L=Uc(H.property("__zoom")),{onViewportChangeStart:q,onViewportChange:Z,onViewportChangeEnd:se}=P.getState();clearTimeout(J.current),ne.current||(ne.current=!0,t==null||t(W,L),q==null||q(L)),ne.current&&(e==null||e(W,L),Z==null||Z(L),J.current=setTimeout(()=>{n==null||n(W,L),se==null||se(L),ne.current=!1},150))},{passive:!1}):typeof K<"u"&&H.on("wheel.zoom",function(W,Q){if(!k&&W.type==="wheel"&&!W.ctrlKey||xo(W,j))return null;W.preventDefault(),K.call(this,W,Q)},{passive:!1}))},[C,l,h,H,D,K,X,a,k,j,t,e,n]),E.useEffect(()=>{D&&D.on("start",W=>{var G,Y;if(!W.sourceEvent||W.sourceEvent.internal)return null;B.current=(G=W.sourceEvent)==null?void 0:G.button;const{onViewportChangeStart:Q}=P.getState(),$=Uc(W.transform);I.current=!0,A.current=$,((Y=W.sourceEvent)==null?void 0:Y.type)==="mousedown"&&P.setState({paneDragging:!0}),Q==null||Q($),t==null||t(W.sourceEvent,$)})},[D,t]),E.useEffect(()=>{D&&(C&&!I.current?D.on("zoom",null):C||D.on("zoom",W=>{var $;const{onViewportChange:Q}=P.getState();if(P.setState({transform:[W.transform.x,W.transform.y,W.transform.k]}),F.current=!!(s&&Rb(g,B.current??0)),(e||Q)&&!(($=W.sourceEvent)!=null&&$.internal)){const G=Uc(W.transform);Q==null||Q(G),e==null||e(W.sourceEvent,G)}}))},[C,D,e,g,s]),E.useEffect(()=>{D&&D.on("end",W=>{if(!W.sourceEvent||W.sourceEvent.internal)return null;const{onViewportChangeEnd:Q}=P.getState();if(I.current=!1,P.setState({paneDragging:!1}),s&&Rb(g,B.current??0)&&!F.current&&s(W.sourceEvent),F.current=!1,(n||Q)&&wP(A.current,W.transform)){const $=Uc(W.transform);A.current=$,clearTimeout(M.current),M.current=setTimeout(()=>{Q==null||Q($),n==null||n(W.sourceEvent,$)},l?150:0)}})},[D,l,g,n,s]),E.useEffect(()=>{D&&D.filter(W=>{const Q=X||o,$=a&&W.ctrlKey;if((g===!0||Array.isArray(g)&&g.includes(1))&&W.button===1&&W.type==="mousedown"&&(xo(W,"react-flow__node")||xo(W,"react-flow__edge")))return!0;if(!g&&!Q&&!l&&!p&&!a||C||!p&&W.type==="dblclick"||xo(W,j)&&W.type==="wheel"||xo(W,T)&&(W.type!=="wheel"||l&&W.type==="wheel"&&!X)||!a&&W.ctrlKey&&W.type==="wheel"||!Q&&!l&&!$&&W.type==="wheel"||!g&&(W.type==="mousedown"||W.type==="touchstart")||Array.isArray(g)&&!g.includes(W.button)&&W.type==="mousedown")return!1;const G=Array.isArray(g)&&g.includes(W.button)||!W.button||W.button<=1;return(!W.ctrlKey||W.type==="wheel")&&G})},[C,D,o,a,l,p,g,f,X]),ue.createElement("div",{className:"react-flow__renderer",ref:O,style:uw},N)},_P=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function kP(){const{userSelectionActive:e,userSelectionRect:t}=rt(_P,$t);return e&&t?ue.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function Mb(e,t){const n=t.parentNode||t.parentId,s=e.find(o=>o.id===n);if(s){const o=t.position.x+t.width-s.width,a=t.position.y+t.height-s.height;if(o>0||a>0||t.position.x<0||t.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),a>0&&(s.style.height+=a),t.position.x<0){const l=Math.abs(t.position.x);s.position.x=s.position.x-l,s.style.width+=l,t.position.x=0}if(t.position.y<0){const l=Math.abs(t.position.y);s.position.y=s.position.y-l,s.style.height+=l,t.position.y=0}s.width=s.style.width,s.height=s.style.height}}}function SP(e,t){if(e.some(s=>s.type==="reset"))return e.filter(s=>s.type==="reset").map(s=>s.item);const n=e.filter(s=>s.type==="add").map(s=>s.item);return t.reduce((s,o)=>{const a=e.filter(u=>u.id===o.id);if(a.length===0)return s.push(o),s;const l={...o};for(const u of a)if(u)switch(u.type){case"select":{l.selected=u.selected;break}case"position":{typeof u.position<"u"&&(l.position=u.position),typeof u.positionAbsolute<"u"&&(l.positionAbsolute=u.positionAbsolute),typeof u.dragging<"u"&&(l.dragging=u.dragging),l.expandParent&&Mb(s,l);break}case"dimensions":{typeof u.dimensions<"u"&&(l.width=u.dimensions.width,l.height=u.dimensions.height),typeof u.updateStyle<"u"&&(l.style={...l.style||{},...u.dimensions}),typeof u.resizing=="boolean"&&(l.resizing=u.resizing),l.expandParent&&Mb(s,l);break}case"remove":return s}return s.push(l),s},n)}function NP(e,t){return SP(e,t)}const Cs=(e,t)=>({id:e,type:"select",selected:t});function No(e,t){return e.reduce((n,s)=>{const o=t.includes(s.id);return!s.selected&&o?(s.selected=!0,n.push(Cs(s.id,!0))):s.selected&&!o&&(s.selected=!1,n.push(Cs(s.id,!1))),n},[])}const Ff=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},EP=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),EC=E.memo(({isSelecting:e,selectionMode:t=rl.Full,panOnDrag:n,onSelectionStart:s,onSelectionEnd:o,onPaneClick:a,onPaneContextMenu:l,onPaneScroll:u,onPaneMouseEnter:h,onPaneMouseMove:p,onPaneMouseLeave:f,children:g})=>{const y=E.useRef(null),w=Tt(),S=E.useRef(0),b=E.useRef(0),_=E.useRef(),{userSelectionActive:k,elementsSelectable:N,dragging:j}=rt(EP,$t),T=()=>{w.setState({userSelectionActive:!1,userSelectionRect:null}),S.current=0,b.current=0},M=K=>{a==null||a(K),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},P=K=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){K.preventDefault();return}l==null||l(K)},I=u?K=>u(K):void 0,F=K=>{const{resetSelectedElements:C,domNode:X}=w.getState();if(_.current=X==null?void 0:X.getBoundingClientRect(),!N||!e||K.button!==0||K.target!==y.current||!_.current)return;const{x:B,y:ne}=Rs(K,_.current);C(),w.setState({userSelectionRect:{width:0,height:0,startX:B,startY:ne,x:B,y:ne}}),s==null||s(K)},O=K=>{const{userSelectionRect:C,nodeInternals:X,edges:B,transform:ne,onNodesChange:J,onEdgesChange:W,nodeOrigin:Q,getNodes:$}=w.getState();if(!e||!_.current||!C)return;w.setState({userSelectionActive:!0,nodesSelectionActive:!1});const G=Rs(K,_.current),Y=C.startX??0,L=C.startY??0,q={...C,x:G.x<Y?G.x:Y,y:G.y<L?G.y:L,width:Math.abs(G.x-Y),height:Math.abs(G.y-L)},Z=$(),se=lC(X,q,ne,t===rl.Partial,!0,Q),fe=cC(se,B).map(ye=>ye.id),he=se.map(ye=>ye.id);if(S.current!==he.length){S.current=he.length;const ye=No(Z,he);ye.length&&(J==null||J(ye))}if(b.current!==fe.length){b.current=fe.length;const ye=No(B,fe);ye.length&&(W==null||W(ye))}w.setState({userSelectionRect:q})},A=K=>{if(K.button!==0)return;const{userSelectionRect:C}=w.getState();!k&&C&&K.target===y.current&&(M==null||M(K)),w.setState({nodesSelectionActive:S.current>0}),T(),o==null||o(K)},D=K=>{k&&(w.setState({nodesSelectionActive:S.current>0}),o==null||o(K)),T()},H=N&&(e||k);return ue.createElement("div",{className:Ht(["react-flow__pane",{dragging:j,selection:e}]),onClick:H?void 0:Ff(M,y),onContextMenu:Ff(P,y),onWheel:Ff(I,y),onMouseEnter:H?void 0:h,onMouseDown:H?F:void 0,onMouseMove:H?O:p,onMouseUp:H?A:void 0,onMouseLeave:H?D:f,ref:y,style:uw},g,ue.createElement(kP,null))});EC.displayName="Pane";function jC(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const s=t.get(n);return s?s.selected?!0:jC(s,t):!1}function Ib(e,t,n){let s=e;do{if(s!=null&&s.matches(t))return!0;if(s===n.current)return!1;s=s.parentElement}while(s);return!1}function jP(e,t,n,s){return Array.from(e.values()).filter(o=>(o.selected||o.id===s)&&(!o.parentNode||o.parentId||!jC(o,e))&&(o.draggable||t&&typeof o.draggable>"u")).map(o=>{var a,l;return{id:o.id,position:o.position||{x:0,y:0},positionAbsolute:o.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((a=o.positionAbsolute)==null?void 0:a.x)??0),y:n.y-(((l=o.positionAbsolute)==null?void 0:l.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 CP(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function CC(e,t,n,s,o=[0,0],a){const l=CP(e,e.extent||s);let u=l;const h=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(h&&e.width&&e.height){const g=n.get(h),{x:y,y:w}=vi(g,o).positionAbsolute;u=g&&Ln(y)&&Ln(w)&&Ln(g.width)&&Ln(g.height)?[[y+e.width*o[0],w+e.height*o[1]],[y+g.width-e.width+e.width*o[0],w+g.height-e.height+e.height*o[1]]]:u}else a==null||a("005",Xr.error005()),u=l;else if(e.extent&&h&&e.extent!=="parent"){const g=n.get(h),{x:y,y:w}=vi(g,o).positionAbsolute;u=[[e.extent[0][0]+y,e.extent[0][1]+w],[e.extent[1][0]+y,e.extent[1][1]+w]]}let p={x:0,y:0};if(h){const g=n.get(h);p=vi(g,o).positionAbsolute}const f=u&&u!=="parent"?rw(t,u):t;return{position:{x:f.x-p.x,y:f.y-p.y},positionAbsolute:f}}function zf({nodeId:e,dragItems:t,nodeInternals:n}){const s=t.map(o=>({...n.get(o.id),position:o.position,positionAbsolute:o.positionAbsolute}));return[e?s.find(o=>o.id===e):s[0],s]}const Ob=(e,t,n,s)=>{const o=t.querySelectorAll(e);if(!o||!o.length)return null;const a=Array.from(o),l=t.getBoundingClientRect(),u={x:l.width*s[0],y:l.height*s[1]};return a.map(h=>{const p=h.getBoundingClientRect();return{id:h.getAttribute("data-handleid"),position:h.getAttribute("data-handlepos"),x:(p.left-l.left-u.x)/n,y:(p.top-l.top-u.y)/n,...nw(h)}})};function Da(e,t,n){return n===void 0?n:s=>{const o=t().nodeInternals.get(e);o&&n(s,{...o})}}function Ty({id:e,store:t,unselect:n=!1,nodeRef:s}){const{addSelectedNodes:o,unselectNodesAndEdges:a,multiSelectionActive:l,nodeInternals:u,onError:h}=t.getState(),p=u.get(e);if(!p){h==null||h("012",Xr.error012(e));return}t.setState({nodesSelectionActive:!1}),p.selected?(n||p.selected&&l)&&(a({nodes:[p],edges:[]}),requestAnimationFrame(()=>{var f;return(f=s==null?void 0:s.current)==null?void 0:f.blur()})):o([e])}function TP(){const e=Tt();return E.useCallback(({sourceEvent:n})=>{const{transform:s,snapGrid:o,snapToGrid:a}=e.getState(),l=n.touches?n.touches[0].clientX:n.clientX,u=n.touches?n.touches[0].clientY:n.clientY,h={x:(l-s[0])/s[2],y:(u-s[1])/s[2]};return{xSnapped:a?o[0]*Math.round(h.x/o[0]):h.x,ySnapped:a?o[1]*Math.round(h.y/o[1]):h.y,...h}},[])}function Bf(e){return(t,n,s)=>e==null?void 0:e(t,s)}function TC({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:s,nodeId:o,isSelectable:a,selectNodesOnDrag:l}){const u=Tt(),[h,p]=E.useState(!1),f=E.useRef([]),g=E.useRef({x:null,y:null}),y=E.useRef(0),w=E.useRef(null),S=E.useRef({x:0,y:0}),b=E.useRef(null),_=E.useRef(!1),k=E.useRef(!1),N=E.useRef(!1),j=TP();return E.useEffect(()=>{if(e!=null&&e.current){const T=$n(e.current),M=({x:F,y:O})=>{const{nodeInternals:A,onNodeDrag:D,onSelectionDrag:H,updateNodePositions:K,nodeExtent:C,snapGrid:X,snapToGrid:B,nodeOrigin:ne,onError:J}=u.getState();g.current={x:F,y:O};let W=!1,Q={x:0,y:0,x2:0,y2:0};if(f.current.length>1&&C){const G=Tu(f.current,ne);Q=nl(G)}if(f.current=f.current.map(G=>{const Y={x:F-G.distance.x,y:O-G.distance.y};B&&(Y.x=X[0]*Math.round(Y.x/X[0]),Y.y=X[1]*Math.round(Y.y/X[1]));const L=[[C[0][0],C[0][1]],[C[1][0],C[1][1]]];f.current.length>1&&C&&!G.extent&&(L[0][0]=G.positionAbsolute.x-Q.x+C[0][0],L[1][0]=G.positionAbsolute.x+(G.width??0)-Q.x2+C[1][0],L[0][1]=G.positionAbsolute.y-Q.y+C[0][1],L[1][1]=G.positionAbsolute.y+(G.height??0)-Q.y2+C[1][1]);const q=CC(G,Y,A,L,ne,J);return W=W||G.position.x!==q.position.x||G.position.y!==q.position.y,G.position=q.position,G.positionAbsolute=q.positionAbsolute,G}),!W)return;K(f.current,!0,!0),p(!0);const $=o?D:Bf(H);if($&&b.current){const[G,Y]=zf({nodeId:o,dragItems:f.current,nodeInternals:A});$(b.current,G,Y)}},P=()=>{if(!w.current)return;const[F,O]=Qj(S.current,w.current);if(F!==0||O!==0){const{transform:A,panBy:D}=u.getState();g.current.x=(g.current.x??0)-F/A[2],g.current.y=(g.current.y??0)-O/A[2],D({x:F,y:O})&&M(g.current)}y.current=requestAnimationFrame(P)},I=F=>{var ne;const{nodeInternals:O,multiSelectionActive:A,nodesDraggable:D,unselectNodesAndEdges:H,onNodeDragStart:K,onSelectionDragStart:C}=u.getState();k.current=!0;const X=o?K:Bf(C);(!l||!a)&&!A&&o&&((ne=O.get(o))!=null&&ne.selected||H()),o&&a&&l&&Ty({id:o,store:u,nodeRef:e});const B=j(F);if(g.current=B,f.current=jP(O,D,B,o),X&&f.current){const[J,W]=zf({nodeId:o,dragItems:f.current,nodeInternals:O});X(F.sourceEvent,J,W)}};if(t)T.on(".drag",null);else{const F=DM().on("start",O=>{const{domNode:A,nodeDragThreshold:D}=u.getState();D===0&&I(O),N.current=!1;const H=j(O);g.current=H,w.current=(A==null?void 0:A.getBoundingClientRect())||null,S.current=Rs(O.sourceEvent,w.current)}).on("drag",O=>{var K,C;const A=j(O),{autoPanOnNodeDrag:D,nodeDragThreshold:H}=u.getState();if(O.sourceEvent.type==="touchmove"&&O.sourceEvent.touches.length>1&&(N.current=!0),!N.current){if(!_.current&&k.current&&D&&(_.current=!0,P()),!k.current){const X=A.xSnapped-(((K=g==null?void 0:g.current)==null?void 0:K.x)??0),B=A.ySnapped-(((C=g==null?void 0:g.current)==null?void 0:C.y)??0);Math.sqrt(X*X+B*B)>H&&I(O)}(g.current.x!==A.xSnapped||g.current.y!==A.ySnapped)&&f.current&&k.current&&(b.current=O.sourceEvent,S.current=Rs(O.sourceEvent,w.current),M(A))}}).on("end",O=>{if(!(!k.current||N.current)&&(p(!1),_.current=!1,k.current=!1,cancelAnimationFrame(y.current),f.current)){const{updateNodePositions:A,nodeInternals:D,onNodeDragStop:H,onSelectionDragStop:K}=u.getState(),C=o?H:Bf(K);if(A(f.current,!1,!1),C){const[X,B]=zf({nodeId:o,dragItems:f.current,nodeInternals:D});C(O.sourceEvent,X,B)}}}).filter(O=>{const A=O.target;return!O.button&&(!n||!Ib(A,`.${n}`,e))&&(!s||Ib(A,s,e))});return T.call(F),()=>{T.on(".drag",null)}}}},[e,t,n,s,a,u,o,l,j]),h}function RC(){const e=Tt();return E.useCallback(n=>{const{nodeInternals:s,nodeExtent:o,updateNodePositions:a,getNodes:l,snapToGrid:u,snapGrid:h,onError:p,nodesDraggable:f}=e.getState(),g=l().filter(N=>N.selected&&(N.draggable||f&&typeof N.draggable>"u")),y=u?h[0]:5,w=u?h[1]:5,S=n.isShiftPressed?4:1,b=n.x*y*S,_=n.y*w*S,k=g.map(N=>{if(N.positionAbsolute){const j={x:N.positionAbsolute.x+b,y:N.positionAbsolute.y+_};u&&(j.x=h[0]*Math.round(j.x/h[0]),j.y=h[1]*Math.round(j.y/h[1]));const{positionAbsolute:T,position:M}=CC(N,j,s,o,void 0,p);N.position=M,N.positionAbsolute=T}return N});a(k,!0,!1)},[])}const Ro={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var Fa=e=>{const t=({id:n,type:s,data:o,xPos:a,yPos:l,xPosOrigin:u,yPosOrigin:h,selected:p,onClick:f,onMouseEnter:g,onMouseMove:y,onMouseLeave:w,onContextMenu:S,onDoubleClick:b,style:_,className:k,isDraggable:N,isSelectable:j,isConnectable:T,isFocusable:M,selectNodesOnDrag:P,sourcePosition:I,targetPosition:F,hidden:O,resizeObserver:A,dragHandle:D,zIndex:H,isParent:K,noDragClassName:C,noPanClassName:X,initialized:B,disableKeyboardA11y:ne,ariaLabel:J,rfId:W,hasHandleBounds:Q})=>{const $=Tt(),G=E.useRef(null),Y=E.useRef(null),L=E.useRef(I),q=E.useRef(F),Z=E.useRef(s),se=j||N||f||g||y||w,fe=RC(),he=Da(n,$.getState,g),ye=Da(n,$.getState,y),Re=Da(n,$.getState,w),Ue=Da(n,$.getState,S),De=Da(n,$.getState,b),Ie=xe=>{const{nodeDragThreshold:we}=$.getState();if(j&&(!P||!N||we>0)&&Ty({id:n,store:$,nodeRef:G}),f){const Ye=$.getState().nodeInternals.get(n);Ye&&f(xe,{...Ye})}},ke=xe=>{if(!Sy(xe)&&!ne)if(tC.includes(xe.key)&&j){const we=xe.key==="Escape";Ty({id:n,store:$,unselect:we,nodeRef:G})}else N&&p&&Object.prototype.hasOwnProperty.call(Ro,xe.key)&&($.setState({ariaLiveMessage:`Moved selected node ${xe.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~a}, y: ${~~l}`}),fe({x:Ro[xe.key].x,y:Ro[xe.key].y,isShiftPressed:xe.shiftKey}))};E.useEffect(()=>()=>{Y.current&&(A==null||A.unobserve(Y.current),Y.current=null)},[]),E.useEffect(()=>{if(G.current&&!O){const xe=G.current;(!B||!Q||Y.current!==xe)&&(Y.current&&(A==null||A.unobserve(Y.current)),A==null||A.observe(xe),Y.current=xe)}},[O,B,Q]),E.useEffect(()=>{const xe=Z.current!==s,we=L.current!==I,Ye=q.current!==F;G.current&&(xe||we||Ye)&&(xe&&(Z.current=s),we&&(L.current=I),Ye&&(q.current=F),$.getState().updateNodeDimensions([{id:n,nodeElement:G.current,forceUpdate:!0}]))},[n,s,I,F]);const ce=TC({nodeRef:G,disabled:O||!N,noDragClassName:C,handleSelector:D,nodeId:n,isSelectable:j,selectNodesOnDrag:P});return O?null:ue.createElement("div",{className:Ht(["react-flow__node",`react-flow__node-${s}`,{[X]:N},k,{selected:p,selectable:j,parent:K,dragging:ce}]),ref:G,style:{zIndex:H,transform:`translate(${u}px,${h}px)`,pointerEvents:se?"all":"none",visibility:B?"visible":"hidden",..._},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:he,onMouseMove:ye,onMouseLeave:Re,onContextMenu:Ue,onClick:Ie,onDoubleClick:De,onKeyDown:M?ke:void 0,tabIndex:M?0:void 0,role:M?"button":void 0,"aria-describedby":ne?void 0:`${bC}-${W}`,"aria-label":J},ue.createElement(BO,{value:n},ue.createElement(e,{id:n,data:o,type:s,xPos:a,yPos:l,selected:p,isConnectable:T,sourcePosition:I,targetPosition:F,dragging:ce,dragHandle:D,zIndex:H})))};return t.displayName="NodeWrapper",E.memo(t)};const RP=e=>{const t=e.getNodes().filter(n=>n.selected);return{...Tu(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function AP({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const s=Tt(),{width:o,height:a,x:l,y:u,transformString:h,userSelectionActive:p}=rt(RP,$t),f=RC(),g=E.useRef(null);if(E.useEffect(()=>{var S;n||(S=g.current)==null||S.focus({preventScroll:!0})},[n]),TC({nodeRef:g}),p||!o||!a)return null;const y=e?S=>{const b=s.getState().getNodes().filter(_=>_.selected);e(S,b)}:void 0,w=S=>{Object.prototype.hasOwnProperty.call(Ro,S.key)&&f({x:Ro[S.key].x,y:Ro[S.key].y,isShiftPressed:S.shiftKey})};return ue.createElement("div",{className:Ht(["react-flow__nodesselection","react-flow__container",t]),style:{transform:h}},ue.createElement("div",{ref:g,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:n?void 0:-1,onKeyDown:n?void 0:w,style:{width:o,height:a,top:u,left:l}}))}var MP=E.memo(AP);const IP=e=>e.nodesSelectionActive,AC=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:a,onPaneScroll:l,deleteKeyCode:u,onMove:h,onMoveStart:p,onMoveEnd:f,selectionKeyCode:g,selectionOnDrag:y,selectionMode:w,onSelectionStart:S,onSelectionEnd:b,multiSelectionKeyCode:_,panActivationKeyCode:k,zoomActivationKeyCode:N,elementsSelectable:j,zoomOnScroll:T,zoomOnPinch:M,panOnScroll:P,panOnScrollSpeed:I,panOnScrollMode:F,zoomOnDoubleClick:O,panOnDrag:A,defaultViewport:D,translateExtent:H,minZoom:K,maxZoom:C,preventScrolling:X,onSelectionContextMenu:B,noWheelClassName:ne,noPanClassName:J,disableKeyboardA11y:W})=>{const Q=rt(IP),$=sl(g),G=sl(k),Y=G||A,L=G||P,q=$||y&&Y!==!0;return vP({deleteKeyCode:u,multiSelectionKeyCode:_}),ue.createElement(bP,{onMove:h,onMoveStart:p,onMoveEnd:f,onPaneContextMenu:a,elementsSelectable:j,zoomOnScroll:T,zoomOnPinch:M,panOnScroll:L,panOnScrollSpeed:I,panOnScrollMode:F,zoomOnDoubleClick:O,panOnDrag:!$&&Y,defaultViewport:D,translateExtent:H,minZoom:K,maxZoom:C,zoomActivationKeyCode:N,preventScrolling:X,noWheelClassName:ne,noPanClassName:J},ue.createElement(EC,{onSelectionStart:S,onSelectionEnd:b,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:a,onPaneScroll:l,panOnDrag:Y,isSelecting:!!q,selectionMode:w},e,Q&&ue.createElement(MP,{onSelectionContextMenu:B,noPanClassName:J,disableKeyboardA11y:W})))};AC.displayName="FlowRenderer";var OP=E.memo(AC);function PP(e){return rt(E.useCallback(n=>e?lC(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function $P(e){const t={input:Fa(e.input||vC),default:Fa(e.default||Cy),output:Fa(e.output||wC),group:Fa(e.group||cw)},n={},s=Object.keys(e).filter(o=>!["input","default","output","group"].includes(o)).reduce((o,a)=>(o[a]=Fa(e[a]||Cy),o),n);return{...t,...s}}const LP=({x:e,y:t,width:n,height:s,origin:o})=>!n||!s?{x:e,y:t}:o[0]<0||o[1]<0||o[0]>1||o[1]>1?{x:e,y:t}:{x:e-n*o[0],y:t-s*o[1]},qP=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),MC=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:s,elementsSelectable:o,updateNodeDimensions:a,onError:l}=rt(qP,$t),u=PP(e.onlyRenderVisibleElements),h=E.useRef(),p=E.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const f=new ResizeObserver(g=>{const y=g.map(w=>({id:w.target.getAttribute("data-id"),nodeElement:w.target,forceUpdate:!0}));a(y)});return h.current=f,f},[]);return E.useEffect(()=>()=>{var f;(f=h==null?void 0:h.current)==null||f.disconnect()},[]),ue.createElement("div",{className:"react-flow__nodes",style:uw},u.map(f=>{var M,P,I;let g=f.type||"default";e.nodeTypes[g]||(l==null||l("003",Xr.error003(g)),g="default");const y=e.nodeTypes[g]||e.nodeTypes.default,w=!!(f.draggable||t&&typeof f.draggable>"u"),S=!!(f.selectable||o&&typeof f.selectable>"u"),b=!!(f.connectable||n&&typeof f.connectable>"u"),_=!!(f.focusable||s&&typeof f.focusable>"u"),k=e.nodeExtent?rw(f.positionAbsolute,e.nodeExtent):f.positionAbsolute,N=(k==null?void 0:k.x)??0,j=(k==null?void 0:k.y)??0,T=LP({x:N,y:j,width:f.width??0,height:f.height??0,origin:e.nodeOrigin});return ue.createElement(y,{key:f.id,id:f.id,className:f.className,style:f.style,type:g,data:f.data,sourcePosition:f.sourcePosition||Oe.Bottom,targetPosition:f.targetPosition||Oe.Top,hidden:f.hidden,xPos:N,yPos:j,xPosOrigin:T.x,yPosOrigin:T.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!f.selected,isDraggable:w,isSelectable:S,isConnectable:b,isFocusable:_,resizeObserver:p,dragHandle:f.dragHandle,zIndex:((M=f[Nt])==null?void 0:M.z)??0,isParent:!!((P=f[Nt])!=null&&P.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!f.width&&!!f.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:f.ariaLabel,hasHandleBounds:!!((I=f[Nt])!=null&&I.handleBounds)})}))};MC.displayName="NodeRenderer";var DP=E.memo(MC);const FP=(e,t,n)=>n===Oe.Left?e-t:n===Oe.Right?e+t:e,zP=(e,t,n)=>n===Oe.Top?e-t:n===Oe.Bottom?e+t:e,Pb="react-flow__edgeupdater",$b=({position:e,centerX:t,centerY:n,radius:s=10,onMouseDown:o,onMouseEnter:a,onMouseOut:l,type:u})=>ue.createElement("circle",{onMouseDown:o,onMouseEnter:a,onMouseOut:l,className:Ht([Pb,`${Pb}-${u}`]),cx:FP(t,s,e),cy:zP(n,s,e),r:s,stroke:"transparent",fill:"transparent"}),BP=()=>!0;var bo=e=>{const t=({id:n,className:s,type:o,data:a,onClick:l,onEdgeDoubleClick:u,selected:h,animated:p,label:f,labelStyle:g,labelShowBg:y,labelBgStyle:w,labelBgPadding:S,labelBgBorderRadius:b,style:_,source:k,target:N,sourceX:j,sourceY:T,targetX:M,targetY:P,sourcePosition:I,targetPosition:F,elementsSelectable:O,hidden:A,sourceHandleId:D,targetHandleId:H,onContextMenu:K,onMouseEnter:C,onMouseMove:X,onMouseLeave:B,reconnectRadius:ne,onReconnect:J,onReconnectStart:W,onReconnectEnd:Q,markerEnd:$,markerStart:G,rfId:Y,ariaLabel:L,isFocusable:q,isReconnectable:Z,pathOptions:se,interactionWidth:fe,disableKeyboardA11y:he})=>{const ye=E.useRef(null),[Re,Ue]=E.useState(!1),[De,Ie]=E.useState(!1),ke=Tt(),ce=E.useMemo(()=>`url('#${Ey(G,Y)}')`,[G,Y]),xe=E.useMemo(()=>`url('#${Ey($,Y)}')`,[$,Y]);if(A)return null;const we=Pe=>{var Ce;const{edges:qe,addSelectedEdges:Ne,unselectNodesAndEdges:We,multiSelectionActive:Et}=ke.getState(),et=qe.find(wt=>wt.id===n);et&&(O&&(ke.setState({nodesSelectionActive:!1}),et.selected&&Et?(We({nodes:[],edges:[et]}),(Ce=ye.current)==null||Ce.blur()):Ne([n])),l&&l(Pe,et))},Ye=qa(n,ke.getState,u),yt=qa(n,ke.getState,K),ct=qa(n,ke.getState,C),st=qa(n,ke.getState,X),Be=qa(n,ke.getState,B),tt=(Pe,qe)=>{if(Pe.button!==0)return;const{edges:Ne,isValidConnection:We}=ke.getState(),Et=qe?N:k,et=(qe?H:D)||null,Ce=qe?"target":"source",wt=We||BP,at=qe,kt=Ne.find(Nn=>Nn.id===n);Ie(!0),W==null||W(Pe,kt,Ce);const Sn=Nn=>{Ie(!1),Q==null||Q(Nn,kt,Ce)};hC({event:Pe,handleId:et,nodeId:Et,onConnect:Nn=>J==null?void 0:J(kt,Nn),isTarget:at,getState:ke.getState,setState:ke.setState,isValidConnection:wt,edgeUpdaterType:Ce,onReconnectEnd:Sn})},Ke=Pe=>tt(Pe,!0),_t=Pe=>tt(Pe,!1),Me=()=>Ue(!0),it=()=>Ue(!1),At=!O&&!l,oe=Pe=>{var qe;if(!he&&tC.includes(Pe.key)&&O){const{unselectNodesAndEdges:Ne,addSelectedEdges:We,edges:Et}=ke.getState();Pe.key==="Escape"?((qe=ye.current)==null||qe.blur(),Ne({edges:[Et.find(Ce=>Ce.id===n)]})):We([n])}};return ue.createElement("g",{className:Ht(["react-flow__edge",`react-flow__edge-${o}`,s,{selected:h,animated:p,inactive:At,updating:Re}]),onClick:we,onDoubleClick:Ye,onContextMenu:yt,onMouseEnter:ct,onMouseMove:st,onMouseLeave:Be,onKeyDown:q?oe:void 0,tabIndex:q?0:void 0,role:q?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":L===null?void 0:L||`Edge from ${k} to ${N}`,"aria-describedby":q?`${_C}-${Y}`:void 0,ref:ye},!De&&ue.createElement(e,{id:n,source:k,target:N,selected:h,animated:p,label:f,labelStyle:g,labelShowBg:y,labelBgStyle:w,labelBgPadding:S,labelBgBorderRadius:b,data:a,style:_,sourceX:j,sourceY:T,targetX:M,targetY:P,sourcePosition:I,targetPosition:F,sourceHandleId:D,targetHandleId:H,markerStart:ce,markerEnd:xe,pathOptions:se,interactionWidth:fe}),Z&&ue.createElement(ue.Fragment,null,(Z==="source"||Z===!0)&&ue.createElement($b,{position:I,centerX:j,centerY:T,radius:ne,onMouseDown:Ke,onMouseEnter:Me,onMouseOut:it,type:"source"}),(Z==="target"||Z===!0)&&ue.createElement($b,{position:F,centerX:M,centerY:P,radius:ne,onMouseDown:_t,onMouseEnter:Me,onMouseOut:it,type:"target"})))};return t.displayName="EdgeWrapper",E.memo(t)};function UP(e){const t={default:bo(e.default||pu),straight:bo(e.bezier||ow),step:bo(e.step||iw),smoothstep:bo(e.step||Cu),simplebezier:bo(e.simplebezier||sw)},n={},s=Object.keys(e).filter(o=>!["default","bezier"].includes(o)).reduce((o,a)=>(o[a]=bo(e[a]||pu),o),n);return{...t,...s}}function Lb(e,t,n=null){const s=((n==null?void 0:n.x)||0)+t.x,o=((n==null?void 0:n.y)||0)+t.y,a=(n==null?void 0:n.width)||t.width,l=(n==null?void 0:n.height)||t.height;switch(e){case Oe.Top:return{x:s+a/2,y:o};case Oe.Right:return{x:s+a,y:o+l/2};case Oe.Bottom:return{x:s+a/2,y:o+l};case Oe.Left:return{x:s,y:o+l/2}}}function qb(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const WP=(e,t,n,s,o,a)=>{const l=Lb(n,e,t),u=Lb(a,s,o);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y}};function HP({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:s,targetWidth:o,targetHeight:a,width:l,height:u,transform:h}){const p={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+o),y2:Math.max(e.y+s,t.y+a)};p.x===p.x2&&(p.x2+=1),p.y===p.y2&&(p.y2+=1);const f=nl({x:(0-h[0])/h[2],y:(0-h[1])/h[2],width:l/h[2],height:u/h[2]}),g=Math.max(0,Math.min(f.x2,p.x2)-Math.max(f.x,p.x)),y=Math.max(0,Math.min(f.y2,p.y2)-Math.max(f.y,p.y));return Math.ceil(g*y)>0}function Db(e){var s,o,a,l,u;const t=((s=e==null?void 0:e[Nt])==null?void 0:s.handleBounds)||null,n=t&&(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((a=e==null?void 0:e.positionAbsolute)==null?void 0:a.y)<"u";return[{x:((l=e==null?void 0:e.positionAbsolute)==null?void 0:l.x)||0,y:((u=e==null?void 0:e.positionAbsolute)==null?void 0:u.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}const GP=[{level:0,isMaxLevel:!0,edges:[]}];function VP(e,t,n=!1){let s=-1;const o=e.reduce((l,u)=>{var f,g;const h=Ln(u.zIndex);let p=h?u.zIndex:0;if(n){const y=t.get(u.target),w=t.get(u.source),S=u.selected||(y==null?void 0:y.selected)||(w==null?void 0:w.selected),b=Math.max(((f=w==null?void 0:w[Nt])==null?void 0:f.z)||0,((g=y==null?void 0:y[Nt])==null?void 0:g.z)||0,1e3);p=(h?u.zIndex:0)+(S?b:0)}return l[p]?l[p].push(u):l[p]=[u],s=p>s?p:s,l},{}),a=Object.entries(o).map(([l,u])=>{const h=+l;return{edges:u,level:h,isMaxLevel:h===s}});return a.length===0?GP:a}function YP(e,t,n){const s=rt(E.useCallback(o=>e?o.edges.filter(a=>{const l=t.get(a.source),u=t.get(a.target);return(l==null?void 0:l.width)&&(l==null?void 0:l.height)&&(u==null?void 0:u.width)&&(u==null?void 0:u.height)&&HP({sourcePos:l.positionAbsolute||{x:0,y:0},targetPos:u.positionAbsolute||{x:0,y:0},sourceWidth:l.width,sourceHeight:l.height,targetWidth:u.width,targetHeight:u.height,width:o.width,height:o.height,transform:o.transform})}):o.edges,[e,t]));return VP(s,t,n)}const KP=({color:e="none",strokeWidth:t=1})=>ue.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),XP=({color:e="none",strokeWidth:t=1})=>ue.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),Fb={[hu.Arrow]:KP,[hu.ArrowClosed]:XP};function QP(e){const t=Tt();return E.useMemo(()=>{var o,a;return Object.prototype.hasOwnProperty.call(Fb,e)?Fb[e]:((a=(o=t.getState()).onError)==null||a.call(o,"009",Xr.error009(e)),null)},[e])}const ZP=({id:e,type:t,color:n,width:s=12.5,height:o=12.5,markerUnits:a="strokeWidth",strokeWidth:l,orient:u="auto-start-reverse"})=>{const h=QP(t);return h?ue.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:a,orient:u,refX:"0",refY:"0"},ue.createElement(h,{color:n,strokeWidth:l})):null},JP=({defaultColor:e,rfId:t})=>n=>{const s=[];return n.edges.reduce((o,a)=>([a.markerStart,a.markerEnd].forEach(l=>{if(l&&typeof l=="object"){const u=Ey(l,t);s.includes(u)||(o.push({id:u,color:l.color||e,...l}),s.push(u))}}),o),[]).sort((o,a)=>o.id.localeCompare(a.id))},IC=({defaultColor:e,rfId:t})=>{const n=rt(E.useCallback(JP({defaultColor:e,rfId:t}),[e,t]),(s,o)=>!(s.length!==o.length||s.some((a,l)=>a.id!==o[l].id)));return ue.createElement("defs",null,n.map(s=>ue.createElement(ZP,{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})))};IC.displayName="MarkerDefinitions";var e$=E.memo(IC);const t$=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}),OC=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:s,edgeTypes:o,noPanClassName:a,onEdgeContextMenu:l,onEdgeMouseEnter:u,onEdgeMouseMove:h,onEdgeMouseLeave:p,onEdgeClick:f,onEdgeDoubleClick:g,onReconnect:y,onReconnectStart:w,onReconnectEnd:S,reconnectRadius:b,children:_,disableKeyboardA11y:k})=>{const{edgesFocusable:N,edgesUpdatable:j,elementsSelectable:T,width:M,height:P,connectionMode:I,nodeInternals:F,onError:O}=rt(t$,$t),A=YP(t,F,n);return M?ue.createElement(ue.Fragment,null,A.map(({level:D,edges:H,isMaxLevel:K})=>ue.createElement("svg",{key:D,style:{zIndex:D},width:M,height:P,className:"react-flow__edges react-flow__container"},K&&ue.createElement(e$,{defaultColor:e,rfId:s}),ue.createElement("g",null,H.map(C=>{const[X,B,ne]=Db(F.get(C.source)),[J,W,Q]=Db(F.get(C.target));if(!ne||!Q)return null;let $=C.type||"default";o[$]||(O==null||O("011",Xr.error011($)),$="default");const G=o[$]||o.default,Y=I===wi.Strict?W.target:(W.target??[]).concat(W.source??[]),L=qb(B.source,C.sourceHandle),q=qb(Y,C.targetHandle),Z=(L==null?void 0:L.position)||Oe.Bottom,se=(q==null?void 0:q.position)||Oe.Top,fe=!!(C.focusable||N&&typeof C.focusable>"u"),he=C.reconnectable||C.updatable,ye=typeof y<"u"&&(he||j&&typeof he>"u");if(!L||!q)return O==null||O("008",Xr.error008(L,C)),null;const{sourceX:Re,sourceY:Ue,targetX:De,targetY:Ie}=WP(X,L,Z,J,q,se);return ue.createElement(G,{key:C.id,id:C.id,className:Ht([C.className,a]),type:$,data:C.data,selected:!!C.selected,animated:!!C.animated,hidden:!!C.hidden,label:C.label,labelStyle:C.labelStyle,labelShowBg:C.labelShowBg,labelBgStyle:C.labelBgStyle,labelBgPadding:C.labelBgPadding,labelBgBorderRadius:C.labelBgBorderRadius,style:C.style,source:C.source,target:C.target,sourceHandleId:C.sourceHandle,targetHandleId:C.targetHandle,markerEnd:C.markerEnd,markerStart:C.markerStart,sourceX:Re,sourceY:Ue,targetX:De,targetY:Ie,sourcePosition:Z,targetPosition:se,elementsSelectable:T,onContextMenu:l,onMouseEnter:u,onMouseMove:h,onMouseLeave:p,onClick:f,onEdgeDoubleClick:g,onReconnect:y,onReconnectStart:w,onReconnectEnd:S,reconnectRadius:b,rfId:s,ariaLabel:C.ariaLabel,isFocusable:fe,isReconnectable:ye,pathOptions:"pathOptions"in C?C.pathOptions:void 0,interactionWidth:C.interactionWidth,disableKeyboardA11y:k})})))),_):null};OC.displayName="EdgeRenderer";var n$=E.memo(OC);const r$=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function s$({children:e}){const t=rt(r$);return ue.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function i$(e){const t=hl(),n=E.useRef(!1);E.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const o$={[Oe.Left]:Oe.Right,[Oe.Right]:Oe.Left,[Oe.Top]:Oe.Bottom,[Oe.Bottom]:Oe.Top},PC=({nodeId:e,handleType:t,style:n,type:s=Ts.Bezier,CustomComponent:o,connectionStatus:a})=>{var P,I,F;const{fromNode:l,handleId:u,toX:h,toY:p,connectionMode:f}=rt(E.useCallback(O=>({fromNode:O.nodeInternals.get(e),handleId:O.connectionHandleId,toX:(O.connectionPosition.x-O.transform[0])/O.transform[2],toY:(O.connectionPosition.y-O.transform[1])/O.transform[2],connectionMode:O.connectionMode}),[e]),$t),g=(P=l==null?void 0:l[Nt])==null?void 0:P.handleBounds;let y=g==null?void 0:g[t];if(f===wi.Loose&&(y=y||(g==null?void 0:g[t==="source"?"target":"source"])),!l||!y)return null;const w=u?y.find(O=>O.id===u):y[0],S=w?w.x+w.width/2:(l.width??0)/2,b=w?w.y+w.height/2:l.height??0,_=(((I=l.positionAbsolute)==null?void 0:I.x)??0)+S,k=(((F=l.positionAbsolute)==null?void 0:F.y)??0)+b,N=w==null?void 0:w.position,j=N?o$[N]:null;if(!N||!j)return null;if(o)return ue.createElement(o,{connectionLineType:s,connectionLineStyle:n,fromNode:l,fromHandle:w,fromX:_,fromY:k,toX:h,toY:p,fromPosition:N,toPosition:j,connectionStatus:a});let T="";const M={sourceX:_,sourceY:k,sourcePosition:N,targetX:h,targetY:p,targetPosition:j};return s===Ts.Bezier?[T]=oC(M):s===Ts.Step?[T]=Ny({...M,borderRadius:0}):s===Ts.SmoothStep?[T]=Ny(M):s===Ts.SimpleBezier?[T]=iC(M):T=`M${_},${k} ${h},${p}`,ue.createElement("path",{d:T,fill:"none",className:"react-flow__connection-path",style:n})};PC.displayName="ConnectionLine";const a$=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function l$({containerStyle:e,style:t,type:n,component:s}){const{nodeId:o,handleType:a,nodesConnectable:l,width:u,height:h,connectionStatus:p}=rt(a$,$t);return!(o&&a&&u&&l)?null:ue.createElement("svg",{style:e,width:u,height:h,className:"react-flow__edges react-flow__connectionline react-flow__container"},ue.createElement("g",{className:Ht(["react-flow__connection",p])},ue.createElement(PC,{nodeId:o,handleType:a,style:t,type:n,CustomComponent:s,connectionStatus:p})))}function zb(e,t){return E.useRef(null),Tt(),E.useMemo(()=>t(e),[e])}const $C=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:s,onMoveEnd:o,onInit:a,onNodeClick:l,onEdgeClick:u,onNodeDoubleClick:h,onEdgeDoubleClick:p,onNodeMouseEnter:f,onNodeMouseMove:g,onNodeMouseLeave:y,onNodeContextMenu:w,onSelectionContextMenu:S,onSelectionStart:b,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:N,connectionLineComponent:j,connectionLineContainerStyle:T,selectionKeyCode:M,selectionOnDrag:P,selectionMode:I,multiSelectionKeyCode:F,panActivationKeyCode:O,zoomActivationKeyCode:A,deleteKeyCode:D,onlyRenderVisibleElements:H,elementsSelectable:K,selectNodesOnDrag:C,defaultViewport:X,translateExtent:B,minZoom:ne,maxZoom:J,preventScrolling:W,defaultMarkerColor:Q,zoomOnScroll:$,zoomOnPinch:G,panOnScroll:Y,panOnScrollSpeed:L,panOnScrollMode:q,zoomOnDoubleClick:Z,panOnDrag:se,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:ye,onPaneMouseLeave:Re,onPaneScroll:Ue,onPaneContextMenu:De,onEdgeContextMenu:Ie,onEdgeMouseEnter:ke,onEdgeMouseMove:ce,onEdgeMouseLeave:xe,onReconnect:we,onReconnectStart:Ye,onReconnectEnd:yt,reconnectRadius:ct,noDragClassName:st,noWheelClassName:Be,noPanClassName:tt,elevateEdgesOnSelect:Ke,disableKeyboardA11y:_t,nodeOrigin:Me,nodeExtent:it,rfId:At})=>{const oe=zb(e,$P),Pe=zb(t,UP);return i$(a),ue.createElement(OP,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:ye,onPaneMouseLeave:Re,onPaneContextMenu:De,onPaneScroll:Ue,deleteKeyCode:D,selectionKeyCode:M,selectionOnDrag:P,selectionMode:I,onSelectionStart:b,onSelectionEnd:_,multiSelectionKeyCode:F,panActivationKeyCode:O,zoomActivationKeyCode:A,elementsSelectable:K,onMove:n,onMoveStart:s,onMoveEnd:o,zoomOnScroll:$,zoomOnPinch:G,zoomOnDoubleClick:Z,panOnScroll:Y,panOnScrollSpeed:L,panOnScrollMode:q,panOnDrag:se,defaultViewport:X,translateExtent:B,minZoom:ne,maxZoom:J,onSelectionContextMenu:S,preventScrolling:W,noDragClassName:st,noWheelClassName:Be,noPanClassName:tt,disableKeyboardA11y:_t},ue.createElement(s$,null,ue.createElement(n$,{edgeTypes:Pe,onEdgeClick:u,onEdgeDoubleClick:p,onlyRenderVisibleElements:H,onEdgeContextMenu:Ie,onEdgeMouseEnter:ke,onEdgeMouseMove:ce,onEdgeMouseLeave:xe,onReconnect:we,onReconnectStart:Ye,onReconnectEnd:yt,reconnectRadius:ct,defaultMarkerColor:Q,noPanClassName:tt,elevateEdgesOnSelect:!!Ke,disableKeyboardA11y:_t,rfId:At},ue.createElement(l$,{style:N,type:k,component:j,containerStyle:T})),ue.createElement("div",{className:"react-flow__edgelabel-renderer"}),ue.createElement(DP,{nodeTypes:oe,onNodeClick:l,onNodeDoubleClick:h,onNodeMouseEnter:f,onNodeMouseMove:g,onNodeMouseLeave:y,onNodeContextMenu:w,selectNodesOnDrag:C,onlyRenderVisibleElements:H,noPanClassName:tt,noDragClassName:st,disableKeyboardA11y:_t,nodeOrigin:Me,nodeExtent:it,rfId:At})))};$C.displayName="GraphView";var c$=E.memo($C);const Ry=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Es={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:Ry,nodeExtent:Ry,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:wi.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:$O,isValidConnection:void 0},u$=()=>QA((e,t)=>({...Es,setNodes:n=>{const{nodeInternals:s,nodeOrigin:o,elevateNodesOnSelect:a}=t();e({nodeInternals:Df(n,s,o,a)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:s={}}=t();e({edges:n.map(o=>({...s,...o}))})},setDefaultNodesAndEdges:(n,s)=>{const o=typeof n<"u",a=typeof s<"u",l=o?Df(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:l,edges:a?s:[],hasDefaultNodes:o,hasDefaultEdges:a})},updateNodeDimensions:n=>{const{onNodesChange:s,nodeInternals:o,fitViewOnInit:a,fitViewOnInitDone:l,fitViewOnInitOptions:u,domNode:h,nodeOrigin:p}=t(),f=h==null?void 0:h.querySelector(".react-flow__viewport");if(!f)return;const g=window.getComputedStyle(f),{m22:y}=new window.DOMMatrixReadOnly(g.transform),w=n.reduce((b,_)=>{const k=o.get(_.id);if(k!=null&&k.hidden)o.set(k.id,{...k,[Nt]:{...k[Nt],handleBounds:void 0}});else if(k){const N=nw(_.nodeElement);!!(N.width&&N.height&&(k.width!==N.width||k.height!==N.height||_.forceUpdate))&&(o.set(k.id,{...k,[Nt]:{...k[Nt],handleBounds:{source:Ob(".source",_.nodeElement,y,p),target:Ob(".target",_.nodeElement,y,p)}},...N}),b.push({id:k.id,type:"dimensions",dimensions:N}))}return b},[]);SC(o,p);const S=l||a&&!l&&NC(t,{initial:!0,...u});e({nodeInternals:new Map(o),fitViewOnInitDone:S}),(w==null?void 0:w.length)>0&&(s==null||s(w))},updateNodePositions:(n,s=!0,o=!1)=>{const{triggerNodeChanges:a}=t(),l=n.map(u=>{const h={id:u.id,type:"position",dragging:o};return s&&(h.positionAbsolute=u.positionAbsolute,h.position=u.position),h});a(l)},triggerNodeChanges:n=>{const{onNodesChange:s,nodeInternals:o,hasDefaultNodes:a,nodeOrigin:l,getNodes:u,elevateNodesOnSelect:h}=t();if(n!=null&&n.length){if(a){const p=NP(n,u()),f=Df(p,o,l,h);e({nodeInternals:f})}s==null||s(n)}},addSelectedNodes:n=>{const{multiSelectionActive:s,edges:o,getNodes:a}=t();let l,u=null;s?l=n.map(h=>Cs(h,!0)):(l=No(a(),n),u=No(o,[])),Bc({changedNodes:l,changedEdges:u,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:s,edges:o,getNodes:a}=t();let l,u=null;s?l=n.map(h=>Cs(h,!0)):(l=No(o,n),u=No(a(),[])),Bc({changedNodes:u,changedEdges:l,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:s}={})=>{const{edges:o,getNodes:a}=t(),l=n||a(),u=s||o,h=l.map(f=>(f.selected=!1,Cs(f.id,!1))),p=u.map(f=>Cs(f.id,!1));Bc({changedNodes:h,changedEdges:p,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:s,maxZoom:o}=t();s==null||s.scaleExtent([n,o]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:s,minZoom:o}=t();s==null||s.scaleExtent([o,n]),e({maxZoom:n})},setTranslateExtent:n=>{var s;(s=t().d3Zoom)==null||s.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:s}=t(),a=s().filter(u=>u.selected).map(u=>Cs(u.id,!1)),l=n.filter(u=>u.selected).map(u=>Cs(u.id,!1));Bc({changedNodes:a,changedEdges:l,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:s}=t();s.forEach(o=>{o.positionAbsolute=rw(o.position,n)}),e({nodeExtent:n,nodeInternals:new Map(s)})},panBy:n=>{const{transform:s,width:o,height:a,d3Zoom:l,d3Selection:u,translateExtent:h}=t();if(!l||!u||!n.x&&!n.y)return!1;const p=Yr.translate(s[0]+n.x,s[1]+n.y).scale(s[2]),f=[[0,0],[o,a]],g=l==null?void 0:l.constrain()(p,f,h);return l.transform(u,g),s[0]!==g.x||s[1]!==g.y||s[2]!==g.k},cancelConnection:()=>e({connectionNodeId:Es.connectionNodeId,connectionHandleId:Es.connectionHandleId,connectionHandleType:Es.connectionHandleType,connectionStatus:Es.connectionStatus,connectionStartHandle:Es.connectionStartHandle,connectionEndHandle:Es.connectionEndHandle}),reset:()=>e({...Es})}),Object.is),dw=({children:e})=>{const t=E.useRef(null);return t.current||(t.current=u$()),ue.createElement(TO,{value:t.current},e)};dw.displayName="ReactFlowProvider";const LC=({children:e})=>E.useContext(ju)?ue.createElement(ue.Fragment,null,e):ue.createElement(dw,null,e);LC.displayName="ReactFlowWrapper";const d$={input:vC,default:Cy,output:wC,group:cw},f$={default:pu,straight:ow,step:iw,smoothstep:Cu,simplebezier:sw},h$=[0,0],p$=[15,15],m$={x:0,y:0,zoom:1},g$={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},qC=E.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,className:o,nodeTypes:a=d$,edgeTypes:l=f$,onNodeClick:u,onEdgeClick:h,onInit:p,onMove:f,onMoveStart:g,onMoveEnd:y,onConnect:w,onConnectStart:S,onConnectEnd:b,onClickConnectStart:_,onClickConnectEnd:k,onNodeMouseEnter:N,onNodeMouseMove:j,onNodeMouseLeave:T,onNodeContextMenu:M,onNodeDoubleClick:P,onNodeDragStart:I,onNodeDrag:F,onNodeDragStop:O,onNodesDelete:A,onEdgesDelete:D,onSelectionChange:H,onSelectionDragStart:K,onSelectionDrag:C,onSelectionDragStop:X,onSelectionContextMenu:B,onSelectionStart:ne,onSelectionEnd:J,connectionMode:W=wi.Strict,connectionLineType:Q=Ts.Bezier,connectionLineStyle:$,connectionLineComponent:G,connectionLineContainerStyle:Y,deleteKeyCode:L="Backspace",selectionKeyCode:q="Shift",selectionOnDrag:Z=!1,selectionMode:se=rl.Full,panActivationKeyCode:fe="Space",multiSelectionKeyCode:he=fu()?"Meta":"Control",zoomActivationKeyCode:ye=fu()?"Meta":"Control",snapToGrid:Re=!1,snapGrid:Ue=p$,onlyRenderVisibleElements:De=!1,selectNodesOnDrag:Ie=!0,nodesDraggable:ke,nodesConnectable:ce,nodesFocusable:xe,nodeOrigin:we=h$,edgesFocusable:Ye,edgesUpdatable:yt,elementsSelectable:ct,defaultViewport:st=m$,minZoom:Be=.5,maxZoom:tt=2,translateExtent:Ke=Ry,preventScrolling:_t=!0,nodeExtent:Me,defaultMarkerColor:it="#b1b1b7",zoomOnScroll:At=!0,zoomOnPinch:oe=!0,panOnScroll:Pe=!1,panOnScrollSpeed:qe=.5,panOnScrollMode:Ne=mi.Free,zoomOnDoubleClick:We=!0,panOnDrag:Et=!0,onPaneClick:et,onPaneMouseEnter:Ce,onPaneMouseMove:wt,onPaneMouseLeave:at,onPaneScroll:kt,onPaneContextMenu:Sn,children:Fn,onEdgeContextMenu:Nn,onEdgeDoubleClick:Ni,onEdgeMouseEnter:mn,onEdgeMouseMove:Ei,onEdgeMouseLeave:ji,onEdgeUpdate:Bt,onEdgeUpdateStart:jr,onEdgeUpdateEnd:zn,onReconnect:Is,onReconnectStart:Cr,onReconnectEnd:Ko,reconnectRadius:dr=10,edgeUpdaterRadius:Tr=10,onNodesChange:fr,onEdgesChange:Jr,noDragClassName:Ci="nodrag",noWheelClassName:Ti="nowheel",noPanClassName:Ri="nopan",fitView:En=!1,fitViewOptions:Ai,connectOnClick:Rr=!0,attributionPosition:Mi,proOptions:Bn,defaultEdgeOptions:Ii,elevateNodesOnSelect:Os=!0,elevateEdgesOnSelect:Ps=!1,disableKeyboardA11y:Oi=!1,autoPanOnConnect:Pi=!0,autoPanOnNodeDrag:nt=!0,connectionRadius:Xo=20,isValidConnection:es,onError:Gt,style:Un,id:$i,nodeDragThreshold:ts,...ht},sn)=>{const Wn=$i||"1";return ue.createElement("div",{...ht,style:{...Un,...g$},ref:sn,className:Ht(["react-flow",o]),"data-testid":"rf__wrapper",id:$i},ue.createElement(LC,null,ue.createElement(c$,{onInit:p,onMove:f,onMoveStart:g,onMoveEnd:y,onNodeClick:u,onEdgeClick:h,onNodeMouseEnter:N,onNodeMouseMove:j,onNodeMouseLeave:T,onNodeContextMenu:M,onNodeDoubleClick:P,nodeTypes:a,edgeTypes:l,connectionLineType:Q,connectionLineStyle:$,connectionLineComponent:G,connectionLineContainerStyle:Y,selectionKeyCode:q,selectionOnDrag:Z,selectionMode:se,deleteKeyCode:L,multiSelectionKeyCode:he,panActivationKeyCode:fe,zoomActivationKeyCode:ye,onlyRenderVisibleElements:De,selectNodesOnDrag:Ie,defaultViewport:st,translateExtent:Ke,minZoom:Be,maxZoom:tt,preventScrolling:_t,zoomOnScroll:At,zoomOnPinch:oe,zoomOnDoubleClick:We,panOnScroll:Pe,panOnScrollSpeed:qe,panOnScrollMode:Ne,panOnDrag:Et,onPaneClick:et,onPaneMouseEnter:Ce,onPaneMouseMove:wt,onPaneMouseLeave:at,onPaneScroll:kt,onPaneContextMenu:Sn,onSelectionContextMenu:B,onSelectionStart:ne,onSelectionEnd:J,onEdgeContextMenu:Nn,onEdgeDoubleClick:Ni,onEdgeMouseEnter:mn,onEdgeMouseMove:Ei,onEdgeMouseLeave:ji,onReconnect:Is??Bt,onReconnectStart:Cr??jr,onReconnectEnd:Ko??zn,reconnectRadius:dr??Tr,defaultMarkerColor:it,noDragClassName:Ci,noWheelClassName:Ti,noPanClassName:Ri,elevateEdgesOnSelect:Ps,rfId:Wn,disableKeyboardA11y:Oi,nodeOrigin:we,nodeExtent:Me}),ue.createElement(iP,{nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:w,onConnectStart:S,onConnectEnd:b,onClickConnectStart:_,onClickConnectEnd:k,nodesDraggable:ke,nodesConnectable:ce,nodesFocusable:xe,edgesFocusable:Ye,edgesUpdatable:yt,elementsSelectable:ct,elevateNodesOnSelect:Os,minZoom:Be,maxZoom:tt,nodeExtent:Me,onNodesChange:fr,onEdgesChange:Jr,snapToGrid:Re,snapGrid:Ue,connectionMode:W,translateExtent:Ke,connectOnClick:Rr,defaultEdgeOptions:Ii,fitView:En,fitViewOptions:Ai,onNodesDelete:A,onEdgesDelete:D,onNodeDragStart:I,onNodeDrag:F,onNodeDragStop:O,onSelectionDrag:C,onSelectionDragStart:K,onSelectionDragStop:X,noPanClassName:Ri,nodeOrigin:we,rfId:Wn,autoPanOnConnect:Pi,autoPanOnNodeDrag:nt,onError:Gt,connectionRadius:Xo,isValidConnection:es,nodeDragThreshold:ts}),ue.createElement(rP,{onSelectionChange:H}),Fn,ue.createElement(AO,{proOptions:Bn,position:Mi}),ue.createElement(uP,{rfId:Wn,disableKeyboardA11y:Oi})))});qC.displayName="ReactFlow";const v$=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function DC(){return rt(v$,$t)}const FC=({id:e,x:t,y:n,width:s,height:o,style:a,color:l,strokeColor:u,strokeWidth:h,className:p,borderRadius:f,shapeRendering:g,onClick:y,selected:w})=>{const{background:S,backgroundColor:b}=a||{},_=l||S||b;return ue.createElement("rect",{className:Ht(["react-flow__minimap-node",{selected:w},p]),x:t,y:n,rx:f,ry:f,width:s,height:o,fill:_,stroke:u,strokeWidth:h,shapeRendering:g,onClick:y?k=>y(k,e):void 0})};FC.displayName="MiniMapNode";var y$=E.memo(FC);const w$=e=>e.nodeOrigin,x$=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),Uf=e=>e instanceof Function?e:()=>e;function b$({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:s=5,nodeStrokeWidth:o=2,nodeComponent:a=y$,onClick:l}){const u=rt(x$,$t),h=rt(w$),p=Uf(t),f=Uf(e),g=Uf(n),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return ue.createElement(ue.Fragment,null,u.map(w=>{const{x:S,y:b}=vi(w,h).positionAbsolute;return ue.createElement(a,{key:w.id,x:S,y:b,width:w.width,height:w.height,style:w.style,selected:w.selected,className:g(w),color:p(w),borderRadius:s,strokeColor:f(w),strokeWidth:o,shapeRendering:y,onClick:l,id:w.id})}))}var _$=E.memo(b$);const k$=200,S$=150,N$=e=>{const t=e.getNodes(),n={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:n,boundingRect:t.length>0?OO(Tu(t,e.nodeOrigin),n):n,rfId:e.rfId}},E$="react-flow__minimap-desc";function zC({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:s="#e2e2e2",nodeClassName:o="",nodeBorderRadius:a=5,nodeStrokeWidth:l=2,nodeComponent:u,maskColor:h="rgb(240, 240, 240, 0.6)",maskStrokeColor:p="none",maskStrokeWidth:f=1,position:g="bottom-right",onClick:y,onNodeClick:w,pannable:S=!1,zoomable:b=!1,ariaLabel:_="React Flow mini map",inversePan:k=!1,zoomStep:N=10,offsetScale:j=5}){const T=Tt(),M=E.useRef(null),{boundingRect:P,viewBB:I,rfId:F}=rt(N$,$t),O=(e==null?void 0:e.width)??k$,A=(e==null?void 0:e.height)??S$,D=P.width/O,H=P.height/A,K=Math.max(D,H),C=K*O,X=K*A,B=j*K,ne=P.x-(C-P.width)/2-B,J=P.y-(X-P.height)/2-B,W=C+B*2,Q=X+B*2,$=`${E$}-${F}`,G=E.useRef(0);G.current=K,E.useEffect(()=>{if(M.current){const q=$n(M.current),Z=he=>{const{transform:ye,d3Selection:Re,d3Zoom:Ue}=T.getState();if(he.sourceEvent.type!=="wheel"||!Re||!Ue)return;const De=-he.sourceEvent.deltaY*(he.sourceEvent.deltaMode===1?.05:he.sourceEvent.deltaMode?1:.002)*N,Ie=ye[2]*Math.pow(2,De);Ue.scaleTo(Re,Ie)},se=he=>{const{transform:ye,d3Selection:Re,d3Zoom:Ue,translateExtent:De,width:Ie,height:ke}=T.getState();if(he.sourceEvent.type!=="mousemove"||!Re||!Ue)return;const ce=G.current*Math.max(1,ye[2])*(k?-1:1),xe={x:ye[0]-he.sourceEvent.movementX*ce,y:ye[1]-he.sourceEvent.movementY*ce},we=[[0,0],[Ie,ke]],Ye=Yr.translate(xe.x,xe.y).scale(ye[2]),yt=Ue.constrain()(Ye,we,De);Ue.transform(Re,yt)},fe=Kj().on("zoom",S?se:null).on("zoom.wheel",b?Z:null);return q.call(fe),()=>{q.on("zoom",null)}}},[S,b,k,N]);const Y=y?q=>{const Z=rr(q);y(q,{x:Z[0],y:Z[1]})}:void 0,L=w?(q,Z)=>{const se=T.getState().nodeInternals.get(Z);w(q,se)}:void 0;return ue.createElement(tw,{position:g,style:e,className:Ht(["react-flow__minimap",t]),"data-testid":"rf__minimap"},ue.createElement("svg",{width:O,height:A,viewBox:`${ne} ${J} ${W} ${Q}`,role:"img","aria-labelledby":$,ref:M,onClick:Y},_&&ue.createElement("title",{id:$},_),ue.createElement(_$,{onClick:L,nodeColor:s,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:o,nodeStrokeWidth:l,nodeComponent:u}),ue.createElement("path",{className:"react-flow__minimap-mask",d:`M${ne-B},${J-B}h${W+B*2}v${Q+B*2}h${-W-B*2}z
57
- M${I.x},${I.y}h${I.width}v${I.height}h${-I.width}z`,fill:h,fillRule:"evenodd",stroke:p,strokeWidth:f,pointerEvents:"none"})))}zC.displayName="MiniMap";var j$=E.memo(zC);function C$(){return ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},ue.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function T$(){return ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},ue.createElement("path",{d:"M0 0h32v4.2H0z"}))}function R$(){return ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},ue.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 A$(){return ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ue.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 M$(){return ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ue.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 kr=({children:e,className:t,...n})=>ue.createElement("button",{type:"button",className:Ht(["react-flow__controls-button",t]),...n},e);kr.displayName="ControlButton";const I$=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),BC=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:s=!0,fitViewOptions:o,onZoomIn:a,onZoomOut:l,onFitView:u,onInteractiveChange:h,className:p,children:f,position:g="bottom-left"})=>{const y=Tt(),[w,S]=E.useState(!1),{isInteractive:b,minZoomReached:_,maxZoomReached:k}=rt(I$,$t),{zoomIn:N,zoomOut:j,fitView:T}=hl();if(E.useEffect(()=>{S(!0)},[]),!w)return null;const M=()=>{N(),a==null||a()},P=()=>{j(),l==null||l()},I=()=>{T(o),u==null||u()},F=()=>{y.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),h==null||h(!b)};return ue.createElement(tw,{className:Ht(["react-flow__controls",p]),position:g,style:e,"data-testid":"rf__controls"},t&&ue.createElement(ue.Fragment,null,ue.createElement(kr,{onClick:M,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:k},ue.createElement(C$,null)),ue.createElement(kr,{onClick:P,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:_},ue.createElement(T$,null))),n&&ue.createElement(kr,{className:"react-flow__controls-fitview",onClick:I,title:"fit view","aria-label":"fit view"},ue.createElement(R$,null)),s&&ue.createElement(kr,{className:"react-flow__controls-interactive",onClick:F,title:"toggle interactivity","aria-label":"toggle interactivity"},b?ue.createElement(M$,null):ue.createElement(A$,null)),f)};BC.displayName="Controls";var O$=E.memo(BC),ar;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ar||(ar={}));function P$({color:e,dimensions:t,lineWidth:n}){return ue.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function $$({color:e,radius:t}){return ue.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const L$={[ar.Dots]:"#91919a",[ar.Lines]:"#eee",[ar.Cross]:"#e2e2e2"},q$={[ar.Dots]:1,[ar.Lines]:1,[ar.Cross]:6},D$=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function UC({id:e,variant:t=ar.Dots,gap:n=20,size:s,lineWidth:o=1,offset:a=2,color:l,style:u,className:h}){const p=E.useRef(null),{transform:f,patternId:g}=rt(D$,$t),y=l||L$[t],w=s||q$[t],S=t===ar.Dots,b=t===ar.Cross,_=Array.isArray(n)?n:[n,n],k=[_[0]*f[2]||1,_[1]*f[2]||1],N=w*f[2],j=b?[N,N]:k,T=S?[N/a,N/a]:[j[0]/a,j[1]/a];return ue.createElement("svg",{className:Ht(["react-flow__background",h]),style:{...u,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:p,"data-testid":"rf__background"},ue.createElement("pattern",{id:g+e,x:f[0]%k[0],y:f[1]%k[1],width:k[0],height:k[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`},S?ue.createElement($$,{color:y,radius:N/a}):ue.createElement(P$,{dimensions:j,color:y,lineWidth:o})),ue.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${g+e})`}))}UC.displayName="Background";var F$=E.memo(UC);const z$=["us-gov","global","apac","us","eu","jp","au"],B$=new RegExp(`^(?:(?:${z$.join("|")})\\.)?anthropic\\.`,"i");function Ru(e){return e.replace(B$,"")}function WC(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function fw(e){const t=e.cache_creation,n=t&&typeof t=="object"?t:e,s=n.ephemeral_1h_input_tokens,o=n.ephemeral_5m_input_tokens;return typeof s!="number"&&typeof o!="number"?{}:{cacheCreate1hTokens:Number(s??0),cacheCreate5mTokens:Number(o??0)}}function U$(e){const t=fw(e),n={inputTokens:Number(e.input_tokens??0),outputTokens:Number(e.output_tokens??0),cacheReadTokens:Number(e.cache_read_input_tokens??e.cached_input_tokens??0),cacheCreateTokens:Number(e.cache_creation_input_tokens??e.cache_write_input_tokens??0),cacheCreate1hTokens:t.cacheCreate1hTokens,cacheCreate5mTokens:t.cacheCreate5mTokens};return typeof e.reasoning_output_tokens=="number"&&(n.reasoningOutputTokens=Number(e.reasoning_output_tokens)),n}function W$(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t={};for(const[n,s]of Object.entries(e))!n||!s||typeof s!="object"||(t[n]=U$(s));return Object.keys(t).length?t:void 0}function HC(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.input_tokens=="number"||typeof n.output_tokens=="number"||typeof n.cache_read_input_tokens=="number"||typeof n.cache_creation_input_tokens=="number")return{inputTokens:Number(n.input_tokens??0),outputTokens:Number(n.output_tokens??0),cacheReadTokens:Number(n.cache_read_input_tokens??0),cacheCreateTokens:Number(n.cache_creation_input_tokens??0),...fw(n)};for(const s of Object.values(n)){const o=HC(s,t+1);if(o)return o}return null}const H$=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i;function GC(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.model=="string"&&H$.test(Ru(n.model)))return n.model;for(const s of Object.values(n)){const o=GC(s,t+1);if(o)return o}return null}function Ay(){return{agents:new Map,toolIndex:new Map,toolOwner:new Map,activeSubagentStack:new Map,lastSeq:0,seqEpoch:null,totalEvents:0,revision:0}}function As(e){if(!e)return;const t=e.replace(/\\/g,"/").split("/").filter(Boolean);return t[t.length-1]}function Bb(){return{msgsUser:0,msgsAssistant:0,toolUses:0,toolResults:0,systemReminders:0,currentContextTokens:0,memoryFiles:[]}}function pl(e,t){return`${e}::${t}`}function mu(e){return e.agent_type??e.subagent_type??"subagent"}function Ka(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function Eo(e,t,n,s){const o=t;let a=e.agents.get(o);return a||(a={id:o,sessionId:t,label:"session",kind:"root",state:"active",startedAt:n,lastEventAt:n,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:s,usage:WC()},e.agents.set(o,a),a)}function VC(e,t,n,s){const o=pl(t,n),a=e.agents.get(o);if(!a)return null;!a.cwd&&s.cwd&&(a.cwd=s.cwd,a.cwdBasename=As(s.cwd));const l=mu(s);return l&&(a.label==="subagent"||!a.label)&&(a.label=l),a}function G$(e,t,n){const s=t.session_id??"unknown",o=Ka(t);if(o){const h=VC(e,s,o,t);if(h)return h}const a=e.activeSubagentStack.get(s),l=a&&a.length>0?a[a.length-1]:null;if(l){const h=e.agents.get(pl(s,l));if(h)return!h.cwd&&t.cwd&&(h.cwd=t.cwd,h.cwdBasename=As(t.cwd)),h}const u=Eo(e,s,n,t.hook_event_name!=="SessionStart");return!u.cwd&&t.cwd&&(u.cwd=t.cwd,u.cwdBasename=As(t.cwd)),u.label==="session"&&t.cwd&&(u.label=As(t.cwd)??"session"),u}function V$(e,t,n,s,o){const a=pl(t,n),l=Eo(e,t,o,!0);let u=e.agents.get(a);if(u){!u.cwd&&s.cwd&&(u.cwd=s.cwd,u.cwdBasename=As(s.cwd));const h=mu(s);return h&&(u.label==="subagent"||!u.label)&&(u.label=h),u}return u={id:a,sessionId:t,label:mu(s),kind:"subagent",parentId:l.id,state:"active",startedAt:o,tools:[],prompts:[],cwd:s.cwd,cwdBasename:As(s.cwd),toolCount:0,childCount:0,usage:WC()},e.agents.set(a,u),l.childCount+=1,u}function Y$(e,t,n){const s=e.activeSubagentStack.get(t)??[];s.includes(n)||(s.push(n),e.activeSubagentStack.set(t,s))}function K$(e,t,n){const s=e.activeSubagentStack.get(t);if(s){for(let o=s.length-1;o>=0;o--)if(s[o]===n){s.splice(o,1);break}s.length===0&&e.activeSubagentStack.delete(t)}}function Wc(e,t=80){if(e==null)return"";if(typeof e=="string")return e.length>t?e.slice(0,t-1)+"…":e;try{const n=JSON.stringify(e);return n.length>t?n.slice(0,t-1)+"…":n}catch{return String(e)}}const Ub=200,X$=25;function Q$(e,t){const n=t.tools;if(n.length>Ub){const s=n.splice(0,n.length-Ub);for(const o of s)e.toolIndex.get(o.id)===o&&(e.toolIndex.delete(o.id),e.toolOwner.delete(o.id))}for(let s=n.length-X$-1;s>=0;s--){const o=n[s];if(o.trimmed)break;o.input=void 0,o.response=void 0,o.trimmed=!0}}function Z$(e,t,n){const s=e.toolIndex.get(n);if(s)return s;for(let o=t.tools.length-1;o>=0;o--)if(t.tools[o].id===n)return t.tools[o];return null}const Wb=2e3;function J$(e,t,n){for(let s=e.prompts.length-1;s>=0;s--){const o=e.prompts[s];if(o.at<t-Wb)return!1;if(o.text===n&&o.at<=t+Wb)return!0}return!1}function YC(e,t){for(const n of t.tools)e.toolIndex.get(n.id)===n&&e.toolIndex.delete(n.id),e.toolOwner.get(n.id)===t.id&&e.toolOwner.delete(n.id)}function ml(e,t){return t&&(e.revision+=1),t}function eL(e,t,n,s){if(e.agents.size<=n)return!1;const o=p=>p.state==="done"&&p.endedAt!=null&&t-p.endedAt>s,a=[],l=new Map;for(const[p,f]of e.agents){if(f.parentId!=null){const g=l.get(f.parentId);g?g.push(p):l.set(f.parentId,[p])}o(f)&&a.push({id:p,endedAt:f.endedAt})}if(a.length===0)return!1;a.sort((p,f)=>p.endedAt-f.endedAt);let u=0;const h=p=>{const f=e.agents.get(p);f&&(YC(e,f),e.agents.delete(p),u++)};for(const p of a){if(e.agents.size<=n)break;if(!e.agents.has(p.id))continue;const f=(l.get(p.id)??[]).map(g=>e.agents.get(g)).filter(g=>g!=null);if(!f.some(g=>!o(g))){for(const g of f)h(g.id);h(p.id)}}return ml(e,u>0)}function tL(e,t,n,s){const o=new Map;for(const[p,f]of e.agents){let g=o.get(f.sessionId);g||(g={ids:[],endedAt:0,live:!1,closed:!1},o.set(f.sessionId,g)),g.ids.push(p),f.kind==="root"&&f.closedAt!=null&&(g.closed=!0),f.state==="done"&&f.endedAt!=null?g.endedAt=Math.max(g.endedAt,f.endedAt):g.live=!0}const a=[...o.values()].filter(p=>!p.live&&p.endedAt>0&&t-p.endedAt>s).sort((p,f)=>p.closed===f.closed?p.endedAt-f.endedAt:p.closed?-1:1);let u=[...o.values()].filter(p=>!p.live).length-n;if(u<=0)return!1;let h=!1;for(const p of a){if(u<=0)break;for(const f of p.ids){const g=e.agents.get(f);g&&YC(e,g),e.agents.delete(f)}u--,h=!0}return ml(e,h)}function nL(e,t){const n=t==null?void 0:t.payload,s=n==null?void 0:n.hook_event_name;if(s!=="PostToolUse"&&s!=="PostToolUseFailure")return!1;const o=n==null?void 0:n.tool_use_id;return typeof o=="string"&&o.length>0&&e.toolIndex.has(o)}function rL(e){let t=!1;for(const n of e.agents.values())for(const s of n.tools)s.endedAt!=null||s.outcomeGap||(s.outcomeGap=!0,t=!0);return ml(e,t)}function sL(e,t,n){let s=!1;for(const o of e.agents.values()){if(o.provider==="codex")continue;const a=e.agents.get(o.sessionId),l=(a==null?void 0:a.lastEventAt)??(a==null?void 0:a.startedAt);for(const u of o.tools){const h=Math.max(u.startedAt,l??u.startedAt);u.endedAt==null&&t-h>n&&(u.endedAt=h,u.ok=!1,u.errorPreview=u.outcomeGap?"no result reached the deck — events were dropped while the deck was paused":"session ended before this call returned",e.toolIndex.delete(u.id),e.toolOwner.delete(u.id),s=!0)}}return ml(e,s)}const Hb=90*6e4;function iL(e,t,n){let s=!1;for(const o of e.agents.values()){if(o.kind!=="root")continue;const a=o.lastEventAt??o.startedAt;if(!(t-a<=n)){o.waiting&&(o.waiting=null,s=!0),o.closedAt==null&&(o.closedAt=a),o.state==="active"&&(o.state="done",o.endedAt=a,o.reaped=!0,s=!0);for(const l of e.agents.values())l.sessionId!==o.sessionId||l.kind==="root"||l.state!=="active"||(l.state="done",l.endedAt=a,s=!0);e.activeSubagentStack.delete(o.sessionId)}}return ml(e,s)}function oL(e){return e==="permission_prompt"?"permission":e==="idle_prompt"?"idle":null}const aL=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved","SessionNamed"]);function lL(e,t){let n=null;for(const s of e.toolIndex.values()){const o=s.agentId?e.agents.get(s.agentId):void 0;!o||o.sessionId!==t||(!n||s.startedAt>n.startedAt)&&(n=s)}return n==null?void 0:n.explicitSubagentId}function cL(e,t,n,s,o){const a=n==="permission"?lL(e,t):void 0;return a?{kind:n,message:s,since:o,subagentId:a}:{kind:n,message:s,since:o}}function uL(e,t,n){if(e.kind!=="permission")return!0;const s=Ka(t);return s==null?!0:e.subagentId!=null&&pl(n,s)===e.subagentId}function Gb(e,t){const n=t.epoch??null;if(n!==null&&n!==e.seqEpoch)e.seqEpoch=n,e.lastSeq=0;else if(t.seq<=e.lastSeq)return e;const s=t.payload??{},o=t.receivedAt,a=s.hook_event_name??"Unknown";if(a==="__clear")return{...Ay(),lastSeq:t.seq,seqEpoch:e.seqEpoch,revision:e.revision+1};e.totalEvents+=1,e.lastSeq=t.seq,e.revision+=1;const l=s.session_id??"unknown";if(!aL.has(a)){const f=e.agents.get(l);f!=null&&f.waiting&&uL(f.waiting,s,l)&&(f.waiting=null)}const u=e.agents.get(l);if(u&&o>(u.lastEventAt??0)&&(u.lastEventAt=o,u.reaped&&(u.reaped=!1,u.state="active",u.endedAt=void 0,u.closedAt=void 0)),typeof s.model_context_window=="number"&&s.model_context_window>0){const f=e.agents.get(l);f&&(f.contextWindow=s.model_context_window)}if(typeof s.approval_policy=="string"&&s.approval_policy){const f=e.agents.get(l);f&&(f.approvalPolicy=s.approval_policy)}if(typeof s.context_tokens=="number"&&s.context_tokens>=0){const f=e.agents.get(l);f&&(f.context={...f.context??Bb(),currentContextTokens:s.context_tokens})}if(a==="ModelObserved"){const f=typeof s.model=="string"?s.model:null;if(f){const y=e.agents.get(l);y&&(y.model=f)}const g=s.subagentModels;if(g&&typeof g=="object")for(const[y,w]of Object.entries(g)){if(typeof w!="string")continue;const S=`${l}::${y}`,b=e.agents.get(S);b&&(b.model=w)}return e}if(a==="ContextObserved"){const f=s.context??null;if(f){const g=e.agents.get(l);if(g){const y=g.context??Bb(),w=(b,_)=>typeof f[b]=="number"?f[b]:_,S=Array.isArray(f.memoryFiles)?f.memoryFiles:Array.isArray(f.claudeMdFiles)?f.claudeMdFiles:null;g.context={msgsUser:w("msgsUser",y.msgsUser),msgsAssistant:w("msgsAssistant",y.msgsAssistant),toolUses:w("toolUses",y.toolUses),toolResults:w("toolResults",y.toolResults),systemReminders:w("systemReminders",y.systemReminders),currentContextTokens:w("currentContextTokens",y.currentContextTokens),memoryFiles:S??y.memoryFiles}}}return e}if(a==="SessionNamed"){const f=e.agents.get(l);if(f){const g=typeof s.sessionName=="string"?s.sessionName.trim():"",y=typeof s.sessionTitle=="string"?s.sessionTitle.trim():"";g&&(f.sessionName=g),y&&(f.sessionTitle=y);const w=f.sessionName??"";f.sessionTitle&&w&&f.sessionTitle.toLowerCase()===w.toLowerCase()&&(f.sessionTitle=void 0)}return e}if(a==="UsageObserved"){const f=s.usage??null;if(f){const g=e.agents.get(l);if(g){g.usage.inputTokens=Number(f.input_tokens??0),g.usage.outputTokens=Number(f.output_tokens??0),g.usage.cacheReadTokens=Number(f.cache_read_input_tokens??f.cached_input_tokens??0),g.usage.cacheCreateTokens=Number(f.cache_creation_input_tokens??f.cache_write_input_tokens??0);const y=fw(f);g.usage.cacheCreate1hTokens=y.cacheCreate1hTokens,g.usage.cacheCreate5mTokens=y.cacheCreate5mTokens,typeof f.reasoning_output_tokens=="number"&&(g.usage.reasoningOutputTokens=Number(f.reasoning_output_tokens)),g.usageByModel=W$(s.usageByModel)}}return e}const h=G$(e,s,o);h.provider||(h.provider=s.provider==="codex"?"codex":"claude");const p=GC(s);switch(p&&(h.model=p),a){case"SessionStart":{const f=Eo(e,l,o,!1);f.synthetic=!1,f.state="active",f.closedAt=void 0,f.startedAt=f.startedAt||o,!f.cwd&&s.cwd&&(f.cwd=s.cwd,f.cwdBasename=As(s.cwd)),f.label==="session"&&s.cwd&&(f.label=As(s.cwd)??"session");break}case"UserPromptSubmit":{for(const y of e.agents.values())y.sessionId===l&&y.kind==="subagent"&&y.state==="done"&&y.exitAt==null&&y.endedAt!=null&&y.endedAt<o&&(y.exitAt=o);const f=Eo(e,l,o,!1);f.state="active",f.endedAt=void 0,f.closedAt=void 0,f.exitAt=void 0;const g=(typeof s.prompt=="string"?s.prompt:typeof s.message=="string"?s.message:"")??"";g&&!J$(f,o,g)&&(f.prompts.push({at:o,text:g}),f.firstPrompt||(f.firstPrompt=Wc(g,120)));break}case"PreToolUse":{const f=s.tool_use_id?Z$(e,h,s.tool_use_id):null;if(f){s.tool_name&&f.name==="?"&&(f.name=s.tool_name),f.endedAt==null&&!f.trimmed&&s.tool_input!==void 0&&(f.input=s.tool_input,f.inputPreview=Wc(s.tool_input));break}const g=s.tool_use_id??`${h.id}:${h.toolCount}`,y=Ka(s),w={id:g,name:s.tool_name??"?",input:s.tool_input,inputPreview:Wc(s.tool_input),agentId:h.id,explicitSubagentId:y?pl(l,y):void 0,startedAt:o};h.tools.push(w),h.toolCount+=1,h.state="active",e.toolIndex.set(g,w),e.toolOwner.set(g,h.id),Q$(e,h);break}case"PostToolUse":case"PostToolUseFailure":{const f=s.tool_use_id;if(!f)break;let g=e.toolIndex.get(f),y=!1;if(!g)for(const S of e.agents.values()){const b=S.tools.find(_=>_.id===f);if(b){g=b,y=!0;break}}if(!g||g.outcomeApplied)break;g.outcomeApplied=!0,g.outcomeGap=void 0,g.endedAt=o,g.ok=a==="PostToolUse",g.trimmed||(g.response=s.tool_response),a==="PostToolUseFailure"?g.errorPreview=Wc(s.tool_response):y&&(g.errorPreview=void 0);const w=HC(s.tool_response);w&&(g.usage=w),e.toolIndex.delete(f),e.toolOwner.delete(f);break}case"SubagentStart":{const f=Ka(s);if(!f)break;const g=V$(e,l,f,s,o);g.state="active",g.startedAt=g.startedAt||o,g.exitAt=void 0,g.endedAt=void 0;const y=mu(s);y&&(g.label=y),Y$(e,l,f);break}case"SubagentStop":{const f=Ka(s);if(!f)break;const g=VC(e,l,f,s);if(!g)break;g.state="done",g.endedAt=o,K$(e,l,f);break}case"Stop":case"SessionEnd":{const f=Eo(e,l,o,!1);f.state="done",f.endedAt=o,a==="SessionEnd"&&(f.closedAt=o),e.activeSubagentStack.delete(l);break}case"Notification":{const f=oL(s.notification_type);if(!f)break;const g=Eo(e,l,o,!1),y=typeof s.message=="string"?s.message:"",w=g.waiting;g.waiting=w&&w.kind===f&&w.message===y?{...w,since:Math.min(w.since,o)}:cL(e,l,f,y,o);break}}return e}function hw(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return Math.abs(t)%360}const dL=Date.UTC(2026,8,1);function fL(e){return e<dL?{input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4}:{input:3,output:15,cacheRead:.3,cacheWrite:3.75,cacheWrite1h:6}}const hL=[{match:/^claude[-_](fable|mythos)[-_]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:10,output:50,cacheRead:1,cacheWrite:12.5,cacheWrite1h:20}},{match:/^claude[-_]opus[-_]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:5,output:25,cacheRead:.5,cacheWrite:6.25,cacheWrite1h:10}},{match:/^claude[-_]sonnet[-_]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:fL},{match:/^claude[-_]opus[-_]4[-_.](?:5|6|7|8)\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:5,output:25,cacheRead:.5,cacheWrite:6.25,cacheWrite1h:10}},{match:/^claude[-_]opus[-_]4(?:[-_.]1)?\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75,cacheWrite1h:30}},{match:/^claude[-_]sonnet[-_]4[-_.](?:5|6)\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:3,output:15,cacheRead:.3,cacheWrite:3.75,cacheWrite1h:6}},{match:/^claude[-_]sonnet[-_]4\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:3,output:15,cacheRead:.3,cacheWrite:3.75,cacheWrite1h:6}},{match:/^claude[-_]haiku[-_]4[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:1,output:5,cacheRead:.1,cacheWrite:1.25,cacheWrite1h:2}},{match:/^claude[-_]haiku[-_]3[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:.8,output:4,cacheRead:.08,cacheWrite:1,cacheWrite1h:1.6}},{match:/^gpt[-_]5[-_.]6[-_]cyber/i,rates:{input:12.5,output:75,cacheRead:1.25,cacheWrite:0}},{match:/^gpt[-_]5[-_.]6[-_]luna/i,rates:{input:.2,output:1.2,cacheRead:.02,cacheWrite:.25}},{match:/^gpt[-_]5[-_.]6[-_]terra/i,rates:{input:2,output:12,cacheRead:.2,cacheWrite:2.5}},{match:/^gpt[-_]5[-_.]6(?:[-_]sol)?\b/i,rates:{input:5,output:30,cacheRead:.5,cacheWrite:6.25}},{match:/^gpt[-_]5[-_.]5[-_]pro/i,rates:{input:30,output:180,cacheRead:30,cacheWrite:0}},{match:/^gpt[-_]5[-_.]5\b/i,rates:{input:5,output:30,cacheRead:.5,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]pro/i,rates:{input:30,output:180,cacheRead:3,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]mini/i,rates:{input:.75,output:4.5,cacheRead:.075,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]nano/i,rates:{input:.2,output:1.25,cacheRead:.02,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4\b/i,rates:{input:2.5,output:15,cacheRead:.25,cacheWrite:0}},{match:/^gpt[-_]5[-_.]3[-_]codex/i,rates:{input:1.75,output:14,cacheRead:.175,cacheWrite:0}},{match:/^gpt[-_]5[-_.]2[-_]pro/i,rates:{input:21,output:168,cacheRead:21,cacheWrite:0}},{match:/^gpt[-_]5[-_.]2\b/i,rates:{input:1.75,output:14,cacheRead:.175,cacheWrite:0}},{match:/^gpt[-_]5[-_.]1[-_]codex[-_]mini/i,rates:{input:.25,output:2,cacheRead:.025,cacheWrite:0}},{match:/^gpt[-_]5[-_.]1(?!\d)/i,rates:{input:1.25,output:10,cacheRead:.125,cacheWrite:0}},{match:/^gpt[-_]5[-_]pro\b/i,rates:{input:15,output:120,cacheRead:15,cacheWrite:0}},{match:/^gpt[-_]5[-_]mini/i,rates:{input:.25,output:2,cacheRead:.025,cacheWrite:0}},{match:/^gpt[-_]5[-_]nano/i,rates:{input:.05,output:.4,cacheRead:.005,cacheWrite:0}},{match:/^gpt[-_]5(?![-_.]\d)/i,rates:{input:1.25,output:10,cacheRead:.125,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[-_]mini/i,rates:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0}},{match:/^o1\b/i,rates:{input:15,output:60,cacheRead:7.5,cacheWrite:0}},{match:/^o3[-_]deep[-_]research/i,rates:{input:10,output:40,cacheRead:2.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[-_]deep[-_]research/i,rates:{input:2,output:8,cacheRead:.5,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 pL(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function Uo(e,t=Date.now()){if(!e)return null;const n=Ru(e);for(const s of hL)if(s.match.test(n))return typeof s.rates=="function"?s.rates(t):s.rates;return null}function KC(e,t){const n=Math.max(0,e.cacheCreate1hTokens??0),s=Math.max(0,e.cacheCreate5mTokens??0),o=Math.max(0,e.cacheCreateTokens-n-s),a=s+o,l=t.cacheWrite1h??t.cacheWrite;return{tokens5m:a,tokens1h:n,usd5m:a*t.cacheWrite/1e6,usd1h:n*l/1e6}}function XC(e,t,n=Date.now()){if(!pL(t))return e.inputTokens;const s=Uo(t,n),o=((s==null?void 0:s.cacheWrite)??0)>0?Math.max(0,e.cacheCreateTokens):0;return Math.max(0,e.inputTokens-e.cacheReadTokens-o)}function pw(e,t,n=Date.now()){const s=Uo(t,n);if(!s)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const o=XC(e,t,n)*s.input/1e6,a=e.outputTokens*s.output/1e6,l=e.cacheReadTokens*s.cacheRead/1e6,u=KC(e,s),h=u.usd5m+u.usd1h;return{input:o,output:a,cacheRead:l,cacheWrite:h,total:o+a+l+h}}const Vb=2e5,mL=1e6,gL=[/\[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],vL=[{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 yL(e){if(!e)return Vb;const t=Ru(e);for(const n of gL)if(n.test(t))return mL;for(const n of vL)if(n.match.test(t))return n.window;return Vb}function QC(e,t){return typeof e=="number"&&e>0?e:yL(t)}const su="not priced";function Ve(e){if(e<=0)return"—";if(e<.005)return"<1¢";if(e<1){const t=(e*100).toFixed(e<.1?1:0);if(Number(t)<100)return`${t}¢`}return e<100?`$${e.toFixed(2)}`:e<1e4?`$${e.toFixed(0)}`:`$${(e/1e3).toFixed(1)}k`}function gu(e,t){if(e<=0||t<10)return null;const n=e/t,s=n*60;return s>=.01?`${Ve(s)}/min`:`${Ve(n*3600)}/hr`}function wL(e,t){const n={inputTokens:e.inputTokens+t.inputTokens,outputTokens:e.outputTokens+t.outputTokens,cacheReadTokens:e.cacheReadTokens+t.cacheReadTokens,cacheCreateTokens:e.cacheCreateTokens+t.cacheCreateTokens};return(e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0||t.cacheCreate1hTokens!==void 0||t.cacheCreate5mTokens!==void 0)&&(n.cacheCreate1hTokens=(e.cacheCreate1hTokens??0)+(t.cacheCreate1hTokens??0),n.cacheCreate5mTokens=(e.cacheCreate5mTokens??0)+(t.cacheCreate5mTokens??0)),(e.reasoningOutputTokens!==void 0||t.reasoningOutputTokens!==void 0)&&(n.reasoningOutputTokens=(e.reasoningOutputTokens??0)+(t.reasoningOutputTokens??0)),n}function xL(e,t){let n=0,s=0,o=0,a=0,l=0,u=0;for(const g of t)n+=g.inputTokens,s+=g.outputTokens,o+=g.cacheReadTokens,a+=g.cacheCreateTokens,l+=g.cacheCreate1hTokens??0,u+=g.cacheCreate5mTokens??0;const h=(g,y)=>Math.max(0,g-y),p={inputTokens:h(e.inputTokens,n),outputTokens:h(e.outputTokens,s),cacheReadTokens:h(e.cacheReadTokens,o),cacheCreateTokens:h(e.cacheCreateTokens,a)};return(e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0)&&(p.cacheCreate1hTokens=h(e.cacheCreate1hTokens??0,l),p.cacheCreate5mTokens=h(e.cacheCreate5mTokens??0,u)),p.inputTokens+p.outputTokens+p.cacheReadTokens+p.cacheCreateTokens>0?p:null}function gl(e){const t=e.usageByModel,n=t?Object.keys(t):[];if(!t||n.length===0)return[{model:e.model,usage:e.usage}];const s=n.map(a=>({model:a,usage:t[a]})),o=xL(e.usage,s.map(a=>a.usage));if(o){const a=s.findIndex(l=>l.model===e.model);a>=0?s[a]={model:s[a].model,usage:wL(s[a].usage,o)}:s.push({model:e.model,usage:o})}return s}function bn(e,t=Date.now()){const n={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const s of gl(e)){const o=pw(s.usage,s.model,t);n.input+=o.input,n.output+=o.output,n.cacheRead+=o.cacheRead,n.cacheWrite+=o.cacheWrite,n.total+=o.total}return n}function My(e,t=Date.now()){let n=0;for(const s of gl(e))Uo(s.model,t)==null&&(n+=s.usage.inputTokens+s.usage.outputTokens);return n}function ZC(e){const t=[];for(const n of gl(e)){if(!n.model||t.includes(n.model))continue;const s=n.usage;s.inputTokens+s.outputTokens+s.cacheReadTokens+s.cacheCreateTokens<=0||t.push(n.model)}return t}function JC(e){return ZC(e).filter(t=>t!==e.model)}const bL=new Set(["untrusted","on-request","on-failure"]);function _L(e){return typeof e!="string"||!e?null:bL.has(e)?!0:e==="never"?!1:null}function kL(e){if(e.provider!=="codex"||e.kind!=="root"||e.waiting||e.state!=="active")return null;const t=_L(e.approvalPolicy);return t===!1?null:{label:"approvals not visible",detail:`${t===!0?`This session's approval policy is "${e.approvalPolicy}", so Codex can stop and ask you to approve a command.`:"This session's approval policy has not been read yet, so it may be able to stop and ask you to approve a command."}
57
+ M${I.x},${I.y}h${I.width}v${I.height}h${-I.width}z`,fill:h,fillRule:"evenodd",stroke:p,strokeWidth:f,pointerEvents:"none"})))}zC.displayName="MiniMap";var j$=E.memo(zC);function C$(){return ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},ue.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function T$(){return ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},ue.createElement("path",{d:"M0 0h32v4.2H0z"}))}function R$(){return ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},ue.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 A$(){return ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ue.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 M$(){return ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ue.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 kr=({children:e,className:t,...n})=>ue.createElement("button",{type:"button",className:Ht(["react-flow__controls-button",t]),...n},e);kr.displayName="ControlButton";const I$=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),BC=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:s=!0,fitViewOptions:o,onZoomIn:a,onZoomOut:l,onFitView:u,onInteractiveChange:h,className:p,children:f,position:g="bottom-left"})=>{const y=Tt(),[w,S]=E.useState(!1),{isInteractive:b,minZoomReached:_,maxZoomReached:k}=rt(I$,$t),{zoomIn:N,zoomOut:j,fitView:T}=hl();if(E.useEffect(()=>{S(!0)},[]),!w)return null;const M=()=>{N(),a==null||a()},P=()=>{j(),l==null||l()},I=()=>{T(o),u==null||u()},F=()=>{y.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),h==null||h(!b)};return ue.createElement(tw,{className:Ht(["react-flow__controls",p]),position:g,style:e,"data-testid":"rf__controls"},t&&ue.createElement(ue.Fragment,null,ue.createElement(kr,{onClick:M,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:k},ue.createElement(C$,null)),ue.createElement(kr,{onClick:P,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:_},ue.createElement(T$,null))),n&&ue.createElement(kr,{className:"react-flow__controls-fitview",onClick:I,title:"fit view","aria-label":"fit view"},ue.createElement(R$,null)),s&&ue.createElement(kr,{className:"react-flow__controls-interactive",onClick:F,title:"toggle interactivity","aria-label":"toggle interactivity"},b?ue.createElement(M$,null):ue.createElement(A$,null)),f)};BC.displayName="Controls";var O$=E.memo(BC),ar;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ar||(ar={}));function P$({color:e,dimensions:t,lineWidth:n}){return ue.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function $$({color:e,radius:t}){return ue.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const L$={[ar.Dots]:"#91919a",[ar.Lines]:"#eee",[ar.Cross]:"#e2e2e2"},q$={[ar.Dots]:1,[ar.Lines]:1,[ar.Cross]:6},D$=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function UC({id:e,variant:t=ar.Dots,gap:n=20,size:s,lineWidth:o=1,offset:a=2,color:l,style:u,className:h}){const p=E.useRef(null),{transform:f,patternId:g}=rt(D$,$t),y=l||L$[t],w=s||q$[t],S=t===ar.Dots,b=t===ar.Cross,_=Array.isArray(n)?n:[n,n],k=[_[0]*f[2]||1,_[1]*f[2]||1],N=w*f[2],j=b?[N,N]:k,T=S?[N/a,N/a]:[j[0]/a,j[1]/a];return ue.createElement("svg",{className:Ht(["react-flow__background",h]),style:{...u,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:p,"data-testid":"rf__background"},ue.createElement("pattern",{id:g+e,x:f[0]%k[0],y:f[1]%k[1],width:k[0],height:k[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`},S?ue.createElement($$,{color:y,radius:N/a}):ue.createElement(P$,{dimensions:j,color:y,lineWidth:o})),ue.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${g+e})`}))}UC.displayName="Background";var F$=E.memo(UC);const z$=["us-gov","global","apac","us","eu","jp","au"],B$=new RegExp(`^(?:(?:${z$.join("|")})\\.)?anthropic\\.`,"i");function Ru(e){return e.replace(B$,"")}function WC(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function fw(e){const t=e.cache_creation,n=t&&typeof t=="object"?t:e,s=n.ephemeral_1h_input_tokens,o=n.ephemeral_5m_input_tokens;return typeof s!="number"&&typeof o!="number"?{}:{cacheCreate1hTokens:Number(s??0),cacheCreate5mTokens:Number(o??0)}}function U$(e){const t=fw(e),n={inputTokens:Number(e.input_tokens??0),outputTokens:Number(e.output_tokens??0),cacheReadTokens:Number(e.cache_read_input_tokens??e.cached_input_tokens??0),cacheCreateTokens:Number(e.cache_creation_input_tokens??e.cache_write_input_tokens??0),cacheCreate1hTokens:t.cacheCreate1hTokens,cacheCreate5mTokens:t.cacheCreate5mTokens};return typeof e.reasoning_output_tokens=="number"&&(n.reasoningOutputTokens=Number(e.reasoning_output_tokens)),n}function W$(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t={};for(const[n,s]of Object.entries(e))!n||!s||typeof s!="object"||(t[n]=U$(s));return Object.keys(t).length?t:void 0}function HC(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.input_tokens=="number"||typeof n.output_tokens=="number"||typeof n.cache_read_input_tokens=="number"||typeof n.cache_creation_input_tokens=="number")return{inputTokens:Number(n.input_tokens??0),outputTokens:Number(n.output_tokens??0),cacheReadTokens:Number(n.cache_read_input_tokens??0),cacheCreateTokens:Number(n.cache_creation_input_tokens??0),...fw(n)};for(const s of Object.values(n)){const o=HC(s,t+1);if(o)return o}return null}const H$=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i;function GC(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.model=="string"&&H$.test(Ru(n.model)))return n.model;for(const s of Object.values(n)){const o=GC(s,t+1);if(o)return o}return null}function Ay(){return{agents:new Map,toolIndex:new Map,toolOwner:new Map,activeSubagentStack:new Map,lastSeq:0,seqEpoch:null,totalEvents:0,revision:0}}function As(e){if(!e)return;const t=e.replace(/\\/g,"/").split("/").filter(Boolean);return t[t.length-1]}function Bb(){return{msgsUser:0,msgsAssistant:0,toolUses:0,toolResults:0,systemReminders:0,currentContextTokens:0,memoryFiles:[]}}function pl(e,t){return`${e}::${t}`}function mu(e){return e.agent_type??e.subagent_type??"subagent"}function Ka(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function Eo(e,t,n,s){const o=t;let a=e.agents.get(o);return a||(a={id:o,sessionId:t,label:"session",kind:"root",state:"active",startedAt:n,lastEventAt:n,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:s,usage:WC()},e.agents.set(o,a),a)}function VC(e,t,n,s){const o=pl(t,n),a=e.agents.get(o);if(!a)return null;!a.cwd&&s.cwd&&(a.cwd=s.cwd,a.cwdBasename=As(s.cwd));const l=mu(s);return l&&(a.label==="subagent"||!a.label)&&(a.label=l),a}function G$(e,t,n){const s=t.session_id??"unknown",o=Ka(t);if(o){const h=VC(e,s,o,t);if(h)return h}const a=e.activeSubagentStack.get(s),l=a&&a.length>0?a[a.length-1]:null;if(l){const h=e.agents.get(pl(s,l));if(h)return!h.cwd&&t.cwd&&(h.cwd=t.cwd,h.cwdBasename=As(t.cwd)),h}const u=Eo(e,s,n,t.hook_event_name!=="SessionStart");return!u.cwd&&t.cwd&&(u.cwd=t.cwd,u.cwdBasename=As(t.cwd)),u.label==="session"&&t.cwd&&(u.label=As(t.cwd)??"session"),u}function V$(e,t,n,s,o){const a=pl(t,n),l=Eo(e,t,o,!0);let u=e.agents.get(a);if(u){!u.cwd&&s.cwd&&(u.cwd=s.cwd,u.cwdBasename=As(s.cwd));const h=mu(s);return h&&(u.label==="subagent"||!u.label)&&(u.label=h),u}return u={id:a,sessionId:t,label:mu(s),kind:"subagent",parentId:l.id,state:"active",startedAt:o,tools:[],prompts:[],cwd:s.cwd,cwdBasename:As(s.cwd),toolCount:0,childCount:0,usage:WC()},e.agents.set(a,u),l.childCount+=1,u}function Y$(e,t,n){const s=e.activeSubagentStack.get(t)??[];s.includes(n)||(s.push(n),e.activeSubagentStack.set(t,s))}function K$(e,t,n){const s=e.activeSubagentStack.get(t);if(s){for(let o=s.length-1;o>=0;o--)if(s[o]===n){s.splice(o,1);break}s.length===0&&e.activeSubagentStack.delete(t)}}function Wc(e,t=80){if(e==null)return"";if(typeof e=="string")return e.length>t?e.slice(0,t-1)+"…":e;try{const n=JSON.stringify(e);return n.length>t?n.slice(0,t-1)+"…":n}catch{return String(e)}}const Ub=200,X$=25;function Q$(e,t){const n=t.tools;if(n.length>Ub){const s=n.splice(0,n.length-Ub);for(const o of s)e.toolIndex.get(o.id)===o&&(e.toolIndex.delete(o.id),e.toolOwner.delete(o.id))}for(let s=n.length-X$-1;s>=0;s--){const o=n[s];if(o.trimmed)break;o.input=void 0,o.response=void 0,o.trimmed=!0}}function Z$(e,t,n){const s=e.toolIndex.get(n);if(s)return s;for(let o=t.tools.length-1;o>=0;o--)if(t.tools[o].id===n)return t.tools[o];return null}const Wb=2e3;function J$(e,t,n){for(let s=e.prompts.length-1;s>=0;s--){const o=e.prompts[s];if(o.at<t-Wb)return!1;if(o.text===n&&o.at<=t+Wb)return!0}return!1}function YC(e,t){for(const n of t.tools)e.toolIndex.get(n.id)===n&&e.toolIndex.delete(n.id),e.toolOwner.get(n.id)===t.id&&e.toolOwner.delete(n.id)}function ml(e,t){return t&&(e.revision+=1),t}function eL(e,t,n,s){if(e.agents.size<=n)return!1;const o=p=>p.state==="done"&&p.endedAt!=null&&t-p.endedAt>s,a=[],l=new Map;for(const[p,f]of e.agents){if(f.parentId!=null){const g=l.get(f.parentId);g?g.push(p):l.set(f.parentId,[p])}o(f)&&a.push({id:p,endedAt:f.endedAt})}if(a.length===0)return!1;a.sort((p,f)=>p.endedAt-f.endedAt);let u=0;const h=p=>{const f=e.agents.get(p);f&&(YC(e,f),e.agents.delete(p),u++)};for(const p of a){if(e.agents.size<=n)break;if(!e.agents.has(p.id))continue;const f=(l.get(p.id)??[]).map(g=>e.agents.get(g)).filter(g=>g!=null);if(!f.some(g=>!o(g))){for(const g of f)h(g.id);h(p.id)}}return ml(e,u>0)}function tL(e,t,n,s){const o=new Map;for(const[p,f]of e.agents){let g=o.get(f.sessionId);g||(g={ids:[],endedAt:0,live:!1,closed:!1},o.set(f.sessionId,g)),g.ids.push(p),f.kind==="root"&&f.closedAt!=null&&(g.closed=!0),f.state==="done"&&f.endedAt!=null?g.endedAt=Math.max(g.endedAt,f.endedAt):g.live=!0}const a=[...o.values()].filter(p=>!p.live&&p.endedAt>0&&t-p.endedAt>s).sort((p,f)=>p.closed===f.closed?p.endedAt-f.endedAt:p.closed?-1:1);let u=[...o.values()].filter(p=>!p.live).length-n;if(u<=0)return!1;let h=!1;for(const p of a){if(u<=0)break;for(const f of p.ids){const g=e.agents.get(f);g&&YC(e,g),e.agents.delete(f)}u--,h=!0}return ml(e,h)}function nL(e,t){const n=t==null?void 0:t.payload,s=n==null?void 0:n.hook_event_name;if(s!=="PostToolUse"&&s!=="PostToolUseFailure")return!1;const o=n==null?void 0:n.tool_use_id;return typeof o=="string"&&o.length>0&&e.toolIndex.has(o)}function rL(e){let t=!1;for(const n of e.agents.values())for(const s of n.tools)s.endedAt!=null||s.outcomeGap||(s.outcomeGap=!0,t=!0);return ml(e,t)}function sL(e,t,n){let s=!1;for(const o of e.agents.values()){if(o.provider==="codex")continue;const a=e.agents.get(o.sessionId),l=(a==null?void 0:a.lastEventAt)??(a==null?void 0:a.startedAt);for(const u of o.tools){const h=Math.max(u.startedAt,l??u.startedAt);u.endedAt==null&&t-h>n&&(u.endedAt=h,u.ok=!1,u.errorPreview=u.outcomeGap?"no result reached the deck — events were dropped while the deck was paused":"session ended before this call returned",e.toolIndex.delete(u.id),e.toolOwner.delete(u.id),s=!0)}}return ml(e,s)}const Hb=90*6e4;function iL(e,t,n){let s=!1;for(const o of e.agents.values()){if(o.kind!=="root")continue;const a=o.lastEventAt??o.startedAt;if(!(t-a<=n)){o.waiting&&(o.waiting=null,s=!0),o.closedAt==null&&(o.closedAt=a),o.state==="active"&&(o.state="done",o.endedAt=a,o.reaped=!0,s=!0);for(const l of e.agents.values())l.sessionId!==o.sessionId||l.kind==="root"||l.state!=="active"||(l.state="done",l.endedAt=a,s=!0);e.activeSubagentStack.delete(o.sessionId)}}return ml(e,s)}function oL(e){return e==="permission_prompt"?"permission":e==="idle_prompt"?"idle":null}const aL=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved","SessionNamed"]);function lL(e,t){let n=null;for(const s of e.toolIndex.values()){const o=s.agentId?e.agents.get(s.agentId):void 0;!o||o.sessionId!==t||(!n||s.startedAt>n.startedAt)&&(n=s)}return n==null?void 0:n.explicitSubagentId}function cL(e,t,n,s,o){const a=n==="permission"?lL(e,t):void 0;return a?{kind:n,message:s,since:o,subagentId:a}:{kind:n,message:s,since:o}}function uL(e,t,n){if(e.kind!=="permission")return!0;const s=Ka(t);return s==null?!0:e.subagentId!=null&&pl(n,s)===e.subagentId}function Gb(e,t){const n=t.epoch??null;if(n!==null&&n!==e.seqEpoch)e.seqEpoch=n,e.lastSeq=0;else if(t.seq<=e.lastSeq)return e;const s=t.payload??{},o=t.receivedAt,a=s.hook_event_name??"Unknown";if(a==="__clear")return{...Ay(),lastSeq:t.seq,seqEpoch:e.seqEpoch,revision:e.revision+1};e.totalEvents+=1,e.lastSeq=t.seq,e.revision+=1;const l=s.session_id??"unknown";if(!aL.has(a)){const f=e.agents.get(l);f!=null&&f.waiting&&uL(f.waiting,s,l)&&(f.waiting=null)}const u=e.agents.get(l);if(u&&o>(u.lastEventAt??0)&&(u.lastEventAt=o,u.reaped&&(u.reaped=!1,u.state="active",u.endedAt=void 0,u.closedAt=void 0)),typeof s.model_context_window=="number"&&s.model_context_window>0){const f=e.agents.get(l);f&&(f.contextWindow=s.model_context_window)}if(typeof s.approval_policy=="string"&&s.approval_policy){const f=e.agents.get(l);f&&(f.approvalPolicy=s.approval_policy)}if(typeof s.context_tokens=="number"&&s.context_tokens>=0){const f=e.agents.get(l);f&&(f.context={...f.context??Bb(),currentContextTokens:s.context_tokens})}if(a==="ModelObserved"){const f=typeof s.model=="string"?s.model:null;if(f){const y=e.agents.get(l);y&&(y.model=f)}const g=s.subagentModels;if(g&&typeof g=="object")for(const[y,w]of Object.entries(g)){if(typeof w!="string")continue;const S=`${l}::${y}`,b=e.agents.get(S);b&&(b.model=w)}return e}if(a==="ContextObserved"){const f=s.context??null;if(f){const g=e.agents.get(l);if(g){const y=g.context??Bb(),w=(b,_)=>typeof f[b]=="number"?f[b]:_,S=Array.isArray(f.memoryFiles)?f.memoryFiles:Array.isArray(f.claudeMdFiles)?f.claudeMdFiles:null;g.context={msgsUser:w("msgsUser",y.msgsUser),msgsAssistant:w("msgsAssistant",y.msgsAssistant),toolUses:w("toolUses",y.toolUses),toolResults:w("toolResults",y.toolResults),systemReminders:w("systemReminders",y.systemReminders),currentContextTokens:w("currentContextTokens",y.currentContextTokens),memoryFiles:S??y.memoryFiles}}}return e}if(a==="SessionNamed"){const f=e.agents.get(l);if(f){const g=typeof s.sessionName=="string"?s.sessionName.trim():"",y=typeof s.sessionTitle=="string"?s.sessionTitle.trim():"";g&&(f.sessionName=g),y&&(f.sessionTitle=y);const w=f.sessionName??"";f.sessionTitle&&w&&f.sessionTitle.toLowerCase()===w.toLowerCase()&&(f.sessionTitle=void 0)}return e}if(a==="UsageObserved"){const f=s.usage??null;if(f){const g=e.agents.get(l);if(g){g.usage.inputTokens=Number(f.input_tokens??0),g.usage.outputTokens=Number(f.output_tokens??0),g.usage.cacheReadTokens=Number(f.cache_read_input_tokens??f.cached_input_tokens??0),g.usage.cacheCreateTokens=Number(f.cache_creation_input_tokens??f.cache_write_input_tokens??0);const y=fw(f);g.usage.cacheCreate1hTokens=y.cacheCreate1hTokens,g.usage.cacheCreate5mTokens=y.cacheCreate5mTokens,typeof f.reasoning_output_tokens=="number"&&(g.usage.reasoningOutputTokens=Number(f.reasoning_output_tokens)),g.usageByModel=W$(s.usageByModel)}}return e}const h=G$(e,s,o);h.provider||(h.provider=s.provider==="codex"?"codex":"claude");const p=GC(s);switch(p&&(h.model=p),a){case"SessionStart":{const f=Eo(e,l,o,!1);f.synthetic=!1,f.state="active",f.closedAt=void 0,f.startedAt=f.startedAt||o,!f.cwd&&s.cwd&&(f.cwd=s.cwd,f.cwdBasename=As(s.cwd)),f.label==="session"&&s.cwd&&(f.label=As(s.cwd)??"session");break}case"UserPromptSubmit":{for(const y of e.agents.values())y.sessionId===l&&y.kind==="subagent"&&y.state==="done"&&y.exitAt==null&&y.endedAt!=null&&y.endedAt<o&&(y.exitAt=o);const f=Eo(e,l,o,!1);f.state="active",f.endedAt=void 0,f.closedAt=void 0,f.exitAt=void 0;const g=(typeof s.prompt=="string"?s.prompt:typeof s.message=="string"?s.message:"")??"";g&&!J$(f,o,g)&&(f.prompts.push({at:o,text:g}),f.firstPrompt||(f.firstPrompt=Wc(g,120)));break}case"PreToolUse":{const f=s.tool_use_id?Z$(e,h,s.tool_use_id):null;if(f){s.tool_name&&f.name==="?"&&(f.name=s.tool_name),f.endedAt==null&&!f.trimmed&&s.tool_input!==void 0&&(f.input=s.tool_input,f.inputPreview=Wc(s.tool_input));break}const g=s.tool_use_id??`${h.id}:${h.toolCount}`,y=Ka(s),w={id:g,name:s.tool_name??"?",input:s.tool_input,inputPreview:Wc(s.tool_input),agentId:h.id,explicitSubagentId:y?pl(l,y):void 0,startedAt:o};h.tools.push(w),h.toolCount+=1,h.state="active",e.toolIndex.set(g,w),e.toolOwner.set(g,h.id),Q$(e,h);break}case"PostToolUse":case"PostToolUseFailure":{const f=s.tool_use_id;if(!f)break;let g=e.toolIndex.get(f),y=!1;if(!g)for(const S of e.agents.values()){const b=S.tools.find(_=>_.id===f);if(b){g=b,y=!0;break}}if(!g||g.outcomeApplied)break;g.outcomeApplied=!0,g.outcomeGap=void 0,g.endedAt=o,g.ok=a==="PostToolUse",g.trimmed||(g.response=s.tool_response),a==="PostToolUseFailure"?g.errorPreview=Wc(s.tool_response):y&&(g.errorPreview=void 0);const w=HC(s.tool_response);w&&(g.usage=w),e.toolIndex.delete(f),e.toolOwner.delete(f);break}case"SubagentStart":{const f=Ka(s);if(!f)break;const g=V$(e,l,f,s,o);g.state="active",g.startedAt=g.startedAt||o,g.exitAt=void 0,g.endedAt=void 0;const y=mu(s);y&&(g.label=y),Y$(e,l,f);break}case"SubagentStop":{const f=Ka(s);if(!f)break;const g=VC(e,l,f,s);if(!g)break;g.state="done",g.endedAt=o,K$(e,l,f);break}case"Stop":case"SessionEnd":{const f=Eo(e,l,o,!1);f.state="done",f.endedAt=o,a==="SessionEnd"&&(f.closedAt=o),e.activeSubagentStack.delete(l);break}case"Notification":{const f=oL(s.notification_type);if(!f)break;const g=Eo(e,l,o,!1),y=typeof s.message=="string"?s.message:"",w=g.waiting;g.waiting=w&&w.kind===f&&w.message===y?{...w,since:Math.min(w.since,o)}:cL(e,l,f,y,o);break}}return e}function hw(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return Math.abs(t)%360}const dL={input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4},fL=[{match:/^claude[-_](fable|mythos)[-_]5[-_.]1\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:10,output:50,cacheRead:.25,cacheWrite:12.5,cacheWrite1h:20}},{match:/^claude[-_](fable|mythos)[-_]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:10,output:50,cacheRead:1,cacheWrite:12.5,cacheWrite1h:20}},{match:/^claude[-_]opus[-_]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:5,output:25,cacheRead:.5,cacheWrite:6.25,cacheWrite1h:10}},{match:/^claude[-_]sonnet[-_]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:dL},{match:/^claude[-_]opus[-_]4[-_.](?:5|6|7|8)\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:5,output:25,cacheRead:.5,cacheWrite:6.25,cacheWrite1h:10}},{match:/^claude[-_]opus[-_]4(?:[-_.]1)?\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75,cacheWrite1h:30}},{match:/^claude[-_]sonnet[-_]4[-_.](?:5|6)\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:3,output:15,cacheRead:.3,cacheWrite:3.75,cacheWrite1h:6}},{match:/^claude[-_]sonnet[-_]4\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:3,output:15,cacheRead:.3,cacheWrite:3.75,cacheWrite1h:6}},{match:/^claude[-_]haiku[-_]4[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:1,output:5,cacheRead:.1,cacheWrite:1.25,cacheWrite1h:2}},{match:/^claude[-_]haiku[-_]3[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:.8,output:4,cacheRead:.08,cacheWrite:1,cacheWrite1h:1.6}},{match:/^gpt[-_]5[-_.]6[-_]cyber/i,rates:{input:12.5,output:75,cacheRead:1.25,cacheWrite:0}},{match:/^gpt[-_]5[-_.]6[-_]luna/i,rates:{input:.2,output:1.2,cacheRead:.02,cacheWrite:.25}},{match:/^gpt[-_]5[-_.]6[-_]terra/i,rates:{input:2,output:12,cacheRead:.2,cacheWrite:2.5}},{match:/^gpt[-_]5[-_.]6(?:[-_]sol)?\b/i,rates:{input:5,output:30,cacheRead:.5,cacheWrite:6.25}},{match:/^gpt[-_]5[-_.]5[-_]pro/i,rates:{input:30,output:180,cacheRead:30,cacheWrite:0}},{match:/^gpt[-_]5[-_.]5\b/i,rates:{input:5,output:30,cacheRead:.5,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]pro/i,rates:{input:30,output:180,cacheRead:3,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]mini/i,rates:{input:.75,output:4.5,cacheRead:.075,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]nano/i,rates:{input:.2,output:1.25,cacheRead:.02,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4\b/i,rates:{input:2.5,output:15,cacheRead:.25,cacheWrite:0}},{match:/^gpt[-_]5[-_.]3[-_]codex/i,rates:{input:1.75,output:14,cacheRead:.175,cacheWrite:0}},{match:/^gpt[-_]5[-_.]2[-_]pro/i,rates:{input:21,output:168,cacheRead:21,cacheWrite:0}},{match:/^gpt[-_]5[-_.]2\b/i,rates:{input:1.75,output:14,cacheRead:.175,cacheWrite:0}},{match:/^gpt[-_]5[-_.]1[-_]codex[-_]mini/i,rates:{input:.25,output:2,cacheRead:.025,cacheWrite:0}},{match:/^gpt[-_]5[-_.]1(?!\d)/i,rates:{input:1.25,output:10,cacheRead:.125,cacheWrite:0}},{match:/^gpt[-_]5[-_]pro\b/i,rates:{input:15,output:120,cacheRead:15,cacheWrite:0}},{match:/^gpt[-_]5[-_]mini/i,rates:{input:.25,output:2,cacheRead:.025,cacheWrite:0}},{match:/^gpt[-_]5[-_]nano/i,rates:{input:.05,output:.4,cacheRead:.005,cacheWrite:0}},{match:/^gpt[-_]5(?![-_.]\d)/i,rates:{input:1.25,output:10,cacheRead:.125,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[-_]mini/i,rates:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0}},{match:/^o1\b/i,rates:{input:15,output:60,cacheRead:7.5,cacheWrite:0}},{match:/^o3[-_]deep[-_]research/i,rates:{input:10,output:40,cacheRead:2.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[-_]deep[-_]research/i,rates:{input:2,output:8,cacheRead:.5,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 hL(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function Uo(e,t=Date.now()){if(!e)return null;const n=Ru(e);for(const s of fL)if(s.match.test(n))return typeof s.rates=="function"?s.rates(t):s.rates;return null}function KC(e,t){const n=Math.max(0,e.cacheCreate1hTokens??0),s=Math.max(0,e.cacheCreate5mTokens??0),o=Math.max(0,e.cacheCreateTokens-n-s),a=s+o,l=t.cacheWrite1h??t.cacheWrite;return{tokens5m:a,tokens1h:n,usd5m:a*t.cacheWrite/1e6,usd1h:n*l/1e6}}function XC(e,t,n=Date.now()){if(!hL(t))return e.inputTokens;const s=Uo(t,n),o=((s==null?void 0:s.cacheWrite)??0)>0?Math.max(0,e.cacheCreateTokens):0;return Math.max(0,e.inputTokens-e.cacheReadTokens-o)}function pw(e,t,n=Date.now()){const s=Uo(t,n);if(!s)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const o=XC(e,t,n)*s.input/1e6,a=e.outputTokens*s.output/1e6,l=e.cacheReadTokens*s.cacheRead/1e6,u=KC(e,s),h=u.usd5m+u.usd1h;return{input:o,output:a,cacheRead:l,cacheWrite:h,total:o+a+l+h}}const Vb=2e5,pL=1e6,mL=[/\[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],gL=[{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 vL(e){if(!e)return Vb;const t=Ru(e);for(const n of mL)if(n.test(t))return pL;for(const n of gL)if(n.match.test(t))return n.window;return Vb}function QC(e,t){return typeof e=="number"&&e>0?e:vL(t)}const su="not priced";function Ve(e){if(e<=0)return"—";if(e<.005)return"<1¢";if(e<1){const t=(e*100).toFixed(e<.1?1:0);if(Number(t)<100)return`${t}¢`}return e<100?`$${e.toFixed(2)}`:e<1e4?`$${e.toFixed(0)}`:`$${(e/1e3).toFixed(1)}k`}function gu(e,t){if(e<=0||t<10)return null;const n=e/t,s=n*60;return s>=.01?`${Ve(s)}/min`:`${Ve(n*3600)}/hr`}function yL(e,t){const n={inputTokens:e.inputTokens+t.inputTokens,outputTokens:e.outputTokens+t.outputTokens,cacheReadTokens:e.cacheReadTokens+t.cacheReadTokens,cacheCreateTokens:e.cacheCreateTokens+t.cacheCreateTokens};return(e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0||t.cacheCreate1hTokens!==void 0||t.cacheCreate5mTokens!==void 0)&&(n.cacheCreate1hTokens=(e.cacheCreate1hTokens??0)+(t.cacheCreate1hTokens??0),n.cacheCreate5mTokens=(e.cacheCreate5mTokens??0)+(t.cacheCreate5mTokens??0)),(e.reasoningOutputTokens!==void 0||t.reasoningOutputTokens!==void 0)&&(n.reasoningOutputTokens=(e.reasoningOutputTokens??0)+(t.reasoningOutputTokens??0)),n}function wL(e,t){let n=0,s=0,o=0,a=0,l=0,u=0;for(const g of t)n+=g.inputTokens,s+=g.outputTokens,o+=g.cacheReadTokens,a+=g.cacheCreateTokens,l+=g.cacheCreate1hTokens??0,u+=g.cacheCreate5mTokens??0;const h=(g,y)=>Math.max(0,g-y),p={inputTokens:h(e.inputTokens,n),outputTokens:h(e.outputTokens,s),cacheReadTokens:h(e.cacheReadTokens,o),cacheCreateTokens:h(e.cacheCreateTokens,a)};return(e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0)&&(p.cacheCreate1hTokens=h(e.cacheCreate1hTokens??0,l),p.cacheCreate5mTokens=h(e.cacheCreate5mTokens??0,u)),p.inputTokens+p.outputTokens+p.cacheReadTokens+p.cacheCreateTokens>0?p:null}function gl(e){const t=e.usageByModel,n=t?Object.keys(t):[];if(!t||n.length===0)return[{model:e.model,usage:e.usage}];const s=n.map(a=>({model:a,usage:t[a]})),o=wL(e.usage,s.map(a=>a.usage));if(o){const a=s.findIndex(l=>l.model===e.model);a>=0?s[a]={model:s[a].model,usage:yL(s[a].usage,o)}:s.push({model:e.model,usage:o})}return s}function bn(e,t=Date.now()){const n={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const s of gl(e)){const o=pw(s.usage,s.model,t);n.input+=o.input,n.output+=o.output,n.cacheRead+=o.cacheRead,n.cacheWrite+=o.cacheWrite,n.total+=o.total}return n}function My(e,t=Date.now()){let n=0;for(const s of gl(e))Uo(s.model,t)==null&&(n+=s.usage.inputTokens+s.usage.outputTokens);return n}function ZC(e){const t=[];for(const n of gl(e)){if(!n.model||t.includes(n.model))continue;const s=n.usage;s.inputTokens+s.outputTokens+s.cacheReadTokens+s.cacheCreateTokens<=0||t.push(n.model)}return t}function JC(e){return ZC(e).filter(t=>t!==e.model)}const xL=new Set(["untrusted","on-request","on-failure"]);function bL(e){return typeof e!="string"||!e?null:xL.has(e)?!0:e==="never"?!1:null}function _L(e){if(e.provider!=="codex"||e.kind!=="root"||e.waiting||e.state!=="active")return null;const t=bL(e.approvalPolicy);return t===!1?null:{label:"approvals not visible",detail:`${t===!0?`This session's approval policy is "${e.approvalPolicy}", so Codex can stop and ask you to approve a command.`:"This session's approval policy has not been read yet, so it may be able to stop and ask you to approve a command."}
58
58
 
59
- Codex writes no approval request to its rollout files, which are the only thing this deck can read — so when it does ask, this card, the sidebar, the topbar count, the tab title and the favicon will all stay silent. Check the terminal.`}}function Yb(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function xi(e){const t=Ru(e).replace(/[-_]\d{8}(?!\d)/,""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const o=Yb(n[1]),a=n[2].replace(/[-_]/g,".");return`${o} ${a}`}const s=t.match(/^gpt[-_](\d+(?:[-_.]\d+)*)((?:[-_][A-Za-z0-9.]+)*)$/i);if(s){const o=s[1].replace(/[-_]/g,"."),a=s[2].split(/[-_]/).filter(Boolean).map(Yb);return[`GPT-${o}`,...a].join(" ")}return e}function Pt(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 vu(e,t,n){const s=(t??n)-e;if(s<1e3)return`${Math.max(0,s)}ms`;const o=Math.floor(s/1e3);if(o<60)return`${o}s`;const a=Math.floor(o/60),l=o%60;return`${a}m ${String(l).padStart(2,"0")}s`}function eT(e,t){if(e.endedAt==null)return t;const n=e.endedAt-e.startedAt;return n<1e3?`${n}ms`:`${(n/1e3).toFixed(2)}s`}function tT(e,t){const n=typeof e=="string"?e.trim():"",s=typeof t=="string"?t.trim():"";return{face:n||s||void 0,tooltip:s||n||void 0}}const SL=1,nT=-1;function NL(){const e=[];let t=0;function n(){let s;for(const o of e)(!s||o.layer>s.layer||o.layer===s.layer&&o.seq>s.seq)&&(s=o);return s}return{push(s,o=0){const a={dismiss:s,layer:o,seq:t++};return e.push(a),()=>{const l=e.indexOf(a);l!==-1&&e.splice(l,1)}},dismissTop(){const s=n();return s?(s.dismiss(),!0):!1},isTop(s){const o=n();return o!=null&&o.dismiss===s},depth(){return e.length},topIsPanel(){const s=n();return s!=null&&s.layer===nT}}}const Ao=NL();function EL(e){return e.overlayOpen&&!e.panelOnTop?"dismiss":e.typing?"blur":e.overlayOpen?"dismiss":"clear-selection"}function Kb(e){return String(e.tagName??"").toUpperCase()==="BODY"}function jL(e,t){return!e||!e.isConnected||Kb(e)?!1:t==null||Kb(t)}const Xb="a[href], button, input, select, textarea, [tabindex]";function CL(e){return!e||e.disabled||e.rendered===!1?!1:(e.tabIndex??0)>=0}function TL(e){if(!e||!e.overflowing||e.hasFocusable)return!1;const t=String(e.overflow??"").toLowerCase();return t==="auto"||t==="scroll"}function RL({count:e,index:t,shiftKey:n}){return e<=0?{kind:"hold"}:t<0||t>=e?{kind:"focus",index:n?e-1:0}:!n&&t===e-1?{kind:"focus",index:0}:n&&t===0?{kind:"focus",index:e-1}:{kind:"allow"}}function mw(e){return e.ctrlKey||e.metaKey||e.altKey}const AL=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),ML=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),IL=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function rT(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function gw(e){if(!e)return!1;if(e.isContentEditable)return!0;const t=rT(e);return t==="TEXTAREA"?!0:t!=="INPUT"?!1:!AL.has(String(e.type??"text").toLowerCase())}function OL(e){if(!e)return!1;if(gw(e)||ML.has(rT(e)))return!0;const t=typeof e.role=="string"?e.role.trim().toLowerCase():"";return t!==""&&t.split(/\s+/).some(n=>IL.has(n))}function PL({key:e,modalOpen:t,sheetOpen:n}){return t?!(e==="?"&&n):!1}function sT(e){return e?Array.from(e.querySelectorAll("*")).filter(t=>{if(t.matches(Xb))return CL({disabled:t.disabled,tabIndex:t.tabIndex,rendered:t.getClientRects().length>0});const n=t.scrollHeight>t.clientHeight;return n&&TL({overflowing:n,overflow:getComputedStyle(t).overflowY,hasFocusable:t.querySelector(Xb)!=null})}):[]}function $L(e,t){const n=sT(e);if(!t||!e.contains(t)||n.includes(t))return n;const s=n.findIndex(o=>(t.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING)!==0);return s===-1?[...n,t]:[...n.slice(0,s),t,...n.slice(s)]}function kn(e,t={}){const{focusRef:n,layer:s}=t,o=E.useRef(null),a=E.useRef(e);a.current=e;const l=E.useRef(null);l.current===null&&(l.current=()=>a.current());const u=l.current;return E.useEffect(()=>Ao.push(u,s),[u,s]),E.useEffect(()=>{var p;const h=document.activeElement;return(p=(n==null?void 0:n.current)??sT(o.current)[0])==null||p.focus(),()=>{jL(h,document.activeElement)&&h.focus()}},[]),E.useEffect(()=>{const h=p=>{var b;if(p.key!=="Tab"||mw(p))return;const f=o.current;if(!f)return;const g=document.activeElement;if(!(g!=null&&f.contains(g))&&!Ao.isTop(u))return;const w=$L(f,g),S=RL({count:w.length,index:g?w.indexOf(g):-1,shiftKey:p.shiftKey});S.kind!=="allow"&&(p.preventDefault(),S.kind==="focus"&&((b=w[S.index])==null||b.focus()))};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[u]),o}function LL(e){return e==="codex"?{subtitle:"reported by the Codex CLI — as of its most recent request",windowScope:"last request",compositionCounted:!1,compositionUncounted:"Not counted for Codex — the deck reconstructs the session from its rollout file and skips whatever was written before it attached, so a message and tool-call breakdown here would be short by an unknown amount. The window figure above is the CLI's own and is unaffected.",memoryHeading:"AGENTS.md files in scope",memoryEmpty:"No AGENTS.md files found on the path from cwd to the filesystem root, or in $CODEX_HOME."}:{subtitle:"approximation — CC's /context isn't hook-exposed",windowScope:"current turn",compositionCounted:!0,compositionUncounted:"",memoryHeading:"CLAUDE.md files in scope",memoryEmpty:"No CLAUDE.md files found on the path from cwd to ~/.claude."}}function Pn(e){return e.toLocaleString()}function qL(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}const DL=60;function FL(e,t=DL){if(e.length<=t)return e;const n=e.slice(e.length-(t-1)),s=n.search(/[/\\]/);return"…"+(s===-1?n:n.slice(s))}function zL({agent:e,onClose:t}){var y;const n=E.useRef(null),s=kn(t,{focusRef:n}),o=e.context,a=e.usage,l=(o==null?void 0:o.currentContextTokens)??0,u=QC(e.contextWindow,e.model),h=Math.min(100,l/u*100),p=bn(e),f=a.inputTokens+a.cacheReadTokens+a.cacheCreateTokens,g=LL(e.provider);return d.jsx("div",{className:"ctx-modal-backdrop",onClick:t,role:"presentation",children:d.jsxs("div",{ref:s,className:"ctx-modal",onClick:w=>w.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Context breakdown",children:[d.jsxs("header",{className:"ctx-modal-head",children:[d.jsxs("div",{children:[d.jsxs("div",{className:"ctx-modal-title",children:["Context · ",e.label]}),d.jsx("div",{className:"ctx-modal-sub",children:g.subtitle})]}),d.jsx("button",{type:"button",ref:n,className:"glyph-btn ctx-modal-close",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),d.jsxs("section",{className:"ctx-window-row",children:[d.jsx("div",{className:"ctx-window-bar",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(h),children:d.jsx("div",{className:"ctx-window-fill",style:{width:`${h}%`}})}),d.jsxs("div",{className:"ctx-window-meta",children:[d.jsxs("span",{className:"ctx-window-pct",children:[h.toFixed(1),"%"]}),d.jsxs("span",{children:[Pn(l)," / ",Pn(u)," tok (",g.windowScope,")"]})]})]}),d.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),d.jsxs("div",{className:"ctx-grid",children:[d.jsx(nr,{label:"input tokens",val:Pn(a.inputTokens)}),d.jsx(nr,{label:"output tokens",val:Pn(a.outputTokens)}),d.jsx(nr,{label:"cache reads",val:Pn(a.cacheReadTokens)}),d.jsx(nr,{label:"cache writes",val:Pn(a.cacheCreateTokens)}),d.jsx(nr,{label:"cumulative total",val:Pn(f)}),d.jsx(nr,{label:"estimated cost",val:Ve(p.total),accent:!0})]}),d.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),g.compositionCounted?d.jsxs("div",{className:"ctx-grid",children:[d.jsx(nr,{label:"user messages",val:Pn((o==null?void 0:o.msgsUser)??0)}),d.jsx(nr,{label:"assistant messages",val:Pn((o==null?void 0:o.msgsAssistant)??0)}),d.jsx(nr,{label:"tool uses",val:Pn((o==null?void 0:o.toolUses)??0)}),d.jsx(nr,{label:"tool results",val:Pn((o==null?void 0:o.toolResults)??0)}),d.jsx(nr,{label:"system-reminders",val:Pn((o==null?void 0:o.systemReminders)??0)})]}):d.jsx("div",{className:"ctx-empty",children:g.compositionUncounted}),d.jsx("h3",{className:"ctx-section-title",children:g.memoryHeading}),(((y=o==null?void 0:o.memoryFiles)==null?void 0:y.length)??0)===0?d.jsx("div",{className:"ctx-empty",children:g.memoryEmpty}):d.jsx("ul",{className:"ctx-md-list",children:o.memoryFiles.map(w=>d.jsxs("li",{children:[d.jsx("span",{className:"ctx-md-path",title:w.path,children:FL(w.path)}),d.jsx("span",{className:"ctx-md-size",children:qL(w.bytes)})]},w.path))})]})})}function nr({label:e,val:t,accent:n}){return d.jsxs("div",{className:`ctx-row${n?" accent":""}`,children:[d.jsx("span",{className:"ctx-row-label",children:e}),d.jsx("span",{className:"ctx-row-val",children:t})]})}function BL({currentContextTokens:e,modelId:t,contextWindow:n,size:s=26,onClick:o,title:a}){const l=QC(n,t),u=Math.min(1,e/l),h=s/2-3,p=s/2,f=2*Math.PI*h,g=f*u,y=u>.9?"var(--err)":u>.7?"var(--inflight)":"var(--accent)";return d.jsx("button",{type:"button",className:"ctx-donut",onClick:o,title:a??`context: ${e.toLocaleString()} / ${l.toLocaleString()} (${(u*100).toFixed(1)}%)`,"aria-label":"Show context breakdown",children:d.jsxs("svg",{width:s,height:s,viewBox:`0 0 ${s} ${s}`,children:[d.jsx("circle",{cx:p,cy:p,r:h,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),d.jsx("circle",{cx:p,cy:p,r:h,stroke:y,strokeWidth:"2.5",fill:"none",strokeDasharray:`${g} ${f-g}`,strokeDashoffset:f/4,strokeLinecap:"round",style:{transition:"var(--ctx-arc-transition)"}}),d.jsx("text",{x:p,y:p+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(u*100)})]})})}function Qb(e,t){const n=Uo(t);if(!n)return`model: ${t}
59
+ Codex writes no approval request to its rollout files, which are the only thing this deck can read — so when it does ask, this card, the sidebar, the topbar count, the tab title and the favicon will all stay silent. Check the terminal.`}}function Yb(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function xi(e){const t=Ru(e).replace(/[-_]\d{8}(?!\d)/,""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const o=Yb(n[1]),a=n[2].replace(/[-_]/g,".");return`${o} ${a}`}const s=t.match(/^gpt[-_](\d+(?:[-_.]\d+)*)((?:[-_][A-Za-z0-9.]+)*)$/i);if(s){const o=s[1].replace(/[-_]/g,"."),a=s[2].split(/[-_]/).filter(Boolean).map(Yb);return[`GPT-${o}`,...a].join(" ")}return e}function Pt(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 vu(e,t,n){const s=(t??n)-e;if(s<1e3)return`${Math.max(0,s)}ms`;const o=Math.floor(s/1e3);if(o<60)return`${o}s`;const a=Math.floor(o/60),l=o%60;return`${a}m ${String(l).padStart(2,"0")}s`}function eT(e,t){if(e.endedAt==null)return t;const n=e.endedAt-e.startedAt;return n<1e3?`${n}ms`:`${(n/1e3).toFixed(2)}s`}function tT(e,t){const n=typeof e=="string"?e.trim():"",s=typeof t=="string"?t.trim():"";return{face:n||s||void 0,tooltip:s||n||void 0}}const kL=1,nT=-1;function SL(){const e=[];let t=0;function n(){let s;for(const o of e)(!s||o.layer>s.layer||o.layer===s.layer&&o.seq>s.seq)&&(s=o);return s}return{push(s,o=0){const a={dismiss:s,layer:o,seq:t++};return e.push(a),()=>{const l=e.indexOf(a);l!==-1&&e.splice(l,1)}},dismissTop(){const s=n();return s?(s.dismiss(),!0):!1},isTop(s){const o=n();return o!=null&&o.dismiss===s},depth(){return e.length},topIsPanel(){const s=n();return s!=null&&s.layer===nT}}}const Ao=SL();function NL(e){return e.overlayOpen&&!e.panelOnTop?"dismiss":e.typing?"blur":e.overlayOpen?"dismiss":"clear-selection"}function Kb(e){return String(e.tagName??"").toUpperCase()==="BODY"}function EL(e,t){return!e||!e.isConnected||Kb(e)?!1:t==null||Kb(t)}const Xb="a[href], button, input, select, textarea, [tabindex]";function jL(e){return!e||e.disabled||e.rendered===!1?!1:(e.tabIndex??0)>=0}function CL(e){if(!e||!e.overflowing||e.hasFocusable)return!1;const t=String(e.overflow??"").toLowerCase();return t==="auto"||t==="scroll"}function TL({count:e,index:t,shiftKey:n}){return e<=0?{kind:"hold"}:t<0||t>=e?{kind:"focus",index:n?e-1:0}:!n&&t===e-1?{kind:"focus",index:0}:n&&t===0?{kind:"focus",index:e-1}:{kind:"allow"}}function mw(e){return e.ctrlKey||e.metaKey||e.altKey}const RL=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),AL=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),ML=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function rT(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function gw(e){if(!e)return!1;if(e.isContentEditable)return!0;const t=rT(e);return t==="TEXTAREA"?!0:t!=="INPUT"?!1:!RL.has(String(e.type??"text").toLowerCase())}function IL(e){if(!e)return!1;if(gw(e)||AL.has(rT(e)))return!0;const t=typeof e.role=="string"?e.role.trim().toLowerCase():"";return t!==""&&t.split(/\s+/).some(n=>ML.has(n))}function OL({key:e,modalOpen:t,sheetOpen:n}){return t?!(e==="?"&&n):!1}function sT(e){return e?Array.from(e.querySelectorAll("*")).filter(t=>{if(t.matches(Xb))return jL({disabled:t.disabled,tabIndex:t.tabIndex,rendered:t.getClientRects().length>0});const n=t.scrollHeight>t.clientHeight;return n&&CL({overflowing:n,overflow:getComputedStyle(t).overflowY,hasFocusable:t.querySelector(Xb)!=null})}):[]}function PL(e,t){const n=sT(e);if(!t||!e.contains(t)||n.includes(t))return n;const s=n.findIndex(o=>(t.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING)!==0);return s===-1?[...n,t]:[...n.slice(0,s),t,...n.slice(s)]}function kn(e,t={}){const{focusRef:n,layer:s}=t,o=E.useRef(null),a=E.useRef(e);a.current=e;const l=E.useRef(null);l.current===null&&(l.current=()=>a.current());const u=l.current;return E.useEffect(()=>Ao.push(u,s),[u,s]),E.useEffect(()=>{var p;const h=document.activeElement;return(p=(n==null?void 0:n.current)??sT(o.current)[0])==null||p.focus(),()=>{EL(h,document.activeElement)&&h.focus()}},[]),E.useEffect(()=>{const h=p=>{var b;if(p.key!=="Tab"||mw(p))return;const f=o.current;if(!f)return;const g=document.activeElement;if(!(g!=null&&f.contains(g))&&!Ao.isTop(u))return;const w=PL(f,g),S=TL({count:w.length,index:g?w.indexOf(g):-1,shiftKey:p.shiftKey});S.kind!=="allow"&&(p.preventDefault(),S.kind==="focus"&&((b=w[S.index])==null||b.focus()))};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[u]),o}function $L(e){return e==="codex"?{subtitle:"reported by the Codex CLI — as of its most recent request",windowScope:"last request",compositionCounted:!1,compositionUncounted:"Not counted for Codex — the deck reconstructs the session from its rollout file and skips whatever was written before it attached, so a message and tool-call breakdown here would be short by an unknown amount. The window figure above is the CLI's own and is unaffected.",memoryHeading:"AGENTS.md files in scope",memoryEmpty:"No AGENTS.md files found on the path from cwd to the filesystem root, or in $CODEX_HOME."}:{subtitle:"approximation — CC's /context isn't hook-exposed",windowScope:"current turn",compositionCounted:!0,compositionUncounted:"",memoryHeading:"CLAUDE.md files in scope",memoryEmpty:"No CLAUDE.md files found on the path from cwd to ~/.claude."}}function Pn(e){return e.toLocaleString()}function LL(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}const qL=60;function DL(e,t=qL){if(e.length<=t)return e;const n=e.slice(e.length-(t-1)),s=n.search(/[/\\]/);return"…"+(s===-1?n:n.slice(s))}function FL({agent:e,onClose:t}){var y;const n=E.useRef(null),s=kn(t,{focusRef:n}),o=e.context,a=e.usage,l=(o==null?void 0:o.currentContextTokens)??0,u=QC(e.contextWindow,e.model),h=Math.min(100,l/u*100),p=bn(e),f=a.inputTokens+a.cacheReadTokens+a.cacheCreateTokens,g=$L(e.provider);return d.jsx("div",{className:"ctx-modal-backdrop",onClick:t,role:"presentation",children:d.jsxs("div",{ref:s,className:"ctx-modal",onClick:w=>w.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Context breakdown",children:[d.jsxs("header",{className:"ctx-modal-head",children:[d.jsxs("div",{children:[d.jsxs("div",{className:"ctx-modal-title",children:["Context · ",e.label]}),d.jsx("div",{className:"ctx-modal-sub",children:g.subtitle})]}),d.jsx("button",{type:"button",ref:n,className:"glyph-btn ctx-modal-close",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),d.jsxs("section",{className:"ctx-window-row",children:[d.jsx("div",{className:"ctx-window-bar",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(h),children:d.jsx("div",{className:"ctx-window-fill",style:{width:`${h}%`}})}),d.jsxs("div",{className:"ctx-window-meta",children:[d.jsxs("span",{className:"ctx-window-pct",children:[h.toFixed(1),"%"]}),d.jsxs("span",{children:[Pn(l)," / ",Pn(u)," tok (",g.windowScope,")"]})]})]}),d.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),d.jsxs("div",{className:"ctx-grid",children:[d.jsx(nr,{label:"input tokens",val:Pn(a.inputTokens)}),d.jsx(nr,{label:"output tokens",val:Pn(a.outputTokens)}),d.jsx(nr,{label:"cache reads",val:Pn(a.cacheReadTokens)}),d.jsx(nr,{label:"cache writes",val:Pn(a.cacheCreateTokens)}),d.jsx(nr,{label:"cumulative total",val:Pn(f)}),d.jsx(nr,{label:"estimated cost",val:Ve(p.total),accent:!0})]}),d.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),g.compositionCounted?d.jsxs("div",{className:"ctx-grid",children:[d.jsx(nr,{label:"user messages",val:Pn((o==null?void 0:o.msgsUser)??0)}),d.jsx(nr,{label:"assistant messages",val:Pn((o==null?void 0:o.msgsAssistant)??0)}),d.jsx(nr,{label:"tool uses",val:Pn((o==null?void 0:o.toolUses)??0)}),d.jsx(nr,{label:"tool results",val:Pn((o==null?void 0:o.toolResults)??0)}),d.jsx(nr,{label:"system-reminders",val:Pn((o==null?void 0:o.systemReminders)??0)})]}):d.jsx("div",{className:"ctx-empty",children:g.compositionUncounted}),d.jsx("h3",{className:"ctx-section-title",children:g.memoryHeading}),(((y=o==null?void 0:o.memoryFiles)==null?void 0:y.length)??0)===0?d.jsx("div",{className:"ctx-empty",children:g.memoryEmpty}):d.jsx("ul",{className:"ctx-md-list",children:o.memoryFiles.map(w=>d.jsxs("li",{children:[d.jsx("span",{className:"ctx-md-path",title:w.path,children:DL(w.path)}),d.jsx("span",{className:"ctx-md-size",children:LL(w.bytes)})]},w.path))})]})})}function nr({label:e,val:t,accent:n}){return d.jsxs("div",{className:`ctx-row${n?" accent":""}`,children:[d.jsx("span",{className:"ctx-row-label",children:e}),d.jsx("span",{className:"ctx-row-val",children:t})]})}function zL({currentContextTokens:e,modelId:t,contextWindow:n,size:s=26,onClick:o,title:a}){const l=QC(n,t),u=Math.min(1,e/l),h=s/2-3,p=s/2,f=2*Math.PI*h,g=f*u,y=u>.9?"var(--err)":u>.7?"var(--inflight)":"var(--accent)";return d.jsx("button",{type:"button",className:"ctx-donut",onClick:o,title:a??`context: ${e.toLocaleString()} / ${l.toLocaleString()} (${(u*100).toFixed(1)}%)`,"aria-label":"Show context breakdown",children:d.jsxs("svg",{width:s,height:s,viewBox:`0 0 ${s} ${s}`,children:[d.jsx("circle",{cx:p,cy:p,r:h,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),d.jsx("circle",{cx:p,cy:p,r:h,stroke:y,strokeWidth:"2.5",fill:"none",strokeDasharray:`${g} ${f-g}`,strokeDashoffset:f/4,strokeLinecap:"round",style:{transition:"var(--ctx-arc-transition)"}}),d.jsx("text",{x:p,y:p+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(u*100)})]})})}function Qb(e,t){const n=Uo(t);if(!n)return`model: ${t}
60
60
  no published rate in this build — the tokens are counted, the dollars are not`;const s=f=>f.toLocaleString(),o=f=>`$${f}/MTok`,a=pw(e,t),l=KC(e,n),u=l.tokens1h>0?[`cache w5m${s(l.tokens5m).padStart(14)} × ${o(n.cacheWrite).padEnd(11)} = ${Ve(l.usd5m)}`,`cache w1h${s(l.tokens1h).padStart(14)} × ${o(n.cacheWrite1h??n.cacheWrite).padEnd(11)} = ${Ve(l.usd1h)}`]:[`cache w ${s(l.tokens5m).padStart(14)} × ${o(n.cacheWrite).padEnd(11)} = ${Ve(l.usd5m)}`],h=XC(e,t),p=h===e.inputTokens?"input":"uncached";return[`model: ${t}`,`${p.padEnd(9)}${s(h).padStart(14)} × ${o(n.input).padEnd(11)} = ${Ve(a.input)}`,`output ${s(e.outputTokens).padStart(14)} × ${o(n.output).padEnd(11)} = ${Ve(a.output)}`,`cache r ${s(e.cacheReadTokens).padStart(14)} × ${o(n.cacheRead).padEnd(11)} = ${Ve(a.cacheRead)}`,...u,"─────────────────────────────────────────",`total = ${Ve(a.total)}`].join(`
61
61
  `)}function Zb(e){const t=gl(e);return t.length<=1?Qb(e.usage,e.model):[...t.map(n=>Qb(n.usage,n.model)),"═════════════════════════════════════════",`all models = ${Ve(bn(e).total)}`].join(`
62
- `)}function UL({data:e,selected:t}){var y;const n=e.now??Date.now(),s=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":"",t?"selected":""].filter(Boolean).join(" "),o=e.tools.filter(w=>!w.endedAt).length,a=hw(e.sessionId),l=((y=e.context)==null?void 0:y.currentContextTokens)??0,u=e.kind==="root"&&l>0,h=e.sessionTitle?e.cwd?`${e.cwd}
62
+ `)}function BL({data:e,selected:t}){var y;const n=e.now??Date.now(),s=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":"",t?"selected":""].filter(Boolean).join(" "),o=e.tools.filter(w=>!w.endedAt).length,a=hw(e.sessionId),l=((y=e.context)==null?void 0:y.currentContextTokens)??0,u=e.kind==="root"&&l>0,h=e.sessionTitle?e.cwd?`${e.cwd}
63
63
  ${e.sessionTitle}`:e.sessionTitle:e.cwd,p=JC(e),f=p.length>0?`${e.model}
64
64
  spend on this card also covers:
65
65
  ${p.join(`
66
- `)}`:e.model,g=tT(e.sessionName,e.sessionTitle);return d.jsxs("div",{className:s,style:{"--session-hue":a},children:[d.jsx("span",{className:"accent-stripe"}),d.jsx(Lo,{type:"target",position:Oe.Left,style:{background:"transparent",border:"none"}}),d.jsxs("div",{className:"head",children:[d.jsxs("div",{className:"title",children:[d.jsx(WL,{state:e.state}),d.jsx("span",{className:"label",title:h,children:e.label}),e.synthetic&&d.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"})]}),d.jsxs("div",{className:"head-right",children:[u&&e.onOpenContext&&d.jsx(BL,{currentContextTokens:l,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)}),d.jsx("div",{className:"time",title:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:vu(e.startedAt,e.endedAt,n)})]})]}),d.jsxs("div",{className:"sub",children:[e.kind==="root"?"session":"subagent",e.childCount>0&&d.jsxs("span",{className:"spawn-badge",title:`${e.childCount} subagents spawned`,children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model?d.jsxs("span",{className:"model-chip",title:f,children:[xi(e.model),p.length>0?` +${p.length}`:""]}):e.provider==="codex"?d.jsx("span",{className:"model-chip",title:"OpenAI Codex — no model reported yet",children:"Codex"}):null]}),e.kind==="root"&&g.face&&d.jsx("div",{className:"session-name",title:g.tooltip,children:g.face}),e.waiting&&d.jsx(GL,{waiting:e.waiting,now:n}),(()=>{const w=kL(e);return w?d.jsxs("div",{className:"approval-blind-row",title:w.detail,children:[d.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),d.jsx("span",{className:"approval-blind-said",children:w.label})]}):null})(),e.tools.length>0&&d.jsx(VL,{tools:e.tools,now:n}),d.jsxs("div",{className:"meta",children:[d.jsxs("span",{children:[d.jsx("b",{children:e.toolCount})," tools"]}),o>0&&d.jsxs("span",{className:"inflight-meta",children:[d.jsx("b",{children:o})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&d.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:[d.jsx("b",{children:Pt(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),e.model&&(()=>{const w=Uo(e.model),S=bn(e),b=My(e);if(!w&&S.total<=0)return e.usage.inputTokens+e.usage.outputTokens<=0?null:d.jsx("span",{className:"cost-unpriced",title:Zb(e),children:su});if(S.total<=0)return null;const _=Math.max(0,((e.endedAt??n)-e.startedAt)/1e3),k=e.state==="active"?gu(S.total,_):null,N=Zb(e)+(k?`
67
- burn: ${k}`:"");return d.jsxs("span",{className:"cost-meta",title:N,children:[d.jsxs("b",{children:[Ve(S.total),b>0?"+":""]}),k&&d.jsx("span",{className:"cost-rate",children:k})]})})()]}),d.jsx(Lo,{type:"source",position:Oe.Right,style:{background:"transparent",border:"none"}})]})}function vw(e){return e==="active"?"live":e==="done"?"done":"err"}function WL({state:e}){return d.jsx("span",{className:`state-pill state-${e}`,children:vw(e)})}function Au(e){return e.message?e.message:e.kind==="permission"?"Needs your permission":"Waiting for your input"}function HL(e){return e.kind==="permission"?Au(e):"Your turn"}function GL({waiting:e,now:t}){const n=e.kind==="permission",s=Au(e);return d.jsxs("div",{className:n?"waiting-row permission":"waiting-row idle",title:`${s}
68
- Blocked for ${vu(e.since,void 0,t)} — the answer goes in the terminal, not here.`,children:[n?d.jsx("span",{className:"ap-pulse","aria-hidden":!0}):d.jsx("span",{className:"waiting-dot","aria-hidden":!0}),d.jsx("span",{className:"waiting-said",children:HL(e)}),d.jsx("b",{children:vu(e.since,void 0,t)})]})}function VL({tools:e,now:t}){const a=new Array(24).fill(0);let l=0;for(const y of e){const w=t-y.startedAt;if(w<0||w>=6e4)continue;const S=23-Math.floor(w/2500);S>=0&&S<24&&(a[S]+=1,l+=1)}const u=Math.max(1,...a),h=132,p=14,f=h/24,g=u/(2500/1e3);return d.jsxs("div",{className:"tool-spark-row",title:`${l} tool calls in last 60s · peak ${g.toFixed(1)}/s`,children:[d.jsx("svg",{className:"tool-spark",width:h,height:p,viewBox:`0 0 ${h} ${p}`,"aria-hidden":!0,children:a.map((y,w)=>{const S=y===0?1.5:Math.max(1.5,y/u*p),b=w===23&&y>0,k=`tool-spark-bar${y>0?" active":""}${b?" latest":""}`;return d.jsx("rect",{x:w*f+.4,y:p-S,width:Math.max(.5,f-1),height:S,rx:.8,className:k},w)})}),d.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function Jb(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function YL({tool:e,onClose:t}){const n=kn(t),s=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return d.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:d.jsxs("div",{ref:n,className:"modal",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[d.jsxs("header",{className:"modal-head",children:[d.jsxs("div",{className:"modal-title",children:[d.jsx("span",{className:`status-dot ${s}`,"aria-hidden":!0}),d.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),d.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),d.jsxs("div",{className:"modal-actions",children:[d.jsx("span",{className:"modal-dur",children:eT(e,"in-flight…")}),d.jsx("button",{className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),d.jsxs("section",{className:"modal-body",children:[e.trimmed&&d.jsx("div",{className:"modal-section",children:d.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),d.jsxs("div",{className:"modal-section",children:[d.jsx("h4",{children:"Input"}),d.jsx("pre",{children:Jb(e.input??e.inputPreview)})]}),d.jsxs("div",{className:"modal-section",children:[d.jsxs("h4",{children:["Response ",s==="err"&&d.jsx("span",{className:"err-tag",children:"error"})]}),d.jsx("pre",{children:e.endedAt==null?"(waiting…)":Jb(e.response??e.errorPreview)})]})]})]})})}const Hc=18,e1=26,KL=12;function XL(e){return QL(e.nodeInternals.values())}function QL(e){const t=new Map;for(const o of e){if(o.type!=="agent")continue;const a=o.data;if(!(a!=null&&a.sessionId)||a.exitAt!=null||o.width==null||o.height==null)continue;const l=o.position.x,u=o.position.y,h=l+o.width,p=u+o.height,f=t.get(a.sessionId);f?(f.minX=Math.min(f.minX,l),f.minY=Math.min(f.minY,u),f.maxX=Math.max(f.maxX,h),f.maxY=Math.max(f.maxY,p),a.kind==="root"&&(f.label=n1(a)??f.label),a.kind==="root"&&(f.name=r1(a))):t.set(a.sessionId,{minX:l,minY:u,maxX:h,maxY:p,label:n1(a)??a.sessionId,name:r1(a)})}const n=new Map;for(const o of t.values())n.set(o.label,(n.get(o.label)??0)+1);const s=[];for(const[o,a]of t){const l=(n.get(a.label)??0)>1;s.push({sessionId:o,...t3(a.label,a.name,o,l),x:a.minX-Hc,y:a.minY-Hc-e1,w:a.maxX-a.minX+Hc*2,h:a.maxY-a.minY+Hc*2+e1})}return s}const Iy=" · ",ZL=32,JL=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function t1(e){return JL.test(e)?2:1}function e3(e,t=ZL){const n=[...e];let s=0;for(const l of n)s+=t1(l);if(s<=t)return e;const o=[];let a=0;for(const l of n){const u=t1(l);if(a+u>t-1)break;o.push(l),a+=u}for(;o.length&&/[\s\-_.:/]/.test(o[o.length-1]);)o.pop();return`${o.join("")}…`}function t3(e,t,n,s){const o=(t==null?void 0:t.trim())??"",a=s?n3(n):void 0,l=[e,o||void 0,a].filter(Boolean);return{label:e,name:o?e3(o):void 0,shortId:a,fullLabel:l.join(Iy)}}function n3(e){const t=e.match(/[a-zA-Z0-9]{4}/);return t?t[0]:e.slice(0,4)}function n1(e){if(e.kind==="root")return e.label}function r1(e){if(e.kind==="root")return tT(e.sessionName,e.sessionTitle).face}function r3(){const{x:e,y:t,zoom:n}=DC(),s=hl(),o=rt(XL,s3);if(o.length<=1)return null;const a=u=>{try{const h=s.getNodes().filter(p=>{const f=p.data;return(f==null?void 0:f.sessionId)===u});if(h.length===0)return;s.fitView({padding:.3,duration:500,nodes:h})}catch{}},l={transform:`translate(${e}px, ${t}px) scale(${n})`};return d.jsx("div",{className:"session-clusters",style:l,children:o.map(u=>{const h=hw(u.sessionId),p={position:"absolute",left:u.x,top:u.y,width:u.w,height:u.h,"--session-hue":h},f={position:"absolute",left:u.x+16,top:u.y-KL,transform:`scale(${Math.min(1,n)/(n||1)})`,transformOrigin:"left top","--session-hue":h};return d.jsxs(ue.Fragment,{children:[d.jsx("div",{className:"cluster-card",style:p,"aria-hidden":!0}),d.jsxs("button",{type:"button",className:"cluster-label",style:f,title:`Fit view to ${u.fullLabel}
69
- drag the wrapper to move the whole session`,onClick:()=>a(u.sessionId),children:[u.label,u.name?d.jsxs(d.Fragment,{children:[Iy,d.jsx("span",{className:"cluster-label-name",children:u.name})]}):null,u.shortId?Iy+u.shortId:null]})]},u.sessionId)})})}function s3(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const s=e[n],o=t[n];if(s.sessionId!==o.sessionId||s.label!==o.label||s.name!==o.name||s.shortId!==o.shortId||s.fullLabel!==o.fullLabel||s.x!==o.x||s.y!==o.y||s.w!==o.w||s.h!==o.h)return!1}return!0}function i3({data:e}){return d.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const vl={exec:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},shell:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},exec_command:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},shell_command:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},write_stdin:{category:"shell",emoji:"💻",label:"stdin",shell:!0},wait:{category:"shell",emoji:"⏳",label:"wait",shell:!0},apply_patch:{category:"file",emoji:"🩹",label:"Edit"},update_plan:{category:"task",emoji:"📋",label:"Plan"},run:{category:"web",emoji:"🌐",label:"Web"}},o3=Object.fromEntries(Object.entries(vl).map(([e,t])=>[e,t.category])),a3=Object.fromEntries(Object.entries(vl).map(([e,t])=>[e,t.emoji])),l3=Object.fromEntries(Object.entries(vl).map(([e,t])=>[e,t.label])),c3=new Set(Object.keys(vl)),u3=new Set(Object.entries(vl).filter(([,e])=>e.shell).map(([e])=>e)),s1={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",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",...o3};function iT(e){return e.startsWith("mcp__")?"mcp":Object.hasOwn(s1,e)?s1[e]:"other"}const d3=/\btools\.exec_command\s*\(\s*\{[^{}]*?\bcmd\s*:\s*(["'`])((?:\\.|(?!\1)[^\\])*)\1/,f3=/\btools\.([A-Za-z_$][\w$]*)\s*\(/;function h3(e){if(typeof e!="string"||!e)return null;const t=d3.exec(e);if(t){const s=p3(t[2]);if(s.trim())return s}const n=f3.exec(e);return n?n[1]:null}function p3(e){return e.replace(/\\(["'`\\nrt])/g,(t,n)=>n==="n"?`
70
- `:n==="r"?"\r":n==="t"?" ":n)}const oT=600,m3=4,g3=36,Oy=16,v3=60,y3=6,i1=220,o1=96,w3=28,a1={Read:"📖",Write:"💾",Edit:"✏️",MultiEdit:"🔧",Glob:"🗺️",Grep:"🔎",Bash:"⚡",PowerShell:"💻",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:"📡",...a3};function l1(e){return e.startsWith("mcp__")?"🔌":Object.hasOwn(a1,e)?a1[e]:"✨"}const c1={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 aT(e){if(!e)return null;let t=e.trim();if(!t)return null;const n=t.match(/^(?:bash|sh|zsh|fish|powershell|pwsh)(?:\.exe)?\s+(?:-c|-Command|-NoProfile|-NonInteractive|\s)+["']([^"']+)["']/i);if(n)return aT(n[1]);for(;;){const a=t.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!a)break;t=t.slice(a[0].length)}t=t.replace(/^sudo(?:\s+-\S+)*\s+/,""),t=t.replace(/^(?:time|nohup|xargs)\s+/,"");const s=t.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 x3(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const t=e;if(typeof t.script=="string"){const n=h3(t.script);if(n)return n}if(typeof t.cmd=="string")return t.cmd;if(typeof t.command=="string")return t.command;if(Array.isArray(t.command)&&t.command.every(n=>typeof n=="string")){const n=t.command;if(/powershell|cmd|bash|sh(\.exe)?$/i.test(n[0]??"")){const s=n.findIndex(o=>/^(-Command|-c)$/i.test(o));if(s>=0&&s+1<n.length)return n[s+1]}return n.join(" ")}return typeof t.script=="string"?t.script:null}const b3=new Set(["Bash","PowerShell",...u3]),_3=c3;function k3(e,t){return _3.has(e)||e.startsWith("mcp__")?Math.max(o1,34+t.length*7.5):o1}function S3(e,t){if(!b3.has(e))return null;const n=x3(t);if(!n)return null;const s=aT(n);return s?{emoji:Object.hasOwn(c1,s)?c1[s]:"⚙️",label:s,category:"shell",detail:n}:null}const N3=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),u1={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:"🗄️"},d1={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 E3(e){const n=e.replace(/\\/g,"/").replace(/\/+$/,""),s=n.lastIndexOf("/");return s>=0?n.slice(s+1):n}function j3(e){const t=e.toLowerCase();if(Object.hasOwn(d1,t))return d1[t];if(t.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(t))return"🧪";const n=t.lastIndexOf(".");if(n>0&&n<t.length-1){const s=t.slice(n+1);if(Object.hasOwn(u1,s))return u1[s]}return"📄"}function C3(e,t){if(!t||typeof t!="object")return null;const n=t;if(e==="apply_patch"&&typeof n.patch=="string"){const s=n.patch.match(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/m);return s?s[1].trim():null}return typeof n.file_path=="string"?n.file_path:typeof n.notebook_path=="string"?n.notebook_path:typeof n.path=="string"?n.path:e==="Glob"&&typeof n.pattern=="string"?n.pattern:null}function T3(e,t){if(!N3.has(e))return null;const n=C3(e,t);if(!n)return null;const s=E3(n);return s?{emoji:e==="LS"?"📂":j3(s),label:s,category:"file",detail:n}:null}const f1={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 yw(e){if(!e.startsWith("mcp__"))return null;const t=e.slice(5),n=t.indexOf("__");return n<=0?{server:t,method:""}:{server:t.slice(0,n),method:t.slice(n+2)}}function R3(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return Math.abs(t)%360}function lT(e){const t=e.toLowerCase();return Object.hasOwn(f1,t)?f1[t]:void 0}function A3(e,t){const n=yw(e);if(!n)return null;const{server:s,method:o}=n;if(!o)return null;const a=lT(s);return{emoji:(a==null?void 0:a.emoji)??"🔌",label:o,category:"mcp",detail:a?`${a.name} · ${o}`:`${s} · ${o}`}}function M3(e,t){return S3(e,t)??T3(e,t)??A3(e)}const h1=l3;function cT(e){const t=yw(e);if(t){const s=lT(t.server);return s?{emoji:s.emoji,label:s.name}:{emoji:"🔌",label:t.server,hue:R3(t.server)}}const n=Object.hasOwn(h1,e)?h1[e]:"";return n?{emoji:l1(e),label:n}:{emoji:l1(e),label:e}}function I3(e){let t=null,n="";for(const s of e){const o=yw(s);if(o){if(!o.server)return null;if(t===null)t=o.server,n=s;else if(o.server!==t)return null}}return t===null?null:cT(n)}function O3(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function P3(e,t,n){if(n==null)return 1;const s=t-n;return s<0?1:Math.max(0,1-s/oT)}function $3(e,t){const n=[],s=new Set;for(let o=e.length-1;o>=0&&n.length<t;o--){const a=e[o];s.has(a.id)||(s.add(a.id),n.push(a))}return n.reverse()}function L3(e,t,n,s,o,a){const l=[];for(const u of e.values()){if(!t.has(u.id)||u.exitAt!=null&&a-u.exitAt>oT)continue;const h=s.get(u.id)??n.get(u.id);if(!h)continue;const p=$3(u.tools,m3);if(p.length===0)continue;const f=u.exitAt??null,g=o.get(u.id),y=Math.max((g==null?void 0:g.width)??i1,i1),w=(g==null?void 0:g.height)??130,S=h.x,b=h.y,_=S+y,k=b+w/2;p.forEach((N,j)=>{const T=j*g3,M=S+y+v3,P=b+y3+T,I=P3(N,a,f),F=N.inputPreview??"",O=O3(N),A=I<.999,D=cT(N.name);l.push({id:`${u.id}::${N.id}`,toolId:N.id,agentId:u.id,toolName:N.name,name:D.label,emoji:D.emoji,status:O,category:iT(N.name),mcpHue:D.hue,inputPreview:F,fade:I,fading:A,worldX:M,worldY:P,anchorX:_,anchorY:k,spawnDx:_-M,spawnDy:k-(P+Oy)});const H=M3(N.name,N.input);if(H){const K=k3(N.name,D.label),C=M+K+w3,X=P,B=M+K,ne=P+Oy;l.push({id:`sub:${u.id}::${N.id}`,toolId:N.id,agentId:u.id,toolName:N.name,name:H.label,emoji:H.emoji,isSub:!0,status:O,category:H.category,inputPreview:H.detail??F,fade:I,fading:A,worldX:C,worldY:X,anchorX:B,anchorY:ne,spawnDx:B-C,spawnDy:0})}})}return l}function q3({agents:e,visibleAgentIds:t,positions:n,pinned:s,measured:o,spotlight:a,hiddenCategories:l,now:u,onOpenTool:h}){const p=L3(e,t,n,s,o,u),f=l&&l.size>0?p.filter(g=>!l.has(g.category)):p;return d.jsx(D3,{bursts:f,spotlight:a,onOpenTool:h})}function D3({bursts:e,spotlight:t,onOpenTool:n}){const{x:s,y:o,zoom:a}=DC();return d.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[d.jsx("svg",{className:"tool-bursts-svg",children:e.map(l=>{const u=l.anchorX*a+s,h=l.anchorY*a+o,p=(l.worldX+6)*a+s,f=(l.worldY+Oy)*a+o,g=u+(p-u)*.55,y=t!=null&&!t.has(l.agentId),w=l.fade*(y?.14:1);return d.jsx("path",{d:`M ${u} ${h} Q ${g} ${h}, ${p} ${f}`,className:`tool-conn status-${l.status}${l.fading?" fading":""}`,opacity:w},`l:${l.id}`)})}),e.map(l=>{const u=l.worldX*a+s,h=l.worldY*a+o,p={left:`${u}px`,top:`${h}px`,transform:`scale(${a})`,transformOrigin:"left top","--spawn-dx":`${l.spawnDx}px`,"--spawn-dy":`${l.spawnDy}px`},f=l.isSub?`${l.toolName} · ${l.name}`:l.toolName,g=l.inputPreview?`${f} · ${l.inputPreview}`:f,y=n!=null,w=l.mcpHue!=null?{"--mcp-hue":l.mcpHue}:{},b=t!=null&&!t.has(l.agentId)?" dim":"";return d.jsx("div",{className:"tool-burst-wrap",style:p,children:d.jsxs("div",{className:`tool-burst cat-${l.category}${l.mcpHue!=null?" mcp-hue":""} status-${l.status}${l.fading?" fading":""}${y?" clickable":""}${l.isSub?" sub":""}${b}`,style:w,title:g,onClick:y?()=>n(l.toolId):void 0,children:[d.jsx("span",{className:"tb-emoji",children:l.emoji}),d.jsx("span",{className:"tb-name",children:l.name}),l.status==="inflight"&&d.jsx("span",{className:"tb-spin"}),l.status==="done"&&d.jsx("span",{className:"tb-mark done",children:"✓"}),l.status==="err"&&d.jsx("span",{className:"tb-mark err",children:"×"})]})},l.id)})]})}function uT(e){const t={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};let n=0,s=0,o=0,a=0;for(const l of e){const u=bn(l);t.input+=u.input,t.output+=u.output,t.cacheRead+=u.cacheRead,t.cacheWrite+=u.cacheWrite,t.total+=u.total,n+=l.usage.inputTokens,s+=l.usage.outputTokens,o+=l.usage.cacheReadTokens,a+=l.usage.cacheCreateTokens}return{cost:t,inputTokens:n,outputTokens:s,cacheReadTokens:o,cacheCreateTokens:a,sum:n+s}}const F3="spend on this board",z3="on this board",B3="board tokens",U3="board cost",yu=`Everything on the board right now, and only that.
66
+ `)}`:e.model,g=tT(e.sessionName,e.sessionTitle);return d.jsxs("div",{className:s,style:{"--session-hue":a},children:[d.jsx("span",{className:"accent-stripe"}),d.jsx(Lo,{type:"target",position:Oe.Left,style:{background:"transparent",border:"none"}}),d.jsxs("div",{className:"head",children:[d.jsxs("div",{className:"title",children:[d.jsx(UL,{state:e.state}),d.jsx("span",{className:"label",title:h,children:e.label}),e.synthetic&&d.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"})]}),d.jsxs("div",{className:"head-right",children:[u&&e.onOpenContext&&d.jsx(zL,{currentContextTokens:l,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)}),d.jsx("div",{className:"time",title:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:vu(e.startedAt,e.endedAt,n)})]})]}),d.jsxs("div",{className:"sub",children:[e.kind==="root"?"session":"subagent",e.childCount>0&&d.jsxs("span",{className:"spawn-badge",title:`${e.childCount} subagents spawned`,children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model?d.jsxs("span",{className:"model-chip",title:f,children:[xi(e.model),p.length>0?` +${p.length}`:""]}):e.provider==="codex"?d.jsx("span",{className:"model-chip",title:"OpenAI Codex — no model reported yet",children:"Codex"}):null]}),e.kind==="root"&&g.face&&d.jsx("div",{className:"session-name",title:g.tooltip,children:g.face}),e.waiting&&d.jsx(HL,{waiting:e.waiting,now:n}),(()=>{const w=_L(e);return w?d.jsxs("div",{className:"approval-blind-row",title:w.detail,children:[d.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),d.jsx("span",{className:"approval-blind-said",children:w.label})]}):null})(),e.tools.length>0&&d.jsx(GL,{tools:e.tools,now:n}),d.jsxs("div",{className:"meta",children:[d.jsxs("span",{children:[d.jsx("b",{children:e.toolCount})," tools"]}),o>0&&d.jsxs("span",{className:"inflight-meta",children:[d.jsx("b",{children:o})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&d.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:[d.jsx("b",{children:Pt(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),e.model&&(()=>{const w=Uo(e.model),S=bn(e),b=My(e);if(!w&&S.total<=0)return e.usage.inputTokens+e.usage.outputTokens<=0?null:d.jsx("span",{className:"cost-unpriced",title:Zb(e),children:su});if(S.total<=0)return null;const _=Math.max(0,((e.endedAt??n)-e.startedAt)/1e3),k=e.state==="active"?gu(S.total,_):null,N=Zb(e)+(k?`
67
+ burn: ${k}`:"");return d.jsxs("span",{className:"cost-meta",title:N,children:[d.jsxs("b",{children:[Ve(S.total),b>0?"+":""]}),k&&d.jsx("span",{className:"cost-rate",children:k})]})})()]}),d.jsx(Lo,{type:"source",position:Oe.Right,style:{background:"transparent",border:"none"}})]})}function vw(e){return e==="active"?"live":e==="done"?"done":"err"}function UL({state:e}){return d.jsx("span",{className:`state-pill state-${e}`,children:vw(e)})}function Au(e){return e.message?e.message:e.kind==="permission"?"Needs your permission":"Waiting for your input"}function WL(e){return e.kind==="permission"?Au(e):"Your turn"}function HL({waiting:e,now:t}){const n=e.kind==="permission",s=Au(e);return d.jsxs("div",{className:n?"waiting-row permission":"waiting-row idle",title:`${s}
68
+ Blocked for ${vu(e.since,void 0,t)} — the answer goes in the terminal, not here.`,children:[n?d.jsx("span",{className:"ap-pulse","aria-hidden":!0}):d.jsx("span",{className:"waiting-dot","aria-hidden":!0}),d.jsx("span",{className:"waiting-said",children:WL(e)}),d.jsx("b",{children:vu(e.since,void 0,t)})]})}function GL({tools:e,now:t}){const a=new Array(24).fill(0);let l=0;for(const y of e){const w=t-y.startedAt;if(w<0||w>=6e4)continue;const S=23-Math.floor(w/2500);S>=0&&S<24&&(a[S]+=1,l+=1)}const u=Math.max(1,...a),h=132,p=14,f=h/24,g=u/(2500/1e3);return d.jsxs("div",{className:"tool-spark-row",title:`${l} tool calls in last 60s · peak ${g.toFixed(1)}/s`,children:[d.jsx("svg",{className:"tool-spark",width:h,height:p,viewBox:`0 0 ${h} ${p}`,"aria-hidden":!0,children:a.map((y,w)=>{const S=y===0?1.5:Math.max(1.5,y/u*p),b=w===23&&y>0,k=`tool-spark-bar${y>0?" active":""}${b?" latest":""}`;return d.jsx("rect",{x:w*f+.4,y:p-S,width:Math.max(.5,f-1),height:S,rx:.8,className:k},w)})}),d.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function Jb(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function VL({tool:e,onClose:t}){const n=kn(t),s=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return d.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:d.jsxs("div",{ref:n,className:"modal",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[d.jsxs("header",{className:"modal-head",children:[d.jsxs("div",{className:"modal-title",children:[d.jsx("span",{className:`status-dot ${s}`,"aria-hidden":!0}),d.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),d.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),d.jsxs("div",{className:"modal-actions",children:[d.jsx("span",{className:"modal-dur",children:eT(e,"in-flight…")}),d.jsx("button",{className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),d.jsxs("section",{className:"modal-body",children:[e.trimmed&&d.jsx("div",{className:"modal-section",children:d.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),d.jsxs("div",{className:"modal-section",children:[d.jsx("h4",{children:"Input"}),d.jsx("pre",{children:Jb(e.input??e.inputPreview)})]}),d.jsxs("div",{className:"modal-section",children:[d.jsxs("h4",{children:["Response ",s==="err"&&d.jsx("span",{className:"err-tag",children:"error"})]}),d.jsx("pre",{children:e.endedAt==null?"(waiting…)":Jb(e.response??e.errorPreview)})]})]})]})})}const Hc=18,e1=26,YL=12;function KL(e){return XL(e.nodeInternals.values())}function XL(e){const t=new Map;for(const o of e){if(o.type!=="agent")continue;const a=o.data;if(!(a!=null&&a.sessionId)||a.exitAt!=null||o.width==null||o.height==null)continue;const l=o.position.x,u=o.position.y,h=l+o.width,p=u+o.height,f=t.get(a.sessionId);f?(f.minX=Math.min(f.minX,l),f.minY=Math.min(f.minY,u),f.maxX=Math.max(f.maxX,h),f.maxY=Math.max(f.maxY,p),a.kind==="root"&&(f.label=n1(a)??f.label),a.kind==="root"&&(f.name=r1(a))):t.set(a.sessionId,{minX:l,minY:u,maxX:h,maxY:p,label:n1(a)??a.sessionId,name:r1(a)})}const n=new Map;for(const o of t.values())n.set(o.label,(n.get(o.label)??0)+1);const s=[];for(const[o,a]of t){const l=(n.get(a.label)??0)>1;s.push({sessionId:o,...e3(a.label,a.name,o,l),x:a.minX-Hc,y:a.minY-Hc-e1,w:a.maxX-a.minX+Hc*2,h:a.maxY-a.minY+Hc*2+e1})}return s}const Iy=" · ",QL=32,ZL=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function t1(e){return ZL.test(e)?2:1}function JL(e,t=QL){const n=[...e];let s=0;for(const l of n)s+=t1(l);if(s<=t)return e;const o=[];let a=0;for(const l of n){const u=t1(l);if(a+u>t-1)break;o.push(l),a+=u}for(;o.length&&/[\s\-_.:/]/.test(o[o.length-1]);)o.pop();return`${o.join("")}…`}function e3(e,t,n,s){const o=(t==null?void 0:t.trim())??"",a=s?t3(n):void 0,l=[e,o||void 0,a].filter(Boolean);return{label:e,name:o?JL(o):void 0,shortId:a,fullLabel:l.join(Iy)}}function t3(e){const t=e.match(/[a-zA-Z0-9]{4}/);return t?t[0]:e.slice(0,4)}function n1(e){if(e.kind==="root")return e.label}function r1(e){if(e.kind==="root")return tT(e.sessionName,e.sessionTitle).face}function n3(){const{x:e,y:t,zoom:n}=DC(),s=hl(),o=rt(KL,r3);if(o.length<=1)return null;const a=u=>{try{const h=s.getNodes().filter(p=>{const f=p.data;return(f==null?void 0:f.sessionId)===u});if(h.length===0)return;s.fitView({padding:.3,duration:500,nodes:h})}catch{}},l={transform:`translate(${e}px, ${t}px) scale(${n})`};return d.jsx("div",{className:"session-clusters",style:l,children:o.map(u=>{const h=hw(u.sessionId),p={position:"absolute",left:u.x,top:u.y,width:u.w,height:u.h,"--session-hue":h},f={position:"absolute",left:u.x+16,top:u.y-YL,transform:`scale(${Math.min(1,n)/(n||1)})`,transformOrigin:"left top","--session-hue":h};return d.jsxs(ue.Fragment,{children:[d.jsx("div",{className:"cluster-card",style:p,"aria-hidden":!0}),d.jsxs("button",{type:"button",className:"cluster-label",style:f,title:`Fit view to ${u.fullLabel}
69
+ drag the wrapper to move the whole session`,onClick:()=>a(u.sessionId),children:[u.label,u.name?d.jsxs(d.Fragment,{children:[Iy,d.jsx("span",{className:"cluster-label-name",children:u.name})]}):null,u.shortId?Iy+u.shortId:null]})]},u.sessionId)})})}function r3(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const s=e[n],o=t[n];if(s.sessionId!==o.sessionId||s.label!==o.label||s.name!==o.name||s.shortId!==o.shortId||s.fullLabel!==o.fullLabel||s.x!==o.x||s.y!==o.y||s.w!==o.w||s.h!==o.h)return!1}return!0}function s3({data:e}){return d.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const vl={exec:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},shell:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},exec_command:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},shell_command:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},write_stdin:{category:"shell",emoji:"💻",label:"stdin",shell:!0},wait:{category:"shell",emoji:"⏳",label:"wait",shell:!0},apply_patch:{category:"file",emoji:"🩹",label:"Edit"},update_plan:{category:"task",emoji:"📋",label:"Plan"},run:{category:"web",emoji:"🌐",label:"Web"}},i3=Object.fromEntries(Object.entries(vl).map(([e,t])=>[e,t.category])),o3=Object.fromEntries(Object.entries(vl).map(([e,t])=>[e,t.emoji])),a3=Object.fromEntries(Object.entries(vl).map(([e,t])=>[e,t.label])),l3=new Set(Object.keys(vl)),c3=new Set(Object.entries(vl).filter(([,e])=>e.shell).map(([e])=>e)),s1={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",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",...i3};function iT(e){return e.startsWith("mcp__")?"mcp":Object.hasOwn(s1,e)?s1[e]:"other"}const u3=/\btools\.exec_command\s*\(\s*\{[^{}]*?\bcmd\s*:\s*(["'`])((?:\\.|(?!\1)[^\\])*)\1/,d3=/\btools\.([A-Za-z_$][\w$]*)\s*\(/;function f3(e){if(typeof e!="string"||!e)return null;const t=u3.exec(e);if(t){const s=h3(t[2]);if(s.trim())return s}const n=d3.exec(e);return n?n[1]:null}function h3(e){return e.replace(/\\(["'`\\nrt])/g,(t,n)=>n==="n"?`
70
+ `:n==="r"?"\r":n==="t"?" ":n)}const oT=600,p3=4,m3=36,Oy=16,g3=60,v3=6,i1=220,o1=96,y3=28,a1={Read:"📖",Write:"💾",Edit:"✏️",MultiEdit:"🔧",Glob:"🗺️",Grep:"🔎",Bash:"⚡",PowerShell:"💻",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:"📡",...o3};function l1(e){return e.startsWith("mcp__")?"🔌":Object.hasOwn(a1,e)?a1[e]:"✨"}const c1={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 aT(e){if(!e)return null;let t=e.trim();if(!t)return null;const n=t.match(/^(?:bash|sh|zsh|fish|powershell|pwsh)(?:\.exe)?\s+(?:-c|-Command|-NoProfile|-NonInteractive|\s)+["']([^"']+)["']/i);if(n)return aT(n[1]);for(;;){const a=t.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!a)break;t=t.slice(a[0].length)}t=t.replace(/^sudo(?:\s+-\S+)*\s+/,""),t=t.replace(/^(?:time|nohup|xargs)\s+/,"");const s=t.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 w3(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const t=e;if(typeof t.script=="string"){const n=f3(t.script);if(n)return n}if(typeof t.cmd=="string")return t.cmd;if(typeof t.command=="string")return t.command;if(Array.isArray(t.command)&&t.command.every(n=>typeof n=="string")){const n=t.command;if(/powershell|cmd|bash|sh(\.exe)?$/i.test(n[0]??"")){const s=n.findIndex(o=>/^(-Command|-c)$/i.test(o));if(s>=0&&s+1<n.length)return n[s+1]}return n.join(" ")}return typeof t.script=="string"?t.script:null}const x3=new Set(["Bash","PowerShell",...c3]),b3=l3;function _3(e,t){return b3.has(e)||e.startsWith("mcp__")?Math.max(o1,34+t.length*7.5):o1}function k3(e,t){if(!x3.has(e))return null;const n=w3(t);if(!n)return null;const s=aT(n);return s?{emoji:Object.hasOwn(c1,s)?c1[s]:"⚙️",label:s,category:"shell",detail:n}:null}const S3=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),u1={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:"🗄️"},d1={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 N3(e){const n=e.replace(/\\/g,"/").replace(/\/+$/,""),s=n.lastIndexOf("/");return s>=0?n.slice(s+1):n}function E3(e){const t=e.toLowerCase();if(Object.hasOwn(d1,t))return d1[t];if(t.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(t))return"🧪";const n=t.lastIndexOf(".");if(n>0&&n<t.length-1){const s=t.slice(n+1);if(Object.hasOwn(u1,s))return u1[s]}return"📄"}function j3(e,t){if(!t||typeof t!="object")return null;const n=t;if(e==="apply_patch"&&typeof n.patch=="string"){const s=n.patch.match(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/m);return s?s[1].trim():null}return typeof n.file_path=="string"?n.file_path:typeof n.notebook_path=="string"?n.notebook_path:typeof n.path=="string"?n.path:e==="Glob"&&typeof n.pattern=="string"?n.pattern:null}function C3(e,t){if(!S3.has(e))return null;const n=j3(e,t);if(!n)return null;const s=N3(n);return s?{emoji:e==="LS"?"📂":E3(s),label:s,category:"file",detail:n}:null}const f1={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 yw(e){if(!e.startsWith("mcp__"))return null;const t=e.slice(5),n=t.indexOf("__");return n<=0?{server:t,method:""}:{server:t.slice(0,n),method:t.slice(n+2)}}function T3(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return Math.abs(t)%360}function lT(e){const t=e.toLowerCase();return Object.hasOwn(f1,t)?f1[t]:void 0}function R3(e,t){const n=yw(e);if(!n)return null;const{server:s,method:o}=n;if(!o)return null;const a=lT(s);return{emoji:(a==null?void 0:a.emoji)??"🔌",label:o,category:"mcp",detail:a?`${a.name} · ${o}`:`${s} · ${o}`}}function A3(e,t){return k3(e,t)??C3(e,t)??R3(e)}const h1=a3;function cT(e){const t=yw(e);if(t){const s=lT(t.server);return s?{emoji:s.emoji,label:s.name}:{emoji:"🔌",label:t.server,hue:T3(t.server)}}const n=Object.hasOwn(h1,e)?h1[e]:"";return n?{emoji:l1(e),label:n}:{emoji:l1(e),label:e}}function M3(e){let t=null,n="";for(const s of e){const o=yw(s);if(o){if(!o.server)return null;if(t===null)t=o.server,n=s;else if(o.server!==t)return null}}return t===null?null:cT(n)}function I3(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function O3(e,t,n){if(n==null)return 1;const s=t-n;return s<0?1:Math.max(0,1-s/oT)}function P3(e,t){const n=[],s=new Set;for(let o=e.length-1;o>=0&&n.length<t;o--){const a=e[o];s.has(a.id)||(s.add(a.id),n.push(a))}return n.reverse()}function $3(e,t,n,s,o,a){const l=[];for(const u of e.values()){if(!t.has(u.id)||u.exitAt!=null&&a-u.exitAt>oT)continue;const h=s.get(u.id)??n.get(u.id);if(!h)continue;const p=P3(u.tools,p3);if(p.length===0)continue;const f=u.exitAt??null,g=o.get(u.id),y=Math.max((g==null?void 0:g.width)??i1,i1),w=(g==null?void 0:g.height)??130,S=h.x,b=h.y,_=S+y,k=b+w/2;p.forEach((N,j)=>{const T=j*m3,M=S+y+g3,P=b+v3+T,I=O3(N,a,f),F=N.inputPreview??"",O=I3(N),A=I<.999,D=cT(N.name);l.push({id:`${u.id}::${N.id}`,toolId:N.id,agentId:u.id,toolName:N.name,name:D.label,emoji:D.emoji,status:O,category:iT(N.name),mcpHue:D.hue,inputPreview:F,fade:I,fading:A,worldX:M,worldY:P,anchorX:_,anchorY:k,spawnDx:_-M,spawnDy:k-(P+Oy)});const H=A3(N.name,N.input);if(H){const K=_3(N.name,D.label),C=M+K+y3,X=P,B=M+K,ne=P+Oy;l.push({id:`sub:${u.id}::${N.id}`,toolId:N.id,agentId:u.id,toolName:N.name,name:H.label,emoji:H.emoji,isSub:!0,status:O,category:H.category,inputPreview:H.detail??F,fade:I,fading:A,worldX:C,worldY:X,anchorX:B,anchorY:ne,spawnDx:B-C,spawnDy:0})}})}return l}function L3({agents:e,visibleAgentIds:t,positions:n,pinned:s,measured:o,spotlight:a,hiddenCategories:l,now:u,onOpenTool:h}){const p=$3(e,t,n,s,o,u),f=l&&l.size>0?p.filter(g=>!l.has(g.category)):p;return d.jsx(q3,{bursts:f,spotlight:a,onOpenTool:h})}function q3({bursts:e,spotlight:t,onOpenTool:n}){const{x:s,y:o,zoom:a}=DC();return d.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[d.jsx("svg",{className:"tool-bursts-svg",children:e.map(l=>{const u=l.anchorX*a+s,h=l.anchorY*a+o,p=(l.worldX+6)*a+s,f=(l.worldY+Oy)*a+o,g=u+(p-u)*.55,y=t!=null&&!t.has(l.agentId),w=l.fade*(y?.14:1);return d.jsx("path",{d:`M ${u} ${h} Q ${g} ${h}, ${p} ${f}`,className:`tool-conn status-${l.status}${l.fading?" fading":""}`,opacity:w},`l:${l.id}`)})}),e.map(l=>{const u=l.worldX*a+s,h=l.worldY*a+o,p={left:`${u}px`,top:`${h}px`,transform:`scale(${a})`,transformOrigin:"left top","--spawn-dx":`${l.spawnDx}px`,"--spawn-dy":`${l.spawnDy}px`},f=l.isSub?`${l.toolName} · ${l.name}`:l.toolName,g=l.inputPreview?`${f} · ${l.inputPreview}`:f,y=n!=null,w=l.mcpHue!=null?{"--mcp-hue":l.mcpHue}:{},b=t!=null&&!t.has(l.agentId)?" dim":"";return d.jsx("div",{className:"tool-burst-wrap",style:p,children:d.jsxs("div",{className:`tool-burst cat-${l.category}${l.mcpHue!=null?" mcp-hue":""} status-${l.status}${l.fading?" fading":""}${y?" clickable":""}${l.isSub?" sub":""}${b}`,style:w,title:g,onClick:y?()=>n(l.toolId):void 0,children:[d.jsx("span",{className:"tb-emoji",children:l.emoji}),d.jsx("span",{className:"tb-name",children:l.name}),l.status==="inflight"&&d.jsx("span",{className:"tb-spin"}),l.status==="done"&&d.jsx("span",{className:"tb-mark done",children:"✓"}),l.status==="err"&&d.jsx("span",{className:"tb-mark err",children:"×"})]})},l.id)})]})}function uT(e){const t={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};let n=0,s=0,o=0,a=0;for(const l of e){const u=bn(l);t.input+=u.input,t.output+=u.output,t.cacheRead+=u.cacheRead,t.cacheWrite+=u.cacheWrite,t.total+=u.total,n+=l.usage.inputTokens,s+=l.usage.outputTokens,o+=l.usage.cacheReadTokens,a+=l.usage.cacheCreateTokens}return{cost:t,inputTokens:n,outputTokens:s,cacheReadTokens:o,cacheCreateTokens:a,sum:n+s}}const D3="spend on this board",F3="on this board",z3="board tokens",B3="board cost",yu=`Everything on the board right now, and only that.
71
71
  Finished sessions are evicted from the canvas a couple of minutes after they end, and their tokens and dollars leave with them — so this figure falls on its own.
72
- Press H for the totals ccusage reads off the logs on disk, which do not forget.`,dT="session spend";function ww({cost:e,size:t="md"}){const n=e.total;if(n<=0)return null;const s=(a,l,u)=>{if(a<=0)return null;const h=a/n*100;return d.jsx("span",{className:`cb-seg ${l}`,style:{width:`${h}%`},title:`${u}: ${Ve(a)} (${h.toFixed(0)}%)`},l)},o=t==="lg";return d.jsxs("div",{className:o?"cost-bar cost-bar-lg":"cost-bar",role:"img","aria-label":"Cost breakdown",children:[s(e.input,"cb-input","input"),s(e.output,"cb-output","output"),s(e.cacheRead,"cb-cache-r","cache read"),s(e.cacheWrite,"cb-cache-w","cache write")]})}function W3({state:e,sessionId:t,onClose:n}){const s=E.useMemo(()=>H3(e,t),[e,t]),o=E.useRef(null),a=kn(n,{focusRef:o});return s?d.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:d.jsxs("div",{ref:a,className:"modal session-summary",onClick:l=>l.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{className:"modal-title",children:[d.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),d.jsx("span",{id:"ss-title",className:"modal-tool-name",title:s.cwd??s.sessionId,children:s.label}),d.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),d.jsxs("div",{className:"modal-actions",children:[d.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.durationLabel}),d.jsx("button",{type:"button",ref:o,className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),d.jsxs("div",{className:"modal-body",children:[d.jsxs("section",{className:"ss-hero",children:[d.jsxs("div",{className:"ss-hero-left",children:[d.jsx("div",{className:"ss-cost-label",children:dT}),d.jsx("div",{className:"ss-cost",children:Ve(s.cost.total)}),s.modelChips.length>0&&d.jsx("div",{className:"ss-models",children:s.modelChips.map(l=>d.jsx("span",{className:"model-chip",title:l,children:xi(l)},l))})]}),d.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&d.jsxs(d.Fragment,{children:[d.jsx(ww,{cost:s.cost,size:"lg"}),d.jsxs("div",{className:"ss-cost-legend",children:[d.jsxs("span",{className:"ssl ssl-in",children:["input ",d.jsx("b",{children:Ve(s.cost.input)})]}),d.jsxs("span",{className:"ssl ssl-out",children:["output ",d.jsx("b",{children:Ve(s.cost.output)})]}),d.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",d.jsx("b",{children:Ve(s.cost.cacheRead)})]}),d.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",d.jsx("b",{children:Ve(s.cost.cacheWrite)})]})]})]})})]}),d.jsxs("section",{className:"ss-stats",children:[d.jsx(_o,{label:"agents",value:s.agentCount}),d.jsx(_o,{label:"subagents",value:s.subagentCount}),d.jsx(_o,{label:"tool calls",value:s.toolCount}),d.jsx(_o,{label:"prompts",value:s.promptCount}),d.jsx(_o,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&d.jsx(_o,{label:"errors",value:s.errCount,tone:"err"})]}),s.topTools.length>0&&d.jsxs("section",{className:"modal-section",children:[d.jsx("h4",{children:"Most-used tools"}),d.jsx("div",{className:"ss-top-tools",children:s.topTools.map(([l,u])=>d.jsxs("div",{className:"ss-tt",children:[d.jsx("span",{className:"ss-tt-name",children:l}),d.jsx("span",{className:"ss-tt-bar",children:d.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${u/s.topTools[0][1]*100}%`}})}),d.jsx("span",{className:"ss-tt-count",children:u})]},l))})]}),s.firstPrompt&&d.jsxs("section",{className:"modal-section",children:[d.jsx("h4",{children:"Opening prompt"}),d.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]})]})}):null}function _o({label:e,value:t,tone:n}){return d.jsxs("div",{className:`ss-stat${n?` tone-${n}`:""}`,children:[d.jsx("div",{className:"ss-stat-value",children:t}),d.jsx("div",{className:"ss-stat-label",children:e})]})}function H3(e,t){const n=e.agents.get(t);if(!n)return null;const s=[];for(const j of e.agents.values())j.sessionId===t&&s.push(j);if(s.length===0)return null;const o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},a=new Set,l=new Map;let u=0,h=0,p=0,f=0,g=0,y,w=1/0,S=0;for(const j of s){const T=bn(j);o.input+=T.input,o.output+=T.output,o.cacheRead+=T.cacheRead,o.cacheWrite+=T.cacheWrite,o.total+=T.total;for(const M of ZC(j))a.add(M);j.model&&a.add(j.model),j.kind==="subagent"&&g++,h+=j.prompts.length,!y&&j.prompts.length>0&&(y=j.prompts[0].text),p+=j.usage.inputTokens+j.usage.outputTokens,u+=j.toolCount,w=Math.min(w,j.startedAt),S=Math.max(S,j.endedAt??Date.now());for(const M of j.tools)l.set(M.name,(l.get(M.name)??0)+1),M.ok===!1&&f++}const b=Math.max(0,S-w),_=Math.floor(b/1e3),k=_<60?`${_}s`:_<3600?`${Math.floor(_/60)}m ${String(_%60).padStart(2,"0")}s`:`${Math.floor(_/3600)}h ${Math.floor(_%3600/60)}m`,N=Array.from(l.entries()).sort((j,T)=>T[1]-j[1]).slice(0,5);return{sessionId:t,label:n.label||n.cwdBasename||"session",cwd:n.cwd,durationLabel:k,cost:o,modelChips:Array.from(a),agentCount:s.length,subagentCount:g,toolCount:u,promptCount:h,tokensSum:p,errCount:f,topTools:N,firstPrompt:y}}function xw(e){return(e==null?void 0:e.kind)==="permission"}function G3(e){const t=[];for(const n of e)n.kind==="root"&&xw(n.waiting)&&t.push({id:n.id,label:n.label,waiting:n.waiting});return t.sort((n,s)=>n.waiting.since-s.waiting.since)}function V3(e){const t=new Set;for(const n of e)n.state==="active"&&t.add(n.sessionId);return t.size}function p1(e){return e.waiting?xw(e.waiting)?0:1:e.state==="active"?2:3}function Y3(e,t){const n=[];for(const s of e.agents.values()){if(s.kind!=="root")continue;let o=s.toolCount,a=bn(s).total,l=s.endedAt??s.startedAt;for(const u of e.agents.values()){if(u.sessionId!==s.sessionId||u.kind==="root")continue;o+=u.toolCount,a+=bn(u).total;const h=u.endedAt??u.startedAt;h>l&&(l=h)}n.push({sessionId:s.sessionId,label:s.label||s.cwdBasename||"session",cwdBasename:s.cwdBasename,state:s.state,waiting:s.waiting,modelId:s.model,toolCount:o,cost:a,startedAt:s.startedAt,lastActivity:l})}return n.sort((s,o)=>{const a=p1(s),l=p1(o);return a!==l?a-l:s.waiting&&o.waiting?s.waiting.since-o.waiting.since:o.lastActivity-s.lastActivity}),n}function m1(e,t,n){const s=(t??n)-e;if(s<1e3)return"<1s";const o=Math.floor(s/1e3);if(o<60)return`${o}s`;const a=Math.floor(o/60);return a<60?`${a}m`:`${Math.floor(a/60)}h ${a%60}m`}function K3({state:e,now:t,selectedIds:n,onSelect:s,onClose:o}){const a=E.useMemo(()=>Y3(e),[e,e.revision,t]),l=a.filter(h=>h.state==="active").length,u=a.filter(h=>xw(h.waiting)).length;return d.jsxs("aside",{className:"session-list",id:"session-list","aria-label":"Sessions",children:[d.jsxs("div",{className:"sl-header",children:[d.jsxs("h2",{children:["Sessions ",d.jsx("span",{className:"sl-count",children:a.length})]}),u>0&&d.jsxs("span",{className:"sl-waiting-count",children:[u," waiting"]}),l>0&&d.jsxs("span",{className:"sl-live-count",children:[l," live"]}),d.jsx("button",{className:"glyph-btn sl-close",onClick:o,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),d.jsxs("div",{className:"sl-rows",children:[a.length===0&&d.jsx("div",{className:"sl-empty",children:"No sessions yet."}),a.map(h=>{const p=n.has(h.sessionId);return d.jsxs("button",{type:"button",className:`sl-row state-${h.state}${p?" selected":""}`,onClick:()=>s(h.sessionId),title:`Focus ${h.label}`,children:[d.jsx("span",{className:`sl-dot state-${h.state}`,"aria-hidden":!0}),d.jsx("span",{className:"vis-hidden",children:vw(h.state)}),d.jsxs("div",{className:"sl-row-body",children:[d.jsxs("div",{className:"sl-row-head",children:[d.jsx("span",{className:"sl-label",children:h.label}),h.modelId&&d.jsx("span",{className:"model-chip",title:h.modelId,children:xi(h.modelId)})]}),d.jsxs("div",{className:"sl-row-meta",children:[d.jsxs("span",{title:"tool calls",children:[d.jsx("b",{children:h.toolCount})," tools"]}),h.cost>0&&d.jsx("span",{className:"sl-cost",title:dT,children:d.jsx("b",{children:Ve(h.cost)})}),h.waiting?d.jsxs("span",{className:"sl-waiting",title:`${Au(h.waiting)}
73
- Blocked since ${new Date(h.waiting.since).toLocaleTimeString()} · started ${new Date(h.startedAt).toLocaleString()}`,children:["waiting ",m1(h.waiting.since,void 0,t)]}):d.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(h.startedAt).toLocaleString()}`,children:m1(h.startedAt,h.state==="active"?void 0:h.lastActivity,t)})]})]})]},h.sessionId)})]})]})}const zt="ccdeck";function fT(e){const t=Math.max(0,e);return t<60?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function Py(e){return fT(Math.floor(e/1e3))}function hT(e,t){const n=e-t;if(n<=0)return null;const s=Math.floor(n/86400),o=Math.floor(n%86400/3600),a=Math.floor(n%3600/60);return s>0?`${s}d ${o}h`:o>0?`${o}h ${a}m`:`${a}m`}function X3(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Q3(e,t,n){const s=new Date(e),o=Py(t-e);return{label:X3(s,new Date(t))?o:`${o} · ${s.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:s.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function pT(e,t){return{disabled:e!=null&&e!==t,busy:e===t}}function mT(e){return e==null}const $y="self";function ir(e,t=!1){const n=pT(e?$y:null,$y);return{disabled:t||n.disabled,"aria-busy":n.busy}}function or(e){return mT(e?$y:null)}function Z3(e){return[...e==null?[]:[`#ap-more-${e}`],".accounts-panel .ap-refresh"]}function J3(e){return e==null||e==="BODY"||e==="HTML"}function g1(e,t){if(!e)return null;const n=t-Math.floor(e/1e3);return n<10?"just now":n<60?`${n}s ago`:n<3600?`${Math.floor(n/60)}m ago`:`${Math.floor(n/3600)}h ago`}function e4(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"}const Wf="__unknown__";function t4(e,t,n,s){const o=Math.max(0,t-s),a=Math.max(0,n-o);if(a<120)return null;const l=Math.min(100,a/n*100),u=e-l;if(Math.abs(u)<3)return{label:"on pace",color:"var(--ok)",expectedPct:l,isDeficit:!1};if(u>0){const h=100-e,p=a>0?e/a:0,f=p>0?h/p:1/0,g={label:`${Math.round(u)}% ahead`,color:"var(--warn)",expectedPct:l,isDeficit:!0};if(f<o&&f<86400){const y=Math.floor(f/3600),w=Math.floor(f%3600/60);g.runsOutIn=y>0?`${y}h ${w}m`:`${w}m`}return g}return{label:`${Math.round(-u)}% reserve`,color:"var(--ok)",expectedPct:l,isDeficit:!1}}function ui({pct:e,label:t,reset:n,resetAt:s,windowSec:o,limitReached:a,nowSec:l}){const u=Math.min(100,Math.max(0,e)),p=a||u>=90?"var(--err)":u>=70?"var(--warn)":"var(--accent)",f=u===0?"< 1%":`${u}%`,g=u===0?2:u,y=s?hT(s,l):null,w=s&&o?t4(u,s,o,l):null;return d.jsxs("div",{className:"qb-row",children:[d.jsxs("div",{className:"qb-meta",children:[d.jsxs("span",{className:"qb-label",children:[t,a&&d.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),d.jsx("span",{className:"qb-pct",style:{color:p},children:f})]}),d.jsxs("div",{className:"qb-track",children:[d.jsx("div",{className:"qb-fill",style:{width:`${g}%`,background:p,opacity:u===0?.4:1}}),w&&d.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`})]}),d.jsxs("div",{className:"qb-reset-row",children:[y?d.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):n?d.jsxs("span",{className:"qb-reset",children:["resets ",n]}):null,w&&d.jsx("span",{className:"qb-pace",style:{color:w.color},children:w.runsOutIn?`runs out in ${w.runsOutIn}`:w.label})]})]})}const n4=6e4;function r4(e){const[t,n]=E.useState(null),[s,o]=E.useState(!1),a=E.useRef(null),l=E.useRef(!1),u=async(p=!1)=>{if(!(p&&!or(l.current))){p&&(l.current=!0,o(!0));try{const g=await fetch(p?"/api/quota?refresh=1":"/api/quota");g.ok&&n(await g.json())}catch{}finally{p&&(l.current=!1,o(!1))}}};return E.useEffect(()=>{if(e)return u(!0),a.current=window.setInterval(()=>u(!1),n4),()=>{a.current!=null&&window.clearInterval(a.current)}},[e]),{quota:t,loading:s,refresh:()=>{e&&u(!0)}}}function s4(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.";case"untrusted_base_url":return"chatgpt_base_url in ~/.codex/config.toml is not an https OpenAI host, so the token was not sent.";default:return"ChatGPT API unreachable — click ↻ to retry."}}const gT=6e4;function i4(e){const[t,n]=E.useState(null),[s,o]=E.useState(!1),a=E.useRef(null),l=E.useRef(!1),u=async(p=!1)=>{if(!(p&&!or(l.current))){p&&(l.current=!0,o(!0));try{const g=await fetch(p?"/api/codex-quota?refresh=1":"/api/codex-quota");g.ok&&n(await g.json())}catch{}finally{p&&(l.current=!1,o(!1))}}};return E.useEffect(()=>{if(e)return u(!0),a.current=window.setInterval(()=>u(!1),gT),()=>{a.current!=null&&window.clearInterval(a.current)}},[e]),{data:t,loading:s,refresh:()=>{e&&u(!0)}}}function o4(e){const[t,n]=E.useState(null),s=E.useRef(null),o=async()=>{try{const a=await fetch("/api/codex-usage");a.ok&&n(await a.json())}catch{}};return E.useEffect(()=>{if(e)return o(),s.current=window.setInterval(o,gT),()=>{s.current!=null&&window.clearInterval(s.current)}},[e]),{data:t}}function a4({state:e,now:t,providers:n,onClose:s}){var H,K;const{quota:o,loading:a,refresh:l}=r4(n.claude),{data:u,loading:h,refresh:p}=i4(n.codex),{data:f}=o4(n.codex),[g,y]=E.useState(()=>Math.floor(Date.now()/1e3));E.useEffect(()=>{const C=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(C)},[]);const{byModel:w,totalCost:S,totalTokens:b,burnRate:_}=E.useMemo(()=>{const C=new Map;for(const Q of e.agents.values())for(const $ of gl(Q)){const G=$.model??Wf,Y=pw($.usage,$.model),L=C.get(G);L?(L.inputTokens+=$.usage.inputTokens,L.outputTokens+=$.usage.outputTokens,L.cacheReadTokens+=$.usage.cacheReadTokens,L.cacheCreateTokens+=$.usage.cacheCreateTokens,L.cost.total+=Y.total,L.cost.input+=Y.input,L.cost.output+=Y.output,L.cost.cacheRead+=Y.cacheRead,L.cost.cacheWrite+=Y.cacheWrite,L.agentCount++):C.set(G,{model:G,inputTokens:$.usage.inputTokens,outputTokens:$.usage.outputTokens,cacheReadTokens:$.usage.cacheReadTokens,cacheCreateTokens:$.usage.cacheCreateTokens,cost:{...Y},agentCount:1,priced:Uo($.model)!=null})}const X=Array.from(C.values()).sort((Q,$)=>$.cost.total-Q.cost.total||$.inputTokens+$.outputTokens-(Q.inputTokens+Q.outputTokens));let B=0,ne=0;for(const Q of e.agents.values()){if(Q.state!=="active")continue;const $=bn(Q);B+=$.total,ne=Math.max(ne,((Q.endedAt??t)-Q.startedAt)/1e3)}const J=ne>0?gu(B,ne):null,W=uT(e.agents.values());return{byModel:X,totalCost:W.cost,totalTokens:W,burnRate:J}},[e,e.revision,t]),k=E.useMemo(()=>{const C=[];for(const X of e.agents.values()){if(X.kind!=="root")continue;let B=bn(X).total,ne=X.usage.inputTokens,J=X.usage.outputTokens,W=My(X);for(const Q of e.agents.values())Q.sessionId!==X.sessionId||Q.kind==="root"||(B+=bn(Q).total,ne+=Q.usage.inputTokens,J+=Q.usage.outputTokens,W+=My(Q));C.push({sessionId:X.sessionId,label:X.label||X.cwdBasename||"session",state:X.state,cost:B,inputTokens:ne,outputTokens:J,unpricedTokens:W})}return C.sort((X,B)=>B.cost-X.cost||B.inputTokens+B.outputTokens-(X.inputTokens+X.outputTokens)).slice(0,12)},[e,e.revision]),N=S.total>0,j=b.sum,T=w.filter(C=>C.cost.total>0||C.inputTokens+C.outputTokens>0),M=k.filter(C=>C.cost>0||C.inputTokens+C.outputTokens>0),P=T.some(C=>!C.priced),I=a||h,F=g1(o==null?void 0:o.fetchedAt,g),O=g1(u==null?void 0:u.fetchedAt,g),A=()=>{l(),p()},D=n.claude&&n.codex?"Refresh Claude + Codex quota":n.codex?"Refresh Codex quota":"Refresh Claude quota";return d.jsxs("aside",{className:"usage-panel",id:"usage-panel","aria-label":"Usage",children:[d.jsxs("div",{className:"up-header",children:[d.jsx("h2",{children:"Usage"}),_&&d.jsx("span",{className:"up-rate",children:_}),d.jsxs("div",{className:"up-header-right",children:[(n.claude||n.codex)&&d.jsx("button",{type:"button",className:"glyph-btn up-refresh-btn",onClick:A,...ir(I),"aria-label":D,title:D,children:I?"…":"↻"}),d.jsx("button",{type:"button",className:"glyph-btn up-close",onClick:s,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),n.claude&&d.jsxs("section",{className:"up-section up-quota-section",children:[d.jsxs("h3",{className:"up-section-title",children:["Claude quota",F&&!a&&d.jsx("span",{className:"up-section-age",title:e4(o==null?void 0:o.source),children:F})]}),o!=null&&o.ok?d.jsxs("div",{className:"up-quota-bars",children:[o.session5hPct!=null&&d.jsx(ui,{label:"5-hour window",pct:o.session5hPct,reset:o.session5hReset,resetAt:o.session5hResetAt,windowSec:o.session5hWindowSec,nowSec:g}),o.week7dPct!=null&&d.jsx(ui,{label:"7-day window",pct:o.week7dPct,reset:o.week7dReset,resetAt:o.week7dResetAt,windowSec:o.week7dWindowSec,nowSec:g}),o.weekSonnetPct!=null&&d.jsx(ui,{label:"Sonnet (7d)",pct:o.weekSonnetPct,nowSec:g}),o.weekOpusPct!=null&&d.jsx(ui,{label:"Opus (7d)",pct:o.weekOpusPct,nowSec:g})]}):(o==null?void 0:o.ok)===!1?d.jsxs("div",{className:"up-quota-na",children:[d.jsx("span",{children:"Quota unavailable."}),d.jsxs("span",{className:"up-quota-hint",children:["Run ",d.jsx("code",{children:"/usage"})," in a claude session, then click ↻"]})]}):d.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),n.codex&&d.jsxs("section",{className:"up-section up-quota-section",children:[d.jsxs("h3",{className:"up-section-title",children:["Codex quota",(u==null?void 0:u.ok)&&u.planLabel&&d.jsx("span",{className:"up-plan-badge",children:u.planLabel}),O&&!h&&d.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:O})]}),u!=null&&u.ok?d.jsxs("div",{className:"up-quota-bars",children:[(H=u.windows)==null?void 0:H.map(C=>d.jsx(ui,{label:C.label,pct:C.pct,reset:C.reset??void 0,resetAt:C.resetAt??void 0,windowSec:C.windowSec??void 0,limitReached:u.limitReached&&C.pct>=100,nowSec:g},C.id)),(K=u.extraWindows)==null?void 0:K.map(C=>d.jsx(ui,{label:C.label,pct:C.pct,reset:C.reset??void 0,resetAt:C.resetAt??void 0,windowSec:C.windowSec??void 0,nowSec:g},C.id)),u.creditLimit&&d.jsx(ui,{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:g}),u.creditsBalance&&!u.creditsUnlimited&&d.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",u.creditsBalance,u.overageReached&&" · overage limit reached"]}),u.creditsUnlimited&&d.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),u.resetCredits&&u.resetCredits.availableCount>0&&d.jsxs("div",{className:"up-quota-sub up-reset-credits",title:`Redeem in the Codex CLI or ChatGPT — ${zt} 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&&d.jsx("div",{className:"up-quota-sub",children:u.promo}),u.partial&&d.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?d.jsxs("div",{className:"up-quota-na",children:[d.jsx("span",{children:"Quota unavailable."}),d.jsx("span",{className:"up-quota-hint",children:s4(u.reason)})]}):d.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"}),(f==null?void 0:f.ok)&&f.window7d&&f.window7d.sessionCount>0&&d.jsxs("div",{className:"up-quota-sub",title:`Counted from the rollout files under CODEX_HOME — no network, no account${f.window5h?`
74
- last 5h: ${Pt(f.window5h.totalTokens)} tokens · ${f.window5h.sessionCount} session${f.window5h.sessionCount!==1?"s":""}`:""}`,children:[Pt(f.window7d.totalTokens)," tokens · ",f.window7d.sessionCount," session",f.window7d.sessionCount!==1?"s":""," (7d)"]})]}),j>0?d.jsxs(d.Fragment,{children:[N&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"up-total",title:yu,children:[d.jsx("span",{className:"up-total-value",children:Ve(S.total)}),d.jsx("span",{className:"up-total-label",children:F3})]}),d.jsx(ww,{cost:S})]}),d.jsxs("div",{className:"up-tokens-row",title:yu,children:[d.jsxs("span",{className:"up-tok",children:[d.jsx("span",{className:"up-k",children:"in"}),Pt(b.inputTokens)]}),d.jsxs("span",{className:"up-tok",children:[d.jsx("span",{className:"up-k",children:"out"}),Pt(b.outputTokens)]}),b.cacheReadTokens>0&&d.jsxs("span",{className:"up-tok",children:[d.jsx("span",{className:"up-k",children:"cache r"}),Pt(b.cacheReadTokens)]}),b.cacheCreateTokens>0&&d.jsxs("span",{className:"up-tok",children:[d.jsx("span",{className:"up-k",children:"cache c"}),Pt(b.cacheCreateTokens)]}),!N&&d.jsx("span",{className:"up-tok up-scope",children:z3})]}),T.length>0&&d.jsxs("section",{className:"up-section",children:[d.jsx("h3",{className:"up-section-title",children:"By model"}),d.jsxs("table",{className:"up-table",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Model"}),d.jsx("th",{children:"Tokens"}),d.jsx("th",{children:"Cost"})]})}),d.jsx("tbody",{children:T.map(C=>d.jsxs("tr",{children:[d.jsx("td",{className:"up-model-name",title:C.model===Wf?"no model reported yet":C.model,children:C.model===Wf?"unknown":xi(C.model)}),d.jsx("td",{className:"up-num",children:Pt(C.inputTokens+C.outputTokens)}),C.priced?d.jsx("td",{className:"up-num up-cost-val",children:Ve(C.cost.total)}):d.jsx("td",{className:"up-num up-unpriced",children:su})]},C.model))})]})]}),M.length>0&&d.jsxs("section",{className:"up-section",children:[d.jsx("h3",{className:"up-section-title",children:"By session"}),d.jsx("div",{className:"up-sessions",children:M.map(C=>d.jsxs("div",{className:"up-session-row",children:[d.jsx("span",{className:`sl-dot state-${C.state}`,"aria-hidden":!0}),d.jsx("span",{className:"vis-hidden",children:vw(C.state)}),d.jsx("span",{className:"up-session-label",children:C.label}),d.jsx("span",{className:"up-session-tokens",children:Pt(C.inputTokens+C.outputTokens)}),C.cost>0?d.jsxs("span",{className:"up-session-cost",title:C.unpricedTokens>0?`${Pt(C.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[Ve(C.cost),C.unpricedTokens>0?"+":""]}):d.jsx("span",{className:"up-session-cost up-unpriced",children:su})]},C.sessionId))})]}),P&&d.jsxs("div",{className:"up-hint",children:["“",su,"” means this build holds no published rate for that model — those tokens are counted above and their dollars are not."]})]}):d.jsxs("div",{className:"up-empty",children:["No usage data yet.",d.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const l4="1",v1="agent-dag.schema",c4=["agent-dag.layout","agent-dag.viewport"];function Mu(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function u4(e,t=l4){let n=null;try{n=e.getItem(v1)}catch{return[]}if(n===t)return[];const s=[];if(n!==null)for(const o of c4)try{e.getItem(o)!==null&&(e.removeItem(o),s.push(o))}catch{}try{e.setItem(v1,t)}catch{}return s}const gt={l:30,r:6,t:6,b:2},Iu=104,d4=64;function fi(e,t=100,n=Iu){const s=n-gt.t-gt.b;return gt.t+s*(1-Math.max(0,Math.min(t,e))/t)}function f4(e,t,n,s=100,o=Iu){if(!e.length)return"";const a=e[e.length-1].t-e[0].t,l=p=>{const f=t-gt.l-gt.r;return gt.l+(a>0?f*(p-e[0].t)/a:f/2)};let u="",h=null;for(const p of e){const f=h&&p.t-h.t<=n*2?"L":"M";u+=`${f}${l(p.t).toFixed(1)} ${fi(p.v,s,o).toFixed(1)}`,h=p}return u}function h4(e,t,n,s=100,o=Iu){if(e.length<2)return"";const a=o-gt.b,l=e[e.length-1].t-e[0].t,u=t-gt.l-gt.r,h=y=>gt.l+(l>0?u*(y-e[0].t)/l:u/2);let p="",f=[];const g=()=>{if(f.length>=2){let y=`M${h(f[0].t).toFixed(1)} ${a}`;for(const w of f)y+=`L${h(w.t).toFixed(1)} ${fi(w.v,s,o).toFixed(1)}`;p+=`${y}L${h(f[f.length-1].t).toFixed(1)} ${a}Z`}f=[]};for(const y of e)f.length&&y.t-f[f.length-1].t>n*2&&g(),f.push(y);return g(),p}function p4(e){return e.length?{now:e[e.length-1].v,peak:e.reduce((t,n)=>Math.max(t,n.v),e[0].v)}:{now:null,peak:null}}function m4(e,t,n){return n!=null&&e>=n?"hot":t!=null&&e>=t?"warn":""}function g4(e,t,n=s=>Xa(s)){const s=e.filter(l=>l.v>0);if(!e.length)return null;if(!s.length)return"never held back";const o=s.length*(t/6e4),a=s[s.length-1];return`held back for ${o===1?"1 minute":`${o} minutes`}, last at ${n(a.t)}`}function Xa(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function vT(e,t){const n=Math.max(0,Math.floor((t-e)/6e4));if(n<1)return"less than a minute";if(n<60)return`${n} minute${n===1?"":"s"}`;const s=Math.floor(n/60),o=n%60;return o?`${s}h ${o}m`:`${s}h`}function v4({group:e,title:t,onClose:n}){const s=kn(n),[o,a]=E.useState(null);E.useEffect(()=>{let p=!0;const f=async()=>{try{const y=await fetch(`/api/system/history?group=${e}`);if(!y.ok)return;const w=await y.json();p&&(w!=null&&w.ok)&&a(w)}catch{}};f();const g=window.setInterval(f,2e4);return()=>{p=!1,window.clearInterval(g)}},[e]);const l=(o==null?void 0:o.series)??[],[u,h]=E.useMemo(()=>{let p=1/0,f=0;for(const g of l)g.points.length&&(p=Math.min(p,g.points[0].t),f=Math.max(f,g.points[g.points.length-1].t));return[Number.isFinite(p)?Math.max(p,(o==null?void 0:o.sinceMs)??0):(o==null?void 0:o.sinceMs)??0,f]},[l,o==null?void 0:o.sinceMs]);return ew.createPortal(d.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:d.jsxs("div",{ref:s,className:"modal hist-modal",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"hist-modal-title",children:[d.jsxs("div",{className:"modal-head",children:[d.jsx("span",{className:"modal-title",id:"hist-modal-title",children:t}),o&&u>0&&d.jsxs("span",{className:"hist-since",children:["since ",Xa(u)," · ",vT(u,h||Date.now())]}),d.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),d.jsx("div",{className:"hist-body",children:o==null?d.jsx("p",{className:"hist-empty",children:"Reading…"}):l.length===0?d.jsx("p",{className:"hist-empty",children:"Nothing has been measured yet."}):l.map(p=>d.jsx(y4,{series:p,stepMs:o.stepMs},p.label))})]})}),document.body)}function y4({series:e,stepMs:t}){const n=E.useRef(null),[s,o]=E.useState(560),[a,l]=E.useState(null);E.useEffect(()=>{const I=n.current;if(!I||typeof ResizeObserver>"u")return;const F=new ResizeObserver(([O])=>o(Math.max(160,O.contentRect.width)));return F.observe(I),()=>F.disconnect()},[]);const{points:u,unit:h,warnAt:p,critAt:f,label:g,top:y,restsAtZero:w}=e,S=w?d4:Iu,{now:b,peak:_}=p4(u),k=h==="C"?"°C":h,N=g==="Throttling"?g4(u,t):null,j=a!=null?u[a]:null,T=u.length>1?u[u.length-1].t-u[0].t:0,M=I=>{const F=s-gt.l-gt.r;return gt.l+(T>0?F*(I-u[0].t)/T:F/2)},P=I=>{if(u.length<2)return;const F=I.currentTarget.getBoundingClientRect(),O=(I.clientX-F.left-gt.l)/Math.max(1,F.width-gt.l-gt.r),A=u[0].t+T*Math.max(0,Math.min(1,O));let D=0;for(let H=1;H<u.length;H++)Math.abs(u[H].t-A)<Math.abs(u[D].t-A)&&(D=H);l(D)};return d.jsxs("section",{className:"hist-series","aria-label":`${g} history`,children:[d.jsxs("div",{className:"hist-head",children:[d.jsx("span",{className:"hist-label",children:g}),d.jsxs("span",{className:"hist-stats",children:[b!=null&&d.jsxs(d.Fragment,{children:[d.jsx("b",{children:b}),d.jsxs("span",{children:[k," now"]})]}),_!=null&&d.jsxs(d.Fragment,{children:[d.jsx("b",{className:m4(_,p,f),children:_}),d.jsxs("span",{children:[k," peak"]})]})]})]}),d.jsx("div",{className:"hist-plot",ref:n,children:d.jsxs("svg",{className:"hist-chart",width:"100%",height:S,viewBox:`0 0 ${s} ${S}`,preserveAspectRatio:"none",role:"img","aria-label":b==null?`${g}: nothing measured yet`:`${g}: ${b}${k} now, peak ${_}${k}, over ${vT(u[0].t,u[u.length-1].t)}`,onPointerMove:P,onPointerLeave:()=>l(null),children:[[["warn",p],["hot",f]].map(([I,F])=>F==null||F>y?null:d.jsxs("g",{children:[d.jsx("line",{className:`hist-rule ${I}`,x1:gt.l,x2:s-gt.r,y1:fi(F,y,S),y2:fi(F,y,S)}),d.jsx("text",{className:`hist-rule-tag ${I}`,x:2,y:fi(F,y,S)+3,children:F})]},I)),d.jsx("line",{className:"hist-floor",x1:gt.l,x2:s-gt.r,y1:S-gt.b,y2:S-gt.b}),d.jsx("path",{className:"hist-area",d:h4(u,s,t,y,S)}),d.jsx("path",{className:"hist-line",d:f4(u,s,t,y,S)}),u.length===1&&d.jsx("circle",{className:"hist-dot",cx:M(u[0].t),cy:fi(u[0].v,y,S),r:3}),j&&d.jsxs("g",{children:[d.jsx("line",{className:"hist-cross",x1:M(j.t),x2:M(j.t),y1:gt.t,y2:S-gt.b}),d.jsx("circle",{className:"hist-dot",cx:M(j.t),cy:fi(j.v,y,S),r:3})]})]})}),d.jsx("div",{className:"hist-axis",children:j?d.jsxs("span",{className:"hist-at",children:[Xa(j.t)," — ",d.jsx("b",{children:j.v}),k]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{children:u.length?Xa(u[0].t):""}),d.jsx("span",{children:u.length?Xa(u[u.length-1].t):""})]})}),N&&d.jsx("div",{className:"hist-note",children:N})]})}function w4({procs:e,total:t,onClose:n}){const s=kn(n),[o,a]=E.useState(yT),l=Ly(e,o);return ew.createPortal(d.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:d.jsxs("div",{ref:s,className:"modal pl-modal",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"pl-modal-title",children:[d.jsxs("div",{className:"modal-head",children:[d.jsx("span",{className:"modal-title",id:"pl-modal-title",children:"Busiest processes"}),d.jsxs("span",{className:"pl-count",children:[l.length," of ",t," running"]}),d.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),d.jsx("div",{className:"pl-body",children:l.length===0?d.jsx("p",{className:"pl-empty",children:"Could not read the process list on this platform."}):d.jsxs("table",{className:"sd-procs pl-table",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx(Mo,{col:"cpu",label:"cpu",sort:o,onSort:a}),d.jsx(Mo,{col:"mem",label:"mem",sort:o,onSort:a}),d.jsx("th",{scope:"col",className:"pl-pid-h",children:"pid"}),d.jsx(Mo,{col:"name",label:"process",sort:o,onSort:a})]})}),d.jsx("tbody",{children:l.map(u=>d.jsxs("tr",{children:[d.jsx("td",{className:"sd-num",children:u.cpu==null?"—":u.cpu.toFixed(0)}),d.jsx("td",{className:"sd-num sd-dim",children:u.mem.toFixed(1)}),d.jsx("td",{className:"sd-num sd-dim pl-pid",children:u.pid}),d.jsx("td",{className:"pl-name",children:u.name})]},u.pid))})]})}),d.jsx("div",{className:"pl-foot",children:"The busiest by processor and by memory, refreshed every four seconds. Not every process on the machine."})]})}),document.body)}const x4=3e3,b4=4e3,Hf=20,za=36,ko=8,_4=8,yT={key:"cpu",dir:"desc",rank:"cpu"};function k4(e,t){return e.key===t?{...e,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:t==="name"?"asc":"desc",rank:t==="name"?e.rank:t}}function Ly(e,t){const n=t.dir==="asc"?1:-1,s=(o,a)=>{if(t.key==="name")return n*o.name.localeCompare(a.name,void 0,{sensitivity:"base"});const l=t.key==="cpu"?o.cpu:o.mem,u=t.key==="cpu"?a.cpu:a.mem;return l==null||u==null?l==null?u==null?0:1:-1:n*(l-u)};return[...e].sort((o,a)=>s(o,a)||(a.cpu??-1)-(o.cpu??-1)||a.mem-o.mem||o.pid-a.pid)}function S4(e,t,n=_4){const s=Ly(e,{key:t.rank,dir:"desc",rank:t.rank});return Ly(s.slice(0,n),t)}function N4(e,t){return e.key!==t?"none":e.dir==="asc"?"ascending":"descending"}function E4(e,t,n){return e>=n?"hot":e>=t?"warn":"calm"}function j4(e,t,n=Date.now()){const s=Math.max(0,Math.min(100,100-e));return{pct:s,value:`${s}%`,tone:s===0?"calm":s>=30?"hot":"warn",note:s>0?`CPU held to ${e}% of full speed to cool down`:t?`at full speed · held to ${100-t.peak}% ${C4(t.lastMs,n)}`:"running at full speed, and never held back"}}function C4(e,t=Date.now()){const n=Math.max(0,Math.floor((t-e)/6e4));if(n<2)return"just now";if(n<60)return`${n} minutes ago`;const s=Math.floor(n/60);return s===1?"an hour ago":`${s} hours ago`}const wT="agent-dag.systemPanelOpen";function T4(){return Mu(wT)==="1"}function R4(e){if(!(typeof window>"u"))try{window.localStorage.setItem(wT,e?"1":"0")}catch{}}function hi(e){return e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} KB`}function A4(e){const t=Math.floor(e/86400),n=Math.floor(e%86400/3600),s=Math.floor(e%3600/60);return t>0?`${t}d ${n}h`:n>0?`${n}h ${s}m`:`${s}m`}function M4(){const[e,t]=E.useState(null),n=E.useRef(null);return E.useEffect(()=>{let s=!0;const o=async()=>{if(document.visibilityState!=="hidden")try{const h=await fetch("/api/system");if(!h.ok)return;const p=await h.json();s&&(p!=null&&p.ok)&&t(p)}catch{}},a=()=>{n.current==null&&(o(),n.current=window.setInterval(o,x4))},l=()=>{n.current!=null&&(window.clearInterval(n.current),n.current=null)},u=()=>{if(document.visibilityState==="hidden"){l();return}a(),o()};return a(),document.addEventListener("visibilitychange",u),()=>{s=!1,l(),document.removeEventListener("visibilitychange",u)}},[]),e}function I4(e){const[t,n]=E.useState(null);return E.useEffect(()=>{let s=!0;const o=async()=>{if(document.visibilityState!=="hidden")try{const l=await fetch("/api/system/processes");if(!l.ok)return;const u=await l.json();s&&(u!=null&&u.ok)&&n({procs:u.procs??[],total:u.total??0})}catch{}};o();const a=window.setInterval(o,b4);return()=>{s=!1,window.clearInterval(a)}},[e]),t}function O4({usageOpen:e=!1}){const t=M4(),[n,s]=E.useState(T4);E.useEffect(()=>{R4(n)},[n]);const o=E.useRef(null),a=E.useRef(null);if(E.useEffect(()=>{if(n)return Ao.push(()=>{var k,N;const _=((k=a.current)==null?void 0:k.contains(document.activeElement))??!1;s(!1),_&&((N=o.current)==null||N.focus())},nT)},[n]),!t||t.cpu==null||!t.memory)return d.jsx("span",{className:"sysmeter idle",title:"Sampling this machine…",children:d.jsx("span",{className:"sm-box","aria-hidden":!0,children:d.jsxs("span",{className:"sm-graphic",children:[d.jsx("svg",{className:"sm-spark",width:za,height:ko,viewBox:`0 0 ${za} ${ko}`}),d.jsx("span",{className:"sm-ram"})]})})});const{cpu:l,cpuHistory:u,cores:h,memory:p,loadavg:f}=t,g=p.usedPct>=90,y=u.slice(-Hf),w=Hf-y.length,S=za/Hf,b=[`CPU ${l.toFixed(0)}% of ${h} cores`,f?`load ${f[0]} · ${f[1]} · ${f[2]} (1m · 5m · 15m)`:null,`Memory ${hi(p.total-p.available)} of ${hi(p.total)} used`,"","Click for detail. This machine, not this session."].filter(_=>_!==null).join(`
75
- `);return d.jsxs("span",{className:"sysmeter-wrap",children:[d.jsxs("button",{type:"button",ref:o,className:"sysmeter",title:b,"aria-label":"Toggle machine detail","aria-expanded":n,"aria-controls":n?"system-panel":void 0,onClick:()=>s(_=>!_),children:[d.jsxs("span",{className:"sm-box","aria-hidden":!0,children:[d.jsxs("span",{className:"sm-graphic",children:[d.jsx("svg",{className:"sm-spark",width:za,height:ko,viewBox:`0 0 ${za} ${ko}`,children:y.map((_,k)=>{const N=w+k,j=Math.max(1,_/100*ko),T=.32+.68*((k+1)/y.length);return d.jsx("rect",{x:N*S,y:ko-j,width:Math.max(.8,S-.7),height:j,rx:.5,fill:"var(--accent)",opacity:T},N)})}),d.jsx("span",{className:"sm-ram",children:d.jsx("span",{className:`sm-ram-fill${g?" warn":""}`,style:{transform:`scaleX(${Math.max(2,p.usedPct)/100})`}})})]}),d.jsxs("span",{className:"sm-read",children:[d.jsx("b",{children:l.toFixed(0)}),d.jsx("i",{children:"·"}),d.jsx("b",{children:p.usedPct.toFixed(0)})]})]}),d.jsxs("span",{className:"sm-sr",children:["CPU ",l.toFixed(0)," percent, memory ",p.usedPct.toFixed(0)," percent used"]})]}),n&&d.jsx(P4,{sys:t,usageOpen:e,panelRef:a,onClose:()=>{var _;s(!1),(_=o.current)==null||_.focus()}})]})}function P4({sys:e,usageOpen:t,panelRef:n,onClose:s}){const o=I4(!0),{memory:a,swap:l,perCore:u,loadavg:h,cores:p,uptimeSec:f,platform:g,thermal:y}=e,w=a?a.total-a.available:0,S=g==="win32"?"Commit":"Swap",b=l&&l.total>0?l.used/l.total*100:0;return d.jsxs("aside",{ref:n,className:`sysdetail${t?" shifted":""}`,id:"system-panel","aria-label":"Machine detail",children:[d.jsxs("div",{className:"sd-head",children:[d.jsx("span",{className:"sd-title",children:"This machine"}),d.jsxs("span",{className:"sd-sub",children:["up ",A4(f)," · ",p," cores"]}),d.jsx("button",{type:"button",className:"glyph-btn sd-close",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),u&&u.length>0&&d.jsx("div",{className:"sd-section",role:"group","aria-label":"Cores",children:d.jsx(iu,{group:"cores",title:"Core history",action:"Show core history",label:"Cores",children:d.jsx("div",{className:"sd-cores",style:{"--n":u.length},children:u.map((_,k)=>d.jsx("span",{className:"sd-core",title:`core ${k+1}: ${_}%`,children:d.jsx("span",{className:"sd-core-fill",style:{transform:`scaleY(${Math.max(2,_)/100})`}})},k))})})}),d.jsx("div",{className:"sd-section",role:"group","aria-label":"Memory",children:d.jsxs(iu,{group:"memory",title:"Memory history",action:"Show memory history",label:"Memory",children:[a&&d.jsx(wu,{label:"Physical",value:d.jsxs(d.Fragment,{children:[d.jsx("b",{children:hi(w)})," of ",hi(a.total)]}),pct:a.usedPct,tone:a.usedPct>=90?"warn":"calm",note:`${hi(a.available)} available`}),l&&l.total>0&&d.jsx(wu,{label:S,value:d.jsxs(d.Fragment,{children:[d.jsx("b",{children:hi(l.used)})," of ",hi(l.total)]}),pct:b,tone:b>=90?"warn":"calm",note:b>=50?"paging to disk":void 0})]})}),h&&d.jsx("div",{className:"sd-section",role:"group","aria-label":"Load average",children:d.jsxs(iu,{group:"load",title:"Load history",action:"Show load history",label:"Load average",children:[d.jsx("div",{className:"sd-load",children:h.map((_,k)=>d.jsxs("span",{className:`sd-load-item${_>p?" over":""}`,children:[d.jsx("b",{children:_.toFixed(2)}),d.jsx("span",{children:["1m","5m","15m"][k]})]},k))}),d.jsx("div",{className:"sd-note",children:h[0]>p?`${(h[0]/p).toFixed(1)}× more work queued than cores to run it`:`within ${p} cores`})]})}),d.jsx($4,{thermal:y}),d.jsx(L4,{read:o})]})}function iu({group:e,title:t,action:n,label:s,children:o}){const[a,l]=E.useState(!1);return d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"sd-open",onClick:()=>l(!0),title:n,"aria-label":n,children:[d.jsxs("div",{className:"sd-h","aria-hidden":!0,children:[s," ",d.jsx("i",{className:"sd-row-more",children:"›"})]}),o]}),a&&d.jsx(v4,{group:e,title:t,onClose:()=>l(!1)})]})}function $4({thermal:e}){if(!e)return null;const t=e.throttle?j4(e.throttle.speedLimit,e.heldBack):null;return d.jsx("div",{className:"sd-section",role:"group","aria-label":"Thermal",children:d.jsxs(iu,{group:"thermal",title:"Thermal history",action:"Show thermal history",label:"Thermal",children:[e.celsius.map(n=>d.jsx(wu,{label:n.label,value:d.jsxs(d.Fragment,{children:[d.jsx("b",{children:n.celsius})," °C"]}),pct:n.celsius,tone:E4(n.celsius,n.warnAt,n.critAt)},n.label)),t&&d.jsx(wu,{label:"Throttling",value:t.value,pct:t.pct,tone:t.tone,note:t.note})]})})}function L4({read:e}){const[t,n]=E.useState(yT),[s,o]=E.useState(!1),a=(e==null?void 0:e.procs)??null;return d.jsxs("div",{className:"sd-section",role:"group","aria-label":"Busiest processes",children:[d.jsxs("div",{className:"sd-hrow",children:[d.jsx("div",{className:"sd-h","aria-hidden":!0,children:"Busiest processes"}),a!=null&&a.length>0&&d.jsxs("button",{type:"button",className:"sd-all",onClick:()=>o(!0),title:"Show every process the deck is watching","aria-label":"Show every process the deck is watching",children:["more ",d.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]})]}),s&&e&&d.jsx(w4,{procs:e.procs,total:e.total,onClose:()=>o(!1)}),a==null?d.jsx("div",{className:"sd-note",children:"reading…"}):a.length===0?d.jsx("div",{className:"sd-note",children:"Could not read the process list on this platform."}):d.jsxs("table",{className:"sd-procs",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx(Mo,{col:"cpu",label:"cpu",sort:t,onSort:n}),d.jsx(Mo,{col:"mem",label:"mem",sort:t,onSort:n}),d.jsx(Mo,{col:"name",label:"process",sort:t,onSort:n})]})}),d.jsx("tbody",{children:S4(a,t).map(l=>d.jsxs("tr",{children:[d.jsx("td",{className:"sd-num",children:l.cpu==null?"—":l.cpu.toFixed(0)}),d.jsx("td",{className:"sd-num sd-dim",children:l.mem.toFixed(1)}),d.jsx("td",{className:"sd-proc-name",title:`pid ${l.pid}`,children:l.name})]},l.pid))})]})]})}function Mo({col:e,label:t,sort:n,onSort:s}){const o=N4(n,e);return d.jsx("th",{scope:"col","aria-sort":o,children:d.jsxs("button",{type:"button",className:"sd-sort",title:`Sort by ${t}`,onClick:()=>s(k4(n,e)),children:[t,d.jsx("span",{className:"sd-sort-dir","aria-hidden":!0,children:o==="none"?"":o==="ascending"?"↑":"↓"})]})})}function wu({label:e,value:t,pct:n,tone:s="calm",note:o}){return d.jsxs("div",{className:"sd-row",children:[d.jsxs("div",{className:"sd-row-head",children:[d.jsx("span",{className:"sd-row-label",children:e}),d.jsx("span",{className:"sd-row-val",children:t})]}),d.jsx("span",{className:"sd-track",children:d.jsx("span",{className:`sd-fill${s==="calm"?"":` ${s}`}`,style:{transform:`scaleX(${n<=0?0:Math.max(1,Math.min(100,n))/100})`}})}),o&&d.jsx("div",{className:"sd-note",children:o})]})}const y1=18,q4=1100,So=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},D4=Array.from({length:y1},(e,t)=>{const n=-72+144*t/(y1-1)+(So(t,1)-.5)*9,s=(n-90)*(Math.PI/180),o=(54+32*Math.cos(n*Math.PI/180))*(.74+So(t,2)*.52);return{dx:Math.cos(s)*o,dy:Math.sin(s)*o,rot:(t%2?1:-1)*(100+So(t,3)*260),delay:Math.round(So(t,4)*90),dur:760+Math.round(So(t,5)*260),scale:.8+So(t,6)*.45,hue:t%4,round:t%3===0}});function w1({anchor:e,lifetimeMs:t=q4}){var a;const[n,s]=E.useState(null),o=typeof window<"u"&&((a=window.matchMedia)==null?void 0:a.call(window,"(prefers-reduced-motion: reduce)").matches);return E.useEffect(()=>{if(o)return;const l=e.current;if(!l)return;const u=l.getBoundingClientRect();s({x:u.left+u.width/2,y:u.top+u.height/2});const h=window.setTimeout(()=>s(null),t);return()=>window.clearTimeout(h)},[e,t,o]),o||!n?null:ew.createPortal(d.jsx("div",{className:"confetti",style:{left:`${n.x}px`,top:`${n.y}px`},"aria-hidden":!0,children:D4.map((l,u)=>d.jsx("span",{className:`confetti-bit${l.round?" round":""}`,"data-hue":l.hue,style:{"--dx":`${l.dx.toFixed(1)}px`,"--dy":`${l.dy.toFixed(1)}px`,"--rot":`${l.rot}deg`,"--s":l.scale.toFixed(2),animationDelay:`${l.delay}ms`,animationDuration:`${l.dur}ms, ${l.dur}ms`}},u))}),document.body)}const xT=new Set(["awaiting_url","awaiting_code","registering"]);function F4(e){return e!=null&&xT.has(e)}function bT(e){return e!=null&&e!=="done"&&!xT.has(e)}const z4="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",B4="the sign-in did not complete";function U4({state:e,serverError:t,localError:n}){const s=e==="idle";return{title:s?"Sign-in ended":"Sign-in failed",message:n||t||(s?z4:B4)}}const W4="done";function H4(){let e=!1;return{shouldAnnounce(t){return t!==W4?(e=!1,!1):e?!1:(e=!0,!0)}}}function bw(e,t){return t&&Object.hasOwn(e,t)?e[t]:void 0}const G4={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 ccdeck2:",corrupt:"that share is incomplete — copy the whole thing",wrong_version:`that share was made by a newer ${zt}`,expired:"that share has expired — make a new one",import_failed:"claude-swap refused the import",unreadable_export:"claude-swap wrote something this deck could not read — try again, and upgrade it if this repeats",mixed_versions:"claude-swap changed format part-way through — try again",nothing_to_share:"none of those accounts could be exported",too_many:"that is more accounts than one share can carry",not_in_bundle:"that account is not in this share",bad_value:"an alias can only use letters, numbers, spaces, dots, dashes and underscores, up to 64 characters, and cannot start with a dash",bad_email:"that does not look like an email address — it cannot contain spaces or start with a dash"},V4={no_cswap:"claude-swap could not be run — it is not on this deck's PATH. Set AGENTS_DECK_CSWAP to its full path",timeout:"claude-swap took too long and was stopped — try again",switch_failed:"claude-swap refused the switch",bad_account:"that is not an account claude-swap has",unknown_setting:"claude-swap has no such setting",out_of_range:"that value is outside what the setting allows",bad_value:"claude-swap does not accept that value",set_failed:"claude-swap refused the change",command_failed:"claude-swap refused the command"},Y4=`claude-swap could not read the login keychain — start ${zt} from a Terminal window rather than a background service`;function qy(e,t){if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(qo(e)))return Y4;const n=bw(V4,e==null?void 0:e.reason);return n||(e==null?void 0:e.reason)||t}function qo(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const K4={no_install:"ccusage is not installed, and AGENTS_DECK_NO_INSTALL=1 forbids fetching it — unset that variable and restart the deck, or install ccusage yourself so it is on this deck's PATH",bad_override:"AGENTS_DECK_CCUSAGE names a file that is not there — correct it to the full path of your ccusage, or unset it to let the deck find its own",timeout:"ccusage took more than 90 seconds and was stopped — a narrower range usually finishes",bad_output:"ccusage ran but printed no usage data — try again, and run ccusage daily --json in a terminal if it keeps happening",run_failed:"ccusage could not report usage — try again",bad_range:"that date range is not a YYYYMMDD date — reopen the modal and pick one of the presets",unreachable:"the deck did not answer — check it is still running, then try again"},X4="ccusage could not be started — npx is not on this deck's PATH. Install Node's npm/npx, or put ccusage on PATH yourself";function Q4(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const Z4="ccusage could not be started — the deck launched npx and Node could not load the npm script it points at. An older deck asked cmd.exe for a bare npx.cmd, which made the shim look for that script under the deck's working directory instead of beside itself; update the deck and reopen this modal",J4="ccusage could not be started — the copy npx fetched will not load: Node could not resolve a file inside it. That copy is in npx's own cache, which the deck never rewrites, so clear it with `npm cache clean --force` and reopen this modal",eq=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),tq=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,nq=/[\\/]_npx[\\/]/i,rq=`the copy of ccusage ${zt} installed for itself`;function sq(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function iq(e,t){const n=oq(e,t),s=sq(e);switch(e==null?void 0:e.stage){case"npx":return s?`ccusage failed on both of its paths. The managed install failed first — ${s} — and the deck then fell back to npx, where ${Ba(n)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${Ba(n)}`;case"managed":return`${rq} failed to run: ${Ba(n)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${Ba(n)}`:`the ccusage this deck found on your PATH failed to run: ${Ba(n)}`;default:return n}}const Ba=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function oq(e,t){const n=qo(e);if(eq(n)){if(nq.test(n))return J4;if(tq.test(n))return Z4}if(Q4(n))return X4;const s=bw(K4,e==null?void 0:e.reason);return s||(e==null?void 0:e.reason)||t}function jo(e,t){if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&bT(e.state))return e.error;const n=bw(G4,e==null?void 0:e.reason);return n||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function aq(e,t,n){if(n<=0||mw(e))return{kind:"pass"};const s=t>=0&&t<n?t:-1;switch(e.key){case"ArrowRight":return{kind:"select",index:s===-1?0:(s+1)%n};case"ArrowLeft":return{kind:"select",index:s===-1?n-1:(s-1+n)%n};case"Home":return{kind:"select",index:0};case"End":return{kind:"select",index:n-1};default:return{kind:"pass"}}}function _T(e,t){const n=Math.round(e/1e3)-t;return n<=0?{text:"expired",tone:"gone"}:n<60?{text:`expires in ${n}s`,tone:"soon"}:{text:`expires in ${Math.round(n/60)}m`,tone:"ok"}}function lq(e){const t=new Map;for(const n of e){const s=(n.email??"").trim().toLowerCase();s&&t.set(s,(t.get(s)??0)+1)}return e.map(n=>{const s=(n.email??"").trim(),o=n.alias||s||`account ${n.num}`,a=[];return n.alias&&s&&a.push(s),s&&(t.get(s.toLowerCase())??0)>1&&a.push(n.org||`slot ${n.num}`),{num:n.num,label:o,sub:a.length?a.join(" · "):null}})}function cq(e){return e<=0?"Nothing picked yet.":e===1?"1 account — its sign-in token will be on your clipboard.":`${e} accounts — ${e} sign-in tokens will be on your clipboard.`}function uq(e){switch(e){case"imported":return"imported";case"healed":return"dead token replaced";case"updated":return"updated";case"present":return"already here";default:return"not imported"}}function dq(e){const t=e.length;if(!t)return"Nothing to import.";const n=p=>e.filter(f=>f.state===p).length,s=[],o=n("imported");o&&s.push(`${o} of ${t} imported`);const a=n("healed");a&&s.push(`${a} had a dead token replaced`);const l=n("updated");l&&s.push(`${l} updated`);const u=n("present");u&&s.push(`${u} already here`);const h=n("failed");return h&&s.push(`${h} did not arrive`),`${s.join(", ")}.`}const fq=1500,Gc=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],x1="aa-panel",b1=e=>`aa-tab-${e}`;async function Ua(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const Dy=ue.forwardRef((e,t)=>d.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:t,children:[d.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),d.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));Dy.displayName="SuccessMark";function hq({onClose:e,onChanged:t}){const[n,s]=E.useState("login"),[o,a]=E.useState(null),[l,u]=E.useState(""),[h,p]=E.useState(""),[f,g]=E.useState(!1),[y,w]=E.useState(null),[S,b]=E.useState(null),[_,k]=E.useState(null),[N,j]=E.useState(null),T=E.useRef(""),M=E.useRef(!1),P=E.useRef(!1),I=E.useRef(null),F=E.useRef(null),O=E.useRef(null),A=E.useRef(null),D=E.useRef([]),H=E.useRef(!1),K=E.useCallback(()=>{M.current&&Ua({action:"login-cancel"}).catch(()=>{}),e()},[e]),C=kn(K,{focusRef:O}),X=E.useCallback(async()=>{if(!or(P.current))return;P.current=!0,g(!0),w(null),M.current=!0;const q=await Ua({action:"login"}).catch(()=>null);if(P.current=!1,g(!1),!(q!=null&&q.ok)){w(jo(q,"could not start the sign-in"));return}a(q)},[]);E.useEffect(()=>{if(!F4(o==null?void 0:o.state))return;const q=window.setInterval(async()=>{try{const Z=await fetch("/api/claude-accounts/login");Z.ok&&a(await Z.json())}catch{}},fq);return()=>window.clearInterval(q)},[o]);const B=E.useRef(t);B.current=t;const ne=E.useState(H4)[0];E.useEffect(()=>{var q;(o==null?void 0:o.state)==="awaiting_code"&&((q=I.current)==null||q.focus()),ne.shouldAnnounce(o==null?void 0:o.state)&&B.current()},[o==null?void 0:o.state,ne]),E.useEffect(()=>{var q;n==="paste"&&!H.current&&((q=F.current)==null||q.focus()),H.current=!1},[n]);const J=E.useCallback(q=>{var se;const Z=aq(q,Gc.findIndex(fe=>fe.id===n),Gc.length);Z.kind!=="pass"&&(q.preventDefault(),H.current=!0,s(Gc[Z.index].id),(se=D.current[Z.index])==null||se.focus())},[n]),W=E.useCallback(async()=>{var Z;if(!or(P.current))return;P.current=!0,g(!0),w(null);const q=await Ua({action:"login-code",code:l}).catch(()=>null);if(P.current=!1,g(!1),!(q!=null&&q.ok)){w(jo(q,"the code was not accepted")),q!=null&&q.state&&a(q),(Z=I.current)==null||Z.select();return}u(""),a(q)},[l,o]),Q=E.useCallback(async()=>{if(!or(P.current))return;P.current=!0,g(!0),w(null);const q=await Ua({action:"import",blob:h}).catch(()=>null);if(P.current=!1,g(!1),!(q!=null&&q.ok)){w(jo(q,"the import failed"));return}T.current=h,p(""),j(null),b(q.results??[]),t()},[h,t]),$=E.useCallback(async q=>{const Z=`${q.email}|${q.org??""}`;if(!or(P.current)||!T.current)return;P.current=!0,g(!0),k(Z),j(null);const se=await Ua({action:"import",blob:T.current,force:!0,only:{email:q.email,org:q.org??""}}).catch(()=>null);if(P.current=!1,g(!1),k(null),!(se!=null&&se.ok)){j({key:Z,text:jo(se,"that account could not be updated")});return}const fe=(se.results??[])[0];fe&&b(he=>he&&he.map(ye=>`${ye.email}|${ye.org??""}`===Z?fe:ye)),t()},[t]),G=(o==null?void 0:o.state)==="done"?o.account:null,Y=bT(o==null?void 0:o.state)||!!(y&&M.current&&!f),L=U4({state:o==null?void 0:o.state,serverError:o==null?void 0:o.error,localError:y});return d.jsx("div",{className:"modal-backdrop",onClick:K,role:"presentation",children:d.jsxs("div",{ref:C,className:"modal aa-modal",onClick:q=>q.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[d.jsxs("header",{className:"modal-head",children:[d.jsx("div",{className:"modal-title",children:d.jsx("span",{className:"aa-tabs",role:"tablist","aria-label":"How to add the account",onKeyDown:J,children:Gc.map((q,Z)=>d.jsx("button",{type:"button",role:"tab",id:b1(q.id),ref:se=>{D.current[Z]=se},"aria-selected":n===q.id,"aria-controls":x1,tabIndex:n===q.id?0:-1,className:`aa-tab${n===q.id?" on":""}`,onClick:()=>{H.current=!1,s(q.id)},children:q.label},q.id))})}),d.jsx("div",{className:"modal-actions",children:d.jsx("button",{type:"button",className:"glyph-btn",onClick:K,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),d.jsx("section",{className:"modal-body aa-body",id:x1,role:"tabpanel","aria-labelledby":b1(n),children:n==="login"?G?d.jsxs("div",{className:"aa-done",children:[d.jsx(Dy,{ref:A}),d.jsx(w1,{anchor:A}),d.jsx("h4",{children:G.added?`Account ${G.num} added`:"Credentials refreshed"}),d.jsxs("p",{className:"aa-note",children:[d.jsx("strong",{children:G.email}),G.added?" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),d.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"?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"aa-step",children:[d.jsx("h4",{children:"1 · Approve in the browser"}),d.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),d.jsx("a",{className:"aa-link",href:o.url??"#",target:"_blank",rel:"noreferrer noopener",children:o.url})]}),d.jsxs("div",{className:"aa-step",children:[d.jsx("h4",{children:"2 · Paste a code, if the page shows one"}),d.jsx("p",{className:"aa-note",children:"It usually finishes on its own — if the page says you are all set, there is nothing to do here."}),d.jsxs("div",{className:"aa-field",children:[d.jsx("input",{ref:I,type:"text",value:l,onChange:q=>u(q.target.value),onKeyDown:q=>{q.key==="Enter"&&l.trim()&&!f&&W()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:o.state==="registering"}),d.jsx("button",{type:"button",className:"btn primary",...ir(f,!l.trim()||o.state==="registering"),onClick:W,children:o.state==="registering"?"registering…":"Continue"})]}),(y||o.error)&&d.jsx("p",{className:"aa-err",children:y??o.error}),d.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."})]})]}):Y?d.jsxs("div",{className:"aa-step",children:[d.jsx("h4",{children:L.title}),d.jsx("p",{className:"aa-err",children:L.message}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{M.current=!1,a(null),w(null),X()},children:"Try again"})]}):f||M.current?d.jsx("div",{className:"aa-step",children:d.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):d.jsxs("div",{className:"aa-step aa-primer",children:[d.jsx("h4",{children:"Sign in to Anthropic"}),d.jsx("p",{className:"aa-note",children:"Opens a browser tab where you approve the sign-in. It normally completes by itself; only if the page hands you a code does it need pasting back here. claude-swap records the account when it completes, and the account you are using now stays active."}),d.jsx("div",{className:"aa-actions",children:d.jsx("button",{type:"button",ref:O,className:"btn primary",onClick:X,children:"Open the sign-in page"})})]}):S?(()=>{const q=S.filter(Z=>Z.state==="imported").length;return d.jsxs("div",{className:"aa-done",children:[d.jsx(Dy,{ref:A}),q>0&&d.jsx(w1,{anchor:A}),d.jsx("h4",{children:dq(S)}),S.length>0&&d.jsx("ul",{className:"aa-results",children:S.map(Z=>{const se=`${Z.email}|${Z.org??""}`;return d.jsxs("li",{className:`aa-result ${Z.state}`,children:[d.jsx("span",{className:"aa-result-who",children:Z.email||(Z.num?`slot ${Z.num}`:"an account")}),d.jsx("span",{className:"aa-result-what",children:uq(Z.state)}),Z.state==="present"&&d.jsx("button",{type:"button",className:"aa-result-fix","aria-busy":_===se,title:`Overwrite the stored login for ${Z.email} with the one in this share. Do this when that account has stopped working here; if it works, leave it.`,onClick:()=>$(Z),children:_===se?"updating…":"update anyway"}),(N==null?void 0:N.key)===se&&d.jsx("span",{className:"aa-result-err",children:N.text})]},se)})}),d.jsxs("p",{className:"aa-note",children:["Nothing changed on the deck you copied this from. An account already here is left as it is, unless its stored login was dead or you pressed",d.jsx("strong",{children:" update anyway"}),"."]}),d.jsxs("div",{className:"aa-actions",children:[d.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{T.current="",j(null),b(null)},children:"Import another"})]})]})})():d.jsxs("div",{className:"aa-step",children:[d.jsx("h4",{children:"Paste an account shared from another deck"}),d.jsxs("div",{className:"aa-field",children:[d.jsx("input",{ref:F,type:"text",value:h,onChange:q=>p(q.target.value),onKeyDown:q=>{q.key==="Enter"&&h.trim()&&!f&&Q()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),d.jsx("button",{type:"button",className:"btn primary",...ir(f,!h.trim()),onClick:Q,children:f?"importing…":"Import"})]}),y&&d.jsx("p",{className:"aa-err",children:y}),d.jsxs("p",{className:"aa-note",children:["Use ",d.jsx("strong",{children:"share"})," on one account in the other deck, or ",d.jsx("strong",{children:"↗"})," above its list to send several at once. A share carries a live login for every account in it and expires ten minutes after it is made."]})]})})]})})}async function pq(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const mq=1800;function gq({accounts:e,onClose:t,copyText:n}){const[s,o]=E.useState([]),[a,l]=E.useState(null),[u,h]=E.useState(!1),[p,f]=E.useState(null),[g,y]=E.useState(!1),[w,S]=E.useState(()=>Math.floor(Date.now()/1e3)),b=E.useRef(null),_=E.useRef(!1),k=kn(t,{focusRef:b});E.useEffect(()=>{if(!a)return;S(Math.floor(Date.now()/1e3));const A=window.setInterval(()=>S(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval(A)},[a]);const N=lq(e),j=e.filter(A=>!s.includes(A.num)).map(A=>A.num),T=j.length===e.length,M=A=>o(D=>D.includes(A)?D.filter(H=>H!==A):[...D,A]),P=E.useCallback(async()=>{if(!or(_.current)||!j.length)return;_.current=!0,h(!0),f(null),y(!1);const A=await pq({action:"share",accounts:j}).catch(()=>null);if(_.current=!1,h(!1),!(A!=null&&A.ok)){f(jo(A,"the share could not be made"));return}l({blob:A.blob,expiresAt:A.expiresAt,shared:A.shared??[],failed:A.failed??[]})},[e,j]),I=a?_T(a.expiresAt,w):null,F=(I==null?void 0:I.tone)==="gone",O=(a==null?void 0:a.shared.length)??0;return d.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:d.jsxs("div",{ref:k,className:"modal sa-modal",onClick:A=>A.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Share accounts with another deck",children:[d.jsxs("header",{className:"modal-head",children:[d.jsx("div",{className:"modal-title",children:d.jsx("h3",{children:"Share accounts"})}),d.jsx("div",{className:"modal-actions",children:d.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),d.jsx("section",{className:"modal-body sa-body",children:a?d.jsxs("div",{className:"sa-step",children:[d.jsx("h4",{children:F?"This share has expired":O===1?"1 account, ready to paste":`${O} accounts, ready to paste`}),d.jsx("code",{className:`ap-share-blob${F?" sa-dead":""}`,children:a.blob}),d.jsxs("div",{className:"ap-share-foot",children:[d.jsx("button",{type:"button",className:"ap-manage-btn",ref:b,onClick:async()=>{if(F){l(null),P();return}await n(a.blob)&&(y(!0),window.setTimeout(()=>y(!1),mq))},children:F?"make a new share":g?"copied":`copy ${O===1?"the share":"all "+O}`}),d.jsxs("span",{className:"ap-manage-hint",title:"This text is the sign-in for every account in it. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the logins themselves are in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign those accounts out and back in.",children:[d.jsx("span",{className:"ap-share-warn",children:O===1?"this is the password":`this is ${O} passwords`})," · ",d.jsx("span",{className:`ap-share-expiry ${I==null?void 0:I.tone}`,children:I==null?void 0:I.text})]})]}),a.failed.length>0&&d.jsxs("div",{className:"sa-failed",role:"alert",children:[d.jsx("p",{className:"sa-failed-head",children:a.failed.length===1?"One account is not in this bundle:":`${a.failed.length} accounts are not in this bundle:`}),d.jsx("ul",{className:"sa-list",children:a.failed.map(A=>{var H;const D=!!(A.email&&((H=A.detail)!=null&&H.includes(A.email)));return d.jsxs("li",{children:[!D&&d.jsx("span",{className:"sa-who",children:A.email||`account ${A.num}`}),d.jsx("span",{className:"sa-why",children:A.detail||"could not be exported"})]},`${A.num}-${A.email}`)})})]}),d.jsx("p",{className:"sa-note",children:F?d.jsx(d.Fragment,{children:"Another deck will refuse this text now. Make a new one — the same accounts are still picked."}):d.jsxs(d.Fragment,{children:["Paste it into the other deck with ",d.jsx("strong",{children:"+"})," → ",d.jsx("strong",{children:"Paste a share"}),". Accounts it already holds are left exactly as they are."]})}),d.jsxs("div",{className:"sa-actions",children:[d.jsx("button",{type:"button",className:"btn",onClick:()=>{l(null),y(!1)},children:"Pick again"}),d.jsx("button",{type:"button",className:"btn primary",onClick:t,children:"Done"})]})]}):e.length===0?d.jsxs("div",{className:"sa-step",children:[d.jsx("h4",{children:"Nothing to share"}),d.jsxs("p",{className:"sa-note",children:["This deck is not holding any accounts right now. Sign one in with ",d.jsx("strong",{children:"+"}),", or wait — the panel is still reading the store."]}),d.jsx("div",{className:"sa-actions",children:d.jsx("button",{type:"button",className:"btn primary",ref:b,onClick:t,children:"Close"})})]}):d.jsxs("div",{className:"sa-step",children:[d.jsxs("h4",{children:["Which accounts go to the other ",zt,"?"]}),d.jsx("p",{className:`sa-count${j.length?"":" empty"}`,children:cq(j.length)}),d.jsx("ul",{className:"sa-list sa-pick",children:N.map(A=>d.jsx("li",{children:d.jsxs("label",{className:"sa-row",children:[d.jsx("input",{type:"checkbox",checked:j.includes(A.num),onChange:()=>M(A.num)}),d.jsx("span",{className:"sa-who",children:A.label}),A.sub&&d.jsx("span",{className:"sa-sub",children:A.sub})]})},A.num))}),p&&d.jsx("p",{className:"aa-err",children:p}),d.jsxs("div",{className:"sa-actions",children:[d.jsx("button",{type:"button",className:"btn",onClick:()=>o(T?e.map(A=>A.num):[]),children:T?"Clear all":"Select all"}),d.jsx("button",{type:"button",className:"btn primary",ref:b,...ir(u,!j.length),onClick:P,children:u?"making the share…":j.length===0?"Share":j.length===1?"Share 1 account":`Share ${j.length} accounts`})]})]})})]})})}function vq(e,t){const n=new Set(e),s=e.length?Math.max(...e):0;return[...new Set([...e,s+1])].sort((o,a)=>o-a).map(o=>{const a=o===t?"here":n.has(o)?"swap":"free";return{slot:o,kind:a,label:a==="here"?`slot ${o}`:`slot ${o} · ${a}`}})}function yq(e,t,n){if(!(n!=null&&n.ok))return null;const s=Number.isInteger(n.to)?n.to:null;if(s==null)return{menuFor:null,confirmRemove:null,shareFor:null,swapNote:null};const o=n.swapped===!0&&s!==t;return{menuFor:e.menuFor===t?s:o&&e.menuFor===s?t:e.menuFor,confirmRemove:null,shareFor:null,swapNote:o?{at:s,displaced:t}:null}}function wq(e,t,n){return t!=null&&e.some(s=>s.slot===t)?t:n}function xq(e,t,n){var o;const s=((o=e.find(a=>a.slot===t))==null?void 0:o.kind)??"here";return s==="swap"?{label:"swap",done:"swapped",sends:!0,swaps:!0,title:`Send this account to slot ${t}. That slot is taken, so the two accounts trade places and the one standing there moves to slot ${n}.`}:s==="free"?{label:"move",done:"moved",sends:!0,swaps:!1,title:`Send this account to slot ${t}. That slot is empty, so no other account moves.`}:{label:"move",done:"here",sends:!1,swaps:!1,title:`This account already holds slot ${n}.`}}function bq(e,t){return{label:"save",done:"saved",sends:e!==t,swaps:!1,title:`Switch the active account out once it passes ${e}% of its limit.`}}function _1(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function k1(e){const t=e.filter(u=>!_1(u)),n=e.filter(u=>_1(u)),s=t.length?t:n,o=t.length?n:[],a=s.reduce((u,h)=>u&&u.pct>=h.pct?u:h,null);let l=null;for(const u of o)a&&u.pct<=a.pct||(!l||u.pct>l.pct)&&(l=u);return{shown:s,rest:o,fuller:l,peak:l??a}}function _q(e,t,n){return e<1?null:t?"fewer":n?`${n.label} ${Math.round(n.pct)}%`:`${e} more`}function kq(e,t,n,s){const o=e==null?"No usage has been collected for this account yet.":`${Math.round(e)}% left on ${t??"the window that runs out first"}, which is the one that runs out first.`,a=n===1?"the other window":`the other ${n} windows`;return`${o} ${s?"Hide":"Show"} ${a}.`}const Sq="\0";function _w(e){const t=typeof e.email=="string"?e.email.trim():"";if(!t)return`slot:${e.num}`;const n=typeof e.org=="string"?e.org.trim():"";return`acct:${t}${Sq}${n}`}function Nq(e,t){const n=_w(t);return e.includes(n)?e.filter(s=>s!==n):[...e,n]}function Eq(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map(_w)),s=e.filter(o=>n.has(o));return s.length===e.length?e:s}const jq=64;function Cq(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}const Tq=Object.freeze({text:"couldn't reach the deck server",reload:!0});async function S1(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function Rq(e){const t=e.find(s=>!s.ok);if(!t)return null;const n=qo(t.body);return{text:qy(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function N1(e,t){return t?e!=null&&e.reload&&e.text===t.text&&e.raw===t.raw?e:t:e!=null&&e.reload?null:e}const E1=15e3,Aq=8e3,Gf=1800,Mq=3e4,Iq=[70,80,85,90,95];function j1(e,t){return fT(t-Math.floor(e/1e3))}function Oq(e,t){if(!e)return"";const n=Math.floor(e/1e3)-t;return n<=0?" · due":n<60?` · next in ${n}s`:` · next in ${Math.round(n/60)}m`}function Pq(e){switch(e){case"invalid_grant":case"no_refresh_token":return{text:"login expired",hint:"claude-swap's stored login for this account was rejected and cannot be refreshed. Signing in again replaces it — the account keeps its slot, its alias and its history.",fixable:!0};case"http-401":return{text:"re-login needed",hint:"Anthropic refused this account's token.",fixable:!0};case"http-429":return{text:"rate limited",hint:"Anthropic is throttling requests for this account. It clears on its own.",fixable:!1};case"transient":return{text:"temporary error",hint:"A network or server hiccup while reading usage. The next collection retries.",fixable:!1};case"timeout":return{text:"timed out",hint:"Reading this account's usage took too long. The next collection retries.",fixable:!1};case"network":return{text:"unreachable",hint:"Could not reach Anthropic to read this account's usage.",fixable:!1};default:return{text:e,hint:`claude-swap reported "${e}" for this account.`,fixable:!1}}}function C1({lane:e,nowSec:t}){const n=Math.min(100,Math.max(0,e.pct)),s=n>=90?"var(--err)":n>=70?"var(--warn)":"var(--accent)",o=e.resetAt?hT(e.resetAt,t):null;return d.jsxs("div",{className:"ap-lane",children:[d.jsx("span",{className:"ap-lane-label",children:e.label}),d.jsx("div",{className:"ap-lane-track",children:d.jsx("div",{className:"ap-lane-fill",style:{width:`${n===0?1.5:n}%`,background:s,opacity:n===0?.4:1}})}),d.jsxs("span",{className:"ap-lane-pct",style:{color:s},children:[n,"%"]}),d.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}async function T1(e){var n;let t=!1;try{t=await Promise.race([((n=navigator.clipboard)==null?void 0:n.writeText(e).then(()=>!0))??Promise.resolve(!1),new Promise(s=>window.setTimeout(()=>s(!1),500))])}catch{t=!1}if(t)return!0;try{const s=document.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(s),s.select(),t=document.execCommand("copy"),s.remove()}catch{t=!1}return t}function $q({onClose:e}){var Ke,_t,Me,it,At;const[t,n]=E.useState(null),[s,o]=E.useState(null),[a,l]=E.useState(null),[u,h]=E.useState(!1),[p,f]=E.useState(null),[g,y]=E.useState(()=>Math.floor(Date.now()/1e3)),w=E.useRef(null),[S,b]=E.useState(null),[_,k]=E.useState(!1),[N,j]=E.useState(""),[T,M]=E.useState(null),[P,I]=E.useState(null),[F,O]=E.useState(null),[A,D]=E.useState(!1),[H,K]=E.useState(!1),[C,X]=E.useState(null),[B,ne]=E.useState(null),[J,W]=E.useState(null),[Q,$]=E.useState(null),[G,Y]=E.useState(!1),[L,q]=E.useState([]),Z=E.useRef(null),se=E.useCallback(oe=>mT(Z.current)?(Z.current=oe,l(oe),!0):!1,[]),fe=E.useCallback(()=>{Z.current=null,l(null)},[]),he=(oe,Pe=!1)=>{const qe=pT(a,oe);return{disabled:qe.disabled,"aria-busy":qe.busy||Pe}},ye=E.useCallback(oe=>{window.requestAnimationFrame(()=>{var Pe;if(J3(((Pe=document.activeElement)==null?void 0:Pe.tagName)??null))for(const qe of Z3(oe)){const Ne=document.querySelector(qe);if(Ne){Ne.focus();return}}})},[]),Re=E.useCallback(async(oe=!1)=>{oe&&h(!0);const Pe=new AbortController,qe=window.setTimeout(()=>Pe.abort(),Mq);try{const[Ne,We]=await Promise.all([fetch(`/api/claude-accounts${oe?"?refresh=1":""}`,{signal:Pe.signal}),fetch("/api/cswap-auto",{signal:Pe.signal})]);if(Ne.ok){const et=await Ne.json();n(et),q(Ce=>Eq(Ce,et.accounts))}We.ok&&o(await We.json());const Et=Rq([await S1(Ne),await S1(We)]);f(et=>N1(et,Et))}catch{f(Ne=>N1(Ne,Tq))}finally{window.clearTimeout(qe),oe&&h(!1)}},[]),Ue=E.useCallback(async(oe,Pe)=>{if(!se(Pe))return null;f(null);try{const Ne=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(oe)})).json().catch(()=>null);return Ne!=null&&Ne.ok||f({text:qy(Ne,"command failed"),raw:qo(Ne)}),Ne}catch{return f({text:"server unreachable"}),null}finally{fe()}},[se,fe]),De=E.useCallback(async(oe,Pe)=>{if(!se(Pe))return null;f(null);try{const Ne=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(oe)})).json().catch(()=>null);return Ne!=null&&Ne.ok||f({text:jo(Ne,"command failed")}),Ne}catch{return f({text:"server unreachable"}),null}finally{fe()}},[se,fe]);E.useEffect(()=>(Re(!0),w.current=window.setInterval(()=>Re(!1),E1),()=>{w.current!=null&&window.clearInterval(w.current)}),[Re]),E.useEffect(()=>{const oe=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(oe)},[]);const Ie=((Ke=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:Ke.value)??"90",ke=Q??Ie,ce=bq(ke,Ie),xe=(_t=t==null?void 0:t.accounts)==null?void 0:_t.find(oe=>oe.active),we=((Me=k1((xe==null?void 0:xe.lanes)??[]).peak)==null?void 0:Me.pct)??null,Ye=we!=null&&we>=Number(Ie)-15,yt=async oe=>{if(se(`switch-${oe}`)){f(null);try{const qe=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:oe})})).json().catch(()=>null);qe!=null&&qe.ok||f({text:qy(qe,"the switch failed"),raw:qo(qe)}),await Re(!0)}catch{f({text:"server unreachable"})}finally{fe(),ye(oe)}}},ct=async(oe,Pe)=>{const{commit:qe,alias:Ne}=Cq(N,Pe);if(qe){const We=await De({action:"alias",account:oe,alias:Ne},`alias-${oe}`);if(await Re(!0),!(We!=null&&We.ok))return;j(Ne)}M(oe),window.setTimeout(()=>M(We=>We===oe?null:We),Gf)},st=async(oe,Pe)=>{const qe=await De({action:"move",account:oe,slot:Pe},`move-${oe}`),Ne=yq({menuFor:S,shareFor:(F==null?void 0:F.num)??null},oe,qe);if(await Re(!0),Ne){b(Ne.menuFor),I(Ne.confirmRemove),Ne.shareFor==null&&(O(null),K(!1)),X(Ne.swapNote);const We=Ne.swapNote;We&&window.setTimeout(()=>X(Et=>Et===We?null:Et),Aq),ne(null),ye(Ne.menuFor)}return qe},Be=async(oe,Pe,qe)=>{if(qe.sends){const Ne=await st(oe,Pe);if(!(Ne!=null&&Ne.ok))return}W(oe),window.setTimeout(()=>W(Ne=>Ne===oe?null:Ne),Gf)},tt=async(oe,Pe)=>{if(Pe.sends){const qe=await Ue({action:"setting",key:"autoswitch.threshold",value:oe},"threshold");if(await Re(!0),!(qe!=null&&qe.ok))return;$(null)}Y(!0),window.setTimeout(()=>Y(!1),Gf)};return d.jsxs("aside",{className:"accounts-panel",id:"accounts-panel","aria-label":"Claude accounts",children:[d.jsxs("div",{className:"ap-header",children:[d.jsx("h2",{children:"Accounts"}),d.jsxs("div",{className:"ap-header-right",children:[d.jsx("button",{type:"button",className:"glyph-btn ap-add",onClick:()=>k(!0),"aria-label":"Add an account",title:"Sign in to another Claude account, or paste one shared from another deck",children:"+"}),(((it=t==null?void 0:t.accounts)==null?void 0:it.length)??0)>0&&d.jsx("button",{type:"button",className:"glyph-btn ap-share-set",onClick:()=>D(!0),"aria-label":"Share accounts with another deck",title:`Copy several accounts to another ${zt} in one paste. The text carries a live login for each one — treat it as those passwords.`,children:"↗"}),d.jsx("button",{type:"button",className:"glyph-btn ap-refresh",onClick:()=>Re(!0),...he("reload",u),"aria-label":"Reload accounts",title:"Reload from claude-swap",children:u?"…":"↻"}),d.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),t==null?p?d.jsxs("div",{className:"ap-empty",role:"alert",children:[d.jsx("span",{title:p.raw||void 0,children:p.text}),d.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",E1/1e3," seconds."]}),d.jsx("button",{type:"button",className:"ap-fix",disabled:u,onClick:()=>Re(!0),children:u?"trying…":"try again"})]}):d.jsx("div",{className:"ap-empty",children:"Checking…"}):t.ok?d.jsxs(d.Fragment,{children:[(At=t.accounts)==null?void 0:At.map(oe=>{const{shown:Pe,rest:qe,fuller:Ne,peak:We}=k1(oe.lanes),Et=L.includes(_w(oe)),et=_q(qe.length,Et,Ne);return d.jsxs("div",{className:`ap-account${oe.active?" active":""}`,children:[d.jsxs("div",{className:"ap-account-head",children:[d.jsx("span",{className:"ap-num",children:oe.num}),oe.alias&&d.jsx("span",{className:"ap-alias",title:oe.alias,children:oe.alias}),d.jsx("span",{className:"ap-email",title:oe.email??void 0,children:oe.email}),d.jsx("button",{type:"button",id:`ap-more-${oe.num}`,className:`ap-more${S===oe.num?" on":""}`,"aria-label":`Manage account ${oe.num}`,"aria-expanded":S===oe.num,"aria-controls":S===oe.num?`ap-manage-${oe.num}`:void 0,title:"Share, rename, move, remove",onClick:()=>{b(S===oe.num?null:oe.num),j(oe.alias??""),I(null),O(null),K(!1),X(null),M(null),ne(null),W(null)},children:"⋯"}),oe.active&&d.jsx("span",{className:"ap-badge-active",children:"active"}),oe.disabled&&d.jsx("span",{className:"ap-badge-held",children:"held out"}),!oe.active&&!oe.disabled&&d.jsx("button",{type:"button",className:"ap-manage-btn ap-switch",...he(`switch-${oe.num}`),onClick:()=>yt(oe.num),title:`Switch to ${oe.alias??oe.email}`,children:a===`switch-${oe.num}`?"…":"switch"})]}),d.jsx("div",{className:"ap-lanes",id:`ap-lanes-${oe.num}`,children:Pe.length?d.jsxs(d.Fragment,{children:[Pe.map(Ce=>d.jsx(C1,{lane:Ce,nowSec:g},Ce.id)),Et&&qe.map(Ce=>d.jsx(C1,{lane:Ce,nowSec:g},Ce.id))]}):d.jsx("div",{className:"ap-hint",children:"No usage recorded yet."})}),d.jsxs("div",{className:"ap-meta",children:[oe.staleCopy&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"ap-stale-copy",title:"The deck can still see this account — its live usage is being read — but claude-swap's own stored copy of the login was rejected, so these numbers stopped updating. Resume re-captures the copy from the login you already have.",children:"numbers paused"}),d.jsx("button",{type:"button",className:"ap-fix",...he("recapture"),onClick:async()=>{const Ce=await De({action:"recapture"},"recapture");Ce!=null&&Ce.ok&&Re(!0)},title:"Re-capture this account's stored credentials from the login you already have. No sign-in, no switch.",children:a==="recapture"?"resuming…":"resume"})]}),oe.error&&(()=>{const Ce=Pq(oe.error);return d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"ap-err",title:Ce.hint,children:Ce.text}),Ce.fixable&&d.jsx("button",{type:"button",className:"ap-fix",onClick:()=>k(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"sign in again"})]})})(),et&&d.jsx("button",{type:"button",className:"ap-lanes-more","aria-expanded":Et,"aria-controls":`ap-lanes-${oe.num}`,title:kq(oe.headroom,(We==null?void 0:We.label)??null,qe.length,Et),onClick:()=>q(Ce=>Nq(Ce,oe)),children:et}),(((s==null?void 0:s.enabled)||(s==null?void 0:s.external))&&!oe.active||oe.disabled)&&d.jsx("button",{type:"button",className:"ap-rotate",...he(`rot-${oe.num}`),onClick:()=>Ue({action:"account",account:oe.num,enabled:oe.disabled},`rot-${oe.num}`).then(()=>Re(!0)),title:oe.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:oe.disabled?"put back":"hold out"}),oe.fetchedAt?d.jsxs("span",{className:`ap-age${oe.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 ",j1(oe.fetchedAt,g),Oq(oe.nextAt,g)]}):d.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),S===oe.num&&d.jsxs("div",{className:"ap-manage",id:`ap-manage-${oe.num}`,role:"group","aria-label":`Manage account ${oe.num}`,children:[d.jsxs("div",{className:"ap-manage-name",children:[d.jsx("label",{className:"vis-hidden",htmlFor:`ap-alias-${oe.num}`,children:"Alias"}),d.jsx("input",{id:`ap-alias-${oe.num}`,className:"ap-manage-input",type:"text",value:N,onChange:Ce=>j(Ce.target.value),onKeyDown:Ce=>{Ce.key==="Enter"&&ct(oe.num,oe.alias)},maxLength:jq,placeholder:"e.g. work",spellCheck:!1,autoFocus:!0}),d.jsx("button",{type:"button",className:"ap-manage-btn",...he(`alias-${oe.num}`),onClick:()=>ct(oe.num,oe.alias),title:"A short name to show instead of the email",children:T===oe.num?"saved":"save"})]}),(()=>{const Ce=vq((t.accounts??[]).map(kt=>kt.num),oe.num),wt=wq(Ce,B,oe.num),at=xq(Ce,wt,oe.num);return d.jsxs("div",{className:"ap-manage-slot",children:[d.jsx("label",{className:"vis-hidden",htmlFor:`ap-slot-${oe.num}`,children:"Slot"}),d.jsx("span",{className:"ap-field",children:d.jsx("select",{id:`ap-slot-${oe.num}`,value:String(wt),...he(`move-${oe.num}`),onChange:kt=>ne(Number(kt.target.value)),children:Ce.map(kt=>d.jsx("option",{value:kt.slot,children:kt.label},kt.slot))})}),d.jsx("button",{type:"button",className:"ap-manage-btn",...he(`move-${oe.num}`),title:at.title,onClick:()=>Be(oe.num,wt,at),children:J===oe.num?at.done:at.label})]})})(),d.jsxs("div",{className:"ap-manage-acts",children:[d.jsx("button",{type:"button",className:"ap-manage-btn",...he(`share-${oe.num}`),title:`Copy this account to another ${zt}. Anyone who has the text can use the account — treat it as the password. The other deck stops accepting it after 10 minutes; that does not make an escaped copy safe.`,onClick:async()=>{K(!1);const Ce=await De({action:"share",account:oe.num},`share-${oe.num}`);Ce!=null&&Ce.ok&&O({num:oe.num,blob:Ce.blob,expiresAt:Ce.expiresAt})},children:"share"}),d.jsx("button",{type:"button",className:`ap-manage-btn danger${P===oe.num?" armed":""}`,...he(`rm-${oe.num}`),title:P===oe.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(P!==oe.num){I(oe.num),window.setTimeout(()=>I(Ce=>Ce===oe.num?null:Ce),4e3);return}I(null),De({action:"remove",account:oe.num},`rm-${oe.num}`).then(()=>{b(null),Re(!0),ye(null)})},children:P===oe.num?"confirm":"remove"})]}),(C==null?void 0:C.at)===oe.num&&(()=>{var at;const Ce=(at=t.accounts)==null?void 0:at.find(kt=>kt.num===C.displaced),wt=(Ce==null?void 0:Ce.alias)??(Ce==null?void 0:Ce.email)??"the account that was there";return d.jsxs("span",{className:"ap-manage-hint ap-manage-swap",title:`Slot ${C.at} was taken, so the two accounts traded places: ${wt} now holds slot ${C.displaced}.`,children:["swapped with slot ",C.displaced]})})(),(F==null?void 0:F.num)===oe.num&&(()=>{const Ce=_T(F.expiresAt,g),wt=Ce.tone==="gone";return d.jsxs("div",{className:`ap-share${wt?" expired":""}`,children:[d.jsx("code",{className:"ap-share-blob",children:F.blob}),d.jsxs("div",{className:"ap-share-foot",children:[d.jsx("button",{type:"button",className:"ap-manage-btn",...he(`share-${oe.num}`),onClick:async()=>{if(wt){K(!1);const at=await De({action:"share",account:oe.num},`share-${oe.num}`);at!=null&&at.ok&&O({num:oe.num,blob:at.blob,expiresAt:at.expiresAt});return}await T1(F.blob)&&(K(!0),window.setTimeout(()=>K(!1),1800))},children:wt?"make a new share":H?"copied":"copy"}),d.jsxs("span",{className:"ap-manage-hint",title:"This text is the account's password. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the login itself is in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign the account out and back in.",children:[d.jsx("span",{className:"ap-share-warn",children:"this is the password"})," · ",d.jsx("span",{className:`ap-share-expiry ${Ce.tone}`,children:Ce.text})]})]})]})})()]})]},oe.num)}),(s==null?void 0:s.ok)&&d.jsxs("div",{className:"ap-auto",children:[d.jsxs("div",{className:"ap-auto-head",children:[d.jsx("h3",{className:"ap-auto-title",children:"Auto-switch"}),d.jsxs("span",{className:"ap-auto-ctl",children:[we!=null&&d.jsxs("span",{className:`ap-auto-now${Ye?" near":""}`,children:[Math.round(we),"%"]}),d.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:d.jsx("select",{"aria-label":"Switch threshold",value:ke,...he("threshold"),onChange:oe=>$(oe.target.value),children:Iq.map(oe=>d.jsxs("option",{value:oe,children:[oe,"%"]},oe))})}),d.jsx("button",{type:"button",className:"ap-manage-btn",...he("threshold"),title:ce.title,onClick:()=>tt(ke,ce),children:G?ce.done:ce.label}),d.jsxs("button",{type:"button",className:`ap-auto-state${s.enabled?" live":""}`,role:"switch","aria-checked":s.enabled,"aria-label":"Auto-switch",...he("enable"),onClick:()=>Ue({action:"enable",enabled:!s.enabled},"enable").then(()=>Re(!0)),title:s.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[d.jsx("i",{className:s.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),s.enabled?"on":"off"]})]})]}),s.external&&d.jsxs("p",{className:"ap-auto-note",children:[d.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",d.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&&d.jsx("div",{className:"ap-auto-foot",children:d.jsxs("span",{className:"ap-auto-result",children:["checked ",j1(s.lastTick.at,g)]})})]}),p&&d.jsxs("div",{className:"ap-failure",role:"alert",children:[d.jsx("span",{className:"ap-failure-text",title:p.raw||void 0,children:p.text}),d.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>f(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),d.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:"These numbers only update while this panel is open."})]}):d.jsx("div",{className:"ap-empty",children:t.reason==="no_cswap"?d.jsxs(d.Fragment,{children:[d.jsx("span",{children:"claude-swap isn't installed."}),d.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."}),t.hint&&d.jsx("code",{className:"ap-cmd",children:t.hint}),d.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",d.jsx("strong",{children:"+"})," button above."]})]}):t.reason==="no_accounts"?d.jsxs(d.Fragment,{children:[d.jsx("span",{children:"No accounts added yet."}),d.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",d.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{children:"Couldn't read the account store."}),d.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",t.reason?` (${t.reason})`:"","."]})]})}),_&&d.jsx(hq,{onClose:()=>k(!1),onChanged:()=>Re(!0)}),A&&d.jsx(gq,{accounts:((t==null?void 0:t.accounts)??[]).map(oe=>({num:oe.num,email:oe.email,alias:oe.alias,org:oe.org})),onClose:()=>D(!1),copyText:T1})]})}const Lq=3e4;function qq({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function Dq({bundle:e,running:t,pending:n,lastTried:s}){return t?qq({bundle:e,running:t,lastTried:s})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function Fq(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function zq({asked:e,reported:t}){return t?t!==e:!1}function Bq(e){const t=e.thresholdMs??Lq;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>=t}}function Uq(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function Wq(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.decks!="number"||typeof t.mine!="boolean")return null;const n=t.owner&&typeof t.owner=="object"?t.owner.port:null;return{path:typeof t.path=="string"&&t.path!==""?t.path:null,decks:t.decks,mine:t.mine,ownerPort:typeof n=="number"?n:null}}function Hq(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function Gq(e,t){const n=Hq(e),s=n?`removes ${n} on the canvas`:null,o=u=>`This ${s?`${s} and ${u}`:u}`;if(!t)return{note:`${o("deletes the event log on disk")} — the file a restarted deck replays to rebuild what you see, and the file every deck on this machine shares unless one was told otherwise. Layout, pins and selection go with it. This cannot be undone.`,confirm:"Clear everything"};if(!t.path)return{note:`${o("leaves nothing on disk — this deck keeps no event log")}. Layout, pins and selection go with it. This cannot be undone.`,confirm:"Clear everything"};if(!t.mine){const u=t.ownerPort===null?"another running deck owns that file":`the deck on port ${t.ownerPort} owns that file`,h=t.decks>2?`, one of ${t.decks} decks sharing it`:"";return{note:`${o(`leaves the event log alone: ${u}${h}`)}. Clearing here empties this canvas only — restart this deck and the log replays back onto it. Layout, pins and selection go with it.`,confirm:"Clear this canvas"}}if(t.decks<=1)return{note:`${o("deletes this deck's event log")} — the file a restarted deck replays to rebuild what you see. Layout, pins and selection go with it. This cannot be undone.`,confirm:"Clear everything"};const a=t.decks-1,l=a===1?"That deck keeps what is on its canvas until it restarts, and then it is gone there too.":"Those decks keep what is on their canvases until they restart, and then it is gone there too.";return{note:`${o(`deletes the event log ${a===1?"1 other running deck shares":`${a} other running decks share`} with this one`)} — every session recorded in it, not just the ones drawn here. ${l} This cannot be undone.`,confirm:"Clear everything"}}function Vq({agentCount:e,onConfirm:t,onCancel:n}){const s=E.useRef(null),o=kn(n,{focusRef:s,layer:SL}),[a,l]=E.useState(null);E.useEffect(()=>{let p=!1;return fetch("/api/clear").then(f=>f.ok?f.json():null).then(f=>{p||l(Wq(f))}).catch(()=>{}),()=>{p=!0}},[]);const{note:u,confirm:h}=Gq(e,a);return d.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:d.jsxs("div",{ref:o,className:"modal clear-confirm",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[d.jsxs("header",{className:"modal-head",children:[d.jsxs("div",{className:"modal-title",children:[d.jsx("span",{className:"status-dot err","aria-hidden":!0}),d.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),d.jsx("div",{className:"modal-actions",children:d.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),d.jsxs("section",{className:"modal-body",children:[d.jsx("p",{className:"modal-note",children:u}),d.jsxs("div",{className:"cc-actions",children:[d.jsx("button",{type:"button",ref:s,className:"btn",onClick:n,children:"Cancel"}),d.jsx("button",{type:"button",className:"btn danger",onClick:t,children:h})]})]})]})})}const Yq="One-key shortcuts run when nothing on the page has focus. A focused control keeps its own keys — this sheet included, which takes the keyboard while it is open — so Esc is the way back to the canvas.",Kq=[{title:"Canvas",rows:[{cap:"Space",action:"pause or resume the stream",binds:[" "]},{cap:"J",action:"next agent",binds:["j","J"]},{cap:"K",action:"previous agent",binds:["k","K"]},{cap:"F",action:"fit every agent on screen",binds:["f","F"]},{cap:"R",action:"re-arrange the canvas and drop the pins",binds:["r","R"]},{cap:"C",action:"clear the canvas and the event log — asks first",binds:["c","C"]}]},{title:"Panels and dialogs",rows:[{cap:"U",action:"usage panel",binds:["u","U"]},{cap:"L",action:"session list",binds:["l","L"]},{cap:"H",action:"usage history",binds:["h","H"]},{cap:"A",action:"Claude accounts, where Claude Code is installed",binds:["a","A"]},{cap:"?",action:"this sheet",binds:["?"]}]},{title:"Settings",rows:[{cap:"M",action:"sound on or off",binds:["m","M"]},{cap:"T",action:"light or dark theme",binds:["t","T"]}]},{title:"Focus and selection",rows:[{cap:"Tab",action:"reach the agent cards",binds:[]},{cap:"Enter",action:"select the focused card",binds:["Enter"]},{cap:"Shift + Enter",action:"add the focused card to the selection",binds:["Enter"]},{cap:"Esc",action:"close what is open, deselect, release focus",binds:["Escape"]}]},{title:"Mouse",rows:[{cap:"drag",action:"move a node, and pin it where you dropped it",binds:[]},{cap:"shift-click",action:"add an agent to the selection",binds:[]},{cap:"click",action:"the topbar speaker opens volume and sound settings",binds:[]}]}];function Xq({onClose:e}){const t=kn(e);return d.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:d.jsxs("div",{ref:t,className:"modal key-help",onClick:n=>n.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title",children:[d.jsxs("header",{className:"modal-head",children:[d.jsx("div",{className:"modal-title",children:d.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),d.jsx("div",{className:"modal-actions",children:d.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),d.jsxs("section",{className:"modal-body",children:[d.jsx("p",{className:"modal-note",children:Yq}),d.jsx("div",{className:"shortcuts",children:Kq.map(n=>d.jsxs(E.Fragment,{children:[d.jsx("h3",{className:"kh-group",children:n.title}),n.rows.map(s=>d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:s.cap}),d.jsx("span",{children:s.action})]},`${n.title}:${s.cap}:${s.action}`))]},n.title))})]})]})})}const Qq=["done","needs-input"],Zq=[{id:"two",label:"Two notes",notes:[{at:0,hz:740,ms:90},{at:.085,hz:440,ms:150}]},{id:"arc",label:"Descent",notes:[{at:0,hz:988,ms:80},{at:.07,hz:659,ms:80},{at:.14,hz:440,ms:160}]},{id:"tap",label:"Double tap",notes:[{at:0,hz:740,ms:55},{at:.055,hz:740,ms:55},{at:.165,hz:440,ms:150}]},{id:"chord",label:"Chord",trim:.7,notes:[{at:0,hz:988,ms:110},{at:0,hz:740,ms:110},{at:.1,hz:440,ms:170}]},{id:"bell",label:"Bell",type:"triangle",notes:[{at:0,hz:740,ms:120},{at:.11,hz:440,ms:260}]},{id:"blip",label:"Blip",type:"square",trim:.7,notes:[{at:0,hz:740,ms:55},{at:.06,hz:440,ms:90}]}],Jq=[{id:"two",label:"Two notes",notes:[{at:0,hz:440,ms:90},{at:.085,hz:740,ms:150}]},{id:"arc",label:"Ascent",notes:[{at:0,hz:440,ms:80},{at:.07,hz:659,ms:80},{at:.14,hz:988,ms:160}]},{id:"tap",label:"Double tap",notes:[{at:0,hz:440,ms:55},{at:.055,hz:440,ms:55},{at:.165,hz:740,ms:150}]},{id:"chord",label:"Chord",trim:.7,notes:[{at:0,hz:440,ms:110},{at:.1,hz:740,ms:170},{at:.1,hz:988,ms:170}]},{id:"bell",label:"Bell",type:"triangle",notes:[{at:0,hz:440,ms:120},{at:.11,hz:740,ms:260}]},{id:"blip",label:"Blip",type:"square",trim:.7,notes:[{at:0,hz:440,ms:55},{at:.06,hz:740,ms:90}]}],kw={done:Zq,"needs-input":Jq},Do="two";function Fy(e,t){const n=kw[e];return n.find(s=>s.id===t)??n.find(s=>s.id===Do)??n[0]}function kT(e,t){return kw[e].some(s=>s.id===t)?t:Do}Fy("done",Do).notes,Fy("needs-input",Do).notes;const R1=.04,eD=.24,ST=0,Sw=100,zy=5,il=50;function ol(e){if(!Number.isFinite(e))return il;const t=Math.round(e/zy)*zy;return Math.min(Sw,Math.max(ST,t))}function tD(e){if(e==null)return il;const t=e.trim();return/^-?\d+(\.\d+)?$/.test(t)?ol(Number(t)):il}function nD(e){const t=ol(e),n=R1+(eD-R1)*(t/Sw);return Math.round(n*1e4)/1e4}function rD(e,t){const n=t.trim,s=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(nD(e)*s*1e4)/1e4}const sD=160,iD="agent-dag.soundLevel.done",oD="agent-dag.soundLevel.needs-input",aD="agent-dag.soundFigure.done",lD="agent-dag.soundFigure.needs-input",NT={done:iD,"needs-input":oD},ET={done:aD,"needs-input":lD},By={done:{level:il,figure:Do},"needs-input":{level:il,figure:Do}};function cD(e){const t=n=>({level:tD(e(NT[n])),figure:kT(n,e(ET[n]))});return{done:t("done"),"needs-input":t("needs-input")}}const uD={Stop:"done",Notification:"needs-input"};function dD(e,t){var s;if(t)return null;const n=(s=e==null?void 0:e.payload)==null?void 0:s.hook_event_name;return typeof n!="string"?null:uD[n]??null}function fD(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null,s=!1;const o=()=>e.enabled()?s&&(n==null?void 0:n.state)==="running"?"ready":"locked":"off",a=()=>{var h;return(h=e.onState)==null?void 0:h.call(e,o())};function l(){var h;if(!(!t||s))try{n=n??new t,(h=n.resume)==null||h.call(n).then(a,()=>{}),s=!0,a()}catch{}}function u(h,p=!1){var S;if(!p&&!e.enabled()||!n||n.state!=="running")return!1;const f=(((S=e.prefs)==null?void 0:S.call(e))??By)[h]??By[h],g=Fy(h,f.figure),y=rD(f.level,g),w=n.currentTime;for(const b of g.notes){const _=n.createOscillator(),k=n.createGain();_.type=g.type??"sine",_.frequency.value=b.hz;const N=w+b.at,j=N+b.ms/1e3;k.gain.setValueAtTime(1e-4,N),k.gain.exponentialRampToValueAtTime(y,N+.012),k.gain.exponentialRampToValueAtTime(1e-4,j),_.connect(k).connect(n.destination),_.start(N),_.stop(j+.02)}return!0}return{unlock:l,play:u,state:o,get context(){return n}}}const A1={done:"Turn finished","needs-input":"Claude is asking"},hD={done:"Every finished turn, on both CLIs.","needs-input":"Claude Code only — Codex has no such event."};function pD({onClose:e,soundOn:t,onToggleSound:n,prefs:s,onLevel:o,onFigure:a,onPreview:l,openerRef:u}){const h=kn(e),p=E.useRef(e);return p.current=e,E.useEffect(()=>{const f=g=>{var w,S;const y=g.target;y&&((w=h.current)!=null&&w.contains(y)||(S=u.current)!=null&&S.contains(y)||p.current())};return window.addEventListener("pointerdown",f,!0),()=>window.removeEventListener("pointerdown",f,!0)},[h,u]),d.jsxs("div",{ref:h,id:"sound-menu",className:"sound-menu",role:"dialog","aria-label":"Sound settings",children:[d.jsxs("button",{type:"button",className:"btn sm-switch",onClick:n,"aria-pressed":t,children:[d.jsx("span",{className:"sm-switch-label",children:"Sound"}),d.jsx("span",{className:"sm-switch-state",children:t?"on":"off"})]}),Qq.map(f=>{const g=s[f],y=`sm-level-${f}`,w=`sm-figure-${f}`;return d.jsxs("section",{className:"sm-tone","aria-labelledby":`sm-name-${f}`,children:[d.jsxs("div",{className:"sm-tone-head",children:[d.jsx("h3",{className:"sm-tone-name",id:`sm-name-${f}`,children:A1[f]}),d.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>l(f),"aria-label":`Hear the ${A1[f].toLowerCase()} tone`,children:[d.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:d.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),"Hear it"]})]}),d.jsxs("div",{className:"sm-row",children:[d.jsx("label",{htmlFor:y,children:"Volume"}),d.jsx("input",{id:y,type:"range",min:ST,max:Sw,step:zy,value:g.level,onChange:S=>o(f,Number(S.target.value))}),d.jsxs("span",{className:"sm-read",children:[g.level,"%"]})]}),d.jsxs("div",{className:"sm-row",children:[d.jsx("label",{htmlFor:w,children:"Sound"}),d.jsx("select",{id:w,className:"sm-select",value:g.figure,onChange:S=>a(f,S.target.value),children:kw[f].map(S=>d.jsx("option",{value:S.id,children:S.label},S.id))})]}),d.jsx("p",{className:"sm-note",children:hD[f]})]},f)}),d.jsx("p",{className:"sm-foot",children:"M turns the sound on and off from anywhere."})]})}const mD={"//":["What a user would NOTICE. One key per version that has something to say,","and no key at all for a version that has nothing — which is most of them.","","The rule this file exists to serve: before every release, ask 'what would a","user notice?' and write the answer here. 'Nothing user-visible' is a valid","and expected answer, and it is spelled by adding no key. A release with no","key shows no modal, and that silence is what keeps the modal worth reading","on the day it is not silent.","","What belongs here: something that changed on the user's machine or under","their hands — a hook written to or removed from settings.json, a default","that flipped, a control that moved or went away, a stored preference that","changed meaning. What does not: bounds, races, assertions that could not","fire, anything that is invisible when it is correct.","","Write it for the person running the deck, not for the person reading the","diff. `title` is the sentence they scan; `body` is what they need in order","to act on it, or to stop worrying about it.","","Keys are versions exactly as package.json spells them. A key that is not a","version, or an entry missing either field, fails the suite rather than","being quietly dropped — see src/web/__tests__/release-notes-file.test.ts.","Ordering here is for humans; the deck sorts by version itself.","","A title may open with an emoji, and if it does, put exactly ONE space after","it. Not two: the dialog gives a leading emoji its own optical gap, because","a colour glyph is drawn edge to edge inside its advance and one word space","after one reads as none. A second space here would be a lie in the data","about a defect in the type, and the suite refuses both it and no space at","all."],"3.2.0":[{title:"🌡️ Windows shows a temperature where it can find one",body:`On most Windows laptops there is nothing to show, and that is Windows rather than this deck: modern machines declare no ACPI thermal zone, and the sensors that do exist sit behind an interface only an administrator may read. Measured on real hardware, elevated and not.
72
+ Press H for the totals ccusage reads off the logs on disk, which do not forget.`,dT="session spend";function ww({cost:e,size:t="md"}){const n=e.total;if(n<=0)return null;const s=(a,l,u)=>{if(a<=0)return null;const h=a/n*100;return d.jsx("span",{className:`cb-seg ${l}`,style:{width:`${h}%`},title:`${u}: ${Ve(a)} (${h.toFixed(0)}%)`},l)},o=t==="lg";return d.jsxs("div",{className:o?"cost-bar cost-bar-lg":"cost-bar",role:"img","aria-label":"Cost breakdown",children:[s(e.input,"cb-input","input"),s(e.output,"cb-output","output"),s(e.cacheRead,"cb-cache-r","cache read"),s(e.cacheWrite,"cb-cache-w","cache write")]})}function U3({state:e,sessionId:t,onClose:n}){const s=E.useMemo(()=>W3(e,t),[e,t]),o=E.useRef(null),a=kn(n,{focusRef:o});return s?d.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:d.jsxs("div",{ref:a,className:"modal session-summary",onClick:l=>l.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{className:"modal-title",children:[d.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),d.jsx("span",{id:"ss-title",className:"modal-tool-name",title:s.cwd??s.sessionId,children:s.label}),d.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),d.jsxs("div",{className:"modal-actions",children:[d.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.durationLabel}),d.jsx("button",{type:"button",ref:o,className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),d.jsxs("div",{className:"modal-body",children:[d.jsxs("section",{className:"ss-hero",children:[d.jsxs("div",{className:"ss-hero-left",children:[d.jsx("div",{className:"ss-cost-label",children:dT}),d.jsx("div",{className:"ss-cost",children:Ve(s.cost.total)}),s.modelChips.length>0&&d.jsx("div",{className:"ss-models",children:s.modelChips.map(l=>d.jsx("span",{className:"model-chip",title:l,children:xi(l)},l))})]}),d.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&d.jsxs(d.Fragment,{children:[d.jsx(ww,{cost:s.cost,size:"lg"}),d.jsxs("div",{className:"ss-cost-legend",children:[d.jsxs("span",{className:"ssl ssl-in",children:["input ",d.jsx("b",{children:Ve(s.cost.input)})]}),d.jsxs("span",{className:"ssl ssl-out",children:["output ",d.jsx("b",{children:Ve(s.cost.output)})]}),d.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",d.jsx("b",{children:Ve(s.cost.cacheRead)})]}),d.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",d.jsx("b",{children:Ve(s.cost.cacheWrite)})]})]})]})})]}),d.jsxs("section",{className:"ss-stats",children:[d.jsx(_o,{label:"agents",value:s.agentCount}),d.jsx(_o,{label:"subagents",value:s.subagentCount}),d.jsx(_o,{label:"tool calls",value:s.toolCount}),d.jsx(_o,{label:"prompts",value:s.promptCount}),d.jsx(_o,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&d.jsx(_o,{label:"errors",value:s.errCount,tone:"err"})]}),s.topTools.length>0&&d.jsxs("section",{className:"modal-section",children:[d.jsx("h4",{children:"Most-used tools"}),d.jsx("div",{className:"ss-top-tools",children:s.topTools.map(([l,u])=>d.jsxs("div",{className:"ss-tt",children:[d.jsx("span",{className:"ss-tt-name",children:l}),d.jsx("span",{className:"ss-tt-bar",children:d.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${u/s.topTools[0][1]*100}%`}})}),d.jsx("span",{className:"ss-tt-count",children:u})]},l))})]}),s.firstPrompt&&d.jsxs("section",{className:"modal-section",children:[d.jsx("h4",{children:"Opening prompt"}),d.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]})]})}):null}function _o({label:e,value:t,tone:n}){return d.jsxs("div",{className:`ss-stat${n?` tone-${n}`:""}`,children:[d.jsx("div",{className:"ss-stat-value",children:t}),d.jsx("div",{className:"ss-stat-label",children:e})]})}function W3(e,t){const n=e.agents.get(t);if(!n)return null;const s=[];for(const j of e.agents.values())j.sessionId===t&&s.push(j);if(s.length===0)return null;const o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},a=new Set,l=new Map;let u=0,h=0,p=0,f=0,g=0,y,w=1/0,S=0;for(const j of s){const T=bn(j);o.input+=T.input,o.output+=T.output,o.cacheRead+=T.cacheRead,o.cacheWrite+=T.cacheWrite,o.total+=T.total;for(const M of ZC(j))a.add(M);j.model&&a.add(j.model),j.kind==="subagent"&&g++,h+=j.prompts.length,!y&&j.prompts.length>0&&(y=j.prompts[0].text),p+=j.usage.inputTokens+j.usage.outputTokens,u+=j.toolCount,w=Math.min(w,j.startedAt),S=Math.max(S,j.endedAt??Date.now());for(const M of j.tools)l.set(M.name,(l.get(M.name)??0)+1),M.ok===!1&&f++}const b=Math.max(0,S-w),_=Math.floor(b/1e3),k=_<60?`${_}s`:_<3600?`${Math.floor(_/60)}m ${String(_%60).padStart(2,"0")}s`:`${Math.floor(_/3600)}h ${Math.floor(_%3600/60)}m`,N=Array.from(l.entries()).sort((j,T)=>T[1]-j[1]).slice(0,5);return{sessionId:t,label:n.label||n.cwdBasename||"session",cwd:n.cwd,durationLabel:k,cost:o,modelChips:Array.from(a),agentCount:s.length,subagentCount:g,toolCount:u,promptCount:h,tokensSum:p,errCount:f,topTools:N,firstPrompt:y}}function xw(e){return(e==null?void 0:e.kind)==="permission"}function H3(e){const t=[];for(const n of e)n.kind==="root"&&xw(n.waiting)&&t.push({id:n.id,label:n.label,waiting:n.waiting});return t.sort((n,s)=>n.waiting.since-s.waiting.since)}function G3(e){const t=new Set;for(const n of e)n.state==="active"&&t.add(n.sessionId);return t.size}function p1(e){return e.waiting?xw(e.waiting)?0:1:e.state==="active"?2:3}function V3(e,t){const n=[];for(const s of e.agents.values()){if(s.kind!=="root")continue;let o=s.toolCount,a=bn(s).total,l=s.endedAt??s.startedAt;for(const u of e.agents.values()){if(u.sessionId!==s.sessionId||u.kind==="root")continue;o+=u.toolCount,a+=bn(u).total;const h=u.endedAt??u.startedAt;h>l&&(l=h)}n.push({sessionId:s.sessionId,label:s.label||s.cwdBasename||"session",cwdBasename:s.cwdBasename,state:s.state,waiting:s.waiting,modelId:s.model,toolCount:o,cost:a,startedAt:s.startedAt,lastActivity:l})}return n.sort((s,o)=>{const a=p1(s),l=p1(o);return a!==l?a-l:s.waiting&&o.waiting?s.waiting.since-o.waiting.since:o.lastActivity-s.lastActivity}),n}function m1(e,t,n){const s=(t??n)-e;if(s<1e3)return"<1s";const o=Math.floor(s/1e3);if(o<60)return`${o}s`;const a=Math.floor(o/60);return a<60?`${a}m`:`${Math.floor(a/60)}h ${a%60}m`}function Y3({state:e,now:t,selectedIds:n,onSelect:s,onClose:o}){const a=E.useMemo(()=>V3(e),[e,e.revision,t]),l=a.filter(h=>h.state==="active").length,u=a.filter(h=>xw(h.waiting)).length;return d.jsxs("aside",{className:"session-list",id:"session-list","aria-label":"Sessions",children:[d.jsxs("div",{className:"sl-header",children:[d.jsxs("h2",{children:["Sessions ",d.jsx("span",{className:"sl-count",children:a.length})]}),u>0&&d.jsxs("span",{className:"sl-waiting-count",children:[u," waiting"]}),l>0&&d.jsxs("span",{className:"sl-live-count",children:[l," live"]}),d.jsx("button",{className:"glyph-btn sl-close",onClick:o,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),d.jsxs("div",{className:"sl-rows",children:[a.length===0&&d.jsx("div",{className:"sl-empty",children:"No sessions yet."}),a.map(h=>{const p=n.has(h.sessionId);return d.jsxs("button",{type:"button",className:`sl-row state-${h.state}${p?" selected":""}`,onClick:()=>s(h.sessionId),title:`Focus ${h.label}`,children:[d.jsx("span",{className:`sl-dot state-${h.state}`,"aria-hidden":!0}),d.jsx("span",{className:"vis-hidden",children:vw(h.state)}),d.jsxs("div",{className:"sl-row-body",children:[d.jsxs("div",{className:"sl-row-head",children:[d.jsx("span",{className:"sl-label",children:h.label}),h.modelId&&d.jsx("span",{className:"model-chip",title:h.modelId,children:xi(h.modelId)})]}),d.jsxs("div",{className:"sl-row-meta",children:[d.jsxs("span",{title:"tool calls",children:[d.jsx("b",{children:h.toolCount})," tools"]}),h.cost>0&&d.jsx("span",{className:"sl-cost",title:dT,children:d.jsx("b",{children:Ve(h.cost)})}),h.waiting?d.jsxs("span",{className:"sl-waiting",title:`${Au(h.waiting)}
73
+ Blocked since ${new Date(h.waiting.since).toLocaleTimeString()} · started ${new Date(h.startedAt).toLocaleString()}`,children:["waiting ",m1(h.waiting.since,void 0,t)]}):d.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(h.startedAt).toLocaleString()}`,children:m1(h.startedAt,h.state==="active"?void 0:h.lastActivity,t)})]})]})]},h.sessionId)})]})]})}const zt="ccdeck";function fT(e){const t=Math.max(0,e);return t<60?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function Py(e){return fT(Math.floor(e/1e3))}function hT(e,t){const n=e-t;if(n<=0)return null;const s=Math.floor(n/86400),o=Math.floor(n%86400/3600),a=Math.floor(n%3600/60);return s>0?`${s}d ${o}h`:o>0?`${o}h ${a}m`:`${a}m`}function K3(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function X3(e,t,n){const s=new Date(e),o=Py(t-e);return{label:K3(s,new Date(t))?o:`${o} · ${s.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:s.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function pT(e,t){return{disabled:e!=null&&e!==t,busy:e===t}}function mT(e){return e==null}const $y="self";function ir(e,t=!1){const n=pT(e?$y:null,$y);return{disabled:t||n.disabled,"aria-busy":n.busy}}function or(e){return mT(e?$y:null)}function Q3(e){return[...e==null?[]:[`#ap-more-${e}`],".accounts-panel .ap-refresh"]}function Z3(e){return e==null||e==="BODY"||e==="HTML"}function g1(e,t){if(!e)return null;const n=t-Math.floor(e/1e3);return n<10?"just now":n<60?`${n}s ago`:n<3600?`${Math.floor(n/60)}m ago`:`${Math.floor(n/3600)}h ago`}function J3(e){return e==="claude-swap"?"Read from claude-swap's last collection — costs no request against your usage-endpoint budget":e==="api"?"Fetched from Anthropic's usage endpoint, at most once every 5 minutes":e==="cli"?"Parsed from `claude /usage`, at most once every 5 minutes":"Last update"}const Wf="__unknown__";function e4(e,t,n,s){const o=Math.max(0,t-s),a=Math.max(0,n-o);if(a<120)return null;const l=Math.min(100,a/n*100),u=e-l;if(Math.abs(u)<3)return{label:"on pace",color:"var(--ok)",expectedPct:l,isDeficit:!1};if(u>0){const h=100-e,p=a>0?e/a:0,f=p>0?h/p:1/0,g={label:`${Math.round(u)}% ahead`,color:"var(--warn)",expectedPct:l,isDeficit:!0};if(f<o&&f<86400){const y=Math.floor(f/3600),w=Math.floor(f%3600/60);g.runsOutIn=y>0?`${y}h ${w}m`:`${w}m`}return g}return{label:`${Math.round(-u)}% reserve`,color:"var(--ok)",expectedPct:l,isDeficit:!1}}function ui({pct:e,label:t,reset:n,resetAt:s,windowSec:o,limitReached:a,nowSec:l}){const u=Math.min(100,Math.max(0,e)),p=a||u>=90?"var(--err)":u>=70?"var(--warn)":"var(--accent)",f=u===0?"< 1%":`${u}%`,g=u===0?2:u,y=s?hT(s,l):null,w=s&&o?e4(u,s,o,l):null;return d.jsxs("div",{className:"qb-row",children:[d.jsxs("div",{className:"qb-meta",children:[d.jsxs("span",{className:"qb-label",children:[t,a&&d.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),d.jsx("span",{className:"qb-pct",style:{color:p},children:f})]}),d.jsxs("div",{className:"qb-track",children:[d.jsx("div",{className:"qb-fill",style:{width:`${g}%`,background:p,opacity:u===0?.4:1}}),w&&d.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`})]}),d.jsxs("div",{className:"qb-reset-row",children:[y?d.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):n?d.jsxs("span",{className:"qb-reset",children:["resets ",n]}):null,w&&d.jsx("span",{className:"qb-pace",style:{color:w.color},children:w.runsOutIn?`runs out in ${w.runsOutIn}`:w.label})]})]})}const t4=6e4;function n4(e){const[t,n]=E.useState(null),[s,o]=E.useState(!1),a=E.useRef(null),l=E.useRef(!1),u=async(p=!1)=>{if(!(p&&!or(l.current))){p&&(l.current=!0,o(!0));try{const g=await fetch(p?"/api/quota?refresh=1":"/api/quota");g.ok&&n(await g.json())}catch{}finally{p&&(l.current=!1,o(!1))}}};return E.useEffect(()=>{if(e)return u(!0),a.current=window.setInterval(()=>u(!1),t4),()=>{a.current!=null&&window.clearInterval(a.current)}},[e]),{quota:t,loading:s,refresh:()=>{e&&u(!0)}}}function r4(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.";case"untrusted_base_url":return"chatgpt_base_url in ~/.codex/config.toml is not an https OpenAI host, so the token was not sent.";default:return"ChatGPT API unreachable — click ↻ to retry."}}const gT=6e4;function s4(e){const[t,n]=E.useState(null),[s,o]=E.useState(!1),a=E.useRef(null),l=E.useRef(!1),u=async(p=!1)=>{if(!(p&&!or(l.current))){p&&(l.current=!0,o(!0));try{const g=await fetch(p?"/api/codex-quota?refresh=1":"/api/codex-quota");g.ok&&n(await g.json())}catch{}finally{p&&(l.current=!1,o(!1))}}};return E.useEffect(()=>{if(e)return u(!0),a.current=window.setInterval(()=>u(!1),gT),()=>{a.current!=null&&window.clearInterval(a.current)}},[e]),{data:t,loading:s,refresh:()=>{e&&u(!0)}}}function i4(e){const[t,n]=E.useState(null),s=E.useRef(null),o=async()=>{try{const a=await fetch("/api/codex-usage");a.ok&&n(await a.json())}catch{}};return E.useEffect(()=>{if(e)return o(),s.current=window.setInterval(o,gT),()=>{s.current!=null&&window.clearInterval(s.current)}},[e]),{data:t}}function o4({state:e,now:t,providers:n,onClose:s}){var H,K;const{quota:o,loading:a,refresh:l}=n4(n.claude),{data:u,loading:h,refresh:p}=s4(n.codex),{data:f}=i4(n.codex),[g,y]=E.useState(()=>Math.floor(Date.now()/1e3));E.useEffect(()=>{const C=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(C)},[]);const{byModel:w,totalCost:S,totalTokens:b,burnRate:_}=E.useMemo(()=>{const C=new Map;for(const Q of e.agents.values())for(const $ of gl(Q)){const G=$.model??Wf,Y=pw($.usage,$.model),L=C.get(G);L?(L.inputTokens+=$.usage.inputTokens,L.outputTokens+=$.usage.outputTokens,L.cacheReadTokens+=$.usage.cacheReadTokens,L.cacheCreateTokens+=$.usage.cacheCreateTokens,L.cost.total+=Y.total,L.cost.input+=Y.input,L.cost.output+=Y.output,L.cost.cacheRead+=Y.cacheRead,L.cost.cacheWrite+=Y.cacheWrite,L.agentCount++):C.set(G,{model:G,inputTokens:$.usage.inputTokens,outputTokens:$.usage.outputTokens,cacheReadTokens:$.usage.cacheReadTokens,cacheCreateTokens:$.usage.cacheCreateTokens,cost:{...Y},agentCount:1,priced:Uo($.model)!=null})}const X=Array.from(C.values()).sort((Q,$)=>$.cost.total-Q.cost.total||$.inputTokens+$.outputTokens-(Q.inputTokens+Q.outputTokens));let B=0,ne=0;for(const Q of e.agents.values()){if(Q.state!=="active")continue;const $=bn(Q);B+=$.total,ne=Math.max(ne,((Q.endedAt??t)-Q.startedAt)/1e3)}const J=ne>0?gu(B,ne):null,W=uT(e.agents.values());return{byModel:X,totalCost:W.cost,totalTokens:W,burnRate:J}},[e,e.revision,t]),k=E.useMemo(()=>{const C=[];for(const X of e.agents.values()){if(X.kind!=="root")continue;let B=bn(X).total,ne=X.usage.inputTokens,J=X.usage.outputTokens,W=My(X);for(const Q of e.agents.values())Q.sessionId!==X.sessionId||Q.kind==="root"||(B+=bn(Q).total,ne+=Q.usage.inputTokens,J+=Q.usage.outputTokens,W+=My(Q));C.push({sessionId:X.sessionId,label:X.label||X.cwdBasename||"session",state:X.state,cost:B,inputTokens:ne,outputTokens:J,unpricedTokens:W})}return C.sort((X,B)=>B.cost-X.cost||B.inputTokens+B.outputTokens-(X.inputTokens+X.outputTokens)).slice(0,12)},[e,e.revision]),N=S.total>0,j=b.sum,T=w.filter(C=>C.cost.total>0||C.inputTokens+C.outputTokens>0),M=k.filter(C=>C.cost>0||C.inputTokens+C.outputTokens>0),P=T.some(C=>!C.priced),I=a||h,F=g1(o==null?void 0:o.fetchedAt,g),O=g1(u==null?void 0:u.fetchedAt,g),A=()=>{l(),p()},D=n.claude&&n.codex?"Refresh Claude + Codex quota":n.codex?"Refresh Codex quota":"Refresh Claude quota";return d.jsxs("aside",{className:"usage-panel",id:"usage-panel","aria-label":"Usage",children:[d.jsxs("div",{className:"up-header",children:[d.jsx("h2",{children:"Usage"}),_&&d.jsx("span",{className:"up-rate",children:_}),d.jsxs("div",{className:"up-header-right",children:[(n.claude||n.codex)&&d.jsx("button",{type:"button",className:"glyph-btn up-refresh-btn",onClick:A,...ir(I),"aria-label":D,title:D,children:I?"…":"↻"}),d.jsx("button",{type:"button",className:"glyph-btn up-close",onClick:s,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),n.claude&&d.jsxs("section",{className:"up-section up-quota-section",children:[d.jsxs("h3",{className:"up-section-title",children:["Claude quota",F&&!a&&d.jsx("span",{className:"up-section-age",title:J3(o==null?void 0:o.source),children:F})]}),o!=null&&o.ok?d.jsxs("div",{className:"up-quota-bars",children:[o.session5hPct!=null&&d.jsx(ui,{label:"5-hour window",pct:o.session5hPct,reset:o.session5hReset,resetAt:o.session5hResetAt,windowSec:o.session5hWindowSec,nowSec:g}),o.week7dPct!=null&&d.jsx(ui,{label:"7-day window",pct:o.week7dPct,reset:o.week7dReset,resetAt:o.week7dResetAt,windowSec:o.week7dWindowSec,nowSec:g}),o.weekSonnetPct!=null&&d.jsx(ui,{label:"Sonnet (7d)",pct:o.weekSonnetPct,nowSec:g}),o.weekOpusPct!=null&&d.jsx(ui,{label:"Opus (7d)",pct:o.weekOpusPct,nowSec:g})]}):(o==null?void 0:o.ok)===!1?d.jsxs("div",{className:"up-quota-na",children:[d.jsx("span",{children:"Quota unavailable."}),d.jsxs("span",{className:"up-quota-hint",children:["Run ",d.jsx("code",{children:"/usage"})," in a claude session, then click ↻"]})]}):d.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),n.codex&&d.jsxs("section",{className:"up-section up-quota-section",children:[d.jsxs("h3",{className:"up-section-title",children:["Codex quota",(u==null?void 0:u.ok)&&u.planLabel&&d.jsx("span",{className:"up-plan-badge",children:u.planLabel}),O&&!h&&d.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:O})]}),u!=null&&u.ok?d.jsxs("div",{className:"up-quota-bars",children:[(H=u.windows)==null?void 0:H.map(C=>d.jsx(ui,{label:C.label,pct:C.pct,reset:C.reset??void 0,resetAt:C.resetAt??void 0,windowSec:C.windowSec??void 0,limitReached:u.limitReached&&C.pct>=100,nowSec:g},C.id)),(K=u.extraWindows)==null?void 0:K.map(C=>d.jsx(ui,{label:C.label,pct:C.pct,reset:C.reset??void 0,resetAt:C.resetAt??void 0,windowSec:C.windowSec??void 0,nowSec:g},C.id)),u.creditLimit&&d.jsx(ui,{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:g}),u.creditsBalance&&!u.creditsUnlimited&&d.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",u.creditsBalance,u.overageReached&&" · overage limit reached"]}),u.creditsUnlimited&&d.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),u.resetCredits&&u.resetCredits.availableCount>0&&d.jsxs("div",{className:"up-quota-sub up-reset-credits",title:`Redeem in the Codex CLI or ChatGPT — ${zt} 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&&d.jsx("div",{className:"up-quota-sub",children:u.promo}),u.partial&&d.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?d.jsxs("div",{className:"up-quota-na",children:[d.jsx("span",{children:"Quota unavailable."}),d.jsx("span",{className:"up-quota-hint",children:r4(u.reason)})]}):d.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"}),(f==null?void 0:f.ok)&&f.window7d&&f.window7d.sessionCount>0&&d.jsxs("div",{className:"up-quota-sub",title:`Counted from the rollout files under CODEX_HOME — no network, no account${f.window5h?`
74
+ last 5h: ${Pt(f.window5h.totalTokens)} tokens · ${f.window5h.sessionCount} session${f.window5h.sessionCount!==1?"s":""}`:""}`,children:[Pt(f.window7d.totalTokens)," tokens · ",f.window7d.sessionCount," session",f.window7d.sessionCount!==1?"s":""," (7d)"]})]}),j>0?d.jsxs(d.Fragment,{children:[N&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"up-total",title:yu,children:[d.jsx("span",{className:"up-total-value",children:Ve(S.total)}),d.jsx("span",{className:"up-total-label",children:D3})]}),d.jsx(ww,{cost:S})]}),d.jsxs("div",{className:"up-tokens-row",title:yu,children:[d.jsxs("span",{className:"up-tok",children:[d.jsx("span",{className:"up-k",children:"in"}),Pt(b.inputTokens)]}),d.jsxs("span",{className:"up-tok",children:[d.jsx("span",{className:"up-k",children:"out"}),Pt(b.outputTokens)]}),b.cacheReadTokens>0&&d.jsxs("span",{className:"up-tok",children:[d.jsx("span",{className:"up-k",children:"cache r"}),Pt(b.cacheReadTokens)]}),b.cacheCreateTokens>0&&d.jsxs("span",{className:"up-tok",children:[d.jsx("span",{className:"up-k",children:"cache c"}),Pt(b.cacheCreateTokens)]}),!N&&d.jsx("span",{className:"up-tok up-scope",children:F3})]}),T.length>0&&d.jsxs("section",{className:"up-section",children:[d.jsx("h3",{className:"up-section-title",children:"By model"}),d.jsxs("table",{className:"up-table",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Model"}),d.jsx("th",{children:"Tokens"}),d.jsx("th",{children:"Cost"})]})}),d.jsx("tbody",{children:T.map(C=>d.jsxs("tr",{children:[d.jsx("td",{className:"up-model-name",title:C.model===Wf?"no model reported yet":C.model,children:C.model===Wf?"unknown":xi(C.model)}),d.jsx("td",{className:"up-num",children:Pt(C.inputTokens+C.outputTokens)}),C.priced?d.jsx("td",{className:"up-num up-cost-val",children:Ve(C.cost.total)}):d.jsx("td",{className:"up-num up-unpriced",children:su})]},C.model))})]})]}),M.length>0&&d.jsxs("section",{className:"up-section",children:[d.jsx("h3",{className:"up-section-title",children:"By session"}),d.jsx("div",{className:"up-sessions",children:M.map(C=>d.jsxs("div",{className:"up-session-row",children:[d.jsx("span",{className:`sl-dot state-${C.state}`,"aria-hidden":!0}),d.jsx("span",{className:"vis-hidden",children:vw(C.state)}),d.jsx("span",{className:"up-session-label",children:C.label}),d.jsx("span",{className:"up-session-tokens",children:Pt(C.inputTokens+C.outputTokens)}),C.cost>0?d.jsxs("span",{className:"up-session-cost",title:C.unpricedTokens>0?`${Pt(C.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[Ve(C.cost),C.unpricedTokens>0?"+":""]}):d.jsx("span",{className:"up-session-cost up-unpriced",children:su})]},C.sessionId))})]}),P&&d.jsxs("div",{className:"up-hint",children:["“",su,"” means this build holds no published rate for that model — those tokens are counted above and their dollars are not."]})]}):d.jsxs("div",{className:"up-empty",children:["No usage data yet.",d.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const a4="1",v1="agent-dag.schema",l4=["agent-dag.layout","agent-dag.viewport"];function Mu(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function c4(e,t=a4){let n=null;try{n=e.getItem(v1)}catch{return[]}if(n===t)return[];const s=[];if(n!==null)for(const o of l4)try{e.getItem(o)!==null&&(e.removeItem(o),s.push(o))}catch{}try{e.setItem(v1,t)}catch{}return s}const gt={l:30,r:6,t:6,b:2},Iu=104,u4=64;function fi(e,t=100,n=Iu){const s=n-gt.t-gt.b;return gt.t+s*(1-Math.max(0,Math.min(t,e))/t)}function d4(e,t,n,s=100,o=Iu){if(!e.length)return"";const a=e[e.length-1].t-e[0].t,l=p=>{const f=t-gt.l-gt.r;return gt.l+(a>0?f*(p-e[0].t)/a:f/2)};let u="",h=null;for(const p of e){const f=h&&p.t-h.t<=n*2?"L":"M";u+=`${f}${l(p.t).toFixed(1)} ${fi(p.v,s,o).toFixed(1)}`,h=p}return u}function f4(e,t,n,s=100,o=Iu){if(e.length<2)return"";const a=o-gt.b,l=e[e.length-1].t-e[0].t,u=t-gt.l-gt.r,h=y=>gt.l+(l>0?u*(y-e[0].t)/l:u/2);let p="",f=[];const g=()=>{if(f.length>=2){let y=`M${h(f[0].t).toFixed(1)} ${a}`;for(const w of f)y+=`L${h(w.t).toFixed(1)} ${fi(w.v,s,o).toFixed(1)}`;p+=`${y}L${h(f[f.length-1].t).toFixed(1)} ${a}Z`}f=[]};for(const y of e)f.length&&y.t-f[f.length-1].t>n*2&&g(),f.push(y);return g(),p}function h4(e){return e.length?{now:e[e.length-1].v,peak:e.reduce((t,n)=>Math.max(t,n.v),e[0].v)}:{now:null,peak:null}}function p4(e,t,n){return n!=null&&e>=n?"hot":t!=null&&e>=t?"warn":""}function m4(e,t,n=s=>Xa(s)){const s=e.filter(l=>l.v>0);if(!e.length)return null;if(!s.length)return"never held back";const o=s.length*(t/6e4),a=s[s.length-1];return`held back for ${o===1?"1 minute":`${o} minutes`}, last at ${n(a.t)}`}function Xa(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function vT(e,t){const n=Math.max(0,Math.floor((t-e)/6e4));if(n<1)return"less than a minute";if(n<60)return`${n} minute${n===1?"":"s"}`;const s=Math.floor(n/60),o=n%60;return o?`${s}h ${o}m`:`${s}h`}function g4({group:e,title:t,onClose:n}){const s=kn(n),[o,a]=E.useState(null);E.useEffect(()=>{let p=!0;const f=async()=>{try{const y=await fetch(`/api/system/history?group=${e}`);if(!y.ok)return;const w=await y.json();p&&(w!=null&&w.ok)&&a(w)}catch{}};f();const g=window.setInterval(f,2e4);return()=>{p=!1,window.clearInterval(g)}},[e]);const l=(o==null?void 0:o.series)??[],[u,h]=E.useMemo(()=>{let p=1/0,f=0;for(const g of l)g.points.length&&(p=Math.min(p,g.points[0].t),f=Math.max(f,g.points[g.points.length-1].t));return[Number.isFinite(p)?Math.max(p,(o==null?void 0:o.sinceMs)??0):(o==null?void 0:o.sinceMs)??0,f]},[l,o==null?void 0:o.sinceMs]);return ew.createPortal(d.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:d.jsxs("div",{ref:s,className:"modal hist-modal",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"hist-modal-title",children:[d.jsxs("div",{className:"modal-head",children:[d.jsx("span",{className:"modal-title",id:"hist-modal-title",children:t}),o&&u>0&&d.jsxs("span",{className:"hist-since",children:["since ",Xa(u)," · ",vT(u,h||Date.now())]}),d.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),d.jsx("div",{className:"hist-body",children:o==null?d.jsx("p",{className:"hist-empty",children:"Reading…"}):l.length===0?d.jsx("p",{className:"hist-empty",children:"Nothing has been measured yet."}):l.map(p=>d.jsx(v4,{series:p,stepMs:o.stepMs},p.label))})]})}),document.body)}function v4({series:e,stepMs:t}){const n=E.useRef(null),[s,o]=E.useState(560),[a,l]=E.useState(null);E.useEffect(()=>{const I=n.current;if(!I||typeof ResizeObserver>"u")return;const F=new ResizeObserver(([O])=>o(Math.max(160,O.contentRect.width)));return F.observe(I),()=>F.disconnect()},[]);const{points:u,unit:h,warnAt:p,critAt:f,label:g,top:y,restsAtZero:w}=e,S=w?u4:Iu,{now:b,peak:_}=h4(u),k=h==="C"?"°C":h,N=g==="Throttling"?m4(u,t):null,j=a!=null?u[a]:null,T=u.length>1?u[u.length-1].t-u[0].t:0,M=I=>{const F=s-gt.l-gt.r;return gt.l+(T>0?F*(I-u[0].t)/T:F/2)},P=I=>{if(u.length<2)return;const F=I.currentTarget.getBoundingClientRect(),O=(I.clientX-F.left-gt.l)/Math.max(1,F.width-gt.l-gt.r),A=u[0].t+T*Math.max(0,Math.min(1,O));let D=0;for(let H=1;H<u.length;H++)Math.abs(u[H].t-A)<Math.abs(u[D].t-A)&&(D=H);l(D)};return d.jsxs("section",{className:"hist-series","aria-label":`${g} history`,children:[d.jsxs("div",{className:"hist-head",children:[d.jsx("span",{className:"hist-label",children:g}),d.jsxs("span",{className:"hist-stats",children:[b!=null&&d.jsxs(d.Fragment,{children:[d.jsx("b",{children:b}),d.jsxs("span",{children:[k," now"]})]}),_!=null&&d.jsxs(d.Fragment,{children:[d.jsx("b",{className:p4(_,p,f),children:_}),d.jsxs("span",{children:[k," peak"]})]})]})]}),d.jsx("div",{className:"hist-plot",ref:n,children:d.jsxs("svg",{className:"hist-chart",width:"100%",height:S,viewBox:`0 0 ${s} ${S}`,preserveAspectRatio:"none",role:"img","aria-label":b==null?`${g}: nothing measured yet`:`${g}: ${b}${k} now, peak ${_}${k}, over ${vT(u[0].t,u[u.length-1].t)}`,onPointerMove:P,onPointerLeave:()=>l(null),children:[[["warn",p],["hot",f]].map(([I,F])=>F==null||F>y?null:d.jsxs("g",{children:[d.jsx("line",{className:`hist-rule ${I}`,x1:gt.l,x2:s-gt.r,y1:fi(F,y,S),y2:fi(F,y,S)}),d.jsx("text",{className:`hist-rule-tag ${I}`,x:2,y:fi(F,y,S)+3,children:F})]},I)),d.jsx("line",{className:"hist-floor",x1:gt.l,x2:s-gt.r,y1:S-gt.b,y2:S-gt.b}),d.jsx("path",{className:"hist-area",d:f4(u,s,t,y,S)}),d.jsx("path",{className:"hist-line",d:d4(u,s,t,y,S)}),u.length===1&&d.jsx("circle",{className:"hist-dot",cx:M(u[0].t),cy:fi(u[0].v,y,S),r:3}),j&&d.jsxs("g",{children:[d.jsx("line",{className:"hist-cross",x1:M(j.t),x2:M(j.t),y1:gt.t,y2:S-gt.b}),d.jsx("circle",{className:"hist-dot",cx:M(j.t),cy:fi(j.v,y,S),r:3})]})]})}),d.jsx("div",{className:"hist-axis",children:j?d.jsxs("span",{className:"hist-at",children:[Xa(j.t)," — ",d.jsx("b",{children:j.v}),k]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{children:u.length?Xa(u[0].t):""}),d.jsx("span",{children:u.length?Xa(u[u.length-1].t):""})]})}),N&&d.jsx("div",{className:"hist-note",children:N})]})}function y4({procs:e,total:t,onClose:n}){const s=kn(n),[o,a]=E.useState(yT),l=Ly(e,o);return ew.createPortal(d.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:d.jsxs("div",{ref:s,className:"modal pl-modal",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"pl-modal-title",children:[d.jsxs("div",{className:"modal-head",children:[d.jsx("span",{className:"modal-title",id:"pl-modal-title",children:"Busiest processes"}),d.jsxs("span",{className:"pl-count",children:[l.length," of ",t," running"]}),d.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),d.jsx("div",{className:"pl-body",children:l.length===0?d.jsx("p",{className:"pl-empty",children:"Could not read the process list on this platform."}):d.jsxs("table",{className:"sd-procs pl-table",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx(Mo,{col:"cpu",label:"cpu",sort:o,onSort:a}),d.jsx(Mo,{col:"mem",label:"mem",sort:o,onSort:a}),d.jsx("th",{scope:"col",className:"pl-pid-h",children:"pid"}),d.jsx(Mo,{col:"name",label:"process",sort:o,onSort:a})]})}),d.jsx("tbody",{children:l.map(u=>d.jsxs("tr",{children:[d.jsx("td",{className:"sd-num",children:u.cpu==null?"—":u.cpu.toFixed(0)}),d.jsx("td",{className:"sd-num sd-dim",children:u.mem.toFixed(1)}),d.jsx("td",{className:"sd-num sd-dim pl-pid",children:u.pid}),d.jsx("td",{className:"pl-name",children:u.name})]},u.pid))})]})}),d.jsx("div",{className:"pl-foot",children:"The busiest by processor and by memory, refreshed every four seconds. Not every process on the machine."})]})}),document.body)}const w4=3e3,x4=4e3,Hf=20,za=36,ko=8,b4=8,yT={key:"cpu",dir:"desc",rank:"cpu"};function _4(e,t){return e.key===t?{...e,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:t==="name"?"asc":"desc",rank:t==="name"?e.rank:t}}function Ly(e,t){const n=t.dir==="asc"?1:-1,s=(o,a)=>{if(t.key==="name")return n*o.name.localeCompare(a.name,void 0,{sensitivity:"base"});const l=t.key==="cpu"?o.cpu:o.mem,u=t.key==="cpu"?a.cpu:a.mem;return l==null||u==null?l==null?u==null?0:1:-1:n*(l-u)};return[...e].sort((o,a)=>s(o,a)||(a.cpu??-1)-(o.cpu??-1)||a.mem-o.mem||o.pid-a.pid)}function k4(e,t,n=b4){const s=Ly(e,{key:t.rank,dir:"desc",rank:t.rank});return Ly(s.slice(0,n),t)}function S4(e,t){return e.key!==t?"none":e.dir==="asc"?"ascending":"descending"}function N4(e,t,n){return e>=n?"hot":e>=t?"warn":"calm"}function E4(e,t,n=Date.now()){const s=Math.max(0,Math.min(100,100-e));return{pct:s,value:`${s}%`,tone:s===0?"calm":s>=30?"hot":"warn",note:s>0?`CPU held to ${e}% of full speed to cool down`:t?`at full speed · held to ${100-t.peak}% ${j4(t.lastMs,n)}`:"running at full speed, and never held back"}}function j4(e,t=Date.now()){const n=Math.max(0,Math.floor((t-e)/6e4));if(n<2)return"just now";if(n<60)return`${n} minutes ago`;const s=Math.floor(n/60);return s===1?"an hour ago":`${s} hours ago`}const wT="agent-dag.systemPanelOpen";function C4(){return Mu(wT)==="1"}function T4(e){if(!(typeof window>"u"))try{window.localStorage.setItem(wT,e?"1":"0")}catch{}}function hi(e){return e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} KB`}function R4(e){const t=Math.floor(e/86400),n=Math.floor(e%86400/3600),s=Math.floor(e%3600/60);return t>0?`${t}d ${n}h`:n>0?`${n}h ${s}m`:`${s}m`}function A4(){const[e,t]=E.useState(null),n=E.useRef(null);return E.useEffect(()=>{let s=!0;const o=async()=>{if(document.visibilityState!=="hidden")try{const h=await fetch("/api/system");if(!h.ok)return;const p=await h.json();s&&(p!=null&&p.ok)&&t(p)}catch{}},a=()=>{n.current==null&&(o(),n.current=window.setInterval(o,w4))},l=()=>{n.current!=null&&(window.clearInterval(n.current),n.current=null)},u=()=>{if(document.visibilityState==="hidden"){l();return}a(),o()};return a(),document.addEventListener("visibilitychange",u),()=>{s=!1,l(),document.removeEventListener("visibilitychange",u)}},[]),e}function M4(e){const[t,n]=E.useState(null);return E.useEffect(()=>{let s=!0;const o=async()=>{if(document.visibilityState!=="hidden")try{const l=await fetch("/api/system/processes");if(!l.ok)return;const u=await l.json();s&&(u!=null&&u.ok)&&n({procs:u.procs??[],total:u.total??0})}catch{}};o();const a=window.setInterval(o,x4);return()=>{s=!1,window.clearInterval(a)}},[e]),t}function I4({usageOpen:e=!1}){const t=A4(),[n,s]=E.useState(C4);E.useEffect(()=>{T4(n)},[n]);const o=E.useRef(null),a=E.useRef(null);if(E.useEffect(()=>{if(n)return Ao.push(()=>{var k,N;const _=((k=a.current)==null?void 0:k.contains(document.activeElement))??!1;s(!1),_&&((N=o.current)==null||N.focus())},nT)},[n]),!t||t.cpu==null||!t.memory)return d.jsx("span",{className:"sysmeter idle",title:"Sampling this machine…",children:d.jsx("span",{className:"sm-box","aria-hidden":!0,children:d.jsxs("span",{className:"sm-graphic",children:[d.jsx("svg",{className:"sm-spark",width:za,height:ko,viewBox:`0 0 ${za} ${ko}`}),d.jsx("span",{className:"sm-ram"})]})})});const{cpu:l,cpuHistory:u,cores:h,memory:p,loadavg:f}=t,g=p.usedPct>=90,y=u.slice(-Hf),w=Hf-y.length,S=za/Hf,b=[`CPU ${l.toFixed(0)}% of ${h} cores`,f?`load ${f[0]} · ${f[1]} · ${f[2]} (1m · 5m · 15m)`:null,`Memory ${hi(p.total-p.available)} of ${hi(p.total)} used`,"","Click for detail. This machine, not this session."].filter(_=>_!==null).join(`
75
+ `);return d.jsxs("span",{className:"sysmeter-wrap",children:[d.jsxs("button",{type:"button",ref:o,className:"sysmeter",title:b,"aria-label":"Toggle machine detail","aria-expanded":n,"aria-controls":n?"system-panel":void 0,onClick:()=>s(_=>!_),children:[d.jsxs("span",{className:"sm-box","aria-hidden":!0,children:[d.jsxs("span",{className:"sm-graphic",children:[d.jsx("svg",{className:"sm-spark",width:za,height:ko,viewBox:`0 0 ${za} ${ko}`,children:y.map((_,k)=>{const N=w+k,j=Math.max(1,_/100*ko),T=.32+.68*((k+1)/y.length);return d.jsx("rect",{x:N*S,y:ko-j,width:Math.max(.8,S-.7),height:j,rx:.5,fill:"var(--accent)",opacity:T},N)})}),d.jsx("span",{className:"sm-ram",children:d.jsx("span",{className:`sm-ram-fill${g?" warn":""}`,style:{transform:`scaleX(${Math.max(2,p.usedPct)/100})`}})})]}),d.jsxs("span",{className:"sm-read",children:[d.jsx("b",{children:l.toFixed(0)}),d.jsx("i",{children:"·"}),d.jsx("b",{children:p.usedPct.toFixed(0)})]})]}),d.jsxs("span",{className:"sm-sr",children:["CPU ",l.toFixed(0)," percent, memory ",p.usedPct.toFixed(0)," percent used"]})]}),n&&d.jsx(O4,{sys:t,usageOpen:e,panelRef:a,onClose:()=>{var _;s(!1),(_=o.current)==null||_.focus()}})]})}function O4({sys:e,usageOpen:t,panelRef:n,onClose:s}){const o=M4(!0),{memory:a,swap:l,perCore:u,loadavg:h,cores:p,uptimeSec:f,platform:g,thermal:y}=e,w=a?a.total-a.available:0,S=g==="win32"?"Commit":"Swap",b=l&&l.total>0?l.used/l.total*100:0;return d.jsxs("aside",{ref:n,className:`sysdetail${t?" shifted":""}`,id:"system-panel","aria-label":"Machine detail",children:[d.jsxs("div",{className:"sd-head",children:[d.jsx("span",{className:"sd-title",children:"This machine"}),d.jsxs("span",{className:"sd-sub",children:["up ",R4(f)," · ",p," cores"]}),d.jsx("button",{type:"button",className:"glyph-btn sd-close",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),u&&u.length>0&&d.jsx("div",{className:"sd-section",role:"group","aria-label":"Cores",children:d.jsx(iu,{group:"cores",title:"Core history",action:"Show core history",label:"Cores",children:d.jsx("div",{className:"sd-cores",style:{"--n":u.length},children:u.map((_,k)=>d.jsx("span",{className:"sd-core",title:`core ${k+1}: ${_}%`,children:d.jsx("span",{className:"sd-core-fill",style:{transform:`scaleY(${Math.max(2,_)/100})`}})},k))})})}),d.jsx("div",{className:"sd-section",role:"group","aria-label":"Memory",children:d.jsxs(iu,{group:"memory",title:"Memory history",action:"Show memory history",label:"Memory",children:[a&&d.jsx(wu,{label:"Physical",value:d.jsxs(d.Fragment,{children:[d.jsx("b",{children:hi(w)})," of ",hi(a.total)]}),pct:a.usedPct,tone:a.usedPct>=90?"warn":"calm",note:`${hi(a.available)} available`}),l&&l.total>0&&d.jsx(wu,{label:S,value:d.jsxs(d.Fragment,{children:[d.jsx("b",{children:hi(l.used)})," of ",hi(l.total)]}),pct:b,tone:b>=90?"warn":"calm",note:b>=50?"paging to disk":void 0})]})}),h&&d.jsx("div",{className:"sd-section",role:"group","aria-label":"Load average",children:d.jsxs(iu,{group:"load",title:"Load history",action:"Show load history",label:"Load average",children:[d.jsx("div",{className:"sd-load",children:h.map((_,k)=>d.jsxs("span",{className:`sd-load-item${_>p?" over":""}`,children:[d.jsx("b",{children:_.toFixed(2)}),d.jsx("span",{children:["1m","5m","15m"][k]})]},k))}),d.jsx("div",{className:"sd-note",children:h[0]>p?`${(h[0]/p).toFixed(1)}× more work queued than cores to run it`:`within ${p} cores`})]})}),d.jsx(P4,{thermal:y}),d.jsx($4,{read:o})]})}function iu({group:e,title:t,action:n,label:s,children:o}){const[a,l]=E.useState(!1);return d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"sd-open",onClick:()=>l(!0),title:n,"aria-label":n,children:[d.jsxs("div",{className:"sd-h","aria-hidden":!0,children:[s," ",d.jsx("i",{className:"sd-row-more",children:"›"})]}),o]}),a&&d.jsx(g4,{group:e,title:t,onClose:()=>l(!1)})]})}function P4({thermal:e}){if(!e)return null;const t=e.throttle?E4(e.throttle.speedLimit,e.heldBack):null;return d.jsx("div",{className:"sd-section",role:"group","aria-label":"Thermal",children:d.jsxs(iu,{group:"thermal",title:"Thermal history",action:"Show thermal history",label:"Thermal",children:[e.celsius.map(n=>d.jsx(wu,{label:n.label,value:d.jsxs(d.Fragment,{children:[d.jsx("b",{children:n.celsius})," °C"]}),pct:n.celsius,tone:N4(n.celsius,n.warnAt,n.critAt)},n.label)),t&&d.jsx(wu,{label:"Throttling",value:t.value,pct:t.pct,tone:t.tone,note:t.note})]})})}function $4({read:e}){const[t,n]=E.useState(yT),[s,o]=E.useState(!1),a=(e==null?void 0:e.procs)??null;return d.jsxs("div",{className:"sd-section",role:"group","aria-label":"Busiest processes",children:[d.jsxs("div",{className:"sd-hrow",children:[d.jsx("div",{className:"sd-h","aria-hidden":!0,children:"Busiest processes"}),a!=null&&a.length>0&&d.jsxs("button",{type:"button",className:"sd-all",onClick:()=>o(!0),title:"Show every process the deck is watching","aria-label":"Show every process the deck is watching",children:["more ",d.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]})]}),s&&e&&d.jsx(y4,{procs:e.procs,total:e.total,onClose:()=>o(!1)}),a==null?d.jsx("div",{className:"sd-note",children:"reading…"}):a.length===0?d.jsx("div",{className:"sd-note",children:"Could not read the process list on this platform."}):d.jsxs("table",{className:"sd-procs",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx(Mo,{col:"cpu",label:"cpu",sort:t,onSort:n}),d.jsx(Mo,{col:"mem",label:"mem",sort:t,onSort:n}),d.jsx(Mo,{col:"name",label:"process",sort:t,onSort:n})]})}),d.jsx("tbody",{children:k4(a,t).map(l=>d.jsxs("tr",{children:[d.jsx("td",{className:"sd-num",children:l.cpu==null?"—":l.cpu.toFixed(0)}),d.jsx("td",{className:"sd-num sd-dim",children:l.mem.toFixed(1)}),d.jsx("td",{className:"sd-proc-name",title:`pid ${l.pid}`,children:l.name})]},l.pid))})]})]})}function Mo({col:e,label:t,sort:n,onSort:s}){const o=S4(n,e);return d.jsx("th",{scope:"col","aria-sort":o,children:d.jsxs("button",{type:"button",className:"sd-sort",title:`Sort by ${t}`,onClick:()=>s(_4(n,e)),children:[t,d.jsx("span",{className:"sd-sort-dir","aria-hidden":!0,children:o==="none"?"":o==="ascending"?"↑":"↓"})]})})}function wu({label:e,value:t,pct:n,tone:s="calm",note:o}){return d.jsxs("div",{className:"sd-row",children:[d.jsxs("div",{className:"sd-row-head",children:[d.jsx("span",{className:"sd-row-label",children:e}),d.jsx("span",{className:"sd-row-val",children:t})]}),d.jsx("span",{className:"sd-track",children:d.jsx("span",{className:`sd-fill${s==="calm"?"":` ${s}`}`,style:{transform:`scaleX(${n<=0?0:Math.max(1,Math.min(100,n))/100})`}})}),o&&d.jsx("div",{className:"sd-note",children:o})]})}const y1=18,L4=1100,So=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},q4=Array.from({length:y1},(e,t)=>{const n=-72+144*t/(y1-1)+(So(t,1)-.5)*9,s=(n-90)*(Math.PI/180),o=(54+32*Math.cos(n*Math.PI/180))*(.74+So(t,2)*.52);return{dx:Math.cos(s)*o,dy:Math.sin(s)*o,rot:(t%2?1:-1)*(100+So(t,3)*260),delay:Math.round(So(t,4)*90),dur:760+Math.round(So(t,5)*260),scale:.8+So(t,6)*.45,hue:t%4,round:t%3===0}});function w1({anchor:e,lifetimeMs:t=L4}){var a;const[n,s]=E.useState(null),o=typeof window<"u"&&((a=window.matchMedia)==null?void 0:a.call(window,"(prefers-reduced-motion: reduce)").matches);return E.useEffect(()=>{if(o)return;const l=e.current;if(!l)return;const u=l.getBoundingClientRect();s({x:u.left+u.width/2,y:u.top+u.height/2});const h=window.setTimeout(()=>s(null),t);return()=>window.clearTimeout(h)},[e,t,o]),o||!n?null:ew.createPortal(d.jsx("div",{className:"confetti",style:{left:`${n.x}px`,top:`${n.y}px`},"aria-hidden":!0,children:q4.map((l,u)=>d.jsx("span",{className:`confetti-bit${l.round?" round":""}`,"data-hue":l.hue,style:{"--dx":`${l.dx.toFixed(1)}px`,"--dy":`${l.dy.toFixed(1)}px`,"--rot":`${l.rot}deg`,"--s":l.scale.toFixed(2),animationDelay:`${l.delay}ms`,animationDuration:`${l.dur}ms, ${l.dur}ms`}},u))}),document.body)}const xT=new Set(["awaiting_url","awaiting_code","registering"]);function D4(e){return e!=null&&xT.has(e)}function bT(e){return e!=null&&e!=="done"&&!xT.has(e)}const F4="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",z4="the sign-in did not complete";function B4({state:e,serverError:t,localError:n}){const s=e==="idle";return{title:s?"Sign-in ended":"Sign-in failed",message:n||t||(s?F4:z4)}}const U4="done";function W4(){let e=!1;return{shouldAnnounce(t){return t!==U4?(e=!1,!1):e?!1:(e=!0,!0)}}}function bw(e,t){return t&&Object.hasOwn(e,t)?e[t]:void 0}const H4={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 ccdeck2:",corrupt:"that share is incomplete — copy the whole thing",wrong_version:`that share was made by a newer ${zt}`,expired:"that share has expired — make a new one",import_failed:"claude-swap refused the import",unreadable_export:"claude-swap wrote something this deck could not read — try again, and upgrade it if this repeats",mixed_versions:"claude-swap changed format part-way through — try again",nothing_to_share:"none of those accounts could be exported",too_many:"that is more accounts than one share can carry",not_in_bundle:"that account is not in this share",bad_value:"an alias can only use letters, numbers, spaces, dots, dashes and underscores, up to 64 characters, and cannot start with a dash",bad_email:"that does not look like an email address — it cannot contain spaces or start with a dash"},G4={no_cswap:"claude-swap could not be run — it is not on this deck's PATH. Set AGENTS_DECK_CSWAP to its full path",timeout:"claude-swap took too long and was stopped — try again",switch_failed:"claude-swap refused the switch",bad_account:"that is not an account claude-swap has",unknown_setting:"claude-swap has no such setting",out_of_range:"that value is outside what the setting allows",bad_value:"claude-swap does not accept that value",set_failed:"claude-swap refused the change",command_failed:"claude-swap refused the command"},V4=`claude-swap could not read the login keychain — start ${zt} from a Terminal window rather than a background service`;function qy(e,t){if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(qo(e)))return V4;const n=bw(G4,e==null?void 0:e.reason);return n||(e==null?void 0:e.reason)||t}function qo(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const Y4={no_install:"ccusage is not installed, and AGENTS_DECK_NO_INSTALL=1 forbids fetching it — unset that variable and restart the deck, or install ccusage yourself so it is on this deck's PATH",bad_override:"AGENTS_DECK_CCUSAGE names a file that is not there — correct it to the full path of your ccusage, or unset it to let the deck find its own",timeout:"ccusage took more than 90 seconds and was stopped — a narrower range usually finishes",bad_output:"ccusage ran but printed no usage data — try again, and run ccusage daily --json in a terminal if it keeps happening",run_failed:"ccusage could not report usage — try again",bad_range:"that date range is not a YYYYMMDD date — reopen the modal and pick one of the presets",unreachable:"the deck did not answer — check it is still running, then try again"},K4="ccusage could not be started — npx is not on this deck's PATH. Install Node's npm/npx, or put ccusage on PATH yourself";function X4(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const Q4="ccusage could not be started — the deck launched npx and Node could not load the npm script it points at. An older deck asked cmd.exe for a bare npx.cmd, which made the shim look for that script under the deck's working directory instead of beside itself; update the deck and reopen this modal",Z4="ccusage could not be started — the copy npx fetched will not load: Node could not resolve a file inside it. That copy is in npx's own cache, which the deck never rewrites, so clear it with `npm cache clean --force` and reopen this modal",J4=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),eq=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,tq=/[\\/]_npx[\\/]/i,nq=`the copy of ccusage ${zt} installed for itself`;function rq(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function sq(e,t){const n=iq(e,t),s=rq(e);switch(e==null?void 0:e.stage){case"npx":return s?`ccusage failed on both of its paths. The managed install failed first — ${s} — and the deck then fell back to npx, where ${Ba(n)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${Ba(n)}`;case"managed":return`${nq} failed to run: ${Ba(n)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${Ba(n)}`:`the ccusage this deck found on your PATH failed to run: ${Ba(n)}`;default:return n}}const Ba=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function iq(e,t){const n=qo(e);if(J4(n)){if(tq.test(n))return Z4;if(eq.test(n))return Q4}if(X4(n))return K4;const s=bw(Y4,e==null?void 0:e.reason);return s||(e==null?void 0:e.reason)||t}function jo(e,t){if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&bT(e.state))return e.error;const n=bw(H4,e==null?void 0:e.reason);return n||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function oq(e,t,n){if(n<=0||mw(e))return{kind:"pass"};const s=t>=0&&t<n?t:-1;switch(e.key){case"ArrowRight":return{kind:"select",index:s===-1?0:(s+1)%n};case"ArrowLeft":return{kind:"select",index:s===-1?n-1:(s-1+n)%n};case"Home":return{kind:"select",index:0};case"End":return{kind:"select",index:n-1};default:return{kind:"pass"}}}function _T(e,t){const n=Math.round(e/1e3)-t;return n<=0?{text:"expired",tone:"gone"}:n<60?{text:`expires in ${n}s`,tone:"soon"}:{text:`expires in ${Math.round(n/60)}m`,tone:"ok"}}function aq(e){const t=new Map;for(const n of e){const s=(n.email??"").trim().toLowerCase();s&&t.set(s,(t.get(s)??0)+1)}return e.map(n=>{const s=(n.email??"").trim(),o=n.alias||s||`account ${n.num}`,a=[];return n.alias&&s&&a.push(s),s&&(t.get(s.toLowerCase())??0)>1&&a.push(n.org||`slot ${n.num}`),{num:n.num,label:o,sub:a.length?a.join(" · "):null}})}function lq(e){return e<=0?"Nothing picked yet.":e===1?"1 account — its sign-in token will be on your clipboard.":`${e} accounts — ${e} sign-in tokens will be on your clipboard.`}function cq(e){switch(e){case"imported":return"imported";case"healed":return"dead token replaced";case"updated":return"updated";case"present":return"already here";default:return"not imported"}}function uq(e){const t=e.length;if(!t)return"Nothing to import.";const n=p=>e.filter(f=>f.state===p).length,s=[],o=n("imported");o&&s.push(`${o} of ${t} imported`);const a=n("healed");a&&s.push(`${a} had a dead token replaced`);const l=n("updated");l&&s.push(`${l} updated`);const u=n("present");u&&s.push(`${u} already here`);const h=n("failed");return h&&s.push(`${h} did not arrive`),`${s.join(", ")}.`}const dq=1500,Gc=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],x1="aa-panel",b1=e=>`aa-tab-${e}`;async function Ua(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const Dy=ue.forwardRef((e,t)=>d.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:t,children:[d.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),d.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));Dy.displayName="SuccessMark";function fq({onClose:e,onChanged:t}){const[n,s]=E.useState("login"),[o,a]=E.useState(null),[l,u]=E.useState(""),[h,p]=E.useState(""),[f,g]=E.useState(!1),[y,w]=E.useState(null),[S,b]=E.useState(null),[_,k]=E.useState(null),[N,j]=E.useState(null),T=E.useRef(""),M=E.useRef(!1),P=E.useRef(!1),I=E.useRef(null),F=E.useRef(null),O=E.useRef(null),A=E.useRef(null),D=E.useRef([]),H=E.useRef(!1),K=E.useCallback(()=>{M.current&&Ua({action:"login-cancel"}).catch(()=>{}),e()},[e]),C=kn(K,{focusRef:O}),X=E.useCallback(async()=>{if(!or(P.current))return;P.current=!0,g(!0),w(null),M.current=!0;const q=await Ua({action:"login"}).catch(()=>null);if(P.current=!1,g(!1),!(q!=null&&q.ok)){w(jo(q,"could not start the sign-in"));return}a(q)},[]);E.useEffect(()=>{if(!D4(o==null?void 0:o.state))return;const q=window.setInterval(async()=>{try{const Z=await fetch("/api/claude-accounts/login");Z.ok&&a(await Z.json())}catch{}},dq);return()=>window.clearInterval(q)},[o]);const B=E.useRef(t);B.current=t;const ne=E.useState(W4)[0];E.useEffect(()=>{var q;(o==null?void 0:o.state)==="awaiting_code"&&((q=I.current)==null||q.focus()),ne.shouldAnnounce(o==null?void 0:o.state)&&B.current()},[o==null?void 0:o.state,ne]),E.useEffect(()=>{var q;n==="paste"&&!H.current&&((q=F.current)==null||q.focus()),H.current=!1},[n]);const J=E.useCallback(q=>{var se;const Z=oq(q,Gc.findIndex(fe=>fe.id===n),Gc.length);Z.kind!=="pass"&&(q.preventDefault(),H.current=!0,s(Gc[Z.index].id),(se=D.current[Z.index])==null||se.focus())},[n]),W=E.useCallback(async()=>{var Z;if(!or(P.current))return;P.current=!0,g(!0),w(null);const q=await Ua({action:"login-code",code:l}).catch(()=>null);if(P.current=!1,g(!1),!(q!=null&&q.ok)){w(jo(q,"the code was not accepted")),q!=null&&q.state&&a(q),(Z=I.current)==null||Z.select();return}u(""),a(q)},[l,o]),Q=E.useCallback(async()=>{if(!or(P.current))return;P.current=!0,g(!0),w(null);const q=await Ua({action:"import",blob:h}).catch(()=>null);if(P.current=!1,g(!1),!(q!=null&&q.ok)){w(jo(q,"the import failed"));return}T.current=h,p(""),j(null),b(q.results??[]),t()},[h,t]),$=E.useCallback(async q=>{const Z=`${q.email}|${q.org??""}`;if(!or(P.current)||!T.current)return;P.current=!0,g(!0),k(Z),j(null);const se=await Ua({action:"import",blob:T.current,force:!0,only:{email:q.email,org:q.org??""}}).catch(()=>null);if(P.current=!1,g(!1),k(null),!(se!=null&&se.ok)){j({key:Z,text:jo(se,"that account could not be updated")});return}const fe=(se.results??[])[0];fe&&b(he=>he&&he.map(ye=>`${ye.email}|${ye.org??""}`===Z?fe:ye)),t()},[t]),G=(o==null?void 0:o.state)==="done"?o.account:null,Y=bT(o==null?void 0:o.state)||!!(y&&M.current&&!f),L=B4({state:o==null?void 0:o.state,serverError:o==null?void 0:o.error,localError:y});return d.jsx("div",{className:"modal-backdrop",onClick:K,role:"presentation",children:d.jsxs("div",{ref:C,className:"modal aa-modal",onClick:q=>q.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[d.jsxs("header",{className:"modal-head",children:[d.jsx("div",{className:"modal-title",children:d.jsx("span",{className:"aa-tabs",role:"tablist","aria-label":"How to add the account",onKeyDown:J,children:Gc.map((q,Z)=>d.jsx("button",{type:"button",role:"tab",id:b1(q.id),ref:se=>{D.current[Z]=se},"aria-selected":n===q.id,"aria-controls":x1,tabIndex:n===q.id?0:-1,className:`aa-tab${n===q.id?" on":""}`,onClick:()=>{H.current=!1,s(q.id)},children:q.label},q.id))})}),d.jsx("div",{className:"modal-actions",children:d.jsx("button",{type:"button",className:"glyph-btn",onClick:K,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),d.jsx("section",{className:"modal-body aa-body",id:x1,role:"tabpanel","aria-labelledby":b1(n),children:n==="login"?G?d.jsxs("div",{className:"aa-done",children:[d.jsx(Dy,{ref:A}),d.jsx(w1,{anchor:A}),d.jsx("h4",{children:G.added?`Account ${G.num} added`:"Credentials refreshed"}),d.jsxs("p",{className:"aa-note",children:[d.jsx("strong",{children:G.email}),G.added?" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),d.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"?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"aa-step",children:[d.jsx("h4",{children:"1 · Approve in the browser"}),d.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),d.jsx("a",{className:"aa-link",href:o.url??"#",target:"_blank",rel:"noreferrer noopener",children:o.url})]}),d.jsxs("div",{className:"aa-step",children:[d.jsx("h4",{children:"2 · Paste a code, if the page shows one"}),d.jsx("p",{className:"aa-note",children:"It usually finishes on its own — if the page says you are all set, there is nothing to do here."}),d.jsxs("div",{className:"aa-field",children:[d.jsx("input",{ref:I,type:"text",value:l,onChange:q=>u(q.target.value),onKeyDown:q=>{q.key==="Enter"&&l.trim()&&!f&&W()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:o.state==="registering"}),d.jsx("button",{type:"button",className:"btn primary",...ir(f,!l.trim()||o.state==="registering"),onClick:W,children:o.state==="registering"?"registering…":"Continue"})]}),(y||o.error)&&d.jsx("p",{className:"aa-err",children:y??o.error}),d.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."})]})]}):Y?d.jsxs("div",{className:"aa-step",children:[d.jsx("h4",{children:L.title}),d.jsx("p",{className:"aa-err",children:L.message}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{M.current=!1,a(null),w(null),X()},children:"Try again"})]}):f||M.current?d.jsx("div",{className:"aa-step",children:d.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):d.jsxs("div",{className:"aa-step aa-primer",children:[d.jsx("h4",{children:"Sign in to Anthropic"}),d.jsx("p",{className:"aa-note",children:"Opens a browser tab where you approve the sign-in. It normally completes by itself; only if the page hands you a code does it need pasting back here. claude-swap records the account when it completes, and the account you are using now stays active."}),d.jsx("div",{className:"aa-actions",children:d.jsx("button",{type:"button",ref:O,className:"btn primary",onClick:X,children:"Open the sign-in page"})})]}):S?(()=>{const q=S.filter(Z=>Z.state==="imported").length;return d.jsxs("div",{className:"aa-done",children:[d.jsx(Dy,{ref:A}),q>0&&d.jsx(w1,{anchor:A}),d.jsx("h4",{children:uq(S)}),S.length>0&&d.jsx("ul",{className:"aa-results",children:S.map(Z=>{const se=`${Z.email}|${Z.org??""}`;return d.jsxs("li",{className:`aa-result ${Z.state}`,children:[d.jsx("span",{className:"aa-result-who",children:Z.email||(Z.num?`slot ${Z.num}`:"an account")}),d.jsx("span",{className:"aa-result-what",children:cq(Z.state)}),Z.state==="present"&&d.jsx("button",{type:"button",className:"aa-result-fix","aria-busy":_===se,title:`Overwrite the stored login for ${Z.email} with the one in this share. Do this when that account has stopped working here; if it works, leave it.`,onClick:()=>$(Z),children:_===se?"updating…":"update anyway"}),(N==null?void 0:N.key)===se&&d.jsx("span",{className:"aa-result-err",children:N.text})]},se)})}),d.jsxs("p",{className:"aa-note",children:["Nothing changed on the deck you copied this from. An account already here is left as it is, unless its stored login was dead or you pressed",d.jsx("strong",{children:" update anyway"}),"."]}),d.jsxs("div",{className:"aa-actions",children:[d.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{T.current="",j(null),b(null)},children:"Import another"})]})]})})():d.jsxs("div",{className:"aa-step",children:[d.jsx("h4",{children:"Paste an account shared from another deck"}),d.jsxs("div",{className:"aa-field",children:[d.jsx("input",{ref:F,type:"text",value:h,onChange:q=>p(q.target.value),onKeyDown:q=>{q.key==="Enter"&&h.trim()&&!f&&Q()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),d.jsx("button",{type:"button",className:"btn primary",...ir(f,!h.trim()),onClick:Q,children:f?"importing…":"Import"})]}),y&&d.jsx("p",{className:"aa-err",children:y}),d.jsxs("p",{className:"aa-note",children:["Use ",d.jsx("strong",{children:"share"})," on one account in the other deck, or ",d.jsx("strong",{children:"↗"})," above its list to send several at once. A share carries a live login for every account in it and expires ten minutes after it is made."]})]})})]})})}async function hq(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const pq=1800;function mq({accounts:e,onClose:t,copyText:n}){const[s,o]=E.useState([]),[a,l]=E.useState(null),[u,h]=E.useState(!1),[p,f]=E.useState(null),[g,y]=E.useState(!1),[w,S]=E.useState(()=>Math.floor(Date.now()/1e3)),b=E.useRef(null),_=E.useRef(!1),k=kn(t,{focusRef:b});E.useEffect(()=>{if(!a)return;S(Math.floor(Date.now()/1e3));const A=window.setInterval(()=>S(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval(A)},[a]);const N=aq(e),j=e.filter(A=>!s.includes(A.num)).map(A=>A.num),T=j.length===e.length,M=A=>o(D=>D.includes(A)?D.filter(H=>H!==A):[...D,A]),P=E.useCallback(async()=>{if(!or(_.current)||!j.length)return;_.current=!0,h(!0),f(null),y(!1);const A=await hq({action:"share",accounts:j}).catch(()=>null);if(_.current=!1,h(!1),!(A!=null&&A.ok)){f(jo(A,"the share could not be made"));return}l({blob:A.blob,expiresAt:A.expiresAt,shared:A.shared??[],failed:A.failed??[]})},[e,j]),I=a?_T(a.expiresAt,w):null,F=(I==null?void 0:I.tone)==="gone",O=(a==null?void 0:a.shared.length)??0;return d.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:d.jsxs("div",{ref:k,className:"modal sa-modal",onClick:A=>A.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Share accounts with another deck",children:[d.jsxs("header",{className:"modal-head",children:[d.jsx("div",{className:"modal-title",children:d.jsx("h3",{children:"Share accounts"})}),d.jsx("div",{className:"modal-actions",children:d.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),d.jsx("section",{className:"modal-body sa-body",children:a?d.jsxs("div",{className:"sa-step",children:[d.jsx("h4",{children:F?"This share has expired":O===1?"1 account, ready to paste":`${O} accounts, ready to paste`}),d.jsx("code",{className:`ap-share-blob${F?" sa-dead":""}`,children:a.blob}),d.jsxs("div",{className:"ap-share-foot",children:[d.jsx("button",{type:"button",className:"ap-manage-btn",ref:b,onClick:async()=>{if(F){l(null),P();return}await n(a.blob)&&(y(!0),window.setTimeout(()=>y(!1),pq))},children:F?"make a new share":g?"copied":`copy ${O===1?"the share":"all "+O}`}),d.jsxs("span",{className:"ap-manage-hint",title:"This text is the sign-in for every account in it. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the logins themselves are in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign those accounts out and back in.",children:[d.jsx("span",{className:"ap-share-warn",children:O===1?"this is the password":`this is ${O} passwords`})," · ",d.jsx("span",{className:`ap-share-expiry ${I==null?void 0:I.tone}`,children:I==null?void 0:I.text})]})]}),a.failed.length>0&&d.jsxs("div",{className:"sa-failed",role:"alert",children:[d.jsx("p",{className:"sa-failed-head",children:a.failed.length===1?"One account is not in this bundle:":`${a.failed.length} accounts are not in this bundle:`}),d.jsx("ul",{className:"sa-list",children:a.failed.map(A=>{var H;const D=!!(A.email&&((H=A.detail)!=null&&H.includes(A.email)));return d.jsxs("li",{children:[!D&&d.jsx("span",{className:"sa-who",children:A.email||`account ${A.num}`}),d.jsx("span",{className:"sa-why",children:A.detail||"could not be exported"})]},`${A.num}-${A.email}`)})})]}),d.jsx("p",{className:"sa-note",children:F?d.jsx(d.Fragment,{children:"Another deck will refuse this text now. Make a new one — the same accounts are still picked."}):d.jsxs(d.Fragment,{children:["Paste it into the other deck with ",d.jsx("strong",{children:"+"})," → ",d.jsx("strong",{children:"Paste a share"}),". Accounts it already holds are left exactly as they are."]})}),d.jsxs("div",{className:"sa-actions",children:[d.jsx("button",{type:"button",className:"btn",onClick:()=>{l(null),y(!1)},children:"Pick again"}),d.jsx("button",{type:"button",className:"btn primary",onClick:t,children:"Done"})]})]}):e.length===0?d.jsxs("div",{className:"sa-step",children:[d.jsx("h4",{children:"Nothing to share"}),d.jsxs("p",{className:"sa-note",children:["This deck is not holding any accounts right now. Sign one in with ",d.jsx("strong",{children:"+"}),", or wait — the panel is still reading the store."]}),d.jsx("div",{className:"sa-actions",children:d.jsx("button",{type:"button",className:"btn primary",ref:b,onClick:t,children:"Close"})})]}):d.jsxs("div",{className:"sa-step",children:[d.jsxs("h4",{children:["Which accounts go to the other ",zt,"?"]}),d.jsx("p",{className:`sa-count${j.length?"":" empty"}`,children:lq(j.length)}),d.jsx("ul",{className:"sa-list sa-pick",children:N.map(A=>d.jsx("li",{children:d.jsxs("label",{className:"sa-row",children:[d.jsx("input",{type:"checkbox",checked:j.includes(A.num),onChange:()=>M(A.num)}),d.jsx("span",{className:"sa-who",children:A.label}),A.sub&&d.jsx("span",{className:"sa-sub",children:A.sub})]})},A.num))}),p&&d.jsx("p",{className:"aa-err",children:p}),d.jsxs("div",{className:"sa-actions",children:[d.jsx("button",{type:"button",className:"btn",onClick:()=>o(T?e.map(A=>A.num):[]),children:T?"Clear all":"Select all"}),d.jsx("button",{type:"button",className:"btn primary",ref:b,...ir(u,!j.length),onClick:P,children:u?"making the share…":j.length===0?"Share":j.length===1?"Share 1 account":`Share ${j.length} accounts`})]})]})})]})})}function gq(e,t){const n=new Set(e),s=e.length?Math.max(...e):0;return[...new Set([...e,s+1])].sort((o,a)=>o-a).map(o=>{const a=o===t?"here":n.has(o)?"swap":"free";return{slot:o,kind:a,label:a==="here"?`slot ${o}`:`slot ${o} · ${a}`}})}function vq(e,t,n){if(!(n!=null&&n.ok))return null;const s=Number.isInteger(n.to)?n.to:null;if(s==null)return{menuFor:null,confirmRemove:null,shareFor:null,swapNote:null};const o=n.swapped===!0&&s!==t;return{menuFor:e.menuFor===t?s:o&&e.menuFor===s?t:e.menuFor,confirmRemove:null,shareFor:null,swapNote:o?{at:s,displaced:t}:null}}function yq(e,t,n){return t!=null&&e.some(s=>s.slot===t)?t:n}function wq(e,t,n){var o;const s=((o=e.find(a=>a.slot===t))==null?void 0:o.kind)??"here";return s==="swap"?{label:"swap",done:"swapped",sends:!0,swaps:!0,title:`Send this account to slot ${t}. That slot is taken, so the two accounts trade places and the one standing there moves to slot ${n}.`}:s==="free"?{label:"move",done:"moved",sends:!0,swaps:!1,title:`Send this account to slot ${t}. That slot is empty, so no other account moves.`}:{label:"move",done:"here",sends:!1,swaps:!1,title:`This account already holds slot ${n}.`}}function xq(e,t){return{label:"save",done:"saved",sends:e!==t,swaps:!1,title:`Switch the active account out once it passes ${e}% of its limit.`}}function _1(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function k1(e){const t=e.filter(u=>!_1(u)),n=e.filter(u=>_1(u)),s=t.length?t:n,o=t.length?n:[],a=s.reduce((u,h)=>u&&u.pct>=h.pct?u:h,null);let l=null;for(const u of o)a&&u.pct<=a.pct||(!l||u.pct>l.pct)&&(l=u);return{shown:s,rest:o,fuller:l,peak:l??a}}function bq(e,t,n){return e<1?null:t?"fewer":n?`${n.label} ${Math.round(n.pct)}%`:`${e} more`}function _q(e,t,n,s){const o=e==null?"No usage has been collected for this account yet.":`${Math.round(e)}% left on ${t??"the window that runs out first"}, which is the one that runs out first.`,a=n===1?"the other window":`the other ${n} windows`;return`${o} ${s?"Hide":"Show"} ${a}.`}const kq="\0";function _w(e){const t=typeof e.email=="string"?e.email.trim():"";if(!t)return`slot:${e.num}`;const n=typeof e.org=="string"?e.org.trim():"";return`acct:${t}${kq}${n}`}function Sq(e,t){const n=_w(t);return e.includes(n)?e.filter(s=>s!==n):[...e,n]}function Nq(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map(_w)),s=e.filter(o=>n.has(o));return s.length===e.length?e:s}const Eq=64;function jq(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}const Cq=Object.freeze({text:"couldn't reach the deck server",reload:!0});async function S1(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function Tq(e){const t=e.find(s=>!s.ok);if(!t)return null;const n=qo(t.body);return{text:qy(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function N1(e,t){return t?e!=null&&e.reload&&e.text===t.text&&e.raw===t.raw?e:t:e!=null&&e.reload?null:e}const E1=15e3,Rq=8e3,Gf=1800,Aq=3e4,Mq=[70,80,85,90,95];function j1(e,t){return fT(t-Math.floor(e/1e3))}function Iq(e,t){if(!e)return"";const n=Math.floor(e/1e3)-t;return n<=0?" · due":n<60?` · next in ${n}s`:` · next in ${Math.round(n/60)}m`}function Oq(e){switch(e){case"invalid_grant":case"no_refresh_token":return{text:"login expired",hint:"claude-swap's stored login for this account was rejected and cannot be refreshed. Signing in again replaces it — the account keeps its slot, its alias and its history.",fixable:!0};case"http-401":return{text:"re-login needed",hint:"Anthropic refused this account's token.",fixable:!0};case"http-429":return{text:"rate limited",hint:"Anthropic is throttling requests for this account. It clears on its own.",fixable:!1};case"transient":return{text:"temporary error",hint:"A network or server hiccup while reading usage. The next collection retries.",fixable:!1};case"timeout":return{text:"timed out",hint:"Reading this account's usage took too long. The next collection retries.",fixable:!1};case"network":return{text:"unreachable",hint:"Could not reach Anthropic to read this account's usage.",fixable:!1};default:return{text:e,hint:`claude-swap reported "${e}" for this account.`,fixable:!1}}}function C1({lane:e,nowSec:t}){const n=Math.min(100,Math.max(0,e.pct)),s=n>=90?"var(--err)":n>=70?"var(--warn)":"var(--accent)",o=e.resetAt?hT(e.resetAt,t):null;return d.jsxs("div",{className:"ap-lane",children:[d.jsx("span",{className:"ap-lane-label",children:e.label}),d.jsx("div",{className:"ap-lane-track",children:d.jsx("div",{className:"ap-lane-fill",style:{width:`${n===0?1.5:n}%`,background:s,opacity:n===0?.4:1}})}),d.jsxs("span",{className:"ap-lane-pct",style:{color:s},children:[n,"%"]}),d.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}async function T1(e){var n;let t=!1;try{t=await Promise.race([((n=navigator.clipboard)==null?void 0:n.writeText(e).then(()=>!0))??Promise.resolve(!1),new Promise(s=>window.setTimeout(()=>s(!1),500))])}catch{t=!1}if(t)return!0;try{const s=document.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(s),s.select(),t=document.execCommand("copy"),s.remove()}catch{t=!1}return t}function Pq({onClose:e}){var Ke,_t,Me,it,At;const[t,n]=E.useState(null),[s,o]=E.useState(null),[a,l]=E.useState(null),[u,h]=E.useState(!1),[p,f]=E.useState(null),[g,y]=E.useState(()=>Math.floor(Date.now()/1e3)),w=E.useRef(null),[S,b]=E.useState(null),[_,k]=E.useState(!1),[N,j]=E.useState(""),[T,M]=E.useState(null),[P,I]=E.useState(null),[F,O]=E.useState(null),[A,D]=E.useState(!1),[H,K]=E.useState(!1),[C,X]=E.useState(null),[B,ne]=E.useState(null),[J,W]=E.useState(null),[Q,$]=E.useState(null),[G,Y]=E.useState(!1),[L,q]=E.useState([]),Z=E.useRef(null),se=E.useCallback(oe=>mT(Z.current)?(Z.current=oe,l(oe),!0):!1,[]),fe=E.useCallback(()=>{Z.current=null,l(null)},[]),he=(oe,Pe=!1)=>{const qe=pT(a,oe);return{disabled:qe.disabled,"aria-busy":qe.busy||Pe}},ye=E.useCallback(oe=>{window.requestAnimationFrame(()=>{var Pe;if(Z3(((Pe=document.activeElement)==null?void 0:Pe.tagName)??null))for(const qe of Q3(oe)){const Ne=document.querySelector(qe);if(Ne){Ne.focus();return}}})},[]),Re=E.useCallback(async(oe=!1)=>{oe&&h(!0);const Pe=new AbortController,qe=window.setTimeout(()=>Pe.abort(),Aq);try{const[Ne,We]=await Promise.all([fetch(`/api/claude-accounts${oe?"?refresh=1":""}`,{signal:Pe.signal}),fetch("/api/cswap-auto",{signal:Pe.signal})]);if(Ne.ok){const et=await Ne.json();n(et),q(Ce=>Nq(Ce,et.accounts))}We.ok&&o(await We.json());const Et=Tq([await S1(Ne),await S1(We)]);f(et=>N1(et,Et))}catch{f(Ne=>N1(Ne,Cq))}finally{window.clearTimeout(qe),oe&&h(!1)}},[]),Ue=E.useCallback(async(oe,Pe)=>{if(!se(Pe))return null;f(null);try{const Ne=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(oe)})).json().catch(()=>null);return Ne!=null&&Ne.ok||f({text:qy(Ne,"command failed"),raw:qo(Ne)}),Ne}catch{return f({text:"server unreachable"}),null}finally{fe()}},[se,fe]),De=E.useCallback(async(oe,Pe)=>{if(!se(Pe))return null;f(null);try{const Ne=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(oe)})).json().catch(()=>null);return Ne!=null&&Ne.ok||f({text:jo(Ne,"command failed")}),Ne}catch{return f({text:"server unreachable"}),null}finally{fe()}},[se,fe]);E.useEffect(()=>(Re(!0),w.current=window.setInterval(()=>Re(!1),E1),()=>{w.current!=null&&window.clearInterval(w.current)}),[Re]),E.useEffect(()=>{const oe=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(oe)},[]);const Ie=((Ke=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:Ke.value)??"90",ke=Q??Ie,ce=xq(ke,Ie),xe=(_t=t==null?void 0:t.accounts)==null?void 0:_t.find(oe=>oe.active),we=((Me=k1((xe==null?void 0:xe.lanes)??[]).peak)==null?void 0:Me.pct)??null,Ye=we!=null&&we>=Number(Ie)-15,yt=async oe=>{if(se(`switch-${oe}`)){f(null);try{const qe=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:oe})})).json().catch(()=>null);qe!=null&&qe.ok||f({text:qy(qe,"the switch failed"),raw:qo(qe)}),await Re(!0)}catch{f({text:"server unreachable"})}finally{fe(),ye(oe)}}},ct=async(oe,Pe)=>{const{commit:qe,alias:Ne}=jq(N,Pe);if(qe){const We=await De({action:"alias",account:oe,alias:Ne},`alias-${oe}`);if(await Re(!0),!(We!=null&&We.ok))return;j(Ne)}M(oe),window.setTimeout(()=>M(We=>We===oe?null:We),Gf)},st=async(oe,Pe)=>{const qe=await De({action:"move",account:oe,slot:Pe},`move-${oe}`),Ne=vq({menuFor:S,shareFor:(F==null?void 0:F.num)??null},oe,qe);if(await Re(!0),Ne){b(Ne.menuFor),I(Ne.confirmRemove),Ne.shareFor==null&&(O(null),K(!1)),X(Ne.swapNote);const We=Ne.swapNote;We&&window.setTimeout(()=>X(Et=>Et===We?null:Et),Rq),ne(null),ye(Ne.menuFor)}return qe},Be=async(oe,Pe,qe)=>{if(qe.sends){const Ne=await st(oe,Pe);if(!(Ne!=null&&Ne.ok))return}W(oe),window.setTimeout(()=>W(Ne=>Ne===oe?null:Ne),Gf)},tt=async(oe,Pe)=>{if(Pe.sends){const qe=await Ue({action:"setting",key:"autoswitch.threshold",value:oe},"threshold");if(await Re(!0),!(qe!=null&&qe.ok))return;$(null)}Y(!0),window.setTimeout(()=>Y(!1),Gf)};return d.jsxs("aside",{className:"accounts-panel",id:"accounts-panel","aria-label":"Claude accounts",children:[d.jsxs("div",{className:"ap-header",children:[d.jsx("h2",{children:"Accounts"}),d.jsxs("div",{className:"ap-header-right",children:[d.jsx("button",{type:"button",className:"glyph-btn ap-add",onClick:()=>k(!0),"aria-label":"Add an account",title:"Sign in to another Claude account, or paste one shared from another deck",children:"+"}),(((it=t==null?void 0:t.accounts)==null?void 0:it.length)??0)>0&&d.jsx("button",{type:"button",className:"glyph-btn ap-share-set",onClick:()=>D(!0),"aria-label":"Share accounts with another deck",title:`Copy several accounts to another ${zt} in one paste. The text carries a live login for each one — treat it as those passwords.`,children:"↗"}),d.jsx("button",{type:"button",className:"glyph-btn ap-refresh",onClick:()=>Re(!0),...he("reload",u),"aria-label":"Reload accounts",title:"Reload from claude-swap",children:u?"…":"↻"}),d.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),t==null?p?d.jsxs("div",{className:"ap-empty",role:"alert",children:[d.jsx("span",{title:p.raw||void 0,children:p.text}),d.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",E1/1e3," seconds."]}),d.jsx("button",{type:"button",className:"ap-fix",disabled:u,onClick:()=>Re(!0),children:u?"trying…":"try again"})]}):d.jsx("div",{className:"ap-empty",children:"Checking…"}):t.ok?d.jsxs(d.Fragment,{children:[(At=t.accounts)==null?void 0:At.map(oe=>{const{shown:Pe,rest:qe,fuller:Ne,peak:We}=k1(oe.lanes),Et=L.includes(_w(oe)),et=bq(qe.length,Et,Ne);return d.jsxs("div",{className:`ap-account${oe.active?" active":""}`,children:[d.jsxs("div",{className:"ap-account-head",children:[d.jsx("span",{className:"ap-num",children:oe.num}),oe.alias&&d.jsx("span",{className:"ap-alias",title:oe.alias,children:oe.alias}),d.jsx("span",{className:"ap-email",title:oe.email??void 0,children:oe.email}),d.jsx("button",{type:"button",id:`ap-more-${oe.num}`,className:`ap-more${S===oe.num?" on":""}`,"aria-label":`Manage account ${oe.num}`,"aria-expanded":S===oe.num,"aria-controls":S===oe.num?`ap-manage-${oe.num}`:void 0,title:"Share, rename, move, remove",onClick:()=>{b(S===oe.num?null:oe.num),j(oe.alias??""),I(null),O(null),K(!1),X(null),M(null),ne(null),W(null)},children:"⋯"}),oe.active&&d.jsx("span",{className:"ap-badge-active",children:"active"}),oe.disabled&&d.jsx("span",{className:"ap-badge-held",children:"held out"}),!oe.active&&!oe.disabled&&d.jsx("button",{type:"button",className:"ap-manage-btn ap-switch",...he(`switch-${oe.num}`),onClick:()=>yt(oe.num),title:`Switch to ${oe.alias??oe.email}`,children:a===`switch-${oe.num}`?"…":"switch"})]}),d.jsx("div",{className:"ap-lanes",id:`ap-lanes-${oe.num}`,children:Pe.length?d.jsxs(d.Fragment,{children:[Pe.map(Ce=>d.jsx(C1,{lane:Ce,nowSec:g},Ce.id)),Et&&qe.map(Ce=>d.jsx(C1,{lane:Ce,nowSec:g},Ce.id))]}):d.jsx("div",{className:"ap-hint",children:"No usage recorded yet."})}),d.jsxs("div",{className:"ap-meta",children:[oe.staleCopy&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"ap-stale-copy",title:"The deck can still see this account — its live usage is being read — but claude-swap's own stored copy of the login was rejected, so these numbers stopped updating. Resume re-captures the copy from the login you already have.",children:"numbers paused"}),d.jsx("button",{type:"button",className:"ap-fix",...he("recapture"),onClick:async()=>{const Ce=await De({action:"recapture"},"recapture");Ce!=null&&Ce.ok&&Re(!0)},title:"Re-capture this account's stored credentials from the login you already have. No sign-in, no switch.",children:a==="recapture"?"resuming…":"resume"})]}),oe.error&&(()=>{const Ce=Oq(oe.error);return d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"ap-err",title:Ce.hint,children:Ce.text}),Ce.fixable&&d.jsx("button",{type:"button",className:"ap-fix",onClick:()=>k(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"sign in again"})]})})(),et&&d.jsx("button",{type:"button",className:"ap-lanes-more","aria-expanded":Et,"aria-controls":`ap-lanes-${oe.num}`,title:_q(oe.headroom,(We==null?void 0:We.label)??null,qe.length,Et),onClick:()=>q(Ce=>Sq(Ce,oe)),children:et}),(((s==null?void 0:s.enabled)||(s==null?void 0:s.external))&&!oe.active||oe.disabled)&&d.jsx("button",{type:"button",className:"ap-rotate",...he(`rot-${oe.num}`),onClick:()=>Ue({action:"account",account:oe.num,enabled:oe.disabled},`rot-${oe.num}`).then(()=>Re(!0)),title:oe.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:oe.disabled?"put back":"hold out"}),oe.fetchedAt?d.jsxs("span",{className:`ap-age${oe.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 ",j1(oe.fetchedAt,g),Iq(oe.nextAt,g)]}):d.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),S===oe.num&&d.jsxs("div",{className:"ap-manage",id:`ap-manage-${oe.num}`,role:"group","aria-label":`Manage account ${oe.num}`,children:[d.jsxs("div",{className:"ap-manage-name",children:[d.jsx("label",{className:"vis-hidden",htmlFor:`ap-alias-${oe.num}`,children:"Alias"}),d.jsx("input",{id:`ap-alias-${oe.num}`,className:"ap-manage-input",type:"text",value:N,onChange:Ce=>j(Ce.target.value),onKeyDown:Ce=>{Ce.key==="Enter"&&ct(oe.num,oe.alias)},maxLength:Eq,placeholder:"e.g. work",spellCheck:!1,autoFocus:!0}),d.jsx("button",{type:"button",className:"ap-manage-btn",...he(`alias-${oe.num}`),onClick:()=>ct(oe.num,oe.alias),title:"A short name to show instead of the email",children:T===oe.num?"saved":"save"})]}),(()=>{const Ce=gq((t.accounts??[]).map(kt=>kt.num),oe.num),wt=yq(Ce,B,oe.num),at=wq(Ce,wt,oe.num);return d.jsxs("div",{className:"ap-manage-slot",children:[d.jsx("label",{className:"vis-hidden",htmlFor:`ap-slot-${oe.num}`,children:"Slot"}),d.jsx("span",{className:"ap-field",children:d.jsx("select",{id:`ap-slot-${oe.num}`,value:String(wt),...he(`move-${oe.num}`),onChange:kt=>ne(Number(kt.target.value)),children:Ce.map(kt=>d.jsx("option",{value:kt.slot,children:kt.label},kt.slot))})}),d.jsx("button",{type:"button",className:"ap-manage-btn",...he(`move-${oe.num}`),title:at.title,onClick:()=>Be(oe.num,wt,at),children:J===oe.num?at.done:at.label})]})})(),d.jsxs("div",{className:"ap-manage-acts",children:[d.jsx("button",{type:"button",className:"ap-manage-btn",...he(`share-${oe.num}`),title:`Copy this account to another ${zt}. Anyone who has the text can use the account — treat it as the password. The other deck stops accepting it after 10 minutes; that does not make an escaped copy safe.`,onClick:async()=>{K(!1);const Ce=await De({action:"share",account:oe.num},`share-${oe.num}`);Ce!=null&&Ce.ok&&O({num:oe.num,blob:Ce.blob,expiresAt:Ce.expiresAt})},children:"share"}),d.jsx("button",{type:"button",className:`ap-manage-btn danger${P===oe.num?" armed":""}`,...he(`rm-${oe.num}`),title:P===oe.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(P!==oe.num){I(oe.num),window.setTimeout(()=>I(Ce=>Ce===oe.num?null:Ce),4e3);return}I(null),De({action:"remove",account:oe.num},`rm-${oe.num}`).then(()=>{b(null),Re(!0),ye(null)})},children:P===oe.num?"confirm":"remove"})]}),(C==null?void 0:C.at)===oe.num&&(()=>{var at;const Ce=(at=t.accounts)==null?void 0:at.find(kt=>kt.num===C.displaced),wt=(Ce==null?void 0:Ce.alias)??(Ce==null?void 0:Ce.email)??"the account that was there";return d.jsxs("span",{className:"ap-manage-hint ap-manage-swap",title:`Slot ${C.at} was taken, so the two accounts traded places: ${wt} now holds slot ${C.displaced}.`,children:["swapped with slot ",C.displaced]})})(),(F==null?void 0:F.num)===oe.num&&(()=>{const Ce=_T(F.expiresAt,g),wt=Ce.tone==="gone";return d.jsxs("div",{className:`ap-share${wt?" expired":""}`,children:[d.jsx("code",{className:"ap-share-blob",children:F.blob}),d.jsxs("div",{className:"ap-share-foot",children:[d.jsx("button",{type:"button",className:"ap-manage-btn",...he(`share-${oe.num}`),onClick:async()=>{if(wt){K(!1);const at=await De({action:"share",account:oe.num},`share-${oe.num}`);at!=null&&at.ok&&O({num:oe.num,blob:at.blob,expiresAt:at.expiresAt});return}await T1(F.blob)&&(K(!0),window.setTimeout(()=>K(!1),1800))},children:wt?"make a new share":H?"copied":"copy"}),d.jsxs("span",{className:"ap-manage-hint",title:"This text is the account's password. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the login itself is in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign the account out and back in.",children:[d.jsx("span",{className:"ap-share-warn",children:"this is the password"})," · ",d.jsx("span",{className:`ap-share-expiry ${Ce.tone}`,children:Ce.text})]})]})]})})()]})]},oe.num)}),(s==null?void 0:s.ok)&&d.jsxs("div",{className:"ap-auto",children:[d.jsxs("div",{className:"ap-auto-head",children:[d.jsx("h3",{className:"ap-auto-title",children:"Auto-switch"}),d.jsxs("span",{className:"ap-auto-ctl",children:[we!=null&&d.jsxs("span",{className:`ap-auto-now${Ye?" near":""}`,children:[Math.round(we),"%"]}),d.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:d.jsx("select",{"aria-label":"Switch threshold",value:ke,...he("threshold"),onChange:oe=>$(oe.target.value),children:Mq.map(oe=>d.jsxs("option",{value:oe,children:[oe,"%"]},oe))})}),d.jsx("button",{type:"button",className:"ap-manage-btn",...he("threshold"),title:ce.title,onClick:()=>tt(ke,ce),children:G?ce.done:ce.label}),d.jsxs("button",{type:"button",className:`ap-auto-state${s.enabled?" live":""}`,role:"switch","aria-checked":s.enabled,"aria-label":"Auto-switch",...he("enable"),onClick:()=>Ue({action:"enable",enabled:!s.enabled},"enable").then(()=>Re(!0)),title:s.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[d.jsx("i",{className:s.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),s.enabled?"on":"off"]})]})]}),s.external&&d.jsxs("p",{className:"ap-auto-note",children:[d.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",d.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&&d.jsx("div",{className:"ap-auto-foot",children:d.jsxs("span",{className:"ap-auto-result",children:["checked ",j1(s.lastTick.at,g)]})})]}),p&&d.jsxs("div",{className:"ap-failure",role:"alert",children:[d.jsx("span",{className:"ap-failure-text",title:p.raw||void 0,children:p.text}),d.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>f(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),d.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:"These numbers only update while this panel is open."})]}):d.jsx("div",{className:"ap-empty",children:t.reason==="no_cswap"?d.jsxs(d.Fragment,{children:[d.jsx("span",{children:"claude-swap isn't installed."}),d.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."}),t.hint&&d.jsx("code",{className:"ap-cmd",children:t.hint}),d.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",d.jsx("strong",{children:"+"})," button above."]})]}):t.reason==="no_accounts"?d.jsxs(d.Fragment,{children:[d.jsx("span",{children:"No accounts added yet."}),d.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",d.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{children:"Couldn't read the account store."}),d.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",t.reason?` (${t.reason})`:"","."]})]})}),_&&d.jsx(fq,{onClose:()=>k(!1),onChanged:()=>Re(!0)}),A&&d.jsx(mq,{accounts:((t==null?void 0:t.accounts)??[]).map(oe=>({num:oe.num,email:oe.email,alias:oe.alias,org:oe.org})),onClose:()=>D(!1),copyText:T1})]})}const $q=3e4;function Lq({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function qq({bundle:e,running:t,pending:n,lastTried:s}){return t?Lq({bundle:e,running:t,lastTried:s})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function Dq(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function Fq({asked:e,reported:t}){return t?t!==e:!1}function zq(e){const t=e.thresholdMs??$q;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>=t}}function Bq(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function Uq(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.decks!="number"||typeof t.mine!="boolean")return null;const n=t.owner&&typeof t.owner=="object"?t.owner.port:null;return{path:typeof t.path=="string"&&t.path!==""?t.path:null,decks:t.decks,mine:t.mine,ownerPort:typeof n=="number"?n:null}}function Wq(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function Hq(e,t){const n=Wq(e),s=n?`removes ${n} on the canvas`:null,o=u=>`This ${s?`${s} and ${u}`:u}`;if(!t)return{note:`${o("deletes the event log on disk")} — the file a restarted deck replays to rebuild what you see, and the file every deck on this machine shares unless one was told otherwise. Layout, pins and selection go with it. This cannot be undone.`,confirm:"Clear everything"};if(!t.path)return{note:`${o("leaves nothing on disk — this deck keeps no event log")}. Layout, pins and selection go with it. This cannot be undone.`,confirm:"Clear everything"};if(!t.mine){const u=t.ownerPort===null?"another running deck owns that file":`the deck on port ${t.ownerPort} owns that file`,h=t.decks>2?`, one of ${t.decks} decks sharing it`:"";return{note:`${o(`leaves the event log alone: ${u}${h}`)}. Clearing here empties this canvas only — restart this deck and the log replays back onto it. Layout, pins and selection go with it.`,confirm:"Clear this canvas"}}if(t.decks<=1)return{note:`${o("deletes this deck's event log")} — the file a restarted deck replays to rebuild what you see. Layout, pins and selection go with it. This cannot be undone.`,confirm:"Clear everything"};const a=t.decks-1,l=a===1?"That deck keeps what is on its canvas until it restarts, and then it is gone there too.":"Those decks keep what is on their canvases until they restart, and then it is gone there too.";return{note:`${o(`deletes the event log ${a===1?"1 other running deck shares":`${a} other running decks share`} with this one`)} — every session recorded in it, not just the ones drawn here. ${l} This cannot be undone.`,confirm:"Clear everything"}}function Gq({agentCount:e,onConfirm:t,onCancel:n}){const s=E.useRef(null),o=kn(n,{focusRef:s,layer:kL}),[a,l]=E.useState(null);E.useEffect(()=>{let p=!1;return fetch("/api/clear").then(f=>f.ok?f.json():null).then(f=>{p||l(Uq(f))}).catch(()=>{}),()=>{p=!0}},[]);const{note:u,confirm:h}=Hq(e,a);return d.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:d.jsxs("div",{ref:o,className:"modal clear-confirm",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[d.jsxs("header",{className:"modal-head",children:[d.jsxs("div",{className:"modal-title",children:[d.jsx("span",{className:"status-dot err","aria-hidden":!0}),d.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),d.jsx("div",{className:"modal-actions",children:d.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),d.jsxs("section",{className:"modal-body",children:[d.jsx("p",{className:"modal-note",children:u}),d.jsxs("div",{className:"cc-actions",children:[d.jsx("button",{type:"button",ref:s,className:"btn",onClick:n,children:"Cancel"}),d.jsx("button",{type:"button",className:"btn danger",onClick:t,children:h})]})]})]})})}const Vq="One-key shortcuts run when nothing on the page has focus. A focused control keeps its own keys — this sheet included, which takes the keyboard while it is open — so Esc is the way back to the canvas.",Yq=[{title:"Canvas",rows:[{cap:"Space",action:"pause or resume the stream",binds:[" "]},{cap:"J",action:"next agent",binds:["j","J"]},{cap:"K",action:"previous agent",binds:["k","K"]},{cap:"F",action:"fit every agent on screen",binds:["f","F"]},{cap:"R",action:"re-arrange the canvas and drop the pins",binds:["r","R"]},{cap:"C",action:"clear the canvas and the event log — asks first",binds:["c","C"]}]},{title:"Panels and dialogs",rows:[{cap:"U",action:"usage panel",binds:["u","U"]},{cap:"L",action:"session list",binds:["l","L"]},{cap:"H",action:"usage history",binds:["h","H"]},{cap:"A",action:"Claude accounts, where Claude Code is installed",binds:["a","A"]},{cap:"?",action:"this sheet",binds:["?"]}]},{title:"Settings",rows:[{cap:"M",action:"sound on or off",binds:["m","M"]},{cap:"T",action:"light or dark theme",binds:["t","T"]}]},{title:"Focus and selection",rows:[{cap:"Tab",action:"reach the agent cards",binds:[]},{cap:"Enter",action:"select the focused card",binds:["Enter"]},{cap:"Shift + Enter",action:"add the focused card to the selection",binds:["Enter"]},{cap:"Esc",action:"close what is open, deselect, release focus",binds:["Escape"]}]},{title:"Mouse",rows:[{cap:"drag",action:"move a node, and pin it where you dropped it",binds:[]},{cap:"shift-click",action:"add an agent to the selection",binds:[]},{cap:"click",action:"the topbar speaker opens volume and sound settings",binds:[]}]}];function Kq({onClose:e}){const t=kn(e);return d.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:d.jsxs("div",{ref:t,className:"modal key-help",onClick:n=>n.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title",children:[d.jsxs("header",{className:"modal-head",children:[d.jsx("div",{className:"modal-title",children:d.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),d.jsx("div",{className:"modal-actions",children:d.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),d.jsxs("section",{className:"modal-body",children:[d.jsx("p",{className:"modal-note",children:Vq}),d.jsx("div",{className:"shortcuts",children:Yq.map(n=>d.jsxs(E.Fragment,{children:[d.jsx("h3",{className:"kh-group",children:n.title}),n.rows.map(s=>d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:s.cap}),d.jsx("span",{children:s.action})]},`${n.title}:${s.cap}:${s.action}`))]},n.title))})]})]})})}const Xq=["done","needs-input"],Qq=[{id:"two",label:"Two notes",notes:[{at:0,hz:740,ms:90},{at:.085,hz:440,ms:150}]},{id:"arc",label:"Descent",notes:[{at:0,hz:988,ms:80},{at:.07,hz:659,ms:80},{at:.14,hz:440,ms:160}]},{id:"tap",label:"Double tap",notes:[{at:0,hz:740,ms:55},{at:.055,hz:740,ms:55},{at:.165,hz:440,ms:150}]},{id:"chord",label:"Chord",trim:.7,notes:[{at:0,hz:988,ms:110},{at:0,hz:740,ms:110},{at:.1,hz:440,ms:170}]},{id:"bell",label:"Bell",type:"triangle",notes:[{at:0,hz:740,ms:120},{at:.11,hz:440,ms:260}]},{id:"blip",label:"Blip",type:"square",trim:.7,notes:[{at:0,hz:740,ms:55},{at:.06,hz:440,ms:90}]}],Zq=[{id:"two",label:"Two notes",notes:[{at:0,hz:440,ms:90},{at:.085,hz:740,ms:150}]},{id:"arc",label:"Ascent",notes:[{at:0,hz:440,ms:80},{at:.07,hz:659,ms:80},{at:.14,hz:988,ms:160}]},{id:"tap",label:"Double tap",notes:[{at:0,hz:440,ms:55},{at:.055,hz:440,ms:55},{at:.165,hz:740,ms:150}]},{id:"chord",label:"Chord",trim:.7,notes:[{at:0,hz:440,ms:110},{at:.1,hz:740,ms:170},{at:.1,hz:988,ms:170}]},{id:"bell",label:"Bell",type:"triangle",notes:[{at:0,hz:440,ms:120},{at:.11,hz:740,ms:260}]},{id:"blip",label:"Blip",type:"square",trim:.7,notes:[{at:0,hz:440,ms:55},{at:.06,hz:740,ms:90}]}],kw={done:Qq,"needs-input":Zq},Do="two";function Fy(e,t){const n=kw[e];return n.find(s=>s.id===t)??n.find(s=>s.id===Do)??n[0]}function kT(e,t){return kw[e].some(s=>s.id===t)?t:Do}Fy("done",Do).notes,Fy("needs-input",Do).notes;const R1=.04,Jq=.24,ST=0,Sw=100,zy=5,il=50;function ol(e){if(!Number.isFinite(e))return il;const t=Math.round(e/zy)*zy;return Math.min(Sw,Math.max(ST,t))}function eD(e){if(e==null)return il;const t=e.trim();return/^-?\d+(\.\d+)?$/.test(t)?ol(Number(t)):il}function tD(e){const t=ol(e),n=R1+(Jq-R1)*(t/Sw);return Math.round(n*1e4)/1e4}function nD(e,t){const n=t.trim,s=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(tD(e)*s*1e4)/1e4}const rD=160,sD="agent-dag.soundLevel.done",iD="agent-dag.soundLevel.needs-input",oD="agent-dag.soundFigure.done",aD="agent-dag.soundFigure.needs-input",NT={done:sD,"needs-input":iD},ET={done:oD,"needs-input":aD},By={done:{level:il,figure:Do},"needs-input":{level:il,figure:Do}};function lD(e){const t=n=>({level:eD(e(NT[n])),figure:kT(n,e(ET[n]))});return{done:t("done"),"needs-input":t("needs-input")}}const cD={Stop:"done",Notification:"needs-input"};function uD(e,t){var s;if(t)return null;const n=(s=e==null?void 0:e.payload)==null?void 0:s.hook_event_name;return typeof n!="string"?null:cD[n]??null}function dD(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null,s=!1;const o=()=>e.enabled()?s&&(n==null?void 0:n.state)==="running"?"ready":"locked":"off",a=()=>{var h;return(h=e.onState)==null?void 0:h.call(e,o())};function l(){var h;if(!(!t||s))try{n=n??new t,(h=n.resume)==null||h.call(n).then(a,()=>{}),s=!0,a()}catch{}}function u(h,p=!1){var S;if(!p&&!e.enabled()||!n||n.state!=="running")return!1;const f=(((S=e.prefs)==null?void 0:S.call(e))??By)[h]??By[h],g=Fy(h,f.figure),y=nD(f.level,g),w=n.currentTime;for(const b of g.notes){const _=n.createOscillator(),k=n.createGain();_.type=g.type??"sine",_.frequency.value=b.hz;const N=w+b.at,j=N+b.ms/1e3;k.gain.setValueAtTime(1e-4,N),k.gain.exponentialRampToValueAtTime(y,N+.012),k.gain.exponentialRampToValueAtTime(1e-4,j),_.connect(k).connect(n.destination),_.start(N),_.stop(j+.02)}return!0}return{unlock:l,play:u,state:o,get context(){return n}}}const A1={done:"Turn finished","needs-input":"Claude is asking"},fD={done:"Every finished turn, on both CLIs.","needs-input":"Claude Code only — Codex has no such event."};function hD({onClose:e,soundOn:t,onToggleSound:n,prefs:s,onLevel:o,onFigure:a,onPreview:l,openerRef:u}){const h=kn(e),p=E.useRef(e);return p.current=e,E.useEffect(()=>{const f=g=>{var w,S;const y=g.target;y&&((w=h.current)!=null&&w.contains(y)||(S=u.current)!=null&&S.contains(y)||p.current())};return window.addEventListener("pointerdown",f,!0),()=>window.removeEventListener("pointerdown",f,!0)},[h,u]),d.jsxs("div",{ref:h,id:"sound-menu",className:"sound-menu",role:"dialog","aria-label":"Sound settings",children:[d.jsxs("button",{type:"button",className:"btn sm-switch",onClick:n,"aria-pressed":t,children:[d.jsx("span",{className:"sm-switch-label",children:"Sound"}),d.jsx("span",{className:"sm-switch-state",children:t?"on":"off"})]}),Xq.map(f=>{const g=s[f],y=`sm-level-${f}`,w=`sm-figure-${f}`;return d.jsxs("section",{className:"sm-tone","aria-labelledby":`sm-name-${f}`,children:[d.jsxs("div",{className:"sm-tone-head",children:[d.jsx("h3",{className:"sm-tone-name",id:`sm-name-${f}`,children:A1[f]}),d.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>l(f),"aria-label":`Hear the ${A1[f].toLowerCase()} tone`,children:[d.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:d.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),"Hear it"]})]}),d.jsxs("div",{className:"sm-row",children:[d.jsx("label",{htmlFor:y,children:"Volume"}),d.jsx("input",{id:y,type:"range",min:ST,max:Sw,step:zy,value:g.level,onChange:S=>o(f,Number(S.target.value))}),d.jsxs("span",{className:"sm-read",children:[g.level,"%"]})]}),d.jsxs("div",{className:"sm-row",children:[d.jsx("label",{htmlFor:w,children:"Sound"}),d.jsx("select",{id:w,className:"sm-select",value:g.figure,onChange:S=>a(f,S.target.value),children:kw[f].map(S=>d.jsx("option",{value:S.id,children:S.label},S.id))})]}),d.jsx("p",{className:"sm-note",children:fD[f]})]},f)}),d.jsx("p",{className:"sm-foot",children:"M turns the sound on and off from anywhere."})]})}const pD={"//":["What a user would NOTICE. One key per version that has something to say,","and no key at all for a version that has nothing — which is most of them.","","The rule this file exists to serve: before every release, ask 'what would a","user notice?' and write the answer here. 'Nothing user-visible' is a valid","and expected answer, and it is spelled by adding no key. A release with no","key shows no modal, and that silence is what keeps the modal worth reading","on the day it is not silent.","","What belongs here: something that changed on the user's machine or under","their hands — a hook written to or removed from settings.json, a default","that flipped, a control that moved or went away, a stored preference that","changed meaning. What does not: bounds, races, assertions that could not","fire, anything that is invisible when it is correct.","","Write it for the person running the deck, not for the person reading the","diff. `title` is the sentence they scan; `body` is what they need in order","to act on it, or to stop worrying about it.","","Keys are versions exactly as package.json spells them. A key that is not a","version, or an entry missing either field, fails the suite rather than","being quietly dropped — see src/web/__tests__/release-notes-file.test.ts.","Ordering here is for humans; the deck sorts by version itself.","","A title may open with an emoji, and if it does, put exactly ONE space after","it. Not two: the dialog gives a leading emoji its own optical gap, because","a colour glyph is drawn edge to edge inside its advance and one word space","after one reads as none. A second space here would be a lie in the data","about a defect in the type, and the suite refuses both it and no space at","all."],"3.2.1":[{title:"💵 Sonnet 5 was being costed fifty per cent high",body:`Sonnet 5 launched at $2/$10 per million tokens as introductory pricing, with a rise to $3/$15 announced for September 1. The deck implemented that schedule, and on September 1 it started charging the higher rate.
76
+
77
+ The increase was cancelled. Anthropic's pricing page now says the $2/$10 rate is simply the price and the rise "will not occur" — so every Sonnet 5 session since the 1st has been shown to you at half again what it cost.
78
+
79
+ It is corrected, and there is no date logic left in that rate to go stale a second time. Numbers already on your board are recomputed from the log the next time the deck starts; nothing was billed by us, only displayed.
80
+
81
+ Fable 5.1 and Mythos 5.1 are also priced now, including the cache read that is a quarter of Fable 5's — which is most of what a long session pays for.`}],"3.2.0":[{title:"🌡️ Windows shows a temperature where it can find one",body:`On most Windows laptops there is nothing to show, and that is Windows rather than this deck: modern machines declare no ACPI thermal zone, and the sensors that do exist sit behind an interface only an administrator may read. Measured on real hardware, elevated and not.
76
82
 
77
83
  One thing does work, and it costs you nothing to have. If LibreHardwareMonitor happens to be running with its web server on, the deck now reads its numbers over localhost — which needs no privileges at all.
78
84
 
@@ -124,20 +130,20 @@ The two lists are separate on purpose, so you can never end up with both tones s
124
130
 
125
131
  M still turns the sound on and off from anywhere.`},{title:"✨ This box is new",body:`After an update, the deck tells you what changed — once, and only when there is something worth telling. Most updates have nothing to say and you will see nothing at all.
126
132
 
127
- Click the version at the top of the deck to read it again whenever you like.`}],"1.45.0":[{title:"🔕 The deck no longer puts anything in your settings.json",body:"It used to add a hook there so Claude Code would play a sound when a turn ended. That entry is removed the first time you start this version, and any sound hook you wrote yourself is put back exactly where you had it. Nothing else in that file is touched. The deck makes the sound itself now — which is also why you finally hear one when a Codex turn ends, not just a Claude one."}]},Nw="agent-dag.releaseNotesSeen";function M1(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function Fo(e,t){const n=M1(e),s=M1(t);for(let o=0;o<Math.max(n.length,s.length);o++){const a=(n[o]??0)-(s[o]??0);if(a!==0)return a<0?-1:1}return 0}function zo(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function gD(e){if(!e||typeof e!="object")return!1;const{title:t,body:n}=e;return typeof t=="string"&&t.trim()!==""&&typeof n=="string"&&n.trim()!==""}function vD(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,s]of Object.entries(e)){if(!zo(n)||!Array.isArray(s))continue;const o=s.filter(gD);o.length&&t.push({version:n,notes:o})}return t.sort((n,s)=>Fo(s.version,n.version))}const I1=vD(mD);function jT(e,t,n){return e.filter(s=>Fo(s.version,n)<=0&&(t===null||Fo(s.version,t)>0))}function yD(e,t){return e.filter(n=>Fo(n.version,t)===0)}function wD(e){if(!e.length)return"";const t=e[0].version,n=e[e.length-1].version;return t===n?`v${t}`:`v${n} – v${t}`}function xD({since:e,running:t,entries:n,firstRun:s}){if(!n.length)return"Nothing in this build has anything to report yet. Most releases do not, which is the point.";if(e!==null){const l=n.length===1?"one release":`${n.length} releases`;return`You were last caught up at v${e}. Since then ${l} changed something you would notice. Clicking the version in the topbar brings this back.`}if(s&&zo(t))return`The deck has not run in this browser before, so this is what v${t} — the release you have — changed. Earlier releases are not repeated here; clicking the version in the topbar brings all of them back.`;const o=n[0].version;if(!zo(t))return"Everything this build has to say, newest first. Most releases have nothing here, which is why the deck stays quiet about them.";const a=Fo(o,t);return a<0?`v${t} — the release you are running — changed nothing you would notice, which most releases do not. Below is the last release that did, and everything before it, newest first.`:a>0?"Everything this build has to say, newest first. Most releases have nothing here, which is why the deck stays quiet about them.":`You are running v${t}, and this is what it changed — and everything before it, newest first. Most releases have nothing here, which is why the deck stays quiet about them.`}const bD=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function _D(e){const t=bD.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function kD(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function SD(e){if(!e)return null;let t=null;try{t=e.getItem(Nw)}catch{return null}return zo(t)?t:null}function ND(e){if(!e)return!1;try{return e.getItem(Nw),!0}catch{return!1}}function ED(e,t){if(!e)return!1;try{return e.setItem(Nw,t),!0}catch{return!1}}function jD({stored:e,running:t,notes:n,remembers:s=!0}){if(!zo(t))return{show:[],record:null,reason:"no-version"};if(!zo(e)){if(!s)return{show:[],record:t,reason:"cannot-remember"};const l=yD(n,t);return l.length?{show:l,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const o=Fo(e,t);if(o===0)return{show:[],record:null,reason:"seen"};if(o>0)return{show:[],record:null,reason:"ahead"};const a=jT(n,e,t);return a.length?{show:a,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function CD({entries:e,since:t,running:n,firstRun:s,onClose:o}){const a=kn(o),l=wD(e);return d.jsx("div",{className:"modal-backdrop",onClick:o,role:"presentation",children:d.jsxs("div",{ref:a,className:"modal release-notes",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"release-notes-title",children:[d.jsxs("header",{className:"modal-head",children:[d.jsxs("div",{className:"modal-title",children:[d.jsx("span",{id:"release-notes-title",className:"modal-tool-name",children:"What's new"}),l&&d.jsx("span",{className:"modal-tool-id",children:l})]}),d.jsx("div",{className:"modal-actions",children:d.jsx("button",{type:"button",className:"glyph-btn",onClick:o,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),d.jsxs("section",{className:"modal-body",children:[d.jsx("p",{className:"modal-note",children:xD({since:t,running:n,firstRun:s,entries:e})}),e.map(u=>d.jsxs("section",{className:"modal-section",children:[d.jsxs("h3",{className:"rn-version",children:["v",u.version]}),d.jsx("ul",{className:"rn-notes",children:u.notes.map((h,p)=>{const{icon:f,rest:g}=_D(h.title);return d.jsxs("li",{className:"rn-note",children:[d.jsxs("p",{className:"rn-note-title",children:[f&&d.jsx("span",{className:"rn-note-icon",children:f}),g]}),d.jsx("p",{className:"rn-note-body",children:h.body})]},p)})})]},u.version))]})]})})}function TD(e){return e.slice().sort((t,n)=>t.y-n.y||t.x-n.x)}function RD(e,t,n){var l;if(e.length===0)return null;const s=TD(e),o=t?s.findIndex(u=>u.id===t):-1,a=o===-1?n===1?0:s.length-1:(o+n+s.length)%s.length;return((l=s[a])==null?void 0:l.id)??null}const AD=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Delete","Backspace"]);function MD(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:AD.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const ID=new Set(["","BODY","HTML","#DOCUMENT"]);function OD(e){return!e||gw(e)?!1:!ID.has(String(e.tagName??"").toUpperCase())}function Vc(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function PD(e,t){let n=!1;for(const o of e)if(!t.has(o)){n=!0;break}if(!n)return e;const s=new Set;for(const o of e)t.has(o)&&s.add(o);return s}function $D(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`);return t}function LD(e,t){if(!t||!e.agents.get(t))return null;const s=new Set([t]);let o=t;for(;o;){const l=e.agents.get(o);if(!(l!=null&&l.parentId)||s.has(l.parentId))break;s.add(l.parentId),o=l.parentId}let a=!0;for(;a;){a=!1;for(const l of e.agents.values())l.parentId&&s.has(l.parentId)&&!s.has(l.id)&&(s.add(l.id),a=!0)}return s}function qD(e,t){const n=new Set;for(const s of t){const o=LD(e,s);if(o)for(const a of o)n.add(a)}return n.size>0?n:null}function CT(e,t,n){return!t.has(e)||n.has(e)}function DD(e,t,n,s){return!t.has(e)&&CT(e,n,s)}function FD(e,t,n){const s={x:0,y:0};return t.set(e,s),n.add(e),s}function zD(e,t,n,s){n.set(e,t),s.delete(e)}const BD=40,UD=120;function WD(e,t){let n=null,s=0,o=Number.NEGATIVE_INFINITY;const a=()=>{n=null,o=t.now(),e()},l=()=>{n!=null&&(t.clearTimeout(n),n=null)},u=(h,p,f)=>{if(n!=null){if(s<=h)return;l()}const g=Math.min(f,Math.max(0,h-p));s=h,n=t.setTimeout(a,g)};return{live(h=BD){const p=t.now(),f=Math.max(o+h,p);if(f<=p){l(),a();return}u(f,p,h)},replay(h=UD){l(),s=t.now()+h,n=t.setTimeout(a,h)},flush(){l(),a()},cancel(){l()}}}const HD=1e3;function GD(e={}){const t=Math.max(1,Math.floor(e.limit??HD)),n=e.protect;let s=!1,o=[],a=new Set,l=0,u=0,h=null;return{get paused(){return s},get size(){return o.length},get dropped(){return l},get overflowed(){return l>0},get through(){return u},accept(p){const f=typeof(p==null?void 0:p.seq)=="number"?p.seq:null,g=(p==null?void 0:p.epoch)??null,y=g!==null&&g!==h;y&&(h=g,u=0);const w=f!==null&&!y&&f<=u;if(f!==null&&f>u&&(u=f),!s)return!0;if(w)return!1;if(o.push(p),n!=null&&n(p)&&a.add(p),o.length>t){let S=0;if(a.size<o.length)for(;a.has(o[S]);)S++;const[b]=o.splice(S,1);a.delete(b),l++}return!1},setPaused(p){if(s=p,p)return[];const f=o;return o=[],a=new Set,l=0,f}}}const TT="agent-dag.theme";function VD(e){return e==="light"?"light":"dark"}function YD(){return VD(Mu(TT))}function KD({waiting:e,running:t,connected:n=!0}){return{title:e>0?`(${e}) ${zt}`:zt,icon:n?e>0?"waiting":t>0?"running":"idle":"offline"}}const Yc={offline:"#e05252",waiting:"#c97d12",running:"#2a90d4",idle:"#7e828c"};function Kc(e,t){const o=l=>`<circle cx="16" cy="16" r="12" fill="none" stroke="${e}" stroke-width="5"${l}/>`;return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">${t==="waiting"?`<circle cx="16" cy="16" r="14.5" fill="${e}"/>`:t==="offline"?o(` stroke-dasharray="${56.5485.toFixed(2)} ${18.8495.toFixed(2)}" transform="rotate(-58 16 16)"`):o("")+(t==="running"?`<circle cx="16" cy="16" r="5" fill="${e}"/>`:"")}</svg>`}const XD=Object.freeze({offline:`data:image/svg+xml,${encodeURIComponent(Kc(Yc.offline,"offline"))}`,waiting:`data:image/svg+xml,${encodeURIComponent(Kc(Yc.waiting,"waiting"))}`,running:`data:image/svg+xml,${encodeURIComponent(Kc(Yc.running,"running"))}`,idle:`data:image/svg+xml,${encodeURIComponent(Kc(Yc.idle,"idle"))}`}),QD="No sessions are waiting for you.";function ZD(e){if(e.length===0)return"";const[t,...n]=e;if(n.length===0)return`${t.label} is waiting for your permission.`;const s=`${n.length} more session${n.length===1?"":"s"}`;return`${t.label} and ${s} are waiting for your permission.`}function JD(e,t){return t!==""?t:e===""?"":QD}function e5(){let e=0;return{begin(){const t=++e;return()=>t===e},cancel(){e++}}}function t5(e,t=new Date){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}function n5(e){return!e.answer||e.answer.range!==e.want?{phase:"busy",stale:!1}:e.answer.ok?{phase:e.answer.days>0?"chart":"empty",stale:e.loading}:{phase:"error",stale:e.loading}}function r5(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const O1={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent"};function Ew(e){const t=e.toLowerCase();return Object.hasOwn(O1,t)?O1[t]:t?t[0].toUpperCase()+t.slice(1):""}function s5(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function i5(e,t=[]){const n=t.length?s5(t.map(Ew)):r5(e);return n?`via ccusage · local ${n} logs`:"via ccusage · local agent logs"}function o5(e){const t=e.claude?{provider:"claude",watching:!0,spans:[{text:"Claude Code sends its events through a hook in "},{text:"~/.claude/settings.json",code:!0},{text:" — or in "},{text:"$CLAUDE_CONFIG_DIR/settings.json",code:!0},{text:" when you have that set — which the deck installs on first run."}]}:{provider:"claude",watching:!1,spans:[{text:"Claude Code capture is off: no Claude Code was found on this machine, or the deck was started with "},{text:"--no-claude",code:!0},{text:"."}]},n=e.codex?{provider:"codex",watching:!0,spans:[{text:"Codex installs nothing and needs no trust prompt — the deck reads "},{text:"~/.codex/sessions/",code:!0},{text:" itself, so an empty canvas means no rollout has been written there yet, or that "},{text:"$CODEX_HOME",code:!0},{text:" points at a different tree."}]}:{provider:"codex",watching:!1,spans:[{text:"Codex capture is off: no "},{text:"~/.codex/",code:!0},{text:" was found — set "},{text:"$CODEX_HOME",code:!0},{text:" if yours lives elsewhere — or the deck was started with "},{text:"--no-codex",code:!0},{text:"."}]};return[t,n]}function a5(e,t){const n=t.prefs??By,s=ol(n.done.level),o=ol(n["needs-input"].level),a=s===o?`${s}%`:`${s}% and ${o}%`,l=t.on?`Sound: on at ${a} — a tone when a turn finishes, another when Claude asks for you (M)`:"Sound: off — press M, or use the switch in here, for a tone when a turn finishes (M)",u=e.codex?`
133
+ Click the version at the top of the deck to read it again whenever you like.`}],"1.45.0":[{title:"🔕 The deck no longer puts anything in your settings.json",body:"It used to add a hook there so Claude Code would play a sound when a turn ended. That entry is removed the first time you start this version, and any sound hook you wrote yourself is put back exactly where you had it. Nothing else in that file is touched. The deck makes the sound itself now — which is also why you finally hear one when a Codex turn ends, not just a Claude one."}]},Nw="agent-dag.releaseNotesSeen";function M1(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function Fo(e,t){const n=M1(e),s=M1(t);for(let o=0;o<Math.max(n.length,s.length);o++){const a=(n[o]??0)-(s[o]??0);if(a!==0)return a<0?-1:1}return 0}function zo(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function mD(e){if(!e||typeof e!="object")return!1;const{title:t,body:n}=e;return typeof t=="string"&&t.trim()!==""&&typeof n=="string"&&n.trim()!==""}function gD(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,s]of Object.entries(e)){if(!zo(n)||!Array.isArray(s))continue;const o=s.filter(mD);o.length&&t.push({version:n,notes:o})}return t.sort((n,s)=>Fo(s.version,n.version))}const I1=gD(pD);function jT(e,t,n){return e.filter(s=>Fo(s.version,n)<=0&&(t===null||Fo(s.version,t)>0))}function vD(e,t){return e.filter(n=>Fo(n.version,t)===0)}function yD(e){if(!e.length)return"";const t=e[0].version,n=e[e.length-1].version;return t===n?`v${t}`:`v${n} – v${t}`}function wD({since:e,running:t,entries:n,firstRun:s}){if(!n.length)return"Nothing in this build has anything to report yet. Most releases do not, which is the point.";if(e!==null){const l=n.length===1?"one release":`${n.length} releases`;return`You were last caught up at v${e}. Since then ${l} changed something you would notice. Clicking the version in the topbar brings this back.`}if(s&&zo(t))return`The deck has not run in this browser before, so this is what v${t} — the release you have — changed. Earlier releases are not repeated here; clicking the version in the topbar brings all of them back.`;const o=n[0].version;if(!zo(t))return"Everything this build has to say, newest first. Most releases have nothing here, which is why the deck stays quiet about them.";const a=Fo(o,t);return a<0?`v${t} — the release you are running — changed nothing you would notice, which most releases do not. Below is the last release that did, and everything before it, newest first.`:a>0?"Everything this build has to say, newest first. Most releases have nothing here, which is why the deck stays quiet about them.":`You are running v${t}, and this is what it changed — and everything before it, newest first. Most releases have nothing here, which is why the deck stays quiet about them.`}const xD=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function bD(e){const t=xD.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function _D(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function kD(e){if(!e)return null;let t=null;try{t=e.getItem(Nw)}catch{return null}return zo(t)?t:null}function SD(e){if(!e)return!1;try{return e.getItem(Nw),!0}catch{return!1}}function ND(e,t){if(!e)return!1;try{return e.setItem(Nw,t),!0}catch{return!1}}function ED({stored:e,running:t,notes:n,remembers:s=!0}){if(!zo(t))return{show:[],record:null,reason:"no-version"};if(!zo(e)){if(!s)return{show:[],record:t,reason:"cannot-remember"};const l=vD(n,t);return l.length?{show:l,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const o=Fo(e,t);if(o===0)return{show:[],record:null,reason:"seen"};if(o>0)return{show:[],record:null,reason:"ahead"};const a=jT(n,e,t);return a.length?{show:a,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function jD({entries:e,since:t,running:n,firstRun:s,onClose:o}){const a=kn(o),l=yD(e);return d.jsx("div",{className:"modal-backdrop",onClick:o,role:"presentation",children:d.jsxs("div",{ref:a,className:"modal release-notes",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"release-notes-title",children:[d.jsxs("header",{className:"modal-head",children:[d.jsxs("div",{className:"modal-title",children:[d.jsx("span",{id:"release-notes-title",className:"modal-tool-name",children:"What's new"}),l&&d.jsx("span",{className:"modal-tool-id",children:l})]}),d.jsx("div",{className:"modal-actions",children:d.jsx("button",{type:"button",className:"glyph-btn",onClick:o,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),d.jsxs("section",{className:"modal-body",children:[d.jsx("p",{className:"modal-note",children:wD({since:t,running:n,firstRun:s,entries:e})}),e.map(u=>d.jsxs("section",{className:"modal-section",children:[d.jsxs("h3",{className:"rn-version",children:["v",u.version]}),d.jsx("ul",{className:"rn-notes",children:u.notes.map((h,p)=>{const{icon:f,rest:g}=bD(h.title);return d.jsxs("li",{className:"rn-note",children:[d.jsxs("p",{className:"rn-note-title",children:[f&&d.jsx("span",{className:"rn-note-icon",children:f}),g]}),d.jsx("p",{className:"rn-note-body",children:h.body})]},p)})})]},u.version))]})]})})}function CD(e){return e.slice().sort((t,n)=>t.y-n.y||t.x-n.x)}function TD(e,t,n){var l;if(e.length===0)return null;const s=CD(e),o=t?s.findIndex(u=>u.id===t):-1,a=o===-1?n===1?0:s.length-1:(o+n+s.length)%s.length;return((l=s[a])==null?void 0:l.id)??null}const RD=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Delete","Backspace"]);function AD(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:RD.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const MD=new Set(["","BODY","HTML","#DOCUMENT"]);function ID(e){return!e||gw(e)?!1:!MD.has(String(e.tagName??"").toUpperCase())}function Vc(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function OD(e,t){let n=!1;for(const o of e)if(!t.has(o)){n=!0;break}if(!n)return e;const s=new Set;for(const o of e)t.has(o)&&s.add(o);return s}function PD(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`);return t}function $D(e,t){if(!t||!e.agents.get(t))return null;const s=new Set([t]);let o=t;for(;o;){const l=e.agents.get(o);if(!(l!=null&&l.parentId)||s.has(l.parentId))break;s.add(l.parentId),o=l.parentId}let a=!0;for(;a;){a=!1;for(const l of e.agents.values())l.parentId&&s.has(l.parentId)&&!s.has(l.id)&&(s.add(l.id),a=!0)}return s}function LD(e,t){const n=new Set;for(const s of t){const o=$D(e,s);if(o)for(const a of o)n.add(a)}return n.size>0?n:null}function CT(e,t,n){return!t.has(e)||n.has(e)}function qD(e,t,n,s){return!t.has(e)&&CT(e,n,s)}function DD(e,t,n){const s={x:0,y:0};return t.set(e,s),n.add(e),s}function FD(e,t,n,s){n.set(e,t),s.delete(e)}const zD=40,BD=120;function UD(e,t){let n=null,s=0,o=Number.NEGATIVE_INFINITY;const a=()=>{n=null,o=t.now(),e()},l=()=>{n!=null&&(t.clearTimeout(n),n=null)},u=(h,p,f)=>{if(n!=null){if(s<=h)return;l()}const g=Math.min(f,Math.max(0,h-p));s=h,n=t.setTimeout(a,g)};return{live(h=zD){const p=t.now(),f=Math.max(o+h,p);if(f<=p){l(),a();return}u(f,p,h)},replay(h=BD){l(),s=t.now()+h,n=t.setTimeout(a,h)},flush(){l(),a()},cancel(){l()}}}const WD=1e3;function HD(e={}){const t=Math.max(1,Math.floor(e.limit??WD)),n=e.protect;let s=!1,o=[],a=new Set,l=0,u=0,h=null;return{get paused(){return s},get size(){return o.length},get dropped(){return l},get overflowed(){return l>0},get through(){return u},accept(p){const f=typeof(p==null?void 0:p.seq)=="number"?p.seq:null,g=(p==null?void 0:p.epoch)??null,y=g!==null&&g!==h;y&&(h=g,u=0);const w=f!==null&&!y&&f<=u;if(f!==null&&f>u&&(u=f),!s)return!0;if(w)return!1;if(o.push(p),n!=null&&n(p)&&a.add(p),o.length>t){let S=0;if(a.size<o.length)for(;a.has(o[S]);)S++;const[b]=o.splice(S,1);a.delete(b),l++}return!1},setPaused(p){if(s=p,p)return[];const f=o;return o=[],a=new Set,l=0,f}}}const TT="agent-dag.theme";function GD(e){return e==="light"?"light":"dark"}function VD(){return GD(Mu(TT))}function YD({waiting:e,running:t,connected:n=!0}){return{title:e>0?`(${e}) ${zt}`:zt,icon:n?e>0?"waiting":t>0?"running":"idle":"offline"}}const Yc={offline:"#e05252",waiting:"#c97d12",running:"#2a90d4",idle:"#7e828c"};function Kc(e,t){const o=l=>`<circle cx="16" cy="16" r="12" fill="none" stroke="${e}" stroke-width="5"${l}/>`;return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">${t==="waiting"?`<circle cx="16" cy="16" r="14.5" fill="${e}"/>`:t==="offline"?o(` stroke-dasharray="${56.5485.toFixed(2)} ${18.8495.toFixed(2)}" transform="rotate(-58 16 16)"`):o("")+(t==="running"?`<circle cx="16" cy="16" r="5" fill="${e}"/>`:"")}</svg>`}const KD=Object.freeze({offline:`data:image/svg+xml,${encodeURIComponent(Kc(Yc.offline,"offline"))}`,waiting:`data:image/svg+xml,${encodeURIComponent(Kc(Yc.waiting,"waiting"))}`,running:`data:image/svg+xml,${encodeURIComponent(Kc(Yc.running,"running"))}`,idle:`data:image/svg+xml,${encodeURIComponent(Kc(Yc.idle,"idle"))}`}),XD="No sessions are waiting for you.";function QD(e){if(e.length===0)return"";const[t,...n]=e;if(n.length===0)return`${t.label} is waiting for your permission.`;const s=`${n.length} more session${n.length===1?"":"s"}`;return`${t.label} and ${s} are waiting for your permission.`}function ZD(e,t){return t!==""?t:e===""?"":XD}function JD(){let e=0;return{begin(){const t=++e;return()=>t===e},cancel(){e++}}}function e5(e,t=new Date){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}function t5(e){return!e.answer||e.answer.range!==e.want?{phase:"busy",stale:!1}:e.answer.ok?{phase:e.answer.days>0?"chart":"empty",stale:e.loading}:{phase:"error",stale:e.loading}}function n5(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const O1={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent"};function Ew(e){const t=e.toLowerCase();return Object.hasOwn(O1,t)?O1[t]:t?t[0].toUpperCase()+t.slice(1):""}function r5(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function s5(e,t=[]){const n=t.length?r5(t.map(Ew)):n5(e);return n?`via ccusage · local ${n} logs`:"via ccusage · local agent logs"}function i5(e){const t=e.claude?{provider:"claude",watching:!0,spans:[{text:"Claude Code sends its events through a hook in "},{text:"~/.claude/settings.json",code:!0},{text:" — or in "},{text:"$CLAUDE_CONFIG_DIR/settings.json",code:!0},{text:" when you have that set — which the deck installs on first run."}]}:{provider:"claude",watching:!1,spans:[{text:"Claude Code capture is off: no Claude Code was found on this machine, or the deck was started with "},{text:"--no-claude",code:!0},{text:"."}]},n=e.codex?{provider:"codex",watching:!0,spans:[{text:"Codex installs nothing and needs no trust prompt — the deck reads "},{text:"~/.codex/sessions/",code:!0},{text:" itself, so an empty canvas means no rollout has been written there yet, or that "},{text:"$CODEX_HOME",code:!0},{text:" points at a different tree."}]}:{provider:"codex",watching:!1,spans:[{text:"Codex capture is off: no "},{text:"~/.codex/",code:!0},{text:" was found — set "},{text:"$CODEX_HOME",code:!0},{text:" if yours lives elsewhere — or the deck was started with "},{text:"--no-codex",code:!0},{text:"."}]};return[t,n]}function o5(e,t){const n=t.prefs??By,s=ol(n.done.level),o=ol(n["needs-input"].level),a=s===o?`${s}%`:`${s}% and ${o}%`,l=t.on?`Sound: on at ${a} — a tone when a turn finishes, another when Claude asks for you (M)`:"Sound: off — press M, or use the switch in here, for a tone when a turn finishes (M)",u=e.codex?`
128
134
 
129
135
  Both CLIs get the finish tone. The second tone — Claude is waiting for you — has no Codex equivalent to fire on, so it only ever plays for Claude Code.`:"",h=t.on&&t.locked?`
130
136
 
131
137
  Waiting for a click: this browser plays no sound until the page has been used at least once. Anything you press unlocks it.`:"";return l+u+h+`
132
138
 
133
- Click to set the volume and the sound of each tone, and to hear either one.`}function RT(e){const t=new Map;for(const n of e)for(const s of n.agents??[]){if(!s||typeof s.agent!="string"||s.agent==="")continue;const o=t.get(s.agent)??{id:s.agent,cost:0,tokens:0};o.cost+=Number.isFinite(s.totalCost)?s.totalCost:0,o.tokens+=Number.isFinite(s.totalTokens)?s.totalTokens:0,t.set(s.agent,o)}return[...t.values()].sort((n,s)=>s.cost-n.cost||n.id.localeCompare(s.id))}function l5(e){const t=RT([{agents:e}]);return t.length<2?null:t.map(n=>`${Ew(n.id)} ${Ve(n.cost)}`).join(" · ")}function P1(e){switch(e.toLowerCase()){case"claude":return"var(--usage-purple)";case"codex":return"var(--usage-orange)";case"gemini":return"var(--usage-indigo)";case"copilot":return"var(--usage-green)";default:return"var(--usage-zinc)"}}function c5(e,t){if(!(t>0)||!(e>0))return"0%";const n=e/t*100;return n<.1?"<0.1%":`${n.toFixed(1)}%`}function Xc(e){const t=e.toLowerCase();return t.includes("opus")?"var(--usage-purple)":t.includes("sonnet")?"var(--usage-blue)":t.includes("haiku")?"var(--usage-green)":t.includes("gpt-5")||t.includes("gpt5")?"var(--usage-amber)":t.includes("gpt")?"var(--usage-red)":t.includes("gemini")?"var(--usage-indigo)":t.includes("codex")?"var(--usage-orange)":"var(--usage-zinc)"}const u5=[7,14,30,90];function d5(e){const[t,n]=E.useState(null),[s,o]=E.useState(!1),a=E.useState(e5)[0],l=E.useRef(!1),u=(h=!1)=>{if(h&&!or(l.current))return;const p=a.begin();l.current=h;const f=e;o(!0);const y=`/api/ccusage?since=${t5(f)}${h?"&refresh=1":""}`;fetch(y).then(w=>w.json()).then(w=>{p()&&n({range:f,resp:w})}).catch(()=>{p()&&n({range:f,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{p()&&(l.current=!1,o(!1))})};return E.useEffect(()=>(u(!1),()=>a.cancel()),[e]),{landed:t,loading:s,reload:()=>u(!0)}}function f5({onClose:e,providers:t}){var F;const[n,s]=E.useState(30),[o,a]=E.useState(null),{landed:l,loading:u,reload:h}=d5(n),p=E.useRef(null),f=kn(e,{focusRef:p}),g=n5({loading:u,want:n,answer:l&&{range:l.range,ok:l.resp.ok===!0,days:((F=l.resp.days)==null?void 0:F.length)??0}}),y=g.phase==="chart"?l.resp.days??[]:[],w=E.useMemo(()=>y.reduce((O,A)=>Math.max(O,A.totalCost),0),[y]),S=E.useRef(null);E.useLayoutEffect(()=>{const O=S.current;O&&(O.scrollLeft=O.scrollWidth)},[y]);const{totalCost:b,totalTok:_,inOut:k,cacheRead:N,modelCosts:j}=E.useMemo(()=>{let O=0,A=0,D=0,H=0;const K=new Map;for(const C of y){O+=C.totalCost,A+=C.totalTokens,D+=C.inputTokens+C.outputTokens,H+=C.cacheReadTokens;for(const X of C.modelBreakdowns)K.set(X.modelName,(K.get(X.modelName)??0)+X.cost)}return{totalCost:O,totalTok:A,inOut:D,cacheRead:H,modelCosts:K}},[y]),T=E.useMemo(()=>Array.from(j.entries()).sort((O,A)=>A[1]-O[1]),[j]),M=E.useMemo(()=>RT(y),[y]),P=M.length>1,I=o?y.find(O=>O.period===o)??null:null;return d.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:d.jsxs("div",{ref:f,className:"uh-modal",onClick:O=>O.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Usage history",children:[d.jsxs("header",{className:"uh-head",children:[d.jsxs("div",{className:"uh-titlewrap",children:[d.jsx("div",{className:"uh-title",children:"Usage history"}),d.jsx("div",{className:"uh-sub",children:i5(t,M.map(O=>O.id))})]}),d.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:u5.map(O=>d.jsxs("button",{type:"button","aria-pressed":n===O,className:"uh-range-btn",onClick:()=>{s(O),a(null)},children:[O,"d"]},O))}),d.jsx("button",{className:"glyph-btn uh-reload",onClick:h,...ir(u),title:"Re-run ccusage","aria-label":"Reload",children:u?"…":"↻"}),d.jsx("button",{ref:p,className:"glyph-btn uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),g.phase==="busy"?d.jsx("div",{className:"uh-status","aria-busy":"true",children:l?"running ccusage…":"running ccusage… (first run downloads the package)"}):g.phase==="error"?d.jsxs("div",{className:"uh-status uh-err",title:qo(l.resp)||void 0,children:[iq(l.resp,"ccusage did not report usage"),d.jsx("div",{children:d.jsx("button",{className:"btn uh-retry",onClick:h,...ir(u),children:u?"trying…":"Try again"})})]}):g.phase==="empty"?d.jsx("div",{className:`uh-status${g.stale?" uh-stale":""}`,"aria-busy":g.stale||void 0,children:"no usage in this range"}):d.jsxs("div",{className:g.stale?"uh-stale":void 0,"aria-busy":g.stale||void 0,children:[d.jsxs("div",{className:"uh-totals",children:[d.jsx(Qc,{label:"total cost",val:Ve(b),accent:!0}),d.jsx(Qc,{label:"tokens",val:Pt(_)}),d.jsx(Qc,{label:"input+output",val:Pt(k)}),d.jsx(Qc,{label:"cache reads",val:Pt(N)})]}),P&&d.jsxs("div",{className:"uh-agents",role:"group","aria-label":"Cost by CLI",children:[d.jsx("div",{className:"uh-agent-bar","aria-hidden":"true",children:M.map(O=>d.jsx("span",{className:"uh-agent-seg",style:{width:`${b>0?O.cost/b*100:0}%`,background:P1(O.id)}},O.id))}),d.jsx("div",{className:"uh-agent-keys",children:M.map(O=>d.jsxs("span",{className:"uh-agent-key",title:`${O.id} · ${Pt(O.tokens)} tokens`,children:[d.jsx("span",{className:"uh-legend-dot",style:{background:P1(O.id)}}),Ew(O.id),d.jsx("span",{className:"uh-agent-cost",children:Ve(O.cost)}),d.jsx("span",{className:"uh-agent-share",children:c5(O.cost,b)})]},O.id))})]}),d.jsx("div",{ref:S,className:"uh-chart",role:"group","aria-label":"Daily cost by model",children:y.map(O=>{const A=w>0?O.totalCost/w*100:0,D=O.period===o,H=`${O.period}, ${Ve(O.totalCost)}`;return d.jsxs("button",{className:`uh-bar-col${D?" sel":""}`,onClick:()=>a(D?null:O.period),"aria-pressed":D,"aria-label":H,title:`${O.period} · ${Ve(O.totalCost)}`,style:{flexBasis:`${100/y.length}%`},children:[d.jsx("div",{className:"uh-bar",style:{height:`${Math.max(A,O.totalCost>0?2:0)}%`},children:O.modelBreakdowns.slice().sort((K,C)=>C.cost-K.cost).map(K=>{const C=O.totalCost>0?K.cost/O.totalCost*100:0;return d.jsx("div",{className:"uh-bar-seg",style:{height:`${C}%`,background:Xc(K.modelName)}},K.modelName)})}),d.jsx("span",{className:"uh-bar-label",children:O.period.slice(5)})]},O.period)})}),d.jsx("div",{className:"uh-legend",children:T.map(([O,A])=>d.jsxs("span",{className:"uh-legend-item",title:O,children:[d.jsx("span",{className:"uh-legend-dot",style:{background:Xc(O)}}),xi(O)," ",d.jsx("span",{className:"uh-legend-cost",children:Ve(A)})]},O))}),I&&d.jsxs("div",{className:"uh-detail",children:[d.jsxs("div",{className:"uh-detail-head",children:[d.jsx("span",{className:"uh-detail-date",children:I.period}),d.jsx("span",{className:"uh-detail-cost",children:Ve(I.totalCost)}),(()=>{var D,H;const A=l5(I.agents)??((H=(D=I.metadata)==null?void 0:D.agents)!=null&&H.length?I.metadata.agents.join(" · "):null);return A?d.jsx("span",{className:"uh-detail-agents",title:A,children:A}):null})()]}),d.jsxs("div",{className:"uh-detail-mini",children:[d.jsx(Zc,{label:"input",val:Pt(I.inputTokens)}),d.jsx(Zc,{label:"output",val:Pt(I.outputTokens)}),d.jsx(Zc,{label:"cache write",val:Pt(I.cacheCreationTokens)}),d.jsx(Zc,{label:"cache read",val:Pt(I.cacheReadTokens)})]}),d.jsx("div",{className:"uh-detail-models",children:I.modelBreakdowns.slice().sort((O,A)=>A.cost-O.cost).map(O=>{const A=I.totalCost>0?O.cost/I.totalCost*100:0;return d.jsxs("div",{className:"uh-model-row",title:O.modelName,children:[d.jsxs("span",{className:"uh-model-name",children:[d.jsx("span",{className:"uh-legend-dot",style:{background:Xc(O.modelName)}}),d.jsx("span",{className:"uh-model-label",children:xi(O.modelName)})]}),d.jsx("span",{className:"uh-model-bar",children:d.jsx("span",{className:"uh-model-bar-fill",style:{width:`${A}%`,background:Xc(O.modelName)}})}),d.jsx("span",{className:"uh-model-cost",children:Ve(O.cost)})]},O.modelName)})})]})]})]})})}function Qc({label:e,val:t,accent:n}){return d.jsxs("div",{className:"uh-stat",children:[d.jsx("span",{className:`uh-stat-val${n?" accent":""}`,children:t}),d.jsx("span",{className:"uh-stat-label",children:e})]})}function Zc({label:e,val:t}){return d.jsxs("div",{className:"uh-ministat",children:[d.jsx("span",{className:"uh-ministat-val",children:t}),d.jsx("span",{className:"uh-ministat-label",children:e})]})}function h5(e){const t=/^#?([0-9a-f]{6})$/i.exec((e??"").trim());if(!t)return!1;const n=parseInt(t[1],16),s=[n>>16&255,n>>8&255,n&255].map(o=>{const a=o/255;return a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)});return .2126*s[0]+.7152*s[1]+.0722*s[2]>.5}const $1=1e4,p5=12e3;function m5({browsers:e,findings:t,watching:n,palette:s,now:o=()=>Date.now()}){const a=E.useRef(null),l=E.useRef(null);return l.current={browsers:e,findings:t,watching:n},E.useEffect(()=>{var w;const u=a.current;if(!u)return;const h=u.getContext("2d");if(!h)return;const p=((w=window.matchMedia)==null?void 0:w.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;let f=0,g=!1;const y=()=>{var ne;if(g)return;const S=l.current;if(!S)return;const{browsers:b,findings:_,watching:k}=S,N=s["--accent"]||"#7dd3fc",j=s["--line"]||"#1f2229",T=s["--text-dim"]||"#6e727c",M=h5(s["--bg"]),P=M?42:26,I=M?.85:.65,F=o(),O=Math.min(window.devicePixelRatio||1,2),A=u.clientWidth,D=u.clientHeight;(u.width!==A*O||u.height!==D*O)&&(u.width=A*O,u.height=D*O),h.setTransform(O,0,0,O,0,0),h.clearRect(0,0,A,D);const H=A/2,K=D/2,C=Math.min(A,D)/2-6;h.strokeStyle=j,h.lineWidth=1,h.globalAlpha=M?1:.9;for(const J of[.4,.7,1])h.beginPath(),h.arc(H,K,C*J,0,Math.PI*2),h.stroke();h.beginPath(),h.moveTo(H-C,K),h.lineTo(H+C,K),h.moveTo(H,K-C),h.lineTo(H,K+C),h.stroke(),h.globalAlpha=1;const B=(k&&!p?F%$1/$1:0)*Math.PI*2-Math.PI/2;if(k){const J=(ne=h.createConicGradient)==null?void 0:ne.call(h,B-.85,H,K);J&&(J.addColorStop(0,"transparent"),J.addColorStop(.85/(Math.PI*2),`color-mix(in srgb, ${N} ${P}%, transparent)`),J.addColorStop(1,"transparent"),h.fillStyle=J,h.beginPath(),h.moveTo(H,K),h.arc(H,K,C,B-.85,B),h.closePath(),h.fill()),h.strokeStyle=N,h.globalAlpha=I,h.beginPath(),h.moveTo(H,K),h.lineTo(H+Math.cos(B)*C,K+Math.sin(B)*C),h.stroke(),h.globalAlpha=1}b.forEach((J,W)=>{const Q=W/Math.max(b.length,1)*Math.PI*2-Math.PI/2,$=J.lastReadMs===null?1:Math.min(1,(F-J.lastReadMs)/12e4),G=C*(.42+$*.5),Y=H+Math.cos(Q)*G,L=K+Math.sin(Q)*G,q=Math.abs((B-Q+Math.PI*3)%(Math.PI*2)-Math.PI),Z=k?Math.max(0,1-q/.55):0;h.beginPath(),h.arc(Y,L,3+Z*1.6,0,Math.PI*2),h.fillStyle=J.running?N:T,h.globalAlpha=J.running?.55+Z*.45:.35,h.fill(),h.globalAlpha=1});for(const J of _){const W=(F-J.atMs)/p5;if(W<0||W>1)continue;const $=Math.max(0,b.findIndex(L=>L.key===J.browser))/Math.max(b.length,1)*Math.PI*2-Math.PI/2,G=H+Math.cos($)*C*.6,Y=K+Math.sin($)*C*.6;h.beginPath(),h.arc(G,Y,4+W*22,0,Math.PI*2),h.strokeStyle=N,h.globalAlpha=(1-W)*.8,h.lineWidth=1.5,h.stroke(),h.globalAlpha=1}f=requestAnimationFrame(y)};return y(),()=>{g=!0,cancelAnimationFrame(f)}},[o,s]),d.jsx("canvas",{ref:a,className:"bw-radar",role:"img","aria-label":n?`Watching ${e.length} browser${e.length===1?"":"s"}`:"Not watching"})}const L1="agent-dag.browserWatch.seenMs";function g5(e,t){return e.filter(n=>n.startMs>t)}function v5(e,t,n){if(e===null)return null;const s=e+t-n;return s>0?s:null}function y5(e){const t=Math.ceil(e/1e3),n=Math.floor(t/60),s=t%60;return n>0?`${n}m ${s}s`:`${s}s`}function AT(e){return(e??[]).filter(t=>t.installed&&t.profiles>0)}function q1(e,t){return t?{kind:"saving",word:"Saving",detail:""}:e.settings.enabled?{kind:"on",word:"Watching",detail:""}:{kind:"off",word:"Paused",detail:"nothing new is recorded"}}function w5(e,t){return e.map(n=>({key:n.key,name:n.name,running:n.running,visits:t.filter(s=>s.browser===n.key).reduce((s,o)=>s+o.programVisits,0)}))}function x5(e,t){if(e===null)return null;const n=Math.max(0,Math.round((t-e)/1e3));if(n<5)return"just now";if(n<60)return`${n} sec ago`;const s=Math.round(n/60);return s<60?`${s} min ago`:`${Math.round(s/60)} hr ago`}function b5(e){const t=e.profiles.filter(s=>s.degraded);if(t.length>0){const s=t[0],o=t.length-1;return{kind:"unreadable",text:`${s.name}/${s.profile} could not be read — ${s.reason??"no reason given"}`+(o>0?`, and ${o} more`:"")+". The watch continues on the profiles it can read."}}const n=AT(e.browsers);return n.length===0?{kind:"no-profiles",text:"No browser on this machine has a profile to read. Open one of the browsers below once and it will be watched from then on."}:n.some(s=>s.running)?null:{kind:"none-running",text:"No watched browser is running, so nothing can be navigated right now. Their history is still read, and anything found while they were open is still here."}}function _5(e){const t=n=>new Date(n).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1});return e.count===1||e.endMs-e.startMs<6e4?t(e.startMs):`${t(e.startMs)} → ${t(e.endMs)}`}function k5(e){return new Date(e).toLocaleDateString(void 0,{weekday:"short",day:"numeric",month:"short"})}function D1(e){const t=Math.round((e.endMs-e.startMs)/6e4);return t<1?"":`${t} min`}function S5({onClose:e,onSeen:t,onWatching:n,palette:s}){const o=kn(e),[a,l]=E.useState(null),[u,h]=E.useState(null),[p,f]=E.useState(!1),g=E.useRef(!1),[y,w]=E.useState(null),[S,b]=E.useState(null),[_,k]=E.useState(!1),[N,j]=E.useState(!1),[T,M]=E.useState(!1),[P,I]=E.useState(!1),[F,O]=E.useState(!1),[A,D]=E.useState(!1),[H,K]=E.useState(()=>Date.now());E.useEffect(()=>{const Y=setInterval(()=>K(Date.now()),1e3);return()=>clearInterval(Y)},[]);const C=E.useCallback(async Y=>{var L;if(!(Y&&!or(g.current))){g.current=Y,f(!0);try{const q=await fetch(`/api/browser-watch${Y?"?refresh=1":""}`);if(!q.ok)throw new Error(`the deck answered ${q.status}`);const Z=await q.json();l(Z),w(se=>{var fe;return se===null?((fe=Z==null?void 0:Z.settings)==null?void 0:fe.quietMinutes)??15:se}),n(((L=Z==null?void 0:Z.settings)==null?void 0:L.enabled)===!0),h(null)}catch(q){h(q instanceof Error?q.message:String(q))}finally{g.current=!1,f(!1)}}},[n]);E.useEffect(()=>{C(!1)},[C]),E.useEffect(()=>{const Y=setInterval(()=>{C(!1)},1e4);return()=>clearInterval(Y)},[C]);const X=E.useCallback(async Y=>{try{await fetch("/api/browser-watch/dismiss",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:Y.host,startMs:Y.startMs})})}finally{await C(!1)}},[C]),B=E.useCallback(async Y=>{k(!0);try{const L=await fetch("/api/browser-watch",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Y)});if(!L.ok)throw new Error(`the deck answered ${L.status}`);await C(!1)}catch(L){h(L instanceof Error?L.message:String(L))}finally{k(!1)}},[C]);E.useEffect(()=>()=>t(Date.now()),[t]);const ne=E.useMemo(()=>{const Y=[];for(const L of(a==null?void 0:a.episodes)??[]){const q=k5(L.startMs),Z=Y[Y.length-1];Z&&Z.label===q?Z.episodes.push(L):Y.push({label:q,episodes:[L]})}return Y},[a]),J=AT(a==null?void 0:a.browsers);J.filter(Y=>Y.running).map(Y=>Y.name);const W=((a==null?void 0:a.browsers)??[]).filter(Y=>!(Y.installed&&Y.profiles>0)),Q=a?b5(a):null,$=J.reduce((Y,L)=>Y+L.profiles,0),G=a?v5(a.coverage.lastHumanMs,a.coverage.quietMs,H):null;return((a==null?void 0:a.profiles)??[]).reduce((Y,L)=>L.lastWrittenMs!==null&&(Y===null||L.lastWrittenMs>Y)?L.lastWrittenMs:Y,null),d.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:d.jsxs("div",{ref:o,className:"modal bw-modal",onClick:Y=>Y.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"bw-title",children:[d.jsxs("header",{className:"modal-head",children:[d.jsxs("div",{className:"modal-title",children:[d.jsx("span",{className:"modal-tool-name",id:"bw-title",children:"Browser watch"}),d.jsx("span",{className:"modal-tool-id",children:a?`${$} ${$===1?"profile":"profiles"} · local only`:"local only"})]}),d.jsxs("div",{className:"modal-actions",children:[d.jsx("button",{className:"glyph-btn",onClick:()=>void C(!0),...ir(p),"aria-label":"Re-read every profile now",title:"Re-read every profile now",children:p?"…":"↻"}),d.jsx("button",{className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),d.jsxs("div",{className:"modal-body bw-body",children:[!a&&!u&&d.jsxs("div",{className:"bw-loading",children:[d.jsx("span",{className:"bw-loading-bar","aria-hidden":!0}),d.jsx("p",{children:"Reading each browser's history. The first look copies the file, which takes a moment."})]}),u&&d.jsx("div",{className:"bw-state",children:d.jsxs("div",{className:"bw-row err",children:[d.jsx("span",{className:"bw-dot","aria-hidden":!0}),d.jsx("span",{className:"bw-row-label",children:"Could not read"}),d.jsx("span",{className:"bw-row-detail",children:u})]})}),a&&Q&&d.jsx("p",{className:`bw-trouble ${Q.kind}`,role:"status",children:Q.text}),a&&d.jsxs("div",{className:"bw-work",children:[d.jsxs("aside",{className:"bw-side",children:[d.jsxs("section",{className:"bw-sec",children:[d.jsxs("h4",{className:"bw-sec-head",children:["Activity overview",d.jsx("button",{className:"bw-help",onClick:()=>I(Y=>!Y),"aria-expanded":P,"aria-label":"What the sweep and the dots mean",children:"?"})]}),d.jsxs("div",{className:"bw-glance",children:[d.jsx(m5,{browsers:J.map(Y=>{var L;return{key:Y.key,name:Y.name,running:Y.running,lastReadMs:((L=a.profiles.find(q=>q.browser===Y.key))==null?void 0:L.lastWrittenMs)??null}}),findings:a.episodes.slice(0,6).map(Y=>({browser:Y.browser??null,atMs:Y.endMs})),watching:a.settings.enabled,palette:s}),d.jsx("ul",{className:"bw-counts",children:w5(J,a.profiles).map(Y=>d.jsxs("li",{children:[d.jsx("span",{className:"bw-count-n",children:Y.visits.toLocaleString("en-US")}),d.jsx("span",{className:"bw-count-of",children:Y.name})]},Y.key))})]}),d.jsx("p",{className:"bw-since",children:"Pages a program opened, since this deck started"}),a.coverage.checkedMs>0&&d.jsxs("p",{className:"bw-since",children:["Last checked ",x5(a.coverage.checkedMs,H),a.coverage.checks>0&&d.jsxs(d.Fragment,{children:[" · ",a.coverage.checks.toLocaleString("en-US")," ",a.coverage.checks===1?"check":"checks"]})]}),G!==null&&d.jsxs("p",{className:"bw-gate",children:["You are browsing — a program page would count in ",y5(G)]}),P&&d.jsxs("dl",{className:"bw-key",children:[d.jsx("dt",{children:"Sweep"}),d.jsx("dd",{children:"one poll of every watched profile"}),d.jsx("dt",{children:"Dot"}),d.jsx("dd",{children:"a browser, further out the longer since it last wrote history"}),d.jsx("dt",{children:"Ring"}),d.jsx("dd",{children:"a finding, leaving the browser it came from"})]})]}),d.jsxs("section",{className:"bw-sec",children:[d.jsxs("h4",{className:"bw-sec-head",children:["Watched profiles",d.jsx("button",{className:"bw-help",onClick:()=>O(Y=>!Y),"aria-expanded":F,"aria-label":"What running, idle and connected to Anthropic mean",children:"?"})]}),F&&d.jsxs("dl",{className:"bw-key",children:[d.jsx("dt",{children:"Running"}),d.jsx("dd",{children:"the browser has a process on this machine right now"}),d.jsx("dt",{children:"Connected"}),d.jsx("dd",{children:"an open connection to an address Anthropic's relay uses — which it shares with claude.ai, so an open tab looks the same as an agent channel"})]}),d.jsx("ul",{className:"bw-profiles",children:J.map(Y=>d.jsxs("li",{children:[d.jsx("span",{className:`bw-prof-dot${Y.running?" on":""}`,"aria-hidden":!0}),d.jsx("span",{className:"bw-prof-name",children:Y.name}),d.jsx("span",{className:"bw-prof-state",children:Y.running?"running":"idle"}),Y.running&&Y.relay.state==="live"&&d.jsx("span",{className:"bw-relay",children:"connected to Anthropic"})]},Y.key))}),W.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{className:"bw-why bw-rest-head",onClick:()=>D(Y=>!Y),"aria-expanded":A,children:[d.jsx("span",{className:"bw-chev","aria-hidden":!0,children:A?"▾":"▸"})," ",W.length," not watched"]}),A&&d.jsxs("p",{className:"bw-rest",children:[W.map(Y=>Y.name).join(", ")," — not installed, or installed and never opened, so there is no history to read."]})]})]})]}),d.jsxs("div",{className:"bw-main",children:[d.jsxs("section",{className:"bw-findings",children:[d.jsxs("h4",{className:"bw-sec-head bw-head-row",children:["Findings",a.episodes.length>0&&d.jsxs("span",{className:"bw-feed-count",children:[a.episodes.length," ",a.episodes.length===1?"episode":"episodes"]})]}),d.jsx("div",{className:"bw-eps",children:ne.length===0?d.jsxs("div",{className:"bw-empty",children:[d.jsx("p",{className:"bw-empty-head",children:"Nothing found yet"}),d.jsxs("p",{className:"bw-empty-note",children:["An episode lands here when a program opens pages in a browser nobody has touched for"," ",a.settings.quietMinutes," ",a.settings.quietMinutes===1?"minute":"minutes",". On most machines that is rare, so an empty list is the ordinary result rather than a sign something is wrong."]}),!a.settings.enabled&&d.jsx("p",{className:"bw-empty-note",children:"Watching is off, so this shows only what this deck has seen since it started. Anything an earlier run recorded comes back when you switch it on."})]}):ne.map(Y=>d.jsxs("div",{className:"bw-day",children:[d.jsx("h4",{className:"bw-sec-head",children:Y.label}),Y.episodes.map(L=>{const q=`${L.host}-${L.startMs}`,Z=S===q;return d.jsxs("div",{className:`bw-ep${Z?" open":""}`,children:[d.jsxs("div",{className:"bw-ep-row",children:[d.jsxs("button",{className:"bw-ep-head",onClick:()=>b(Z?null:q),"aria-expanded":Z,children:[d.jsx("span",{className:"bw-chev","aria-hidden":!0,children:Z?"▾":"▸"}),d.jsx("span",{className:"bw-ep-host",children:L.host}),d.jsxs("span",{className:"bw-ep-meta",children:[_5(L),D1(L)&&d.jsxs(d.Fragment,{children:[" · ",D1(L)]})]}),d.jsxs("span",{className:"bw-ep-count",children:[L.count," ",L.count===1?"page":"pages"]})]}),d.jsx("button",{className:"glyph-btn bw-ep-x",onClick:()=>void X(L),"aria-label":`Dismiss ${L.host}`,title:"Dismiss — it leaves this list for good, and stays in the log file",children:"×"})]}),Z&&d.jsx("ul",{className:"bw-urls",children:L.urls.map((se,fe)=>d.jsxs("li",{children:[d.jsx("span",{className:"bw-url-time",children:new Date(se.timeMs).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1})}),d.jsx("span",{className:"bw-url",children:se.url})]},`${se.url}-${se.timeMs}-${fe}`))})]},q)})]},Y.label))})]}),d.jsxs("section",{className:"bw-feed",children:[d.jsxs("h4",{className:"bw-sec-head bw-head-row",children:["Live activity",d.jsxs("span",{className:"bw-feed-count",children:[a.log.length," ",a.log.length===1?"event":"events"]})]}),d.jsx("p",{className:"bw-since bw-feed-note",children:"Pages you opened yourself — counted to run the rule, never written down. Addresses appear under Findings, and only for pages a program opened."}),d.jsx("div",{className:"bw-log","aria-live":"polite","aria-relevant":"additions",children:a.log.length===0?d.jsx("p",{className:"bw-note",children:"The deck writes a line here each time it looks at a profile."}):a.log.map(Y=>d.jsxs("div",{className:`bw-log-line ${Y.level}${Y.parts?"":" sys"}`,children:[d.jsx("span",{className:"bw-log-time",children:new Date(Y.atMs).toLocaleTimeString("en-GB",{hour12:!1})}),Y.parts?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"bw-log-browser",children:Y.parts.browser}),d.jsx("span",{className:"bw-log-profile",title:Y.parts.profile,children:Y.parts.profile}),d.jsxs("span",{className:"bw-log-value",children:[Y.parts.value,Y.parts.flagged>0&&d.jsxs("span",{className:"bw-log-flag",children:[" · ",Y.parts.flagged," flagged"]})]})]}):d.jsx("span",{className:"bw-log-sys",children:Y.text})]},`${Y.atMs}-${Y.level}-${Y.text}`))})]})]})]}),a&&N&&d.jsxs("div",{className:"bw-settings",children:[d.jsxs("label",{title:"A program opening a page counts as a finding only if nobody had touched the browser for this long. Shorter catches more and reports more of your own work; longer is quieter.",children:[d.jsx("span",{children:"Nobody browsing for"}),d.jsxs("select",{value:y??a.settings.quietMinutes,onChange:Y=>{w(Number(Y.target.value)),B({quietMinutes:Number(Y.target.value)})},children:[d.jsx("option",{value:1,children:"1 min"}),d.jsx("option",{value:5,children:"5 min"}),d.jsx("option",{value:15,children:"15 min"}),d.jsx("option",{value:30,children:"30 min"}),d.jsx("option",{value:60,children:"60 min"})]})]}),d.jsxs("label",{children:[d.jsx("span",{children:"When it finds one"}),d.jsx("select",{value:a.settings.reaction,onChange:Y=>void B({reaction:Y.target.value}),disabled:!a.settings.enabled,title:a.settings.enabled?"What to do besides writing it down.":"Turn watching on to arm a reaction.",children:(a.reactions??["notify"]).map(Y=>d.jsx("option",{value:Y,children:Y==="notify"?"notify me":Y==="close-tab"?"close the tab":"quit the browser"},Y))})]}),d.jsxs("div",{className:"bw-settings-note",children:[d.jsxs("p",{children:["Chrome marks a navigation that came from an extension or a command rather than from a click. These are the ones that happened while nobody had touched the browser for the time above. ",d.jsx("strong",{children:"Usually that is your own agent doing what you asked."})]}),d.jsxs("button",{className:"bw-why",onClick:()=>M(Y=>!Y),"aria-expanded":T,children:[d.jsx("span",{className:"bw-chev","aria-hidden":!0,children:T?"▾":"▸"})," What Browser Watch can access"]}),T&&d.jsxs("dl",{className:"bw-access",children:[d.jsx("dt",{children:"Reads"}),d.jsxs("dd",{children:["A copy of each browser's own history database — the live file is locked while the browser holds it. Only rows newer than the moment this deck started:"," ",new Date(a.coverage.startedMs).toLocaleString(),"."]}),d.jsx("dt",{children:"Keeps"}),d.jsxs("dd",{children:["Only while the switch is on, and only the episodes it flagged — never your ordinary browsing. In ",d.jsx("code",{className:"bw-path",children:a.coverage.logPath}),", with every address written in full so you can check it yourself."]}),d.jsx("dt",{children:"Sends"}),d.jsx("dd",{children:"Nothing. No part of this reads or writes over the network; the deck serves on 127.0.0.1 and this panel talks only to it."}),d.jsx("dt",{children:"Never reads"}),d.jsx("dd",{children:"Anything from before this deck started, cookies, saved passwords, page contents, or any browser profile with no history file."})]})]})]}),a&&d.jsxs("footer",{className:"bw-status",children:[d.jsx("span",{className:`bw-mode-dot${a.settings.enabled?" on":""}`,"aria-hidden":!0}),d.jsx("span",{className:"bw-mode-word",children:q1(a,_).word},q1(a,_).kind),d.jsx("span",{className:"bw-status-text",children:a.coverage.archived===0?a.settings.enabled?"No episodes recorded yet":"No episodes on disk":`${a.coverage.archived} ${a.coverage.archived===1?"episode":"episodes"} on disk`}),d.jsx("button",{className:`glyph-btn bw-gear${N?" on":""}`,onClick:()=>j(Y=>!Y),"aria-expanded":N,"aria-label":"Settings",title:"Settings",children:d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3","aria-hidden":!0,children:[d.jsx("circle",{cx:"7",cy:"7",r:"2.1"}),d.jsx("path",{d:"M7 1.2v1.6M7 11.2v1.6M1.2 7h1.6M11.2 7h1.6M2.9 2.9l1.1 1.1M10 10l1.1 1.1M11.1 2.9L10 4M4 10l-1.1 1.1"})]})}),d.jsxs("label",{className:"bw-switch",htmlFor:"bw-enabled",children:[d.jsx("span",{className:"bw-switch-label",id:"bw-enabled-label",children:"Watch browser activity"}),d.jsx("button",{id:"bw-enabled",type:"button",role:"switch","aria-checked":a.settings.enabled,"aria-labelledby":"bw-enabled-label",className:"bw-toggle",onClick:()=>void B({enabled:!a.settings.enabled}),title:a.settings.enabled?"On — every episode it finds is written down, so the list outlives the browsing history being cleared":"Off — showing only what this deck has seen since it started. Anything an earlier run archived is hidden until you switch back on, and nothing new is kept",children:d.jsx("span",{className:"bw-toggle-knob"})})]})]})]})]})})}function jw(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 Vf,F1;function N5(){if(F1)return Vf;F1=1;function e(){this.__data__=[],this.size=0}return Vf=e,Vf}var Yf,z1;function Wo(){if(z1)return Yf;z1=1;function e(t,n){return t===n||t!==t&&n!==n}return Yf=e,Yf}var Kf,B1;function Ou(){if(B1)return Kf;B1=1;var e=Wo();function t(n,s){for(var o=n.length;o--;)if(e(n[o][0],s))return o;return-1}return Kf=t,Kf}var Xf,U1;function E5(){if(U1)return Xf;U1=1;var e=Ou(),t=Array.prototype,n=t.splice;function s(o){var a=this.__data__,l=e(a,o);if(l<0)return!1;var u=a.length-1;return l==u?a.pop():n.call(a,l,1),--this.size,!0}return Xf=s,Xf}var Qf,W1;function j5(){if(W1)return Qf;W1=1;var e=Ou();function t(n){var s=this.__data__,o=e(s,n);return o<0?void 0:s[o][1]}return Qf=t,Qf}var Zf,H1;function C5(){if(H1)return Zf;H1=1;var e=Ou();function t(n){return e(this.__data__,n)>-1}return Zf=t,Zf}var Jf,G1;function T5(){if(G1)return Jf;G1=1;var e=Ou();function t(n,s){var o=this.__data__,a=e(o,n);return a<0?(++this.size,o.push([n,s])):o[a][1]=s,this}return Jf=t,Jf}var eh,V1;function Pu(){if(V1)return eh;V1=1;var e=N5(),t=E5(),n=j5(),s=C5(),o=T5();function a(l){var u=-1,h=l==null?0:l.length;for(this.clear();++u<h;){var p=l[u];this.set(p[0],p[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=s,a.prototype.set=o,eh=a,eh}var th,Y1;function R5(){if(Y1)return th;Y1=1;var e=Pu();function t(){this.__data__=new e,this.size=0}return th=t,th}var nh,K1;function A5(){if(K1)return nh;K1=1;function e(t){var n=this.__data__,s=n.delete(t);return this.size=n.size,s}return nh=e,nh}var rh,X1;function M5(){if(X1)return rh;X1=1;function e(t){return this.__data__.get(t)}return rh=e,rh}var sh,Q1;function I5(){if(Q1)return sh;Q1=1;function e(t){return this.__data__.has(t)}return sh=e,sh}var ih,Z1;function MT(){if(Z1)return ih;Z1=1;var e=typeof Ic=="object"&&Ic&&Ic.Object===Object&&Ic;return ih=e,ih}var oh,J1;function ur(){if(J1)return oh;J1=1;var e=MT(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return oh=n,oh}var ah,e_;function Ho(){if(e_)return ah;e_=1;var e=ur(),t=e.Symbol;return ah=t,ah}var lh,t_;function O5(){if(t_)return lh;t_=1;var e=Ho(),t=Object.prototype,n=t.hasOwnProperty,s=t.toString,o=e?e.toStringTag:void 0;function a(l){var u=n.call(l,o),h=l[o];try{l[o]=void 0;var p=!0}catch{}var f=s.call(l);return p&&(u?l[o]=h:delete l[o]),f}return lh=a,lh}var ch,n_;function P5(){if(n_)return ch;n_=1;var e=Object.prototype,t=e.toString;function n(s){return t.call(s)}return ch=n,ch}var uh,r_;function bi(){if(r_)return uh;r_=1;var e=Ho(),t=O5(),n=P5(),s="[object Null]",o="[object Undefined]",a=e?e.toStringTag:void 0;function l(u){return u==null?u===void 0?o:s:a&&a in Object(u)?t(u):n(u)}return uh=l,uh}var dh,s_;function qn(){if(s_)return dh;s_=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return dh=e,dh}var fh,i_;function yl(){if(i_)return fh;i_=1;var e=bi(),t=qn(),n="[object AsyncFunction]",s="[object Function]",o="[object GeneratorFunction]",a="[object Proxy]";function l(u){if(!t(u))return!1;var h=e(u);return h==s||h==o||h==n||h==a}return fh=l,fh}var hh,o_;function $5(){if(o_)return hh;o_=1;var e=ur(),t=e["__core-js_shared__"];return hh=t,hh}var ph,a_;function L5(){if(a_)return ph;a_=1;var e=$5(),t=(function(){var s=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""})();function n(s){return!!t&&t in s}return ph=n,ph}var mh,l_;function IT(){if(l_)return mh;l_=1;var e=Function.prototype,t=e.toString;function n(s){if(s!=null){try{return t.call(s)}catch{}try{return s+""}catch{}}return""}return mh=n,mh}var gh,c_;function q5(){if(c_)return gh;c_=1;var e=yl(),t=L5(),n=qn(),s=IT(),o=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,l=Function.prototype,u=Object.prototype,h=l.toString,p=u.hasOwnProperty,f=RegExp("^"+h.call(p).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function g(y){if(!n(y)||t(y))return!1;var w=e(y)?f:a;return w.test(s(y))}return gh=g,gh}var vh,u_;function D5(){if(u_)return vh;u_=1;function e(t,n){return t==null?void 0:t[n]}return vh=e,vh}var yh,d_;function _i(){if(d_)return yh;d_=1;var e=q5(),t=D5();function n(s,o){var a=t(s,o);return e(a)?a:void 0}return yh=n,yh}var wh,f_;function Cw(){if(f_)return wh;f_=1;var e=_i(),t=ur(),n=e(t,"Map");return wh=n,wh}var xh,h_;function $u(){if(h_)return xh;h_=1;var e=_i(),t=e(Object,"create");return xh=t,xh}var bh,p_;function F5(){if(p_)return bh;p_=1;var e=$u();function t(){this.__data__=e?e(null):{},this.size=0}return bh=t,bh}var _h,m_;function z5(){if(m_)return _h;m_=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return _h=e,_h}var kh,g_;function B5(){if(g_)return kh;g_=1;var e=$u(),t="__lodash_hash_undefined__",n=Object.prototype,s=n.hasOwnProperty;function o(a){var l=this.__data__;if(e){var u=l[a];return u===t?void 0:u}return s.call(l,a)?l[a]:void 0}return kh=o,kh}var Sh,v_;function U5(){if(v_)return Sh;v_=1;var e=$u(),t=Object.prototype,n=t.hasOwnProperty;function s(o){var a=this.__data__;return e?a[o]!==void 0:n.call(a,o)}return Sh=s,Sh}var Nh,y_;function W5(){if(y_)return Nh;y_=1;var e=$u(),t="__lodash_hash_undefined__";function n(s,o){var a=this.__data__;return this.size+=this.has(s)?0:1,a[s]=e&&o===void 0?t:o,this}return Nh=n,Nh}var Eh,w_;function H5(){if(w_)return Eh;w_=1;var e=F5(),t=z5(),n=B5(),s=U5(),o=W5();function a(l){var u=-1,h=l==null?0:l.length;for(this.clear();++u<h;){var p=l[u];this.set(p[0],p[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=s,a.prototype.set=o,Eh=a,Eh}var jh,x_;function G5(){if(x_)return jh;x_=1;var e=H5(),t=Pu(),n=Cw();function s(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return jh=s,jh}var Ch,b_;function V5(){if(b_)return Ch;b_=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return Ch=e,Ch}var Th,__;function Lu(){if(__)return Th;__=1;var e=V5();function t(n,s){var o=n.__data__;return e(s)?o[typeof s=="string"?"string":"hash"]:o.map}return Th=t,Th}var Rh,k_;function Y5(){if(k_)return Rh;k_=1;var e=Lu();function t(n){var s=e(this,n).delete(n);return this.size-=s?1:0,s}return Rh=t,Rh}var Ah,S_;function K5(){if(S_)return Ah;S_=1;var e=Lu();function t(n){return e(this,n).get(n)}return Ah=t,Ah}var Mh,N_;function X5(){if(N_)return Mh;N_=1;var e=Lu();function t(n){return e(this,n).has(n)}return Mh=t,Mh}var Ih,E_;function Q5(){if(E_)return Ih;E_=1;var e=Lu();function t(n,s){var o=e(this,n),a=o.size;return o.set(n,s),this.size+=o.size==a?0:1,this}return Ih=t,Ih}var Oh,j_;function Tw(){if(j_)return Oh;j_=1;var e=G5(),t=Y5(),n=K5(),s=X5(),o=Q5();function a(l){var u=-1,h=l==null?0:l.length;for(this.clear();++u<h;){var p=l[u];this.set(p[0],p[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=s,a.prototype.set=o,Oh=a,Oh}var Ph,C_;function Z5(){if(C_)return Ph;C_=1;var e=Pu(),t=Cw(),n=Tw(),s=200;function o(a,l){var u=this.__data__;if(u instanceof e){var h=u.__data__;if(!t||h.length<s-1)return h.push([a,l]),this.size=++u.size,this;u=this.__data__=new n(h)}return u.set(a,l),this.size=u.size,this}return Ph=o,Ph}var $h,T_;function qu(){if(T_)return $h;T_=1;var e=Pu(),t=R5(),n=A5(),s=M5(),o=I5(),a=Z5();function l(u){var h=this.__data__=new e(u);this.size=h.size}return l.prototype.clear=t,l.prototype.delete=n,l.prototype.get=s,l.prototype.has=o,l.prototype.set=a,$h=l,$h}var Lh,R_;function Rw(){if(R_)return Lh;R_=1;function e(t,n){for(var s=-1,o=t==null?0:t.length;++s<o&&n(t[s],s,t)!==!1;);return t}return Lh=e,Lh}var qh,A_;function OT(){if(A_)return qh;A_=1;var e=_i(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return qh=t,qh}var Dh,M_;function Du(){if(M_)return Dh;M_=1;var e=OT();function t(n,s,o){s=="__proto__"&&e?e(n,s,{configurable:!0,enumerable:!0,value:o,writable:!0}):n[s]=o}return Dh=t,Dh}var Fh,I_;function Fu(){if(I_)return Fh;I_=1;var e=Du(),t=Wo(),n=Object.prototype,s=n.hasOwnProperty;function o(a,l,u){var h=a[l];(!(s.call(a,l)&&t(h,u))||u===void 0&&!(l in a))&&e(a,l,u)}return Fh=o,Fh}var zh,O_;function wl(){if(O_)return zh;O_=1;var e=Fu(),t=Du();function n(s,o,a,l){var u=!a;a||(a={});for(var h=-1,p=o.length;++h<p;){var f=o[h],g=l?l(a[f],s[f],f,a,s):void 0;g===void 0&&(g=s[f]),u?t(a,f,g):e(a,f,g)}return a}return zh=n,zh}var Bh,P_;function J5(){if(P_)return Bh;P_=1;function e(t,n){for(var s=-1,o=Array(t);++s<t;)o[s]=n(s);return o}return Bh=e,Bh}var Uh,$_;function Er(){if($_)return Uh;$_=1;function e(t){return t!=null&&typeof t=="object"}return Uh=e,Uh}var Wh,L_;function eF(){if(L_)return Wh;L_=1;var e=bi(),t=Er(),n="[object Arguments]";function s(o){return t(o)&&e(o)==n}return Wh=s,Wh}var Hh,q_;function xl(){if(q_)return Hh;q_=1;var e=eF(),t=Er(),n=Object.prototype,s=n.hasOwnProperty,o=n.propertyIsEnumerable,a=e((function(){return arguments})())?e:function(l){return t(l)&&s.call(l,"callee")&&!o.call(l,"callee")};return Hh=a,Hh}var Gh,D_;function Rt(){if(D_)return Gh;D_=1;var e=Array.isArray;return Gh=e,Gh}var Ga={exports:{}},Vh,F_;function tF(){if(F_)return Vh;F_=1;function e(){return!1}return Vh=e,Vh}Ga.exports;var z_;function Go(){return z_||(z_=1,(function(e,t){var n=ur(),s=tF(),o=t&&!t.nodeType&&t,a=o&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===o,u=l?n.Buffer:void 0,h=u?u.isBuffer:void 0,p=h||s;e.exports=p})(Ga,Ga.exports)),Ga.exports}var Yh,B_;function zu(){if(B_)return Yh;B_=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(s,o){var a=typeof s;return o=o??e,!!o&&(a=="number"||a!="symbol"&&t.test(s))&&s>-1&&s%1==0&&s<o}return Yh=n,Yh}var Kh,U_;function Aw(){if(U_)return Kh;U_=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return Kh=t,Kh}var Xh,W_;function nF(){if(W_)return Xh;W_=1;var e=bi(),t=Aw(),n=Er(),s="[object Arguments]",o="[object Array]",a="[object Boolean]",l="[object Date]",u="[object Error]",h="[object Function]",p="[object Map]",f="[object Number]",g="[object Object]",y="[object RegExp]",w="[object Set]",S="[object String]",b="[object WeakMap]",_="[object ArrayBuffer]",k="[object DataView]",N="[object Float32Array]",j="[object Float64Array]",T="[object Int8Array]",M="[object Int16Array]",P="[object Int32Array]",I="[object Uint8Array]",F="[object Uint8ClampedArray]",O="[object Uint16Array]",A="[object Uint32Array]",D={};D[N]=D[j]=D[T]=D[M]=D[P]=D[I]=D[F]=D[O]=D[A]=!0,D[s]=D[o]=D[_]=D[a]=D[k]=D[l]=D[u]=D[h]=D[p]=D[f]=D[g]=D[y]=D[w]=D[S]=D[b]=!1;function H(K){return n(K)&&t(K.length)&&!!D[e(K)]}return Xh=H,Xh}var Qh,H_;function Bu(){if(H_)return Qh;H_=1;function e(t){return function(n){return t(n)}}return Qh=e,Qh}var Va={exports:{}};Va.exports;var G_;function Mw(){return G_||(G_=1,(function(e,t){var n=MT(),s=t&&!t.nodeType&&t,o=s&&!0&&e&&!e.nodeType&&e,a=o&&o.exports===s,l=a&&n.process,u=(function(){try{var h=o&&o.require&&o.require("util").types;return h||l&&l.binding&&l.binding("util")}catch{}})();e.exports=u})(Va,Va.exports)),Va.exports}var Zh,V_;function bl(){if(V_)return Zh;V_=1;var e=nF(),t=Bu(),n=Mw(),s=n&&n.isTypedArray,o=s?t(s):e;return Zh=o,Zh}var Jh,Y_;function PT(){if(Y_)return Jh;Y_=1;var e=J5(),t=xl(),n=Rt(),s=Go(),o=zu(),a=bl(),l=Object.prototype,u=l.hasOwnProperty;function h(p,f){var g=n(p),y=!g&&t(p),w=!g&&!y&&s(p),S=!g&&!y&&!w&&a(p),b=g||y||w||S,_=b?e(p.length,String):[],k=_.length;for(var N in p)(f||u.call(p,N))&&!(b&&(N=="length"||w&&(N=="offset"||N=="parent")||S&&(N=="buffer"||N=="byteLength"||N=="byteOffset")||o(N,k)))&&_.push(N);return _}return Jh=h,Jh}var ep,K_;function Uu(){if(K_)return ep;K_=1;var e=Object.prototype;function t(n){var s=n&&n.constructor,o=typeof s=="function"&&s.prototype||e;return n===o}return ep=t,ep}var tp,X_;function $T(){if(X_)return tp;X_=1;function e(t,n){return function(s){return t(n(s))}}return tp=e,tp}var np,Q_;function rF(){if(Q_)return np;Q_=1;var e=$T(),t=e(Object.keys,Object);return np=t,np}var rp,Z_;function Iw(){if(Z_)return rp;Z_=1;var e=Uu(),t=rF(),n=Object.prototype,s=n.hasOwnProperty;function o(a){if(!e(a))return t(a);var l=[];for(var u in Object(a))s.call(a,u)&&u!="constructor"&&l.push(u);return l}return rp=o,rp}var sp,J_;function Qr(){if(J_)return sp;J_=1;var e=yl(),t=Aw();function n(s){return s!=null&&t(s.length)&&!e(s)}return sp=n,sp}var ip,ek;function Ms(){if(ek)return ip;ek=1;var e=PT(),t=Iw(),n=Qr();function s(o){return n(o)?e(o):t(o)}return ip=s,ip}var op,tk;function sF(){if(tk)return op;tk=1;var e=wl(),t=Ms();function n(s,o){return s&&e(o,t(o),s)}return op=n,op}var ap,nk;function iF(){if(nk)return ap;nk=1;function e(t){var n=[];if(t!=null)for(var s in Object(t))n.push(s);return n}return ap=e,ap}var lp,rk;function oF(){if(rk)return lp;rk=1;var e=qn(),t=Uu(),n=iF(),s=Object.prototype,o=s.hasOwnProperty;function a(l){if(!e(l))return n(l);var u=t(l),h=[];for(var p in l)p=="constructor"&&(u||!o.call(l,p))||h.push(p);return h}return lp=a,lp}var cp,sk;function ki(){if(sk)return cp;sk=1;var e=PT(),t=oF(),n=Qr();function s(o){return n(o)?e(o,!0):t(o)}return cp=s,cp}var up,ik;function aF(){if(ik)return up;ik=1;var e=wl(),t=ki();function n(s,o){return s&&e(o,t(o),s)}return up=n,up}var Ya={exports:{}};Ya.exports;var ok;function LT(){return ok||(ok=1,(function(e,t){var n=ur(),s=t&&!t.nodeType&&t,o=s&&!0&&e&&!e.nodeType&&e,a=o&&o.exports===s,l=a?n.Buffer:void 0,u=l?l.allocUnsafe:void 0;function h(p,f){if(f)return p.slice();var g=p.length,y=u?u(g):new p.constructor(g);return p.copy(y),y}e.exports=h})(Ya,Ya.exports)),Ya.exports}var dp,ak;function qT(){if(ak)return dp;ak=1;function e(t,n){var s=-1,o=t.length;for(n||(n=Array(o));++s<o;)n[s]=t[s];return n}return dp=e,dp}var fp,lk;function DT(){if(lk)return fp;lk=1;function e(t,n){for(var s=-1,o=t==null?0:t.length,a=0,l=[];++s<o;){var u=t[s];n(u,s,t)&&(l[a++]=u)}return l}return fp=e,fp}var hp,ck;function FT(){if(ck)return hp;ck=1;function e(){return[]}return hp=e,hp}var pp,uk;function Ow(){if(uk)return pp;uk=1;var e=DT(),t=FT(),n=Object.prototype,s=n.propertyIsEnumerable,o=Object.getOwnPropertySymbols,a=o?function(l){return l==null?[]:(l=Object(l),e(o(l),function(u){return s.call(l,u)}))}:t;return pp=a,pp}var mp,dk;function lF(){if(dk)return mp;dk=1;var e=wl(),t=Ow();function n(s,o){return e(s,t(s),o)}return mp=n,mp}var gp,fk;function Pw(){if(fk)return gp;fk=1;function e(t,n){for(var s=-1,o=n.length,a=t.length;++s<o;)t[a+s]=n[s];return t}return gp=e,gp}var vp,hk;function Wu(){if(hk)return vp;hk=1;var e=$T(),t=e(Object.getPrototypeOf,Object);return vp=t,vp}var yp,pk;function zT(){if(pk)return yp;pk=1;var e=Pw(),t=Wu(),n=Ow(),s=FT(),o=Object.getOwnPropertySymbols,a=o?function(l){for(var u=[];l;)e(u,n(l)),l=t(l);return u}:s;return yp=a,yp}var wp,mk;function cF(){if(mk)return wp;mk=1;var e=wl(),t=zT();function n(s,o){return e(s,t(s),o)}return wp=n,wp}var xp,gk;function BT(){if(gk)return xp;gk=1;var e=Pw(),t=Rt();function n(s,o,a){var l=o(s);return t(s)?l:e(l,a(s))}return xp=n,xp}var bp,vk;function UT(){if(vk)return bp;vk=1;var e=BT(),t=Ow(),n=Ms();function s(o){return e(o,n,t)}return bp=s,bp}var _p,yk;function uF(){if(yk)return _p;yk=1;var e=BT(),t=zT(),n=ki();function s(o){return e(o,n,t)}return _p=s,_p}var kp,wk;function dF(){if(wk)return kp;wk=1;var e=_i(),t=ur(),n=e(t,"DataView");return kp=n,kp}var Sp,xk;function fF(){if(xk)return Sp;xk=1;var e=_i(),t=ur(),n=e(t,"Promise");return Sp=n,Sp}var Np,bk;function WT(){if(bk)return Np;bk=1;var e=_i(),t=ur(),n=e(t,"Set");return Np=n,Np}var Ep,_k;function hF(){if(_k)return Ep;_k=1;var e=_i(),t=ur(),n=e(t,"WeakMap");return Ep=n,Ep}var jp,kk;function Vo(){if(kk)return jp;kk=1;var e=dF(),t=Cw(),n=fF(),s=WT(),o=hF(),a=bi(),l=IT(),u="[object Map]",h="[object Object]",p="[object Promise]",f="[object Set]",g="[object WeakMap]",y="[object DataView]",w=l(e),S=l(t),b=l(n),_=l(s),k=l(o),N=a;return(e&&N(new e(new ArrayBuffer(1)))!=y||t&&N(new t)!=u||n&&N(n.resolve())!=p||s&&N(new s)!=f||o&&N(new o)!=g)&&(N=function(j){var T=a(j),M=T==h?j.constructor:void 0,P=M?l(M):"";if(P)switch(P){case w:return y;case S:return u;case b:return p;case _:return f;case k:return g}return T}),jp=N,jp}var Cp,Sk;function pF(){if(Sk)return Cp;Sk=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s){var o=s.length,a=new s.constructor(o);return o&&typeof s[0]=="string"&&t.call(s,"index")&&(a.index=s.index,a.input=s.input),a}return Cp=n,Cp}var Tp,Nk;function HT(){if(Nk)return Tp;Nk=1;var e=ur(),t=e.Uint8Array;return Tp=t,Tp}var Rp,Ek;function $w(){if(Ek)return Rp;Ek=1;var e=HT();function t(n){var s=new n.constructor(n.byteLength);return new e(s).set(new e(n)),s}return Rp=t,Rp}var Ap,jk;function mF(){if(jk)return Ap;jk=1;var e=$w();function t(n,s){var o=s?e(n.buffer):n.buffer;return new n.constructor(o,n.byteOffset,n.byteLength)}return Ap=t,Ap}var Mp,Ck;function gF(){if(Ck)return Mp;Ck=1;var e=/\w*$/;function t(n){var s=new n.constructor(n.source,e.exec(n));return s.lastIndex=n.lastIndex,s}return Mp=t,Mp}var Ip,Tk;function vF(){if(Tk)return Ip;Tk=1;var e=Ho(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function s(o){return n?Object(n.call(o)):{}}return Ip=s,Ip}var Op,Rk;function GT(){if(Rk)return Op;Rk=1;var e=$w();function t(n,s){var o=s?e(n.buffer):n.buffer;return new n.constructor(o,n.byteOffset,n.length)}return Op=t,Op}var Pp,Ak;function yF(){if(Ak)return Pp;Ak=1;var e=$w(),t=mF(),n=gF(),s=vF(),o=GT(),a="[object Boolean]",l="[object Date]",u="[object Map]",h="[object Number]",p="[object RegExp]",f="[object Set]",g="[object String]",y="[object Symbol]",w="[object ArrayBuffer]",S="[object DataView]",b="[object Float32Array]",_="[object Float64Array]",k="[object Int8Array]",N="[object Int16Array]",j="[object Int32Array]",T="[object Uint8Array]",M="[object Uint8ClampedArray]",P="[object Uint16Array]",I="[object Uint32Array]";function F(O,A,D){var H=O.constructor;switch(A){case w:return e(O);case a:case l:return new H(+O);case S:return t(O,D);case b:case _:case k:case N:case j:case T:case M:case P:case I:return o(O,D);case u:return new H;case h:case g:return new H(O);case p:return n(O);case f:return new H;case y:return s(O)}}return Pp=F,Pp}var $p,Mk;function VT(){if(Mk)return $p;Mk=1;var e=qn(),t=Object.create,n=(function(){function s(){}return function(o){if(!e(o))return{};if(t)return t(o);s.prototype=o;var a=new s;return s.prototype=void 0,a}})();return $p=n,$p}var Lp,Ik;function YT(){if(Ik)return Lp;Ik=1;var e=VT(),t=Wu(),n=Uu();function s(o){return typeof o.constructor=="function"&&!n(o)?e(t(o)):{}}return Lp=s,Lp}var qp,Ok;function wF(){if(Ok)return qp;Ok=1;var e=Vo(),t=Er(),n="[object Map]";function s(o){return t(o)&&e(o)==n}return qp=s,qp}var Dp,Pk;function xF(){if(Pk)return Dp;Pk=1;var e=wF(),t=Bu(),n=Mw(),s=n&&n.isMap,o=s?t(s):e;return Dp=o,Dp}var Fp,$k;function bF(){if($k)return Fp;$k=1;var e=Vo(),t=Er(),n="[object Set]";function s(o){return t(o)&&e(o)==n}return Fp=s,Fp}var zp,Lk;function _F(){if(Lk)return zp;Lk=1;var e=bF(),t=Bu(),n=Mw(),s=n&&n.isSet,o=s?t(s):e;return zp=o,zp}var Bp,qk;function KT(){if(qk)return Bp;qk=1;var e=qu(),t=Rw(),n=Fu(),s=sF(),o=aF(),a=LT(),l=qT(),u=lF(),h=cF(),p=UT(),f=uF(),g=Vo(),y=pF(),w=yF(),S=YT(),b=Rt(),_=Go(),k=xF(),N=qn(),j=_F(),T=Ms(),M=ki(),P=1,I=2,F=4,O="[object Arguments]",A="[object Array]",D="[object Boolean]",H="[object Date]",K="[object Error]",C="[object Function]",X="[object GeneratorFunction]",B="[object Map]",ne="[object Number]",J="[object Object]",W="[object RegExp]",Q="[object Set]",$="[object String]",G="[object Symbol]",Y="[object WeakMap]",L="[object ArrayBuffer]",q="[object DataView]",Z="[object Float32Array]",se="[object Float64Array]",fe="[object Int8Array]",he="[object Int16Array]",ye="[object Int32Array]",Re="[object Uint8Array]",Ue="[object Uint8ClampedArray]",De="[object Uint16Array]",Ie="[object Uint32Array]",ke={};ke[O]=ke[A]=ke[L]=ke[q]=ke[D]=ke[H]=ke[Z]=ke[se]=ke[fe]=ke[he]=ke[ye]=ke[B]=ke[ne]=ke[J]=ke[W]=ke[Q]=ke[$]=ke[G]=ke[Re]=ke[Ue]=ke[De]=ke[Ie]=!0,ke[K]=ke[C]=ke[Y]=!1;function ce(xe,we,Ye,yt,ct,st){var Be,tt=we&P,Ke=we&I,_t=we&F;if(Ye&&(Be=ct?Ye(xe,yt,ct,st):Ye(xe)),Be!==void 0)return Be;if(!N(xe))return xe;var Me=b(xe);if(Me){if(Be=y(xe),!tt)return l(xe,Be)}else{var it=g(xe),At=it==C||it==X;if(_(xe))return a(xe,tt);if(it==J||it==O||At&&!ct){if(Be=Ke||At?{}:S(xe),!tt)return Ke?h(xe,o(Be,xe)):u(xe,s(Be,xe))}else{if(!ke[it])return ct?xe:{};Be=w(xe,it,tt)}}st||(st=new e);var oe=st.get(xe);if(oe)return oe;st.set(xe,Be),j(xe)?xe.forEach(function(Ne){Be.add(ce(Ne,we,Ye,Ne,xe,st))}):k(xe)&&xe.forEach(function(Ne,We){Be.set(We,ce(Ne,we,Ye,We,xe,st))});var Pe=_t?Ke?f:p:Ke?M:T,qe=Me?void 0:Pe(xe);return t(qe||xe,function(Ne,We){qe&&(We=Ne,Ne=xe[We]),n(Be,We,ce(Ne,we,Ye,We,xe,st))}),Be}return Bp=ce,Bp}var Up,Dk;function kF(){if(Dk)return Up;Dk=1;var e=KT(),t=4;function n(s){return e(s,t)}return Up=n,Up}var Wp,Fk;function Lw(){if(Fk)return Wp;Fk=1;function e(t){return function(){return t}}return Wp=e,Wp}var Hp,zk;function SF(){if(zk)return Hp;zk=1;function e(t){return function(n,s,o){for(var a=-1,l=Object(n),u=o(n),h=u.length;h--;){var p=u[t?h:++a];if(s(l[p],p,l)===!1)break}return n}}return Hp=e,Hp}var Gp,Bk;function qw(){if(Bk)return Gp;Bk=1;var e=SF(),t=e();return Gp=t,Gp}var Vp,Uk;function Dw(){if(Uk)return Vp;Uk=1;var e=qw(),t=Ms();function n(s,o){return s&&e(s,o,t)}return Vp=n,Vp}var Yp,Wk;function NF(){if(Wk)return Yp;Wk=1;var e=Qr();function t(n,s){return function(o,a){if(o==null)return o;if(!e(o))return n(o,a);for(var l=o.length,u=s?l:-1,h=Object(o);(s?u--:++u<l)&&a(h[u],u,h)!==!1;);return o}}return Yp=t,Yp}var Kp,Hk;function Hu(){if(Hk)return Kp;Hk=1;var e=Dw(),t=NF(),n=t(e);return Kp=n,Kp}var Xp,Gk;function Si(){if(Gk)return Xp;Gk=1;function e(t){return t}return Xp=e,Xp}var Qp,Vk;function XT(){if(Vk)return Qp;Vk=1;var e=Si();function t(n){return typeof n=="function"?n:e}return Qp=t,Qp}var Zp,Yk;function QT(){if(Yk)return Zp;Yk=1;var e=Rw(),t=Hu(),n=XT(),s=Rt();function o(a,l){var u=s(a)?e:t;return u(a,n(l))}return Zp=o,Zp}var Jp,Kk;function ZT(){return Kk||(Kk=1,Jp=QT()),Jp}var em,Xk;function EF(){if(Xk)return em;Xk=1;var e=Hu();function t(n,s){var o=[];return e(n,function(a,l,u){s(a,l,u)&&o.push(a)}),o}return em=t,em}var tm,Qk;function jF(){if(Qk)return tm;Qk=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return tm=t,tm}var nm,Zk;function CF(){if(Zk)return nm;Zk=1;function e(t){return this.__data__.has(t)}return nm=e,nm}var rm,Jk;function JT(){if(Jk)return rm;Jk=1;var e=Tw(),t=jF(),n=CF();function s(o){var a=-1,l=o==null?0:o.length;for(this.__data__=new e;++a<l;)this.add(o[a])}return s.prototype.add=s.prototype.push=t,s.prototype.has=n,rm=s,rm}var sm,eS;function TF(){if(eS)return sm;eS=1;function e(t,n){for(var s=-1,o=t==null?0:t.length;++s<o;)if(n(t[s],s,t))return!0;return!1}return sm=e,sm}var im,tS;function eR(){if(tS)return im;tS=1;function e(t,n){return t.has(n)}return im=e,im}var om,nS;function tR(){if(nS)return om;nS=1;var e=JT(),t=TF(),n=eR(),s=1,o=2;function a(l,u,h,p,f,g){var y=h&s,w=l.length,S=u.length;if(w!=S&&!(y&&S>w))return!1;var b=g.get(l),_=g.get(u);if(b&&_)return b==u&&_==l;var k=-1,N=!0,j=h&o?new e:void 0;for(g.set(l,u),g.set(u,l);++k<w;){var T=l[k],M=u[k];if(p)var P=y?p(M,T,k,u,l,g):p(T,M,k,l,u,g);if(P!==void 0){if(P)continue;N=!1;break}if(j){if(!t(u,function(I,F){if(!n(j,F)&&(T===I||f(T,I,h,p,g)))return j.push(F)})){N=!1;break}}else if(!(T===M||f(T,M,h,p,g))){N=!1;break}}return g.delete(l),g.delete(u),N}return om=a,om}var am,rS;function RF(){if(rS)return am;rS=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(o,a){s[++n]=[a,o]}),s}return am=e,am}var lm,sS;function Fw(){if(sS)return lm;sS=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(o){s[++n]=o}),s}return lm=e,lm}var cm,iS;function AF(){if(iS)return cm;iS=1;var e=Ho(),t=HT(),n=Wo(),s=tR(),o=RF(),a=Fw(),l=1,u=2,h="[object Boolean]",p="[object Date]",f="[object Error]",g="[object Map]",y="[object Number]",w="[object RegExp]",S="[object Set]",b="[object String]",_="[object Symbol]",k="[object ArrayBuffer]",N="[object DataView]",j=e?e.prototype:void 0,T=j?j.valueOf:void 0;function M(P,I,F,O,A,D,H){switch(F){case N:if(P.byteLength!=I.byteLength||P.byteOffset!=I.byteOffset)return!1;P=P.buffer,I=I.buffer;case k:return!(P.byteLength!=I.byteLength||!D(new t(P),new t(I)));case h:case p:case y:return n(+P,+I);case f:return P.name==I.name&&P.message==I.message;case w:case b:return P==I+"";case g:var K=o;case S:var C=O&l;if(K||(K=a),P.size!=I.size&&!C)return!1;var X=H.get(P);if(X)return X==I;O|=u,H.set(P,I);var B=s(K(P),K(I),O,A,D,H);return H.delete(P),B;case _:if(T)return T.call(P)==T.call(I)}return!1}return cm=M,cm}var um,oS;function MF(){if(oS)return um;oS=1;var e=UT(),t=1,n=Object.prototype,s=n.hasOwnProperty;function o(a,l,u,h,p,f){var g=u&t,y=e(a),w=y.length,S=e(l),b=S.length;if(w!=b&&!g)return!1;for(var _=w;_--;){var k=y[_];if(!(g?k in l:s.call(l,k)))return!1}var N=f.get(a),j=f.get(l);if(N&&j)return N==l&&j==a;var T=!0;f.set(a,l),f.set(l,a);for(var M=g;++_<w;){k=y[_];var P=a[k],I=l[k];if(h)var F=g?h(I,P,k,l,a,f):h(P,I,k,a,l,f);if(!(F===void 0?P===I||p(P,I,u,h,f):F)){T=!1;break}M||(M=k=="constructor")}if(T&&!M){var O=a.constructor,A=l.constructor;O!=A&&"constructor"in a&&"constructor"in l&&!(typeof O=="function"&&O instanceof O&&typeof A=="function"&&A instanceof A)&&(T=!1)}return f.delete(a),f.delete(l),T}return um=o,um}var dm,aS;function IF(){if(aS)return dm;aS=1;var e=qu(),t=tR(),n=AF(),s=MF(),o=Vo(),a=Rt(),l=Go(),u=bl(),h=1,p="[object Arguments]",f="[object Array]",g="[object Object]",y=Object.prototype,w=y.hasOwnProperty;function S(b,_,k,N,j,T){var M=a(b),P=a(_),I=M?f:o(b),F=P?f:o(_);I=I==p?g:I,F=F==p?g:F;var O=I==g,A=F==g,D=I==F;if(D&&l(b)){if(!l(_))return!1;M=!0,O=!1}if(D&&!O)return T||(T=new e),M||u(b)?t(b,_,k,N,j,T):n(b,_,I,k,N,j,T);if(!(k&h)){var H=O&&w.call(b,"__wrapped__"),K=A&&w.call(_,"__wrapped__");if(H||K){var C=H?b.value():b,X=K?_.value():_;return T||(T=new e),j(C,X,k,N,T)}}return D?(T||(T=new e),s(b,_,k,N,j,T)):!1}return dm=S,dm}var fm,lS;function nR(){if(lS)return fm;lS=1;var e=IF(),t=Er();function n(s,o,a,l,u){return s===o?!0:s==null||o==null||!t(s)&&!t(o)?s!==s&&o!==o:e(s,o,a,l,n,u)}return fm=n,fm}var hm,cS;function OF(){if(cS)return hm;cS=1;var e=qu(),t=nR(),n=1,s=2;function o(a,l,u,h){var p=u.length,f=p,g=!h;if(a==null)return!f;for(a=Object(a);p--;){var y=u[p];if(g&&y[2]?y[1]!==a[y[0]]:!(y[0]in a))return!1}for(;++p<f;){y=u[p];var w=y[0],S=a[w],b=y[1];if(g&&y[2]){if(S===void 0&&!(w in a))return!1}else{var _=new e;if(h)var k=h(S,b,w,a,l,_);if(!(k===void 0?t(b,S,n|s,h,_):k))return!1}}return!0}return hm=o,hm}var pm,uS;function rR(){if(uS)return pm;uS=1;var e=qn();function t(n){return n===n&&!e(n)}return pm=t,pm}var mm,dS;function PF(){if(dS)return mm;dS=1;var e=rR(),t=Ms();function n(s){for(var o=t(s),a=o.length;a--;){var l=o[a],u=s[l];o[a]=[l,u,e(u)]}return o}return mm=n,mm}var gm,fS;function sR(){if(fS)return gm;fS=1;function e(t,n){return function(s){return s==null?!1:s[t]===n&&(n!==void 0||t in Object(s))}}return gm=e,gm}var vm,hS;function $F(){if(hS)return vm;hS=1;var e=OF(),t=PF(),n=sR();function s(o){var a=t(o);return a.length==1&&a[0][2]?n(a[0][0],a[0][1]):function(l){return l===o||e(l,o,a)}}return vm=s,vm}var ym,pS;function Yo(){if(pS)return ym;pS=1;var e=bi(),t=Er(),n="[object Symbol]";function s(o){return typeof o=="symbol"||t(o)&&e(o)==n}return ym=s,ym}var wm,mS;function zw(){if(mS)return wm;mS=1;var e=Rt(),t=Yo(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function o(a,l){if(e(a))return!1;var u=typeof a;return u=="number"||u=="symbol"||u=="boolean"||a==null||t(a)?!0:s.test(a)||!n.test(a)||l!=null&&a in Object(l)}return wm=o,wm}var xm,gS;function LF(){if(gS)return xm;gS=1;var e=Tw(),t="Expected a function";function n(s,o){if(typeof s!="function"||o!=null&&typeof o!="function")throw new TypeError(t);var a=function(){var l=arguments,u=o?o.apply(this,l):l[0],h=a.cache;if(h.has(u))return h.get(u);var p=s.apply(this,l);return a.cache=h.set(u,p)||h,p};return a.cache=new(n.Cache||e),a}return n.Cache=e,xm=n,xm}var bm,vS;function qF(){if(vS)return bm;vS=1;var e=LF(),t=500;function n(s){var o=e(s,function(l){return a.size===t&&a.clear(),l}),a=o.cache;return o}return bm=n,bm}var _m,yS;function DF(){if(yS)return _m;yS=1;var e=qF(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,s=e(function(o){var a=[];return o.charCodeAt(0)===46&&a.push(""),o.replace(t,function(l,u,h,p){a.push(h?p.replace(n,"$1"):u||l)}),a});return _m=s,_m}var km,wS;function Gu(){if(wS)return km;wS=1;function e(t,n){for(var s=-1,o=t==null?0:t.length,a=Array(o);++s<o;)a[s]=n(t[s],s,t);return a}return km=e,km}var Sm,xS;function FF(){if(xS)return Sm;xS=1;var e=Ho(),t=Gu(),n=Rt(),s=Yo(),o=e?e.prototype:void 0,a=o?o.toString:void 0;function l(u){if(typeof u=="string")return u;if(n(u))return t(u,l)+"";if(s(u))return a?a.call(u):"";var h=u+"";return h=="0"&&1/u==-1/0?"-0":h}return Sm=l,Sm}var Nm,bS;function iR(){if(bS)return Nm;bS=1;var e=FF();function t(n){return n==null?"":e(n)}return Nm=t,Nm}var Em,_S;function Vu(){if(_S)return Em;_S=1;var e=Rt(),t=zw(),n=DF(),s=iR();function o(a,l){return e(a)?a:t(a,l)?[a]:n(s(a))}return Em=o,Em}var jm,kS;function _l(){if(kS)return jm;kS=1;var e=Yo();function t(n){if(typeof n=="string"||e(n))return n;var s=n+"";return s=="0"&&1/n==-1/0?"-0":s}return jm=t,jm}var Cm,SS;function Yu(){if(SS)return Cm;SS=1;var e=Vu(),t=_l();function n(s,o){o=e(o,s);for(var a=0,l=o.length;s!=null&&a<l;)s=s[t(o[a++])];return a&&a==l?s:void 0}return Cm=n,Cm}var Tm,NS;function zF(){if(NS)return Tm;NS=1;var e=Yu();function t(n,s,o){var a=n==null?void 0:e(n,s);return a===void 0?o:a}return Tm=t,Tm}var Rm,ES;function BF(){if(ES)return Rm;ES=1;function e(t,n){return t!=null&&n in Object(t)}return Rm=e,Rm}var Am,jS;function oR(){if(jS)return Am;jS=1;var e=Vu(),t=xl(),n=Rt(),s=zu(),o=Aw(),a=_l();function l(u,h,p){h=e(h,u);for(var f=-1,g=h.length,y=!1;++f<g;){var w=a(h[f]);if(!(y=u!=null&&p(u,w)))break;u=u[w]}return y||++f!=g?y:(g=u==null?0:u.length,!!g&&o(g)&&s(w,g)&&(n(u)||t(u)))}return Am=l,Am}var Mm,CS;function aR(){if(CS)return Mm;CS=1;var e=BF(),t=oR();function n(s,o){return s!=null&&t(s,o,e)}return Mm=n,Mm}var Im,TS;function UF(){if(TS)return Im;TS=1;var e=nR(),t=zF(),n=aR(),s=zw(),o=rR(),a=sR(),l=_l(),u=1,h=2;function p(f,g){return s(f)&&o(g)?a(l(f),g):function(y){var w=t(y,f);return w===void 0&&w===g?n(y,f):e(g,w,u|h)}}return Im=p,Im}var Om,RS;function lR(){if(RS)return Om;RS=1;function e(t){return function(n){return n==null?void 0:n[t]}}return Om=e,Om}var Pm,AS;function WF(){if(AS)return Pm;AS=1;var e=Yu();function t(n){return function(s){return e(s,n)}}return Pm=t,Pm}var $m,MS;function HF(){if(MS)return $m;MS=1;var e=lR(),t=WF(),n=zw(),s=_l();function o(a){return n(a)?e(s(a)):t(a)}return $m=o,$m}var Lm,IS;function Zr(){if(IS)return Lm;IS=1;var e=$F(),t=UF(),n=Si(),s=Rt(),o=HF();function a(l){return typeof l=="function"?l:l==null?n:typeof l=="object"?s(l)?t(l[0],l[1]):e(l):o(l)}return Lm=a,Lm}var qm,OS;function cR(){if(OS)return qm;OS=1;var e=DT(),t=EF(),n=Zr(),s=Rt();function o(a,l){var u=s(a)?e:t;return u(a,n(l,3))}return qm=o,qm}var Dm,PS;function GF(){if(PS)return Dm;PS=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s,o){return s!=null&&t.call(s,o)}return Dm=n,Dm}var Fm,$S;function uR(){if($S)return Fm;$S=1;var e=GF(),t=oR();function n(s,o){return s!=null&&t(s,o,e)}return Fm=n,Fm}var zm,LS;function VF(){if(LS)return zm;LS=1;var e=Iw(),t=Vo(),n=xl(),s=Rt(),o=Qr(),a=Go(),l=Uu(),u=bl(),h="[object Map]",p="[object Set]",f=Object.prototype,g=f.hasOwnProperty;function y(w){if(w==null)return!0;if(o(w)&&(s(w)||typeof w=="string"||typeof w.splice=="function"||a(w)||u(w)||n(w)))return!w.length;var S=t(w);if(S==h||S==p)return!w.size;if(l(w))return!e(w).length;for(var b in w)if(g.call(w,b))return!1;return!0}return zm=y,zm}var Bm,qS;function dR(){if(qS)return Bm;qS=1;function e(t){return t===void 0}return Bm=e,Bm}var Um,DS;function fR(){if(DS)return Um;DS=1;var e=Hu(),t=Qr();function n(s,o){var a=-1,l=t(s)?Array(s.length):[];return e(s,function(u,h,p){l[++a]=o(u,h,p)}),l}return Um=n,Um}var Wm,FS;function hR(){if(FS)return Wm;FS=1;var e=Gu(),t=Zr(),n=fR(),s=Rt();function o(a,l){var u=s(a)?e:n;return u(a,t(l,3))}return Wm=o,Wm}var Hm,zS;function YF(){if(zS)return Hm;zS=1;function e(t,n,s,o){var a=-1,l=t==null?0:t.length;for(o&&l&&(s=t[++a]);++a<l;)s=n(s,t[a],a,t);return s}return Hm=e,Hm}var Gm,BS;function KF(){if(BS)return Gm;BS=1;function e(t,n,s,o,a){return a(t,function(l,u,h){s=o?(o=!1,l):n(s,l,u,h)}),s}return Gm=e,Gm}var Vm,US;function pR(){if(US)return Vm;US=1;var e=YF(),t=Hu(),n=Zr(),s=KF(),o=Rt();function a(l,u,h){var p=o(l)?e:s,f=arguments.length<3;return p(l,n(u,4),h,f,t)}return Vm=a,Vm}var Ym,WS;function XF(){if(WS)return Ym;WS=1;var e=bi(),t=Rt(),n=Er(),s="[object String]";function o(a){return typeof a=="string"||!t(a)&&n(a)&&e(a)==s}return Ym=o,Ym}var Km,HS;function QF(){if(HS)return Km;HS=1;var e=lR(),t=e("length");return Km=t,Km}var Xm,GS;function ZF(){if(GS)return Xm;GS=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=t+n+s,a="\\ufe0e\\ufe0f",l="\\u200d",u=RegExp("["+l+e+o+a+"]");function h(p){return u.test(p)}return Xm=h,Xm}var Qm,VS;function JF(){if(VS)return Qm;VS=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=t+n+s,a="\\ufe0e\\ufe0f",l="["+e+"]",u="["+o+"]",h="\\ud83c[\\udffb-\\udfff]",p="(?:"+u+"|"+h+")",f="[^"+e+"]",g="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",S=p+"?",b="["+a+"]?",_="(?:"+w+"(?:"+[f,g,y].join("|")+")"+b+S+")*",k=b+S+_,N="(?:"+[f+u+"?",u,g,y,l].join("|")+")",j=RegExp(h+"(?="+h+")|"+N+k,"g");function T(M){for(var P=j.lastIndex=0;j.test(M);)++P;return P}return Qm=T,Qm}var Zm,YS;function e6(){if(YS)return Zm;YS=1;var e=QF(),t=ZF(),n=JF();function s(o){return t(o)?n(o):e(o)}return Zm=s,Zm}var Jm,KS;function t6(){if(KS)return Jm;KS=1;var e=Iw(),t=Vo(),n=Qr(),s=XF(),o=e6(),a="[object Map]",l="[object Set]";function u(h){if(h==null)return 0;if(n(h))return s(h)?o(h):h.length;var p=t(h);return p==a||p==l?h.size:e(h).length}return Jm=u,Jm}var eg,XS;function n6(){if(XS)return eg;XS=1;var e=Rw(),t=VT(),n=Dw(),s=Zr(),o=Wu(),a=Rt(),l=Go(),u=yl(),h=qn(),p=bl();function f(g,y,w){var S=a(g),b=S||l(g)||p(g);if(y=s(y,4),w==null){var _=g&&g.constructor;b?w=S?new _:[]:h(g)?w=u(_)?t(o(g)):{}:w={}}return(b?e:n)(g,function(k,N,j){return y(w,k,N,j)}),w}return eg=f,eg}var tg,QS;function r6(){if(QS)return tg;QS=1;var e=Ho(),t=xl(),n=Rt(),s=e?e.isConcatSpreadable:void 0;function o(a){return n(a)||t(a)||!!(s&&a&&a[s])}return tg=o,tg}var ng,ZS;function Bw(){if(ZS)return ng;ZS=1;var e=Pw(),t=r6();function n(s,o,a,l,u){var h=-1,p=s.length;for(a||(a=t),u||(u=[]);++h<p;){var f=s[h];o>0&&a(f)?o>1?n(f,o-1,a,l,u):e(u,f):l||(u[u.length]=f)}return u}return ng=n,ng}var rg,JS;function s6(){if(JS)return rg;JS=1;function e(t,n,s){switch(s.length){case 0:return t.call(n);case 1:return t.call(n,s[0]);case 2:return t.call(n,s[0],s[1]);case 3:return t.call(n,s[0],s[1],s[2])}return t.apply(n,s)}return rg=e,rg}var sg,eN;function mR(){if(eN)return sg;eN=1;var e=s6(),t=Math.max;function n(s,o,a){return o=t(o===void 0?s.length-1:o,0),function(){for(var l=arguments,u=-1,h=t(l.length-o,0),p=Array(h);++u<h;)p[u]=l[o+u];u=-1;for(var f=Array(o+1);++u<o;)f[u]=l[u];return f[o]=a(p),e(s,this,f)}}return sg=n,sg}var ig,tN;function i6(){if(tN)return ig;tN=1;var e=Lw(),t=OT(),n=Si(),s=t?function(o,a){return t(o,"toString",{configurable:!0,enumerable:!1,value:e(a),writable:!0})}:n;return ig=s,ig}var og,nN;function o6(){if(nN)return og;nN=1;var e=800,t=16,n=Date.now;function s(o){var a=0,l=0;return function(){var u=n(),h=t-(u-l);if(l=u,h>0){if(++a>=e)return arguments[0]}else a=0;return o.apply(void 0,arguments)}}return og=s,og}var ag,rN;function gR(){if(rN)return ag;rN=1;var e=i6(),t=o6(),n=t(e);return ag=n,ag}var lg,sN;function Ku(){if(sN)return lg;sN=1;var e=Si(),t=mR(),n=gR();function s(o,a){return n(t(o,a,e),o+"")}return lg=s,lg}var cg,iN;function vR(){if(iN)return cg;iN=1;function e(t,n,s,o){for(var a=t.length,l=s+(o?1:-1);o?l--:++l<a;)if(n(t[l],l,t))return l;return-1}return cg=e,cg}var ug,oN;function a6(){if(oN)return ug;oN=1;function e(t){return t!==t}return ug=e,ug}var dg,aN;function l6(){if(aN)return dg;aN=1;function e(t,n,s){for(var o=s-1,a=t.length;++o<a;)if(t[o]===n)return o;return-1}return dg=e,dg}var fg,lN;function c6(){if(lN)return fg;lN=1;var e=vR(),t=a6(),n=l6();function s(o,a,l){return a===a?n(o,a,l):e(o,t,l)}return fg=s,fg}var hg,cN;function u6(){if(cN)return hg;cN=1;var e=c6();function t(n,s){var o=n==null?0:n.length;return!!o&&e(n,s,0)>-1}return hg=t,hg}var pg,uN;function d6(){if(uN)return pg;uN=1;function e(t,n,s){for(var o=-1,a=t==null?0:t.length;++o<a;)if(s(n,t[o]))return!0;return!1}return pg=e,pg}var mg,dN;function f6(){if(dN)return mg;dN=1;function e(){}return mg=e,mg}var gg,fN;function h6(){if(fN)return gg;fN=1;var e=WT(),t=f6(),n=Fw(),s=1/0,o=e&&1/n(new e([,-0]))[1]==s?function(a){return new e(a)}:t;return gg=o,gg}var vg,hN;function p6(){if(hN)return vg;hN=1;var e=JT(),t=u6(),n=d6(),s=eR(),o=h6(),a=Fw(),l=200;function u(h,p,f){var g=-1,y=t,w=h.length,S=!0,b=[],_=b;if(f)S=!1,y=n;else if(w>=l){var k=p?null:o(h);if(k)return a(k);S=!1,y=s,_=new e}else _=p?[]:b;e:for(;++g<w;){var N=h[g],j=p?p(N):N;if(N=f||N!==0?N:0,S&&j===j){for(var T=_.length;T--;)if(_[T]===j)continue e;p&&_.push(j),b.push(N)}else y(_,j,f)||(_!==b&&_.push(j),b.push(N))}return b}return vg=u,vg}var yg,pN;function yR(){if(pN)return yg;pN=1;var e=Qr(),t=Er();function n(s){return t(s)&&e(s)}return yg=n,yg}var wg,mN;function m6(){if(mN)return wg;mN=1;var e=Bw(),t=Ku(),n=p6(),s=yR(),o=t(function(a){return n(e(a,1,s,!0))});return wg=o,wg}var xg,gN;function g6(){if(gN)return xg;gN=1;var e=Gu();function t(n,s){return e(s,function(o){return n[o]})}return xg=t,xg}var bg,vN;function wR(){if(vN)return bg;vN=1;var e=g6(),t=Ms();function n(s){return s==null?[]:e(s,t(s))}return bg=n,bg}var _g,yN;function Dn(){if(yN)return _g;yN=1;var e;if(typeof jw=="function")try{e={clone:kF(),constant:Lw(),each:ZT(),filter:cR(),has:uR(),isArray:Rt(),isEmpty:VF(),isFunction:yl(),isUndefined:dR(),keys:Ms(),map:hR(),reduce:pR(),size:t6(),transform:n6(),union:m6(),values:wR()}}catch{}return e||(e=window._),_g=e,_g}var kg,wN;function Uw(){if(wN)return kg;wN=1;var e=Dn();kg=o;var t="\0",n="\0",s="";function o(f){this._isDirected=e.has(f,"directed")?f.directed:!0,this._isMultigraph=e.has(f,"multigraph")?f.multigraph:!1,this._isCompound=e.has(f,"compound")?f.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[n]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(f){return this._label=f,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultNodeLabelFn=f,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var f=this;return e.filter(this.nodes(),function(g){return e.isEmpty(f._in[g])})},o.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(g){return e.isEmpty(f._out[g])})},o.prototype.setNodes=function(f,g){var y=arguments,w=this;return e.each(f,function(S){y.length>1?w.setNode(S,g):w.setNode(S)}),this},o.prototype.setNode=function(f,g){return e.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=g),this):(this._nodes[f]=arguments.length>1?g:this._defaultNodeLabelFn(f),this._isCompound&&(this._parent[f]=n,this._children[f]={},this._children[n][f]=!0),this._in[f]={},this._preds[f]={},this._out[f]={},this._sucs[f]={},++this._nodeCount,this)},o.prototype.node=function(f){return this._nodes[f]},o.prototype.hasNode=function(f){return e.has(this._nodes,f)},o.prototype.removeNode=function(f){var g=this;if(e.has(this._nodes,f)){var y=function(w){g.removeEdge(g._edgeObjs[w])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(w){g.setParent(w)}),delete this._children[f]),e.each(e.keys(this._in[f]),y),delete this._in[f],delete this._preds[f],e.each(e.keys(this._out[f]),y),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},o.prototype.setParent=function(f,g){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(g))g=n;else{g+="";for(var y=g;!e.isUndefined(y);y=this.parent(y))if(y===f)throw new Error("Setting "+g+" as parent of "+f+" would create a cycle");this.setNode(g)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=g,this._children[g][f]=!0,this},o.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},o.prototype.parent=function(f){if(this._isCompound){var g=this._parent[f];if(g!==n)return g}},o.prototype.children=function(f){if(e.isUndefined(f)&&(f=n),this._isCompound){var g=this._children[f];if(g)return e.keys(g)}else{if(f===n)return this.nodes();if(this.hasNode(f))return[]}},o.prototype.predecessors=function(f){var g=this._preds[f];if(g)return e.keys(g)},o.prototype.successors=function(f){var g=this._sucs[f];if(g)return e.keys(g)},o.prototype.neighbors=function(f){var g=this.predecessors(f);if(g)return e.union(g,this.successors(f))},o.prototype.isLeaf=function(f){var g;return this.isDirected()?g=this.successors(f):g=this.neighbors(f),g.length===0},o.prototype.filterNodes=function(f){var g=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});g.setGraph(this.graph());var y=this;e.each(this._nodes,function(b,_){f(_)&&g.setNode(_,b)}),e.each(this._edgeObjs,function(b){g.hasNode(b.v)&&g.hasNode(b.w)&&g.setEdge(b,y.edge(b))});var w={};function S(b){var _=y.parent(b);return _===void 0||g.hasNode(_)?(w[b]=_,_):_ in w?w[_]:S(_)}return this._isCompound&&e.each(g.nodes(),function(b){g.setParent(b,S(b))}),g},o.prototype.setDefaultEdgeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultEdgeLabelFn=f,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(f,g){var y=this,w=arguments;return e.reduce(f,function(S,b){return w.length>1?y.setEdge(S,b,g):y.setEdge(S,b),b}),this},o.prototype.setEdge=function(){var f,g,y,w,S=!1,b=arguments[0];typeof b=="object"&&b!==null&&"v"in b?(f=b.v,g=b.w,y=b.name,arguments.length===2&&(w=arguments[1],S=!0)):(f=b,g=arguments[1],y=arguments[3],arguments.length>2&&(w=arguments[2],S=!0)),f=""+f,g=""+g,e.isUndefined(y)||(y=""+y);var _=u(this._isDirected,f,g,y);if(e.has(this._edgeLabels,_))return S&&(this._edgeLabels[_]=w),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(g),this._edgeLabels[_]=S?w:this._defaultEdgeLabelFn(f,g,y);var k=h(this._isDirected,f,g,y);return f=k.v,g=k.w,Object.freeze(k),this._edgeObjs[_]=k,a(this._preds[g],f),a(this._sucs[f],g),this._in[g][_]=k,this._out[f][_]=k,this._edgeCount++,this},o.prototype.edge=function(f,g,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,f,g,y);return this._edgeLabels[w]},o.prototype.hasEdge=function(f,g,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,f,g,y);return e.has(this._edgeLabels,w)},o.prototype.removeEdge=function(f,g,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,f,g,y),S=this._edgeObjs[w];return S&&(f=S.v,g=S.w,delete this._edgeLabels[w],delete this._edgeObjs[w],l(this._preds[g],f),l(this._sucs[f],g),delete this._in[g][w],delete this._out[f][w],this._edgeCount--),this},o.prototype.inEdges=function(f,g){var y=this._in[f];if(y){var w=e.values(y);return g?e.filter(w,function(S){return S.v===g}):w}},o.prototype.outEdges=function(f,g){var y=this._out[f];if(y){var w=e.values(y);return g?e.filter(w,function(S){return S.w===g}):w}},o.prototype.nodeEdges=function(f,g){var y=this.inEdges(f,g);if(y)return y.concat(this.outEdges(f,g))};function a(f,g){f[g]?f[g]++:f[g]=1}function l(f,g){--f[g]||delete f[g]}function u(f,g,y,w){var S=""+g,b=""+y;if(!f&&S>b){var _=S;S=b,b=_}return S+s+b+s+(e.isUndefined(w)?t:w)}function h(f,g,y,w){var S=""+g,b=""+y;if(!f&&S>b){var _=S;S=b,b=_}var k={v:S,w:b};return w&&(k.name=w),k}function p(f,g){return u(f,g.v,g.w,g.name)}return kg}var Sg,xN;function v6(){return xN||(xN=1,Sg="2.1.8"),Sg}var Ng,bN;function y6(){return bN||(bN=1,Ng={Graph:Uw(),version:v6()}),Ng}var Eg,_N;function w6(){if(_N)return Eg;_N=1;var e=Dn(),t=Uw();Eg={write:n,read:a};function n(l){var u={options:{directed:l.isDirected(),multigraph:l.isMultigraph(),compound:l.isCompound()},nodes:s(l),edges:o(l)};return e.isUndefined(l.graph())||(u.value=e.clone(l.graph())),u}function s(l){return e.map(l.nodes(),function(u){var h=l.node(u),p=l.parent(u),f={v:u};return e.isUndefined(h)||(f.value=h),e.isUndefined(p)||(f.parent=p),f})}function o(l){return e.map(l.edges(),function(u){var h=l.edge(u),p={v:u.v,w:u.w};return e.isUndefined(u.name)||(p.name=u.name),e.isUndefined(h)||(p.value=h),p})}function a(l){var u=new t(l.options).setGraph(l.value);return e.each(l.nodes,function(h){u.setNode(h.v,h.value),h.parent&&u.setParent(h.v,h.parent)}),e.each(l.edges,function(h){u.setEdge({v:h.v,w:h.w,name:h.name},h.value)}),u}return Eg}var jg,kN;function x6(){if(kN)return jg;kN=1;var e=Dn();jg=t;function t(n){var s={},o=[],a;function l(u){e.has(s,u)||(s[u]=!0,a.push(u),e.each(n.successors(u),l),e.each(n.predecessors(u),l))}return e.each(n.nodes(),function(u){a=[],l(u),a.length&&o.push(a)}),o}return jg}var Cg,SN;function xR(){if(SN)return Cg;SN=1;var e=Dn();Cg=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(n){return n.key})},t.prototype.has=function(n){return e.has(this._keyIndices,n)},t.prototype.priority=function(n){var s=this._keyIndices[n];if(s!==void 0)return this._arr[s].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(n,s){var o=this._keyIndices;if(n=String(n),!e.has(o,n)){var a=this._arr,l=a.length;return o[n]=l,a.push({key:n,priority:s}),this._decrease(l),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key},t.prototype.decrease=function(n,s){var o=this._keyIndices[n];if(s>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[o].priority+" New: "+s);this._arr[o].priority=s,this._decrease(o)},t.prototype._heapify=function(n){var s=this._arr,o=2*n,a=o+1,l=n;o<s.length&&(l=s[o].priority<s[l].priority?o:l,a<s.length&&(l=s[a].priority<s[l].priority?a:l),l!==n&&(this._swap(n,l),this._heapify(l)))},t.prototype._decrease=function(n){for(var s=this._arr,o=s[n].priority,a;n!==0&&(a=n>>1,!(s[a].priority<o));)this._swap(n,a),n=a},t.prototype._swap=function(n,s){var o=this._arr,a=this._keyIndices,l=o[n],u=o[s];o[n]=u,o[s]=l,a[u.key]=n,a[l.key]=s},Cg}var Tg,NN;function bR(){if(NN)return Tg;NN=1;var e=Dn(),t=xR();Tg=s;var n=e.constant(1);function s(a,l,u,h){return o(a,String(l),u||n,h||function(p){return a.outEdges(p)})}function o(a,l,u,h){var p={},f=new t,g,y,w=function(S){var b=S.v!==g?S.v:S.w,_=p[b],k=u(S),N=y.distance+k;if(k<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+S+" Weight: "+k);N<_.distance&&(_.distance=N,_.predecessor=g,f.decrease(b,N))};for(a.nodes().forEach(function(S){var b=S===l?0:Number.POSITIVE_INFINITY;p[S]={distance:b},f.add(S,b)});f.size()>0&&(g=f.removeMin(),y=p[g],y.distance!==Number.POSITIVE_INFINITY);)h(g).forEach(w);return p}return Tg}var Rg,EN;function b6(){if(EN)return Rg;EN=1;var e=bR(),t=Dn();Rg=n;function n(s,o,a){return t.transform(s.nodes(),function(l,u){l[u]=e(s,u,o,a)},{})}return Rg}var Ag,jN;function _R(){if(jN)return Ag;jN=1;var e=Dn();Ag=t;function t(n){var s=0,o=[],a={},l=[];function u(h){var p=a[h]={onStack:!0,lowlink:s,index:s++};if(o.push(h),n.successors(h).forEach(function(y){e.has(a,y)?a[y].onStack&&(p.lowlink=Math.min(p.lowlink,a[y].index)):(u(y),p.lowlink=Math.min(p.lowlink,a[y].lowlink))}),p.lowlink===p.index){var f=[],g;do g=o.pop(),a[g].onStack=!1,f.push(g);while(h!==g);l.push(f)}}return n.nodes().forEach(function(h){e.has(a,h)||u(h)}),l}return Ag}var Mg,CN;function _6(){if(CN)return Mg;CN=1;var e=Dn(),t=_R();Mg=n;function n(s){return e.filter(t(s),function(o){return o.length>1||o.length===1&&s.hasEdge(o[0],o[0])})}return Mg}var Ig,TN;function k6(){if(TN)return Ig;TN=1;var e=Dn();Ig=n;var t=e.constant(1);function n(o,a,l){return s(o,a||t,l||function(u){return o.outEdges(u)})}function s(o,a,l){var u={},h=o.nodes();return h.forEach(function(p){u[p]={},u[p][p]={distance:0},h.forEach(function(f){p!==f&&(u[p][f]={distance:Number.POSITIVE_INFINITY})}),l(p).forEach(function(f){var g=f.v===p?f.w:f.v,y=a(f);u[p][g]={distance:y,predecessor:p}})}),h.forEach(function(p){var f=u[p];h.forEach(function(g){var y=u[g];h.forEach(function(w){var S=y[p],b=f[w],_=y[w],k=S.distance+b.distance;k<_.distance&&(_.distance=k,_.predecessor=b.predecessor)})})}),u}return Ig}var Og,RN;function kR(){if(RN)return Og;RN=1;var e=Dn();Og=t,t.CycleException=n;function t(s){var o={},a={},l=[];function u(h){if(e.has(a,h))throw new n;e.has(o,h)||(a[h]=!0,o[h]=!0,e.each(s.predecessors(h),u),delete a[h],l.push(h))}if(e.each(s.sinks(),u),e.size(o)!==s.nodeCount())throw new n;return l}function n(){}return n.prototype=new Error,Og}var Pg,AN;function S6(){if(AN)return Pg;AN=1;var e=kR();Pg=t;function t(n){try{e(n)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return Pg}var $g,MN;function SR(){if(MN)return $g;MN=1;var e=Dn();$g=t;function t(s,o,a){e.isArray(o)||(o=[o]);var l=(s.isDirected()?s.successors:s.neighbors).bind(s),u=[],h={};return e.each(o,function(p){if(!s.hasNode(p))throw new Error("Graph does not have node: "+p);n(s,p,a==="post",h,l,u)}),u}function n(s,o,a,l,u,h){e.has(l,o)||(l[o]=!0,a||h.push(o),e.each(u(o),function(p){n(s,p,a,l,u,h)}),a&&h.push(o))}return $g}var Lg,IN;function N6(){if(IN)return Lg;IN=1;var e=SR();Lg=t;function t(n,s){return e(n,s,"post")}return Lg}var qg,ON;function E6(){if(ON)return qg;ON=1;var e=SR();qg=t;function t(n,s){return e(n,s,"pre")}return qg}var Dg,PN;function j6(){if(PN)return Dg;PN=1;var e=Dn(),t=Uw(),n=xR();Dg=s;function s(o,a){var l=new t,u={},h=new n,p;function f(y){var w=y.v===p?y.w:y.v,S=h.priority(w);if(S!==void 0){var b=a(y);b<S&&(u[w]=p,h.decrease(w,b))}}if(o.nodeCount()===0)return l;e.each(o.nodes(),function(y){h.add(y,Number.POSITIVE_INFINITY),l.setNode(y)}),h.decrease(o.nodes()[0],0);for(var g=!1;h.size()>0;){if(p=h.removeMin(),e.has(u,p))l.setEdge(p,u[p]);else{if(g)throw new Error("Input graph is not connected: "+o);g=!0}o.nodeEdges(p).forEach(f)}return l}return Dg}var Fg,$N;function C6(){return $N||($N=1,Fg={components:x6(),dijkstra:bR(),dijkstraAll:b6(),findCycles:_6(),floydWarshall:k6(),isAcyclic:S6(),postorder:N6(),preorder:E6(),prim:j6(),tarjan:_R(),topsort:kR()}),Fg}var zg,LN;function T6(){if(LN)return zg;LN=1;var e=y6();return zg={Graph:e.Graph,json:w6(),alg:C6(),version:e.version},zg}var Bg,qN;function lr(){if(qN)return Bg;qN=1;var e;if(typeof jw=="function")try{e=T6()}catch{}return e||(e=window.graphlib),Bg=e,Bg}var Ug,DN;function R6(){if(DN)return Ug;DN=1;var e=KT(),t=1,n=4;function s(o){return e(o,t|n)}return Ug=s,Ug}var Wg,FN;function Xu(){if(FN)return Wg;FN=1;var e=Wo(),t=Qr(),n=zu(),s=qn();function o(a,l,u){if(!s(u))return!1;var h=typeof l;return(h=="number"?t(u)&&n(l,u.length):h=="string"&&l in u)?e(u[l],a):!1}return Wg=o,Wg}var Hg,zN;function A6(){if(zN)return Hg;zN=1;var e=Ku(),t=Wo(),n=Xu(),s=ki(),o=Object.prototype,a=o.hasOwnProperty,l=e(function(u,h){u=Object(u);var p=-1,f=h.length,g=f>2?h[2]:void 0;for(g&&n(h[0],h[1],g)&&(f=1);++p<f;)for(var y=h[p],w=s(y),S=-1,b=w.length;++S<b;){var _=w[S],k=u[_];(k===void 0||t(k,o[_])&&!a.call(u,_))&&(u[_]=y[_])}return u});return Hg=l,Hg}var Gg,BN;function M6(){if(BN)return Gg;BN=1;var e=Zr(),t=Qr(),n=Ms();function s(o){return function(a,l,u){var h=Object(a);if(!t(a)){var p=e(l,3);a=n(a),l=function(g){return p(h[g],g,h)}}var f=o(a,l,u);return f>-1?h[p?a[f]:f]:void 0}}return Gg=s,Gg}var Vg,UN;function I6(){if(UN)return Vg;UN=1;var e=/\s/;function t(n){for(var s=n.length;s--&&e.test(n.charAt(s)););return s}return Vg=t,Vg}var Yg,WN;function O6(){if(WN)return Yg;WN=1;var e=I6(),t=/^\s+/;function n(s){return s&&s.slice(0,e(s)+1).replace(t,"")}return Yg=n,Yg}var Kg,HN;function P6(){if(HN)return Kg;HN=1;var e=O6(),t=qn(),n=Yo(),s=NaN,o=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,l=/^0o[0-7]+$/i,u=parseInt;function h(p){if(typeof p=="number")return p;if(n(p))return s;if(t(p)){var f=typeof p.valueOf=="function"?p.valueOf():p;p=t(f)?f+"":f}if(typeof p!="string")return p===0?p:+p;p=e(p);var g=a.test(p);return g||l.test(p)?u(p.slice(2),g?2:8):o.test(p)?s:+p}return Kg=h,Kg}var Xg,GN;function NR(){if(GN)return Xg;GN=1;var e=P6(),t=1/0,n=17976931348623157e292;function s(o){if(!o)return o===0?o:0;if(o=e(o),o===t||o===-t){var a=o<0?-1:1;return a*n}return o===o?o:0}return Xg=s,Xg}var Qg,VN;function $6(){if(VN)return Qg;VN=1;var e=NR();function t(n){var s=e(n),o=s%1;return s===s?o?s-o:s:0}return Qg=t,Qg}var Zg,YN;function L6(){if(YN)return Zg;YN=1;var e=vR(),t=Zr(),n=$6(),s=Math.max;function o(a,l,u){var h=a==null?0:a.length;if(!h)return-1;var p=u==null?0:n(u);return p<0&&(p=s(h+p,0)),e(a,t(l,3),p)}return Zg=o,Zg}var Jg,KN;function q6(){if(KN)return Jg;KN=1;var e=M6(),t=L6(),n=e(t);return Jg=n,Jg}var ev,XN;function ER(){if(XN)return ev;XN=1;var e=Bw();function t(n){var s=n==null?0:n.length;return s?e(n,1):[]}return ev=t,ev}var tv,QN;function D6(){if(QN)return tv;QN=1;var e=qw(),t=XT(),n=ki();function s(o,a){return o==null?o:e(o,t(a),n)}return tv=s,tv}var nv,ZN;function F6(){if(ZN)return nv;ZN=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return nv=e,nv}var rv,JN;function z6(){if(JN)return rv;JN=1;var e=Du(),t=Dw(),n=Zr();function s(o,a){var l={};return a=n(a,3),t(o,function(u,h,p){e(l,h,a(u,h,p))}),l}return rv=s,rv}var sv,eE;function Ww(){if(eE)return sv;eE=1;var e=Yo();function t(n,s,o){for(var a=-1,l=n.length;++a<l;){var u=n[a],h=s(u);if(h!=null&&(p===void 0?h===h&&!e(h):o(h,p)))var p=h,f=u}return f}return sv=t,sv}var iv,tE;function B6(){if(tE)return iv;tE=1;function e(t,n){return t>n}return iv=e,iv}var ov,nE;function U6(){if(nE)return ov;nE=1;var e=Ww(),t=B6(),n=Si();function s(o){return o&&o.length?e(o,n,t):void 0}return ov=s,ov}var av,rE;function jR(){if(rE)return av;rE=1;var e=Du(),t=Wo();function n(s,o,a){(a!==void 0&&!t(s[o],a)||a===void 0&&!(o in s))&&e(s,o,a)}return av=n,av}var lv,sE;function W6(){if(sE)return lv;sE=1;var e=bi(),t=Wu(),n=Er(),s="[object Object]",o=Function.prototype,a=Object.prototype,l=o.toString,u=a.hasOwnProperty,h=l.call(Object);function p(f){if(!n(f)||e(f)!=s)return!1;var g=t(f);if(g===null)return!0;var y=u.call(g,"constructor")&&g.constructor;return typeof y=="function"&&y instanceof y&&l.call(y)==h}return lv=p,lv}var cv,iE;function CR(){if(iE)return cv;iE=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return cv=e,cv}var uv,oE;function H6(){if(oE)return uv;oE=1;var e=wl(),t=ki();function n(s){return e(s,t(s))}return uv=n,uv}var dv,aE;function G6(){if(aE)return dv;aE=1;var e=jR(),t=LT(),n=GT(),s=qT(),o=YT(),a=xl(),l=Rt(),u=yR(),h=Go(),p=yl(),f=qn(),g=W6(),y=bl(),w=CR(),S=H6();function b(_,k,N,j,T,M,P){var I=w(_,N),F=w(k,N),O=P.get(F);if(O){e(_,N,O);return}var A=M?M(I,F,N+"",_,k,P):void 0,D=A===void 0;if(D){var H=l(F),K=!H&&h(F),C=!H&&!K&&y(F);A=F,H||K||C?l(I)?A=I:u(I)?A=s(I):K?(D=!1,A=t(F,!0)):C?(D=!1,A=n(F,!0)):A=[]:g(F)||a(F)?(A=I,a(I)?A=S(I):(!f(I)||p(I))&&(A=o(F))):D=!1}D&&(P.set(F,A),T(A,F,j,M,P),P.delete(F)),e(_,N,A)}return dv=b,dv}var fv,lE;function V6(){if(lE)return fv;lE=1;var e=qu(),t=jR(),n=qw(),s=G6(),o=qn(),a=ki(),l=CR();function u(h,p,f,g,y){h!==p&&n(p,function(w,S){if(y||(y=new e),o(w))s(h,p,S,f,u,g,y);else{var b=g?g(l(h,S),w,S+"",h,p,y):void 0;b===void 0&&(b=w),t(h,S,b)}},a)}return fv=u,fv}var hv,cE;function Y6(){if(cE)return hv;cE=1;var e=Ku(),t=Xu();function n(s){return e(function(o,a){var l=-1,u=a.length,h=u>1?a[u-1]:void 0,p=u>2?a[2]:void 0;for(h=s.length>3&&typeof h=="function"?(u--,h):void 0,p&&t(a[0],a[1],p)&&(h=u<3?void 0:h,u=1),o=Object(o);++l<u;){var f=a[l];f&&s(o,f,l,h)}return o})}return hv=n,hv}var pv,uE;function K6(){if(uE)return pv;uE=1;var e=V6(),t=Y6(),n=t(function(s,o,a){e(s,o,a)});return pv=n,pv}var mv,dE;function TR(){if(dE)return mv;dE=1;function e(t,n){return t<n}return mv=e,mv}var gv,fE;function X6(){if(fE)return gv;fE=1;var e=Ww(),t=TR(),n=Si();function s(o){return o&&o.length?e(o,n,t):void 0}return gv=s,gv}var vv,hE;function Q6(){if(hE)return vv;hE=1;var e=Ww(),t=Zr(),n=TR();function s(o,a){return o&&o.length?e(o,t(a,2),n):void 0}return vv=s,vv}var yv,pE;function Z6(){if(pE)return yv;pE=1;var e=ur(),t=function(){return e.Date.now()};return yv=t,yv}var wv,mE;function J6(){if(mE)return wv;mE=1;var e=Fu(),t=Vu(),n=zu(),s=qn(),o=_l();function a(l,u,h,p){if(!s(l))return l;u=t(u,l);for(var f=-1,g=u.length,y=g-1,w=l;w!=null&&++f<g;){var S=o(u[f]),b=h;if(S==="__proto__"||S==="constructor"||S==="prototype")return l;if(f!=y){var _=w[S];b=p?p(_,S,w):void 0,b===void 0&&(b=s(_)?_:n(u[f+1])?[]:{})}e(w,S,b),w=w[S]}return l}return wv=a,wv}var xv,gE;function ez(){if(gE)return xv;gE=1;var e=Yu(),t=J6(),n=Vu();function s(o,a,l){for(var u=-1,h=a.length,p={};++u<h;){var f=a[u],g=e(o,f);l(g,f)&&t(p,n(f,o),g)}return p}return xv=s,xv}var bv,vE;function tz(){if(vE)return bv;vE=1;var e=ez(),t=aR();function n(s,o){return e(s,o,function(a,l){return t(s,l)})}return bv=n,bv}var _v,yE;function nz(){if(yE)return _v;yE=1;var e=ER(),t=mR(),n=gR();function s(o){return n(t(o,void 0,e),o+"")}return _v=s,_v}var kv,wE;function rz(){if(wE)return kv;wE=1;var e=tz(),t=nz(),n=t(function(s,o){return s==null?{}:e(s,o)});return kv=n,kv}var Sv,xE;function sz(){if(xE)return Sv;xE=1;var e=Math.ceil,t=Math.max;function n(s,o,a,l){for(var u=-1,h=t(e((o-s)/(a||1)),0),p=Array(h);h--;)p[l?h:++u]=s,s+=a;return p}return Sv=n,Sv}var Nv,bE;function iz(){if(bE)return Nv;bE=1;var e=sz(),t=Xu(),n=NR();function s(o){return function(a,l,u){return u&&typeof u!="number"&&t(a,l,u)&&(l=u=void 0),a=n(a),l===void 0?(l=a,a=0):l=n(l),u=u===void 0?a<l?1:-1:n(u),e(a,l,u,o)}}return Nv=s,Nv}var Ev,_E;function oz(){if(_E)return Ev;_E=1;var e=iz(),t=e();return Ev=t,Ev}var jv,kE;function az(){if(kE)return jv;kE=1;function e(t,n){var s=t.length;for(t.sort(n);s--;)t[s]=t[s].value;return t}return jv=e,jv}var Cv,SE;function lz(){if(SE)return Cv;SE=1;var e=Yo();function t(n,s){if(n!==s){var o=n!==void 0,a=n===null,l=n===n,u=e(n),h=s!==void 0,p=s===null,f=s===s,g=e(s);if(!p&&!g&&!u&&n>s||u&&h&&f&&!p&&!g||a&&h&&f||!o&&f||!l)return 1;if(!a&&!u&&!g&&n<s||g&&o&&l&&!a&&!u||p&&o&&l||!h&&l||!f)return-1}return 0}return Cv=t,Cv}var Tv,NE;function cz(){if(NE)return Tv;NE=1;var e=lz();function t(n,s,o){for(var a=-1,l=n.criteria,u=s.criteria,h=l.length,p=o.length;++a<h;){var f=e(l[a],u[a]);if(f){if(a>=p)return f;var g=o[a];return f*(g=="desc"?-1:1)}}return n.index-s.index}return Tv=t,Tv}var Rv,EE;function uz(){if(EE)return Rv;EE=1;var e=Gu(),t=Yu(),n=Zr(),s=fR(),o=az(),a=Bu(),l=cz(),u=Si(),h=Rt();function p(f,g,y){g.length?g=e(g,function(b){return h(b)?function(_){return t(_,b.length===1?b[0]:b)}:b}):g=[u];var w=-1;g=e(g,a(n));var S=s(f,function(b,_,k){var N=e(g,function(j){return j(b)});return{criteria:N,index:++w,value:b}});return o(S,function(b,_){return l(b,_,y)})}return Rv=p,Rv}var Av,jE;function dz(){if(jE)return Av;jE=1;var e=Bw(),t=uz(),n=Ku(),s=Xu(),o=n(function(a,l){if(a==null)return[];var u=l.length;return u>1&&s(a,l[0],l[1])?l=[]:u>2&&s(l[0],l[1],l[2])&&(l=[l[0]]),t(a,e(l,1),[])});return Av=o,Av}var Mv,CE;function fz(){if(CE)return Mv;CE=1;var e=iR(),t=0;function n(s){var o=++t;return e(s)+o}return Mv=n,Mv}var Iv,TE;function hz(){if(TE)return Iv;TE=1;function e(t,n,s){for(var o=-1,a=t.length,l=n.length,u={};++o<a;){var h=o<l?n[o]:void 0;s(u,t[o],h)}return u}return Iv=e,Iv}var Ov,RE;function pz(){if(RE)return Ov;RE=1;var e=Fu(),t=hz();function n(s,o){return t(s||[],o||[],e)}return Ov=n,Ov}var Pv,AE;function vt(){if(AE)return Pv;AE=1;var e;if(typeof jw=="function")try{e={cloneDeep:R6(),constant:Lw(),defaults:A6(),each:ZT(),filter:cR(),find:q6(),flatten:ER(),forEach:QT(),forIn:D6(),has:uR(),isUndefined:dR(),last:F6(),map:hR(),mapValues:z6(),max:U6(),merge:K6(),min:X6(),minBy:Q6(),now:Z6(),pick:rz(),range:oz(),reduce:pR(),sortBy:dz(),uniqueId:fz(),values:wR(),zipObject:pz()}}catch{}return e||(e=window._),Pv=e,Pv}var $v,ME;function mz(){if(ME)return $v;ME=1,$v=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 t(o),o},e.prototype.enqueue=function(s){var o=this._sentinel;s._prev&&s._next&&t(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,a=o._prev;a!==o;)s.push(JSON.stringify(a,n)),a=a._prev;return"["+s.join(", ")+"]"};function t(s){s._prev._next=s._next,s._next._prev=s._prev,delete s._next,delete s._prev}function n(s,o){if(s!=="_next"&&s!=="_prev")return o}return $v}var Lv,IE;function gz(){if(IE)return Lv;IE=1;var e=vt(),t=lr().Graph,n=mz();Lv=o;var s=e.constant(1);function o(p,f){if(p.nodeCount()<=1)return[];var g=u(p,f||s),y=a(g.graph,g.buckets,g.zeroIdx);return e.flatten(e.map(y,function(w){return p.outEdges(w.v,w.w)}),!0)}function a(p,f,g){for(var y=[],w=f[f.length-1],S=f[0],b;p.nodeCount();){for(;b=S.dequeue();)l(p,f,g,b);for(;b=w.dequeue();)l(p,f,g,b);if(p.nodeCount()){for(var _=f.length-2;_>0;--_)if(b=f[_].dequeue(),b){y=y.concat(l(p,f,g,b,!0));break}}}return y}function l(p,f,g,y,w){var S=w?[]:void 0;return e.forEach(p.inEdges(y.v),function(b){var _=p.edge(b),k=p.node(b.v);w&&S.push({v:b.v,w:b.w}),k.out-=_,h(f,g,k)}),e.forEach(p.outEdges(y.v),function(b){var _=p.edge(b),k=b.w,N=p.node(k);N.in-=_,h(f,g,N)}),p.removeNode(y.v),S}function u(p,f){var g=new t,y=0,w=0;e.forEach(p.nodes(),function(_){g.setNode(_,{v:_,in:0,out:0})}),e.forEach(p.edges(),function(_){var k=g.edge(_.v,_.w)||0,N=f(_),j=k+N;g.setEdge(_.v,_.w,j),w=Math.max(w,g.node(_.v).out+=N),y=Math.max(y,g.node(_.w).in+=N)});var S=e.range(w+y+3).map(function(){return new n}),b=y+1;return e.forEach(g.nodes(),function(_){h(S,b,g.node(_))}),{graph:g,buckets:S,zeroIdx:b}}function h(p,f,g){g.out?g.in?p[g.out-g.in+f].enqueue(g):p[p.length-1].enqueue(g):p[0].enqueue(g)}return Lv}var qv,OE;function vz(){if(OE)return qv;OE=1;var e=vt(),t=gz();qv={run:n,undo:o};function n(a){var l=a.graph().acyclicer==="greedy"?t(a,u(a)):s(a);e.forEach(l,function(h){var p=a.edge(h);a.removeEdge(h),p.forwardName=h.name,p.reversed=!0,a.setEdge(h.w,h.v,p,e.uniqueId("rev"))});function u(h){return function(p){return h.edge(p).weight}}}function s(a){var l=[],u={},h={};function p(f){e.has(h,f)||(h[f]=!0,u[f]=!0,e.forEach(a.outEdges(f),function(g){e.has(u,g.w)?l.push(g):p(g.w)}),delete u[f])}return e.forEach(a.nodes(),p),l}function o(a){e.forEach(a.edges(),function(l){var u=a.edge(l);if(u.reversed){a.removeEdge(l);var h=u.forwardName;delete u.reversed,delete u.forwardName,a.setEdge(l.w,l.v,u,h)}})}return qv}var Dv,PE;function pn(){if(PE)return Dv;PE=1;var e=vt(),t=lr().Graph;Dv={addDummyNode:n,simplify:s,asNonCompoundGraph:o,successorWeights:a,predecessorWeights:l,intersectRect:u,buildLayerMatrix:h,normalizeRanks:p,removeEmptyRanks:f,addBorderNode:g,maxRank:y,partition:w,time:S,notime:b};function n(_,k,N,j){var T;do T=e.uniqueId(j);while(_.hasNode(T));return N.dummy=k,_.setNode(T,N),T}function s(_){var k=new t().setGraph(_.graph());return e.forEach(_.nodes(),function(N){k.setNode(N,_.node(N))}),e.forEach(_.edges(),function(N){var j=k.edge(N.v,N.w)||{weight:0,minlen:1},T=_.edge(N);k.setEdge(N.v,N.w,{weight:j.weight+T.weight,minlen:Math.max(j.minlen,T.minlen)})}),k}function o(_){var k=new t({multigraph:_.isMultigraph()}).setGraph(_.graph());return e.forEach(_.nodes(),function(N){_.children(N).length||k.setNode(N,_.node(N))}),e.forEach(_.edges(),function(N){k.setEdge(N,_.edge(N))}),k}function a(_){var k=e.map(_.nodes(),function(N){var j={};return e.forEach(_.outEdges(N),function(T){j[T.w]=(j[T.w]||0)+_.edge(T).weight}),j});return e.zipObject(_.nodes(),k)}function l(_){var k=e.map(_.nodes(),function(N){var j={};return e.forEach(_.inEdges(N),function(T){j[T.v]=(j[T.v]||0)+_.edge(T).weight}),j});return e.zipObject(_.nodes(),k)}function u(_,k){var N=_.x,j=_.y,T=k.x-N,M=k.y-j,P=_.width/2,I=_.height/2;if(!T&&!M)throw new Error("Not possible to find intersection inside of the rectangle");var F,O;return Math.abs(M)*P>Math.abs(T)*I?(M<0&&(I=-I),F=I*T/M,O=I):(T<0&&(P=-P),F=P,O=P*M/T),{x:N+F,y:j+O}}function h(_){var k=e.map(e.range(y(_)+1),function(){return[]});return e.forEach(_.nodes(),function(N){var j=_.node(N),T=j.rank;e.isUndefined(T)||(k[T][j.order]=N)}),k}function p(_){var k=e.min(e.map(_.nodes(),function(N){return _.node(N).rank}));e.forEach(_.nodes(),function(N){var j=_.node(N);e.has(j,"rank")&&(j.rank-=k)})}function f(_){var k=e.min(e.map(_.nodes(),function(M){return _.node(M).rank})),N=[];e.forEach(_.nodes(),function(M){var P=_.node(M).rank-k;N[P]||(N[P]=[]),N[P].push(M)});var j=0,T=_.graph().nodeRankFactor;e.forEach(N,function(M,P){e.isUndefined(M)&&P%T!==0?--j:j&&e.forEach(M,function(I){_.node(I).rank+=j})})}function g(_,k,N,j){var T={width:0,height:0};return arguments.length>=4&&(T.rank=N,T.order=j),n(_,"border",T,k)}function y(_){return e.max(e.map(_.nodes(),function(k){var N=_.node(k).rank;if(!e.isUndefined(N))return N}))}function w(_,k){var N={lhs:[],rhs:[]};return e.forEach(_,function(j){k(j)?N.lhs.push(j):N.rhs.push(j)}),N}function S(_,k){var N=e.now();try{return k()}finally{console.log(_+" time: "+(e.now()-N)+"ms")}}function b(_,k){return k()}return Dv}var Fv,$E;function yz(){if($E)return Fv;$E=1;var e=vt(),t=pn();Fv={run:n,undo:o};function n(a){a.graph().dummyChains=[],e.forEach(a.edges(),function(l){s(a,l)})}function s(a,l){var u=l.v,h=a.node(u).rank,p=l.w,f=a.node(p).rank,g=l.name,y=a.edge(l),w=y.labelRank;if(f!==h+1){a.removeEdge(l);var S,b,_;for(_=0,++h;h<f;++_,++h)y.points=[],b={width:0,height:0,edgeLabel:y,edgeObj:l,rank:h},S=t.addDummyNode(a,"edge",b,"_d"),h===w&&(b.width=y.width,b.height=y.height,b.dummy="edge-label",b.labelpos=y.labelpos),a.setEdge(u,S,{weight:y.weight},g),_===0&&a.graph().dummyChains.push(S),u=S;a.setEdge(u,p,{weight:y.weight},g)}}function o(a){e.forEach(a.graph().dummyChains,function(l){var u=a.node(l),h=u.edgeLabel,p;for(a.setEdge(u.edgeObj,h);u.dummy;)p=a.successors(l)[0],a.removeNode(l),h.points.push({x:u.x,y:u.y}),u.dummy==="edge-label"&&(h.x=u.x,h.y=u.y,h.width=u.width,h.height=u.height),l=p,u=a.node(l)})}return Fv}var zv,LE;function xu(){if(LE)return zv;LE=1;var e=vt();zv={longestPath:t,slack:n};function t(s){var o={};function a(l){var u=s.node(l);if(e.has(o,l))return u.rank;o[l]=!0;var h=e.min(e.map(s.outEdges(l),function(p){return a(p.w)-s.edge(p).minlen}));return(h===Number.POSITIVE_INFINITY||h===void 0||h===null)&&(h=0),u.rank=h}e.forEach(s.sources(),a)}function n(s,o){return s.node(o.w).rank-s.node(o.v).rank-s.edge(o).minlen}return zv}var Bv,qE;function RR(){if(qE)return Bv;qE=1;var e=vt(),t=lr().Graph,n=xu().slack;Bv=s;function s(u){var h=new t({directed:!1}),p=u.nodes()[0],f=u.nodeCount();h.setNode(p,{});for(var g,y;o(h,u)<f;)g=a(h,u),y=h.hasNode(g.v)?n(u,g):-n(u,g),l(h,u,y);return h}function o(u,h){function p(f){e.forEach(h.nodeEdges(f),function(g){var y=g.v,w=f===y?g.w:y;!u.hasNode(w)&&!n(h,g)&&(u.setNode(w,{}),u.setEdge(f,w,{}),p(w))})}return e.forEach(u.nodes(),p),u.nodeCount()}function a(u,h){return e.minBy(h.edges(),function(p){if(u.hasNode(p.v)!==u.hasNode(p.w))return n(h,p)})}function l(u,h,p){e.forEach(u.nodes(),function(f){h.node(f).rank+=p})}return Bv}var Uv,DE;function wz(){if(DE)return Uv;DE=1;var e=vt(),t=RR(),n=xu().slack,s=xu().longestPath,o=lr().alg.preorder,a=lr().alg.postorder,l=pn().simplify;Uv=u,u.initLowLimValues=g,u.initCutValues=h,u.calcCutValue=f,u.leaveEdge=w,u.enterEdge=S,u.exchangeEdges=b;function u(j){j=l(j),s(j);var T=t(j);g(T),h(T,j);for(var M,P;M=w(T);)P=S(T,j,M),b(T,j,M,P)}function h(j,T){var M=a(j,j.nodes());M=M.slice(0,M.length-1),e.forEach(M,function(P){p(j,T,P)})}function p(j,T,M){var P=j.node(M),I=P.parent;j.edge(M,I).cutvalue=f(j,T,M)}function f(j,T,M){var P=j.node(M),I=P.parent,F=!0,O=T.edge(M,I),A=0;return O||(F=!1,O=T.edge(I,M)),A=O.weight,e.forEach(T.nodeEdges(M),function(D){var H=D.v===M,K=H?D.w:D.v;if(K!==I){var C=H===F,X=T.edge(D).weight;if(A+=C?X:-X,k(j,M,K)){var B=j.edge(M,K).cutvalue;A+=C?-B:B}}}),A}function g(j,T){arguments.length<2&&(T=j.nodes()[0]),y(j,{},1,T)}function y(j,T,M,P,I){var F=M,O=j.node(P);return T[P]=!0,e.forEach(j.neighbors(P),function(A){e.has(T,A)||(M=y(j,T,M,A,P))}),O.low=F,O.lim=M++,I?O.parent=I:delete O.parent,M}function w(j){return e.find(j.edges(),function(T){return j.edge(T).cutvalue<0})}function S(j,T,M){var P=M.v,I=M.w;T.hasEdge(P,I)||(P=M.w,I=M.v);var F=j.node(P),O=j.node(I),A=F,D=!1;F.lim>O.lim&&(A=O,D=!0);var H=e.filter(T.edges(),function(K){return D===N(j,j.node(K.v),A)&&D!==N(j,j.node(K.w),A)});return e.minBy(H,function(K){return n(T,K)})}function b(j,T,M,P){var I=M.v,F=M.w;j.removeEdge(I,F),j.setEdge(P.v,P.w,{}),g(j),h(j,T),_(j,T)}function _(j,T){var M=e.find(j.nodes(),function(I){return!T.node(I).parent}),P=o(j,M);P=P.slice(1),e.forEach(P,function(I){var F=j.node(I).parent,O=T.edge(I,F),A=!1;O||(O=T.edge(F,I),A=!0),T.node(I).rank=T.node(F).rank+(A?O.minlen:-O.minlen)})}function k(j,T,M){return j.hasEdge(T,M)}function N(j,T,M){return M.low<=T.lim&&T.lim<=M.lim}return Uv}var Wv,FE;function xz(){if(FE)return Wv;FE=1;var e=xu(),t=e.longestPath,n=RR(),s=wz();Wv=o;function o(h){switch(h.graph().ranker){case"network-simplex":u(h);break;case"tight-tree":l(h);break;case"longest-path":a(h);break;default:u(h)}}var a=t;function l(h){t(h),n(h)}function u(h){s(h)}return Wv}var Hv,zE;function bz(){if(zE)return Hv;zE=1;var e=vt();Hv=t;function t(o){var a=s(o);e.forEach(o.graph().dummyChains,function(l){for(var u=o.node(l),h=u.edgeObj,p=n(o,a,h.v,h.w),f=p.path,g=p.lca,y=0,w=f[y],S=!0;l!==h.w;){if(u=o.node(l),S){for(;(w=f[y])!==g&&o.node(w).maxRank<u.rank;)y++;w===g&&(S=!1)}if(!S){for(;y<f.length-1&&o.node(w=f[y+1]).minRank<=u.rank;)y++;w=f[y]}o.setParent(l,w),l=o.successors(l)[0]}})}function n(o,a,l,u){var h=[],p=[],f=Math.min(a[l].low,a[u].low),g=Math.max(a[l].lim,a[u].lim),y,w;y=l;do y=o.parent(y),h.push(y);while(y&&(a[y].low>f||g>a[y].lim));for(w=y,y=u;(y=o.parent(y))!==w;)p.push(y);return{path:h.concat(p.reverse()),lca:w}}function s(o){var a={},l=0;function u(h){var p=l;e.forEach(o.children(h),u),a[h]={low:p,lim:l++}}return e.forEach(o.children(),u),a}return Hv}var Gv,BE;function _z(){if(BE)return Gv;BE=1;var e=vt(),t=pn();Gv={run:n,cleanup:l};function n(u){var h=t.addDummyNode(u,"root",{},"_root"),p=o(u),f=e.max(e.values(p))-1,g=2*f+1;u.graph().nestingRoot=h,e.forEach(u.edges(),function(w){u.edge(w).minlen*=g});var y=a(u)+1;e.forEach(u.children(),function(w){s(u,h,g,y,f,p,w)}),u.graph().nodeRankFactor=g}function s(u,h,p,f,g,y,w){var S=u.children(w);if(!S.length){w!==h&&u.setEdge(h,w,{weight:0,minlen:p});return}var b=t.addBorderNode(u,"_bt"),_=t.addBorderNode(u,"_bb"),k=u.node(w);u.setParent(b,w),k.borderTop=b,u.setParent(_,w),k.borderBottom=_,e.forEach(S,function(N){s(u,h,p,f,g,y,N);var j=u.node(N),T=j.borderTop?j.borderTop:N,M=j.borderBottom?j.borderBottom:N,P=j.borderTop?f:2*f,I=T!==M?1:g-y[w]+1;u.setEdge(b,T,{weight:P,minlen:I,nestingEdge:!0}),u.setEdge(M,_,{weight:P,minlen:I,nestingEdge:!0})}),u.parent(w)||u.setEdge(h,b,{weight:0,minlen:g+y[w]})}function o(u){var h={};function p(f,g){var y=u.children(f);y&&y.length&&e.forEach(y,function(w){p(w,g+1)}),h[f]=g}return e.forEach(u.children(),function(f){p(f,1)}),h}function a(u){return e.reduce(u.edges(),function(h,p){return h+u.edge(p).weight},0)}function l(u){var h=u.graph();u.removeNode(h.nestingRoot),delete h.nestingRoot,e.forEach(u.edges(),function(p){var f=u.edge(p);f.nestingEdge&&u.removeEdge(p)})}return Gv}var Vv,UE;function kz(){if(UE)return Vv;UE=1;var e=vt(),t=pn();Vv=n;function n(o){function a(l){var u=o.children(l),h=o.node(l);if(u.length&&e.forEach(u,a),e.has(h,"minRank")){h.borderLeft=[],h.borderRight=[];for(var p=h.minRank,f=h.maxRank+1;p<f;++p)s(o,"borderLeft","_bl",l,h,p),s(o,"borderRight","_br",l,h,p)}}e.forEach(o.children(),a)}function s(o,a,l,u,h,p){var f={width:0,height:0,rank:p,borderType:a},g=h[a][p-1],y=t.addDummyNode(o,"border",f,l);h[a][p]=y,o.setParent(y,u),g&&o.setEdge(g,y,{weight:1})}return Vv}var Yv,WE;function Sz(){if(WE)return Yv;WE=1;var e=vt();Yv={adjust:t,undo:n};function t(p){var f=p.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&s(p)}function n(p){var f=p.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&a(p),(f==="lr"||f==="rl")&&(u(p),s(p))}function s(p){e.forEach(p.nodes(),function(f){o(p.node(f))}),e.forEach(p.edges(),function(f){o(p.edge(f))})}function o(p){var f=p.width;p.width=p.height,p.height=f}function a(p){e.forEach(p.nodes(),function(f){l(p.node(f))}),e.forEach(p.edges(),function(f){var g=p.edge(f);e.forEach(g.points,l),e.has(g,"y")&&l(g)})}function l(p){p.y=-p.y}function u(p){e.forEach(p.nodes(),function(f){h(p.node(f))}),e.forEach(p.edges(),function(f){var g=p.edge(f);e.forEach(g.points,h),e.has(g,"x")&&h(g)})}function h(p){var f=p.x;p.x=p.y,p.y=f}return Yv}var Kv,HE;function Nz(){if(HE)return Kv;HE=1;var e=vt();Kv=t;function t(n){var s={},o=e.filter(n.nodes(),function(p){return!n.children(p).length}),a=e.max(e.map(o,function(p){return n.node(p).rank})),l=e.map(e.range(a+1),function(){return[]});function u(p){if(!e.has(s,p)){s[p]=!0;var f=n.node(p);l[f.rank].push(p),e.forEach(n.successors(p),u)}}var h=e.sortBy(o,function(p){return n.node(p).rank});return e.forEach(h,u),l}return Kv}var Xv,GE;function Ez(){if(GE)return Xv;GE=1;var e=vt();Xv=t;function t(s,o){for(var a=0,l=1;l<o.length;++l)a+=n(s,o[l-1],o[l]);return a}function n(s,o,a){for(var l=e.zipObject(a,e.map(a,function(y,w){return w})),u=e.flatten(e.map(o,function(y){return e.sortBy(e.map(s.outEdges(y),function(w){return{pos:l[w.w],weight:s.edge(w).weight}}),"pos")}),!0),h=1;h<a.length;)h<<=1;var p=2*h-1;h-=1;var f=e.map(new Array(p),function(){return 0}),g=0;return e.forEach(u.forEach(function(y){var w=y.pos+h;f[w]+=y.weight;for(var S=0;w>0;)w%2&&(S+=f[w+1]),w=w-1>>1,f[w]+=y.weight;g+=y.weight*S})),g}return Xv}var Qv,VE;function jz(){if(VE)return Qv;VE=1;var e=vt();Qv=t;function t(n,s){return e.map(s,function(o){var a=n.inEdges(o);if(a.length){var l=e.reduce(a,function(u,h){var p=n.edge(h),f=n.node(h.v);return{sum:u.sum+p.weight*f.order,weight:u.weight+p.weight}},{sum:0,weight:0});return{v:o,barycenter:l.sum/l.weight,weight:l.weight}}else return{v:o}})}return Qv}var Zv,YE;function Cz(){if(YE)return Zv;YE=1;var e=vt();Zv=t;function t(o,a){var l={};e.forEach(o,function(h,p){var f=l[h.v]={indegree:0,in:[],out:[],vs:[h.v],i:p};e.isUndefined(h.barycenter)||(f.barycenter=h.barycenter,f.weight=h.weight)}),e.forEach(a.edges(),function(h){var p=l[h.v],f=l[h.w];!e.isUndefined(p)&&!e.isUndefined(f)&&(f.indegree++,p.out.push(l[h.w]))});var u=e.filter(l,function(h){return!h.indegree});return n(u)}function n(o){var a=[];function l(p){return function(f){f.merged||(e.isUndefined(f.barycenter)||e.isUndefined(p.barycenter)||f.barycenter>=p.barycenter)&&s(p,f)}}function u(p){return function(f){f.in.push(p),--f.indegree===0&&o.push(f)}}for(;o.length;){var h=o.pop();a.push(h),e.forEach(h.in.reverse(),l(h)),e.forEach(h.out,u(h))}return e.map(e.filter(a,function(p){return!p.merged}),function(p){return e.pick(p,["vs","i","barycenter","weight"])})}function s(o,a){var l=0,u=0;o.weight&&(l+=o.barycenter*o.weight,u+=o.weight),a.weight&&(l+=a.barycenter*a.weight,u+=a.weight),o.vs=a.vs.concat(o.vs),o.barycenter=l/u,o.weight=u,o.i=Math.min(a.i,o.i),a.merged=!0}return Zv}var Jv,KE;function Tz(){if(KE)return Jv;KE=1;var e=vt(),t=pn();Jv=n;function n(a,l){var u=t.partition(a,function(b){return e.has(b,"barycenter")}),h=u.lhs,p=e.sortBy(u.rhs,function(b){return-b.i}),f=[],g=0,y=0,w=0;h.sort(o(!!l)),w=s(f,p,w),e.forEach(h,function(b){w+=b.vs.length,f.push(b.vs),g+=b.barycenter*b.weight,y+=b.weight,w=s(f,p,w)});var S={vs:e.flatten(f,!0)};return y&&(S.barycenter=g/y,S.weight=y),S}function s(a,l,u){for(var h;l.length&&(h=e.last(l)).i<=u;)l.pop(),a.push(h.vs),u++;return u}function o(a){return function(l,u){return l.barycenter<u.barycenter?-1:l.barycenter>u.barycenter?1:a?u.i-l.i:l.i-u.i}}return Jv}var ey,XE;function Rz(){if(XE)return ey;XE=1;var e=vt(),t=jz(),n=Cz(),s=Tz();ey=o;function o(u,h,p,f){var g=u.children(h),y=u.node(h),w=y?y.borderLeft:void 0,S=y?y.borderRight:void 0,b={};w&&(g=e.filter(g,function(M){return M!==w&&M!==S}));var _=t(u,g);e.forEach(_,function(M){if(u.children(M.v).length){var P=o(u,M.v,p,f);b[M.v]=P,e.has(P,"barycenter")&&l(M,P)}});var k=n(_,p);a(k,b);var N=s(k,f);if(w&&(N.vs=e.flatten([w,N.vs,S],!0),u.predecessors(w).length)){var j=u.node(u.predecessors(w)[0]),T=u.node(u.predecessors(S)[0]);e.has(N,"barycenter")||(N.barycenter=0,N.weight=0),N.barycenter=(N.barycenter*N.weight+j.order+T.order)/(N.weight+2),N.weight+=2}return N}function a(u,h){e.forEach(u,function(p){p.vs=e.flatten(p.vs.map(function(f){return h[f]?h[f].vs:f}),!0)})}function l(u,h){e.isUndefined(u.barycenter)?(u.barycenter=h.barycenter,u.weight=h.weight):(u.barycenter=(u.barycenter*u.weight+h.barycenter*h.weight)/(u.weight+h.weight),u.weight+=h.weight)}return ey}var ty,QE;function Az(){if(QE)return ty;QE=1;var e=vt(),t=lr().Graph;ty=n;function n(o,a,l){var u=s(o),h=new t({compound:!0}).setGraph({root:u}).setDefaultNodeLabel(function(p){return o.node(p)});return e.forEach(o.nodes(),function(p){var f=o.node(p),g=o.parent(p);(f.rank===a||f.minRank<=a&&a<=f.maxRank)&&(h.setNode(p),h.setParent(p,g||u),e.forEach(o[l](p),function(y){var w=y.v===p?y.w:y.v,S=h.edge(w,p),b=e.isUndefined(S)?0:S.weight;h.setEdge(w,p,{weight:o.edge(y).weight+b})}),e.has(f,"minRank")&&h.setNode(p,{borderLeft:f.borderLeft[a],borderRight:f.borderRight[a]}))}),h}function s(o){for(var a;o.hasNode(a=e.uniqueId("_root")););return a}return ty}var ny,ZE;function Mz(){if(ZE)return ny;ZE=1;var e=vt();ny=t;function t(n,s,o){var a={},l;e.forEach(o,function(u){for(var h=n.parent(u),p,f;h;){if(p=n.parent(h),p?(f=a[p],a[p]=h):(f=l,l=h),f&&f!==h){s.setEdge(f,h);return}h=p}})}return ny}var ry,JE;function Iz(){if(JE)return ry;JE=1;var e=vt(),t=Nz(),n=Ez(),s=Rz(),o=Az(),a=Mz(),l=lr().Graph,u=pn();ry=h;function h(y){var w=u.maxRank(y),S=p(y,e.range(1,w+1),"inEdges"),b=p(y,e.range(w-1,-1,-1),"outEdges"),_=t(y);g(y,_);for(var k=Number.POSITIVE_INFINITY,N,j=0,T=0;T<4;++j,++T){f(j%2?S:b,j%4>=2),_=u.buildLayerMatrix(y);var M=n(y,_);M<k&&(T=0,N=e.cloneDeep(_),k=M)}g(y,N)}function p(y,w,S){return e.map(w,function(b){return o(y,b,S)})}function f(y,w){var S=new l;e.forEach(y,function(b){var _=b.graph().root,k=s(b,_,S,w);e.forEach(k.vs,function(N,j){b.node(N).order=j}),a(b,S,k.vs)})}function g(y,w){e.forEach(w,function(S){e.forEach(S,function(b,_){y.node(b).order=_})})}return ry}var sy,ej;function Oz(){if(ej)return sy;ej=1;var e=vt(),t=lr().Graph,n=pn();sy={positionX:S,findType1Conflicts:s,findType2Conflicts:o,addConflict:l,hasConflict:u,verticalAlignment:h,horizontalCompaction:p,alignCoordinates:y,findSmallestWidthAlignment:g,balance:w};function s(k,N){var j={};function T(M,P){var I=0,F=0,O=M.length,A=e.last(P);return e.forEach(P,function(D,H){var K=a(k,D),C=K?k.node(K).order:O;(K||D===A)&&(e.forEach(P.slice(F,H+1),function(X){e.forEach(k.predecessors(X),function(B){var ne=k.node(B),J=ne.order;(J<I||C<J)&&!(ne.dummy&&k.node(X).dummy)&&l(j,B,X)})}),F=H+1,I=C)}),P}return e.reduce(N,T),j}function o(k,N){var j={};function T(P,I,F,O,A){var D;e.forEach(e.range(I,F),function(H){D=P[H],k.node(D).dummy&&e.forEach(k.predecessors(D),function(K){var C=k.node(K);C.dummy&&(C.order<O||C.order>A)&&l(j,K,D)})})}function M(P,I){var F=-1,O,A=0;return e.forEach(I,function(D,H){if(k.node(D).dummy==="border"){var K=k.predecessors(D);K.length&&(O=k.node(K[0]).order,T(I,A,H,F,O),A=H,F=O)}T(I,A,I.length,O,P.length)}),I}return e.reduce(N,M),j}function a(k,N){if(k.node(N).dummy)return e.find(k.predecessors(N),function(j){return k.node(j).dummy})}function l(k,N,j){if(N>j){var T=N;N=j,j=T}var M=k[N];M||(k[N]=M={}),M[j]=!0}function u(k,N,j){if(N>j){var T=N;N=j,j=T}return e.has(k[N],j)}function h(k,N,j,T){var M={},P={},I={};return e.forEach(N,function(F){e.forEach(F,function(O,A){M[O]=O,P[O]=O,I[O]=A})}),e.forEach(N,function(F){var O=-1;e.forEach(F,function(A){var D=T(A);if(D.length){D=e.sortBy(D,function(B){return I[B]});for(var H=(D.length-1)/2,K=Math.floor(H),C=Math.ceil(H);K<=C;++K){var X=D[K];P[A]===A&&O<I[X]&&!u(j,A,X)&&(P[X]=A,P[A]=M[A]=M[X],O=I[X])}}})}),{root:M,align:P}}function p(k,N,j,T,M){var P={},I=f(k,N,j,M),F=M?"borderLeft":"borderRight";function O(H,K){for(var C=I.nodes(),X=C.pop(),B={};X;)B[X]?H(X):(B[X]=!0,C.push(X),C=C.concat(K(X))),X=C.pop()}function A(H){P[H]=I.inEdges(H).reduce(function(K,C){return Math.max(K,P[C.v]+I.edge(C))},0)}function D(H){var K=I.outEdges(H).reduce(function(X,B){return Math.min(X,P[B.w]-I.edge(B))},Number.POSITIVE_INFINITY),C=k.node(H);K!==Number.POSITIVE_INFINITY&&C.borderType!==F&&(P[H]=Math.max(P[H],K))}return O(A,I.predecessors.bind(I)),O(D,I.successors.bind(I)),e.forEach(T,function(H){P[H]=P[j[H]]}),P}function f(k,N,j,T){var M=new t,P=k.graph(),I=b(P.nodesep,P.edgesep,T);return e.forEach(N,function(F){var O;e.forEach(F,function(A){var D=j[A];if(M.setNode(D),O){var H=j[O],K=M.edge(H,D);M.setEdge(H,D,Math.max(I(k,A,O),K||0))}O=A})}),M}function g(k,N){return e.minBy(e.values(N),function(j){var T=Number.NEGATIVE_INFINITY,M=Number.POSITIVE_INFINITY;return e.forIn(j,function(P,I){var F=_(k,I)/2;T=Math.max(P+F,T),M=Math.min(P-F,M)}),T-M})}function y(k,N){var j=e.values(N),T=e.min(j),M=e.max(j);e.forEach(["u","d"],function(P){e.forEach(["l","r"],function(I){var F=P+I,O=k[F],A;if(O!==N){var D=e.values(O);A=I==="l"?T-e.min(D):M-e.max(D),A&&(k[F]=e.mapValues(O,function(H){return H+A}))}})})}function w(k,N){return e.mapValues(k.ul,function(j,T){if(N)return k[N.toLowerCase()][T];var M=e.sortBy(e.map(k,T));return(M[1]+M[2])/2})}function S(k){var N=n.buildLayerMatrix(k),j=e.merge(s(k,N),o(k,N)),T={},M;e.forEach(["u","d"],function(I){M=I==="u"?N:e.values(N).reverse(),e.forEach(["l","r"],function(F){F==="r"&&(M=e.map(M,function(H){return e.values(H).reverse()}));var O=(I==="u"?k.predecessors:k.successors).bind(k),A=h(k,M,j,O),D=p(k,M,A.root,A.align,F==="r");F==="r"&&(D=e.mapValues(D,function(H){return-H})),T[I+F]=D})});var P=g(k,T);return y(T,P),w(T,k.graph().align)}function b(k,N,j){return function(T,M,P){var I=T.node(M),F=T.node(P),O=0,A;if(O+=I.width/2,e.has(I,"labelpos"))switch(I.labelpos.toLowerCase()){case"l":A=-I.width/2;break;case"r":A=I.width/2;break}if(A&&(O+=j?A:-A),A=0,O+=(I.dummy?N:k)/2,O+=(F.dummy?N:k)/2,O+=F.width/2,e.has(F,"labelpos"))switch(F.labelpos.toLowerCase()){case"l":A=F.width/2;break;case"r":A=-F.width/2;break}return A&&(O+=j?A:-A),A=0,O}}function _(k,N){return k.node(N).width}return sy}var iy,tj;function Pz(){if(tj)return iy;tj=1;var e=vt(),t=pn(),n=Oz().positionX;iy=s;function s(a){a=t.asNonCompoundGraph(a),o(a),e.forEach(n(a),function(l,u){a.node(u).x=l})}function o(a){var l=t.buildLayerMatrix(a),u=a.graph().ranksep,h=0;e.forEach(l,function(p){var f=e.max(e.map(p,function(g){return a.node(g).height}));e.forEach(p,function(g){a.node(g).y=h+f/2}),h+=f+u})}return iy}var oy,nj;function $z(){if(nj)return oy;nj=1;var e=vt(),t=vz(),n=yz(),s=xz(),o=pn().normalizeRanks,a=bz(),l=pn().removeEmptyRanks,u=_z(),h=kz(),p=Sz(),f=Iz(),g=Pz(),y=pn(),w=lr().Graph;oy=S;function S(L,q){var Z=q&&q.debugTiming?y.time:y.notime;Z("layout",function(){var se=Z(" buildLayoutGraph",function(){return O(L)});Z(" runLayout",function(){b(se,Z)}),Z(" updateInputGraph",function(){_(L,se)})})}function b(L,q){q(" makeSpaceForEdgeLabels",function(){A(L)}),q(" removeSelfEdges",function(){W(L)}),q(" acyclic",function(){t.run(L)}),q(" nestingGraph.run",function(){u.run(L)}),q(" rank",function(){s(y.asNonCompoundGraph(L))}),q(" injectEdgeLabelProxies",function(){D(L)}),q(" removeEmptyRanks",function(){l(L)}),q(" nestingGraph.cleanup",function(){u.cleanup(L)}),q(" normalizeRanks",function(){o(L)}),q(" assignRankMinMax",function(){H(L)}),q(" removeEdgeLabelProxies",function(){K(L)}),q(" normalize.run",function(){n.run(L)}),q(" parentDummyChains",function(){a(L)}),q(" addBorderSegments",function(){h(L)}),q(" order",function(){f(L)}),q(" insertSelfEdges",function(){Q(L)}),q(" adjustCoordinateSystem",function(){p.adjust(L)}),q(" position",function(){g(L)}),q(" positionSelfEdges",function(){$(L)}),q(" removeBorderNodes",function(){J(L)}),q(" normalize.undo",function(){n.undo(L)}),q(" fixupEdgeLabelCoords",function(){B(L)}),q(" undoCoordinateSystem",function(){p.undo(L)}),q(" translateGraph",function(){C(L)}),q(" assignNodeIntersects",function(){X(L)}),q(" reversePoints",function(){ne(L)}),q(" acyclic.undo",function(){t.undo(L)})}function _(L,q){e.forEach(L.nodes(),function(Z){var se=L.node(Z),fe=q.node(Z);se&&(se.x=fe.x,se.y=fe.y,q.children(Z).length&&(se.width=fe.width,se.height=fe.height))}),e.forEach(L.edges(),function(Z){var se=L.edge(Z),fe=q.edge(Z);se.points=fe.points,e.has(fe,"x")&&(se.x=fe.x,se.y=fe.y)}),L.graph().width=q.graph().width,L.graph().height=q.graph().height}var k=["nodesep","edgesep","ranksep","marginx","marginy"],N={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},j=["acyclicer","ranker","rankdir","align"],T=["width","height"],M={width:0,height:0},P=["minlen","weight","width","height","labeloffset"],I={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},F=["labelpos"];function O(L){var q=new w({multigraph:!0,compound:!0}),Z=Y(L.graph());return q.setGraph(e.merge({},N,G(Z,k),e.pick(Z,j))),e.forEach(L.nodes(),function(se){var fe=Y(L.node(se));q.setNode(se,e.defaults(G(fe,T),M)),q.setParent(se,L.parent(se))}),e.forEach(L.edges(),function(se){var fe=Y(L.edge(se));q.setEdge(se,e.merge({},I,G(fe,P),e.pick(fe,F)))}),q}function A(L){var q=L.graph();q.ranksep/=2,e.forEach(L.edges(),function(Z){var se=L.edge(Z);se.minlen*=2,se.labelpos.toLowerCase()!=="c"&&(q.rankdir==="TB"||q.rankdir==="BT"?se.width+=se.labeloffset:se.height+=se.labeloffset)})}function D(L){e.forEach(L.edges(),function(q){var Z=L.edge(q);if(Z.width&&Z.height){var se=L.node(q.v),fe=L.node(q.w),he={rank:(fe.rank-se.rank)/2+se.rank,e:q};y.addDummyNode(L,"edge-proxy",he,"_ep")}})}function H(L){var q=0;e.forEach(L.nodes(),function(Z){var se=L.node(Z);se.borderTop&&(se.minRank=L.node(se.borderTop).rank,se.maxRank=L.node(se.borderBottom).rank,q=e.max(q,se.maxRank))}),L.graph().maxRank=q}function K(L){e.forEach(L.nodes(),function(q){var Z=L.node(q);Z.dummy==="edge-proxy"&&(L.edge(Z.e).labelRank=Z.rank,L.removeNode(q))})}function C(L){var q=Number.POSITIVE_INFINITY,Z=0,se=Number.POSITIVE_INFINITY,fe=0,he=L.graph(),ye=he.marginx||0,Re=he.marginy||0;function Ue(De){var Ie=De.x,ke=De.y,ce=De.width,xe=De.height;q=Math.min(q,Ie-ce/2),Z=Math.max(Z,Ie+ce/2),se=Math.min(se,ke-xe/2),fe=Math.max(fe,ke+xe/2)}e.forEach(L.nodes(),function(De){Ue(L.node(De))}),e.forEach(L.edges(),function(De){var Ie=L.edge(De);e.has(Ie,"x")&&Ue(Ie)}),q-=ye,se-=Re,e.forEach(L.nodes(),function(De){var Ie=L.node(De);Ie.x-=q,Ie.y-=se}),e.forEach(L.edges(),function(De){var Ie=L.edge(De);e.forEach(Ie.points,function(ke){ke.x-=q,ke.y-=se}),e.has(Ie,"x")&&(Ie.x-=q),e.has(Ie,"y")&&(Ie.y-=se)}),he.width=Z-q+ye,he.height=fe-se+Re}function X(L){e.forEach(L.edges(),function(q){var Z=L.edge(q),se=L.node(q.v),fe=L.node(q.w),he,ye;Z.points?(he=Z.points[0],ye=Z.points[Z.points.length-1]):(Z.points=[],he=fe,ye=se),Z.points.unshift(y.intersectRect(se,he)),Z.points.push(y.intersectRect(fe,ye))})}function B(L){e.forEach(L.edges(),function(q){var Z=L.edge(q);if(e.has(Z,"x"))switch((Z.labelpos==="l"||Z.labelpos==="r")&&(Z.width-=Z.labeloffset),Z.labelpos){case"l":Z.x-=Z.width/2+Z.labeloffset;break;case"r":Z.x+=Z.width/2+Z.labeloffset;break}})}function ne(L){e.forEach(L.edges(),function(q){var Z=L.edge(q);Z.reversed&&Z.points.reverse()})}function J(L){e.forEach(L.nodes(),function(q){if(L.children(q).length){var Z=L.node(q),se=L.node(Z.borderTop),fe=L.node(Z.borderBottom),he=L.node(e.last(Z.borderLeft)),ye=L.node(e.last(Z.borderRight));Z.width=Math.abs(ye.x-he.x),Z.height=Math.abs(fe.y-se.y),Z.x=he.x+Z.width/2,Z.y=se.y+Z.height/2}}),e.forEach(L.nodes(),function(q){L.node(q).dummy==="border"&&L.removeNode(q)})}function W(L){e.forEach(L.edges(),function(q){if(q.v===q.w){var Z=L.node(q.v);Z.selfEdges||(Z.selfEdges=[]),Z.selfEdges.push({e:q,label:L.edge(q)}),L.removeEdge(q)}})}function Q(L){var q=y.buildLayerMatrix(L);e.forEach(q,function(Z){var se=0;e.forEach(Z,function(fe,he){var ye=L.node(fe);ye.order=he+se,e.forEach(ye.selfEdges,function(Re){y.addDummyNode(L,"selfedge",{width:Re.label.width,height:Re.label.height,rank:ye.rank,order:he+ ++se,e:Re.e,label:Re.label},"_se")}),delete ye.selfEdges})})}function $(L){e.forEach(L.nodes(),function(q){var Z=L.node(q);if(Z.dummy==="selfedge"){var se=L.node(Z.e.v),fe=se.x+se.width/2,he=se.y,ye=Z.x-fe,Re=se.height/2;L.setEdge(Z.e,Z.label),L.removeNode(q),Z.label.points=[{x:fe+2*ye/3,y:he-Re},{x:fe+5*ye/6,y:he-Re},{x:fe+ye,y:he},{x:fe+5*ye/6,y:he+Re},{x:fe+2*ye/3,y:he+Re}],Z.label.x=Z.x,Z.label.y=Z.y}})}function G(L,q){return e.mapValues(e.pick(L,q),Number)}function Y(L){var q={};return e.forEach(L,function(Z,se){q[se.toLowerCase()]=Z}),q}return oy}var ay,rj;function Lz(){if(rj)return ay;rj=1;var e=vt(),t=pn(),n=lr().Graph;ay={debugOrdering:s};function s(o){var a=t.buildLayerMatrix(o),l=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(u){l.setNode(u,{label:u}),l.setParent(u,"layer"+o.node(u).rank)}),e.forEach(o.edges(),function(u){l.setEdge(u.v,u.w,{},u.name)}),e.forEach(a,function(u,h){var p="layer"+h;l.setNode(p,{rank:"same"}),e.reduce(u,function(f,g){return l.setEdge(f,g,{style:"invis"}),g})}),l}return ay}var ly,sj;function qz(){return sj||(sj=1,ly="0.8.5"),ly}var cy,ij;function Dz(){return ij||(ij=1,cy={graphlib:lr(),layout:$z(),debug:Lz(),util:{time:pn().time,notime:pn().notime},version:qz()}),cy}var Fz=Dz();const oj=Vy(Fz),Bo=240,bu=130,Io=74,Qu=72,aj=Io+Qu;function zz(e,t){var s;let n=Bo;for(const o of e)n=Math.max(n,((s=t.get(o.id))==null?void 0:s.width)??Bo);return n}const AR=420,Bz=2;function al(e){var n;return((n=e.data)==null?void 0:n.sessionId)??"_default"}function Uz(e,t){return((t==null?void 0:t.get(e))??0)>0?AR:0}function Wz(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function ll(e,t,n){const s=t.get(e);return{w:((s==null?void 0:s.width)??Bo)+Uz(e,n),h:Math.max((s==null?void 0:s.height)??bu,Wz(e,n))}}function Hz(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function Gz(e,t,n,s,o,a){const l=new oj.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const u=e.filter(k=>!o.has(k)),h=new Set(u);for(const k of u){const{w:N,h:j}=ll(k,s,a);l.setNode(k,{width:N,height:j})}for(const k of t)h.has(k.source)&&h.has(k.target)&&l.setEdge(k.source,k.target);oj.layout(l);const p=new Map;let f=1/0,g=1/0,y=-1/0,w=-1/0;for(const k of u){const N=l.node(k);if(!N)continue;const j=s.get(k),T=(j==null?void 0:j.width)??Bo,M=(j==null?void 0:j.height)??bu,P=ll(k,s,a),I=N.x-P.w/2,F=N.y-P.h/2;p.set(k,{x:I,y:F}),I<f&&(f=I),F<g&&(g=F),I+T>y&&(y=I+T),F+M>w&&(w=F+M)}if(Number.isFinite(f)&&Number.isFinite(g))for(const[k,N]of p)p.set(k,{x:N.x-f,y:N.y-g});const S=Number.isFinite(y)?y-f:0,b=Number.isFinite(w)?w-g:0;let _=null;for(const k of e){const N=o.get(k);if(!N)continue;const j=s.get(k),T=(j==null?void 0:j.width)??Bo,M=(j==null?void 0:j.height)??bu;_=_===null?{minX:N.x,minY:N.y,maxX:N.x+T,maxY:N.y+M}:{minX:Math.min(_.minX,N.x),minY:Math.min(_.minY,N.y),maxX:Math.max(_.maxX,N.x+T),maxY:Math.max(_.maxY,N.y+M)}}return{positions:p,width:S,height:b,pinnedBox:_}}function Vz(e,t,n={}){const s=n.direction??"LR",o=n.pinned??new Map,a=n.measured??new Map,l=n.lanes,u=new Map;for(const k of e){const N=al(k),j=u.get(N);j?j.push(k.id):u.set(N,[k.id])}const p=Array.from(u.keys()).sort().map(k=>({sid:k,...Gz(u.get(k),t,s,a,o,l)})),f=zz(e,a),g=n.availableHeight&&n.availableHeight>0?n.availableHeight:Number.POSITIVE_INFINITY,y=k=>{const N=[[]];let j=0;for(const T of p)N.length<k&&j>0&&j+T.height>g&&(N.push([]),j=0),N[N.length-1].push(T),j+=T.height+aj;return N},w=k=>k.reduce((N,j)=>Math.max(N,j.width),0)+AR;let S=y(n.availableWidth?Bz:1);S.length>1&&S.reduce((N,j)=>N+w(j),0)+f*(S.length-1)>(n.availableWidth??0)&&(S=y(1));const b=new Map;let _=0;for(const k of S){const N=w(k);let j=0;for(const{positions:T,height:M,pinnedBox:P}of k){for(const[F,O]of T)b.set(F,{x:O.x+_,y:O.y+j});let I=j+M;P&&P.maxY>I&&P.minX<_+N&&_<P.maxX&&(I=P.maxY),j=I+aj}_+=N+f}return e.map(k=>{const N=o.get(k.id);if(N)return{...k,position:N};const j=b.get(k.id);return j?{...k,position:j}:k})}function Yz(e,t,n,s,o){const l=Io+Qu,u=60,h=w=>ll(w,s,o),p=new Map(e.map(w=>[w.id,al(w)])),f=[],g=e.map(w=>({id:w.id,pos:n.get(w.id)??t.get(w.id)})).filter(w=>w.pos!=null).sort((w,S)=>w.pos.y-S.pos.y||w.pos.x-S.pos.x||w.id.localeCompare(S.id)),y=[];for(const{id:w,pos:S}of g){const{w:b,h:_}=h(w),k=p.get(w)??"_default";if(n.has(w)){f.push({x:S.x,y:S.y,w:b,h:_,sid:k});continue}let N=S.y;for(let j=0;j<f.length+1;j++){const T=f.find(M=>{const P=M.sid===k?24:u,I=M.sid===k?24:l;return S.x<M.x+M.w+P&&M.x<S.x+b+P&&N<M.y+M.h+I&&M.y<N+_+I});if(!T)break;N=T.y+T.h+(T.sid===k?24:l)}N!==S.y&&(t.set(w,{x:S.x,y:N}),y.push(w)),f.push({x:S.x,y:N,w:b,h:_,sid:k})}return y}function Kz(e,t,n,s,o,a){const l=b=>ll(b,s,a),u=b=>n.get(b)??t.get(b),h=new Map;for(const b of e){if(!u(b.id))continue;const _=al(b),k=h.get(_);k?k.push(b):h.set(_,[b])}const p=new Set;for(const[b,_]of h)_.every(k=>o.has(k.id)&&!n.has(k.id))&&p.add(b);const f=new Map,g=[];for(const b of e){const _=u(b.id);if(!_)continue;const{w:k,h:N}=l(b.id),j=al(b);p.has(j)?(f.get(j)??f.set(j,[]).get(j)).push(b):g.push({x:_.x,y:_.y,w:k,h:N})}if(f.size===0)return[];const y=Io+Qu,w=(b,_,k,N)=>g.some(j=>b<j.x+j.w+Io&&j.x<b+k+Io&&_<j.y+j.h+y&&j.y<_+N+y),S=[];for(const b of[...f.keys()].sort()){const _=f.get(b);let k=1/0,N=1/0,j=-1/0,T=-1/0;for(const D of _){const H=u(D.id),{w:K,h:C}=l(D.id);k=Math.min(k,H.x),N=Math.min(N,H.y),j=Math.max(j,H.x+K),T=Math.max(T,H.y+C)}const M=j-k,P=T-N,I=[...new Set(g.map(D=>Math.round(D.x)))].sort((D,H)=>D-H),F=I.length?I:[k],O=[0,...g.map(D=>D.y+D.h+y)].sort((D,H)=>D-H);let A=null;e:for(const D of F)for(const H of O){if(H>=N)break;if(!w(D,H,M,P)){A={x:D,y:H};break e}}if(A){const D=A.x-k,H=A.y-N;for(const K of _){const C=u(K.id);t.set(K.id,{x:C.x+D,y:C.y+H})}S.push(b)}for(const D of _){const H=u(D.id),{w:K,h:C}=l(D.id);g.push({x:H.x,y:H.y,w:K,h:C})}}return S}function Xz(e,t,n,s,o,a=!1,l){const p=Io+Qu+1,f=8,g=1.75,y=200,w=.7,S=.01,b=A=>ll(A,s,l),_=A=>n.get(A)??t.get(A),k=new Map;for(const A of e){if(!_(A.id))continue;const D=al(A),H=k.get(D);H?H.push(A):k.set(D,[A])}const N=[],j=new Set,T=new Set,M=o.size===0;for(const A of[...k.keys()].sort()){const D=k.get(A);let H=1/0,K=1/0,C=-1/0,X=-1/0,B=!1;for(const Q of D){const $=_(Q.id),{w:G,h:Y}=b(Q.id);H=Math.min(H,$.x),K=Math.min(K,$.y),C=Math.max(C,$.x+G),X=Math.max(X,$.y+Y),n.has(Q.id)&&(B=!0)}const ne=C-H,J=X-K;T.add(A);const W=o.get(A);W&&(ne>W.w+f||J>W.h+f)&&j.add(A),o.set(A,{w:ne,h:J}),N.push({sid:A,members:D.map(Q=>Q.id),x:H,y:K,w:ne,h:J,anchored:B,mass:1})}for(const A of[...o.keys()])T.has(A)||o.delete(A);if(a||M)return[];let P=!1;for(let A=0;A<N.length&&!P;A++)for(let D=A+1;D<N.length;D++){const H=N[A],K=N[D];if(!(H.anchored&&K.anchored)&&Math.abs(H.x+H.w/2-(K.x+K.w/2))<(H.w+K.w)/2+61&&Math.abs(H.y+H.h/2-(K.y+K.h/2))<(H.h+K.h)/2+p){P=!0;break}}if(j.size===0&&!P)return[];if(j.size>0)for(const A of N)j.has(A.sid)&&(A.mass=8);else for(const A of N)A.mass=Math.max(1,A.w*A.h/(Bo*bu));const I=new Map(N.map(A=>[A.sid,A.x])),F=new Map(N.map(A=>[A.sid,A.y]));for(let A=0;A<y;A++){const D=new Map,H=new Map;let K=0;for(let C=0;C<N.length;C++)for(let X=C+1;X<N.length;X++){const B=N[C],ne=N[X];if(B.anchored&&ne.anchored)continue;const J=B.x+B.w/2,W=B.y+B.h/2,Q=ne.x+ne.w/2,$=ne.y+ne.h/2,G=(B.w+ne.w)/2+61-Math.abs(J-Q),Y=(B.h+ne.h)/2+p-Math.abs(W-$);if(G<=0||Y<=0)continue;const L=(Be,tt)=>!Be.anchored&&!(tt<0&&Be.x<=0),q=(Be,tt)=>!Be.anchored&&!(tt<0&&Be.y<=0),Z=(Be,tt,Ke)=>{const _t=Be===tt,Me=_t?B.sid<ne.sid?-1:1:Math.sign(Be-tt);return Ke(B,Me)||Ke(ne,-Me)?Me:_t&&(Ke(B,-Me)||Ke(ne,Me))?-Me:0},se=Z(J,Q,L),fe=Z(W,$,q),he=se!==0,ye=fe!==0;if(!he&&!ye)continue;const Re=he&&(!ye||G*g<Y),[Ue,De,Ie,ke]=Re?[se,G,D,L]:[fe,Y,H,q],ce=ke(B,Ue),xe=ke(ne,-Ue),we=B.mass,Ye=ne.mass,yt=ce?xe?Ye/(we+Ye):1:0,ct=xe?ce?we/(we+Ye):1:0,st=De*w;Ie.set(B.sid,(Ie.get(B.sid)??0)+Ue*st*yt),Ie.set(ne.sid,(Ie.get(ne.sid)??0)-Ue*st*ct),K+=st}for(const C of N)C.anchored||(C.x=Math.max(0,C.x+(D.get(C.sid)??0)),C.y=Math.max(0,C.y+(H.get(C.sid)??0)));if(K<S)break}const O=[];for(const A of N){const D=A.x-I.get(A.sid),H=A.y-F.get(A.sid);if(!(Math.abs(D)<1&&Math.abs(H)<1)){for(const K of A.members){if(n.has(K))continue;const C=t.get(K);C&&t.set(K,{x:C.x+D,y:C.y+H})}O.push(A.sid)}}return O}const Qz=600;function Uy(e,t){return!(e.exitAt!=null&&t-e.exitAt>Qz||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function Zz(e,t){const n=new Set;for(const s of e.agents.values())Uy(s,t)&&n.add(s.id);return n}function Jz(e,t,n=0){return e.right+n>t.left&&e.left-n<t.right&&e.bottom+n>t.top&&e.top-n<t.bottom}function eB(e,t,n=0){if(!e)return!1;for(const s of t)if(Jz(e,s,n))return!0;return!1}const MR="sessionGroup";function tB(e,t){var s;if(e.type===MR)return"transparent";const n=(s=e.data)==null?void 0:s.state;return t(n==="err"?"--err":n==="active"?"--inflight":"--ok")}const IR=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function lj(e){const t={};for(const n of IR)t[n]=e(n);return t}function nB(e){return t=>e[t]??""}function rB(e,t){return IR.every(n=>e[n]===t[n])}function sB(e){const t=new Set(e.pins),n=new Map,s=new Map;for(const[o,a]of e.positions)n.set(o,a),t.has(o)&&s.set(o,a);return{positions:n,pinned:s}}const iB=1200,oB=1e3;function cj(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<iB?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<oB}function uy({durationMs:e,documentHidden:t}){return t?!1:Number.isFinite(e)&&e>0}function aB(e,t,n){const s=e.x*t.zoom+t.x,o=e.y*t.zoom+t.y,a=(e.x+e.width)*t.zoom+t.x,l=(e.y+e.height)*t.zoom+t.y;return a>0&&s<n.width&&l>0&&o<n.height}function lB({pane:e,viewport:t,boxes:n}){if(!e||!(e.width>0)||!(e.height>0)||!Number.isFinite(t.zoom)||t.zoom<=0||!Number.isFinite(t.x)||!Number.isFinite(t.y))return!1;let s=!1;for(const o of n)if(s=!0,aB(o,t,e))return!1;return s}const cB="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",dy="click for what's new";function uB(e){if(e.checkDisabled)return`${cB} · ${dy}`;if(e.checking)return`Asking npm for the newest release… · ${dy}`;const t=e.latest?`npm has v${e.latest}`:e.latestPending?`npm's latest tag names v${e.latestPending}, which it cannot serve yet`:"npm not reached yet",n=e.checkedAgo?` · checked ${e.checkedAgo}`:"";return`${t}${n} · re-checked periodically · ${dy}, and to check npm now`}function dB(e){const t=`Version v${e.running}, show what's new`;return e.checkDisabled?`${t} — update checks are off`:e.checking?`${t} — checking npm for a newer release`:`${t} and check npm for a newer release`}function fB(e){const t=e.kind==="restart"?`v${e.to} is installed and waiting for a restart`:`v${e.to} is available on npm`,n=e.open?"show what's new":"show what's new and the notice";return`Version v${e.from}, ${t} — ${n}`}function hB(e){if(e==null)return{kind:"unknown",lead:"No data yet. Start a Claude Code or Codex session — it appears here as soon as the deck sees its first event.",workspace:null,tail:""};const t=e.trim();return t===""?{kind:"machine",lead:"No data yet. Start a Claude Code or Codex session anywhere on this machine — this deck is unscoped and captures every workspace.",workspace:null,tail:""}:{kind:"scoped",lead:"No data yet. This deck only captures sessions running under",workspace:t,tail:" — start one there, or restart it without --workspace/--scope to watch the whole machine."}}const Wy={kind:"assumed",claude:!0,codex:!0};function pB(e){if(!e||typeof e!="object")return Wy;const t=e.providers;if(!t||typeof t!="object")return Wy;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function _u(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const uj=99;function mB(e){const t=Math.max(0,Math.floor(e));return t>uj?`${uj}+`:String(t)}const gB="Pause the canvas";function vB(e){if(!e.paused)return"Pause live updates — events keep arriving and are applied when you resume (Space)";const t=Math.max(0,Math.floor(e.dropped??0));return t>0?`The pause is full — ${_u(e.held)} held and ${t} older ${t===1?"one":"ones"} already dropped. Resume to follow the canvas again (Space)`:e.held<=0?"Nothing has arrived since you paused. Resume to follow the canvas again (Space)":`${_u(e.held)} arrived while paused and will be applied in order when you resume (Space)`}function yB(e){return e.connected||!e.paused?null:"The canvas is paused as well — Space resumes it, but nothing new arrives until the stream is back."}const OR="paused · full",wB=(e,t)=>t>0?OR:e>0?`paused · ${mB(e)}`:"paused";function xB(e){const t=Math.max(0,Math.floor(e.dropped??0));return e.connected?e.paused?{tone:"paused",resting:!1,label:wB(e.held,t),widest:OR,title:t>0?`Connected — the pause is full at ${_u(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up (Space)`:e.held>0?`Connected — ${_u(e.held)} held until you resume (Space)`:"Connected — updates held until you resume (Space)"}:{tone:"live",resting:!0,label:"live",widest:"live",title:"Receiving events"}:{tone:"dead",resting:!1,label:"offline",widest:"offline",title:e.paused?"SSE disconnected — and the canvas is paused, so resuming will not bring events back until it reconnects":"SSE disconnected"}}function dj(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const bB={agent:UL,sessionGroup:i3},PR="react-flow__node";function fj(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,PR))===!0}function _B(e){try{const t=document.querySelector(`.${PR}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}const kB=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(","),SB=420,Jc=18,NB=200,EB=5*6e4,jB=6,CB=2*6e4,hj=400,Hw="agent-dag.layout",Gw="agent-dag.viewport",$R="agent-dag.summariesDismissed",LR="agent-dag.sessionListOpen",qR="agent-dag.detailOpen",DR="agent-dag.usagePanelOpen",pj="agent-dag.accountsPanelOpen",fy="agent-dag.versionNoticeDismissed",mj="agent-dag.oldNameNoticeDismissed",TB=15*6e4,hy={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:"},gj="agent-dag.autoRestart",vj="agent-dag.bundleReloadedFor";function RB(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(LR)==="1"}catch{return!1}}function AB(e){if(!(typeof window>"u"))try{window.localStorage.setItem(LR,e?"1":"0")}catch{}}function MB(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(qR)==="1"}catch{return!1}}function IB(e){if(!(typeof window>"u"))try{window.localStorage.setItem(qR,e?"1":"0")}catch{}}function OB(){const e=Mu(DR);return e===null?!0:e==="1"}function PB(e){if(!(typeof window>"u"))try{window.localStorage.setItem(DR,e?"1":"0")}catch{}}function $B(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem($R);if(!e)return new Set;const t=JSON.parse(e);return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function yj(e){if(!(typeof window>"u"))try{const t=Array.from(e),n=t.length>200?t.slice(-200):t;window.localStorage.setItem($R,JSON.stringify(n))}catch{}}function LB(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const t=window.localStorage.getItem(Hw);if(!t)return e;const n=JSON.parse(t);if(!("v"in n)){const o=Object.entries(n).filter(([,a])=>a&&typeof a.x=="number"&&typeof a.y=="number");return{positions:o,pins:o.map(([a])=>a)}}return{positions:Object.entries(n.positions??{}).filter(([,o])=>o&&typeof o.x=="number"&&typeof o.y=="number"),pins:Array.isArray(n.pins)?n.pins:[]}}catch{return e}}function py(e,t){if(!(typeof window>"u"))try{const n={};for(const[s,o]of e)n[s]=o;for(const[s,o]of t)n[s]=o;window.localStorage.setItem(Hw,JSON.stringify({v:2,positions:n,pins:Array.from(t.keys())}))}catch{}}function qB(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Gw);if(!e)return null;const t=JSON.parse(e);return typeof(t==null?void 0:t.x)!="number"||typeof(t==null?void 0:t.y)!="number"||typeof(t==null?void 0:t.zoom)!="number"?null:t}catch{return null}}function DB(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Gw,JSON.stringify(e))}catch{}}function wj(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Hw)}catch{}try{window.localStorage.removeItem(Gw)}catch{}}}function FB(e,t){const n=e.agents.get(t);if(!n)return;const s=[];for(const f of e.agents.values())f.sessionId===t&&s.push(f);const o={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:t,label:n.label,cwd:n.cwd,startedAt:n.startedAt,endedAt:n.endedAt,model:n.model,agents:s.map(f=>({id:f.id,kind:f.kind,label:f.label,parentId:f.parentId,state:f.state,startedAt:f.startedAt,endedAt:f.endedAt,model:f.model,cwd:f.cwd,usage:f.usage,prompts:f.prompts,tools:f.tools.map(g=>({id:g.id,name:g.name,inputPreview:g.inputPreview,startedAt:g.startedAt,endedAt:g.endedAt,ok:g.ok,errorPreview:g.errorPreview,usage:g.usage}))}))},a=JSON.stringify(o,null,2),l=new Blob([a],{type:"application/json"}),u=URL.createObjectURL(l),h=document.createElement("a"),p=(n.label||"session").replace(/[^a-z0-9._-]/gi,"_");h.href=u,h.download=`${zt}-${p}-${t.slice(0,8)}.json`,document.body.appendChild(h),h.click(),document.body.removeChild(h),setTimeout(()=>URL.revokeObjectURL(u),1e3)}const Hy={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Gy={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},FR=iT;function zB(e,t,n,s,o,a,l,u,h,p,f,g,y,w,S,b,_,k){const N=[],j=[];for(const A of e.agents.values()){if(!_.has(A.id))continue;const D=A.exitAt!=null,H=b!=null&&!b.has(A.id),K=[D?"rf-exiting":"",H?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,C=a.get(A.id);if(N.push({id:A.id,type:"agent",position:{x:0,y:0},data:{...A,now:t,onOpenContext:k},className:K,...C?{width:C.width,height:C.height}:null}),A.parentId&&_.has(A.parentId)){const X=hw(A.sessionId),B=D,ne=S.size>0&&(S.has(A.id)||S.has(A.parentId)),J=b!=null&&!b.has(A.id)&&!b.has(A.parentId),W=A.state==="active"?2:1.5,Q=ne?W+1.5:W,$=B?.2:J?.12:1,G=["sess-edge",A.state==="active"?"sess-live":"sess-idle",B?"rf-edge-exiting":"",ne?"rf-edge-selected":""].filter(Boolean).join(" ");j.push({id:`e:${A.parentId}->${A.id}`,source:A.parentId,target:A.id,animated:(A.state==="active"||ne)&&!B,type:"smoothstep",style:{"--session-hue":X,strokeWidth:Q,opacity:$,transition:"var(--edge-transition)"},className:G})}}const T=new Map;for(const A of e.agents.values())A.tools.length>0&&T.set(A.id,Math.min(4,A.tools.length));const M=`${y}#lanes:${Hz(T)}`,P=N.filter(A=>DD(A.id,o,f,g));if(P.length>0||M!==w.current){if(P.length>0){const A=Vz(N,j,{direction:"LR",pinned:o,measured:a,availableWidth:n,availableHeight:s,lanes:T});for(const D of A)CT(D.id,f,g)&&zD(D.id,D.position,f,g);Kz(N,f,o,a,new Set(P.map(D=>D.id)),T)}Yz(N,f,o,a,T),w.current=M}const I=Xz(N,f,o,a,l,!h||p,T);I.length>0&&u(I),Vc(f,e.agents),Vc(g,e.agents),Vc(o,e.agents),Vc(a,$D(e.agents.values()));const F=[];let O=!1;for(const A of N){let D=o.get(A.id)??f.get(A.id);D||(D=FD(A.id,f,g),O=!0),F.push({...A,position:D})}return O&&(w.current=""),{nodes:F,edges:j}}function BB(){return d.jsx(dw,{children:d.jsx(UB,{})})}function UB(){var us,ql,Ys,Dl;const e=hl(),t=Tt(),n=E.useState(Ay)[0],s=E.useRef(n),[,o]=E.useState(0),a=E.useCallback(()=>o(z=>z+1),[]),[l,u]=E.useState(()=>new Set),[h,p]=E.useState(null),[f,g]=E.useState(null),y=E.useCallback((z,V)=>{u(ae=>{if(!V)return new Set([z]);const de=new Set(ae);return de.has(z)?de.delete(z):de.add(z),de}),p(ae=>V&&ae===z?ae:z)},[]),w=E.useCallback(()=>{u(new Set),p(null)},[]),[S,b]=E.useState(null),[_,k]=E.useState(null),N=E.useCallback(z=>k(z),[]),[j,T]=E.useState(!1),[M,P]=E.useState(!1),I=E.useState($B)[0],[F,O]=E.useState(RB);E.useEffect(()=>{AB(F)},[F]);const[A,D]=E.useState(MB);E.useEffect(()=>{IB(A)},[A]);const[H,K]=E.useState(OB);E.useEffect(()=>{PB(H)},[H]);const[C,X]=E.useState(()=>{try{const z=window.localStorage.getItem(pj);return z===null?!0:z==="1"}catch{return!0}});E.useEffect(()=>{try{window.localStorage.setItem(pj,C?"1":"0")}catch{}},[C]);const[B,ne]=E.useState(null);E.useEffect(()=>{let z=null;try{z=localStorage.getItem("agent-dag.sound")}catch{}ne(z===null?!0:z==="on")},[]);const J=E.useCallback(()=>{ne(z=>{var ae;const V=z!==!0;try{localStorage.setItem("agent-dag.sound",V?"on":"off")}catch{}return V&&((ae=Re.current)==null||ae.unlock()),V})},[]),W=E.useCallback(z=>{J()},[J]),Q=E.useRef(W);Q.current=W;const $=E.useRef(B);$.current=B;const[G,Y]=E.useState(()=>cD(Mu)),L=E.useRef(G);L.current=G;const q=E.useRef(null),Z=E.useCallback((z,V=!1)=>{var ae,de;if((ae=Re.current)==null||ae.unlock(),q.current!==null&&clearTimeout(q.current),q.current=null,!V){(de=Re.current)==null||de.play(z,!0);return}q.current=setTimeout(()=>{var be;q.current=null,(be=Re.current)==null||be.play(z,!0)},sD)},[]),se=E.useCallback((z,V)=>{Y(ae=>{const de={level:ol(V.level??ae[z].level),figure:kT(z,V.figure??ae[z].figure)};try{localStorage.setItem(NT[z],String(de.level)),localStorage.setItem(ET[z],de.figure)}catch{}return{...ae,[z]:de}}),Z(z,!0)},[Z]);E.useEffect(()=>()=>{q.current!==null&&clearTimeout(q.current)},[]);const[fe,he]=E.useState(!1),ye=E.useRef(null),Re=E.useRef(null),[Ue,De]=E.useState("locked");E.useEffect(()=>{const z=fD({enabled:()=>$.current===!0,prefs:()=>L.current,onState:De});Re.current=z,De(z.state());const V=()=>z.unlock();return window.addEventListener("pointerdown",V,{once:!0,capture:!0}),window.addEventListener("keydown",V,{once:!0,capture:!0}),()=>{window.removeEventListener("pointerdown",V,{capture:!0}),window.removeEventListener("keydown",V,{capture:!0})}},[]);const[Ie,ke]=E.useState(!1),[ce,xe]=E.useState(null),[we,Ye]=E.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(fy)??""}catch{return""}}),[yt,ct]=E.useState(!1),st=E.useRef(0),[Be,tt]=E.useState(!1),Ke=E.useCallback((z=!1)=>(z&&(st.current=Date.now(),tt(!0)),fetch(z?"/api/version?refresh=1":"/api/version").then(V=>V.ok?V.json():null).then(V=>{V&&xe(V)}).catch(()=>{}).finally(()=>{z&&tt(!1)})),[]),_t=E.useCallback(()=>{Ke(Date.now()-st.current>=TB)},[Ke]);E.useEffect(()=>{Ke();const z=window.setInterval(_t,5*6e4),V=()=>{document.visibilityState==="visible"&&_t()};return document.addEventListener("visibilitychange",V),()=>{window.clearInterval(z),document.removeEventListener("visibilitychange",V)}},[Ke,_t]),E.useEffect(()=>{Ie&&Ke()},[Ie,Ke]);const Me=(ce==null?void 0:ce.notice)??null,[it,At]=E.useState(null),oe=E.useRef(!1);E.useEffect(()=>{if(oe.current)return;const z=kD(),V=SD(z),ae=jD({stored:V,running:(ce==null?void 0:ce.running)??null,notes:I1,remembers:ND(z)});ae.reason!=="no-version"&&(oe.current=!0,ae.record&&ED(z,ae.record),ae.show.length&&At({entries:ae.show,since:V,firstRun:ae.reason==="welcome"}))},[ce==null?void 0:ce.running]);const Pe=(ce==null?void 0:ce.running)??"3.2.0",qe=E.useMemo(()=>jT(I1,null,Pe),[Pe]),Ne=E.useCallback(()=>{At({entries:qe,since:null,firstRun:!1})},[qe]),[We,Et]=E.useState(null),[et,Ce]=E.useState(Wy);E.useEffect(()=>{let z=!1;return fetch("/api/health").then(V=>V.ok?V.json():null).then(V=>{z||(Ce(pB(V)),!(!V||typeof V.workspace!="string")&&Et(V.workspace))}).catch(()=>{}),()=>{z=!0}},[Ie]);const wt=E.useRef(et);wt.current=et;const at=Me?`${Me.kind}:${Me.to}`:"",kt=Me!=null&&we!==at,Sn=E.useCallback(()=>{Ye("");try{window.localStorage.setItem(fy,"")}catch{}},[]),Fn=E.useCallback(()=>{if(Me){Ye(at);try{window.localStorage.setItem(fy,at)}catch{}}},[Me,at]),[Nn,Ni]=E.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(mj)??""}catch{return""}}),mn=ce!=null&&ce.invokedAs&&ce.invokedAs!==zt?ce.invokedAs:null,Ei=mn!=null&&Nn!==mn,ji=E.useCallback(()=>{if(mn){Ni(mn);try{window.localStorage.setItem(mj,mn)}catch{}}},[mn]),Bt=((us=ce==null?void 0:ce.upgrade)==null?void 0:us.state)??"idle",jr=Fq(ce==null?void 0:ce.upgrade),zn=E.useRef(!1),Is=E.useCallback(async()=>{if(or(zn.current||Bt==="running")){zn.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await Ke(),zn.current=!1}},[Bt,Ke]);E.useEffect(()=>{if(Bt!=="running")return;const z=window.setInterval(Ke,3e3);return()=>window.clearInterval(z)},[Bt,Ke]);const Cr=E.useCallback(async()=>{var ae;const z=ce==null?void 0:ce.command;if(!z)return;let V=!1;try{V=await Promise.race([((ae=navigator.clipboard)==null?void 0:ae.writeText(z).then(()=>!0))??Promise.resolve(!1),new Promise(de=>window.setTimeout(()=>de(!1),500))])}catch{V=!1}if(!V)try{const de=document.createElement("textarea");de.value=z,de.setAttribute("readonly",""),de.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(de),de.select(),V=document.execCommand("copy"),de.remove()}catch{V=!1}V&&(ct(!0),window.setTimeout(()=>ct(!1),1600))},[ce==null?void 0:ce.command]),Ko=E.useCallback(()=>{O(z=>(z||X(!1),!z))},[]),dr=E.useCallback(()=>{X(z=>(z||O(!1),!z))},[]),[Tr,fr]=E.useState(!1),[Jr,Ci]=E.useState(!1),[Ti,Ri]=E.useState(()=>{try{return Number(localStorage.getItem(L1))||0}catch{return 0}}),[En,Ai]=E.useState([]),[Rr,Mi]=E.useState(!1);E.useEffect(()=>{let z=!0;const V=()=>{fetch("/api/browser-watch").then(de=>de.ok?de.json():null).then(de=>{var be;!z||!(de!=null&&de.ok)||(Ai(de.episodes??[]),Mi(((be=de.settings)==null?void 0:be.enabled)===!0))}).catch(()=>{})};V();const ae=setInterval(V,5*6e4);return()=>{z=!1,clearInterval(ae)}},[]);const Bn=E.useMemo(()=>g5(En,Ti).length,[En,Ti]),[Ii,Os]=E.useState(0),Ps=E.useRef(null),[Oi,Pi]=E.useState(!1),nt=E.useRef(null),[Xo,es]=E.useState(0),Gt=E.useState(()=>GD({protect:z=>nL(s.current,z)}))[0],[Un,$i]=E.useState(!1),ts=E.useCallback(()=>{const z=Gt.paused&&Gt.dropped>0,V=Gt.setPaused(!Gt.paused);z&&rL(s.current);for(const ae of V)s.current=Gb(s.current,ae);$i(Gt.paused)},[Gt]),[ht,sn]=E.useState(Date.now()),[Wn,gn]=E.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(gj)!=="0"}catch{return!0}}),Zu=E.useCallback(()=>{gn(z=>{const V=!z;try{window.localStorage.setItem(gj,V?"1":"0")}catch{}return V})},[]),[Ar,Li]=E.useState(!1),[qi,Di]=E.useState("restart"),[ns,$s]=E.useState(null),rs=E.useRef(!1),kl=E.useRef(null),Fi=E.useRef(0),Ls=E.useCallback(async z=>{if(!or(rs.current))return;const V=(z==null?void 0:z.upgrade)===!0;rs.current=!0,kl.current=jr;const ae=++Fi.current;Di(V?"npx":"restart"),Li(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(Me==null?void 0:Me.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:V})})}catch{}window.setTimeout(()=>{if(Fi.current===ae&&rs.current){rs.current=!1,Li(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},V?18e4:3e4)},[Me==null?void 0:Me.to,jr]),zi=E.useRef(null);E.useEffect(()=>{let z=!1;for(const ae of s.current.agents.values())if(ae.state==="active"){z=!0;break}const V=Bq({enabled:Wn,kind:Me==null?void 0:Me.kind,canRestart:(ce==null?void 0:ce.canRestart)===!0,busy:z,idleSince:zi.current,now:ht});zi.current=V.idleSince,V.restart&&Ls()},[Wn,Me==null?void 0:Me.kind,ce==null?void 0:ce.canRestart,ht,Ls]),E.useEffect(()=>{const z=ce==null?void 0:ce.running;let V=null,ae=null;try{V=window.sessionStorage.getItem("agent-dag.restartPending"),ae=window.sessionStorage.getItem(vj)}catch{return}const de=Dq({bundle:"3.2.0",running:z,pending:V,lastTried:ae});if(de==="reload"){try{window.sessionStorage.setItem(vj,z??"")}catch{return}window.location.reload();return}if(de!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}rs.current=!1,Li(!1),$s(z??null);const be=window.setTimeout(()=>$s(null),6e3);return()=>window.clearTimeout(be)},[ce==null?void 0:ce.running]),E.useEffect(()=>{if(Ar&&zq({asked:kl.current,reported:jr})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}rs.current=!1,Li(!1)}},[Ar,jr]);const ss=E.useState(()=>sB(LB()))[0],Jt=E.useRef(ss.pinned),is=E.useRef(null),Xe=E.useState(()=>qB())[0],[Qo,Sl]=E.useState(()=>new Set),[Mr,Zo]=E.useState(YD),[Hn,Nl]=E.useState(()=>lj(dj)),Bi=E.useMemo(()=>nB(Hn),[Hn]),Ui=E.useCallback(z=>tB(z,Bi),[Bi]),hr=E.useMemo(()=>({background:Hn["--panel"],border:`1px solid ${Hn["--line"]}`,borderRadius:8}),[Hn]),[Gn,pr]=E.useState(!1);E.useEffect(()=>{document.documentElement.dataset.theme=Mr;try{window.localStorage.setItem(TT,Mr)}catch{}Nl(z=>{const V=lj(dj);return rB(z,V)?z:V})},[Mr]);const vn=E.useCallback((z,V)=>{if(uy({durationMs:V,documentHidden:document.hidden})){e.setViewport(z,{duration:V});return}const{d3Zoom:ae,d3Selection:de}=t.getState(),be=de==null?void 0:de.property("__zoom");if(ae&&de&&be&&be.k>0&&z.zoom>0){ae.transform(de,be.scale(z.zoom/be.k).translate((z.x-be.x)/z.zoom,(z.y-be.y)/z.zoom));return}e.setViewport(z,{duration:0})},[e,t]),Vn=E.useRef(null);E.useEffect(()=>{if(!Xe)return;const z=window.setTimeout(()=>{try{vn(Xe,0)}catch{}Kn.current=Date.now()},60);return()=>window.clearTimeout(z)},[vn,Xe]);const Yn=E.useRef(!0);E.useEffect(()=>{const z=new EventSource("/events"),V=WD(a,{now:()=>Date.now(),setTimeout:(ae,de)=>window.setTimeout(ae,de),clearTimeout:ae=>window.clearTimeout(ae)});return z.addEventListener("open",()=>{ke(!0),pr(!0)}),z.addEventListener("error",()=>ke(!1)),z.addEventListener("replay-end",()=>{Yn.current=!1,V.flush()}),z.addEventListener("hook",ae=>{var de;try{const be=JSON.parse(ae.data);if(!Gt.accept(be))return;s.current=Gb(s.current,be);const je=be.replay===!0||Yn.current||Date.now()-be.receivedAt>3e4;je?V.replay():V.live();const ze=dD(be,je);ze&&((de=Re.current)==null||de.play(ze))}catch{}}),()=>{z.close(),V.cancel()}},[a]),E.useEffect(()=>{const z=setInterval(()=>{const V=Date.now();sn(V);let ae=sL(s.current,V,Hb);iL(s.current,V,Hb)&&(ae=!0),eL(s.current,V,NB,EB)&&(ae=!0),tL(s.current,V,jB,CB)&&(ae=!0),u(de=>PD(de,s.current.agents)),p(de=>de!=null&&!s.current.agents.has(de)?null:de),ae&&a()},250);return()=>clearInterval(z)},[a]);const Jo=E.useRef(null),Kn=E.useRef(0),qs=420,jn=E.useCallback((z=500)=>{try{const je=document.querySelector(".canvas-wrap"),ze=Array.from(document.querySelectorAll(".react-flow__node")).filter(ut=>ut.offsetWidth>0);if(!je||ze.length===0)return;const Ze=je.getBoundingClientRect(),pt=e.getViewport();if(!Number.isFinite(pt.zoom)||pt.zoom<=0)return;const ot=ut=>(ut-Ze.left-pt.x)/pt.zoom,on=ut=>(ut-Ze.top-pt.y)/pt.zoom,Yt=ze.map(ut=>ut.getBoundingClientRect()),ds=Math.min(...Yt.map(ut=>ot(ut.left))),Fl=Math.max(...Yt.map(ut=>ot(ut.right))),ha=Math.min(...Yt.map(ut=>on(ut.top))),zl=Math.max(...Yt.map(ut=>on(ut.bottom))),pa=Fl-ds,Ks=zl-ha;if(!(pa>0&&Ks>0))return;const Xs=Math.max(.2,Math.min(1,(Ze.width-160)/(pa+qs)*.86,(Ze.height-160)/Ks*.86)),Qs={x:80-ds*Xs,y:Math.max(80,(Ze.height-Ks*Xs)/2)-ha*Xs,zoom:Xs};vn(Qs,z),Kn.current=Date.now(),Vn.current=uy({durationMs:z,documentHidden:document.hidden})?{target:Qs,until:Date.now()+z+60}:null,window.setTimeout(()=>{var ut;try{((ut=Vn.current)==null?void 0:ut.target)===Qs&&(Vn.current=null);const Zi=e.getViewport();(Math.abs(Zi.zoom-Xs)>.01||Math.abs(Zi.x-Qs.x)>2)&&vn(Qs,0)}catch{}},z+60)}catch{}},[e,vn]);E.useEffect(()=>{const z=()=>{if(!document.hidden)return;const V=Vn.current;if(Vn.current=null,!(!V||Date.now()>V.until)){try{vn(V.target,0)}catch{}Kn.current=Date.now()}};return document.addEventListener("visibilitychange",z),()=>document.removeEventListener("visibilitychange",z)},[vn]);const Wi=E.useRef(""),os=E.useRef(null),ea=E.useRef(0),Hi=E.useCallback(()=>{ea.current=Date.now()},[]),Ir=E.useRef(null),as=E.useRef(0),mr=E.useCallback(()=>{as.current=Date.now()},[]),Ds=E.useCallback(z=>({hasSourceEvent:!!z,at:Date.now(),lastDeckFitAt:Kn.current,lastCanvasInputAt:as.current}),[]),ta="agent-dag.autoFitDisabled",El=E.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(ta)==="1"}catch{return!1}})[0],gr=E.useRef(El),[Fs,Gi]=E.useState(El),Vi=E.useCallback(()=>{if(!gr.current){gr.current=!0,Gi(!0);try{window.localStorage.setItem(ta,"1")}catch{}}},[]),vr=E.useCallback(()=>{gr.current=!1,Gi(!1);try{window.localStorage.removeItem(ta)}catch{}jn(400)},[e,jn]);E.useEffect(()=>{const z=setInterval(()=>{if(gr.current||Date.now()-ea.current<800)return;const V=s.current,ae=Date.now(),de=[];for(const je of V.agents.values())Uy(je,ae)&&de.push({id:je.id});if(de.length===0)return;const be=[];for(const{id:je}of de){const ze=Xn.current.get(je),Ze=Jt.current.get(je)??Mt.current.get(je);!ze||!Ze||be.push({x:Ze.x,y:Ze.y,width:ze.width,height:ze.height})}lB({pane:Ir.current,viewport:e.getViewport(),boxes:be})&&jn(600)},1500);return()=>clearInterval(z)},[e]);const zs=E.useRef(!1),Xn=E.useRef(new Map),na=E.useRef(0),Yi=E.useCallback(z=>{const V=Xn.current;let ae=!1;for(const de of z.nodeInternals.values()){const be=de.width,je=de.height;if(be==null||je==null)continue;const ze=V.get(de.id);ze?(Math.abs(ze.height-je)>4||Math.abs(ze.width-be)>4)&&(V.set(de.id,{width:be,height:je}),ae=!0):(V.set(de.id,{width:be,height:je}),ae=!0)}return ae&&(na.current+=1),na.current},[]),Bs=rt(Yi),[ra,en]=E.useState(0);E.useEffect(()=>{let z=0;const V=()=>{const de=Xn.current;let be=!1;for(const je of document.querySelectorAll(".react-flow__node[data-id]")){const ze=je.getAttribute("data-id");if(!ze)continue;const Ze=je.offsetWidth,pt=je.offsetHeight;if(!Ze||!pt)continue;const ot=de.get(ze);(!ot||Math.abs(ot.width-Ze)>4||Math.abs(ot.height-pt)>4)&&(de.set(ze,{width:Ze,height:pt}),be=!0)}be&&en(je=>je+1)};if(zs.current)return;let ae=0;return document.visibilityState==="hidden"?ae=window.setTimeout(V,32):z=requestAnimationFrame(V),()=>{cancelAnimationFrame(z),window.clearTimeout(ae)}});const Mt=E.useRef(ss.positions),sa=E.useRef(new Set),Or=E.useRef(""),ls=E.useMemo(()=>{const z=[];for(const V of s.current.agents.values())Uy(V,ht)&&z.push(V.id+(V.parentId?`>${V.parentId}`:""));return z.sort(),`${z.join("|")}#sv${Bs}.${ra}`},[s.current,s.current.revision,ht,Bs,ra]),Pr=E.useRef(null);E.useEffect(()=>(Pr.current!=null&&window.clearTimeout(Pr.current),Pr.current=window.setTimeout(()=>{py(Mt.current,Jt.current)},1500),()=>{Pr.current!=null&&window.clearTimeout(Pr.current)}),[ls]),E.useEffect(()=>{if(Wi.current===ls)return;const z=Wi.current;if(Wi.current=ls,!z||gr.current)return;Date.now()-Kn.current>1200&&jn(400),Jo.current&&window.clearTimeout(Jo.current),Jo.current=window.setTimeout(()=>{gr.current||jn(500)},280)},[ls,e,jn]);const Us=E.useMemo(()=>qD(s.current,l),[s.current,s.current.revision,l]),$r=E.useMemo(()=>Zz(s.current,ht),[s.current,s.current.revision,ht]),Ws=E.useRef(null),[Hs,jl]=E.useState({w:0,h:0});E.useEffect(()=>{const z=Ws.current;if(!z||typeof ResizeObserver>"u")return;const V=new ResizeObserver(ae=>{var be;const de=(be=ae[0])==null?void 0:be.contentRect;de&&(Ir.current={width:de.width,height:de.height},jl(je=>Math.abs(je.w-de.width)>40||Math.abs(je.h-de.height)>40?{w:de.width,h:de.height}:je))});return V.observe(z),Ir.current={width:z.clientWidth,height:z.clientHeight},jl({w:z.clientWidth,h:z.clientHeight}),()=>V.disconnect()},[]);const Ju=E.useCallback(z=>{var ae,de;const V=z.target;!(V!=null&&V.closest)||V.closest(kB)!==z.currentTarget||(z.preventDefault(),(de=(ae=document.activeElement)==null?void 0:ae.blur)==null||de.call(ae))},[]),ed=E.useRef(new Map),[Ki,td]=E.useState(!1);E.useEffect(()=>{const z=window.setTimeout(()=>td(!0),2500);return()=>window.clearTimeout(z)},[]);const[nd,ia]=E.useState(!1),yr=E.useRef(null),[oa,aa]=E.useState(!1),rd=E.useCallback(()=>{yr.current&&(window.clearTimeout(yr.current),yr.current=null),ia(!1)},[]),sd=E.useCallback(z=>{z.length!==0&&queueMicrotask(()=>{ia(!0),yr.current&&window.clearTimeout(yr.current),yr.current=window.setTimeout(()=>ia(!1),SB+80)})},[]);E.useEffect(()=>()=>{yr.current&&window.clearTimeout(yr.current)},[]);const Cl=Hs.w>0?Hs.w*.92:0,Tl=Hs.h>0?Hs.h:0,{nodes:Cn,edges:id}=E.useMemo(()=>zB(s.current,ht,Cl,Tl,Jt.current,Xn.current,ed.current,sd,Ki,oa,Mt.current,sa.current,ls,Or,l,Us,$r,N),[s.current,s.current.revision,ht,Cl,Tl,Ki,oa,ls,l,Us,$r,N,Ii]),Rl=E.useMemo(()=>{const z=new Map;for(const ae of Cn){const de=ae.data;if(!(de!=null&&de.sessionId)||de.exitAt!=null)continue;const be=ae.width,je=ae.height;if(be==null||je==null)continue;const ze=ae.position.x,Ze=ae.position.y,pt=ze+be,ot=Ze+je,on=z.get(de.sessionId);on?(on.minX=Math.min(on.minX,ze),on.minY=Math.min(on.minY,Ze),on.maxX=Math.max(on.maxX,pt),on.maxY=Math.max(on.maxY,ot)):z.set(de.sessionId,{minX:ze,minY:Ze,maxX:pt,maxY:ot})}const V=[];for(const[ae,de]of z){const be=de.maxX-de.minX+Jc*2,je=de.maxY-de.minY+Jc*2;V.push({id:`group:${ae}`,type:MR,position:{x:de.minX-Jc,y:de.minY-Jc},data:{sessionId:ae,w:be,h:je},width:be,height:je,style:{width:be,height:je},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return V},[Cn,ht]),od=E.useMemo(()=>{const z=[...Rl,...Cn],V=nt.current;return!V||V.size===0?z:z.map(ae=>{const de=V.get(ae.id);return de?{...ae,position:de}:ae})},[Rl,Cn,Xo]),Gs=E.useMemo(()=>{const z=new Set;for(const V of s.current.agents.values())for(const ae of V.tools)z.add(FR(ae.name));return Object.keys(Hy).filter(V=>z.has(V))},[s.current,s.current.revision]);E.useEffect(()=>{if(Gs.length<=1){Pi(!1);return}let z=0;const V=()=>{const ae=Ps.current;if(ae&&!document.hidden){const de=ae.getBoundingClientRect(),be=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(ze=>ze.getBoundingClientRect()),je=eB(de,be,8);Pi(ze=>ze===je?ze:je)}z=window.setTimeout(V,300)};return V(),()=>window.clearTimeout(z)},[Gs.length]);const ad=E.useCallback(z=>{Sl(V=>{const ae=new Set(V);return ae.has(z)?ae.delete(z):ae.add(z),ae})},[]),tn=h?s.current.agents.get(h):null,la=f?Array.from(s.current.agents.values()).flatMap(z=>z.tools).find(z=>z.id===f)??null:null,Al=E.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}s.current=Ay(),Jt.current.clear(),Xn.current.clear(),Mt.current.clear(),Or.current="",wj(),w(),a()},[a,w]),Ml=E.useRef(j);Ml.current=j;const Il=E.useRef(M);Il.current=M;const ca=E.useRef(!1);ca.current=la!=null||Tr||_!=null||S!=null||Jr||M||it!=null;const cs=E.useCallback(z=>{const V=Uq(z,{confirmOpen:Ml.current,modalOpen:ca.current});V==="confirm"?T(!0):V==="clear"&&(T(!1),Al())},[Al]),Lr=E.useCallback(()=>{Jt.current.clear(),Mt.current.clear(),Or.current="",wj(),a(),window.setTimeout(()=>jn(500),80)},[a,e,jn]),Ol=E.useCallback(()=>jn(500),[jn]),Vs=E.useRef(Cn);Vs.current=Cn;const ua=E.useRef(h);ua.current=h;const Xi=E.useCallback(z=>{const V=Vs.current,ae=RD(V.map(je=>({id:je.id,x:je.position.x,y:je.position.y})),ua.current,z),de=ae?V.find(je=>je.id===ae):void 0;if(!de)return;const be=fj(document.activeElement);y(de.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[de]})}catch{}Kn.current=Date.now(),be&&_B(de.id)},30)},[y,e]),da=E.useCallback(z=>{y(z,!1),window.setTimeout(()=>{try{const V=Vs.current.find(ae=>ae.id===z);V&&e.fitView({padding:.3,duration:500,nodes:[V]}),Kn.current=Date.now()}catch{}},60)},[y,e]);E.useEffect(()=>{const z=V=>{var Ze,pt;const ae=V.target,de={tagName:ae==null?void 0:ae.tagName,isContentEditable:ae==null?void 0:ae.isContentEditable,role:(Ze=ae==null?void 0:ae.getAttribute)==null?void 0:Ze.call(ae,"role"),type:ae==null?void 0:ae.type};if(V.key==="Escape"){const ot=EL({overlayOpen:Ao.depth()>0,panelOnTop:Ao.topIsPanel(),typing:gw(de)});ot==="dismiss"?Ao.dismissTop():ot==="blur"?ae==null||ae.blur():(OD(de)&&(ae==null||ae.blur()),w());return}if(mw(V))return;const be=fj(ae)?(pt=ae==null?void 0:ae.getAttribute)==null?void 0:pt.call(ae,"data-id"):null,je=be&&Vs.current.some(ot=>ot.id===be)?be:null,ze=MD(V,je);if(ze.kind==="activate"){V.preventDefault(),y(ze.nodeId,ze.additive);return}ze.kind!=="node"&&(ze.nodeId==null&&OL(de)||PL({key:V.key,modalOpen:ca.current,sheetOpen:Il.current})||(V.key===" "&&(V.preventDefault(),ts()),(V.key==="c"||V.key==="C")&&cs("shortcut"),(V.key==="r"||V.key==="R")&&Lr(),(V.key==="f"||V.key==="F")&&Ol(),(V.key==="l"||V.key==="L")&&Ko(),(V.key==="h"||V.key==="H")&&fr(ot=>!ot),(V.key==="u"||V.key==="U")&&K(ot=>!ot),(V.key==="a"||V.key==="A")&&wt.current.claude&&dr(),(V.key==="j"||V.key==="J")&&Xi(1),(V.key==="k"||V.key==="K")&&Xi(-1),(V.key==="t"||V.key==="T")&&Zo(ot=>ot==="dark"?"light":"dark"),(V.key==="m"||V.key==="M")&&wt.current.claude&&$.current!==null&&Q.current(V.shiftKey),V.key==="?"&&P(ot=>!ot)))};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[cs,Lr,Ol,w,y,Xi,ts]);const Qi=s.current.agents.size,Vt=E.useMemo(()=>G3(s.current.agents.values()),[s.current,s.current.revision]),Pl=E.useMemo(()=>V3(s.current.agents.values()),[s.current,s.current.revision]),$l=E.useRef(null);E.useEffect(()=>{const z=KD({waiting:Vt.length,running:Pl,connected:Ie}),V=$l.current;if($l.current=z,(V==null?void 0:V.title)!==z.title&&(document.title=z.title),(V==null?void 0:V.icon)!==z.icon){const ae=document.querySelector('link[rel="icon"]');ae&&(ae.href=XD[z.icon])}},[Vt.length,Pl,Ie]);const[ld,Ll]=E.useState(""),fa=ZD(Vt);E.useEffect(()=>{Ll(z=>JD(z,fa))},[fa]);const Lt=E.useMemo(()=>uT(s.current.agents.values()),[s.current,s.current.revision]);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),d.jsxs("header",{className:"topbar",children:[d.jsxs("div",{className:"readout",children:[d.jsxs("div",{className:"brand",children:[d.jsx("span",{className:"logo"}),d.jsx("h1",{children:zt}),Me?d.jsxs("button",{type:"button",className:"v stale",onClick:()=>{Ne(),Sn()},"aria-haspopup":"dialog","aria-label":fB({...Me,open:kt}),title:Me.kind==="restart"?`Running v${Me.from}; v${Me.to} is installed on disk. Restart to pick it up · click for what's new`:`Running v${Me.from}; v${Me.to} is on npm · click for what's new`,children:["v",Me.from,d.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const z={running:Pe,latest:ce==null?void 0:ce.latest,latestPending:ce==null?void 0:ce.latestPending,checkedAgo:ce!=null&&ce.checkedAt?Py(ht-ce.checkedAt):null,checkDisabled:ce==null?void 0:ce.checkDisabled,checking:Be};return d.jsxs("button",{type:"button",className:Be?"v checking":"v",onClick:()=>{Ne(),Ke(!0)},"aria-busy":Be||void 0,"aria-haspopup":"dialog","aria-label":dB(z),title:uB(z),children:["v",z.running]})})()]}),d.jsxs("span",{className:"status",children:[(()=>{const z=xB({connected:Ie,paused:Un,held:Gt.size,dropped:Gt.dropped});return z.resting?null:d.jsx("span",{className:`pill ${z.tone}`,title:z.title,children:d.jsxs("span",{className:"pill-box",children:[d.jsx("span",{className:"pill-widest","aria-hidden":!0,children:z.widest}),d.jsx("span",{className:"pill-label",children:z.label})]})})})(),d.jsx(O4,{usageOpen:H}),Lt.sum>0&&d.jsxs("span",{className:"stat",title:`in:${Lt.inputTokens.toLocaleString()} out:${Lt.outputTokens.toLocaleString()} cache-r:${Lt.cacheReadTokens.toLocaleString()} cache-c:${Lt.cacheCreateTokens.toLocaleString()}
139
+ Click to set the volume and the sound of each tone, and to hear either one.`}function RT(e){const t=new Map;for(const n of e)for(const s of n.agents??[]){if(!s||typeof s.agent!="string"||s.agent==="")continue;const o=t.get(s.agent)??{id:s.agent,cost:0,tokens:0};o.cost+=Number.isFinite(s.totalCost)?s.totalCost:0,o.tokens+=Number.isFinite(s.totalTokens)?s.totalTokens:0,t.set(s.agent,o)}return[...t.values()].sort((n,s)=>s.cost-n.cost||n.id.localeCompare(s.id))}function a5(e){const t=RT([{agents:e}]);return t.length<2?null:t.map(n=>`${Ew(n.id)} ${Ve(n.cost)}`).join(" · ")}function P1(e){switch(e.toLowerCase()){case"claude":return"var(--usage-purple)";case"codex":return"var(--usage-orange)";case"gemini":return"var(--usage-indigo)";case"copilot":return"var(--usage-green)";default:return"var(--usage-zinc)"}}function l5(e,t){if(!(t>0)||!(e>0))return"0%";const n=e/t*100;return n<.1?"<0.1%":`${n.toFixed(1)}%`}function Xc(e){const t=e.toLowerCase();return t.includes("opus")?"var(--usage-purple)":t.includes("sonnet")?"var(--usage-blue)":t.includes("haiku")?"var(--usage-green)":t.includes("gpt-5")||t.includes("gpt5")?"var(--usage-amber)":t.includes("gpt")?"var(--usage-red)":t.includes("gemini")?"var(--usage-indigo)":t.includes("codex")?"var(--usage-orange)":"var(--usage-zinc)"}const c5=[7,14,30,90];function u5(e){const[t,n]=E.useState(null),[s,o]=E.useState(!1),a=E.useState(JD)[0],l=E.useRef(!1),u=(h=!1)=>{if(h&&!or(l.current))return;const p=a.begin();l.current=h;const f=e;o(!0);const y=`/api/ccusage?since=${e5(f)}${h?"&refresh=1":""}`;fetch(y).then(w=>w.json()).then(w=>{p()&&n({range:f,resp:w})}).catch(()=>{p()&&n({range:f,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{p()&&(l.current=!1,o(!1))})};return E.useEffect(()=>(u(!1),()=>a.cancel()),[e]),{landed:t,loading:s,reload:()=>u(!0)}}function d5({onClose:e,providers:t}){var F;const[n,s]=E.useState(30),[o,a]=E.useState(null),{landed:l,loading:u,reload:h}=u5(n),p=E.useRef(null),f=kn(e,{focusRef:p}),g=t5({loading:u,want:n,answer:l&&{range:l.range,ok:l.resp.ok===!0,days:((F=l.resp.days)==null?void 0:F.length)??0}}),y=g.phase==="chart"?l.resp.days??[]:[],w=E.useMemo(()=>y.reduce((O,A)=>Math.max(O,A.totalCost),0),[y]),S=E.useRef(null);E.useLayoutEffect(()=>{const O=S.current;O&&(O.scrollLeft=O.scrollWidth)},[y]);const{totalCost:b,totalTok:_,inOut:k,cacheRead:N,modelCosts:j}=E.useMemo(()=>{let O=0,A=0,D=0,H=0;const K=new Map;for(const C of y){O+=C.totalCost,A+=C.totalTokens,D+=C.inputTokens+C.outputTokens,H+=C.cacheReadTokens;for(const X of C.modelBreakdowns)K.set(X.modelName,(K.get(X.modelName)??0)+X.cost)}return{totalCost:O,totalTok:A,inOut:D,cacheRead:H,modelCosts:K}},[y]),T=E.useMemo(()=>Array.from(j.entries()).sort((O,A)=>A[1]-O[1]),[j]),M=E.useMemo(()=>RT(y),[y]),P=M.length>1,I=o?y.find(O=>O.period===o)??null:null;return d.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:d.jsxs("div",{ref:f,className:"uh-modal",onClick:O=>O.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Usage history",children:[d.jsxs("header",{className:"uh-head",children:[d.jsxs("div",{className:"uh-titlewrap",children:[d.jsx("div",{className:"uh-title",children:"Usage history"}),d.jsx("div",{className:"uh-sub",children:s5(t,M.map(O=>O.id))})]}),d.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:c5.map(O=>d.jsxs("button",{type:"button","aria-pressed":n===O,className:"uh-range-btn",onClick:()=>{s(O),a(null)},children:[O,"d"]},O))}),d.jsx("button",{className:"glyph-btn uh-reload",onClick:h,...ir(u),title:"Re-run ccusage","aria-label":"Reload",children:u?"…":"↻"}),d.jsx("button",{ref:p,className:"glyph-btn uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),g.phase==="busy"?d.jsx("div",{className:"uh-status","aria-busy":"true",children:l?"running ccusage…":"running ccusage… (first run downloads the package)"}):g.phase==="error"?d.jsxs("div",{className:"uh-status uh-err",title:qo(l.resp)||void 0,children:[sq(l.resp,"ccusage did not report usage"),d.jsx("div",{children:d.jsx("button",{className:"btn uh-retry",onClick:h,...ir(u),children:u?"trying…":"Try again"})})]}):g.phase==="empty"?d.jsx("div",{className:`uh-status${g.stale?" uh-stale":""}`,"aria-busy":g.stale||void 0,children:"no usage in this range"}):d.jsxs("div",{className:g.stale?"uh-stale":void 0,"aria-busy":g.stale||void 0,children:[d.jsxs("div",{className:"uh-totals",children:[d.jsx(Qc,{label:"total cost",val:Ve(b),accent:!0}),d.jsx(Qc,{label:"tokens",val:Pt(_)}),d.jsx(Qc,{label:"input+output",val:Pt(k)}),d.jsx(Qc,{label:"cache reads",val:Pt(N)})]}),P&&d.jsxs("div",{className:"uh-agents",role:"group","aria-label":"Cost by CLI",children:[d.jsx("div",{className:"uh-agent-bar","aria-hidden":"true",children:M.map(O=>d.jsx("span",{className:"uh-agent-seg",style:{width:`${b>0?O.cost/b*100:0}%`,background:P1(O.id)}},O.id))}),d.jsx("div",{className:"uh-agent-keys",children:M.map(O=>d.jsxs("span",{className:"uh-agent-key",title:`${O.id} · ${Pt(O.tokens)} tokens`,children:[d.jsx("span",{className:"uh-legend-dot",style:{background:P1(O.id)}}),Ew(O.id),d.jsx("span",{className:"uh-agent-cost",children:Ve(O.cost)}),d.jsx("span",{className:"uh-agent-share",children:l5(O.cost,b)})]},O.id))})]}),d.jsx("div",{ref:S,className:"uh-chart",role:"group","aria-label":"Daily cost by model",children:y.map(O=>{const A=w>0?O.totalCost/w*100:0,D=O.period===o,H=`${O.period}, ${Ve(O.totalCost)}`;return d.jsxs("button",{className:`uh-bar-col${D?" sel":""}`,onClick:()=>a(D?null:O.period),"aria-pressed":D,"aria-label":H,title:`${O.period} · ${Ve(O.totalCost)}`,style:{flexBasis:`${100/y.length}%`},children:[d.jsx("div",{className:"uh-bar",style:{height:`${Math.max(A,O.totalCost>0?2:0)}%`},children:O.modelBreakdowns.slice().sort((K,C)=>C.cost-K.cost).map(K=>{const C=O.totalCost>0?K.cost/O.totalCost*100:0;return d.jsx("div",{className:"uh-bar-seg",style:{height:`${C}%`,background:Xc(K.modelName)}},K.modelName)})}),d.jsx("span",{className:"uh-bar-label",children:O.period.slice(5)})]},O.period)})}),d.jsx("div",{className:"uh-legend",children:T.map(([O,A])=>d.jsxs("span",{className:"uh-legend-item",title:O,children:[d.jsx("span",{className:"uh-legend-dot",style:{background:Xc(O)}}),xi(O)," ",d.jsx("span",{className:"uh-legend-cost",children:Ve(A)})]},O))}),I&&d.jsxs("div",{className:"uh-detail",children:[d.jsxs("div",{className:"uh-detail-head",children:[d.jsx("span",{className:"uh-detail-date",children:I.period}),d.jsx("span",{className:"uh-detail-cost",children:Ve(I.totalCost)}),(()=>{var D,H;const A=a5(I.agents)??((H=(D=I.metadata)==null?void 0:D.agents)!=null&&H.length?I.metadata.agents.join(" · "):null);return A?d.jsx("span",{className:"uh-detail-agents",title:A,children:A}):null})()]}),d.jsxs("div",{className:"uh-detail-mini",children:[d.jsx(Zc,{label:"input",val:Pt(I.inputTokens)}),d.jsx(Zc,{label:"output",val:Pt(I.outputTokens)}),d.jsx(Zc,{label:"cache write",val:Pt(I.cacheCreationTokens)}),d.jsx(Zc,{label:"cache read",val:Pt(I.cacheReadTokens)})]}),d.jsx("div",{className:"uh-detail-models",children:I.modelBreakdowns.slice().sort((O,A)=>A.cost-O.cost).map(O=>{const A=I.totalCost>0?O.cost/I.totalCost*100:0;return d.jsxs("div",{className:"uh-model-row",title:O.modelName,children:[d.jsxs("span",{className:"uh-model-name",children:[d.jsx("span",{className:"uh-legend-dot",style:{background:Xc(O.modelName)}}),d.jsx("span",{className:"uh-model-label",children:xi(O.modelName)})]}),d.jsx("span",{className:"uh-model-bar",children:d.jsx("span",{className:"uh-model-bar-fill",style:{width:`${A}%`,background:Xc(O.modelName)}})}),d.jsx("span",{className:"uh-model-cost",children:Ve(O.cost)})]},O.modelName)})})]})]})]})})}function Qc({label:e,val:t,accent:n}){return d.jsxs("div",{className:"uh-stat",children:[d.jsx("span",{className:`uh-stat-val${n?" accent":""}`,children:t}),d.jsx("span",{className:"uh-stat-label",children:e})]})}function Zc({label:e,val:t}){return d.jsxs("div",{className:"uh-ministat",children:[d.jsx("span",{className:"uh-ministat-val",children:t}),d.jsx("span",{className:"uh-ministat-label",children:e})]})}function f5(e){const t=/^#?([0-9a-f]{6})$/i.exec((e??"").trim());if(!t)return!1;const n=parseInt(t[1],16),s=[n>>16&255,n>>8&255,n&255].map(o=>{const a=o/255;return a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)});return .2126*s[0]+.7152*s[1]+.0722*s[2]>.5}const $1=1e4,h5=12e3;function p5({browsers:e,findings:t,watching:n,palette:s,now:o=()=>Date.now()}){const a=E.useRef(null),l=E.useRef(null);return l.current={browsers:e,findings:t,watching:n},E.useEffect(()=>{var w;const u=a.current;if(!u)return;const h=u.getContext("2d");if(!h)return;const p=((w=window.matchMedia)==null?void 0:w.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;let f=0,g=!1;const y=()=>{var ne;if(g)return;const S=l.current;if(!S)return;const{browsers:b,findings:_,watching:k}=S,N=s["--accent"]||"#7dd3fc",j=s["--line"]||"#1f2229",T=s["--text-dim"]||"#6e727c",M=f5(s["--bg"]),P=M?42:26,I=M?.85:.65,F=o(),O=Math.min(window.devicePixelRatio||1,2),A=u.clientWidth,D=u.clientHeight;(u.width!==A*O||u.height!==D*O)&&(u.width=A*O,u.height=D*O),h.setTransform(O,0,0,O,0,0),h.clearRect(0,0,A,D);const H=A/2,K=D/2,C=Math.min(A,D)/2-6;h.strokeStyle=j,h.lineWidth=1,h.globalAlpha=M?1:.9;for(const J of[.4,.7,1])h.beginPath(),h.arc(H,K,C*J,0,Math.PI*2),h.stroke();h.beginPath(),h.moveTo(H-C,K),h.lineTo(H+C,K),h.moveTo(H,K-C),h.lineTo(H,K+C),h.stroke(),h.globalAlpha=1;const B=(k&&!p?F%$1/$1:0)*Math.PI*2-Math.PI/2;if(k){const J=(ne=h.createConicGradient)==null?void 0:ne.call(h,B-.85,H,K);J&&(J.addColorStop(0,"transparent"),J.addColorStop(.85/(Math.PI*2),`color-mix(in srgb, ${N} ${P}%, transparent)`),J.addColorStop(1,"transparent"),h.fillStyle=J,h.beginPath(),h.moveTo(H,K),h.arc(H,K,C,B-.85,B),h.closePath(),h.fill()),h.strokeStyle=N,h.globalAlpha=I,h.beginPath(),h.moveTo(H,K),h.lineTo(H+Math.cos(B)*C,K+Math.sin(B)*C),h.stroke(),h.globalAlpha=1}b.forEach((J,W)=>{const Q=W/Math.max(b.length,1)*Math.PI*2-Math.PI/2,$=J.lastReadMs===null?1:Math.min(1,(F-J.lastReadMs)/12e4),G=C*(.42+$*.5),Y=H+Math.cos(Q)*G,L=K+Math.sin(Q)*G,q=Math.abs((B-Q+Math.PI*3)%(Math.PI*2)-Math.PI),Z=k?Math.max(0,1-q/.55):0;h.beginPath(),h.arc(Y,L,3+Z*1.6,0,Math.PI*2),h.fillStyle=J.running?N:T,h.globalAlpha=J.running?.55+Z*.45:.35,h.fill(),h.globalAlpha=1});for(const J of _){const W=(F-J.atMs)/h5;if(W<0||W>1)continue;const $=Math.max(0,b.findIndex(L=>L.key===J.browser))/Math.max(b.length,1)*Math.PI*2-Math.PI/2,G=H+Math.cos($)*C*.6,Y=K+Math.sin($)*C*.6;h.beginPath(),h.arc(G,Y,4+W*22,0,Math.PI*2),h.strokeStyle=N,h.globalAlpha=(1-W)*.8,h.lineWidth=1.5,h.stroke(),h.globalAlpha=1}f=requestAnimationFrame(y)};return y(),()=>{g=!0,cancelAnimationFrame(f)}},[o,s]),d.jsx("canvas",{ref:a,className:"bw-radar",role:"img","aria-label":n?`Watching ${e.length} browser${e.length===1?"":"s"}`:"Not watching"})}const L1="agent-dag.browserWatch.seenMs";function m5(e,t){return e.filter(n=>n.startMs>t)}function g5(e,t,n){if(e===null)return null;const s=e+t-n;return s>0?s:null}function v5(e){const t=Math.ceil(e/1e3),n=Math.floor(t/60),s=t%60;return n>0?`${n}m ${s}s`:`${s}s`}function AT(e){return(e??[]).filter(t=>t.installed&&t.profiles>0)}function q1(e,t){return t?{kind:"saving",word:"Saving",detail:""}:e.settings.enabled?{kind:"on",word:"Watching",detail:""}:{kind:"off",word:"Paused",detail:"nothing new is recorded"}}function y5(e,t){return e.map(n=>({key:n.key,name:n.name,running:n.running,visits:t.filter(s=>s.browser===n.key).reduce((s,o)=>s+o.programVisits,0)}))}function w5(e,t){if(e===null)return null;const n=Math.max(0,Math.round((t-e)/1e3));if(n<5)return"just now";if(n<60)return`${n} sec ago`;const s=Math.round(n/60);return s<60?`${s} min ago`:`${Math.round(s/60)} hr ago`}function x5(e){const t=e.profiles.filter(s=>s.degraded);if(t.length>0){const s=t[0],o=t.length-1;return{kind:"unreadable",text:`${s.name}/${s.profile} could not be read — ${s.reason??"no reason given"}`+(o>0?`, and ${o} more`:"")+". The watch continues on the profiles it can read."}}const n=AT(e.browsers);return n.length===0?{kind:"no-profiles",text:"No browser on this machine has a profile to read. Open one of the browsers below once and it will be watched from then on."}:n.some(s=>s.running)?null:{kind:"none-running",text:"No watched browser is running, so nothing can be navigated right now. Their history is still read, and anything found while they were open is still here."}}function b5(e){const t=n=>new Date(n).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1});return e.count===1||e.endMs-e.startMs<6e4?t(e.startMs):`${t(e.startMs)} → ${t(e.endMs)}`}function _5(e){return new Date(e).toLocaleDateString(void 0,{weekday:"short",day:"numeric",month:"short"})}function D1(e){const t=Math.round((e.endMs-e.startMs)/6e4);return t<1?"":`${t} min`}function k5({onClose:e,onSeen:t,onWatching:n,palette:s}){const o=kn(e),[a,l]=E.useState(null),[u,h]=E.useState(null),[p,f]=E.useState(!1),g=E.useRef(!1),[y,w]=E.useState(null),[S,b]=E.useState(null),[_,k]=E.useState(!1),[N,j]=E.useState(!1),[T,M]=E.useState(!1),[P,I]=E.useState(!1),[F,O]=E.useState(!1),[A,D]=E.useState(!1),[H,K]=E.useState(()=>Date.now());E.useEffect(()=>{const Y=setInterval(()=>K(Date.now()),1e3);return()=>clearInterval(Y)},[]);const C=E.useCallback(async Y=>{var L;if(!(Y&&!or(g.current))){g.current=Y,f(!0);try{const q=await fetch(`/api/browser-watch${Y?"?refresh=1":""}`);if(!q.ok)throw new Error(`the deck answered ${q.status}`);const Z=await q.json();l(Z),w(se=>{var fe;return se===null?((fe=Z==null?void 0:Z.settings)==null?void 0:fe.quietMinutes)??15:se}),n(((L=Z==null?void 0:Z.settings)==null?void 0:L.enabled)===!0),h(null)}catch(q){h(q instanceof Error?q.message:String(q))}finally{g.current=!1,f(!1)}}},[n]);E.useEffect(()=>{C(!1)},[C]),E.useEffect(()=>{const Y=setInterval(()=>{C(!1)},1e4);return()=>clearInterval(Y)},[C]);const X=E.useCallback(async Y=>{try{await fetch("/api/browser-watch/dismiss",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:Y.host,startMs:Y.startMs})})}finally{await C(!1)}},[C]),B=E.useCallback(async Y=>{k(!0);try{const L=await fetch("/api/browser-watch",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Y)});if(!L.ok)throw new Error(`the deck answered ${L.status}`);await C(!1)}catch(L){h(L instanceof Error?L.message:String(L))}finally{k(!1)}},[C]);E.useEffect(()=>()=>t(Date.now()),[t]);const ne=E.useMemo(()=>{const Y=[];for(const L of(a==null?void 0:a.episodes)??[]){const q=_5(L.startMs),Z=Y[Y.length-1];Z&&Z.label===q?Z.episodes.push(L):Y.push({label:q,episodes:[L]})}return Y},[a]),J=AT(a==null?void 0:a.browsers);J.filter(Y=>Y.running).map(Y=>Y.name);const W=((a==null?void 0:a.browsers)??[]).filter(Y=>!(Y.installed&&Y.profiles>0)),Q=a?x5(a):null,$=J.reduce((Y,L)=>Y+L.profiles,0),G=a?g5(a.coverage.lastHumanMs,a.coverage.quietMs,H):null;return((a==null?void 0:a.profiles)??[]).reduce((Y,L)=>L.lastWrittenMs!==null&&(Y===null||L.lastWrittenMs>Y)?L.lastWrittenMs:Y,null),d.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:d.jsxs("div",{ref:o,className:"modal bw-modal",onClick:Y=>Y.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"bw-title",children:[d.jsxs("header",{className:"modal-head",children:[d.jsxs("div",{className:"modal-title",children:[d.jsx("span",{className:"modal-tool-name",id:"bw-title",children:"Browser watch"}),d.jsx("span",{className:"modal-tool-id",children:a?`${$} ${$===1?"profile":"profiles"} · local only`:"local only"})]}),d.jsxs("div",{className:"modal-actions",children:[d.jsx("button",{className:"glyph-btn",onClick:()=>void C(!0),...ir(p),"aria-label":"Re-read every profile now",title:"Re-read every profile now",children:p?"…":"↻"}),d.jsx("button",{className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),d.jsxs("div",{className:"modal-body bw-body",children:[!a&&!u&&d.jsxs("div",{className:"bw-loading",children:[d.jsx("span",{className:"bw-loading-bar","aria-hidden":!0}),d.jsx("p",{children:"Reading each browser's history. The first look copies the file, which takes a moment."})]}),u&&d.jsx("div",{className:"bw-state",children:d.jsxs("div",{className:"bw-row err",children:[d.jsx("span",{className:"bw-dot","aria-hidden":!0}),d.jsx("span",{className:"bw-row-label",children:"Could not read"}),d.jsx("span",{className:"bw-row-detail",children:u})]})}),a&&Q&&d.jsx("p",{className:`bw-trouble ${Q.kind}`,role:"status",children:Q.text}),a&&d.jsxs("div",{className:"bw-work",children:[d.jsxs("aside",{className:"bw-side",children:[d.jsxs("section",{className:"bw-sec",children:[d.jsxs("h4",{className:"bw-sec-head",children:["Activity overview",d.jsx("button",{className:"bw-help",onClick:()=>I(Y=>!Y),"aria-expanded":P,"aria-label":"What the sweep and the dots mean",children:"?"})]}),d.jsxs("div",{className:"bw-glance",children:[d.jsx(p5,{browsers:J.map(Y=>{var L;return{key:Y.key,name:Y.name,running:Y.running,lastReadMs:((L=a.profiles.find(q=>q.browser===Y.key))==null?void 0:L.lastWrittenMs)??null}}),findings:a.episodes.slice(0,6).map(Y=>({browser:Y.browser??null,atMs:Y.endMs})),watching:a.settings.enabled,palette:s}),d.jsx("ul",{className:"bw-counts",children:y5(J,a.profiles).map(Y=>d.jsxs("li",{children:[d.jsx("span",{className:"bw-count-n",children:Y.visits.toLocaleString("en-US")}),d.jsx("span",{className:"bw-count-of",children:Y.name})]},Y.key))})]}),d.jsx("p",{className:"bw-since",children:"Pages a program opened, since this deck started"}),a.coverage.checkedMs>0&&d.jsxs("p",{className:"bw-since",children:["Last checked ",w5(a.coverage.checkedMs,H),a.coverage.checks>0&&d.jsxs(d.Fragment,{children:[" · ",a.coverage.checks.toLocaleString("en-US")," ",a.coverage.checks===1?"check":"checks"]})]}),G!==null&&d.jsxs("p",{className:"bw-gate",children:["You are browsing — a program page would count in ",v5(G)]}),P&&d.jsxs("dl",{className:"bw-key",children:[d.jsx("dt",{children:"Sweep"}),d.jsx("dd",{children:"one poll of every watched profile"}),d.jsx("dt",{children:"Dot"}),d.jsx("dd",{children:"a browser, further out the longer since it last wrote history"}),d.jsx("dt",{children:"Ring"}),d.jsx("dd",{children:"a finding, leaving the browser it came from"})]})]}),d.jsxs("section",{className:"bw-sec",children:[d.jsxs("h4",{className:"bw-sec-head",children:["Watched profiles",d.jsx("button",{className:"bw-help",onClick:()=>O(Y=>!Y),"aria-expanded":F,"aria-label":"What running, idle and connected to Anthropic mean",children:"?"})]}),F&&d.jsxs("dl",{className:"bw-key",children:[d.jsx("dt",{children:"Running"}),d.jsx("dd",{children:"the browser has a process on this machine right now"}),d.jsx("dt",{children:"Connected"}),d.jsx("dd",{children:"an open connection to an address Anthropic's relay uses — which it shares with claude.ai, so an open tab looks the same as an agent channel"})]}),d.jsx("ul",{className:"bw-profiles",children:J.map(Y=>d.jsxs("li",{children:[d.jsx("span",{className:`bw-prof-dot${Y.running?" on":""}`,"aria-hidden":!0}),d.jsx("span",{className:"bw-prof-name",children:Y.name}),d.jsx("span",{className:"bw-prof-state",children:Y.running?"running":"idle"}),Y.running&&Y.relay.state==="live"&&d.jsx("span",{className:"bw-relay",children:"connected to Anthropic"})]},Y.key))}),W.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{className:"bw-why bw-rest-head",onClick:()=>D(Y=>!Y),"aria-expanded":A,children:[d.jsx("span",{className:"bw-chev","aria-hidden":!0,children:A?"▾":"▸"})," ",W.length," not watched"]}),A&&d.jsxs("p",{className:"bw-rest",children:[W.map(Y=>Y.name).join(", ")," — not installed, or installed and never opened, so there is no history to read."]})]})]})]}),d.jsxs("div",{className:"bw-main",children:[d.jsxs("section",{className:"bw-findings",children:[d.jsxs("h4",{className:"bw-sec-head bw-head-row",children:["Findings",a.episodes.length>0&&d.jsxs("span",{className:"bw-feed-count",children:[a.episodes.length," ",a.episodes.length===1?"episode":"episodes"]})]}),d.jsx("div",{className:"bw-eps",children:ne.length===0?d.jsxs("div",{className:"bw-empty",children:[d.jsx("p",{className:"bw-empty-head",children:"Nothing found yet"}),d.jsxs("p",{className:"bw-empty-note",children:["An episode lands here when a program opens pages in a browser nobody has touched for"," ",a.settings.quietMinutes," ",a.settings.quietMinutes===1?"minute":"minutes",". On most machines that is rare, so an empty list is the ordinary result rather than a sign something is wrong."]}),!a.settings.enabled&&d.jsx("p",{className:"bw-empty-note",children:"Watching is off, so this shows only what this deck has seen since it started. Anything an earlier run recorded comes back when you switch it on."})]}):ne.map(Y=>d.jsxs("div",{className:"bw-day",children:[d.jsx("h4",{className:"bw-sec-head",children:Y.label}),Y.episodes.map(L=>{const q=`${L.host}-${L.startMs}`,Z=S===q;return d.jsxs("div",{className:`bw-ep${Z?" open":""}`,children:[d.jsxs("div",{className:"bw-ep-row",children:[d.jsxs("button",{className:"bw-ep-head",onClick:()=>b(Z?null:q),"aria-expanded":Z,children:[d.jsx("span",{className:"bw-chev","aria-hidden":!0,children:Z?"▾":"▸"}),d.jsx("span",{className:"bw-ep-host",children:L.host}),d.jsxs("span",{className:"bw-ep-meta",children:[b5(L),D1(L)&&d.jsxs(d.Fragment,{children:[" · ",D1(L)]})]}),d.jsxs("span",{className:"bw-ep-count",children:[L.count," ",L.count===1?"page":"pages"]})]}),d.jsx("button",{className:"glyph-btn bw-ep-x",onClick:()=>void X(L),"aria-label":`Dismiss ${L.host}`,title:"Dismiss — it leaves this list for good, and stays in the log file",children:"×"})]}),Z&&d.jsx("ul",{className:"bw-urls",children:L.urls.map((se,fe)=>d.jsxs("li",{children:[d.jsx("span",{className:"bw-url-time",children:new Date(se.timeMs).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1})}),d.jsx("span",{className:"bw-url",children:se.url})]},`${se.url}-${se.timeMs}-${fe}`))})]},q)})]},Y.label))})]}),d.jsxs("section",{className:"bw-feed",children:[d.jsxs("h4",{className:"bw-sec-head bw-head-row",children:["Live activity",d.jsxs("span",{className:"bw-feed-count",children:[a.log.length," ",a.log.length===1?"event":"events"]})]}),d.jsx("p",{className:"bw-since bw-feed-note",children:"Pages you opened yourself — counted to run the rule, never written down. Addresses appear under Findings, and only for pages a program opened."}),d.jsx("div",{className:"bw-log","aria-live":"polite","aria-relevant":"additions",children:a.log.length===0?d.jsx("p",{className:"bw-note",children:"The deck writes a line here each time it looks at a profile."}):a.log.map(Y=>d.jsxs("div",{className:`bw-log-line ${Y.level}${Y.parts?"":" sys"}`,children:[d.jsx("span",{className:"bw-log-time",children:new Date(Y.atMs).toLocaleTimeString("en-GB",{hour12:!1})}),Y.parts?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"bw-log-browser",children:Y.parts.browser}),d.jsx("span",{className:"bw-log-profile",title:Y.parts.profile,children:Y.parts.profile}),d.jsxs("span",{className:"bw-log-value",children:[Y.parts.value,Y.parts.flagged>0&&d.jsxs("span",{className:"bw-log-flag",children:[" · ",Y.parts.flagged," flagged"]})]})]}):d.jsx("span",{className:"bw-log-sys",children:Y.text})]},`${Y.atMs}-${Y.level}-${Y.text}`))})]})]})]}),a&&N&&d.jsxs("div",{className:"bw-settings",children:[d.jsxs("label",{title:"A program opening a page counts as a finding only if nobody had touched the browser for this long. Shorter catches more and reports more of your own work; longer is quieter.",children:[d.jsx("span",{children:"Nobody browsing for"}),d.jsxs("select",{value:y??a.settings.quietMinutes,onChange:Y=>{w(Number(Y.target.value)),B({quietMinutes:Number(Y.target.value)})},children:[d.jsx("option",{value:1,children:"1 min"}),d.jsx("option",{value:5,children:"5 min"}),d.jsx("option",{value:15,children:"15 min"}),d.jsx("option",{value:30,children:"30 min"}),d.jsx("option",{value:60,children:"60 min"})]})]}),d.jsxs("label",{children:[d.jsx("span",{children:"When it finds one"}),d.jsx("select",{value:a.settings.reaction,onChange:Y=>void B({reaction:Y.target.value}),disabled:!a.settings.enabled,title:a.settings.enabled?"What to do besides writing it down.":"Turn watching on to arm a reaction.",children:(a.reactions??["notify"]).map(Y=>d.jsx("option",{value:Y,children:Y==="notify"?"notify me":Y==="close-tab"?"close the tab":"quit the browser"},Y))})]}),d.jsxs("div",{className:"bw-settings-note",children:[d.jsxs("p",{children:["Chrome marks a navigation that came from an extension or a command rather than from a click. These are the ones that happened while nobody had touched the browser for the time above. ",d.jsx("strong",{children:"Usually that is your own agent doing what you asked."})]}),d.jsxs("button",{className:"bw-why",onClick:()=>M(Y=>!Y),"aria-expanded":T,children:[d.jsx("span",{className:"bw-chev","aria-hidden":!0,children:T?"▾":"▸"})," What Browser Watch can access"]}),T&&d.jsxs("dl",{className:"bw-access",children:[d.jsx("dt",{children:"Reads"}),d.jsxs("dd",{children:["A copy of each browser's own history database — the live file is locked while the browser holds it. Only rows newer than the moment this deck started:"," ",new Date(a.coverage.startedMs).toLocaleString(),"."]}),d.jsx("dt",{children:"Keeps"}),d.jsxs("dd",{children:["Only while the switch is on, and only the episodes it flagged — never your ordinary browsing. In ",d.jsx("code",{className:"bw-path",children:a.coverage.logPath}),", with every address written in full so you can check it yourself."]}),d.jsx("dt",{children:"Sends"}),d.jsx("dd",{children:"Nothing. No part of this reads or writes over the network; the deck serves on 127.0.0.1 and this panel talks only to it."}),d.jsx("dt",{children:"Never reads"}),d.jsx("dd",{children:"Anything from before this deck started, cookies, saved passwords, page contents, or any browser profile with no history file."})]})]})]}),a&&d.jsxs("footer",{className:"bw-status",children:[d.jsx("span",{className:`bw-mode-dot${a.settings.enabled?" on":""}`,"aria-hidden":!0}),d.jsx("span",{className:"bw-mode-word",children:q1(a,_).word},q1(a,_).kind),d.jsx("span",{className:"bw-status-text",children:a.coverage.archived===0?a.settings.enabled?"No episodes recorded yet":"No episodes on disk":`${a.coverage.archived} ${a.coverage.archived===1?"episode":"episodes"} on disk`}),d.jsx("button",{className:`glyph-btn bw-gear${N?" on":""}`,onClick:()=>j(Y=>!Y),"aria-expanded":N,"aria-label":"Settings",title:"Settings",children:d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3","aria-hidden":!0,children:[d.jsx("circle",{cx:"7",cy:"7",r:"2.1"}),d.jsx("path",{d:"M7 1.2v1.6M7 11.2v1.6M1.2 7h1.6M11.2 7h1.6M2.9 2.9l1.1 1.1M10 10l1.1 1.1M11.1 2.9L10 4M4 10l-1.1 1.1"})]})}),d.jsxs("label",{className:"bw-switch",htmlFor:"bw-enabled",children:[d.jsx("span",{className:"bw-switch-label",id:"bw-enabled-label",children:"Watch browser activity"}),d.jsx("button",{id:"bw-enabled",type:"button",role:"switch","aria-checked":a.settings.enabled,"aria-labelledby":"bw-enabled-label",className:"bw-toggle",onClick:()=>void B({enabled:!a.settings.enabled}),title:a.settings.enabled?"On — every episode it finds is written down, so the list outlives the browsing history being cleared":"Off — showing only what this deck has seen since it started. Anything an earlier run archived is hidden until you switch back on, and nothing new is kept",children:d.jsx("span",{className:"bw-toggle-knob"})})]})]})]})]})})}function jw(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 Vf,F1;function S5(){if(F1)return Vf;F1=1;function e(){this.__data__=[],this.size=0}return Vf=e,Vf}var Yf,z1;function Wo(){if(z1)return Yf;z1=1;function e(t,n){return t===n||t!==t&&n!==n}return Yf=e,Yf}var Kf,B1;function Ou(){if(B1)return Kf;B1=1;var e=Wo();function t(n,s){for(var o=n.length;o--;)if(e(n[o][0],s))return o;return-1}return Kf=t,Kf}var Xf,U1;function N5(){if(U1)return Xf;U1=1;var e=Ou(),t=Array.prototype,n=t.splice;function s(o){var a=this.__data__,l=e(a,o);if(l<0)return!1;var u=a.length-1;return l==u?a.pop():n.call(a,l,1),--this.size,!0}return Xf=s,Xf}var Qf,W1;function E5(){if(W1)return Qf;W1=1;var e=Ou();function t(n){var s=this.__data__,o=e(s,n);return o<0?void 0:s[o][1]}return Qf=t,Qf}var Zf,H1;function j5(){if(H1)return Zf;H1=1;var e=Ou();function t(n){return e(this.__data__,n)>-1}return Zf=t,Zf}var Jf,G1;function C5(){if(G1)return Jf;G1=1;var e=Ou();function t(n,s){var o=this.__data__,a=e(o,n);return a<0?(++this.size,o.push([n,s])):o[a][1]=s,this}return Jf=t,Jf}var eh,V1;function Pu(){if(V1)return eh;V1=1;var e=S5(),t=N5(),n=E5(),s=j5(),o=C5();function a(l){var u=-1,h=l==null?0:l.length;for(this.clear();++u<h;){var p=l[u];this.set(p[0],p[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=s,a.prototype.set=o,eh=a,eh}var th,Y1;function T5(){if(Y1)return th;Y1=1;var e=Pu();function t(){this.__data__=new e,this.size=0}return th=t,th}var nh,K1;function R5(){if(K1)return nh;K1=1;function e(t){var n=this.__data__,s=n.delete(t);return this.size=n.size,s}return nh=e,nh}var rh,X1;function A5(){if(X1)return rh;X1=1;function e(t){return this.__data__.get(t)}return rh=e,rh}var sh,Q1;function M5(){if(Q1)return sh;Q1=1;function e(t){return this.__data__.has(t)}return sh=e,sh}var ih,Z1;function MT(){if(Z1)return ih;Z1=1;var e=typeof Ic=="object"&&Ic&&Ic.Object===Object&&Ic;return ih=e,ih}var oh,J1;function ur(){if(J1)return oh;J1=1;var e=MT(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return oh=n,oh}var ah,e_;function Ho(){if(e_)return ah;e_=1;var e=ur(),t=e.Symbol;return ah=t,ah}var lh,t_;function I5(){if(t_)return lh;t_=1;var e=Ho(),t=Object.prototype,n=t.hasOwnProperty,s=t.toString,o=e?e.toStringTag:void 0;function a(l){var u=n.call(l,o),h=l[o];try{l[o]=void 0;var p=!0}catch{}var f=s.call(l);return p&&(u?l[o]=h:delete l[o]),f}return lh=a,lh}var ch,n_;function O5(){if(n_)return ch;n_=1;var e=Object.prototype,t=e.toString;function n(s){return t.call(s)}return ch=n,ch}var uh,r_;function bi(){if(r_)return uh;r_=1;var e=Ho(),t=I5(),n=O5(),s="[object Null]",o="[object Undefined]",a=e?e.toStringTag:void 0;function l(u){return u==null?u===void 0?o:s:a&&a in Object(u)?t(u):n(u)}return uh=l,uh}var dh,s_;function qn(){if(s_)return dh;s_=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return dh=e,dh}var fh,i_;function yl(){if(i_)return fh;i_=1;var e=bi(),t=qn(),n="[object AsyncFunction]",s="[object Function]",o="[object GeneratorFunction]",a="[object Proxy]";function l(u){if(!t(u))return!1;var h=e(u);return h==s||h==o||h==n||h==a}return fh=l,fh}var hh,o_;function P5(){if(o_)return hh;o_=1;var e=ur(),t=e["__core-js_shared__"];return hh=t,hh}var ph,a_;function $5(){if(a_)return ph;a_=1;var e=P5(),t=(function(){var s=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""})();function n(s){return!!t&&t in s}return ph=n,ph}var mh,l_;function IT(){if(l_)return mh;l_=1;var e=Function.prototype,t=e.toString;function n(s){if(s!=null){try{return t.call(s)}catch{}try{return s+""}catch{}}return""}return mh=n,mh}var gh,c_;function L5(){if(c_)return gh;c_=1;var e=yl(),t=$5(),n=qn(),s=IT(),o=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,l=Function.prototype,u=Object.prototype,h=l.toString,p=u.hasOwnProperty,f=RegExp("^"+h.call(p).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function g(y){if(!n(y)||t(y))return!1;var w=e(y)?f:a;return w.test(s(y))}return gh=g,gh}var vh,u_;function q5(){if(u_)return vh;u_=1;function e(t,n){return t==null?void 0:t[n]}return vh=e,vh}var yh,d_;function _i(){if(d_)return yh;d_=1;var e=L5(),t=q5();function n(s,o){var a=t(s,o);return e(a)?a:void 0}return yh=n,yh}var wh,f_;function Cw(){if(f_)return wh;f_=1;var e=_i(),t=ur(),n=e(t,"Map");return wh=n,wh}var xh,h_;function $u(){if(h_)return xh;h_=1;var e=_i(),t=e(Object,"create");return xh=t,xh}var bh,p_;function D5(){if(p_)return bh;p_=1;var e=$u();function t(){this.__data__=e?e(null):{},this.size=0}return bh=t,bh}var _h,m_;function F5(){if(m_)return _h;m_=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return _h=e,_h}var kh,g_;function z5(){if(g_)return kh;g_=1;var e=$u(),t="__lodash_hash_undefined__",n=Object.prototype,s=n.hasOwnProperty;function o(a){var l=this.__data__;if(e){var u=l[a];return u===t?void 0:u}return s.call(l,a)?l[a]:void 0}return kh=o,kh}var Sh,v_;function B5(){if(v_)return Sh;v_=1;var e=$u(),t=Object.prototype,n=t.hasOwnProperty;function s(o){var a=this.__data__;return e?a[o]!==void 0:n.call(a,o)}return Sh=s,Sh}var Nh,y_;function U5(){if(y_)return Nh;y_=1;var e=$u(),t="__lodash_hash_undefined__";function n(s,o){var a=this.__data__;return this.size+=this.has(s)?0:1,a[s]=e&&o===void 0?t:o,this}return Nh=n,Nh}var Eh,w_;function W5(){if(w_)return Eh;w_=1;var e=D5(),t=F5(),n=z5(),s=B5(),o=U5();function a(l){var u=-1,h=l==null?0:l.length;for(this.clear();++u<h;){var p=l[u];this.set(p[0],p[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=s,a.prototype.set=o,Eh=a,Eh}var jh,x_;function H5(){if(x_)return jh;x_=1;var e=W5(),t=Pu(),n=Cw();function s(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return jh=s,jh}var Ch,b_;function G5(){if(b_)return Ch;b_=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return Ch=e,Ch}var Th,__;function Lu(){if(__)return Th;__=1;var e=G5();function t(n,s){var o=n.__data__;return e(s)?o[typeof s=="string"?"string":"hash"]:o.map}return Th=t,Th}var Rh,k_;function V5(){if(k_)return Rh;k_=1;var e=Lu();function t(n){var s=e(this,n).delete(n);return this.size-=s?1:0,s}return Rh=t,Rh}var Ah,S_;function Y5(){if(S_)return Ah;S_=1;var e=Lu();function t(n){return e(this,n).get(n)}return Ah=t,Ah}var Mh,N_;function K5(){if(N_)return Mh;N_=1;var e=Lu();function t(n){return e(this,n).has(n)}return Mh=t,Mh}var Ih,E_;function X5(){if(E_)return Ih;E_=1;var e=Lu();function t(n,s){var o=e(this,n),a=o.size;return o.set(n,s),this.size+=o.size==a?0:1,this}return Ih=t,Ih}var Oh,j_;function Tw(){if(j_)return Oh;j_=1;var e=H5(),t=V5(),n=Y5(),s=K5(),o=X5();function a(l){var u=-1,h=l==null?0:l.length;for(this.clear();++u<h;){var p=l[u];this.set(p[0],p[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=s,a.prototype.set=o,Oh=a,Oh}var Ph,C_;function Q5(){if(C_)return Ph;C_=1;var e=Pu(),t=Cw(),n=Tw(),s=200;function o(a,l){var u=this.__data__;if(u instanceof e){var h=u.__data__;if(!t||h.length<s-1)return h.push([a,l]),this.size=++u.size,this;u=this.__data__=new n(h)}return u.set(a,l),this.size=u.size,this}return Ph=o,Ph}var $h,T_;function qu(){if(T_)return $h;T_=1;var e=Pu(),t=T5(),n=R5(),s=A5(),o=M5(),a=Q5();function l(u){var h=this.__data__=new e(u);this.size=h.size}return l.prototype.clear=t,l.prototype.delete=n,l.prototype.get=s,l.prototype.has=o,l.prototype.set=a,$h=l,$h}var Lh,R_;function Rw(){if(R_)return Lh;R_=1;function e(t,n){for(var s=-1,o=t==null?0:t.length;++s<o&&n(t[s],s,t)!==!1;);return t}return Lh=e,Lh}var qh,A_;function OT(){if(A_)return qh;A_=1;var e=_i(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return qh=t,qh}var Dh,M_;function Du(){if(M_)return Dh;M_=1;var e=OT();function t(n,s,o){s=="__proto__"&&e?e(n,s,{configurable:!0,enumerable:!0,value:o,writable:!0}):n[s]=o}return Dh=t,Dh}var Fh,I_;function Fu(){if(I_)return Fh;I_=1;var e=Du(),t=Wo(),n=Object.prototype,s=n.hasOwnProperty;function o(a,l,u){var h=a[l];(!(s.call(a,l)&&t(h,u))||u===void 0&&!(l in a))&&e(a,l,u)}return Fh=o,Fh}var zh,O_;function wl(){if(O_)return zh;O_=1;var e=Fu(),t=Du();function n(s,o,a,l){var u=!a;a||(a={});for(var h=-1,p=o.length;++h<p;){var f=o[h],g=l?l(a[f],s[f],f,a,s):void 0;g===void 0&&(g=s[f]),u?t(a,f,g):e(a,f,g)}return a}return zh=n,zh}var Bh,P_;function Z5(){if(P_)return Bh;P_=1;function e(t,n){for(var s=-1,o=Array(t);++s<t;)o[s]=n(s);return o}return Bh=e,Bh}var Uh,$_;function Er(){if($_)return Uh;$_=1;function e(t){return t!=null&&typeof t=="object"}return Uh=e,Uh}var Wh,L_;function J5(){if(L_)return Wh;L_=1;var e=bi(),t=Er(),n="[object Arguments]";function s(o){return t(o)&&e(o)==n}return Wh=s,Wh}var Hh,q_;function xl(){if(q_)return Hh;q_=1;var e=J5(),t=Er(),n=Object.prototype,s=n.hasOwnProperty,o=n.propertyIsEnumerable,a=e((function(){return arguments})())?e:function(l){return t(l)&&s.call(l,"callee")&&!o.call(l,"callee")};return Hh=a,Hh}var Gh,D_;function Rt(){if(D_)return Gh;D_=1;var e=Array.isArray;return Gh=e,Gh}var Ga={exports:{}},Vh,F_;function eF(){if(F_)return Vh;F_=1;function e(){return!1}return Vh=e,Vh}Ga.exports;var z_;function Go(){return z_||(z_=1,(function(e,t){var n=ur(),s=eF(),o=t&&!t.nodeType&&t,a=o&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===o,u=l?n.Buffer:void 0,h=u?u.isBuffer:void 0,p=h||s;e.exports=p})(Ga,Ga.exports)),Ga.exports}var Yh,B_;function zu(){if(B_)return Yh;B_=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(s,o){var a=typeof s;return o=o??e,!!o&&(a=="number"||a!="symbol"&&t.test(s))&&s>-1&&s%1==0&&s<o}return Yh=n,Yh}var Kh,U_;function Aw(){if(U_)return Kh;U_=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return Kh=t,Kh}var Xh,W_;function tF(){if(W_)return Xh;W_=1;var e=bi(),t=Aw(),n=Er(),s="[object Arguments]",o="[object Array]",a="[object Boolean]",l="[object Date]",u="[object Error]",h="[object Function]",p="[object Map]",f="[object Number]",g="[object Object]",y="[object RegExp]",w="[object Set]",S="[object String]",b="[object WeakMap]",_="[object ArrayBuffer]",k="[object DataView]",N="[object Float32Array]",j="[object Float64Array]",T="[object Int8Array]",M="[object Int16Array]",P="[object Int32Array]",I="[object Uint8Array]",F="[object Uint8ClampedArray]",O="[object Uint16Array]",A="[object Uint32Array]",D={};D[N]=D[j]=D[T]=D[M]=D[P]=D[I]=D[F]=D[O]=D[A]=!0,D[s]=D[o]=D[_]=D[a]=D[k]=D[l]=D[u]=D[h]=D[p]=D[f]=D[g]=D[y]=D[w]=D[S]=D[b]=!1;function H(K){return n(K)&&t(K.length)&&!!D[e(K)]}return Xh=H,Xh}var Qh,H_;function Bu(){if(H_)return Qh;H_=1;function e(t){return function(n){return t(n)}}return Qh=e,Qh}var Va={exports:{}};Va.exports;var G_;function Mw(){return G_||(G_=1,(function(e,t){var n=MT(),s=t&&!t.nodeType&&t,o=s&&!0&&e&&!e.nodeType&&e,a=o&&o.exports===s,l=a&&n.process,u=(function(){try{var h=o&&o.require&&o.require("util").types;return h||l&&l.binding&&l.binding("util")}catch{}})();e.exports=u})(Va,Va.exports)),Va.exports}var Zh,V_;function bl(){if(V_)return Zh;V_=1;var e=tF(),t=Bu(),n=Mw(),s=n&&n.isTypedArray,o=s?t(s):e;return Zh=o,Zh}var Jh,Y_;function PT(){if(Y_)return Jh;Y_=1;var e=Z5(),t=xl(),n=Rt(),s=Go(),o=zu(),a=bl(),l=Object.prototype,u=l.hasOwnProperty;function h(p,f){var g=n(p),y=!g&&t(p),w=!g&&!y&&s(p),S=!g&&!y&&!w&&a(p),b=g||y||w||S,_=b?e(p.length,String):[],k=_.length;for(var N in p)(f||u.call(p,N))&&!(b&&(N=="length"||w&&(N=="offset"||N=="parent")||S&&(N=="buffer"||N=="byteLength"||N=="byteOffset")||o(N,k)))&&_.push(N);return _}return Jh=h,Jh}var ep,K_;function Uu(){if(K_)return ep;K_=1;var e=Object.prototype;function t(n){var s=n&&n.constructor,o=typeof s=="function"&&s.prototype||e;return n===o}return ep=t,ep}var tp,X_;function $T(){if(X_)return tp;X_=1;function e(t,n){return function(s){return t(n(s))}}return tp=e,tp}var np,Q_;function nF(){if(Q_)return np;Q_=1;var e=$T(),t=e(Object.keys,Object);return np=t,np}var rp,Z_;function Iw(){if(Z_)return rp;Z_=1;var e=Uu(),t=nF(),n=Object.prototype,s=n.hasOwnProperty;function o(a){if(!e(a))return t(a);var l=[];for(var u in Object(a))s.call(a,u)&&u!="constructor"&&l.push(u);return l}return rp=o,rp}var sp,J_;function Qr(){if(J_)return sp;J_=1;var e=yl(),t=Aw();function n(s){return s!=null&&t(s.length)&&!e(s)}return sp=n,sp}var ip,ek;function Ms(){if(ek)return ip;ek=1;var e=PT(),t=Iw(),n=Qr();function s(o){return n(o)?e(o):t(o)}return ip=s,ip}var op,tk;function rF(){if(tk)return op;tk=1;var e=wl(),t=Ms();function n(s,o){return s&&e(o,t(o),s)}return op=n,op}var ap,nk;function sF(){if(nk)return ap;nk=1;function e(t){var n=[];if(t!=null)for(var s in Object(t))n.push(s);return n}return ap=e,ap}var lp,rk;function iF(){if(rk)return lp;rk=1;var e=qn(),t=Uu(),n=sF(),s=Object.prototype,o=s.hasOwnProperty;function a(l){if(!e(l))return n(l);var u=t(l),h=[];for(var p in l)p=="constructor"&&(u||!o.call(l,p))||h.push(p);return h}return lp=a,lp}var cp,sk;function ki(){if(sk)return cp;sk=1;var e=PT(),t=iF(),n=Qr();function s(o){return n(o)?e(o,!0):t(o)}return cp=s,cp}var up,ik;function oF(){if(ik)return up;ik=1;var e=wl(),t=ki();function n(s,o){return s&&e(o,t(o),s)}return up=n,up}var Ya={exports:{}};Ya.exports;var ok;function LT(){return ok||(ok=1,(function(e,t){var n=ur(),s=t&&!t.nodeType&&t,o=s&&!0&&e&&!e.nodeType&&e,a=o&&o.exports===s,l=a?n.Buffer:void 0,u=l?l.allocUnsafe:void 0;function h(p,f){if(f)return p.slice();var g=p.length,y=u?u(g):new p.constructor(g);return p.copy(y),y}e.exports=h})(Ya,Ya.exports)),Ya.exports}var dp,ak;function qT(){if(ak)return dp;ak=1;function e(t,n){var s=-1,o=t.length;for(n||(n=Array(o));++s<o;)n[s]=t[s];return n}return dp=e,dp}var fp,lk;function DT(){if(lk)return fp;lk=1;function e(t,n){for(var s=-1,o=t==null?0:t.length,a=0,l=[];++s<o;){var u=t[s];n(u,s,t)&&(l[a++]=u)}return l}return fp=e,fp}var hp,ck;function FT(){if(ck)return hp;ck=1;function e(){return[]}return hp=e,hp}var pp,uk;function Ow(){if(uk)return pp;uk=1;var e=DT(),t=FT(),n=Object.prototype,s=n.propertyIsEnumerable,o=Object.getOwnPropertySymbols,a=o?function(l){return l==null?[]:(l=Object(l),e(o(l),function(u){return s.call(l,u)}))}:t;return pp=a,pp}var mp,dk;function aF(){if(dk)return mp;dk=1;var e=wl(),t=Ow();function n(s,o){return e(s,t(s),o)}return mp=n,mp}var gp,fk;function Pw(){if(fk)return gp;fk=1;function e(t,n){for(var s=-1,o=n.length,a=t.length;++s<o;)t[a+s]=n[s];return t}return gp=e,gp}var vp,hk;function Wu(){if(hk)return vp;hk=1;var e=$T(),t=e(Object.getPrototypeOf,Object);return vp=t,vp}var yp,pk;function zT(){if(pk)return yp;pk=1;var e=Pw(),t=Wu(),n=Ow(),s=FT(),o=Object.getOwnPropertySymbols,a=o?function(l){for(var u=[];l;)e(u,n(l)),l=t(l);return u}:s;return yp=a,yp}var wp,mk;function lF(){if(mk)return wp;mk=1;var e=wl(),t=zT();function n(s,o){return e(s,t(s),o)}return wp=n,wp}var xp,gk;function BT(){if(gk)return xp;gk=1;var e=Pw(),t=Rt();function n(s,o,a){var l=o(s);return t(s)?l:e(l,a(s))}return xp=n,xp}var bp,vk;function UT(){if(vk)return bp;vk=1;var e=BT(),t=Ow(),n=Ms();function s(o){return e(o,n,t)}return bp=s,bp}var _p,yk;function cF(){if(yk)return _p;yk=1;var e=BT(),t=zT(),n=ki();function s(o){return e(o,n,t)}return _p=s,_p}var kp,wk;function uF(){if(wk)return kp;wk=1;var e=_i(),t=ur(),n=e(t,"DataView");return kp=n,kp}var Sp,xk;function dF(){if(xk)return Sp;xk=1;var e=_i(),t=ur(),n=e(t,"Promise");return Sp=n,Sp}var Np,bk;function WT(){if(bk)return Np;bk=1;var e=_i(),t=ur(),n=e(t,"Set");return Np=n,Np}var Ep,_k;function fF(){if(_k)return Ep;_k=1;var e=_i(),t=ur(),n=e(t,"WeakMap");return Ep=n,Ep}var jp,kk;function Vo(){if(kk)return jp;kk=1;var e=uF(),t=Cw(),n=dF(),s=WT(),o=fF(),a=bi(),l=IT(),u="[object Map]",h="[object Object]",p="[object Promise]",f="[object Set]",g="[object WeakMap]",y="[object DataView]",w=l(e),S=l(t),b=l(n),_=l(s),k=l(o),N=a;return(e&&N(new e(new ArrayBuffer(1)))!=y||t&&N(new t)!=u||n&&N(n.resolve())!=p||s&&N(new s)!=f||o&&N(new o)!=g)&&(N=function(j){var T=a(j),M=T==h?j.constructor:void 0,P=M?l(M):"";if(P)switch(P){case w:return y;case S:return u;case b:return p;case _:return f;case k:return g}return T}),jp=N,jp}var Cp,Sk;function hF(){if(Sk)return Cp;Sk=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s){var o=s.length,a=new s.constructor(o);return o&&typeof s[0]=="string"&&t.call(s,"index")&&(a.index=s.index,a.input=s.input),a}return Cp=n,Cp}var Tp,Nk;function HT(){if(Nk)return Tp;Nk=1;var e=ur(),t=e.Uint8Array;return Tp=t,Tp}var Rp,Ek;function $w(){if(Ek)return Rp;Ek=1;var e=HT();function t(n){var s=new n.constructor(n.byteLength);return new e(s).set(new e(n)),s}return Rp=t,Rp}var Ap,jk;function pF(){if(jk)return Ap;jk=1;var e=$w();function t(n,s){var o=s?e(n.buffer):n.buffer;return new n.constructor(o,n.byteOffset,n.byteLength)}return Ap=t,Ap}var Mp,Ck;function mF(){if(Ck)return Mp;Ck=1;var e=/\w*$/;function t(n){var s=new n.constructor(n.source,e.exec(n));return s.lastIndex=n.lastIndex,s}return Mp=t,Mp}var Ip,Tk;function gF(){if(Tk)return Ip;Tk=1;var e=Ho(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function s(o){return n?Object(n.call(o)):{}}return Ip=s,Ip}var Op,Rk;function GT(){if(Rk)return Op;Rk=1;var e=$w();function t(n,s){var o=s?e(n.buffer):n.buffer;return new n.constructor(o,n.byteOffset,n.length)}return Op=t,Op}var Pp,Ak;function vF(){if(Ak)return Pp;Ak=1;var e=$w(),t=pF(),n=mF(),s=gF(),o=GT(),a="[object Boolean]",l="[object Date]",u="[object Map]",h="[object Number]",p="[object RegExp]",f="[object Set]",g="[object String]",y="[object Symbol]",w="[object ArrayBuffer]",S="[object DataView]",b="[object Float32Array]",_="[object Float64Array]",k="[object Int8Array]",N="[object Int16Array]",j="[object Int32Array]",T="[object Uint8Array]",M="[object Uint8ClampedArray]",P="[object Uint16Array]",I="[object Uint32Array]";function F(O,A,D){var H=O.constructor;switch(A){case w:return e(O);case a:case l:return new H(+O);case S:return t(O,D);case b:case _:case k:case N:case j:case T:case M:case P:case I:return o(O,D);case u:return new H;case h:case g:return new H(O);case p:return n(O);case f:return new H;case y:return s(O)}}return Pp=F,Pp}var $p,Mk;function VT(){if(Mk)return $p;Mk=1;var e=qn(),t=Object.create,n=(function(){function s(){}return function(o){if(!e(o))return{};if(t)return t(o);s.prototype=o;var a=new s;return s.prototype=void 0,a}})();return $p=n,$p}var Lp,Ik;function YT(){if(Ik)return Lp;Ik=1;var e=VT(),t=Wu(),n=Uu();function s(o){return typeof o.constructor=="function"&&!n(o)?e(t(o)):{}}return Lp=s,Lp}var qp,Ok;function yF(){if(Ok)return qp;Ok=1;var e=Vo(),t=Er(),n="[object Map]";function s(o){return t(o)&&e(o)==n}return qp=s,qp}var Dp,Pk;function wF(){if(Pk)return Dp;Pk=1;var e=yF(),t=Bu(),n=Mw(),s=n&&n.isMap,o=s?t(s):e;return Dp=o,Dp}var Fp,$k;function xF(){if($k)return Fp;$k=1;var e=Vo(),t=Er(),n="[object Set]";function s(o){return t(o)&&e(o)==n}return Fp=s,Fp}var zp,Lk;function bF(){if(Lk)return zp;Lk=1;var e=xF(),t=Bu(),n=Mw(),s=n&&n.isSet,o=s?t(s):e;return zp=o,zp}var Bp,qk;function KT(){if(qk)return Bp;qk=1;var e=qu(),t=Rw(),n=Fu(),s=rF(),o=oF(),a=LT(),l=qT(),u=aF(),h=lF(),p=UT(),f=cF(),g=Vo(),y=hF(),w=vF(),S=YT(),b=Rt(),_=Go(),k=wF(),N=qn(),j=bF(),T=Ms(),M=ki(),P=1,I=2,F=4,O="[object Arguments]",A="[object Array]",D="[object Boolean]",H="[object Date]",K="[object Error]",C="[object Function]",X="[object GeneratorFunction]",B="[object Map]",ne="[object Number]",J="[object Object]",W="[object RegExp]",Q="[object Set]",$="[object String]",G="[object Symbol]",Y="[object WeakMap]",L="[object ArrayBuffer]",q="[object DataView]",Z="[object Float32Array]",se="[object Float64Array]",fe="[object Int8Array]",he="[object Int16Array]",ye="[object Int32Array]",Re="[object Uint8Array]",Ue="[object Uint8ClampedArray]",De="[object Uint16Array]",Ie="[object Uint32Array]",ke={};ke[O]=ke[A]=ke[L]=ke[q]=ke[D]=ke[H]=ke[Z]=ke[se]=ke[fe]=ke[he]=ke[ye]=ke[B]=ke[ne]=ke[J]=ke[W]=ke[Q]=ke[$]=ke[G]=ke[Re]=ke[Ue]=ke[De]=ke[Ie]=!0,ke[K]=ke[C]=ke[Y]=!1;function ce(xe,we,Ye,yt,ct,st){var Be,tt=we&P,Ke=we&I,_t=we&F;if(Ye&&(Be=ct?Ye(xe,yt,ct,st):Ye(xe)),Be!==void 0)return Be;if(!N(xe))return xe;var Me=b(xe);if(Me){if(Be=y(xe),!tt)return l(xe,Be)}else{var it=g(xe),At=it==C||it==X;if(_(xe))return a(xe,tt);if(it==J||it==O||At&&!ct){if(Be=Ke||At?{}:S(xe),!tt)return Ke?h(xe,o(Be,xe)):u(xe,s(Be,xe))}else{if(!ke[it])return ct?xe:{};Be=w(xe,it,tt)}}st||(st=new e);var oe=st.get(xe);if(oe)return oe;st.set(xe,Be),j(xe)?xe.forEach(function(Ne){Be.add(ce(Ne,we,Ye,Ne,xe,st))}):k(xe)&&xe.forEach(function(Ne,We){Be.set(We,ce(Ne,we,Ye,We,xe,st))});var Pe=_t?Ke?f:p:Ke?M:T,qe=Me?void 0:Pe(xe);return t(qe||xe,function(Ne,We){qe&&(We=Ne,Ne=xe[We]),n(Be,We,ce(Ne,we,Ye,We,xe,st))}),Be}return Bp=ce,Bp}var Up,Dk;function _F(){if(Dk)return Up;Dk=1;var e=KT(),t=4;function n(s){return e(s,t)}return Up=n,Up}var Wp,Fk;function Lw(){if(Fk)return Wp;Fk=1;function e(t){return function(){return t}}return Wp=e,Wp}var Hp,zk;function kF(){if(zk)return Hp;zk=1;function e(t){return function(n,s,o){for(var a=-1,l=Object(n),u=o(n),h=u.length;h--;){var p=u[t?h:++a];if(s(l[p],p,l)===!1)break}return n}}return Hp=e,Hp}var Gp,Bk;function qw(){if(Bk)return Gp;Bk=1;var e=kF(),t=e();return Gp=t,Gp}var Vp,Uk;function Dw(){if(Uk)return Vp;Uk=1;var e=qw(),t=Ms();function n(s,o){return s&&e(s,o,t)}return Vp=n,Vp}var Yp,Wk;function SF(){if(Wk)return Yp;Wk=1;var e=Qr();function t(n,s){return function(o,a){if(o==null)return o;if(!e(o))return n(o,a);for(var l=o.length,u=s?l:-1,h=Object(o);(s?u--:++u<l)&&a(h[u],u,h)!==!1;);return o}}return Yp=t,Yp}var Kp,Hk;function Hu(){if(Hk)return Kp;Hk=1;var e=Dw(),t=SF(),n=t(e);return Kp=n,Kp}var Xp,Gk;function Si(){if(Gk)return Xp;Gk=1;function e(t){return t}return Xp=e,Xp}var Qp,Vk;function XT(){if(Vk)return Qp;Vk=1;var e=Si();function t(n){return typeof n=="function"?n:e}return Qp=t,Qp}var Zp,Yk;function QT(){if(Yk)return Zp;Yk=1;var e=Rw(),t=Hu(),n=XT(),s=Rt();function o(a,l){var u=s(a)?e:t;return u(a,n(l))}return Zp=o,Zp}var Jp,Kk;function ZT(){return Kk||(Kk=1,Jp=QT()),Jp}var em,Xk;function NF(){if(Xk)return em;Xk=1;var e=Hu();function t(n,s){var o=[];return e(n,function(a,l,u){s(a,l,u)&&o.push(a)}),o}return em=t,em}var tm,Qk;function EF(){if(Qk)return tm;Qk=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return tm=t,tm}var nm,Zk;function jF(){if(Zk)return nm;Zk=1;function e(t){return this.__data__.has(t)}return nm=e,nm}var rm,Jk;function JT(){if(Jk)return rm;Jk=1;var e=Tw(),t=EF(),n=jF();function s(o){var a=-1,l=o==null?0:o.length;for(this.__data__=new e;++a<l;)this.add(o[a])}return s.prototype.add=s.prototype.push=t,s.prototype.has=n,rm=s,rm}var sm,eS;function CF(){if(eS)return sm;eS=1;function e(t,n){for(var s=-1,o=t==null?0:t.length;++s<o;)if(n(t[s],s,t))return!0;return!1}return sm=e,sm}var im,tS;function eR(){if(tS)return im;tS=1;function e(t,n){return t.has(n)}return im=e,im}var om,nS;function tR(){if(nS)return om;nS=1;var e=JT(),t=CF(),n=eR(),s=1,o=2;function a(l,u,h,p,f,g){var y=h&s,w=l.length,S=u.length;if(w!=S&&!(y&&S>w))return!1;var b=g.get(l),_=g.get(u);if(b&&_)return b==u&&_==l;var k=-1,N=!0,j=h&o?new e:void 0;for(g.set(l,u),g.set(u,l);++k<w;){var T=l[k],M=u[k];if(p)var P=y?p(M,T,k,u,l,g):p(T,M,k,l,u,g);if(P!==void 0){if(P)continue;N=!1;break}if(j){if(!t(u,function(I,F){if(!n(j,F)&&(T===I||f(T,I,h,p,g)))return j.push(F)})){N=!1;break}}else if(!(T===M||f(T,M,h,p,g))){N=!1;break}}return g.delete(l),g.delete(u),N}return om=a,om}var am,rS;function TF(){if(rS)return am;rS=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(o,a){s[++n]=[a,o]}),s}return am=e,am}var lm,sS;function Fw(){if(sS)return lm;sS=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(o){s[++n]=o}),s}return lm=e,lm}var cm,iS;function RF(){if(iS)return cm;iS=1;var e=Ho(),t=HT(),n=Wo(),s=tR(),o=TF(),a=Fw(),l=1,u=2,h="[object Boolean]",p="[object Date]",f="[object Error]",g="[object Map]",y="[object Number]",w="[object RegExp]",S="[object Set]",b="[object String]",_="[object Symbol]",k="[object ArrayBuffer]",N="[object DataView]",j=e?e.prototype:void 0,T=j?j.valueOf:void 0;function M(P,I,F,O,A,D,H){switch(F){case N:if(P.byteLength!=I.byteLength||P.byteOffset!=I.byteOffset)return!1;P=P.buffer,I=I.buffer;case k:return!(P.byteLength!=I.byteLength||!D(new t(P),new t(I)));case h:case p:case y:return n(+P,+I);case f:return P.name==I.name&&P.message==I.message;case w:case b:return P==I+"";case g:var K=o;case S:var C=O&l;if(K||(K=a),P.size!=I.size&&!C)return!1;var X=H.get(P);if(X)return X==I;O|=u,H.set(P,I);var B=s(K(P),K(I),O,A,D,H);return H.delete(P),B;case _:if(T)return T.call(P)==T.call(I)}return!1}return cm=M,cm}var um,oS;function AF(){if(oS)return um;oS=1;var e=UT(),t=1,n=Object.prototype,s=n.hasOwnProperty;function o(a,l,u,h,p,f){var g=u&t,y=e(a),w=y.length,S=e(l),b=S.length;if(w!=b&&!g)return!1;for(var _=w;_--;){var k=y[_];if(!(g?k in l:s.call(l,k)))return!1}var N=f.get(a),j=f.get(l);if(N&&j)return N==l&&j==a;var T=!0;f.set(a,l),f.set(l,a);for(var M=g;++_<w;){k=y[_];var P=a[k],I=l[k];if(h)var F=g?h(I,P,k,l,a,f):h(P,I,k,a,l,f);if(!(F===void 0?P===I||p(P,I,u,h,f):F)){T=!1;break}M||(M=k=="constructor")}if(T&&!M){var O=a.constructor,A=l.constructor;O!=A&&"constructor"in a&&"constructor"in l&&!(typeof O=="function"&&O instanceof O&&typeof A=="function"&&A instanceof A)&&(T=!1)}return f.delete(a),f.delete(l),T}return um=o,um}var dm,aS;function MF(){if(aS)return dm;aS=1;var e=qu(),t=tR(),n=RF(),s=AF(),o=Vo(),a=Rt(),l=Go(),u=bl(),h=1,p="[object Arguments]",f="[object Array]",g="[object Object]",y=Object.prototype,w=y.hasOwnProperty;function S(b,_,k,N,j,T){var M=a(b),P=a(_),I=M?f:o(b),F=P?f:o(_);I=I==p?g:I,F=F==p?g:F;var O=I==g,A=F==g,D=I==F;if(D&&l(b)){if(!l(_))return!1;M=!0,O=!1}if(D&&!O)return T||(T=new e),M||u(b)?t(b,_,k,N,j,T):n(b,_,I,k,N,j,T);if(!(k&h)){var H=O&&w.call(b,"__wrapped__"),K=A&&w.call(_,"__wrapped__");if(H||K){var C=H?b.value():b,X=K?_.value():_;return T||(T=new e),j(C,X,k,N,T)}}return D?(T||(T=new e),s(b,_,k,N,j,T)):!1}return dm=S,dm}var fm,lS;function nR(){if(lS)return fm;lS=1;var e=MF(),t=Er();function n(s,o,a,l,u){return s===o?!0:s==null||o==null||!t(s)&&!t(o)?s!==s&&o!==o:e(s,o,a,l,n,u)}return fm=n,fm}var hm,cS;function IF(){if(cS)return hm;cS=1;var e=qu(),t=nR(),n=1,s=2;function o(a,l,u,h){var p=u.length,f=p,g=!h;if(a==null)return!f;for(a=Object(a);p--;){var y=u[p];if(g&&y[2]?y[1]!==a[y[0]]:!(y[0]in a))return!1}for(;++p<f;){y=u[p];var w=y[0],S=a[w],b=y[1];if(g&&y[2]){if(S===void 0&&!(w in a))return!1}else{var _=new e;if(h)var k=h(S,b,w,a,l,_);if(!(k===void 0?t(b,S,n|s,h,_):k))return!1}}return!0}return hm=o,hm}var pm,uS;function rR(){if(uS)return pm;uS=1;var e=qn();function t(n){return n===n&&!e(n)}return pm=t,pm}var mm,dS;function OF(){if(dS)return mm;dS=1;var e=rR(),t=Ms();function n(s){for(var o=t(s),a=o.length;a--;){var l=o[a],u=s[l];o[a]=[l,u,e(u)]}return o}return mm=n,mm}var gm,fS;function sR(){if(fS)return gm;fS=1;function e(t,n){return function(s){return s==null?!1:s[t]===n&&(n!==void 0||t in Object(s))}}return gm=e,gm}var vm,hS;function PF(){if(hS)return vm;hS=1;var e=IF(),t=OF(),n=sR();function s(o){var a=t(o);return a.length==1&&a[0][2]?n(a[0][0],a[0][1]):function(l){return l===o||e(l,o,a)}}return vm=s,vm}var ym,pS;function Yo(){if(pS)return ym;pS=1;var e=bi(),t=Er(),n="[object Symbol]";function s(o){return typeof o=="symbol"||t(o)&&e(o)==n}return ym=s,ym}var wm,mS;function zw(){if(mS)return wm;mS=1;var e=Rt(),t=Yo(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function o(a,l){if(e(a))return!1;var u=typeof a;return u=="number"||u=="symbol"||u=="boolean"||a==null||t(a)?!0:s.test(a)||!n.test(a)||l!=null&&a in Object(l)}return wm=o,wm}var xm,gS;function $F(){if(gS)return xm;gS=1;var e=Tw(),t="Expected a function";function n(s,o){if(typeof s!="function"||o!=null&&typeof o!="function")throw new TypeError(t);var a=function(){var l=arguments,u=o?o.apply(this,l):l[0],h=a.cache;if(h.has(u))return h.get(u);var p=s.apply(this,l);return a.cache=h.set(u,p)||h,p};return a.cache=new(n.Cache||e),a}return n.Cache=e,xm=n,xm}var bm,vS;function LF(){if(vS)return bm;vS=1;var e=$F(),t=500;function n(s){var o=e(s,function(l){return a.size===t&&a.clear(),l}),a=o.cache;return o}return bm=n,bm}var _m,yS;function qF(){if(yS)return _m;yS=1;var e=LF(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,s=e(function(o){var a=[];return o.charCodeAt(0)===46&&a.push(""),o.replace(t,function(l,u,h,p){a.push(h?p.replace(n,"$1"):u||l)}),a});return _m=s,_m}var km,wS;function Gu(){if(wS)return km;wS=1;function e(t,n){for(var s=-1,o=t==null?0:t.length,a=Array(o);++s<o;)a[s]=n(t[s],s,t);return a}return km=e,km}var Sm,xS;function DF(){if(xS)return Sm;xS=1;var e=Ho(),t=Gu(),n=Rt(),s=Yo(),o=e?e.prototype:void 0,a=o?o.toString:void 0;function l(u){if(typeof u=="string")return u;if(n(u))return t(u,l)+"";if(s(u))return a?a.call(u):"";var h=u+"";return h=="0"&&1/u==-1/0?"-0":h}return Sm=l,Sm}var Nm,bS;function iR(){if(bS)return Nm;bS=1;var e=DF();function t(n){return n==null?"":e(n)}return Nm=t,Nm}var Em,_S;function Vu(){if(_S)return Em;_S=1;var e=Rt(),t=zw(),n=qF(),s=iR();function o(a,l){return e(a)?a:t(a,l)?[a]:n(s(a))}return Em=o,Em}var jm,kS;function _l(){if(kS)return jm;kS=1;var e=Yo();function t(n){if(typeof n=="string"||e(n))return n;var s=n+"";return s=="0"&&1/n==-1/0?"-0":s}return jm=t,jm}var Cm,SS;function Yu(){if(SS)return Cm;SS=1;var e=Vu(),t=_l();function n(s,o){o=e(o,s);for(var a=0,l=o.length;s!=null&&a<l;)s=s[t(o[a++])];return a&&a==l?s:void 0}return Cm=n,Cm}var Tm,NS;function FF(){if(NS)return Tm;NS=1;var e=Yu();function t(n,s,o){var a=n==null?void 0:e(n,s);return a===void 0?o:a}return Tm=t,Tm}var Rm,ES;function zF(){if(ES)return Rm;ES=1;function e(t,n){return t!=null&&n in Object(t)}return Rm=e,Rm}var Am,jS;function oR(){if(jS)return Am;jS=1;var e=Vu(),t=xl(),n=Rt(),s=zu(),o=Aw(),a=_l();function l(u,h,p){h=e(h,u);for(var f=-1,g=h.length,y=!1;++f<g;){var w=a(h[f]);if(!(y=u!=null&&p(u,w)))break;u=u[w]}return y||++f!=g?y:(g=u==null?0:u.length,!!g&&o(g)&&s(w,g)&&(n(u)||t(u)))}return Am=l,Am}var Mm,CS;function aR(){if(CS)return Mm;CS=1;var e=zF(),t=oR();function n(s,o){return s!=null&&t(s,o,e)}return Mm=n,Mm}var Im,TS;function BF(){if(TS)return Im;TS=1;var e=nR(),t=FF(),n=aR(),s=zw(),o=rR(),a=sR(),l=_l(),u=1,h=2;function p(f,g){return s(f)&&o(g)?a(l(f),g):function(y){var w=t(y,f);return w===void 0&&w===g?n(y,f):e(g,w,u|h)}}return Im=p,Im}var Om,RS;function lR(){if(RS)return Om;RS=1;function e(t){return function(n){return n==null?void 0:n[t]}}return Om=e,Om}var Pm,AS;function UF(){if(AS)return Pm;AS=1;var e=Yu();function t(n){return function(s){return e(s,n)}}return Pm=t,Pm}var $m,MS;function WF(){if(MS)return $m;MS=1;var e=lR(),t=UF(),n=zw(),s=_l();function o(a){return n(a)?e(s(a)):t(a)}return $m=o,$m}var Lm,IS;function Zr(){if(IS)return Lm;IS=1;var e=PF(),t=BF(),n=Si(),s=Rt(),o=WF();function a(l){return typeof l=="function"?l:l==null?n:typeof l=="object"?s(l)?t(l[0],l[1]):e(l):o(l)}return Lm=a,Lm}var qm,OS;function cR(){if(OS)return qm;OS=1;var e=DT(),t=NF(),n=Zr(),s=Rt();function o(a,l){var u=s(a)?e:t;return u(a,n(l,3))}return qm=o,qm}var Dm,PS;function HF(){if(PS)return Dm;PS=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s,o){return s!=null&&t.call(s,o)}return Dm=n,Dm}var Fm,$S;function uR(){if($S)return Fm;$S=1;var e=HF(),t=oR();function n(s,o){return s!=null&&t(s,o,e)}return Fm=n,Fm}var zm,LS;function GF(){if(LS)return zm;LS=1;var e=Iw(),t=Vo(),n=xl(),s=Rt(),o=Qr(),a=Go(),l=Uu(),u=bl(),h="[object Map]",p="[object Set]",f=Object.prototype,g=f.hasOwnProperty;function y(w){if(w==null)return!0;if(o(w)&&(s(w)||typeof w=="string"||typeof w.splice=="function"||a(w)||u(w)||n(w)))return!w.length;var S=t(w);if(S==h||S==p)return!w.size;if(l(w))return!e(w).length;for(var b in w)if(g.call(w,b))return!1;return!0}return zm=y,zm}var Bm,qS;function dR(){if(qS)return Bm;qS=1;function e(t){return t===void 0}return Bm=e,Bm}var Um,DS;function fR(){if(DS)return Um;DS=1;var e=Hu(),t=Qr();function n(s,o){var a=-1,l=t(s)?Array(s.length):[];return e(s,function(u,h,p){l[++a]=o(u,h,p)}),l}return Um=n,Um}var Wm,FS;function hR(){if(FS)return Wm;FS=1;var e=Gu(),t=Zr(),n=fR(),s=Rt();function o(a,l){var u=s(a)?e:n;return u(a,t(l,3))}return Wm=o,Wm}var Hm,zS;function VF(){if(zS)return Hm;zS=1;function e(t,n,s,o){var a=-1,l=t==null?0:t.length;for(o&&l&&(s=t[++a]);++a<l;)s=n(s,t[a],a,t);return s}return Hm=e,Hm}var Gm,BS;function YF(){if(BS)return Gm;BS=1;function e(t,n,s,o,a){return a(t,function(l,u,h){s=o?(o=!1,l):n(s,l,u,h)}),s}return Gm=e,Gm}var Vm,US;function pR(){if(US)return Vm;US=1;var e=VF(),t=Hu(),n=Zr(),s=YF(),o=Rt();function a(l,u,h){var p=o(l)?e:s,f=arguments.length<3;return p(l,n(u,4),h,f,t)}return Vm=a,Vm}var Ym,WS;function KF(){if(WS)return Ym;WS=1;var e=bi(),t=Rt(),n=Er(),s="[object String]";function o(a){return typeof a=="string"||!t(a)&&n(a)&&e(a)==s}return Ym=o,Ym}var Km,HS;function XF(){if(HS)return Km;HS=1;var e=lR(),t=e("length");return Km=t,Km}var Xm,GS;function QF(){if(GS)return Xm;GS=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=t+n+s,a="\\ufe0e\\ufe0f",l="\\u200d",u=RegExp("["+l+e+o+a+"]");function h(p){return u.test(p)}return Xm=h,Xm}var Qm,VS;function ZF(){if(VS)return Qm;VS=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=t+n+s,a="\\ufe0e\\ufe0f",l="["+e+"]",u="["+o+"]",h="\\ud83c[\\udffb-\\udfff]",p="(?:"+u+"|"+h+")",f="[^"+e+"]",g="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",S=p+"?",b="["+a+"]?",_="(?:"+w+"(?:"+[f,g,y].join("|")+")"+b+S+")*",k=b+S+_,N="(?:"+[f+u+"?",u,g,y,l].join("|")+")",j=RegExp(h+"(?="+h+")|"+N+k,"g");function T(M){for(var P=j.lastIndex=0;j.test(M);)++P;return P}return Qm=T,Qm}var Zm,YS;function JF(){if(YS)return Zm;YS=1;var e=XF(),t=QF(),n=ZF();function s(o){return t(o)?n(o):e(o)}return Zm=s,Zm}var Jm,KS;function e6(){if(KS)return Jm;KS=1;var e=Iw(),t=Vo(),n=Qr(),s=KF(),o=JF(),a="[object Map]",l="[object Set]";function u(h){if(h==null)return 0;if(n(h))return s(h)?o(h):h.length;var p=t(h);return p==a||p==l?h.size:e(h).length}return Jm=u,Jm}var eg,XS;function t6(){if(XS)return eg;XS=1;var e=Rw(),t=VT(),n=Dw(),s=Zr(),o=Wu(),a=Rt(),l=Go(),u=yl(),h=qn(),p=bl();function f(g,y,w){var S=a(g),b=S||l(g)||p(g);if(y=s(y,4),w==null){var _=g&&g.constructor;b?w=S?new _:[]:h(g)?w=u(_)?t(o(g)):{}:w={}}return(b?e:n)(g,function(k,N,j){return y(w,k,N,j)}),w}return eg=f,eg}var tg,QS;function n6(){if(QS)return tg;QS=1;var e=Ho(),t=xl(),n=Rt(),s=e?e.isConcatSpreadable:void 0;function o(a){return n(a)||t(a)||!!(s&&a&&a[s])}return tg=o,tg}var ng,ZS;function Bw(){if(ZS)return ng;ZS=1;var e=Pw(),t=n6();function n(s,o,a,l,u){var h=-1,p=s.length;for(a||(a=t),u||(u=[]);++h<p;){var f=s[h];o>0&&a(f)?o>1?n(f,o-1,a,l,u):e(u,f):l||(u[u.length]=f)}return u}return ng=n,ng}var rg,JS;function r6(){if(JS)return rg;JS=1;function e(t,n,s){switch(s.length){case 0:return t.call(n);case 1:return t.call(n,s[0]);case 2:return t.call(n,s[0],s[1]);case 3:return t.call(n,s[0],s[1],s[2])}return t.apply(n,s)}return rg=e,rg}var sg,eN;function mR(){if(eN)return sg;eN=1;var e=r6(),t=Math.max;function n(s,o,a){return o=t(o===void 0?s.length-1:o,0),function(){for(var l=arguments,u=-1,h=t(l.length-o,0),p=Array(h);++u<h;)p[u]=l[o+u];u=-1;for(var f=Array(o+1);++u<o;)f[u]=l[u];return f[o]=a(p),e(s,this,f)}}return sg=n,sg}var ig,tN;function s6(){if(tN)return ig;tN=1;var e=Lw(),t=OT(),n=Si(),s=t?function(o,a){return t(o,"toString",{configurable:!0,enumerable:!1,value:e(a),writable:!0})}:n;return ig=s,ig}var og,nN;function i6(){if(nN)return og;nN=1;var e=800,t=16,n=Date.now;function s(o){var a=0,l=0;return function(){var u=n(),h=t-(u-l);if(l=u,h>0){if(++a>=e)return arguments[0]}else a=0;return o.apply(void 0,arguments)}}return og=s,og}var ag,rN;function gR(){if(rN)return ag;rN=1;var e=s6(),t=i6(),n=t(e);return ag=n,ag}var lg,sN;function Ku(){if(sN)return lg;sN=1;var e=Si(),t=mR(),n=gR();function s(o,a){return n(t(o,a,e),o+"")}return lg=s,lg}var cg,iN;function vR(){if(iN)return cg;iN=1;function e(t,n,s,o){for(var a=t.length,l=s+(o?1:-1);o?l--:++l<a;)if(n(t[l],l,t))return l;return-1}return cg=e,cg}var ug,oN;function o6(){if(oN)return ug;oN=1;function e(t){return t!==t}return ug=e,ug}var dg,aN;function a6(){if(aN)return dg;aN=1;function e(t,n,s){for(var o=s-1,a=t.length;++o<a;)if(t[o]===n)return o;return-1}return dg=e,dg}var fg,lN;function l6(){if(lN)return fg;lN=1;var e=vR(),t=o6(),n=a6();function s(o,a,l){return a===a?n(o,a,l):e(o,t,l)}return fg=s,fg}var hg,cN;function c6(){if(cN)return hg;cN=1;var e=l6();function t(n,s){var o=n==null?0:n.length;return!!o&&e(n,s,0)>-1}return hg=t,hg}var pg,uN;function u6(){if(uN)return pg;uN=1;function e(t,n,s){for(var o=-1,a=t==null?0:t.length;++o<a;)if(s(n,t[o]))return!0;return!1}return pg=e,pg}var mg,dN;function d6(){if(dN)return mg;dN=1;function e(){}return mg=e,mg}var gg,fN;function f6(){if(fN)return gg;fN=1;var e=WT(),t=d6(),n=Fw(),s=1/0,o=e&&1/n(new e([,-0]))[1]==s?function(a){return new e(a)}:t;return gg=o,gg}var vg,hN;function h6(){if(hN)return vg;hN=1;var e=JT(),t=c6(),n=u6(),s=eR(),o=f6(),a=Fw(),l=200;function u(h,p,f){var g=-1,y=t,w=h.length,S=!0,b=[],_=b;if(f)S=!1,y=n;else if(w>=l){var k=p?null:o(h);if(k)return a(k);S=!1,y=s,_=new e}else _=p?[]:b;e:for(;++g<w;){var N=h[g],j=p?p(N):N;if(N=f||N!==0?N:0,S&&j===j){for(var T=_.length;T--;)if(_[T]===j)continue e;p&&_.push(j),b.push(N)}else y(_,j,f)||(_!==b&&_.push(j),b.push(N))}return b}return vg=u,vg}var yg,pN;function yR(){if(pN)return yg;pN=1;var e=Qr(),t=Er();function n(s){return t(s)&&e(s)}return yg=n,yg}var wg,mN;function p6(){if(mN)return wg;mN=1;var e=Bw(),t=Ku(),n=h6(),s=yR(),o=t(function(a){return n(e(a,1,s,!0))});return wg=o,wg}var xg,gN;function m6(){if(gN)return xg;gN=1;var e=Gu();function t(n,s){return e(s,function(o){return n[o]})}return xg=t,xg}var bg,vN;function wR(){if(vN)return bg;vN=1;var e=m6(),t=Ms();function n(s){return s==null?[]:e(s,t(s))}return bg=n,bg}var _g,yN;function Dn(){if(yN)return _g;yN=1;var e;if(typeof jw=="function")try{e={clone:_F(),constant:Lw(),each:ZT(),filter:cR(),has:uR(),isArray:Rt(),isEmpty:GF(),isFunction:yl(),isUndefined:dR(),keys:Ms(),map:hR(),reduce:pR(),size:e6(),transform:t6(),union:p6(),values:wR()}}catch{}return e||(e=window._),_g=e,_g}var kg,wN;function Uw(){if(wN)return kg;wN=1;var e=Dn();kg=o;var t="\0",n="\0",s="";function o(f){this._isDirected=e.has(f,"directed")?f.directed:!0,this._isMultigraph=e.has(f,"multigraph")?f.multigraph:!1,this._isCompound=e.has(f,"compound")?f.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[n]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(f){return this._label=f,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultNodeLabelFn=f,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var f=this;return e.filter(this.nodes(),function(g){return e.isEmpty(f._in[g])})},o.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(g){return e.isEmpty(f._out[g])})},o.prototype.setNodes=function(f,g){var y=arguments,w=this;return e.each(f,function(S){y.length>1?w.setNode(S,g):w.setNode(S)}),this},o.prototype.setNode=function(f,g){return e.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=g),this):(this._nodes[f]=arguments.length>1?g:this._defaultNodeLabelFn(f),this._isCompound&&(this._parent[f]=n,this._children[f]={},this._children[n][f]=!0),this._in[f]={},this._preds[f]={},this._out[f]={},this._sucs[f]={},++this._nodeCount,this)},o.prototype.node=function(f){return this._nodes[f]},o.prototype.hasNode=function(f){return e.has(this._nodes,f)},o.prototype.removeNode=function(f){var g=this;if(e.has(this._nodes,f)){var y=function(w){g.removeEdge(g._edgeObjs[w])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(w){g.setParent(w)}),delete this._children[f]),e.each(e.keys(this._in[f]),y),delete this._in[f],delete this._preds[f],e.each(e.keys(this._out[f]),y),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},o.prototype.setParent=function(f,g){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(g))g=n;else{g+="";for(var y=g;!e.isUndefined(y);y=this.parent(y))if(y===f)throw new Error("Setting "+g+" as parent of "+f+" would create a cycle");this.setNode(g)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=g,this._children[g][f]=!0,this},o.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},o.prototype.parent=function(f){if(this._isCompound){var g=this._parent[f];if(g!==n)return g}},o.prototype.children=function(f){if(e.isUndefined(f)&&(f=n),this._isCompound){var g=this._children[f];if(g)return e.keys(g)}else{if(f===n)return this.nodes();if(this.hasNode(f))return[]}},o.prototype.predecessors=function(f){var g=this._preds[f];if(g)return e.keys(g)},o.prototype.successors=function(f){var g=this._sucs[f];if(g)return e.keys(g)},o.prototype.neighbors=function(f){var g=this.predecessors(f);if(g)return e.union(g,this.successors(f))},o.prototype.isLeaf=function(f){var g;return this.isDirected()?g=this.successors(f):g=this.neighbors(f),g.length===0},o.prototype.filterNodes=function(f){var g=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});g.setGraph(this.graph());var y=this;e.each(this._nodes,function(b,_){f(_)&&g.setNode(_,b)}),e.each(this._edgeObjs,function(b){g.hasNode(b.v)&&g.hasNode(b.w)&&g.setEdge(b,y.edge(b))});var w={};function S(b){var _=y.parent(b);return _===void 0||g.hasNode(_)?(w[b]=_,_):_ in w?w[_]:S(_)}return this._isCompound&&e.each(g.nodes(),function(b){g.setParent(b,S(b))}),g},o.prototype.setDefaultEdgeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultEdgeLabelFn=f,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(f,g){var y=this,w=arguments;return e.reduce(f,function(S,b){return w.length>1?y.setEdge(S,b,g):y.setEdge(S,b),b}),this},o.prototype.setEdge=function(){var f,g,y,w,S=!1,b=arguments[0];typeof b=="object"&&b!==null&&"v"in b?(f=b.v,g=b.w,y=b.name,arguments.length===2&&(w=arguments[1],S=!0)):(f=b,g=arguments[1],y=arguments[3],arguments.length>2&&(w=arguments[2],S=!0)),f=""+f,g=""+g,e.isUndefined(y)||(y=""+y);var _=u(this._isDirected,f,g,y);if(e.has(this._edgeLabels,_))return S&&(this._edgeLabels[_]=w),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(g),this._edgeLabels[_]=S?w:this._defaultEdgeLabelFn(f,g,y);var k=h(this._isDirected,f,g,y);return f=k.v,g=k.w,Object.freeze(k),this._edgeObjs[_]=k,a(this._preds[g],f),a(this._sucs[f],g),this._in[g][_]=k,this._out[f][_]=k,this._edgeCount++,this},o.prototype.edge=function(f,g,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,f,g,y);return this._edgeLabels[w]},o.prototype.hasEdge=function(f,g,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,f,g,y);return e.has(this._edgeLabels,w)},o.prototype.removeEdge=function(f,g,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,f,g,y),S=this._edgeObjs[w];return S&&(f=S.v,g=S.w,delete this._edgeLabels[w],delete this._edgeObjs[w],l(this._preds[g],f),l(this._sucs[f],g),delete this._in[g][w],delete this._out[f][w],this._edgeCount--),this},o.prototype.inEdges=function(f,g){var y=this._in[f];if(y){var w=e.values(y);return g?e.filter(w,function(S){return S.v===g}):w}},o.prototype.outEdges=function(f,g){var y=this._out[f];if(y){var w=e.values(y);return g?e.filter(w,function(S){return S.w===g}):w}},o.prototype.nodeEdges=function(f,g){var y=this.inEdges(f,g);if(y)return y.concat(this.outEdges(f,g))};function a(f,g){f[g]?f[g]++:f[g]=1}function l(f,g){--f[g]||delete f[g]}function u(f,g,y,w){var S=""+g,b=""+y;if(!f&&S>b){var _=S;S=b,b=_}return S+s+b+s+(e.isUndefined(w)?t:w)}function h(f,g,y,w){var S=""+g,b=""+y;if(!f&&S>b){var _=S;S=b,b=_}var k={v:S,w:b};return w&&(k.name=w),k}function p(f,g){return u(f,g.v,g.w,g.name)}return kg}var Sg,xN;function g6(){return xN||(xN=1,Sg="2.1.8"),Sg}var Ng,bN;function v6(){return bN||(bN=1,Ng={Graph:Uw(),version:g6()}),Ng}var Eg,_N;function y6(){if(_N)return Eg;_N=1;var e=Dn(),t=Uw();Eg={write:n,read:a};function n(l){var u={options:{directed:l.isDirected(),multigraph:l.isMultigraph(),compound:l.isCompound()},nodes:s(l),edges:o(l)};return e.isUndefined(l.graph())||(u.value=e.clone(l.graph())),u}function s(l){return e.map(l.nodes(),function(u){var h=l.node(u),p=l.parent(u),f={v:u};return e.isUndefined(h)||(f.value=h),e.isUndefined(p)||(f.parent=p),f})}function o(l){return e.map(l.edges(),function(u){var h=l.edge(u),p={v:u.v,w:u.w};return e.isUndefined(u.name)||(p.name=u.name),e.isUndefined(h)||(p.value=h),p})}function a(l){var u=new t(l.options).setGraph(l.value);return e.each(l.nodes,function(h){u.setNode(h.v,h.value),h.parent&&u.setParent(h.v,h.parent)}),e.each(l.edges,function(h){u.setEdge({v:h.v,w:h.w,name:h.name},h.value)}),u}return Eg}var jg,kN;function w6(){if(kN)return jg;kN=1;var e=Dn();jg=t;function t(n){var s={},o=[],a;function l(u){e.has(s,u)||(s[u]=!0,a.push(u),e.each(n.successors(u),l),e.each(n.predecessors(u),l))}return e.each(n.nodes(),function(u){a=[],l(u),a.length&&o.push(a)}),o}return jg}var Cg,SN;function xR(){if(SN)return Cg;SN=1;var e=Dn();Cg=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(n){return n.key})},t.prototype.has=function(n){return e.has(this._keyIndices,n)},t.prototype.priority=function(n){var s=this._keyIndices[n];if(s!==void 0)return this._arr[s].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(n,s){var o=this._keyIndices;if(n=String(n),!e.has(o,n)){var a=this._arr,l=a.length;return o[n]=l,a.push({key:n,priority:s}),this._decrease(l),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key},t.prototype.decrease=function(n,s){var o=this._keyIndices[n];if(s>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[o].priority+" New: "+s);this._arr[o].priority=s,this._decrease(o)},t.prototype._heapify=function(n){var s=this._arr,o=2*n,a=o+1,l=n;o<s.length&&(l=s[o].priority<s[l].priority?o:l,a<s.length&&(l=s[a].priority<s[l].priority?a:l),l!==n&&(this._swap(n,l),this._heapify(l)))},t.prototype._decrease=function(n){for(var s=this._arr,o=s[n].priority,a;n!==0&&(a=n>>1,!(s[a].priority<o));)this._swap(n,a),n=a},t.prototype._swap=function(n,s){var o=this._arr,a=this._keyIndices,l=o[n],u=o[s];o[n]=u,o[s]=l,a[u.key]=n,a[l.key]=s},Cg}var Tg,NN;function bR(){if(NN)return Tg;NN=1;var e=Dn(),t=xR();Tg=s;var n=e.constant(1);function s(a,l,u,h){return o(a,String(l),u||n,h||function(p){return a.outEdges(p)})}function o(a,l,u,h){var p={},f=new t,g,y,w=function(S){var b=S.v!==g?S.v:S.w,_=p[b],k=u(S),N=y.distance+k;if(k<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+S+" Weight: "+k);N<_.distance&&(_.distance=N,_.predecessor=g,f.decrease(b,N))};for(a.nodes().forEach(function(S){var b=S===l?0:Number.POSITIVE_INFINITY;p[S]={distance:b},f.add(S,b)});f.size()>0&&(g=f.removeMin(),y=p[g],y.distance!==Number.POSITIVE_INFINITY);)h(g).forEach(w);return p}return Tg}var Rg,EN;function x6(){if(EN)return Rg;EN=1;var e=bR(),t=Dn();Rg=n;function n(s,o,a){return t.transform(s.nodes(),function(l,u){l[u]=e(s,u,o,a)},{})}return Rg}var Ag,jN;function _R(){if(jN)return Ag;jN=1;var e=Dn();Ag=t;function t(n){var s=0,o=[],a={},l=[];function u(h){var p=a[h]={onStack:!0,lowlink:s,index:s++};if(o.push(h),n.successors(h).forEach(function(y){e.has(a,y)?a[y].onStack&&(p.lowlink=Math.min(p.lowlink,a[y].index)):(u(y),p.lowlink=Math.min(p.lowlink,a[y].lowlink))}),p.lowlink===p.index){var f=[],g;do g=o.pop(),a[g].onStack=!1,f.push(g);while(h!==g);l.push(f)}}return n.nodes().forEach(function(h){e.has(a,h)||u(h)}),l}return Ag}var Mg,CN;function b6(){if(CN)return Mg;CN=1;var e=Dn(),t=_R();Mg=n;function n(s){return e.filter(t(s),function(o){return o.length>1||o.length===1&&s.hasEdge(o[0],o[0])})}return Mg}var Ig,TN;function _6(){if(TN)return Ig;TN=1;var e=Dn();Ig=n;var t=e.constant(1);function n(o,a,l){return s(o,a||t,l||function(u){return o.outEdges(u)})}function s(o,a,l){var u={},h=o.nodes();return h.forEach(function(p){u[p]={},u[p][p]={distance:0},h.forEach(function(f){p!==f&&(u[p][f]={distance:Number.POSITIVE_INFINITY})}),l(p).forEach(function(f){var g=f.v===p?f.w:f.v,y=a(f);u[p][g]={distance:y,predecessor:p}})}),h.forEach(function(p){var f=u[p];h.forEach(function(g){var y=u[g];h.forEach(function(w){var S=y[p],b=f[w],_=y[w],k=S.distance+b.distance;k<_.distance&&(_.distance=k,_.predecessor=b.predecessor)})})}),u}return Ig}var Og,RN;function kR(){if(RN)return Og;RN=1;var e=Dn();Og=t,t.CycleException=n;function t(s){var o={},a={},l=[];function u(h){if(e.has(a,h))throw new n;e.has(o,h)||(a[h]=!0,o[h]=!0,e.each(s.predecessors(h),u),delete a[h],l.push(h))}if(e.each(s.sinks(),u),e.size(o)!==s.nodeCount())throw new n;return l}function n(){}return n.prototype=new Error,Og}var Pg,AN;function k6(){if(AN)return Pg;AN=1;var e=kR();Pg=t;function t(n){try{e(n)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return Pg}var $g,MN;function SR(){if(MN)return $g;MN=1;var e=Dn();$g=t;function t(s,o,a){e.isArray(o)||(o=[o]);var l=(s.isDirected()?s.successors:s.neighbors).bind(s),u=[],h={};return e.each(o,function(p){if(!s.hasNode(p))throw new Error("Graph does not have node: "+p);n(s,p,a==="post",h,l,u)}),u}function n(s,o,a,l,u,h){e.has(l,o)||(l[o]=!0,a||h.push(o),e.each(u(o),function(p){n(s,p,a,l,u,h)}),a&&h.push(o))}return $g}var Lg,IN;function S6(){if(IN)return Lg;IN=1;var e=SR();Lg=t;function t(n,s){return e(n,s,"post")}return Lg}var qg,ON;function N6(){if(ON)return qg;ON=1;var e=SR();qg=t;function t(n,s){return e(n,s,"pre")}return qg}var Dg,PN;function E6(){if(PN)return Dg;PN=1;var e=Dn(),t=Uw(),n=xR();Dg=s;function s(o,a){var l=new t,u={},h=new n,p;function f(y){var w=y.v===p?y.w:y.v,S=h.priority(w);if(S!==void 0){var b=a(y);b<S&&(u[w]=p,h.decrease(w,b))}}if(o.nodeCount()===0)return l;e.each(o.nodes(),function(y){h.add(y,Number.POSITIVE_INFINITY),l.setNode(y)}),h.decrease(o.nodes()[0],0);for(var g=!1;h.size()>0;){if(p=h.removeMin(),e.has(u,p))l.setEdge(p,u[p]);else{if(g)throw new Error("Input graph is not connected: "+o);g=!0}o.nodeEdges(p).forEach(f)}return l}return Dg}var Fg,$N;function j6(){return $N||($N=1,Fg={components:w6(),dijkstra:bR(),dijkstraAll:x6(),findCycles:b6(),floydWarshall:_6(),isAcyclic:k6(),postorder:S6(),preorder:N6(),prim:E6(),tarjan:_R(),topsort:kR()}),Fg}var zg,LN;function C6(){if(LN)return zg;LN=1;var e=v6();return zg={Graph:e.Graph,json:y6(),alg:j6(),version:e.version},zg}var Bg,qN;function lr(){if(qN)return Bg;qN=1;var e;if(typeof jw=="function")try{e=C6()}catch{}return e||(e=window.graphlib),Bg=e,Bg}var Ug,DN;function T6(){if(DN)return Ug;DN=1;var e=KT(),t=1,n=4;function s(o){return e(o,t|n)}return Ug=s,Ug}var Wg,FN;function Xu(){if(FN)return Wg;FN=1;var e=Wo(),t=Qr(),n=zu(),s=qn();function o(a,l,u){if(!s(u))return!1;var h=typeof l;return(h=="number"?t(u)&&n(l,u.length):h=="string"&&l in u)?e(u[l],a):!1}return Wg=o,Wg}var Hg,zN;function R6(){if(zN)return Hg;zN=1;var e=Ku(),t=Wo(),n=Xu(),s=ki(),o=Object.prototype,a=o.hasOwnProperty,l=e(function(u,h){u=Object(u);var p=-1,f=h.length,g=f>2?h[2]:void 0;for(g&&n(h[0],h[1],g)&&(f=1);++p<f;)for(var y=h[p],w=s(y),S=-1,b=w.length;++S<b;){var _=w[S],k=u[_];(k===void 0||t(k,o[_])&&!a.call(u,_))&&(u[_]=y[_])}return u});return Hg=l,Hg}var Gg,BN;function A6(){if(BN)return Gg;BN=1;var e=Zr(),t=Qr(),n=Ms();function s(o){return function(a,l,u){var h=Object(a);if(!t(a)){var p=e(l,3);a=n(a),l=function(g){return p(h[g],g,h)}}var f=o(a,l,u);return f>-1?h[p?a[f]:f]:void 0}}return Gg=s,Gg}var Vg,UN;function M6(){if(UN)return Vg;UN=1;var e=/\s/;function t(n){for(var s=n.length;s--&&e.test(n.charAt(s)););return s}return Vg=t,Vg}var Yg,WN;function I6(){if(WN)return Yg;WN=1;var e=M6(),t=/^\s+/;function n(s){return s&&s.slice(0,e(s)+1).replace(t,"")}return Yg=n,Yg}var Kg,HN;function O6(){if(HN)return Kg;HN=1;var e=I6(),t=qn(),n=Yo(),s=NaN,o=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,l=/^0o[0-7]+$/i,u=parseInt;function h(p){if(typeof p=="number")return p;if(n(p))return s;if(t(p)){var f=typeof p.valueOf=="function"?p.valueOf():p;p=t(f)?f+"":f}if(typeof p!="string")return p===0?p:+p;p=e(p);var g=a.test(p);return g||l.test(p)?u(p.slice(2),g?2:8):o.test(p)?s:+p}return Kg=h,Kg}var Xg,GN;function NR(){if(GN)return Xg;GN=1;var e=O6(),t=1/0,n=17976931348623157e292;function s(o){if(!o)return o===0?o:0;if(o=e(o),o===t||o===-t){var a=o<0?-1:1;return a*n}return o===o?o:0}return Xg=s,Xg}var Qg,VN;function P6(){if(VN)return Qg;VN=1;var e=NR();function t(n){var s=e(n),o=s%1;return s===s?o?s-o:s:0}return Qg=t,Qg}var Zg,YN;function $6(){if(YN)return Zg;YN=1;var e=vR(),t=Zr(),n=P6(),s=Math.max;function o(a,l,u){var h=a==null?0:a.length;if(!h)return-1;var p=u==null?0:n(u);return p<0&&(p=s(h+p,0)),e(a,t(l,3),p)}return Zg=o,Zg}var Jg,KN;function L6(){if(KN)return Jg;KN=1;var e=A6(),t=$6(),n=e(t);return Jg=n,Jg}var ev,XN;function ER(){if(XN)return ev;XN=1;var e=Bw();function t(n){var s=n==null?0:n.length;return s?e(n,1):[]}return ev=t,ev}var tv,QN;function q6(){if(QN)return tv;QN=1;var e=qw(),t=XT(),n=ki();function s(o,a){return o==null?o:e(o,t(a),n)}return tv=s,tv}var nv,ZN;function D6(){if(ZN)return nv;ZN=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return nv=e,nv}var rv,JN;function F6(){if(JN)return rv;JN=1;var e=Du(),t=Dw(),n=Zr();function s(o,a){var l={};return a=n(a,3),t(o,function(u,h,p){e(l,h,a(u,h,p))}),l}return rv=s,rv}var sv,eE;function Ww(){if(eE)return sv;eE=1;var e=Yo();function t(n,s,o){for(var a=-1,l=n.length;++a<l;){var u=n[a],h=s(u);if(h!=null&&(p===void 0?h===h&&!e(h):o(h,p)))var p=h,f=u}return f}return sv=t,sv}var iv,tE;function z6(){if(tE)return iv;tE=1;function e(t,n){return t>n}return iv=e,iv}var ov,nE;function B6(){if(nE)return ov;nE=1;var e=Ww(),t=z6(),n=Si();function s(o){return o&&o.length?e(o,n,t):void 0}return ov=s,ov}var av,rE;function jR(){if(rE)return av;rE=1;var e=Du(),t=Wo();function n(s,o,a){(a!==void 0&&!t(s[o],a)||a===void 0&&!(o in s))&&e(s,o,a)}return av=n,av}var lv,sE;function U6(){if(sE)return lv;sE=1;var e=bi(),t=Wu(),n=Er(),s="[object Object]",o=Function.prototype,a=Object.prototype,l=o.toString,u=a.hasOwnProperty,h=l.call(Object);function p(f){if(!n(f)||e(f)!=s)return!1;var g=t(f);if(g===null)return!0;var y=u.call(g,"constructor")&&g.constructor;return typeof y=="function"&&y instanceof y&&l.call(y)==h}return lv=p,lv}var cv,iE;function CR(){if(iE)return cv;iE=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return cv=e,cv}var uv,oE;function W6(){if(oE)return uv;oE=1;var e=wl(),t=ki();function n(s){return e(s,t(s))}return uv=n,uv}var dv,aE;function H6(){if(aE)return dv;aE=1;var e=jR(),t=LT(),n=GT(),s=qT(),o=YT(),a=xl(),l=Rt(),u=yR(),h=Go(),p=yl(),f=qn(),g=U6(),y=bl(),w=CR(),S=W6();function b(_,k,N,j,T,M,P){var I=w(_,N),F=w(k,N),O=P.get(F);if(O){e(_,N,O);return}var A=M?M(I,F,N+"",_,k,P):void 0,D=A===void 0;if(D){var H=l(F),K=!H&&h(F),C=!H&&!K&&y(F);A=F,H||K||C?l(I)?A=I:u(I)?A=s(I):K?(D=!1,A=t(F,!0)):C?(D=!1,A=n(F,!0)):A=[]:g(F)||a(F)?(A=I,a(I)?A=S(I):(!f(I)||p(I))&&(A=o(F))):D=!1}D&&(P.set(F,A),T(A,F,j,M,P),P.delete(F)),e(_,N,A)}return dv=b,dv}var fv,lE;function G6(){if(lE)return fv;lE=1;var e=qu(),t=jR(),n=qw(),s=H6(),o=qn(),a=ki(),l=CR();function u(h,p,f,g,y){h!==p&&n(p,function(w,S){if(y||(y=new e),o(w))s(h,p,S,f,u,g,y);else{var b=g?g(l(h,S),w,S+"",h,p,y):void 0;b===void 0&&(b=w),t(h,S,b)}},a)}return fv=u,fv}var hv,cE;function V6(){if(cE)return hv;cE=1;var e=Ku(),t=Xu();function n(s){return e(function(o,a){var l=-1,u=a.length,h=u>1?a[u-1]:void 0,p=u>2?a[2]:void 0;for(h=s.length>3&&typeof h=="function"?(u--,h):void 0,p&&t(a[0],a[1],p)&&(h=u<3?void 0:h,u=1),o=Object(o);++l<u;){var f=a[l];f&&s(o,f,l,h)}return o})}return hv=n,hv}var pv,uE;function Y6(){if(uE)return pv;uE=1;var e=G6(),t=V6(),n=t(function(s,o,a){e(s,o,a)});return pv=n,pv}var mv,dE;function TR(){if(dE)return mv;dE=1;function e(t,n){return t<n}return mv=e,mv}var gv,fE;function K6(){if(fE)return gv;fE=1;var e=Ww(),t=TR(),n=Si();function s(o){return o&&o.length?e(o,n,t):void 0}return gv=s,gv}var vv,hE;function X6(){if(hE)return vv;hE=1;var e=Ww(),t=Zr(),n=TR();function s(o,a){return o&&o.length?e(o,t(a,2),n):void 0}return vv=s,vv}var yv,pE;function Q6(){if(pE)return yv;pE=1;var e=ur(),t=function(){return e.Date.now()};return yv=t,yv}var wv,mE;function Z6(){if(mE)return wv;mE=1;var e=Fu(),t=Vu(),n=zu(),s=qn(),o=_l();function a(l,u,h,p){if(!s(l))return l;u=t(u,l);for(var f=-1,g=u.length,y=g-1,w=l;w!=null&&++f<g;){var S=o(u[f]),b=h;if(S==="__proto__"||S==="constructor"||S==="prototype")return l;if(f!=y){var _=w[S];b=p?p(_,S,w):void 0,b===void 0&&(b=s(_)?_:n(u[f+1])?[]:{})}e(w,S,b),w=w[S]}return l}return wv=a,wv}var xv,gE;function J6(){if(gE)return xv;gE=1;var e=Yu(),t=Z6(),n=Vu();function s(o,a,l){for(var u=-1,h=a.length,p={};++u<h;){var f=a[u],g=e(o,f);l(g,f)&&t(p,n(f,o),g)}return p}return xv=s,xv}var bv,vE;function ez(){if(vE)return bv;vE=1;var e=J6(),t=aR();function n(s,o){return e(s,o,function(a,l){return t(s,l)})}return bv=n,bv}var _v,yE;function tz(){if(yE)return _v;yE=1;var e=ER(),t=mR(),n=gR();function s(o){return n(t(o,void 0,e),o+"")}return _v=s,_v}var kv,wE;function nz(){if(wE)return kv;wE=1;var e=ez(),t=tz(),n=t(function(s,o){return s==null?{}:e(s,o)});return kv=n,kv}var Sv,xE;function rz(){if(xE)return Sv;xE=1;var e=Math.ceil,t=Math.max;function n(s,o,a,l){for(var u=-1,h=t(e((o-s)/(a||1)),0),p=Array(h);h--;)p[l?h:++u]=s,s+=a;return p}return Sv=n,Sv}var Nv,bE;function sz(){if(bE)return Nv;bE=1;var e=rz(),t=Xu(),n=NR();function s(o){return function(a,l,u){return u&&typeof u!="number"&&t(a,l,u)&&(l=u=void 0),a=n(a),l===void 0?(l=a,a=0):l=n(l),u=u===void 0?a<l?1:-1:n(u),e(a,l,u,o)}}return Nv=s,Nv}var Ev,_E;function iz(){if(_E)return Ev;_E=1;var e=sz(),t=e();return Ev=t,Ev}var jv,kE;function oz(){if(kE)return jv;kE=1;function e(t,n){var s=t.length;for(t.sort(n);s--;)t[s]=t[s].value;return t}return jv=e,jv}var Cv,SE;function az(){if(SE)return Cv;SE=1;var e=Yo();function t(n,s){if(n!==s){var o=n!==void 0,a=n===null,l=n===n,u=e(n),h=s!==void 0,p=s===null,f=s===s,g=e(s);if(!p&&!g&&!u&&n>s||u&&h&&f&&!p&&!g||a&&h&&f||!o&&f||!l)return 1;if(!a&&!u&&!g&&n<s||g&&o&&l&&!a&&!u||p&&o&&l||!h&&l||!f)return-1}return 0}return Cv=t,Cv}var Tv,NE;function lz(){if(NE)return Tv;NE=1;var e=az();function t(n,s,o){for(var a=-1,l=n.criteria,u=s.criteria,h=l.length,p=o.length;++a<h;){var f=e(l[a],u[a]);if(f){if(a>=p)return f;var g=o[a];return f*(g=="desc"?-1:1)}}return n.index-s.index}return Tv=t,Tv}var Rv,EE;function cz(){if(EE)return Rv;EE=1;var e=Gu(),t=Yu(),n=Zr(),s=fR(),o=oz(),a=Bu(),l=lz(),u=Si(),h=Rt();function p(f,g,y){g.length?g=e(g,function(b){return h(b)?function(_){return t(_,b.length===1?b[0]:b)}:b}):g=[u];var w=-1;g=e(g,a(n));var S=s(f,function(b,_,k){var N=e(g,function(j){return j(b)});return{criteria:N,index:++w,value:b}});return o(S,function(b,_){return l(b,_,y)})}return Rv=p,Rv}var Av,jE;function uz(){if(jE)return Av;jE=1;var e=Bw(),t=cz(),n=Ku(),s=Xu(),o=n(function(a,l){if(a==null)return[];var u=l.length;return u>1&&s(a,l[0],l[1])?l=[]:u>2&&s(l[0],l[1],l[2])&&(l=[l[0]]),t(a,e(l,1),[])});return Av=o,Av}var Mv,CE;function dz(){if(CE)return Mv;CE=1;var e=iR(),t=0;function n(s){var o=++t;return e(s)+o}return Mv=n,Mv}var Iv,TE;function fz(){if(TE)return Iv;TE=1;function e(t,n,s){for(var o=-1,a=t.length,l=n.length,u={};++o<a;){var h=o<l?n[o]:void 0;s(u,t[o],h)}return u}return Iv=e,Iv}var Ov,RE;function hz(){if(RE)return Ov;RE=1;var e=Fu(),t=fz();function n(s,o){return t(s||[],o||[],e)}return Ov=n,Ov}var Pv,AE;function vt(){if(AE)return Pv;AE=1;var e;if(typeof jw=="function")try{e={cloneDeep:T6(),constant:Lw(),defaults:R6(),each:ZT(),filter:cR(),find:L6(),flatten:ER(),forEach:QT(),forIn:q6(),has:uR(),isUndefined:dR(),last:D6(),map:hR(),mapValues:F6(),max:B6(),merge:Y6(),min:K6(),minBy:X6(),now:Q6(),pick:nz(),range:iz(),reduce:pR(),sortBy:uz(),uniqueId:dz(),values:wR(),zipObject:hz()}}catch{}return e||(e=window._),Pv=e,Pv}var $v,ME;function pz(){if(ME)return $v;ME=1,$v=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 t(o),o},e.prototype.enqueue=function(s){var o=this._sentinel;s._prev&&s._next&&t(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,a=o._prev;a!==o;)s.push(JSON.stringify(a,n)),a=a._prev;return"["+s.join(", ")+"]"};function t(s){s._prev._next=s._next,s._next._prev=s._prev,delete s._next,delete s._prev}function n(s,o){if(s!=="_next"&&s!=="_prev")return o}return $v}var Lv,IE;function mz(){if(IE)return Lv;IE=1;var e=vt(),t=lr().Graph,n=pz();Lv=o;var s=e.constant(1);function o(p,f){if(p.nodeCount()<=1)return[];var g=u(p,f||s),y=a(g.graph,g.buckets,g.zeroIdx);return e.flatten(e.map(y,function(w){return p.outEdges(w.v,w.w)}),!0)}function a(p,f,g){for(var y=[],w=f[f.length-1],S=f[0],b;p.nodeCount();){for(;b=S.dequeue();)l(p,f,g,b);for(;b=w.dequeue();)l(p,f,g,b);if(p.nodeCount()){for(var _=f.length-2;_>0;--_)if(b=f[_].dequeue(),b){y=y.concat(l(p,f,g,b,!0));break}}}return y}function l(p,f,g,y,w){var S=w?[]:void 0;return e.forEach(p.inEdges(y.v),function(b){var _=p.edge(b),k=p.node(b.v);w&&S.push({v:b.v,w:b.w}),k.out-=_,h(f,g,k)}),e.forEach(p.outEdges(y.v),function(b){var _=p.edge(b),k=b.w,N=p.node(k);N.in-=_,h(f,g,N)}),p.removeNode(y.v),S}function u(p,f){var g=new t,y=0,w=0;e.forEach(p.nodes(),function(_){g.setNode(_,{v:_,in:0,out:0})}),e.forEach(p.edges(),function(_){var k=g.edge(_.v,_.w)||0,N=f(_),j=k+N;g.setEdge(_.v,_.w,j),w=Math.max(w,g.node(_.v).out+=N),y=Math.max(y,g.node(_.w).in+=N)});var S=e.range(w+y+3).map(function(){return new n}),b=y+1;return e.forEach(g.nodes(),function(_){h(S,b,g.node(_))}),{graph:g,buckets:S,zeroIdx:b}}function h(p,f,g){g.out?g.in?p[g.out-g.in+f].enqueue(g):p[p.length-1].enqueue(g):p[0].enqueue(g)}return Lv}var qv,OE;function gz(){if(OE)return qv;OE=1;var e=vt(),t=mz();qv={run:n,undo:o};function n(a){var l=a.graph().acyclicer==="greedy"?t(a,u(a)):s(a);e.forEach(l,function(h){var p=a.edge(h);a.removeEdge(h),p.forwardName=h.name,p.reversed=!0,a.setEdge(h.w,h.v,p,e.uniqueId("rev"))});function u(h){return function(p){return h.edge(p).weight}}}function s(a){var l=[],u={},h={};function p(f){e.has(h,f)||(h[f]=!0,u[f]=!0,e.forEach(a.outEdges(f),function(g){e.has(u,g.w)?l.push(g):p(g.w)}),delete u[f])}return e.forEach(a.nodes(),p),l}function o(a){e.forEach(a.edges(),function(l){var u=a.edge(l);if(u.reversed){a.removeEdge(l);var h=u.forwardName;delete u.reversed,delete u.forwardName,a.setEdge(l.w,l.v,u,h)}})}return qv}var Dv,PE;function pn(){if(PE)return Dv;PE=1;var e=vt(),t=lr().Graph;Dv={addDummyNode:n,simplify:s,asNonCompoundGraph:o,successorWeights:a,predecessorWeights:l,intersectRect:u,buildLayerMatrix:h,normalizeRanks:p,removeEmptyRanks:f,addBorderNode:g,maxRank:y,partition:w,time:S,notime:b};function n(_,k,N,j){var T;do T=e.uniqueId(j);while(_.hasNode(T));return N.dummy=k,_.setNode(T,N),T}function s(_){var k=new t().setGraph(_.graph());return e.forEach(_.nodes(),function(N){k.setNode(N,_.node(N))}),e.forEach(_.edges(),function(N){var j=k.edge(N.v,N.w)||{weight:0,minlen:1},T=_.edge(N);k.setEdge(N.v,N.w,{weight:j.weight+T.weight,minlen:Math.max(j.minlen,T.minlen)})}),k}function o(_){var k=new t({multigraph:_.isMultigraph()}).setGraph(_.graph());return e.forEach(_.nodes(),function(N){_.children(N).length||k.setNode(N,_.node(N))}),e.forEach(_.edges(),function(N){k.setEdge(N,_.edge(N))}),k}function a(_){var k=e.map(_.nodes(),function(N){var j={};return e.forEach(_.outEdges(N),function(T){j[T.w]=(j[T.w]||0)+_.edge(T).weight}),j});return e.zipObject(_.nodes(),k)}function l(_){var k=e.map(_.nodes(),function(N){var j={};return e.forEach(_.inEdges(N),function(T){j[T.v]=(j[T.v]||0)+_.edge(T).weight}),j});return e.zipObject(_.nodes(),k)}function u(_,k){var N=_.x,j=_.y,T=k.x-N,M=k.y-j,P=_.width/2,I=_.height/2;if(!T&&!M)throw new Error("Not possible to find intersection inside of the rectangle");var F,O;return Math.abs(M)*P>Math.abs(T)*I?(M<0&&(I=-I),F=I*T/M,O=I):(T<0&&(P=-P),F=P,O=P*M/T),{x:N+F,y:j+O}}function h(_){var k=e.map(e.range(y(_)+1),function(){return[]});return e.forEach(_.nodes(),function(N){var j=_.node(N),T=j.rank;e.isUndefined(T)||(k[T][j.order]=N)}),k}function p(_){var k=e.min(e.map(_.nodes(),function(N){return _.node(N).rank}));e.forEach(_.nodes(),function(N){var j=_.node(N);e.has(j,"rank")&&(j.rank-=k)})}function f(_){var k=e.min(e.map(_.nodes(),function(M){return _.node(M).rank})),N=[];e.forEach(_.nodes(),function(M){var P=_.node(M).rank-k;N[P]||(N[P]=[]),N[P].push(M)});var j=0,T=_.graph().nodeRankFactor;e.forEach(N,function(M,P){e.isUndefined(M)&&P%T!==0?--j:j&&e.forEach(M,function(I){_.node(I).rank+=j})})}function g(_,k,N,j){var T={width:0,height:0};return arguments.length>=4&&(T.rank=N,T.order=j),n(_,"border",T,k)}function y(_){return e.max(e.map(_.nodes(),function(k){var N=_.node(k).rank;if(!e.isUndefined(N))return N}))}function w(_,k){var N={lhs:[],rhs:[]};return e.forEach(_,function(j){k(j)?N.lhs.push(j):N.rhs.push(j)}),N}function S(_,k){var N=e.now();try{return k()}finally{console.log(_+" time: "+(e.now()-N)+"ms")}}function b(_,k){return k()}return Dv}var Fv,$E;function vz(){if($E)return Fv;$E=1;var e=vt(),t=pn();Fv={run:n,undo:o};function n(a){a.graph().dummyChains=[],e.forEach(a.edges(),function(l){s(a,l)})}function s(a,l){var u=l.v,h=a.node(u).rank,p=l.w,f=a.node(p).rank,g=l.name,y=a.edge(l),w=y.labelRank;if(f!==h+1){a.removeEdge(l);var S,b,_;for(_=0,++h;h<f;++_,++h)y.points=[],b={width:0,height:0,edgeLabel:y,edgeObj:l,rank:h},S=t.addDummyNode(a,"edge",b,"_d"),h===w&&(b.width=y.width,b.height=y.height,b.dummy="edge-label",b.labelpos=y.labelpos),a.setEdge(u,S,{weight:y.weight},g),_===0&&a.graph().dummyChains.push(S),u=S;a.setEdge(u,p,{weight:y.weight},g)}}function o(a){e.forEach(a.graph().dummyChains,function(l){var u=a.node(l),h=u.edgeLabel,p;for(a.setEdge(u.edgeObj,h);u.dummy;)p=a.successors(l)[0],a.removeNode(l),h.points.push({x:u.x,y:u.y}),u.dummy==="edge-label"&&(h.x=u.x,h.y=u.y,h.width=u.width,h.height=u.height),l=p,u=a.node(l)})}return Fv}var zv,LE;function xu(){if(LE)return zv;LE=1;var e=vt();zv={longestPath:t,slack:n};function t(s){var o={};function a(l){var u=s.node(l);if(e.has(o,l))return u.rank;o[l]=!0;var h=e.min(e.map(s.outEdges(l),function(p){return a(p.w)-s.edge(p).minlen}));return(h===Number.POSITIVE_INFINITY||h===void 0||h===null)&&(h=0),u.rank=h}e.forEach(s.sources(),a)}function n(s,o){return s.node(o.w).rank-s.node(o.v).rank-s.edge(o).minlen}return zv}var Bv,qE;function RR(){if(qE)return Bv;qE=1;var e=vt(),t=lr().Graph,n=xu().slack;Bv=s;function s(u){var h=new t({directed:!1}),p=u.nodes()[0],f=u.nodeCount();h.setNode(p,{});for(var g,y;o(h,u)<f;)g=a(h,u),y=h.hasNode(g.v)?n(u,g):-n(u,g),l(h,u,y);return h}function o(u,h){function p(f){e.forEach(h.nodeEdges(f),function(g){var y=g.v,w=f===y?g.w:y;!u.hasNode(w)&&!n(h,g)&&(u.setNode(w,{}),u.setEdge(f,w,{}),p(w))})}return e.forEach(u.nodes(),p),u.nodeCount()}function a(u,h){return e.minBy(h.edges(),function(p){if(u.hasNode(p.v)!==u.hasNode(p.w))return n(h,p)})}function l(u,h,p){e.forEach(u.nodes(),function(f){h.node(f).rank+=p})}return Bv}var Uv,DE;function yz(){if(DE)return Uv;DE=1;var e=vt(),t=RR(),n=xu().slack,s=xu().longestPath,o=lr().alg.preorder,a=lr().alg.postorder,l=pn().simplify;Uv=u,u.initLowLimValues=g,u.initCutValues=h,u.calcCutValue=f,u.leaveEdge=w,u.enterEdge=S,u.exchangeEdges=b;function u(j){j=l(j),s(j);var T=t(j);g(T),h(T,j);for(var M,P;M=w(T);)P=S(T,j,M),b(T,j,M,P)}function h(j,T){var M=a(j,j.nodes());M=M.slice(0,M.length-1),e.forEach(M,function(P){p(j,T,P)})}function p(j,T,M){var P=j.node(M),I=P.parent;j.edge(M,I).cutvalue=f(j,T,M)}function f(j,T,M){var P=j.node(M),I=P.parent,F=!0,O=T.edge(M,I),A=0;return O||(F=!1,O=T.edge(I,M)),A=O.weight,e.forEach(T.nodeEdges(M),function(D){var H=D.v===M,K=H?D.w:D.v;if(K!==I){var C=H===F,X=T.edge(D).weight;if(A+=C?X:-X,k(j,M,K)){var B=j.edge(M,K).cutvalue;A+=C?-B:B}}}),A}function g(j,T){arguments.length<2&&(T=j.nodes()[0]),y(j,{},1,T)}function y(j,T,M,P,I){var F=M,O=j.node(P);return T[P]=!0,e.forEach(j.neighbors(P),function(A){e.has(T,A)||(M=y(j,T,M,A,P))}),O.low=F,O.lim=M++,I?O.parent=I:delete O.parent,M}function w(j){return e.find(j.edges(),function(T){return j.edge(T).cutvalue<0})}function S(j,T,M){var P=M.v,I=M.w;T.hasEdge(P,I)||(P=M.w,I=M.v);var F=j.node(P),O=j.node(I),A=F,D=!1;F.lim>O.lim&&(A=O,D=!0);var H=e.filter(T.edges(),function(K){return D===N(j,j.node(K.v),A)&&D!==N(j,j.node(K.w),A)});return e.minBy(H,function(K){return n(T,K)})}function b(j,T,M,P){var I=M.v,F=M.w;j.removeEdge(I,F),j.setEdge(P.v,P.w,{}),g(j),h(j,T),_(j,T)}function _(j,T){var M=e.find(j.nodes(),function(I){return!T.node(I).parent}),P=o(j,M);P=P.slice(1),e.forEach(P,function(I){var F=j.node(I).parent,O=T.edge(I,F),A=!1;O||(O=T.edge(F,I),A=!0),T.node(I).rank=T.node(F).rank+(A?O.minlen:-O.minlen)})}function k(j,T,M){return j.hasEdge(T,M)}function N(j,T,M){return M.low<=T.lim&&T.lim<=M.lim}return Uv}var Wv,FE;function wz(){if(FE)return Wv;FE=1;var e=xu(),t=e.longestPath,n=RR(),s=yz();Wv=o;function o(h){switch(h.graph().ranker){case"network-simplex":u(h);break;case"tight-tree":l(h);break;case"longest-path":a(h);break;default:u(h)}}var a=t;function l(h){t(h),n(h)}function u(h){s(h)}return Wv}var Hv,zE;function xz(){if(zE)return Hv;zE=1;var e=vt();Hv=t;function t(o){var a=s(o);e.forEach(o.graph().dummyChains,function(l){for(var u=o.node(l),h=u.edgeObj,p=n(o,a,h.v,h.w),f=p.path,g=p.lca,y=0,w=f[y],S=!0;l!==h.w;){if(u=o.node(l),S){for(;(w=f[y])!==g&&o.node(w).maxRank<u.rank;)y++;w===g&&(S=!1)}if(!S){for(;y<f.length-1&&o.node(w=f[y+1]).minRank<=u.rank;)y++;w=f[y]}o.setParent(l,w),l=o.successors(l)[0]}})}function n(o,a,l,u){var h=[],p=[],f=Math.min(a[l].low,a[u].low),g=Math.max(a[l].lim,a[u].lim),y,w;y=l;do y=o.parent(y),h.push(y);while(y&&(a[y].low>f||g>a[y].lim));for(w=y,y=u;(y=o.parent(y))!==w;)p.push(y);return{path:h.concat(p.reverse()),lca:w}}function s(o){var a={},l=0;function u(h){var p=l;e.forEach(o.children(h),u),a[h]={low:p,lim:l++}}return e.forEach(o.children(),u),a}return Hv}var Gv,BE;function bz(){if(BE)return Gv;BE=1;var e=vt(),t=pn();Gv={run:n,cleanup:l};function n(u){var h=t.addDummyNode(u,"root",{},"_root"),p=o(u),f=e.max(e.values(p))-1,g=2*f+1;u.graph().nestingRoot=h,e.forEach(u.edges(),function(w){u.edge(w).minlen*=g});var y=a(u)+1;e.forEach(u.children(),function(w){s(u,h,g,y,f,p,w)}),u.graph().nodeRankFactor=g}function s(u,h,p,f,g,y,w){var S=u.children(w);if(!S.length){w!==h&&u.setEdge(h,w,{weight:0,minlen:p});return}var b=t.addBorderNode(u,"_bt"),_=t.addBorderNode(u,"_bb"),k=u.node(w);u.setParent(b,w),k.borderTop=b,u.setParent(_,w),k.borderBottom=_,e.forEach(S,function(N){s(u,h,p,f,g,y,N);var j=u.node(N),T=j.borderTop?j.borderTop:N,M=j.borderBottom?j.borderBottom:N,P=j.borderTop?f:2*f,I=T!==M?1:g-y[w]+1;u.setEdge(b,T,{weight:P,minlen:I,nestingEdge:!0}),u.setEdge(M,_,{weight:P,minlen:I,nestingEdge:!0})}),u.parent(w)||u.setEdge(h,b,{weight:0,minlen:g+y[w]})}function o(u){var h={};function p(f,g){var y=u.children(f);y&&y.length&&e.forEach(y,function(w){p(w,g+1)}),h[f]=g}return e.forEach(u.children(),function(f){p(f,1)}),h}function a(u){return e.reduce(u.edges(),function(h,p){return h+u.edge(p).weight},0)}function l(u){var h=u.graph();u.removeNode(h.nestingRoot),delete h.nestingRoot,e.forEach(u.edges(),function(p){var f=u.edge(p);f.nestingEdge&&u.removeEdge(p)})}return Gv}var Vv,UE;function _z(){if(UE)return Vv;UE=1;var e=vt(),t=pn();Vv=n;function n(o){function a(l){var u=o.children(l),h=o.node(l);if(u.length&&e.forEach(u,a),e.has(h,"minRank")){h.borderLeft=[],h.borderRight=[];for(var p=h.minRank,f=h.maxRank+1;p<f;++p)s(o,"borderLeft","_bl",l,h,p),s(o,"borderRight","_br",l,h,p)}}e.forEach(o.children(),a)}function s(o,a,l,u,h,p){var f={width:0,height:0,rank:p,borderType:a},g=h[a][p-1],y=t.addDummyNode(o,"border",f,l);h[a][p]=y,o.setParent(y,u),g&&o.setEdge(g,y,{weight:1})}return Vv}var Yv,WE;function kz(){if(WE)return Yv;WE=1;var e=vt();Yv={adjust:t,undo:n};function t(p){var f=p.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&s(p)}function n(p){var f=p.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&a(p),(f==="lr"||f==="rl")&&(u(p),s(p))}function s(p){e.forEach(p.nodes(),function(f){o(p.node(f))}),e.forEach(p.edges(),function(f){o(p.edge(f))})}function o(p){var f=p.width;p.width=p.height,p.height=f}function a(p){e.forEach(p.nodes(),function(f){l(p.node(f))}),e.forEach(p.edges(),function(f){var g=p.edge(f);e.forEach(g.points,l),e.has(g,"y")&&l(g)})}function l(p){p.y=-p.y}function u(p){e.forEach(p.nodes(),function(f){h(p.node(f))}),e.forEach(p.edges(),function(f){var g=p.edge(f);e.forEach(g.points,h),e.has(g,"x")&&h(g)})}function h(p){var f=p.x;p.x=p.y,p.y=f}return Yv}var Kv,HE;function Sz(){if(HE)return Kv;HE=1;var e=vt();Kv=t;function t(n){var s={},o=e.filter(n.nodes(),function(p){return!n.children(p).length}),a=e.max(e.map(o,function(p){return n.node(p).rank})),l=e.map(e.range(a+1),function(){return[]});function u(p){if(!e.has(s,p)){s[p]=!0;var f=n.node(p);l[f.rank].push(p),e.forEach(n.successors(p),u)}}var h=e.sortBy(o,function(p){return n.node(p).rank});return e.forEach(h,u),l}return Kv}var Xv,GE;function Nz(){if(GE)return Xv;GE=1;var e=vt();Xv=t;function t(s,o){for(var a=0,l=1;l<o.length;++l)a+=n(s,o[l-1],o[l]);return a}function n(s,o,a){for(var l=e.zipObject(a,e.map(a,function(y,w){return w})),u=e.flatten(e.map(o,function(y){return e.sortBy(e.map(s.outEdges(y),function(w){return{pos:l[w.w],weight:s.edge(w).weight}}),"pos")}),!0),h=1;h<a.length;)h<<=1;var p=2*h-1;h-=1;var f=e.map(new Array(p),function(){return 0}),g=0;return e.forEach(u.forEach(function(y){var w=y.pos+h;f[w]+=y.weight;for(var S=0;w>0;)w%2&&(S+=f[w+1]),w=w-1>>1,f[w]+=y.weight;g+=y.weight*S})),g}return Xv}var Qv,VE;function Ez(){if(VE)return Qv;VE=1;var e=vt();Qv=t;function t(n,s){return e.map(s,function(o){var a=n.inEdges(o);if(a.length){var l=e.reduce(a,function(u,h){var p=n.edge(h),f=n.node(h.v);return{sum:u.sum+p.weight*f.order,weight:u.weight+p.weight}},{sum:0,weight:0});return{v:o,barycenter:l.sum/l.weight,weight:l.weight}}else return{v:o}})}return Qv}var Zv,YE;function jz(){if(YE)return Zv;YE=1;var e=vt();Zv=t;function t(o,a){var l={};e.forEach(o,function(h,p){var f=l[h.v]={indegree:0,in:[],out:[],vs:[h.v],i:p};e.isUndefined(h.barycenter)||(f.barycenter=h.barycenter,f.weight=h.weight)}),e.forEach(a.edges(),function(h){var p=l[h.v],f=l[h.w];!e.isUndefined(p)&&!e.isUndefined(f)&&(f.indegree++,p.out.push(l[h.w]))});var u=e.filter(l,function(h){return!h.indegree});return n(u)}function n(o){var a=[];function l(p){return function(f){f.merged||(e.isUndefined(f.barycenter)||e.isUndefined(p.barycenter)||f.barycenter>=p.barycenter)&&s(p,f)}}function u(p){return function(f){f.in.push(p),--f.indegree===0&&o.push(f)}}for(;o.length;){var h=o.pop();a.push(h),e.forEach(h.in.reverse(),l(h)),e.forEach(h.out,u(h))}return e.map(e.filter(a,function(p){return!p.merged}),function(p){return e.pick(p,["vs","i","barycenter","weight"])})}function s(o,a){var l=0,u=0;o.weight&&(l+=o.barycenter*o.weight,u+=o.weight),a.weight&&(l+=a.barycenter*a.weight,u+=a.weight),o.vs=a.vs.concat(o.vs),o.barycenter=l/u,o.weight=u,o.i=Math.min(a.i,o.i),a.merged=!0}return Zv}var Jv,KE;function Cz(){if(KE)return Jv;KE=1;var e=vt(),t=pn();Jv=n;function n(a,l){var u=t.partition(a,function(b){return e.has(b,"barycenter")}),h=u.lhs,p=e.sortBy(u.rhs,function(b){return-b.i}),f=[],g=0,y=0,w=0;h.sort(o(!!l)),w=s(f,p,w),e.forEach(h,function(b){w+=b.vs.length,f.push(b.vs),g+=b.barycenter*b.weight,y+=b.weight,w=s(f,p,w)});var S={vs:e.flatten(f,!0)};return y&&(S.barycenter=g/y,S.weight=y),S}function s(a,l,u){for(var h;l.length&&(h=e.last(l)).i<=u;)l.pop(),a.push(h.vs),u++;return u}function o(a){return function(l,u){return l.barycenter<u.barycenter?-1:l.barycenter>u.barycenter?1:a?u.i-l.i:l.i-u.i}}return Jv}var ey,XE;function Tz(){if(XE)return ey;XE=1;var e=vt(),t=Ez(),n=jz(),s=Cz();ey=o;function o(u,h,p,f){var g=u.children(h),y=u.node(h),w=y?y.borderLeft:void 0,S=y?y.borderRight:void 0,b={};w&&(g=e.filter(g,function(M){return M!==w&&M!==S}));var _=t(u,g);e.forEach(_,function(M){if(u.children(M.v).length){var P=o(u,M.v,p,f);b[M.v]=P,e.has(P,"barycenter")&&l(M,P)}});var k=n(_,p);a(k,b);var N=s(k,f);if(w&&(N.vs=e.flatten([w,N.vs,S],!0),u.predecessors(w).length)){var j=u.node(u.predecessors(w)[0]),T=u.node(u.predecessors(S)[0]);e.has(N,"barycenter")||(N.barycenter=0,N.weight=0),N.barycenter=(N.barycenter*N.weight+j.order+T.order)/(N.weight+2),N.weight+=2}return N}function a(u,h){e.forEach(u,function(p){p.vs=e.flatten(p.vs.map(function(f){return h[f]?h[f].vs:f}),!0)})}function l(u,h){e.isUndefined(u.barycenter)?(u.barycenter=h.barycenter,u.weight=h.weight):(u.barycenter=(u.barycenter*u.weight+h.barycenter*h.weight)/(u.weight+h.weight),u.weight+=h.weight)}return ey}var ty,QE;function Rz(){if(QE)return ty;QE=1;var e=vt(),t=lr().Graph;ty=n;function n(o,a,l){var u=s(o),h=new t({compound:!0}).setGraph({root:u}).setDefaultNodeLabel(function(p){return o.node(p)});return e.forEach(o.nodes(),function(p){var f=o.node(p),g=o.parent(p);(f.rank===a||f.minRank<=a&&a<=f.maxRank)&&(h.setNode(p),h.setParent(p,g||u),e.forEach(o[l](p),function(y){var w=y.v===p?y.w:y.v,S=h.edge(w,p),b=e.isUndefined(S)?0:S.weight;h.setEdge(w,p,{weight:o.edge(y).weight+b})}),e.has(f,"minRank")&&h.setNode(p,{borderLeft:f.borderLeft[a],borderRight:f.borderRight[a]}))}),h}function s(o){for(var a;o.hasNode(a=e.uniqueId("_root")););return a}return ty}var ny,ZE;function Az(){if(ZE)return ny;ZE=1;var e=vt();ny=t;function t(n,s,o){var a={},l;e.forEach(o,function(u){for(var h=n.parent(u),p,f;h;){if(p=n.parent(h),p?(f=a[p],a[p]=h):(f=l,l=h),f&&f!==h){s.setEdge(f,h);return}h=p}})}return ny}var ry,JE;function Mz(){if(JE)return ry;JE=1;var e=vt(),t=Sz(),n=Nz(),s=Tz(),o=Rz(),a=Az(),l=lr().Graph,u=pn();ry=h;function h(y){var w=u.maxRank(y),S=p(y,e.range(1,w+1),"inEdges"),b=p(y,e.range(w-1,-1,-1),"outEdges"),_=t(y);g(y,_);for(var k=Number.POSITIVE_INFINITY,N,j=0,T=0;T<4;++j,++T){f(j%2?S:b,j%4>=2),_=u.buildLayerMatrix(y);var M=n(y,_);M<k&&(T=0,N=e.cloneDeep(_),k=M)}g(y,N)}function p(y,w,S){return e.map(w,function(b){return o(y,b,S)})}function f(y,w){var S=new l;e.forEach(y,function(b){var _=b.graph().root,k=s(b,_,S,w);e.forEach(k.vs,function(N,j){b.node(N).order=j}),a(b,S,k.vs)})}function g(y,w){e.forEach(w,function(S){e.forEach(S,function(b,_){y.node(b).order=_})})}return ry}var sy,ej;function Iz(){if(ej)return sy;ej=1;var e=vt(),t=lr().Graph,n=pn();sy={positionX:S,findType1Conflicts:s,findType2Conflicts:o,addConflict:l,hasConflict:u,verticalAlignment:h,horizontalCompaction:p,alignCoordinates:y,findSmallestWidthAlignment:g,balance:w};function s(k,N){var j={};function T(M,P){var I=0,F=0,O=M.length,A=e.last(P);return e.forEach(P,function(D,H){var K=a(k,D),C=K?k.node(K).order:O;(K||D===A)&&(e.forEach(P.slice(F,H+1),function(X){e.forEach(k.predecessors(X),function(B){var ne=k.node(B),J=ne.order;(J<I||C<J)&&!(ne.dummy&&k.node(X).dummy)&&l(j,B,X)})}),F=H+1,I=C)}),P}return e.reduce(N,T),j}function o(k,N){var j={};function T(P,I,F,O,A){var D;e.forEach(e.range(I,F),function(H){D=P[H],k.node(D).dummy&&e.forEach(k.predecessors(D),function(K){var C=k.node(K);C.dummy&&(C.order<O||C.order>A)&&l(j,K,D)})})}function M(P,I){var F=-1,O,A=0;return e.forEach(I,function(D,H){if(k.node(D).dummy==="border"){var K=k.predecessors(D);K.length&&(O=k.node(K[0]).order,T(I,A,H,F,O),A=H,F=O)}T(I,A,I.length,O,P.length)}),I}return e.reduce(N,M),j}function a(k,N){if(k.node(N).dummy)return e.find(k.predecessors(N),function(j){return k.node(j).dummy})}function l(k,N,j){if(N>j){var T=N;N=j,j=T}var M=k[N];M||(k[N]=M={}),M[j]=!0}function u(k,N,j){if(N>j){var T=N;N=j,j=T}return e.has(k[N],j)}function h(k,N,j,T){var M={},P={},I={};return e.forEach(N,function(F){e.forEach(F,function(O,A){M[O]=O,P[O]=O,I[O]=A})}),e.forEach(N,function(F){var O=-1;e.forEach(F,function(A){var D=T(A);if(D.length){D=e.sortBy(D,function(B){return I[B]});for(var H=(D.length-1)/2,K=Math.floor(H),C=Math.ceil(H);K<=C;++K){var X=D[K];P[A]===A&&O<I[X]&&!u(j,A,X)&&(P[X]=A,P[A]=M[A]=M[X],O=I[X])}}})}),{root:M,align:P}}function p(k,N,j,T,M){var P={},I=f(k,N,j,M),F=M?"borderLeft":"borderRight";function O(H,K){for(var C=I.nodes(),X=C.pop(),B={};X;)B[X]?H(X):(B[X]=!0,C.push(X),C=C.concat(K(X))),X=C.pop()}function A(H){P[H]=I.inEdges(H).reduce(function(K,C){return Math.max(K,P[C.v]+I.edge(C))},0)}function D(H){var K=I.outEdges(H).reduce(function(X,B){return Math.min(X,P[B.w]-I.edge(B))},Number.POSITIVE_INFINITY),C=k.node(H);K!==Number.POSITIVE_INFINITY&&C.borderType!==F&&(P[H]=Math.max(P[H],K))}return O(A,I.predecessors.bind(I)),O(D,I.successors.bind(I)),e.forEach(T,function(H){P[H]=P[j[H]]}),P}function f(k,N,j,T){var M=new t,P=k.graph(),I=b(P.nodesep,P.edgesep,T);return e.forEach(N,function(F){var O;e.forEach(F,function(A){var D=j[A];if(M.setNode(D),O){var H=j[O],K=M.edge(H,D);M.setEdge(H,D,Math.max(I(k,A,O),K||0))}O=A})}),M}function g(k,N){return e.minBy(e.values(N),function(j){var T=Number.NEGATIVE_INFINITY,M=Number.POSITIVE_INFINITY;return e.forIn(j,function(P,I){var F=_(k,I)/2;T=Math.max(P+F,T),M=Math.min(P-F,M)}),T-M})}function y(k,N){var j=e.values(N),T=e.min(j),M=e.max(j);e.forEach(["u","d"],function(P){e.forEach(["l","r"],function(I){var F=P+I,O=k[F],A;if(O!==N){var D=e.values(O);A=I==="l"?T-e.min(D):M-e.max(D),A&&(k[F]=e.mapValues(O,function(H){return H+A}))}})})}function w(k,N){return e.mapValues(k.ul,function(j,T){if(N)return k[N.toLowerCase()][T];var M=e.sortBy(e.map(k,T));return(M[1]+M[2])/2})}function S(k){var N=n.buildLayerMatrix(k),j=e.merge(s(k,N),o(k,N)),T={},M;e.forEach(["u","d"],function(I){M=I==="u"?N:e.values(N).reverse(),e.forEach(["l","r"],function(F){F==="r"&&(M=e.map(M,function(H){return e.values(H).reverse()}));var O=(I==="u"?k.predecessors:k.successors).bind(k),A=h(k,M,j,O),D=p(k,M,A.root,A.align,F==="r");F==="r"&&(D=e.mapValues(D,function(H){return-H})),T[I+F]=D})});var P=g(k,T);return y(T,P),w(T,k.graph().align)}function b(k,N,j){return function(T,M,P){var I=T.node(M),F=T.node(P),O=0,A;if(O+=I.width/2,e.has(I,"labelpos"))switch(I.labelpos.toLowerCase()){case"l":A=-I.width/2;break;case"r":A=I.width/2;break}if(A&&(O+=j?A:-A),A=0,O+=(I.dummy?N:k)/2,O+=(F.dummy?N:k)/2,O+=F.width/2,e.has(F,"labelpos"))switch(F.labelpos.toLowerCase()){case"l":A=F.width/2;break;case"r":A=-F.width/2;break}return A&&(O+=j?A:-A),A=0,O}}function _(k,N){return k.node(N).width}return sy}var iy,tj;function Oz(){if(tj)return iy;tj=1;var e=vt(),t=pn(),n=Iz().positionX;iy=s;function s(a){a=t.asNonCompoundGraph(a),o(a),e.forEach(n(a),function(l,u){a.node(u).x=l})}function o(a){var l=t.buildLayerMatrix(a),u=a.graph().ranksep,h=0;e.forEach(l,function(p){var f=e.max(e.map(p,function(g){return a.node(g).height}));e.forEach(p,function(g){a.node(g).y=h+f/2}),h+=f+u})}return iy}var oy,nj;function Pz(){if(nj)return oy;nj=1;var e=vt(),t=gz(),n=vz(),s=wz(),o=pn().normalizeRanks,a=xz(),l=pn().removeEmptyRanks,u=bz(),h=_z(),p=kz(),f=Mz(),g=Oz(),y=pn(),w=lr().Graph;oy=S;function S(L,q){var Z=q&&q.debugTiming?y.time:y.notime;Z("layout",function(){var se=Z(" buildLayoutGraph",function(){return O(L)});Z(" runLayout",function(){b(se,Z)}),Z(" updateInputGraph",function(){_(L,se)})})}function b(L,q){q(" makeSpaceForEdgeLabels",function(){A(L)}),q(" removeSelfEdges",function(){W(L)}),q(" acyclic",function(){t.run(L)}),q(" nestingGraph.run",function(){u.run(L)}),q(" rank",function(){s(y.asNonCompoundGraph(L))}),q(" injectEdgeLabelProxies",function(){D(L)}),q(" removeEmptyRanks",function(){l(L)}),q(" nestingGraph.cleanup",function(){u.cleanup(L)}),q(" normalizeRanks",function(){o(L)}),q(" assignRankMinMax",function(){H(L)}),q(" removeEdgeLabelProxies",function(){K(L)}),q(" normalize.run",function(){n.run(L)}),q(" parentDummyChains",function(){a(L)}),q(" addBorderSegments",function(){h(L)}),q(" order",function(){f(L)}),q(" insertSelfEdges",function(){Q(L)}),q(" adjustCoordinateSystem",function(){p.adjust(L)}),q(" position",function(){g(L)}),q(" positionSelfEdges",function(){$(L)}),q(" removeBorderNodes",function(){J(L)}),q(" normalize.undo",function(){n.undo(L)}),q(" fixupEdgeLabelCoords",function(){B(L)}),q(" undoCoordinateSystem",function(){p.undo(L)}),q(" translateGraph",function(){C(L)}),q(" assignNodeIntersects",function(){X(L)}),q(" reversePoints",function(){ne(L)}),q(" acyclic.undo",function(){t.undo(L)})}function _(L,q){e.forEach(L.nodes(),function(Z){var se=L.node(Z),fe=q.node(Z);se&&(se.x=fe.x,se.y=fe.y,q.children(Z).length&&(se.width=fe.width,se.height=fe.height))}),e.forEach(L.edges(),function(Z){var se=L.edge(Z),fe=q.edge(Z);se.points=fe.points,e.has(fe,"x")&&(se.x=fe.x,se.y=fe.y)}),L.graph().width=q.graph().width,L.graph().height=q.graph().height}var k=["nodesep","edgesep","ranksep","marginx","marginy"],N={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},j=["acyclicer","ranker","rankdir","align"],T=["width","height"],M={width:0,height:0},P=["minlen","weight","width","height","labeloffset"],I={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},F=["labelpos"];function O(L){var q=new w({multigraph:!0,compound:!0}),Z=Y(L.graph());return q.setGraph(e.merge({},N,G(Z,k),e.pick(Z,j))),e.forEach(L.nodes(),function(se){var fe=Y(L.node(se));q.setNode(se,e.defaults(G(fe,T),M)),q.setParent(se,L.parent(se))}),e.forEach(L.edges(),function(se){var fe=Y(L.edge(se));q.setEdge(se,e.merge({},I,G(fe,P),e.pick(fe,F)))}),q}function A(L){var q=L.graph();q.ranksep/=2,e.forEach(L.edges(),function(Z){var se=L.edge(Z);se.minlen*=2,se.labelpos.toLowerCase()!=="c"&&(q.rankdir==="TB"||q.rankdir==="BT"?se.width+=se.labeloffset:se.height+=se.labeloffset)})}function D(L){e.forEach(L.edges(),function(q){var Z=L.edge(q);if(Z.width&&Z.height){var se=L.node(q.v),fe=L.node(q.w),he={rank:(fe.rank-se.rank)/2+se.rank,e:q};y.addDummyNode(L,"edge-proxy",he,"_ep")}})}function H(L){var q=0;e.forEach(L.nodes(),function(Z){var se=L.node(Z);se.borderTop&&(se.minRank=L.node(se.borderTop).rank,se.maxRank=L.node(se.borderBottom).rank,q=e.max(q,se.maxRank))}),L.graph().maxRank=q}function K(L){e.forEach(L.nodes(),function(q){var Z=L.node(q);Z.dummy==="edge-proxy"&&(L.edge(Z.e).labelRank=Z.rank,L.removeNode(q))})}function C(L){var q=Number.POSITIVE_INFINITY,Z=0,se=Number.POSITIVE_INFINITY,fe=0,he=L.graph(),ye=he.marginx||0,Re=he.marginy||0;function Ue(De){var Ie=De.x,ke=De.y,ce=De.width,xe=De.height;q=Math.min(q,Ie-ce/2),Z=Math.max(Z,Ie+ce/2),se=Math.min(se,ke-xe/2),fe=Math.max(fe,ke+xe/2)}e.forEach(L.nodes(),function(De){Ue(L.node(De))}),e.forEach(L.edges(),function(De){var Ie=L.edge(De);e.has(Ie,"x")&&Ue(Ie)}),q-=ye,se-=Re,e.forEach(L.nodes(),function(De){var Ie=L.node(De);Ie.x-=q,Ie.y-=se}),e.forEach(L.edges(),function(De){var Ie=L.edge(De);e.forEach(Ie.points,function(ke){ke.x-=q,ke.y-=se}),e.has(Ie,"x")&&(Ie.x-=q),e.has(Ie,"y")&&(Ie.y-=se)}),he.width=Z-q+ye,he.height=fe-se+Re}function X(L){e.forEach(L.edges(),function(q){var Z=L.edge(q),se=L.node(q.v),fe=L.node(q.w),he,ye;Z.points?(he=Z.points[0],ye=Z.points[Z.points.length-1]):(Z.points=[],he=fe,ye=se),Z.points.unshift(y.intersectRect(se,he)),Z.points.push(y.intersectRect(fe,ye))})}function B(L){e.forEach(L.edges(),function(q){var Z=L.edge(q);if(e.has(Z,"x"))switch((Z.labelpos==="l"||Z.labelpos==="r")&&(Z.width-=Z.labeloffset),Z.labelpos){case"l":Z.x-=Z.width/2+Z.labeloffset;break;case"r":Z.x+=Z.width/2+Z.labeloffset;break}})}function ne(L){e.forEach(L.edges(),function(q){var Z=L.edge(q);Z.reversed&&Z.points.reverse()})}function J(L){e.forEach(L.nodes(),function(q){if(L.children(q).length){var Z=L.node(q),se=L.node(Z.borderTop),fe=L.node(Z.borderBottom),he=L.node(e.last(Z.borderLeft)),ye=L.node(e.last(Z.borderRight));Z.width=Math.abs(ye.x-he.x),Z.height=Math.abs(fe.y-se.y),Z.x=he.x+Z.width/2,Z.y=se.y+Z.height/2}}),e.forEach(L.nodes(),function(q){L.node(q).dummy==="border"&&L.removeNode(q)})}function W(L){e.forEach(L.edges(),function(q){if(q.v===q.w){var Z=L.node(q.v);Z.selfEdges||(Z.selfEdges=[]),Z.selfEdges.push({e:q,label:L.edge(q)}),L.removeEdge(q)}})}function Q(L){var q=y.buildLayerMatrix(L);e.forEach(q,function(Z){var se=0;e.forEach(Z,function(fe,he){var ye=L.node(fe);ye.order=he+se,e.forEach(ye.selfEdges,function(Re){y.addDummyNode(L,"selfedge",{width:Re.label.width,height:Re.label.height,rank:ye.rank,order:he+ ++se,e:Re.e,label:Re.label},"_se")}),delete ye.selfEdges})})}function $(L){e.forEach(L.nodes(),function(q){var Z=L.node(q);if(Z.dummy==="selfedge"){var se=L.node(Z.e.v),fe=se.x+se.width/2,he=se.y,ye=Z.x-fe,Re=se.height/2;L.setEdge(Z.e,Z.label),L.removeNode(q),Z.label.points=[{x:fe+2*ye/3,y:he-Re},{x:fe+5*ye/6,y:he-Re},{x:fe+ye,y:he},{x:fe+5*ye/6,y:he+Re},{x:fe+2*ye/3,y:he+Re}],Z.label.x=Z.x,Z.label.y=Z.y}})}function G(L,q){return e.mapValues(e.pick(L,q),Number)}function Y(L){var q={};return e.forEach(L,function(Z,se){q[se.toLowerCase()]=Z}),q}return oy}var ay,rj;function $z(){if(rj)return ay;rj=1;var e=vt(),t=pn(),n=lr().Graph;ay={debugOrdering:s};function s(o){var a=t.buildLayerMatrix(o),l=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(u){l.setNode(u,{label:u}),l.setParent(u,"layer"+o.node(u).rank)}),e.forEach(o.edges(),function(u){l.setEdge(u.v,u.w,{},u.name)}),e.forEach(a,function(u,h){var p="layer"+h;l.setNode(p,{rank:"same"}),e.reduce(u,function(f,g){return l.setEdge(f,g,{style:"invis"}),g})}),l}return ay}var ly,sj;function Lz(){return sj||(sj=1,ly="0.8.5"),ly}var cy,ij;function qz(){return ij||(ij=1,cy={graphlib:lr(),layout:Pz(),debug:$z(),util:{time:pn().time,notime:pn().notime},version:Lz()}),cy}var Dz=qz();const oj=Vy(Dz),Bo=240,bu=130,Io=74,Qu=72,aj=Io+Qu;function Fz(e,t){var s;let n=Bo;for(const o of e)n=Math.max(n,((s=t.get(o.id))==null?void 0:s.width)??Bo);return n}const AR=420,zz=2;function al(e){var n;return((n=e.data)==null?void 0:n.sessionId)??"_default"}function Bz(e,t){return((t==null?void 0:t.get(e))??0)>0?AR:0}function Uz(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function ll(e,t,n){const s=t.get(e);return{w:((s==null?void 0:s.width)??Bo)+Bz(e,n),h:Math.max((s==null?void 0:s.height)??bu,Uz(e,n))}}function Wz(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function Hz(e,t,n,s,o,a){const l=new oj.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const u=e.filter(k=>!o.has(k)),h=new Set(u);for(const k of u){const{w:N,h:j}=ll(k,s,a);l.setNode(k,{width:N,height:j})}for(const k of t)h.has(k.source)&&h.has(k.target)&&l.setEdge(k.source,k.target);oj.layout(l);const p=new Map;let f=1/0,g=1/0,y=-1/0,w=-1/0;for(const k of u){const N=l.node(k);if(!N)continue;const j=s.get(k),T=(j==null?void 0:j.width)??Bo,M=(j==null?void 0:j.height)??bu,P=ll(k,s,a),I=N.x-P.w/2,F=N.y-P.h/2;p.set(k,{x:I,y:F}),I<f&&(f=I),F<g&&(g=F),I+T>y&&(y=I+T),F+M>w&&(w=F+M)}if(Number.isFinite(f)&&Number.isFinite(g))for(const[k,N]of p)p.set(k,{x:N.x-f,y:N.y-g});const S=Number.isFinite(y)?y-f:0,b=Number.isFinite(w)?w-g:0;let _=null;for(const k of e){const N=o.get(k);if(!N)continue;const j=s.get(k),T=(j==null?void 0:j.width)??Bo,M=(j==null?void 0:j.height)??bu;_=_===null?{minX:N.x,minY:N.y,maxX:N.x+T,maxY:N.y+M}:{minX:Math.min(_.minX,N.x),minY:Math.min(_.minY,N.y),maxX:Math.max(_.maxX,N.x+T),maxY:Math.max(_.maxY,N.y+M)}}return{positions:p,width:S,height:b,pinnedBox:_}}function Gz(e,t,n={}){const s=n.direction??"LR",o=n.pinned??new Map,a=n.measured??new Map,l=n.lanes,u=new Map;for(const k of e){const N=al(k),j=u.get(N);j?j.push(k.id):u.set(N,[k.id])}const p=Array.from(u.keys()).sort().map(k=>({sid:k,...Hz(u.get(k),t,s,a,o,l)})),f=Fz(e,a),g=n.availableHeight&&n.availableHeight>0?n.availableHeight:Number.POSITIVE_INFINITY,y=k=>{const N=[[]];let j=0;for(const T of p)N.length<k&&j>0&&j+T.height>g&&(N.push([]),j=0),N[N.length-1].push(T),j+=T.height+aj;return N},w=k=>k.reduce((N,j)=>Math.max(N,j.width),0)+AR;let S=y(n.availableWidth?zz:1);S.length>1&&S.reduce((N,j)=>N+w(j),0)+f*(S.length-1)>(n.availableWidth??0)&&(S=y(1));const b=new Map;let _=0;for(const k of S){const N=w(k);let j=0;for(const{positions:T,height:M,pinnedBox:P}of k){for(const[F,O]of T)b.set(F,{x:O.x+_,y:O.y+j});let I=j+M;P&&P.maxY>I&&P.minX<_+N&&_<P.maxX&&(I=P.maxY),j=I+aj}_+=N+f}return e.map(k=>{const N=o.get(k.id);if(N)return{...k,position:N};const j=b.get(k.id);return j?{...k,position:j}:k})}function Vz(e,t,n,s,o){const l=Io+Qu,u=60,h=w=>ll(w,s,o),p=new Map(e.map(w=>[w.id,al(w)])),f=[],g=e.map(w=>({id:w.id,pos:n.get(w.id)??t.get(w.id)})).filter(w=>w.pos!=null).sort((w,S)=>w.pos.y-S.pos.y||w.pos.x-S.pos.x||w.id.localeCompare(S.id)),y=[];for(const{id:w,pos:S}of g){const{w:b,h:_}=h(w),k=p.get(w)??"_default";if(n.has(w)){f.push({x:S.x,y:S.y,w:b,h:_,sid:k});continue}let N=S.y;for(let j=0;j<f.length+1;j++){const T=f.find(M=>{const P=M.sid===k?24:u,I=M.sid===k?24:l;return S.x<M.x+M.w+P&&M.x<S.x+b+P&&N<M.y+M.h+I&&M.y<N+_+I});if(!T)break;N=T.y+T.h+(T.sid===k?24:l)}N!==S.y&&(t.set(w,{x:S.x,y:N}),y.push(w)),f.push({x:S.x,y:N,w:b,h:_,sid:k})}return y}function Yz(e,t,n,s,o,a){const l=b=>ll(b,s,a),u=b=>n.get(b)??t.get(b),h=new Map;for(const b of e){if(!u(b.id))continue;const _=al(b),k=h.get(_);k?k.push(b):h.set(_,[b])}const p=new Set;for(const[b,_]of h)_.every(k=>o.has(k.id)&&!n.has(k.id))&&p.add(b);const f=new Map,g=[];for(const b of e){const _=u(b.id);if(!_)continue;const{w:k,h:N}=l(b.id),j=al(b);p.has(j)?(f.get(j)??f.set(j,[]).get(j)).push(b):g.push({x:_.x,y:_.y,w:k,h:N})}if(f.size===0)return[];const y=Io+Qu,w=(b,_,k,N)=>g.some(j=>b<j.x+j.w+Io&&j.x<b+k+Io&&_<j.y+j.h+y&&j.y<_+N+y),S=[];for(const b of[...f.keys()].sort()){const _=f.get(b);let k=1/0,N=1/0,j=-1/0,T=-1/0;for(const D of _){const H=u(D.id),{w:K,h:C}=l(D.id);k=Math.min(k,H.x),N=Math.min(N,H.y),j=Math.max(j,H.x+K),T=Math.max(T,H.y+C)}const M=j-k,P=T-N,I=[...new Set(g.map(D=>Math.round(D.x)))].sort((D,H)=>D-H),F=I.length?I:[k],O=[0,...g.map(D=>D.y+D.h+y)].sort((D,H)=>D-H);let A=null;e:for(const D of F)for(const H of O){if(H>=N)break;if(!w(D,H,M,P)){A={x:D,y:H};break e}}if(A){const D=A.x-k,H=A.y-N;for(const K of _){const C=u(K.id);t.set(K.id,{x:C.x+D,y:C.y+H})}S.push(b)}for(const D of _){const H=u(D.id),{w:K,h:C}=l(D.id);g.push({x:H.x,y:H.y,w:K,h:C})}}return S}function Kz(e,t,n,s,o,a=!1,l){const p=Io+Qu+1,f=8,g=1.75,y=200,w=.7,S=.01,b=A=>ll(A,s,l),_=A=>n.get(A)??t.get(A),k=new Map;for(const A of e){if(!_(A.id))continue;const D=al(A),H=k.get(D);H?H.push(A):k.set(D,[A])}const N=[],j=new Set,T=new Set,M=o.size===0;for(const A of[...k.keys()].sort()){const D=k.get(A);let H=1/0,K=1/0,C=-1/0,X=-1/0,B=!1;for(const Q of D){const $=_(Q.id),{w:G,h:Y}=b(Q.id);H=Math.min(H,$.x),K=Math.min(K,$.y),C=Math.max(C,$.x+G),X=Math.max(X,$.y+Y),n.has(Q.id)&&(B=!0)}const ne=C-H,J=X-K;T.add(A);const W=o.get(A);W&&(ne>W.w+f||J>W.h+f)&&j.add(A),o.set(A,{w:ne,h:J}),N.push({sid:A,members:D.map(Q=>Q.id),x:H,y:K,w:ne,h:J,anchored:B,mass:1})}for(const A of[...o.keys()])T.has(A)||o.delete(A);if(a||M)return[];let P=!1;for(let A=0;A<N.length&&!P;A++)for(let D=A+1;D<N.length;D++){const H=N[A],K=N[D];if(!(H.anchored&&K.anchored)&&Math.abs(H.x+H.w/2-(K.x+K.w/2))<(H.w+K.w)/2+61&&Math.abs(H.y+H.h/2-(K.y+K.h/2))<(H.h+K.h)/2+p){P=!0;break}}if(j.size===0&&!P)return[];if(j.size>0)for(const A of N)j.has(A.sid)&&(A.mass=8);else for(const A of N)A.mass=Math.max(1,A.w*A.h/(Bo*bu));const I=new Map(N.map(A=>[A.sid,A.x])),F=new Map(N.map(A=>[A.sid,A.y]));for(let A=0;A<y;A++){const D=new Map,H=new Map;let K=0;for(let C=0;C<N.length;C++)for(let X=C+1;X<N.length;X++){const B=N[C],ne=N[X];if(B.anchored&&ne.anchored)continue;const J=B.x+B.w/2,W=B.y+B.h/2,Q=ne.x+ne.w/2,$=ne.y+ne.h/2,G=(B.w+ne.w)/2+61-Math.abs(J-Q),Y=(B.h+ne.h)/2+p-Math.abs(W-$);if(G<=0||Y<=0)continue;const L=(Be,tt)=>!Be.anchored&&!(tt<0&&Be.x<=0),q=(Be,tt)=>!Be.anchored&&!(tt<0&&Be.y<=0),Z=(Be,tt,Ke)=>{const _t=Be===tt,Me=_t?B.sid<ne.sid?-1:1:Math.sign(Be-tt);return Ke(B,Me)||Ke(ne,-Me)?Me:_t&&(Ke(B,-Me)||Ke(ne,Me))?-Me:0},se=Z(J,Q,L),fe=Z(W,$,q),he=se!==0,ye=fe!==0;if(!he&&!ye)continue;const Re=he&&(!ye||G*g<Y),[Ue,De,Ie,ke]=Re?[se,G,D,L]:[fe,Y,H,q],ce=ke(B,Ue),xe=ke(ne,-Ue),we=B.mass,Ye=ne.mass,yt=ce?xe?Ye/(we+Ye):1:0,ct=xe?ce?we/(we+Ye):1:0,st=De*w;Ie.set(B.sid,(Ie.get(B.sid)??0)+Ue*st*yt),Ie.set(ne.sid,(Ie.get(ne.sid)??0)-Ue*st*ct),K+=st}for(const C of N)C.anchored||(C.x=Math.max(0,C.x+(D.get(C.sid)??0)),C.y=Math.max(0,C.y+(H.get(C.sid)??0)));if(K<S)break}const O=[];for(const A of N){const D=A.x-I.get(A.sid),H=A.y-F.get(A.sid);if(!(Math.abs(D)<1&&Math.abs(H)<1)){for(const K of A.members){if(n.has(K))continue;const C=t.get(K);C&&t.set(K,{x:C.x+D,y:C.y+H})}O.push(A.sid)}}return O}const Xz=600;function Uy(e,t){return!(e.exitAt!=null&&t-e.exitAt>Xz||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function Qz(e,t){const n=new Set;for(const s of e.agents.values())Uy(s,t)&&n.add(s.id);return n}function Zz(e,t,n=0){return e.right+n>t.left&&e.left-n<t.right&&e.bottom+n>t.top&&e.top-n<t.bottom}function Jz(e,t,n=0){if(!e)return!1;for(const s of t)if(Zz(e,s,n))return!0;return!1}const MR="sessionGroup";function eB(e,t){var s;if(e.type===MR)return"transparent";const n=(s=e.data)==null?void 0:s.state;return t(n==="err"?"--err":n==="active"?"--inflight":"--ok")}const IR=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function lj(e){const t={};for(const n of IR)t[n]=e(n);return t}function tB(e){return t=>e[t]??""}function nB(e,t){return IR.every(n=>e[n]===t[n])}function rB(e){const t=new Set(e.pins),n=new Map,s=new Map;for(const[o,a]of e.positions)n.set(o,a),t.has(o)&&s.set(o,a);return{positions:n,pinned:s}}const sB=1200,iB=1e3;function cj(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<sB?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<iB}function uy({durationMs:e,documentHidden:t}){return t?!1:Number.isFinite(e)&&e>0}function oB(e,t,n){const s=e.x*t.zoom+t.x,o=e.y*t.zoom+t.y,a=(e.x+e.width)*t.zoom+t.x,l=(e.y+e.height)*t.zoom+t.y;return a>0&&s<n.width&&l>0&&o<n.height}function aB({pane:e,viewport:t,boxes:n}){if(!e||!(e.width>0)||!(e.height>0)||!Number.isFinite(t.zoom)||t.zoom<=0||!Number.isFinite(t.x)||!Number.isFinite(t.y))return!1;let s=!1;for(const o of n)if(s=!0,oB(o,t,e))return!1;return s}const lB="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",dy="click for what's new";function cB(e){if(e.checkDisabled)return`${lB} · ${dy}`;if(e.checking)return`Asking npm for the newest release… · ${dy}`;const t=e.latest?`npm has v${e.latest}`:e.latestPending?`npm's latest tag names v${e.latestPending}, which it cannot serve yet`:"npm not reached yet",n=e.checkedAgo?` · checked ${e.checkedAgo}`:"";return`${t}${n} · re-checked periodically · ${dy}, and to check npm now`}function uB(e){const t=`Version v${e.running}, show what's new`;return e.checkDisabled?`${t} — update checks are off`:e.checking?`${t} — checking npm for a newer release`:`${t} and check npm for a newer release`}function dB(e){const t=e.kind==="restart"?`v${e.to} is installed and waiting for a restart`:`v${e.to} is available on npm`,n=e.open?"show what's new":"show what's new and the notice";return`Version v${e.from}, ${t} — ${n}`}function fB(e){if(e==null)return{kind:"unknown",lead:"No data yet. Start a Claude Code or Codex session — it appears here as soon as the deck sees its first event.",workspace:null,tail:""};const t=e.trim();return t===""?{kind:"machine",lead:"No data yet. Start a Claude Code or Codex session anywhere on this machine — this deck is unscoped and captures every workspace.",workspace:null,tail:""}:{kind:"scoped",lead:"No data yet. This deck only captures sessions running under",workspace:t,tail:" — start one there, or restart it without --workspace/--scope to watch the whole machine."}}const Wy={kind:"assumed",claude:!0,codex:!0};function hB(e){if(!e||typeof e!="object")return Wy;const t=e.providers;if(!t||typeof t!="object")return Wy;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function _u(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const uj=99;function pB(e){const t=Math.max(0,Math.floor(e));return t>uj?`${uj}+`:String(t)}const mB="Pause the canvas";function gB(e){if(!e.paused)return"Pause live updates — events keep arriving and are applied when you resume (Space)";const t=Math.max(0,Math.floor(e.dropped??0));return t>0?`The pause is full — ${_u(e.held)} held and ${t} older ${t===1?"one":"ones"} already dropped. Resume to follow the canvas again (Space)`:e.held<=0?"Nothing has arrived since you paused. Resume to follow the canvas again (Space)":`${_u(e.held)} arrived while paused and will be applied in order when you resume (Space)`}function vB(e){return e.connected||!e.paused?null:"The canvas is paused as well — Space resumes it, but nothing new arrives until the stream is back."}const OR="paused · full",yB=(e,t)=>t>0?OR:e>0?`paused · ${pB(e)}`:"paused";function wB(e){const t=Math.max(0,Math.floor(e.dropped??0));return e.connected?e.paused?{tone:"paused",resting:!1,label:yB(e.held,t),widest:OR,title:t>0?`Connected — the pause is full at ${_u(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up (Space)`:e.held>0?`Connected — ${_u(e.held)} held until you resume (Space)`:"Connected — updates held until you resume (Space)"}:{tone:"live",resting:!0,label:"live",widest:"live",title:"Receiving events"}:{tone:"dead",resting:!1,label:"offline",widest:"offline",title:e.paused?"SSE disconnected — and the canvas is paused, so resuming will not bring events back until it reconnects":"SSE disconnected"}}function dj(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const xB={agent:BL,sessionGroup:s3},PR="react-flow__node";function fj(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,PR))===!0}function bB(e){try{const t=document.querySelector(`.${PR}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}const _B=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(","),kB=420,Jc=18,SB=200,NB=5*6e4,EB=6,jB=2*6e4,hj=400,Hw="agent-dag.layout",Gw="agent-dag.viewport",$R="agent-dag.summariesDismissed",LR="agent-dag.sessionListOpen",qR="agent-dag.detailOpen",DR="agent-dag.usagePanelOpen",pj="agent-dag.accountsPanelOpen",fy="agent-dag.versionNoticeDismissed",mj="agent-dag.oldNameNoticeDismissed",CB=15*6e4,hy={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:"},gj="agent-dag.autoRestart",vj="agent-dag.bundleReloadedFor";function TB(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(LR)==="1"}catch{return!1}}function RB(e){if(!(typeof window>"u"))try{window.localStorage.setItem(LR,e?"1":"0")}catch{}}function AB(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(qR)==="1"}catch{return!1}}function MB(e){if(!(typeof window>"u"))try{window.localStorage.setItem(qR,e?"1":"0")}catch{}}function IB(){const e=Mu(DR);return e===null?!0:e==="1"}function OB(e){if(!(typeof window>"u"))try{window.localStorage.setItem(DR,e?"1":"0")}catch{}}function PB(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem($R);if(!e)return new Set;const t=JSON.parse(e);return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function yj(e){if(!(typeof window>"u"))try{const t=Array.from(e),n=t.length>200?t.slice(-200):t;window.localStorage.setItem($R,JSON.stringify(n))}catch{}}function $B(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const t=window.localStorage.getItem(Hw);if(!t)return e;const n=JSON.parse(t);if(!("v"in n)){const o=Object.entries(n).filter(([,a])=>a&&typeof a.x=="number"&&typeof a.y=="number");return{positions:o,pins:o.map(([a])=>a)}}return{positions:Object.entries(n.positions??{}).filter(([,o])=>o&&typeof o.x=="number"&&typeof o.y=="number"),pins:Array.isArray(n.pins)?n.pins:[]}}catch{return e}}function py(e,t){if(!(typeof window>"u"))try{const n={};for(const[s,o]of e)n[s]=o;for(const[s,o]of t)n[s]=o;window.localStorage.setItem(Hw,JSON.stringify({v:2,positions:n,pins:Array.from(t.keys())}))}catch{}}function LB(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Gw);if(!e)return null;const t=JSON.parse(e);return typeof(t==null?void 0:t.x)!="number"||typeof(t==null?void 0:t.y)!="number"||typeof(t==null?void 0:t.zoom)!="number"?null:t}catch{return null}}function qB(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Gw,JSON.stringify(e))}catch{}}function wj(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Hw)}catch{}try{window.localStorage.removeItem(Gw)}catch{}}}function DB(e,t){const n=e.agents.get(t);if(!n)return;const s=[];for(const f of e.agents.values())f.sessionId===t&&s.push(f);const o={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:t,label:n.label,cwd:n.cwd,startedAt:n.startedAt,endedAt:n.endedAt,model:n.model,agents:s.map(f=>({id:f.id,kind:f.kind,label:f.label,parentId:f.parentId,state:f.state,startedAt:f.startedAt,endedAt:f.endedAt,model:f.model,cwd:f.cwd,usage:f.usage,prompts:f.prompts,tools:f.tools.map(g=>({id:g.id,name:g.name,inputPreview:g.inputPreview,startedAt:g.startedAt,endedAt:g.endedAt,ok:g.ok,errorPreview:g.errorPreview,usage:g.usage}))}))},a=JSON.stringify(o,null,2),l=new Blob([a],{type:"application/json"}),u=URL.createObjectURL(l),h=document.createElement("a"),p=(n.label||"session").replace(/[^a-z0-9._-]/gi,"_");h.href=u,h.download=`${zt}-${p}-${t.slice(0,8)}.json`,document.body.appendChild(h),h.click(),document.body.removeChild(h),setTimeout(()=>URL.revokeObjectURL(u),1e3)}const Hy={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Gy={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},FR=iT;function FB(e,t,n,s,o,a,l,u,h,p,f,g,y,w,S,b,_,k){const N=[],j=[];for(const A of e.agents.values()){if(!_.has(A.id))continue;const D=A.exitAt!=null,H=b!=null&&!b.has(A.id),K=[D?"rf-exiting":"",H?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,C=a.get(A.id);if(N.push({id:A.id,type:"agent",position:{x:0,y:0},data:{...A,now:t,onOpenContext:k},className:K,...C?{width:C.width,height:C.height}:null}),A.parentId&&_.has(A.parentId)){const X=hw(A.sessionId),B=D,ne=S.size>0&&(S.has(A.id)||S.has(A.parentId)),J=b!=null&&!b.has(A.id)&&!b.has(A.parentId),W=A.state==="active"?2:1.5,Q=ne?W+1.5:W,$=B?.2:J?.12:1,G=["sess-edge",A.state==="active"?"sess-live":"sess-idle",B?"rf-edge-exiting":"",ne?"rf-edge-selected":""].filter(Boolean).join(" ");j.push({id:`e:${A.parentId}->${A.id}`,source:A.parentId,target:A.id,animated:(A.state==="active"||ne)&&!B,type:"smoothstep",style:{"--session-hue":X,strokeWidth:Q,opacity:$,transition:"var(--edge-transition)"},className:G})}}const T=new Map;for(const A of e.agents.values())A.tools.length>0&&T.set(A.id,Math.min(4,A.tools.length));const M=`${y}#lanes:${Wz(T)}`,P=N.filter(A=>qD(A.id,o,f,g));if(P.length>0||M!==w.current){if(P.length>0){const A=Gz(N,j,{direction:"LR",pinned:o,measured:a,availableWidth:n,availableHeight:s,lanes:T});for(const D of A)CT(D.id,f,g)&&FD(D.id,D.position,f,g);Yz(N,f,o,a,new Set(P.map(D=>D.id)),T)}Vz(N,f,o,a,T),w.current=M}const I=Kz(N,f,o,a,l,!h||p,T);I.length>0&&u(I),Vc(f,e.agents),Vc(g,e.agents),Vc(o,e.agents),Vc(a,PD(e.agents.values()));const F=[];let O=!1;for(const A of N){let D=o.get(A.id)??f.get(A.id);D||(D=DD(A.id,f,g),O=!0),F.push({...A,position:D})}return O&&(w.current=""),{nodes:F,edges:j}}function zB(){return d.jsx(dw,{children:d.jsx(BB,{})})}function BB(){var us,ql,Ys,Dl;const e=hl(),t=Tt(),n=E.useState(Ay)[0],s=E.useRef(n),[,o]=E.useState(0),a=E.useCallback(()=>o(z=>z+1),[]),[l,u]=E.useState(()=>new Set),[h,p]=E.useState(null),[f,g]=E.useState(null),y=E.useCallback((z,V)=>{u(ae=>{if(!V)return new Set([z]);const de=new Set(ae);return de.has(z)?de.delete(z):de.add(z),de}),p(ae=>V&&ae===z?ae:z)},[]),w=E.useCallback(()=>{u(new Set),p(null)},[]),[S,b]=E.useState(null),[_,k]=E.useState(null),N=E.useCallback(z=>k(z),[]),[j,T]=E.useState(!1),[M,P]=E.useState(!1),I=E.useState(PB)[0],[F,O]=E.useState(TB);E.useEffect(()=>{RB(F)},[F]);const[A,D]=E.useState(AB);E.useEffect(()=>{MB(A)},[A]);const[H,K]=E.useState(IB);E.useEffect(()=>{OB(H)},[H]);const[C,X]=E.useState(()=>{try{const z=window.localStorage.getItem(pj);return z===null?!0:z==="1"}catch{return!0}});E.useEffect(()=>{try{window.localStorage.setItem(pj,C?"1":"0")}catch{}},[C]);const[B,ne]=E.useState(null);E.useEffect(()=>{let z=null;try{z=localStorage.getItem("agent-dag.sound")}catch{}ne(z===null?!0:z==="on")},[]);const J=E.useCallback(()=>{ne(z=>{var ae;const V=z!==!0;try{localStorage.setItem("agent-dag.sound",V?"on":"off")}catch{}return V&&((ae=Re.current)==null||ae.unlock()),V})},[]),W=E.useCallback(z=>{J()},[J]),Q=E.useRef(W);Q.current=W;const $=E.useRef(B);$.current=B;const[G,Y]=E.useState(()=>lD(Mu)),L=E.useRef(G);L.current=G;const q=E.useRef(null),Z=E.useCallback((z,V=!1)=>{var ae,de;if((ae=Re.current)==null||ae.unlock(),q.current!==null&&clearTimeout(q.current),q.current=null,!V){(de=Re.current)==null||de.play(z,!0);return}q.current=setTimeout(()=>{var be;q.current=null,(be=Re.current)==null||be.play(z,!0)},rD)},[]),se=E.useCallback((z,V)=>{Y(ae=>{const de={level:ol(V.level??ae[z].level),figure:kT(z,V.figure??ae[z].figure)};try{localStorage.setItem(NT[z],String(de.level)),localStorage.setItem(ET[z],de.figure)}catch{}return{...ae,[z]:de}}),Z(z,!0)},[Z]);E.useEffect(()=>()=>{q.current!==null&&clearTimeout(q.current)},[]);const[fe,he]=E.useState(!1),ye=E.useRef(null),Re=E.useRef(null),[Ue,De]=E.useState("locked");E.useEffect(()=>{const z=dD({enabled:()=>$.current===!0,prefs:()=>L.current,onState:De});Re.current=z,De(z.state());const V=()=>z.unlock();return window.addEventListener("pointerdown",V,{once:!0,capture:!0}),window.addEventListener("keydown",V,{once:!0,capture:!0}),()=>{window.removeEventListener("pointerdown",V,{capture:!0}),window.removeEventListener("keydown",V,{capture:!0})}},[]);const[Ie,ke]=E.useState(!1),[ce,xe]=E.useState(null),[we,Ye]=E.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(fy)??""}catch{return""}}),[yt,ct]=E.useState(!1),st=E.useRef(0),[Be,tt]=E.useState(!1),Ke=E.useCallback((z=!1)=>(z&&(st.current=Date.now(),tt(!0)),fetch(z?"/api/version?refresh=1":"/api/version").then(V=>V.ok?V.json():null).then(V=>{V&&xe(V)}).catch(()=>{}).finally(()=>{z&&tt(!1)})),[]),_t=E.useCallback(()=>{Ke(Date.now()-st.current>=CB)},[Ke]);E.useEffect(()=>{Ke();const z=window.setInterval(_t,5*6e4),V=()=>{document.visibilityState==="visible"&&_t()};return document.addEventListener("visibilitychange",V),()=>{window.clearInterval(z),document.removeEventListener("visibilitychange",V)}},[Ke,_t]),E.useEffect(()=>{Ie&&Ke()},[Ie,Ke]);const Me=(ce==null?void 0:ce.notice)??null,[it,At]=E.useState(null),oe=E.useRef(!1);E.useEffect(()=>{if(oe.current)return;const z=_D(),V=kD(z),ae=ED({stored:V,running:(ce==null?void 0:ce.running)??null,notes:I1,remembers:SD(z)});ae.reason!=="no-version"&&(oe.current=!0,ae.record&&ND(z,ae.record),ae.show.length&&At({entries:ae.show,since:V,firstRun:ae.reason==="welcome"}))},[ce==null?void 0:ce.running]);const Pe=(ce==null?void 0:ce.running)??"3.2.1",qe=E.useMemo(()=>jT(I1,null,Pe),[Pe]),Ne=E.useCallback(()=>{At({entries:qe,since:null,firstRun:!1})},[qe]),[We,Et]=E.useState(null),[et,Ce]=E.useState(Wy);E.useEffect(()=>{let z=!1;return fetch("/api/health").then(V=>V.ok?V.json():null).then(V=>{z||(Ce(hB(V)),!(!V||typeof V.workspace!="string")&&Et(V.workspace))}).catch(()=>{}),()=>{z=!0}},[Ie]);const wt=E.useRef(et);wt.current=et;const at=Me?`${Me.kind}:${Me.to}`:"",kt=Me!=null&&we!==at,Sn=E.useCallback(()=>{Ye("");try{window.localStorage.setItem(fy,"")}catch{}},[]),Fn=E.useCallback(()=>{if(Me){Ye(at);try{window.localStorage.setItem(fy,at)}catch{}}},[Me,at]),[Nn,Ni]=E.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(mj)??""}catch{return""}}),mn=ce!=null&&ce.invokedAs&&ce.invokedAs!==zt?ce.invokedAs:null,Ei=mn!=null&&Nn!==mn,ji=E.useCallback(()=>{if(mn){Ni(mn);try{window.localStorage.setItem(mj,mn)}catch{}}},[mn]),Bt=((us=ce==null?void 0:ce.upgrade)==null?void 0:us.state)??"idle",jr=Dq(ce==null?void 0:ce.upgrade),zn=E.useRef(!1),Is=E.useCallback(async()=>{if(or(zn.current||Bt==="running")){zn.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await Ke(),zn.current=!1}},[Bt,Ke]);E.useEffect(()=>{if(Bt!=="running")return;const z=window.setInterval(Ke,3e3);return()=>window.clearInterval(z)},[Bt,Ke]);const Cr=E.useCallback(async()=>{var ae;const z=ce==null?void 0:ce.command;if(!z)return;let V=!1;try{V=await Promise.race([((ae=navigator.clipboard)==null?void 0:ae.writeText(z).then(()=>!0))??Promise.resolve(!1),new Promise(de=>window.setTimeout(()=>de(!1),500))])}catch{V=!1}if(!V)try{const de=document.createElement("textarea");de.value=z,de.setAttribute("readonly",""),de.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(de),de.select(),V=document.execCommand("copy"),de.remove()}catch{V=!1}V&&(ct(!0),window.setTimeout(()=>ct(!1),1600))},[ce==null?void 0:ce.command]),Ko=E.useCallback(()=>{O(z=>(z||X(!1),!z))},[]),dr=E.useCallback(()=>{X(z=>(z||O(!1),!z))},[]),[Tr,fr]=E.useState(!1),[Jr,Ci]=E.useState(!1),[Ti,Ri]=E.useState(()=>{try{return Number(localStorage.getItem(L1))||0}catch{return 0}}),[En,Ai]=E.useState([]),[Rr,Mi]=E.useState(!1);E.useEffect(()=>{let z=!0;const V=()=>{fetch("/api/browser-watch").then(de=>de.ok?de.json():null).then(de=>{var be;!z||!(de!=null&&de.ok)||(Ai(de.episodes??[]),Mi(((be=de.settings)==null?void 0:be.enabled)===!0))}).catch(()=>{})};V();const ae=setInterval(V,5*6e4);return()=>{z=!1,clearInterval(ae)}},[]);const Bn=E.useMemo(()=>m5(En,Ti).length,[En,Ti]),[Ii,Os]=E.useState(0),Ps=E.useRef(null),[Oi,Pi]=E.useState(!1),nt=E.useRef(null),[Xo,es]=E.useState(0),Gt=E.useState(()=>HD({protect:z=>nL(s.current,z)}))[0],[Un,$i]=E.useState(!1),ts=E.useCallback(()=>{const z=Gt.paused&&Gt.dropped>0,V=Gt.setPaused(!Gt.paused);z&&rL(s.current);for(const ae of V)s.current=Gb(s.current,ae);$i(Gt.paused)},[Gt]),[ht,sn]=E.useState(Date.now()),[Wn,gn]=E.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(gj)!=="0"}catch{return!0}}),Zu=E.useCallback(()=>{gn(z=>{const V=!z;try{window.localStorage.setItem(gj,V?"1":"0")}catch{}return V})},[]),[Ar,Li]=E.useState(!1),[qi,Di]=E.useState("restart"),[ns,$s]=E.useState(null),rs=E.useRef(!1),kl=E.useRef(null),Fi=E.useRef(0),Ls=E.useCallback(async z=>{if(!or(rs.current))return;const V=(z==null?void 0:z.upgrade)===!0;rs.current=!0,kl.current=jr;const ae=++Fi.current;Di(V?"npx":"restart"),Li(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(Me==null?void 0:Me.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:V})})}catch{}window.setTimeout(()=>{if(Fi.current===ae&&rs.current){rs.current=!1,Li(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},V?18e4:3e4)},[Me==null?void 0:Me.to,jr]),zi=E.useRef(null);E.useEffect(()=>{let z=!1;for(const ae of s.current.agents.values())if(ae.state==="active"){z=!0;break}const V=zq({enabled:Wn,kind:Me==null?void 0:Me.kind,canRestart:(ce==null?void 0:ce.canRestart)===!0,busy:z,idleSince:zi.current,now:ht});zi.current=V.idleSince,V.restart&&Ls()},[Wn,Me==null?void 0:Me.kind,ce==null?void 0:ce.canRestart,ht,Ls]),E.useEffect(()=>{const z=ce==null?void 0:ce.running;let V=null,ae=null;try{V=window.sessionStorage.getItem("agent-dag.restartPending"),ae=window.sessionStorage.getItem(vj)}catch{return}const de=qq({bundle:"3.2.1",running:z,pending:V,lastTried:ae});if(de==="reload"){try{window.sessionStorage.setItem(vj,z??"")}catch{return}window.location.reload();return}if(de!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}rs.current=!1,Li(!1),$s(z??null);const be=window.setTimeout(()=>$s(null),6e3);return()=>window.clearTimeout(be)},[ce==null?void 0:ce.running]),E.useEffect(()=>{if(Ar&&Fq({asked:kl.current,reported:jr})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}rs.current=!1,Li(!1)}},[Ar,jr]);const ss=E.useState(()=>rB($B()))[0],Jt=E.useRef(ss.pinned),is=E.useRef(null),Xe=E.useState(()=>LB())[0],[Qo,Sl]=E.useState(()=>new Set),[Mr,Zo]=E.useState(VD),[Hn,Nl]=E.useState(()=>lj(dj)),Bi=E.useMemo(()=>tB(Hn),[Hn]),Ui=E.useCallback(z=>eB(z,Bi),[Bi]),hr=E.useMemo(()=>({background:Hn["--panel"],border:`1px solid ${Hn["--line"]}`,borderRadius:8}),[Hn]),[Gn,pr]=E.useState(!1);E.useEffect(()=>{document.documentElement.dataset.theme=Mr;try{window.localStorage.setItem(TT,Mr)}catch{}Nl(z=>{const V=lj(dj);return nB(z,V)?z:V})},[Mr]);const vn=E.useCallback((z,V)=>{if(uy({durationMs:V,documentHidden:document.hidden})){e.setViewport(z,{duration:V});return}const{d3Zoom:ae,d3Selection:de}=t.getState(),be=de==null?void 0:de.property("__zoom");if(ae&&de&&be&&be.k>0&&z.zoom>0){ae.transform(de,be.scale(z.zoom/be.k).translate((z.x-be.x)/z.zoom,(z.y-be.y)/z.zoom));return}e.setViewport(z,{duration:0})},[e,t]),Vn=E.useRef(null);E.useEffect(()=>{if(!Xe)return;const z=window.setTimeout(()=>{try{vn(Xe,0)}catch{}Kn.current=Date.now()},60);return()=>window.clearTimeout(z)},[vn,Xe]);const Yn=E.useRef(!0);E.useEffect(()=>{const z=new EventSource("/events"),V=UD(a,{now:()=>Date.now(),setTimeout:(ae,de)=>window.setTimeout(ae,de),clearTimeout:ae=>window.clearTimeout(ae)});return z.addEventListener("open",()=>{ke(!0),pr(!0)}),z.addEventListener("error",()=>ke(!1)),z.addEventListener("replay-end",()=>{Yn.current=!1,V.flush()}),z.addEventListener("hook",ae=>{var de;try{const be=JSON.parse(ae.data);if(!Gt.accept(be))return;s.current=Gb(s.current,be);const je=be.replay===!0||Yn.current||Date.now()-be.receivedAt>3e4;je?V.replay():V.live();const ze=uD(be,je);ze&&((de=Re.current)==null||de.play(ze))}catch{}}),()=>{z.close(),V.cancel()}},[a]),E.useEffect(()=>{const z=setInterval(()=>{const V=Date.now();sn(V);let ae=sL(s.current,V,Hb);iL(s.current,V,Hb)&&(ae=!0),eL(s.current,V,SB,NB)&&(ae=!0),tL(s.current,V,EB,jB)&&(ae=!0),u(de=>OD(de,s.current.agents)),p(de=>de!=null&&!s.current.agents.has(de)?null:de),ae&&a()},250);return()=>clearInterval(z)},[a]);const Jo=E.useRef(null),Kn=E.useRef(0),qs=420,jn=E.useCallback((z=500)=>{try{const je=document.querySelector(".canvas-wrap"),ze=Array.from(document.querySelectorAll(".react-flow__node")).filter(ut=>ut.offsetWidth>0);if(!je||ze.length===0)return;const Ze=je.getBoundingClientRect(),pt=e.getViewport();if(!Number.isFinite(pt.zoom)||pt.zoom<=0)return;const ot=ut=>(ut-Ze.left-pt.x)/pt.zoom,on=ut=>(ut-Ze.top-pt.y)/pt.zoom,Yt=ze.map(ut=>ut.getBoundingClientRect()),ds=Math.min(...Yt.map(ut=>ot(ut.left))),Fl=Math.max(...Yt.map(ut=>ot(ut.right))),ha=Math.min(...Yt.map(ut=>on(ut.top))),zl=Math.max(...Yt.map(ut=>on(ut.bottom))),pa=Fl-ds,Ks=zl-ha;if(!(pa>0&&Ks>0))return;const Xs=Math.max(.2,Math.min(1,(Ze.width-160)/(pa+qs)*.86,(Ze.height-160)/Ks*.86)),Qs={x:80-ds*Xs,y:Math.max(80,(Ze.height-Ks*Xs)/2)-ha*Xs,zoom:Xs};vn(Qs,z),Kn.current=Date.now(),Vn.current=uy({durationMs:z,documentHidden:document.hidden})?{target:Qs,until:Date.now()+z+60}:null,window.setTimeout(()=>{var ut;try{((ut=Vn.current)==null?void 0:ut.target)===Qs&&(Vn.current=null);const Zi=e.getViewport();(Math.abs(Zi.zoom-Xs)>.01||Math.abs(Zi.x-Qs.x)>2)&&vn(Qs,0)}catch{}},z+60)}catch{}},[e,vn]);E.useEffect(()=>{const z=()=>{if(!document.hidden)return;const V=Vn.current;if(Vn.current=null,!(!V||Date.now()>V.until)){try{vn(V.target,0)}catch{}Kn.current=Date.now()}};return document.addEventListener("visibilitychange",z),()=>document.removeEventListener("visibilitychange",z)},[vn]);const Wi=E.useRef(""),os=E.useRef(null),ea=E.useRef(0),Hi=E.useCallback(()=>{ea.current=Date.now()},[]),Ir=E.useRef(null),as=E.useRef(0),mr=E.useCallback(()=>{as.current=Date.now()},[]),Ds=E.useCallback(z=>({hasSourceEvent:!!z,at:Date.now(),lastDeckFitAt:Kn.current,lastCanvasInputAt:as.current}),[]),ta="agent-dag.autoFitDisabled",El=E.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(ta)==="1"}catch{return!1}})[0],gr=E.useRef(El),[Fs,Gi]=E.useState(El),Vi=E.useCallback(()=>{if(!gr.current){gr.current=!0,Gi(!0);try{window.localStorage.setItem(ta,"1")}catch{}}},[]),vr=E.useCallback(()=>{gr.current=!1,Gi(!1);try{window.localStorage.removeItem(ta)}catch{}jn(400)},[e,jn]);E.useEffect(()=>{const z=setInterval(()=>{if(gr.current||Date.now()-ea.current<800)return;const V=s.current,ae=Date.now(),de=[];for(const je of V.agents.values())Uy(je,ae)&&de.push({id:je.id});if(de.length===0)return;const be=[];for(const{id:je}of de){const ze=Xn.current.get(je),Ze=Jt.current.get(je)??Mt.current.get(je);!ze||!Ze||be.push({x:Ze.x,y:Ze.y,width:ze.width,height:ze.height})}aB({pane:Ir.current,viewport:e.getViewport(),boxes:be})&&jn(600)},1500);return()=>clearInterval(z)},[e]);const zs=E.useRef(!1),Xn=E.useRef(new Map),na=E.useRef(0),Yi=E.useCallback(z=>{const V=Xn.current;let ae=!1;for(const de of z.nodeInternals.values()){const be=de.width,je=de.height;if(be==null||je==null)continue;const ze=V.get(de.id);ze?(Math.abs(ze.height-je)>4||Math.abs(ze.width-be)>4)&&(V.set(de.id,{width:be,height:je}),ae=!0):(V.set(de.id,{width:be,height:je}),ae=!0)}return ae&&(na.current+=1),na.current},[]),Bs=rt(Yi),[ra,en]=E.useState(0);E.useEffect(()=>{let z=0;const V=()=>{const de=Xn.current;let be=!1;for(const je of document.querySelectorAll(".react-flow__node[data-id]")){const ze=je.getAttribute("data-id");if(!ze)continue;const Ze=je.offsetWidth,pt=je.offsetHeight;if(!Ze||!pt)continue;const ot=de.get(ze);(!ot||Math.abs(ot.width-Ze)>4||Math.abs(ot.height-pt)>4)&&(de.set(ze,{width:Ze,height:pt}),be=!0)}be&&en(je=>je+1)};if(zs.current)return;let ae=0;return document.visibilityState==="hidden"?ae=window.setTimeout(V,32):z=requestAnimationFrame(V),()=>{cancelAnimationFrame(z),window.clearTimeout(ae)}});const Mt=E.useRef(ss.positions),sa=E.useRef(new Set),Or=E.useRef(""),ls=E.useMemo(()=>{const z=[];for(const V of s.current.agents.values())Uy(V,ht)&&z.push(V.id+(V.parentId?`>${V.parentId}`:""));return z.sort(),`${z.join("|")}#sv${Bs}.${ra}`},[s.current,s.current.revision,ht,Bs,ra]),Pr=E.useRef(null);E.useEffect(()=>(Pr.current!=null&&window.clearTimeout(Pr.current),Pr.current=window.setTimeout(()=>{py(Mt.current,Jt.current)},1500),()=>{Pr.current!=null&&window.clearTimeout(Pr.current)}),[ls]),E.useEffect(()=>{if(Wi.current===ls)return;const z=Wi.current;if(Wi.current=ls,!z||gr.current)return;Date.now()-Kn.current>1200&&jn(400),Jo.current&&window.clearTimeout(Jo.current),Jo.current=window.setTimeout(()=>{gr.current||jn(500)},280)},[ls,e,jn]);const Us=E.useMemo(()=>LD(s.current,l),[s.current,s.current.revision,l]),$r=E.useMemo(()=>Qz(s.current,ht),[s.current,s.current.revision,ht]),Ws=E.useRef(null),[Hs,jl]=E.useState({w:0,h:0});E.useEffect(()=>{const z=Ws.current;if(!z||typeof ResizeObserver>"u")return;const V=new ResizeObserver(ae=>{var be;const de=(be=ae[0])==null?void 0:be.contentRect;de&&(Ir.current={width:de.width,height:de.height},jl(je=>Math.abs(je.w-de.width)>40||Math.abs(je.h-de.height)>40?{w:de.width,h:de.height}:je))});return V.observe(z),Ir.current={width:z.clientWidth,height:z.clientHeight},jl({w:z.clientWidth,h:z.clientHeight}),()=>V.disconnect()},[]);const Ju=E.useCallback(z=>{var ae,de;const V=z.target;!(V!=null&&V.closest)||V.closest(_B)!==z.currentTarget||(z.preventDefault(),(de=(ae=document.activeElement)==null?void 0:ae.blur)==null||de.call(ae))},[]),ed=E.useRef(new Map),[Ki,td]=E.useState(!1);E.useEffect(()=>{const z=window.setTimeout(()=>td(!0),2500);return()=>window.clearTimeout(z)},[]);const[nd,ia]=E.useState(!1),yr=E.useRef(null),[oa,aa]=E.useState(!1),rd=E.useCallback(()=>{yr.current&&(window.clearTimeout(yr.current),yr.current=null),ia(!1)},[]),sd=E.useCallback(z=>{z.length!==0&&queueMicrotask(()=>{ia(!0),yr.current&&window.clearTimeout(yr.current),yr.current=window.setTimeout(()=>ia(!1),kB+80)})},[]);E.useEffect(()=>()=>{yr.current&&window.clearTimeout(yr.current)},[]);const Cl=Hs.w>0?Hs.w*.92:0,Tl=Hs.h>0?Hs.h:0,{nodes:Cn,edges:id}=E.useMemo(()=>FB(s.current,ht,Cl,Tl,Jt.current,Xn.current,ed.current,sd,Ki,oa,Mt.current,sa.current,ls,Or,l,Us,$r,N),[s.current,s.current.revision,ht,Cl,Tl,Ki,oa,ls,l,Us,$r,N,Ii]),Rl=E.useMemo(()=>{const z=new Map;for(const ae of Cn){const de=ae.data;if(!(de!=null&&de.sessionId)||de.exitAt!=null)continue;const be=ae.width,je=ae.height;if(be==null||je==null)continue;const ze=ae.position.x,Ze=ae.position.y,pt=ze+be,ot=Ze+je,on=z.get(de.sessionId);on?(on.minX=Math.min(on.minX,ze),on.minY=Math.min(on.minY,Ze),on.maxX=Math.max(on.maxX,pt),on.maxY=Math.max(on.maxY,ot)):z.set(de.sessionId,{minX:ze,minY:Ze,maxX:pt,maxY:ot})}const V=[];for(const[ae,de]of z){const be=de.maxX-de.minX+Jc*2,je=de.maxY-de.minY+Jc*2;V.push({id:`group:${ae}`,type:MR,position:{x:de.minX-Jc,y:de.minY-Jc},data:{sessionId:ae,w:be,h:je},width:be,height:je,style:{width:be,height:je},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return V},[Cn,ht]),od=E.useMemo(()=>{const z=[...Rl,...Cn],V=nt.current;return!V||V.size===0?z:z.map(ae=>{const de=V.get(ae.id);return de?{...ae,position:de}:ae})},[Rl,Cn,Xo]),Gs=E.useMemo(()=>{const z=new Set;for(const V of s.current.agents.values())for(const ae of V.tools)z.add(FR(ae.name));return Object.keys(Hy).filter(V=>z.has(V))},[s.current,s.current.revision]);E.useEffect(()=>{if(Gs.length<=1){Pi(!1);return}let z=0;const V=()=>{const ae=Ps.current;if(ae&&!document.hidden){const de=ae.getBoundingClientRect(),be=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(ze=>ze.getBoundingClientRect()),je=Jz(de,be,8);Pi(ze=>ze===je?ze:je)}z=window.setTimeout(V,300)};return V(),()=>window.clearTimeout(z)},[Gs.length]);const ad=E.useCallback(z=>{Sl(V=>{const ae=new Set(V);return ae.has(z)?ae.delete(z):ae.add(z),ae})},[]),tn=h?s.current.agents.get(h):null,la=f?Array.from(s.current.agents.values()).flatMap(z=>z.tools).find(z=>z.id===f)??null:null,Al=E.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}s.current=Ay(),Jt.current.clear(),Xn.current.clear(),Mt.current.clear(),Or.current="",wj(),w(),a()},[a,w]),Ml=E.useRef(j);Ml.current=j;const Il=E.useRef(M);Il.current=M;const ca=E.useRef(!1);ca.current=la!=null||Tr||_!=null||S!=null||Jr||M||it!=null;const cs=E.useCallback(z=>{const V=Bq(z,{confirmOpen:Ml.current,modalOpen:ca.current});V==="confirm"?T(!0):V==="clear"&&(T(!1),Al())},[Al]),Lr=E.useCallback(()=>{Jt.current.clear(),Mt.current.clear(),Or.current="",wj(),a(),window.setTimeout(()=>jn(500),80)},[a,e,jn]),Ol=E.useCallback(()=>jn(500),[jn]),Vs=E.useRef(Cn);Vs.current=Cn;const ua=E.useRef(h);ua.current=h;const Xi=E.useCallback(z=>{const V=Vs.current,ae=TD(V.map(je=>({id:je.id,x:je.position.x,y:je.position.y})),ua.current,z),de=ae?V.find(je=>je.id===ae):void 0;if(!de)return;const be=fj(document.activeElement);y(de.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[de]})}catch{}Kn.current=Date.now(),be&&bB(de.id)},30)},[y,e]),da=E.useCallback(z=>{y(z,!1),window.setTimeout(()=>{try{const V=Vs.current.find(ae=>ae.id===z);V&&e.fitView({padding:.3,duration:500,nodes:[V]}),Kn.current=Date.now()}catch{}},60)},[y,e]);E.useEffect(()=>{const z=V=>{var Ze,pt;const ae=V.target,de={tagName:ae==null?void 0:ae.tagName,isContentEditable:ae==null?void 0:ae.isContentEditable,role:(Ze=ae==null?void 0:ae.getAttribute)==null?void 0:Ze.call(ae,"role"),type:ae==null?void 0:ae.type};if(V.key==="Escape"){const ot=NL({overlayOpen:Ao.depth()>0,panelOnTop:Ao.topIsPanel(),typing:gw(de)});ot==="dismiss"?Ao.dismissTop():ot==="blur"?ae==null||ae.blur():(ID(de)&&(ae==null||ae.blur()),w());return}if(mw(V))return;const be=fj(ae)?(pt=ae==null?void 0:ae.getAttribute)==null?void 0:pt.call(ae,"data-id"):null,je=be&&Vs.current.some(ot=>ot.id===be)?be:null,ze=AD(V,je);if(ze.kind==="activate"){V.preventDefault(),y(ze.nodeId,ze.additive);return}ze.kind!=="node"&&(ze.nodeId==null&&IL(de)||OL({key:V.key,modalOpen:ca.current,sheetOpen:Il.current})||(V.key===" "&&(V.preventDefault(),ts()),(V.key==="c"||V.key==="C")&&cs("shortcut"),(V.key==="r"||V.key==="R")&&Lr(),(V.key==="f"||V.key==="F")&&Ol(),(V.key==="l"||V.key==="L")&&Ko(),(V.key==="h"||V.key==="H")&&fr(ot=>!ot),(V.key==="u"||V.key==="U")&&K(ot=>!ot),(V.key==="a"||V.key==="A")&&wt.current.claude&&dr(),(V.key==="j"||V.key==="J")&&Xi(1),(V.key==="k"||V.key==="K")&&Xi(-1),(V.key==="t"||V.key==="T")&&Zo(ot=>ot==="dark"?"light":"dark"),(V.key==="m"||V.key==="M")&&wt.current.claude&&$.current!==null&&Q.current(V.shiftKey),V.key==="?"&&P(ot=>!ot)))};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[cs,Lr,Ol,w,y,Xi,ts]);const Qi=s.current.agents.size,Vt=E.useMemo(()=>H3(s.current.agents.values()),[s.current,s.current.revision]),Pl=E.useMemo(()=>G3(s.current.agents.values()),[s.current,s.current.revision]),$l=E.useRef(null);E.useEffect(()=>{const z=YD({waiting:Vt.length,running:Pl,connected:Ie}),V=$l.current;if($l.current=z,(V==null?void 0:V.title)!==z.title&&(document.title=z.title),(V==null?void 0:V.icon)!==z.icon){const ae=document.querySelector('link[rel="icon"]');ae&&(ae.href=KD[z.icon])}},[Vt.length,Pl,Ie]);const[ld,Ll]=E.useState(""),fa=QD(Vt);E.useEffect(()=>{Ll(z=>ZD(z,fa))},[fa]);const Lt=E.useMemo(()=>uT(s.current.agents.values()),[s.current,s.current.revision]);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),d.jsxs("header",{className:"topbar",children:[d.jsxs("div",{className:"readout",children:[d.jsxs("div",{className:"brand",children:[d.jsx("span",{className:"logo"}),d.jsx("h1",{children:zt}),Me?d.jsxs("button",{type:"button",className:"v stale",onClick:()=>{Ne(),Sn()},"aria-haspopup":"dialog","aria-label":dB({...Me,open:kt}),title:Me.kind==="restart"?`Running v${Me.from}; v${Me.to} is installed on disk. Restart to pick it up · click for what's new`:`Running v${Me.from}; v${Me.to} is on npm · click for what's new`,children:["v",Me.from,d.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const z={running:Pe,latest:ce==null?void 0:ce.latest,latestPending:ce==null?void 0:ce.latestPending,checkedAgo:ce!=null&&ce.checkedAt?Py(ht-ce.checkedAt):null,checkDisabled:ce==null?void 0:ce.checkDisabled,checking:Be};return d.jsxs("button",{type:"button",className:Be?"v checking":"v",onClick:()=>{Ne(),Ke(!0)},"aria-busy":Be||void 0,"aria-haspopup":"dialog","aria-label":uB(z),title:cB(z),children:["v",z.running]})})()]}),d.jsxs("span",{className:"status",children:[(()=>{const z=wB({connected:Ie,paused:Un,held:Gt.size,dropped:Gt.dropped});return z.resting?null:d.jsx("span",{className:`pill ${z.tone}`,title:z.title,children:d.jsxs("span",{className:"pill-box",children:[d.jsx("span",{className:"pill-widest","aria-hidden":!0,children:z.widest}),d.jsx("span",{className:"pill-label",children:z.label})]})})})(),d.jsx(I4,{usageOpen:H}),Lt.sum>0&&d.jsxs("span",{className:"stat",title:`in:${Lt.inputTokens.toLocaleString()} out:${Lt.outputTokens.toLocaleString()} cache-r:${Lt.cacheReadTokens.toLocaleString()} cache-c:${Lt.cacheCreateTokens.toLocaleString()}
134
140
 
135
- ${yu}`,children:[d.jsx("span",{className:"count",children:Pt(Lt.sum)}),d.jsx("span",{className:"lbl",children:B3})]}),Lt.cost.total>0&&(()=>{let z=0,V=0;for(const be of s.current.agents.values()){if(be.state!=="active")continue;const je=bn(be);z+=je.total,V=Math.max(V,((be.endedAt??ht)-be.startedAt)/1e3)}const ae=V>0?gu(z,V):null,de=`input ${Ve(Lt.cost.input)} + output ${Ve(Lt.cost.output)} + cache r ${Ve(Lt.cost.cacheRead)} + cache w ${Ve(Lt.cost.cacheWrite)}${ae?`
141
+ ${yu}`,children:[d.jsx("span",{className:"count",children:Pt(Lt.sum)}),d.jsx("span",{className:"lbl",children:z3})]}),Lt.cost.total>0&&(()=>{let z=0,V=0;for(const be of s.current.agents.values()){if(be.state!=="active")continue;const je=bn(be);z+=je.total,V=Math.max(V,((be.endedAt??ht)-be.startedAt)/1e3)}const ae=V>0?gu(z,V):null,de=`input ${Ve(Lt.cost.input)} + output ${Ve(Lt.cost.output)} + cache r ${Ve(Lt.cost.cacheRead)} + cache w ${Ve(Lt.cost.cacheWrite)}${ae?`
136
142
  active burn: ${ae}`:""}
137
143
 
138
- ${yu}`;return d.jsxs("span",{className:"stat",title:de,children:[d.jsx("span",{className:"count",children:Ve(Lt.cost.total)}),d.jsxs("span",{className:"lbl",children:[U3,ae?` · ${ae}`:""]})]})})()]}),d.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:ld}),Vt.length>0&&d.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>da(Vt[0].id),title:`Blocked waiting for you — click to go to the one that has been stuck longest:
144
+ ${yu}`;return d.jsxs("span",{className:"stat",title:de,children:[d.jsx("span",{className:"count",children:Ve(Lt.cost.total)}),d.jsxs("span",{className:"lbl",children:[B3,ae?` · ${ae}`:""]})]})})()]}),d.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:ld}),Vt.length>0&&d.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>da(Vt[0].id),title:`Blocked waiting for you — click to go to the one that has been stuck longest:
139
145
  ${Vt.map(z=>` ${z.label}: ${Au(z.waiting)} (${Py(ht-z.waiting.since)})`).join(`
140
- `)}`,"aria-label":`${Vt.length} session${Vt.length===1?"":"s"} waiting for you`,children:[d.jsx("span",{className:"ap-pulse","aria-hidden":!0}),d.jsx("b",{children:Vt.length})," waiting"]})]}),tn&&(()=>{const z=bn(tn),V=Math.max(0,((tn.endedAt??ht)-tn.startedAt)/1e3),ae=tn.state==="active"?gu(z.total,V):null,de=l.size-1;return d.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${tn.label}`,onClick:()=>{try{const be=Cn.find(je=>je.id===tn.id);be&&e.fitView({padding:.35,duration:500,nodes:[be]}),Kn.current=Date.now()}catch{}},children:[d.jsx("span",{className:`state-pill state-${tn.state}`,children:tn.state==="active"?"live":tn.state}),d.jsx("span",{className:"selected-label",children:tn.label}),z.total>0&&d.jsxs("span",{className:"selected-cost",children:[Ve(z.total),ae?d.jsxs("span",{className:"selected-rate",children:[" · ",ae]}):null]}),de>0&&d.jsxs("span",{className:"selected-extra",children:["+",de]}),d.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:be=>{be.stopPropagation(),w()},children:"×"})]})})(),d.jsxs("div",{className:"actions",children:[d.jsxs("div",{className:"action-run",children:[d.jsx("button",{className:"btn icon-btn",onClick:()=>K(z=>!z),title:`${H?"Hide":"Show"} usage panel (U)`,"aria-label":"Toggle usage panel","aria-expanded":H,"aria-controls":H?"usage-panel":void 0,children:"$"}),et.claude&&d.jsx("button",{className:"btn icon-btn",onClick:dr,title:`${C?"Hide":"Show"} accounts (A)`,"aria-label":"Toggle accounts panel","aria-expanded":C,"aria-controls":C?"accounts-panel":void 0,children:d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[d.jsx("circle",{cx:"7",cy:"4.6",r:"2.4"}),d.jsx("path",{d:"M2.4 12c0-2.3 2.1-3.7 4.6-3.7s4.6 1.4 4.6 3.7"})]})}),d.jsx("button",{className:"btn icon-btn",onClick:()=>fr(z=>!z),title:"Usage history — ccusage (H)","aria-label":"Open usage history","aria-haspopup":"dialog",children:d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":!0,children:[d.jsx("line",{x1:"3",y1:"11.5",x2:"3",y2:"7"}),d.jsx("line",{x1:"7",y1:"11.5",x2:"7",y2:"3"}),d.jsx("line",{x1:"11",y1:"11.5",x2:"11",y2:"8.5"})]})}),d.jsxs("button",{className:`btn icon-btn bw-btn${Bn>0?" has-findings":Rr?" watching":""}`,onClick:()=>Ci(z=>!z),title:Rr?"Browser watch — watching; the deck is keeping its own copy":"Browser watch — not watching; reading the browser's history live","aria-label":`Browser watch, ${Rr?"watching":"not watching"}`+(Bn>0?`, ${Bn} unread`:""),"aria-haspopup":"dialog",children:[d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":!0,children:[d.jsx("path",{d:"M0.9 7s2.2-4 6.1-4 6.1 4 6.1 4-2.2 4-6.1 4S0.9 7 0.9 7Z"}),Rr||Bn>0?d.jsx("circle",{cx:"7",cy:"7",r:"1.8",fill:"currentColor",stroke:"none"}):d.jsx("line",{x1:"2.4",y1:"11.6",x2:"11.6",y2:"2.4"})]}),Bn>0&&d.jsx("span",{className:"bw-badge","aria-hidden":!0,children:Bn})]})]}),d.jsxs("div",{className:"action-run",children:[et.claude&&B!==null&&d.jsxs("div",{className:"sound-slot",children:[d.jsx("button",{ref:ye,className:"btn icon-btn",onClick:()=>he(z=>!z),...ir(!1),title:a5(et,{on:B===!0,locked:Ue==="locked",prefs:G}),"aria-label":"Sound settings","aria-haspopup":"dialog","aria-expanded":fe,"aria-controls":fe?"sound-menu":void 0,children:d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[d.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),B?d.jsxs(d.Fragment,{children:[d.jsx("path",{d:"M9.8 5.4a2.4 2.4 0 0 1 0 3.2"}),d.jsx("path",{d:"M11.3 3.9a4.6 4.6 0 0 1 0 6.2"})]}):d.jsxs(d.Fragment,{children:[d.jsx("path",{d:"M10 5.6l2.6 2.8"}),d.jsx("path",{d:"M12.6 5.6L10 8.4"})]})]})}),fe&&d.jsx(pD,{onClose:()=>he(!1),soundOn:B===!0,onToggleSound:J,prefs:G,onLevel:(z,V)=>se(z,{level:V}),onFigure:(z,V)=>se(z,{figure:V}),onPreview:z=>Z(z),openerRef:ye})]}),d.jsx("button",{className:"btn icon-btn",onClick:()=>Zo(z=>z==="dark"?"light":"dark"),title:`Switch to ${Mr==="dark"?"light":"dark"} mode (T)`,"aria-label":"Toggle theme",children:Mr==="dark"?"☀":"☾"})]})]})]}),ns?d.jsxs("div",{className:"ver-banner done",role:"status",children:[d.jsx("span",{className:"ver-dot"}),d.jsxs("strong",{children:["Restarted — now running v",ns,"."]}),d.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):Gn&&!Ie?d.jsxs("div",{className:"conn-banner",role:"alert",children:[d.jsx("span",{className:"conn-dot"}),Ar?qi==="npx"?"Fetching the new version with npx — this can take a minute…":`Restarting ${zt}…`:(()=>{const z=yB({connected:Ie,paused:Un});return d.jsxs(d.Fragment,{children:[`Lost connection to the ${zt} server. Reconnecting…`,z&&d.jsx("span",{className:"conn-sub",children:z})]})})()]}):kt&&Me?d.jsxs("div",{className:`ver-banner ${Me.kind}`,role:"status",children:[d.jsx("span",{className:"ver-dot"}),Me.kind==="restart"?d.jsxs(d.Fragment,{children:[d.jsxs("strong",{children:["v",Me.to," is installed — this deck still runs v",Me.from,"."]}),ce!=null&&ce.canRestart?d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"ver-act",onClick:()=>Ls(),...ir(Ar),title:"Stop this process and bring it back on the same port. The canvas replays from the event log.",children:Ar?"restarting…":"Restart now"}),d.jsxs("button",{type:"button",className:`ver-auto${Wn?" on":""}`,role:"switch","aria-checked":Wn,onClick:Zu,title:Wn?"Restarts on its own once nothing has been running for 30 seconds. Click to require a click instead.":"Only restarts when you click. Click to let it restart itself while idle.",children:[d.jsx("i",{"aria-hidden":!0}),"auto when idle"]})]}):d.jsx("span",{className:"ver-sub",title:"Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.",children:"Restart it to pick up the new code."})]}):d.jsxs(d.Fragment,{children:[d.jsxs("strong",{children:[zt," v",Me.to," is out — you are on v",Me.from,"."]}),(ce==null?void 0:ce.upgradeMode)==="install"&&Bt!=="failed"&&d.jsx("button",{type:"button",className:"ver-act",onClick:Is,...ir(Bt==="running",Bt==="done"),title:`Runs ${((ql=ce==null?void 0:ce.upgrade)==null?void 0:ql.command)??(ce==null?void 0:ce.command)??"npm i -g"} here, then restarts once nothing is running.`,children:Bt==="running"?"installing…":Bt==="done"?"installed":"Update now"}),(ce==null?void 0:ce.upgradeMode)==="npx"&&(ce==null?void 0:ce.canRestart)&&d.jsx("button",{type:"button",className:"ver-act",onClick:()=>Ls({upgrade:!0}),...ir(Ar),title:`Runs ${ce==null?void 0:ce.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`,children:Ar?"fetching…":Bt==="failed"?"Retry update":"Update & restart"}),Bt==="failed"?d.jsxs("span",{className:"ver-sub fail",title:((Ys=ce==null?void 0:ce.upgrade)==null?void 0:Ys.error)??"",children:[(ce==null?void 0:ce.upgradeMode)==="npx"?"update failed":"install failed",": ",((Dl=ce==null?void 0:ce.upgrade)==null?void 0:Dl.error)??"unknown error"," — run it yourself:"]}):(ce==null?void 0:ce.upgradeMode)==="npx"?d.jsx("span",{className:"ver-sub",children:ce!=null&&ce.canRestart?"npx cannot upgrade in place, so the deck re-runs:":hy.npx}):ce!=null&&ce.upgradeBlocked?d.jsx("span",{className:"ver-sub",children:Object.hasOwn(hy,ce.upgradeBlocked)?hy[ce.upgradeBlocked]:"cannot install from here"}):null,d.jsxs("button",{type:"button",className:"ver-cmd",onClick:Cr,title:"Copy to clipboard",children:[d.jsx("code",{children:ce==null?void 0:ce.command}),d.jsx("span",{className:"ver-cmd-hint",children:yt?"copied":"copy"})]})]}),d.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:Fn,children:"×"})]}):Ei&&mn?d.jsxs("div",{className:"ver-banner",role:"status",children:[d.jsx("span",{className:"ver-dot"}),d.jsxs("strong",{children:[mn," still works — the deck is called ",zt," now."]}),ce!=null&&ce.renameFix?d.jsx("span",{className:"ver-sub",children:ce.renameFix}):null,d.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:ji,children:"×"})]}):null,H&&d.jsx(a4,{state:s.current,now:ht,providers:et,onClose:()=>K(!1)}),C&&et.claude&&d.jsx($q,{onClose:()=>X(!1)}),F&&d.jsx(K3,{state:s.current,now:ht,selectedIds:l,onSelect:da,onClose:()=>O(!1)}),d.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${nd?" bubbling":""}${oa?" dragging-any":""}`,ref:Ws,onMouseDownCapture:Ju,onPointerDownCapture:mr,onPointerUpCapture:mr,onWheelCapture:mr,children:[Qi===0&&d.jsx(WB,{live:Ie,everConnected:Gn,providers:et}),Gs.length>1&&d.jsx("div",{ref:Ps,className:`cat-filter-bar${Oi?" occluded":""}`,role:"group","aria-label":"Filter tools by category",children:Gs.map(z=>{const V=Qo.has(z);return d.jsxs("button",{type:"button",className:`cat-filter${V?" off":""}`,onClick:()=>ad(z),"aria-pressed":!V,title:`${V?"Show":"Hide"} ${Gy[z]} tools`,children:[d.jsx("span",{className:"cat-emoji",children:Hy[z]}),d.jsx("span",{className:"cat-name",children:Gy[z]})]},z)})}),d.jsxs(qC,{nodes:od,edges:id,nodeTypes:bB,fitView:!Xe,fitViewOptions:{padding:.25,duration:uy({durationMs:hj,documentHidden:document.hidden})?hj:0},minZoom:.2,maxZoom:1.6,panOnScroll:!0,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,onNodeClick:(z,V)=>{if(V.type==="sessionGroup"){w();return}y(V.id,z.shiftKey)},onPaneClick:()=>w(),onMoveStart:z=>{cj(Ds(z))&&Vi()},onMove:(z,V)=>{Hi(),cj(Ds(z))&&Vi(),os.current&&window.clearTimeout(os.current),os.current=window.setTimeout(()=>DB(V),250)},onNodeDragStart:(z,V)=>{var ae;if(rd(),zs.current=!0,nt.current=new Map,aa(!0),Hi(),Vi(),V.type==="sessionGroup"){const de=(ae=V.data)==null?void 0:ae.sessionId,be=new Map;if(de)for(const je of Cn){const ze=je.data;(ze==null?void 0:ze.sessionId)===de&&be.set(je.id,{x:je.position.x,y:je.position.y})}is.current={start:{x:V.position.x,y:V.position.y},members:be};return}Jt.current.set(V.id,{x:V.position.x,y:V.position.y})},onNodeDrag:(z,V)=>{var ae;if(Hi(),V.type==="sessionGroup"){const de=is.current;if(!de)return;const be=V.position.x-de.start.x,je=V.position.y-de.start.y;for(const[Ze,pt]of de.members){const ot={x:pt.x+be,y:pt.y+je};Jt.current.set(Ze,ot),Mt.current.set(Ze,ot)}const ze=nt.current;if(ze){for(const[Ze,pt]of de.members)ze.set(Ze,{x:pt.x+be,y:pt.y+je});ze.set(V.id,{x:V.position.x,y:V.position.y})}es(Ze=>Ze+1);return}Jt.current.set(V.id,{x:V.position.x,y:V.position.y}),Mt.current.set(V.id,{x:V.position.x,y:V.position.y}),(ae=nt.current)==null||ae.set(V.id,{x:V.position.x,y:V.position.y}),es(de=>de+1)},onNodeDragStop:(z,V)=>{if(Hi(),zs.current=!1,nt.current=null,aa(!1),Os(ae=>ae+1),V.type==="sessionGroup"){const ae=is.current;if(ae){const de=V.position.x-ae.start.x,be=V.position.y-ae.start.y;for(const[je,ze]of ae.members){const Ze={x:ze.x+de,y:ze.y+be};Jt.current.set(je,Ze),Mt.current.set(je,Ze)}}is.current=null,py(Mt.current,Jt.current),Os(de=>de+1);return}Jt.current.set(V.id,{x:V.position.x,y:V.position.y}),Mt.current.set(V.id,{x:V.position.x,y:V.position.y}),py(Mt.current,Jt.current)},children:[d.jsx(F$,{gap:28,size:1,color:Hn["--grid-line"]}),d.jsx(r3,{}),d.jsx(q3,{agents:s.current.agents,visibleAgentIds:$r,positions:Mt.current,pinned:Jt.current,measured:Xn.current,spotlight:Us,hiddenCategories:Qo,now:ht,onOpenTool:g}),d.jsxs(O$,{showInteractive:!1,children:[d.jsx(kr,{onClick:vr,title:Fs?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view",style:Fs?{color:"var(--accent)"}:void 0,children:d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[d.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),d.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),d.jsx(kr,{onClick:ts,title:vB({paused:Un,held:Gt.size,dropped:Gt.dropped}),"aria-label":gB,"aria-pressed":Un,children:d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:d.jsx("path",{d:"M9 5.5v13M15 5.5v13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),d.jsx(kr,{onClick:Lr,title:"Auto-arrange — clear pins (R)","aria-label":"Re-arrange the canvas",children:d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[d.jsx("rect",{x:"8.5",y:"2",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),d.jsx("rect",{x:"1.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),d.jsx("rect",{x:"15.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),d.jsx("path",{d:"M12 7v6.5M5 17v-3.5h14V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),d.jsx(kr,{onClick:()=>cs("button"),title:"Clear the canvas and the server's event log — asks first (C)","aria-label":"Clear the canvas",children:d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[d.jsx("path",{d:"M4 6.2h16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),d.jsx("path",{d:"M9 6.2V4.4a1.6 1.6 0 0 1 1.6-1.6h2.8a1.6 1.6 0 0 1 1.6 1.6v1.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),d.jsx("path",{d:"M17.4 6.4 16.7 20a2 2 0 0 1-2 1.9H9.3a2 2 0 0 1-2-1.9L6.6 6.4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),d.jsx("path",{d:"M10.3 10.6v6.8M13.7 10.6v6.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),d.jsx(kr,{onClick:()=>P(z=>!z),title:"Keyboard shortcuts (?)","aria-label":"Open the keyboard shortcuts","aria-haspopup":"dialog",children:d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[d.jsx("path",{d:"M8.6 8.4a3.5 3.5 0 1 1 4.6 3.35c-.85.3-1.2 1-1.2 1.85v1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),d.jsx("path",{d:"M12 18.4v.2",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",fill:"none"})]})})]}),d.jsx(j$,{zoomable:!0,pannable:!0,nodeColor:Ui,nodeStrokeWidth:2,maskColor:Hn["--minimap-mask"],style:hr})]})]}),A?d.jsxs("aside",{className:"detail","aria-label":"Detail",children:[d.jsx("button",{type:"button",className:"glyph-btn detail-close",title:"Close panel","aria-label":"Close detail panel",onClick:()=>D(!1),children:"×"}),tn?d.jsx(VB,{agent:tn,now:ht,onOpenTool:g,onShowSummary:z=>{I.has(z)&&(I.delete(z),yj(I)),b(z)},onExportSession:z=>FB(s.current,z)}):d.jsx(GB,{count:Qi,workspace:We})]}):d.jsx("button",{type:"button",className:"detail-reopen",title:"Show detail panel","aria-label":"Show detail panel",onClick:()=>D(!0),children:"‹"}),la&&d.jsx(YL,{tool:la,onClose:()=>g(null)}),Tr&&d.jsx(f5,{providers:et,onClose:()=>fr(!1)}),Jr&&d.jsx(S5,{onClose:()=>Ci(!1),onSeen:z=>{Ri(z);try{localStorage.setItem(L1,String(z))}catch{}},onWatching:Mi,palette:Hn}),_&&(()=>{const z=s.current.agents.get(_);return z?d.jsx(zL,{agent:z,onClose:()=>k(null)}):null})(),S&&d.jsx(W3,{state:s.current,sessionId:S,onClose:()=>{I.add(S),yj(I),b(null)}}),it&&d.jsx(CD,{entries:it.entries,since:it.since,firstRun:it.firstRun,running:Pe,onClose:()=>At(null)}),M&&d.jsx(Xq,{onClose:()=>P(!1)}),j&&d.jsx(Vq,{agentCount:Qi,onConfirm:()=>cs("confirmation"),onCancel:()=>T(!1)})]})}function WB({live:e,everConnected:t,providers:n}){const s=!e;return d.jsxs("div",{className:"empty-hero",children:[d.jsxs("div",{className:"orbit-stack","aria-hidden":!0,children:[d.jsx("div",{className:"core"}),d.jsxs("div",{className:"orbit r1",children:[d.jsx("span",{className:"dot"}),d.jsx("span",{className:"dot b"})]}),d.jsxs("div",{className:"orbit r2",children:[d.jsx("span",{className:"dot"}),d.jsx("span",{className:"dot b"})]}),d.jsxs("div",{className:"orbit r3",children:[d.jsx("span",{className:"dot"}),d.jsx("span",{className:"dot b"})]})]}),s?d.jsxs(d.Fragment,{children:[d.jsx("h2",{children:t?"Disconnected from server":"Server unreachable"}),d.jsxs("p",{children:["The browser cannot reach ",d.jsx("code",{children:"/events"}),". Check that",d.jsx("code",{children:zt})," is still running in your terminal, then this page will resume automatically."]})]}):HB(n)]})}function HB(e){return d.jsxs(d.Fragment,{children:[d.jsx("h2",{children:"Waiting for Claude Code or Codex"}),d.jsxs("p",{children:["Run ",d.jsx("code",{children:"claude"})," or ",d.jsx("code",{children:"codex"})," in any folder. As soon as a session sends an event, a node appears here and grows as subagents fork and tools are called."]}),d.jsxs("p",{className:"hint-row",children:["Not seeing anything? Make sure ",d.jsx("code",{children:zt})," is running."]}),o5(e).map(t=>d.jsx("p",{className:"hint-row",children:t.spans.map((n,s)=>n.code?d.jsx("code",{children:n.text},s):d.jsx("span",{children:n.text},s))},t.provider))]})}function GB({count:e,workspace:t}){const n=hB(t);return d.jsxs(d.Fragment,{children:[d.jsx("h2",{children:"Detail"}),e===0?d.jsxs("div",{className:"hint",children:[n.lead,n.workspace!==null&&d.jsxs(d.Fragment,{children:[" ",d.jsx("code",{children:n.workspace}),n.tail]})]}):d.jsx("div",{className:"empty",children:"Click an agent to see its tools."}),d.jsx("h3",{style:{marginTop:4},children:"Shortcuts"}),d.jsxs("div",{className:"shortcuts",children:[d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"?"}),d.jsx("span",{children:"all shortcuts"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"drag"}),d.jsx("span",{children:"move a node"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"tab"}),d.jsx("span",{children:"reach the cards"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"enter"}),d.jsx("span",{children:"select the focused card"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"space"}),d.jsx("span",{children:"pause / resume"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"J"}),d.jsx("span",{children:"next agent"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"K"}),d.jsx("span",{children:"previous agent"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"R"}),d.jsx("span",{children:"re-arrange"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"F"}),d.jsx("span",{children:"fit view"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"L"}),d.jsx("span",{children:"session list"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"H"}),d.jsx("span",{children:"usage history"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"U"}),d.jsx("span",{children:"usage panel"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"C"}),d.jsx("span",{children:"clear canvas"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"T"}),d.jsx("span",{children:"toggle theme"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"Esc"}),d.jsx("span",{children:"deselect, release focus"})]})]})]})}function VB({agent:e,now:t,onOpenTool:n,onShowSummary:s,onExportSession:o}){const a=vu(e.startedAt,e.endedAt,t),l=bn(e),u=l.total>0,h=e.usage.inputTokens+e.usage.outputTokens,p=new Map;for(const S of e.tools){const b=FR(S.name);p.set(b,(p.get(b)??0)+1)}const f=e.tools.filter(S=>S.ok===!1).length,g=e.tools.filter(S=>!S.endedAt).length,y=Array.from(p.entries()).sort((S,b)=>b[1]-S[1]),w=p.has("mcp")?I3(e.tools.map(S=>S.name)):null;return d.jsxs(d.Fragment,{children:[d.jsxs("header",{className:"detail-hero",children:[d.jsxs("div",{className:"hero-line",children:[d.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),d.jsx("h2",{className:"hero-title",title:e.cwd??e.label,children:e.label})]}),d.jsxs("div",{className:"hero-meta",children:[d.jsx("span",{className:"hero-meta-item",children:e.kind}),d.jsx("span",{className:"hero-sep",children:"·"}),d.jsx("span",{className:"hero-meta-item",title:`started ${new Date(e.startedAt).toLocaleString()}`,children:a}),e.model&&(()=>{const S=JC(e);return d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"hero-sep",children:"·"}),d.jsxs("span",{className:"model-chip",title:S.length>0?`${e.model}
146
+ `)}`,"aria-label":`${Vt.length} session${Vt.length===1?"":"s"} waiting for you`,children:[d.jsx("span",{className:"ap-pulse","aria-hidden":!0}),d.jsx("b",{children:Vt.length})," waiting"]})]}),tn&&(()=>{const z=bn(tn),V=Math.max(0,((tn.endedAt??ht)-tn.startedAt)/1e3),ae=tn.state==="active"?gu(z.total,V):null,de=l.size-1;return d.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${tn.label}`,onClick:()=>{try{const be=Cn.find(je=>je.id===tn.id);be&&e.fitView({padding:.35,duration:500,nodes:[be]}),Kn.current=Date.now()}catch{}},children:[d.jsx("span",{className:`state-pill state-${tn.state}`,children:tn.state==="active"?"live":tn.state}),d.jsx("span",{className:"selected-label",children:tn.label}),z.total>0&&d.jsxs("span",{className:"selected-cost",children:[Ve(z.total),ae?d.jsxs("span",{className:"selected-rate",children:[" · ",ae]}):null]}),de>0&&d.jsxs("span",{className:"selected-extra",children:["+",de]}),d.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:be=>{be.stopPropagation(),w()},children:"×"})]})})(),d.jsxs("div",{className:"actions",children:[d.jsxs("div",{className:"action-run",children:[d.jsx("button",{className:"btn icon-btn",onClick:()=>K(z=>!z),title:`${H?"Hide":"Show"} usage panel (U)`,"aria-label":"Toggle usage panel","aria-expanded":H,"aria-controls":H?"usage-panel":void 0,children:"$"}),et.claude&&d.jsx("button",{className:"btn icon-btn",onClick:dr,title:`${C?"Hide":"Show"} accounts (A)`,"aria-label":"Toggle accounts panel","aria-expanded":C,"aria-controls":C?"accounts-panel":void 0,children:d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[d.jsx("circle",{cx:"7",cy:"4.6",r:"2.4"}),d.jsx("path",{d:"M2.4 12c0-2.3 2.1-3.7 4.6-3.7s4.6 1.4 4.6 3.7"})]})}),d.jsx("button",{className:"btn icon-btn",onClick:()=>fr(z=>!z),title:"Usage history — ccusage (H)","aria-label":"Open usage history","aria-haspopup":"dialog",children:d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":!0,children:[d.jsx("line",{x1:"3",y1:"11.5",x2:"3",y2:"7"}),d.jsx("line",{x1:"7",y1:"11.5",x2:"7",y2:"3"}),d.jsx("line",{x1:"11",y1:"11.5",x2:"11",y2:"8.5"})]})}),d.jsxs("button",{className:`btn icon-btn bw-btn${Bn>0?" has-findings":Rr?" watching":""}`,onClick:()=>Ci(z=>!z),title:Rr?"Browser watch — watching; the deck is keeping its own copy":"Browser watch — not watching; reading the browser's history live","aria-label":`Browser watch, ${Rr?"watching":"not watching"}`+(Bn>0?`, ${Bn} unread`:""),"aria-haspopup":"dialog",children:[d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":!0,children:[d.jsx("path",{d:"M0.9 7s2.2-4 6.1-4 6.1 4 6.1 4-2.2 4-6.1 4S0.9 7 0.9 7Z"}),Rr||Bn>0?d.jsx("circle",{cx:"7",cy:"7",r:"1.8",fill:"currentColor",stroke:"none"}):d.jsx("line",{x1:"2.4",y1:"11.6",x2:"11.6",y2:"2.4"})]}),Bn>0&&d.jsx("span",{className:"bw-badge","aria-hidden":!0,children:Bn})]})]}),d.jsxs("div",{className:"action-run",children:[et.claude&&B!==null&&d.jsxs("div",{className:"sound-slot",children:[d.jsx("button",{ref:ye,className:"btn icon-btn",onClick:()=>he(z=>!z),...ir(!1),title:o5(et,{on:B===!0,locked:Ue==="locked",prefs:G}),"aria-label":"Sound settings","aria-haspopup":"dialog","aria-expanded":fe,"aria-controls":fe?"sound-menu":void 0,children:d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[d.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),B?d.jsxs(d.Fragment,{children:[d.jsx("path",{d:"M9.8 5.4a2.4 2.4 0 0 1 0 3.2"}),d.jsx("path",{d:"M11.3 3.9a4.6 4.6 0 0 1 0 6.2"})]}):d.jsxs(d.Fragment,{children:[d.jsx("path",{d:"M10 5.6l2.6 2.8"}),d.jsx("path",{d:"M12.6 5.6L10 8.4"})]})]})}),fe&&d.jsx(hD,{onClose:()=>he(!1),soundOn:B===!0,onToggleSound:J,prefs:G,onLevel:(z,V)=>se(z,{level:V}),onFigure:(z,V)=>se(z,{figure:V}),onPreview:z=>Z(z),openerRef:ye})]}),d.jsx("button",{className:"btn icon-btn",onClick:()=>Zo(z=>z==="dark"?"light":"dark"),title:`Switch to ${Mr==="dark"?"light":"dark"} mode (T)`,"aria-label":"Toggle theme",children:Mr==="dark"?"☀":"☾"})]})]})]}),ns?d.jsxs("div",{className:"ver-banner done",role:"status",children:[d.jsx("span",{className:"ver-dot"}),d.jsxs("strong",{children:["Restarted — now running v",ns,"."]}),d.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):Gn&&!Ie?d.jsxs("div",{className:"conn-banner",role:"alert",children:[d.jsx("span",{className:"conn-dot"}),Ar?qi==="npx"?"Fetching the new version with npx — this can take a minute…":`Restarting ${zt}…`:(()=>{const z=vB({connected:Ie,paused:Un});return d.jsxs(d.Fragment,{children:[`Lost connection to the ${zt} server. Reconnecting…`,z&&d.jsx("span",{className:"conn-sub",children:z})]})})()]}):kt&&Me?d.jsxs("div",{className:`ver-banner ${Me.kind}`,role:"status",children:[d.jsx("span",{className:"ver-dot"}),Me.kind==="restart"?d.jsxs(d.Fragment,{children:[d.jsxs("strong",{children:["v",Me.to," is installed — this deck still runs v",Me.from,"."]}),ce!=null&&ce.canRestart?d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"ver-act",onClick:()=>Ls(),...ir(Ar),title:"Stop this process and bring it back on the same port. The canvas replays from the event log.",children:Ar?"restarting…":"Restart now"}),d.jsxs("button",{type:"button",className:`ver-auto${Wn?" on":""}`,role:"switch","aria-checked":Wn,onClick:Zu,title:Wn?"Restarts on its own once nothing has been running for 30 seconds. Click to require a click instead.":"Only restarts when you click. Click to let it restart itself while idle.",children:[d.jsx("i",{"aria-hidden":!0}),"auto when idle"]})]}):d.jsx("span",{className:"ver-sub",title:"Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.",children:"Restart it to pick up the new code."})]}):d.jsxs(d.Fragment,{children:[d.jsxs("strong",{children:[zt," v",Me.to," is out — you are on v",Me.from,"."]}),(ce==null?void 0:ce.upgradeMode)==="install"&&Bt!=="failed"&&d.jsx("button",{type:"button",className:"ver-act",onClick:Is,...ir(Bt==="running",Bt==="done"),title:`Runs ${((ql=ce==null?void 0:ce.upgrade)==null?void 0:ql.command)??(ce==null?void 0:ce.command)??"npm i -g"} here, then restarts once nothing is running.`,children:Bt==="running"?"installing…":Bt==="done"?"installed":"Update now"}),(ce==null?void 0:ce.upgradeMode)==="npx"&&(ce==null?void 0:ce.canRestart)&&d.jsx("button",{type:"button",className:"ver-act",onClick:()=>Ls({upgrade:!0}),...ir(Ar),title:`Runs ${ce==null?void 0:ce.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`,children:Ar?"fetching…":Bt==="failed"?"Retry update":"Update & restart"}),Bt==="failed"?d.jsxs("span",{className:"ver-sub fail",title:((Ys=ce==null?void 0:ce.upgrade)==null?void 0:Ys.error)??"",children:[(ce==null?void 0:ce.upgradeMode)==="npx"?"update failed":"install failed",": ",((Dl=ce==null?void 0:ce.upgrade)==null?void 0:Dl.error)??"unknown error"," — run it yourself:"]}):(ce==null?void 0:ce.upgradeMode)==="npx"?d.jsx("span",{className:"ver-sub",children:ce!=null&&ce.canRestart?"npx cannot upgrade in place, so the deck re-runs:":hy.npx}):ce!=null&&ce.upgradeBlocked?d.jsx("span",{className:"ver-sub",children:Object.hasOwn(hy,ce.upgradeBlocked)?hy[ce.upgradeBlocked]:"cannot install from here"}):null,d.jsxs("button",{type:"button",className:"ver-cmd",onClick:Cr,title:"Copy to clipboard",children:[d.jsx("code",{children:ce==null?void 0:ce.command}),d.jsx("span",{className:"ver-cmd-hint",children:yt?"copied":"copy"})]})]}),d.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:Fn,children:"×"})]}):Ei&&mn?d.jsxs("div",{className:"ver-banner",role:"status",children:[d.jsx("span",{className:"ver-dot"}),d.jsxs("strong",{children:[mn," still works — the deck is called ",zt," now."]}),ce!=null&&ce.renameFix?d.jsx("span",{className:"ver-sub",children:ce.renameFix}):null,d.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:ji,children:"×"})]}):null,H&&d.jsx(o4,{state:s.current,now:ht,providers:et,onClose:()=>K(!1)}),C&&et.claude&&d.jsx(Pq,{onClose:()=>X(!1)}),F&&d.jsx(Y3,{state:s.current,now:ht,selectedIds:l,onSelect:da,onClose:()=>O(!1)}),d.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${nd?" bubbling":""}${oa?" dragging-any":""}`,ref:Ws,onMouseDownCapture:Ju,onPointerDownCapture:mr,onPointerUpCapture:mr,onWheelCapture:mr,children:[Qi===0&&d.jsx(UB,{live:Ie,everConnected:Gn,providers:et}),Gs.length>1&&d.jsx("div",{ref:Ps,className:`cat-filter-bar${Oi?" occluded":""}`,role:"group","aria-label":"Filter tools by category",children:Gs.map(z=>{const V=Qo.has(z);return d.jsxs("button",{type:"button",className:`cat-filter${V?" off":""}`,onClick:()=>ad(z),"aria-pressed":!V,title:`${V?"Show":"Hide"} ${Gy[z]} tools`,children:[d.jsx("span",{className:"cat-emoji",children:Hy[z]}),d.jsx("span",{className:"cat-name",children:Gy[z]})]},z)})}),d.jsxs(qC,{nodes:od,edges:id,nodeTypes:xB,fitView:!Xe,fitViewOptions:{padding:.25,duration:uy({durationMs:hj,documentHidden:document.hidden})?hj:0},minZoom:.2,maxZoom:1.6,panOnScroll:!0,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,onNodeClick:(z,V)=>{if(V.type==="sessionGroup"){w();return}y(V.id,z.shiftKey)},onPaneClick:()=>w(),onMoveStart:z=>{cj(Ds(z))&&Vi()},onMove:(z,V)=>{Hi(),cj(Ds(z))&&Vi(),os.current&&window.clearTimeout(os.current),os.current=window.setTimeout(()=>qB(V),250)},onNodeDragStart:(z,V)=>{var ae;if(rd(),zs.current=!0,nt.current=new Map,aa(!0),Hi(),Vi(),V.type==="sessionGroup"){const de=(ae=V.data)==null?void 0:ae.sessionId,be=new Map;if(de)for(const je of Cn){const ze=je.data;(ze==null?void 0:ze.sessionId)===de&&be.set(je.id,{x:je.position.x,y:je.position.y})}is.current={start:{x:V.position.x,y:V.position.y},members:be};return}Jt.current.set(V.id,{x:V.position.x,y:V.position.y})},onNodeDrag:(z,V)=>{var ae;if(Hi(),V.type==="sessionGroup"){const de=is.current;if(!de)return;const be=V.position.x-de.start.x,je=V.position.y-de.start.y;for(const[Ze,pt]of de.members){const ot={x:pt.x+be,y:pt.y+je};Jt.current.set(Ze,ot),Mt.current.set(Ze,ot)}const ze=nt.current;if(ze){for(const[Ze,pt]of de.members)ze.set(Ze,{x:pt.x+be,y:pt.y+je});ze.set(V.id,{x:V.position.x,y:V.position.y})}es(Ze=>Ze+1);return}Jt.current.set(V.id,{x:V.position.x,y:V.position.y}),Mt.current.set(V.id,{x:V.position.x,y:V.position.y}),(ae=nt.current)==null||ae.set(V.id,{x:V.position.x,y:V.position.y}),es(de=>de+1)},onNodeDragStop:(z,V)=>{if(Hi(),zs.current=!1,nt.current=null,aa(!1),Os(ae=>ae+1),V.type==="sessionGroup"){const ae=is.current;if(ae){const de=V.position.x-ae.start.x,be=V.position.y-ae.start.y;for(const[je,ze]of ae.members){const Ze={x:ze.x+de,y:ze.y+be};Jt.current.set(je,Ze),Mt.current.set(je,Ze)}}is.current=null,py(Mt.current,Jt.current),Os(de=>de+1);return}Jt.current.set(V.id,{x:V.position.x,y:V.position.y}),Mt.current.set(V.id,{x:V.position.x,y:V.position.y}),py(Mt.current,Jt.current)},children:[d.jsx(F$,{gap:28,size:1,color:Hn["--grid-line"]}),d.jsx(n3,{}),d.jsx(L3,{agents:s.current.agents,visibleAgentIds:$r,positions:Mt.current,pinned:Jt.current,measured:Xn.current,spotlight:Us,hiddenCategories:Qo,now:ht,onOpenTool:g}),d.jsxs(O$,{showInteractive:!1,children:[d.jsx(kr,{onClick:vr,title:Fs?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view",style:Fs?{color:"var(--accent)"}:void 0,children:d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[d.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),d.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),d.jsx(kr,{onClick:ts,title:gB({paused:Un,held:Gt.size,dropped:Gt.dropped}),"aria-label":mB,"aria-pressed":Un,children:d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:d.jsx("path",{d:"M9 5.5v13M15 5.5v13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),d.jsx(kr,{onClick:Lr,title:"Auto-arrange — clear pins (R)","aria-label":"Re-arrange the canvas",children:d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[d.jsx("rect",{x:"8.5",y:"2",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),d.jsx("rect",{x:"1.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),d.jsx("rect",{x:"15.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),d.jsx("path",{d:"M12 7v6.5M5 17v-3.5h14V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),d.jsx(kr,{onClick:()=>cs("button"),title:"Clear the canvas and the server's event log — asks first (C)","aria-label":"Clear the canvas",children:d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[d.jsx("path",{d:"M4 6.2h16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),d.jsx("path",{d:"M9 6.2V4.4a1.6 1.6 0 0 1 1.6-1.6h2.8a1.6 1.6 0 0 1 1.6 1.6v1.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),d.jsx("path",{d:"M17.4 6.4 16.7 20a2 2 0 0 1-2 1.9H9.3a2 2 0 0 1-2-1.9L6.6 6.4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),d.jsx("path",{d:"M10.3 10.6v6.8M13.7 10.6v6.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),d.jsx(kr,{onClick:()=>P(z=>!z),title:"Keyboard shortcuts (?)","aria-label":"Open the keyboard shortcuts","aria-haspopup":"dialog",children:d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[d.jsx("path",{d:"M8.6 8.4a3.5 3.5 0 1 1 4.6 3.35c-.85.3-1.2 1-1.2 1.85v1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),d.jsx("path",{d:"M12 18.4v.2",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",fill:"none"})]})})]}),d.jsx(j$,{zoomable:!0,pannable:!0,nodeColor:Ui,nodeStrokeWidth:2,maskColor:Hn["--minimap-mask"],style:hr})]})]}),A?d.jsxs("aside",{className:"detail","aria-label":"Detail",children:[d.jsx("button",{type:"button",className:"glyph-btn detail-close",title:"Close panel","aria-label":"Close detail panel",onClick:()=>D(!1),children:"×"}),tn?d.jsx(GB,{agent:tn,now:ht,onOpenTool:g,onShowSummary:z=>{I.has(z)&&(I.delete(z),yj(I)),b(z)},onExportSession:z=>DB(s.current,z)}):d.jsx(HB,{count:Qi,workspace:We})]}):d.jsx("button",{type:"button",className:"detail-reopen",title:"Show detail panel","aria-label":"Show detail panel",onClick:()=>D(!0),children:"‹"}),la&&d.jsx(VL,{tool:la,onClose:()=>g(null)}),Tr&&d.jsx(d5,{providers:et,onClose:()=>fr(!1)}),Jr&&d.jsx(k5,{onClose:()=>Ci(!1),onSeen:z=>{Ri(z);try{localStorage.setItem(L1,String(z))}catch{}},onWatching:Mi,palette:Hn}),_&&(()=>{const z=s.current.agents.get(_);return z?d.jsx(FL,{agent:z,onClose:()=>k(null)}):null})(),S&&d.jsx(U3,{state:s.current,sessionId:S,onClose:()=>{I.add(S),yj(I),b(null)}}),it&&d.jsx(jD,{entries:it.entries,since:it.since,firstRun:it.firstRun,running:Pe,onClose:()=>At(null)}),M&&d.jsx(Kq,{onClose:()=>P(!1)}),j&&d.jsx(Gq,{agentCount:Qi,onConfirm:()=>cs("confirmation"),onCancel:()=>T(!1)})]})}function UB({live:e,everConnected:t,providers:n}){const s=!e;return d.jsxs("div",{className:"empty-hero",children:[d.jsxs("div",{className:"orbit-stack","aria-hidden":!0,children:[d.jsx("div",{className:"core"}),d.jsxs("div",{className:"orbit r1",children:[d.jsx("span",{className:"dot"}),d.jsx("span",{className:"dot b"})]}),d.jsxs("div",{className:"orbit r2",children:[d.jsx("span",{className:"dot"}),d.jsx("span",{className:"dot b"})]}),d.jsxs("div",{className:"orbit r3",children:[d.jsx("span",{className:"dot"}),d.jsx("span",{className:"dot b"})]})]}),s?d.jsxs(d.Fragment,{children:[d.jsx("h2",{children:t?"Disconnected from server":"Server unreachable"}),d.jsxs("p",{children:["The browser cannot reach ",d.jsx("code",{children:"/events"}),". Check that",d.jsx("code",{children:zt})," is still running in your terminal, then this page will resume automatically."]})]}):WB(n)]})}function WB(e){return d.jsxs(d.Fragment,{children:[d.jsx("h2",{children:"Waiting for Claude Code or Codex"}),d.jsxs("p",{children:["Run ",d.jsx("code",{children:"claude"})," or ",d.jsx("code",{children:"codex"})," in any folder. As soon as a session sends an event, a node appears here and grows as subagents fork and tools are called."]}),d.jsxs("p",{className:"hint-row",children:["Not seeing anything? Make sure ",d.jsx("code",{children:zt})," is running."]}),i5(e).map(t=>d.jsx("p",{className:"hint-row",children:t.spans.map((n,s)=>n.code?d.jsx("code",{children:n.text},s):d.jsx("span",{children:n.text},s))},t.provider))]})}function HB({count:e,workspace:t}){const n=fB(t);return d.jsxs(d.Fragment,{children:[d.jsx("h2",{children:"Detail"}),e===0?d.jsxs("div",{className:"hint",children:[n.lead,n.workspace!==null&&d.jsxs(d.Fragment,{children:[" ",d.jsx("code",{children:n.workspace}),n.tail]})]}):d.jsx("div",{className:"empty",children:"Click an agent to see its tools."}),d.jsx("h3",{style:{marginTop:4},children:"Shortcuts"}),d.jsxs("div",{className:"shortcuts",children:[d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"?"}),d.jsx("span",{children:"all shortcuts"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"drag"}),d.jsx("span",{children:"move a node"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"tab"}),d.jsx("span",{children:"reach the cards"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"enter"}),d.jsx("span",{children:"select the focused card"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"space"}),d.jsx("span",{children:"pause / resume"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"J"}),d.jsx("span",{children:"next agent"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"K"}),d.jsx("span",{children:"previous agent"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"R"}),d.jsx("span",{children:"re-arrange"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"F"}),d.jsx("span",{children:"fit view"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"L"}),d.jsx("span",{children:"session list"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"H"}),d.jsx("span",{children:"usage history"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"U"}),d.jsx("span",{children:"usage panel"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"C"}),d.jsx("span",{children:"clear canvas"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"T"}),d.jsx("span",{children:"toggle theme"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"Esc"}),d.jsx("span",{children:"deselect, release focus"})]})]})]})}function GB({agent:e,now:t,onOpenTool:n,onShowSummary:s,onExportSession:o}){const a=vu(e.startedAt,e.endedAt,t),l=bn(e),u=l.total>0,h=e.usage.inputTokens+e.usage.outputTokens,p=new Map;for(const S of e.tools){const b=FR(S.name);p.set(b,(p.get(b)??0)+1)}const f=e.tools.filter(S=>S.ok===!1).length,g=e.tools.filter(S=>!S.endedAt).length,y=Array.from(p.entries()).sort((S,b)=>b[1]-S[1]),w=p.has("mcp")?M3(e.tools.map(S=>S.name)):null;return d.jsxs(d.Fragment,{children:[d.jsxs("header",{className:"detail-hero",children:[d.jsxs("div",{className:"hero-line",children:[d.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),d.jsx("h2",{className:"hero-title",title:e.cwd??e.label,children:e.label})]}),d.jsxs("div",{className:"hero-meta",children:[d.jsx("span",{className:"hero-meta-item",children:e.kind}),d.jsx("span",{className:"hero-sep",children:"·"}),d.jsx("span",{className:"hero-meta-item",title:`started ${new Date(e.startedAt).toLocaleString()}`,children:a}),e.model&&(()=>{const S=JC(e);return d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"hero-sep",children:"·"}),d.jsxs("span",{className:"model-chip",title:S.length>0?`${e.model}
141
147
  spend on this panel also covers:
142
148
  ${S.join(`
143
- `)}`:e.model,children:[xi(e.model),S.length>0?` +${S.length}`:""]})]})})()]}),u&&d.jsxs("div",{className:"hero-cost",children:[d.jsxs("div",{className:"hero-cost-headline",children:[d.jsx("span",{className:"hero-cost-value",children:Ve(l.total)}),d.jsx("span",{className:"hero-cost-label",children:"spend"})]}),d.jsx(ww,{cost:l})]}),d.jsxs("div",{className:"hero-actions",children:[e.kind==="root"&&e.state==="done"&&s&&d.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>s(e.sessionId),title:"Reopen the end-of-session recap modal",children:"Show recap"}),o&&d.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>o(e.sessionId),title:"Download this session as JSON",children:"Export JSON"})]})]}),e.tools.length>0&&d.jsxs("section",{className:"detail-section",children:[d.jsx("h3",{children:"Activity"}),d.jsxs("div",{className:"activity-row",children:[d.jsxs("div",{className:"activity-counters",children:[d.jsxs("span",{className:"ac-item",children:[d.jsx("b",{children:e.toolCount})," calls"]}),g>0&&d.jsxs("span",{className:"ac-item ac-live",children:[d.jsx("b",{children:g})," live"]}),f>0&&d.jsxs("span",{className:"ac-item ac-err",children:[d.jsx("b",{children:f})," err"]})]}),d.jsx("div",{className:"cat-strip",children:y.map(([S,b])=>{const _=S==="mcp"?w:null,k=_==null?void 0:_.hue,N=`${b} ${Gy[S]} call${b===1?"":"s"}`;return d.jsxs("span",{className:`cat-chip cat-${S}${k!=null?" mcp-hue":""}`,style:k!=null?{"--mcp-hue":k}:void 0,title:_?`${N}, all to ${_.label}`:N,children:[d.jsx("span",{className:"cat-emoji",children:Hy[S]}),d.jsx("span",{className:"cat-count",children:b}),_&&d.jsx("span",{className:"cat-server",children:_.label})]},S)})})]})]}),h>0&&d.jsxs("section",{className:"detail-section",children:[d.jsx("h3",{children:"Tokens"}),d.jsxs("div",{className:"tokens-grid",children:[d.jsxs("div",{children:[d.jsx("span",{className:"k",children:"in"}),d.jsx("b",{children:e.usage.inputTokens.toLocaleString()})]}),d.jsxs("div",{children:[d.jsx("span",{className:"k",children:"out"}),d.jsx("b",{children:e.usage.outputTokens.toLocaleString()})]}),d.jsxs("div",{children:[d.jsx("span",{className:"k",children:"cache r"}),d.jsx("b",{children:e.usage.cacheReadTokens.toLocaleString()})]}),d.jsxs("div",{children:[d.jsx("span",{className:"k",children:"cache c"}),d.jsx("b",{children:e.usage.cacheCreateTokens.toLocaleString()})]})]})]}),d.jsxs("section",{className:"detail-section",children:[d.jsx("h3",{children:"Identity"}),d.jsxs("div",{children:[e.cwd&&d.jsxs("div",{className:"row",children:[d.jsx("span",{className:"k",children:"cwd"}),d.jsx("span",{className:"v",title:e.cwd,children:e.cwd})]}),d.jsxs("div",{className:"row",children:[d.jsx("span",{className:"k",children:"session"}),d.jsxs("span",{className:"v",children:[e.sessionId.slice(0,12),"…"]})]}),e.parentId&&d.jsxs("div",{className:"row",children:[d.jsx("span",{className:"k",children:"parent"}),d.jsxs("span",{className:"v",children:[e.parentId.slice(0,12),"…"]})]})]})]}),e.prompts.length>0&&d.jsxs("section",{className:"detail-section",children:[d.jsxs("h3",{children:["Prompts ",d.jsx("span",{className:"section-count",children:e.prompts.length})]}),d.jsx("div",{className:"prompts",children:e.prompts.slice().reverse().map((S,b)=>{const _=Q3(S.at,t);return d.jsxs("div",{className:"prompt-entry",children:[d.jsx("div",{className:"prompt-time",title:_.title,children:_.label}),d.jsx("div",{className:"prompt-text",children:S.text})]},b)})})]}),d.jsxs("section",{className:"detail-section",children:[d.jsxs("h3",{children:["Tool calls ",d.jsx("span",{className:"section-count",children:e.tools.length})]}),e.tools.length===0&&d.jsx("div",{className:"empty",children:"No tool calls yet."}),d.jsx("div",{children:e.tools.slice().reverse().map(S=>d.jsx(KB,{t:S,onClick:()=>n(S.id)},S.id))})]})]})}const YB={inflight:"in-flight",done:"done",err:"error"};function KB({t:e,onClick:t}){const n=e.endedAt==null?"inflight":e.ok===!1?"err":"done",s=eT(e,"…");return d.jsxs("button",{className:"tool clickable",title:e.inputPreview||e.name,onClick:t,children:[d.jsxs("span",{className:"name",children:[d.jsx("span",{className:`status-dot ${n}`,"aria-hidden":!0}),d.jsx("span",{className:"vis-hidden",children:YB[n]}),e.name]}),d.jsx("span",{style:{color:"var(--muted)"},children:s})]})}try{u4(window.localStorage)}catch{}const XB=DA.createRoot(document.getElementById("root"));XB.render(d.jsx(BB,{}));
149
+ `)}`:e.model,children:[xi(e.model),S.length>0?` +${S.length}`:""]})]})})()]}),u&&d.jsxs("div",{className:"hero-cost",children:[d.jsxs("div",{className:"hero-cost-headline",children:[d.jsx("span",{className:"hero-cost-value",children:Ve(l.total)}),d.jsx("span",{className:"hero-cost-label",children:"spend"})]}),d.jsx(ww,{cost:l})]}),d.jsxs("div",{className:"hero-actions",children:[e.kind==="root"&&e.state==="done"&&s&&d.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>s(e.sessionId),title:"Reopen the end-of-session recap modal",children:"Show recap"}),o&&d.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>o(e.sessionId),title:"Download this session as JSON",children:"Export JSON"})]})]}),e.tools.length>0&&d.jsxs("section",{className:"detail-section",children:[d.jsx("h3",{children:"Activity"}),d.jsxs("div",{className:"activity-row",children:[d.jsxs("div",{className:"activity-counters",children:[d.jsxs("span",{className:"ac-item",children:[d.jsx("b",{children:e.toolCount})," calls"]}),g>0&&d.jsxs("span",{className:"ac-item ac-live",children:[d.jsx("b",{children:g})," live"]}),f>0&&d.jsxs("span",{className:"ac-item ac-err",children:[d.jsx("b",{children:f})," err"]})]}),d.jsx("div",{className:"cat-strip",children:y.map(([S,b])=>{const _=S==="mcp"?w:null,k=_==null?void 0:_.hue,N=`${b} ${Gy[S]} call${b===1?"":"s"}`;return d.jsxs("span",{className:`cat-chip cat-${S}${k!=null?" mcp-hue":""}`,style:k!=null?{"--mcp-hue":k}:void 0,title:_?`${N}, all to ${_.label}`:N,children:[d.jsx("span",{className:"cat-emoji",children:Hy[S]}),d.jsx("span",{className:"cat-count",children:b}),_&&d.jsx("span",{className:"cat-server",children:_.label})]},S)})})]})]}),h>0&&d.jsxs("section",{className:"detail-section",children:[d.jsx("h3",{children:"Tokens"}),d.jsxs("div",{className:"tokens-grid",children:[d.jsxs("div",{children:[d.jsx("span",{className:"k",children:"in"}),d.jsx("b",{children:e.usage.inputTokens.toLocaleString()})]}),d.jsxs("div",{children:[d.jsx("span",{className:"k",children:"out"}),d.jsx("b",{children:e.usage.outputTokens.toLocaleString()})]}),d.jsxs("div",{children:[d.jsx("span",{className:"k",children:"cache r"}),d.jsx("b",{children:e.usage.cacheReadTokens.toLocaleString()})]}),d.jsxs("div",{children:[d.jsx("span",{className:"k",children:"cache c"}),d.jsx("b",{children:e.usage.cacheCreateTokens.toLocaleString()})]})]})]}),d.jsxs("section",{className:"detail-section",children:[d.jsx("h3",{children:"Identity"}),d.jsxs("div",{children:[e.cwd&&d.jsxs("div",{className:"row",children:[d.jsx("span",{className:"k",children:"cwd"}),d.jsx("span",{className:"v",title:e.cwd,children:e.cwd})]}),d.jsxs("div",{className:"row",children:[d.jsx("span",{className:"k",children:"session"}),d.jsxs("span",{className:"v",children:[e.sessionId.slice(0,12),"…"]})]}),e.parentId&&d.jsxs("div",{className:"row",children:[d.jsx("span",{className:"k",children:"parent"}),d.jsxs("span",{className:"v",children:[e.parentId.slice(0,12),"…"]})]})]})]}),e.prompts.length>0&&d.jsxs("section",{className:"detail-section",children:[d.jsxs("h3",{children:["Prompts ",d.jsx("span",{className:"section-count",children:e.prompts.length})]}),d.jsx("div",{className:"prompts",children:e.prompts.slice().reverse().map((S,b)=>{const _=X3(S.at,t);return d.jsxs("div",{className:"prompt-entry",children:[d.jsx("div",{className:"prompt-time",title:_.title,children:_.label}),d.jsx("div",{className:"prompt-text",children:S.text})]},b)})})]}),d.jsxs("section",{className:"detail-section",children:[d.jsxs("h3",{children:["Tool calls ",d.jsx("span",{className:"section-count",children:e.tools.length})]}),e.tools.length===0&&d.jsx("div",{className:"empty",children:"No tool calls yet."}),d.jsx("div",{children:e.tools.slice().reverse().map(S=>d.jsx(YB,{t:S,onClick:()=>n(S.id)},S.id))})]})]})}const VB={inflight:"in-flight",done:"done",err:"error"};function YB({t:e,onClick:t}){const n=e.endedAt==null?"inflight":e.ok===!1?"err":"done",s=eT(e,"…");return d.jsxs("button",{className:"tool clickable",title:e.inputPreview||e.name,onClick:t,children:[d.jsxs("span",{className:"name",children:[d.jsx("span",{className:`status-dot ${n}`,"aria-hidden":!0}),d.jsx("span",{className:"vis-hidden",children:VB[n]}),e.name]}),d.jsx("span",{style:{color:"var(--muted)"},children:s})]})}try{c4(window.localStorage)}catch{}const KB=DA.createRoot(document.getElementById("root"));KB.render(d.jsx(zB,{}));