ccdeck 3.38.1 → 3.38.2

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.
@@ -1,307 +0,0 @@
1
- var K3=Object.defineProperty;var Y3=(e,t,n)=>t in e?K3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var lp=(e,t,n)=>Y3(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();var Nu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Tb(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var cp={exports:{}},hl={},up={exports:{}},Le={};/**
2
- * @license React
3
- * react.production.min.js
4
- *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var hN;function X3(){if(hN)return Le;hN=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.iterator;function g(D){return D===null||typeof D!="object"?null:(D=p&&D[p]||D["@@iterator"],typeof D=="function"?D:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,k={};function x(D,W,J){this.props=D,this.context=W,this.refs=k,this.updater=J||v}x.prototype.isReactComponent={},x.prototype.setState=function(D,W){if(typeof D!="object"&&typeof D!="function"&&D!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,D,W,"setState")},x.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function j(){}j.prototype=x.prototype;function b(D,W,J){this.props=D,this.context=W,this.refs=k,this.updater=J||v}var _=b.prototype=new j;_.constructor=b,N(_,x.prototype),_.isPureReactComponent=!0;var E=Array.isArray,R=Object.prototype.hasOwnProperty,C={current:null},A={key:!0,ref:!0,__self:!0,__source:!0};function U(D,W,J){var V,X={},Y=null,Z=null;if(W!=null)for(V in W.ref!==void 0&&(Z=W.ref),W.key!==void 0&&(Y=""+W.key),W)R.call(W,V)&&!A.hasOwnProperty(V)&&(X[V]=W[V]);var ee=arguments.length-2;if(ee===1)X.children=J;else if(1<ee){for(var ne=Array(ee),se=0;se<ee;se++)ne[se]=arguments[se+2];X.children=ne}if(D&&D.defaultProps)for(V in ee=D.defaultProps,ee)X[V]===void 0&&(X[V]=ee[V]);return{$$typeof:e,type:D,key:Y,ref:Z,props:X,_owner:C.current}}function L(D,W){return{$$typeof:e,type:D.type,key:W,ref:D.ref,props:D.props,_owner:D._owner}}function F(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function O(D){var W={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(J){return W[J]})}var I=/\/+/g;function B(D,W){return typeof D=="object"&&D!==null&&D.key!=null?O(""+D.key):W.toString(36)}function M(D,W,J,V,X){var Y=typeof D;(Y==="undefined"||Y==="boolean")&&(D=null);var Z=!1;if(D===null)Z=!0;else switch(Y){case"string":case"number":Z=!0;break;case"object":switch(D.$$typeof){case e:case t:Z=!0}}if(Z)return Z=D,X=X(Z),D=V===""?"."+B(Z,0):V,E(X)?(J="",D!=null&&(J=D.replace(I,"$&/")+"/"),M(X,W,J,"",function(se){return se})):X!=null&&(F(X)&&(X=L(X,J+(!X.key||Z&&Z.key===X.key?"":(""+X.key).replace(I,"$&/")+"/")+D)),W.push(X)),1;if(Z=0,V=V===""?".":V+":",E(D))for(var ee=0;ee<D.length;ee++){Y=D[ee];var ne=V+B(Y,ee);Z+=M(Y,W,J,ne,X)}else if(ne=g(D),typeof ne=="function")for(D=ne.call(D),ee=0;!(Y=D.next()).done;)Y=Y.value,ne=V+B(Y,ee++),Z+=M(Y,W,J,ne,X);else if(Y==="object")throw W=String(D),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(D).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.");return Z}function $(D,W,J){if(D==null)return D;var V=[],X=0;return M(D,V,"","",function(Y){return W.call(J,Y,X++)}),V}function P(D){if(D._status===-1){var W=D._result;W=W(),W.then(function(J){(D._status===0||D._status===-1)&&(D._status=1,D._result=J)},function(J){(D._status===0||D._status===-1)&&(D._status=2,D._result=J)}),D._status===-1&&(D._status=0,D._result=W)}if(D._status===1)return D._result.default;throw D._result}var G={current:null},K={transition:null},q={ReactCurrentDispatcher:G,ReactCurrentBatchConfig:K,ReactCurrentOwner:C};function H(){throw Error("act(...) is not supported in production builds of React.")}return Le.Children={map:$,forEach:function(D,W,J){$(D,function(){W.apply(this,arguments)},J)},count:function(D){var W=0;return $(D,function(){W++}),W},toArray:function(D){return $(D,function(W){return W})||[]},only:function(D){if(!F(D))throw Error("React.Children.only expected to receive a single React element child.");return D}},Le.Component=x,Le.Fragment=n,Le.Profiler=s,Le.PureComponent=b,Le.StrictMode=r,Le.Suspense=d,Le.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=q,Le.act=H,Le.cloneElement=function(D,W,J){if(D==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+D+".");var V=N({},D.props),X=D.key,Y=D.ref,Z=D._owner;if(W!=null){if(W.ref!==void 0&&(Y=W.ref,Z=C.current),W.key!==void 0&&(X=""+W.key),D.type&&D.type.defaultProps)var ee=D.type.defaultProps;for(ne in W)R.call(W,ne)&&!A.hasOwnProperty(ne)&&(V[ne]=W[ne]===void 0&&ee!==void 0?ee[ne]:W[ne])}var ne=arguments.length-2;if(ne===1)V.children=J;else if(1<ne){ee=Array(ne);for(var se=0;se<ne;se++)ee[se]=arguments[se+2];V.children=ee}return{$$typeof:e,type:D.type,key:X,ref:Y,props:V,_owner:Z}},Le.createContext=function(D){return D={$$typeof:l,_currentValue:D,_currentValue2:D,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},D.Provider={$$typeof:o,_context:D},D.Consumer=D},Le.createElement=U,Le.createFactory=function(D){var W=U.bind(null,D);return W.type=D,W},Le.createRef=function(){return{current:null}},Le.forwardRef=function(D){return{$$typeof:c,render:D}},Le.isValidElement=F,Le.lazy=function(D){return{$$typeof:f,_payload:{_status:-1,_result:D},_init:P}},Le.memo=function(D,W){return{$$typeof:h,type:D,compare:W===void 0?null:W}},Le.startTransition=function(D){var W=K.transition;K.transition={};try{D()}finally{K.transition=W}},Le.unstable_act=H,Le.useCallback=function(D,W){return G.current.useCallback(D,W)},Le.useContext=function(D){return G.current.useContext(D)},Le.useDebugValue=function(){},Le.useDeferredValue=function(D){return G.current.useDeferredValue(D)},Le.useEffect=function(D,W){return G.current.useEffect(D,W)},Le.useId=function(){return G.current.useId()},Le.useImperativeHandle=function(D,W,J){return G.current.useImperativeHandle(D,W,J)},Le.useInsertionEffect=function(D,W){return G.current.useInsertionEffect(D,W)},Le.useLayoutEffect=function(D,W){return G.current.useLayoutEffect(D,W)},Le.useMemo=function(D,W){return G.current.useMemo(D,W)},Le.useReducer=function(D,W,J){return G.current.useReducer(D,W,J)},Le.useRef=function(D){return G.current.useRef(D)},Le.useState=function(D){return G.current.useState(D)},Le.useSyncExternalStore=function(D,W,J){return G.current.useSyncExternalStore(D,W,J)},Le.useTransition=function(){return G.current.useTransition()},Le.version="18.3.1",Le}var fN;function oc(){return fN||(fN=1,up.exports=X3()),up.exports}/**
10
- * @license React
11
- * react-jsx-runtime.production.min.js
12
- *
13
- * Copyright (c) Facebook, Inc. and its affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var pN;function Z3(){if(pN)return hl;pN=1;var e=oc(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,s=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function l(c,d,h){var f,p={},g=null,v=null;h!==void 0&&(g=""+h),d.key!==void 0&&(g=""+d.key),d.ref!==void 0&&(v=d.ref);for(f in d)r.call(d,f)&&!o.hasOwnProperty(f)&&(p[f]=d[f]);if(c&&c.defaultProps)for(f in d=c.defaultProps,d)p[f]===void 0&&(p[f]=d[f]);return{$$typeof:t,type:c,key:g,ref:v,props:p,_owner:s.current}}return hl.Fragment=n,hl.jsx=l,hl.jsxs=l,hl}var mN;function J3(){return mN||(mN=1,cp.exports=Z3()),cp.exports}var a=J3(),ju={},dp={exports:{}},un={},hp={exports:{}},fp={};/**
18
- * @license React
19
- * scheduler.production.min.js
20
- *
21
- * Copyright (c) Facebook, Inc. and its affiliates.
22
- *
23
- * This source code is licensed under the MIT license found in the
24
- * LICENSE file in the root directory of this source tree.
25
- */var gN;function Q3(){return gN||(gN=1,(function(e){function t(K,q){var H=K.length;K.push(q);e:for(;0<H;){var D=H-1>>>1,W=K[D];if(0<s(W,q))K[D]=q,K[H]=W,H=D;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var q=K[0],H=K.pop();if(H!==q){K[0]=H;e:for(var D=0,W=K.length,J=W>>>1;D<J;){var V=2*(D+1)-1,X=K[V],Y=V+1,Z=K[Y];if(0>s(X,H))Y<W&&0>s(Z,X)?(K[D]=Z,K[Y]=H,D=Y):(K[D]=X,K[V]=H,D=V);else if(Y<W&&0>s(Z,H))K[D]=Z,K[Y]=H,D=Y;else break e}}return q}function s(K,q){var H=K.sortIndex-q.sortIndex;return H!==0?H:K.id-q.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var l=Date,c=l.now();e.unstable_now=function(){return l.now()-c}}var d=[],h=[],f=1,p=null,g=3,v=!1,N=!1,k=!1,x=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,b=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function _(K){for(var q=n(h);q!==null;){if(q.callback===null)r(h);else if(q.startTime<=K)r(h),q.sortIndex=q.expirationTime,t(d,q);else break;q=n(h)}}function E(K){if(k=!1,_(K),!N)if(n(d)!==null)N=!0,P(R);else{var q=n(h);q!==null&&G(E,q.startTime-K)}}function R(K,q){N=!1,k&&(k=!1,j(U),U=-1),v=!0;var H=g;try{for(_(q),p=n(d);p!==null&&(!(p.expirationTime>q)||K&&!O());){var D=p.callback;if(typeof D=="function"){p.callback=null,g=p.priorityLevel;var W=D(p.expirationTime<=q);q=e.unstable_now(),typeof W=="function"?p.callback=W:p===n(d)&&r(d),_(q)}else r(d);p=n(d)}if(p!==null)var J=!0;else{var V=n(h);V!==null&&G(E,V.startTime-q),J=!1}return J}finally{p=null,g=H,v=!1}}var C=!1,A=null,U=-1,L=5,F=-1;function O(){return!(e.unstable_now()-F<L)}function I(){if(A!==null){var K=e.unstable_now();F=K;var q=!0;try{q=A(!0,K)}finally{q?B():(C=!1,A=null)}}else C=!1}var B;if(typeof b=="function")B=function(){b(I)};else if(typeof MessageChannel<"u"){var M=new MessageChannel,$=M.port2;M.port1.onmessage=I,B=function(){$.postMessage(null)}}else B=function(){x(I,0)};function P(K){A=K,C||(C=!0,B())}function G(K,q){U=x(function(){K(e.unstable_now())},q)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(K){K.callback=null},e.unstable_continueExecution=function(){N||v||(N=!0,P(R))},e.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<K?Math.floor(1e3/K):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(K){switch(g){case 1:case 2:case 3:var q=3;break;default:q=g}var H=g;g=q;try{return K()}finally{g=H}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(K,q){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var H=g;g=K;try{return q()}finally{g=H}},e.unstable_scheduleCallback=function(K,q,H){var D=e.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?D+H:D):H=D,K){case 1:var W=-1;break;case 2:W=250;break;case 5:W=1073741823;break;case 4:W=1e4;break;default:W=5e3}return W=H+W,K={id:f++,callback:q,priorityLevel:K,startTime:H,expirationTime:W,sortIndex:-1},H>D?(K.sortIndex=H,t(h,K),n(d)===null&&K===n(h)&&(k?(j(U),U=-1):k=!0,G(E,H-D))):(K.sortIndex=W,t(d,K),N||v||(N=!0,P(R))),K},e.unstable_shouldYield=O,e.unstable_wrapCallback=function(K){var q=g;return function(){var H=g;g=q;try{return K.apply(this,arguments)}finally{g=H}}}})(fp)),fp}var yN;function e4(){return yN||(yN=1,hp.exports=Q3()),hp.exports}/**
26
- * @license React
27
- * react-dom.production.min.js
28
- *
29
- * Copyright (c) Facebook, Inc. and its affiliates.
30
- *
31
- * This source code is licensed under the MIT license found in the
32
- * LICENSE file in the root directory of this source tree.
33
- */var wN;function t4(){if(wN)return un;wN=1;var e=oc(),t=e4();function n(i){for(var u="https://reactjs.org/docs/error-decoder.html?invariant="+i,m=1;m<arguments.length;m++)u+="&args[]="+encodeURIComponent(arguments[m]);return"Minified React error #"+i+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,s={};function o(i,u){l(i,u),l(i+"Capture",u)}function l(i,u){for(s[i]=u,i=0;i<u.length;i++)r.add(u[i])}var c=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),d=Object.prototype.hasOwnProperty,h=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},p={};function g(i){return d.call(p,i)?!0:d.call(f,i)?!1:h.test(i)?p[i]=!0:(f[i]=!0,!1)}function v(i,u,m,w){if(m!==null&&m.type===0)return!1;switch(typeof u){case"function":case"symbol":return!0;case"boolean":return w?!1:m!==null?!m.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function N(i,u,m,w){if(u===null||typeof u>"u"||v(i,u,m,w))return!0;if(w)return!1;if(m!==null)switch(m.type){case 3:return!u;case 4:return u===!1;case 5:return isNaN(u);case 6:return isNaN(u)||1>u}return!1}function k(i,u,m,w,S,T,z){this.acceptsBooleans=u===2||u===3||u===4,this.attributeName=w,this.attributeNamespace=S,this.mustUseProperty=m,this.propertyName=i,this.type=u,this.sanitizeURL=T,this.removeEmptyString=z}var x={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){x[i]=new k(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var u=i[0];x[u]=new k(u,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){x[i]=new k(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){x[i]=new k(i,2,!1,i,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(i){x[i]=new k(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){x[i]=new k(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){x[i]=new k(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){x[i]=new k(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){x[i]=new k(i,5,!1,i.toLowerCase(),null,!1,!1)});var j=/[\-:]([a-z])/g;function b(i){return i[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(i){var u=i.replace(j,b);x[u]=new k(u,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var u=i.replace(j,b);x[u]=new k(u,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var u=i.replace(j,b);x[u]=new k(u,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){x[i]=new k(i,1,!1,i.toLowerCase(),null,!1,!1)}),x.xlinkHref=new k("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){x[i]=new k(i,1,!1,i.toLowerCase(),null,!0,!0)});function _(i,u,m,w){var S=x.hasOwnProperty(u)?x[u]:null;(S!==null?S.type!==0:w||!(2<u.length)||u[0]!=="o"&&u[0]!=="O"||u[1]!=="n"&&u[1]!=="N")&&(N(u,m,S,w)&&(m=null),w||S===null?g(u)&&(m===null?i.removeAttribute(u):i.setAttribute(u,""+m)):S.mustUseProperty?i[S.propertyName]=m===null?S.type===3?!1:"":m:(u=S.attributeName,w=S.attributeNamespace,m===null?i.removeAttribute(u):(S=S.type,m=S===3||S===4&&m===!0?"":""+m,w?i.setAttributeNS(w,u,m):i.setAttribute(u,m))))}var E=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,R=Symbol.for("react.element"),C=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),U=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),F=Symbol.for("react.provider"),O=Symbol.for("react.context"),I=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),M=Symbol.for("react.suspense_list"),$=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),G=Symbol.for("react.offscreen"),K=Symbol.iterator;function q(i){return i===null||typeof i!="object"?null:(i=K&&i[K]||i["@@iterator"],typeof i=="function"?i:null)}var H=Object.assign,D;function W(i){if(D===void 0)try{throw Error()}catch(m){var u=m.stack.trim().match(/\n( *(at )?)/);D=u&&u[1]||""}return`
34
- `+D+i}var J=!1;function V(i,u){if(!i||J)return"";J=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(u)if(u=function(){throw Error()},Object.defineProperty(u.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(u,[])}catch(ce){var w=ce}Reflect.construct(i,[],u)}else{try{u.call()}catch(ce){w=ce}i.call(u.prototype)}else{try{throw Error()}catch(ce){w=ce}i()}}catch(ce){if(ce&&w&&typeof ce.stack=="string"){for(var S=ce.stack.split(`
35
- `),T=w.stack.split(`
36
- `),z=S.length-1,Q=T.length-1;1<=z&&0<=Q&&S[z]!==T[Q];)Q--;for(;1<=z&&0<=Q;z--,Q--)if(S[z]!==T[Q]){if(z!==1||Q!==1)do if(z--,Q--,0>Q||S[z]!==T[Q]){var te=`
37
- `+S[z].replace(" at new "," at ");return i.displayName&&te.includes("<anonymous>")&&(te=te.replace("<anonymous>",i.displayName)),te}while(1<=z&&0<=Q);break}}}finally{J=!1,Error.prepareStackTrace=m}return(i=i?i.displayName||i.name:"")?W(i):""}function X(i){switch(i.tag){case 5:return W(i.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return i=V(i.type,!1),i;case 11:return i=V(i.type.render,!1),i;case 1:return i=V(i.type,!0),i;default:return""}}function Y(i){if(i==null)return null;if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case A:return"Fragment";case C:return"Portal";case L:return"Profiler";case U:return"StrictMode";case B:return"Suspense";case M:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case O:return(i.displayName||"Context")+".Consumer";case F:return(i._context.displayName||"Context")+".Provider";case I:var u=i.render;return i=i.displayName,i||(i=u.displayName||u.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case $:return u=i.displayName||null,u!==null?u:Y(i.type)||"Memo";case P:u=i._payload,i=i._init;try{return Y(i(u))}catch{}}return null}function Z(i){var u=i.type;switch(i.tag){case 24:return"Cache";case 9:return(u.displayName||"Context")+".Consumer";case 10:return(u._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return i=u.render,i=i.displayName||i.name||"",u.displayName||(i!==""?"ForwardRef("+i+")":"ForwardRef");case 7:return"Fragment";case 5:return u;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Y(u);case 8:return u===U?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof u=="function")return u.displayName||u.name||null;if(typeof u=="string")return u}return null}function ee(i){switch(typeof i){case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function ne(i){var u=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(u==="checkbox"||u==="radio")}function se(i){var u=ne(i)?"checked":"value",m=Object.getOwnPropertyDescriptor(i.constructor.prototype,u),w=""+i[u];if(!i.hasOwnProperty(u)&&typeof m<"u"&&typeof m.get=="function"&&typeof m.set=="function"){var S=m.get,T=m.set;return Object.defineProperty(i,u,{configurable:!0,get:function(){return S.call(this)},set:function(z){w=""+z,T.call(this,z)}}),Object.defineProperty(i,u,{enumerable:m.enumerable}),{getValue:function(){return w},setValue:function(z){w=""+z},stopTracking:function(){i._valueTracker=null,delete i[u]}}}}function pe(i){i._valueTracker||(i._valueTracker=se(i))}function ke(i){if(!i)return!1;var u=i._valueTracker;if(!u)return!0;var m=u.getValue(),w="";return i&&(w=ne(i)?i.checked?"true":"false":i.value),i=w,i!==m?(u.setValue(i),!0):!1}function ae(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}function fe(i,u){var m=u.checked;return H({},u,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:m??i._wrapperState.initialChecked})}function me(i,u){var m=u.defaultValue==null?"":u.defaultValue,w=u.checked!=null?u.checked:u.defaultChecked;m=ee(u.value!=null?u.value:m),i._wrapperState={initialChecked:w,initialValue:m,controlled:u.type==="checkbox"||u.type==="radio"?u.checked!=null:u.value!=null}}function he(i,u){u=u.checked,u!=null&&_(i,"checked",u,!1)}function ge(i,u){he(i,u);var m=ee(u.value),w=u.type;if(m!=null)w==="number"?(m===0&&i.value===""||i.value!=m)&&(i.value=""+m):i.value!==""+m&&(i.value=""+m);else if(w==="submit"||w==="reset"){i.removeAttribute("value");return}u.hasOwnProperty("value")?be(i,u.type,m):u.hasOwnProperty("defaultValue")&&be(i,u.type,ee(u.defaultValue)),u.checked==null&&u.defaultChecked!=null&&(i.defaultChecked=!!u.defaultChecked)}function ue(i,u,m){if(u.hasOwnProperty("value")||u.hasOwnProperty("defaultValue")){var w=u.type;if(!(w!=="submit"&&w!=="reset"||u.value!==void 0&&u.value!==null))return;u=""+i._wrapperState.initialValue,m||u===i.value||(i.value=u),i.defaultValue=u}m=i.name,m!==""&&(i.name=""),i.defaultChecked=!!i._wrapperState.initialChecked,m!==""&&(i.name=m)}function be(i,u,m){(u!=="number"||ae(i.ownerDocument)!==i)&&(m==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+m&&(i.defaultValue=""+m))}var oe=Array.isArray;function je(i,u,m,w){if(i=i.options,u){u={};for(var S=0;S<m.length;S++)u["$"+m[S]]=!0;for(m=0;m<i.length;m++)S=u.hasOwnProperty("$"+i[m].value),i[m].selected!==S&&(i[m].selected=S),S&&w&&(i[m].defaultSelected=!0)}else{for(m=""+ee(m),u=null,S=0;S<i.length;S++){if(i[S].value===m){i[S].selected=!0,w&&(i[S].defaultSelected=!0);return}u!==null||i[S].disabled||(u=i[S])}u!==null&&(u.selected=!0)}}function $e(i,u){if(u.dangerouslySetInnerHTML!=null)throw Error(n(91));return H({},u,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function Oe(i,u){var m=u.value;if(m==null){if(m=u.children,u=u.defaultValue,m!=null){if(u!=null)throw Error(n(92));if(oe(m)){if(1<m.length)throw Error(n(93));m=m[0]}u=m}u==null&&(u=""),m=u}i._wrapperState={initialValue:ee(m)}}function Ue(i,u){var m=ee(u.value),w=ee(u.defaultValue);m!=null&&(m=""+m,m!==i.value&&(i.value=m),u.defaultValue==null&&i.defaultValue!==m&&(i.defaultValue=m)),w!=null&&(i.defaultValue=""+w)}function Be(i){var u=i.textContent;u===i._wrapperState.initialValue&&u!==""&&u!==null&&(i.value=u)}function We(i){switch(i){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function He(i,u){return i==null||i==="http://www.w3.org/1999/xhtml"?We(u):i==="http://www.w3.org/2000/svg"&&u==="foreignObject"?"http://www.w3.org/1999/xhtml":i}var rt,lt=(function(i){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(u,m,w,S){MSApp.execUnsafeLocalFunction(function(){return i(u,m,w,S)})}:i})(function(i,u){if(i.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in i)i.innerHTML=u;else{for(rt=rt||document.createElement("div"),rt.innerHTML="<svg>"+u.valueOf().toString()+"</svg>",u=rt.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;u.firstChild;)i.appendChild(u.firstChild)}});function Rt(i,u){if(u){var m=i.firstChild;if(m&&m===i.lastChild&&m.nodeType===3){m.nodeValue=u;return}}i.textContent=u}var De={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},et=["Webkit","ms","Moz","O"];Object.keys(De).forEach(function(i){et.forEach(function(u){u=u+i.charAt(0).toUpperCase()+i.substring(1),De[u]=De[i]})});function Je(i,u,m){return u==null||typeof u=="boolean"||u===""?"":m||typeof u!="number"||u===0||De.hasOwnProperty(i)&&De[i]?(""+u).trim():u+"px"}function tt(i,u){i=i.style;for(var m in u)if(u.hasOwnProperty(m)){var w=m.indexOf("--")===0,S=Je(m,u[m],w);m==="float"&&(m="cssFloat"),w?i.setProperty(m,S):i[m]=S}}var yt=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Pt(i,u){if(u){if(yt[i]&&(u.children!=null||u.dangerouslySetInnerHTML!=null))throw Error(n(137,i));if(u.dangerouslySetInnerHTML!=null){if(u.children!=null)throw Error(n(60));if(typeof u.dangerouslySetInnerHTML!="object"||!("__html"in u.dangerouslySetInnerHTML))throw Error(n(61))}if(u.style!=null&&typeof u.style!="object")throw Error(n(62))}}function wt(i,u){if(i.indexOf("-")===-1)return typeof u.is=="string";switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var st=null;function zt(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Wt=null,Dt=null,Ht=null;function Vt(i){if(i=Zi(i)){if(typeof Wt!="function")throw Error(n(280));var u=i.stateNode;u&&(u=Dc(u),Wt(i.stateNode,i.type,u))}}function vs(i){Dt?Ht?Ht.push(i):Ht=[i]:Dt=i}function Cn(){if(Dt){var i=Dt,u=Ht;if(Ht=Dt=null,Vt(i),u)for(i=0;i<u.length;i++)Vt(u[i])}}function mr(i,u){return i(u)}function zr(){}var gr=!1;function Wr(i,u,m){if(gr)return i(u,m);gr=!0;try{return mr(i,u,m)}finally{gr=!1,(Dt!==null||Ht!==null)&&(zr(),Cn())}}function mn(i,u){var m=i.stateNode;if(m===null)return null;var w=Dc(m);if(w===null)return null;m=w[u];e:switch(u){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(w=!w.disabled)||(i=i.type,w=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!w;break e;default:i=!1}if(i)return null;if(m&&typeof m!="function")throw Error(n(231,u,typeof m));return m}var Hr=!1;if(c)try{var An={};Object.defineProperty(An,"passive",{get:function(){Hr=!0}}),window.addEventListener("test",An,An),window.removeEventListener("test",An,An)}catch{Hr=!1}function da(i,u,m,w,S,T,z,Q,te){var ce=Array.prototype.slice.call(arguments,3);try{u.apply(m,ce)}catch(ve){this.onError(ve)}}var gn=!1,yr=null,wr=!1,xt=null,xs={onError:function(i){gn=!0,yr=i}};function vr(i,u,m,w,S,T,z,Q,te){gn=!1,yr=null,da.apply(xs,arguments)}function xr(i,u,m,w,S,T,z,Q,te){if(vr.apply(this,arguments),gn){if(gn){var ce=yr;gn=!1,yr=null}else throw Error(n(198));wr||(wr=!0,xt=ce)}}function Gt(i){var u=i,m=i;if(i.alternate)for(;u.return;)u=u.return;else{i=u;do u=i,(u.flags&4098)!==0&&(m=u.return),i=u.return;while(i)}return u.tag===3?m:null}function bs(i){if(i.tag===13){var u=i.memoizedState;if(u===null&&(i=i.alternate,i!==null&&(u=i.memoizedState)),u!==null)return u.dehydrated}return null}function Vr(i){if(Gt(i)!==i)throw Error(n(188))}function ye(i){var u=i.alternate;if(!u){if(u=Gt(i),u===null)throw Error(n(188));return u!==i?null:i}for(var m=i,w=u;;){var S=m.return;if(S===null)break;var T=S.alternate;if(T===null){if(w=S.return,w!==null){m=w;continue}break}if(S.child===T.child){for(T=S.child;T;){if(T===m)return Vr(S),i;if(T===w)return Vr(S),u;T=T.sibling}throw Error(n(188))}if(m.return!==w.return)m=S,w=T;else{for(var z=!1,Q=S.child;Q;){if(Q===m){z=!0,m=S,w=T;break}if(Q===w){z=!0,w=S,m=T;break}Q=Q.sibling}if(!z){for(Q=T.child;Q;){if(Q===m){z=!0,m=T,w=S;break}if(Q===w){z=!0,w=T,m=S;break}Q=Q.sibling}if(!z)throw Error(n(189))}}if(m.alternate!==w)throw Error(n(190))}if(m.tag!==3)throw Error(n(188));return m.stateNode.current===m?i:u}function Fe(i){return i=ye(i),i!==null?Ge(i):null}function Ge(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var u=Ge(i);if(u!==null)return u;i=i.sibling}return null}var rn=t.unstable_scheduleCallback,Gr=t.unstable_cancelCallback,br=t.unstable_shouldYield,ha=t.unstable_requestPaint,Ke=t.unstable_now,Kr=t.unstable_getCurrentPriorityLevel,ks=t.unstable_ImmediatePriority,kr=t.unstable_UserBlockingPriority,Kn=t.unstable_NormalPriority,Yr=t.unstable_LowPriority,ao=t.unstable_IdlePriority,Ns=null,Jt=null;function js(i){if(Jt&&typeof Jt.onCommitFiberRoot=="function")try{Jt.onCommitFiberRoot(Ns,i,void 0,(i.current.flags&128)===128)}catch{}}var yn=Math.clz32?Math.clz32:Nr,xc=Math.log,bc=Math.LN2;function Nr(i){return i>>>=0,i===0?32:31-(xc(i)/bc|0)|0}var oo=64,io=4194304;function Ss(i){switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return i&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return i}}function fa(i,u){var m=i.pendingLanes;if(m===0)return 0;var w=0,S=i.suspendedLanes,T=i.pingedLanes,z=m&268435455;if(z!==0){var Q=z&~S;Q!==0?w=Ss(Q):(T&=z,T!==0&&(w=Ss(T)))}else z=m&~S,z!==0?w=Ss(z):T!==0&&(w=Ss(T));if(w===0)return 0;if(u!==0&&u!==w&&(u&S)===0&&(S=w&-w,T=u&-u,S>=T||S===16&&(T&4194240)!==0))return u;if((w&4)!==0&&(w|=m&16),u=i.entangledLanes,u!==0)for(i=i.entanglements,u&=w;0<u;)m=31-yn(u),S=1<<m,w|=i[m],u&=~S;return w}function Mi(i,u){switch(i){case 1:case 2:case 4:return u+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return u+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function $i(i,u){for(var m=i.suspendedLanes,w=i.pingedLanes,S=i.expirationTimes,T=i.pendingLanes;0<T;){var z=31-yn(T),Q=1<<z,te=S[z];te===-1?((Q&m)===0||(Q&w)!==0)&&(S[z]=Mi(Q,u)):te<=u&&(i.expiredLanes|=Q),T&=~Q}}function Yn(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function kc(){var i=oo;return oo<<=1,(oo&4194240)===0&&(oo=64),i}function Ii(i){for(var u=[],m=0;31>m;m++)u.push(i);return u}function pa(i,u,m){i.pendingLanes|=u,u!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,u=31-yn(u),i[u]=m}function Nc(i,u){var m=i.pendingLanes&~u;i.pendingLanes=u,i.suspendedLanes=0,i.pingedLanes=0,i.expiredLanes&=u,i.mutableReadLanes&=u,i.entangledLanes&=u,u=i.entanglements;var w=i.eventTimes;for(i=i.expirationTimes;0<m;){var S=31-yn(m),T=1<<S;u[S]=0,w[S]=-1,i[S]=-1,m&=~T}}function jr(i,u){var m=i.entangledLanes|=u;for(i=i.entanglements;m;){var w=31-yn(m),S=1<<w;S&u|i[w]&u&&(i[w]|=u),m&=~S}}var Ye=0;function Oi(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var Li,ma,jc,Sc,lo,co=!1,uo=[],Sr=null,_r=null,Rn=null,ga=new Map,_s=new Map,Er=[],Lh="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function _c(i,u){switch(i){case"focusin":case"focusout":Sr=null;break;case"dragenter":case"dragleave":_r=null;break;case"mouseover":case"mouseout":Rn=null;break;case"pointerover":case"pointerout":ga.delete(u.pointerId);break;case"gotpointercapture":case"lostpointercapture":_s.delete(u.pointerId)}}function Es(i,u,m,w,S,T){return i===null||i.nativeEvent!==T?(i={blockedOn:u,domEventName:m,eventSystemFlags:w,nativeEvent:T,targetContainers:[S]},u!==null&&(u=Zi(u),u!==null&&ma(u)),i):(i.eventSystemFlags|=w,u=i.targetContainers,S!==null&&u.indexOf(S)===-1&&u.push(S),i)}function Ph(i,u,m,w,S){switch(u){case"focusin":return Sr=Es(Sr,i,u,m,w,S),!0;case"dragenter":return _r=Es(_r,i,u,m,w,S),!0;case"mouseover":return Rn=Es(Rn,i,u,m,w,S),!0;case"pointerover":var T=S.pointerId;return ga.set(T,Es(ga.get(T)||null,i,u,m,w,S)),!0;case"gotpointercapture":return T=S.pointerId,_s.set(T,Es(_s.get(T)||null,i,u,m,w,S)),!0}return!1}function Ec(i){var u=ka(i.target);if(u!==null){var m=Gt(u);if(m!==null){if(u=m.tag,u===13){if(u=bs(m),u!==null){i.blockedOn=u,lo(i.priority,function(){jc(m)});return}}else if(u===3&&m.stateNode.current.memoizedState.isDehydrated){i.blockedOn=m.tag===3?m.stateNode.containerInfo:null;return}}}i.blockedOn=null}function ya(i){if(i.blockedOn!==null)return!1;for(var u=i.targetContainers;0<u.length;){var m=ho(i.domEventName,i.eventSystemFlags,u[0],i.nativeEvent);if(m===null){m=i.nativeEvent;var w=new m.constructor(m.type,m);st=w,m.target.dispatchEvent(w),st=null}else return u=Zi(m),u!==null&&ma(u),i.blockedOn=m,!1;u.shift()}return!0}function Ts(i,u,m){ya(i)&&m.delete(u)}function Pi(){co=!1,Sr!==null&&ya(Sr)&&(Sr=null),_r!==null&&ya(_r)&&(_r=null),Rn!==null&&ya(Rn)&&(Rn=null),ga.forEach(Ts),_s.forEach(Ts)}function wn(i,u){i.blockedOn===u&&(i.blockedOn=null,co||(co=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Pi)))}function Cs(i){function u(S){return wn(S,i)}if(0<uo.length){wn(uo[0],i);for(var m=1;m<uo.length;m++){var w=uo[m];w.blockedOn===i&&(w.blockedOn=null)}}for(Sr!==null&&wn(Sr,i),_r!==null&&wn(_r,i),Rn!==null&&wn(Rn,i),ga.forEach(u),_s.forEach(u),m=0;m<Er.length;m++)w=Er[m],w.blockedOn===i&&(w.blockedOn=null);for(;0<Er.length&&(m=Er[0],m.blockedOn===null);)Ec(m),m.blockedOn===null&&Er.shift()}var Xr=E.ReactCurrentBatchConfig,wa=!0;function Tc(i,u,m,w){var S=Ye,T=Xr.transition;Xr.transition=null;try{Ye=1,Fi(i,u,m,w)}finally{Ye=S,Xr.transition=T}}function Di(i,u,m,w){var S=Ye,T=Xr.transition;Xr.transition=null;try{Ye=4,Fi(i,u,m,w)}finally{Ye=S,Xr.transition=T}}function Fi(i,u,m,w){if(wa){var S=ho(i,u,m,w);if(S===null)Zh(i,u,w,As,m),_c(i,w);else if(Ph(S,i,u,m,w))w.stopPropagation();else if(_c(i,w),u&4&&-1<Lh.indexOf(i)){for(;S!==null;){var T=Zi(S);if(T!==null&&Li(T),T=ho(i,u,m,w),T===null&&Zh(i,u,w,As,m),T===S)break;S=T}S!==null&&w.stopPropagation()}else Zh(i,u,w,null,m)}}var As=null;function ho(i,u,m,w){if(As=null,i=zt(w),i=ka(i),i!==null)if(u=Gt(i),u===null)i=null;else if(m=u.tag,m===13){if(i=bs(u),i!==null)return i;i=null}else if(m===3){if(u.stateNode.current.memoizedState.isDehydrated)return u.tag===3?u.stateNode.containerInfo:null;i=null}else u!==i&&(i=null);return As=i,null}function Bi(i){switch(i){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Kr()){case ks:return 1;case kr:return 4;case Kn:case Yr:return 16;case ao:return 536870912;default:return 16}default:return 16}}var Tr=null,qi=null,Rs=null;function va(){if(Rs)return Rs;var i,u=qi,m=u.length,w,S="value"in Tr?Tr.value:Tr.textContent,T=S.length;for(i=0;i<m&&u[i]===S[i];i++);var z=m-i;for(w=1;w<=z&&u[m-w]===S[T-w];w++);return Rs=S.slice(i,1<w?1-w:void 0)}function fo(i){var u=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&u===13&&(i=13)):i=u,i===10&&(i=13),32<=i||i===13?i:0}function Cr(){return!0}function Cc(){return!1}function Qt(i){function u(m,w,S,T,z){this._reactName=m,this._targetInst=S,this.type=w,this.nativeEvent=T,this.target=z,this.currentTarget=null;for(var Q in i)i.hasOwnProperty(Q)&&(m=i[Q],this[Q]=m?m(T):T[Q]);return this.isDefaultPrevented=(T.defaultPrevented!=null?T.defaultPrevented:T.returnValue===!1)?Cr:Cc,this.isPropagationStopped=Cc,this}return H(u.prototype,{preventDefault:function(){this.defaultPrevented=!0;var m=this.nativeEvent;m&&(m.preventDefault?m.preventDefault():typeof m.returnValue!="unknown"&&(m.returnValue=!1),this.isDefaultPrevented=Cr)},stopPropagation:function(){var m=this.nativeEvent;m&&(m.stopPropagation?m.stopPropagation():typeof m.cancelBubble!="unknown"&&(m.cancelBubble=!0),this.isPropagationStopped=Cr)},persist:function(){},isPersistent:Cr}),u}var Ms={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},po=Qt(Ms),xa=H({},Ms,{view:0,detail:0}),Dh=Qt(xa),mo,Zr,$s,Is=H({},xa,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Bh,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==$s&&($s&&i.type==="mousemove"?(mo=i.screenX-$s.screenX,Zr=i.screenY-$s.screenY):Zr=mo=0,$s=i),mo)},movementY:function(i){return"movementY"in i?i.movementY:Zr}}),Ac=Qt(Is),ba=H({},Is,{dataTransfer:0}),NP=Qt(ba),jP=H({},xa,{relatedTarget:0}),Fh=Qt(jP),SP=H({},Ms,{animationName:0,elapsedTime:0,pseudoElement:0}),_P=Qt(SP),EP=H({},Ms,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),TP=Qt(EP),CP=H({},Ms,{data:0}),nk=Qt(CP),AP={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},RP={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},MP={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function $P(i){var u=this.nativeEvent;return u.getModifierState?u.getModifierState(i):(i=MP[i])?!!u[i]:!1}function Bh(){return $P}var IP=H({},xa,{key:function(i){if(i.key){var u=AP[i.key]||i.key;if(u!=="Unidentified")return u}return i.type==="keypress"?(i=fo(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?RP[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Bh,charCode:function(i){return i.type==="keypress"?fo(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?fo(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),OP=Qt(IP),LP=H({},Is,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),rk=Qt(LP),PP=H({},xa,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Bh}),DP=Qt(PP),FP=H({},Ms,{propertyName:0,elapsedTime:0,pseudoElement:0}),BP=Qt(FP),qP=H({},Is,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),UP=Qt(qP),zP=[9,13,27,32],qh=c&&"CompositionEvent"in window,Ui=null;c&&"documentMode"in document&&(Ui=document.documentMode);var WP=c&&"TextEvent"in window&&!Ui,sk=c&&(!qh||Ui&&8<Ui&&11>=Ui),ak=" ",ok=!1;function ik(i,u){switch(i){case"keyup":return zP.indexOf(u.keyCode)!==-1;case"keydown":return u.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lk(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var go=!1;function HP(i,u){switch(i){case"compositionend":return lk(u);case"keypress":return u.which!==32?null:(ok=!0,ak);case"textInput":return i=u.data,i===ak&&ok?null:i;default:return null}}function VP(i,u){if(go)return i==="compositionend"||!qh&&ik(i,u)?(i=va(),Rs=qi=Tr=null,go=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(u.ctrlKey||u.altKey||u.metaKey)||u.ctrlKey&&u.altKey){if(u.char&&1<u.char.length)return u.char;if(u.which)return String.fromCharCode(u.which)}return null;case"compositionend":return sk&&u.locale!=="ko"?null:u.data;default:return null}}var GP={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function ck(i){var u=i&&i.nodeName&&i.nodeName.toLowerCase();return u==="input"?!!GP[i.type]:u==="textarea"}function uk(i,u,m,w){vs(w),u=Oc(u,"onChange"),0<u.length&&(m=new po("onChange","change",null,m,w),i.push({event:m,listeners:u}))}var zi=null,Wi=null;function KP(i){Tk(i,0)}function Rc(i){var u=bo(i);if(ke(u))return i}function YP(i,u){if(i==="change")return u}var dk=!1;if(c){var Uh;if(c){var zh="oninput"in document;if(!zh){var hk=document.createElement("div");hk.setAttribute("oninput","return;"),zh=typeof hk.oninput=="function"}Uh=zh}else Uh=!1;dk=Uh&&(!document.documentMode||9<document.documentMode)}function fk(){zi&&(zi.detachEvent("onpropertychange",pk),Wi=zi=null)}function pk(i){if(i.propertyName==="value"&&Rc(Wi)){var u=[];uk(u,Wi,i,zt(i)),Wr(KP,u)}}function XP(i,u,m){i==="focusin"?(fk(),zi=u,Wi=m,zi.attachEvent("onpropertychange",pk)):i==="focusout"&&fk()}function ZP(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Rc(Wi)}function JP(i,u){if(i==="click")return Rc(u)}function QP(i,u){if(i==="input"||i==="change")return Rc(u)}function e3(i,u){return i===u&&(i!==0||1/i===1/u)||i!==i&&u!==u}var Xn=typeof Object.is=="function"?Object.is:e3;function Hi(i,u){if(Xn(i,u))return!0;if(typeof i!="object"||i===null||typeof u!="object"||u===null)return!1;var m=Object.keys(i),w=Object.keys(u);if(m.length!==w.length)return!1;for(w=0;w<m.length;w++){var S=m[w];if(!d.call(u,S)||!Xn(i[S],u[S]))return!1}return!0}function mk(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function gk(i,u){var m=mk(i);i=0;for(var w;m;){if(m.nodeType===3){if(w=i+m.textContent.length,i<=u&&w>=u)return{node:m,offset:u-i};i=w}e:{for(;m;){if(m.nextSibling){m=m.nextSibling;break e}m=m.parentNode}m=void 0}m=mk(m)}}function yk(i,u){return i&&u?i===u?!0:i&&i.nodeType===3?!1:u&&u.nodeType===3?yk(i,u.parentNode):"contains"in i?i.contains(u):i.compareDocumentPosition?!!(i.compareDocumentPosition(u)&16):!1:!1}function wk(){for(var i=window,u=ae();u instanceof i.HTMLIFrameElement;){try{var m=typeof u.contentWindow.location.href=="string"}catch{m=!1}if(m)i=u.contentWindow;else break;u=ae(i.document)}return u}function Wh(i){var u=i&&i.nodeName&&i.nodeName.toLowerCase();return u&&(u==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||u==="textarea"||i.contentEditable==="true")}function t3(i){var u=wk(),m=i.focusedElem,w=i.selectionRange;if(u!==m&&m&&m.ownerDocument&&yk(m.ownerDocument.documentElement,m)){if(w!==null&&Wh(m)){if(u=w.start,i=w.end,i===void 0&&(i=u),"selectionStart"in m)m.selectionStart=u,m.selectionEnd=Math.min(i,m.value.length);else if(i=(u=m.ownerDocument||document)&&u.defaultView||window,i.getSelection){i=i.getSelection();var S=m.textContent.length,T=Math.min(w.start,S);w=w.end===void 0?T:Math.min(w.end,S),!i.extend&&T>w&&(S=w,w=T,T=S),S=gk(m,T);var z=gk(m,w);S&&z&&(i.rangeCount!==1||i.anchorNode!==S.node||i.anchorOffset!==S.offset||i.focusNode!==z.node||i.focusOffset!==z.offset)&&(u=u.createRange(),u.setStart(S.node,S.offset),i.removeAllRanges(),T>w?(i.addRange(u),i.extend(z.node,z.offset)):(u.setEnd(z.node,z.offset),i.addRange(u)))}}for(u=[],i=m;i=i.parentNode;)i.nodeType===1&&u.push({element:i,left:i.scrollLeft,top:i.scrollTop});for(typeof m.focus=="function"&&m.focus(),m=0;m<u.length;m++)i=u[m],i.element.scrollLeft=i.left,i.element.scrollTop=i.top}}var n3=c&&"documentMode"in document&&11>=document.documentMode,yo=null,Hh=null,Vi=null,Vh=!1;function vk(i,u,m){var w=m.window===m?m.document:m.nodeType===9?m:m.ownerDocument;Vh||yo==null||yo!==ae(w)||(w=yo,"selectionStart"in w&&Wh(w)?w={start:w.selectionStart,end:w.selectionEnd}:(w=(w.ownerDocument&&w.ownerDocument.defaultView||window).getSelection(),w={anchorNode:w.anchorNode,anchorOffset:w.anchorOffset,focusNode:w.focusNode,focusOffset:w.focusOffset}),Vi&&Hi(Vi,w)||(Vi=w,w=Oc(Hh,"onSelect"),0<w.length&&(u=new po("onSelect","select",null,u,m),i.push({event:u,listeners:w}),u.target=yo)))}function Mc(i,u){var m={};return m[i.toLowerCase()]=u.toLowerCase(),m["Webkit"+i]="webkit"+u,m["Moz"+i]="moz"+u,m}var wo={animationend:Mc("Animation","AnimationEnd"),animationiteration:Mc("Animation","AnimationIteration"),animationstart:Mc("Animation","AnimationStart"),transitionend:Mc("Transition","TransitionEnd")},Gh={},xk={};c&&(xk=document.createElement("div").style,"AnimationEvent"in window||(delete wo.animationend.animation,delete wo.animationiteration.animation,delete wo.animationstart.animation),"TransitionEvent"in window||delete wo.transitionend.transition);function $c(i){if(Gh[i])return Gh[i];if(!wo[i])return i;var u=wo[i],m;for(m in u)if(u.hasOwnProperty(m)&&m in xk)return Gh[i]=u[m];return i}var bk=$c("animationend"),kk=$c("animationiteration"),Nk=$c("animationstart"),jk=$c("transitionend"),Sk=new Map,_k="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Os(i,u){Sk.set(i,u),o(u,[i])}for(var Kh=0;Kh<_k.length;Kh++){var Yh=_k[Kh],r3=Yh.toLowerCase(),s3=Yh[0].toUpperCase()+Yh.slice(1);Os(r3,"on"+s3)}Os(bk,"onAnimationEnd"),Os(kk,"onAnimationIteration"),Os(Nk,"onAnimationStart"),Os("dblclick","onDoubleClick"),Os("focusin","onFocus"),Os("focusout","onBlur"),Os(jk,"onTransitionEnd"),l("onMouseEnter",["mouseout","mouseover"]),l("onMouseLeave",["mouseout","mouseover"]),l("onPointerEnter",["pointerout","pointerover"]),l("onPointerLeave",["pointerout","pointerover"]),o("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),o("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),o("onBeforeInput",["compositionend","keypress","textInput","paste"]),o("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Gi="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),a3=new Set("cancel close invalid load scroll toggle".split(" ").concat(Gi));function Ek(i,u,m){var w=i.type||"unknown-event";i.currentTarget=m,xr(w,u,void 0,i),i.currentTarget=null}function Tk(i,u){u=(u&4)!==0;for(var m=0;m<i.length;m++){var w=i[m],S=w.event;w=w.listeners;e:{var T=void 0;if(u)for(var z=w.length-1;0<=z;z--){var Q=w[z],te=Q.instance,ce=Q.currentTarget;if(Q=Q.listener,te!==T&&S.isPropagationStopped())break e;Ek(S,Q,ce),T=te}else for(z=0;z<w.length;z++){if(Q=w[z],te=Q.instance,ce=Q.currentTarget,Q=Q.listener,te!==T&&S.isPropagationStopped())break e;Ek(S,Q,ce),T=te}}}if(wr)throw i=xt,wr=!1,xt=null,i}function at(i,u){var m=u[rf];m===void 0&&(m=u[rf]=new Set);var w=i+"__bubble";m.has(w)||(Ck(u,i,2,!1),m.add(w))}function Xh(i,u,m){var w=0;u&&(w|=4),Ck(m,i,w,u)}var Ic="_reactListening"+Math.random().toString(36).slice(2);function Ki(i){if(!i[Ic]){i[Ic]=!0,r.forEach(function(m){m!=="selectionchange"&&(a3.has(m)||Xh(m,!1,i),Xh(m,!0,i))});var u=i.nodeType===9?i:i.ownerDocument;u===null||u[Ic]||(u[Ic]=!0,Xh("selectionchange",!1,u))}}function Ck(i,u,m,w){switch(Bi(u)){case 1:var S=Tc;break;case 4:S=Di;break;default:S=Fi}m=S.bind(null,u,m,i),S=void 0,!Hr||u!=="touchstart"&&u!=="touchmove"&&u!=="wheel"||(S=!0),w?S!==void 0?i.addEventListener(u,m,{capture:!0,passive:S}):i.addEventListener(u,m,!0):S!==void 0?i.addEventListener(u,m,{passive:S}):i.addEventListener(u,m,!1)}function Zh(i,u,m,w,S){var T=w;if((u&1)===0&&(u&2)===0&&w!==null)e:for(;;){if(w===null)return;var z=w.tag;if(z===3||z===4){var Q=w.stateNode.containerInfo;if(Q===S||Q.nodeType===8&&Q.parentNode===S)break;if(z===4)for(z=w.return;z!==null;){var te=z.tag;if((te===3||te===4)&&(te=z.stateNode.containerInfo,te===S||te.nodeType===8&&te.parentNode===S))return;z=z.return}for(;Q!==null;){if(z=ka(Q),z===null)return;if(te=z.tag,te===5||te===6){w=T=z;continue e}Q=Q.parentNode}}w=w.return}Wr(function(){var ce=T,ve=zt(m),xe=[];e:{var we=Sk.get(i);if(we!==void 0){var Se=po,Ee=i;switch(i){case"keypress":if(fo(m)===0)break e;case"keydown":case"keyup":Se=OP;break;case"focusin":Ee="focus",Se=Fh;break;case"focusout":Ee="blur",Se=Fh;break;case"beforeblur":case"afterblur":Se=Fh;break;case"click":if(m.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Se=Ac;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Se=NP;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Se=DP;break;case bk:case kk:case Nk:Se=_P;break;case jk:Se=BP;break;case"scroll":Se=Dh;break;case"wheel":Se=UP;break;case"copy":case"cut":case"paste":Se=TP;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Se=rk}var Te=(u&4)!==0,vt=!Te&&i==="scroll",ie=Te?we!==null?we+"Capture":null:we;Te=[];for(var re=ce,le;re!==null;){le=re;var Ne=le.stateNode;if(le.tag===5&&Ne!==null&&(le=Ne,ie!==null&&(Ne=mn(re,ie),Ne!=null&&Te.push(Yi(re,Ne,le)))),vt)break;re=re.return}0<Te.length&&(we=new Se(we,Ee,null,m,ve),xe.push({event:we,listeners:Te}))}}if((u&7)===0){e:{if(we=i==="mouseover"||i==="pointerover",Se=i==="mouseout"||i==="pointerout",we&&m!==st&&(Ee=m.relatedTarget||m.fromElement)&&(ka(Ee)||Ee[Jr]))break e;if((Se||we)&&(we=ve.window===ve?ve:(we=ve.ownerDocument)?we.defaultView||we.parentWindow:window,Se?(Ee=m.relatedTarget||m.toElement,Se=ce,Ee=Ee?ka(Ee):null,Ee!==null&&(vt=Gt(Ee),Ee!==vt||Ee.tag!==5&&Ee.tag!==6)&&(Ee=null)):(Se=null,Ee=ce),Se!==Ee)){if(Te=Ac,Ne="onMouseLeave",ie="onMouseEnter",re="mouse",(i==="pointerout"||i==="pointerover")&&(Te=rk,Ne="onPointerLeave",ie="onPointerEnter",re="pointer"),vt=Se==null?we:bo(Se),le=Ee==null?we:bo(Ee),we=new Te(Ne,re+"leave",Se,m,ve),we.target=vt,we.relatedTarget=le,Ne=null,ka(ve)===ce&&(Te=new Te(ie,re+"enter",Ee,m,ve),Te.target=le,Te.relatedTarget=vt,Ne=Te),vt=Ne,Se&&Ee)t:{for(Te=Se,ie=Ee,re=0,le=Te;le;le=vo(le))re++;for(le=0,Ne=ie;Ne;Ne=vo(Ne))le++;for(;0<re-le;)Te=vo(Te),re--;for(;0<le-re;)ie=vo(ie),le--;for(;re--;){if(Te===ie||ie!==null&&Te===ie.alternate)break t;Te=vo(Te),ie=vo(ie)}Te=null}else Te=null;Se!==null&&Ak(xe,we,Se,Te,!1),Ee!==null&&vt!==null&&Ak(xe,vt,Ee,Te,!0)}}e:{if(we=ce?bo(ce):window,Se=we.nodeName&&we.nodeName.toLowerCase(),Se==="select"||Se==="input"&&we.type==="file")var Ce=YP;else if(ck(we))if(dk)Ce=QP;else{Ce=ZP;var Re=XP}else(Se=we.nodeName)&&Se.toLowerCase()==="input"&&(we.type==="checkbox"||we.type==="radio")&&(Ce=JP);if(Ce&&(Ce=Ce(i,ce))){uk(xe,Ce,m,ve);break e}Re&&Re(i,we,ce),i==="focusout"&&(Re=we._wrapperState)&&Re.controlled&&we.type==="number"&&be(we,"number",we.value)}switch(Re=ce?bo(ce):window,i){case"focusin":(ck(Re)||Re.contentEditable==="true")&&(yo=Re,Hh=ce,Vi=null);break;case"focusout":Vi=Hh=yo=null;break;case"mousedown":Vh=!0;break;case"contextmenu":case"mouseup":case"dragend":Vh=!1,vk(xe,m,ve);break;case"selectionchange":if(n3)break;case"keydown":case"keyup":vk(xe,m,ve)}var Me;if(qh)e:{switch(i){case"compositionstart":var Ie="onCompositionStart";break e;case"compositionend":Ie="onCompositionEnd";break e;case"compositionupdate":Ie="onCompositionUpdate";break e}Ie=void 0}else go?ik(i,m)&&(Ie="onCompositionEnd"):i==="keydown"&&m.keyCode===229&&(Ie="onCompositionStart");Ie&&(sk&&m.locale!=="ko"&&(go||Ie!=="onCompositionStart"?Ie==="onCompositionEnd"&&go&&(Me=va()):(Tr=ve,qi="value"in Tr?Tr.value:Tr.textContent,go=!0)),Re=Oc(ce,Ie),0<Re.length&&(Ie=new nk(Ie,i,null,m,ve),xe.push({event:Ie,listeners:Re}),Me?Ie.data=Me:(Me=lk(m),Me!==null&&(Ie.data=Me)))),(Me=WP?HP(i,m):VP(i,m))&&(ce=Oc(ce,"onBeforeInput"),0<ce.length&&(ve=new nk("onBeforeInput","beforeinput",null,m,ve),xe.push({event:ve,listeners:ce}),ve.data=Me))}Tk(xe,u)})}function Yi(i,u,m){return{instance:i,listener:u,currentTarget:m}}function Oc(i,u){for(var m=u+"Capture",w=[];i!==null;){var S=i,T=S.stateNode;S.tag===5&&T!==null&&(S=T,T=mn(i,m),T!=null&&w.unshift(Yi(i,T,S)),T=mn(i,u),T!=null&&w.push(Yi(i,T,S))),i=i.return}return w}function vo(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function Ak(i,u,m,w,S){for(var T=u._reactName,z=[];m!==null&&m!==w;){var Q=m,te=Q.alternate,ce=Q.stateNode;if(te!==null&&te===w)break;Q.tag===5&&ce!==null&&(Q=ce,S?(te=mn(m,T),te!=null&&z.unshift(Yi(m,te,Q))):S||(te=mn(m,T),te!=null&&z.push(Yi(m,te,Q)))),m=m.return}z.length!==0&&i.push({event:u,listeners:z})}var o3=/\r\n?/g,i3=/\u0000|\uFFFD/g;function Rk(i){return(typeof i=="string"?i:""+i).replace(o3,`
38
- `).replace(i3,"")}function Lc(i,u,m){if(u=Rk(u),Rk(i)!==u&&m)throw Error(n(425))}function Pc(){}var Jh=null,Qh=null;function ef(i,u){return i==="textarea"||i==="noscript"||typeof u.children=="string"||typeof u.children=="number"||typeof u.dangerouslySetInnerHTML=="object"&&u.dangerouslySetInnerHTML!==null&&u.dangerouslySetInnerHTML.__html!=null}var tf=typeof setTimeout=="function"?setTimeout:void 0,l3=typeof clearTimeout=="function"?clearTimeout:void 0,Mk=typeof Promise=="function"?Promise:void 0,c3=typeof queueMicrotask=="function"?queueMicrotask:typeof Mk<"u"?function(i){return Mk.resolve(null).then(i).catch(u3)}:tf;function u3(i){setTimeout(function(){throw i})}function nf(i,u){var m=u,w=0;do{var S=m.nextSibling;if(i.removeChild(m),S&&S.nodeType===8)if(m=S.data,m==="/$"){if(w===0){i.removeChild(S),Cs(u);return}w--}else m!=="$"&&m!=="$?"&&m!=="$!"||w++;m=S}while(m);Cs(u)}function Ls(i){for(;i!=null;i=i.nextSibling){var u=i.nodeType;if(u===1||u===3)break;if(u===8){if(u=i.data,u==="$"||u==="$!"||u==="$?")break;if(u==="/$")return null}}return i}function $k(i){i=i.previousSibling;for(var u=0;i;){if(i.nodeType===8){var m=i.data;if(m==="$"||m==="$!"||m==="$?"){if(u===0)return i;u--}else m==="/$"&&u++}i=i.previousSibling}return null}var xo=Math.random().toString(36).slice(2),Ar="__reactFiber$"+xo,Xi="__reactProps$"+xo,Jr="__reactContainer$"+xo,rf="__reactEvents$"+xo,d3="__reactListeners$"+xo,h3="__reactHandles$"+xo;function ka(i){var u=i[Ar];if(u)return u;for(var m=i.parentNode;m;){if(u=m[Jr]||m[Ar]){if(m=u.alternate,u.child!==null||m!==null&&m.child!==null)for(i=$k(i);i!==null;){if(m=i[Ar])return m;i=$k(i)}return u}i=m,m=i.parentNode}return null}function Zi(i){return i=i[Ar]||i[Jr],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function bo(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(n(33))}function Dc(i){return i[Xi]||null}var sf=[],ko=-1;function Ps(i){return{current:i}}function ot(i){0>ko||(i.current=sf[ko],sf[ko]=null,ko--)}function nt(i,u){ko++,sf[ko]=i.current,i.current=u}var Ds={},Kt=Ps(Ds),sn=Ps(!1),Na=Ds;function No(i,u){var m=i.type.contextTypes;if(!m)return Ds;var w=i.stateNode;if(w&&w.__reactInternalMemoizedUnmaskedChildContext===u)return w.__reactInternalMemoizedMaskedChildContext;var S={},T;for(T in m)S[T]=u[T];return w&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=u,i.__reactInternalMemoizedMaskedChildContext=S),S}function an(i){return i=i.childContextTypes,i!=null}function Fc(){ot(sn),ot(Kt)}function Ik(i,u,m){if(Kt.current!==Ds)throw Error(n(168));nt(Kt,u),nt(sn,m)}function Ok(i,u,m){var w=i.stateNode;if(u=u.childContextTypes,typeof w.getChildContext!="function")return m;w=w.getChildContext();for(var S in w)if(!(S in u))throw Error(n(108,Z(i)||"Unknown",S));return H({},m,w)}function Bc(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||Ds,Na=Kt.current,nt(Kt,i),nt(sn,sn.current),!0}function Lk(i,u,m){var w=i.stateNode;if(!w)throw Error(n(169));m?(i=Ok(i,u,Na),w.__reactInternalMemoizedMergedChildContext=i,ot(sn),ot(Kt),nt(Kt,i)):ot(sn),nt(sn,m)}var Qr=null,qc=!1,af=!1;function Pk(i){Qr===null?Qr=[i]:Qr.push(i)}function f3(i){qc=!0,Pk(i)}function Fs(){if(!af&&Qr!==null){af=!0;var i=0,u=Ye;try{var m=Qr;for(Ye=1;i<m.length;i++){var w=m[i];do w=w(!0);while(w!==null)}Qr=null,qc=!1}catch(S){throw Qr!==null&&(Qr=Qr.slice(i+1)),rn(ks,Fs),S}finally{Ye=u,af=!1}}return null}var jo=[],So=0,Uc=null,zc=0,Mn=[],$n=0,ja=null,es=1,ts="";function Sa(i,u){jo[So++]=zc,jo[So++]=Uc,Uc=i,zc=u}function Dk(i,u,m){Mn[$n++]=es,Mn[$n++]=ts,Mn[$n++]=ja,ja=i;var w=es;i=ts;var S=32-yn(w)-1;w&=~(1<<S),m+=1;var T=32-yn(u)+S;if(30<T){var z=S-S%5;T=(w&(1<<z)-1).toString(32),w>>=z,S-=z,es=1<<32-yn(u)+S|m<<S|w,ts=T+i}else es=1<<T|m<<S|w,ts=i}function of(i){i.return!==null&&(Sa(i,1),Dk(i,1,0))}function lf(i){for(;i===Uc;)Uc=jo[--So],jo[So]=null,zc=jo[--So],jo[So]=null;for(;i===ja;)ja=Mn[--$n],Mn[$n]=null,ts=Mn[--$n],Mn[$n]=null,es=Mn[--$n],Mn[$n]=null}var vn=null,xn=null,ct=!1,Zn=null;function Fk(i,u){var m=Pn(5,null,null,0);m.elementType="DELETED",m.stateNode=u,m.return=i,u=i.deletions,u===null?(i.deletions=[m],i.flags|=16):u.push(m)}function Bk(i,u){switch(i.tag){case 5:var m=i.type;return u=u.nodeType!==1||m.toLowerCase()!==u.nodeName.toLowerCase()?null:u,u!==null?(i.stateNode=u,vn=i,xn=Ls(u.firstChild),!0):!1;case 6:return u=i.pendingProps===""||u.nodeType!==3?null:u,u!==null?(i.stateNode=u,vn=i,xn=null,!0):!1;case 13:return u=u.nodeType!==8?null:u,u!==null?(m=ja!==null?{id:es,overflow:ts}:null,i.memoizedState={dehydrated:u,treeContext:m,retryLane:1073741824},m=Pn(18,null,null,0),m.stateNode=u,m.return=i,i.child=m,vn=i,xn=null,!0):!1;default:return!1}}function cf(i){return(i.mode&1)!==0&&(i.flags&128)===0}function uf(i){if(ct){var u=xn;if(u){var m=u;if(!Bk(i,u)){if(cf(i))throw Error(n(418));u=Ls(m.nextSibling);var w=vn;u&&Bk(i,u)?Fk(w,m):(i.flags=i.flags&-4097|2,ct=!1,vn=i)}}else{if(cf(i))throw Error(n(418));i.flags=i.flags&-4097|2,ct=!1,vn=i}}}function qk(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;vn=i}function Wc(i){if(i!==vn)return!1;if(!ct)return qk(i),ct=!0,!1;var u;if((u=i.tag!==3)&&!(u=i.tag!==5)&&(u=i.type,u=u!=="head"&&u!=="body"&&!ef(i.type,i.memoizedProps)),u&&(u=xn)){if(cf(i))throw Uk(),Error(n(418));for(;u;)Fk(i,u),u=Ls(u.nextSibling)}if(qk(i),i.tag===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(317));e:{for(i=i.nextSibling,u=0;i;){if(i.nodeType===8){var m=i.data;if(m==="/$"){if(u===0){xn=Ls(i.nextSibling);break e}u--}else m!=="$"&&m!=="$!"&&m!=="$?"||u++}i=i.nextSibling}xn=null}}else xn=vn?Ls(i.stateNode.nextSibling):null;return!0}function Uk(){for(var i=xn;i;)i=Ls(i.nextSibling)}function _o(){xn=vn=null,ct=!1}function df(i){Zn===null?Zn=[i]:Zn.push(i)}var p3=E.ReactCurrentBatchConfig;function Ji(i,u,m){if(i=m.ref,i!==null&&typeof i!="function"&&typeof i!="object"){if(m._owner){if(m=m._owner,m){if(m.tag!==1)throw Error(n(309));var w=m.stateNode}if(!w)throw Error(n(147,i));var S=w,T=""+i;return u!==null&&u.ref!==null&&typeof u.ref=="function"&&u.ref._stringRef===T?u.ref:(u=function(z){var Q=S.refs;z===null?delete Q[T]:Q[T]=z},u._stringRef=T,u)}if(typeof i!="string")throw Error(n(284));if(!m._owner)throw Error(n(290,i))}return i}function Hc(i,u){throw i=Object.prototype.toString.call(u),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(u).join(", ")+"}":i))}function zk(i){var u=i._init;return u(i._payload)}function Wk(i){function u(ie,re){if(i){var le=ie.deletions;le===null?(ie.deletions=[re],ie.flags|=16):le.push(re)}}function m(ie,re){if(!i)return null;for(;re!==null;)u(ie,re),re=re.sibling;return null}function w(ie,re){for(ie=new Map;re!==null;)re.key!==null?ie.set(re.key,re):ie.set(re.index,re),re=re.sibling;return ie}function S(ie,re){return ie=Gs(ie,re),ie.index=0,ie.sibling=null,ie}function T(ie,re,le){return ie.index=le,i?(le=ie.alternate,le!==null?(le=le.index,le<re?(ie.flags|=2,re):le):(ie.flags|=2,re)):(ie.flags|=1048576,re)}function z(ie){return i&&ie.alternate===null&&(ie.flags|=2),ie}function Q(ie,re,le,Ne){return re===null||re.tag!==6?(re=np(le,ie.mode,Ne),re.return=ie,re):(re=S(re,le),re.return=ie,re)}function te(ie,re,le,Ne){var Ce=le.type;return Ce===A?ve(ie,re,le.props.children,Ne,le.key):re!==null&&(re.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===P&&zk(Ce)===re.type)?(Ne=S(re,le.props),Ne.ref=Ji(ie,re,le),Ne.return=ie,Ne):(Ne=mu(le.type,le.key,le.props,null,ie.mode,Ne),Ne.ref=Ji(ie,re,le),Ne.return=ie,Ne)}function ce(ie,re,le,Ne){return re===null||re.tag!==4||re.stateNode.containerInfo!==le.containerInfo||re.stateNode.implementation!==le.implementation?(re=rp(le,ie.mode,Ne),re.return=ie,re):(re=S(re,le.children||[]),re.return=ie,re)}function ve(ie,re,le,Ne,Ce){return re===null||re.tag!==7?(re=$a(le,ie.mode,Ne,Ce),re.return=ie,re):(re=S(re,le),re.return=ie,re)}function xe(ie,re,le){if(typeof re=="string"&&re!==""||typeof re=="number")return re=np(""+re,ie.mode,le),re.return=ie,re;if(typeof re=="object"&&re!==null){switch(re.$$typeof){case R:return le=mu(re.type,re.key,re.props,null,ie.mode,le),le.ref=Ji(ie,null,re),le.return=ie,le;case C:return re=rp(re,ie.mode,le),re.return=ie,re;case P:var Ne=re._init;return xe(ie,Ne(re._payload),le)}if(oe(re)||q(re))return re=$a(re,ie.mode,le,null),re.return=ie,re;Hc(ie,re)}return null}function we(ie,re,le,Ne){var Ce=re!==null?re.key:null;if(typeof le=="string"&&le!==""||typeof le=="number")return Ce!==null?null:Q(ie,re,""+le,Ne);if(typeof le=="object"&&le!==null){switch(le.$$typeof){case R:return le.key===Ce?te(ie,re,le,Ne):null;case C:return le.key===Ce?ce(ie,re,le,Ne):null;case P:return Ce=le._init,we(ie,re,Ce(le._payload),Ne)}if(oe(le)||q(le))return Ce!==null?null:ve(ie,re,le,Ne,null);Hc(ie,le)}return null}function Se(ie,re,le,Ne,Ce){if(typeof Ne=="string"&&Ne!==""||typeof Ne=="number")return ie=ie.get(le)||null,Q(re,ie,""+Ne,Ce);if(typeof Ne=="object"&&Ne!==null){switch(Ne.$$typeof){case R:return ie=ie.get(Ne.key===null?le:Ne.key)||null,te(re,ie,Ne,Ce);case C:return ie=ie.get(Ne.key===null?le:Ne.key)||null,ce(re,ie,Ne,Ce);case P:var Re=Ne._init;return Se(ie,re,le,Re(Ne._payload),Ce)}if(oe(Ne)||q(Ne))return ie=ie.get(le)||null,ve(re,ie,Ne,Ce,null);Hc(re,Ne)}return null}function Ee(ie,re,le,Ne){for(var Ce=null,Re=null,Me=re,Ie=re=0,It=null;Me!==null&&Ie<le.length;Ie++){Me.index>Ie?(It=Me,Me=null):It=Me.sibling;var Ve=we(ie,Me,le[Ie],Ne);if(Ve===null){Me===null&&(Me=It);break}i&&Me&&Ve.alternate===null&&u(ie,Me),re=T(Ve,re,Ie),Re===null?Ce=Ve:Re.sibling=Ve,Re=Ve,Me=It}if(Ie===le.length)return m(ie,Me),ct&&Sa(ie,Ie),Ce;if(Me===null){for(;Ie<le.length;Ie++)Me=xe(ie,le[Ie],Ne),Me!==null&&(re=T(Me,re,Ie),Re===null?Ce=Me:Re.sibling=Me,Re=Me);return ct&&Sa(ie,Ie),Ce}for(Me=w(ie,Me);Ie<le.length;Ie++)It=Se(Me,ie,Ie,le[Ie],Ne),It!==null&&(i&&It.alternate!==null&&Me.delete(It.key===null?Ie:It.key),re=T(It,re,Ie),Re===null?Ce=It:Re.sibling=It,Re=It);return i&&Me.forEach(function(Ks){return u(ie,Ks)}),ct&&Sa(ie,Ie),Ce}function Te(ie,re,le,Ne){var Ce=q(le);if(typeof Ce!="function")throw Error(n(150));if(le=Ce.call(le),le==null)throw Error(n(151));for(var Re=Ce=null,Me=re,Ie=re=0,It=null,Ve=le.next();Me!==null&&!Ve.done;Ie++,Ve=le.next()){Me.index>Ie?(It=Me,Me=null):It=Me.sibling;var Ks=we(ie,Me,Ve.value,Ne);if(Ks===null){Me===null&&(Me=It);break}i&&Me&&Ks.alternate===null&&u(ie,Me),re=T(Ks,re,Ie),Re===null?Ce=Ks:Re.sibling=Ks,Re=Ks,Me=It}if(Ve.done)return m(ie,Me),ct&&Sa(ie,Ie),Ce;if(Me===null){for(;!Ve.done;Ie++,Ve=le.next())Ve=xe(ie,Ve.value,Ne),Ve!==null&&(re=T(Ve,re,Ie),Re===null?Ce=Ve:Re.sibling=Ve,Re=Ve);return ct&&Sa(ie,Ie),Ce}for(Me=w(ie,Me);!Ve.done;Ie++,Ve=le.next())Ve=Se(Me,ie,Ie,Ve.value,Ne),Ve!==null&&(i&&Ve.alternate!==null&&Me.delete(Ve.key===null?Ie:Ve.key),re=T(Ve,re,Ie),Re===null?Ce=Ve:Re.sibling=Ve,Re=Ve);return i&&Me.forEach(function(G3){return u(ie,G3)}),ct&&Sa(ie,Ie),Ce}function vt(ie,re,le,Ne){if(typeof le=="object"&&le!==null&&le.type===A&&le.key===null&&(le=le.props.children),typeof le=="object"&&le!==null){switch(le.$$typeof){case R:e:{for(var Ce=le.key,Re=re;Re!==null;){if(Re.key===Ce){if(Ce=le.type,Ce===A){if(Re.tag===7){m(ie,Re.sibling),re=S(Re,le.props.children),re.return=ie,ie=re;break e}}else if(Re.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===P&&zk(Ce)===Re.type){m(ie,Re.sibling),re=S(Re,le.props),re.ref=Ji(ie,Re,le),re.return=ie,ie=re;break e}m(ie,Re);break}else u(ie,Re);Re=Re.sibling}le.type===A?(re=$a(le.props.children,ie.mode,Ne,le.key),re.return=ie,ie=re):(Ne=mu(le.type,le.key,le.props,null,ie.mode,Ne),Ne.ref=Ji(ie,re,le),Ne.return=ie,ie=Ne)}return z(ie);case C:e:{for(Re=le.key;re!==null;){if(re.key===Re)if(re.tag===4&&re.stateNode.containerInfo===le.containerInfo&&re.stateNode.implementation===le.implementation){m(ie,re.sibling),re=S(re,le.children||[]),re.return=ie,ie=re;break e}else{m(ie,re);break}else u(ie,re);re=re.sibling}re=rp(le,ie.mode,Ne),re.return=ie,ie=re}return z(ie);case P:return Re=le._init,vt(ie,re,Re(le._payload),Ne)}if(oe(le))return Ee(ie,re,le,Ne);if(q(le))return Te(ie,re,le,Ne);Hc(ie,le)}return typeof le=="string"&&le!==""||typeof le=="number"?(le=""+le,re!==null&&re.tag===6?(m(ie,re.sibling),re=S(re,le),re.return=ie,ie=re):(m(ie,re),re=np(le,ie.mode,Ne),re.return=ie,ie=re),z(ie)):m(ie,re)}return vt}var Eo=Wk(!0),Hk=Wk(!1),Vc=Ps(null),Gc=null,To=null,hf=null;function ff(){hf=To=Gc=null}function pf(i){var u=Vc.current;ot(Vc),i._currentValue=u}function mf(i,u,m){for(;i!==null;){var w=i.alternate;if((i.childLanes&u)!==u?(i.childLanes|=u,w!==null&&(w.childLanes|=u)):w!==null&&(w.childLanes&u)!==u&&(w.childLanes|=u),i===m)break;i=i.return}}function Co(i,u){Gc=i,hf=To=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&u)!==0&&(on=!0),i.firstContext=null)}function In(i){var u=i._currentValue;if(hf!==i)if(i={context:i,memoizedValue:u,next:null},To===null){if(Gc===null)throw Error(n(308));To=i,Gc.dependencies={lanes:0,firstContext:i}}else To=To.next=i;return u}var _a=null;function gf(i){_a===null?_a=[i]:_a.push(i)}function Vk(i,u,m,w){var S=u.interleaved;return S===null?(m.next=m,gf(u)):(m.next=S.next,S.next=m),u.interleaved=m,ns(i,w)}function ns(i,u){i.lanes|=u;var m=i.alternate;for(m!==null&&(m.lanes|=u),m=i,i=i.return;i!==null;)i.childLanes|=u,m=i.alternate,m!==null&&(m.childLanes|=u),m=i,i=i.return;return m.tag===3?m.stateNode:null}var Bs=!1;function yf(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Gk(i,u){i=i.updateQueue,u.updateQueue===i&&(u.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,effects:i.effects})}function rs(i,u){return{eventTime:i,lane:u,tag:0,payload:null,callback:null,next:null}}function qs(i,u,m){var w=i.updateQueue;if(w===null)return null;if(w=w.shared,(ze&2)!==0){var S=w.pending;return S===null?u.next=u:(u.next=S.next,S.next=u),w.pending=u,ns(i,m)}return S=w.interleaved,S===null?(u.next=u,gf(w)):(u.next=S.next,S.next=u),w.interleaved=u,ns(i,m)}function Kc(i,u,m){if(u=u.updateQueue,u!==null&&(u=u.shared,(m&4194240)!==0)){var w=u.lanes;w&=i.pendingLanes,m|=w,u.lanes=m,jr(i,m)}}function Kk(i,u){var m=i.updateQueue,w=i.alternate;if(w!==null&&(w=w.updateQueue,m===w)){var S=null,T=null;if(m=m.firstBaseUpdate,m!==null){do{var z={eventTime:m.eventTime,lane:m.lane,tag:m.tag,payload:m.payload,callback:m.callback,next:null};T===null?S=T=z:T=T.next=z,m=m.next}while(m!==null);T===null?S=T=u:T=T.next=u}else S=T=u;m={baseState:w.baseState,firstBaseUpdate:S,lastBaseUpdate:T,shared:w.shared,effects:w.effects},i.updateQueue=m;return}i=m.lastBaseUpdate,i===null?m.firstBaseUpdate=u:i.next=u,m.lastBaseUpdate=u}function Yc(i,u,m,w){var S=i.updateQueue;Bs=!1;var T=S.firstBaseUpdate,z=S.lastBaseUpdate,Q=S.shared.pending;if(Q!==null){S.shared.pending=null;var te=Q,ce=te.next;te.next=null,z===null?T=ce:z.next=ce,z=te;var ve=i.alternate;ve!==null&&(ve=ve.updateQueue,Q=ve.lastBaseUpdate,Q!==z&&(Q===null?ve.firstBaseUpdate=ce:Q.next=ce,ve.lastBaseUpdate=te))}if(T!==null){var xe=S.baseState;z=0,ve=ce=te=null,Q=T;do{var we=Q.lane,Se=Q.eventTime;if((w&we)===we){ve!==null&&(ve=ve.next={eventTime:Se,lane:0,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null});e:{var Ee=i,Te=Q;switch(we=u,Se=m,Te.tag){case 1:if(Ee=Te.payload,typeof Ee=="function"){xe=Ee.call(Se,xe,we);break e}xe=Ee;break e;case 3:Ee.flags=Ee.flags&-65537|128;case 0:if(Ee=Te.payload,we=typeof Ee=="function"?Ee.call(Se,xe,we):Ee,we==null)break e;xe=H({},xe,we);break e;case 2:Bs=!0}}Q.callback!==null&&Q.lane!==0&&(i.flags|=64,we=S.effects,we===null?S.effects=[Q]:we.push(Q))}else Se={eventTime:Se,lane:we,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null},ve===null?(ce=ve=Se,te=xe):ve=ve.next=Se,z|=we;if(Q=Q.next,Q===null){if(Q=S.shared.pending,Q===null)break;we=Q,Q=we.next,we.next=null,S.lastBaseUpdate=we,S.shared.pending=null}}while(!0);if(ve===null&&(te=xe),S.baseState=te,S.firstBaseUpdate=ce,S.lastBaseUpdate=ve,u=S.shared.interleaved,u!==null){S=u;do z|=S.lane,S=S.next;while(S!==u)}else T===null&&(S.shared.lanes=0);Ca|=z,i.lanes=z,i.memoizedState=xe}}function Yk(i,u,m){if(i=u.effects,u.effects=null,i!==null)for(u=0;u<i.length;u++){var w=i[u],S=w.callback;if(S!==null){if(w.callback=null,w=m,typeof S!="function")throw Error(n(191,S));S.call(w)}}}var Qi={},Rr=Ps(Qi),el=Ps(Qi),tl=Ps(Qi);function Ea(i){if(i===Qi)throw Error(n(174));return i}function wf(i,u){switch(nt(tl,u),nt(el,i),nt(Rr,Qi),i=u.nodeType,i){case 9:case 11:u=(u=u.documentElement)?u.namespaceURI:He(null,"");break;default:i=i===8?u.parentNode:u,u=i.namespaceURI||null,i=i.tagName,u=He(u,i)}ot(Rr),nt(Rr,u)}function Ao(){ot(Rr),ot(el),ot(tl)}function Xk(i){Ea(tl.current);var u=Ea(Rr.current),m=He(u,i.type);u!==m&&(nt(el,i),nt(Rr,m))}function vf(i){el.current===i&&(ot(Rr),ot(el))}var ht=Ps(0);function Xc(i){for(var u=i;u!==null;){if(u.tag===13){var m=u.memoizedState;if(m!==null&&(m=m.dehydrated,m===null||m.data==="$?"||m.data==="$!"))return u}else if(u.tag===19&&u.memoizedProps.revealOrder!==void 0){if((u.flags&128)!==0)return u}else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===i)break;for(;u.sibling===null;){if(u.return===null||u.return===i)return null;u=u.return}u.sibling.return=u.return,u=u.sibling}return null}var xf=[];function bf(){for(var i=0;i<xf.length;i++)xf[i]._workInProgressVersionPrimary=null;xf.length=0}var Zc=E.ReactCurrentDispatcher,kf=E.ReactCurrentBatchConfig,Ta=0,ft=null,St=null,Mt=null,Jc=!1,nl=!1,rl=0,m3=0;function Yt(){throw Error(n(321))}function Nf(i,u){if(u===null)return!1;for(var m=0;m<u.length&&m<i.length;m++)if(!Xn(i[m],u[m]))return!1;return!0}function jf(i,u,m,w,S,T){if(Ta=T,ft=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,Zc.current=i===null||i.memoizedState===null?v3:x3,i=m(w,S),nl){T=0;do{if(nl=!1,rl=0,25<=T)throw Error(n(301));T+=1,Mt=St=null,u.updateQueue=null,Zc.current=b3,i=m(w,S)}while(nl)}if(Zc.current=tu,u=St!==null&&St.next!==null,Ta=0,Mt=St=ft=null,Jc=!1,u)throw Error(n(300));return i}function Sf(){var i=rl!==0;return rl=0,i}function Mr(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Mt===null?ft.memoizedState=Mt=i:Mt=Mt.next=i,Mt}function On(){if(St===null){var i=ft.alternate;i=i!==null?i.memoizedState:null}else i=St.next;var u=Mt===null?ft.memoizedState:Mt.next;if(u!==null)Mt=u,St=i;else{if(i===null)throw Error(n(310));St=i,i={memoizedState:St.memoizedState,baseState:St.baseState,baseQueue:St.baseQueue,queue:St.queue,next:null},Mt===null?ft.memoizedState=Mt=i:Mt=Mt.next=i}return Mt}function sl(i,u){return typeof u=="function"?u(i):u}function _f(i){var u=On(),m=u.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=i;var w=St,S=w.baseQueue,T=m.pending;if(T!==null){if(S!==null){var z=S.next;S.next=T.next,T.next=z}w.baseQueue=S=T,m.pending=null}if(S!==null){T=S.next,w=w.baseState;var Q=z=null,te=null,ce=T;do{var ve=ce.lane;if((Ta&ve)===ve)te!==null&&(te=te.next={lane:0,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null}),w=ce.hasEagerState?ce.eagerState:i(w,ce.action);else{var xe={lane:ve,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null};te===null?(Q=te=xe,z=w):te=te.next=xe,ft.lanes|=ve,Ca|=ve}ce=ce.next}while(ce!==null&&ce!==T);te===null?z=w:te.next=Q,Xn(w,u.memoizedState)||(on=!0),u.memoizedState=w,u.baseState=z,u.baseQueue=te,m.lastRenderedState=w}if(i=m.interleaved,i!==null){S=i;do T=S.lane,ft.lanes|=T,Ca|=T,S=S.next;while(S!==i)}else S===null&&(m.lanes=0);return[u.memoizedState,m.dispatch]}function Ef(i){var u=On(),m=u.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=i;var w=m.dispatch,S=m.pending,T=u.memoizedState;if(S!==null){m.pending=null;var z=S=S.next;do T=i(T,z.action),z=z.next;while(z!==S);Xn(T,u.memoizedState)||(on=!0),u.memoizedState=T,u.baseQueue===null&&(u.baseState=T),m.lastRenderedState=T}return[T,w]}function Zk(){}function Jk(i,u){var m=ft,w=On(),S=u(),T=!Xn(w.memoizedState,S);if(T&&(w.memoizedState=S,on=!0),w=w.queue,Tf(t1.bind(null,m,w,i),[i]),w.getSnapshot!==u||T||Mt!==null&&Mt.memoizedState.tag&1){if(m.flags|=2048,al(9,e1.bind(null,m,w,S,u),void 0,null),$t===null)throw Error(n(349));(Ta&30)!==0||Qk(m,u,S)}return S}function Qk(i,u,m){i.flags|=16384,i={getSnapshot:u,value:m},u=ft.updateQueue,u===null?(u={lastEffect:null,stores:null},ft.updateQueue=u,u.stores=[i]):(m=u.stores,m===null?u.stores=[i]:m.push(i))}function e1(i,u,m,w){u.value=m,u.getSnapshot=w,n1(u)&&r1(i)}function t1(i,u,m){return m(function(){n1(u)&&r1(i)})}function n1(i){var u=i.getSnapshot;i=i.value;try{var m=u();return!Xn(i,m)}catch{return!0}}function r1(i){var u=ns(i,1);u!==null&&tr(u,i,1,-1)}function s1(i){var u=Mr();return typeof i=="function"&&(i=i()),u.memoizedState=u.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:sl,lastRenderedState:i},u.queue=i,i=i.dispatch=w3.bind(null,ft,i),[u.memoizedState,i]}function al(i,u,m,w){return i={tag:i,create:u,destroy:m,deps:w,next:null},u=ft.updateQueue,u===null?(u={lastEffect:null,stores:null},ft.updateQueue=u,u.lastEffect=i.next=i):(m=u.lastEffect,m===null?u.lastEffect=i.next=i:(w=m.next,m.next=i,i.next=w,u.lastEffect=i)),i}function a1(){return On().memoizedState}function Qc(i,u,m,w){var S=Mr();ft.flags|=i,S.memoizedState=al(1|u,m,void 0,w===void 0?null:w)}function eu(i,u,m,w){var S=On();w=w===void 0?null:w;var T=void 0;if(St!==null){var z=St.memoizedState;if(T=z.destroy,w!==null&&Nf(w,z.deps)){S.memoizedState=al(u,m,T,w);return}}ft.flags|=i,S.memoizedState=al(1|u,m,T,w)}function o1(i,u){return Qc(8390656,8,i,u)}function Tf(i,u){return eu(2048,8,i,u)}function i1(i,u){return eu(4,2,i,u)}function l1(i,u){return eu(4,4,i,u)}function c1(i,u){if(typeof u=="function")return i=i(),u(i),function(){u(null)};if(u!=null)return i=i(),u.current=i,function(){u.current=null}}function u1(i,u,m){return m=m!=null?m.concat([i]):null,eu(4,4,c1.bind(null,u,i),m)}function Cf(){}function d1(i,u){var m=On();u=u===void 0?null:u;var w=m.memoizedState;return w!==null&&u!==null&&Nf(u,w[1])?w[0]:(m.memoizedState=[i,u],i)}function h1(i,u){var m=On();u=u===void 0?null:u;var w=m.memoizedState;return w!==null&&u!==null&&Nf(u,w[1])?w[0]:(i=i(),m.memoizedState=[i,u],i)}function f1(i,u,m){return(Ta&21)===0?(i.baseState&&(i.baseState=!1,on=!0),i.memoizedState=m):(Xn(m,u)||(m=kc(),ft.lanes|=m,Ca|=m,i.baseState=!0),u)}function g3(i,u){var m=Ye;Ye=m!==0&&4>m?m:4,i(!0);var w=kf.transition;kf.transition={};try{i(!1),u()}finally{Ye=m,kf.transition=w}}function p1(){return On().memoizedState}function y3(i,u,m){var w=Hs(i);if(m={lane:w,action:m,hasEagerState:!1,eagerState:null,next:null},m1(i))g1(u,m);else if(m=Vk(i,u,m,w),m!==null){var S=tn();tr(m,i,w,S),y1(m,u,w)}}function w3(i,u,m){var w=Hs(i),S={lane:w,action:m,hasEagerState:!1,eagerState:null,next:null};if(m1(i))g1(u,S);else{var T=i.alternate;if(i.lanes===0&&(T===null||T.lanes===0)&&(T=u.lastRenderedReducer,T!==null))try{var z=u.lastRenderedState,Q=T(z,m);if(S.hasEagerState=!0,S.eagerState=Q,Xn(Q,z)){var te=u.interleaved;te===null?(S.next=S,gf(u)):(S.next=te.next,te.next=S),u.interleaved=S;return}}catch{}finally{}m=Vk(i,u,S,w),m!==null&&(S=tn(),tr(m,i,w,S),y1(m,u,w))}}function m1(i){var u=i.alternate;return i===ft||u!==null&&u===ft}function g1(i,u){nl=Jc=!0;var m=i.pending;m===null?u.next=u:(u.next=m.next,m.next=u),i.pending=u}function y1(i,u,m){if((m&4194240)!==0){var w=u.lanes;w&=i.pendingLanes,m|=w,u.lanes=m,jr(i,m)}}var tu={readContext:In,useCallback:Yt,useContext:Yt,useEffect:Yt,useImperativeHandle:Yt,useInsertionEffect:Yt,useLayoutEffect:Yt,useMemo:Yt,useReducer:Yt,useRef:Yt,useState:Yt,useDebugValue:Yt,useDeferredValue:Yt,useTransition:Yt,useMutableSource:Yt,useSyncExternalStore:Yt,useId:Yt,unstable_isNewReconciler:!1},v3={readContext:In,useCallback:function(i,u){return Mr().memoizedState=[i,u===void 0?null:u],i},useContext:In,useEffect:o1,useImperativeHandle:function(i,u,m){return m=m!=null?m.concat([i]):null,Qc(4194308,4,c1.bind(null,u,i),m)},useLayoutEffect:function(i,u){return Qc(4194308,4,i,u)},useInsertionEffect:function(i,u){return Qc(4,2,i,u)},useMemo:function(i,u){var m=Mr();return u=u===void 0?null:u,i=i(),m.memoizedState=[i,u],i},useReducer:function(i,u,m){var w=Mr();return u=m!==void 0?m(u):u,w.memoizedState=w.baseState=u,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:u},w.queue=i,i=i.dispatch=y3.bind(null,ft,i),[w.memoizedState,i]},useRef:function(i){var u=Mr();return i={current:i},u.memoizedState=i},useState:s1,useDebugValue:Cf,useDeferredValue:function(i){return Mr().memoizedState=i},useTransition:function(){var i=s1(!1),u=i[0];return i=g3.bind(null,i[1]),Mr().memoizedState=i,[u,i]},useMutableSource:function(){},useSyncExternalStore:function(i,u,m){var w=ft,S=Mr();if(ct){if(m===void 0)throw Error(n(407));m=m()}else{if(m=u(),$t===null)throw Error(n(349));(Ta&30)!==0||Qk(w,u,m)}S.memoizedState=m;var T={value:m,getSnapshot:u};return S.queue=T,o1(t1.bind(null,w,T,i),[i]),w.flags|=2048,al(9,e1.bind(null,w,T,m,u),void 0,null),m},useId:function(){var i=Mr(),u=$t.identifierPrefix;if(ct){var m=ts,w=es;m=(w&~(1<<32-yn(w)-1)).toString(32)+m,u=":"+u+"R"+m,m=rl++,0<m&&(u+="H"+m.toString(32)),u+=":"}else m=m3++,u=":"+u+"r"+m.toString(32)+":";return i.memoizedState=u},unstable_isNewReconciler:!1},x3={readContext:In,useCallback:d1,useContext:In,useEffect:Tf,useImperativeHandle:u1,useInsertionEffect:i1,useLayoutEffect:l1,useMemo:h1,useReducer:_f,useRef:a1,useState:function(){return _f(sl)},useDebugValue:Cf,useDeferredValue:function(i){var u=On();return f1(u,St.memoizedState,i)},useTransition:function(){var i=_f(sl)[0],u=On().memoizedState;return[i,u]},useMutableSource:Zk,useSyncExternalStore:Jk,useId:p1,unstable_isNewReconciler:!1},b3={readContext:In,useCallback:d1,useContext:In,useEffect:Tf,useImperativeHandle:u1,useInsertionEffect:i1,useLayoutEffect:l1,useMemo:h1,useReducer:Ef,useRef:a1,useState:function(){return Ef(sl)},useDebugValue:Cf,useDeferredValue:function(i){var u=On();return St===null?u.memoizedState=i:f1(u,St.memoizedState,i)},useTransition:function(){var i=Ef(sl)[0],u=On().memoizedState;return[i,u]},useMutableSource:Zk,useSyncExternalStore:Jk,useId:p1,unstable_isNewReconciler:!1};function Jn(i,u){if(i&&i.defaultProps){u=H({},u),i=i.defaultProps;for(var m in i)u[m]===void 0&&(u[m]=i[m]);return u}return u}function Af(i,u,m,w){u=i.memoizedState,m=m(w,u),m=m==null?u:H({},u,m),i.memoizedState=m,i.lanes===0&&(i.updateQueue.baseState=m)}var nu={isMounted:function(i){return(i=i._reactInternals)?Gt(i)===i:!1},enqueueSetState:function(i,u,m){i=i._reactInternals;var w=tn(),S=Hs(i),T=rs(w,S);T.payload=u,m!=null&&(T.callback=m),u=qs(i,T,S),u!==null&&(tr(u,i,S,w),Kc(u,i,S))},enqueueReplaceState:function(i,u,m){i=i._reactInternals;var w=tn(),S=Hs(i),T=rs(w,S);T.tag=1,T.payload=u,m!=null&&(T.callback=m),u=qs(i,T,S),u!==null&&(tr(u,i,S,w),Kc(u,i,S))},enqueueForceUpdate:function(i,u){i=i._reactInternals;var m=tn(),w=Hs(i),S=rs(m,w);S.tag=2,u!=null&&(S.callback=u),u=qs(i,S,w),u!==null&&(tr(u,i,w,m),Kc(u,i,w))}};function w1(i,u,m,w,S,T,z){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(w,T,z):u.prototype&&u.prototype.isPureReactComponent?!Hi(m,w)||!Hi(S,T):!0}function v1(i,u,m){var w=!1,S=Ds,T=u.contextType;return typeof T=="object"&&T!==null?T=In(T):(S=an(u)?Na:Kt.current,w=u.contextTypes,T=(w=w!=null)?No(i,S):Ds),u=new u(m,T),i.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=nu,i.stateNode=u,u._reactInternals=i,w&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=S,i.__reactInternalMemoizedMaskedChildContext=T),u}function x1(i,u,m,w){i=u.state,typeof u.componentWillReceiveProps=="function"&&u.componentWillReceiveProps(m,w),typeof u.UNSAFE_componentWillReceiveProps=="function"&&u.UNSAFE_componentWillReceiveProps(m,w),u.state!==i&&nu.enqueueReplaceState(u,u.state,null)}function Rf(i,u,m,w){var S=i.stateNode;S.props=m,S.state=i.memoizedState,S.refs={},yf(i);var T=u.contextType;typeof T=="object"&&T!==null?S.context=In(T):(T=an(u)?Na:Kt.current,S.context=No(i,T)),S.state=i.memoizedState,T=u.getDerivedStateFromProps,typeof T=="function"&&(Af(i,u,T,m),S.state=i.memoizedState),typeof u.getDerivedStateFromProps=="function"||typeof S.getSnapshotBeforeUpdate=="function"||typeof S.UNSAFE_componentWillMount!="function"&&typeof S.componentWillMount!="function"||(u=S.state,typeof S.componentWillMount=="function"&&S.componentWillMount(),typeof S.UNSAFE_componentWillMount=="function"&&S.UNSAFE_componentWillMount(),u!==S.state&&nu.enqueueReplaceState(S,S.state,null),Yc(i,m,S,w),S.state=i.memoizedState),typeof S.componentDidMount=="function"&&(i.flags|=4194308)}function Ro(i,u){try{var m="",w=u;do m+=X(w),w=w.return;while(w);var S=m}catch(T){S=`
39
- Error generating stack: `+T.message+`
40
- `+T.stack}return{value:i,source:u,stack:S,digest:null}}function Mf(i,u,m){return{value:i,source:null,stack:m??null,digest:u??null}}function $f(i,u){try{console.error(u.value)}catch(m){setTimeout(function(){throw m})}}var k3=typeof WeakMap=="function"?WeakMap:Map;function b1(i,u,m){m=rs(-1,m),m.tag=3,m.payload={element:null};var w=u.value;return m.callback=function(){cu||(cu=!0,Kf=w),$f(i,u)},m}function k1(i,u,m){m=rs(-1,m),m.tag=3;var w=i.type.getDerivedStateFromError;if(typeof w=="function"){var S=u.value;m.payload=function(){return w(S)},m.callback=function(){$f(i,u)}}var T=i.stateNode;return T!==null&&typeof T.componentDidCatch=="function"&&(m.callback=function(){$f(i,u),typeof w!="function"&&(zs===null?zs=new Set([this]):zs.add(this));var z=u.stack;this.componentDidCatch(u.value,{componentStack:z!==null?z:""})}),m}function N1(i,u,m){var w=i.pingCache;if(w===null){w=i.pingCache=new k3;var S=new Set;w.set(u,S)}else S=w.get(u),S===void 0&&(S=new Set,w.set(u,S));S.has(m)||(S.add(m),i=L3.bind(null,i,u,m),u.then(i,i))}function j1(i){do{var u;if((u=i.tag===13)&&(u=i.memoizedState,u=u!==null?u.dehydrated!==null:!0),u)return i;i=i.return}while(i!==null);return null}function S1(i,u,m,w,S){return(i.mode&1)===0?(i===u?i.flags|=65536:(i.flags|=128,m.flags|=131072,m.flags&=-52805,m.tag===1&&(m.alternate===null?m.tag=17:(u=rs(-1,1),u.tag=2,qs(m,u,1))),m.lanes|=1),i):(i.flags|=65536,i.lanes=S,i)}var N3=E.ReactCurrentOwner,on=!1;function en(i,u,m,w){u.child=i===null?Hk(u,null,m,w):Eo(u,i.child,m,w)}function _1(i,u,m,w,S){m=m.render;var T=u.ref;return Co(u,S),w=jf(i,u,m,w,T,S),m=Sf(),i!==null&&!on?(u.updateQueue=i.updateQueue,u.flags&=-2053,i.lanes&=~S,ss(i,u,S)):(ct&&m&&of(u),u.flags|=1,en(i,u,w,S),u.child)}function E1(i,u,m,w,S){if(i===null){var T=m.type;return typeof T=="function"&&!tp(T)&&T.defaultProps===void 0&&m.compare===null&&m.defaultProps===void 0?(u.tag=15,u.type=T,T1(i,u,T,w,S)):(i=mu(m.type,null,w,u,u.mode,S),i.ref=u.ref,i.return=u,u.child=i)}if(T=i.child,(i.lanes&S)===0){var z=T.memoizedProps;if(m=m.compare,m=m!==null?m:Hi,m(z,w)&&i.ref===u.ref)return ss(i,u,S)}return u.flags|=1,i=Gs(T,w),i.ref=u.ref,i.return=u,u.child=i}function T1(i,u,m,w,S){if(i!==null){var T=i.memoizedProps;if(Hi(T,w)&&i.ref===u.ref)if(on=!1,u.pendingProps=w=T,(i.lanes&S)!==0)(i.flags&131072)!==0&&(on=!0);else return u.lanes=i.lanes,ss(i,u,S)}return If(i,u,m,w,S)}function C1(i,u,m){var w=u.pendingProps,S=w.children,T=i!==null?i.memoizedState:null;if(w.mode==="hidden")if((u.mode&1)===0)u.memoizedState={baseLanes:0,cachePool:null,transitions:null},nt($o,bn),bn|=m;else{if((m&1073741824)===0)return i=T!==null?T.baseLanes|m:m,u.lanes=u.childLanes=1073741824,u.memoizedState={baseLanes:i,cachePool:null,transitions:null},u.updateQueue=null,nt($o,bn),bn|=i,null;u.memoizedState={baseLanes:0,cachePool:null,transitions:null},w=T!==null?T.baseLanes:m,nt($o,bn),bn|=w}else T!==null?(w=T.baseLanes|m,u.memoizedState=null):w=m,nt($o,bn),bn|=w;return en(i,u,S,m),u.child}function A1(i,u){var m=u.ref;(i===null&&m!==null||i!==null&&i.ref!==m)&&(u.flags|=512,u.flags|=2097152)}function If(i,u,m,w,S){var T=an(m)?Na:Kt.current;return T=No(u,T),Co(u,S),m=jf(i,u,m,w,T,S),w=Sf(),i!==null&&!on?(u.updateQueue=i.updateQueue,u.flags&=-2053,i.lanes&=~S,ss(i,u,S)):(ct&&w&&of(u),u.flags|=1,en(i,u,m,S),u.child)}function R1(i,u,m,w,S){if(an(m)){var T=!0;Bc(u)}else T=!1;if(Co(u,S),u.stateNode===null)su(i,u),v1(u,m,w),Rf(u,m,w,S),w=!0;else if(i===null){var z=u.stateNode,Q=u.memoizedProps;z.props=Q;var te=z.context,ce=m.contextType;typeof ce=="object"&&ce!==null?ce=In(ce):(ce=an(m)?Na:Kt.current,ce=No(u,ce));var ve=m.getDerivedStateFromProps,xe=typeof ve=="function"||typeof z.getSnapshotBeforeUpdate=="function";xe||typeof z.UNSAFE_componentWillReceiveProps!="function"&&typeof z.componentWillReceiveProps!="function"||(Q!==w||te!==ce)&&x1(u,z,w,ce),Bs=!1;var we=u.memoizedState;z.state=we,Yc(u,w,z,S),te=u.memoizedState,Q!==w||we!==te||sn.current||Bs?(typeof ve=="function"&&(Af(u,m,ve,w),te=u.memoizedState),(Q=Bs||w1(u,m,Q,w,we,te,ce))?(xe||typeof z.UNSAFE_componentWillMount!="function"&&typeof z.componentWillMount!="function"||(typeof z.componentWillMount=="function"&&z.componentWillMount(),typeof z.UNSAFE_componentWillMount=="function"&&z.UNSAFE_componentWillMount()),typeof z.componentDidMount=="function"&&(u.flags|=4194308)):(typeof z.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=w,u.memoizedState=te),z.props=w,z.state=te,z.context=ce,w=Q):(typeof z.componentDidMount=="function"&&(u.flags|=4194308),w=!1)}else{z=u.stateNode,Gk(i,u),Q=u.memoizedProps,ce=u.type===u.elementType?Q:Jn(u.type,Q),z.props=ce,xe=u.pendingProps,we=z.context,te=m.contextType,typeof te=="object"&&te!==null?te=In(te):(te=an(m)?Na:Kt.current,te=No(u,te));var Se=m.getDerivedStateFromProps;(ve=typeof Se=="function"||typeof z.getSnapshotBeforeUpdate=="function")||typeof z.UNSAFE_componentWillReceiveProps!="function"&&typeof z.componentWillReceiveProps!="function"||(Q!==xe||we!==te)&&x1(u,z,w,te),Bs=!1,we=u.memoizedState,z.state=we,Yc(u,w,z,S);var Ee=u.memoizedState;Q!==xe||we!==Ee||sn.current||Bs?(typeof Se=="function"&&(Af(u,m,Se,w),Ee=u.memoizedState),(ce=Bs||w1(u,m,ce,w,we,Ee,te)||!1)?(ve||typeof z.UNSAFE_componentWillUpdate!="function"&&typeof z.componentWillUpdate!="function"||(typeof z.componentWillUpdate=="function"&&z.componentWillUpdate(w,Ee,te),typeof z.UNSAFE_componentWillUpdate=="function"&&z.UNSAFE_componentWillUpdate(w,Ee,te)),typeof z.componentDidUpdate=="function"&&(u.flags|=4),typeof z.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof z.componentDidUpdate!="function"||Q===i.memoizedProps&&we===i.memoizedState||(u.flags|=4),typeof z.getSnapshotBeforeUpdate!="function"||Q===i.memoizedProps&&we===i.memoizedState||(u.flags|=1024),u.memoizedProps=w,u.memoizedState=Ee),z.props=w,z.state=Ee,z.context=te,w=ce):(typeof z.componentDidUpdate!="function"||Q===i.memoizedProps&&we===i.memoizedState||(u.flags|=4),typeof z.getSnapshotBeforeUpdate!="function"||Q===i.memoizedProps&&we===i.memoizedState||(u.flags|=1024),w=!1)}return Of(i,u,m,w,T,S)}function Of(i,u,m,w,S,T){A1(i,u);var z=(u.flags&128)!==0;if(!w&&!z)return S&&Lk(u,m,!1),ss(i,u,T);w=u.stateNode,N3.current=u;var Q=z&&typeof m.getDerivedStateFromError!="function"?null:w.render();return u.flags|=1,i!==null&&z?(u.child=Eo(u,i.child,null,T),u.child=Eo(u,null,Q,T)):en(i,u,Q,T),u.memoizedState=w.state,S&&Lk(u,m,!0),u.child}function M1(i){var u=i.stateNode;u.pendingContext?Ik(i,u.pendingContext,u.pendingContext!==u.context):u.context&&Ik(i,u.context,!1),wf(i,u.containerInfo)}function $1(i,u,m,w,S){return _o(),df(S),u.flags|=256,en(i,u,m,w),u.child}var Lf={dehydrated:null,treeContext:null,retryLane:0};function Pf(i){return{baseLanes:i,cachePool:null,transitions:null}}function I1(i,u,m){var w=u.pendingProps,S=ht.current,T=!1,z=(u.flags&128)!==0,Q;if((Q=z)||(Q=i!==null&&i.memoizedState===null?!1:(S&2)!==0),Q?(T=!0,u.flags&=-129):(i===null||i.memoizedState!==null)&&(S|=1),nt(ht,S&1),i===null)return uf(u),i=u.memoizedState,i!==null&&(i=i.dehydrated,i!==null)?((u.mode&1)===0?u.lanes=1:i.data==="$!"?u.lanes=8:u.lanes=1073741824,null):(z=w.children,i=w.fallback,T?(w=u.mode,T=u.child,z={mode:"hidden",children:z},(w&1)===0&&T!==null?(T.childLanes=0,T.pendingProps=z):T=gu(z,w,0,null),i=$a(i,w,m,null),T.return=u,i.return=u,T.sibling=i,u.child=T,u.child.memoizedState=Pf(m),u.memoizedState=Lf,i):Df(u,z));if(S=i.memoizedState,S!==null&&(Q=S.dehydrated,Q!==null))return j3(i,u,z,w,Q,S,m);if(T){T=w.fallback,z=u.mode,S=i.child,Q=S.sibling;var te={mode:"hidden",children:w.children};return(z&1)===0&&u.child!==S?(w=u.child,w.childLanes=0,w.pendingProps=te,u.deletions=null):(w=Gs(S,te),w.subtreeFlags=S.subtreeFlags&14680064),Q!==null?T=Gs(Q,T):(T=$a(T,z,m,null),T.flags|=2),T.return=u,w.return=u,w.sibling=T,u.child=w,w=T,T=u.child,z=i.child.memoizedState,z=z===null?Pf(m):{baseLanes:z.baseLanes|m,cachePool:null,transitions:z.transitions},T.memoizedState=z,T.childLanes=i.childLanes&~m,u.memoizedState=Lf,w}return T=i.child,i=T.sibling,w=Gs(T,{mode:"visible",children:w.children}),(u.mode&1)===0&&(w.lanes=m),w.return=u,w.sibling=null,i!==null&&(m=u.deletions,m===null?(u.deletions=[i],u.flags|=16):m.push(i)),u.child=w,u.memoizedState=null,w}function Df(i,u){return u=gu({mode:"visible",children:u},i.mode,0,null),u.return=i,i.child=u}function ru(i,u,m,w){return w!==null&&df(w),Eo(u,i.child,null,m),i=Df(u,u.pendingProps.children),i.flags|=2,u.memoizedState=null,i}function j3(i,u,m,w,S,T,z){if(m)return u.flags&256?(u.flags&=-257,w=Mf(Error(n(422))),ru(i,u,z,w)):u.memoizedState!==null?(u.child=i.child,u.flags|=128,null):(T=w.fallback,S=u.mode,w=gu({mode:"visible",children:w.children},S,0,null),T=$a(T,S,z,null),T.flags|=2,w.return=u,T.return=u,w.sibling=T,u.child=w,(u.mode&1)!==0&&Eo(u,i.child,null,z),u.child.memoizedState=Pf(z),u.memoizedState=Lf,T);if((u.mode&1)===0)return ru(i,u,z,null);if(S.data==="$!"){if(w=S.nextSibling&&S.nextSibling.dataset,w)var Q=w.dgst;return w=Q,T=Error(n(419)),w=Mf(T,w,void 0),ru(i,u,z,w)}if(Q=(z&i.childLanes)!==0,on||Q){if(w=$t,w!==null){switch(z&-z){case 4:S=2;break;case 16:S=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:S=32;break;case 536870912:S=268435456;break;default:S=0}S=(S&(w.suspendedLanes|z))!==0?0:S,S!==0&&S!==T.retryLane&&(T.retryLane=S,ns(i,S),tr(w,i,S,-1))}return ep(),w=Mf(Error(n(421))),ru(i,u,z,w)}return S.data==="$?"?(u.flags|=128,u.child=i.child,u=P3.bind(null,i),S._reactRetry=u,null):(i=T.treeContext,xn=Ls(S.nextSibling),vn=u,ct=!0,Zn=null,i!==null&&(Mn[$n++]=es,Mn[$n++]=ts,Mn[$n++]=ja,es=i.id,ts=i.overflow,ja=u),u=Df(u,w.children),u.flags|=4096,u)}function O1(i,u,m){i.lanes|=u;var w=i.alternate;w!==null&&(w.lanes|=u),mf(i.return,u,m)}function Ff(i,u,m,w,S){var T=i.memoizedState;T===null?i.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:w,tail:m,tailMode:S}:(T.isBackwards=u,T.rendering=null,T.renderingStartTime=0,T.last=w,T.tail=m,T.tailMode=S)}function L1(i,u,m){var w=u.pendingProps,S=w.revealOrder,T=w.tail;if(en(i,u,w.children,m),w=ht.current,(w&2)!==0)w=w&1|2,u.flags|=128;else{if(i!==null&&(i.flags&128)!==0)e:for(i=u.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&O1(i,m,u);else if(i.tag===19)O1(i,m,u);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===u)break e;for(;i.sibling===null;){if(i.return===null||i.return===u)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}w&=1}if(nt(ht,w),(u.mode&1)===0)u.memoizedState=null;else switch(S){case"forwards":for(m=u.child,S=null;m!==null;)i=m.alternate,i!==null&&Xc(i)===null&&(S=m),m=m.sibling;m=S,m===null?(S=u.child,u.child=null):(S=m.sibling,m.sibling=null),Ff(u,!1,S,m,T);break;case"backwards":for(m=null,S=u.child,u.child=null;S!==null;){if(i=S.alternate,i!==null&&Xc(i)===null){u.child=S;break}i=S.sibling,S.sibling=m,m=S,S=i}Ff(u,!0,m,null,T);break;case"together":Ff(u,!1,null,null,void 0);break;default:u.memoizedState=null}return u.child}function su(i,u){(u.mode&1)===0&&i!==null&&(i.alternate=null,u.alternate=null,u.flags|=2)}function ss(i,u,m){if(i!==null&&(u.dependencies=i.dependencies),Ca|=u.lanes,(m&u.childLanes)===0)return null;if(i!==null&&u.child!==i.child)throw Error(n(153));if(u.child!==null){for(i=u.child,m=Gs(i,i.pendingProps),u.child=m,m.return=u;i.sibling!==null;)i=i.sibling,m=m.sibling=Gs(i,i.pendingProps),m.return=u;m.sibling=null}return u.child}function S3(i,u,m){switch(u.tag){case 3:M1(u),_o();break;case 5:Xk(u);break;case 1:an(u.type)&&Bc(u);break;case 4:wf(u,u.stateNode.containerInfo);break;case 10:var w=u.type._context,S=u.memoizedProps.value;nt(Vc,w._currentValue),w._currentValue=S;break;case 13:if(w=u.memoizedState,w!==null)return w.dehydrated!==null?(nt(ht,ht.current&1),u.flags|=128,null):(m&u.child.childLanes)!==0?I1(i,u,m):(nt(ht,ht.current&1),i=ss(i,u,m),i!==null?i.sibling:null);nt(ht,ht.current&1);break;case 19:if(w=(m&u.childLanes)!==0,(i.flags&128)!==0){if(w)return L1(i,u,m);u.flags|=128}if(S=u.memoizedState,S!==null&&(S.rendering=null,S.tail=null,S.lastEffect=null),nt(ht,ht.current),w)break;return null;case 22:case 23:return u.lanes=0,C1(i,u,m)}return ss(i,u,m)}var P1,Bf,D1,F1;P1=function(i,u){for(var m=u.child;m!==null;){if(m.tag===5||m.tag===6)i.appendChild(m.stateNode);else if(m.tag!==4&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===u)break;for(;m.sibling===null;){if(m.return===null||m.return===u)return;m=m.return}m.sibling.return=m.return,m=m.sibling}},Bf=function(){},D1=function(i,u,m,w){var S=i.memoizedProps;if(S!==w){i=u.stateNode,Ea(Rr.current);var T=null;switch(m){case"input":S=fe(i,S),w=fe(i,w),T=[];break;case"select":S=H({},S,{value:void 0}),w=H({},w,{value:void 0}),T=[];break;case"textarea":S=$e(i,S),w=$e(i,w),T=[];break;default:typeof S.onClick!="function"&&typeof w.onClick=="function"&&(i.onclick=Pc)}Pt(m,w);var z;m=null;for(ce in S)if(!w.hasOwnProperty(ce)&&S.hasOwnProperty(ce)&&S[ce]!=null)if(ce==="style"){var Q=S[ce];for(z in Q)Q.hasOwnProperty(z)&&(m||(m={}),m[z]="")}else ce!=="dangerouslySetInnerHTML"&&ce!=="children"&&ce!=="suppressContentEditableWarning"&&ce!=="suppressHydrationWarning"&&ce!=="autoFocus"&&(s.hasOwnProperty(ce)?T||(T=[]):(T=T||[]).push(ce,null));for(ce in w){var te=w[ce];if(Q=S!=null?S[ce]:void 0,w.hasOwnProperty(ce)&&te!==Q&&(te!=null||Q!=null))if(ce==="style")if(Q){for(z in Q)!Q.hasOwnProperty(z)||te&&te.hasOwnProperty(z)||(m||(m={}),m[z]="");for(z in te)te.hasOwnProperty(z)&&Q[z]!==te[z]&&(m||(m={}),m[z]=te[z])}else m||(T||(T=[]),T.push(ce,m)),m=te;else ce==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,Q=Q?Q.__html:void 0,te!=null&&Q!==te&&(T=T||[]).push(ce,te)):ce==="children"?typeof te!="string"&&typeof te!="number"||(T=T||[]).push(ce,""+te):ce!=="suppressContentEditableWarning"&&ce!=="suppressHydrationWarning"&&(s.hasOwnProperty(ce)?(te!=null&&ce==="onScroll"&&at("scroll",i),T||Q===te||(T=[])):(T=T||[]).push(ce,te))}m&&(T=T||[]).push("style",m);var ce=T;(u.updateQueue=ce)&&(u.flags|=4)}},F1=function(i,u,m,w){m!==w&&(u.flags|=4)};function ol(i,u){if(!ct)switch(i.tailMode){case"hidden":u=i.tail;for(var m=null;u!==null;)u.alternate!==null&&(m=u),u=u.sibling;m===null?i.tail=null:m.sibling=null;break;case"collapsed":m=i.tail;for(var w=null;m!==null;)m.alternate!==null&&(w=m),m=m.sibling;w===null?u||i.tail===null?i.tail=null:i.tail.sibling=null:w.sibling=null}}function Xt(i){var u=i.alternate!==null&&i.alternate.child===i.child,m=0,w=0;if(u)for(var S=i.child;S!==null;)m|=S.lanes|S.childLanes,w|=S.subtreeFlags&14680064,w|=S.flags&14680064,S.return=i,S=S.sibling;else for(S=i.child;S!==null;)m|=S.lanes|S.childLanes,w|=S.subtreeFlags,w|=S.flags,S.return=i,S=S.sibling;return i.subtreeFlags|=w,i.childLanes=m,u}function _3(i,u,m){var w=u.pendingProps;switch(lf(u),u.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Xt(u),null;case 1:return an(u.type)&&Fc(),Xt(u),null;case 3:return w=u.stateNode,Ao(),ot(sn),ot(Kt),bf(),w.pendingContext&&(w.context=w.pendingContext,w.pendingContext=null),(i===null||i.child===null)&&(Wc(u)?u.flags|=4:i===null||i.memoizedState.isDehydrated&&(u.flags&256)===0||(u.flags|=1024,Zn!==null&&(Zf(Zn),Zn=null))),Bf(i,u),Xt(u),null;case 5:vf(u);var S=Ea(tl.current);if(m=u.type,i!==null&&u.stateNode!=null)D1(i,u,m,w,S),i.ref!==u.ref&&(u.flags|=512,u.flags|=2097152);else{if(!w){if(u.stateNode===null)throw Error(n(166));return Xt(u),null}if(i=Ea(Rr.current),Wc(u)){w=u.stateNode,m=u.type;var T=u.memoizedProps;switch(w[Ar]=u,w[Xi]=T,i=(u.mode&1)!==0,m){case"dialog":at("cancel",w),at("close",w);break;case"iframe":case"object":case"embed":at("load",w);break;case"video":case"audio":for(S=0;S<Gi.length;S++)at(Gi[S],w);break;case"source":at("error",w);break;case"img":case"image":case"link":at("error",w),at("load",w);break;case"details":at("toggle",w);break;case"input":me(w,T),at("invalid",w);break;case"select":w._wrapperState={wasMultiple:!!T.multiple},at("invalid",w);break;case"textarea":Oe(w,T),at("invalid",w)}Pt(m,T),S=null;for(var z in T)if(T.hasOwnProperty(z)){var Q=T[z];z==="children"?typeof Q=="string"?w.textContent!==Q&&(T.suppressHydrationWarning!==!0&&Lc(w.textContent,Q,i),S=["children",Q]):typeof Q=="number"&&w.textContent!==""+Q&&(T.suppressHydrationWarning!==!0&&Lc(w.textContent,Q,i),S=["children",""+Q]):s.hasOwnProperty(z)&&Q!=null&&z==="onScroll"&&at("scroll",w)}switch(m){case"input":pe(w),ue(w,T,!0);break;case"textarea":pe(w),Be(w);break;case"select":case"option":break;default:typeof T.onClick=="function"&&(w.onclick=Pc)}w=S,u.updateQueue=w,w!==null&&(u.flags|=4)}else{z=S.nodeType===9?S:S.ownerDocument,i==="http://www.w3.org/1999/xhtml"&&(i=We(m)),i==="http://www.w3.org/1999/xhtml"?m==="script"?(i=z.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof w.is=="string"?i=z.createElement(m,{is:w.is}):(i=z.createElement(m),m==="select"&&(z=i,w.multiple?z.multiple=!0:w.size&&(z.size=w.size))):i=z.createElementNS(i,m),i[Ar]=u,i[Xi]=w,P1(i,u,!1,!1),u.stateNode=i;e:{switch(z=wt(m,w),m){case"dialog":at("cancel",i),at("close",i),S=w;break;case"iframe":case"object":case"embed":at("load",i),S=w;break;case"video":case"audio":for(S=0;S<Gi.length;S++)at(Gi[S],i);S=w;break;case"source":at("error",i),S=w;break;case"img":case"image":case"link":at("error",i),at("load",i),S=w;break;case"details":at("toggle",i),S=w;break;case"input":me(i,w),S=fe(i,w),at("invalid",i);break;case"option":S=w;break;case"select":i._wrapperState={wasMultiple:!!w.multiple},S=H({},w,{value:void 0}),at("invalid",i);break;case"textarea":Oe(i,w),S=$e(i,w),at("invalid",i);break;default:S=w}Pt(m,S),Q=S;for(T in Q)if(Q.hasOwnProperty(T)){var te=Q[T];T==="style"?tt(i,te):T==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,te!=null&&lt(i,te)):T==="children"?typeof te=="string"?(m!=="textarea"||te!=="")&&Rt(i,te):typeof te=="number"&&Rt(i,""+te):T!=="suppressContentEditableWarning"&&T!=="suppressHydrationWarning"&&T!=="autoFocus"&&(s.hasOwnProperty(T)?te!=null&&T==="onScroll"&&at("scroll",i):te!=null&&_(i,T,te,z))}switch(m){case"input":pe(i),ue(i,w,!1);break;case"textarea":pe(i),Be(i);break;case"option":w.value!=null&&i.setAttribute("value",""+ee(w.value));break;case"select":i.multiple=!!w.multiple,T=w.value,T!=null?je(i,!!w.multiple,T,!1):w.defaultValue!=null&&je(i,!!w.multiple,w.defaultValue,!0);break;default:typeof S.onClick=="function"&&(i.onclick=Pc)}switch(m){case"button":case"input":case"select":case"textarea":w=!!w.autoFocus;break e;case"img":w=!0;break e;default:w=!1}}w&&(u.flags|=4)}u.ref!==null&&(u.flags|=512,u.flags|=2097152)}return Xt(u),null;case 6:if(i&&u.stateNode!=null)F1(i,u,i.memoizedProps,w);else{if(typeof w!="string"&&u.stateNode===null)throw Error(n(166));if(m=Ea(tl.current),Ea(Rr.current),Wc(u)){if(w=u.stateNode,m=u.memoizedProps,w[Ar]=u,(T=w.nodeValue!==m)&&(i=vn,i!==null))switch(i.tag){case 3:Lc(w.nodeValue,m,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&Lc(w.nodeValue,m,(i.mode&1)!==0)}T&&(u.flags|=4)}else w=(m.nodeType===9?m:m.ownerDocument).createTextNode(w),w[Ar]=u,u.stateNode=w}return Xt(u),null;case 13:if(ot(ht),w=u.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(ct&&xn!==null&&(u.mode&1)!==0&&(u.flags&128)===0)Uk(),_o(),u.flags|=98560,T=!1;else if(T=Wc(u),w!==null&&w.dehydrated!==null){if(i===null){if(!T)throw Error(n(318));if(T=u.memoizedState,T=T!==null?T.dehydrated:null,!T)throw Error(n(317));T[Ar]=u}else _o(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;Xt(u),T=!1}else Zn!==null&&(Zf(Zn),Zn=null),T=!0;if(!T)return u.flags&65536?u:null}return(u.flags&128)!==0?(u.lanes=m,u):(w=w!==null,w!==(i!==null&&i.memoizedState!==null)&&w&&(u.child.flags|=8192,(u.mode&1)!==0&&(i===null||(ht.current&1)!==0?_t===0&&(_t=3):ep())),u.updateQueue!==null&&(u.flags|=4),Xt(u),null);case 4:return Ao(),Bf(i,u),i===null&&Ki(u.stateNode.containerInfo),Xt(u),null;case 10:return pf(u.type._context),Xt(u),null;case 17:return an(u.type)&&Fc(),Xt(u),null;case 19:if(ot(ht),T=u.memoizedState,T===null)return Xt(u),null;if(w=(u.flags&128)!==0,z=T.rendering,z===null)if(w)ol(T,!1);else{if(_t!==0||i!==null&&(i.flags&128)!==0)for(i=u.child;i!==null;){if(z=Xc(i),z!==null){for(u.flags|=128,ol(T,!1),w=z.updateQueue,w!==null&&(u.updateQueue=w,u.flags|=4),u.subtreeFlags=0,w=m,m=u.child;m!==null;)T=m,i=w,T.flags&=14680066,z=T.alternate,z===null?(T.childLanes=0,T.lanes=i,T.child=null,T.subtreeFlags=0,T.memoizedProps=null,T.memoizedState=null,T.updateQueue=null,T.dependencies=null,T.stateNode=null):(T.childLanes=z.childLanes,T.lanes=z.lanes,T.child=z.child,T.subtreeFlags=0,T.deletions=null,T.memoizedProps=z.memoizedProps,T.memoizedState=z.memoizedState,T.updateQueue=z.updateQueue,T.type=z.type,i=z.dependencies,T.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),m=m.sibling;return nt(ht,ht.current&1|2),u.child}i=i.sibling}T.tail!==null&&Ke()>Io&&(u.flags|=128,w=!0,ol(T,!1),u.lanes=4194304)}else{if(!w)if(i=Xc(z),i!==null){if(u.flags|=128,w=!0,m=i.updateQueue,m!==null&&(u.updateQueue=m,u.flags|=4),ol(T,!0),T.tail===null&&T.tailMode==="hidden"&&!z.alternate&&!ct)return Xt(u),null}else 2*Ke()-T.renderingStartTime>Io&&m!==1073741824&&(u.flags|=128,w=!0,ol(T,!1),u.lanes=4194304);T.isBackwards?(z.sibling=u.child,u.child=z):(m=T.last,m!==null?m.sibling=z:u.child=z,T.last=z)}return T.tail!==null?(u=T.tail,T.rendering=u,T.tail=u.sibling,T.renderingStartTime=Ke(),u.sibling=null,m=ht.current,nt(ht,w?m&1|2:m&1),u):(Xt(u),null);case 22:case 23:return Qf(),w=u.memoizedState!==null,i!==null&&i.memoizedState!==null!==w&&(u.flags|=8192),w&&(u.mode&1)!==0?(bn&1073741824)!==0&&(Xt(u),u.subtreeFlags&6&&(u.flags|=8192)):Xt(u),null;case 24:return null;case 25:return null}throw Error(n(156,u.tag))}function E3(i,u){switch(lf(u),u.tag){case 1:return an(u.type)&&Fc(),i=u.flags,i&65536?(u.flags=i&-65537|128,u):null;case 3:return Ao(),ot(sn),ot(Kt),bf(),i=u.flags,(i&65536)!==0&&(i&128)===0?(u.flags=i&-65537|128,u):null;case 5:return vf(u),null;case 13:if(ot(ht),i=u.memoizedState,i!==null&&i.dehydrated!==null){if(u.alternate===null)throw Error(n(340));_o()}return i=u.flags,i&65536?(u.flags=i&-65537|128,u):null;case 19:return ot(ht),null;case 4:return Ao(),null;case 10:return pf(u.type._context),null;case 22:case 23:return Qf(),null;case 24:return null;default:return null}}var au=!1,Zt=!1,T3=typeof WeakSet=="function"?WeakSet:Set,_e=null;function Mo(i,u){var m=i.ref;if(m!==null)if(typeof m=="function")try{m(null)}catch(w){pt(i,u,w)}else m.current=null}function qf(i,u,m){try{m()}catch(w){pt(i,u,w)}}var B1=!1;function C3(i,u){if(Jh=wa,i=wk(),Wh(i)){if("selectionStart"in i)var m={start:i.selectionStart,end:i.selectionEnd};else e:{m=(m=i.ownerDocument)&&m.defaultView||window;var w=m.getSelection&&m.getSelection();if(w&&w.rangeCount!==0){m=w.anchorNode;var S=w.anchorOffset,T=w.focusNode;w=w.focusOffset;try{m.nodeType,T.nodeType}catch{m=null;break e}var z=0,Q=-1,te=-1,ce=0,ve=0,xe=i,we=null;t:for(;;){for(var Se;xe!==m||S!==0&&xe.nodeType!==3||(Q=z+S),xe!==T||w!==0&&xe.nodeType!==3||(te=z+w),xe.nodeType===3&&(z+=xe.nodeValue.length),(Se=xe.firstChild)!==null;)we=xe,xe=Se;for(;;){if(xe===i)break t;if(we===m&&++ce===S&&(Q=z),we===T&&++ve===w&&(te=z),(Se=xe.nextSibling)!==null)break;xe=we,we=xe.parentNode}xe=Se}m=Q===-1||te===-1?null:{start:Q,end:te}}else m=null}m=m||{start:0,end:0}}else m=null;for(Qh={focusedElem:i,selectionRange:m},wa=!1,_e=u;_e!==null;)if(u=_e,i=u.child,(u.subtreeFlags&1028)!==0&&i!==null)i.return=u,_e=i;else for(;_e!==null;){u=_e;try{var Ee=u.alternate;if((u.flags&1024)!==0)switch(u.tag){case 0:case 11:case 15:break;case 1:if(Ee!==null){var Te=Ee.memoizedProps,vt=Ee.memoizedState,ie=u.stateNode,re=ie.getSnapshotBeforeUpdate(u.elementType===u.type?Te:Jn(u.type,Te),vt);ie.__reactInternalSnapshotBeforeUpdate=re}break;case 3:var le=u.stateNode.containerInfo;le.nodeType===1?le.textContent="":le.nodeType===9&&le.documentElement&&le.removeChild(le.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Ne){pt(u,u.return,Ne)}if(i=u.sibling,i!==null){i.return=u.return,_e=i;break}_e=u.return}return Ee=B1,B1=!1,Ee}function il(i,u,m){var w=u.updateQueue;if(w=w!==null?w.lastEffect:null,w!==null){var S=w=w.next;do{if((S.tag&i)===i){var T=S.destroy;S.destroy=void 0,T!==void 0&&qf(u,m,T)}S=S.next}while(S!==w)}}function ou(i,u){if(u=u.updateQueue,u=u!==null?u.lastEffect:null,u!==null){var m=u=u.next;do{if((m.tag&i)===i){var w=m.create;m.destroy=w()}m=m.next}while(m!==u)}}function Uf(i){var u=i.ref;if(u!==null){var m=i.stateNode;switch(i.tag){case 5:i=m;break;default:i=m}typeof u=="function"?u(i):u.current=i}}function q1(i){var u=i.alternate;u!==null&&(i.alternate=null,q1(u)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(u=i.stateNode,u!==null&&(delete u[Ar],delete u[Xi],delete u[rf],delete u[d3],delete u[h3])),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}function U1(i){return i.tag===5||i.tag===3||i.tag===4}function z1(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||U1(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function zf(i,u,m){var w=i.tag;if(w===5||w===6)i=i.stateNode,u?m.nodeType===8?m.parentNode.insertBefore(i,u):m.insertBefore(i,u):(m.nodeType===8?(u=m.parentNode,u.insertBefore(i,m)):(u=m,u.appendChild(i)),m=m._reactRootContainer,m!=null||u.onclick!==null||(u.onclick=Pc));else if(w!==4&&(i=i.child,i!==null))for(zf(i,u,m),i=i.sibling;i!==null;)zf(i,u,m),i=i.sibling}function Wf(i,u,m){var w=i.tag;if(w===5||w===6)i=i.stateNode,u?m.insertBefore(i,u):m.appendChild(i);else if(w!==4&&(i=i.child,i!==null))for(Wf(i,u,m),i=i.sibling;i!==null;)Wf(i,u,m),i=i.sibling}var Ft=null,Qn=!1;function Us(i,u,m){for(m=m.child;m!==null;)W1(i,u,m),m=m.sibling}function W1(i,u,m){if(Jt&&typeof Jt.onCommitFiberUnmount=="function")try{Jt.onCommitFiberUnmount(Ns,m)}catch{}switch(m.tag){case 5:Zt||Mo(m,u);case 6:var w=Ft,S=Qn;Ft=null,Us(i,u,m),Ft=w,Qn=S,Ft!==null&&(Qn?(i=Ft,m=m.stateNode,i.nodeType===8?i.parentNode.removeChild(m):i.removeChild(m)):Ft.removeChild(m.stateNode));break;case 18:Ft!==null&&(Qn?(i=Ft,m=m.stateNode,i.nodeType===8?nf(i.parentNode,m):i.nodeType===1&&nf(i,m),Cs(i)):nf(Ft,m.stateNode));break;case 4:w=Ft,S=Qn,Ft=m.stateNode.containerInfo,Qn=!0,Us(i,u,m),Ft=w,Qn=S;break;case 0:case 11:case 14:case 15:if(!Zt&&(w=m.updateQueue,w!==null&&(w=w.lastEffect,w!==null))){S=w=w.next;do{var T=S,z=T.destroy;T=T.tag,z!==void 0&&((T&2)!==0||(T&4)!==0)&&qf(m,u,z),S=S.next}while(S!==w)}Us(i,u,m);break;case 1:if(!Zt&&(Mo(m,u),w=m.stateNode,typeof w.componentWillUnmount=="function"))try{w.props=m.memoizedProps,w.state=m.memoizedState,w.componentWillUnmount()}catch(Q){pt(m,u,Q)}Us(i,u,m);break;case 21:Us(i,u,m);break;case 22:m.mode&1?(Zt=(w=Zt)||m.memoizedState!==null,Us(i,u,m),Zt=w):Us(i,u,m);break;default:Us(i,u,m)}}function H1(i){var u=i.updateQueue;if(u!==null){i.updateQueue=null;var m=i.stateNode;m===null&&(m=i.stateNode=new T3),u.forEach(function(w){var S=D3.bind(null,i,w);m.has(w)||(m.add(w),w.then(S,S))})}}function er(i,u){var m=u.deletions;if(m!==null)for(var w=0;w<m.length;w++){var S=m[w];try{var T=i,z=u,Q=z;e:for(;Q!==null;){switch(Q.tag){case 5:Ft=Q.stateNode,Qn=!1;break e;case 3:Ft=Q.stateNode.containerInfo,Qn=!0;break e;case 4:Ft=Q.stateNode.containerInfo,Qn=!0;break e}Q=Q.return}if(Ft===null)throw Error(n(160));W1(T,z,S),Ft=null,Qn=!1;var te=S.alternate;te!==null&&(te.return=null),S.return=null}catch(ce){pt(S,u,ce)}}if(u.subtreeFlags&12854)for(u=u.child;u!==null;)V1(u,i),u=u.sibling}function V1(i,u){var m=i.alternate,w=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(er(u,i),$r(i),w&4){try{il(3,i,i.return),ou(3,i)}catch(Te){pt(i,i.return,Te)}try{il(5,i,i.return)}catch(Te){pt(i,i.return,Te)}}break;case 1:er(u,i),$r(i),w&512&&m!==null&&Mo(m,m.return);break;case 5:if(er(u,i),$r(i),w&512&&m!==null&&Mo(m,m.return),i.flags&32){var S=i.stateNode;try{Rt(S,"")}catch(Te){pt(i,i.return,Te)}}if(w&4&&(S=i.stateNode,S!=null)){var T=i.memoizedProps,z=m!==null?m.memoizedProps:T,Q=i.type,te=i.updateQueue;if(i.updateQueue=null,te!==null)try{Q==="input"&&T.type==="radio"&&T.name!=null&&he(S,T),wt(Q,z);var ce=wt(Q,T);for(z=0;z<te.length;z+=2){var ve=te[z],xe=te[z+1];ve==="style"?tt(S,xe):ve==="dangerouslySetInnerHTML"?lt(S,xe):ve==="children"?Rt(S,xe):_(S,ve,xe,ce)}switch(Q){case"input":ge(S,T);break;case"textarea":Ue(S,T);break;case"select":var we=S._wrapperState.wasMultiple;S._wrapperState.wasMultiple=!!T.multiple;var Se=T.value;Se!=null?je(S,!!T.multiple,Se,!1):we!==!!T.multiple&&(T.defaultValue!=null?je(S,!!T.multiple,T.defaultValue,!0):je(S,!!T.multiple,T.multiple?[]:"",!1))}S[Xi]=T}catch(Te){pt(i,i.return,Te)}}break;case 6:if(er(u,i),$r(i),w&4){if(i.stateNode===null)throw Error(n(162));S=i.stateNode,T=i.memoizedProps;try{S.nodeValue=T}catch(Te){pt(i,i.return,Te)}}break;case 3:if(er(u,i),$r(i),w&4&&m!==null&&m.memoizedState.isDehydrated)try{Cs(u.containerInfo)}catch(Te){pt(i,i.return,Te)}break;case 4:er(u,i),$r(i);break;case 13:er(u,i),$r(i),S=i.child,S.flags&8192&&(T=S.memoizedState!==null,S.stateNode.isHidden=T,!T||S.alternate!==null&&S.alternate.memoizedState!==null||(Gf=Ke())),w&4&&H1(i);break;case 22:if(ve=m!==null&&m.memoizedState!==null,i.mode&1?(Zt=(ce=Zt)||ve,er(u,i),Zt=ce):er(u,i),$r(i),w&8192){if(ce=i.memoizedState!==null,(i.stateNode.isHidden=ce)&&!ve&&(i.mode&1)!==0)for(_e=i,ve=i.child;ve!==null;){for(xe=_e=ve;_e!==null;){switch(we=_e,Se=we.child,we.tag){case 0:case 11:case 14:case 15:il(4,we,we.return);break;case 1:Mo(we,we.return);var Ee=we.stateNode;if(typeof Ee.componentWillUnmount=="function"){w=we,m=we.return;try{u=w,Ee.props=u.memoizedProps,Ee.state=u.memoizedState,Ee.componentWillUnmount()}catch(Te){pt(w,m,Te)}}break;case 5:Mo(we,we.return);break;case 22:if(we.memoizedState!==null){Y1(xe);continue}}Se!==null?(Se.return=we,_e=Se):Y1(xe)}ve=ve.sibling}e:for(ve=null,xe=i;;){if(xe.tag===5){if(ve===null){ve=xe;try{S=xe.stateNode,ce?(T=S.style,typeof T.setProperty=="function"?T.setProperty("display","none","important"):T.display="none"):(Q=xe.stateNode,te=xe.memoizedProps.style,z=te!=null&&te.hasOwnProperty("display")?te.display:null,Q.style.display=Je("display",z))}catch(Te){pt(i,i.return,Te)}}}else if(xe.tag===6){if(ve===null)try{xe.stateNode.nodeValue=ce?"":xe.memoizedProps}catch(Te){pt(i,i.return,Te)}}else if((xe.tag!==22&&xe.tag!==23||xe.memoizedState===null||xe===i)&&xe.child!==null){xe.child.return=xe,xe=xe.child;continue}if(xe===i)break e;for(;xe.sibling===null;){if(xe.return===null||xe.return===i)break e;ve===xe&&(ve=null),xe=xe.return}ve===xe&&(ve=null),xe.sibling.return=xe.return,xe=xe.sibling}}break;case 19:er(u,i),$r(i),w&4&&H1(i);break;case 21:break;default:er(u,i),$r(i)}}function $r(i){var u=i.flags;if(u&2){try{e:{for(var m=i.return;m!==null;){if(U1(m)){var w=m;break e}m=m.return}throw Error(n(160))}switch(w.tag){case 5:var S=w.stateNode;w.flags&32&&(Rt(S,""),w.flags&=-33);var T=z1(i);Wf(i,T,S);break;case 3:case 4:var z=w.stateNode.containerInfo,Q=z1(i);zf(i,Q,z);break;default:throw Error(n(161))}}catch(te){pt(i,i.return,te)}i.flags&=-3}u&4096&&(i.flags&=-4097)}function A3(i,u,m){_e=i,G1(i)}function G1(i,u,m){for(var w=(i.mode&1)!==0;_e!==null;){var S=_e,T=S.child;if(S.tag===22&&w){var z=S.memoizedState!==null||au;if(!z){var Q=S.alternate,te=Q!==null&&Q.memoizedState!==null||Zt;Q=au;var ce=Zt;if(au=z,(Zt=te)&&!ce)for(_e=S;_e!==null;)z=_e,te=z.child,z.tag===22&&z.memoizedState!==null?X1(S):te!==null?(te.return=z,_e=te):X1(S);for(;T!==null;)_e=T,G1(T),T=T.sibling;_e=S,au=Q,Zt=ce}K1(i)}else(S.subtreeFlags&8772)!==0&&T!==null?(T.return=S,_e=T):K1(i)}}function K1(i){for(;_e!==null;){var u=_e;if((u.flags&8772)!==0){var m=u.alternate;try{if((u.flags&8772)!==0)switch(u.tag){case 0:case 11:case 15:Zt||ou(5,u);break;case 1:var w=u.stateNode;if(u.flags&4&&!Zt)if(m===null)w.componentDidMount();else{var S=u.elementType===u.type?m.memoizedProps:Jn(u.type,m.memoizedProps);w.componentDidUpdate(S,m.memoizedState,w.__reactInternalSnapshotBeforeUpdate)}var T=u.updateQueue;T!==null&&Yk(u,T,w);break;case 3:var z=u.updateQueue;if(z!==null){if(m=null,u.child!==null)switch(u.child.tag){case 5:m=u.child.stateNode;break;case 1:m=u.child.stateNode}Yk(u,z,m)}break;case 5:var Q=u.stateNode;if(m===null&&u.flags&4){m=Q;var te=u.memoizedProps;switch(u.type){case"button":case"input":case"select":case"textarea":te.autoFocus&&m.focus();break;case"img":te.src&&(m.src=te.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(u.memoizedState===null){var ce=u.alternate;if(ce!==null){var ve=ce.memoizedState;if(ve!==null){var xe=ve.dehydrated;xe!==null&&Cs(xe)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Zt||u.flags&512&&Uf(u)}catch(we){pt(u,u.return,we)}}if(u===i){_e=null;break}if(m=u.sibling,m!==null){m.return=u.return,_e=m;break}_e=u.return}}function Y1(i){for(;_e!==null;){var u=_e;if(u===i){_e=null;break}var m=u.sibling;if(m!==null){m.return=u.return,_e=m;break}_e=u.return}}function X1(i){for(;_e!==null;){var u=_e;try{switch(u.tag){case 0:case 11:case 15:var m=u.return;try{ou(4,u)}catch(te){pt(u,m,te)}break;case 1:var w=u.stateNode;if(typeof w.componentDidMount=="function"){var S=u.return;try{w.componentDidMount()}catch(te){pt(u,S,te)}}var T=u.return;try{Uf(u)}catch(te){pt(u,T,te)}break;case 5:var z=u.return;try{Uf(u)}catch(te){pt(u,z,te)}}}catch(te){pt(u,u.return,te)}if(u===i){_e=null;break}var Q=u.sibling;if(Q!==null){Q.return=u.return,_e=Q;break}_e=u.return}}var R3=Math.ceil,iu=E.ReactCurrentDispatcher,Hf=E.ReactCurrentOwner,Ln=E.ReactCurrentBatchConfig,ze=0,$t=null,bt=null,Bt=0,bn=0,$o=Ps(0),_t=0,ll=null,Ca=0,lu=0,Vf=0,cl=null,ln=null,Gf=0,Io=1/0,as=null,cu=!1,Kf=null,zs=null,uu=!1,Ws=null,du=0,ul=0,Yf=null,hu=-1,fu=0;function tn(){return(ze&6)!==0?Ke():hu!==-1?hu:hu=Ke()}function Hs(i){return(i.mode&1)===0?1:(ze&2)!==0&&Bt!==0?Bt&-Bt:p3.transition!==null?(fu===0&&(fu=kc()),fu):(i=Ye,i!==0||(i=window.event,i=i===void 0?16:Bi(i.type)),i)}function tr(i,u,m,w){if(50<ul)throw ul=0,Yf=null,Error(n(185));pa(i,m,w),((ze&2)===0||i!==$t)&&(i===$t&&((ze&2)===0&&(lu|=m),_t===4&&Vs(i,Bt)),cn(i,w),m===1&&ze===0&&(u.mode&1)===0&&(Io=Ke()+500,qc&&Fs()))}function cn(i,u){var m=i.callbackNode;$i(i,u);var w=fa(i,i===$t?Bt:0);if(w===0)m!==null&&Gr(m),i.callbackNode=null,i.callbackPriority=0;else if(u=w&-w,i.callbackPriority!==u){if(m!=null&&Gr(m),u===1)i.tag===0?f3(J1.bind(null,i)):Pk(J1.bind(null,i)),c3(function(){(ze&6)===0&&Fs()}),m=null;else{switch(Oi(w)){case 1:m=ks;break;case 4:m=kr;break;case 16:m=Kn;break;case 536870912:m=ao;break;default:m=Kn}m=oN(m,Z1.bind(null,i))}i.callbackPriority=u,i.callbackNode=m}}function Z1(i,u){if(hu=-1,fu=0,(ze&6)!==0)throw Error(n(327));var m=i.callbackNode;if(Oo()&&i.callbackNode!==m)return null;var w=fa(i,i===$t?Bt:0);if(w===0)return null;if((w&30)!==0||(w&i.expiredLanes)!==0||u)u=pu(i,w);else{u=w;var S=ze;ze|=2;var T=eN();($t!==i||Bt!==u)&&(as=null,Io=Ke()+500,Ra(i,u));do try{I3();break}catch(Q){Q1(i,Q)}while(!0);ff(),iu.current=T,ze=S,bt!==null?u=0:($t=null,Bt=0,u=_t)}if(u!==0){if(u===2&&(S=Yn(i),S!==0&&(w=S,u=Xf(i,S))),u===1)throw m=ll,Ra(i,0),Vs(i,w),cn(i,Ke()),m;if(u===6)Vs(i,w);else{if(S=i.current.alternate,(w&30)===0&&!M3(S)&&(u=pu(i,w),u===2&&(T=Yn(i),T!==0&&(w=T,u=Xf(i,T))),u===1))throw m=ll,Ra(i,0),Vs(i,w),cn(i,Ke()),m;switch(i.finishedWork=S,i.finishedLanes=w,u){case 0:case 1:throw Error(n(345));case 2:Ma(i,ln,as);break;case 3:if(Vs(i,w),(w&130023424)===w&&(u=Gf+500-Ke(),10<u)){if(fa(i,0)!==0)break;if(S=i.suspendedLanes,(S&w)!==w){tn(),i.pingedLanes|=i.suspendedLanes&S;break}i.timeoutHandle=tf(Ma.bind(null,i,ln,as),u);break}Ma(i,ln,as);break;case 4:if(Vs(i,w),(w&4194240)===w)break;for(u=i.eventTimes,S=-1;0<w;){var z=31-yn(w);T=1<<z,z=u[z],z>S&&(S=z),w&=~T}if(w=S,w=Ke()-w,w=(120>w?120:480>w?480:1080>w?1080:1920>w?1920:3e3>w?3e3:4320>w?4320:1960*R3(w/1960))-w,10<w){i.timeoutHandle=tf(Ma.bind(null,i,ln,as),w);break}Ma(i,ln,as);break;case 5:Ma(i,ln,as);break;default:throw Error(n(329))}}}return cn(i,Ke()),i.callbackNode===m?Z1.bind(null,i):null}function Xf(i,u){var m=cl;return i.current.memoizedState.isDehydrated&&(Ra(i,u).flags|=256),i=pu(i,u),i!==2&&(u=ln,ln=m,u!==null&&Zf(u)),i}function Zf(i){ln===null?ln=i:ln.push.apply(ln,i)}function M3(i){for(var u=i;;){if(u.flags&16384){var m=u.updateQueue;if(m!==null&&(m=m.stores,m!==null))for(var w=0;w<m.length;w++){var S=m[w],T=S.getSnapshot;S=S.value;try{if(!Xn(T(),S))return!1}catch{return!1}}}if(m=u.child,u.subtreeFlags&16384&&m!==null)m.return=u,u=m;else{if(u===i)break;for(;u.sibling===null;){if(u.return===null||u.return===i)return!0;u=u.return}u.sibling.return=u.return,u=u.sibling}}return!0}function Vs(i,u){for(u&=~Vf,u&=~lu,i.suspendedLanes|=u,i.pingedLanes&=~u,i=i.expirationTimes;0<u;){var m=31-yn(u),w=1<<m;i[m]=-1,u&=~w}}function J1(i){if((ze&6)!==0)throw Error(n(327));Oo();var u=fa(i,0);if((u&1)===0)return cn(i,Ke()),null;var m=pu(i,u);if(i.tag!==0&&m===2){var w=Yn(i);w!==0&&(u=w,m=Xf(i,w))}if(m===1)throw m=ll,Ra(i,0),Vs(i,u),cn(i,Ke()),m;if(m===6)throw Error(n(345));return i.finishedWork=i.current.alternate,i.finishedLanes=u,Ma(i,ln,as),cn(i,Ke()),null}function Jf(i,u){var m=ze;ze|=1;try{return i(u)}finally{ze=m,ze===0&&(Io=Ke()+500,qc&&Fs())}}function Aa(i){Ws!==null&&Ws.tag===0&&(ze&6)===0&&Oo();var u=ze;ze|=1;var m=Ln.transition,w=Ye;try{if(Ln.transition=null,Ye=1,i)return i()}finally{Ye=w,Ln.transition=m,ze=u,(ze&6)===0&&Fs()}}function Qf(){bn=$o.current,ot($o)}function Ra(i,u){i.finishedWork=null,i.finishedLanes=0;var m=i.timeoutHandle;if(m!==-1&&(i.timeoutHandle=-1,l3(m)),bt!==null)for(m=bt.return;m!==null;){var w=m;switch(lf(w),w.tag){case 1:w=w.type.childContextTypes,w!=null&&Fc();break;case 3:Ao(),ot(sn),ot(Kt),bf();break;case 5:vf(w);break;case 4:Ao();break;case 13:ot(ht);break;case 19:ot(ht);break;case 10:pf(w.type._context);break;case 22:case 23:Qf()}m=m.return}if($t=i,bt=i=Gs(i.current,null),Bt=bn=u,_t=0,ll=null,Vf=lu=Ca=0,ln=cl=null,_a!==null){for(u=0;u<_a.length;u++)if(m=_a[u],w=m.interleaved,w!==null){m.interleaved=null;var S=w.next,T=m.pending;if(T!==null){var z=T.next;T.next=S,w.next=z}m.pending=w}_a=null}return i}function Q1(i,u){do{var m=bt;try{if(ff(),Zc.current=tu,Jc){for(var w=ft.memoizedState;w!==null;){var S=w.queue;S!==null&&(S.pending=null),w=w.next}Jc=!1}if(Ta=0,Mt=St=ft=null,nl=!1,rl=0,Hf.current=null,m===null||m.return===null){_t=1,ll=u,bt=null;break}e:{var T=i,z=m.return,Q=m,te=u;if(u=Bt,Q.flags|=32768,te!==null&&typeof te=="object"&&typeof te.then=="function"){var ce=te,ve=Q,xe=ve.tag;if((ve.mode&1)===0&&(xe===0||xe===11||xe===15)){var we=ve.alternate;we?(ve.updateQueue=we.updateQueue,ve.memoizedState=we.memoizedState,ve.lanes=we.lanes):(ve.updateQueue=null,ve.memoizedState=null)}var Se=j1(z);if(Se!==null){Se.flags&=-257,S1(Se,z,Q,T,u),Se.mode&1&&N1(T,ce,u),u=Se,te=ce;var Ee=u.updateQueue;if(Ee===null){var Te=new Set;Te.add(te),u.updateQueue=Te}else Ee.add(te);break e}else{if((u&1)===0){N1(T,ce,u),ep();break e}te=Error(n(426))}}else if(ct&&Q.mode&1){var vt=j1(z);if(vt!==null){(vt.flags&65536)===0&&(vt.flags|=256),S1(vt,z,Q,T,u),df(Ro(te,Q));break e}}T=te=Ro(te,Q),_t!==4&&(_t=2),cl===null?cl=[T]:cl.push(T),T=z;do{switch(T.tag){case 3:T.flags|=65536,u&=-u,T.lanes|=u;var ie=b1(T,te,u);Kk(T,ie);break e;case 1:Q=te;var re=T.type,le=T.stateNode;if((T.flags&128)===0&&(typeof re.getDerivedStateFromError=="function"||le!==null&&typeof le.componentDidCatch=="function"&&(zs===null||!zs.has(le)))){T.flags|=65536,u&=-u,T.lanes|=u;var Ne=k1(T,Q,u);Kk(T,Ne);break e}}T=T.return}while(T!==null)}nN(m)}catch(Ce){u=Ce,bt===m&&m!==null&&(bt=m=m.return);continue}break}while(!0)}function eN(){var i=iu.current;return iu.current=tu,i===null?tu:i}function ep(){(_t===0||_t===3||_t===2)&&(_t=4),$t===null||(Ca&268435455)===0&&(lu&268435455)===0||Vs($t,Bt)}function pu(i,u){var m=ze;ze|=2;var w=eN();($t!==i||Bt!==u)&&(as=null,Ra(i,u));do try{$3();break}catch(S){Q1(i,S)}while(!0);if(ff(),ze=m,iu.current=w,bt!==null)throw Error(n(261));return $t=null,Bt=0,_t}function $3(){for(;bt!==null;)tN(bt)}function I3(){for(;bt!==null&&!br();)tN(bt)}function tN(i){var u=aN(i.alternate,i,bn);i.memoizedProps=i.pendingProps,u===null?nN(i):bt=u,Hf.current=null}function nN(i){var u=i;do{var m=u.alternate;if(i=u.return,(u.flags&32768)===0){if(m=_3(m,u,bn),m!==null){bt=m;return}}else{if(m=E3(m,u),m!==null){m.flags&=32767,bt=m;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{_t=6,bt=null;return}}if(u=u.sibling,u!==null){bt=u;return}bt=u=i}while(u!==null);_t===0&&(_t=5)}function Ma(i,u,m){var w=Ye,S=Ln.transition;try{Ln.transition=null,Ye=1,O3(i,u,m,w)}finally{Ln.transition=S,Ye=w}return null}function O3(i,u,m,w){do Oo();while(Ws!==null);if((ze&6)!==0)throw Error(n(327));m=i.finishedWork;var S=i.finishedLanes;if(m===null)return null;if(i.finishedWork=null,i.finishedLanes=0,m===i.current)throw Error(n(177));i.callbackNode=null,i.callbackPriority=0;var T=m.lanes|m.childLanes;if(Nc(i,T),i===$t&&(bt=$t=null,Bt=0),(m.subtreeFlags&2064)===0&&(m.flags&2064)===0||uu||(uu=!0,oN(Kn,function(){return Oo(),null})),T=(m.flags&15990)!==0,(m.subtreeFlags&15990)!==0||T){T=Ln.transition,Ln.transition=null;var z=Ye;Ye=1;var Q=ze;ze|=4,Hf.current=null,C3(i,m),V1(m,i),t3(Qh),wa=!!Jh,Qh=Jh=null,i.current=m,A3(m),ha(),ze=Q,Ye=z,Ln.transition=T}else i.current=m;if(uu&&(uu=!1,Ws=i,du=S),T=i.pendingLanes,T===0&&(zs=null),js(m.stateNode),cn(i,Ke()),u!==null)for(w=i.onRecoverableError,m=0;m<u.length;m++)S=u[m],w(S.value,{componentStack:S.stack,digest:S.digest});if(cu)throw cu=!1,i=Kf,Kf=null,i;return(du&1)!==0&&i.tag!==0&&Oo(),T=i.pendingLanes,(T&1)!==0?i===Yf?ul++:(ul=0,Yf=i):ul=0,Fs(),null}function Oo(){if(Ws!==null){var i=Oi(du),u=Ln.transition,m=Ye;try{if(Ln.transition=null,Ye=16>i?16:i,Ws===null)var w=!1;else{if(i=Ws,Ws=null,du=0,(ze&6)!==0)throw Error(n(331));var S=ze;for(ze|=4,_e=i.current;_e!==null;){var T=_e,z=T.child;if((_e.flags&16)!==0){var Q=T.deletions;if(Q!==null){for(var te=0;te<Q.length;te++){var ce=Q[te];for(_e=ce;_e!==null;){var ve=_e;switch(ve.tag){case 0:case 11:case 15:il(8,ve,T)}var xe=ve.child;if(xe!==null)xe.return=ve,_e=xe;else for(;_e!==null;){ve=_e;var we=ve.sibling,Se=ve.return;if(q1(ve),ve===ce){_e=null;break}if(we!==null){we.return=Se,_e=we;break}_e=Se}}}var Ee=T.alternate;if(Ee!==null){var Te=Ee.child;if(Te!==null){Ee.child=null;do{var vt=Te.sibling;Te.sibling=null,Te=vt}while(Te!==null)}}_e=T}}if((T.subtreeFlags&2064)!==0&&z!==null)z.return=T,_e=z;else e:for(;_e!==null;){if(T=_e,(T.flags&2048)!==0)switch(T.tag){case 0:case 11:case 15:il(9,T,T.return)}var ie=T.sibling;if(ie!==null){ie.return=T.return,_e=ie;break e}_e=T.return}}var re=i.current;for(_e=re;_e!==null;){z=_e;var le=z.child;if((z.subtreeFlags&2064)!==0&&le!==null)le.return=z,_e=le;else e:for(z=re;_e!==null;){if(Q=_e,(Q.flags&2048)!==0)try{switch(Q.tag){case 0:case 11:case 15:ou(9,Q)}}catch(Ce){pt(Q,Q.return,Ce)}if(Q===z){_e=null;break e}var Ne=Q.sibling;if(Ne!==null){Ne.return=Q.return,_e=Ne;break e}_e=Q.return}}if(ze=S,Fs(),Jt&&typeof Jt.onPostCommitFiberRoot=="function")try{Jt.onPostCommitFiberRoot(Ns,i)}catch{}w=!0}return w}finally{Ye=m,Ln.transition=u}}return!1}function rN(i,u,m){u=Ro(m,u),u=b1(i,u,1),i=qs(i,u,1),u=tn(),i!==null&&(pa(i,1,u),cn(i,u))}function pt(i,u,m){if(i.tag===3)rN(i,i,m);else for(;u!==null;){if(u.tag===3){rN(u,i,m);break}else if(u.tag===1){var w=u.stateNode;if(typeof u.type.getDerivedStateFromError=="function"||typeof w.componentDidCatch=="function"&&(zs===null||!zs.has(w))){i=Ro(m,i),i=k1(u,i,1),u=qs(u,i,1),i=tn(),u!==null&&(pa(u,1,i),cn(u,i));break}}u=u.return}}function L3(i,u,m){var w=i.pingCache;w!==null&&w.delete(u),u=tn(),i.pingedLanes|=i.suspendedLanes&m,$t===i&&(Bt&m)===m&&(_t===4||_t===3&&(Bt&130023424)===Bt&&500>Ke()-Gf?Ra(i,0):Vf|=m),cn(i,u)}function sN(i,u){u===0&&((i.mode&1)===0?u=1:(u=io,io<<=1,(io&130023424)===0&&(io=4194304)));var m=tn();i=ns(i,u),i!==null&&(pa(i,u,m),cn(i,m))}function P3(i){var u=i.memoizedState,m=0;u!==null&&(m=u.retryLane),sN(i,m)}function D3(i,u){var m=0;switch(i.tag){case 13:var w=i.stateNode,S=i.memoizedState;S!==null&&(m=S.retryLane);break;case 19:w=i.stateNode;break;default:throw Error(n(314))}w!==null&&w.delete(u),sN(i,m)}var aN;aN=function(i,u,m){if(i!==null)if(i.memoizedProps!==u.pendingProps||sn.current)on=!0;else{if((i.lanes&m)===0&&(u.flags&128)===0)return on=!1,S3(i,u,m);on=(i.flags&131072)!==0}else on=!1,ct&&(u.flags&1048576)!==0&&Dk(u,zc,u.index);switch(u.lanes=0,u.tag){case 2:var w=u.type;su(i,u),i=u.pendingProps;var S=No(u,Kt.current);Co(u,m),S=jf(null,u,w,i,S,m);var T=Sf();return u.flags|=1,typeof S=="object"&&S!==null&&typeof S.render=="function"&&S.$$typeof===void 0?(u.tag=1,u.memoizedState=null,u.updateQueue=null,an(w)?(T=!0,Bc(u)):T=!1,u.memoizedState=S.state!==null&&S.state!==void 0?S.state:null,yf(u),S.updater=nu,u.stateNode=S,S._reactInternals=u,Rf(u,w,i,m),u=Of(null,u,w,!0,T,m)):(u.tag=0,ct&&T&&of(u),en(null,u,S,m),u=u.child),u;case 16:w=u.elementType;e:{switch(su(i,u),i=u.pendingProps,S=w._init,w=S(w._payload),u.type=w,S=u.tag=B3(w),i=Jn(w,i),S){case 0:u=If(null,u,w,i,m);break e;case 1:u=R1(null,u,w,i,m);break e;case 11:u=_1(null,u,w,i,m);break e;case 14:u=E1(null,u,w,Jn(w.type,i),m);break e}throw Error(n(306,w,""))}return u;case 0:return w=u.type,S=u.pendingProps,S=u.elementType===w?S:Jn(w,S),If(i,u,w,S,m);case 1:return w=u.type,S=u.pendingProps,S=u.elementType===w?S:Jn(w,S),R1(i,u,w,S,m);case 3:e:{if(M1(u),i===null)throw Error(n(387));w=u.pendingProps,T=u.memoizedState,S=T.element,Gk(i,u),Yc(u,w,null,m);var z=u.memoizedState;if(w=z.element,T.isDehydrated)if(T={element:w,isDehydrated:!1,cache:z.cache,pendingSuspenseBoundaries:z.pendingSuspenseBoundaries,transitions:z.transitions},u.updateQueue.baseState=T,u.memoizedState=T,u.flags&256){S=Ro(Error(n(423)),u),u=$1(i,u,w,m,S);break e}else if(w!==S){S=Ro(Error(n(424)),u),u=$1(i,u,w,m,S);break e}else for(xn=Ls(u.stateNode.containerInfo.firstChild),vn=u,ct=!0,Zn=null,m=Hk(u,null,w,m),u.child=m;m;)m.flags=m.flags&-3|4096,m=m.sibling;else{if(_o(),w===S){u=ss(i,u,m);break e}en(i,u,w,m)}u=u.child}return u;case 5:return Xk(u),i===null&&uf(u),w=u.type,S=u.pendingProps,T=i!==null?i.memoizedProps:null,z=S.children,ef(w,S)?z=null:T!==null&&ef(w,T)&&(u.flags|=32),A1(i,u),en(i,u,z,m),u.child;case 6:return i===null&&uf(u),null;case 13:return I1(i,u,m);case 4:return wf(u,u.stateNode.containerInfo),w=u.pendingProps,i===null?u.child=Eo(u,null,w,m):en(i,u,w,m),u.child;case 11:return w=u.type,S=u.pendingProps,S=u.elementType===w?S:Jn(w,S),_1(i,u,w,S,m);case 7:return en(i,u,u.pendingProps,m),u.child;case 8:return en(i,u,u.pendingProps.children,m),u.child;case 12:return en(i,u,u.pendingProps.children,m),u.child;case 10:e:{if(w=u.type._context,S=u.pendingProps,T=u.memoizedProps,z=S.value,nt(Vc,w._currentValue),w._currentValue=z,T!==null)if(Xn(T.value,z)){if(T.children===S.children&&!sn.current){u=ss(i,u,m);break e}}else for(T=u.child,T!==null&&(T.return=u);T!==null;){var Q=T.dependencies;if(Q!==null){z=T.child;for(var te=Q.firstContext;te!==null;){if(te.context===w){if(T.tag===1){te=rs(-1,m&-m),te.tag=2;var ce=T.updateQueue;if(ce!==null){ce=ce.shared;var ve=ce.pending;ve===null?te.next=te:(te.next=ve.next,ve.next=te),ce.pending=te}}T.lanes|=m,te=T.alternate,te!==null&&(te.lanes|=m),mf(T.return,m,u),Q.lanes|=m;break}te=te.next}}else if(T.tag===10)z=T.type===u.type?null:T.child;else if(T.tag===18){if(z=T.return,z===null)throw Error(n(341));z.lanes|=m,Q=z.alternate,Q!==null&&(Q.lanes|=m),mf(z,m,u),z=T.sibling}else z=T.child;if(z!==null)z.return=T;else for(z=T;z!==null;){if(z===u){z=null;break}if(T=z.sibling,T!==null){T.return=z.return,z=T;break}z=z.return}T=z}en(i,u,S.children,m),u=u.child}return u;case 9:return S=u.type,w=u.pendingProps.children,Co(u,m),S=In(S),w=w(S),u.flags|=1,en(i,u,w,m),u.child;case 14:return w=u.type,S=Jn(w,u.pendingProps),S=Jn(w.type,S),E1(i,u,w,S,m);case 15:return T1(i,u,u.type,u.pendingProps,m);case 17:return w=u.type,S=u.pendingProps,S=u.elementType===w?S:Jn(w,S),su(i,u),u.tag=1,an(w)?(i=!0,Bc(u)):i=!1,Co(u,m),v1(u,w,S),Rf(u,w,S,m),Of(null,u,w,!0,i,m);case 19:return L1(i,u,m);case 22:return C1(i,u,m)}throw Error(n(156,u.tag))};function oN(i,u){return rn(i,u)}function F3(i,u,m,w){this.tag=i,this.key=m,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=u,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=w,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Pn(i,u,m,w){return new F3(i,u,m,w)}function tp(i){return i=i.prototype,!(!i||!i.isReactComponent)}function B3(i){if(typeof i=="function")return tp(i)?1:0;if(i!=null){if(i=i.$$typeof,i===I)return 11;if(i===$)return 14}return 2}function Gs(i,u){var m=i.alternate;return m===null?(m=Pn(i.tag,u,i.key,i.mode),m.elementType=i.elementType,m.type=i.type,m.stateNode=i.stateNode,m.alternate=i,i.alternate=m):(m.pendingProps=u,m.type=i.type,m.flags=0,m.subtreeFlags=0,m.deletions=null),m.flags=i.flags&14680064,m.childLanes=i.childLanes,m.lanes=i.lanes,m.child=i.child,m.memoizedProps=i.memoizedProps,m.memoizedState=i.memoizedState,m.updateQueue=i.updateQueue,u=i.dependencies,m.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext},m.sibling=i.sibling,m.index=i.index,m.ref=i.ref,m}function mu(i,u,m,w,S,T){var z=2;if(w=i,typeof i=="function")tp(i)&&(z=1);else if(typeof i=="string")z=5;else e:switch(i){case A:return $a(m.children,S,T,u);case U:z=8,S|=8;break;case L:return i=Pn(12,m,u,S|2),i.elementType=L,i.lanes=T,i;case B:return i=Pn(13,m,u,S),i.elementType=B,i.lanes=T,i;case M:return i=Pn(19,m,u,S),i.elementType=M,i.lanes=T,i;case G:return gu(m,S,T,u);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case F:z=10;break e;case O:z=9;break e;case I:z=11;break e;case $:z=14;break e;case P:z=16,w=null;break e}throw Error(n(130,i==null?i:typeof i,""))}return u=Pn(z,m,u,S),u.elementType=i,u.type=w,u.lanes=T,u}function $a(i,u,m,w){return i=Pn(7,i,w,u),i.lanes=m,i}function gu(i,u,m,w){return i=Pn(22,i,w,u),i.elementType=G,i.lanes=m,i.stateNode={isHidden:!1},i}function np(i,u,m){return i=Pn(6,i,null,u),i.lanes=m,i}function rp(i,u,m){return u=Pn(4,i.children!==null?i.children:[],i.key,u),u.lanes=m,u.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},u}function q3(i,u,m,w,S){this.tag=u,this.containerInfo=i,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ii(0),this.expirationTimes=Ii(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ii(0),this.identifierPrefix=w,this.onRecoverableError=S,this.mutableSourceEagerHydrationData=null}function sp(i,u,m,w,S,T,z,Q,te){return i=new q3(i,u,m,Q,te),u===1?(u=1,T===!0&&(u|=8)):u=0,T=Pn(3,null,null,u),i.current=T,T.stateNode=i,T.memoizedState={element:w,isDehydrated:m,cache:null,transitions:null,pendingSuspenseBoundaries:null},yf(T),i}function U3(i,u,m){var w=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:C,key:w==null?null:""+w,children:i,containerInfo:u,implementation:m}}function iN(i){if(!i)return Ds;i=i._reactInternals;e:{if(Gt(i)!==i||i.tag!==1)throw Error(n(170));var u=i;do{switch(u.tag){case 3:u=u.stateNode.context;break e;case 1:if(an(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break e}}u=u.return}while(u!==null);throw Error(n(171))}if(i.tag===1){var m=i.type;if(an(m))return Ok(i,m,u)}return u}function lN(i,u,m,w,S,T,z,Q,te){return i=sp(m,w,!0,i,S,T,z,Q,te),i.context=iN(null),m=i.current,w=tn(),S=Hs(m),T=rs(w,S),T.callback=u??null,qs(m,T,S),i.current.lanes=S,pa(i,S,w),cn(i,w),i}function yu(i,u,m,w){var S=u.current,T=tn(),z=Hs(S);return m=iN(m),u.context===null?u.context=m:u.pendingContext=m,u=rs(T,z),u.payload={element:i},w=w===void 0?null:w,w!==null&&(u.callback=w),i=qs(S,u,z),i!==null&&(tr(i,S,z,T),Kc(i,S,z)),z}function wu(i){if(i=i.current,!i.child)return null;switch(i.child.tag){case 5:return i.child.stateNode;default:return i.child.stateNode}}function cN(i,u){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var m=i.retryLane;i.retryLane=m!==0&&m<u?m:u}}function ap(i,u){cN(i,u),(i=i.alternate)&&cN(i,u)}function z3(){return null}var uN=typeof reportError=="function"?reportError:function(i){console.error(i)};function op(i){this._internalRoot=i}vu.prototype.render=op.prototype.render=function(i){var u=this._internalRoot;if(u===null)throw Error(n(409));yu(i,u,null,null)},vu.prototype.unmount=op.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var u=i.containerInfo;Aa(function(){yu(null,i,null,null)}),u[Jr]=null}};function vu(i){this._internalRoot=i}vu.prototype.unstable_scheduleHydration=function(i){if(i){var u=Sc();i={blockedOn:null,target:i,priority:u};for(var m=0;m<Er.length&&u!==0&&u<Er[m].priority;m++);Er.splice(m,0,i),m===0&&Ec(i)}};function ip(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function xu(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function dN(){}function W3(i,u,m,w,S){if(S){if(typeof w=="function"){var T=w;w=function(){var ce=wu(z);T.call(ce)}}var z=lN(u,w,i,0,null,!1,!1,"",dN);return i._reactRootContainer=z,i[Jr]=z.current,Ki(i.nodeType===8?i.parentNode:i),Aa(),z}for(;S=i.lastChild;)i.removeChild(S);if(typeof w=="function"){var Q=w;w=function(){var ce=wu(te);Q.call(ce)}}var te=sp(i,0,!1,null,null,!1,!1,"",dN);return i._reactRootContainer=te,i[Jr]=te.current,Ki(i.nodeType===8?i.parentNode:i),Aa(function(){yu(u,te,m,w)}),te}function bu(i,u,m,w,S){var T=m._reactRootContainer;if(T){var z=T;if(typeof S=="function"){var Q=S;S=function(){var te=wu(z);Q.call(te)}}yu(u,z,i,S)}else z=W3(m,u,i,S,w);return wu(z)}Li=function(i){switch(i.tag){case 3:var u=i.stateNode;if(u.current.memoizedState.isDehydrated){var m=Ss(u.pendingLanes);m!==0&&(jr(u,m|1),cn(u,Ke()),(ze&6)===0&&(Io=Ke()+500,Fs()))}break;case 13:Aa(function(){var w=ns(i,1);if(w!==null){var S=tn();tr(w,i,1,S)}}),ap(i,1)}},ma=function(i){if(i.tag===13){var u=ns(i,134217728);if(u!==null){var m=tn();tr(u,i,134217728,m)}ap(i,134217728)}},jc=function(i){if(i.tag===13){var u=Hs(i),m=ns(i,u);if(m!==null){var w=tn();tr(m,i,u,w)}ap(i,u)}},Sc=function(){return Ye},lo=function(i,u){var m=Ye;try{return Ye=i,u()}finally{Ye=m}},Wt=function(i,u,m){switch(u){case"input":if(ge(i,m),u=m.name,m.type==="radio"&&u!=null){for(m=i;m.parentNode;)m=m.parentNode;for(m=m.querySelectorAll("input[name="+JSON.stringify(""+u)+'][type="radio"]'),u=0;u<m.length;u++){var w=m[u];if(w!==i&&w.form===i.form){var S=Dc(w);if(!S)throw Error(n(90));ke(w),ge(w,S)}}}break;case"textarea":Ue(i,m);break;case"select":u=m.value,u!=null&&je(i,!!m.multiple,u,!1)}},mr=Jf,zr=Aa;var H3={usingClientEntryPoint:!1,Events:[Zi,bo,Dc,vs,Cn,Jf]},dl={findFiberByHostInstance:ka,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},V3={bundleType:dl.bundleType,version:dl.version,rendererPackageName:dl.rendererPackageName,rendererConfig:dl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:E.ReactCurrentDispatcher,findHostInstanceByFiber:function(i){return i=Fe(i),i===null?null:i.stateNode},findFiberByHostInstance:dl.findFiberByHostInstance||z3,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var ku=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ku.isDisabled&&ku.supportsFiber)try{Ns=ku.inject(V3),Jt=ku}catch{}}return un.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=H3,un.createPortal=function(i,u){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!ip(u))throw Error(n(200));return U3(i,u,null,m)},un.createRoot=function(i,u){if(!ip(i))throw Error(n(299));var m=!1,w="",S=uN;return u!=null&&(u.unstable_strictMode===!0&&(m=!0),u.identifierPrefix!==void 0&&(w=u.identifierPrefix),u.onRecoverableError!==void 0&&(S=u.onRecoverableError)),u=sp(i,1,!1,null,null,m,!1,w,S),i[Jr]=u.current,Ki(i.nodeType===8?i.parentNode:i),new op(u)},un.findDOMNode=function(i){if(i==null)return null;if(i.nodeType===1)return i;var u=i._reactInternals;if(u===void 0)throw typeof i.render=="function"?Error(n(188)):(i=Object.keys(i).join(","),Error(n(268,i)));return i=Fe(u),i=i===null?null:i.stateNode,i},un.flushSync=function(i){return Aa(i)},un.hydrate=function(i,u,m){if(!xu(u))throw Error(n(200));return bu(null,i,u,!0,m)},un.hydrateRoot=function(i,u,m){if(!ip(i))throw Error(n(405));var w=m!=null&&m.hydratedSources||null,S=!1,T="",z=uN;if(m!=null&&(m.unstable_strictMode===!0&&(S=!0),m.identifierPrefix!==void 0&&(T=m.identifierPrefix),m.onRecoverableError!==void 0&&(z=m.onRecoverableError)),u=lN(u,null,i,1,m??null,S,!1,T,z),i[Jr]=u.current,Ki(i),w)for(i=0;i<w.length;i++)m=w[i],S=m._getVersion,S=S(m._source),u.mutableSourceEagerHydrationData==null?u.mutableSourceEagerHydrationData=[m,S]:u.mutableSourceEagerHydrationData.push(m,S);return new vu(u)},un.render=function(i,u,m){if(!xu(u))throw Error(n(200));return bu(null,i,u,!1,m)},un.unmountComponentAtNode=function(i){if(!xu(i))throw Error(n(40));return i._reactRootContainer?(Aa(function(){bu(null,null,i,!1,function(){i._reactRootContainer=null,i[Jr]=null})}),!0):!1},un.unstable_batchedUpdates=Jf,un.unstable_renderSubtreeIntoContainer=function(i,u,m,w){if(!xu(m))throw Error(n(200));if(i==null||i._reactInternals===void 0)throw Error(n(38));return bu(i,u,m,!1,w)},un.version="18.3.1-next-f1338f8080-20240426",un}var vN;function xM(){if(vN)return dp.exports;vN=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),dp.exports=t4(),dp.exports}var xN;function n4(){if(xN)return ju;xN=1;var e=xM();return ju.createRoot=e.createRoot,ju.hydrateRoot=e.hydrateRoot,ju}var r4=n4(),y=oc();const de=Tb(y);function Ut(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=Ut(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var pp={exports:{}},mp={},gp={exports:{}},yp={};/**
41
- * @license React
42
- * use-sync-external-store-shim.production.js
43
- *
44
- * Copyright (c) Meta Platforms, Inc. and affiliates.
45
- *
46
- * This source code is licensed under the MIT license found in the
47
- * LICENSE file in the root directory of this source tree.
48
- */var bN;function s4(){if(bN)return yp;bN=1;var e=oc();function t(p,g){return p===g&&(p!==0||1/p===1/g)||p!==p&&g!==g}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,s=e.useEffect,o=e.useLayoutEffect,l=e.useDebugValue;function c(p,g){var v=g(),N=r({inst:{value:v,getSnapshot:g}}),k=N[0].inst,x=N[1];return o(function(){k.value=v,k.getSnapshot=g,d(k)&&x({inst:k})},[p,v,g]),s(function(){return d(k)&&x({inst:k}),p(function(){d(k)&&x({inst:k})})},[p]),l(v),v}function d(p){var g=p.getSnapshot;p=p.value;try{var v=g();return!n(p,v)}catch{return!0}}function h(p,g){return g()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:c;return yp.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,yp}var kN;function a4(){return kN||(kN=1,gp.exports=s4()),gp.exports}/**
49
- * @license React
50
- * use-sync-external-store-shim/with-selector.production.js
51
- *
52
- * Copyright (c) Meta Platforms, Inc. and affiliates.
53
- *
54
- * This source code is licensed under the MIT license found in the
55
- * LICENSE file in the root directory of this source tree.
56
- */var NN;function o4(){if(NN)return mp;NN=1;var e=oc(),t=a4();function n(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var r=typeof Object.is=="function"?Object.is:n,s=t.useSyncExternalStore,o=e.useRef,l=e.useEffect,c=e.useMemo,d=e.useDebugValue;return mp.useSyncExternalStoreWithSelector=function(h,f,p,g,v){var N=o(null);if(N.current===null){var k={hasValue:!1,value:null};N.current=k}else k=N.current;N=c(function(){function j(C){if(!b){if(b=!0,_=C,C=g(C),v!==void 0&&k.hasValue){var A=k.value;if(v(A,C))return E=A}return E=C}if(A=E,r(_,C))return A;var U=g(C);return v!==void 0&&v(A,U)?(_=C,A):(_=C,E=U)}var b=!1,_,E,R=p===void 0?null:p;return[function(){return j(f())},R===null?void 0:function(){return j(R())}]},[f,p,g,v]);var x=s(h,N[0],N[1]);return l(function(){k.hasValue=!0,k.value=x},[x]),d(x),x},mp}var jN;function i4(){return jN||(jN=1,pp.exports=o4()),pp.exports}var l4=i4();const c4=Tb(l4),u4={},SN=e=>{let t;const n=new Set,r=(f,p)=>{const g=typeof f=="function"?f(t):f;if(!Object.is(g,t)){const v=t;t=p??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(N=>N(t,v))}},s=()=>t,d={setState:r,getState:s,getInitialState:()=>h,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(u4?"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()}},h=t=e(r,s,d);return d},d4=e=>e?SN(e):SN,{useDebugValue:h4}=de,{useSyncExternalStoreWithSelector:f4}=c4,p4=e=>e;function bM(e,t=p4,n){const r=f4(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return h4(r),r}const _N=(e,t)=>{const n=d4(e),r=(s,o=t)=>bM(n,s,o);return Object.assign(r,n),r},m4=(e,t)=>e?_N(e,t):_N;function At(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[r,s]of e)if(!Object.is(s,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var g4={value:()=>{}};function zd(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Zu(n)}function Zu(e){this._=e}function y4(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",s=n.indexOf(".");if(s>=0&&(r=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Zu.prototype=zd.prototype={constructor:Zu,on:function(e,t){var n=this._,r=y4(e+"",n),s,o=-1,l=r.length;if(arguments.length<2){for(;++o<l;)if((s=(e=r[o]).type)&&(s=w4(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<l;)if(s=(e=r[o]).type)n[s]=EN(n[s],e.name,t);else if(t==null)for(s in n)n[s]=EN(n[s],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Zu(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),r=0,s,o;r<s;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],r=0,s=o.length;r<s;++r)o[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],s=0,o=r.length;s<o;++s)r[s].value.apply(t,n)}};function w4(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function EN(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=g4,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var gx="http://www.w3.org/1999/xhtml";const TN={svg:"http://www.w3.org/2000/svg",xhtml:gx,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Wd(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),TN.hasOwnProperty(t)?{space:TN[t],local:e}:e}function v4(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===gx&&t.documentElement.namespaceURI===gx?t.createElement(e):t.createElementNS(n,e)}}function x4(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function kM(e){var t=Wd(e);return(t.local?x4:v4)(t)}function b4(){}function Cb(e){return e==null?b4:function(){return this.querySelector(e)}}function k4(e){typeof e!="function"&&(e=Cb(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],l=o.length,c=r[s]=new Array(l),d,h,f=0;f<l;++f)(d=o[f])&&(h=e.call(d,d.__data__,f,o))&&("__data__"in d&&(h.__data__=d.__data__),c[f]=h);return new En(r,this._parents)}function N4(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function j4(){return[]}function NM(e){return e==null?j4:function(){return this.querySelectorAll(e)}}function S4(e){return function(){return N4(e.apply(this,arguments))}}function _4(e){typeof e=="function"?e=S4(e):e=NM(e);for(var t=this._groups,n=t.length,r=[],s=[],o=0;o<n;++o)for(var l=t[o],c=l.length,d,h=0;h<c;++h)(d=l[h])&&(r.push(e.call(d,d.__data__,h,l)),s.push(d));return new En(r,s)}function jM(e){return function(){return this.matches(e)}}function SM(e){return function(t){return t.matches(e)}}var E4=Array.prototype.find;function T4(e){return function(){return E4.call(this.children,e)}}function C4(){return this.firstElementChild}function A4(e){return this.select(e==null?C4:T4(typeof e=="function"?e:SM(e)))}var R4=Array.prototype.filter;function M4(){return Array.from(this.children)}function $4(e){return function(){return R4.call(this.children,e)}}function I4(e){return this.selectAll(e==null?M4:$4(typeof e=="function"?e:SM(e)))}function O4(e){typeof e!="function"&&(e=jM(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],l=o.length,c=r[s]=[],d,h=0;h<l;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&c.push(d);return new En(r,this._parents)}function _M(e){return new Array(e.length)}function L4(){return new En(this._enter||this._groups.map(_M),this._parents)}function cd(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}cd.prototype={constructor:cd,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 P4(e){return function(){return e}}function D4(e,t,n,r,s,o){for(var l=0,c,d=t.length,h=o.length;l<h;++l)(c=t[l])?(c.__data__=o[l],r[l]=c):n[l]=new cd(e,o[l]);for(;l<d;++l)(c=t[l])&&(s[l]=c)}function F4(e,t,n,r,s,o,l){var c,d,h=new Map,f=t.length,p=o.length,g=new Array(f),v;for(c=0;c<f;++c)(d=t[c])&&(g[c]=v=l.call(d,d.__data__,c,t)+"",h.has(v)?s[c]=d:h.set(v,d));for(c=0;c<p;++c)v=l.call(e,o[c],c,o)+"",(d=h.get(v))?(r[c]=d,d.__data__=o[c],h.delete(v)):n[c]=new cd(e,o[c]);for(c=0;c<f;++c)(d=t[c])&&h.get(g[c])===d&&(s[c]=d)}function B4(e){return e.__data__}function q4(e,t){if(!arguments.length)return Array.from(this,B4);var n=t?F4:D4,r=this._parents,s=this._groups;typeof e!="function"&&(e=P4(e));for(var o=s.length,l=new Array(o),c=new Array(o),d=new Array(o),h=0;h<o;++h){var f=r[h],p=s[h],g=p.length,v=U4(e.call(f,f&&f.__data__,h,r)),N=v.length,k=c[h]=new Array(N),x=l[h]=new Array(N),j=d[h]=new Array(g);n(f,p,k,x,j,v,t);for(var b=0,_=0,E,R;b<N;++b)if(E=k[b]){for(b>=_&&(_=b+1);!(R=x[_])&&++_<N;);E._next=R||null}}return l=new En(l,r),l._enter=c,l._exit=d,l}function U4(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function z4(){return new En(this._exit||this._groups.map(_M),this._parents)}function W4(e,t,n){var r=this.enter(),s=this,o=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?o.remove():n(o),r&&s?r.merge(s).order():s}function H4(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,o=r.length,l=Math.min(s,o),c=new Array(s),d=0;d<l;++d)for(var h=n[d],f=r[d],p=h.length,g=c[d]=new Array(p),v,N=0;N<p;++N)(v=h[N]||f[N])&&(g[N]=v);for(;d<s;++d)c[d]=n[d];return new En(c,this._parents)}function V4(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],s=r.length-1,o=r[s],l;--s>=0;)(l=r[s])&&(o&&l.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(l,o),o=l);return this}function G4(e){e||(e=K4);function t(p,g){return p&&g?e(p.__data__,g.__data__):!p-!g}for(var n=this._groups,r=n.length,s=new Array(r),o=0;o<r;++o){for(var l=n[o],c=l.length,d=s[o]=new Array(c),h,f=0;f<c;++f)(h=l[f])&&(d[f]=h);d.sort(t)}return new En(s,this._parents).order()}function K4(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Y4(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function X4(){return Array.from(this)}function Z4(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,o=r.length;s<o;++s){var l=r[s];if(l)return l}return null}function J4(){let e=0;for(const t of this)++e;return e}function Q4(){return!this.node()}function eD(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var s=t[n],o=0,l=s.length,c;o<l;++o)(c=s[o])&&e.call(c,c.__data__,o,s);return this}function tD(e){return function(){this.removeAttribute(e)}}function nD(e){return function(){this.removeAttributeNS(e.space,e.local)}}function rD(e,t){return function(){this.setAttribute(e,t)}}function sD(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function aD(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function oD(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 iD(e,t){var n=Wd(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?nD:tD:typeof t=="function"?n.local?oD:aD:n.local?sD:rD)(n,t))}function EM(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function lD(e){return function(){this.style.removeProperty(e)}}function cD(e,t,n){return function(){this.style.setProperty(e,t,n)}}function uD(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function dD(e,t,n){return arguments.length>1?this.each((t==null?lD:typeof t=="function"?uD:cD)(e,t,n??"")):li(this.node(),e)}function li(e,t){return e.style.getPropertyValue(t)||EM(e).getComputedStyle(e,null).getPropertyValue(t)}function hD(e){return function(){delete this[e]}}function fD(e,t){return function(){this[e]=t}}function pD(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function mD(e,t){return arguments.length>1?this.each((t==null?hD:typeof t=="function"?pD:fD)(e,t)):this.node()[e]}function TM(e){return e.trim().split(/^|\s+/)}function Ab(e){return e.classList||new CM(e)}function CM(e){this._node=e,this._names=TM(e.getAttribute("class")||"")}CM.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 AM(e,t){for(var n=Ab(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function RM(e,t){for(var n=Ab(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function gD(e){return function(){AM(this,e)}}function yD(e){return function(){RM(this,e)}}function wD(e,t){return function(){(t.apply(this,arguments)?AM:RM)(this,e)}}function vD(e,t){var n=TM(e+"");if(arguments.length<2){for(var r=Ab(this.node()),s=-1,o=n.length;++s<o;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?wD:t?gD:yD)(n,t))}function xD(){this.textContent=""}function bD(e){return function(){this.textContent=e}}function kD(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function ND(e){return arguments.length?this.each(e==null?xD:(typeof e=="function"?kD:bD)(e)):this.node().textContent}function jD(){this.innerHTML=""}function SD(e){return function(){this.innerHTML=e}}function _D(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function ED(e){return arguments.length?this.each(e==null?jD:(typeof e=="function"?_D:SD)(e)):this.node().innerHTML}function TD(){this.nextSibling&&this.parentNode.appendChild(this)}function CD(){return this.each(TD)}function AD(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function RD(){return this.each(AD)}function MD(e){var t=typeof e=="function"?e:kM(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function $D(){return null}function ID(e,t){var n=typeof e=="function"?e:kM(e),r=t==null?$D:typeof t=="function"?t:Cb(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function OD(){var e=this.parentNode;e&&e.removeChild(this)}function LD(){return this.each(OD)}function PD(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function DD(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function FD(e){return this.select(e?DD:PD)}function BD(e){return arguments.length?this.property("__data__",e):this.node().__data__}function qD(e){return function(t){e.call(this,t,this.__data__)}}function UD(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function zD(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,o;n<s;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++r]=o;++r?t.length=r:delete this.__on}}}function WD(e,t,n){return function(){var r=this.__on,s,o=qD(t);if(r){for(var l=0,c=r.length;l<c;++l)if((s=r[l]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=o,s.options=n),s.value=t;return}}this.addEventListener(e.type,o,n),s={type:e.type,name:e.name,value:t,listener:o,options:n},r?r.push(s):this.__on=[s]}}function HD(e,t,n){var r=UD(e+""),s,o=r.length,l;if(arguments.length<2){var c=this.node().__on;if(c){for(var d=0,h=c.length,f;d<h;++d)for(s=0,f=c[d];s<o;++s)if((l=r[s]).type===f.type&&l.name===f.name)return f.value}return}for(c=t?WD:zD,s=0;s<o;++s)this.each(c(r[s],t,n));return this}function MM(e,t,n){var r=EM(e),s=r.CustomEvent;typeof s=="function"?s=new s(t,n):(s=r.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function VD(e,t){return function(){return MM(this,e,t)}}function GD(e,t){return function(){return MM(this,e,t.apply(this,arguments))}}function KD(e,t){return this.each((typeof t=="function"?GD:VD)(e,t))}function*YD(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,o=r.length,l;s<o;++s)(l=r[s])&&(yield l)}var $M=[null];function En(e,t){this._groups=e,this._parents=t}function ic(){return new En([[document.documentElement]],$M)}function XD(){return this}En.prototype=ic.prototype={constructor:En,select:k4,selectAll:_4,selectChild:A4,selectChildren:I4,filter:O4,data:q4,enter:L4,exit:z4,join:W4,merge:H4,selection:XD,order:V4,sort:G4,call:Y4,nodes:X4,node:Z4,size:J4,empty:Q4,each:eD,attr:iD,style:dD,property:mD,classed:vD,text:ND,html:ED,raise:CD,lower:RD,append:MD,insert:ID,remove:LD,clone:FD,datum:BD,on:HD,dispatch:KD,[Symbol.iterator]:YD};function qn(e){return typeof e=="string"?new En([[document.querySelector(e)]],[document.documentElement]):new En([[e]],$M)}function ZD(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ar(e,t){if(e=ZD(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}const JD={passive:!1},Ol={capture:!0,passive:!1};function wp(e){e.stopImmediatePropagation()}function ni(e){e.preventDefault(),e.stopImmediatePropagation()}function IM(e){var t=e.document.documentElement,n=qn(e).on("dragstart.drag",ni,Ol);"onselectstart"in t?n.on("selectstart.drag",ni,Ol):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function OM(e,t){var n=e.document.documentElement,r=qn(e).on("dragstart.drag",null);t&&(r.on("click.drag",ni,Ol),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Su=e=>()=>e;function yx(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:o,x:l,y:c,dx:d,dy:h,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:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:l,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:d,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:f}})}yx.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function QD(e){return!e.ctrlKey&&!e.button}function eF(){return this.parentNode}function tF(e,t){return t??{x:e.x,y:e.y}}function nF(){return navigator.maxTouchPoints||"ontouchstart"in this}function rF(){var e=QD,t=eF,n=tF,r=nF,s={},o=zd("start","drag","end"),l=0,c,d,h,f,p=0;function g(E){E.on("mousedown.drag",v).filter(r).on("touchstart.drag",x).on("touchmove.drag",j,JD).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(E,R){if(!(f||!e.call(this,E,R))){var C=_(this,t.call(this,E,R),E,R,"mouse");C&&(qn(E.view).on("mousemove.drag",N,Ol).on("mouseup.drag",k,Ol),IM(E.view),wp(E),h=!1,c=E.clientX,d=E.clientY,C("start",E))}}function N(E){if(ni(E),!h){var R=E.clientX-c,C=E.clientY-d;h=R*R+C*C>p}s.mouse("drag",E)}function k(E){qn(E.view).on("mousemove.drag mouseup.drag",null),OM(E.view,h),ni(E),s.mouse("end",E)}function x(E,R){if(e.call(this,E,R)){var C=E.changedTouches,A=t.call(this,E,R),U=C.length,L,F;for(L=0;L<U;++L)(F=_(this,A,E,R,C[L].identifier,C[L]))&&(wp(E),F("start",E,C[L]))}}function j(E){var R=E.changedTouches,C=R.length,A,U;for(A=0;A<C;++A)(U=s[R[A].identifier])&&(ni(E),U("drag",E,R[A]))}function b(E){var R=E.changedTouches,C=R.length,A,U;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),A=0;A<C;++A)(U=s[R[A].identifier])&&(wp(E),U("end",E,R[A]))}function _(E,R,C,A,U,L){var F=o.copy(),O=ar(L||C,R),I,B,M;if((M=n.call(E,new yx("beforestart",{sourceEvent:C,target:g,identifier:U,active:l,x:O[0],y:O[1],dx:0,dy:0,dispatch:F}),A))!=null)return I=M.x-O[0]||0,B=M.y-O[1]||0,function $(P,G,K){var q=O,H;switch(P){case"start":s[U]=$,H=l++;break;case"end":delete s[U],--l;case"drag":O=ar(K||G,R),H=l;break}F.call(P,E,new yx(P,{sourceEvent:G,subject:M,target:g,identifier:U,active:H,x:O[0]+I,y:O[1]+B,dx:O[0]-q[0],dy:O[1]-q[1],dispatch:F}),A)}}return g.filter=function(E){return arguments.length?(e=typeof E=="function"?E:Su(!!E),g):e},g.container=function(E){return arguments.length?(t=typeof E=="function"?E:Su(E),g):t},g.subject=function(E){return arguments.length?(n=typeof E=="function"?E:Su(E),g):n},g.touchable=function(E){return arguments.length?(r=typeof E=="function"?E:Su(!!E),g):r},g.on=function(){var E=o.on.apply(o,arguments);return E===o?g:E},g.clickDistance=function(E){return arguments.length?(p=(E=+E)*E,g):Math.sqrt(p)},g}function Rb(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function LM(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function lc(){}var Ll=.7,ud=1/Ll,ri="\\s*([+-]?\\d+)\\s*",Pl="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Pr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",sF=/^#([0-9a-f]{3,8})$/,aF=new RegExp(`^rgb\\(${ri},${ri},${ri}\\)$`),oF=new RegExp(`^rgb\\(${Pr},${Pr},${Pr}\\)$`),iF=new RegExp(`^rgba\\(${ri},${ri},${ri},${Pl}\\)$`),lF=new RegExp(`^rgba\\(${Pr},${Pr},${Pr},${Pl}\\)$`),cF=new RegExp(`^hsl\\(${Pl},${Pr},${Pr}\\)$`),uF=new RegExp(`^hsla\\(${Pl},${Pr},${Pr},${Pl}\\)$`),CN={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};Rb(lc,Dl,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:AN,formatHex:AN,formatHex8:dF,formatHsl:hF,formatRgb:RN,toString:RN});function AN(){return this.rgb().formatHex()}function dF(){return this.rgb().formatHex8()}function hF(){return PM(this).formatHsl()}function RN(){return this.rgb().formatRgb()}function Dl(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=sF.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?MN(t):n===3?new hn(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?_u(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?_u(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=aF.exec(e))?new hn(t[1],t[2],t[3],1):(t=oF.exec(e))?new hn(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=iF.exec(e))?_u(t[1],t[2],t[3],t[4]):(t=lF.exec(e))?_u(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=cF.exec(e))?ON(t[1],t[2]/100,t[3]/100,1):(t=uF.exec(e))?ON(t[1],t[2]/100,t[3]/100,t[4]):CN.hasOwnProperty(e)?MN(CN[e]):e==="transparent"?new hn(NaN,NaN,NaN,0):null}function MN(e){return new hn(e>>16&255,e>>8&255,e&255,1)}function _u(e,t,n,r){return r<=0&&(e=t=n=NaN),new hn(e,t,n,r)}function fF(e){return e instanceof lc||(e=Dl(e)),e?(e=e.rgb(),new hn(e.r,e.g,e.b,e.opacity)):new hn}function wx(e,t,n,r){return arguments.length===1?fF(e):new hn(e,t,n,r??1)}function hn(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Rb(hn,wx,LM(lc,{brighter(e){return e=e==null?ud:Math.pow(ud,e),new hn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ll:Math.pow(Ll,e),new hn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new hn(za(this.r),za(this.g),za(this.b),dd(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:$N,formatHex:$N,formatHex8:pF,formatRgb:IN,toString:IN}));function $N(){return`#${Ba(this.r)}${Ba(this.g)}${Ba(this.b)}`}function pF(){return`#${Ba(this.r)}${Ba(this.g)}${Ba(this.b)}${Ba((isNaN(this.opacity)?1:this.opacity)*255)}`}function IN(){const e=dd(this.opacity);return`${e===1?"rgb(":"rgba("}${za(this.r)}, ${za(this.g)}, ${za(this.b)}${e===1?")":`, ${e})`}`}function dd(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function za(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ba(e){return e=za(e),(e<16?"0":"")+e.toString(16)}function ON(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new or(e,t,n,r)}function PM(e){if(e instanceof or)return new or(e.h,e.s,e.l,e.opacity);if(e instanceof lc||(e=Dl(e)),!e)return new or;if(e instanceof or)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),o=Math.max(t,n,r),l=NaN,c=o-s,d=(o+s)/2;return c?(t===o?l=(n-r)/c+(n<r)*6:n===o?l=(r-t)/c+2:l=(t-n)/c+4,c/=d<.5?o+s:2-o-s,l*=60):c=d>0&&d<1?0:l,new or(l,c,d,e.opacity)}function mF(e,t,n,r){return arguments.length===1?PM(e):new or(e,t,n,r??1)}function or(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Rb(or,mF,LM(lc,{brighter(e){return e=e==null?ud:Math.pow(ud,e),new or(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ll:Math.pow(Ll,e),new or(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,r=n+(n<.5?n:1-n)*t,s=2*n-r;return new hn(vp(e>=240?e-240:e+120,s,r),vp(e,s,r),vp(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new or(LN(this.h),Eu(this.s),Eu(this.l),dd(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=dd(this.opacity);return`${e===1?"hsl(":"hsla("}${LN(this.h)}, ${Eu(this.s)*100}%, ${Eu(this.l)*100}%${e===1?")":`, ${e})`}`}}));function LN(e){return e=(e||0)%360,e<0?e+360:e}function Eu(e){return Math.max(0,Math.min(1,e||0))}function vp(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 DM=e=>()=>e;function gF(e,t){return function(n){return e+n*t}}function yF(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function wF(e){return(e=+e)==1?FM:function(t,n){return n-t?yF(t,n,e):DM(isNaN(t)?n:t)}}function FM(e,t){var n=t-e;return n?gF(e,n):DM(isNaN(e)?t:e)}const PN=(function e(t){var n=wF(t);function r(s,o){var l=n((s=wx(s)).r,(o=wx(o)).r),c=n(s.g,o.g),d=n(s.b,o.b),h=FM(s.opacity,o.opacity);return function(f){return s.r=l(f),s.g=c(f),s.b=d(f),s.opacity=h(f),s+""}}return r.gamma=e,r})(1);function Zs(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var vx=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,xp=new RegExp(vx.source,"g");function vF(e){return function(){return e}}function xF(e){return function(t){return e(t)+""}}function bF(e,t){var n=vx.lastIndex=xp.lastIndex=0,r,s,o,l=-1,c=[],d=[];for(e=e+"",t=t+"";(r=vx.exec(e))&&(s=xp.exec(t));)(o=s.index)>n&&(o=t.slice(n,o),c[l]?c[l]+=o:c[++l]=o),(r=r[0])===(s=s[0])?c[l]?c[l]+=s:c[++l]=s:(c[++l]=null,d.push({i:l,x:Zs(r,s)})),n=xp.lastIndex;return n<t.length&&(o=t.slice(n),c[l]?c[l]+=o:c[++l]=o),c.length<2?d[0]?xF(d[0].x):vF(t):(t=d.length,function(h){for(var f=0,p;f<t;++f)c[(p=d[f]).i]=p.x(h);return c.join("")})}var DN=180/Math.PI,xx={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function BM(e,t,n,r,s,o){var l,c,d;return(l=Math.sqrt(e*e+t*t))&&(e/=l,t/=l),(d=e*n+t*r)&&(n-=e*d,r-=t*d),(c=Math.sqrt(n*n+r*r))&&(n/=c,r/=c,d/=c),e*r<t*n&&(e=-e,t=-t,d=-d,l=-l),{translateX:s,translateY:o,rotate:Math.atan2(t,e)*DN,skewX:Math.atan(d)*DN,scaleX:l,scaleY:c}}var Tu;function kF(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?xx:BM(t.a,t.b,t.c,t.d,t.e,t.f)}function NF(e){return e==null||(Tu||(Tu=document.createElementNS("http://www.w3.org/2000/svg","g")),Tu.setAttribute("transform",e),!(e=Tu.transform.baseVal.consolidate()))?xx:(e=e.matrix,BM(e.a,e.b,e.c,e.d,e.e,e.f))}function qM(e,t,n,r){function s(h){return h.length?h.pop()+" ":""}function o(h,f,p,g,v,N){if(h!==p||f!==g){var k=v.push("translate(",null,t,null,n);N.push({i:k-4,x:Zs(h,p)},{i:k-2,x:Zs(f,g)})}else(p||g)&&v.push("translate("+p+t+g+n)}function l(h,f,p,g){h!==f?(h-f>180?f+=360:f-h>180&&(h+=360),g.push({i:p.push(s(p)+"rotate(",null,r)-2,x:Zs(h,f)})):f&&p.push(s(p)+"rotate("+f+r)}function c(h,f,p,g){h!==f?g.push({i:p.push(s(p)+"skewX(",null,r)-2,x:Zs(h,f)}):f&&p.push(s(p)+"skewX("+f+r)}function d(h,f,p,g,v,N){if(h!==p||f!==g){var k=v.push(s(v)+"scale(",null,",",null,")");N.push({i:k-4,x:Zs(h,p)},{i:k-2,x:Zs(f,g)})}else(p!==1||g!==1)&&v.push(s(v)+"scale("+p+","+g+")")}return function(h,f){var p=[],g=[];return h=e(h),f=e(f),o(h.translateX,h.translateY,f.translateX,f.translateY,p,g),l(h.rotate,f.rotate,p,g),c(h.skewX,f.skewX,p,g),d(h.scaleX,h.scaleY,f.scaleX,f.scaleY,p,g),h=f=null,function(v){for(var N=-1,k=g.length,x;++N<k;)p[(x=g[N]).i]=x.x(v);return p.join("")}}}var jF=qM(kF,"px, ","px)","deg)"),SF=qM(NF,", ",")",")"),_F=1e-12;function FN(e){return((e=Math.exp(e))+1/e)/2}function EF(e){return((e=Math.exp(e))-1/e)/2}function TF(e){return((e=Math.exp(2*e))-1)/(e+1)}const CF=(function e(t,n,r){function s(o,l){var c=o[0],d=o[1],h=o[2],f=l[0],p=l[1],g=l[2],v=f-c,N=p-d,k=v*v+N*N,x,j;if(k<_F)j=Math.log(g/h)/t,x=function(A){return[c+A*v,d+A*N,h*Math.exp(t*A*j)]};else{var b=Math.sqrt(k),_=(g*g-h*h+r*k)/(2*h*n*b),E=(g*g-h*h-r*k)/(2*g*n*b),R=Math.log(Math.sqrt(_*_+1)-_),C=Math.log(Math.sqrt(E*E+1)-E);j=(C-R)/t,x=function(A){var U=A*j,L=FN(R),F=h/(n*b)*(L*TF(t*U+R)-EF(R));return[c+F*v,d+F*N,h*L/FN(t*U+R)]}}return x.duration=j*1e3*t/Math.SQRT2,x}return s.rho=function(o){var l=Math.max(.001,+o),c=l*l,d=c*c;return e(l,c,d)},s})(Math.SQRT2,2,4);var ci=0,kl=0,fl=0,UM=1e3,hd,Nl,fd=0,Ka=0,Hd=0,Fl=typeof performance=="object"&&performance.now?performance:Date,zM=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Mb(){return Ka||(zM(AF),Ka=Fl.now()+Hd)}function AF(){Ka=0}function pd(){this._call=this._time=this._next=null}pd.prototype=WM.prototype={constructor:pd,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Mb():+n)+(t==null?0:+t),!this._next&&Nl!==this&&(Nl?Nl._next=this:hd=this,Nl=this),this._call=e,this._time=n,bx()},stop:function(){this._call&&(this._call=null,this._time=1/0,bx())}};function WM(e,t,n){var r=new pd;return r.restart(e,t,n),r}function RF(){Mb(),++ci;for(var e=hd,t;e;)(t=Ka-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ci}function BN(){Ka=(fd=Fl.now())+Hd,ci=kl=0;try{RF()}finally{ci=0,$F(),Ka=0}}function MF(){var e=Fl.now(),t=e-fd;t>UM&&(Hd-=t,fd=e)}function $F(){for(var e,t=hd,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:hd=n);Nl=e,bx(r)}function bx(e){if(!ci){kl&&(kl=clearTimeout(kl));var t=e-Ka;t>24?(e<1/0&&(kl=setTimeout(BN,e-Fl.now()-Hd)),fl&&(fl=clearInterval(fl))):(fl||(fd=Fl.now(),fl=setInterval(MF,UM)),ci=1,zM(BN))}}function qN(e,t,n){var r=new pd;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var IF=zd("start","end","cancel","interrupt"),OF=[],HM=0,UN=1,kx=2,Ju=3,zN=4,Nx=5,Qu=6;function Vd(e,t,n,r,s,o){var l=e.__transition;if(!l)e.__transition={};else if(n in l)return;LF(e,n,{name:t,index:r,group:s,on:IF,tween:OF,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:HM})}function $b(e,t){var n=fr(e,t);if(n.state>HM)throw new Error("too late; already scheduled");return n}function qr(e,t){var n=fr(e,t);if(n.state>Ju)throw new Error("too late; already running");return n}function fr(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function LF(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=WM(o,0,n.time);function o(h){n.state=UN,n.timer.restart(l,n.delay,n.time),n.delay<=h&&l(h-n.delay)}function l(h){var f,p,g,v;if(n.state!==UN)return d();for(f in r)if(v=r[f],v.name===n.name){if(v.state===Ju)return qN(l);v.state===zN?(v.state=Qu,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete r[f]):+f<t&&(v.state=Qu,v.timer.stop(),v.on.call("cancel",e,e.__data__,v.index,v.group),delete r[f])}if(qN(function(){n.state===Ju&&(n.state=zN,n.timer.restart(c,n.delay,n.time),c(h))}),n.state=kx,n.on.call("start",e,e.__data__,n.index,n.group),n.state===kx){for(n.state=Ju,s=new Array(g=n.tween.length),f=0,p=-1;f<g;++f)(v=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(s[++p]=v);s.length=p+1}}function c(h){for(var f=h<n.duration?n.ease.call(null,h/n.duration):(n.timer.restart(d),n.state=Nx,1),p=-1,g=s.length;++p<g;)s[p].call(e,f);n.state===Nx&&(n.on.call("end",e,e.__data__,n.index,n.group),d())}function d(){n.state=Qu,n.timer.stop(),delete r[t];for(var h in r)return;delete e.__transition}}function ed(e,t){var n=e.__transition,r,s,o=!0,l;if(n){t=t==null?null:t+"";for(l in n){if((r=n[l]).name!==t){o=!1;continue}s=r.state>kx&&r.state<Nx,r.state=Qu,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[l]}o&&delete e.__transition}}function PF(e){return this.each(function(){ed(this,e)})}function DF(e,t){var n,r;return function(){var s=qr(this,e),o=s.tween;if(o!==n){r=n=o;for(var l=0,c=r.length;l<c;++l)if(r[l].name===t){r=r.slice(),r.splice(l,1);break}}s.tween=r}}function FF(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var o=qr(this,e),l=o.tween;if(l!==r){s=(r=l).slice();for(var c={name:t,value:n},d=0,h=s.length;d<h;++d)if(s[d].name===t){s[d]=c;break}d===h&&s.push(c)}o.tween=s}}function BF(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=fr(this.node(),n).tween,s=0,o=r.length,l;s<o;++s)if((l=r[s]).name===e)return l.value;return null}return this.each((t==null?DF:FF)(n,e,t))}function Ib(e,t,n){var r=e._id;return e.each(function(){var s=qr(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return fr(s,r).value[t]}}function VM(e,t){var n;return(typeof t=="number"?Zs:t instanceof Dl?PN:(n=Dl(t))?(t=n,PN):bF)(e,t)}function qF(e){return function(){this.removeAttribute(e)}}function UF(e){return function(){this.removeAttributeNS(e.space,e.local)}}function zF(e,t,n){var r,s=n+"",o;return function(){var l=this.getAttribute(e);return l===s?null:l===r?o:o=t(r=l,n)}}function WF(e,t,n){var r,s=n+"",o;return function(){var l=this.getAttributeNS(e.space,e.local);return l===s?null:l===r?o:o=t(r=l,n)}}function HF(e,t,n){var r,s,o;return function(){var l,c=n(this),d;return c==null?void this.removeAttribute(e):(l=this.getAttribute(e),d=c+"",l===d?null:l===r&&d===s?o:(s=d,o=t(r=l,c)))}}function VF(e,t,n){var r,s,o;return function(){var l,c=n(this),d;return c==null?void this.removeAttributeNS(e.space,e.local):(l=this.getAttributeNS(e.space,e.local),d=c+"",l===d?null:l===r&&d===s?o:(s=d,o=t(r=l,c)))}}function GF(e,t){var n=Wd(e),r=n==="transform"?SF:VM;return this.attrTween(e,typeof t=="function"?(n.local?VF:HF)(n,r,Ib(this,"attr."+e,t)):t==null?(n.local?UF:qF)(n):(n.local?WF:zF)(n,r,t))}function KF(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function YF(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function XF(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&YF(e,o)),n}return s._value=t,s}function ZF(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&KF(e,o)),n}return s._value=t,s}function JF(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 r=Wd(e);return this.tween(n,(r.local?XF:ZF)(r,t))}function QF(e,t){return function(){$b(this,e).delay=+t.apply(this,arguments)}}function e5(e,t){return t=+t,function(){$b(this,e).delay=t}}function t5(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?QF:e5)(t,e)):fr(this.node(),t).delay}function n5(e,t){return function(){qr(this,e).duration=+t.apply(this,arguments)}}function r5(e,t){return t=+t,function(){qr(this,e).duration=t}}function s5(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?n5:r5)(t,e)):fr(this.node(),t).duration}function a5(e,t){if(typeof t!="function")throw new Error;return function(){qr(this,e).ease=t}}function o5(e){var t=this._id;return arguments.length?this.each(a5(t,e)):fr(this.node(),t).ease}function i5(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;qr(this,e).ease=n}}function l5(e){if(typeof e!="function")throw new Error;return this.each(i5(this._id,e))}function c5(e){typeof e!="function"&&(e=jM(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],l=o.length,c=r[s]=[],d,h=0;h<l;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&c.push(d);return new fs(r,this._parents,this._name,this._id)}function u5(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,s=n.length,o=Math.min(r,s),l=new Array(r),c=0;c<o;++c)for(var d=t[c],h=n[c],f=d.length,p=l[c]=new Array(f),g,v=0;v<f;++v)(g=d[v]||h[v])&&(p[v]=g);for(;c<r;++c)l[c]=t[c];return new fs(l,this._parents,this._name,this._id)}function d5(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 h5(e,t,n){var r,s,o=d5(t)?$b:qr;return function(){var l=o(this,e),c=l.on;c!==r&&(s=(r=c).copy()).on(t,n),l.on=s}}function f5(e,t){var n=this._id;return arguments.length<2?fr(this.node(),n).on.on(e):this.each(h5(n,e,t))}function p5(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function m5(){return this.on("end.remove",p5(this._id))}function g5(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Cb(e));for(var r=this._groups,s=r.length,o=new Array(s),l=0;l<s;++l)for(var c=r[l],d=c.length,h=o[l]=new Array(d),f,p,g=0;g<d;++g)(f=c[g])&&(p=e.call(f,f.__data__,g,c))&&("__data__"in f&&(p.__data__=f.__data__),h[g]=p,Vd(h[g],t,n,g,h,fr(f,n)));return new fs(o,this._parents,t,n)}function y5(e){var t=this._name,n=this._id;typeof e!="function"&&(e=NM(e));for(var r=this._groups,s=r.length,o=[],l=[],c=0;c<s;++c)for(var d=r[c],h=d.length,f,p=0;p<h;++p)if(f=d[p]){for(var g=e.call(f,f.__data__,p,d),v,N=fr(f,n),k=0,x=g.length;k<x;++k)(v=g[k])&&Vd(v,t,n,k,g,N);o.push(g),l.push(f)}return new fs(o,l,t,n)}var w5=ic.prototype.constructor;function v5(){return new w5(this._groups,this._parents)}function x5(e,t){var n,r,s;return function(){var o=li(this,e),l=(this.style.removeProperty(e),li(this,e));return o===l?null:o===n&&l===r?s:s=t(n=o,r=l)}}function GM(e){return function(){this.style.removeProperty(e)}}function b5(e,t,n){var r,s=n+"",o;return function(){var l=li(this,e);return l===s?null:l===r?o:o=t(r=l,n)}}function k5(e,t,n){var r,s,o;return function(){var l=li(this,e),c=n(this),d=c+"";return c==null&&(d=c=(this.style.removeProperty(e),li(this,e))),l===d?null:l===r&&d===s?o:(s=d,o=t(r=l,c))}}function N5(e,t){var n,r,s,o="style."+t,l="end."+o,c;return function(){var d=qr(this,e),h=d.on,f=d.value[o]==null?c||(c=GM(t)):void 0;(h!==n||s!==f)&&(r=(n=h).copy()).on(l,s=f),d.on=r}}function j5(e,t,n){var r=(e+="")=="transform"?jF:VM;return t==null?this.styleTween(e,x5(e,r)).on("end.style."+e,GM(e)):typeof t=="function"?this.styleTween(e,k5(e,r,Ib(this,"style."+e,t))).each(N5(this._id,e)):this.styleTween(e,b5(e,r,t),n).on("end.style."+e,null)}function S5(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function _5(e,t,n){var r,s;function o(){var l=t.apply(this,arguments);return l!==s&&(r=(s=l)&&S5(e,l,n)),r}return o._value=t,o}function E5(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,_5(e,t,n??""))}function T5(e){return function(){this.textContent=e}}function C5(e){return function(){var t=e(this);this.textContent=t??""}}function A5(e){return this.tween("text",typeof e=="function"?C5(Ib(this,"text",e)):T5(e==null?"":e+""))}function R5(e){return function(t){this.textContent=e.call(this,t)}}function M5(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&R5(s)),t}return r._value=e,r}function $5(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,M5(e))}function I5(){for(var e=this._name,t=this._id,n=KM(),r=this._groups,s=r.length,o=0;o<s;++o)for(var l=r[o],c=l.length,d,h=0;h<c;++h)if(d=l[h]){var f=fr(d,t);Vd(d,e,n,h,l,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new fs(r,this._parents,e,n)}function O5(){var e,t,n=this,r=n._id,s=n.size();return new Promise(function(o,l){var c={value:l},d={value:function(){--s===0&&o()}};n.each(function(){var h=qr(this,r),f=h.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(c),t._.interrupt.push(c),t._.end.push(d)),h.on=t}),s===0&&o()})}var L5=0;function fs(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function KM(){return++L5}var os=ic.prototype;fs.prototype={constructor:fs,select:g5,selectAll:y5,selectChild:os.selectChild,selectChildren:os.selectChildren,filter:c5,merge:u5,selection:v5,transition:I5,call:os.call,nodes:os.nodes,node:os.node,size:os.size,empty:os.empty,each:os.each,on:f5,attr:GF,attrTween:JF,style:j5,styleTween:E5,text:A5,textTween:$5,remove:m5,tween:BF,delay:t5,duration:s5,ease:o5,easeVarying:l5,end:O5,[Symbol.iterator]:os[Symbol.iterator]};function P5(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var D5={time:null,delay:0,duration:250,ease:P5};function F5(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 B5(e){var t,n;e instanceof fs?(t=e._id,e=e._name):(t=KM(),(n=D5).time=Mb(),e=e==null?null:e+"");for(var r=this._groups,s=r.length,o=0;o<s;++o)for(var l=r[o],c=l.length,d,h=0;h<c;++h)(d=l[h])&&Vd(d,e,t,h,l,n||F5(d,t));return new fs(r,this._parents,e,t)}ic.prototype.interrupt=PF;ic.prototype.transition=B5;const Cu=e=>()=>e;function q5(e,{sourceEvent:t,target:n,transform:r,dispatch:s}){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:r,enumerable:!0,configurable:!0},_:{value:s}})}function ls(e,t,n){this.k=e,this.x=t,this.y=n}ls.prototype={constructor:ls,scale:function(e){return e===1?this:new ls(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ls(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 us=new ls(1,0,0);ls.prototype;function bp(e){e.stopImmediatePropagation()}function pl(e){e.preventDefault(),e.stopImmediatePropagation()}function U5(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function z5(){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 WN(){return this.__zoom||us}function W5(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function H5(){return navigator.maxTouchPoints||"ontouchstart"in this}function V5(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],l=e.invertY(t[1][1])-n[1][1];return e.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),l>o?(o+l)/2:Math.min(0,o)||Math.max(0,l))}function YM(){var e=U5,t=z5,n=V5,r=W5,s=H5,o=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,d=CF,h=zd("start","zoom","end"),f,p,g,v=500,N=150,k=0,x=10;function j(M){M.property("__zoom",WN).on("wheel.zoom",U,{passive:!1}).on("mousedown.zoom",L).on("dblclick.zoom",F).filter(s).on("touchstart.zoom",O).on("touchmove.zoom",I).on("touchend.zoom touchcancel.zoom",B).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}j.transform=function(M,$,P,G){var K=M.selection?M.selection():M;K.property("__zoom",WN),M!==K?R(M,$,P,G):K.interrupt().each(function(){C(this,arguments).event(G).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},j.scaleBy=function(M,$,P,G){j.scaleTo(M,function(){var K=this.__zoom.k,q=typeof $=="function"?$.apply(this,arguments):$;return K*q},P,G)},j.scaleTo=function(M,$,P,G){j.transform(M,function(){var K=t.apply(this,arguments),q=this.__zoom,H=P==null?E(K):typeof P=="function"?P.apply(this,arguments):P,D=q.invert(H),W=typeof $=="function"?$.apply(this,arguments):$;return n(_(b(q,W),H,D),K,l)},P,G)},j.translateBy=function(M,$,P,G){j.transform(M,function(){return n(this.__zoom.translate(typeof $=="function"?$.apply(this,arguments):$,typeof P=="function"?P.apply(this,arguments):P),t.apply(this,arguments),l)},null,G)},j.translateTo=function(M,$,P,G,K){j.transform(M,function(){var q=t.apply(this,arguments),H=this.__zoom,D=G==null?E(q):typeof G=="function"?G.apply(this,arguments):G;return n(us.translate(D[0],D[1]).scale(H.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof P=="function"?-P.apply(this,arguments):-P),q,l)},G,K)};function b(M,$){return $=Math.max(o[0],Math.min(o[1],$)),$===M.k?M:new ls($,M.x,M.y)}function _(M,$,P){var G=$[0]-P[0]*M.k,K=$[1]-P[1]*M.k;return G===M.x&&K===M.y?M:new ls(M.k,G,K)}function E(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function R(M,$,P,G){M.on("start.zoom",function(){C(this,arguments).event(G).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(G).end()}).tween("zoom",function(){var K=this,q=arguments,H=C(K,q).event(G),D=t.apply(K,q),W=P==null?E(D):typeof P=="function"?P.apply(K,q):P,J=Math.max(D[1][0]-D[0][0],D[1][1]-D[0][1]),V=K.__zoom,X=typeof $=="function"?$.apply(K,q):$,Y=d(V.invert(W).concat(J/V.k),X.invert(W).concat(J/X.k));return function(Z){if(Z===1)Z=X;else{var ee=Y(Z),ne=J/ee[2];Z=new ls(ne,W[0]-ee[0]*ne,W[1]-ee[1]*ne)}H.zoom(null,Z)}})}function C(M,$,P){return!P&&M.__zooming||new A(M,$)}function A(M,$){this.that=M,this.args=$,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,$),this.taps=0}A.prototype={event:function(M){return M&&(this.sourceEvent=M),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(M,$){return this.mouse&&M!=="mouse"&&(this.mouse[1]=$.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=$.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=$.invert(this.touch1[0])),this.that.__zoom=$,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var $=qn(this.that).datum();h.call(M,this.that,new q5(M,{sourceEvent:this.sourceEvent,target:j,transform:this.that.__zoom,dispatch:h}),$)}};function U(M,...$){if(!e.apply(this,arguments))return;var P=C(this,$).event(M),G=this.__zoom,K=Math.max(o[0],Math.min(o[1],G.k*Math.pow(2,r.apply(this,arguments)))),q=ar(M);if(P.wheel)(P.mouse[0][0]!==q[0]||P.mouse[0][1]!==q[1])&&(P.mouse[1]=G.invert(P.mouse[0]=q)),clearTimeout(P.wheel);else{if(G.k===K)return;P.mouse=[q,G.invert(q)],ed(this),P.start()}pl(M),P.wheel=setTimeout(H,N),P.zoom("mouse",n(_(b(G,K),P.mouse[0],P.mouse[1]),P.extent,l));function H(){P.wheel=null,P.end()}}function L(M,...$){if(g||!e.apply(this,arguments))return;var P=M.currentTarget,G=C(this,$,!0).event(M),K=qn(M.view).on("mousemove.zoom",W,!0).on("mouseup.zoom",J,!0),q=ar(M,P),H=M.clientX,D=M.clientY;IM(M.view),bp(M),G.mouse=[q,this.__zoom.invert(q)],ed(this),G.start();function W(V){if(pl(V),!G.moved){var X=V.clientX-H,Y=V.clientY-D;G.moved=X*X+Y*Y>k}G.event(V).zoom("mouse",n(_(G.that.__zoom,G.mouse[0]=ar(V,P),G.mouse[1]),G.extent,l))}function J(V){K.on("mousemove.zoom mouseup.zoom",null),OM(V.view,G.moved),pl(V),G.event(V).end()}}function F(M,...$){if(e.apply(this,arguments)){var P=this.__zoom,G=ar(M.changedTouches?M.changedTouches[0]:M,this),K=P.invert(G),q=P.k*(M.shiftKey?.5:2),H=n(_(b(P,q),G,K),t.apply(this,$),l);pl(M),c>0?qn(this).transition().duration(c).call(R,H,G,M):qn(this).call(j.transform,H,G,M)}}function O(M,...$){if(e.apply(this,arguments)){var P=M.touches,G=P.length,K=C(this,$,M.changedTouches.length===G).event(M),q,H,D,W;for(bp(M),H=0;H<G;++H)D=P[H],W=ar(D,this),W=[W,this.__zoom.invert(W),D.identifier],K.touch0?!K.touch1&&K.touch0[2]!==W[2]&&(K.touch1=W,K.taps=0):(K.touch0=W,q=!0,K.taps=1+!!f);f&&(f=clearTimeout(f)),q&&(K.taps<2&&(p=W[0],f=setTimeout(function(){f=null},v)),ed(this),K.start())}}function I(M,...$){if(this.__zooming){var P=C(this,$).event(M),G=M.changedTouches,K=G.length,q,H,D,W;for(pl(M),q=0;q<K;++q)H=G[q],D=ar(H,this),P.touch0&&P.touch0[2]===H.identifier?P.touch0[0]=D:P.touch1&&P.touch1[2]===H.identifier&&(P.touch1[0]=D);if(H=P.that.__zoom,P.touch1){var J=P.touch0[0],V=P.touch0[1],X=P.touch1[0],Y=P.touch1[1],Z=(Z=X[0]-J[0])*Z+(Z=X[1]-J[1])*Z,ee=(ee=Y[0]-V[0])*ee+(ee=Y[1]-V[1])*ee;H=b(H,Math.sqrt(Z/ee)),D=[(J[0]+X[0])/2,(J[1]+X[1])/2],W=[(V[0]+Y[0])/2,(V[1]+Y[1])/2]}else if(P.touch0)D=P.touch0[0],W=P.touch0[1];else return;P.zoom("touch",n(_(H,D,W),P.extent,l))}}function B(M,...$){if(this.__zooming){var P=C(this,$).event(M),G=M.changedTouches,K=G.length,q,H;for(bp(M),g&&clearTimeout(g),g=setTimeout(function(){g=null},v),q=0;q<K;++q)H=G[q],P.touch0&&P.touch0[2]===H.identifier?delete P.touch0:P.touch1&&P.touch1[2]===H.identifier&&delete P.touch1;if(P.touch1&&!P.touch0&&(P.touch0=P.touch1,delete P.touch1),P.touch0)P.touch0[1]=this.__zoom.invert(P.touch0[0]);else if(P.end(),P.taps===2&&(H=ar(H,this),Math.hypot(p[0]-H[0],p[1]-H[1])<x)){var D=qn(this).on("dblclick.zoom");D&&D.apply(this,arguments)}}}return j.wheelDelta=function(M){return arguments.length?(r=typeof M=="function"?M:Cu(+M),j):r},j.filter=function(M){return arguments.length?(e=typeof M=="function"?M:Cu(!!M),j):e},j.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:Cu(!!M),j):s},j.extent=function(M){return arguments.length?(t=typeof M=="function"?M:Cu([[+M[0][0],+M[0][1]],[+M[1][0],+M[1][1]]]),j):t},j.scaleExtent=function(M){return arguments.length?(o[0]=+M[0],o[1]=+M[1],j):[o[0],o[1]]},j.translateExtent=function(M){return arguments.length?(l[0][0]=+M[0][0],l[1][0]=+M[1][0],l[0][1]=+M[0][1],l[1][1]=+M[1][1],j):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},j.constrain=function(M){return arguments.length?(n=M,j):n},j.duration=function(M){return arguments.length?(c=+M,j):c},j.interpolate=function(M){return arguments.length?(d=M,j):d},j.on=function(){var M=h.on.apply(h,arguments);return M===h?j:M},j.clickDistance=function(M){return arguments.length?(k=(M=+M)*M,j):Math.sqrt(k)},j.tapDistance=function(M){return arguments.length?(x=+M,j):x},j}var Lt=xM();const Gd=y.createContext(null),G5=Gd.Provider,ps={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.`},XM=ps.error001();function Xe(e,t){const n=y.useContext(Gd);if(n===null)throw new Error(XM);return bM(n,e,t)}const Nt=()=>{const e=y.useContext(Gd);if(e===null)throw new Error(XM);return y.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},K5=e=>e.userSelectionActive?"none":"all";function Ob({position:e,children:t,className:n,style:r,...s}){const o=Xe(K5),l=`${e}`.split("-");return de.createElement("div",{className:Ut(["react-flow__panel",n,...l]),style:{...r,pointerEvents:o},...s},t)}function Y5({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:de.createElement(Ob,{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"},de.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const X5=({x:e,y:t,label:n,labelStyle:r={},labelShowBg:s=!0,labelBgStyle:o={},labelBgPadding:l=[2,4],labelBgBorderRadius:c=2,children:d,className:h,...f})=>{const p=y.useRef(null),[g,v]=y.useState({x:0,y:0,width:0,height:0}),N=Ut(["react-flow__edge-textwrapper",h]);return y.useEffect(()=>{if(p.current){const k=p.current.getBBox();v({x:k.x,y:k.y,width:k.width,height:k.height})}},[n]),typeof n>"u"||!n?null:de.createElement("g",{transform:`translate(${e-g.width/2} ${t-g.height/2})`,className:N,visibility:g.width?"visible":"hidden",...f},s&&de.createElement("rect",{width:g.width+2*l[0],x:-l[0],y:-l[1],height:g.height+2*l[1],className:"react-flow__edge-textbg",style:o,rx:c,ry:c}),de.createElement("text",{className:"react-flow__edge-text",y:g.height/2,dy:"0.3em",ref:p,style:r},n),d)};var Z5=y.memo(X5);const Lb=e=>({width:e.offsetWidth,height:e.offsetHeight}),ui=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Pb=(e={x:0,y:0},t)=>({x:ui(e.x,t[0][0],t[1][0]),y:ui(e.y,t[0][1],t[1][1])}),HN=(e,t,n)=>e<t?ui(Math.abs(e-t),1,50)/50:e>n?-ui(Math.abs(e-n),1,50)/50:0,ZM=(e,t)=>{const n=HN(e.x,35,t.width-35)*20,r=HN(e.y,35,t.height-35)*20;return[n,r]},JM=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},QM=(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)}),Bl=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),e2=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),VN=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),J5=(e,t)=>e2(QM(Bl(e),Bl(t))),jx=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},Q5=e=>Un(e.width)&&Un(e.height)&&Un(e.x)&&Un(e.y),Un=e=>!isNaN(e)&&isFinite(e),mt=Symbol.for("internals"),t2=["Enter"," ","Escape"],e6=(e,t)=>{},t6=e=>"nativeEvent"in e;function Sx(e){var s,o;const t=t6(e)?e.nativeEvent:e,n=((o=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:o[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 n2=e=>"clientX"in e,sa=(e,t)=>{var o,l;const n=n2(e),r=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,s=n?e.clientY:(l=e.touches)==null?void 0:l[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},md=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},cc=({id:e,path:t,labelX:n,labelY:r,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:g,interactionWidth:v=20})=>de.createElement(de.Fragment,null,de.createElement("path",{id:e,style:f,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:p,markerStart:g}),v&&de.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:v,className:"react-flow__edge-interaction"}),s&&Un(n)&&Un(r)?de.createElement(Z5,{x:n,y:r,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h}):null);cc.displayName="BaseEdge";function ml(e,t,n){return n===void 0?n:r=>{const s=t().edges.find(o=>o.id===e);s&&n(r,{...s})}}function r2({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,o=n<e?n+s:n-s,l=Math.abs(r-t)/2,c=r<t?r+l:r-l;return[o,c,s,l]}function s2({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:o,targetControlX:l,targetControlY:c}){const d=e*.125+s*.375+l*.375+n*.125,h=t*.125+o*.375+c*.375+r*.125,f=Math.abs(d-e),p=Math.abs(h-t);return[d,h,f,p]}var Ya;(function(e){e.Strict="strict",e.Loose="loose"})(Ya||(Ya={}));var qa;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(qa||(qa={}));var ql;(function(e){e.Partial="partial",e.Full="full"})(ql||(ql={}));var Qs;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Qs||(Qs={}));var gd;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(gd||(gd={}));var Ae;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ae||(Ae={}));function GN({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===Ae.Left||e===Ae.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function a2({sourceX:e,sourceY:t,sourcePosition:n=Ae.Bottom,targetX:r,targetY:s,targetPosition:o=Ae.Top}){const[l,c]=GN({pos:n,x1:e,y1:t,x2:r,y2:s}),[d,h]=GN({pos:o,x1:r,y1:s,x2:e,y2:t}),[f,p,g,v]=s2({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:d,targetControlY:h});return[`M${e},${t} C${l},${c} ${d},${h} ${r},${s}`,f,p,g,v]}const Db=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s=Ae.Bottom,targetPosition:o=Ae.Top,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:N,interactionWidth:k})=>{const[x,j,b]=a2({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o});return de.createElement(cc,{path:x,labelX:j,labelY:b,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:N,interactionWidth:k})});Db.displayName="SimpleBezierEdge";const KN={[Ae.Left]:{x:-1,y:0},[Ae.Right]:{x:1,y:0},[Ae.Top]:{x:0,y:-1},[Ae.Bottom]:{x:0,y:1}},n6=({source:e,sourcePosition:t=Ae.Bottom,target:n})=>t===Ae.Left||t===Ae.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},YN=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function r6({source:e,sourcePosition:t=Ae.Bottom,target:n,targetPosition:r=Ae.Top,center:s,offset:o}){const l=KN[t],c=KN[r],d={x:e.x+l.x*o,y:e.y+l.y*o},h={x:n.x+c.x*o,y:n.y+c.y*o},f=n6({source:d,sourcePosition:t,target:h}),p=f.x!==0?"x":"y",g=f[p];let v=[],N,k;const x={x:0,y:0},j={x:0,y:0},[b,_,E,R]=r2({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){N=s.x??b,k=s.y??_;const A=[{x:N,y:d.y},{x:N,y:h.y}],U=[{x:d.x,y:k},{x:h.x,y:k}];l[p]===g?v=p==="x"?A:U:v=p==="x"?U:A}else{const A=[{x:d.x,y:h.y}],U=[{x:h.x,y:d.y}];if(p==="x"?v=l.x===g?U:A:v=l.y===g?A:U,t===r){const B=Math.abs(e[p]-n[p]);if(B<=o){const M=Math.min(o-1,o-B);l[p]===g?x[p]=(d[p]>e[p]?-1:1)*M:j[p]=(h[p]>n[p]?-1:1)*M}}if(t!==r){const B=p==="x"?"y":"x",M=l[p]===c[B],$=d[B]>h[B],P=d[B]<h[B];(l[p]===1&&(!M&&$||M&&P)||l[p]!==1&&(!M&&P||M&&$))&&(v=p==="x"?A:U)}const L={x:d.x+x.x,y:d.y+x.y},F={x:h.x+j.x,y:h.y+j.y},O=Math.max(Math.abs(L.x-v[0].x),Math.abs(F.x-v[0].x)),I=Math.max(Math.abs(L.y-v[0].y),Math.abs(F.y-v[0].y));O>=I?(N=(L.x+F.x)/2,k=v[0].y):(N=v[0].x,k=(L.y+F.y)/2)}return[[e,{x:d.x+x.x,y:d.y+x.y},...v,{x:h.x+j.x,y:h.y+j.y},n],N,k,E,R]}function s6(e,t,n,r){const s=Math.min(YN(e,t)/2,YN(t,n)/2,r),{x:o,y:l}=t;if(e.x===o&&o===n.x||e.y===l&&l===n.y)return`L${o} ${l}`;if(e.y===l){const h=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${o+s*h},${l}Q ${o},${l} ${o},${l+s*f}`}const c=e.x<n.x?1:-1,d=e.y<n.y?-1:1;return`L ${o},${l+s*d}Q ${o},${l} ${o+s*c},${l}`}function _x({sourceX:e,sourceY:t,sourcePosition:n=Ae.Bottom,targetX:r,targetY:s,targetPosition:o=Ae.Top,borderRadius:l=5,centerX:c,centerY:d,offset:h=20}){const[f,p,g,v,N]=r6({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:o,center:{x:c,y:d},offset:h});return[f.reduce((x,j,b)=>{let _="";return b>0&&b<f.length-1?_=s6(f[b-1],j,f[b+1],l):_=`${b===0?"M":"L"}${j.x} ${j.y}`,x+=_,x},""),p,g,v,N]}const Kd=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,sourcePosition:p=Ae.Bottom,targetPosition:g=Ae.Top,markerEnd:v,markerStart:N,pathOptions:k,interactionWidth:x})=>{const[j,b,_]=_x({sourceX:e,sourceY:t,sourcePosition:p,targetX:n,targetY:r,targetPosition:g,borderRadius:k==null?void 0:k.borderRadius,offset:k==null?void 0:k.offset});return de.createElement(cc,{path:j,labelX:b,labelY:_,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:v,markerStart:N,interactionWidth:x})});Kd.displayName="SmoothStepEdge";const Fb=y.memo(e=>{var t;return de.createElement(Kd,{...e,pathOptions:y.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});Fb.displayName="StepEdge";function a6({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,o,l,c]=r2({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,o,l,c]}const Bb=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:g,interactionWidth:v})=>{const[N,k,x]=a6({sourceX:e,sourceY:t,targetX:n,targetY:r});return de.createElement(cc,{path:N,labelX:k,labelY:x,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:g,interactionWidth:v})});Bb.displayName="StraightEdge";function Au(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function XN({pos:e,x1:t,y1:n,x2:r,y2:s,c:o}){switch(e){case Ae.Left:return[t-Au(t-r,o),n];case Ae.Right:return[t+Au(r-t,o),n];case Ae.Top:return[t,n-Au(n-s,o)];case Ae.Bottom:return[t,n+Au(s-n,o)]}}function qb({sourceX:e,sourceY:t,sourcePosition:n=Ae.Bottom,targetX:r,targetY:s,targetPosition:o=Ae.Top,curvature:l=.25}){const[c,d]=XN({pos:n,x1:e,y1:t,x2:r,y2:s,c:l}),[h,f]=XN({pos:o,x1:r,y1:s,x2:e,y2:t,c:l}),[p,g,v,N]=s2({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:c,sourceControlY:d,targetControlX:h,targetControlY:f});return[`M${e},${t} C${c},${d} ${h},${f} ${r},${s}`,p,g,v,N]}const yd=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s=Ae.Bottom,targetPosition:o=Ae.Top,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:N,pathOptions:k,interactionWidth:x})=>{const[j,b,_]=qb({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o,curvature:k==null?void 0:k.curvature});return de.createElement(cc,{path:j,labelX:b,labelY:_,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:N,interactionWidth:x})});yd.displayName="BezierEdge";const Ub=y.createContext(null),o6=Ub.Provider;Ub.Consumer;const i6=()=>y.useContext(Ub),l6=e=>"id"in e&&"source"in e&&"target"in e,c6=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,Ex=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`,u6=(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)),d6=(e,t)=>{if(!e.source||!e.target)return t;let n;return l6(e)?n={...e}:n={...e,id:c6(e)},u6(n,t)?t:t.concat(n)},Tx=({x:e,y:t},[n,r,s],o,[l,c])=>{const d={x:(e-n)/s,y:(t-r)/s};return o?{x:l*Math.round(d.x/l),y:c*Math.round(d.y/c)}:d},o2=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r}),Wa=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],r=(e.height??0)*t[1],s={x:e.position.x-n,y:e.position.y-r};return{...s,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-r}:s}},Yd=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,s)=>{const{x:o,y:l}=Wa(s,t).positionAbsolute;return QM(r,Bl({x:o,y:l,width:s.width||0,height:s.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return e2(n)},i2=(e,t,[n,r,s]=[0,0,1],o=!1,l=!1,c=[0,0])=>{const d={x:(t.x-n)/s,y:(t.y-r)/s,width:t.width/s,height:t.height/s},h=[];return e.forEach(f=>{const{width:p,height:g,selectable:v=!0,hidden:N=!1}=f;if(l&&!v||N)return!1;const{positionAbsolute:k}=Wa(f,c),x={x:k.x,y:k.y,width:p||0,height:g||0},j=jx(d,x),b=typeof p>"u"||typeof g>"u"||p===null||g===null,_=o&&j>0,E=(p||0)*(g||0);(b||_||j>=E||f.dragging)&&h.push(f)}),h},l2=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},c2=(e,t,n,r,s,o=.1)=>{const l=t/(e.width*(1+o)),c=n/(e.height*(1+o)),d=Math.min(l,c),h=ui(d,r,s),f=e.x+e.width/2,p=e.y+e.height/2,g=t/2-f*h,v=n/2-p*h;return{x:g,y:v,zoom:h}},Oa=(e,t=0)=>e.transition().duration(t);function ZN(e,t,n,r){return(t[n]||[]).reduce((s,o)=>{var l,c;return`${e.id}-${o.id}-${n}`!==r&&s.push({id:o.id||null,type:n,nodeId:e.id,x:(((l=e.positionAbsolute)==null?void 0:l.x)??0)+o.x+o.width/2,y:(((c=e.positionAbsolute)==null?void 0:c.y)??0)+o.y+o.height/2}),s},[])}function h6(e,t,n,r,s,o){const{x:l,y:c}=sa(e),h=t.elementsFromPoint(l,c).find(N=>N.classList.contains("react-flow__handle"));if(h){const N=h.getAttribute("data-nodeid");if(N){const k=zb(void 0,h),x=h.getAttribute("data-handleid"),j=o({nodeId:N,id:x,type:k});if(j){const b=s.find(_=>_.nodeId===N&&_.type===k&&_.id===x);return{handle:{id:x,type:k,nodeId:N,x:(b==null?void 0:b.x)||n.x,y:(b==null?void 0:b.y)||n.y},validHandleResult:j}}}}let f=[],p=1/0;if(s.forEach(N=>{const k=Math.sqrt((N.x-n.x)**2+(N.y-n.y)**2);if(k<=r){const x=o(N);k<=p&&(k<p?f=[{handle:N,validHandleResult:x}]:k===p&&f.push({handle:N,validHandleResult:x}),p=k)}}),!f.length)return{handle:null,validHandleResult:u2()};if(f.length===1)return f[0];const g=f.some(({validHandleResult:N})=>N.isValid),v=f.some(({handle:N})=>N.type==="target");return f.find(({handle:N,validHandleResult:k})=>v?N.type==="target":g?k.isValid:!0)||f[0]}const f6={source:null,target:null,sourceHandle:null,targetHandle:null},u2=()=>({handleDomNode:null,isValid:!1,connection:f6,endHandle:null});function d2(e,t,n,r,s,o,l){const c=s==="target",d=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}"]`),h={...u2(),handleDomNode:d};if(d){const f=zb(void 0,d),p=d.getAttribute("data-nodeid"),g=d.getAttribute("data-handleid"),v=d.classList.contains("connectable"),N=d.classList.contains("connectableend"),k={source:c?p:n,sourceHandle:c?g:r,target:c?n:p,targetHandle:c?r:g};h.connection=k,v&&N&&(t===Ya.Strict?c&&f==="source"||!c&&f==="target":p!==n||g!==r)&&(h.endHandle={nodeId:p,handleId:g,type:f},h.isValid=o(k))}return h}function p6({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((s,o)=>{if(o[mt]){const{handleBounds:l}=o[mt];let c=[],d=[];l&&(c=ZN(o,l,"source",`${t}-${n}-${r}`),d=ZN(o,l,"target",`${t}-${n}-${r}`)),s.push(...c,...d)}return s},[])}function zb(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function kp(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function m6(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function h2({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:s,getState:o,setState:l,isValidConnection:c,edgeUpdaterType:d,onReconnectEnd:h}){const f=JM(e.target),{connectionMode:p,domNode:g,autoPanOnConnect:v,connectionRadius:N,onConnectStart:k,panBy:x,getNodes:j,cancelConnection:b}=o();let _=0,E;const{x:R,y:C}=sa(e),A=f==null?void 0:f.elementFromPoint(R,C),U=zb(d,A),L=g==null?void 0:g.getBoundingClientRect();if(!L||!U)return;let F,O=sa(e,L),I=!1,B=null,M=!1,$=null;const P=p6({nodes:j(),nodeId:n,handleId:t,handleType:U}),G=()=>{if(!v)return;const[H,D]=ZM(O,L);x({x:H,y:D}),_=requestAnimationFrame(G)};l({connectionPosition:O,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:U,connectionStartHandle:{nodeId:n,handleId:t,type:U},connectionEndHandle:null}),k==null||k(e,{nodeId:n,handleId:t,handleType:U});function K(H){const{transform:D}=o();O=sa(H,L);const{handle:W,validHandleResult:J}=h6(H,f,Tx(O,D,!1,[1,1]),N,P,V=>d2(V,p,n,t,s?"target":"source",c,f));if(E=W,I||(G(),I=!0),$=J.handleDomNode,B=J.connection,M=J.isValid,l({connectionPosition:E&&M?o2({x:E.x,y:E.y},D):O,connectionStatus:m6(!!E,M),connectionEndHandle:J.endHandle}),!E&&!M&&!$)return kp(F);B.source!==B.target&&$&&(kp(F),F=$,$.classList.add("connecting","react-flow__handle-connecting"),$.classList.toggle("valid",M),$.classList.toggle("react-flow__handle-valid",M))}function q(H){var D,W;(E||$)&&B&&M&&(r==null||r(B)),(W=(D=o()).onConnectEnd)==null||W.call(D,H),d&&(h==null||h(H)),kp(F),b(),cancelAnimationFrame(_),I=!1,M=!1,B=null,$=null,f.removeEventListener("mousemove",K),f.removeEventListener("mouseup",q),f.removeEventListener("touchmove",K),f.removeEventListener("touchend",q)}f.addEventListener("mousemove",K),f.addEventListener("mouseup",q),f.addEventListener("touchmove",K),f.addEventListener("touchend",q)}const JN=()=>!0,g6=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),y6=(e,t,n)=>r=>{const{connectionStartHandle:s,connectionEndHandle:o,connectionClickStartHandle:l}=r;return{connecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.handleId)===t&&(s==null?void 0:s.type)===n||(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.handleId)===t&&(o==null?void 0:o.type)===n,clickConnecting:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.handleId)===t&&(l==null?void 0:l.type)===n}},f2=y.forwardRef(({type:e="source",position:t=Ae.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:o=!0,id:l,onConnect:c,children:d,className:h,onMouseDown:f,onTouchStart:p,...g},v)=>{var L,F;const N=l||null,k=e==="target",x=Nt(),j=i6(),{connectOnClick:b,noPanClassName:_}=Xe(g6,At),{connecting:E,clickConnecting:R}=Xe(y6(j,N,e),At);j||(F=(L=x.getState()).onError)==null||F.call(L,"010",ps.error010());const C=O=>{const{defaultEdgeOptions:I,onConnect:B,hasDefaultEdges:M}=x.getState(),$={...I,...O};if(M){const{edges:P,setEdges:G}=x.getState();G(d6($,P))}B==null||B($),c==null||c($)},A=O=>{if(!j)return;const I=n2(O);s&&(I&&O.button===0||!I)&&h2({event:O,handleId:N,nodeId:j,onConnect:C,isTarget:k,getState:x.getState,setState:x.setState,isValidConnection:n||x.getState().isValidConnection||JN}),I?f==null||f(O):p==null||p(O)},U=O=>{const{onClickConnectStart:I,onClickConnectEnd:B,connectionClickStartHandle:M,connectionMode:$,isValidConnection:P}=x.getState();if(!j||!M&&!s)return;if(!M){I==null||I(O,{nodeId:j,handleId:N,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:j,type:e,handleId:N}});return}const G=JM(O.target),K=n||P||JN,{connection:q,isValid:H}=d2({nodeId:j,id:N,type:e},$,M.nodeId,M.handleId||null,M.type,K,G);H&&C(q),B==null||B(O),x.setState({connectionClickStartHandle:null})};return de.createElement("div",{"data-handleid":N,"data-nodeid":j,"data-handlepos":t,"data-id":`${j}-${N}-${e}`,className:Ut(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",_,h,{source:!k,target:k,connectable:r,connectablestart:s,connectableend:o,connecting:R,connectionindicator:r&&(s&&!E||o&&E)}]),onMouseDown:A,onTouchStart:A,onClick:b?U:void 0,ref:v,...g},d)});f2.displayName="Handle";var Xa=y.memo(f2);const p2=({data:e,isConnectable:t,targetPosition:n=Ae.Top,sourcePosition:r=Ae.Bottom})=>de.createElement(de.Fragment,null,de.createElement(Xa,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,de.createElement(Xa,{type:"source",position:r,isConnectable:t}));p2.displayName="DefaultNode";var Cx=y.memo(p2);const m2=({data:e,isConnectable:t,sourcePosition:n=Ae.Bottom})=>de.createElement(de.Fragment,null,e==null?void 0:e.label,de.createElement(Xa,{type:"source",position:n,isConnectable:t}));m2.displayName="InputNode";var g2=y.memo(m2);const y2=({data:e,isConnectable:t,targetPosition:n=Ae.Top})=>de.createElement(de.Fragment,null,de.createElement(Xa,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);y2.displayName="OutputNode";var w2=y.memo(y2);const Wb=()=>null;Wb.displayName="GroupNode";const w6=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),Ru=e=>e.id;function v6(e,t){return At(e.selectedNodes.map(Ru),t.selectedNodes.map(Ru))&&At(e.selectedEdges.map(Ru),t.selectedEdges.map(Ru))}const v2=y.memo(({onSelectionChange:e})=>{const t=Nt(),{selectedNodes:n,selectedEdges:r}=Xe(w6,v6);return y.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChange.forEach(o=>o(s))},[n,r,e]),null});v2.displayName="SelectionListener";const x6=e=>!!e.onSelectionChange;function b6({onSelectionChange:e}){const t=Xe(x6);return e||t?de.createElement(v2,{onSelectionChange:e}):null}const k6=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 Lo(e,t){y.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function Pe(e,t,n){y.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const N6=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:s,onConnectStart:o,onConnectEnd:l,onClickConnectStart:c,onClickConnectEnd:d,nodesDraggable:h,nodesConnectable:f,nodesFocusable:p,edgesFocusable:g,edgesUpdatable:v,elevateNodesOnSelect:N,minZoom:k,maxZoom:x,nodeExtent:j,onNodesChange:b,onEdgesChange:_,elementsSelectable:E,connectionMode:R,snapGrid:C,snapToGrid:A,translateExtent:U,connectOnClick:L,defaultEdgeOptions:F,fitView:O,fitViewOptions:I,onNodesDelete:B,onEdgesDelete:M,onNodeDrag:$,onNodeDragStart:P,onNodeDragStop:G,onSelectionDrag:K,onSelectionDragStart:q,onSelectionDragStop:H,noPanClassName:D,nodeOrigin:W,rfId:J,autoPanOnConnect:V,autoPanOnNodeDrag:X,onError:Y,connectionRadius:Z,isValidConnection:ee,nodeDragThreshold:ne})=>{const{setNodes:se,setEdges:pe,setDefaultNodesAndEdges:ke,setMinZoom:ae,setMaxZoom:fe,setTranslateExtent:me,setNodeExtent:he,reset:ge}=Xe(k6,At),ue=Nt();return y.useEffect(()=>{const be=r==null?void 0:r.map(oe=>({...oe,...F}));return ke(n,be),()=>{ge()}},[]),Pe("defaultEdgeOptions",F,ue.setState),Pe("connectionMode",R,ue.setState),Pe("onConnect",s,ue.setState),Pe("onConnectStart",o,ue.setState),Pe("onConnectEnd",l,ue.setState),Pe("onClickConnectStart",c,ue.setState),Pe("onClickConnectEnd",d,ue.setState),Pe("nodesDraggable",h,ue.setState),Pe("nodesConnectable",f,ue.setState),Pe("nodesFocusable",p,ue.setState),Pe("edgesFocusable",g,ue.setState),Pe("edgesUpdatable",v,ue.setState),Pe("elementsSelectable",E,ue.setState),Pe("elevateNodesOnSelect",N,ue.setState),Pe("snapToGrid",A,ue.setState),Pe("snapGrid",C,ue.setState),Pe("onNodesChange",b,ue.setState),Pe("onEdgesChange",_,ue.setState),Pe("connectOnClick",L,ue.setState),Pe("fitViewOnInit",O,ue.setState),Pe("fitViewOnInitOptions",I,ue.setState),Pe("onNodesDelete",B,ue.setState),Pe("onEdgesDelete",M,ue.setState),Pe("onNodeDrag",$,ue.setState),Pe("onNodeDragStart",P,ue.setState),Pe("onNodeDragStop",G,ue.setState),Pe("onSelectionDrag",K,ue.setState),Pe("onSelectionDragStart",q,ue.setState),Pe("onSelectionDragStop",H,ue.setState),Pe("noPanClassName",D,ue.setState),Pe("nodeOrigin",W,ue.setState),Pe("rfId",J,ue.setState),Pe("autoPanOnConnect",V,ue.setState),Pe("autoPanOnNodeDrag",X,ue.setState),Pe("onError",Y,ue.setState),Pe("connectionRadius",Z,ue.setState),Pe("isValidConnection",ee,ue.setState),Pe("nodeDragThreshold",ne,ue.setState),Lo(e,se),Lo(t,pe),Lo(k,ae),Lo(x,fe),Lo(U,me),Lo(j,he),null},QN={display:"none"},j6={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},x2="react-flow__node-desc",b2="react-flow__edge-desc",S6="react-flow__aria-live",_6=e=>e.ariaLiveMessage;function E6({rfId:e}){const t=Xe(_6);return de.createElement("div",{id:`${S6}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:j6},t)}function T6({rfId:e,disableKeyboardA11y:t}){return de.createElement(de.Fragment,null,de.createElement("div",{id:`${x2}-${e}`,style:QN},"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."," "),de.createElement("div",{id:`${b2}-${e}`,style:QN},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&de.createElement(E6,{rfId:e}))}var Ul=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,r]=y.useState(!1),s=y.useRef(!1),o=y.useRef(new Set([])),[l,c]=y.useMemo(()=>{if(e!==null){const h=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.split("+")),f=h.reduce((p,g)=>p.concat(...g),[]);return[h,f]}return[[],[]]},[e]);return y.useEffect(()=>{const d=typeof document<"u"?document:null,h=(t==null?void 0:t.target)||d;if(e!==null){const f=v=>{if(s.current=v.ctrlKey||v.metaKey||v.shiftKey,(!s.current||s.current&&!t.actInsideInputWithModifier)&&Sx(v))return!1;const k=tj(v.code,c);o.current.add(v[k]),ej(l,o.current,!1)&&(v.preventDefault(),r(!0))},p=v=>{if((!s.current||s.current&&!t.actInsideInputWithModifier)&&Sx(v))return!1;const k=tj(v.code,c);ej(l,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(v[k]),v.key==="Meta"&&o.current.clear(),s.current=!1},g=()=>{o.current.clear(),r(!1)};return h==null||h.addEventListener("keydown",f),h==null||h.addEventListener("keyup",p),window.addEventListener("blur",g),()=>{h==null||h.removeEventListener("keydown",f),h==null||h.removeEventListener("keyup",p),window.removeEventListener("blur",g)}}},[e,r]),n};function ej(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function tj(e,t){return t.includes(e)?"code":"key"}function k2(e,t,n,r){var c,d;const s=e.parentNode||e.parentId;if(!s)return n;const o=t.get(s),l=Wa(o,r);return k2(o,t,{x:(n.x??0)+l.x,y:(n.y??0)+l.y,z:(((c=o[mt])==null?void 0:c.z)??0)>(n.z??0)?((d=o[mt])==null?void 0:d.z)??0:n.z??0},r)}function N2(e,t,n){e.forEach(r=>{var o;const s=r.parentNode||r.parentId;if(s&&!e.has(s))throw new Error(`Parent node ${s} not found`);if(s||n!=null&&n[r.id]){const{x:l,y:c,z:d}=k2(r,e,{...r.position,z:((o=r[mt])==null?void 0:o.z)??0},t);r.positionAbsolute={x:l,y:c},r[mt].z=d,n!=null&&n[r.id]&&(r[mt].isParent=!0)}})}function Np(e,t,n,r){const s=new Map,o={},l=r?1e3:0;return e.forEach(c=>{var v;const d=(Un(c.zIndex)?c.zIndex:0)+(c.selected?l:0),h=t.get(c.id),f={...c,positionAbsolute:{x:c.position.x,y:c.position.y}},p=c.parentNode||c.parentId;p&&(o[p]=!0);const g=(h==null?void 0:h.type)&&(h==null?void 0:h.type)!==c.type;Object.defineProperty(f,mt,{enumerable:!1,value:{handleBounds:g||(v=h==null?void 0:h[mt])==null?void 0:v.handleBounds,z:d}}),s.set(c.id,f)}),N2(s,n,o),s}function j2(e,t={}){const{getNodes:n,width:r,height:s,minZoom:o,maxZoom:l,d3Zoom:c,d3Selection:d,fitViewOnInitDone:h,fitViewOnInit:f,nodeOrigin:p}=e(),g=t.initial&&!h&&f;if(c&&d&&(g||!t.initial)){const N=n().filter(x=>{var b;const j=t.includeHiddenNodes?x.width&&x.height:!x.hidden;return(b=t.nodes)!=null&&b.length?j&&t.nodes.some(_=>_.id===x.id):j}),k=N.every(x=>x.width&&x.height);if(N.length>0&&k){const x=Yd(N,p),{x:j,y:b,zoom:_}=c2(x,r,s,t.minZoom??o,t.maxZoom??l,t.padding??.1),E=us.translate(j,b).scale(_);return typeof t.duration=="number"&&t.duration>0?c.transform(Oa(d,t.duration),E):c.transform(d,E),!0}}return!1}function C6(e,t){return e.forEach(n=>{const r=t.get(n.id);r&&t.set(r.id,{...r,[mt]:r[mt],selected:n.selected})}),new Map(t)}function A6(e,t){return t.map(n=>{const r=e.find(s=>s.id===n.id);return r&&(n.selected=r.selected),n})}function Mu({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:s,edges:o,onNodesChange:l,onEdgesChange:c,hasDefaultNodes:d,hasDefaultEdges:h}=n();e!=null&&e.length&&(d&&r({nodeInternals:C6(e,s)}),l==null||l(e)),t!=null&&t.length&&(h&&r({edges:A6(t,o)}),c==null||c(t))}const Po=()=>{},R6={zoomIn:Po,zoomOut:Po,zoomTo:Po,getZoom:()=>1,setViewport:Po,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Po,fitBounds:Po,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},M6=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),$6=()=>{const e=Nt(),{d3Zoom:t,d3Selection:n}=Xe(M6,At);return y.useMemo(()=>n&&t?{zoomIn:s=>t.scaleBy(Oa(n,s==null?void 0:s.duration),1.2),zoomOut:s=>t.scaleBy(Oa(n,s==null?void 0:s.duration),1/1.2),zoomTo:(s,o)=>t.scaleTo(Oa(n,o==null?void 0:o.duration),s),getZoom:()=>e.getState().transform[2],setViewport:(s,o)=>{const[l,c,d]=e.getState().transform,h=us.translate(s.x??l,s.y??c).scale(s.zoom??d);t.transform(Oa(n,o==null?void 0:o.duration),h)},getViewport:()=>{const[s,o,l]=e.getState().transform;return{x:s,y:o,zoom:l}},fitView:s=>j2(e.getState,s),setCenter:(s,o,l)=>{const{width:c,height:d,maxZoom:h}=e.getState(),f=typeof(l==null?void 0:l.zoom)<"u"?l.zoom:h,p=c/2-s*f,g=d/2-o*f,v=us.translate(p,g).scale(f);t.transform(Oa(n,l==null?void 0:l.duration),v)},fitBounds:(s,o)=>{const{width:l,height:c,minZoom:d,maxZoom:h}=e.getState(),{x:f,y:p,zoom:g}=c2(s,l,c,d,h,(o==null?void 0:o.padding)??.1),v=us.translate(f,p).scale(g);t.transform(Oa(n,o==null?void 0:o.duration),v)},project:s=>{const{transform:o,snapToGrid:l,snapGrid:c}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),Tx(s,o,l,c)},screenToFlowPosition:s=>{const{transform:o,snapToGrid:l,snapGrid:c,domNode:d}=e.getState();if(!d)return s;const{x:h,y:f}=d.getBoundingClientRect(),p={x:s.x-h,y:s.y-f};return Tx(p,o,l,c)},flowToScreenPosition:s=>{const{transform:o,domNode:l}=e.getState();if(!l)return s;const{x:c,y:d}=l.getBoundingClientRect(),h=o2(s,o);return{x:h.x+c,y:h.y+d}},viewportInitialized:!0}:R6,[t,n])};function ki(){const e=$6(),t=Nt(),n=y.useCallback(()=>t.getState().getNodes().map(k=>({...k})),[]),r=y.useCallback(k=>t.getState().nodeInternals.get(k),[]),s=y.useCallback(()=>{const{edges:k=[]}=t.getState();return k.map(x=>({...x}))},[]),o=y.useCallback(k=>{const{edges:x=[]}=t.getState();return x.find(j=>j.id===k)},[]),l=y.useCallback(k=>{const{getNodes:x,setNodes:j,hasDefaultNodes:b,onNodesChange:_}=t.getState(),E=x(),R=typeof k=="function"?k(E):k;if(b)j(R);else if(_){const C=R.length===0?E.map(A=>({type:"remove",id:A.id})):R.map(A=>({item:A,type:"reset"}));_(C)}},[]),c=y.useCallback(k=>{const{edges:x=[],setEdges:j,hasDefaultEdges:b,onEdgesChange:_}=t.getState(),E=typeof k=="function"?k(x):k;if(b)j(E);else if(_){const R=E.length===0?x.map(C=>({type:"remove",id:C.id})):E.map(C=>({item:C,type:"reset"}));_(R)}},[]),d=y.useCallback(k=>{const x=Array.isArray(k)?k:[k],{getNodes:j,setNodes:b,hasDefaultNodes:_,onNodesChange:E}=t.getState();if(_){const C=[...j(),...x];b(C)}else if(E){const R=x.map(C=>({item:C,type:"add"}));E(R)}},[]),h=y.useCallback(k=>{const x=Array.isArray(k)?k:[k],{edges:j=[],setEdges:b,hasDefaultEdges:_,onEdgesChange:E}=t.getState();if(_)b([...j,...x]);else if(E){const R=x.map(C=>({item:C,type:"add"}));E(R)}},[]),f=y.useCallback(()=>{const{getNodes:k,edges:x=[],transform:j}=t.getState(),[b,_,E]=j;return{nodes:k().map(R=>({...R})),edges:x.map(R=>({...R})),viewport:{x:b,y:_,zoom:E}}},[]),p=y.useCallback(({nodes:k,edges:x})=>{const{nodeInternals:j,getNodes:b,edges:_,hasDefaultNodes:E,hasDefaultEdges:R,onNodesDelete:C,onEdgesDelete:A,onNodesChange:U,onEdgesChange:L}=t.getState(),F=(k||[]).map($=>$.id),O=(x||[]).map($=>$.id),I=b().reduce(($,P)=>{const G=P.parentNode||P.parentId,K=!F.includes(P.id)&&G&&$.find(H=>H.id===G);return(typeof P.deletable=="boolean"?P.deletable:!0)&&(F.includes(P.id)||K)&&$.push(P),$},[]),B=_.filter($=>typeof $.deletable=="boolean"?$.deletable:!0),M=B.filter($=>O.includes($.id));if(I||M){const $=l2(I,B),P=[...M,...$],G=P.reduce((K,q)=>(K.includes(q.id)||K.push(q.id),K),[]);if((R||E)&&(R&&t.setState({edges:_.filter(K=>!G.includes(K.id))}),E&&(I.forEach(K=>{j.delete(K.id)}),t.setState({nodeInternals:new Map(j)}))),G.length>0&&(A==null||A(P),L&&L(G.map(K=>({id:K,type:"remove"})))),I.length>0&&(C==null||C(I),U)){const K=I.map(q=>({id:q.id,type:"remove"}));U(K)}}},[]),g=y.useCallback(k=>{const x=Q5(k),j=x?null:t.getState().nodeInternals.get(k.id);return!x&&!j?[null,null,x]:[x?k:VN(j),j,x]},[]),v=y.useCallback((k,x=!0,j)=>{const[b,_,E]=g(k);return b?(j||t.getState().getNodes()).filter(R=>{if(!E&&(R.id===_.id||!R.positionAbsolute))return!1;const C=VN(R),A=jx(C,b);return x&&A>0||A>=b.width*b.height}):[]},[]),N=y.useCallback((k,x,j=!0)=>{const[b]=g(k);if(!b)return!1;const _=jx(b,x);return j&&_>0||_>=b.width*b.height},[]);return y.useMemo(()=>({...e,getNodes:n,getNode:r,getEdges:s,getEdge:o,setNodes:l,setEdges:c,addNodes:d,addEdges:h,toObject:f,deleteElements:p,getIntersectingNodes:v,isNodeIntersecting:N}),[e,n,r,s,o,l,c,d,h,f,p,v,N])}const I6={actInsideInputWithModifier:!1};var O6=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=Nt(),{deleteElements:r}=ki(),s=Ul(e,I6),o=Ul(t);y.useEffect(()=>{if(s){const{edges:l,getNodes:c}=n.getState(),d=c().filter(f=>f.selected),h=l.filter(f=>f.selected);r({nodes:d,edges:h}),n.setState({nodesSelectionActive:!1})}},[s]),y.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])};function L6(e){const t=Nt();y.useEffect(()=>{let n;const r=()=>{var o,l;if(!e.current)return;const s=Lb(e.current);(s.height===0||s.width===0)&&((l=(o=t.getState()).onError)==null||l.call(o,"004",ps.error004())),t.setState({width:s.width||500,height:s.height||500})};return r(),window.addEventListener("resize",r),e.current&&(n=new ResizeObserver(()=>r()),n.observe(e.current)),()=>{window.removeEventListener("resize",r),n&&e.current&&n.unobserve(e.current)}},[])}const Hb={position:"absolute",width:"100%",height:"100%",top:0,left:0},P6=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,$u=e=>({x:e.x,y:e.y,zoom:e.k}),Do=(e,t)=>e.target.closest(`.${t}`),nj=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),rj=e=>{const t=e.ctrlKey&&md()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},D6=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),F6=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:s=!0,zoomOnPinch:o=!0,panOnScroll:l=!1,panOnScrollSpeed:c=.5,panOnScrollMode:d=qa.Free,zoomOnDoubleClick:h=!0,elementsSelectable:f,panOnDrag:p=!0,defaultViewport:g,translateExtent:v,minZoom:N,maxZoom:k,zoomActivationKeyCode:x,preventScrolling:j=!0,children:b,noWheelClassName:_,noPanClassName:E})=>{const R=y.useRef(),C=Nt(),A=y.useRef(!1),U=y.useRef(!1),L=y.useRef(null),F=y.useRef({x:0,y:0,zoom:0}),{d3Zoom:O,d3Selection:I,d3ZoomHandler:B,userSelectionActive:M}=Xe(D6,At),$=Ul(x),P=y.useRef(0),G=y.useRef(!1),K=y.useRef();return L6(L),y.useEffect(()=>{if(L.current){const q=L.current.getBoundingClientRect(),H=YM().scaleExtent([N,k]).translateExtent(v),D=qn(L.current).call(H),W=us.translate(g.x,g.y).scale(ui(g.zoom,N,k)),J=[[0,0],[q.width,q.height]],V=H.constrain()(W,J,v);H.transform(D,V),H.wheelDelta(rj),C.setState({d3Zoom:H,d3Selection:D,d3ZoomHandler:D.on("wheel.zoom"),transform:[V.x,V.y,V.k],domNode:L.current.closest(".react-flow")})}},[]),y.useEffect(()=>{I&&O&&(l&&!$&&!M?I.on("wheel.zoom",q=>{if(Do(q,_))return!1;q.preventDefault(),q.stopImmediatePropagation();const H=I.property("__zoom").k||1;if(q.ctrlKey&&o){const ee=ar(q),ne=rj(q),se=H*Math.pow(2,ne);O.scaleTo(I,se,ee,q);return}const D=q.deltaMode===1?20:1;let W=d===qa.Vertical?0:q.deltaX*D,J=d===qa.Horizontal?0:q.deltaY*D;!md()&&q.shiftKey&&d!==qa.Vertical&&(W=q.deltaY*D,J=0),O.translateBy(I,-(W/H)*c,-(J/H)*c,{internal:!0});const V=$u(I.property("__zoom")),{onViewportChangeStart:X,onViewportChange:Y,onViewportChangeEnd:Z}=C.getState();clearTimeout(K.current),G.current||(G.current=!0,t==null||t(q,V),X==null||X(V)),G.current&&(e==null||e(q,V),Y==null||Y(V),K.current=setTimeout(()=>{n==null||n(q,V),Z==null||Z(V),G.current=!1},150))},{passive:!1}):typeof B<"u"&&I.on("wheel.zoom",function(q,H){if(!j&&q.type==="wheel"&&!q.ctrlKey||Do(q,_))return null;q.preventDefault(),B.call(this,q,H)},{passive:!1}))},[M,l,d,I,O,B,$,o,j,_,t,e,n]),y.useEffect(()=>{O&&O.on("start",q=>{var W,J;if(!q.sourceEvent||q.sourceEvent.internal)return null;P.current=(W=q.sourceEvent)==null?void 0:W.button;const{onViewportChangeStart:H}=C.getState(),D=$u(q.transform);A.current=!0,F.current=D,((J=q.sourceEvent)==null?void 0:J.type)==="mousedown"&&C.setState({paneDragging:!0}),H==null||H(D),t==null||t(q.sourceEvent,D)})},[O,t]),y.useEffect(()=>{O&&(M&&!A.current?O.on("zoom",null):M||O.on("zoom",q=>{var D;const{onViewportChange:H}=C.getState();if(C.setState({transform:[q.transform.x,q.transform.y,q.transform.k]}),U.current=!!(r&&nj(p,P.current??0)),(e||H)&&!((D=q.sourceEvent)!=null&&D.internal)){const W=$u(q.transform);H==null||H(W),e==null||e(q.sourceEvent,W)}}))},[M,O,e,p,r]),y.useEffect(()=>{O&&O.on("end",q=>{if(!q.sourceEvent||q.sourceEvent.internal)return null;const{onViewportChangeEnd:H}=C.getState();if(A.current=!1,C.setState({paneDragging:!1}),r&&nj(p,P.current??0)&&!U.current&&r(q.sourceEvent),U.current=!1,(n||H)&&P6(F.current,q.transform)){const D=$u(q.transform);F.current=D,clearTimeout(R.current),R.current=setTimeout(()=>{H==null||H(D),n==null||n(q.sourceEvent,D)},l?150:0)}})},[O,l,p,n,r]),y.useEffect(()=>{O&&O.filter(q=>{const H=$||s,D=o&&q.ctrlKey;if((p===!0||Array.isArray(p)&&p.includes(1))&&q.button===1&&q.type==="mousedown"&&(Do(q,"react-flow__node")||Do(q,"react-flow__edge")))return!0;if(!p&&!H&&!l&&!h&&!o||M||!h&&q.type==="dblclick"||Do(q,_)&&q.type==="wheel"||Do(q,E)&&(q.type!=="wheel"||l&&q.type==="wheel"&&!$)||!o&&q.ctrlKey&&q.type==="wheel"||!H&&!l&&!D&&q.type==="wheel"||!p&&(q.type==="mousedown"||q.type==="touchstart")||Array.isArray(p)&&!p.includes(q.button)&&q.type==="mousedown")return!1;const W=Array.isArray(p)&&p.includes(q.button)||!q.button||q.button<=1;return(!q.ctrlKey||q.type==="wheel")&&W})},[M,O,s,o,l,h,p,f,$]),de.createElement("div",{className:"react-flow__renderer",ref:L,style:Hb},b)},B6=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function q6(){const{userSelectionActive:e,userSelectionRect:t}=Xe(B6,At);return e&&t?de.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 sj(e,t){const n=t.parentNode||t.parentId,r=e.find(s=>s.id===n);if(r){const s=t.position.x+t.width-r.width,o=t.position.y+t.height-r.height;if(s>0||o>0||t.position.x<0||t.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,s>0&&(r.style.width+=s),o>0&&(r.style.height+=o),t.position.x<0){const l=Math.abs(t.position.x);r.position.x=r.position.x-l,r.style.width+=l,t.position.x=0}if(t.position.y<0){const l=Math.abs(t.position.y);r.position.y=r.position.y-l,r.style.height+=l,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function U6(e,t){if(e.some(r=>r.type==="reset"))return e.filter(r=>r.type==="reset").map(r=>r.item);const n=e.filter(r=>r.type==="add").map(r=>r.item);return t.reduce((r,s)=>{const o=e.filter(c=>c.id===s.id);if(o.length===0)return r.push(s),r;const l={...s};for(const c of o)if(c)switch(c.type){case"select":{l.selected=c.selected;break}case"position":{typeof c.position<"u"&&(l.position=c.position),typeof c.positionAbsolute<"u"&&(l.positionAbsolute=c.positionAbsolute),typeof c.dragging<"u"&&(l.dragging=c.dragging),l.expandParent&&sj(r,l);break}case"dimensions":{typeof c.dimensions<"u"&&(l.width=c.dimensions.width,l.height=c.dimensions.height),typeof c.updateStyle<"u"&&(l.style={...l.style||{},...c.dimensions}),typeof c.resizing=="boolean"&&(l.resizing=c.resizing),l.expandParent&&sj(r,l);break}case"remove":return r}return r.push(l),r},n)}function z6(e,t){return U6(e,t)}const Js=(e,t)=>({id:e,type:"select",selected:t});function Zo(e,t){return e.reduce((n,r)=>{const s=t.includes(r.id);return!r.selected&&s?(r.selected=!0,n.push(Js(r.id,!0))):r.selected&&!s&&(r.selected=!1,n.push(Js(r.id,!1))),n},[])}const jp=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},W6=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),S2=y.memo(({isSelecting:e,selectionMode:t=ql.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:s,onPaneClick:o,onPaneContextMenu:l,onPaneScroll:c,onPaneMouseEnter:d,onPaneMouseMove:h,onPaneMouseLeave:f,children:p})=>{const g=y.useRef(null),v=Nt(),N=y.useRef(0),k=y.useRef(0),x=y.useRef(),{userSelectionActive:j,elementsSelectable:b,dragging:_}=Xe(W6,At),E=()=>{v.setState({userSelectionActive:!1,userSelectionRect:null}),N.current=0,k.current=0},R=B=>{o==null||o(B),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},C=B=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){B.preventDefault();return}l==null||l(B)},A=c?B=>c(B):void 0,U=B=>{const{resetSelectedElements:M,domNode:$}=v.getState();if(x.current=$==null?void 0:$.getBoundingClientRect(),!b||!e||B.button!==0||B.target!==g.current||!x.current)return;const{x:P,y:G}=sa(B,x.current);M(),v.setState({userSelectionRect:{width:0,height:0,startX:P,startY:G,x:P,y:G}}),r==null||r(B)},L=B=>{const{userSelectionRect:M,nodeInternals:$,edges:P,transform:G,onNodesChange:K,onEdgesChange:q,nodeOrigin:H,getNodes:D}=v.getState();if(!e||!x.current||!M)return;v.setState({userSelectionActive:!0,nodesSelectionActive:!1});const W=sa(B,x.current),J=M.startX??0,V=M.startY??0,X={...M,x:W.x<J?W.x:J,y:W.y<V?W.y:V,width:Math.abs(W.x-J),height:Math.abs(W.y-V)},Y=D(),Z=i2($,X,G,t===ql.Partial,!0,H),ee=l2(Z,P).map(se=>se.id),ne=Z.map(se=>se.id);if(N.current!==ne.length){N.current=ne.length;const se=Zo(Y,ne);se.length&&(K==null||K(se))}if(k.current!==ee.length){k.current=ee.length;const se=Zo(P,ee);se.length&&(q==null||q(se))}v.setState({userSelectionRect:X})},F=B=>{if(B.button!==0)return;const{userSelectionRect:M}=v.getState();!j&&M&&B.target===g.current&&(R==null||R(B)),v.setState({nodesSelectionActive:N.current>0}),E(),s==null||s(B)},O=B=>{j&&(v.setState({nodesSelectionActive:N.current>0}),s==null||s(B)),E()},I=b&&(e||j);return de.createElement("div",{className:Ut(["react-flow__pane",{dragging:_,selection:e}]),onClick:I?void 0:jp(R,g),onContextMenu:jp(C,g),onWheel:jp(A,g),onMouseEnter:I?void 0:d,onMouseDown:I?U:void 0,onMouseMove:I?L:h,onMouseUp:I?F:void 0,onMouseLeave:I?O:f,ref:g,style:Hb},p,de.createElement(q6,null))});S2.displayName="Pane";function _2(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return r?r.selected?!0:_2(r,t):!1}function aj(e,t,n){let r=e;do{if(r!=null&&r.matches(t))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function H6(e,t,n,r){return Array.from(e.values()).filter(s=>(s.selected||s.id===r)&&(!s.parentNode||s.parentId||!_2(s,e))&&(s.draggable||t&&typeof s.draggable>"u")).map(s=>{var o,l;return{id:s.id,position:s.position||{x:0,y:0},positionAbsolute:s.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((o=s.positionAbsolute)==null?void 0:o.x)??0),y:n.y-(((l=s.positionAbsolute)==null?void 0:l.y)??0)},delta:{x:0,y:0},extent:s.extent,parentNode:s.parentNode||s.parentId,parentId:s.parentNode||s.parentId,width:s.width,height:s.height,expandParent:s.expandParent}})}function V6(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function E2(e,t,n,r,s=[0,0],o){const l=V6(e,e.extent||r);let c=l;const d=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(d&&e.width&&e.height){const p=n.get(d),{x:g,y:v}=Wa(p,s).positionAbsolute;c=p&&Un(g)&&Un(v)&&Un(p.width)&&Un(p.height)?[[g+e.width*s[0],v+e.height*s[1]],[g+p.width-e.width+e.width*s[0],v+p.height-e.height+e.height*s[1]]]:c}else o==null||o("005",ps.error005()),c=l;else if(e.extent&&d&&e.extent!=="parent"){const p=n.get(d),{x:g,y:v}=Wa(p,s).positionAbsolute;c=[[e.extent[0][0]+g,e.extent[0][1]+v],[e.extent[1][0]+g,e.extent[1][1]+v]]}let h={x:0,y:0};if(d){const p=n.get(d);h=Wa(p,s).positionAbsolute}const f=c&&c!=="parent"?Pb(t,c):t;return{position:{x:f.x-h.x,y:f.y-h.y},positionAbsolute:f}}function Sp({nodeId:e,dragItems:t,nodeInternals:n}){const r=t.map(s=>({...n.get(s.id),position:s.position,positionAbsolute:s.positionAbsolute}));return[e?r.find(s=>s.id===e):r[0],r]}const oj=(e,t,n,r)=>{const s=t.querySelectorAll(e);if(!s||!s.length)return null;const o=Array.from(s),l=t.getBoundingClientRect(),c={x:l.width*r[0],y:l.height*r[1]};return o.map(d=>{const h=d.getBoundingClientRect();return{id:d.getAttribute("data-handleid"),position:d.getAttribute("data-handlepos"),x:(h.left-l.left-c.x)/n,y:(h.top-l.top-c.y)/n,...Lb(d)}})};function gl(e,t,n){return n===void 0?n:r=>{const s=t().nodeInternals.get(e);s&&n(r,{...s})}}function Ax({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:o,multiSelectionActive:l,nodeInternals:c,onError:d}=t.getState(),h=c.get(e);if(!h){d==null||d("012",ps.error012(e));return}t.setState({nodesSelectionActive:!1}),h.selected?(n||h.selected&&l)&&(o({nodes:[h],edges:[]}),requestAnimationFrame(()=>{var f;return(f=r==null?void 0:r.current)==null?void 0:f.blur()})):s([e])}function G6(){const e=Nt();return y.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:s,snapToGrid:o}=e.getState(),l=n.touches?n.touches[0].clientX:n.clientX,c=n.touches?n.touches[0].clientY:n.clientY,d={x:(l-r[0])/r[2],y:(c-r[1])/r[2]};return{xSnapped:o?s[0]*Math.round(d.x/s[0]):d.x,ySnapped:o?s[1]*Math.round(d.y/s[1]):d.y,...d}},[])}function _p(e){return(t,n,r)=>e==null?void 0:e(t,r)}function T2({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:o,selectNodesOnDrag:l}){const c=Nt(),[d,h]=y.useState(!1),f=y.useRef([]),p=y.useRef({x:null,y:null}),g=y.useRef(0),v=y.useRef(null),N=y.useRef({x:0,y:0}),k=y.useRef(null),x=y.useRef(!1),j=y.useRef(!1),b=y.useRef(!1),_=G6();return y.useEffect(()=>{if(e!=null&&e.current){const E=qn(e.current),R=({x:U,y:L})=>{const{nodeInternals:F,onNodeDrag:O,onSelectionDrag:I,updateNodePositions:B,nodeExtent:M,snapGrid:$,snapToGrid:P,nodeOrigin:G,onError:K}=c.getState();p.current={x:U,y:L};let q=!1,H={x:0,y:0,x2:0,y2:0};if(f.current.length>1&&M){const W=Yd(f.current,G);H=Bl(W)}if(f.current=f.current.map(W=>{const J={x:U-W.distance.x,y:L-W.distance.y};P&&(J.x=$[0]*Math.round(J.x/$[0]),J.y=$[1]*Math.round(J.y/$[1]));const V=[[M[0][0],M[0][1]],[M[1][0],M[1][1]]];f.current.length>1&&M&&!W.extent&&(V[0][0]=W.positionAbsolute.x-H.x+M[0][0],V[1][0]=W.positionAbsolute.x+(W.width??0)-H.x2+M[1][0],V[0][1]=W.positionAbsolute.y-H.y+M[0][1],V[1][1]=W.positionAbsolute.y+(W.height??0)-H.y2+M[1][1]);const X=E2(W,J,F,V,G,K);return q=q||W.position.x!==X.position.x||W.position.y!==X.position.y,W.position=X.position,W.positionAbsolute=X.positionAbsolute,W}),!q)return;B(f.current,!0,!0),h(!0);const D=s?O:_p(I);if(D&&k.current){const[W,J]=Sp({nodeId:s,dragItems:f.current,nodeInternals:F});D(k.current,W,J)}},C=()=>{if(!v.current)return;const[U,L]=ZM(N.current,v.current);if(U!==0||L!==0){const{transform:F,panBy:O}=c.getState();p.current.x=(p.current.x??0)-U/F[2],p.current.y=(p.current.y??0)-L/F[2],O({x:U,y:L})&&R(p.current)}g.current=requestAnimationFrame(C)},A=U=>{var G;const{nodeInternals:L,multiSelectionActive:F,nodesDraggable:O,unselectNodesAndEdges:I,onNodeDragStart:B,onSelectionDragStart:M}=c.getState();j.current=!0;const $=s?B:_p(M);(!l||!o)&&!F&&s&&((G=L.get(s))!=null&&G.selected||I()),s&&o&&l&&Ax({id:s,store:c,nodeRef:e});const P=_(U);if(p.current=P,f.current=H6(L,O,P,s),$&&f.current){const[K,q]=Sp({nodeId:s,dragItems:f.current,nodeInternals:L});$(U.sourceEvent,K,q)}};if(t)E.on(".drag",null);else{const U=rF().on("start",L=>{const{domNode:F,nodeDragThreshold:O}=c.getState();O===0&&A(L),b.current=!1;const I=_(L);p.current=I,v.current=(F==null?void 0:F.getBoundingClientRect())||null,N.current=sa(L.sourceEvent,v.current)}).on("drag",L=>{var B,M;const F=_(L),{autoPanOnNodeDrag:O,nodeDragThreshold:I}=c.getState();if(L.sourceEvent.type==="touchmove"&&L.sourceEvent.touches.length>1&&(b.current=!0),!b.current){if(!x.current&&j.current&&O&&(x.current=!0,C()),!j.current){const $=F.xSnapped-(((B=p==null?void 0:p.current)==null?void 0:B.x)??0),P=F.ySnapped-(((M=p==null?void 0:p.current)==null?void 0:M.y)??0);Math.sqrt($*$+P*P)>I&&A(L)}(p.current.x!==F.xSnapped||p.current.y!==F.ySnapped)&&f.current&&j.current&&(k.current=L.sourceEvent,N.current=sa(L.sourceEvent,v.current),R(F))}}).on("end",L=>{if(!(!j.current||b.current)&&(h(!1),x.current=!1,j.current=!1,cancelAnimationFrame(g.current),f.current)){const{updateNodePositions:F,nodeInternals:O,onNodeDragStop:I,onSelectionDragStop:B}=c.getState(),M=s?I:_p(B);if(F(f.current,!1,!1),M){const[$,P]=Sp({nodeId:s,dragItems:f.current,nodeInternals:O});M(L.sourceEvent,$,P)}}}).filter(L=>{const F=L.target;return!L.button&&(!n||!aj(F,`.${n}`,e))&&(!r||aj(F,r,e))});return E.call(U),()=>{E.on(".drag",null)}}}},[e,t,n,r,o,c,s,l,_]),d}function C2(){const e=Nt();return y.useCallback(n=>{const{nodeInternals:r,nodeExtent:s,updateNodePositions:o,getNodes:l,snapToGrid:c,snapGrid:d,onError:h,nodesDraggable:f}=e.getState(),p=l().filter(b=>b.selected&&(b.draggable||f&&typeof b.draggable>"u")),g=c?d[0]:5,v=c?d[1]:5,N=n.isShiftPressed?4:1,k=n.x*g*N,x=n.y*v*N,j=p.map(b=>{if(b.positionAbsolute){const _={x:b.positionAbsolute.x+k,y:b.positionAbsolute.y+x};c&&(_.x=d[0]*Math.round(_.x/d[0]),_.y=d[1]*Math.round(_.y/d[1]));const{positionAbsolute:E,position:R}=E2(b,_,r,s,void 0,h);b.position=R,b.positionAbsolute=E}return b});o(j,!0,!1)},[])}const si={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var yl=e=>{const t=({id:n,type:r,data:s,xPos:o,yPos:l,xPosOrigin:c,yPosOrigin:d,selected:h,onClick:f,onMouseEnter:p,onMouseMove:g,onMouseLeave:v,onContextMenu:N,onDoubleClick:k,style:x,className:j,isDraggable:b,isSelectable:_,isConnectable:E,isFocusable:R,selectNodesOnDrag:C,sourcePosition:A,targetPosition:U,hidden:L,resizeObserver:F,dragHandle:O,zIndex:I,isParent:B,noDragClassName:M,noPanClassName:$,initialized:P,disableKeyboardA11y:G,ariaLabel:K,rfId:q,hasHandleBounds:H})=>{const D=Nt(),W=y.useRef(null),J=y.useRef(null),V=y.useRef(A),X=y.useRef(U),Y=y.useRef(r),Z=_||b||f||p||g||v,ee=C2(),ne=gl(n,D.getState,p),se=gl(n,D.getState,g),pe=gl(n,D.getState,v),ke=gl(n,D.getState,N),ae=gl(n,D.getState,k),fe=ge=>{const{nodeDragThreshold:ue}=D.getState();if(_&&(!C||!b||ue>0)&&Ax({id:n,store:D,nodeRef:W}),f){const be=D.getState().nodeInternals.get(n);be&&f(ge,{...be})}},me=ge=>{if(!Sx(ge)&&!G)if(t2.includes(ge.key)&&_){const ue=ge.key==="Escape";Ax({id:n,store:D,unselect:ue,nodeRef:W})}else b&&h&&Object.prototype.hasOwnProperty.call(si,ge.key)&&(D.setState({ariaLiveMessage:`Moved selected node ${ge.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~l}`}),ee({x:si[ge.key].x,y:si[ge.key].y,isShiftPressed:ge.shiftKey}))};y.useEffect(()=>()=>{J.current&&(F==null||F.unobserve(J.current),J.current=null)},[]),y.useEffect(()=>{if(W.current&&!L){const ge=W.current;(!P||!H||J.current!==ge)&&(J.current&&(F==null||F.unobserve(J.current)),F==null||F.observe(ge),J.current=ge)}},[L,P,H]),y.useEffect(()=>{const ge=Y.current!==r,ue=V.current!==A,be=X.current!==U;W.current&&(ge||ue||be)&&(ge&&(Y.current=r),ue&&(V.current=A),be&&(X.current=U),D.getState().updateNodeDimensions([{id:n,nodeElement:W.current,forceUpdate:!0}]))},[n,r,A,U]);const he=T2({nodeRef:W,disabled:L||!b,noDragClassName:M,handleSelector:O,nodeId:n,isSelectable:_,selectNodesOnDrag:C});return L?null:de.createElement("div",{className:Ut(["react-flow__node",`react-flow__node-${r}`,{[$]:b},j,{selected:h,selectable:_,parent:B,dragging:he}]),ref:W,style:{zIndex:I,transform:`translate(${c}px,${d}px)`,pointerEvents:Z?"all":"none",visibility:P?"visible":"hidden",...x},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:ne,onMouseMove:se,onMouseLeave:pe,onContextMenu:ke,onClick:fe,onDoubleClick:ae,onKeyDown:R?me:void 0,tabIndex:R?0:void 0,role:R?"button":void 0,"aria-describedby":G?void 0:`${x2}-${q}`,"aria-label":K},de.createElement(o6,{value:n},de.createElement(e,{id:n,data:s,type:r,xPos:o,yPos:l,selected:h,isConnectable:E,sourcePosition:A,targetPosition:U,dragging:he,dragHandle:O,zIndex:I})))};return t.displayName="NodeWrapper",y.memo(t)};const K6=e=>{const t=e.getNodes().filter(n=>n.selected);return{...Yd(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function Y6({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Nt(),{width:s,height:o,x:l,y:c,transformString:d,userSelectionActive:h}=Xe(K6,At),f=C2(),p=y.useRef(null);if(y.useEffect(()=>{var N;n||(N=p.current)==null||N.focus({preventScroll:!0})},[n]),T2({nodeRef:p}),h||!s||!o)return null;const g=e?N=>{const k=r.getState().getNodes().filter(x=>x.selected);e(N,k)}:void 0,v=N=>{Object.prototype.hasOwnProperty.call(si,N.key)&&f({x:si[N.key].x,y:si[N.key].y,isShiftPressed:N.shiftKey})};return de.createElement("div",{className:Ut(["react-flow__nodesselection","react-flow__container",t]),style:{transform:d}},de.createElement("div",{ref:p,className:"react-flow__nodesselection-rect",onContextMenu:g,tabIndex:n?void 0:-1,onKeyDown:n?void 0:v,style:{width:s,height:o,top:c,left:l}}))}var X6=y.memo(Y6);const Z6=e=>e.nodesSelectionActive,A2=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:l,deleteKeyCode:c,onMove:d,onMoveStart:h,onMoveEnd:f,selectionKeyCode:p,selectionOnDrag:g,selectionMode:v,onSelectionStart:N,onSelectionEnd:k,multiSelectionKeyCode:x,panActivationKeyCode:j,zoomActivationKeyCode:b,elementsSelectable:_,zoomOnScroll:E,zoomOnPinch:R,panOnScroll:C,panOnScrollSpeed:A,panOnScrollMode:U,zoomOnDoubleClick:L,panOnDrag:F,defaultViewport:O,translateExtent:I,minZoom:B,maxZoom:M,preventScrolling:$,onSelectionContextMenu:P,noWheelClassName:G,noPanClassName:K,disableKeyboardA11y:q})=>{const H=Xe(Z6),D=Ul(p),W=Ul(j),J=W||F,V=W||C,X=D||g&&J!==!0;return O6({deleteKeyCode:c,multiSelectionKeyCode:x}),de.createElement(F6,{onMove:d,onMoveStart:h,onMoveEnd:f,onPaneContextMenu:o,elementsSelectable:_,zoomOnScroll:E,zoomOnPinch:R,panOnScroll:V,panOnScrollSpeed:A,panOnScrollMode:U,zoomOnDoubleClick:L,panOnDrag:!D&&J,defaultViewport:O,translateExtent:I,minZoom:B,maxZoom:M,zoomActivationKeyCode:b,preventScrolling:$,noWheelClassName:G,noPanClassName:K},de.createElement(S2,{onSelectionStart:N,onSelectionEnd:k,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:l,panOnDrag:J,isSelecting:!!X,selectionMode:v},e,H&&de.createElement(X6,{onSelectionContextMenu:P,noPanClassName:K,disableKeyboardA11y:q})))};A2.displayName="FlowRenderer";var J6=y.memo(A2);function Q6(e){return Xe(y.useCallback(n=>e?i2(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function eB(e){const t={input:yl(e.input||g2),default:yl(e.default||Cx),output:yl(e.output||w2),group:yl(e.group||Wb)},n={},r=Object.keys(e).filter(s=>!["input","default","output","group"].includes(s)).reduce((s,o)=>(s[o]=yl(e[o]||Cx),s),n);return{...t,...r}}const tB=({x:e,y:t,width:n,height:r,origin:s})=>!n||!r?{x:e,y:t}:s[0]<0||s[1]<0||s[0]>1||s[1]>1?{x:e,y:t}:{x:e-n*s[0],y:t-r*s[1]},nB=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),R2=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,updateNodeDimensions:o,onError:l}=Xe(nB,At),c=Q6(e.onlyRenderVisibleElements),d=y.useRef(),h=y.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const f=new ResizeObserver(p=>{const g=p.map(v=>({id:v.target.getAttribute("data-id"),nodeElement:v.target,forceUpdate:!0}));o(g)});return d.current=f,f},[]);return y.useEffect(()=>()=>{var f;(f=d==null?void 0:d.current)==null||f.disconnect()},[]),de.createElement("div",{className:"react-flow__nodes",style:Hb},c.map(f=>{var R,C,A;let p=f.type||"default";e.nodeTypes[p]||(l==null||l("003",ps.error003(p)),p="default");const g=e.nodeTypes[p]||e.nodeTypes.default,v=!!(f.draggable||t&&typeof f.draggable>"u"),N=!!(f.selectable||s&&typeof f.selectable>"u"),k=!!(f.connectable||n&&typeof f.connectable>"u"),x=!!(f.focusable||r&&typeof f.focusable>"u"),j=e.nodeExtent?Pb(f.positionAbsolute,e.nodeExtent):f.positionAbsolute,b=(j==null?void 0:j.x)??0,_=(j==null?void 0:j.y)??0,E=tB({x:b,y:_,width:f.width??0,height:f.height??0,origin:e.nodeOrigin});return de.createElement(g,{key:f.id,id:f.id,className:f.className,style:f.style,type:p,data:f.data,sourcePosition:f.sourcePosition||Ae.Bottom,targetPosition:f.targetPosition||Ae.Top,hidden:f.hidden,xPos:b,yPos:_,xPosOrigin:E.x,yPosOrigin:E.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:v,isSelectable:N,isConnectable:k,isFocusable:x,resizeObserver:h,dragHandle:f.dragHandle,zIndex:((R=f[mt])==null?void 0:R.z)??0,isParent:!!((C=f[mt])!=null&&C.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!f.width&&!!f.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:f.ariaLabel,hasHandleBounds:!!((A=f[mt])!=null&&A.handleBounds)})}))};R2.displayName="NodeRenderer";var rB=y.memo(R2);const sB=(e,t,n)=>n===Ae.Left?e-t:n===Ae.Right?e+t:e,aB=(e,t,n)=>n===Ae.Top?e-t:n===Ae.Bottom?e+t:e,ij="react-flow__edgeupdater",lj=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:o,onMouseOut:l,type:c})=>de.createElement("circle",{onMouseDown:s,onMouseEnter:o,onMouseOut:l,className:Ut([ij,`${ij}-${c}`]),cx:sB(t,r,e),cy:aB(n,r,e),r,stroke:"transparent",fill:"transparent"}),oB=()=>!0;var Fo=e=>{const t=({id:n,className:r,type:s,data:o,onClick:l,onEdgeDoubleClick:c,selected:d,animated:h,label:f,labelStyle:p,labelShowBg:g,labelBgStyle:v,labelBgPadding:N,labelBgBorderRadius:k,style:x,source:j,target:b,sourceX:_,sourceY:E,targetX:R,targetY:C,sourcePosition:A,targetPosition:U,elementsSelectable:L,hidden:F,sourceHandleId:O,targetHandleId:I,onContextMenu:B,onMouseEnter:M,onMouseMove:$,onMouseLeave:P,reconnectRadius:G,onReconnect:K,onReconnectStart:q,onReconnectEnd:H,markerEnd:D,markerStart:W,rfId:J,ariaLabel:V,isFocusable:X,isReconnectable:Y,pathOptions:Z,interactionWidth:ee,disableKeyboardA11y:ne})=>{const se=y.useRef(null),[pe,ke]=y.useState(!1),[ae,fe]=y.useState(!1),me=Nt(),he=y.useMemo(()=>`url('#${Ex(W,J)}')`,[W,J]),ge=y.useMemo(()=>`url('#${Ex(D,J)}')`,[D,J]);if(F)return null;const ue=De=>{var wt;const{edges:et,addSelectedEdges:Je,unselectNodesAndEdges:tt,multiSelectionActive:yt}=me.getState(),Pt=et.find(st=>st.id===n);Pt&&(L&&(me.setState({nodesSelectionActive:!1}),Pt.selected&&yt?(tt({nodes:[],edges:[Pt]}),(wt=se.current)==null||wt.blur()):Je([n])),l&&l(De,Pt))},be=ml(n,me.getState,c),oe=ml(n,me.getState,B),je=ml(n,me.getState,M),$e=ml(n,me.getState,$),Oe=ml(n,me.getState,P),Ue=(De,et)=>{if(De.button!==0)return;const{edges:Je,isValidConnection:tt}=me.getState(),yt=et?b:j,Pt=(et?I:O)||null,wt=et?"target":"source",st=tt||oB,zt=et,Wt=Je.find(Vt=>Vt.id===n);fe(!0),q==null||q(De,Wt,wt);const Dt=Vt=>{fe(!1),H==null||H(Vt,Wt,wt)};h2({event:De,handleId:Pt,nodeId:yt,onConnect:Vt=>K==null?void 0:K(Wt,Vt),isTarget:zt,getState:me.getState,setState:me.setState,isValidConnection:st,edgeUpdaterType:wt,onReconnectEnd:Dt})},Be=De=>Ue(De,!0),We=De=>Ue(De,!1),He=()=>ke(!0),rt=()=>ke(!1),lt=!L&&!l,Rt=De=>{var et;if(!ne&&t2.includes(De.key)&&L){const{unselectNodesAndEdges:Je,addSelectedEdges:tt,edges:yt}=me.getState();De.key==="Escape"?((et=se.current)==null||et.blur(),Je({edges:[yt.find(wt=>wt.id===n)]})):tt([n])}};return de.createElement("g",{className:Ut(["react-flow__edge",`react-flow__edge-${s}`,r,{selected:d,animated:h,inactive:lt,updating:pe}]),onClick:ue,onDoubleClick:be,onContextMenu:oe,onMouseEnter:je,onMouseMove:$e,onMouseLeave:Oe,onKeyDown:X?Rt:void 0,tabIndex:X?0:void 0,role:X?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":V===null?void 0:V||`Edge from ${j} to ${b}`,"aria-describedby":X?`${b2}-${J}`:void 0,ref:se},!ae&&de.createElement(e,{id:n,source:j,target:b,selected:d,animated:h,label:f,labelStyle:p,labelShowBg:g,labelBgStyle:v,labelBgPadding:N,labelBgBorderRadius:k,data:o,style:x,sourceX:_,sourceY:E,targetX:R,targetY:C,sourcePosition:A,targetPosition:U,sourceHandleId:O,targetHandleId:I,markerStart:he,markerEnd:ge,pathOptions:Z,interactionWidth:ee}),Y&&de.createElement(de.Fragment,null,(Y==="source"||Y===!0)&&de.createElement(lj,{position:A,centerX:_,centerY:E,radius:G,onMouseDown:Be,onMouseEnter:He,onMouseOut:rt,type:"source"}),(Y==="target"||Y===!0)&&de.createElement(lj,{position:U,centerX:R,centerY:C,radius:G,onMouseDown:We,onMouseEnter:He,onMouseOut:rt,type:"target"})))};return t.displayName="EdgeWrapper",y.memo(t)};function iB(e){const t={default:Fo(e.default||yd),straight:Fo(e.bezier||Bb),step:Fo(e.step||Fb),smoothstep:Fo(e.step||Kd),simplebezier:Fo(e.simplebezier||Db)},n={},r=Object.keys(e).filter(s=>!["default","bezier"].includes(s)).reduce((s,o)=>(s[o]=Fo(e[o]||yd),s),n);return{...t,...r}}function cj(e,t,n=null){const r=((n==null?void 0:n.x)||0)+t.x,s=((n==null?void 0:n.y)||0)+t.y,o=(n==null?void 0:n.width)||t.width,l=(n==null?void 0:n.height)||t.height;switch(e){case Ae.Top:return{x:r+o/2,y:s};case Ae.Right:return{x:r+o,y:s+l/2};case Ae.Bottom:return{x:r+o/2,y:s+l};case Ae.Left:return{x:r,y:s+l/2}}}function uj(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const lB=(e,t,n,r,s,o)=>{const l=cj(n,e,t),c=cj(o,r,s);return{sourceX:l.x,sourceY:l.y,targetX:c.x,targetY:c.y}};function cB({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:s,targetHeight:o,width:l,height:c,transform:d}){const h={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+s),y2:Math.max(e.y+r,t.y+o)};h.x===h.x2&&(h.x2+=1),h.y===h.y2&&(h.y2+=1);const f=Bl({x:(0-d[0])/d[2],y:(0-d[1])/d[2],width:l/d[2],height:c/d[2]}),p=Math.max(0,Math.min(f.x2,h.x2)-Math.max(f.x,h.x)),g=Math.max(0,Math.min(f.y2,h.y2)-Math.max(f.y,h.y));return Math.ceil(p*g)>0}function dj(e){var r,s,o,l,c;const t=((r=e==null?void 0:e[mt])==null?void 0:r.handleBounds)||null,n=t&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((s=e==null?void 0:e.positionAbsolute)==null?void 0:s.x)<"u"&&typeof((o=e==null?void 0:e.positionAbsolute)==null?void 0:o.y)<"u";return[{x:((l=e==null?void 0:e.positionAbsolute)==null?void 0:l.x)||0,y:((c=e==null?void 0:e.positionAbsolute)==null?void 0:c.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}const uB=[{level:0,isMaxLevel:!0,edges:[]}];function dB(e,t,n=!1){let r=-1;const s=e.reduce((l,c)=>{var f,p;const d=Un(c.zIndex);let h=d?c.zIndex:0;if(n){const g=t.get(c.target),v=t.get(c.source),N=c.selected||(g==null?void 0:g.selected)||(v==null?void 0:v.selected),k=Math.max(((f=v==null?void 0:v[mt])==null?void 0:f.z)||0,((p=g==null?void 0:g[mt])==null?void 0:p.z)||0,1e3);h=(d?c.zIndex:0)+(N?k:0)}return l[h]?l[h].push(c):l[h]=[c],r=h>r?h:r,l},{}),o=Object.entries(s).map(([l,c])=>{const d=+l;return{edges:c,level:d,isMaxLevel:d===r}});return o.length===0?uB:o}function hB(e,t,n){const r=Xe(y.useCallback(s=>e?s.edges.filter(o=>{const l=t.get(o.source),c=t.get(o.target);return(l==null?void 0:l.width)&&(l==null?void 0:l.height)&&(c==null?void 0:c.width)&&(c==null?void 0:c.height)&&cB({sourcePos:l.positionAbsolute||{x:0,y:0},targetPos:c.positionAbsolute||{x:0,y:0},sourceWidth:l.width,sourceHeight:l.height,targetWidth:c.width,targetHeight:c.height,width:s.width,height:s.height,transform:s.transform})}):s.edges,[e,t]));return dB(r,t,n)}const fB=({color:e="none",strokeWidth:t=1})=>de.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),pB=({color:e="none",strokeWidth:t=1})=>de.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),hj={[gd.Arrow]:fB,[gd.ArrowClosed]:pB};function mB(e){const t=Nt();return y.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(hj,e)?hj[e]:((o=(s=t.getState()).onError)==null||o.call(s,"009",ps.error009(e)),null)},[e])}const gB=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:o="strokeWidth",strokeWidth:l,orient:c="auto-start-reverse"})=>{const d=mB(t);return d?de.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:c,refX:"0",refY:"0"},de.createElement(d,{color:n,strokeWidth:l})):null},yB=({defaultColor:e,rfId:t})=>n=>{const r=[];return n.edges.reduce((s,o)=>([o.markerStart,o.markerEnd].forEach(l=>{if(l&&typeof l=="object"){const c=Ex(l,t);r.includes(c)||(s.push({id:c,color:l.color||e,...l}),r.push(c))}}),s),[]).sort((s,o)=>s.id.localeCompare(o.id))},M2=({defaultColor:e,rfId:t})=>{const n=Xe(y.useCallback(yB({defaultColor:e,rfId:t}),[e,t]),(r,s)=>!(r.length!==s.length||r.some((o,l)=>o.id!==s[l].id)));return de.createElement("defs",null,n.map(r=>de.createElement(gB,{id:r.id,key:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient})))};M2.displayName="MarkerDefinitions";var wB=y.memo(M2);const vB=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}),$2=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:s,noPanClassName:o,onEdgeContextMenu:l,onEdgeMouseEnter:c,onEdgeMouseMove:d,onEdgeMouseLeave:h,onEdgeClick:f,onEdgeDoubleClick:p,onReconnect:g,onReconnectStart:v,onReconnectEnd:N,reconnectRadius:k,children:x,disableKeyboardA11y:j})=>{const{edgesFocusable:b,edgesUpdatable:_,elementsSelectable:E,width:R,height:C,connectionMode:A,nodeInternals:U,onError:L}=Xe(vB,At),F=hB(t,U,n);return R?de.createElement(de.Fragment,null,F.map(({level:O,edges:I,isMaxLevel:B})=>de.createElement("svg",{key:O,style:{zIndex:O},width:R,height:C,className:"react-flow__edges react-flow__container"},B&&de.createElement(wB,{defaultColor:e,rfId:r}),de.createElement("g",null,I.map(M=>{const[$,P,G]=dj(U.get(M.source)),[K,q,H]=dj(U.get(M.target));if(!G||!H)return null;let D=M.type||"default";s[D]||(L==null||L("011",ps.error011(D)),D="default");const W=s[D]||s.default,J=A===Ya.Strict?q.target:(q.target??[]).concat(q.source??[]),V=uj(P.source,M.sourceHandle),X=uj(J,M.targetHandle),Y=(V==null?void 0:V.position)||Ae.Bottom,Z=(X==null?void 0:X.position)||Ae.Top,ee=!!(M.focusable||b&&typeof M.focusable>"u"),ne=M.reconnectable||M.updatable,se=typeof g<"u"&&(ne||_&&typeof ne>"u");if(!V||!X)return L==null||L("008",ps.error008(V,M)),null;const{sourceX:pe,sourceY:ke,targetX:ae,targetY:fe}=lB($,V,Y,K,X,Z);return de.createElement(W,{key:M.id,id:M.id,className:Ut([M.className,o]),type:D,data:M.data,selected:!!M.selected,animated:!!M.animated,hidden:!!M.hidden,label:M.label,labelStyle:M.labelStyle,labelShowBg:M.labelShowBg,labelBgStyle:M.labelBgStyle,labelBgPadding:M.labelBgPadding,labelBgBorderRadius:M.labelBgBorderRadius,style:M.style,source:M.source,target:M.target,sourceHandleId:M.sourceHandle,targetHandleId:M.targetHandle,markerEnd:M.markerEnd,markerStart:M.markerStart,sourceX:pe,sourceY:ke,targetX:ae,targetY:fe,sourcePosition:Y,targetPosition:Z,elementsSelectable:E,onContextMenu:l,onMouseEnter:c,onMouseMove:d,onMouseLeave:h,onClick:f,onEdgeDoubleClick:p,onReconnect:g,onReconnectStart:v,onReconnectEnd:N,reconnectRadius:k,rfId:r,ariaLabel:M.ariaLabel,isFocusable:ee,isReconnectable:se,pathOptions:"pathOptions"in M?M.pathOptions:void 0,interactionWidth:M.interactionWidth,disableKeyboardA11y:j})})))),x):null};$2.displayName="EdgeRenderer";var xB=y.memo($2);const bB=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function kB({children:e}){const t=Xe(bB);return de.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function NB(e){const t=ki(),n=y.useRef(!1);y.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const jB={[Ae.Left]:Ae.Right,[Ae.Right]:Ae.Left,[Ae.Top]:Ae.Bottom,[Ae.Bottom]:Ae.Top},I2=({nodeId:e,handleType:t,style:n,type:r=Qs.Bezier,CustomComponent:s,connectionStatus:o})=>{var C,A,U;const{fromNode:l,handleId:c,toX:d,toY:h,connectionMode:f}=Xe(y.useCallback(L=>({fromNode:L.nodeInternals.get(e),handleId:L.connectionHandleId,toX:(L.connectionPosition.x-L.transform[0])/L.transform[2],toY:(L.connectionPosition.y-L.transform[1])/L.transform[2],connectionMode:L.connectionMode}),[e]),At),p=(C=l==null?void 0:l[mt])==null?void 0:C.handleBounds;let g=p==null?void 0:p[t];if(f===Ya.Loose&&(g=g||(p==null?void 0:p[t==="source"?"target":"source"])),!l||!g)return null;const v=c?g.find(L=>L.id===c):g[0],N=v?v.x+v.width/2:(l.width??0)/2,k=v?v.y+v.height/2:l.height??0,x=(((A=l.positionAbsolute)==null?void 0:A.x)??0)+N,j=(((U=l.positionAbsolute)==null?void 0:U.y)??0)+k,b=v==null?void 0:v.position,_=b?jB[b]:null;if(!b||!_)return null;if(s)return de.createElement(s,{connectionLineType:r,connectionLineStyle:n,fromNode:l,fromHandle:v,fromX:x,fromY:j,toX:d,toY:h,fromPosition:b,toPosition:_,connectionStatus:o});let E="";const R={sourceX:x,sourceY:j,sourcePosition:b,targetX:d,targetY:h,targetPosition:_};return r===Qs.Bezier?[E]=qb(R):r===Qs.Step?[E]=_x({...R,borderRadius:0}):r===Qs.SmoothStep?[E]=_x(R):r===Qs.SimpleBezier?[E]=a2(R):E=`M${x},${j} ${d},${h}`,de.createElement("path",{d:E,fill:"none",className:"react-flow__connection-path",style:n})};I2.displayName="ConnectionLine";const SB=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function _B({containerStyle:e,style:t,type:n,component:r}){const{nodeId:s,handleType:o,nodesConnectable:l,width:c,height:d,connectionStatus:h}=Xe(SB,At);return!(s&&o&&c&&l)?null:de.createElement("svg",{style:e,width:c,height:d,className:"react-flow__edges react-flow__connectionline react-flow__container"},de.createElement("g",{className:Ut(["react-flow__connection",h])},de.createElement(I2,{nodeId:s,handleType:o,style:t,type:n,CustomComponent:r,connectionStatus:h})))}function fj(e,t){return y.useRef(null),Nt(),y.useMemo(()=>t(e),[e])}const O2=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:s,onInit:o,onNodeClick:l,onEdgeClick:c,onNodeDoubleClick:d,onEdgeDoubleClick:h,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:g,onNodeContextMenu:v,onSelectionContextMenu:N,onSelectionStart:k,onSelectionEnd:x,connectionLineType:j,connectionLineStyle:b,connectionLineComponent:_,connectionLineContainerStyle:E,selectionKeyCode:R,selectionOnDrag:C,selectionMode:A,multiSelectionKeyCode:U,panActivationKeyCode:L,zoomActivationKeyCode:F,deleteKeyCode:O,onlyRenderVisibleElements:I,elementsSelectable:B,selectNodesOnDrag:M,defaultViewport:$,translateExtent:P,minZoom:G,maxZoom:K,preventScrolling:q,defaultMarkerColor:H,zoomOnScroll:D,zoomOnPinch:W,panOnScroll:J,panOnScrollSpeed:V,panOnScrollMode:X,zoomOnDoubleClick:Y,panOnDrag:Z,onPaneClick:ee,onPaneMouseEnter:ne,onPaneMouseMove:se,onPaneMouseLeave:pe,onPaneScroll:ke,onPaneContextMenu:ae,onEdgeContextMenu:fe,onEdgeMouseEnter:me,onEdgeMouseMove:he,onEdgeMouseLeave:ge,onReconnect:ue,onReconnectStart:be,onReconnectEnd:oe,reconnectRadius:je,noDragClassName:$e,noWheelClassName:Oe,noPanClassName:Ue,elevateEdgesOnSelect:Be,disableKeyboardA11y:We,nodeOrigin:He,nodeExtent:rt,rfId:lt})=>{const Rt=fj(e,eB),De=fj(t,iB);return NB(o),de.createElement(J6,{onPaneClick:ee,onPaneMouseEnter:ne,onPaneMouseMove:se,onPaneMouseLeave:pe,onPaneContextMenu:ae,onPaneScroll:ke,deleteKeyCode:O,selectionKeyCode:R,selectionOnDrag:C,selectionMode:A,onSelectionStart:k,onSelectionEnd:x,multiSelectionKeyCode:U,panActivationKeyCode:L,zoomActivationKeyCode:F,elementsSelectable:B,onMove:n,onMoveStart:r,onMoveEnd:s,zoomOnScroll:D,zoomOnPinch:W,zoomOnDoubleClick:Y,panOnScroll:J,panOnScrollSpeed:V,panOnScrollMode:X,panOnDrag:Z,defaultViewport:$,translateExtent:P,minZoom:G,maxZoom:K,onSelectionContextMenu:N,preventScrolling:q,noDragClassName:$e,noWheelClassName:Oe,noPanClassName:Ue,disableKeyboardA11y:We},de.createElement(kB,null,de.createElement(xB,{edgeTypes:De,onEdgeClick:c,onEdgeDoubleClick:h,onlyRenderVisibleElements:I,onEdgeContextMenu:fe,onEdgeMouseEnter:me,onEdgeMouseMove:he,onEdgeMouseLeave:ge,onReconnect:ue,onReconnectStart:be,onReconnectEnd:oe,reconnectRadius:je,defaultMarkerColor:H,noPanClassName:Ue,elevateEdgesOnSelect:!!Be,disableKeyboardA11y:We,rfId:lt},de.createElement(_B,{style:b,type:j,component:_,containerStyle:E})),de.createElement("div",{className:"react-flow__edgelabel-renderer"}),de.createElement(rB,{nodeTypes:Rt,onNodeClick:l,onNodeDoubleClick:d,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:g,onNodeContextMenu:v,selectNodesOnDrag:M,onlyRenderVisibleElements:I,noPanClassName:Ue,noDragClassName:$e,disableKeyboardA11y:We,nodeOrigin:He,nodeExtent:rt,rfId:lt})))};O2.displayName="GraphView";var EB=y.memo(O2);const Rx=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ys={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:Rx,nodeExtent:Rx,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Ya.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:e6,isValidConnection:void 0},TB=()=>m4((e,t)=>({...Ys,setNodes:n=>{const{nodeInternals:r,nodeOrigin:s,elevateNodesOnSelect:o}=t();e({nodeInternals:Np(n,r,s,o)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=t();e({edges:n.map(s=>({...r,...s}))})},setDefaultNodesAndEdges:(n,r)=>{const s=typeof n<"u",o=typeof r<"u",l=s?Np(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:l,edges:o?r:[],hasDefaultNodes:s,hasDefaultEdges:o})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:s,fitViewOnInit:o,fitViewOnInitDone:l,fitViewOnInitOptions:c,domNode:d,nodeOrigin:h}=t(),f=d==null?void 0:d.querySelector(".react-flow__viewport");if(!f)return;const p=window.getComputedStyle(f),{m22:g}=new window.DOMMatrixReadOnly(p.transform),v=n.reduce((k,x)=>{const j=s.get(x.id);if(j!=null&&j.hidden)s.set(j.id,{...j,[mt]:{...j[mt],handleBounds:void 0}});else if(j){const b=Lb(x.nodeElement);!!(b.width&&b.height&&(j.width!==b.width||j.height!==b.height||x.forceUpdate))&&(s.set(j.id,{...j,[mt]:{...j[mt],handleBounds:{source:oj(".source",x.nodeElement,g,h),target:oj(".target",x.nodeElement,g,h)}},...b}),k.push({id:j.id,type:"dimensions",dimensions:b}))}return k},[]);N2(s,h);const N=l||o&&!l&&j2(t,{initial:!0,...c});e({nodeInternals:new Map(s),fitViewOnInitDone:N}),(v==null?void 0:v.length)>0&&(r==null||r(v))},updateNodePositions:(n,r=!0,s=!1)=>{const{triggerNodeChanges:o}=t(),l=n.map(c=>{const d={id:c.id,type:"position",dragging:s};return r&&(d.positionAbsolute=c.positionAbsolute,d.position=c.position),d});o(l)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:s,hasDefaultNodes:o,nodeOrigin:l,getNodes:c,elevateNodesOnSelect:d}=t();if(n!=null&&n.length){if(o){const h=z6(n,c()),f=Np(h,s,l,d);e({nodeInternals:f})}r==null||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:s,getNodes:o}=t();let l,c=null;r?l=n.map(d=>Js(d,!0)):(l=Zo(o(),n),c=Zo(s,[])),Mu({changedNodes:l,changedEdges:c,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:s,getNodes:o}=t();let l,c=null;r?l=n.map(d=>Js(d,!0)):(l=Zo(s,n),c=Zo(o(),[])),Mu({changedNodes:c,changedEdges:l,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:s,getNodes:o}=t(),l=n||o(),c=r||s,d=l.map(f=>(f.selected=!1,Js(f.id,!1))),h=c.map(f=>Js(f.id,!1));Mu({changedNodes:d,changedEdges:h,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:s}=t();r==null||r.scaleExtent([n,s]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:s}=t();r==null||r.scaleExtent([s,n]),e({maxZoom:n})},setTranslateExtent:n=>{var r;(r=t().d3Zoom)==null||r.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=t(),o=r().filter(c=>c.selected).map(c=>Js(c.id,!1)),l=n.filter(c=>c.selected).map(c=>Js(c.id,!1));Mu({changedNodes:o,changedEdges:l,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach(s=>{s.positionAbsolute=Pb(s.position,n)}),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:s,height:o,d3Zoom:l,d3Selection:c,translateExtent:d}=t();if(!l||!c||!n.x&&!n.y)return!1;const h=us.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),f=[[0,0],[s,o]],p=l==null?void 0:l.constrain()(h,f,d);return l.transform(c,p),r[0]!==p.x||r[1]!==p.y||r[2]!==p.k},cancelConnection:()=>e({connectionNodeId:Ys.connectionNodeId,connectionHandleId:Ys.connectionHandleId,connectionHandleType:Ys.connectionHandleType,connectionStatus:Ys.connectionStatus,connectionStartHandle:Ys.connectionStartHandle,connectionEndHandle:Ys.connectionEndHandle}),reset:()=>e({...Ys})}),Object.is),Vb=({children:e})=>{const t=y.useRef(null);return t.current||(t.current=TB()),de.createElement(G5,{value:t.current},e)};Vb.displayName="ReactFlowProvider";const L2=({children:e})=>y.useContext(Gd)?de.createElement(de.Fragment,null,e):de.createElement(Vb,null,e);L2.displayName="ReactFlowWrapper";const CB={input:g2,default:Cx,output:w2,group:Wb},AB={default:yd,straight:Bb,step:Fb,smoothstep:Kd,simplebezier:Db},RB=[0,0],MB=[15,15],$B={x:0,y:0,zoom:1},IB={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},P2=y.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:o=CB,edgeTypes:l=AB,onNodeClick:c,onEdgeClick:d,onInit:h,onMove:f,onMoveStart:p,onMoveEnd:g,onConnect:v,onConnectStart:N,onConnectEnd:k,onClickConnectStart:x,onClickConnectEnd:j,onNodeMouseEnter:b,onNodeMouseMove:_,onNodeMouseLeave:E,onNodeContextMenu:R,onNodeDoubleClick:C,onNodeDragStart:A,onNodeDrag:U,onNodeDragStop:L,onNodesDelete:F,onEdgesDelete:O,onSelectionChange:I,onSelectionDragStart:B,onSelectionDrag:M,onSelectionDragStop:$,onSelectionContextMenu:P,onSelectionStart:G,onSelectionEnd:K,connectionMode:q=Ya.Strict,connectionLineType:H=Qs.Bezier,connectionLineStyle:D,connectionLineComponent:W,connectionLineContainerStyle:J,deleteKeyCode:V="Backspace",selectionKeyCode:X="Shift",selectionOnDrag:Y=!1,selectionMode:Z=ql.Full,panActivationKeyCode:ee="Space",multiSelectionKeyCode:ne=md()?"Meta":"Control",zoomActivationKeyCode:se=md()?"Meta":"Control",snapToGrid:pe=!1,snapGrid:ke=MB,onlyRenderVisibleElements:ae=!1,selectNodesOnDrag:fe=!0,nodesDraggable:me,nodesConnectable:he,nodesFocusable:ge,nodeOrigin:ue=RB,edgesFocusable:be,edgesUpdatable:oe,elementsSelectable:je,defaultViewport:$e=$B,minZoom:Oe=.5,maxZoom:Ue=2,translateExtent:Be=Rx,preventScrolling:We=!0,nodeExtent:He,defaultMarkerColor:rt="#b1b1b7",zoomOnScroll:lt=!0,zoomOnPinch:Rt=!0,panOnScroll:De=!1,panOnScrollSpeed:et=.5,panOnScrollMode:Je=qa.Free,zoomOnDoubleClick:tt=!0,panOnDrag:yt=!0,onPaneClick:Pt,onPaneMouseEnter:wt,onPaneMouseMove:st,onPaneMouseLeave:zt,onPaneScroll:Wt,onPaneContextMenu:Dt,children:Ht,onEdgeContextMenu:Vt,onEdgeDoubleClick:vs,onEdgeMouseEnter:Cn,onEdgeMouseMove:mr,onEdgeMouseLeave:zr,onEdgeUpdate:gr,onEdgeUpdateStart:Wr,onEdgeUpdateEnd:mn,onReconnect:Hr,onReconnectStart:An,onReconnectEnd:da,reconnectRadius:gn=10,edgeUpdaterRadius:yr=10,onNodesChange:wr,onEdgesChange:xt,noDragClassName:xs="nodrag",noWheelClassName:vr="nowheel",noPanClassName:xr="nopan",fitView:Gt=!1,fitViewOptions:bs,connectOnClick:Vr=!0,attributionPosition:ye,proOptions:Fe,defaultEdgeOptions:Ge,elevateNodesOnSelect:rn=!0,elevateEdgesOnSelect:Gr=!1,disableKeyboardA11y:br=!1,autoPanOnConnect:ha=!0,autoPanOnNodeDrag:Ke=!0,connectionRadius:Kr=20,isValidConnection:ks,onError:kr,style:Kn,id:Yr,nodeDragThreshold:ao,...Ns},Jt)=>{const js=Yr||"1";return de.createElement("div",{...Ns,style:{...Kn,...IB},ref:Jt,className:Ut(["react-flow",s]),"data-testid":"rf__wrapper",id:Yr},de.createElement(L2,null,de.createElement(EB,{onInit:h,onMove:f,onMoveStart:p,onMoveEnd:g,onNodeClick:c,onEdgeClick:d,onNodeMouseEnter:b,onNodeMouseMove:_,onNodeMouseLeave:E,onNodeContextMenu:R,onNodeDoubleClick:C,nodeTypes:o,edgeTypes:l,connectionLineType:H,connectionLineStyle:D,connectionLineComponent:W,connectionLineContainerStyle:J,selectionKeyCode:X,selectionOnDrag:Y,selectionMode:Z,deleteKeyCode:V,multiSelectionKeyCode:ne,panActivationKeyCode:ee,zoomActivationKeyCode:se,onlyRenderVisibleElements:ae,selectNodesOnDrag:fe,defaultViewport:$e,translateExtent:Be,minZoom:Oe,maxZoom:Ue,preventScrolling:We,zoomOnScroll:lt,zoomOnPinch:Rt,zoomOnDoubleClick:tt,panOnScroll:De,panOnScrollSpeed:et,panOnScrollMode:Je,panOnDrag:yt,onPaneClick:Pt,onPaneMouseEnter:wt,onPaneMouseMove:st,onPaneMouseLeave:zt,onPaneScroll:Wt,onPaneContextMenu:Dt,onSelectionContextMenu:P,onSelectionStart:G,onSelectionEnd:K,onEdgeContextMenu:Vt,onEdgeDoubleClick:vs,onEdgeMouseEnter:Cn,onEdgeMouseMove:mr,onEdgeMouseLeave:zr,onReconnect:Hr??gr,onReconnectStart:An??Wr,onReconnectEnd:da??mn,reconnectRadius:gn??yr,defaultMarkerColor:rt,noDragClassName:xs,noWheelClassName:vr,noPanClassName:xr,elevateEdgesOnSelect:Gr,rfId:js,disableKeyboardA11y:br,nodeOrigin:ue,nodeExtent:He}),de.createElement(N6,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:v,onConnectStart:N,onConnectEnd:k,onClickConnectStart:x,onClickConnectEnd:j,nodesDraggable:me,nodesConnectable:he,nodesFocusable:ge,edgesFocusable:be,edgesUpdatable:oe,elementsSelectable:je,elevateNodesOnSelect:rn,minZoom:Oe,maxZoom:Ue,nodeExtent:He,onNodesChange:wr,onEdgesChange:xt,snapToGrid:pe,snapGrid:ke,connectionMode:q,translateExtent:Be,connectOnClick:Vr,defaultEdgeOptions:Ge,fitView:Gt,fitViewOptions:bs,onNodesDelete:F,onEdgesDelete:O,onNodeDragStart:A,onNodeDrag:U,onNodeDragStop:L,onSelectionDrag:M,onSelectionDragStart:B,onSelectionDragStop:$,noPanClassName:xr,nodeOrigin:ue,rfId:js,autoPanOnConnect:ha,autoPanOnNodeDrag:Ke,onError:kr,connectionRadius:Kr,isValidConnection:ks,nodeDragThreshold:ao}),de.createElement(b6,{onSelectionChange:I}),Ht,de.createElement(Y5,{proOptions:Fe,position:ye}),de.createElement(T6,{rfId:js,disableKeyboardA11y:br})))});P2.displayName="ReactFlow";const OB=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function D2(){return Xe(OB,At)}const F2=({id:e,x:t,y:n,width:r,height:s,style:o,color:l,strokeColor:c,strokeWidth:d,className:h,borderRadius:f,shapeRendering:p,onClick:g,selected:v})=>{const{background:N,backgroundColor:k}=o||{},x=l||N||k;return de.createElement("rect",{className:Ut(["react-flow__minimap-node",{selected:v},h]),x:t,y:n,rx:f,ry:f,width:r,height:s,fill:x,stroke:c,strokeWidth:d,shapeRendering:p,onClick:g?j=>g(j,e):void 0})};F2.displayName="MiniMapNode";var LB=y.memo(F2);const PB=e=>e.nodeOrigin,DB=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),Ep=e=>e instanceof Function?e:()=>e;function FB({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s=2,nodeComponent:o=LB,onClick:l}){const c=Xe(DB,At),d=Xe(PB),h=Ep(t),f=Ep(e),p=Ep(n),g=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return de.createElement(de.Fragment,null,c.map(v=>{const{x:N,y:k}=Wa(v,d).positionAbsolute;return de.createElement(o,{key:v.id,x:N,y:k,width:v.width,height:v.height,style:v.style,selected:v.selected,className:p(v),color:h(v),borderRadius:r,strokeColor:f(v),strokeWidth:s,shapeRendering:g,onClick:l,id:v.id})}))}var BB=y.memo(FB);const qB=200,UB=150,zB=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?J5(Yd(t,e.nodeOrigin),n):n,rfId:e.rfId}},WB="react-flow__minimap-desc";function B2({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:r="#e2e2e2",nodeClassName:s="",nodeBorderRadius:o=5,nodeStrokeWidth:l=2,nodeComponent:c,maskColor:d="rgb(240, 240, 240, 0.6)",maskStrokeColor:h="none",maskStrokeWidth:f=1,position:p="bottom-right",onClick:g,onNodeClick:v,pannable:N=!1,zoomable:k=!1,ariaLabel:x="React Flow mini map",inversePan:j=!1,zoomStep:b=10,offsetScale:_=5}){const E=Nt(),R=y.useRef(null),{boundingRect:C,viewBB:A,rfId:U}=Xe(zB,At),L=(e==null?void 0:e.width)??qB,F=(e==null?void 0:e.height)??UB,O=C.width/L,I=C.height/F,B=Math.max(O,I),M=B*L,$=B*F,P=_*B,G=C.x-(M-C.width)/2-P,K=C.y-($-C.height)/2-P,q=M+P*2,H=$+P*2,D=`${WB}-${U}`,W=y.useRef(0);W.current=B,y.useEffect(()=>{if(R.current){const X=qn(R.current),Y=ne=>{const{transform:se,d3Selection:pe,d3Zoom:ke}=E.getState();if(ne.sourceEvent.type!=="wheel"||!pe||!ke)return;const ae=-ne.sourceEvent.deltaY*(ne.sourceEvent.deltaMode===1?.05:ne.sourceEvent.deltaMode?1:.002)*b,fe=se[2]*Math.pow(2,ae);ke.scaleTo(pe,fe)},Z=ne=>{const{transform:se,d3Selection:pe,d3Zoom:ke,translateExtent:ae,width:fe,height:me}=E.getState();if(ne.sourceEvent.type!=="mousemove"||!pe||!ke)return;const he=W.current*Math.max(1,se[2])*(j?-1:1),ge={x:se[0]-ne.sourceEvent.movementX*he,y:se[1]-ne.sourceEvent.movementY*he},ue=[[0,0],[fe,me]],be=us.translate(ge.x,ge.y).scale(se[2]),oe=ke.constrain()(be,ue,ae);ke.transform(pe,oe)},ee=YM().on("zoom",N?Z:null).on("zoom.wheel",k?Y:null);return X.call(ee),()=>{X.on("zoom",null)}}},[N,k,j,b]);const J=g?X=>{const Y=ar(X);g(X,{x:Y[0],y:Y[1]})}:void 0,V=v?(X,Y)=>{const Z=E.getState().nodeInternals.get(Y);v(X,Z)}:void 0;return de.createElement(Ob,{position:p,style:e,className:Ut(["react-flow__minimap",t]),"data-testid":"rf__minimap"},de.createElement("svg",{width:L,height:F,viewBox:`${G} ${K} ${q} ${H}`,role:"img","aria-labelledby":D,ref:R,onClick:J},x&&de.createElement("title",{id:D},x),de.createElement(BB,{onClick:V,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:s,nodeStrokeWidth:l,nodeComponent:c}),de.createElement("path",{className:"react-flow__minimap-mask",d:`M${G-P},${K-P}h${q+P*2}v${H+P*2}h${-q-P*2}z
57
- M${A.x},${A.y}h${A.width}v${A.height}h${-A.width}z`,fill:d,fillRule:"evenodd",stroke:h,strokeWidth:f,pointerEvents:"none"})))}B2.displayName="MiniMap";var HB=y.memo(B2);function VB(){return de.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},de.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function GB(){return de.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},de.createElement("path",{d:"M0 0h32v4.2H0z"}))}function KB(){return de.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},de.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 YB(){return de.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},de.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 XB(){return de.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},de.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 Fn=({children:e,className:t,...n})=>de.createElement("button",{type:"button",className:Ut(["react-flow__controls-button",t]),...n},e);Fn.displayName="ControlButton";const ZB=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),q2=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:o,onZoomOut:l,onFitView:c,onInteractiveChange:d,className:h,children:f,position:p="bottom-left"})=>{const g=Nt(),[v,N]=y.useState(!1),{isInteractive:k,minZoomReached:x,maxZoomReached:j}=Xe(ZB,At),{zoomIn:b,zoomOut:_,fitView:E}=ki();if(y.useEffect(()=>{N(!0)},[]),!v)return null;const R=()=>{b(),o==null||o()},C=()=>{_(),l==null||l()},A=()=>{E(s),c==null||c()},U=()=>{g.setState({nodesDraggable:!k,nodesConnectable:!k,elementsSelectable:!k}),d==null||d(!k)};return de.createElement(Ob,{className:Ut(["react-flow__controls",h]),position:p,style:e,"data-testid":"rf__controls"},t&&de.createElement(de.Fragment,null,de.createElement(Fn,{onClick:R,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:j},de.createElement(VB,null)),de.createElement(Fn,{onClick:C,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:x},de.createElement(GB,null))),n&&de.createElement(Fn,{className:"react-flow__controls-fitview",onClick:A,title:"fit view","aria-label":"fit view"},de.createElement(KB,null)),r&&de.createElement(Fn,{className:"react-flow__controls-interactive",onClick:U,title:"toggle interactivity","aria-label":"toggle interactivity"},k?de.createElement(XB,null):de.createElement(YB,null)),f)};q2.displayName="Controls";var JB=y.memo(q2),cr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(cr||(cr={}));function QB({color:e,dimensions:t,lineWidth:n}){return de.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function e8({color:e,radius:t}){return de.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const t8={[cr.Dots]:"#91919a",[cr.Lines]:"#eee",[cr.Cross]:"#e2e2e2"},n8={[cr.Dots]:1,[cr.Lines]:1,[cr.Cross]:6},r8=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function U2({id:e,variant:t=cr.Dots,gap:n=20,size:r,lineWidth:s=1,offset:o=2,color:l,style:c,className:d}){const h=y.useRef(null),{transform:f,patternId:p}=Xe(r8,At),g=l||t8[t],v=r||n8[t],N=t===cr.Dots,k=t===cr.Cross,x=Array.isArray(n)?n:[n,n],j=[x[0]*f[2]||1,x[1]*f[2]||1],b=v*f[2],_=k?[b,b]:j,E=N?[b/o,b/o]:[_[0]/o,_[1]/o];return de.createElement("svg",{className:Ut(["react-flow__background",d]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:h,"data-testid":"rf__background"},de.createElement("pattern",{id:p+e,x:f[0]%j[0],y:f[1]%j[1],width:j[0],height:j[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${E[0]},-${E[1]})`},N?de.createElement(e8,{color:g,radius:b/o}):de.createElement(QB,{dimensions:_,color:g,lineWidth:s})),de.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${p+e})`}))}U2.displayName="Background";var s8=y.memo(U2);function a8(e,t){return e?t==="gone"?"entering":t==="leaving"?"here":t:t==="gone"?"gone":"leaving"}function La(e){return e!=="gone"}function td(e,t){const[n,r]=y.useState(()=>e?"here":"gone"),s=y.useRef(null);return y.useEffect(()=>{r(o=>a8(e,o))},[e]),y.useEffect(()=>{if(n==="leaving")return s.current=window.setTimeout(()=>r("gone"),t),()=>{s.current!=null&&window.clearTimeout(s.current)}},[n,t]),y.useEffect(()=>{n==="entering"&&r("here")},[n]),n}const pj="agent-dag.fm-custom-stations",mj="agent-dag.fm-muted",Mx="custom:",o8=/^UC[A-Za-z0-9_-]{22}$/,i8=/^[A-Za-z0-9_-]{11}$/,Gb=/^[A-Za-z0-9_-]{1,80}$/,l8=/\.(mp3|aac|ogg)$/i,c8=/\.m3u8$/i,z2=2048,zl=80;function Za(e){return`${Mx}${e}`}function di(e){if(!e.startsWith(Mx))return null;const t=e.slice(Mx.length);return Gb.test(t)?t:null}function gj(e){return di(e)??e}function u8(e){return e?"This station could not be played. Check its link, pick another, or pick it again to retry.":"This station is not live right now. Pick another, or pick it again later to retry."}function Kb(e){var l,c;const t=e.trim();if(t.length>z2)return null;let n;try{n=new URL(t)}catch{return null}if(n.protocol!=="https:"||n.username||n.password)return null;const r=n.toString(),s=n.hostname.toLowerCase();if(s==="youtube.com"||s==="www.youtube.com"||s==="m.youtube.com"){if(n.port)return null;const d=(l=/^\/channel\/([^/]+)(?:\/live)?\/?$/.exec(n.pathname))==null?void 0:l[1];if(d&&o8.test(d))return{kind:"youtube-channel",url:r,channel:d};const h=(c=/^\/@([^/]+)\/live\/?$/.exec(n.pathname))==null?void 0:c[1];if(h&&/^[A-Za-z0-9._-]{1,64}$/.test(h))return{kind:"youtube-handle",url:r,handle:h};if(n.pathname==="/watch"){const f=n.searchParams.get("v")??"";if(i8.test(f))return{kind:"youtube-video",url:r,video:f}}return null}return c8.test(n.pathname)?{kind:"direct-audio",url:r,format:"hls"}:l8.test(n.pathname)?{kind:"direct-audio",url:r,format:"audio"}:null}function d8(e){return e==="1"}function h8(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];const n=new Set,r=[];for(const s of t){if(!s||typeof s!="object")continue;const o=typeof s.id=="string"?s.id:"",l=typeof s.name=="string"?s.name.trim():"",c=typeof s.url=="string"?s.url.trim():"",d=Kb(c);!Gb.test(o)||n.has(o)||!l||l.length>zl||!d||(n.add(o),r.push({id:o,name:l,url:d.url}))}return r}function f8(e,t,n){const r=di(e??"");return r&&t.some(s=>s.id===r)?Za(r):n(e)}function p8(e,t){return e===Za(t)?"claude-fm":e}function m8(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function g8(e,t,n=m8()){const r=e.trim(),s=Kb(t);return!r||r.length>zl||!Gb.test(n)||!s?null:{id:n,name:r,url:s.url}}const W2=.2,H2=1.6;function y8(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!="object")return null;const{x:n,y:r,zoom:s}=t;return typeof n!="number"||typeof r!="number"||typeof s!="number"||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(s)||s<W2||s>H2?null:{x:n,y:r,zoom:s}}function $x({durationMs:e,documentHidden:t,reducedMotion:n=w8()}){return t||n?!1:Number.isFinite(e)&&e>0}function w8(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}const v8=["us-gov","global","apac","us","eu","jp","au"],x8=new RegExp(`^(?:(?:${v8.join("|")})\\.)?anthropic\\.`,"i");function cs(e){return e.replace(x8,"")}const b8=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i,k8=new Set(["tool_input","tool_response"]);function V2(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.model=="string"&&b8.test(cs(n.model)))return n.model;for(const[r,s]of Object.entries(n)){if(k8.has(r))continue;const o=V2(s,t+1);if(o)return o}return null}function Yb(){return{agents:new Map,toolIndex:new Map,activeSubagentStack:new Map,subagentTombstones:new Map,pendingSubagentModels:new Map,lastSeq:0,seqEpoch:null,totalEvents:0,revision:0}}function gs(e,t){return`${e}::${t}`}function Ni(e,t){return`${e}\0${t}`}const N8=/[0-9a-f]{16,}/i,j8=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function G2(e){return N8.test(e)||j8.test(e)}function S8(e){if(!e)return;const t=e.replace(/\\/g,"/").split("/").filter(Boolean);for(let n=t.length-1;n>=0;n--)if(!G2(t[n]))return t[n];return t[t.length-1]}function K2(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function Y2(e){const t=e.cache_creation,n=t&&typeof t=="object"?t:e,r=n.ephemeral_1h_input_tokens,s=n.ephemeral_5m_input_tokens;return typeof r!="number"&&typeof s!="number"?{}:{cacheCreate1hTokens:Number(r??0),cacheCreate5mTokens:Number(s??0)}}function Xb(e){const t=Y2(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 _8(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t={};for(const[n,r]of Object.entries(e)){if(!n||!r||typeof r!="object")continue;const s=r;t[n]=Xb(s);const o=E8(s.speeds);o&&(t[n].bySpeed=o)}return Object.keys(t).length?t:void 0}function E8(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=Object.entries(e).filter(([n,r])=>n&&r&&typeof r=="object").map(([n,r])=>[n,Xb(r)]);return t.length?Object.fromEntries(t):void 0}function X2(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),...Y2(n)};for(const r of Object.values(n)){const s=X2(r,t+1);if(s)return s}return null}function Zb(e){return S8(e)}function Jb(e){const t=e.agent_type??e.subagent_type;return t&&!G2(t)?t:"subagent"}function ji(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function Wl(e,t){!e.cwd&&t.cwd&&(e.cwd=t.cwd,e.cwdBasename=Zb(t.cwd))}function Z2(e,t){e.label==="session"&&t.cwd&&(e.label=Zb(t.cwd)??"session")}function J2(e,t){const n=Jb(t);n&&(e.label==="subagent"||!e.label)&&(e.label=n)}function Si(e,t,n,r){const s=t;let o=e.agents.get(s);return o||(o={id:s,sessionId:t,label:"session",kind:"root",state:"active",startedAt:n,lastEventAt:n,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:r,usage:K2()},e.agents.set(s,o),o)}function Q2(e,t,n,r){const s=gs(t,n),o=e.agents.get(s);return o?(Wl(o,r),J2(o,r),o):null}function T8(e,t,n){var h;const r=t.session_id??"unknown",s=ji(t);if(s){const f=Q2(e,r,s,t);if(f)return f}const l=((h=e.agents.get(r))==null?void 0:h.keyedSubagents)===!0?void 0:e.activeSubagentStack.get(r),c=l&&l.length>0?l[l.length-1]:null;if(c){const f=e.agents.get(gs(r,c));if(f)return Wl(f,t),f}const d=Si(e,r,n,t.hook_event_name!=="SessionStart");return Wl(d,t),Z2(d,t),d}function C8(e,t,n,r){if(t==="SubagentStart"||t==="SubagentStop"||typeof n.agent_id!="string"||n.agent_id==="")return!1;const s=e.agents.get(r);return!s||s.keyedSubagents?!1:(s.keyedSubagents=!0,!0)}function A8(e,t,n,r,s){const o=gs(t,n),l=Si(e,t,s,!0);let c=e.agents.get(o);if(c)return Wl(c,r),J2(c,r),c;c={id:o,sessionId:t,label:Jb(r),kind:"subagent",parentId:l.id,state:"active",startedAt:s,tools:[],prompts:[],cwd:r.cwd,cwdBasename:Zb(r.cwd),toolCount:0,childCount:0,usage:K2()},e.agents.set(o,c);const d=e.pendingSubagentModels.get(o);return d&&(c.model=d,e.pendingSubagentModels.delete(o)),l.childCount+=1,c}function R8(e,t,n){const r=e.activeSubagentStack.get(t)??[];r.includes(n)||(r.push(n),e.activeSubagentStack.set(t,r))}function e$(e,t,n){const r=e.activeSubagentStack.get(t);if(r){for(let s=r.length-1;s>=0;s--)if(r[s]===n){r.splice(s,1);break}r.length===0&&e.activeSubagentStack.delete(t)}}function Ot(e,t){return Object.hasOwn(e,t)?e[t]:void 0}const M8=/^\s*<task-notification>([\s\S]*?)<\/task-notification>/;function yj(e,t){var n;return((n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`).exec(e))==null?void 0:n[1].trim())||void 0}const $8={completed:"background task finished",failed:"background task failed",killed:"background task stopped"};function Qb(e){const t=M8.exec(e);if(!t)return null;const n=yj(t[1],"status");return{label:(n?Ot($8,n):void 0)??"background task update",detail:yj(t[1],"summary")}}function t$(e){return e.filter(t=>!Qb(t.text))}const wj=2e3;function I8(e,t,n){for(let r=e.length-1;r>=0;r--){const s=e[r];if(s.at<t-wj)return!1;if(s.text===n&&s.at<=t+wj)return!0}return!1}function O8(e,t,n){if(I8(e,t,n))return!1;let r=e.length;for(;r>0&&e[r-1].at>t;)r--;return e.splice(r,0,{at:t,text:n}),!0}const wd=2e3;function L8(e){const t=e.prompts[e.prompts.length-1];return t&&t.at>e.startedAt?t.at:e.startedAt}const vj=["B","KB","MB","GB","TB"];function ea(e){if(e==null||!Number.isFinite(e)||e<0)return"—";if(e===0)return"0 B";let t=e,n=0;for(;n<vj.length-1&&Number(t.toFixed(1))>=1024;)t/=1024,n++;return`${t.toFixed(1)} ${vj[n]}`}const P8=60,D8=6e3,zn=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),kn=e=>typeof e=="string"?e:null;function F8(e){return zn(e)&&e.ccdeck_truncated===!0&&typeof e.chars=="number"&&Object.keys(e).length===2?e.chars:null}function hi(e){const t=F8(e);if(t!=null)return`(too large to show — ${ea(t)}, cut by the hook)`;if(Array.isArray(e)){const n=e.map(hi);return n.some((r,s)=>r!==e[s])?n:e}if(zn(e)){let n=!1;const r={};for(const[s,o]of Object.entries(e))r[s]=hi(o),r[s]!==o&&(n=!0);return n?r:e}return e}function Ja(e,t=""){if(e==null)return"(none)";if(typeof e=="string")return e;if(typeof e!="object")return String(e);const n=Array.isArray(e),r=n?e.map((o,l)=>[String(l),o]):Object.entries(e);if(r.length===0)return n?"[]":"{}";const s=[];for(const[o,l]of r){const c=n?`${t}-`:`${t}${o}:`;if(typeof l=="string"&&l.includes(`
58
- `)){s.push(c);for(const d of l.split(`
59
- `))s.push(`${t} ${d}`)}else if(l!==null&&typeof l=="object"){const d=Ja(l,`${t} `);d==="[]"||d==="{}"?s.push(`${c} ${d}`):s.push(c,d)}else s.push(`${c} ${l===void 0?"(none)":String(l)}`)}return s.join(`
60
- `)}function B8(e){return e.lines??e.text.split(`
61
- `).map(t=>({text:t}))}function n$(e,t){if(t)return{shown:e,cut:!1};const n=[];let r=0;for(const s of e){if(n.length===P8)return{shown:n,cut:!0};const o=D8-r;if(s.text.length>o)return n.push({...s,text:`${s.text.slice(0,Math.max(o,0))}…`}),{shown:n,cut:!0};n.push(s),r+=s.text.length+1}return{shown:n,cut:!1}}function q8(e,t){return n$(e,!1).cut?t?{label:"show less",expanded:!0}:{label:"show all",expanded:!1}:null}const nn=(e,t,n=!1)=>({...e?{label:e}:{},text:t,...n?{err:!0}:{}}),Nn=(e,t)=>({label:e,text:t,inline:!0}),r$=(e,t)=>({label:e,text:t.map(n=>n.text).join(`
62
- `),lines:t});function U8(e,t){return[...e.split(`
63
- `).map(n=>({text:`- ${n}`,tone:"del"})),...t.split(`
64
- `).map(n=>({text:`+ ${n}`,tone:"add"}))]}function z8(e){if(!Array.isArray(e)||e.length===0)return null;const t=[];for(const n of e){if(!zn(n)||!Array.isArray(n.lines))return null;t.push({text:`@@ -${n.oldStart},${n.oldLines} +${n.newStart},${n.newLines} @@`,tone:"ctx"});for(const r of n.lines){const s=String(r);t.push(s.startsWith("+")?{text:s,tone:"add"}:s.startsWith("-")?{text:s,tone:"del"}:{text:s})}}return t}function xj(e){if(typeof e=="string")return[nn(void 0,e)];if(!zn(e))return[nn(void 0,Ja(e))];const t=[],n=kn(e.type);n==="create"&&t.push(Nn("result","created the file"));const r=z8(e.structuredPatch);return r&&t.push(r$("applied",r)),e.userModified===!0&&t.push(Nn("note","the user changed it before it was applied")),t.length?t:[Nn("result",n==="update"?"updated the file":"done")]}function W8(e){const t=typeof e.offset=="number"?e.offset:null,n=typeof e.limit=="number"?e.limit:null;if(t==null&&n==null)return null;const r=t??1;return n!=null?`${r}–${r+n-1}`:`from ${r}`}function H8(e){if(typeof e=="string")return[nn(void 0,e)];const t=zn(e)&&zn(e.file)?e.file:null,n=kn(t==null?void 0:t.content);if(t&&n!=null){const s=[],o=Number(t.numLines),l=Number(t.totalLines),c=Number(t.startLine);return Number.isFinite(o)&&Number.isFinite(l)&&l>0&&s.push(Nn("lines",o>=l?`all ${l}`:Number.isFinite(c)?`${c}–${c+o-1} of ${l}`:`${o} of ${l}`)),s.push(nn("content",n)),s}const r=zn(e)?kn(e.type):null;return r&&r!=="text"?[Nn("result",`${/^[aeiou]/i.test(r)?"an":"a"} ${r} file`)]:[nn(void 0,Ja(e))]}function V8(e){if(typeof e=="string")return[nn("output",e)];if(!zn(e))return[nn(void 0,Ja(e))];const t=kn(e.stdout),n=kn(e.stderr);if(t==null&&n==null)return[nn(void 0,Ja(e))];const r=[];return t&&r.push(nn("output",t.replace(/\n$/,""))),n&&r.push(nn("errors",n.replace(/\n$/,""),!0)),e.interrupted===!0&&r.push(Nn("note","interrupted before it finished")),r.length?r:[Nn("output","none")]}function G8(e,t,n){const r=hi(t),s=hi(n),o=zn(r)?r:null;if(o&&(e==="Edit"||e==="MultiEdit")){const l=kn(o.file_path),c=(e==="MultiEdit"?Array.isArray(o.edits)?o.edits:[]:[o]).filter(zn).filter(d=>kn(d.old_string)!=null&&kn(d.new_string)!=null);if(l&&c.length){const d=[Nn("file",l)];return c.forEach((h,f)=>{const p=h.replace_all===!0?", every occurrence":"";d.push(r$(c.length>1?`change ${f+1}${p}`:`change${p}`,U8(h.old_string,h.new_string)))}),{input:d,response:xj(s)}}}if(o&&e==="Write"){const l=kn(o.file_path),c=kn(o.content);if(l&&c!=null)return{input:[Nn("file",l),nn("content",c)],response:xj(s)}}if(o&&e==="Read"){const l=kn(o.file_path);if(l){const c=W8(o);return{input:c?[Nn("file",l),Nn("lines",c)]:[Nn("file",l)],response:H8(s)}}}if(o&&e==="Bash"){const l=kn(o.command);if(l!=null){const c=kn(o.description);return{input:c?[nn("command",l),Nn("why",c)]:[nn("command",l)],response:V8(s)}}}return{input:[nn(void 0,Ja(r))],response:[nn(void 0,Ja(s))]}}function bj(e,t,n){const r=hi(n);if(r==null)return"";if(typeof r=="string")return r;if(zn(r)){if(e==="Bash"&&t==="input"&&typeof r.command=="string")return r.command;if(e==="Bash"&&t==="response"&&(typeof r.stdout=="string"||typeof r.stderr=="string"))return[r.stdout,r.stderr].filter(s=>typeof s=="string"&&s!=="").join(`
65
- `);if(e==="Read"&&t==="response"&&zn(r.file)&&typeof r.file.content=="string")return r.file.content}try{return JSON.stringify(r,null,2)??String(r)}catch{return String(r)}}function vd(e,t=80){const n=hi(e);if(n==null)return"";if(typeof n=="string")return n.length>t?n.slice(0,t-1)+"…":n;try{const r=JSON.stringify(n);return r.length>t?r.slice(0,t-1)+"…":r}catch{return String(n)}}const kj=200;function s$(e,t,n){const r=t.ok===!1;t.ok=n,e&&r===n&&(e.toolErrorCount=(e.toolErrorCount??0)+(n?-1:1))}function a$(e,t){return t.agentId==null?void 0:e.agents.get(t.agentId)}function Cl(e,t,n){const r=e.toolCountByName??(e.toolCountByName=new Map),s=(r.get(t)??0)+n;s>0?r.set(t,s):r.delete(t)}function K8(e,t,n){var r;return((r=e.get(t))==null?void 0:r.tools.find(s=>s.id===n))??null}const o$=25;function i$(e,t){const n=t.tools;if(n.length>kj){const r=n.splice(0,n.length-kj);for(const s of r)c$(e,t,s)}for(let r=n.length-o$-1;r>=0;r--){const s=n[r];if(s.trimmed)break;s.input=void 0,s.response=void 0,s.trimmed=!0}}function Y8(e,t,n){const r=e.toolIndex.get(Ni(t.sessionId,n));if(r)return r;for(let s=t.tools.length-1;s>=0;s--)if(t.tools[s].id===n)return t.tools[s];return null}function l$(e,t){for(const n of t.tools)c$(e,t,n)}function c$(e,t,n){const r=Ni(t.sessionId,n.id);e.toolIndex.get(r)===n&&e.toolIndex.delete(r)}function X8(e,t){const n=e.agents.get(t);if(!n)return;let r=!1;for(const s of e.agents.values()){if(s===n||s.sessionId!==t)continue;const o=s.tools.filter(l=>l.explicitSubagentId==null);if(o.length!==0){for(const l of o)s.toolCount-=1,Cl(s,l.name,-1),l.ok===!1&&(s.toolErrorCount=(s.toolErrorCount??0)-1),l.agentId=n.id,n.tools.push(l),n.toolCount+=1,Cl(n,l.name,1),l.ok===!1&&(n.toolErrorCount=(n.toolErrorCount??0)+1);s.tools=s.tools.filter(l=>l.explicitSubagentId!=null),r=!0}}if(r){n.tools.sort((s,o)=>s.startedAt-o.startedAt),i$(e,n);for(let s=0;s<n.tools.length-o$;s++){const o=n.tools[s];o.trimmed||(o.input=void 0,o.response=void 0,o.trimmed=!0)}}}const Z8="no result reached the deck — events were dropped while the deck was paused";function u$(e,t,n,r,s){n.endedAt=r,s$(t,n,!1),n.errorPreview=n.outcomeGap?Z8:s,e.toolIndex.delete(Ni(t.sessionId,n.id))}function J8(e,t){const n=t==null?void 0:t.payload,r=n==null?void 0:n.hook_event_name;if(r!=="PostToolUse"&&r!=="PostToolUseFailure")return!1;const s=n==null?void 0:n.tool_use_id;return typeof s!="string"||s.length===0?!1:e.toolIndex.has(Ni((n==null?void 0:n.session_id)??"unknown",s))}function Q8(e,t,n,r,s){const o=t.tool_use_id?Y8(e,r,t.tool_use_id):null;if(o){if(t.tool_name&&o.name==="?"){o.name=t.tool_name;const h=a$(e,o);h&&(Cl(h,"?",-1),Cl(h,o.name,1))}o.endedAt==null&&!o.trimmed&&t.tool_input!==void 0&&(o.input=t.tool_input,o.inputPreview=vd(t.tool_input));return}const l=t.tool_use_id??`${r.id}:${r.toolCount}`,c=ji(t),d={id:l,name:t.tool_name??"?",input:t.tool_input,inputPreview:vd(t.tool_input),agentId:r.id,explicitSubagentId:c?gs(n,c):void 0,startedAt:s};r.tools.push(d),r.toolCount+=1,Cl(r,d.name,1),r.state="active",e.toolIndex.set(Ni(r.sessionId,l),d),i$(e,r)}function eq(e,t,n,r,s){const o=t.tool_use_id;if(!o)return;const l=Ni(r,o);let c=e.toolIndex.get(l),d=!1;if(!c)for(const f of e.agents.values()){if(f.sessionId!==r)continue;const p=f.tools.find(g=>g.id===o);if(p){c=p,d=!0;break}}if(!c||c.outcomeApplied)return;c.outcomeApplied=!0,c.outcomeGap=void 0,c.endedAt=s,s$(a$(e,c),c,n==="PostToolUse"),c.trimmed||(c.response=t.tool_response),n==="PostToolUseFailure"?c.errorPreview=vd(t.tool_response):d&&(c.errorPreview=void 0);const h=X2(t.tool_response);h&&(c.usage=h),e.toolIndex.delete(l)}function tq(e,t,n){const r=e.agents.get(t);r&&n>(r.lastEventAt??0)&&(r.lastEventAt=n,r.reaped&&(r.reaped=!1,r.state="active",r.endedAt=void 0,r.closedAt=void 0))}function nq(e,t,n,r){const s=Si(e,n,r,!1);s.synthetic=!1,s.state="active",s.closedAt=void 0,s.endedAt=void 0,s.startedAt=Math.min(s.startedAt??r,r),Wl(s,t),Z2(s,t)}function rq(e,t,n,r){for(const l of e.agents.values())l.sessionId===n&&l.kind==="subagent"&&l.state==="done"&&l.exitAt==null&&l.endedAt!=null&&l.endedAt<r&&(l.exitAt=r);const s=Si(e,n,r,!1);s.state="active",s.endedAt=void 0,s.closedAt=void 0,s.exitAt=void 0;const o=(typeof t.prompt=="string"?t.prompt:typeof t.message=="string"?t.message:"")??"";o&&O8(s.prompts,r,o)&&!s.firstPrompt&&!Qb(o)&&(s.firstPrompt=vd(o,120))}function sq(e,t,n,r){const s=Si(e,n,r,!1),o=L8(s);if(r<o)return;const l=s.lastTurnEndAt;if(!(l!=null&&o>l&&r<=l+wd)){s.state="done",s.endedAt=r,s.lastTurnEndAt=r;for(const c of s.provider==="codex"?[]:e.agents.values())if(c.sessionId===n)for(const d of c.tools)d.endedAt==null&&d.explicitSubagentId==null&&u$(e,c,d,r,"the turn ended before this call returned");t==="SessionEnd"&&(s.closedAt=r),e.activeSubagentStack.delete(n)}}function aq(e,t,n,r){const s=ji(t);if(!s)return;const o=A8(e,n,s,t,r),l=Jb(t);l&&(o.label=l);const c=e.subagentTombstones.get(o.id);c!=null&&e.subagentTombstones.delete(o.id);const d=o.endedAt!=null&&r-o.endedAt<=wd,h=c!=null&&r-c<=wd;if(d||h){const f=h?c:o.endedAt;o.state="done",o.endedAt=f,o.startedAt=Math.min(o.startedAt,f),e$(e,n,s);return}o.state="active",o.startedAt=o.startedAt||r,o.exitAt=void 0,o.endedAt=void 0,R8(e,n,s)}function oq(e,t,n,r){const s=ji(t);if(!s)return;const o=Q2(e,n,s,t);if(!o){for(const[l,c]of e.subagentTombstones)r-c>wd&&e.subagentTombstones.delete(l);e.subagentTombstones.set(gs(n,s),r);return}o.state="done",o.endedAt=Math.min(o.endedAt??r,r),e$(e,n,s)}function d$(){return{msgsUser:0,msgsAssistant:0,toolUses:0,toolResults:0,systemReminders:0,currentContextTokens:0,memoryFiles:[]}}function iq(e,t,n){if(typeof t.model_context_window=="number"&&t.model_context_window>0){const r=e.agents.get(n);r&&(r.contextWindow=t.model_context_window)}if(typeof t.approval_policy=="string"&&t.approval_policy){const r=e.agents.get(n);r&&(r.approvalPolicy=t.approval_policy)}if(typeof t.context_tokens=="number"&&t.context_tokens>=0){const r=e.agents.get(n);r&&(r.context={...r.context??d$(),currentContextTokens:t.context_tokens})}}const lq=6e4,Nj=64;function cq(e,t,n){const r=typeof t.model=="string"?t.model:null;if(r){const o=e.agents.get(n);o&&(o.model=r)}const s=t.subagentModels;if(s&&typeof s=="object")for(const[o,l]of Object.entries(s)){if(typeof l!="string")continue;const c=gs(n,o),d=e.agents.get(c);if(d)d.model=l,e.pendingSubagentModels.delete(c);else if(e.pendingSubagentModels.delete(c),e.pendingSubagentModels.set(c,l),e.pendingSubagentModels.size>256){const h=e.pendingSubagentModels.keys().next().value;h!==void 0&&e.pendingSubagentModels.delete(h)}}}function uq(e,t,n){const r=t.context??null;if(r){const s=e.agents.get(n);if(s){const o=s.context??d$(),l=(d,h)=>typeof r[d]=="number"?r[d]:h,c=Array.isArray(r.memoryFiles)?r.memoryFiles:Array.isArray(r.claudeMdFiles)?r.claudeMdFiles:null;s.context={msgsUser:l("msgsUser",o.msgsUser),msgsAssistant:l("msgsAssistant",o.msgsAssistant),toolUses:l("toolUses",o.toolUses),toolResults:l("toolResults",o.toolResults),systemReminders:l("systemReminders",o.systemReminders),currentContextTokens:l("currentContextTokens",o.currentContextTokens),memoryFiles:c??o.memoryFiles}}}}function dq(e,t,n){const r=e.agents.get(n);if(r){const s=typeof t.sessionName=="string"?t.sessionName.trim():"",o=typeof t.sessionTitle=="string"?t.sessionTitle.trim():"";s&&(r.sessionName=s),o&&(r.sessionTitle=o);const l=r.sessionName??"";r.sessionTitle&&l&&r.sessionTitle.toLowerCase()===l.toLowerCase()&&(r.sessionTitle=void 0)}}function hq(e,t,n){const r=e.agents.get(n);if(r){const s=t.recap;s===null?r.recap=void 0:s&&typeof s.text=="string"&&s.text.trim()&&Number.isFinite(s.at)&&(r.recap={text:s.text.trim(),at:s.at})}}function fq(e,t,n){const r=e.agents.get(n),s=t.activity;!r||!s||typeof s.text!="string"||!s.text.trim()||!Number.isFinite(s.at)||r.activity&&s.at<r.activity.at||(r.activity={text:s.text.trim(),source:s.source==="said"?"said":"tool",at:s.at})}const pq=new Set(["working","blocked","done","failed","stopped"]);function mq(e,t,n){const r=e.agents.get(n);if(!r)return;const s=t.job;if(s===null){r.job=void 0;return}if(!s||typeof s!="object"||!pq.has(s.state))return;const o=l=>typeof l=="string"&&l.trim()?l.trim():void 0;r.job={id:o(s.id)??"",state:s.state,detail:o(s.detail)??"",needs:o(s.needs),suggestedReply:o(s.suggestedReply),result:o(s.result),updatedAt:Number.isFinite(s.updatedAt)?s.updatedAt:0}}function gq(e,t,n,r){const s=t.kind==="thinking"||t.kind==="text"||t.kind==="tool_use"?t.kind:null,o=typeof t.at=="number"&&Number.isFinite(t.at)?t.at:r;if(!s)return;const l=e.agents.get(n);if(l&&!(l.lastOutputAt!=null&&o<=l.lastOutputAt)){if(l.lastOutputAt=o,s!=="tool_use"){const c=(l.outputs??[]).filter(d=>o-d<lq);c.push(o),l.outputs=c.length>Nj?c.slice(-Nj):c}e.revision+=1}}function yq(e,t,n){const r=t.usage??null;if(r){const s=e.agents.get(n);s&&(Object.assign(s.usage,Xb(r)),s.usageByModel=_8(t.usageByModel))}}const wq=["command","cmd","file_path","path","url","pattern","notebook_path"],jj=120,Tp=e=>e.length>jj?`${e.slice(0,jj-1)}…`:e;function vq(e){if(typeof e=="string")return e.trim()?Tp(e.trim()):null;if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;for(const n of wq){const r=t[n];if(typeof r=="string"&&r.trim())return Tp(r.trim());if(Array.isArray(r)&&r.length>0&&r.every(s=>typeof s=="string")){const s=r.join(" ").trim();if(s)return Tp(s)}}return null}function xq(e){return e==="permission_prompt"?"permission":e==="agent_needs_input"?"asked":e==="idle_prompt"?"idle":null}const bq=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved","SessionNamed","SessionRecapped","OutputObserved","ActivityObserved","JobObserved"]);function kq(e,t){let n=null;for(const r of e.toolIndex.values()){const s=r.agentId?e.agents.get(r.agentId):void 0;!s||s.sessionId!==t||(!n||r.startedAt>n.startedAt)&&(n=r)}return n}const Nq=3e4;function jq(e,t){if(!(!e||!e.name)&&!(t-e.startedAt>Nq)&&!(e.startedAt>t))return{name:e.name,preview:vq(e.input)??""}}function Sq(e,t,n,r,s){if(n!=="permission")return{kind:n,message:r,since:s};const o=kq(e,t),l={kind:n,message:r,since:s};o!=null&&o.explicitSubagentId&&(l.subagentId=o.explicitSubagentId);const c=jq(o,s);return c&&(l.tool=c),l}function _q(e,t,n){if(e.kind==="idle")return!0;const r=ji(t);return r==null?!0:e.subagentId!=null&&gs(n,r)===e.subagentId}function Eq(e,t,n,r){if(!bq.has(t)){const s=e.agents.get(r);s!=null&&s.waiting&&_q(s.waiting,n,r)&&(s.waiting=null)}}function Tq(e,t,n,r){const s=xq(t.notification_type);if(!s)return;const o=Si(e,n,r,!1),l=typeof t.message=="string"?t.message:"",c=o.waiting;o.waiting=c&&c.kind===s&&c.message===l?{...c,since:Math.min(c.since,r)}:Sq(e,n,s,l,r)}function uc(e,t){return t&&(e.revision+=1),t}function Cq(e,t,n,r,s){if(e.agents.size<=n)return!1;const o=p=>p.state==="done"&&p.endedAt!=null&&t-p.endedAt>r,l=[],c=new Map;for(const[p,g]of e.agents){if(g.parentId!=null){const v=c.get(g.parentId);v?v.push(p):c.set(g.parentId,[p])}o(g)&&l.push({id:p,endedAt:g.endedAt})}if(l.length===0)return!1;l.sort((p,g)=>p.endedAt-g.endedAt);let d=0;const h=new Set,f=p=>{const g=e.agents.get(p);g&&(l$(e,g),e.agents.delete(p),h.add(g.sessionId),d++)};for(const p of l){if(e.agents.size<=n)break;if(!e.agents.has(p.id))continue;const g=(c.get(p.id)??[]).map(v=>e.agents.get(v)).filter(v=>v!=null);if(!g.some(v=>!o(v))){for(const v of g)f(v.id);f(p.id)}}if(s&&h.size>0){const p=new Set;for(const g of e.agents.values())p.add(g.sessionId);for(const g of h)p.has(g)||s(g)}return uc(e,d>0)}function Aq(e,t,n,r,s){const o=new Map;for(const[f,p]of e.agents){let g=o.get(p.sessionId);g||(g={ids:[],endedAt:0,live:!1,closed:!1},o.set(p.sessionId,g)),g.ids.push(f),p.kind==="root"&&p.closedAt!=null&&(g.closed=!0),p.state==="done"&&p.endedAt!=null?g.endedAt=Math.max(g.endedAt,p.endedAt):g.live=!0}const l=[...o].filter(([,f])=>!f.live&&f.endedAt>0&&t-f.endedAt>r).sort(([,f],[,p])=>f.closed===p.closed?f.endedAt-p.endedAt:f.closed?-1:1);let d=[...o.values()].filter(f=>!f.live).length-n;if(d<=0)return!1;let h=!1;for(const[f,p]of l){if(d<=0)break;for(const v of p.ids){const N=e.agents.get(v);N&&l$(e,N),e.agents.delete(v)}const g=gs(f,"");for(const v of e.pendingSubagentModels.keys())v.startsWith(g)&&e.pendingSubagentModels.delete(v);s==null||s(f),d--,h=!0}return uc(e,h)}function Rq(e){let t=!1;for(const n of e.agents.values())for(const r of n.tools)r.endedAt!=null||r.outcomeGap||(r.outcomeGap=!0,t=!0);return uc(e,t)}function Mq(e,t,n){let r=!1;for(const s of e.agents.values()){if(s.provider==="codex")continue;const o=e.agents.get(s.sessionId),l=(o==null?void 0:o.lastEventAt)??(o==null?void 0:o.startedAt);for(const c of s.tools){const d=Math.max(c.startedAt,l??c.startedAt);c.endedAt==null&&t-d>n&&(u$(e,s,c,d,"session ended before this call returned"),r=!0)}}return uc(e,r)}const Sj=90*6e4;function $q(e,t,n){let r=!1;for(const s of e.agents.values()){if(s.kind!=="root")continue;const o=s.lastEventAt??s.startedAt;if(!(t-o<=n)){s.waiting&&(s.waiting=null,r=!0),s.closedAt==null&&(s.closedAt=o),s.state==="active"&&(s.state="done",s.endedAt=o,s.reaped=!0,r=!0);for(const l of e.agents.values())l.sessionId!==s.sessionId||l.kind==="root"||l.state!=="active"||(l.state="done",l.endedAt=o,r=!0);e.activeSubagentStack.delete(s.sessionId)}}return uc(e,r)}function xd(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 h$(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 r=t.payload??{},s=t.receivedAt,o=r.hook_event_name??"Unknown";if(o==="__clear")return{...Yb(),lastSeq:t.seq,seqEpoch:e.seqEpoch,revision:e.revision+1};e.totalEvents+=1,e.lastSeq=t.seq,e.revision+=1;const l=r.session_id??"unknown";switch(Eq(e,o,r,l),o!=="JobObserved"&&tq(e,l,s),iq(e,r,l),o){case"ModelObserved":return cq(e,r,l),e;case"ContextObserved":return uq(e,r,l),e;case"SessionNamed":return dq(e,r,l),e;case"SessionRecapped":return hq(e,r,l),e;case"ActivityObserved":return fq(e,r,l),e;case"JobObserved":return mq(e,r,l),e;case"OutputObserved":return gq(e,r,l,s),e;case"UsageObserved":return yq(e,r,l),e}const c=T8(e,r,s);C8(e,o,r,l)&&X8(e,l),c.provider||(c.provider=r.provider==="codex"?"codex":"claude");const d=V2(r),h=ji(r),f=h?gs(l,h):l;switch(d&&c.id===f&&(c.model=d),o){case"SessionStart":nq(e,r,l,s);break;case"UserPromptSubmit":rq(e,r,l,s);break;case"PreToolUse":Q8(e,r,l,c,s);break;case"PostToolUse":case"PostToolUseFailure":eq(e,r,o,l,s);break;case"SubagentStart":aq(e,r,l,s);break;case"SubagentStop":oq(e,r,l,s);break;case"Stop":case"SessionEnd":sq(e,o,l,s);break;case"Notification":Tq(e,r,l,s);break}return e}const Iq={input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4},Oq=[{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[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:4,output:20,cacheRead:.2,cacheWrite:5,cacheWrite1h:8}},{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[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4}},{match:/^claude[-_]sonnet[-_]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:Iq},{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[-_]6[-_]astra\b(?![-_][A-Za-z])/i,rates:{input:10,output:50,cacheRead:1,cacheWrite:12.5}},{match:/^gpt[-_]5[-_.]6[-_]cyber/i,rates:{input:12.5,output:75,cacheRead:1.25,cacheWrite:15.625}},{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(?![-_][A-Za-z])/i,rates:{input:4,output:20,cacheRead:.4,cacheWrite:5}},{match:/^gpt[-_]5[-_.]5[-_]pro/i,rates:{input:30,output:180,cacheRead:30,cacheWrite:0}},{match:/^gpt[-_]5[-_.]5\b(?![-_][A-Za-z])/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}}],Lq=[{match:/^claude[-_]opus[-_]5[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:8,output:40,cacheRead:.4,cacheWrite:10,cacheWrite1h:16}},{match:/^claude[-_]opus[-_]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:10,output:50,cacheRead:1,cacheWrite:12.5,cacheWrite1h:20}},{match:/^claude[-_]opus[-_]4[-_.]8\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:10,output:50,cacheRead:1,cacheWrite:12.5,cacheWrite1h:20}}];function Pq(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function ca(e,t=Date.now(),n=aa){if(!e)return null;const r=Dq.get(n);if(!r)return null;const s=cs(e);for(const o of r)if(o.match.test(s))return typeof o.rates=="function"?o.rates(t):o.rates;return null}const aa="standard",Dq=new Map([[aa,Oq],["fast",Lq]]);function Al(e,t){return e*t/1e6}function f$(e,t){const n=Math.max(0,e.cacheCreate1hTokens??0),r=Math.max(0,e.cacheCreate5mTokens??0),s=Math.max(0,e.cacheCreateTokens-n-r),o=r+s,l=t.cacheWrite1h??t.cacheWrite;return{tokens5m:o,tokens1h:n,usd5m:Al(o,t.cacheWrite),usd1h:Al(n,l)}}function p$(e,t,n=Date.now()){if(!Pq(t))return e.inputTokens;const r=ca(t,n),s=((r==null?void 0:r.cacheWrite)??0)>0?Math.max(0,e.cacheCreateTokens):0;return Math.max(0,e.inputTokens-e.cacheReadTokens-s)}function Xd(e,t,n=Date.now()){const r={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const s of Zd(e)){const o=bd(s.usage,t,s.speed,n);r.input+=o.input,r.output+=o.output,r.cacheRead+=o.cacheRead,r.cacheWrite+=o.cacheWrite,r.total+=o.total}return r}function bd(e,t,n,r=Date.now()){const s=ca(t,r,n);if(!s)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const o=Al(p$(e,t,r),s.input),l=Al(e.outputTokens,s.output),c=Al(e.cacheReadTokens,s.cacheRead),d=f$(e,s),h=d.usd5m+d.usd1h;return{input:o,output:l,cacheRead:c,cacheWrite:h,total:o+l+c+h}}function Zd(e){const t=e.bySpeed?Object.entries(e.bySpeed):[];return t.length===0?[{speed:aa,usage:e}]:[{speed:aa,usage:Fq(e,t.map(([,n])=>n))},...t.map(([n,r])=>({speed:n,usage:r}))]}function Fq(e,t){const n=o=>t.reduce((l,c)=>l+(o(c)??0),0),r=o=>Math.max(0,(o(e)??0)-n(o)),s={inputTokens:r(o=>o.inputTokens),outputTokens:r(o=>o.outputTokens),cacheReadTokens:r(o=>o.cacheReadTokens),cacheCreateTokens:r(o=>o.cacheCreateTokens)};return(e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0)&&(s.cacheCreate1hTokens=r(o=>o.cacheCreate1hTokens),s.cacheCreate5mTokens=r(o=>o.cacheCreate5mTokens)),e.reasoningOutputTokens!==void 0&&(s.reasoningOutputTokens=e.reasoningOutputTokens),s}const ms="not priced";function Rl(e,t,n){const r=e.toFixed(t);return Number(r)<n?r:null}function qe(e){if(e<=0)return"—";if(e<.005)return"<1¢";if(e<1){const t=Rl(e*100,e<.1?1:0,100);if(t!==null)return`${t}¢`}if(e<100){const t=Rl(e,2,100);if(t!==null)return`$${t}`}if(e<1e4){const t=Rl(e,0,1e4);if(t!==null)return`$${t}`}return`$${(e/1e3).toFixed(1)}k`}function e0(e,t){if(e<=0||t<10)return null;const n=e/t,r=n*60;return r>=.01?`${qe(r)}/min`:`${qe(n*3600)}/hr`}function m$(e,t){const n={inputTokens:e.inputTokens+t.inputTokens,outputTokens:e.outputTokens+t.outputTokens,cacheReadTokens:e.cacheReadTokens+t.cacheReadTokens,cacheCreateTokens:e.cacheCreateTokens+t.cacheCreateTokens};if((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)),e.bySpeed||t.bySpeed){const r=new Map(Object.entries(e.bySpeed??{}));for(const[s,o]of Object.entries(t.bySpeed??{})){const l=r.get(s);r.set(s,l?m$(l,o):o)}n.bySpeed=Object.fromEntries(r)}return n}function Bq(e,t){let n=0,r=0,s=0,o=0,l=0,c=0;for(const p of t)n+=p.inputTokens,r+=p.outputTokens,s+=p.cacheReadTokens,o+=p.cacheCreateTokens,l+=p.cacheCreate1hTokens??0,c+=p.cacheCreate5mTokens??0;const d=(p,g)=>Math.max(0,p-g),h={inputTokens:d(e.inputTokens,n),outputTokens:d(e.outputTokens,r),cacheReadTokens:d(e.cacheReadTokens,s),cacheCreateTokens:d(e.cacheCreateTokens,o)};return(e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0)&&(h.cacheCreate1hTokens=d(e.cacheCreate1hTokens??0,l),h.cacheCreate5mTokens=d(e.cacheCreate5mTokens??0,c)),h.inputTokens+h.outputTokens+h.cacheReadTokens+h.cacheCreateTokens>0?h:null}function dc(e){const t=e.usageByModel,n=t?Object.keys(t):[];if(!t||n.length===0)return[{model:e.model,usage:e.usage}];const r=n.map(o=>({model:o,usage:t[o]})),s=Bq(e.usage,r.map(o=>o.usage));if(s){const o=r.findIndex(l=>l.model===e.model);o>=0?r[o]={model:r[o].model,usage:m$(r[o].usage,s)}:r.push({model:e.model,usage:s})}return r}function pn(e,t=Date.now()){const n={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const r of dc(e)){const s=Xd(r.usage,r.model,t);n.input+=s.input,n.output+=s.output,n.cacheRead+=s.cacheRead,n.cacheWrite+=s.cacheWrite,n.total+=s.total}return n}function Hl(e,t=Date.now()){let n=0;for(const r of dc(e))for(const s of Zd(r.usage))ca(r.model,t,s.speed)==null&&(n+=s.usage.inputTokens+s.usage.outputTokens);return n}function g$(e){const t=[];for(const n of dc(e)){if(!n.model||t.includes(n.model))continue;const r=n.usage;r.inputTokens+r.outputTokens+r.cacheReadTokens+r.cacheCreateTokens<=0||t.push(n.model)}return t}function y$(e){return g$(e).filter(t=>t!==e.model)}function _j(e,t){if(!e.bySpeed)return Cp(e,t,aa);const n=Zd(e).filter(r=>r.speed!==aa||qq(r.usage));return n.length===1?Cp(n[0].usage,t,n[0].speed):[...n.map(r=>Cp(r.usage,t,r.speed)),"═════════════════════════════════════════",`all speeds = ${qe(Xd(e,t).total)}`].join(`
66
- `)}function qq(e){return e.inputTokens+e.outputTokens+e.cacheReadTokens+e.cacheCreateTokens>0}function Cp(e,t,n){const r=ca(t,Date.now(),n),s=n===aa?`model: ${t}`:`model: ${t} · ${n}`;if(!r)return`${s}
67
- no published rate in this build — the tokens are counted, the dollars are not`;const o=g=>g.toLocaleString(),l=g=>`$${g}/MTok`,c=bd(e,t,n),d=f$(e,r),h=d.tokens1h>0?[`cache w5m${o(d.tokens5m).padStart(14)} × ${l(r.cacheWrite).padEnd(11)} = ${qe(d.usd5m)}`,`cache w1h${o(d.tokens1h).padStart(14)} × ${l(r.cacheWrite1h??r.cacheWrite).padEnd(11)} = ${qe(d.usd1h)}`]:[`cache w ${o(d.tokens5m).padStart(14)} × ${l(r.cacheWrite).padEnd(11)} = ${qe(d.usd5m)}`],f=p$(e,t),p=f===e.inputTokens?"input":"uncached";return[s,`${p.padEnd(9)}${o(f).padStart(14)} × ${l(r.input).padEnd(11)} = ${qe(c.input)}`,`output ${o(e.outputTokens).padStart(14)} × ${l(r.output).padEnd(11)} = ${qe(c.output)}`,`cache r ${o(e.cacheReadTokens).padStart(14)} × ${l(r.cacheRead).padEnd(11)} = ${qe(c.cacheRead)}`,...h,"─────────────────────────────────────────",`total = ${qe(c.total)}`].join(`
68
- `)}function Ej(e){const t=dc(e),[n]=t;return t.length<=1?_j(n.usage,n.model):[...t.map(r=>_j(r.usage,r.model)),"═════════════════════════════════════════",`all models = ${qe(pn(e).total)}`].join(`
69
- `)}function Uq(e){if(!e.model)return null;const t=ca(e.model),n=pn(e),r=Hl(e);if(!t&&n.total<=0)return e.usage.inputTokens+e.usage.outputTokens<=0?null:{kind:"unpriced",tt:Ej(e)};if(n.total<=0)return null;const s=Math.max(0,((e.endedAt??Date.now())-e.startedAt)/1e3),o=e.state==="active"&&!e.synthetic?e0(n.total,s):null,l=Ej(e)+(o?`
70
- burn: ${o}`:"");return{kind:"spent",total:n.total,floor:r>0,tt:l}}const zq=new Set(["untrusted","on-request","on-failure"]);function Wq(e){return typeof e!="string"||!e?null:zq.has(e)?!0:e==="never"?!1:null}function Hq(e){if(e.provider!=="codex"||e.kind!=="root"||e.waiting||e.state!=="active")return null;const t=Wq(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."}
71
-
72
- 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 Tj(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function oa(e){const t=cs(e).replace(/[-_]\d{8}(?!\d)/,""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const s=Tj(n[1]),o=n[2].replace(/[-_]/g,".");return`${s} ${o}`}const r=t.match(/^gpt[-_](\d+(?:[-_.]\d+)*)((?:[-_][A-Za-z0-9.]+)*)$/i);if(r){const s=r[1].replace(/[-_]/g,"."),o=r[2].split(/[-_]/).filter(Boolean).map(Tj);return[`GPT-${s}`,...o].join(" ")}return e}function Jd(e){const t=cs(e??""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_]/i);return n?n[1].toLowerCase():/^gpt[-_]/i.test(t)?"gpt":""}function Sn(e){return(e==null?void 0:e.kind)==="permission"||(e==null?void 0:e.kind)==="asked"}function Ix(e){const t=[];for(const n of e)n.kind==="root"&&Sn(n.waiting)&&t.push({id:n.id,label:n.label,waiting:n.waiting});return t.sort((n,r)=>n.waiting.since-r.waiting.since)}function Vq(e,t){if(e.length===0)return null;const n=e.findIndex(r=>r.id===t);return e[(n+1)%e.length]}function Gq(e){const t=new Set;for(const n of e)n.state==="active"&&t.add(n.sessionId);return t.size}function Qd(e,t){return`${e}@${t.since}`}function w$(e,t){if(!e.tool)return null;const{name:n,preview:r}=e.tool,s=new RegExp(`\\b${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"i").test(t);return r?s?r:`${n} · ${r}`:s?null:n}function Kq(e){const t=e.message||"Needs your permission",n=w$(e,t);return n?`${t}
73
- Likely on: ${n}`:t}function Yq(e,t,n,r=!0){if(!r)return[];if(n)return[];const s=[];for(const o of e){if(!Sn(o.waiting))continue;const l=Qd(o.id,o.waiting);t.has(l)||s.push({key:l,title:o.label,body:Kq(o.waiting),sessionId:o.id})}return s}function Xq(e,t,n){const r=new Set;for(const o of e)r.add(Qd(o.id,o.waiting));const s=new Set;for(const o of n)r.has(o)&&s.add(o);for(const o of t)s.add(o.key);return s}function Iu(e){return new Set(e.map(t=>Qd(t.id,t.waiting)))}function Zq(e,t){return e!==t}function Jq(e,t){return!e&&t!=null}function Qq(e,t){return e!==null&&t!=null}function fi(e){return e==="active"?"live":e==="done"?"done":"err"}function pi(e){return e.message?e.message:e.kind==="permission"?"Needs your permission":"Waiting for your input"}function eU(e){return`${e} subagent${e===1?"":"s"} spawned`}function tU(e,t=Date.now(),n=!1){const r=e.toolErrorCount??0,s=pn(e,t).total;return[e.label,e.kind==="root"?"session":"subagent",fi(e.state),Sn(e.waiting)?pi(e.waiting):null,e.model?oa(e.model):null,`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,r>0?`${r} failed`:null,s>0?`${qe(s)}${Hl(e,t)>0?"+":""}`:null,n?"selected":null].filter(Boolean).join(", ")}function nU(e,t){const n=w$(e,t);return n?`Likely on: ${n}`:null}function t0(e){return e.kind==="idle"?"Your turn":pi(e)}function it(e){const t=Math.round(e);if(t<1e3)return`${t}`;if(t<1e6){const n=Rl(t/1e3,1,1e3);if(n!==null)return`${n}k`}if(t<1e9){const n=Rl(t/1e6,2,1e3);if(n!==null)return`${n}M`}return`${(t/1e9).toFixed(2)}B`}function mi(e,t,n){const r=(t??n)-e;if(r<1e3)return`${Math.max(0,r)}ms`;const s=Math.floor(r/1e3);if(s<60)return`${s}s`;const o=Math.floor(s/60),l=s%60;return`${o}m ${String(l).padStart(2,"0")}s`}function v$(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 n0(e,t){const n=typeof e=="string"?e.trim():"",r=typeof t=="string"?t.trim():"";return{face:n||r||void 0,tooltip:r||n||void 0}}const Cj=2e5,rU=1e6,sU=[/\[1m\]/i,/^claude[-_]opus[-_]5\b/i,/^claude[-_]sonnet[-_]5\b/i,/^claude[-_]opus[-_]4[-_.](?:6|7|8)\b/i,/^claude[-_]sonnet[-_]4[-_.]6\b/i,/^claude[-_](fable|mythos)[-_]5\b/i],aU=[{match:/^gpt[-_]6[-_]astra/i,window:105e4},{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 oU(e){if(!e)return Cj;const t=cs(e);for(const n of sU)if(n.test(t))return rU;for(const n of aU)if(n.match.test(t))return n.window;return Cj}function x$(e,t){return typeof e=="number"&&e>0?e:oU(t)}const iU=1;function lU(){const e=[];let t=0;function n(){let r;for(const s of e)(!r||s.layer>r.layer||s.layer===r.layer&&s.seq>r.seq)&&(r=s);return r}return{push(r,s=0,o="dialog"){const l={dismiss:r,layer:s,kind:o,seq:t++};return e.push(l),()=>{const c=e.indexOf(l);c!==-1&&e.splice(c,1)}},dismissTop(){const r=n();return r?(r.dismiss(),!0):!1},isTop(r){const s=n();return s!=null&&s.dismiss===r},depth(){return e.length},dialogDepth(){return e.filter(r=>r.kind==="dialog").length}}}const ds=lU(),b$=e=>e==="Escape";function cU(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function Aj(e){return String(e.tagName??"").toUpperCase()==="BODY"}function uU(e,t){return!e||!e.isConnected||Aj(e)?!1:t==null||Aj(t)}const Rj="a[href], button, input, select, textarea, [tabindex]";function dU(e){return!e||e.disabled||e.rendered===!1?!1:(e.tabIndex??0)>=0}function hU(e){if(!e||!e.overflowing||e.hasFocusable)return!1;const t=String(e.overflow??"").toLowerCase();return t==="auto"||t==="scroll"}function fU({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 eh(e){return e.ctrlKey||e.metaKey||e.altKey}const pU=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),mU=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),gU=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function r0(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function yU(e){return r0(e)==="BUTTON"?!0:(typeof e.role=="string"?e.role.trim().toLowerCase():"").split(/\s+/).includes("button")}function hc(e){if(!e)return!1;if(e.isContentEditable)return!0;const t=r0(e);return t==="TEXTAREA"?!0:t!=="INPUT"?!1:!pU.has(String(e.type??"text").toLowerCase())}function wU(e,t){if(!e)return!1;if(hc(e))return!0;if(t!=null&&(t.length===1||t==="Delete")&&t!==" "&&e.pointerFocused&&yU(e))return!1;if(mU.has(r0(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(r=>gU.has(r))}function vU({key:e,modalOpen:t,sheetOpen:n}){return t?!(e==="?"&&n):!1}function xU({key:e,sheetOpen:t,target:n}){return t&&e==="?"&&!hc(n)}function k$({appModal:e,dialogDepth:t}){return e||t>0}function N$(e){return e?Array.from(e.querySelectorAll("*")).filter(t=>{if(t.matches(Rj))return dU({disabled:t.disabled,tabIndex:t.tabIndex,rendered:t.getClientRects().length>0});const n=t.scrollHeight>t.clientHeight;return n&&hU({overflowing:n,overflow:getComputedStyle(t).overflowY,hasFocusable:t.querySelector(Rj)!=null})}):[]}function bU(e,t){const n=N$(e);if(!t||!e.contains(t)||n.includes(t))return n;const r=n.findIndex(s=>(t.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_FOLLOWING)!==0);return r===-1?[...n,t]:[...n.slice(0,r),t,...n.slice(r)]}function ut(e,t={}){const{focusRef:n,layer:r,popover:s}=t,o=s?"popover":"dialog",l=y.useRef(null),c=y.useRef(e);c.current=e;const d=y.useRef(null);d.current===null&&(d.current=()=>c.current());const h=d.current;return y.useEffect(()=>ds.push(h,r,o),[h,r,o]),y.useEffect(()=>{var p;const f=document.activeElement;return(p=(n==null?void 0:n.current)??N$(l.current)[0])==null||p.focus(),()=>{uU(f,document.activeElement)&&f.focus()}},[]),y.useEffect(()=>{const f=p=>{var j;if(p.key!=="Tab"||eh(p))return;const g=l.current;if(!g)return;const v=document.activeElement;if(!(v!=null&&g.contains(v))&&!ds.isTop(h))return;const k=bU(g,v),x=fU({count:k.length,index:v?k.indexOf(v):-1,shiftKey:p.shiftKey});x.kind!=="allow"&&(p.preventDefault(),x.kind==="focus"&&((j=k[x.index])==null||j.focus()))};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[h]),l}function gt(e){const t=y.useRef(!1);return{onPointerDown:n=>{t.current=n.target===n.currentTarget},onPointerUp:n=>{n.target!==n.currentTarget&&(t.current=!1)},onClick:n=>{const r=t.current&&n.target===n.currentTarget;t.current=!1,r&&e()}}}function kU(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 Dn(e){return e.toLocaleString()}const NU=60;function jU(e,t=NU){if(e.length<=t)return e;const n=e.slice(e.length-(t-1)),r=n.search(/[/\\]/);return"…"+(r===-1?n:n.slice(r))}function SU({agent:e,onClose:t}){var v;const n=y.useRef(null),r=ut(t,{focusRef:n}),s=gt(t),o=e.context,l=e.usage,c=(o==null?void 0:o.currentContextTokens)??0,d=x$(e.contextWindow,e.model),h=Math.min(100,c/d*100),f=pn(e),p=e.provider==="codex"?l.inputTokens+l.outputTokens:l.inputTokens+l.outputTokens+l.cacheReadTokens+l.cacheCreateTokens,g=kU(e.provider);return a.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal ctx-modal",onClick:N=>N.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Context breakdown",children:[a.jsxs("header",{className:"ctx-modal-head",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"ctx-modal-title",children:["Context · ",e.label]}),a.jsx("div",{className:"ctx-modal-sub",children:g.subtitle})]}),a.jsx("button",{type:"button",ref:n,className:"glyph-btn ctx-modal-close",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),a.jsxs("section",{className:"ctx-window-row",children:[a.jsx("div",{className:"ctx-window-bar",role:"progressbar","aria-label":"Context window used","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(h),children:a.jsx("div",{className:"ctx-window-fill",style:{transform:`scaleX(${Math.min(100,Math.max(0,h))/100})`}})}),a.jsxs("div",{className:"ctx-window-meta",children:[a.jsxs("span",{className:"ctx-window-pct",children:[h.toFixed(1),"%"]}),a.jsxs("span",{children:[Dn(c)," / ",Dn(d)," tok (",g.windowScope,")"]})]})]}),a.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),a.jsxs("div",{className:"ctx-grid",children:[a.jsx(nr,{label:"input tokens",val:Dn(l.inputTokens)}),a.jsx(nr,{label:"output tokens",val:Dn(l.outputTokens)}),a.jsx(nr,{label:"cache reads",val:Dn(l.cacheReadTokens)}),a.jsx(nr,{label:"cache writes",val:Dn(l.cacheCreateTokens)}),a.jsx(nr,{label:"cumulative total",val:Dn(p)}),a.jsx(nr,{label:"estimated cost",val:qe(f.total),accent:!0})]}),a.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),g.compositionCounted?a.jsxs("div",{className:"ctx-grid",children:[a.jsx(nr,{label:"user messages",val:Dn((o==null?void 0:o.msgsUser)??0)}),a.jsx(nr,{label:"assistant messages",val:Dn((o==null?void 0:o.msgsAssistant)??0)}),a.jsx(nr,{label:"tool uses",val:Dn((o==null?void 0:o.toolUses)??0)}),a.jsx(nr,{label:"tool results",val:Dn((o==null?void 0:o.toolResults)??0)}),a.jsx(nr,{label:"system-reminders",val:Dn((o==null?void 0:o.systemReminders)??0)})]}):a.jsx("div",{className:"ctx-empty",children:g.compositionUncounted}),a.jsx("h3",{className:"ctx-section-title",children:g.memoryHeading}),(((v=o==null?void 0:o.memoryFiles)==null?void 0:v.length)??0)===0?a.jsx("div",{className:"ctx-empty",children:g.memoryEmpty}):a.jsx("ul",{className:"ctx-md-list",children:o.memoryFiles.map(N=>a.jsxs("li",{children:[a.jsx("span",{className:"ctx-md-path",title:N.path,children:jU(N.path)}),a.jsx("span",{className:"ctx-md-size",children:ea(N.bytes)})]},N.path))})]})})}function nr({label:e,val:t,accent:n}){return a.jsxs("div",{className:`ctx-row${n?" accent":""}`,children:[a.jsx("span",{className:"ctx-row-label",children:e}),a.jsx("span",{className:"ctx-row-val",children:t})]})}function _U({currentContextTokens:e,modelId:t,contextWindow:n,size:r=26,onClick:s}){const o=x$(n,t),l=Math.min(1,e/o),c=r/2-3,d=r/2,h=2*Math.PI*c,f=h*l,p=l>.9?"var(--err)":l>.7?"var(--warn)":"var(--accent)";return a.jsx("button",{type:"button",className:"ctx-donut",onClick:g=>{g.stopPropagation(),s==null||s()},title:`context: ${e.toLocaleString()} / ${o.toLocaleString()} (${(l*100).toFixed(1)}%)`,"aria-label":`Context ${Math.round(l*100)}% of ${o.toLocaleString()} tokens — show breakdown`,children:a.jsxs("svg",{width:r,height:r,viewBox:`0 0 ${r} ${r}`,"aria-hidden":"true",children:[a.jsx("circle",{cx:d,cy:d,r:c,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),a.jsx("circle",{cx:d,cy:d,r:c,stroke:p,strokeWidth:"2.5",fill:"none",strokeDasharray:`${f} ${h-f}`,strokeDashoffset:h/4,strokeLinecap:"round",style:{transition:"var(--ctx-arc-transition)"}}),a.jsx("text",{x:d,y:d+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(l*100)})]})})}const Mj=new Map;function j$(e){let t=Mj.get(e);return t||(t={now:Date.now(),listeners:new Set,timer:null},Mj.set(e,t)),t}function EU(e,t){const n=j$(e);return n.listeners.add(t),n.timer===null&&(n.now=Date.now(),n.timer=setInterval(()=>{n.now=Date.now();for(const r of n.listeners)r()},e)),()=>{n.listeners.delete(t),n.listeners.size===0&&n.timer!==null&&(clearInterval(n.timer),n.timer=null)}}function TU(e){return j$(e).now}const $j=new Map,Ij=new Map;function _i(e=1e3){let t=$j.get(e);t||(t=r=>EU(e,r),$j.set(e,t));let n=Ij.get(e);return n||(n=()=>TU(e),Ij.set(e,n)),y.useSyncExternalStore(t,n,n)}function th(e){const t=e.recap;if(e.kind!=="root"||!t||e.state==="active"||e.closedAt!=null)return null;for(const n of e.prompts)if(n.at>t.at)return null;return t}const CU="1",Oj="agent-dag.schema",AU=["agent-dag.layout","agent-dag.viewport"];function Qe(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function Ze(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}function hs(e){if(!(typeof window>"u"))try{window.localStorage.removeItem(e)}catch{}}function Ml(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function RU(e,t=CU){let n=null;try{n=e.getItem(Oj)}catch{return[]}if(n===t)return[];const r=[];if(n!==null)for(const s of AU)try{e.getItem(s)!==null&&(e.removeItem(s),r.push(s))}catch{}try{e.setItem(Oj,t)}catch{}return r}const S$="agent-dag.recapsDismissed",Lj=200;function MU(){const e=Qe(S$);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}let gi=new Set(MU());const Ox=new Set;let _$=0;function E$(e){return Ox.add(e),()=>{Ox.delete(e)}}function T$(e){gi=e,_$++;const t=Array.from(e);Ze(S$,JSON.stringify(t.length>Lj?t.slice(-Lj):t));for(const n of Ox)n()}function C$(e,t){return`${e}@${t}`}function $U(e){return gi.has(e)}function IU(e){if(gi.has(e))return;const t=new Set(gi);t.add(e),T$(t)}function OU(e){const t=new Set(gi);t.delete(e)||t.add(e),T$(t)}function LU(e){return y.useSyncExternalStore(E$,()=>e!=null&&gi.has(e),()=>!1)}function s0(e){return`recap:${e}`}function PU(e){return e.startsWith("recap:")}function DU(){return y.useSyncExternalStore(E$,()=>_$,()=>0)}function FU(e){const t=new Map;for(const n of e){if(n.kind!=="subagent"||n.exitAt!=null)continue;let r=t.get(n.sessionId);r||(r={total:0,live:0,done:0,err:0,failed:0},t.set(n.sessionId,r)),r.total+=1,n.state==="active"?r.live+=1:n.state==="err"?r.err+=1:r.done+=1,r.failed+=n.toolErrorCount??0}return t}function A$(e){return[`${e.total} ${e.total===1?"subagent":"subagents"}`,e.live>0?`${e.live} live`:null,e.done>0?`${e.done} done`:null,e.err>0?`${e.err} err`:null].filter(Boolean).join(" · ")}function R$(e){return e.live>0?`→ ${e.total} · ${e.live} live`:`→ ${e.total} · done`}function BU(e,t,n){const r=e.kind==="root"?e.waiting:null;if(r&&Sn(r))return{tone:"warn",long:n.sayWaiting(r),short:r.kind==="permission"?"Needs you":"Asked you"};if(r&&r.kind==="idle"){const o=n.sayWaiting(r);return{tone:"idle",long:o,short:o}}const s=e.toolErrorCount??0;if(s>0)return{tone:"err",long:`${s} tool ${s===1?"call":"calls"} failed`,short:`${s} failed`};if(t&&t.total>0)return{tone:"muted",long:A$(t),short:R$(t)};if(e.state==="active")for(let o=e.tools.length-1;o>=0;o--){const l=e.tools[o];if(l.endedAt!=null)continue;const{name:c,subject:d}=n.describeCall(l);return{tone:"muted",long:d?`${c} · ${d}`:c,short:c}}return null}function Lx(e){return e==="active"?"live":e==="done"?"done":"err"}const nh={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"}},qU=Object.fromEntries(Object.entries(nh).map(([e,t])=>[e,t.category])),UU=Object.fromEntries(Object.entries(nh).map(([e,t])=>[e,t.emoji])),zU=Object.fromEntries(Object.entries(nh).map(([e,t])=>[e,t.label])),WU=new Set(Object.entries(nh).filter(([,e])=>e.shell).map(([e])=>e)),HU={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",...qU};function M$(e){return e.startsWith("mcp__")?"mcp":Ot(HU,e)??"other"}const VU=/\btools\.exec_command\s*\(\s*\{[^{}]*?\bcmd\s*:\s*(["'`])((?:\\.|(?!\1)[^\\])*)\1/,GU=/\btools\.([A-Za-z_$][\w$]*)\s*\(/;function KU(e){if(typeof e!="string"||!e)return null;const t=VU.exec(e);if(t){const r=YU(t[2]);if(r.trim())return r}const n=GU.exec(e);return n?n[1]:null}function YU(e){return e.replace(/\\(["'`\\nrt])/g,(t,n)=>n==="n"?`
74
- `:n==="r"?"\r":n==="t"?" ":n)}const XU={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:"📡",...UU};function Pj(e){return e.startsWith("mcp__")?"🔌":Ot(XU,e)??"✨"}const ZU={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 $$(e){return/^-(?:Command|c)$/i.test(e)||/^-[a-z]+c$/.test(e)}function I$(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+-[A-Za-z]+)+)\s*["']([^"']+)["']/i);if(n&&n[1].trim().split(/\s+/).every(o=>$$(o)||/^-(?:NoProfile|NonInteractive)$/i.test(o)))return I$(n[2]);for(;;){const o=t.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!o)break;t=t.slice(o[0].length)}t=t.replace(/^sudo(?:\s+-\S+)*\s+/,""),t=t.replace(/^(?:time|nohup|xargs)\s+/,"");const r=t.match(/^([^\s|;&<>(]+)/);if(!r)return null;let s=r[1];return/^[A-Za-z0-9_][\w.+-]*$/.test(s.replace(/^.*[/\\]/,""))?(s=s.replace(/^.*[/\\]/,""),s=s.replace(/\.(exe|cmd|bat|ps1)$/i,""),s||null):null}function JU(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const t=e;if(typeof t.script=="string"){const n=KU(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 r=n.findIndex($$);if(r>=0&&r+1<n.length)return n[r+1]}return n.join(" ")}return typeof t.script=="string"?t.script:null}const QU=new Set(["Bash","PowerShell",...WU]);function ez(e,t){if(!QU.has(e))return null;const n=JU(t);if(!n)return null;const r=I$(n);return r?{emoji:Ot(ZU,r)??"⚙️",label:r,category:"shell",detail:n}:null}const tz=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),nz={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:"🗄️"},rz={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 sz(e){const n=e.replace(/\\/g,"/").replace(/\/+$/,""),r=n.lastIndexOf("/");return r>=0?n.slice(r+1):n}function az(e){const t=e.toLowerCase(),n=Ot(rz,t);if(n!==void 0)return n;if(t.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(t))return"🧪";const r=t.lastIndexOf(".");if(r>0&&r<t.length-1){const s=Ot(nz,t.slice(r+1));if(s!==void 0)return s}return"📄"}function oz(e,t){if(!t||typeof t!="object")return null;const n=t;if(e==="apply_patch"&&typeof n.patch=="string"){const r=n.patch.match(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/m);return r?r[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 iz(e,t){if(!tz.has(e))return null;const n=oz(e,t);if(!n)return null;const r=sz(n);return r?{emoji:e==="LS"?"📂":az(r),label:r,category:"file",detail:n}:null}const lz={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 a0(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 cz(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 O$(e){return Ot(lz,e.toLowerCase())}function uz(e,t){const n=a0(e);if(!n)return null;const{server:r,method:s}=n;if(!s)return null;const o=O$(r);return{emoji:(o==null?void 0:o.emoji)??"🔌",label:s,category:"mcp",detail:o?`${o.name} · ${s}`:`${r} · ${s}`}}function L$(e,t){return ez(e,t)??iz(e,t)??uz(e)}function dz(e,t){var n;return((n=L$(e,t))==null?void 0:n.label)??null}const hz=zU,Dj=18;function Ou(e){const t=[...e];return t.length<=Dj?e:t.slice(0,Dj-1).join("")+"…"}const Ap=13,fz=6;function pz(e,t){const n=[...e];if(n.length<=Ap)return e;const r=n.lastIndexOf("."),s=r>0?n.slice(r):[];return t==="file"&&s.length>1&&s.length<=fz?n.slice(0,Ap-1-s.length).join("")+"…"+s.join(""):n.slice(0,Ap-1).join("")+"…"}function o0(e){const t=a0(e);if(t){const r=O$(t.server);return r?{emoji:r.emoji,label:Ou(r.name)}:{emoji:"🔌",label:Ou(t.server),hue:cz(t.server)}}const n=Ot(hz,e)??"";return n?{emoji:Pj(e),label:Ou(n)}:{emoji:Pj(e),label:Ou(e)}}function mz(e){let t=null,n="";for(const r of e){const s=a0(r);if(s){if(!s.server)return null;if(t===null)t=s.server,n=r;else if(s.server!==t)return null}}return t===null?null:o0(n)}const Px=6e4,ai=24,Fj=Px/ai,Rp=132,nd=14;function gz(e,t,n){const r=new Array(ai).fill(0);let s=0;const o=g=>{const v=n-g;if(v<0||v>=Px)return;const N=ai-1-Math.floor(v/Fj);N>=0&&N<ai&&(r[N]+=1,s+=1)};for(const g of e)o(g.startedAt);for(const g of t??[])o(g);const c=Math.max(0,...r)/(Fj/1e3),d=e.filter(g=>n-g.startedAt>=0&&n-g.startedAt<Px).length,h=s-d,f=[d>0?`${d} tool ${d===1?"call":"calls"}`:"",h>0?`${h} ${h===1?"block":"blocks"} of thinking and writing`:""].filter(Boolean),p=s===0?"nothing in the last 60s":`${f.join(" · ")} in last 60s · peak ${c.toFixed(1)}/s`;return{counts:r,title:p}}const yz=2;function wz(e){return e===0?1.5:Math.max(1.5,Math.min(1,e/yz)*nd)}function P$({kind:e}){return a.jsxs("svg",{className:"state-mark","data-kind":e,viewBox:"0 0 10 10",width:"10",height:"10","aria-hidden":"true",focusable:"false",children:[e==="live"&&a.jsx("circle",{cx:"5",cy:"5",r:"3.2",fill:"currentColor"}),e==="done"&&a.jsx("path",{d:"M2.2 5.3l1.9 1.9 3.8-4.4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),e==="err"&&a.jsx("path",{d:"M2.8 2.8l4.4 4.4M7.2 2.8l-4.4 4.4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",fill:"none"})]})}function i0(){return a.jsxs("svg",{className:"alert-mark",viewBox:"0 0 12 12",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[a.jsx("path",{d:"M6 1.4l4.7 8.3H1.3z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M6 4.6v2.4",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"}),a.jsx("circle",{cx:"6",cy:"8.35",r:"0.72",fill:"currentColor"})]})}function Vl(){return a.jsxs("svg",{className:"recap-glyph",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true",focusable:"false",children:[a.jsx("path",{d:"M3.3 3.3l5.4 5.4M8.7 3.3l-5.4 5.4",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",fill:"none"}),a.jsx("circle",{cx:"6",cy:"1.2",r:"1.05",fill:"currentColor"}),a.jsx("circle",{cx:"6",cy:"10.8",r:"1.05",fill:"currentColor"}),a.jsx("circle",{cx:"1.2",cy:"6",r:"1.05",fill:"currentColor"}),a.jsx("circle",{cx:"10.8",cy:"6",r:"1.05",fill:"currentColor"})]})}function vz({data:e}){var x,j;const t=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":""].filter(Boolean).join(" "),n=e.tools.filter(b=>!b.endedAt).length,r=e.toolErrorCount??0,s=xd(e.sessionId),o=((x=e.context)==null?void 0:x.currentContextTokens)??0,l=e.kind==="root"&&o>0,c=e.sessionTitle?e.cwd?`${e.cwd}
75
- ${e.sessionTitle}`:e.sessionTitle:e.cwd,d=y$(e),h=d.length>0?`${e.model}
76
- spend on this card also covers:
77
- ${d.join(`
78
- `)}`:e.model,f=n0(e.sessionName,e.sessionTitle),p=th(e),g=p?C$(e.sessionId,p.at):null,v=LU(g),N=p!=null&&!v,k=Uq(e);return a.jsxs("div",{className:t,style:{"--session-hue":s},children:[a.jsx("span",{className:"accent-stripe"}),a.jsx(Xa,{type:"target",position:Ae.Left,style:{background:"transparent",border:"none"}}),a.jsxs("div",{className:"head",children:[a.jsxs("div",{className:"title",children:[a.jsx(Nz,{state:e.state}),a.jsx("span",{className:"label",title:c,children:e.label}),e.synthetic&&a.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"}),p&&g&&a.jsx("button",{type:"button",className:"glyph-btn recap-pin","aria-label":"Claude Code's recap","aria-expanded":N,title:N?"Hide the recap":"Show Claude Code's recap",onClick:b=>{b.stopPropagation(),OU(g)},children:a.jsx(Vl,{})})]}),a.jsxs("div",{className:"head-right",children:[l&&e.onOpenContext&&a.jsx(_U,{currentContextTokens:o,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)}),a.jsxs("div",{className:"time",title:e.synthetic?`The deck joined this session after it began, so it has run at least this long — first seen ${new Date(e.startedAt).toLocaleTimeString()}`:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:[e.synthetic?"≥ ":"",a.jsx(kz,{start:e.startedAt,end:e.endedAt})]})]})]}),a.jsxs("div",{className:"sub",children:[e.kind==="root"?"session":"subagent",e.childCount>0&&a.jsxs("span",{className:"spawn-badge",title:eU(e.childCount),children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model?a.jsxs("span",{className:"model-chip","data-family":Jd(e.model),title:h,children:[oa(e.model),d.length>0?` +${d.length}`:""]}):e.provider==="codex"?a.jsx("span",{className:"model-chip",title:"OpenAI Codex — no model reported yet",children:"Codex"}):null]}),e.kind==="root"&&f.face&&a.jsx("div",{className:"session-name",title:f.tooltip,children:f.face}),e.waiting&&a.jsx(jz,{waiting:e.waiting}),(()=>{const b=Hq(e);return b?a.jsxs("div",{className:"approval-blind-row",title:b.detail,children:[a.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),a.jsx("span",{className:"approval-blind-said",children:b.label})]}):null})(),(e.tools.length>0||(((j=e.outputs)==null?void 0:j.length)??0)>0)&&a.jsx(Sz,{tools:e.tools,outputs:e.outputs}),a.jsxs("div",{className:"meta",children:[a.jsxs("span",{children:[a.jsx("b",{children:e.toolCount})," ",e.toolCount===1?"tool":"tools"]}),r>0&&a.jsxs("span",{className:"failed-meta",title:`${r} tool ${r===1?"call":"calls"} returned an error`,children:[a.jsx("b",{children:r})," err"]}),n>0&&a.jsxs("span",{className:"inflight-meta",children:[a.jsx("b",{children:n})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&a.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:[a.jsx("b",{children:it(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),(k==null?void 0:k.kind)==="unpriced"&&a.jsx("span",{className:"cost-unpriced",title:k.tt,children:ms}),(k==null?void 0:k.kind)==="spent"&&a.jsx("span",{className:"cost-meta",title:k.tt,children:a.jsxs("b",{children:[qe(k.total),k.floor?"+":""]})})]}),a.jsx(bz,{data:e,title:e.kind==="root"?f.face:void 0}),a.jsx(Xa,{type:"source",position:Ae.Right,style:{background:"transparent",border:"none"}})]})}const xz=y.memo(vz);function bz({data:e,title:t}){const n=e.kind==="root"&&Sn(e.waiting),r=BU(e,e.branch,{sayWaiting:t0,describeCall:s=>({name:o0(s.name).label,subject:dz(s.name,s.input)})});return a.jsxs("div",{className:"lod-face","data-kind":e.kind,"data-alarm":n?"":void 0,"data-signal":r?"":void 0,"aria-hidden":!0,children:[a.jsxs("div",{className:"lod-id",children:[a.jsx(P$,{kind:Lx(e.state)}),a.jsx("span",{className:"lod-name",children:e.label}),r&&a.jsx("span",{className:"lod-inline","data-tone":r.tone,children:r.short}),n&&a.jsx(i0,{})]}),t&&a.jsx("div",{className:"lod-title",children:t}),r&&a.jsxs("div",{className:"lod-signal","data-tone":r.tone,children:[a.jsx("span",{className:"lod-long",children:r.long}),a.jsx("span",{className:"lod-short",children:r.short})]})]})}function kz({start:e,end:t}){const n=_i(1e3);return a.jsx(a.Fragment,{children:mi(e,t,n)})}function Nz({state:e}){return a.jsx("span",{className:`state-pill state-${e}`,children:fi(e)})}function jz({waiting:e}){const t=_i(1e3),n=Sn(e),r=pi(e);return a.jsxs("div",{className:n?"waiting-row permission":"waiting-row idle",title:`${r}
79
- Blocked for ${mi(e.since,void 0,t)} — the answer goes in the terminal, not here.`,children:[n?a.jsx("span",{className:"ap-pulse","aria-hidden":!0}):a.jsx("span",{className:"waiting-dot","aria-hidden":!0}),a.jsx("span",{className:"waiting-said",children:t0(e)}),a.jsx("b",{children:mi(e.since,void 0,t)})]})}function Sz({tools:e,outputs:t}){const n=_i(1e3),{counts:r,title:s}=gz(e,t,n),o=Rp/ai;return a.jsxs("div",{className:"tool-spark-row",title:s,children:[a.jsx("svg",{className:"tool-spark",width:Rp,height:nd,viewBox:`0 0 ${Rp} ${nd}`,"aria-hidden":!0,children:r.map((l,c)=>{const d=wz(l),h=c===ai-1&&l>0,p=`tool-spark-bar${l>0?" active":""}${h?" latest":""}`;return a.jsx("rect",{x:c*o+.4,y:nd-d,width:Math.max(.5,o-1),height:d,rx:.8,className:p},h?`landed:${l}`:c)})}),a.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function _z({enableAutoFitAndRefit:e}){return a.jsxs("div",{className:"autofit-chip",children:[a.jsx("span",{className:"autofit-state",title:"New sessions are not brought into view while you are moving it yourself",children:"Auto-fit off"}),a.jsx("button",{type:"button",className:"autofit-resume",onClick:e,title:"Bring new sessions into view again","aria-label":"Resume auto-fit",children:"Resume"})]})}function kd(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const Bj=99;function Ez(e){const t=Math.max(0,Math.floor(e));return t>Bj?`${Bj}+`:String(t)}const Tz="Pause the canvas";function Cz(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 — ${kd(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)":`${kd(e.held)} arrived while paused and will be applied in order when you resume (Space)`}function Az(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 D$="paused · full",Rz=(e,t)=>t>0?D$:e>0?`paused · ${Ez(e)}`:"paused";function Mz(e){const t=Math.max(0,Math.floor(e.dropped??0));return e.connected?e.paused?{tone:"paused",resting:!1,label:Rz(e.held,t),widest:D$,title:t>0?`Connected — the pause is full at ${kd(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up (Space)`:e.held>0?`Connected — ${kd(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"}}const $z=e=>e.transform[2]>=e.maxZoom,Iz=e=>e.transform[2]<=e.minZoom;function Oz({autoFitDisabled:e,enableAutoFitAndRefit:t,paused:n,pauseGate:r,togglePause:s,handleRelayout:o,requestClear:l,setKeyHelpOpen:c}){const d=ki(),h=Xe($z),f=Xe(Iz);return a.jsxs(JB,{showInteractive:!1,showFitView:!1,showZoom:!1,children:[a.jsx(Fn,{onClick:()=>{h||d.zoomIn()},title:"Zoom in","aria-label":"Zoom in","aria-disabled":h||void 0,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M12 5v14M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(Fn,{onClick:()=>{f||d.zoomOut()},title:"Zoom out","aria-label":"Zoom out","aria-disabled":f||void 0,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(Fn,{onClick:t,title:e?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view","data-nudge":e?"":void 0,children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),a.jsx(Fn,{"data-group-start":"",onClick:s,title:Cz({paused:n,held:r.size,dropped:r.dropped}),"aria-label":Tz,"aria-pressed":n,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M9 5.5v13M15 5.5v13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(Fn,{onClick:o,title:"Auto-arrange — clear pins (R)","aria-label":"Re-arrange the canvas",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("rect",{x:"8.5",y:"2",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("rect",{x:"1.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("rect",{x:"15.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("path",{d:"M12 7v6.5M5 17v-3.5h14V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),a.jsx(Fn,{"data-group-start":"","data-danger":"",onClick:()=>l("button"),title:"Clear the canvas and the server's event log — asks first (C)","aria-label":"Clear the canvas",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("path",{d:"M4 6.2h16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),a.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"}),a.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"}),a.jsx("path",{d:"M10.3 10.6v6.8M13.7 10.6v6.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),a.jsx(Fn,{"data-group-start":"",onClick:()=>c(p=>!p),title:"Keyboard shortcuts (?)","aria-label":"Open the keyboard shortcuts","aria-haspopup":"dialog",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.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"}),a.jsx("path",{d:"M12 18.4v.2",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",fill:"none"})]})})]})}const Ha=148,qj=6e3,Lz=16e3,F$=46,na=34;function Pz(e,t,n=Ha){let r=-Math.round(t()*n);if(Math.abs(r-e)<na){const s=e-na>=-n?-na:na;r=Math.max(-n,Math.min(0,Math.round(e+s)))}return{to:r,ms:Math.round(Math.abs(r-e)*F$)}}function Dz(e){return Math.round(qj+e()*(Lz-qj))}const Uj=[{kind:"stroll",weight:44},{kind:"tidy",weight:17},{kind:"kick",weight:17},{kind:"sit",weight:12},{kind:"watch",weight:16},{kind:"leave",weight:7},{kind:"fish",weight:12},{kind:"skip",weight:10}];function Fz(e){const t=Uj.reduce((r,s)=>r+s.weight,0);let n=e()*t;for(const r of Uj)if(n-=r.weight,n<0)return r.kind;return"stroll"}const Bz=720,qz=260,Uz=620,zz=220,zj=520,B$=1600,Wj=7e3,Wz=15e3,Hj=6e3,Hz=14e3;function Bo(e,t,n=Ha){let r=-Math.round(t()*n);if(Math.abs(r-e)<na){const s=e-na>=-n?-na:na;r=Math.max(-n,Math.min(0,Math.round(e+s)))}return r}const Ct=(e,t)=>Math.round(Math.abs(t-e)*F$),Vz=120,Lu=0;function Gz(e,t){const n=r=>({kind:"litter",at:t,...r});return[{x:t,prop:n({}),act:"walk",ms:Ct(e,t)},{x:t,prop:n({}),act:"stoop",ms:Bz},{x:Lu,prop:n({held:!0}),act:"carry",ms:Ct(t,Lu)},{x:Lu,prop:n({held:!0}),act:"windup",ms:qz},{x:Lu,prop:n({held:!0,leaving:!0}),act:"toss",ms:Uz}]}function Kz(e,t){const n=t>e?1:-1,r=t-n*Math.min(15,Math.abs(t-e)),s=(o={})=>({kind:"ball",at:t,...o});return[{x:r,prop:s(),act:"walk",ms:Ct(e,r)},{x:r,prop:s(),act:"windup",ms:zz,facing:n>0?"right":"left"},{x:r,prop:s({leaving:!0}),act:"kick",ms:zj,facing:n>0?"right":"left"},{x:r,prop:s({leaving:!0}),act:"stand",ms:B$-zj}]}const q$=640;function Yz(e,t,n){const r=Math.max(-70,Math.min(-20,t)),s={x:r,prop:null,facing:"left"};return[{x:r,prop:null,act:"walk",ms:Ct(e,r)},{...s,act:"sit",ms:600},{...s,act:"cast",ms:900},{...s,act:"fish",ms:6e3+Math.round(n()*4e3)},{...s,act:"reel",ms:1200},{...s,act:"stow",ms:500},{...s,act:"stand",ms:400},{x:0,prop:null,act:"walk",ms:Ct(r,0)}]}function Xz(e,t,n){const r=Math.max(-110,Math.min(-30,t)),s={x:r,prop:null};return[{...s,act:"walk",ms:Ct(e,r)},{...s,act:"skip-ready",ms:500},{...s,act:"skip",ms:q$*(6+Math.floor(n()*5))},{...s,act:"skip-rest",ms:600},{...s,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:Ct(r,0)}]}function Zz(e,t,n){return[{x:t,prop:null,act:"walk",ms:Ct(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(Hj+n()*(Hz-Hj))},{x:t,prop:null,act:"stand",ms:400}]}function Jz(e,t,n){t=Math.max(-110,Math.min(0,t));const r=()=>({kind:"scope",at:t,held:!0});return[{x:t,prop:null,act:"walk",ms:Ct(e,t)},{x:t,prop:r(),act:"watch",ms:Math.round(Wj+n()*(Wz-Wj))},{x:t,prop:r(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function Mp(e,t,n){return e.facing?e.facing:e.act==="watch"||e.act==="scope-pack"?"left":e.x===t?n:e.x>t?"right":"left"}const Qz=1500,eW=e=>Math.round(1e3*Math.sqrt(2*e/Qz)),tW=115,nW=e=>Math.round(e/tW*1e3),rW=620,sW=200,aW=760,oW=600,iW=240;function lW(e,t,n){const s=-(t.ledgeSpan??Ha),o=eW(t.ledgeH),l=nW(t.ledgeH),c=n(),d=n(),h=-Math.round(c*t.floorSpan),f=-Math.round(d*t.floorSpan);return[{x:s,act:"walk",prop:null,ms:Ct(e,s)},{x:s,act:"peer",prop:null,ms:rW},{x:s,act:"fall",prop:null,ms:o,place:"floor"},{x:s,act:"land",prop:null,ms:sW,place:"floor"},{x:h,act:"walk",prop:null,ms:Ct(s,h),place:"floor",floorFrac:c},{x:f,act:"walk",prop:null,ms:Ct(h,f),place:"floor",floorFrac:d},{x:s,act:"walk",prop:null,ms:Ct(f,s),place:"floor"},{x:s,act:"lasso",prop:null,ms:aW,place:"floor"},{x:s,act:"rope-throw",prop:null,ms:oW,place:"floor"},{x:s,act:"rope-catch",prop:null,ms:iW,place:"floor"},{x:s,act:"climb",prop:null,ms:l},{x:s,act:"pull-up",prop:null,ms:480}]}function cW(e,t,n){const r=(n==null?void 0:n.ledgeSpan)??Ha;switch(Fz(t)){case"tidy":return Gz(e,Bo(e,t,r));case"kick":return Kz(e,Bo(e,t,r));case"sit":return Zz(e,Bo(e,t,r),t);case"watch":return Jz(e,Bo(e,t,r),t);case"fish":return Yz(e,Bo(e,t,r),t);case"skip":return Xz(e,Bo(e,t,r),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return lW(e,n,t)}}const o=Pz(e,t,r);return[{x:o.to,prop:null,act:"walk",ms:o.ms}]}const uW=420;function dW(e,t,n){const r=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(uW,Math.max(0,r))}const hW=260,fW=200;function pW(e,t,n){const r=(f,p=Ct(e,f))=>({x:f,prop:null,act:"walk",ms:p,place:"floor"});if(!n||n.height<=0)return[r(t)];const s=Math.min(e,t);if(Math.max(e,t)<=n.left||s>=n.right)return[r(t)];const l=t>e,c=l?n.left:n.right,d=l?n.right:n.left,h={place:"floor",riser:n.height,prop:null};return[r(c,Ct(e,c)),{...h,x:c,act:"mount",ms:hW},{...h,x:d,act:"walk",ms:Ct(c,d)},{x:d,prop:null,act:"dismount",ms:fW,place:"floor"},{x:t,prop:null,act:"walk",ms:Ct(d,t),place:"floor"}]}const U$=["bob","sway","groove"],Vj=9e3,mW=16e3,z$=1e3,gW=.08;function yW(e,t){const n=U$.filter(o=>o!==e),r=n[Math.min(n.length-1,Math.floor(t()*n.length))],s=(t()*2-1)*gW;return{dance:r,beatMs:Math.round(z$*(1+s))}}function wW(e){return Math.round(Vj+e()*(mW-Vj))}const W$=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],Gj=18,vW=W$.length,H$=new Set(["a","c","p"]);function rh(e=W$){const t=[];return e.forEach((n,r)=>{let s=0;for(;s<n.length;){const o=n[s];if(o==="."){s+=1;continue}let l=1;for(;s+l<n.length&&n[s+l]===o;)l+=1;t.push({x:s,y:r,w:l,cell:o}),s+=l}}),t}const xW=[".xx.","xxxx",".xx."],bW=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],kW=["...xx...............","..xaax..............",".xaallx.............","xaallllx............",".xllllllx...........","..xllllllx..........","...xllllllx.........","....xllllllxx.......",".....xllllxsxx..xx..","......xllxsssx.xllxx",".......xxssssxxxllxx","........xssssssxx...",".........xssssx.....","..........xxxx......","..........xax.......",".........xxxxx......","........xx.x.xx.....","........xl.x.lx.....",".......xl..x..lx....",".......xl..x..lx....","......xl...x...lx...","......xl...x...lx...",".....xl....x....lx..","....xxx...xxx...xxx."],$p={litter:xW,ball:bW,scope:kW},NW=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],jW=3,SW=-1,Dx=11,Kj=9,Fx="https://www.youtube-nocookie.com";function _W(e,t,n){const r=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${Fx}/embed/${n?encodeURIComponent(n):"live_stream"}?${r.toString()}`}function qo(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function EW(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const TW=[1,3],CW=[0,2],AW=[2,5,100,101,150];function RW(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!="object")return null;const{event:n,info:r}=t;if(n==="onReady")return{kind:"ready"};if(n==="onError"){const s=typeof r=="number"?r:Number(r==null?void 0:r.errorCode);return Number.isFinite(s)?{kind:"error",code:s}:null}if(n==="onStateChange"||n==="infoDelivery"){const s=typeof r=="number"?r:r==null?void 0:r.playerState;return typeof s!="number"||!Number.isFinite(s)?null:TW.includes(s)?{kind:"playing",playing:!0}:CW.includes(s)?{kind:"playing",playing:!1}:null}return null}const MW="modulepreload",$W=function(e){return"/"+e},Yj={},l0=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.map(f=>Promise.resolve(f).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));s=l(n.map(h=>{if(h=$W(h),h in Yj)return;Yj[h]=!0;const f=h.endsWith(".css"),p=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${p}`))return;const g=document.createElement("link");if(g.rel=f?"stylesheet":MW,f||(g.as="script"),g.crossOrigin="",g.href=h,d&&g.setAttribute("nonce",d),document.head.appendChild(g),f)return new Promise((v,N)=>{g.addEventListener("load",v),g.addEventListener("error",()=>N(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return s.then(l=>{for(const c of l||[])c.status==="rejected"&&o(c.reason);return t().catch(o)})},wl=new Set;let Xj="";function Zj(e){const t=new Date().toISOString().slice(0,10);if(t!==Xj&&(wl.clear(),Xj=t),!wl.has(e)){wl.add(e);try{const n=typeof navigator>"u"?void 0:navigator;(!n||typeof n.sendBeacon!="function"||!n.sendBeacon("/api/feature",JSON.stringify({name:e})))&&wl.delete(e)}catch{wl.delete(e)}}}const Jj=864e5,IW=6e4;function qt(e,t=!0){y.useEffect(()=>{if(!t)return;Zj(e);let n;const r=()=>{n=setTimeout(()=>{Zj(e),r()},Jj-Date.now()%Jj+IW)};return r(),()=>clearTimeout(n)},[e,t])}const OW={"claude-fm":null,"lofi-relax":null,"lofi-game":null,"lofi-vibe":null,"lofi-sleep":null,"radio-mix":"/api/live-radio-mix","best-of-nostalgia":"/api/best-of-nostalgia","good-life-radio":"/api/good-life-radio","cafe-music-bgm":"/api/cafe-music-bgm"};function LW({fetchImpl:e,volume:t,muted:n,source:r,playRequest:s,customStation:o,onAvailabilityChange:l}){const[c,d]=y.useState(null),[h,f]=y.useState(!1),[p,g]=y.useState(!1),[v,N]=y.useState(!1);qt("claude-fm",v);const k=y.useRef(s),x=y.useRef(null),j=y.useRef(null),b=y.useRef(null),_=y.useCallback(()=>{var F;(F=j.current)==null||F.destroy(),j.current=null;const L=x.current;L&&(L.pause(),L.removeAttribute("src"),L.load(),x.current=null)},[]),E=y.useCallback(L=>{var F,O;(O=(F=b.current)==null?void 0:F.contentWindow)==null||O.postMessage(L,Fx)},[]),R=y.useRef(t);R.current=t;const C=y.useRef(n);C.current=n;const A=y.useCallback((L,F,O)=>{_();const I=new Audio;I.preload="none",I.volume=R.current/100,I.muted=C.current,x.current=I,g(!0),N(!0);const B=()=>x.current===I,M=()=>{_(),g(!1),N(!1)},$=()=>{B()&&(M(),f(!0),l==null||l(O,!0))},P=G=>{if(B()){if(G instanceof DOMException&&G.name==="NotAllowedError"){M();return}$()}};I.addEventListener("playing",()=>{B()&&(N(!0),l==null||l(O,!1))}),I.addEventListener("ended",()=>{B()&&M()}),I.addEventListener("error",$,{once:!0}),F&&!I.canPlayType("application/vnd.apple.mpegurl")?l0(async()=>{const{default:G}=await import("./hls-BFpXDghs.js");return{default:G}},[]).then(({default:G})=>{if(!B())return;if(!G.isSupported()){$();return}const K=new G;j.current=K,K.on(G.Events.ERROR,(q,H)=>{H.fatal&&$()}),K.on(G.Events.MEDIA_ATTACHED,()=>K.loadSource(L)),K.on(G.Events.MANIFEST_PARSED,()=>{I.play().catch(P)}),K.attachMedia(I)},$):(I.src=L,I.play().catch(P))},[l,_]);return y.useEffect(()=>{p&&(E(qo("setVolume",[t])),E(qo(n?"mute":"unMute")),x.current&&(x.current.volume=t/100,x.current.muted=n))},[t,n,p,E]),y.useEffect(()=>{let L=!0;const F=e??fetch,O=k.current!==s;k.current=s,d(null),f(!1),g(O),N(O),_();const I=o&&Za(o.id)===r?Kb(o.url):null;if(I)return I.kind==="direct-audio"?(d({live:!0,channel:"",audio:I.url,hls:I.format==="hls"}),l==null||l(r,!1),O&&A(I.url,I.format==="hls",r),()=>{L=!1}):(F(`/api/fm-station?url=${encodeURIComponent(I.url)}`).then($=>$.ok?$.json():null).then($=>{L&&($!=null&&$.channel||$!=null&&$.video?(d({live:!0,channel:$.channel??"",video:$.video??void 0}),l==null||l(r,!1)):(f(!0),l==null||l(r,!0)))}).catch(()=>{L&&(f(!0),l==null||l(r,!0))}),()=>{L=!1});if(di(r))return f(!0),l==null||l(r,!0),()=>{L=!1};const B=r,M=OW[B];if(M)F(M).then($=>$.ok?$.json():null).then($=>{L&&($!=null&&$.video&&d({live:!0,channel:"",video:$.video}),l==null||l(r,!($!=null&&$.video)))}).catch(()=>{L&&(l==null||l(r,!0))});else if(B!=="claude-fm"){const $=B.replace("lofi-","");F(`/api/lofi-girl?station=${encodeURIComponent($)}`).then(P=>P.ok?P.json():null).then(P=>{L&&(P!=null&&P.video&&d({live:!0,channel:"",video:P.video}),l==null||l(r,!(P!=null&&P.video)))}).catch(()=>{L&&(l==null||l(r,!0))})}else F("/api/claude-fm").then($=>$.ok?$.json():null).then($=>{if(!L)return;const P=!!($!=null&&$.live&&($!=null&&$.channel));P&&d({live:!0,channel:$.channel}),l==null||l(r,!P)}).catch(()=>{L&&(l==null||l(r,!0))});return()=>{L=!1}},[o==null?void 0:o.id,o==null?void 0:o.url,e,l,s,r,A,_]),y.useEffect(()=>()=>_(),[_]),y.useEffect(()=>{if(!p)return;const L=F=>{var I;if(F.origin!==Fx||F.source!==((I=b.current)==null?void 0:I.contentWindow))return;const O=RW(F.data);if(O){if(O.kind==="ready"){E(qo("setVolume",[R.current])),E(qo(n?"mute":"unMute")),E(qo("playVideo"));return}if(O.kind==="playing"){N(O.playing);return}AW.includes(O.code)&&(g(!1),N(!1),f(!0),l==null||l(r,!0))}};return window.addEventListener("message",L),()=>window.removeEventListener("message",L)},[p,n,l,E,r]),{probe:c,dead:h,armed:p,playing:v,frame:b,say:E,press:()=>{if(!c)return;if(c.audio){if(p){_(),g(!1),N(!1);return}A(c.audio,c.hls===!0,r);return}if(!p){g(!0),N(!0);return}const L=!v;N(L),E(qo(L?"playVideo":"pauseVideo")),L||g(!1)}}}function Qj(e){let t=null,n=null,r=0,s=0,o=!1;const l=()=>{t!==null&&clearTimeout(t),t=null},c=()=>{o||e.hidden||!n||t!==null||(s=performance.now(),t=setTimeout(()=>{t=null;const h=n;n=null,h==null||h()},r))},d=()=>{e.hidden&&t!==null?(r=Math.max(0,r-(performance.now()-s)),l()):e.hidden||c()};return e.addEventListener("visibilitychange",d),{schedule(h,f){o||(l(),n=h,r=Math.max(0,f),c())},dispose(){o=!0,l(),n=null,e.removeEventListener("visibilitychange",d)}}}function PW(e,t,n){const[r,s]=y.useState(0),[o,l]=y.useState(0),[c,d]=y.useState(null),[h,f]=y.useState(null),[p,g]=y.useState({x:0,drop:0}),[v,N]=y.useState("ledge"),[k,x]=y.useState("left"),[j,b]=y.useState(0),_=y.useRef(null),[E,R]=y.useState(()=>document.hidden);y.useEffect(()=>{const I=new Set,B=()=>{var M;if(document.hidden){for(const $ of((M=_.current)==null?void 0:M.getAnimations({subtree:!0}))??[])if($.playState==="running"||$.pending){const P=$.currentTime;$.pause(),P!==null&&($.currentTime=P),I.add($)}}else{for(const $ of I)$.playState==="paused"&&$.play();I.clear()}R(document.hidden)};return B(),document.addEventListener("visibilitychange",B),()=>document.removeEventListener("visibilitychange",B)},[e,t]);const[C,A]=y.useState(null),[U,L]=y.useState(z$),[F,O]=y.useState(()=>{var I;return((I=window.matchMedia)==null?void 0:I.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});return y.useEffect(()=>{var M;const I=(M=window.matchMedia)==null?void 0:M.call(window,"(prefers-reduced-motion: reduce)");if(!I)return;const B=()=>O(I.matches);return B(),I.addEventListener("change",B),()=>I.removeEventListener("change",B)},[]),y.useEffect(()=>{var Y;if(!e||t||F)return;const I=Qj(document);let B=0;s(Z=>B=Z);let M=null,$=0,P=0;const G=Z=>{var ke,ae;const[ee,...ne]=Z;if(!ee){M=null,d(null),f(null),J();return}d(ee.act),f(ee.prop),N(ee.place??"ledge"),b(ee.riser??0);const se=B,pe=D(ee);if(ee.act==="kick"){const fe=(ae=(ke=_.current)==null?void 0:ke.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:ae.getBoundingClientRect();fe&&g({x:dW(fe.x,Mp(ee,se,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-fe.y+24)})}P=ee.act==="walk"?Math.max(Ct(se,pe),Vz):ee.ms,ee.act==="carry"&&(P=Ct(se,pe)),l(P),x(fe=>Mp({...ee,x:pe},se,fe)),s(pe),B=pe,M=ee,$=Date.now(),I.schedule(()=>G(ne),P)},K=()=>{const Z=_.current,ee=Z==null?void 0:Z.querySelector(".fm-sprite"),ne=Z==null?void 0:Z.parentElement;if(!Z||!ee||!ne)return null;const se=Z.getBoundingClientRect(),pe=ne.getBoundingClientRect(),ke=pe.right-se.right,ae=pe.width-ke*2-ee.offsetWidth;return ae>0?ae:null},q=()=>{const Z=_.current,ee=Z==null?void 0:Z.querySelector(".fm-walker"),ne=K();if(!Z||!ee||ne==null)return;const se=Z.getBoundingClientRect().bottom-ee.getBoundingClientRect().bottom;if(se>0)return{ledgeH:se,floorSpan:ne}},H=()=>{const Z=_.current,ee=document.querySelector(".autofit-chip");if(!Z||!ee)return null;const ne=Z.getBoundingClientRect(),se=ee.getBoundingClientRect();return se.width<=0||se.height<=0?null:{left:se.left-ne.right,right:se.right-ne.right,height:se.height}},D=Z=>{const ee=(Z.place??"ledge")==="floor",ne=ee?K()??Ha:Ha,se=ee&&Z.floorFrac!=null?-Math.round(Z.floorFrac*ne):Z.x;return Math.max(-ne,Math.min(0,se))},W=()=>{if(!M)return;const Z=D(M);Z!==B&&(l(Math.max(0,$+P-Date.now())),x(ee=>Mp({...M,x:Z},B,ee)),s(Z),B=Z)},J=()=>{I.schedule(()=>{const Z=cW(B,Math.random,q()),ee=Z.some(pe=>pe.place==="floor")?H():null;let ne=B;const se=Z.flatMap(pe=>{const ke=ne;if(ne=pe.x,!(pe.place==="floor"&&pe.act==="walk"))return[pe];const ae=pW(ke,pe.x,ee),fe=ae.length-1;return pe.floorFrac==null?ae:ae.map((me,he)=>he===fe?{...me,floorFrac:pe.floorFrac}:me)});G(se)},Dz(Math.random))},V=(Y=_.current)==null?void 0:Y.parentElement,X=typeof ResizeObserver>"u"?null:new ResizeObserver(W);return V&&X&&X.observe(V),J(),()=>{I.dispose(),X==null||X.disconnect(),N("ledge"),s(Z=>Math.max(-Ha,Math.min(0,Z))),l(0),d(null),f(null),b(0)}},[e,t,F]),y.useEffect(()=>{if(!n||F){A(null);return}const I=Qj(document),B=M=>{const $=yW(M,Math.random);A($.dance),L($.beatMs),I.schedule(()=>B($.dance),wW(Math.random))};return B(null),()=>I.dispose()},[n,F]),{scene:_,suspended:E,x:r,walkMs:o,act:c,prop:h,ballFlight:p,place:v,facing:k,riser:j,dance:C,beatMs:U}}const Ip={e:"fm-eye",s:"fm-shade",p:"fm-pad"},Nd=rh().filter(e=>!H$.has(e.cell)),DW=rh().filter(e=>H$.has(e.cell)),eS=Nd.filter(e=>e.cell==="e"),FW=rh(NW),BW=Nd.filter(e=>e.y<Dx&&e.cell!=="e").map(e=>{if(e.y!==8&&e.y!==9)return e;const t=Math.max(6,e.x);return{...e,x:t,w:Math.max(0,Math.min(12,e.x+e.w)-t)}}).filter(e=>e.w>0),qW={left:Nd.filter(e=>e.y>=Dx&&e.x<Kj),right:Nd.filter(e=>e.y>=Dx&&e.x>=Kj)},UW=y.memo(function({act:t,facing:n}){return a.jsxs("svg",{viewBox:`0 0 ${Gj} ${vW}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:DW.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:Ip[r.cell]},`g${r.y}-${r.x}`))})}),a.jsxs("g",{className:"fm-body",children:[eS.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:"var(--accent)"},`eye-bed-${r.x}`)),BW.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:Ip[r.cell]},`b${r.y}-${r.x}`)),a.jsxs("g",{className:"fm-arms",children:[a.jsx("rect",{x:4,y:8,width:2,height:2}),a.jsx("rect",{x:12,y:8,width:1,height:2}),a.jsx("rect",{x:13,y:8,width:1,height:2,className:"fm-shade"})]}),eS.map(r=>a.jsx("rect",{x:r.x-(r.x>=Gj/2?1:0)+(n==="right"?1:0),y:r.y,width:r.w,height:1,className:"fm-eye"},`eye-${r.x}`))]}),a.jsx("g",{className:"fm-hat",children:FW.map(r=>a.jsx("rect",{x:jW+r.x,y:SW+r.y,width:r.w,height:1,className:r.cell==="k"?"fm-hatband":void 0},`h${r.y}-${r.x}`))}),(t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up")&&a.jsxs("g",{className:"fm-grip",children:[a.jsx("path",{className:"fm-grip-left",d:"M5 9H4V4H7V3H9V5H6V9Z"}),a.jsx("path",{className:"fm-grip-right",d:"M12 9H14V6H11V5H9V7H12Z"})]}),(t==="land"||t==="dismount")&&a.jsxs("g",{className:"fm-crouch-legs",children:[a.jsx("path",{d:"M6 11H8V13H6Z"}),a.jsx("path",{d:"M10 11H12V13H10Z"})]}),["sit","cast","fish","reel","stow"].includes(t)&&a.jsxs("g",{className:"fm-seated-legs",children:[a.jsx("path",{className:"fm-seated-far",d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),a.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(r=>a.jsx("g",{className:"fm-leg","data-side":r,children:qW[r].map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:Ip[s.cell]},`${r}${s.y}-${s.x}`))},r))]})}),zW={"claude-fm":"Claude FM","lofi-relax":"Lofi Girl relax/study","lofi-game":"Lofi Girl chill/game","lofi-vibe":"Lofi Girl vibe/chill","lofi-sleep":"Lofi Girl sleep/chill","radio-mix":"Radio Mix Live","best-of-nostalgia":"Best of Nostalgia Live","good-life-radio":"The Good Life Radio Live","cafe-music-bgm":"Cafe Music BGM Live"};function WW(e,t){return t&&Za(t.id)===e?t.name:di(e)?"Custom FM":zW[e]}function Op(e,t){var r;const n=((r=e[0])==null?void 0:r.length)??0;return a.jsx("svg",{viewBox:`0 0 ${n} ${e.length}`,shapeRendering:"crispEdges","aria-hidden":!0,children:rh(e).map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,fill:s.cell==="s"?"var(--fm-prop-shadow, var(--bg))":s.cell==="l"?"var(--fm-prop-light, var(--text))":s.cell==="a"?"var(--accent)":void 0},`${t}${s.y}-${s.x}`))})}const tS={litter:Op($p.litter,"litter"),ball:Op($p.ball,"ball"),scope:Op($p.scope,"scope")};function HW(e){try{return new URL(e).host}catch{return"the station's server"}}const VW=y.memo(function({fetchImpl:t,volume:n,muted:r=!1,source:s="claude-fm",playRequest:o=0,customStation:l,onAvailabilityChange:c}){const{probe:d,dead:h,armed:f,playing:p,frame:g,say:v,press:N}=LW({fetchImpl:t,volume:n,muted:r,source:s,playRequest:o,customStation:l,onAvailabilityChange:c}),{scene:k,suspended:x,x:j,walkMs:b,act:_,prop:E,ballFlight:R,place:C,facing:A,riser:U,dance:L,beatMs:F}=PW(d,h,p);if(!d||h)return null;const O=WW(s,l),I=d.audio?HW(d.audio):"YouTube";return a.jsxs("div",{ref:k,className:"fm","data-suspended":x?"":void 0,"data-place":C,style:{"--fm-beat":`${F}ms`},children:[E&&!E.held&&a.jsx("div",{className:"fm-prop","data-prop":E.kind,"data-leaving":E.leaving?"":void 0,style:{"--fm-prop-x":`${E.at}px`,"--fm-roll-to":`${R.x}px`,"--fm-ball-drop":`${R.drop}px`,"--fm-ball-flight-ms":`${B$}ms`,"--fm-ball-turn":A==="right"?"1080deg":"-1080deg"},children:tS[E.kind]}),(_==="lasso"||_==="rope-throw"||_==="rope-catch"||_==="climb"||_==="pull-up")&&a.jsxs("div",{className:"fm-rope","data-act":_,style:{"--fm-rope-x":`${j}px`,"--fm-rope-ms":`${b}ms`},children:[a.jsx("div",{className:"fm-rope-line"}),a.jsxs("svg",{className:"fm-rope-hook",viewBox:"0 0 9 9",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("path",{d:"M4 8V3H3V1H1V3H0V5H2V4H3V6H5V4H6V5H8V3H7V1H5V3H4"}),a.jsx("rect",{className:"fm-rope-knot",x:"3",y:"6",width:"3",height:"2"})]})]}),a.jsxs("div",{className:"fm-walker","data-act":_??void 0,"data-place":C,"data-facing":A,style:{"--fm-x":`${j}px`,"--fm-walk-ms":`${b}ms`,"--fm-riser":`${U}px`,"--fm-skip-beat":`${q$}ms`},children:[(E==null?void 0:E.held)&&a.jsx("div",{className:"fm-held","data-prop":E.kind,"data-toss":E.leaving?"":void 0,children:tS[E.kind]}),["cast","fish","reel","stow"].includes(_)&&a.jsxs("svg",{className:"fm-fishing",viewBox:"0 0 24 32",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsxs("g",{children:[a.jsx("path",{d:"M24 11H22V9H20V7H18V5H16V3H13V2H8"}),a.jsx("rect",{className:"fm-fishing-grip",x:"21",y:"9",width:"3",height:"3"})]}),a.jsxs("g",{className:"fm-fishing-line",children:[a.jsx("path",{d:"M8 2V26"}),a.jsxs("g",{className:"fm-float",children:[a.jsx("rect",{x:"7",y:"25",width:"3",height:"2"}),a.jsx("rect",{x:"8",y:"24",width:"1",height:"1"})]})]}),a.jsx("path",{className:"fm-ripple",d:"M3 28H6M10 28H14M5 30H12"})]}),["skip-ready","skip","skip-rest"].includes(_)&&a.jsxs("svg",{className:"fm-skipping-rope",viewBox:"0 0 26 26",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("path",{className:"fm-skip-back",d:"M5 18H3V8H5V5H8V2H18V5H21V8H23V18H21"}),a.jsx("path",{className:"fm-skip-forward",d:"M5 18H3V14H5V11H8V9H18V11H21V14H23V18H21"}),a.jsx("path",{className:"fm-skip-front",d:"M5 18H3V21H5V23H8V25H18V23H21V21H23V18H21"}),a.jsx("path",{className:"fm-skip-return",d:"M5 18H3V19H8V20H18V19H23V18H21"}),a.jsx("path",{className:"fm-skip-handles",d:"M5 17V19M21 17V19"})]}),a.jsx("button",{type:"button",className:"fm-sprite","data-playing":p?"":void 0,"data-dance":p?L??U$[0]:void 0,onClick:N,title:p?`Stop ${O}`:`Play ${O} — streams from ${I}`,"aria-label":p?`Stop ${O}`:`Play ${O}`,children:a.jsx(UW,{act:_,facing:A})})]}),f&&!d.audio&&(d.channel||d.video)&&a.jsx("iframe",{ref:g,className:"fm-frame",title:O,src:_W(d.channel,window.location.origin,d.video),onLoad:()=>v(EW()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})]})});function V$(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 jd(e){return V$(Math.floor(e/1e3))}function sh(e,t){const n=e-t;if(n<=0)return null;const r=Math.floor(n/86400),s=Math.floor(n%86400/3600),o=Math.floor(n%3600/60);return r>0?`${r}d ${s}h`:s>0?`${s}h ${o}m`:`${o}m`}function GW(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Sd(e,t,n){const r=new Date(e),s=jd(t-e);return{label:GW(r,new Date(t))?s:`${s} · ${r.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:r.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function KW({data:e}){const t=_i(3e4),n=Sd(e.recap.at,t);return a.jsxs("div",{className:"recap-note",role:"note","aria-label":"Claude Code's recap",style:{"--session-hue":e.hue},children:[a.jsxs("div",{className:"recap-note-head",children:[a.jsxs("span",{className:"recap-note-mark",children:[a.jsx(Vl,{}),"recap"]}),a.jsx("span",{className:"recap-note-age",title:n.title,children:n.label}),a.jsx("button",{type:"button",className:"glyph-btn recap-note-close","aria-label":"Hide the recap",title:"Hide — the ※ on the card brings it back",onClick:r=>{r.stopPropagation(),IU(e.noteKey)},children:"×"})]}),a.jsx("p",{className:"recap-note-text",children:e.recap.text}),a.jsxs("div",{className:"lod-face recap-face","aria-hidden":!0,children:[a.jsxs("div",{className:"lod-id",children:[a.jsxs("span",{className:"recap-note-mark",children:[a.jsx(Vl,{}),"recap"]}),a.jsx("span",{className:"recap-face-age",children:n.label})]}),a.jsx("p",{className:"recap-face-text",children:e.recap.text})]}),a.jsx(Xa,{type:"source",position:Ae.Right,style:{background:"transparent",border:"none"}})]})}function YW({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s,targetPosition:o,style:l}){const[c]=qb({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o,curvature:.35});return a.jsxs("g",{className:"recap-tie",style:l,children:[a.jsx("path",{className:"recap-tie-thread",d:c}),a.jsx("path",{className:"recap-tie-beads",d:c}),a.jsx("circle",{className:"recap-tie-end",cx:e,cy:t,r:3.5}),a.jsx("circle",{className:"recap-tie-end",cx:n,cy:r,r:3.5})]})}function Bx(e){return e.replace(/[^a-zA-Z0-9]/g,"")}function c0(e,t){const n=Bx(e);return n?n.slice(-t):e.slice(-t)}function G$(e,t,n=4){const r=Bx(e);if(!r)return c0(e,n);let s=n;for(const o of t){if(o===e)continue;const l=Bx(o);let c=0;for(;c<r.length&&c<l.length&&r[r.length-1-c]===l[l.length-1-c];)c++;s=Math.max(s,c+1)}return r.slice(-s)}const rd=" · ",XW=32,ZW=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function nS(e){return ZW.test(e)?2:1}function rS(e,t=XW){const n=[...e];let r=0;for(const l of n)r+=nS(l);if(r<=t)return e;const s=[];let o=0;for(const l of n){const c=nS(l);if(o+c>t-1)break;s.push(l),o+=c}for(;s.length&&/[\s\-_.:/]/.test(s[s.length-1]);)s.pop();return`${s.join("")}…`}function JW(e,t,n,r,s=[]){const o=(t==null?void 0:t.trim())??"",l=r?G$(n,s):void 0,c=[e,o||void 0,l].filter(Boolean);return{label:rS(e),name:o?rS(o):void 0,shortId:l,fullLabel:c.join(rd)}}const Ua=18,qx=26,K$=12,QW=240;function eH(e,t){return(e+QW)*(t||1)}function tH(e,t){return{position:"absolute",left:0,top:0,transform:`translate(${e.x}px, ${e.y}px)`,width:e.w,height:e.h,"--session-hue":t}}function nH(e,t,n){return{position:"absolute",left:e.x+16,top:e.y-K$/(t||1),transform:`scale(${1/(t||1)})`,transformOrigin:"left top",maxWidth:eH(e.w,t),"--session-hue":n}}function rH(e){const t=new Map;for(const s of e){if(s.type!=="agent"&&s.type!=="recapNote")continue;const o=s.data;if(!(o!=null&&o.sessionId)||o.exitAt!=null||s.width==null||s.height==null)continue;const l=s.position.x,c=s.position.y,d=l+s.width,h=c+s.height,f=t.get(o.sessionId),p=sH(o);f?(f.minX=Math.min(f.minX,l),f.minY=Math.min(f.minY,c),f.maxX=Math.max(f.maxX,d),f.maxY=Math.max(f.maxY,h),p&&(f.label=p.label??f.label,f.name=p.name,f.alarm=p.alarm,f.branch=p.branch)):t.set(o.sessionId,{minX:l,minY:c,maxX:d,maxY:h,label:(p==null?void 0:p.label)??o.sessionId,name:p==null?void 0:p.name,alarm:(p==null?void 0:p.alarm)??!1,branch:p==null?void 0:p.branch})}const n=new Map;for(const[s,o]of t){const l=n.get(o.label);l?l.push(s):n.set(o.label,[s])}const r=[];for(const[s,o]of t){const l=n.get(o.label)??[],c=l.length>1;r.push({sessionId:s,...JW(o.label,o.name,s,c,l),x:o.minX-Ua,y:o.minY-Ua-qx,w:o.maxX-o.minX+Ua*2,h:o.maxY-o.minY+Ua*2+qx,...o.alarm?{alarm:!0}:null,...o.branch?{branch:o.branch}:null})}return r}function sH(e){if(e.kind!=="root")return null;const t=e.branch;return{label:e.label,name:n0(e.sessionName,e.sessionTitle).face,alarm:Sn(e.waiting),branch:t&&t.total>0?R$(t):void 0}}function aH(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const r=e[n],s=t[n];if(r.sessionId!==s.sessionId||r.label!==s.label||r.name!==s.name||r.shortId!==s.shortId||r.alarm!==s.alarm||r.branch!==s.branch||r.fullLabel!==s.fullLabel||r.x!==s.x||r.y!==s.y||r.w!==s.w||r.h!==s.h)return!1}return!0}function oH(e){return rH(e.nodeInternals.values())}function iH({onFocusSession:e}){const{x:t,y:n,zoom:r}=D2(),s=Xe(oH,aH);if(s.length<=1)return null;const o=c=>{try{e==null||e(c)}catch{}},l={transform:`translate(${t}px, ${n}px) scale(${r})`};return a.jsx("div",{className:"session-clusters",style:l,children:s.map(c=>{const d=xd(c.sessionId),h=tH(c,d),f=nH(c,r,d);return a.jsxs(de.Fragment,{children:[a.jsx("div",{className:"cluster-card",style:h,"aria-hidden":!0}),a.jsxs("button",{type:"button",className:"cluster-label","data-alarm":c.alarm?"":void 0,style:f,title:`${c.alarm?`Waiting on you
80
- `:""}Zoom to ${c.fullLabel}
81
- drag the wrapper to move the whole session`,onClick:()=>o(c.sessionId),children:[c.alarm?a.jsxs(a.Fragment,{children:[a.jsx(i0,{}),a.jsx("span",{className:"cluster-label-said",children:"waiting on you: "})]}):null,c.label,c.branch?a.jsx("span",{className:"cluster-label-branch",children:rd+c.branch}):null,c.name?a.jsx("span",{className:"cluster-label-name",children:rd+c.name}):null,c.shortId?a.jsx("span",{className:"cluster-label-id",children:rd+c.shortId}):null]})]},c.sessionId)})})}function lH({data:e}){return a.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const Y$=600,cH=4,uH=36,Ux=16,dH=60,hH=6,sS=220,fH=96,pH=28;function mH(e,t){return Math.max(fH,61+[...t].length*6.8)}function gH(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function yH(e,t){if(t==null)return 1;const n=e-t;return n<0?1:Math.max(0,1-n/Y$)}function wH(e,t){const n=[],r=new Set;for(let s=e.length-1;s>=0&&n.length<t;s--){const o=e[s];r.has(o.id)||(r.add(o.id),n.push(o))}return n.reverse()}function vH(e,t,n,r,s,o){const l=[];for(const c of e.values()){if(!t.has(c.id)||c.exitAt!=null&&o-c.exitAt>Y$)continue;const d=r.get(c.id)??n.get(c.id);if(!d)continue;const h=wH(c.tools,cH);if(h.length===0)continue;const f=c.exitAt??null,p=s.get(c.id),g=Math.max((p==null?void 0:p.width)??sS,sS),v=(p==null?void 0:p.height)??130,N=d.x,k=d.y,x=N+g,j=k+v/2;h.forEach((b,_)=>{const E=_*uH,R=N+g+dH,C=k+hH+E,A=yH(o,f),U=b.inputPreview??"",L=gH(b),F=A<.999,O=o0(b.name);l.push({id:`${c.id}::${b.id}`,toolId:b.id,agentId:c.id,toolName:b.name,name:O.label,emoji:O.emoji,status:L,category:M$(b.name),mcpHue:O.hue,inputPreview:U,fade:A,fading:F,worldX:R,worldY:C,anchorX:x,anchorY:j,spawnDx:x-R,spawnDy:j-(C+Ux)});const I=L$(b.name,b.input);if(I){const B=mH(b.name,O.label),M=R+B+pH,$=C,P=R+B,G=C+Ux;l.push({id:`sub:${c.id}::${b.id}`,toolId:b.id,agentId:c.id,toolName:b.name,name:pz(I.label,I.category),fullName:I.label,emoji:I.emoji,isSub:!0,status:L,category:I.category,inputPreview:I.detail??U,fade:A,fading:F,worldX:M,worldY:$,anchorX:P,anchorY:G,spawnDx:P-M,spawnDy:0})}})}return l}function xH({agents:e,visibleAgentIds:t,positions:n,pinned:r,measured:s,spotlight:o,hiddenCategories:l,now:c,onOpenTool:d}){const h=vH(e,t,n,r,s,c),f=l&&l.size>0?h.filter(p=>!l.has(p.category)):h;return a.jsx(bH,{bursts:f,spotlight:o,onOpenTool:d})}function bH({bursts:e,spotlight:t,onOpenTool:n}){const r=e.map(o=>{const l=o.anchorX,c=o.anchorY,d=o.worldX+6,h=o.worldY+Ux,f=Math.max(1,d-l),p=Math.min(1,Math.abs(h-c)/f),g=l+f*(.55-.22*p),v=t!=null&&!t.has(o.agentId),N=o.fade*(v?.14:1);return a.jsx("path",{d:`M ${l} ${c} Q ${g} ${c}, ${d} ${h}`,className:`tool-conn status-${o.status}${o.fading?" fading":""}`,opacity:N,vectorEffect:"non-scaling-stroke"},`l:${o.id}`)}),s=e.map(o=>a.jsx(jH,{b:o,dim:t!=null&&!t.has(o.agentId),onOpenTool:n},o.id));return a.jsx(kH,{connectors:r,bubbles:s})}function kH({connectors:e,bubbles:t}){const{x:n,y:r,zoom:s}=D2();return a.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[a.jsx("svg",{className:"tool-bursts-svg",children:a.jsx("g",{transform:`translate(${n} ${r}) scale(${s})`,children:e})}),a.jsx("div",{className:"tool-bursts-world",style:{transform:`translate(${n}px, ${r}px) scale(${s})`},children:t})]})}function NH(e,t){const n=e.b,r=t.b;return e.dim===t.dim&&e.onOpenTool===t.onOpenTool&&n.id===r.id&&n.toolId===r.toolId&&n.worldX===r.worldX&&n.worldY===r.worldY&&n.spawnDx===r.spawnDx&&n.spawnDy===r.spawnDy&&n.status===r.status&&n.fading===r.fading&&n.category===r.category&&n.mcpHue===r.mcpHue&&n.isSub===r.isSub&&n.emoji===r.emoji&&n.name===r.name&&n.fullName===r.fullName&&n.toolName===r.toolName&&n.inputPreview===r.inputPreview}const jH=y.memo(function({b:t,dim:n,onOpenTool:r}){const s={left:`${t.worldX}px`,top:`${t.worldY}px`,"--spawn-dx":`${t.spawnDx}px`,"--spawn-dy":`${t.spawnDy}px`},o=t.isSub?`${t.toolName} · ${t.fullName??t.name}`:t.toolName,l=t.inputPreview?`${o} · ${t.inputPreview}`:o,c=r!=null,d=t.mcpHue!=null?{"--mcp-hue":t.mcpHue}:{},h=n?" dim":"";return a.jsx("div",{className:"tool-burst-wrap",style:s,children:a.jsxs("div",{className:`tool-burst cat-${t.category}${t.mcpHue!=null?" mcp-hue":""} status-${t.status}${t.fading?" fading":""}${c?" clickable":""}${t.isSub?" sub":""}${h}`,style:d,title:l,onClick:c?()=>r(t.agentId,t.toolId):void 0,children:[a.jsx("span",{className:"tb-emoji",children:t.emoji}),a.jsx("span",{className:"tb-name",children:t.name}),t.status==="inflight"&&a.jsx("span",{className:"tb-spin"}),t.status==="done"&&a.jsx("span",{className:"tb-mark done",children:"✓"}),t.status==="err"&&a.jsx("span",{className:"tb-mark err",children:"×"})]})})},NH),SH={agent:xz,sessionGroup:lH,recapNote:KW},_H={recapTie:YW},aS=400;function EH({graph:e,layout:t,viewport:n,clicks:r,drag:s,appearance:o,fm:l,autoFit:c,pause:d,stateRef:h,measuredRef:f,hiddenCats:p,now:g,openTool:v,focusAgent:N,requestClear:k,setKeyHelpOpen:x}){const{allNodes:j,edges:b,visibleAgentIds:_,spotlightSet:E}=e,{positionsRef:R,pinnedRef:C,handleRelayout:A}=t,{restoredViewport:U,onMoveStart:L,onMove:F}=n,{onNodeClick:O,onPaneClick:I,onNodeDoubleClick:B,onNodeMouseEnter:M,onNodeMouseLeave:$}=r,{onNodeDragStart:P,onNodeDrag:G,onNodeDragStop:K}=s,{palette:q,minimapNodeFill:H,characterEnabled:D}=o,{fmVolume:W,fmMuted:J,fmSource:V,fmPlayRequest:X,customFmStations:Y,markFmStationAvailability:Z}=l,{autoFitDisabled:ee,enableAutoFitAndRefit:ne}=c,{paused:se,pauseGate:pe,togglePause:ke}=d;return a.jsxs(P2,{nodes:j,edges:b,nodeTypes:SH,edgesFocusable:!1,edgeTypes:_H,fitView:!U,fitViewOptions:{padding:.25,duration:$x({durationMs:aS,documentHidden:document.hidden})?aS:0},minZoom:W2,maxZoom:H2,panOnScroll:!0,panActivationKeyCode:null,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,disableKeyboardA11y:!0,deleteKeyCode:null,onNodeClick:O,onPaneClick:I,onNodeDoubleClick:B,onNodeMouseEnter:M,onNodeMouseLeave:$,onMoveStart:L,onMove:F,onNodeDragStart:P,onNodeDrag:G,onNodeDragStop:K,children:[a.jsx(s8,{gap:28,size:1,color:q["--grid-line"]}),a.jsx(iH,{onFocusSession:N}),a.jsx(xH,{agents:h.current.agents,visibleAgentIds:_,positions:R.current,pinned:C.current,measured:f.current,spotlight:E,hiddenCategories:p,now:g,onOpenTool:v}),ee&&a.jsx(_z,{enableAutoFitAndRefit:ne}),a.jsx(Oz,{autoFitDisabled:ee,enableAutoFitAndRefit:ne,paused:se,pauseGate:pe,togglePause:ke,handleRelayout:A,requestClear:k,setKeyHelpOpen:x}),a.jsx(HB,{zoomable:!0,pannable:!0,nodeColor:H,nodeStrokeWidth:2,maskColor:q["--minimap-mask"],maskStrokeColor:q["--line"]}),D&&a.jsx(VW,{volume:W,muted:J,source:V,playRequest:X,customStation:Y.find(ae=>Za(ae.id)===V),onAvailabilityChange:Z})]})}function TH(e){const t={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};let n=0,r=0,s=0,o=0;for(const l of e){const c=pn(l);t.input+=c.input,t.output+=c.output,t.cacheRead+=c.cacheRead,t.cacheWrite+=c.cacheWrite,t.total+=c.total,n+=l.usage.inputTokens,r+=l.usage.outputTokens,s+=l.usage.cacheReadTokens,o+=l.usage.cacheCreateTokens}return{cost:t,inputTokens:n,outputTokens:r,cacheReadTokens:s,cacheCreateTokens:o,sum:n+r}}const CH="spend on this board",AH="on this board",oS=`Everything on the board right now, and only that.
82
- 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.
83
- Press H for the totals ccusage reads off the logs on disk, which do not forget.`,X$="session spend",zx="__unknown__",RH=12;function MH(e,t=Date.now()){const n=new Map;for(const r of e)for(const s of dc(r)){const o=s.model??zx,l=Xd(s.usage,s.model,t),c=n.get(o);c?(c.inputTokens+=s.usage.inputTokens,c.outputTokens+=s.usage.outputTokens,c.cacheReadTokens+=s.usage.cacheReadTokens,c.cacheCreateTokens+=s.usage.cacheCreateTokens,c.cost.total+=l.total,c.cost.input+=l.input,c.cost.output+=l.output,c.cost.cacheRead+=l.cacheRead,c.cost.cacheWrite+=l.cacheWrite,c.agentCount++):n.set(o,{model:o,inputTokens:s.usage.inputTokens,outputTokens:s.usage.outputTokens,cacheReadTokens:s.usage.cacheReadTokens,cacheCreateTokens:s.usage.cacheCreateTokens,cost:{...l},agentCount:1,priced:ca(s.model,t)!=null})}return Array.from(n.values()).sort((r,s)=>s.cost.total-r.cost.total||s.inputTokens+s.outputTokens-(r.inputTokens+r.outputTokens))}function $H(e,t=Date.now()){const n=[...e],r=[];for(const s of n){if(s.kind!=="root")continue;let o=pn(s,t).total,l=s.usage.inputTokens,c=s.usage.outputTokens,d=Hl(s,t);for(const h of n)h.sessionId!==s.sessionId||h.kind==="root"||(o+=pn(h,t).total,l+=h.usage.inputTokens,c+=h.usage.outputTokens,d+=Hl(h,t));r.push({sessionId:s.sessionId,label:s.label||s.cwdBasename||"session",state:s.state,cost:o,inputTokens:l,outputTokens:c,unpricedTokens:d})}return r.sort((s,o)=>o.cost-s.cost||o.inputTokens+o.outputTokens-(s.inputTokens+s.outputTokens)).slice(0,RH)}function IH(e){switch(e){case"needs":return"needs you";case"done":return"done";case"failed":return"failed";default:return"now"}}function OH(e){let t,n;switch(e.state){case"blocked":t="needs",n=e.needs||e.detail;break;case"done":t="done",n=e.result||e.detail;break;case"failed":t="failed",n=e.detail||e.result||"";break;case"working":t="now",n=e.detail;break;default:return null}if(!n)return null;const r={kind:t,text:n,at:e.updatedAt,source:"job"};return t==="needs"&&e.suggestedReply&&(r.reply=e.suggestedReply),r}function LH(e){if(e.kind!=="root"||e.closedAt!=null)return null;if(e.job){const n=OH(e.job);if(n)return n}const t=e.activity;if(!t||e.state!=="active")return null;for(const n of e.prompts)if(n.at>t.at)return null;return{kind:"now",text:t.text,at:t.at,source:"activity"}}function PH(e,t){return e&&t?t.at>e.at?{status:null,recap:t}:{status:e,recap:null}:{status:e,recap:t}}const DH=600;function ah(e,t){return!(e.exitAt!=null&&t-e.exitAt>DH||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function FH(e,t){const n=new Set;for(const r of e.agents.values())ah(r,t)&&n.add(r.id);return n}function BH(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 qH(e,t,n=0){if(!e)return!1;for(const r of t)if(BH(e,r,n))return!0;return!1}function iS(e){return e.waiting?Sn(e.waiting)?0:1:e.state==="active"?2:3}function UH(e,t){const n=[];for(const r of e.agents.values()){if(r.kind!=="root")continue;let s=r.toolCount,o=pn(r).total,l=r.endedAt??r.startedAt;for(const h of e.agents.values()){if(h.sessionId!==r.sessionId||h.kind==="root")continue;s+=h.toolCount,o+=pn(h).total;const f=h.endedAt??h.startedAt;f>l&&(l=f)}const{status:c,recap:d}=PH(LH(r),th(r));n.push({sessionId:r.sessionId,label:r.label||r.cwdBasename||"session",cwdBasename:r.cwdBasename,state:r.state,waiting:r.waiting,recap:d,status:c,modelId:r.model,toolCount:s,cost:o,startedAt:r.startedAt,lastActivity:l})}return n.sort((r,s)=>{const o=iS(r),l=iS(s);return o!==l?o-l:r.waiting&&s.waiting?r.waiting.since-s.waiting.since:s.lastActivity-r.lastActivity}),n}function zH(e){return[e.text,e.reply?`Suggested reply: ${e.reply}`:"",e.source==="job"?"Claude Code's own line for this background session":"From the session's newest reply"].filter(Boolean).join(`
84
- `)}function lS(e,t,n){const r=(t??n)-e;if(r<1e3)return"<1s";const s=Math.floor(r/1e3);if(s<60)return`${s}s`;const o=Math.floor(s/60);return o<60?`${o}m`:`${Math.floor(o/60)}h ${o%60}m`}function WH({state:e,now:t,selectedIds:n,onSelect:r,onClose:s,removedIds:o,onBringBackAll:l}){const c=y.useMemo(()=>UH(e),[e,e.revision,t]),d=c.filter(f=>f.state==="active").length,h=c.filter(f=>Sn(f.waiting)).length;return a.jsxs("aside",{className:"session-list",id:"session-list","aria-label":"Sessions",children:[a.jsxs("div",{className:"sl-header",children:[a.jsxs("h2",{children:["Sessions ",a.jsx("span",{className:"sl-count",children:c.length})]}),h>0&&a.jsxs("span",{className:"sl-waiting-count",children:[h," waiting"]}),d>0&&a.jsxs("span",{className:"sl-live-count",children:[d," live"]}),a.jsx("button",{className:"glyph-btn sl-close",onClick:s,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),a.jsxs("ul",{className:"sl-rows",children:[c.length===0&&a.jsx("li",{className:"sl-empty",children:"No sessions yet."}),c.map(f=>{var v;const p=n.has(f.sessionId),g=(o==null?void 0:o.has(f.sessionId))??!1;return a.jsx("li",{className:"sl-row-item",children:a.jsxs("button",{type:"button",className:`sl-row state-${f.state}${p?" selected":""}${g?" removed":""}`,"aria-current":p?"true":void 0,onClick:()=>r(f.sessionId),title:g?`Bring ${f.label} back to the board`:`Focus ${f.label}`,children:[a.jsx("span",{className:`sl-dot state-${f.state}`,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:fi(f.state)}),a.jsxs("div",{className:"sl-row-body",children:[a.jsxs("div",{className:"sl-row-head",children:[a.jsx("span",{className:"sl-label",children:f.label}),g&&a.jsx("span",{className:"sl-removed",children:"off the board"}),f.modelId&&a.jsx("span",{className:"model-chip","data-family":Jd(f.modelId),title:f.modelId,children:oa(f.modelId)})]}),a.jsxs("div",{className:"sl-row-meta",children:[a.jsxs("span",{title:"tool calls",children:[a.jsx("b",{children:f.toolCount})," ",f.toolCount===1?"tool":"tools"]}),f.cost>0&&a.jsx("span",{className:"sl-cost",title:X$,children:a.jsx("b",{children:qe(f.cost)})}),f.waiting?a.jsxs("span",{className:"sl-waiting",title:[pi(f.waiting),nU(f.waiting,pi(f.waiting)),`${Sn(f.waiting)?"Blocked":"Your turn"} since ${new Date(f.waiting.since).toLocaleTimeString()} · started ${new Date(f.startedAt).toLocaleString()}`].filter(Boolean).join(`
85
- `),children:[Sn(f.waiting)?"waiting":"your turn"," ",lS(f.waiting.since,void 0,t),f.waiting.tool&&a.jsxs("span",{className:"sl-waiting-tool",children:[" · ",f.waiting.tool.name]})]}):a.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(f.startedAt).toLocaleString()}`,children:lS(f.startedAt,f.state==="active"?void 0:f.lastActivity,t)})]}),f.recap&&a.jsxs("span",{className:"sl-recap",title:f.recap.text,children:[a.jsx(Vl,{}),f.recap.text]}),f.status&&a.jsxs("span",{className:`sl-status status-${f.status.kind}`,title:zH(f.status),children:[a.jsx("span",{className:"sl-status-tag",children:IH(f.status.kind)})," ",f.status.text]}),((v=f.status)==null?void 0:v.reply)&&a.jsxs("span",{className:"sl-status-reply",children:["suggested reply “",f.status.reply,"”"]})]})]})},f.sessionId)})]}),(()=>{let f=0;for(const p of o??[]){const g=e.agents.get(p);g&&ah(g,t)&&f++}return f===0||!l?null:a.jsx("div",{className:"sl-foot",children:a.jsxs("button",{type:"button",className:"btn sl-bring-back",onClick:p=>{const g=p.currentTarget.closest(".session-list");l(),requestAnimationFrame(()=>{var v;return(v=g==null?void 0:g.querySelector(".sl-row"))==null?void 0:v.focus()})},children:["Bring back ",f," removed ",f===1?"card":"cards"]})})})()]})}const Wx={cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,sessions:0};function HH(e){if(!e.synthetic)return!1;const t=e.usage;return t.inputTokens+t.outputTokens+t.cacheReadTokens+t.cacheCreateTokens<=0}function Hx(e,t){const n=new Map;for(const r of e){if(r.kind!=="root"||!r.sessionId||HH(r))continue;const s=pn(r,t);n.set(r.sessionId,{cost:s.total,inputTokens:r.usage.inputTokens,outputTokens:r.usage.outputTokens,cacheReadTokens:r.usage.cacheReadTokens,cacheCreateTokens:r.usage.cacheCreateTokens})}return n}function VH(e,t){if(!e)return Wx;const n={...Wx};for(const[r,s]of t){const o=e.get(r);if(!o)continue;const l={cost:s.cost-o.cost,inputTokens:s.inputTokens-o.inputTokens,outputTokens:s.outputTokens-o.outputTokens,cacheReadTokens:s.cacheReadTokens-o.cacheReadTokens,cacheCreateTokens:s.cacheCreateTokens-o.cacheCreateTokens};l.cost<0||l.inputTokens<0||l.outputTokens<0||l.cost===0&&l.inputTokens===0&&l.outputTokens===0&&l.cacheReadTokens===0&&l.cacheCreateTokens===0||(n.cost+=l.cost,n.inputTokens+=Math.max(0,l.inputTokens),n.outputTokens+=Math.max(0,l.outputTokens),n.cacheReadTokens+=Math.max(0,l.cacheReadTokens),n.cacheCreateTokens+=Math.max(0,l.cacheCreateTokens),n.sessions+=1)}return n}function Vx(e,t=new Date){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}const oh=[{key:"today",label:"today",noun:"today",hint:"Since midnight, on this machine's clock."},{key:"month",label:"month",noun:"this month",hint:"Since the 1st of this calendar month — not the last 30 days."},{key:"all",label:"all",noun:"all time",hint:"Every transcript on disk, back to 2020."}];function GH(e,t,n=oh.length){return n<=0?null:e==="ArrowRight"||e==="ArrowDown"?(t+1)%n:e==="ArrowLeft"||e==="ArrowUp"?(t-1+n)%n:e==="Home"?0:e==="End"?n-1:null}function Z$(e,t=new Date){return e==="today"?Vx(1,t):e==="month"?Vx(t.getDate(),t):"20200101"}const dn=e=>typeof e=="number"&&Number.isFinite(e)?e:0,sd=e=>typeof e=="string"?e:"";function J$(e){const t=Array.isArray(e==null?void 0:e.days)?e.days:[],n=new Map;for(const r of t){const s=Array.isArray(r==null?void 0:r.modelBreakdowns)?r.modelBreakdowns:[];for(const o of s){const l=sd(o==null?void 0:o.modelName);if(!l)continue;let c=n.get(l);c||(c={model:l,cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,get tokens(){return this.inputTokens+this.outputTokens+this.cacheReadTokens+this.cacheCreateTokens}},n.set(l,c)),c.cost+=dn(o==null?void 0:o.cost),c.inputTokens+=dn(o==null?void 0:o.inputTokens),c.outputTokens+=dn(o==null?void 0:o.outputTokens),c.cacheReadTokens+=dn(o==null?void 0:o.cacheReadTokens),c.cacheCreateTokens+=dn(o==null?void 0:o.cacheCreationTokens)}}return[...n.values()].sort((r,s)=>s.cost-r.cost||s.tokens-r.tokens)}const KH=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function YH(e){var t;return((t=KH.exec(e))==null?void 0:t[0])??e}function XH(e,t=new Map){const n=Array.isArray(e==null?void 0:e.sessions)?e.sessions:[],r=[];for(const s of n){const o=sd(s==null?void 0:s.period);if(!o)continue;const l=YH(o),c=s==null?void 0:s.metadata,d=typeof(c==null?void 0:c.lastActivity)=="string"?Date.parse(c.lastActivity):NaN;r.push({sessionId:l,label:t.get(l)??null,agent:sd(s==null?void 0:s.agent)||"claude",cost:dn(s==null?void 0:s.totalCost),tokens:dn(s==null?void 0:s.totalTokens),models:Array.isArray(s==null?void 0:s.modelsUsed)?s.modelsUsed.map(sd).filter(Boolean):[],lastActivityMs:Number.isFinite(d)?d:null})}return r.sort((s,o)=>o.cost-s.cost||o.tokens-s.tokens)}function ZH(e,t=ih(e).cost){const r=(Array.isArray(e==null?void 0:e.sessions)?e.sessions:[]).reduce((o,l)=>o+dn(l==null?void 0:l.totalCost),0),s=Math.max(.01,t*.01);return{sum:r,total:t,over:r>t+s}}function JH(e,t,n){const r=`Sessions with activity ${e}, and what ccusage puts against each one.`;return t.over?`${r}
86
- They add up to ${n(t.sum)}, more than the ${n(t.total)} above: what a session cost and what a day cost are two different measurements, and they need not agree.`:r}function ih(e){const t=e==null?void 0:e.totals;if(t&&typeof t=="object"){const d=dn(t.cacheReadTokens),h=dn(t.cacheCreationTokens),f=dn(t.inputTokens),p=dn(t.outputTokens);return{cost:dn(t.totalCost),inputTokens:f,outputTokens:p,cacheReadTokens:d,cacheCreateTokens:h,tokens:dn(t.totalTokens)||f+p+d+h}}const n=J$(e),r=d=>n.reduce((h,f)=>h+d(f),0),s=r(d=>d.inputTokens),o=r(d=>d.outputTokens),l=r(d=>d.cacheReadTokens),c=r(d=>d.cacheCreateTokens);return{cost:r(d=>d.cost),inputTokens:s,outputTokens:o,cacheReadTokens:l,cacheCreateTokens:c,tokens:s+o+l+c}}function QH(e,t){return{data:(e==null?void 0:e.data)??null,shown:(e==null?void 0:e.period)??null,stale:e!=null&&e.period!==t,baseline:(e==null?void 0:e.baseline)??null}}function Q$(e,t){var n;return((n=oh.find(r=>r.key===(e??t)))==null?void 0:n.noun)??"today"}function e7(e,t,n){const r=e!=null,s=ih(e);return{fromRange:r,cost:r?s.cost+n.cost:t.cost.total,inputTokens:r?s.inputTokens+n.inputTokens:t.inputTokens,outputTokens:r?s.outputTokens+n.outputTokens:t.outputTokens,cacheReadTokens:r?s.cacheReadTokens+n.cacheReadTokens:t.cacheReadTokens,cacheCreateTokens:r?s.cacheCreateTokens+n.cacheCreateTokens:t.cacheCreateTokens,hasCost:r?s.cost>0:t.cost.total>0,tokenSum:r?s.tokens:t.sum,showCostBar:!r}}const eI="agent-dag.usagePeriod";function t7(){const e=Qe(eI);return oh.some(t=>t.key===e)?e:"today"}function n7(e){Ze(eI,e)}const tI="agent-dag.usageSessionsOpen";function r7(){return Qe(tI)==="1"}function s7(e){Ze(tI,e?"1":"0")}function u0({cost:e,size:t="md"}){const n=e.total;if(n<=0)return null;const r=(o,l,c)=>{if(o<=0)return null;const d=o/n*100;return a.jsx("span",{className:`cb-seg ${l}`,style:{width:`${d}%`},title:`${c}: ${qe(o)} (${d.toFixed(0)}%)`},l)},s=t==="lg";return a.jsxs("div",{className:s?"cost-bar cost-bar-lg":"cost-bar",role:"img","aria-label":"Cost breakdown",children:[r(e.input,"cb-input","input"),r(e.output,"cb-output","output"),r(e.cacheRead,"cb-cache-r","cache read"),r(e.cacheWrite,"cb-cache-w","cache write")]})}const Pu="https://ccdeck.dev/guides",a7={localNetwork:{href:`${Pu}/local-network/#film`,subject:"Local network"},claudeAccounts:{href:`${Pu}/claude-accounts/#film`,subject:"Claude accounts"},usage:{href:`${Pu}/cost-and-quota/#film`,subject:"cost and quota"},tour:{href:`${Pu}/first-run/#film`,subject:"first run"}};function Gl({film:e}){const{href:t,subject:n}=a7[e];return a.jsxs("a",{className:"film-link",href:t,target:"_blank",rel:"noopener noreferrer",title:`The ${n} video on ccdeck.dev, 30 seconds — opens in your browser`,children:["Watch · 30 s",a.jsxs("span",{className:"vis-hidden",children:[": the ",n," video on ccdeck.dev, opens in your browser"]})]})}const kt="ccdeck",o7="/brand/ccdeck-mark-gradient-small-optical.svg",i7="/brand/ccdeck-mark-mono-dark-small-optical.svg";function nI(e,t){const n=t.nextExpiryAt!=null?` · expires ${new Date(t.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`:"";return`${t.availableCount} ${e}${t.availableCount!==1?"s":""} available${n}`}function l7({incidents:e}){return a.jsx(a.Fragment,{children:e.map(t=>a.jsxs("a",{className:t.stale?"provider-incident provider-incident-stale":"provider-incident","data-state":t.state,href:t.href,target:"_blank",rel:"noopener noreferrer",title:t.detail,children:[a.jsx("span",{className:"pi-dot","aria-hidden":!0}),a.jsx("span",{className:"pi-name",children:t.name}),a.jsxs("span",{className:"pi-words",children:["· ",t.chipWords]}),a.jsxs("span",{className:"pi-short",children:["· ",t.shortWords]}),t.asOf&&a.jsxs("span",{className:"pi-asof",children:["· as of ",t.asOf]}),a.jsx("span",{className:"pi-go","aria-hidden":!0,children:"↗"}),a.jsxs("span",{className:"vis-hidden",children:[", on ",t.host,", opens in a new tab"]})]},t.provider))})}function rI({incident:e}){return e?a.jsxs("a",{className:e.stale?"up-incident up-incident-stale":"up-incident","data-state":e.state,href:e.href,target:"_blank",rel:"noopener noreferrer",title:e.detail,children:[a.jsx("span",{className:"pi-dot","aria-hidden":!0}),a.jsxs("span",{className:"up-incident-words",children:[a.jsxs("span",{className:"vis-hidden",children:[e.name,": "]}),e.words[0].toUpperCase()+e.words.slice(1),e.asOf?` · as of ${e.asOf}`:""]}),a.jsx("span",{className:"up-incident-go","aria-hidden":!0,children:"↗"}),e.what&&a.jsx("span",{className:"up-incident-what",children:e.what}),a.jsxs("span",{className:"vis-hidden",children:[", on ",e.host,", opens in a new tab"]})]}):null}function c7(e,t,n,r,s=!1){const o=Math.max(0,t-r),l=Math.max(0,n-o);if(l<120)return null;const c=Math.min(100,l/n*100),d=e-c;if(s||e>=100)return{label:"used up",color:"var(--warn)",expectedPct:c,isDeficit:!0};if(Math.abs(d)<3)return{label:"on pace",color:"var(--ok)",expectedPct:c,isDeficit:!1};if(d>0){const h=100-e,f=l>0?e/l:0,p=f>0?h/f:1/0,g={label:`${Math.round(d)}% over pace`,color:"var(--warn)",expectedPct:c,isDeficit:!0};if(p<o&&p<86400){const v=Math.floor(p/3600),N=Math.floor(p%3600/60);g.runsOutIn=v>0?`${v}h ${N}m`:`${N}m`}return g}return{label:`${Math.round(-d)}% under pace`,color:"var(--ok)",expectedPct:c,isDeficit:!1}}function ta({pct:e,label:t,reset:n,resetAt:r,windowSec:s,limitReached:o,nowSec:l}){const c=!!r&&r<=l,d=e!=null&&!c,h=d?Math.min(100,Math.max(0,e)):0,p=o||h>=90?"var(--err)":h>=70?"var(--warn)":"var(--accent)",g=h<1,v=c?"reset":d?g?"< 1%":`${Math.round(h)}%`:"no reading",N=g?2:h,k=r&&!c?sh(r,l):null,x=d&&r&&s?c7(h,r,s,l,o):null,[j,b]=y.useState(!1),_=y.useId();return a.jsxs("div",{className:"qb-row",children:[a.jsxs("div",{className:"qb-meta",children:[a.jsxs("span",{className:"qb-label",children:[t,o&&!c&&a.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),a.jsx("span",{className:"qb-pct",style:{color:d?p:"var(--muted)"},children:v})]}),a.jsxs("div",{className:"qb-track",children:[d&&a.jsx("div",{className:"qb-fill",style:{transform:`scaleX(${N/100})`,background:p,opacity:g?.4:1}}),x&&a.jsx("div",{className:"qb-pace-rail",style:{transform:`translateX(${x.expectedPct}%)`},children:a.jsx("div",{"aria-hidden":!0,className:"qb-pace-marker",style:{background:x.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(x.expectedPct)}% by now`})})]}),a.jsxs("div",{className:"qb-reset-row",children:[c?a.jsx("span",{className:"qb-reset",children:"waiting for a new reading"}):k?a.jsxs("span",{className:"qb-reset",children:["resets in ",k]}):n?a.jsxs("span",{className:"qb-reset",children:["resets ",n]}):null,x&&a.jsxs("button",{type:"button",className:"qb-pace",style:{color:x.color},"aria-expanded":j,"aria-controls":j?_:void 0,onClick:()=>b(E=>!E),children:[a.jsx("i",{className:"qb-pace-key","aria-hidden":!0,style:{background:x.isDeficit?"var(--err)":"var(--ok)"}}),x.runsOutIn?`runs out in ${x.runsOutIn}`:x.label]})]}),j&&x&&a.jsxs("div",{id:_,className:"qb-why",children:["To last until reset, stay near ",Math.round(x.expectedPct),"% by now."]})]})}function sI(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 u7(e){return e==="claude-swap"?"Read from claude-swap's last collection — costs no request against your usage-endpoint budget. Saved limit resets, which it does not collect, are read separately: every 30 minutes, or 5 on refresh":e==="api"?"Fetched from Anthropic's usage endpoint, at most once every 5 minutes":e==="cli"?"Parsed from `claude /usage`, at most once every 5 minutes":"Last update"}function d7(e){switch(e){case"no_subscription":return"This install signs in with an API key (or Bedrock/Vertex), which is billed per token and has no session window.";case"rate_limited":return"Anthropic asked the deck to wait — it will retry on its own.";case"waiting":return"Waiting for the next allowed read — or click ↻.";default:return"Run /usage in a claude session, then click ↻"}}function h7(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.";case"rate_limited":return"OpenAI asked the deck to wait — it will retry on its own.";case"waiting":return"Waiting for the next allowed read — or click ↻.";default:return"ChatGPT API unreachable — click ↻ to retry."}}function f7({quota:e,quotaLoading:t,nowSec:n,incident:r}){const s=sI(e==null?void 0:e.fetchedAt,n);return a.jsxs("section",{className:"up-section up-quota-section",children:[a.jsxs("h3",{className:"up-section-title",children:["Claude quota",s&&!t&&a.jsxs("span",{className:"up-section-age",title:u7(e==null?void 0:e.source),children:[s,(e==null?void 0:e.stale)&&" · no newer reading"]})]}),a.jsx(rI,{incident:r}),e!=null&&e.ok?a.jsxs("div",{className:"up-quota-bars",children:[e.session5hPct!=null&&a.jsx(ta,{label:"5-hour window",pct:e.session5hPct,reset:e.session5hReset,resetAt:e.session5hResetAt,windowSec:e.session5hWindowSec,nowSec:n}),a.jsx(ta,{label:"7-day window",pct:e.week7dPct??null,reset:e.week7dReset,resetAt:e.week7dResetAt,windowSec:e.week7dWindowSec,nowSec:n}),e.weekSonnetPct!=null&&a.jsx(ta,{label:"Sonnet (7d)",pct:e.weekSonnetPct,nowSec:n}),e.weekOpusPct!=null&&a.jsx(ta,{label:"Opus (7d)",pct:e.weekOpusPct,nowSec:n}),e.extraEnabled&&e.extraUsedCredits!=null&&e.extraMonthlyLimit?a.jsx(ta,{label:`Extra credits (month${e.extraCurrency?`, ${e.extraCurrency}`:""})`,pct:Math.min(100,Math.round(e.extraUsedCredits/e.extraMonthlyLimit*100)),nowSec:n}):e.extraEnabled&&a.jsx("div",{className:"up-quota-sub up-credits",children:"extra usage credits: on"}),e.resetCredits&&e.resetCredits.availableCount>0&&a.jsx("div",{className:"up-quota-sub up-reset-credits",title:`Saved in Claude as "Reset for free". Redeem one in Claude on the web or desktop — ${kt} only reports them`,children:nI("limit reset",e.resetCredits)})]}):(e==null?void 0:e.ok)===!1?a.jsxs("div",{className:"up-quota-na",children:[a.jsx("span",{children:e.reason==="no_subscription"?"No quota to show.":"Quota unavailable."}),a.jsx("span",{className:"up-quota-hint",children:d7(e.reason)})]}):a.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]})}function p7({codexQuota:e,codexLoading:t,codexUsage:n,nowSec:r,incident:s}){var l,c;const o=sI(e==null?void 0:e.fetchedAt,r);return a.jsxs("section",{className:"up-section up-quota-section",children:[a.jsxs("h3",{className:"up-section-title",children:["Codex quota",(e==null?void 0:e.ok)&&e.planLabel&&a.jsx("span",{className:"up-plan-badge",children:e.planLabel}),o&&!t&&a.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:o})]}),a.jsx(rI,{incident:s}),e!=null&&e.ok?a.jsxs("div",{className:"up-quota-bars",children:[(l=e.windows)==null?void 0:l.map(d=>a.jsx(ta,{label:d.label,pct:d.pct,reset:d.reset??void 0,resetAt:d.resetAt??void 0,windowSec:d.windowSec??void 0,limitReached:e.limitReached&&d.pct>=100,nowSec:r},d.id)),(c=e.extraWindows)==null?void 0:c.map(d=>a.jsx(ta,{label:d.label,pct:d.pct,reset:d.reset??void 0,resetAt:d.resetAt??void 0,windowSec:d.windowSec??void 0,nowSec:r},d.id)),e.creditLimit&&a.jsx(ta,{label:`spend cap · $${Math.round(e.creditLimit.used)} of $${Math.round(e.creditLimit.limit)}`,pct:e.creditLimit.usedPct,reset:e.creditLimit.reset??void 0,resetAt:e.creditLimit.resetAt??void 0,limitReached:e.spendControlReached,nowSec:r}),e.creditsBalance&&!e.creditsUnlimited&&a.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",e.creditsBalance,e.overageReached&&" · overage limit reached"]}),e.creditsUnlimited&&a.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),e.resetCredits&&e.resetCredits.availableCount>0&&a.jsx("div",{className:"up-quota-sub up-reset-credits",title:`Redeem in the Codex CLI or ChatGPT — ${kt} only reports them`,children:nI("rate-limit reset",e.resetCredits)}),e.promo&&a.jsx("div",{className:"up-quota-sub",children:e.promo}),e.partial&&a.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(e==null?void 0:e.ok)===!1?a.jsxs("div",{className:"up-quota-na",children:[a.jsx("span",{children:"Quota unavailable."}),a.jsx("span",{className:"up-quota-hint",children:h7(e.reason)})]}):a.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"}),(n==null?void 0:n.ok)&&n.window7d&&n.window7d.sessionCount>0&&a.jsxs("div",{className:"up-quota-sub",title:`Counted from the rollout files under CODEX_HOME — no network, no account${n.window5h?`
87
- last 5h: ${it(n.window5h.totalTokens)} tokens · ${n.window5h.sessionCount} session${n.window5h.sessionCount!==1?"s":""}`:""}`,children:[it(n.window7d.totalTokens)," tokens · ",n.window7d.sessionCount," session",n.window7d.sessionCount!==1?"s":""," (7d)"]})]})}function m7({fromRange:e,rangeModelRows:t,boardModelRows:n}){return a.jsxs("section",{className:"up-section",children:[a.jsx("h3",{className:"up-section-title",children:"By model"}),a.jsxs("table",{className:"up-table",children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Model"}),a.jsx("th",{children:"Tokens"}),a.jsx("th",{children:"Cost"})]})}),a.jsx("tbody",{children:e?t.map(r=>a.jsxs("tr",{children:[a.jsx("td",{className:"up-model-name",title:r.model,children:oa(r.model)}),a.jsx("td",{className:"up-num",children:it(r.tokens)}),r.cost>0?a.jsx("td",{className:"up-num up-cost-val",children:qe(r.cost)}):a.jsx("td",{className:"up-num up-unpriced",children:ms})]},r.model)):n.map(r=>a.jsxs("tr",{children:[a.jsx("td",{className:"up-model-name",title:r.model===zx?"no model reported yet":r.model,children:r.model===zx?"unknown":oa(r.model)}),a.jsx("td",{className:"up-num",children:it(r.inputTokens+r.outputTokens)}),r.priced?a.jsx("td",{className:"up-num up-cost-val",children:qe(r.cost.total)}):a.jsx("td",{className:"up-num up-unpriced",children:ms})]},r.model))})]})]})}function g7({period:e,rangePending:t,setPeriod:n}){const r=y.useRef([]);return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"uh-range up-period",role:"toolbar","aria-orientation":"horizontal","aria-label":"Period","aria-busy":t||void 0,onKeyDown:s=>{var c;const o=r.current.indexOf(s.target);if(o<0)return;const l=GH(s.key,o);l!==null&&(s.preventDefault(),(c=r.current[l])==null||c.focus())},children:oh.map((s,o)=>a.jsx("button",{type:"button",ref:l=>{r.current[o]=l},tabIndex:e===s.key?0:-1,"aria-pressed":e===s.key,"data-pending":e===s.key&&t?"":void 0,title:e===s.key&&t?`Reading ${s.noun} from the transcripts on this machine…`:s.hint,className:"uh-range-btn",onClick:()=>n(s.key),children:s.label},s.key))}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:t?`Reading ${Q$(e,e)}…`:""})]})}function y7({fromRange:e,rangeSessionRows:t,boardSessionRows:n,boardStates:r,sessionsOpen:s,setSessionsOpen:o,periodNoun:l,sessionScale:c}){const d=e?t.length:n.length;return a.jsxs("section",{className:"up-section",children:[a.jsx("h3",{className:"up-section-title",children:a.jsxs("button",{type:"button",className:"up-disclose","aria-expanded":s,"aria-controls":"up-sessions",title:s?"Hide the per-session breakdown":`Show the per-session breakdown — ${d} session${d===1?"":"s"}`,onClick:()=>o(h=>!h),children:["By session",e&&a.jsxs("span",{className:"up-section-age",title:JH(l,c,qe),children:["active ",l]}),a.jsx("svg",{className:"up-chev",width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M2.2 3.6 5 6.4 7.8 3.6"})})]})}),a.jsxs("div",{className:"up-sessions",id:"up-sessions",hidden:!s,children:[e&&t.map(h=>{const f=r.get(h.sessionId);return a.jsxs("div",{className:"up-session-row",children:[f?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:`sl-dot state-${f}`,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:fi(f)})]}):a.jsx("span",{className:"sl-dot up-dot-past","aria-hidden":!0}),a.jsx("span",{className:`up-session-label${h.label?"":" up-session-id"}`,title:h.label?`${h.label}
88
- ${h.sessionId}`:h.sessionId,children:h.label??c0(h.sessionId,8)}),a.jsx("span",{className:"up-session-tokens",children:it(h.tokens)}),h.cost>0?a.jsx("span",{className:"up-session-cost",title:h.models.join(", ")||void 0,children:qe(h.cost)}):a.jsx("span",{className:"up-session-cost up-unpriced",children:ms})]},h.sessionId)}),!e&&n.map(h=>a.jsxs("div",{className:"up-session-row",children:[a.jsx("span",{className:`sl-dot state-${h.state}`,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:fi(h.state)}),a.jsx("span",{className:"up-session-label",children:h.label}),a.jsx("span",{className:"up-session-tokens",children:it(h.inputTokens+h.outputTokens)}),h.cost>0?a.jsxs("span",{className:"up-session-cost",title:h.unpricedTokens>0?`${it(h.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[qe(h.cost),h.unpricedTokens>0?"+":""]}):a.jsx("span",{className:"up-session-cost up-unpriced",children:ms})]},h.sessionId))]})]})}function ia(e,t){return{disabled:e!=null&&e!==t,busy:e===t}}function lh(e){return e==null}const Gx="self";function Dr(e,t=!1){const n=ia(e?Gx:null,Gx);return{disabled:t||n.disabled,"aria-busy":n.busy}}function lr(e){return lh(e?Gx:null)}const Kl=400;function Yl({armedFor:e,target:t,armedAt:n,now:r,gapMs:s}){return e!==t?"arm":r-n<s?"ignore":"fire"}function aI(e){return[...e==null?[]:[`#ap-more-${e}`],".accounts-panel .ap-refresh"]}function Tn(e){return e==null||e==="BODY"||e==="HTML"}const w7=6e4,v7=2e4;function x7(e){const[t,n]=y.useState(null),[r,s]=y.useState(!1),o=y.useRef(null),l=y.useRef(!1),c=async(h=!1)=>{if(!(h&&!lr(l.current))){h&&(l.current=!0,s(!0));try{const p=await fetch(h?"/api/quota?refresh=1":"/api/quota",{signal:AbortSignal.timeout(v7)});p.ok&&n(await p.json())}catch{}finally{h&&(l.current=!1,s(!1))}}};return y.useEffect(()=>{if(e)return c(!0),o.current=window.setInterval(()=>c(!1),w7),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{quota:t,loading:r,refresh:()=>{e&&c(!0)}}}const oI=6e4;function b7(e){const[t,n]=y.useState(null),[r,s]=y.useState(!1),o=y.useRef(null),l=y.useRef(!1),c=async(h=!1)=>{if(!(h&&!lr(l.current))){h&&(l.current=!0,s(!0));try{const p=await fetch(h?"/api/codex-quota?refresh=1":"/api/codex-quota");p.ok&&n(await p.json())}catch{}finally{h&&(l.current=!1,s(!1))}}};return y.useEffect(()=>{if(e)return c(!0),o.current=window.setInterval(()=>c(!1),oI),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{data:t,loading:r,refresh:()=>{e&&c(!0)}}}function k7(e){const[t,n]=y.useState(null),r=y.useRef(null),s=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return y.useEffect(()=>{if(e)return s(),r.current=window.setInterval(s,oI),()=>{r.current!=null&&window.clearInterval(r.current)}},[e]),{data:t}}const cS=6e4;function N7(e,t,n){const[r,s]=y.useState(null),[o,l]=y.useState(!1),[c,d]=y.useState(0),h=y.useRef(0);y.useEffect(()=>{const p=()=>document.visibilityState==="visible",g=()=>{p()&&d(k=>k+1)},v=window.setInterval(g,cS),N=()=>{p()&&Date.now()-h.current>=cS&&d(k=>k+1)};return document.addEventListener("visibilitychange",N),()=>{window.clearInterval(v),document.removeEventListener("visibilitychange",N)}},[]);const f=y.useRef(t);return y.useEffect(()=>{let p=!0;const g=t!==f.current;f.current=t;const v=e,N=Z$(v);return l(!0),fetch(`/api/ccusage?since=${N}${g?"&refresh=1":""}`).then(k=>k.ok?k.json():null).then(k=>{!p||!(k!=null&&k.ok)||(h.current=Date.now(),s({period:v,data:k,baseline:n()}))}).catch(()=>{}).finally(()=>{p&&l(!1)}),()=>{p=!1}},[e,t,c]),{...QH(r,e),loading:o}}const j7=e=>1-Math.pow(1-e,5),iI=420;function S7(e,t){if(!Number.isFinite(e)||!Number.isFinite(t)||e===t)return!1;const n=Math.abs(t-e);if(n<1)return!1;const r=Math.max(Math.abs(e),Math.abs(t));return r===0||n/r>=.005}function _7(e,t,n,r=iI){return n>=r?t:n<=0?e:e+(t-e)*j7(n/r)}function lI(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function uS(e,t,n,r={}){const s=r.now??(()=>performance.now()),o=r.raf??(v=>requestAnimationFrame(v)),l=r.cancel??(v=>cancelAnimationFrame(v)),c=r.reducedMotion??lI,d=r.hidden??(()=>typeof document=="object"&&document.hidden===!0);if(c()||d()||!S7(e,t))return n(t),()=>{};const h=s();let f=0,p=!0;const g=()=>{if(!p)return;const v=s()-h;n(_7(e,t,v)),v<iI&&(f=o(g))};return f=o(g),()=>{p=!1,f&&l(f)}}const E7=typeof window>"u"?y.useEffect:y.useLayoutEffect;function Da(e,{countIn:t=!1}={}){const[n,r]=y.useState(e),s=y.useRef(e),o=y.useRef(!0);return y.useEffect(()=>{s.current=n},[n]),E7(()=>{!t||lI()||(s.current=0,r(0))},[]),y.useEffect(()=>{if(o.current){if(o.current=!1,t)return uS(0,e,c=>{s.current=c,r(c)});s.current=e,r(e);return}return uS(s.current,e,c=>{s.current=c,r(c)})},[e]),n}function cI(e,t,n){const r=C7*Math.max(1,n/dI);let s=0;for(const[o,l]of t){const c=e.get(o);if(c===void 0)continue;const d=l.cost-c.cost;d>0&&d<=r&&(s+=d)}return s}const dS={samples:[],last:new Map,watched:0},uI=10*6e4,T7=6e4,dI=5e3,C7=20;function A7(e,t,n){const r=e.samples[e.samples.length-1];if(r&&t-r.t<dI)return e;const s=e.watched+cI(e.last,n,r?t-r.t:0),o=e.samples.filter(l=>t-l.t<=uI);return o.push({t,watched:s}),{samples:o,last:n,watched:s}}function R7(e,t,n){const r=e.samples[0];if(!r)return null;const s=t-r.t;if(s<T7)return null;const o=e.samples[e.samples.length-1].t,l=e.watched+cI(e.last,n,t-o)-r.watched;return l>0?{spent:l,spanSec:s/1e3,spanMin:Math.min(uI/6e4,Math.ceil(s/6e4))}:null}function M7(e,t,n){const r=y.useRef(dS),s=y.useRef(null);return y.useMemo(()=>{const o=MH(e.agents.values()),l=TH(e.agents.values());s.current!==n&&(s.current=n,r.current=dS);const c=Hx(e.agents.values(),t);n!=null&&(r.current=A7(r.current,t,c));const d=n==null?null:R7(r.current,t,c),h=d?{label:e0(d.spent,d.spanSec),spanMin:d.spanMin}:null;return{byModel:o,totalCost:l.cost,totalTokens:l,burnRate:h}},[e,e.revision,t,n])}const $7=3e4;function hI(){const[e,t]=y.useState(()=>Math.floor(Date.now()/1e3));return y.useEffect(()=>{const n=window.setInterval(()=>t(Math.floor(Date.now()/1e3)),$7);return()=>window.clearInterval(n)},[]),e}function hS(e){return(typeof e.cost=="number"?e.cost:e.cost.total)>0||e.inputTokens+e.outputTokens>0}function I7(e,t,n){return e?t.some(r=>r.cost<=0&&r.tokens>0):n.some(r=>!r.priced)}function O7(e){return e.claude&&e.codex?"Refresh Claude + Codex quota":e.codex?"Refresh Codex quota":"Refresh Claude quota"}function L7(e){const t=new Map;for(const n of e){if(n.kind!=="root"||!n.sessionId)continue;const r=n.label||n.cwdBasename;r&&t.set(n.sessionId,r)}return t}function P7(e){const t=new Map;for(const n of e)n.kind!=="root"||!n.sessionId||t.set(n.sessionId,n.state);return t}function D7(e){const t=new Map;for(const n of e){if(!n.label)continue;const r=t.get(n.label);r?r.push(n.sessionId):t.set(n.label,[n.sessionId])}return e.map(n=>{const r=n.label?t.get(n.label)??[]:[];return r.length>1?{...n,label:`${n.label} ${G$(n.sessionId,r)}`}:n})}function F7({state:e,now:t,providers:n,incidents:r=[],leaving:s,onClose:o,liveSince:l=null}){const{quota:c,loading:d,refresh:h}=x7(n.claude),{data:f,loading:p,refresh:g}=b7(n.codex),{data:v}=k7(n.codex),N=hI(),{byModel:k,totalCost:x,totalTokens:j,burnRate:b}=M7(e,t,l),_=y.useMemo(()=>$H(e.agents.values()),[e,e.revision]),[E,R]=y.useState(t7);y.useEffect(()=>{n7(E)},[E]);const[C,A]=y.useState(r7);y.useEffect(()=>{s7(C)},[C]);const[U,L]=y.useState(0),F=y.useRef(()=>new Map);F.current=()=>l==null?null:Hx(e.agents.values(),t);const O=y.useCallback(()=>F.current(),[]),{data:I,shown:B,stale:M,loading:$,baseline:P}=N7(E,U,O),G=I!=null,K=$&&M,q=y.useMemo(()=>L7(e.agents.values()),[e,e.revision]),H=y.useMemo(()=>P7(e.agents.values()),[e,e.revision]),D=y.useMemo(()=>G?J$(I):[],[I,G]),W=y.useMemo(()=>G?D7(XH(I,q).slice(0,12)):[],[I,G,q]),J=y.useMemo(()=>ih(I),[I]),V=y.useMemo(()=>ZH(I,J.cost),[I,J.cost]),X=Q$(B,E),Y=y.useMemo(()=>G?VH(P,Hx(e.agents.values(),t)):Wx,[e,e.revision,P,G,t]),Z=e7(I,{...j,cost:x},Y),ee=Z.hasCost,ne=Z.tokenSum,se=Da(Z.cost),pe=Da(Z.inputTokens),ke=Da(Z.outputTokens),ae=Da(Z.cacheReadTokens),fe=Da(Z.cacheCreateTokens),me=k.filter(hS),he=_.filter(hS),ge=I7(G,D,me),ue=d||p,be=()=>{h(),g(),L(je=>je+1)},oe=O7(n);return a.jsxs("aside",{className:`usage-panel${s?" leaving":""}`,id:"usage-panel","aria-label":"Usage",children:[a.jsxs("div",{className:"up-header",children:[a.jsx("h2",{children:"Usage"}),b&&a.jsxs("span",{className:"up-rate",title:`Spend on this board over the last ${b.spanMin} min`,children:[b.label,a.jsxs("span",{className:"up-rate-span",children:[" · ",b.spanMin," min"]})]}),a.jsxs("div",{className:"up-header-right",children:[(n.claude||n.codex)&&a.jsx("button",{type:"button",className:"glyph-btn up-refresh-btn",onClick:be,...Dr(ue),"aria-label":oe,title:oe,children:ue?"…":"↻"}),a.jsx("button",{type:"button",className:"glyph-btn up-close",onClick:o,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),n.claude&&a.jsx(f7,{quota:c,quotaLoading:d,nowSec:N,incident:r.find(je=>je.provider==="claude")}),n.codex&&a.jsx(p7,{codexQuota:f,codexLoading:p,codexUsage:v,nowSec:N,incident:r.find(je=>je.provider==="codex")}),G&&a.jsx(g7,{period:E,rangePending:K,setPeriod:R}),ne>0?a.jsxs(a.Fragment,{children:[ee&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"up-total",title:G?void 0:oS,children:[a.jsx("span",{className:"up-total-value",children:qe(se)}),a.jsx("span",{className:"up-total-label",children:G?X:CH})]}),Z.showCostBar&&a.jsx(u0,{cost:x})]}),a.jsxs("div",{className:"up-tokens-row",title:G?void 0:oS,children:[a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"in"}),it(pe)]}),a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"out"}),it(ke)]}),Z.cacheReadTokens>0&&a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"cache r"}),it(ae)]}),Z.cacheCreateTokens>0&&a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"cache c"}),it(fe)]}),!ee&&a.jsx("span",{className:"up-tok up-scope",children:AH})]}),(G?D.length:me.length)>0&&a.jsx(m7,{fromRange:G,rangeModelRows:D,boardModelRows:me}),G&&W.length===0&&J.tokens>0&&a.jsxs("section",{className:"up-section",children:[a.jsx("h3",{className:"up-section-title",children:"By session"}),a.jsxs("div",{className:"up-hint",children:["No session is dated ",X," yet — ccusage dates sessions in UTC, and the totals above are your local day."]})]}),(G?W.length:he.length)>0&&a.jsx(y7,{fromRange:G,rangeSessionRows:W,boardSessionRows:he,boardStates:H,sessionsOpen:C,setSessionsOpen:A,periodNoun:X,sessionScale:V}),ge&&a.jsxs("div",{className:"up-hint",children:["“",ms,"” means this build holds no published rate for that model — those tokens are counted above and their dollars are not."]})]}):a.jsx("div",{className:"up-empty",children:G?(B??E)==="all"?a.jsx(a.Fragment,{children:"No usage in any transcript on this machine."}):a.jsxs(a.Fragment,{children:["No usage ",X,".",a.jsx("br",{}),"Try a longer period."]}):a.jsxs(a.Fragment,{children:["No usage data yet.",a.jsx("br",{}),"Start a Claude Code or Codex session."]})}),a.jsx("div",{className:"film-foot",children:a.jsx(Gl,{film:"usage"})})]})}function Lp(e){return e<9.95?e.toFixed(1):String(Math.round(e))}function d0(e){const t=Number.isFinite(e)?Math.max(0,e):0;return t<50?{value:"0",unit:"KB/s"}:t<999500?{value:Lp(t/1e3),unit:"KB/s"}:t<9995e5?{value:Lp(t/1e6),unit:"MB/s"}:{value:Lp(t/1e9),unit:"GB/s"}}function ch(e){const t=Number.isFinite(e)?Math.max(0,e):0;return t<999.5?{value:String(Math.round(t)),unit:"ms"}:{value:(t/1e3).toFixed(1),unit:"s"}}function Xl(e){return e.unit?e.unit==="%"||e.unit==="°C"?`${e.value}${e.unit}`:`${e.value} ${e.unit}`:e.value}const B7="thermal:Throttling";function h0(e){const t="timeHeld"in e?e.timeHeld:100-e.speedLimit;return Math.max(0,Math.min(100,t))}function q7(e){var n,r,s,o;const t={};e.cpu!=null&&(t["cpu:all"]=e.cpu),(n=e.perCore)!=null&&n.length&&(t["cpu:busiest"]=Math.max(...e.perCore)),e.memory&&(t["mem:physical"]=e.memory.usedPct),e.swap&&e.swap.total>0&&(t["mem:swap"]=Math.round(e.swap.used/e.swap.total*1e3)/10),(r=e.loadavg)!=null&&r.length&&(t["load:1m"]=e.loadavg[0]);for(const l of((s=e.thermal)==null?void 0:s.celsius)??[])t[`thermal:${l.label}`]=l.celsius;return(o=e.thermal)!=null&&o.throttle&&(t[B7]=h0(e.thermal.throttle)),t}function $l(e,t){return t==="B/s"?Xl(d0(e)):t==="ms"?Xl(ch(e)):t==="C"?`${Math.round(e)}°`:t==="%"?`${Math.round(e)}%`:e.toFixed(2)}function Du(e,t){return t==="B/s"||t==="ms"||!Number.isInteger(e)?$l(e,t):t==="C"?`${e}°`:t==="%"?`${e}%`:`${e}`}function U7(e,t,n){return e>=n?"hot":e>=t?"warn":"calm"}function z7(e,t,n=Date.now()){const r=h0(e),s="timeHeld"in e;return{pct:r,value:`${r}%`,tone:r===0?"calm":r>=30?"hot":"warn",note:r>0?s?`CPU throttled ${r}% of the time to cool down`:`CPU held to ${100-r}% of full speed to cool down`:t?s?`at full speed · ${t.peak}% throttled ${fS(t.lastMs,n)}`:`at full speed · held to ${100-t.peak}% ${fS(t.lastMs,n)}`:"running at full speed, and never held back"}}function fS(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 r=Math.floor(n/60);return r===1?"an hour ago":`${r} hours ago`}function W7(e){const t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${n}h`:n>0?`${n}h ${r}m`:`${r}m`}function H7(e){var r,s;const t=(r=e.thermal)==null?void 0:r.throttle,n=t?h0(t):0;return t&&n>0?"timeHeld"in t?`throttled ${n}% of the time`:`throttled to ${100-n}% of full speed`:e.memory&&e.memory.usedPct>=90?`physical memory ${Math.round(e.memory.usedPct)}% full`:(s=e.network)!=null&&s.api&&e.network.api.ms==null?"the Claude API is not answering":null}function V7(e){return e.kind==="tailscale-exit"?e.node?`Tailscale exit node ${e.node}`:"a Tailscale exit node":e.kind==="tailscale"?"Tailscale":`${e.name?`${e.name} `:""}VPN${e.iface?` (${e.iface})`:""}`}const G7=3e3;function K7(){const[e,t]=y.useState(null),n=y.useRef(null);return y.useEffect(()=>{let r=!0;const s=async()=>{if(document.visibilityState!=="hidden")try{const d=await fetch("/api/system");if(!d.ok)return;const h=await d.json();r&&(h!=null&&h.ok)&&t(h)}catch{}},o=()=>{n.current==null&&(s(),n.current=window.setInterval(s,G7))},l=()=>{n.current!=null&&(window.clearInterval(n.current),n.current=null)},c=()=>{if(document.visibilityState==="hidden"){l();return}o(),s()};return o(),document.addEventListener("visibilitychange",c),()=>{r=!1,l(),document.removeEventListener("visibilitychange",c)}},[]),e}function Y7(e,t){return!e||e.key!==t?"none":e.dir==="asc"?"ascending":"descending"}function jl({col:e,label:t,note:n,sort:r,next:s,onSort:o,className:l}){const c=Y7(r,e);return a.jsx("th",{scope:"col","aria-sort":c,className:l,children:a.jsxs("button",{type:"button",className:"sd-sort",title:n?`Sort by ${t}
89
-
90
- ${n}`:`Sort by ${t}`,onClick:()=>o(s(r,e)),children:[t,a.jsx("span",{className:"sd-sort-dir","aria-hidden":!0,children:c==="none"?"":c==="ascending"?"↑":"↓"})]})})}function Pp(e,t){return t==="B/s"?d0(e):t==="ms"?ch(e):{value:String(e),unit:t==="C"?"°C":t}}const Et={l:30,r:6,t:6,b:2},Xs={l:0,r:0,t:2,b:1},uh=104,X7=64;function ir(e,t=100,n=uh,r=Et){const s=n-r.t-r.b;return r.t+s*(1-Math.max(0,Math.min(t,e))/t)}function fI(e,t){return t??[e[0].t,e[e.length-1].t]}function f0(e,[t,n],r,s=Et){const o=r-s.l-s.r,l=n-t;return s.l+(l>0?o*(e-t)/l:o/2)}function pI(e,t,n,r=100,s=uh,o=Et,l){if(!e.length)return"";const c=fI(e,l),d=p=>f0(p,c,t,o);let h="",f=null;for(const p of e){const g=f&&p.t-f.t<=n*2?"L":"M";h+=`${g}${d(p.t).toFixed(1)} ${ir(p.v,r,s,o).toFixed(1)}`,f=p}return h}function mI(e,t,n,r=100,s=uh,o=Et,l){if(e.length<2)return"";const c=s-o.b,d=fI(e,l),h=v=>f0(v,d,t,o);let f="",p=[];const g=()=>{if(p.length>=2){let v=`M${h(p[0].t).toFixed(1)} ${c}`;for(const N of p)v+=`L${h(N.t).toFixed(1)} ${ir(N.v,r,s,o).toFixed(1)}`;f+=`${v}L${h(p[p.length-1].t).toFixed(1)} ${c}Z`}p=[]};for(const v of e)p.length&&v.t-p[p.length-1].t>n*2&&g(),p.push(v);return g(),f}function Z7(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 gI(e,t,n){return n!=null&&e>=n?"hot":t!=null&&e>=t?"warn":""}function J7(e,t,n=r=>Fa(r)){const r=e.filter(l=>l.v>0);if(!e.length)return null;if(!r.length)return"never held back";const s=r.length*(t/6e4),o=r[r.length-1];return`held back for ${s===1?"1 minute":`${s} minutes`}, last at ${n(o.t)}`}function Fa(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function p0(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 r=Math.floor(n/60),s=n%60;return s?`${r}h ${s}m`:`${r}h`}function Q7({group:e,title:t,onClose:n}){const r=ut(n),s=gt(n),[o,l]=y.useState(null);y.useEffect(()=>{let p=!0;const g=async()=>{try{const N=await fetch(`/api/system/history?group=${e}`);if(!N.ok)return;const k=await N.json();p&&(k!=null&&k.ok)&&l(k)}catch{}};g();const v=window.setInterval(g,2e4);return()=>{p=!1,window.clearInterval(v)}},[e]);const c=(o==null?void 0:o.series)??[],[d,h,f]=y.useMemo(()=>{let p=1/0,g=0;for(const v of c)v.points.length&&(p=Math.min(p,v.points[0].t),g=Math.max(g,v.points[v.points.length-1].t));return Number.isFinite(p)?[Math.max(p,(o==null?void 0:o.sinceMs)??0),g,[p,g]]:[(o==null?void 0:o.sinceMs)??0,g,void 0]},[c,o==null?void 0:o.sinceMs]);return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal hist-modal",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"hist-modal-title",children:[a.jsxs("div",{className:"modal-head",children:[a.jsx("span",{className:"modal-title",id:"hist-modal-title",children:t}),o&&d>0&&a.jsxs("span",{className:"hist-since",children:["since ",Fa(d)," · ",p0(d,h||Date.now())]}),a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),a.jsx("div",{className:"hist-body",children:o==null?a.jsx("p",{className:"hist-empty",children:"Reading…"}):c.length===0?a.jsx("p",{className:"hist-empty",children:"Nothing has been measured yet."}):c.map(p=>a.jsx(e9,{series:p,stepMs:o.stepMs,domain:f},p.label))})]})}),document.body)}function e9({series:e,stepMs:t,domain:n}){const r=y.useRef(null),[s,o]=y.useState(560),[l,c]=y.useState(null);y.useEffect(()=>{const O=r.current;if(!O||typeof ResizeObserver>"u")return;const I=new ResizeObserver(([B])=>o(Math.max(160,B.contentRect.width)));return I.observe(O),()=>I.disconnect()},[]);const{points:d,unit:h,warnAt:f,critAt:p,label:g,top:v,restsAtZero:N,changes:k}=e,x=N?X7:uh,{now:j,peak:b}=Z7(d),_=j!=null?Pp(j,h):null,E=b!=null?Pp(b,h):null,R=g==="Throttling"?J7(d,t):null,C=l!=null?d[l]:null,[A,U]=n??(d.length?[d[0].t,d[d.length-1].t]:[0,0]),L=O=>f0(O,[A,U],s),F=O=>{if(d.length<2)return;const I=O.currentTarget.getBoundingClientRect(),B=(O.clientX-I.left-Et.l)/Math.max(1,I.width-Et.l-Et.r),M=A+(U-A)*Math.max(0,Math.min(1,B));let $=0;for(let P=1;P<d.length;P++)Math.abs(d[P].t-M)<Math.abs(d[$].t-M)&&($=P);c($)};return a.jsxs("section",{className:"hist-series","aria-label":`${g} history`,children:[a.jsxs("div",{className:"hist-head",children:[a.jsx("span",{className:"hist-label",children:g}),a.jsxs("span",{className:"hist-stats",children:[_&&a.jsxs(a.Fragment,{children:[a.jsx("b",{children:_.value}),a.jsxs("span",{children:[_.unit," now"]})]}),b!=null&&E&&a.jsxs(a.Fragment,{children:[a.jsx("b",{className:gI(b,f,p),children:E.value}),a.jsxs("span",{children:[E.unit," peak"]})]})]})]}),a.jsx("div",{className:"hist-plot",ref:r,children:a.jsxs("svg",{className:"hist-chart",width:"100%",height:x,viewBox:`0 0 ${s} ${x}`,preserveAspectRatio:"none",role:"img","aria-label":_==null||E==null?`${g}: nothing measured yet`:`${g}: ${Xl(_)} now, peak ${Xl(E)}, over ${p0(d[0].t,d[d.length-1].t)}`,onPointerMove:F,onPointerLeave:()=>c(null),children:[[["warn",f],["hot",p]].map(([O,I])=>I==null||I>v?null:a.jsxs("g",{children:[a.jsx("line",{className:`hist-rule ${O}`,x1:Et.l,x2:s-Et.r,y1:ir(I,v,x),y2:ir(I,v,x)}),a.jsx("text",{className:`hist-rule-tag ${O}`,x:2,y:ir(I,v,x)+3,children:I})]},O)),a.jsx("line",{className:"hist-floor",x1:Et.l,x2:s-Et.r,y1:x-Et.b,y2:x-Et.b}),(k??[]).filter(O=>O.from!=null&&d.length>1&&O.t>=A&&O.t<=U).map(O=>a.jsx("line",{className:"hist-mark",x1:L(O.t),x2:L(O.t),y1:Et.t,y2:x-Et.b},O.t)),a.jsx("path",{className:"hist-area",d:mI(d,s,t,v,x,Et,[A,U])}),a.jsx("path",{className:"hist-line",d:pI(d,s,t,v,x,Et,[A,U])}),d.length===1&&a.jsx("circle",{className:"hist-dot",cx:L(d[0].t),cy:ir(d[0].v,v,x),r:3}),C&&a.jsxs("g",{children:[a.jsx("line",{className:"hist-cross",x1:L(C.t),x2:L(C.t),y1:Et.t,y2:x-Et.b}),a.jsx("circle",{className:"hist-dot",cx:L(C.t),cy:ir(C.v,v,x),r:3})]})]})}),a.jsx("div",{className:"hist-axis",children:C?a.jsxs("span",{className:"hist-at",children:[Fa(C.t)," — ",(()=>{const O=Pp(C.v,h);return a.jsxs(a.Fragment,{children:[a.jsx("b",{children:O.value}),O.unit==="%"||O.unit==="°C"||!O.unit?O.unit:` ${O.unit}`]})})()]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{children:d.length?Fa(A):""}),a.jsx("span",{children:d.length?Fa(U):""})]})}),R&&a.jsx("div",{className:"hist-note",children:R}),k==null?void 0:k.slice(-3).map(O=>a.jsx("div",{className:"hist-note hist-route",children:O.from==null?`Since ${Fa(O.t)} — ${O.label}`:`${Fa(O.t)} — ${O.label.charAt(0).toUpperCase()+O.label.slice(1)}`},O.t))]})}const pS=["cores","memory","load","thermal"],Ia=116,Ir=24,t9=60,n9=6e4;function r9(e){return e.points.length?e.restsAtZero?e.points.some(t=>t.v>0):!0:!1}function s9(e){return e.unit==="C"?`${e.label} temp`:e.key==="mem:physical"?"Physical RAM":e.key==="mem:swap"?`${e.label} memory`:e.label}function a9(e,t=t9){return e.points.length<=t?e:{...e,points:e.points.slice(-t)}}function o9({sys:e}){const[t,n]=y.useState({});y.useEffect(()=>{let l=!0;const c=async()=>{const h=await Promise.all(pS.map(async f=>{try{const p=await fetch(`/api/system/history?group=${f}`);return p.ok?[f,await p.json()]:[f,null]}catch{return[f,null]}}));l&&n(f=>{const p={...f};for(const[g,v]of h)v!=null&&v.ok&&(p[g]=v);return p})};c();const d=setInterval(()=>void c(),n9);return()=>{l=!1,clearInterval(d)}},[]);const r=y.useMemo(()=>q7(e),[e]),s=y.useMemo(()=>pS.flatMap(l=>{const c=t[l];return c?c.series.filter(r9).map(d=>({series:a9(d),stepMs:c.stepMs})):[]}),[t]),o=y.useMemo(()=>{let l=1/0,c=-1/0;for(const{series:d}of s){const h=d.points;h.length&&(l=Math.min(l,h[0].t),c=Math.max(c,h[h.length-1].t))}return Number.isFinite(l)?p0(l,c):"less than a minute"},[s]);return Object.keys(r).length?a.jsx("div",{className:"pl-strip",role:"group","aria-label":`This machine, over the last ${o}`,children:s.map(({series:l,stepMs:c})=>a.jsx(i9,{series:l,stepMs:c,now:r[l.key],span:o},l.key))}):null}function i9({series:e,stepMs:t,now:n,span:r}){var v;const{points:s,top:o,unit:l,warnAt:c,critAt:d}=e,h=s9(e),f=n??((v=s[s.length-1])==null?void 0:v.v),p=f==null?"":gI(f,c,d),g=Math.max(...s.map(N=>N.v));return a.jsxs("div",{className:`pl-cell${p?` ${p}`:""}`,title:[`${h} · peak ${$l(g,l)} over the last ${r}`,c!=null?`over ${Du(c,l)} is uncomfortable`:"",d!=null?`over ${Du(d,l)} the machine acts`:""].filter(Boolean).join(" · "),children:[a.jsxs("div",{className:"pl-cell-head",children:[a.jsx("span",{className:"pl-cell-label",children:h}),a.jsx("span",{className:"pl-cell-now",children:f==null?"—":$l(f,l)})]}),a.jsxs("svg",{className:"pl-spark",width:Ia,height:Ir,viewBox:`0 0 ${Ia} ${Ir}`,preserveAspectRatio:"none","aria-hidden":!0,children:[a.jsx("line",{className:"pl-spark-floor",x1:0,x2:Ia,y1:Ir-Xs.b,y2:Ir-Xs.b}),a.jsx("path",{className:"pl-spark-area",d:mI(s,Ia,t,o,Ir,Xs)}),c!=null&&a.jsx("line",{className:"pl-rule warn",x1:0,x2:Ia,y1:ir(c,o,Ir,Xs),y2:ir(c,o,Ir,Xs)}),d!=null&&a.jsx("line",{className:"pl-rule hot",x1:0,x2:Ia,y1:ir(d,o,Ir,Xs),y2:ir(d,o,Ir,Xs)}),a.jsx("path",{className:"pl-spark-line",d:pI(s,Ia,t,o,Ir,Xs)})]}),a.jsxs("span",{className:"vis-hidden",children:["peak ",$l(g,l)," over the last ",r,c!=null&&`, uncomfortable over ${Du(c,l)}`,d!=null&&`, the machine acts over ${Du(d,l)}`]})]})}const yI={key:"cpu",dir:"desc"};function l9(e,t){return e.key===t?{...e,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:t==="name"||t==="user"?"asc":"desc"}}function c9(e,t){const n=t.dir==="asc"?1:-1,r=o=>t.key==="cpu"?o.cpu:t.key==="mem"?o.mem:t.key==="rss"?o.rssBytes:t.key==="threads"?o.threads:o.uptimeSec,s=(o,l)=>{if(t.key==="name")return n*o.name.localeCompare(l.name,void 0,{sensitivity:"base"});if(t.key==="user"){const h=o.user??"",f=l.user??"";return!h||!f?h===f?0:h?-1:1:n*h.localeCompare(f,void 0,{sensitivity:"base"})}const c=r(o),d=r(l);return c==null||d==null?c==null?d==null?0:1:-1:n*(c-d)};return[...e].sort((o,l)=>s(o,l)||(l.cpu??-1)-(o.cpu??-1)||l.mem-o.mem||o.pid-l.pid)}const u9=4e3;function d9(e,t){const n=t!=null&&t.ok&&Array.isArray(t.procs)?t.procs:[];return n.length?{procs:n,total:t.total??0}:e??{procs:[],total:0}}function h9(){const[e,t]=y.useState(null);return y.useEffect(()=>{let n=!0;const r=async()=>{if(document.visibilityState!=="hidden")try{const o=await fetch("/api/system/processes?detail=1");if(!o.ok)return;const l=await o.json();n&&t(c=>d9(c,l))}catch{}};r();const s=window.setInterval(r,u9);return()=>{n=!1,window.clearInterval(s)}},[]),e}function f9(e){return e==null||!Number.isFinite(e)||e<0?"—":e<60?`${Math.floor(e)}s`:e<3600?`${Math.floor(e/60)}m`:e<86400?`${Math.floor(e/3600)}h`:`${Math.floor(e/86400)}d`}function p9({sys:e,onClose:t}){qt("process-list");const n=ut(t),r=gt(t),[s,o]=y.useState(yI),l=h9();return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:a.jsx("div",{ref:n,className:"modal pl-modal",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"pl-modal-title",children:a.jsx(m9,{read:l,sort:s,onSort:o,sys:e,onClose:t})})}),document.body)}function m9({read:e,sort:t,onSort:n,sys:r,onClose:s}){const o=e?c9(e.procs,t):null;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"modal-head",children:[a.jsx("span",{className:"modal-title",id:"pl-modal-title",children:"Busiest processes"}),o!=null&&o.length>0&&a.jsxs("span",{className:"pl-count",children:[o.length," of ",e.total," running"]}),a.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),a.jsxs("div",{className:"pl-split",children:[a.jsx("div",{className:"pl-body",children:o==null?a.jsx("p",{className:"pl-empty",children:"Reading the process list…"}):o.length===0?a.jsx("p",{className:"pl-empty",children:"Could not read the process list — retrying."}):a.jsxs("table",{className:"sd-procs pl-table",children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx(Uo,{col:"cpu",label:"cpu",sort:t,onSort:n}),a.jsx(Uo,{col:"rss",label:"memory",note:"Resident set size, which is what ps and Task Manager report; macOS Activity Monitor shows a different figure.",sort:t,onSort:n}),a.jsx(Uo,{col:"threads",label:"threads",sort:t,onSort:n}),a.jsx(Uo,{col:"uptime",label:"up",sort:t,onSort:n}),a.jsx(Uo,{col:"user",label:"user",sort:t,onSort:n}),a.jsx("th",{scope:"col",className:"pl-pid-h",children:"pid"}),a.jsx(Uo,{col:"name",label:"process",note:"Command lines have anything secret-shaped removed, which is a filter and not a guarantee.",sort:t,onSort:n})]})}),a.jsx("tbody",{children:o.map(l=>a.jsxs("tr",{children:[a.jsx("td",{className:"sd-num",children:l.cpu==null?"—":l.cpu.toFixed(0)}),a.jsx("td",{className:"sd-num sd-dim",title:`${l.mem.toFixed(1)}% of installed memory`,children:ea(l.rssBytes)}),a.jsx("td",{className:"sd-num sd-dim",children:l.threads??"—"}),a.jsx("td",{className:"sd-num sd-dim",children:f9(l.uptimeSec)}),a.jsx("td",{className:"sd-dim pl-user",children:l.user??"—"}),a.jsx("td",{className:"sd-num sd-dim pl-pid",children:l.pid}),a.jsxs("td",{className:"pl-name",children:[l.name,l.cmd&&a.jsxs("span",{className:"pl-cmd",title:l.cmd,children:[" ",l.cmd]})]})]},l.pid))})]})}),a.jsx(o9,{sys:r})]})]})}function Uo(e){return a.jsx(jl,{...e,next:(t,n)=>l9(t??yI,n)})}function Kx({value:e,unit:t,cap:n}){return t?a.jsxs("span",{className:"sd-fig",children:[a.jsx("span",{className:"sd-fig-cap",children:n}),a.jsxs("span",{className:"sd-fig-read",children:[a.jsx("b",{children:e})," ",a.jsx("span",{className:"sd-fig-unit",children:t})]})]}):a.jsxs("span",{className:"sd-fig",children:[a.jsx("b",{children:e}),a.jsx("span",{className:"sd-fig-cap",children:n})]})}const g9=300;function Zl({group:e,title:t,action:n,label:r,value:s,hint:o,children:l}){const[c,d]=y.useState(!1),h=y.useRef(null),f=y.useRef(null),p=()=>{f.current!=null&&window.clearTimeout(f.current),f.current=null};y.useEffect(()=>p,[]);const g=v=>{var N;p(),!(v.detail>1||((N=window.getSelection())==null?void 0:N.isCollapsed)===!1)&&(f.current=window.setTimeout(()=>{var k,x;f.current=null,((k=window.getSelection())==null?void 0:k.isCollapsed)!==!1&&((x=h.current)==null||x.focus({preventScroll:!0}),d(!0))},g9))};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"sd-reading",onClick:g,children:[a.jsx("button",{ref:h,type:"button",className:"sd-open",onClick:v=>{v.stopPropagation(),p(),d(!0)},title:n,"aria-label":s==null?`${r}: show history`:`${r}: show history, now ${s}`,"aria-describedby":o?`sd-hint-${e}`:void 0,children:a.jsxs("span",{className:"sd-h","aria-hidden":!0,children:[r," ",a.jsx("i",{className:"sd-row-more",children:"›"}),s!=null&&a.jsx("span",{className:"sd-h-val",children:s})]})}),l]}),o&&a.jsx("span",{id:`sd-hint-${e}`,className:"vis-hidden",children:o}),c&&a.jsx(Q7,{group:e,title:t,onClose:()=>d(!1)})]})}function _d({label:e,value:t,pct:n,tone:r="calm",note:s,mark:o,title:l,trackLabel:c}){return a.jsxs("div",{className:"sd-row",title:l,children:[a.jsxs("div",{className:"sd-row-head",children:[a.jsx("span",{className:"sd-row-label",children:e}),a.jsx("span",{className:"sd-row-val",children:t})]}),a.jsxs("span",{className:"sd-track",role:c?"img":void 0,"aria-label":c,children:[a.jsx("span",{className:`sd-fill${r==="calm"?"":` ${r}`}`,style:{transform:`scaleX(${n<=0?0:Math.max(1,Math.min(100,n))/100})`}}),o!=null&&o>0&&o<100&&a.jsx("span",{className:"sd-mark",style:{left:`${o}%`},"aria-hidden":!0})]}),s&&a.jsx("div",{className:"sd-note",children:s})]})}function y9(e,t,n){if(n<=0||eh(e))return{kind:"pass"};const r=t>=0&&t<n?t:-1;switch(e.key){case"ArrowDown":return{kind:"focus",index:r===-1?0:(r+1)%n};case"ArrowUp":return{kind:"focus",index:r===-1?n-1:(r-1+n)%n};case"Home":return{kind:"focus",index:0};case"End":return{kind:"focus",index:n-1};default:return{kind:"pass"}}}const ra=4,Bn=8;function m0(e,t,n){const r=n.width-Bn-(e.right+ra),s=e.left-ra-Bn,o=t.width<=r||r>=s?"right":"left",l=o==="right"?e.right+ra:e.left-ra-t.width,c=n.height-Bn*2,d=t.height<=c,h=d?t.height:Math.max(0,c),f=Math.max(Bn,Math.min(e.top,n.height-Bn-h)),p=Math.max(Bn,Math.min(l,n.width-Bn-t.width));return{top:f,left:p,side:o,maxHeight:d?null:h}}function w9(e,t,n){const r=n.height-Bn-(e.bottom+ra),s=e.top-ra-Bn,o=t.height<=r||r>=s?"below":"above",l=o==="below"?r:s,c=t.height<=l,d=c?t.height:Math.max(0,l),h=o==="below"?e.bottom+ra:e.top-ra-d,f=Math.max(Bn,Math.min(e.right-t.width,n.width-Bn-t.width));return{top:Math.max(Bn,h),left:f,side:o,maxHeight:c?null:d}}function v9(e,t,n){return!(!e||t!=null&&t.contains(e)||n!=null&&n.contains(e))}function wI(e,t,n){const r=y.useRef(t);r.current=t;const s=y.useRef(n);s.current=n,y.useEffect(()=>{const o=l=>{v9(l.target,e.current,r.current())&&s.current()};return window.addEventListener("pointerdown",o,!0),()=>window.removeEventListener("pointerdown",o,!0)},[e])}const vI='[role="menuitem"]';function mS(e){return e?Array.from(e.querySelectorAll(vI)).filter(t=>!t.disabled):[]}function dh({anchorId:e,boundaryId:t,id:n,className:r,role:s,labelledBy:o,start:l="first",focusRef:c,fallbackFocus:d,onClose:h,children:f}){const p=y.useRef(h);p.current=h;const g=y.useRef(d);g.current=d;const v=ut(()=>{var b;(b=document.getElementById(e))==null||b.focus(),p.current()},{popover:!0,focusRef:c}),N=y.useCallback(()=>{var A,U,L;const b=v.current;if(!b)return;const _=document.getElementById(e);if(!_){p.current();return}if(_.getClientRects().length===0){b.contains(document.activeElement)&&((U=(A=g.current)==null?void 0:A.call(g))==null||U.focus()),p.current();return}const E=_.getBoundingClientRect(),R=t?(L=document.getElementById(t))==null?void 0:L.getBoundingClientRect():null;if(R&&(E.bottom<=R.top||E.top>=R.bottom)){b.contains(document.activeElement)&&_.focus({preventScroll:!0}),p.current();return}b.style.maxHeight="";const C=w9(E,{width:b.offsetWidth,height:b.offsetHeight},{width:window.innerWidth,height:window.innerHeight});b.style.top=`${C.top}px`,b.style.left=`${C.left}px`,b.style.maxHeight=C.maxHeight==null?"":`${C.maxHeight}px`,b.dataset.side=C.side},[e,t,v]);y.useLayoutEffect(()=>{N()}),y.useEffect(()=>{const b=_=>{var E;(E=v.current)!=null&&E.contains(_.target)||N()};return window.addEventListener("scroll",b,!0),window.addEventListener("resize",N),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",N)}},[N,v]),wI(v,()=>document.getElementById(e),h),y.useEffect(()=>{var _;if(s!=="menu")return;const b=mS(v.current);(_=l==="last"?b[b.length-1]:b[0])==null||_.focus()},[]);const k=b=>{var _;if(s==="menu"&&b.key==="Tab"){b.stopPropagation(),(_=document.getElementById(e))==null||_.focus(),b.shiftKey&&b.preventDefault(),p.current();return}if(s==="menu"){const E=mS(v.current),R=y9(b,E.indexOf(document.activeElement),E.length);R.kind==="focus"&&(b.preventDefault(),E[R.index].focus())}b.key.length===1&&b.stopPropagation()},x=b=>{b.target.closest("button, input, select, textarea, code")||b.preventDefault()},j=b=>{if(s!=="menu"||b.pointerType==="touch")return;const _=b.target.closest(vI);_&&!_.disabled&&document.activeElement!==_&&_.focus({preventScroll:!0})};return Lt.createPortal(a.jsx("div",{ref:v,id:n,className:`anchored-popover${r?` ${r}`:""}`,role:s,"aria-labelledby":o,onKeyDown:k,onMouseDown:x,onPointerMove:j,children:f}),document.body)}function x9({network:e}){const{down:t,up:n,api:r,route:s}=e,[o,l]=y.useState(!1),c=r&&r.ms!=null?ch(r.ms):null,d=t!=null&&n!=null;return a.jsxs("div",{className:"sd-section",role:"group","aria-label":"Network",children:[a.jsxs(Zl,{group:"network",title:"Network history",action:"Show network history",label:"Network",children:[(d||c)&&a.jsxs("div",{className:"sd-figs sd-figs-named",children:[d&&[["Download",t],["Upload",n]].map(([h,f])=>{const p=d0(f);return a.jsx(Kx,{value:p.value,unit:p.unit,cap:h},h)}),c&&a.jsx(Kx,{value:c.value,unit:c.unit,cap:"Claude API"})]}),!d&&a.jsx("div",{className:"sd-note",children:"measuring…"}),r&&r.ms==null&&a.jsx("div",{className:"sd-note sd-note-warn",children:"Can’t reach Claude"})]}),s&&a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:"sd-detail",id:"sd-conn","aria-expanded":o,"aria-haspopup":"dialog",onClick:()=>l(h=>!h),children:["Connection details",s.relay&&a.jsx("span",{className:"sd-route-relay",children:" · relayed"}),a.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),o&&a.jsx(b9,{route:s,api:r,onClose:()=>l(!1)})]})]})}function b9({route:e,api:t,onClose:n}){return a.jsxs(dh,{anchorId:"sd-conn",boundaryId:"system-panel",id:"sd-conn-pop",className:"sd-pop",role:"dialog",labelledBy:"sd-conn-title",onClose:n,children:[a.jsx("p",{className:"sd-pop-title",id:"sd-conn-title",children:"Connection"}),a.jsxs("dl",{className:"sd-pop-rows",children:[a.jsxs("div",{className:"sd-pop-row",children:[a.jsx("dt",{children:e.to==="claude"?"Traffic to Claude":"Internet traffic"}),a.jsxs("dd",{children:["through ",V7(e)]})]}),e.relay&&a.jsxs("div",{className:"sd-pop-row",children:[a.jsx("dt",{children:"Relay"}),a.jsxs("dd",{children:[a.jsx("span",{className:"sd-route-relay",children:e.relay})," — not a direct path, so every packet carries one more round trip than it has to"]})]}),t&&a.jsxs("div",{className:"sd-pop-row",children:[a.jsx("dt",{children:"Round trip"}),a.jsx("dd",{children:t.ms==null?`${t.host} did not answer`:`${Xl(ch(t.ms))} to open a connection to ${t.host}`})]}),a.jsxs("div",{className:"sd-pop-row",children:[a.jsx("dt",{children:"Throughput"}),a.jsx("dd",{children:"every interface on this machine, not this path alone"})]})]})]})}function gS({usageOpen:e,leaving:t,sub:n,flag:r,onClose:s,children:o}){return a.jsxs("aside",{className:`sysdetail${e?" shifted":""}${t?" leaving":""}`,id:"system-panel","aria-labelledby":"sd-title",children:[a.jsxs("div",{className:"sd-top",children:[a.jsxs("div",{className:"sd-head",children:[a.jsx("h2",{className:"sd-title",id:"sd-title",children:"This machine"}),n&&a.jsx("span",{className:"sd-sub",children:n}),a.jsx("button",{type:"button",className:"glyph-btn sd-close",onClick:s,"aria-label":"Close",title:"Close",children:"×"})]}),r&&a.jsx("p",{className:"sd-flag",children:r})]}),o]})}function k9({usageOpen:e,leaving:t,onClose:n}){const r=K7();if(!r||r.cpu==null||!r.memory)return a.jsx(gS,{usageOpen:e,leaving:t,onClose:n,children:a.jsx("div",{className:"sd-note",children:"reading this machine…"})});const{memory:s,swap:o,perCore:l,loadavg:c,cores:d,uptimeSec:h,platform:f,thermal:p,network:g,cpu:v}=r;return a.jsxs(gS,{usageOpen:e,leaving:t,sub:`up ${W7(h)} · ${d} cores`,flag:H7(r),onClose:n,children:[a.jsx(N9,{cpu:v,perCore:l,loadavg:c,cores:d}),a.jsx(j9,{memory:s,swap:o,platform:f}),g&&a.jsx(x9,{network:g}),a.jsx(S9,{thermal:p}),a.jsx(_9,{sys:r})]})}function N9({cpu:e,perCore:t,loadavg:n,cores:r}){const s=!!t&&t.length>0;return!s&&!n?null:a.jsxs("div",{className:"sd-section sd-cpu",role:"group","aria-label":"CPU",children:[s&&a.jsx(Zl,{group:"cores",title:"Core history",action:"Show core history",label:"CPU",value:e==null?null:`${Math.round(e)}%`,children:a.jsx("div",{className:"sd-cores",role:"img","aria-label":`${t.length} logical cores, busiest at ${Math.round(Math.max(...t))}%`,children:t.map((o,l)=>a.jsx("span",{className:"sd-core",title:`logical core ${l+1} · ${o}% busy`,children:a.jsx("span",{className:"sd-core-fill",style:{transform:`scaleY(${Math.max(2,o)/100})`}})},l))})}),n&&a.jsxs(Zl,{group:"load",title:"Load history",action:"Show load history",label:"Load average",hint:"the queue for the cores, counted in tasks rather than as a share of them",children:[a.jsx("div",{className:"sd-figs",title:"The queue for this machine's cores, averaged over one, five and fifteen minutes. A count of tasks, not a share of the CPU.",children:n.map((o,l)=>a.jsx(Kx,{value:o.toFixed(2),cap:["1m","5m","15m"][l]},l))}),n[0]>r&&a.jsx("div",{className:"sd-note",children:`${(n[0]/r).toFixed(1)}× more work queued than cores to run it`})]})]})}function j9({memory:e,swap:t,platform:n}){const r=e.total-e.available,s=n==="win32"?"Commit":"Swap",o=t&&t.total>0?t.used/t.total*100:0;return a.jsx("div",{className:"sd-section",role:"group","aria-label":"Memory",children:a.jsxs(Zl,{group:"memory",title:"Memory history",action:"Show memory history",label:"Memory",children:[a.jsx(_d,{label:"Physical",value:a.jsxs(a.Fragment,{children:[a.jsx("b",{children:ea(r)})," of ",ea(e.total)]}),pct:e.usedPct,tone:e.usedPct>=90?"warn":"calm",note:`${ea(e.available)} available`}),t&&t.total>0&&a.jsx(_d,{label:s,value:a.jsxs(a.Fragment,{children:[a.jsx("b",{children:ea(t.used)})," of ",ea(t.total)]}),pct:o,tone:o>=90?"warn":"calm"})]})})}function S9({thermal:e}){if(!e)return null;const t=e.throttle?z7(e.throttle,e.heldBack):null;return a.jsx("div",{className:"sd-section",role:"group","aria-label":"Thermal",children:a.jsxs(Zl,{group:"thermal",title:"Thermal history",action:"Show thermal history",label:"Thermal",children:[e.celsius.map(n=>a.jsx(_d,{label:n.label,value:a.jsxs(a.Fragment,{children:[a.jsx("b",{children:n.celsius})," °C"]}),pct:n.celsius/n.critAt*100,mark:n.warnAt/n.critAt*100,tone:U7(n.celsius,n.warnAt,n.critAt),title:`bar runs 0–${n.critAt} °C · amber from ${n.warnAt} °C, red at ${n.critAt} °C`,trackLabel:`${n.celsius} °C on a bar that runs to ${n.critAt} °C, amber from ${n.warnAt} °C`},n.label)),t&&a.jsx(_d,{label:"Throttling",value:a.jsx("b",{children:t.value}),pct:t.pct,tone:t.tone,note:t.note})]})})}function _9({sys:e}){const[t,n]=y.useState(!1);return a.jsxs("div",{className:"sd-section sd-door-section",children:[a.jsx("button",{type:"button",className:"sd-open sd-door",onClick:()=>n(!0),"aria-label":"Busiest processes: show every process the deck is watching",children:a.jsxs("span",{className:"sd-door-plate",children:[a.jsxs("span",{className:"sd-door-name",children:["Busiest processes",a.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),a.jsx("span",{className:"sd-door-sub",children:"every process, with its command line"})]})}),t&&a.jsx(p9,{sys:e,onClose:()=>n(!1)})]})}function g0(e){const t={inputTokens:e.i,outputTokens:e.o,cacheReadTokens:e.cr,cacheCreateTokens:e.cc,cacheCreate1hTokens:e.c1h,cacheCreate5mTokens:e.c5m},n=e.s?Object.entries(e.s):[];return n.length>0&&(t.bySpeed=Object.fromEntries(n.map(([r,s])=>[r,g0(s)]))),t}function yS(e){const t=r=>({...r,cacheCreate1hTokens:0,cacheCreate5mTokens:0}),n=t(g0(e));return n.bySpeed&&(n.bySpeed=Object.fromEntries(Object.entries(n.bySpeed).map(([r,s])=>[r,t(s)]))),n}function xI(e){return e.i+e.o+e.cr+e.cc}function bI(e,t){var n;e.i+=t.i,e.o+=t.o,e.cr+=t.cr,e.cc+=t.cc,e.c1h+=t.c1h,e.c5m+=t.c5m;for(const[r,s]of Object.entries(t.s??{}))bI((n=e.s??(e.s={}))[r]??(n[r]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),s);return e}function wS(e,t,n){let r=0,s=0,o=0;const l=[];for(const c of Zd(e)){if(!ca(t,n,c.speed)){const d=c.usage,h=d.inputTokens+d.outputTokens+d.cacheReadTokens+d.cacheCreateTokens;h>0&&(o+=h,l.push(c.speed));continue}r+=bd(c.usage,t,c.speed,n).total,s+=bd(c.usage,t,aa,n).total}return{atSpeed:r,atStandard:s,unpriced:o,unpricedSpeeds:l}}function vS(e){let t=0;for(const n of Object.values(e))t+=xI(n);return t}function E9(e){const t=s=>typeof s=="number"&&Number.isFinite(s)?s:0,n=new Map,r=e&&Array.isArray(e.days)?e.days:[];for(const s of r){const o=typeof s.period=="string"?s.period:"",l=Array.isArray(s.modelBreakdowns)?s.modelBreakdowns:[];for(const c of l){const d=typeof c.modelName=="string"?c.modelName:"";if(!o||!/claude/i.test(d)||c.missingPricing===!0)continue;const h=`${o}|${d}`,f=n.get(h),p=f?f.usage:{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,cacheCreate1hTokens:0,cacheCreate5mTokens:0};p.inputTokens+=t(c.inputTokens),p.outputTokens+=t(c.outputTokens),p.cacheReadTokens+=t(c.cacheReadTokens),p.cacheCreateTokens+=t(c.cacheCreationTokens),f?f.cost+=t(c.cost):n.set(h,{cost:t(c.cost),usage:p})}}return n}function T9(e,t,n,r=Date.now()){const s=new Map;for(const A of e){const U={},L=F=>{for(const[O,I]of Object.entries(F))bI(U[O]??(U[O]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),I)};for(const F of A.projects)L(F.models);A.unattributed&&L(A.unattributed);for(const[F,O]of Object.entries(U)){if(!O.s)continue;const{atSpeed:I,atStandard:B}=wS(yS(O),F,r);if(!(I>0&&B>0))continue;let M=s.get(A.day);M||(M=new Map,s.set(A.day,M)),M.set(F,I/B),M.has(cs(F))||M.set(cs(F),I/B)}}const o=(A,U)=>{const L=s.get(A);return(L==null?void 0:L.get(U))??(L==null?void 0:L.get(cs(U)))??1},l=new Map;let c=0,d=0;for(const[A,U]of n){const L=A.indexOf("|"),F=A.slice(0,L),O=A.slice(L+1),I=Xd(U.usage,O,r).total*o(F,O);if(!(I>0&&U.cost>0))continue;c+=U.cost,d+=I;let B=l.get(F);B||(B=new Map,l.set(F,B)),B.set(O,U.cost/I)}const h=d>0,f=(A,U)=>{const L=l.get(A);return(L==null?void 0:L.get(U))??(L==null?void 0:L.get(cs(U)))??null},p=new Set,g=(A,U)=>{let L=0,F=0;for(const[O,I]of Object.entries(A)){if(ca(O,r)){const M=U(O),$=wS(M===null?g0(I):yS(I),O,r);L+=M===null?$.atSpeed:$.atSpeed*M,F+=$.unpriced;for(const P of $.unpricedSpeeds)p.add(`${O} (${P})`);continue}const B=xI(I);B>0&&(F+=B,p.add(O))}return{cost:L,unpriced:F}},v=new Map,N=[];for(const A of e){const U=new Map,L=new Map;let F=0;for(const O of A.projects){const{cost:I,unpriced:B}=g(O.models,$=>f(A.day,$));U.set(O.path,(U.get(O.path)??0)+I),B>0&&L.set(O.path,(L.get(O.path)??0)+B),F+=I;let M=v.get(O.path);M||(M={path:O.path,cost:0,tokens:0,unpricedTokens:0},v.set(O.path,M)),M.cost+=I,M.tokens+=vS(O.models),M.unpricedTokens+=B}N.push({day:A.day,total:F,byPath:U,unpricedByPath:L})}const k=[...v.values()].sort((A,U)=>U.cost-A.cost||U.tokens-A.tokens),x=k.reduce((A,U)=>A+U.cost,0),j=k.reduce((A,U)=>A+U.tokens,0),b=k.reduce((A,U)=>A+U.unpricedTokens,0),_=h?c/d:null,E=t?vS(t):0,R=t?g(t,()=>_):{cost:0,unpriced:0},C=R.cost>0||E>0?{cost:R.cost,tokens:E,unpricedTokens:R.unpriced}:null;return{projects:k,totalCost:x,totalTokens:j,unpricedTokens:b,perDay:N,unattributed:C,unpricedModels:[...p].sort(),calibrated:h,reconciled:h&&b===0}}function Or(e,t,n=qe){return t>0?e>0?`${n(e)}+`:ms:n(e)}function zo(e){return e>0?`${it(e)} of these tokens are on an unpriced model, so this is a floor`:void 0}function C9(e){if(e.length===0)return null;const t=e.length===1,n=t?e[0]:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`;return t?`${n} is ${ms}: this build holds no published rate for it, so its tokens are counted and its dollars are not.`:`${n} are ${ms}: this build holds no published rate for them, so their tokens are counted and their dollars are not.`}const A9={phase:"running"},R9={phase:"failed"},M9={gen:0,report:null,error:null,early:null};function $9(e,t){var n,r;if(t.type!=="start"&&t.gen!==e.gen)return e;switch(t.type){case"start":return{...e,gen:t.gen,error:null,early:null};case"report":{const s=((n=e.early)==null?void 0:n.gen)===t.gen?e.early.cost:A9;return{...e,report:{gen:t.gen,days:t.days,data:t.data,cost:s},early:null}}case"reportFailed":return{...e,report:null,error:t.message,early:null};case"cost":return((r=e.report)==null?void 0:r.gen)===t.gen?{...e,report:{...e.report,cost:t.cost}}:{...e,early:{gen:t.gen,cost:t.cost}}}}function I9(e){var t;return((t=e.report)==null?void 0:t.gen)!==e.gen&&e.error===null}function O9(e){const t=e;return t&&t.ok!==!1?{phase:"ready",range:t}:R9}function L9(e){return`${e.getFullYear()}${String(e.getMonth()+1).padStart(2,"0")}${String(e.getDate()).padStart(2,"0")}`}function P9(e,t,n=Date.now()){const r=t===0?60:t,s=new Date(n),o=Vx(r,s),l=L9(s);return{report:`/api/account-projects?num=${e}&days=${t}`,ccusage:`/api/ccusage?since=${o}&until=${l}`}}function D9({num:e,days:t,gen:n,dispatch:r,get:s=(l,c)=>fetch(l,c),now:o=Date.now()}){const l=P9(e,t,o),c={credentials:"same-origin"};s(l.report,c).then(d=>d.ok?d.json():Promise.reject(new Error(`HTTP ${d.status}`))).then(d=>r({type:"report",gen:n,days:t,data:d}),d=>r({type:"reportFailed",gen:n,message:(d==null?void 0:d.message)||"Could not load"})),s(l.ccusage,c).then(d=>d.ok?d.json():null).catch(()=>null).then(d=>r({type:"cost",gen:n,cost:O9(d)}))}async function eo(e,t=500){var r;if(!e)return!1;let n=!1;try{n=await Promise.race([((r=navigator.clipboard)==null?void 0:r.writeText(e).then(()=>!0))??Promise.resolve(!1),new Promise(s=>window.setTimeout(()=>s(!1),t))])}catch{n=!1}if(n)return!0;try{const s=document.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(s),s.select(),n=document.execCommand("copy"),s.remove()}catch{n=!1}return n}function kI(e){return/^[A-Za-z]:[\\/]$/.test(e)?e:e.replace(/[\\/]+$/,"")}function Dp(e){const t=kI(e).replace(/\\/g,"/");return/^[A-Za-z]:\//.test(t)?t.toLowerCase():t}function xS(e){if(!e)return e;const t=kI(e),n=t.match(/^\/(?:Users|home)\/[^/]+(\/.*)?$/);if(n)return`~${n[1]??""}`;const r=t.replace(/\\/g,"/").match(/^[A-Za-z]:\/Users\/[^/]+(\/.*)?$/i);return r?`~${r[1]??""}`:t.replace(/\\/g,"/")}function F9(e,t){const n=Dp(e);let r;for(const s of t){const o=Dp(s.path);!o||o===n||!n.startsWith(`${o}/`)||(!r||Dp(r.path).length<o.length)&&(r=s)}return r==null?void 0:r.label}function Yx(e){return e===0?"all time":e===1?"today":`the last ${e} days`}function B9(e){return e===1?"No work attributed to this account yet today.":`No work attributed to this account in ${Yx(e)}.`}function q9(e){return e===1?7:e===7?30:e===30?0:null}function U9(e,t){return e!==1&&t>0}const z9=[{days:1,label:"Today"},{days:7,label:"7d"},{days:30,label:"30d"},{days:0,label:"All"}],Wo=["var(--usage-blue)","var(--usage-teal)","var(--usage-lime)","var(--usage-purple)","var(--usage-indigo)","var(--usage-pink)","var(--usage-orange)","var(--usage-zinc)"],W9="var(--usage-zinc)",Fp=6,H9=1600;function V9(e){const t=qe(e),n=/^\$(\d{4,})$/.exec(t);return n?`$${Number(n[1]).toLocaleString("en-US")}`:t}function Fu(e,t){if(t<=0||e<=0)return"0%";const n=e/t*100;return n<.01?"<0.01%":n<1?`${n.toFixed(2)}%`:n<10?`${n.toFixed(1)}%`:`${Math.round(n)}%`}function G9(e){const t=/^\d{4}-(\d{2})-(\d{2})$/.exec(e);return t?`${Number(t[1])}/${Number(t[2])}`:e}function K9(e){const t=Math.max(1,Math.ceil(e/6));return n=>n===0||n===e-1||n%t===0}function Bp(e){if(!e)return"";try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function Y9({num:e,name:t,onClose:n}){var P,G,K,q;qt("account-projects");const[r,s]=y.useState(1),[o,l]=y.useReducer($9,M9),c=((P=o.report)==null?void 0:P.data)??null,d=((G=o.report)==null?void 0:G.days)??r,h=((K=o.report)==null?void 0:K.cost.phase)==="ready"?o.report.cost.range:null,f=((q=o.report)==null?void 0:q.cost.phase)==="running",[p,g]=y.useState(null),[v,N]=y.useState(()=>new Set),k=I9(o),x=o.error,[j,b]=y.useState(null),_=y.useRef(void 0),E=y.useRef(!0);y.useEffect(()=>()=>{E.current=!1,window.clearTimeout(_.current)},[]);const R=y.useRef(null),C=ut(n,{focusRef:R}),A=gt(n),U=y.useRef(0);y.useEffect(()=>{const H=++U.current;l({type:"start",gen:H}),g(null),N(new Set),D9({num:e,days:r,gen:H,dispatch:l})},[e,r]);const L=y.useMemo(()=>{const H=Date.now();if(!c)return null;const D=T9(c.daily??[],c.unattributed,E9(h),H),W=be=>be.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||be||"(unknown)",J=new Map;for(const be of D.projects)J.set(W(be.path),(J.get(W(be.path))??0)+1);const V=be=>{const oe=W(be);if((J.get(oe)??0)<=1)return oe;const je=be.replace(/[\\/]+$/,"").split(/[\\/]/).slice(-2,-1)[0];return je?`${je}/${oe}`:oe},X=D.projects.map(be=>({path:be.path,label:V(be.path)})),Y=be=>({path:be.path,label:V(be.path),parentLabel:F9(be.path,X),cost:be.cost,tokens:be.tokens,unpricedTokens:be.unpricedTokens}),Z=Wo[Fp%Wo.length],ee=new Map,ne=[],se=D.projects.slice(0,Fp),pe=D.projects.slice(Fp);se.forEach((be,oe)=>{ee.set(be.path,Wo[oe%Wo.length]),ne.push({key:be.path,...Y(be),color:Wo[oe%Wo.length]})}),pe.length&&ne.push({key:"__other__",label:`Other · ${pe.length} project${pe.length>1?"s":""}`,cost:pe.reduce((be,oe)=>be+oe.cost,0),tokens:pe.reduce((be,oe)=>be+oe.tokens,0),unpricedTokens:pe.reduce((be,oe)=>be+oe.unpricedTokens,0),color:Z,muted:!0,members:pe.map(Y)});const ke=D.totalCost,ae=D.totalTokens,fe=ke>0&&D.unpricedTokens===0?"cost":"tokens",me=fe==="cost"?ke:ae,he=ne.map(be=>be.color),ge=D.perDay.map(be=>{const oe=new Map;for(const[Oe,Ue]of be.byPath){const Be=ee.get(Oe)??Z;oe.set(Be,(oe.get(Be)??0)+Ue)}const je=new Map;let $e=0;for(const[Oe,Ue]of be.unpricedByPath){const Be=ee.get(Oe)??Z;je.set(Be,(je.get(Be)??0)+Ue),$e+=Ue}return{day:be.day,total:be.total,costByColor:oe,unpricedByColor:je,unpriced:$e}}),ue=ge.reduce((be,oe)=>Math.max(be,oe.total),0);return{projectCount:D.projects.length,rows:ne,totalCost:ke,totalTokens:ae,basis:fe,denom:me,un:D.unattributed,chart:ge,maxDay:ue,colorOrder:he,unpricedTokens:D.unpricedTokens,unpricedNote:C9(D.unpricedModels),calibrated:D.calibrated,reconciled:D.reconciled}},[c,h]),F=(H,D)=>{eo(H).then(W=>{E.current&&(window.clearTimeout(_.current),b({path:H,label:D,ok:W}),_.current=window.setTimeout(()=>{E.current&&b(null)},H9))})},O=H=>j!=null&&j.ok&&j.path===H?"Copied":"Copy",I=c!=null&&c.trackedSince?`Tracked since ${Bp(c.trackedSince)}`:"Tracking starts with this version",B=Yx(d),M=q9(d),$=k&&!!c;return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...A,role:"presentation",children:a.jsxs("div",{ref:C,className:"modal ap-proj-modal",onClick:H=>H.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ap-proj-title ap-proj-sub",children:[a.jsxs("header",{className:"ap-proj-head",children:[a.jsxs("div",{className:"ap-proj-titlewrap",children:[a.jsx("div",{className:"ap-proj-title",id:"ap-proj-title",children:"Projects"}),a.jsx("div",{className:"ap-proj-sub",id:"ap-proj-sub",title:t,children:t})]}),a.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:z9.map(H=>a.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":r===H.days,onClick:()=>s(H.days),children:H.label},H.days))}),a.jsx("button",{ref:R,className:"glyph-btn ap-proj-close",onClick:n,"aria-label":"Close",children:"×"})]}),a.jsxs("div",{className:`ap-proj-body${$?" refreshing":""}`,"aria-busy":k,children:[k&&!c&&a.jsx("div",{className:"ap-proj-state",children:"Loading…"}),!k&&x&&a.jsxs("div",{className:"ap-proj-state ap-proj-error",children:["Couldn’t load this report: ",x]}),!x&&L&&a.jsx(a.Fragment,{children:L.rows.length===0?a.jsxs("div",{className:"ap-proj-state",children:[$?"Updating…":B9(d),M!=null&&a.jsx("div",{className:"ap-proj-widen-wrap",children:a.jsxs("button",{type:"button",className:"ap-proj-copy",onClick:()=>s(M),children:["Show ",Yx(M)]})}),a.jsxs("div",{className:"ap-proj-note",children:[I,". Only work from this version onward can be tied to an account."]})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"ap-proj-bar",role:"img","aria-label":`Share of ${L.basis==="cost"?qe(L.totalCost):`${it(L.totalTokens)} tokens`} across ${L.projectCount} project${L.projectCount>1?"s":""}`,children:L.rows.map(H=>{const D=L.basis==="cost"?H.cost:H.tokens,W=L.denom>0?D/L.denom*100:0;if(W<=0)return null;const J=L.basis==="cost"?Fu(H.cost,L.totalCost):`${Fu(H.tokens,L.totalTokens)} of tokens`;return a.jsx("span",{className:"ap-proj-seg",style:{width:`${W}%`,background:H.color},title:`${H.label} · ${Or(H.cost,H.unpricedTokens)} · ${J}${H.tokens?` · ${it(H.tokens)} tokens`:""}`},H.key)})}),a.jsxs("div",{className:"ap-proj-totals",children:[a.jsx("span",{className:"ap-proj-total-cost",title:zo(L.unpricedTokens),children:Or(L.totalCost,L.unpricedTokens)}),a.jsxs("span",{className:"ap-proj-total-tok",children:[it(L.totalTokens)," tokens"]}),a.jsxs("span",{className:"ap-proj-total-win",children:["· ",$?"updating…":B]}),f&&a.jsx("span",{className:"ap-proj-total-pending",children:"Reconciling cost…"})]}),L.unpricedNote&&a.jsx("div",{className:"ap-proj-note",children:L.unpricedNote}),U9(d,L.chart.length)&&a.jsxs("div",{className:"ap-proj-days",children:[a.jsxs("div",{className:"ap-proj-days-cap",children:["By day",L.chart.length>1?" · click a bar":""]}),a.jsx("div",{className:"ap-proj-days-plot",role:"group","aria-label":`Spend across ${L.chart.length} day${L.chart.length>1?"s":""}`,children:L.chart.map(H=>{const D=L.maxDay>0?H.total/L.maxDay*100:0,W=p===H.day,J=L.rows.map(X=>({label:X.label,c:H.costByColor.get(X.color)??0,u:H.unpricedByColor.get(X.color)??0})).filter(X=>X.c>0||X.u>0),V=`${Bp(Date.parse(`${H.day}T00:00:00`))}, ${Or(H.total,H.unpriced)}. ${J.map(X=>`${X.label} ${Or(X.c,X.u)}`).join(", ")}`;return a.jsx("button",{type:"button",className:`ap-proj-day${W?" selected":""}`,"aria-pressed":W,"aria-label":V,title:`${H.day} · ${Or(H.total,H.unpriced)}`,onClick:()=>g(X=>X===H.day?null:H.day),children:a.jsx("span",{className:"ap-proj-col",style:{height:`${D}%`},children:L.colorOrder.map((X,Y)=>{const Z=H.costByColor.get(X)??0;return Z<=0||H.total<=0?null:a.jsx("span",{className:"ap-proj-colseg",style:{height:`${Z/H.total*100}%`,background:X}},Y)})})},H.day)})}),(()=>{const H=K9(L.chart.length);return a.jsx("div",{className:"ap-proj-days-axis","aria-hidden":"true",children:L.chart.map((D,W)=>a.jsx("div",{className:"ap-proj-axis-cell",children:H(W)?G9(D.day):""},D.day))})})(),(()=>{const H=p?L.chart.find(W=>W.day===p):null;if(!H)return null;const D=L.rows.map(W=>({r:W,c:H.costByColor.get(W.color)??0,u:H.unpricedByColor.get(W.color)??0})).filter(W=>W.c>0||W.u>0);return a.jsxs("div",{className:"ap-proj-day-detail",children:[a.jsxs("div",{className:"ap-proj-day-detail-head",children:[a.jsx("span",{children:Bp(Date.parse(`${H.day}T00:00:00`))}),a.jsx("span",{className:"ap-proj-day-detail-total",title:zo(H.unpriced),children:Or(H.total,H.unpriced)})]}),D.map(({r:W,c:J,u:V})=>a.jsxs("div",{className:"ap-proj-day-detail-row",children:[a.jsx("span",{className:"ap-proj-dot",style:{background:W.color},"aria-hidden":"true"}),a.jsx("span",{className:"ap-proj-day-detail-name",children:W.label}),a.jsx("span",{className:"ap-proj-day-detail-cost",title:zo(V),children:Or(J,V)})]},W.key))]})})()]}),a.jsx("ul",{className:"ap-proj-list",children:L.rows.map((H,D)=>{const W=L.basis==="cost"?H.cost:H.tokens,J=L.denom>0?W/L.denom*100:0,V=v.has(H.key),X=`ap-proj-details-${D}`,Y=V&&(!!H.path||!!H.members),Z=H.members?`${V?"Hide":"Show"} the ${H.members.length} project${H.members.length>1?"s":""} folded into Other`:`${V?"Hide":"Show"} location for ${H.label}`;return a.jsxs("li",{className:`ap-proj-row${H.muted?" muted":""}${V?" expanded":""}`,children:[a.jsx("span",{className:"ap-proj-dot",style:{background:H.color},"aria-hidden":"true"}),a.jsxs("span",{className:"ap-proj-name",children:[H.label,H.parentLabel&&a.jsxs("span",{className:"ap-proj-parent",children:[" · in ",H.parentLabel]})]}),a.jsx("span",{className:"ap-proj-track",title:L.basis==="cost"?`${Fu(H.cost,L.totalCost)} of tracked cost`:`${Fu(H.tokens,L.totalTokens)} of tracked tokens`,children:a.jsx("span",{className:"ap-proj-fill",style:{width:`${J}%`,background:H.color}})}),a.jsx("span",{className:"ap-proj-cost",title:zo(H.unpricedTokens),children:Or(H.cost,H.unpricedTokens)}),a.jsx("span",{className:"ap-proj-tok",children:it(H.tokens)}),a.jsx("button",{type:"button",className:"glyph-btn ap-proj-info","aria-expanded":V,"aria-controls":Y?X:void 0,"aria-label":Z,onClick:()=>N(ee=>{const ne=new Set(ee);return ne.has(H.key)?ne.delete(H.key):ne.add(H.key),ne}),children:"ⓘ"}),V&&H.path&&a.jsxs("div",{className:"ap-proj-details",id:X,children:[a.jsx("code",{className:"ap-proj-path",children:xS(H.path)}),a.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${O(H.path)} location for ${H.label}`,onClick:()=>F(H.path,H.label),children:O(H.path)})]}),V&&H.members&&a.jsx("div",{className:"ap-proj-details ap-proj-other-members",id:X,children:H.members.map(ee=>a.jsxs("div",{className:"ap-proj-other-member",children:[a.jsxs("div",{className:"ap-proj-other-name",children:[ee.label,ee.parentLabel&&a.jsxs("span",{className:"ap-proj-parent",children:[" · in ",ee.parentLabel]})]}),a.jsx("code",{className:"ap-proj-path",children:xS(ee.path)}),a.jsx("span",{className:"ap-proj-cost",title:zo(ee.unpricedTokens),children:Or(ee.cost,ee.unpricedTokens)}),a.jsx("span",{className:"ap-proj-tok",children:it(ee.tokens)}),a.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${O(ee.path)} location for ${ee.label}`,onClick:()=>F(ee.path,ee.label),children:O(ee.path)})]},ee.path))})]},H.key)})}),L.un&&a.jsxs("div",{className:"ap-proj-unattributed",children:[a.jsx("span",{className:"ap-proj-dot",style:{background:W9},"aria-hidden":"true"}),a.jsxs("div",{className:"ap-proj-un-labels",children:[a.jsx("span",{className:"ap-proj-un-title",children:"Unattributed usage"}),a.jsx("span",{className:"ap-proj-un-tag",children:"Excluded from the project totals"})]}),a.jsx("span",{className:"ap-proj-un-cost",title:zo(L.un.unpricedTokens),children:Or(L.un.cost,L.un.unpricedTokens,V9)}),a.jsx("span",{className:"ap-proj-un-tok",children:it(L.un.tokens)}),a.jsx("div",{className:"ap-proj-note",children:"Work no account could be tied to — from before tracking, or a gap."})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:j&&(j.ok?`Copied the location of ${j.label}`:`Could not copy the location of ${j.label} — select it and copy it by hand`)}),a.jsxs("div",{className:"ap-proj-foot",children:[f?"Dollars estimated · ccusage still running":L.reconciled?"Dollars from ccusage · split by activity":L.calibrated?"Dollars from ccusage for the priced models · split by activity":h?"Dollars estimated · ccusage could not price this window":"Dollars estimated · ccusage unavailable"," · ",I]})]})})]})]})}),document.body)}function yi(e,t){return V$(t-Math.floor(e/1e3))}function X9(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 y0(){return a.jsxs("svg",{className:"ap-warn-glyph",width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M7 1.9 12.9 12H1.1Z"}),a.jsx("path",{d:"M7 5.6v2.9"}),a.jsx("path",{d:"M7 10.3v.05"})]})}function Z9({anchorId:e,boundaryId:t,issue:n,who:r,fetchedAt:s,nowSec:o,onClose:l,onSignIn:c,onReport:d}){const h=y.useRef(null);return a.jsx(dh,{anchorId:e,boundaryId:t,id:"ap-issue-pop",className:"ap-pop ap-issue-pop",role:"dialog",labelledBy:"ap-issue-title",focusRef:h,onClose:()=>l(),children:a.jsxs("div",{className:"ap-pop-form",children:[a.jsxs("p",{className:"ap-pop-title ap-issue-title",id:"ap-issue-title","data-tone":n.tone,children:[n.tone==="warn"&&a.jsx(y0,{}),n.text]}),a.jsx("p",{className:"ap-pop-note ap-issue-hint",children:n.hint}),a.jsxs("p",{className:"ap-pop-note ap-issue-when",children:[a.jsx("span",{className:"ap-issue-who",children:r})," · ",s?`last collected ${yi(s,o)}`:"never collected"]}),a.jsxs("div",{className:"ap-pop-actions",children:[d&&a.jsx("button",{type:"button",className:"ap-issue-report",onClick:()=>{l(),d()},children:"Report this"}),a.jsx("button",{type:"button",ref:h,className:"btn",onClick:()=>l(!0),children:"Done"}),n.fix&&a.jsx("button",{type:"button",className:"btn primary",onClick:()=>{l(!0),c()},title:"Open the sign-in dialog. Signing in as this account puts its login back in this slot — it keeps its slot, its alias and its history.",children:n.fix})]})]})})}function Sl(e){return e.charAt(0).toUpperCase()+e.slice(1)}function J9(e,t){const n="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.";if((e==null?void 0:e.state)==="running")return{text:"resuming…",hint:`${n} The deck is re-capturing it from the login you already have. No sign-in, no switch.`};if((e==null?void 0:e.state)==="failed"){const r=Math.max(1,Math.ceil((e.retryAt/1e3-t)/60)),s=e.reason?`Re-capturing it from the login you already have did not work (${e.reason}).`:"The deck re-captured it from the login you already have, and claude-swap still cannot read it.";return{text:"numbers paused",hint:`${n} ${s} It tries again in ${r}m. No sign-in, no switch.`}}return{text:"numbers paused",hint:n}}function Q9(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 eV(e){switch(e){case"no_credentials":return{text:"no stored login",hint:"claude-swap holds no credentials for this account, so there is nothing to read its usage with and nothing to switch to. A paired deck that has them sends them on its own; signing in as this account puts them there by hand.",fix:"sign in"};case"relogin_required":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.",fix:"sign in again"};case"keychain_unavailable":return{text:"keychain unreadable",hint:"This is about the deck, not the account: claude-swap could not open your keychain, so it cannot read any account's stored login. A deck started from a background session cannot reach the keychain at all — start it from a terminal, or let it start at login, and this clears."};case"token_expired":return{text:"token expired",hint:"The access token ran out and the refresh was deferred. The next collection retries."};case"foreign_credential":return{text:"wrong credential",hint:"The live credential belongs to a different account. Switching to this one repairs it."};case null:case void 0:return null;default:return{text:e,hint:`claude-swap reported "${e}" for this account.`}}}const bS={text:"Login expired on all online decks",hint:"Every paired deck online right now that shares this account holds a copy that has expired too, so none of them can repair this one. Claude retires a login's other copies each time one machine refreshes it, which is how shared copies expire together. Sign in again on any one machine; the others repair from it on their next round."};function wi(e,t,n){const r=nV(e,t);return!r||!(n!=null&&n.noCopyWorksNearby)||!tV(e)?r:{...r,text:bS.text,hint:bS.hint}}function tV(e){return e.staleCopy?!1:e.stopped?e.collector==="relogin_required":e.error==="invalid_grant"||e.error==="no_refresh_token"}function nV(e,t){if(e.staleCopy){const n=J9(e.repair??null,t);return{text:Sl(n.text),hint:n.hint,fix:null,tone:"quiet",blocksSwitch:!1}}if(e.stopped){const n=eV(e.collector??null);if(!n)return{text:"Not collecting",hint:"claude-swap has collected nothing for this account in over half a day and has not said why. A paired deck holding a working copy of this account will replace it on its own. To do it by hand, sign in as this account from + Add.",fix:null,tone:"quiet",blocksSwitch:!1};const r=e.collector==="no_credentials"||e.collector==="relogin_required";return{text:Sl(n.text),hint:n.hint,fix:n.fix?Sl(n.fix):null,tone:r||e.collector==="keychain_unavailable"?"warn":"quiet",blocksSwitch:r}}if(e.error){const n=Q9(e.error);return{text:Sl(n.text),hint:n.hint,fix:n.fixable?"Sign in again":null,tone:n.fixable?"warn":"quiet",blocksSwitch:n.fixable}}return null}function kS(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function NS(e){const t=e.filter(c=>!kS(c)),n=e.filter(c=>kS(c)),r=t.length?t:n,s=t.length?n:[],o=r.reduce((c,d)=>c&&c.pct>=d.pct?c:d,null);let l=null;for(const c of s)o&&c.pct<=o.pct||(!l||c.pct>l.pct)&&(l=c);return{shown:r,rest:s,fuller:l,peak:l??o}}function Jl(e,t){return!!e.resetAt&&e.resetAt<=t}function w0(e,t){const n=e.lanes??[],r=n.filter(s=>!Jl(s,t));return r.length===n.length?e.headroom:r.length?Math.max(0,100-Math.max(...r.map(s=>s.pct))):null}const rV="\0";function Lr(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}${rV}${n}`}function sV(e,t,n=Lr){const r=n(t);return e.includes(r)?e.filter(s=>s!==r):[...e,r]}const hh="slot",v0=[{lane:"five_hour",name:"5h"},{lane:"seven_day",name:"7d"}],NI=e=>e.id.startsWith("scoped-");function aV(e){var t;return((t=v0.find(n=>n.lane===e.id))==null?void 0:t.name)??e.label}function oV(e){if(e==="room")return"room";const t=/^(.+):(full|empty)$/.exec(e);return t?t[1]:null}function jI(e){const t=[...new Set(e.flatMap(r=>(r.lanes??[]).filter(NI).map(s=>s.label)))].sort((r,s)=>r.localeCompare(s)),n=[...v0.map(r=>r.name),...t];return[{id:hh,label:"Slot"},...n.flatMap(r=>[{id:`${r}:full`,label:`${r} · fullest`},{id:`${r}:empty`,label:`${r} · emptiest`}]),{id:"room",label:"Most room"}]}function jS(e,t,n){const r=v0.find(o=>o.name===t),s=(e.lanes??[]).find(o=>r?o.id===r.lane:NI(o)&&o.label===t);return s&&n!=null&&Jl(s,n)?null:s&&Number.isFinite(s.pct)?s.pct:null}function iV(e,t,n=()=>!0,r){const s=[...e],o=f=>[...f.filter(n),...f.filter(p=>!n(p))];if(t==="room"){const f=p=>r==null?p.headroom:w0(p,r);return o(SS(s,p=>{const g=f(p);return Number.isFinite(g)?g:null},"desc"))}const l=/^(.+):(full|empty)$/.exec(t);if(!l)return s;const[,c,d]=l;if(!s.some(f=>jS(f,c,r)!=null))return s;const h=SS(s,f=>jS(f,c,r),d==="full"?"desc":"asc");return d==="empty"?o(h):h}function SS(e,t,n){const r=e.filter(o=>t(o)!=null),s=e.filter(o=>t(o)==null);return r.sort((o,l)=>n==="desc"?t(l)-t(o):t(o)-t(l)),[...r,...s]}function lV(e,t){return jI(t).some(n=>n.id===e)?e:hh}function Xx(e,t){if(!t)return[...e];const n=new Map(t.map((o,l)=>[o,l])),r=e.filter(o=>n.has(Lr(o))).sort((o,l)=>n.get(Lr(o))-n.get(Lr(l))),s=e.filter(o=>!n.has(Lr(o)));return[...r,...s]}function x0(e){const t=Lr(e);return t.startsWith("slot:")?t:`h:${cV(t)}`}function cV(e){let t=3735928559,n=1103547991;for(let r=0;r<e.length;r++){const s=e.charCodeAt(r);t=Math.imul(t^s,2654435761),n=Math.imul(n^s,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),(4294967296*(2097151&n)+(t>>>0)).toString(36)}const Zx={mode:"some",keys:[]};function SI(e,t){const n=e.keys.includes(x0(t));return e.mode==="all"?!n:n}function uV(e,t){return{mode:e.mode,keys:sV(e.keys,t,x0)}}function _I(e,t){return t.length>0&&t.every(n=>SI(e,n))}function dV(e,t){return _I(e,t)?Zx:{mode:"all",keys:[]}}function hV(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map(x0)),r=e.keys.filter(s=>n.has(s));return r.length===e.keys.length?e:{mode:e.mode,keys:r}}function fV(e){return e>=90?"hi":e>=70?"mid":void 0}function pV({lane:e,nowSec:t,frozen:n,sortedBy:r}){const s=Math.min(100,Math.max(0,e.pct)),o=Jl(e,t),l=n||o,c=l?"var(--muted)":s>=90?"var(--err)":s>=70?"var(--warn)":"var(--accent)",d=e.resetAt&&!l?sh(e.resetAt,t):null;return a.jsxs("div",{className:"ap-lane","data-sort-key":r?"":void 0,children:[a.jsx("span",{className:"ap-lane-label",title:e.label,children:e.label}),a.jsx("div",{className:"ap-lane-track",children:a.jsx("div",{className:"ap-lane-fill",style:{width:`${s===0?1.5:s}%`,background:c,opacity:s===0||l?.4:1}})}),a.jsxs("span",{className:"ap-lane-pct",style:{color:c},children:[Math.round(s),"%"]}),a.jsxs("span",{className:"ap-lane-reset",title:d?`${e.label} resets in ${d}`:o&&!n?`${e.label} has reset since this reading`:void 0,children:[d&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"vis-hidden",children:"resets in "}),d]}),o&&!n&&"reset"]})]})}function mV({a:e,nowSec:t,lan:n,opened:r,onToggleLanes:s,busy:o,pressProps:l,onSwitch:c,menuOpen:d,onOpenMenu:h,onCloseMenu:f,refusal:p,onDismissRefusal:g,switchedHere:v,swapped:N,displaced:k,issueExpanded:x,onOpenIssue:j,sortKey:b=null}){const _=e.lanes.filter(M=>!Jl(M,t)),{shown:E}=NS(e.lanes),{fuller:R}=NS(_),C=b==="room"?_.reduce((M,$)=>M&&M.pct>=$.pct?M:$,null):b?e.lanes.find(M=>aV(M)===b)??null:null,A=wi(e,t,n),U=e.active||r,L=e.alias??e.email??`account ${e.num}`,F=e.alias&&e.email?`${e.alias} · ${e.email}`:L,O=e.stale||(A==null?void 0:A.blocksSwitch)===!0,I=R?[...E,R]:E,B=e.fetchedAt?yi(e.fetchedAt,t):null;return a.jsxs("li",{className:`ap-account${e.active?" active":""}`,"aria-current":e.active?"true":void 0,"data-open":U?"":void 0,"data-frozen":O?"":void 0,children:[!e.active&&a.jsx("button",{type:"button",className:"ap-row-open",id:`ap-row-${e.num}`,title:F,"aria-expanded":U,"aria-controls":U?`ap-detail-${e.num}`:void 0,"aria-describedby":[e.alias&&e.email?`ap-email-${e.num}`:null,!U&&!(A!=null&&A.blocksSwitch)?`ap-quota-${e.num}`:null].filter(Boolean).join(" ")||void 0,onClick:()=>s(),children:a.jsxs("span",{className:"vis-hidden",children:[L,", ",U?"hide details":"details"]})}),a.jsxs("div",{className:"ap-account-head",children:[e.active?a.jsx("span",{className:"ap-live",title:`Active account · slot ${e.num}`,children:a.jsxs("span",{className:"vis-hidden",children:["Active account, slot ",e.num,":"]})}):a.jsx("span",{className:"ap-num",children:e.num}),e.alias&&a.jsx("span",{className:"ap-alias",title:e.alias,children:e.alias}),a.jsx("span",{className:"ap-email",id:`ap-email-${e.num}`,title:e.email??void 0,children:e.email}),e.disabled&&a.jsx("span",{className:"ap-held",children:"held out"}),!e.active&&!e.disabled&&!(A!=null&&A.blocksSwitch)&&a.jsx("button",{type:"button",className:"ap-switch",...l(`switch-${e.num}`),onClick:()=>c(e.num,L),"aria-label":`Switch to ${L}`,title:`Switch to ${e.alias??e.email}`,children:o===`switch-${e.num}`?"…":"Switch"}),a.jsx("button",{type:"button",id:`ap-more-${e.num}`,className:"ap-more","aria-label":`More actions for ${e.email??e.alias??`account ${e.num}`}`,"aria-haspopup":"menu","aria-expanded":d,"aria-controls":d?`ap-menu-${e.num}`:void 0,title:"More actions",onClick:()=>d?f():h(e.num),onKeyDown:M=>{M.key!=="ArrowDown"&&M.key!=="ArrowUp"||(M.preventDefault(),h(e.num,M.key==="ArrowUp"?"last":"first"))},children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"currentColor","aria-hidden":!0,children:[a.jsx("circle",{cx:"2.8",cy:"7",r:"1.15"}),a.jsx("circle",{cx:"7",cy:"7",r:"1.15"}),a.jsx("circle",{cx:"11.2",cy:"7",r:"1.15"})]})})]}),p&&a.jsxs("div",{className:"ap-failure ap-row-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",title:p.raw||void 0,children:p.text}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>g(),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),e.active&&v&&a.jsx("p",{className:"ap-switched",children:"Now active. New sessions start on it; ones already running pick it up on their next message, up to about 30 seconds later on macOS."}),N&&(()=>{const M=(k==null?void 0:k.alias)??(k==null?void 0:k.email)??"the account that was there";return a.jsxs("p",{className:"ap-note ap-swap-note",title:`Slot ${N.at} was taken, so the two accounts traded places: ${M} now holds slot ${N.displaced}.`,children:["swapped with slot ",N.displaced]})})(),A&&a.jsxs("div",{className:"ap-issue-line",children:[a.jsxs("button",{type:"button",id:`ap-issue-${e.num}`,className:"ap-issue","data-tone":A.tone,"aria-haspopup":"dialog","aria-expanded":x,"aria-controls":x?"ap-issue-pop":void 0,onClick:()=>j(e.num,`ap-issue-${e.num}`),children:[A.tone==="warn"&&a.jsx(y0,{}),a.jsx("span",{className:"ap-issue-text",children:A.text})]}),!U&&a.jsx("span",{className:"ap-issue-age",title:"When claude-swap last read this account's usage",children:B??"never collected"})]}),!U&&!(A!=null&&A.blocksSwitch)&&a.jsxs("p",{className:"ap-quota",id:`ap-quota-${e.num}`,children:[I.length?I.map(M=>a.jsxs("span",{className:"ap-q","data-sort-key":M.id===(C==null?void 0:C.id)?"":void 0,children:[a.jsx("span",{className:"ap-q-label",children:M.label})," ",Jl(M,t)?a.jsx("span",{className:"ap-q-pct",title:`${M.label} has reset since this reading`,children:"reset"}):a.jsxs("span",{className:"ap-q-pct","data-level":O?void 0:fV(M.pct),children:[Math.round(M.pct),"%"]})]},M.id)):a.jsx("span",{className:"ap-q-label",children:"no usage recorded yet"}),e.stale&&!A&&a.jsx("span",{className:"ap-q-age","data-never":B?void 0:"",title:"When claude-swap last read this account's usage",children:B??"never collected"})]}),U&&a.jsxs("div",{className:"ap-detail",id:`ap-detail-${e.num}`,children:[a.jsx("div",{className:"ap-lanes",children:e.lanes.length?e.lanes.map(M=>a.jsx(pV,{lane:M,nowSec:t,frozen:O,sortedBy:M.id===(C==null?void 0:C.id)},M.id)):a.jsx("div",{className:"ap-hint",children:"No usage recorded yet."})}),a.jsx("div",{className:"ap-meta",children:e.fetchedAt?a.jsxs("span",{className:`ap-age${e.stale&&!A?" 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 ",yi(e.fetchedAt,t),A!=null&&A.blocksSwitch?"":X9(e.nextAt,t)]}):a.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})})]})]})}function gV({data:e}){return a.jsx("div",{className:"ap-empty",children:e.reason==="cswap_installing"?a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"Installing claude-swap…"}),a.jsx("span",{className:"ap-hint",children:"The deck is setting it up in the background, so there is nothing to do here. On a new machine this can take a few minutes; the panel fills in by itself when it is done."})]}):e.reason==="no_cswap"?a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"claude-swap isn't installed."}),a.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."}),e.hint&&a.jsx("code",{className:"ap-cmd",children:e.hint}),a.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",a.jsx("strong",{children:"+"})," button above."]})]}):e.reason==="cswap_refused"?a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"claude-swap was installed, but not the version the deck asked for."}),a.jsxs("span",{className:"ap-hint",children:[e.version?`v${e.version} answered`:"A different version answered",e.want?` where ${e.want} was asked for`:"",", so the deck is not driving it. Install the version it asked for, or set AGENTS_DECK_CSWAP to a claude-swap you trust."]})]}):e.reason==="no_accounts"?a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"No accounts added yet."}),a.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",a.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"Couldn't read the account store."}),a.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",e.reason?` (${e.reason})`:"","."]})]})})}function yV({canShare:e,canReport:t,onAdd:n,onReport:r,onShareSet:s,onReload:o,pressProps:l,reloading:c,closeButton:d}){return a.jsxs("div",{className:"ap-header",children:[a.jsx("h2",{children:"Claude accounts"}),a.jsxs("div",{className:"ap-header-right",children:[a.jsx("button",{type:"button",className:"glyph-btn ap-add",onClick:()=>n(),"aria-label":"Add an account",title:"Sign in to another Claude account, or paste one shared from another deck",children:a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:a.jsx("path",{d:"M7 2.2v9.6M2.2 7h9.6"})})}),t&&a.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>r(),"aria-label":"Account capacity","aria-haspopup":"dialog",title:"Account capacity — how many accounts are ready, and what the 5h and 7d windows have left",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M2.5 10.9A5.2 5.2 0 1 1 11.5 10.9"}),a.jsx("path",{d:"M7 8.3l2.1-2.1"})]})}),e&&a.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>s(),"aria-label":"Share accounts with another deck",title:`Copy several accounts to another ${kt} in one paste. The text carries a live login for each one — treat it as those passwords.`,children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M3.3 10.7L10.7 3.3"}),a.jsx("path",{d:"M5.5 3.3h5.2v5.2"})]})}),a.jsx("button",{type:"button",className:"glyph-btn ap-refresh",onClick:()=>o(),...l("reload",c),"aria-label":"Reload accounts",title:"Reload from claude-swap",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),a.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]})}),d]})]})}const Va=[{id:"five_hour",label:"5h",long:"5-hour"},{id:"seven_day",label:"7d",long:"7-day"}];function _S(e){return e.counted?e.pct:e.why==="login"?null:e.estimate}function wV(e){const t=_S(e.five_hour),n=_S(e.seven_day);if(t==null||n==null)return"stale";const r=+(t>=100)+ +(n>=100);return r===0?"ready":r===1?"limited":"exhausted"}function vV(e,t){const n=Va.map(r=>e.cells[r.id]);for(const r of n)if(!r.counted&&(r.why==="login"||r.why==="none"))return{text:r.say,old:!0};return e.updatedAt==null?{text:"never read",old:!0}:n.every(r=>r.counted)?{text:"now",old:!1}:{text:yi(e.updatedAt,t),old:!0}}const xV=15*6e4,bV=e=>e.alias??e.email??`account ${e.num}`;function ES(e,t,n){const r=Va.find(f=>f.id===t).label,s=(e.lanes??[]).find(f=>f.id===t),o=s&&Number.isFinite(s.pct)?kV(s.pct):null,l=wi(e,n),c=(s==null?void 0:s.resetAt)!=null&&s.resetAt<=n,d=(f,p)=>({counted:!1,why:f,say:p,last:o,estimate:o==null?null:c?0:o,resetAt:c?null:(s==null?void 0:s.resetAt)??null});return l!=null&&l.blocksSwitch?d("login",l.text):o==null?d("none",`No ${r} reading`):e.stale||e.fetchedAt==null||n*1e3-e.fetchedAt>xV?d("stale",e.fetchedAt?`Updated ${yi(e.fetchedAt,n)}`:"Never read"):c?d("reset",`Reset ${yi(s.resetAt*1e3,n)}, not updated`):{counted:!0,pct:o,resetAt:s.resetAt}}const kV=e=>Math.min(100,Math.max(0,e));function NV(e,t){const n=Va.find(h=>h.id===t);let r=0,s=0,o=0;const l=[];for(const h of e){const f=h.cells[t],p=f.counted?f.pct:f.estimate;p!=null&&(r+=p,o++,f.counted&&s++,f.resetAt!=null&&l.push({at:f.resetAt,name:h.name,pct:p}))}const c=l.reduce((h,f)=>!h||f.at<h.at?f:h,null),d=c&&{...c,more:l.filter(h=>h!==c&&h.at-c.at<60).length};return{id:t,label:n.label,long:n.long,reporting:s,included:o,total:e.length,used:o?r/o:null,nextReset:d}}function EI(e,t){const n=e.map(s=>{const o={five_hour:ES(s,"five_hour",t),seven_day:ES(s,"seven_day",t)};return{num:s.num,key:Lr(s),name:bV(s),active:s.active,heldOut:s.disabled===!0,cells:o,status:wV(o),updatedAt:s.fetchedAt??null}}),r=n.filter(s=>s.status==="ready").length;return{rows:n,windows:Va.map(s=>NV(n,s.id)),roomInBoth:r}}function Bu(e,t){return(e==null?void 0:e.key)===t?{key:t,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:"asc"}}const jV={ready:0,limited:1,exhausted:2,stale:3};function SV(e){return e.counted?e.pct:e.last}function TS(e,t){return t==="status"?jV[e.status]:t==="updated"?e.updatedAt==null?null:-e.updatedAt:SV(e.cells[t])}function _V(e,t){if(!t)return[...e];const n=t.dir==="asc"?1:-1,r=new Map(e.map((o,l)=>[o.num,l])),s=(o,l)=>{if(t.key==="account")return n*o.name.localeCompare(l.name,void 0,{sensitivity:"base"});const c=TS(o,t.key),d=TS(l,t.key);return c==null||d==null?c==null?d==null?0:1:-1:n*(c-d)};return[...e].sort((o,l)=>s(o,l)||r.get(o.num)-r.get(l.num))}function Ed(e){return e>=100?100:Math.min(99,Math.round(e))}function EV(e){const t=Ed(e);return{used:t,available:100-t}}function TV(e,t,n){return e?`${e} These are the last readings.`:t&&n?"The account store could not be read just now. These are the last readings.":null}function TI(e){return e>=90?"hi":e>=70?"mid":void 0}const CI=(e,t,n)=>`${e} ${e===1?t:n}`;function CS(e){const t=e.more>0?`, and ${CI(e.more,"more account","more accounts")} in the same minute`:"";return`First: ${e.name} (${Ed(e.pct)}% used)${t}`}function CV({w:e,nowSec:t}){const n=`ap-report-${e.id}`,r=e.total-e.included,s=r>0&&a.jsxs("p",{className:"ap-report-basis",children:[r," never read"]}),{used:o,available:l}=EV(e.used??0),c=Math.round(Da(l,{countIn:!0}));if(e.used==null)return a.jsxs("section",{className:"ap-report-sum","aria-labelledby":n,children:[a.jsxs("h3",{className:"ap-report-win",id:n,children:[e.long," window"]}),a.jsxs("p",{className:"ap-report-none",children:["No account has a ",e.long," reading yet."]}),s]});const d=e.nextReset?sh(e.nextReset.at,t):null;return a.jsxs("section",{className:"ap-report-sum","aria-labelledby":n,children:[a.jsxs("h3",{className:"ap-report-win",id:n,children:[e.long," window"]}),a.jsxs("p",{className:"ap-report-left",children:[a.jsxs("b",{children:[c,"%"]})," remaining"]}),a.jsx("div",{className:"ap-report-meter","data-level":TI(o),"aria-hidden":!0,children:a.jsx("i",{style:{"--left":l/100}})}),d&&e.nextReset&&a.jsxs("p",{className:"ap-report-reset",title:CS(e.nextReset),children:[a.jsxs("span",{children:["Next reset in ",a.jsx("span",{className:"ap-report-num",children:d})]}),a.jsx("span",{"aria-hidden":!0,children:"·"}),a.jsx("span",{className:"ap-report-who",children:e.nextReset.name}),e.nextReset.more>0&&a.jsxs("span",{className:"ap-report-more",children:["+",e.nextReset.more]}),a.jsxs("span",{className:"vis-hidden",children:[". ",CS(e.nextReset)]})]}),s]})}function AV({cell:e,nowSec:t}){if(!e.counted)return a.jsxs("td",{className:"ap-report-cell","data-uncounted":"",children:[a.jsx("span",{className:"ap-report-pct",children:e.last==null?a.jsxs(a.Fragment,{children:[a.jsx("span",{"aria-hidden":!0,children:"—"}),a.jsx("span",{className:"vis-hidden",children:"no reading"})]}):`${Ed(e.last)}%`}),a.jsx("span",{className:"vis-hidden",children:", not counted"})]});const n=e.resetAt!=null?sh(e.resetAt,t):null;return a.jsxs("td",{className:"ap-report-cell",children:[a.jsxs("span",{className:"ap-report-pct","data-level":TI(e.pct),children:[Ed(e.pct),"%"]}),n&&a.jsxs("span",{className:"ap-report-in",children:[a.jsx("span",{className:"vis-hidden",children:"resets in "}),n]})]})}const RV={ready:"Ready",limited:"Limited",exhausted:"Exhausted",stale:"Stale"};function MV({row:e}){return a.jsx("td",{className:"ap-report-state","data-status":e.status,children:a.jsxs("span",{className:"ap-report-state-word",children:[a.jsx("i",{"aria-hidden":!0}),RV[e.status]]})})}function $V({row:e,nowSec:t}){const n=vV(e,t);return a.jsx("td",{className:"ap-report-upd","data-old":n.old?"":void 0,children:n.text})}function IV(){return a.jsxs("svg",{className:"ap-report-how-mark",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":!0,focusable:"false",children:[a.jsx("circle",{cx:"8",cy:"8",r:"6.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),a.jsx("path",{d:"M8 7.2v4.1M8 4.8v.1",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}function OV({accounts:e,nowSec:t,held:n,sort:r=null,onSort:s=()=>{}}){const o=EI(e,t),l=o.rows.length,c=Math.round(Da(o.roomInBoth,{countIn:!0}));return a.jsxs("div",{className:"ap-proj-body ap-report-body",role:"region","aria-label":"Report",children:[n&&a.jsx("p",{className:"ap-report-held",children:n}),a.jsxs("p",{className:"ap-report-lead",children:[a.jsx("b",{children:c})," of ",CI(l,"Claude account","Claude accounts")," ready"]}),a.jsx("div",{className:"ap-report-sums",children:o.windows.map(d=>a.jsx(CV,{w:d,nowSec:t},d.id))}),a.jsxs("table",{className:"ap-report-table",children:[a.jsx("caption",{className:"vis-hidden",children:"Each account's use of each window, and what it can do now"}),a.jsxs("colgroup",{children:[a.jsx("col",{}),Va.map(d=>a.jsx("col",{className:"ap-report-col-win"},d.id)),a.jsx("col",{className:"ap-report-col-state"}),a.jsx("col",{className:"ap-report-col-upd"})]}),a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx(jl,{col:"account",label:"Account",sort:r,next:Bu,onSort:s}),Va.map(d=>a.jsx(jl,{col:d.id,label:`${d.label} used`,sort:r,next:Bu,onSort:s},d.id)),a.jsx(jl,{col:"status",label:"Status",sort:r,next:Bu,onSort:s}),a.jsx(jl,{col:"updated",label:"Updated",className:"ap-report-upd-h",sort:r,next:Bu,onSort:s})]})}),a.jsx("tbody",{children:o.rows.map((d,h)=>a.jsxs("tr",{"data-active":d.active?"":void 0,style:{"--row":h},children:[a.jsx("th",{scope:"row",className:"ap-report-acct",children:a.jsxs("span",{className:"ap-report-acct-in",children:[a.jsx("span",{className:"ap-report-name",title:d.name,children:d.name}),d.active&&a.jsx("span",{className:"ap-report-current",children:"Current"}),d.heldOut&&a.jsx("span",{className:"ap-report-tag",children:"held out"})]})}),Va.map(f=>a.jsx(AV,{cell:d.cells[f.id],nowSec:t},f.id)),a.jsx(MV,{row:d}),a.jsx($V,{row:d,nowSec:t})]},d.num))})]}),a.jsxs("details",{className:"ap-report-how",children:[a.jsxs("summary",{children:[a.jsx(IV,{}),"How usage is calculated"]}),a.jsxs("div",{className:"ap-report-how-body",children:[a.jsxs("p",{children:["Every account here, at its last reading: ",a.jsx("b",{children:"used"})," is their average, and ",a.jsx("b",{children:"remaining"})," is the rest."]}),a.jsxs("p",{children:[a.jsx("b",{children:"Ready"})," has room in both windows. ",a.jsx("b",{children:"Limited"})," is at the limit of one, and ",a.jsx("b",{children:"Exhausted"})," of both. ",a.jsx("b",{children:"Stale"})," was never read, or is signed out."]})]})]})]})}function LV({accounts:e,order:t,failed:n,nowSec:r,onClose:s}){const o=y.useRef(null),l=ut(s,{focusRef:o}),c=gt(s),[d,h]=y.useState(e??[]);y.useEffect(()=>{e&&e.length>0&&h(e)},[e]);const f=TV(n,!e||e.length===0,d.length>0),[p,g]=y.useState(null),v=Xx(d,(p==null?void 0:p.order)??t),N=k=>{const x=EI(Xx(d,t),r).rows;g({sort:k,order:_V(x,k).map(j=>j.key)})};return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...c,role:"presentation",children:a.jsxs("div",{ref:l,className:"modal ap-report-modal",onClick:k=>k.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ap-report-title",children:[a.jsxs("header",{className:"ap-proj-head",children:[a.jsx("div",{className:"ap-proj-titlewrap",children:a.jsx("h2",{className:"ap-proj-title",id:"ap-report-title",children:"Account capacity"})}),a.jsx("button",{ref:o,type:"button",className:"glyph-btn ap-proj-close",onClick:s,"aria-label":"Close",children:"×"})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:f??""}),a.jsx(OV,{accounts:v,nowSec:r,held:f,sort:(p==null?void 0:p.sort)??null,onSort:N})]})}),document.body)}const qp=[70,80,85,90,95];function PV(e){const t=Number(e);return[...Number.isFinite(t)&&t>0&&!qp.includes(t)?[...qp,t]:qp].sort((r,s)=>r-s)}function DV({auto:e,threshold:t,thresholdPick:n,thresholdCtl:r,thresholdSaved:s,thresholdRef:o,thresholdSaveRef:l,proposeThreshold:c,doThreshold:d,pressProps:h,post:f,load:p}){return a.jsxs("div",{className:"ap-policy-block",children:[a.jsxs("div",{className:"ap-policy",children:[a.jsx("h3",{className:"ap-auto-title",children:"Auto-switch"}),a.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:a.jsx("select",{ref:o,"aria-label":"Switch threshold",value:n,...h("threshold"),onChange:g=>c(g.target.value),children:PV(t).map(g=>a.jsxs("option",{value:g,children:[g,"%"]},g))})}),(r.sends||s)&&a.jsx("button",{ref:l,type:"button",className:"ap-manage-btn",...h("threshold"),title:r.title,onClick:()=>d(n,r),children:s&&!r.sends?r.done:r.label}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":e.enabled,"aria-label":"Auto-switch",...h("enable"),onClick:()=>f({action:"enable",enabled:!e.enabled},"enable").then(()=>p(!0)),title:e.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:a.jsx("span",{className:"switch-knob"})})]}),e.external&&a.jsxs("p",{className:"ap-auto-note",children:[a.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",a.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",e.enabled?" — this toggle takes over when you stop it.":"."]})]})}const AS=18,FV=1100,Ho=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},BV=Array.from({length:AS},(e,t)=>{const n=-72+144*t/(AS-1)+(Ho(t,1)-.5)*9,r=(n-90)*(Math.PI/180),s=(54+32*Math.cos(n*Math.PI/180))*(.74+Ho(t,2)*.52);return{dx:Math.cos(r)*s,dy:Math.sin(r)*s,rot:(t%2?1:-1)*(100+Ho(t,3)*260),delay:Math.round(Ho(t,4)*90),dur:760+Math.round(Ho(t,5)*260),scale:.8+Ho(t,6)*.45,hue:t%4,round:t%3===0}});function RS({anchor:e}){var s;const[t,n]=y.useState(null),r=typeof window<"u"&&((s=window.matchMedia)==null?void 0:s.call(window,"(prefers-reduced-motion: reduce)").matches);return y.useEffect(()=>{if(r)return;const o=e.current;if(!o)return;const l=o.getBoundingClientRect();n({x:l.left+l.width/2,y:l.top+l.height/2});const c=window.setTimeout(()=>n(null),FV);return()=>window.clearTimeout(c)},[e,r]),r||!t?null:Lt.createPortal(a.jsx("div",{className:"confetti",style:{left:`${t.x}px`,top:`${t.y}px`},"aria-hidden":!0,children:BV.map((o,l)=>a.jsx("span",{className:`confetti-bit${o.round?" round":""}`,"data-hue":o.hue,style:{"--dx":`${o.dx.toFixed(1)}px`,"--dy":`${o.dy.toFixed(1)}px`,"--rot":`${o.rot}deg`,"--s":o.scale.toFixed(2),animationDelay:`${o.delay}ms`,animationDuration:`${o.dur}ms, ${o.dur}ms`}},l))}),document.body)}const Td=y.forwardRef((e,t)=>a.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:t,children:[a.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),a.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));Td.displayName="SuccessMark";const AI=new Set(["awaiting_url","awaiting_code","registering"]);function RI(e){return e!=null&&AI.has(e)}function MI(e){return e!=null&&e!=="done"&&!AI.has(e)}const qV="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",UV="the sign-in did not complete";function zV({state:e,serverError:t,localError:n}){const r=e==="idle";return{title:r?"Sign-in ended":"Sign-in failed",message:n||t||(r?qV:UV)}}function WV({restored:e,activeAccount:t}){if(e!==!1)return null;const n=(t==null?void 0:t.email)||((t==null?void 0:t.num)!=null?`account ${t.num}`:null);return n?`This machine is now signed in as ${n} — the account you were using could not be put back. Switch back from the accounts panel.`:"The account you were using could not be put back — check which account this machine is signed in as from the accounts panel."}function HV({started:e,state:t}){return!e||t==="done"?null:{action:"login-cancel"}}function VV({login:e,started:t,loginError:n,loginBusy:r}){return(e==null?void 0:e.state)==="done"&&e.account?"done":(e==null?void 0:e.state)==="awaiting_code"||(e==null?void 0:e.state)==="registering"?"code":MI(e==null?void 0:e.state)||n&&t&&!r?"ended":r||RI(e==null?void 0:e.state)?"asking":"primer"}const GV="done";function KV(){let e=!1;return{shouldAnnounce(t){return t!==GV?(e=!1,!1):e?!1:(e=!0,!0)}}}function b0(e,t){return t?Ot(e,t):void 0}const YV={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 ${kt}`,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"},XV={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"},k0=`claude-swap could not read the login keychain — start ${kt} from a Terminal window rather than a background service`,ZV={unreadable_here:{short:"Keychain locked on this Mac",long:`${k0}.`},no_credentials_here:{short:"no stored login here",long:"claude-swap still holds no login for it here."},relogin_required_here:{short:"login expired",long:"the imported login was rejected — sign in again on a deck where it still works."},unverified_here:{short:"not checked",long:"claude-swap could not confirm whether this Mac can read it."}};function Cd(e){return e?Ot(ZV,e)??null:null}const $I={401:"this deck did not accept the page as its own, so nothing was changed",403:"this deck refused a change from this address — open it on the address the deck prints, not through a proxy"};function Jx(e,t,n){const r=n==null?null:$I[n];if(r)return r;if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(Ql(e)))return k0;const s=b0(XV,e==null?void 0:e.reason);return s||(e==null?void 0:e.reason)||t}function Ql(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const JV={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"},QV="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 eG(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const tG="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",nG="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",rG=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),sG=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,aG=/[\\/]_npx[\\/]/i,oG=`the copy of ccusage ${kt} installed for itself`;function iG(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function Hle(e,t){const n=lG(e,t),r=iG(e);switch(e==null?void 0:e.stage){case"npx":return r?`ccusage failed on both of its paths. The managed install failed first — ${r} — and the deck then fell back to npx, where ${vl(n)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${vl(n)}`;case"managed":return`${oG} failed to run: ${vl(n)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${vl(n)}`:`the ccusage this deck found on your PATH failed to run: ${vl(n)}`;default:return n}}const vl=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function lG(e,t){const n=Ql(e);if(rG(n)){if(aG.test(n))return nG;if(sG.test(n))return tG}if(eG(n))return QV;const r=b0(JV,e==null?void 0:e.reason);return r||(e==null?void 0:e.reason)||t}function Jo(e,t,n){const r=n==null?null:$I[n];if(r)return r;if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&MI(e.state))return e.error;const s=b0(YV,e==null?void 0:e.reason);return s||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function cG(e,t,n){if(n<=0||eh(e))return{kind:"pass"};const r=t>=0&&t<n?t:-1;switch(e.key){case"ArrowRight":return{kind:"select",index:r===-1?0:(r+1)%n};case"ArrowLeft":return{kind:"select",index:r===-1?n-1:(r-1+n)%n};case"Home":return{kind:"select",index:0};case"End":return{kind:"select",index:n-1};default:return{kind:"pass"}}}function II(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 uG(e){const t=new Map;for(const n of e){const r=(n.email??"").trim().toLowerCase();r&&t.set(r,(t.get(r)??0)+1)}return e.map(n=>{const r=(n.email??"").trim(),s=n.alias||r||`account ${n.num}`,o=[];return n.alias&&r&&o.push(r),r&&(t.get(r.toLowerCase())??0)>1&&o.push(n.org||`slot ${n.num}`),{num:n.num,label:s,sub:o.length?o.join(" · "):null}})}function dG(e,t){return e.filter(n=>!t.includes(n.num)).map(n=>n.num)}function hG(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function fG(e){return e.length?{action:"share",accounts:[...e]}:null}function pG(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 Qx(e){return`${e.email}|${e.org??""}`}function mG(e,t,n){return e&&e.map(r=>Qx(r)===t?n:r)}function gG(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 yG(e){const t=e.length;if(!t)return"Nothing to import.";const n=f=>e.filter(p=>p.state===f).length,r=[],s=n("imported");s&&r.push(`${s} of ${t} imported`);const o=n("healed");o&&r.push(`${o} had a dead token replaced`);const l=n("updated");l&&r.push(`${l} updated`);const c=n("present");c&&r.push(`${c} already here`);const d=n("failed");d&&r.push(`${d} did not arrive`);const h=[...new Set(e.map(f=>{var p;return(p=Cd(f.check))==null?void 0:p.short}).filter(f=>!!f))];return`${r.join(", ")}${h.length?`, ${h.join(", ")}`:""}.`}const wG=1500,qu=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],MS="aa-panel",$S=e=>`aa-tab-${e}`;async function Vo(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}function OI({onClose:e,onChanged:t,email:n=null,onSignedIn:r}){qt("add-account");const[s,o]=y.useState("login"),[l,c]=y.useState(null),[d,h]=y.useState(""),[f,p]=y.useState(""),[g,v]=y.useState(!1),[N,k]=y.useState(!1),[x,j]=y.useState(null),[b,_]=y.useState(null),E=g||N,[R,C]=y.useState(null),[A,U]=y.useState(null),[L,F]=y.useState(null),O=y.useRef(""),I=y.useRef(!1),B=y.useRef(!1),M=y.useRef(null),$=y.useRef(null),P=y.useRef(null),G=y.useRef(null),K=y.useRef([]),q=y.useRef(!1),H=y.useCallback(()=>{const he=HV({started:I.current,state:l==null?void 0:l.state});he&&Vo(he).catch(()=>{}),e()},[e,l==null?void 0:l.state]),D=ut(H,{focusRef:P}),W=gt(H),J=y.useCallback(async()=>{if(!lr(B.current))return;B.current=!0,v(!0),j(null),I.current=!0;let he=await Vo(n?{action:"login",email:n}:{action:"login"}).catch(()=>null);if(n&&(he==null?void 0:he.reason)==="bad_email"&&(he=await Vo({action:"login"}).catch(()=>null)),B.current=!1,v(!1),!(he!=null&&he.ok)){j(Jo(he,"could not start the sign-in"));return}c(he)},[n]);y.useEffect(()=>{if(!RI(l==null?void 0:l.state))return;const he=window.setInterval(async()=>{try{const ge=await fetch("/api/claude-accounts/login");ge.ok&&c(await ge.json())}catch{}},wG);return()=>window.clearInterval(he)},[l]);const V=y.useRef(t);V.current=t;const X=y.useState(KV)[0];y.useEffect(()=>{var he;(l==null?void 0:l.state)==="awaiting_code"&&((he=M.current)==null||he.focus()),X.shouldAnnounce(l==null?void 0:l.state)&&V.current()},[l==null?void 0:l.state,X]);const Y=y.useRef(r);Y.current=r;const Z=y.useRef(null);y.useEffect(()=>{var ue;const he=(l==null?void 0:l.state)==="done"?l.account:null,ge=he?`${he.num??""}|${he.email}`:null;!he||Z.current===ge||(Z.current=ge,(ue=Y.current)==null||ue.call(Y,he))},[l]),y.useEffect(()=>{var he;s==="paste"&&!q.current&&((he=$.current)==null||he.focus()),q.current=!1},[s]);const ee=y.useCallback(he=>{var ue;const ge=cG(he,qu.findIndex(be=>be.id===s),qu.length);ge.kind!=="pass"&&(he.preventDefault(),q.current=!0,o(qu[ge.index].id),(ue=K.current[ge.index])==null||ue.focus())},[s]),ne=y.useCallback(async()=>{var ge;if(!lr(B.current))return;B.current=!0,v(!0),j(null);const he=await Vo({action:"login-code",code:d}).catch(()=>null);if(B.current=!1,v(!1),!(he!=null&&he.ok)){j(Jo(he,"the code was not accepted")),he!=null&&he.state&&c(he),(ge=M.current)==null||ge.select();return}h(""),c(he)},[d,l]),se=y.useCallback(async()=>{if(!lr(B.current))return;B.current=!0,k(!0),_(null);const he=await Vo({action:"import",blob:f}).catch(()=>null);if(B.current=!1,k(!1),!(he!=null&&he.ok)){_(Jo(he,"the import failed"));return}O.current=f,p(""),F(null),C(he.results??[]),t()},[f,t]),pe=y.useCallback(async he=>{const ge=Qx(he);if(!lr(B.current)||!O.current)return;B.current=!0,k(!0),U(ge),F(null);const ue=await Vo({action:"import",blob:O.current,force:!0,only:{email:he.email,org:he.org??""}}).catch(()=>null);if(B.current=!1,k(!1),U(null),!(ue!=null&&ue.ok)){F({key:ge,text:Jo(ue,"that account could not be updated")});return}const be=(ue.results??[])[0];be&&C(oe=>mG(oe,ge,be)),t()},[t]),ke=(l==null?void 0:l.state)==="done"?l.account:null,ae=WV({restored:l==null?void 0:l.restored,activeAccount:l==null?void 0:l.activeAccount}),fe=VV({login:l,started:I.current,loginError:x,loginBusy:g}),me=zV({state:l==null?void 0:l.state,serverError:l==null?void 0:l.error,localError:x});return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...W,role:"presentation",children:a.jsxs("div",{ref:D,className:"modal aa-modal",onClick:he=>he.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{className:"aa-tabs",role:"tablist","aria-label":"How to add the account",onKeyDown:ee,children:qu.map((he,ge)=>a.jsx("button",{type:"button",role:"tab",id:$S(he.id),ref:ue=>{K.current[ge]=ue},"aria-selected":s===he.id,"aria-controls":MS,tabIndex:s===he.id?0:-1,className:`aa-tab${s===he.id?" on":""}`,onClick:()=>{q.current=!1,o(he.id)},children:he.label},he.id))})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:H,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsx("section",{className:"modal-body aa-body",id:MS,role:"tabpanel","aria-labelledby":$S(s),children:s==="login"?fe==="done"&&ke?a.jsxs("div",{className:"aa-done",children:[a.jsx(Td,{ref:G}),a.jsx(RS,{anchor:G}),a.jsx("h4",{children:ke.added?`Account ${ke.num} added`:"Credentials refreshed"}),a.jsxs("p",{className:"aa-note",children:[a.jsx("strong",{children:ke.email}),ke.added?ae?" is in the rotation.":" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),ae?a.jsx("p",{className:"aa-note aa-warn",role:"status",children:ae}):null,a.jsx("button",{type:"button",className:"btn primary",onClick:H,children:"Done"})]}):fe==="code"&&l?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"aa-step",children:[a.jsx("h4",{children:"1 · Approve in the browser"}),a.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),a.jsx("a",{className:"aa-link",href:l.url??"#",target:"_blank",rel:"noreferrer noopener",children:l.url})]}),a.jsxs("div",{className:"aa-step",children:[a.jsx("h4",{children:"2 · Paste a code, if the page shows one"}),a.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."}),a.jsxs("div",{className:"aa-field",children:[a.jsx("input",{ref:M,type:"text",value:d,onChange:he=>h(he.target.value),onKeyDown:he=>{he.key==="Enter"&&d.trim()&&!E&&ne()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:l.state==="registering"}),a.jsx("button",{type:"button",className:"btn primary",...Dr(E,!d.trim()||l.state==="registering"),onClick:ne,children:l.state==="registering"?"registering…":"Continue"})]}),(x||l.error)&&a.jsx("p",{className:"aa-err",children:x??l.error}),a.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."})]})]}):fe==="ended"?a.jsxs("div",{className:"aa-step",children:[a.jsx("h4",{children:me.title}),a.jsx("p",{className:"aa-err",children:me.message}),a.jsx("button",{type:"button",className:"btn",onClick:()=>{I.current=!1,c(null),j(null),J()},children:"Try again"})]}):fe==="asking"?a.jsx("div",{className:"aa-step",children:a.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):a.jsxs("div",{className:"aa-step aa-primer",children:[a.jsx("h4",{children:n?a.jsxs(a.Fragment,{children:["Sign in again as ",a.jsx("strong",{children:n})]}):"Sign in to Anthropic"}),a.jsxs("p",{className:"aa-note",children:["Opens a browser tab where you approve the sign-in",n?", with this address already filled in":"",". It normally completes by itself; only if the page hands you a code does it need pasting back here.",n?" claude-swap replaces the expired login in place — the account keeps its slot, its alias and its history — and the account you are using now stays active.":" claude-swap records the account when it completes, and the account you are using now stays active."]}),a.jsx("div",{className:"aa-actions",children:a.jsx("button",{type:"button",ref:P,className:"btn primary",...Dr(E),onClick:J,children:"Open the sign-in page"})})]}):R?(()=>{const he=R.filter(ue=>ue.state==="imported").length,ge=R.some(ue=>Cd(ue.check));return a.jsxs("div",{className:"aa-done",children:[!ge&&a.jsx(Td,{ref:G}),he>0&&!ge&&a.jsx(RS,{anchor:G}),a.jsx("h4",{children:yG(R)}),R.length>0&&a.jsx("ul",{className:"aa-results",children:R.map(ue=>{const be=Qx(ue),oe=Cd(ue.check);return a.jsxs("li",{className:`aa-result ${ue.state}`,children:[a.jsx("span",{className:"aa-result-who",children:ue.email||(ue.num?`slot ${ue.num}`:"an account")}),a.jsx("span",{className:"aa-result-what",children:gG(ue.state)}),ue.state==="present"&&a.jsx("button",{type:"button",className:"aa-result-fix","aria-busy":A===be,title:`Overwrite the stored login for ${ue.email} with the one in this share. Do this when that account has stopped working here; if it works, leave it.`,onClick:()=>pe(ue),children:A===be?"updating…":"update anyway"}),oe&&a.jsx("span",{className:"aa-result-err",children:oe.long}),(L==null?void 0:L.key)===be&&a.jsx("span",{className:"aa-result-err",children:L.text})]},be)})}),a.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",a.jsx("strong",{children:" update anyway"}),"."]}),a.jsxs("div",{className:"aa-actions",children:[a.jsx("button",{type:"button",className:"btn primary",onClick:H,children:"Done"}),a.jsx("button",{type:"button",className:"btn",onClick:()=>{O.current="",F(null),C(null)},children:"Import another"})]})]})})():a.jsxs("div",{className:"aa-step",children:[a.jsx("h4",{children:"Paste an account shared from another deck"}),a.jsxs("div",{className:"aa-field",children:[a.jsx("input",{ref:$,type:"text",value:f,onChange:he=>p(he.target.value),onKeyDown:he=>{he.key==="Enter"&&f.trim()&&!E&&se()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),a.jsx("button",{type:"button",className:"btn primary",...Dr(E,!f.trim()),onClick:se,children:N?"importing…":"Import"})]}),b&&a.jsx("p",{className:"aa-err",children:b}),a.jsxs("p",{className:"aa-note",children:["Use ",a.jsx("strong",{children:"share"})," on one account in the other deck, or ",a.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."]})]})})]})}),document.body)}function vG(e,t){const n=new Set(e),r=e.length?Math.max(...e):0;return[...new Set([...e,r+1])].sort((s,o)=>s-o).map(s=>{const o=s===t?"here":n.has(s)?"swap":"free";return{slot:s,kind:o,label:o==="here"?`slot ${s}`:`slot ${s} · ${o}`}})}function xG(e,t,n){if(!(n!=null&&n.ok))return null;const r=Number.isInteger(n.to)?n.to:null;if(r==null)return{menuFor:null,confirmRemove:null,shareFor:null,swapNote:null};const s=n.swapped===!0&&r!==t;return{menuFor:e.menuFor===t?r:s&&e.menuFor===r?t:e.menuFor,confirmRemove:null,shareFor:null,swapNote:s?{at:r,displaced:t}:null}}const bG=64;function kG(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}function NG(e,t,n){return t!=null&&e.some(r=>r.slot===t)?t:n}function jG(e,t,n){var s;const r=((s=e.find(o=>o.slot===t))==null?void 0:s.kind)??"here";return r==="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}.`}:r==="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 SG(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 _G({a:e,slots:t,nowSec:n,boundaryId:r,accountMenu:s,busy:o,pressProps:l,rotating:c,onProjects:d,onRotation:h}){const{menu:f,menuError:p,aliasDraft:g,confirmRemove:v,share:N,shareCopied:k,slotDraft:x,dropMenu:j,closeMenu:b,startRename:_,typeAlias:E,doAlias:R,startMove:C,pickSlot:A,doSlot:U,makeShare:L,copyShare:F,pressRemove:O}=s;if(!f)return null;const I=`ap-pop-title-${e.num}`,B=p&&a.jsx("p",{className:"ap-pop-error",role:"alert",title:p.raw||void 0,children:p.text});return a.jsxs(dh,{anchorId:`ap-more-${e.num}`,boundaryId:r,id:`ap-menu-${e.num}`,className:"ap-pop",role:f.view==="menu"?"menu":"dialog",labelledBy:f.view==="menu"?`ap-more-${e.num}`:I,start:f.start,onClose:j,children:[f.view==="menu"&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>_(e.num,e.alias),children:"Rename"}),a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>C(e.num),children:"Move to slot…"}),a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...l(`share-${e.num}`),title:`Copy this account to another ${kt}. 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:()=>L(e.num),children:o===`share-${e.num}`?"Sharing…":"Share"}),a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",title:"See how much this account worked in each project",onClick:()=>d(),children:"Projects"}),(c&&!e.active||e.disabled)&&a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...l(`rot-${e.num}`),title:e.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",onClick:()=>h(),children:e.disabled?"Put back in rotation":"Hold out of rotation"}),a.jsx("div",{role:"separator",className:"ap-menu-sep"}),a.jsx("button",{type:"button",role:"menuitem",className:`ap-menu-item danger${v===e.num?" armed":""}`,...l(`rm-${e.num}`),"aria-label":v===e.num?"Confirm remove":void 0,title:v===e.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>O(e.num),children:o===`rm-${e.num}`?"Removing…":v===e.num?"Confirm":"Remove"}),B]}),f.view==="rename"&&a.jsxs("form",{className:"ap-pop-form",onSubmit:M=>{M.preventDefault(),R(e.num,e.alias)},children:[a.jsx("label",{className:"ap-pop-title",id:I,htmlFor:`ap-alias-${e.num}`,children:"Rename account"}),a.jsx("input",{id:`ap-alias-${e.num}`,className:"ap-manage-input",type:"text",value:g,onChange:M=>E(M.target.value),maxLength:bG,placeholder:"e.g. work",spellCheck:!1,autoComplete:"off",autoFocus:!0,onFocus:M=>M.currentTarget.select()}),B,a.jsxs("div",{className:"ap-pop-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>b(),children:"Cancel"}),a.jsx("button",{type:"submit",className:"btn primary",...l(`alias-${e.num}`),title:"A short name to show instead of the email",children:o===`alias-${e.num}`?"…":"Save"})]})]}),f.view==="move"&&(()=>{const M=vG(t,e.num),$=NG(M,x,e.num),P=jG(M,$,e.num);return a.jsxs("div",{className:"ap-pop-form",children:[a.jsx("label",{className:"ap-pop-title",id:I,htmlFor:`ap-slot-${e.num}`,children:"Move to slot"}),a.jsx("span",{className:"ap-field",children:a.jsx("select",{id:`ap-slot-${e.num}`,value:String($),...l(`move-${e.num}`),onChange:G=>A(Number(G.target.value)),autoFocus:!0,children:M.map(G=>a.jsx("option",{value:G.slot,children:G.label},G.slot))})}),B,a.jsxs("div",{className:"ap-pop-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>b(),children:"Cancel"}),a.jsx("button",{type:"button",className:"btn primary",...l(`move-${e.num}`),title:P.title,onClick:()=>U(e.num,$,P),children:o===`move-${e.num}`?"…":Sl(P.label)})]})]})})(),f.view==="share"&&(N==null?void 0:N.num)===e.num&&(()=>{const M=II(N.expiresAt,n),$=M.tone==="gone";return a.jsxs("div",{className:"ap-pop-form",children:[a.jsx("p",{className:"ap-pop-title",id:I,children:"Share account"}),a.jsx("code",{className:"ap-share-blob",children:N.blob}),a.jsxs("p",{className:"ap-pop-note",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:[a.jsx("span",{className:"ap-share-warn",children:"This is the password"})," · ",a.jsx("span",{className:`ap-share-expiry ${M.tone}`,children:M.text})]}),B,a.jsxs("div",{className:"ap-pop-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>b(),children:"Done"}),a.jsx("button",{type:"button",className:"btn primary",...l(`share-${e.num}`),autoFocus:!0,onClick:async()=>{if($){await L(e.num);return}await F(N.blob)},children:$?"Make a new share":k?"Copied":"Copy"})]})]})})()]})}const EG=6;function TG(e,t){const n=e.filter(c=>c.ready);if(t.armed&&e.length>0&&n.length===0)return{text:"Auto-switch has nowhere to go",tone:"bad",free:null};const r=n.length===e.length?`${e.length} ready`:n.length===0?e.length===1?"not ready":`none of ${e.length} ready`:`${n.length} of ${e.length} ready`,s=n.length?"ok":"idle",o=t.strained&&!t.armed?CG(n):null,l=[r];return o!=null&&l.push(`${o}% free`),l.push(t.armed?`auto ${t.threshold??"on"}${t.threshold?"%":""}`:"auto off"),{text:l.join(" · "),tone:s,free:o}}function CG(e){const t=e.map(n=>n.headroom).filter(n=>typeof n=="number");return t.length?Math.round(Math.max(...t)):null}function AG(e){const t=[...e].sort((s,o)=>{if(s.ready!==o.ready)return s.ready?-1:1;if(!s.ready)return s.name.localeCompare(o.name);const l=s.headroom,c=o.headroom;return l==null&&c==null?s.name.localeCompare(o.name):l==null?1:c==null?-1:c-l}),n=t.slice(0,EG),r=t.length-n.length;return{title:e.some(s=>s.ready)?"Where you could switch":"Nothing to switch to",shown:n,rest:r>0?`and ${r} more`:null}}function Fr(e,t){if(e==null)return"not seen";const n=Math.max(0,Math.round((t-e)/1e3));if(n<90)return"now";const r=Math.round(n/60);if(r<60)return`${r}m ago`;const s=Math.round(r/60);return s<48?`${s}h ago`:`${Math.round(s/24)}d ago`}const RG={keychain_unavailable:{short:"Keychain locked on the other Mac",long:`the other Mac could not export it. On that Mac: ${k0}. The next round brings it.`}};function eb(e){return e.why?Ot(RG,e.why)??Cd(e.why):null}const N0={"waiting for the other deck to accept this one":{text:"waiting for them to say yes",tone:"idle"},"that deck said no":{text:"it said no",tone:"bad"},"that deck pairs only by invite":{text:"it pairs only by invite",tone:"idle"},"this deck pairs only by invite":{text:"needs an invite · your setting",tone:"idle"}},MG={ECONNREFUSED:"not listening",EHOSTUNREACH:"no route to it",ENETUNREACH:"no network here",ETIMEDOUT:"no answer",ECONNRESET:"it hung up",EHOSTDOWN:"it is down",ENOTFOUND:"name not found",EACCES:"blocked here",EPIPE:"it hung up"};function IS(e){var r;const t=$G[e];if(t)return t;const n=(r=/\b(E[A-Z]{3,})\b/.exec(e))==null?void 0:r[1];return n&&MG[n]||e}const $G={"handshake timed out":"no answer","peer closed the connection":"it hung up","peer went quiet":"it stopped mid-sentence","bad reply":"it answered with nonsense","no manifest":"it would not say what it has","bad challenge":"it answered as somebody else","a different deck is answering at that address":"a different deck is at that address","that deck could not prove its own key":"it could not prove who it is","the other deck refused this one's proof":"it would not take this deck's word","the other deck refused this handshake":"it turned this deck away","that deck has this one pinned under a different key":"it knows this deck by another key"};function fh(e,t){var f;if(!e)return null;if(e.error&&((f=e.done)!=null&&f.length)){const p=fh({...e,error:void 0},t),g=` · ${Fr(e.at,t)}`;return{...p,text:`${p.text.slice(0,-g.length)}, then ${IS(e.error)}${g}`,tone:"bad"}}if(e.error)return N0[e.error]??{text:IS(e.error),tone:"bad"};const n=e.done??[];if(!n.length)return{text:`all logins fine · ${Fr(e.at,t)}`,tone:"idle"};const r=n.filter(p=>p.ok),s=r.length===1?"login":"logins",o=n.map(p=>({d:p,why:eb(p)})).filter(p=>p.why),l=[...new Set(o.map(p=>p.why.short))],c=l.length?`, ${l.join(", ")}`:"",d=o.length?o.map(p=>`${p.d.email}: ${p.why.long}`).join(" "):void 0,h=Fr(e.at,t);return r.length===n.length?{text:`${r.length} ${s} arrived${c} · ${h}`,tone:o.length?"warn":"ok",...d?{hint:d}:{}}:{text:`${r.length} of ${n.length} logins arrived${c} · ${h}`,tone:"bad",...d?{hint:d}:{}}}const IG=9e4;function OG({error:e,host:t,port:n},r,s,o=45317){if(e!=="handshake timed out")return null;const l=(t??"").trim();if(!l)return null;const c=r.filter(h=>h.addr===l&&h.port&&h.at>0&&s-h.at<IG);if(!c.length)return null;const d=[...new Set(c.map(h=>h.port))];if(n!=null&&!d.includes(n)){const h=d.length===1?`port ${d[0]}`:`ports ${d.join(" and ")}`;return`A deck at ${l} is announcing itself on ${h}, not on ${n}. This deck already hears it and dials it there, so this typed row has nothing to reach.`}return`That machine is running the deck — its beacon arrives here every half minute — and what this deck sends back never gets there. That is a firewall on ${l}, not a network fault. Whoever uses it can allow two ports: UDP ${o} and TCP ${n??d[0]}.`}function ph(e,t){var n,r;return(n=e.last)!=null&&n.error&&!N0[e.last.error]?!1:!!((r=e.last)!=null&&r.at&&t-e.last.at<tb||e.lastSeen!=null&&t-e.lastSeen<tb)}const tb=95e3;function LG(e,t){if(!e)return{text:"checking…",tone:"idle"};if(!e.enabled)return{text:"",tone:"idle"};if(e.stalled)return{text:`could not start — ${e.stalled}`,tone:"bad"};if(!e.running)return{text:"starting…",tone:"wait"};const n=(e.pending??[]).length;if(n)return{text:n===1?"1 deck is waiting for your answer":`${n} decks are waiting for your answer`,tone:"wait"};const r=(e.peers??[]).filter(p=>p.paired!==!1||p.met);if(!r.length)return{text:"no deck paired yet",tone:"idle"};const s=p=>p.waiting?LI(p.lastSeen,t):ph(p,t),o=p=>{var g;return!p.waiting&&((g=p.last)==null?void 0:g.error)==="waiting for the other deck to accept this one"},l=e.aliases??{};let c=0,d=0,h=0;for(const p of DI(r,g=>PI(g,g.peerFp??g.fp,l).name,g=>g.addr??"")){const g=p.filter(s);if(!g.length){h++;continue}c++,g.every(o)&&d++}if(c&&d===c)return{text:c===1?"1 deck found · waiting for them to accept":`${c} decks found · waiting for them to accept`,tone:"wait"};if(!c)return{text:h===1?"this deck cannot reach the one it is paired with":`this deck cannot reach any of its ${h} decks`,tone:"bad"};const f=c===1?"1 deck ready":`${c} decks ready`;return{text:h?`${f} · ${h} away`:f,tone:"ok"}}function PG(e,t,n){if(n)return"checking…";if(e==null)return"not checked yet";const r=Fr(e,t);return r==="now"?"checked just now":`checked ${r}`}function j0(e,t){const n=Math.max(0,Math.round((t-e)/1e3));if(n<90)return"just now";const r=Math.round(n/60);return r<60?`${r}m ago`:`${Math.round(r/60)}h ago`}function LI(e,t){return e!=null&&t-e<tb}function DG(e,t){if(e==null)return{text:"one-way · has not called yet",here:!1};const n=LI(e,t);return{text:n?"online · one-way, it calls in":`one-way · last online ${Fr(e,t)}`,here:n}}function OS(e,t,n){return t?"online":e.lastSeen!=null?`last online ${Fr(e.lastSeen,n)}`:e.waiting?"has not called yet":"never reached"}function FG(e,t){if(!e)return[];const n=[],r=new Set,s=(p,g)=>p.name.localeCompare(g.name,void 0,{numeric:!0}),o=e.aliases??{};for(const p of e.pending??[])!(p!=null&&p.fp)||r.has(p.fp)||(r.add(p.fp),n.push(BG(p,o,t)));const l=[],c=[];for(const p of e.peers??[]){const g=p.peerFp??p.fp;!g||r.has(g)||(r.add(g),!p.paired&&p.manual&&!p.met?c.push(qG(p,g,t)):l.push(UG(p,g,o,t)))}n.push(...HG(l).sort(s),...c.sort(s));const d=[];for(const p of e.strangers??[])!(p!=null&&p.fp)||r.has(p.fp)||(r.add(p.fp),d.push(zG(p,o,e.pairingMode)));n.push(...d.sort(s));const h=[];for(const p of e.declined??[])!(p!=null&&p.fp)||r.has(p.fp)||(r.add(p.fp),h.push(WG(p,o)));n.push(...h.sort(s));const f=new Map;for(const p of n)f.set(p.name,(f.get(p.name)??0)+1);for(const p of n)(f.get(p.name)??0)<2||!p.addr||(p.state=p.quiet||!p.state?p.addr:`${p.addr} · ${p.state}`,p.quiet=!1);return n}function BG(e,t,n){const r=mh(t,e.fp,e.name||e.fp);return{fp:e.fp,...r,addr:e.addr??"",kind:"asks",state:`wants to pair · ${j0(e.at,n)}`,tone:"wait",here:!0,hint:`${r.name} at ${e.addr}${e.via==="tailscale"?", over Tailscale,":""} is waiting for an answer.`,...gh(e.via)}}function qG(e,t,n){var o;const r=fh(e.last,n),s=e.addr?`${e.addr}:${e.port}`:"";return{fp:s,name:s||e.name||t,addr:e.addr??"",kind:"dialling",state:r?nb(r):"trying…",tone:r?r.tone:"idle",here:!1,hint:(o=e.last)!=null&&o.error?`Nothing has answered at ${s} yet — ${e.last.error}.`:`Dialling ${s} until something answers.`,...gh(e.via)}}function UG(e,t,n,r){var v,N,k,x;const s=fh(e.last,r),o=ph(e,r),l=e.addr?`${e.addr}:${e.port}`:"",c=e.waiting?DG(e.lastSeen,r):null,d=c?c.here:o,h=!c&&s?d?`online · ${nb(s)}`:`${nb(s)} · ${OS(e,d,r)}`:c?c.text:OS(e,d,r),f=(v=e.last)!=null&&v.error?N0[e.last.error]:null,p=!c&&d&&!((N=e.last)!=null&&N.error)&&!(((k=e.last)==null?void 0:k.done)??[]).length,g=PI(e,t,n);return{fp:t,...g,addr:e.addr??"",kind:"paired",state:h,quiet:p,tone:f?f.tone==="bad"?"bad":"wait":s?s.tone:d?"ok":"idle",here:c?c.here:o,...gh(e.via),hint:c?`${g.name} calls this deck, and this deck has no address to call back on — so it can repair its logins from here, and this deck cannot repair from it. ${e.lastSeen==null?"It has not called since this deck started.":`It last called ${Fr(e.lastSeen,r)}.`} Add its address through Add a deck, the link at the top of this view, to reach it either way.`:`${g.name}${l?` at ${l}`:""}${(x=e.last)!=null&&x.error?` — ${e.last.error}`:""}${s!=null&&s.hint?` — ${s.hint}`:""}`}}function PI(e,t,n){return e.manual&&!e.met?{name:e.addr?`${e.addr}:${e.port}`:""}:mh(n,t,e.name||t)}function zG(e,t,n){const r=mh(t,e.fp,e.name||e.fp);return{fp:e.fp,...r,addr:e.addr??"",kind:"nearby",state:n==="invite"?"needs an invite":"not paired yet",tone:"idle",here:!0,hint:e.via==="tailscale"?`${r.name} at ${e.addr} is on your tailnet and nothing is shared with it.`:`${r.name} at ${e.addr} is on this network and nothing is shared with it.`,...gh(e.via)}}function WG(e,t){const n=mh(t,e.fp,e.name||e.fp);return{fp:e.fp,...n,addr:e.addr??"",kind:"declined",state:"you said no",tone:"idle",here:!1,hint:`${n.name} asked and was turned away. It is not asking any more.`}}function mh(e,t,n){const r=t?e[t]:void 0;return r&&r!==n?{name:r,self:n}:{name:n}}function gh(e){return e==="tailscale"?{via:"tailscale"}:{}}function nb(e){return e.text.replace(/ · .*$/,"")}function HG(e){return DI(e,t=>t.name,t=>t.addr).map(VG)}function DI(e,t,n){const r=new Map;for(const o of e){const l=r.get(t(o));l?l.push(o):r.set(t(o),[o])}const s=[];for(const o of r.values()){const l=[...new Set(o.map(n).filter(Boolean))];if(l.length>1){for(const c of l)s.push(o.filter(d=>n(d)===c));for(const c of o)n(c)||s.push([c])}else s.push(o)}return s}function VG(e){const[t,...n]=[...e].sort((r,s)=>Number(s.here)-Number(r.here)||+!!s.addr-+!!r.addr);return n.length?{...t,twins:n}:t}function LS(e,t){return t?e.map(n=>t[n.fp]?{...n,name:t[n.fp]}:n):e}function ec(e,t){if(!e)return{};switch(t.kind){case"paired":return{peer:(e.peers??[]).find(n=>(n.peerFp??n.fp)===t.fp)??null};case"dialling":return{peer:(e.peers??[]).find(n=>n.manual&&!n.met&&`${n.addr}:${n.port}`===t.fp)??null};case"nearby":return{stranger:(e.strangers??[]).find(n=>n.fp===t.fp)??null};case"declined":return{stranger:(e.declined??[]).find(n=>n.fp===t.fp)??null};case"asks":return{stranger:(e.pending??[]).find(n=>n.fp===t.fp)??null}}}function GG(e,t){var o;if(!e)return{text:"checking…",tone:"idle",live:!1};if(!e.enabled)return{text:"Off",tone:"idle",live:!1};if(e.stalled)return{text:"could not start",tone:"bad",live:!1};if(!e.running)return{text:"starting…",tone:"wait",live:!1};const n=t.filter(l=>l.kind==="asks").length;if(n)return{text:n===1?"1 deck wants to pair":`${n} decks want to pair`,tone:"wait",live:!1};if((o=e.reach)!=null&&o.blocked)return{text:"nothing can get in",tone:"bad",live:!1};const r=t.filter(l=>l.kind==="paired");if(!r.length)return{text:"On · none paired yet",tone:"idle",live:!1};const s=r.filter(l=>l.here).length;return s?s===r.length?{text:`${s} online`,tone:"ok",live:!0}:{text:`${s} of ${r.length} online`,tone:"ok",live:!0}:{text:`none of ${r.length} online`,tone:"idle",live:!1}}function KG(e,t){const n=e.filter(f=>f.kind==="asks"),r=e.filter(f=>f.kind!=="asks"),s=r.filter(f=>f.here),o=r.filter(f=>!f.here),l=o.filter(f=>f.tone==="bad").length,c=t||s.length===0,d=c?[...s,...o]:s,h=r.filter(f=>f.kind==="paired").length;return{asks:n,rest:r,live:s,folded:o,troubled:l,showFolded:c,shown:d,paired:h}}function PS(e){return e.map(t=>({key:`${String(t.email??"").trim().toLowerCase()}@@${t.orgUuid??""}`,email:t.email??"",alive:t.alive===!0,shareable:t.collector==="ok"||t.collector==null&&!t.active}))}function YG(e,t,n){if(!(t!=null&&t.enabled)||!(t.shared??[]).includes(e))return!1;const r=(t.peers??[]).filter(s=>s.paired&&ph(s,n)).map(s=>{var o,l;return(l=(o=s.offers)==null?void 0:o.accounts)==null?void 0:l.find(c=>c.key===e)}).filter(s=>s!=null);return r.length>0&&r.every(s=>!s.alive)}function XG(e,t,n,r){if(!(n!=null&&n.enabled)||n.running===!1||!(n.shared??[]).includes(e))return!1;const s=String(t??"").trim().toLowerCase();return(n.peers??[]).some(o=>{var c,d,h,f;if(!o.paired||!ph(o,r))return!1;const l=(d=(c=o.offers)==null?void 0:c.accounts)==null?void 0:d.find(p=>p.key===e);return!(l!=null&&l.alive)||l.shareable===!1?!1:!((f=(h=o.last)==null?void 0:h.done)!=null&&f.some(p=>p.action==="heal"&&String(p.email??"").trim().toLowerCase()===s))})}const FI=160,BI=140;function ZG(){const[e,t]=y.useState(!1),n=y.useRef(0);return y.useEffect(()=>()=>window.clearTimeout(n.current),[]),{peek:e,openPeek:c=>{window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!0),c)},shutPeek:()=>{window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!1),BI)},holdPeek:()=>window.clearTimeout(n.current),dropPeek:()=>{window.clearTimeout(n.current),t(!1)}}}function JG(e){var t;return((t=e==null?void 0:e.detail)==null?void 0:t.fix)==="give_back"}function sr(e,t){return{text:e,giveBack:JG(t),done:!1}}async function QG(){try{return await(await fetch("/api/prefs/give-back",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json().catch(()=>null)}catch{return null}}const eK={cancelled:"Nothing changed — the password dialog was closed. The folder still belongs to another user.",timed_out:"Nothing changed — the password dialog was not answered in time.",busy:"The password dialog is already open. It may be behind this window."};function tK(e){if(e!=null&&e.ok)return{text:e.changed===!1?"The settings folder is already yours, and the deck has read it again. Try that once more.":"Done — the settings folder is yours again, and the deck has read it again. Try that once more.",giveBack:!1,done:!0};if(e==null)return{text:"Could not give it back — the deck did not answer.",giveBack:!0,done:!1};const t=e.reason?eK[e.reason]:void 0;return t?{text:t,giveBack:!0,done:!1}:{text:"macOS did not give the folder back. The deck's log has the command that does it by hand.",giveBack:!1,done:!1}}const rb=5e3,qI=6e4;function Tt(e,t){if(t==null)return`Could not ${e} — the deck did not answer.`;const n=t.reason?sK(t.reason,t.detail):void 0;return n?`Could not ${e} — ${n}`:t.reason?`Could not ${e} — the deck refused it (${t.reason}).`:`Could not ${e}.`}const nK={prefs_unreadable:"this deck cannot read its settings file, so it will not write over it. The file may belong to another user, for example after ccdeck was run with sudo. The deck's log names the file.",prefs_not_writable:"this deck is not allowed to save its settings. The settings folder may belong to another user, for example after ccdeck was run with sudo, or another program may be holding the file. The deck's log names the folder."},rK=new Set(["EACCES","EPERM"]);function sK(e,t){const n=nK[e];if(!n)return;const r=e==="prefs_unreadable"&&t?aK(t):void 0,s=t!=null&&t.code&&t.code!=="BADJSON"?` Error code: ${t.code}.`:"";return(r??n)+s}function aK({code:e,owner:t,on:n}){if(e==="BADJSON")return"its settings file is damaged and could not be moved aside, so it will not write over it. The deck's log names the file.";if(n==="folder"&&t==="other")return"this deck cannot open its settings folder, which belongs to another user, for example after ccdeck was run with sudo. The deck's log has the command that gives it back.";if(n==="folder"&&t==="you")return"this deck cannot open its own settings folder, so it will not write over what is in it. The deck's log names the folder.";if(t==="other")return"its settings file belongs to another user and could not be moved aside, so it will not write over it. The deck's log names the file.";if(t==="you")return"this deck cannot read its settings file although the file is yours, so it will not write over it. Something on this machine is blocking the read; the deck's log names the file.";if(e&&!rK.has(e))return"this deck cannot read its settings file, so it will not write over it. The deck's log names the file."}async function Go(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}function oK(e,t){const[n,r]=y.useState(null),[s,o]=y.useState([]),[l,c]=y.useState(null),[d,h]=y.useState(null),f=y.useRef(null),p=y.useCallback(O=>lh(f.current)?(f.current=O,c(O),!0):!1,[]),g=y.useCallback(()=>{f.current=null,x.current&&c(null)},[]),v=O=>{const I=ia(l,O);return{disabled:I.disabled,"aria-busy":I.busy}},[N,k]=y.useState(()=>Date.now()),x=y.useRef(!0),j=y.useRef(rb),b=y.useCallback(async()=>{var O,I;try{const[B,M]=await Promise.all([fetch("/api/lan").then($=>$.json()),fetch("/api/prefs").then($=>$.json())]);if(!x.current)return;B!=null&&B.ok&&r(B),M!=null&&M.ok&&o(Array.isArray((I=(O=M.prefs)==null?void 0:O.lan)==null?void 0:I.manual)?M.prefs.lan.manual:[]),j.current=(B==null?void 0:B.enabled)===!0?rb:qI}catch{}},[]);y.useEffect(()=>{x.current=!0;let O=0;const I=async()=>{k(Date.now()),await b(),x.current&&(O=window.setTimeout(I,j.current))};return I(),()=>{x.current=!1,window.clearTimeout(O)}},[b]);const _=y.useCallback(async()=>{const O=(n==null?void 0:n.enabled)===!0;if(p("switch"))try{const I=await Go("/api/prefs",{lan:{enabled:!O}});if(!x.current)return;I!=null&&I.ok?(h(null),O||t()):h(sr(Tt(O?"turn this off":"turn this on",I),I)),await b()}catch{x.current&&h(sr(Tt(O?"turn this off":"turn this on",null)))}finally{g()}},[n==null?void 0:n.enabled,b,p,g,t]),E=y.useCallback(async(O,I,B)=>{if(!p(`${O}:${I}`))return null;let M=null;try{const $=await Go("/api/lan/peer",{action:O,fp:I});if(!x.current)return null;$!=null&&$.ok?(r($),h(null)):(M=Tt(B,$),h(sr(M,$))),await b()}catch{M=Tt(B,null),x.current&&h(sr(M))}finally{g()}return M},[b,p,g]),R=y.useCallback(async O=>{if(!p(`drop:${O}`))return null;let I=null;try{const B=await Go("/api/prefs",{lan:{manual:s.filter(M=>M!==O)}});if(!x.current)return null;B!=null&&B.ok?(h(null),e()):(I=Tt("stop dialling that address",B),h(sr(I,B))),await b()}catch{I=Tt("stop dialling that address",null),x.current&&h(sr(I))}finally{g()}return I},[s,b,e,p,g]),C=y.useCallback(async(O,I)=>{if(!p(`alias:${O}`))return"Something else is still being saved. Try again in a moment.";try{const B=await Go("/api/lan/peer",{action:"alias",fp:O,name:I});return x.current?B!=null&&B.ok?(r(B),null):Tt("rename that deck",B):null}catch{return Tt("rename that deck",null)}finally{g()}},[p,g]),A=y.useCallback(async O=>{if(!p(`check:${O}`))return null;try{const I=await Go("/api/lan/sync",{fp:O});return x.current?I!=null&&I.ok?(r(I),e(),null):(I==null?void 0:I.reason)==="no_address"?"There is no address here to call it on. It calls this deck, and it is up to date each time it does.":Tt("check that deck",I):null}catch{return Tt("check that deck",null)}finally{g()}},[p,g,e]),U=y.useCallback(async()=>{if(p("check"))try{const O=await Go("/api/lan/sync",{});if(!x.current)return;O!=null&&O.ok?(r(O),h(null)):h(sr(Tt("check the other decks",O),O)),e()}catch{x.current&&h(sr(Tt("check the other decks",null)))}finally{g()}},[p,g,e]);return{status:n,manual:s,now:N,busy:l,failure:d,dismissFailure:()=>h(null),answerGiveBack:O=>{h(O),O.done&&(b(),e())},pressProps:v,load:b,toggle:_,answer:E,dropAddress:R,rename:C,checkOne:A,checkNow:U}}function iK(e){const[t,n]=y.useState(null),r=y.useRef(0);return y.useEffect(()=>{if(t==null)return;const o=window.setTimeout(()=>n(null),4e3);return()=>window.clearTimeout(o)},[t]),{armed:t,pressUnpair:o=>{const l=Date.now(),c=Yl({armedFor:t,target:o.fp,armedAt:r.current,now:l,gapMs:Kl});if(c==="arm"){n(o.fp),r.current=l;return}c!=="ignore"&&(n(null),e("unpair",o.fp,"unpair that deck"))}}}function UI({title:e,steps:t,finish:n,aside:r,onClose:s}){const o=y.useRef(null),l=ut(s,{focusRef:o}),c=gt(s),[d,h]=y.useState(0),f=d===t.length-1,p=t[d],g=k=>h(Math.max(0,Math.min(t.length-1,k)));y.useEffect(()=>{var k,x;Tn(((k=document.activeElement)==null?void 0:k.tagName)??null)&&((x=o.current)==null||x.focus())},[d]);const v=k=>{k.key!=="ArrowRight"&&k.key!=="ArrowLeft"||(k.preventDefault(),k.stopPropagation(),g(k.key==="ArrowRight"?d+1:d-1))},N=()=>{if(!f){g(d+1);return}n?n.act():s()};return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...c,role:"presentation",children:a.jsxs("div",{ref:l,className:"modal guide",onClick:k=>k.stopPropagation(),onKeyDown:v,role:"dialog","aria-modal":"true","aria-labelledby":"guide-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{id:"guide-title",className:"modal-tool-name",children:e}),a.jsxs("span",{className:"modal-tool-id",children:[d+1," / ",t.length]})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsx("div",{className:"guide-stage",children:p.art},d),a.jsx("p",{className:"guide-line","aria-live":"polite",children:p.line}),a.jsx("p",{className:"guide-tip",children:p.tip??""}),a.jsxs("div",{className:"guide-foot",children:[a.jsx("div",{className:"guide-dots",children:t.map((k,x)=>a.jsx("button",{type:"button",className:"glyph-btn guide-dot","aria-label":`Step ${x+1} of ${t.length}`,"aria-current":x===d?"step":void 0,onClick:()=>g(x)},x))}),f&&r&&a.jsx("button",{type:"button",className:"ap-lan-word guide-aside",onClick:r.act,children:r.label}),d>0&&a.jsx("button",{type:"button",className:"btn",onClick:()=>g(d-1),children:"Back"}),a.jsx("button",{ref:o,type:"button",className:"btn primary",onClick:N,children:f?(n==null?void 0:n.label)??"Done":"Next"})]})]})]})}),document.body)}const sb={ok:"ga-ok",warn:"ga-warn",accent:"ga-accent",flight:"ga-flight"};function Hn({children:e}){return a.jsx("svg",{className:"guide-art",viewBox:"0 0 440 200","aria-hidden":!0,focusable:"false",children:e})}function Wn({x:e,y:t=34,w:n=176,h:r=132,label:s}){return a.jsxs(a.Fragment,{children:[s&&a.jsx("text",{x:e+2,y:t-9,className:"ga-cap",children:s}),a.jsx("rect",{x:e,y:t,width:n,height:r,rx:10,className:"ga-screen"})]})}function ur({x:e,y:t,email:n,state:r,tone:s,bars:o}){return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:e+3,cy:t-4,r:3,className:sb[s]}),a.jsx("text",{x:e+12,y:t,className:"ga-t ga-mono",children:n}),a.jsx("text",{x:e+12,y:t+16,className:`ga-s ${sb[s]}`,children:r}),o==null?void 0:o.map((l,c)=>a.jsxs("g",{children:[a.jsx("text",{x:e,y:t+40+c*18,className:"ga-s",children:c?"7d":"5h"}),a.jsx("rect",{x:e+22,y:t+35+c*18,width:96,height:4,rx:2,className:"ga-track"}),a.jsx("rect",{x:e+22,y:t+35+c*18,width:96*l/100,height:4,rx:2,className:"ga-accent"}),a.jsxs("text",{x:e+148,y:t+40+c*18,className:"ga-s ga-accent",textAnchor:"end",children:[l,"%"]})]},c))]})}function zI({x:e,y:t,on:n}){return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:e,y:t,width:30,height:18,rx:9,className:n?"ga-switch-on":"ga-switch"}),a.jsx("circle",{cx:n?e+21:e+9,cy:t+9,r:6,className:n?"ga-knob-on":"ga-knob"})]})}function Uu({x:e,y:t,name:n,here:r=!0}){return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:e+3,cy:t-4,r:3,className:r?"ga-ok":"ga-dim"}),a.jsx("text",{x:e+12,y:t,className:r?"ga-t":"ga-s",children:n})]})}function DS({x:e,y:t,on:n}){return n?a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:e,y:t,width:12,height:12,rx:3,className:"ga-accent"}),a.jsx("path",{d:`M${e+3} ${t+6.2}l2.3 2.3 4-4.6`,className:"ga-tick"})]}):a.jsx("rect",{x:e+.5,y:t+.5,width:11,height:11,rx:3,className:"ga-box"})}function FS({x:e,y:t,d:n}){return a.jsx("path",{d:n,transform:`translate(${e} ${t})`,className:"ga-glyph"})}function S0({x:e,y:t}){return a.jsx("path",{d:`M${e} ${t}l0 13 3.4-3 2.4 5.2 2-.9-2.4-5.1 4.6-.2z`,className:"ga-pointer"})}function _0(){return a.jsxs(a.Fragment,{children:[a.jsx("circle",{r:9,className:"ga-key-bed"}),a.jsxs("g",{transform:"translate(-6 -6) scale(0.857)",className:"ga-key",children:[a.jsx("circle",{cx:4.6,cy:7,r:2.6}),a.jsx("path",{d:"M7.2 7h5.2M10.6 7v2.2M12.4 7v1.6"})]})]})}function Qo({x:e,y:t,w:n,title:r,sub:s,tone:o}){return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:e,y:t,width:n,height:40,rx:8,className:"ga-screen"}),a.jsx("rect",{x:e+6,y:t+10,width:3,height:20,rx:1.5,className:sb[o]}),a.jsx("text",{x:e+16,y:t+17,className:"ga-t ga-strong",children:r}),a.jsx("text",{x:e+16,y:t+31,className:"ga-s",children:s})]})}function oi({x:e,y:t,label:n,live:r}){return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:e,y:t,width:46,height:20,rx:10,className:r?"ga-chip-live":"ga-chip"}),a.jsx("text",{x:e+23,y:t+14,className:"ga-s ga-mono",textAnchor:"middle",children:n})]})}function Ad({x:e,y:t}){return a.jsxs(a.Fragment,{children:[a.jsx("text",{x:e,y:t,className:"ga-cap",children:"LOCAL NETWORK"}),a.jsx(zI,{x:e+118,y:t-13,on:!0})]})}function lK(){return a.jsxs(Hn,{children:[a.jsx("rect",{x:14,y:14,width:206,height:172,rx:10,className:"ga-screen"}),a.jsx("text",{x:28,y:38,className:"ga-t ga-strong",children:"Sessions"}),a.jsx("text",{x:206,y:38,className:"ga-s ga-warn",textAnchor:"end",children:"1 waiting"}),a.jsx("rect",{x:20,y:50,width:194,height:42,rx:6,className:"ga-bed-warn"}),a.jsx("circle",{cx:33,cy:64,r:7,className:"ga-ring-warn ga-ping"}),a.jsx("circle",{cx:33,cy:64,r:3.5,className:"ga-warn"}),a.jsx("text",{x:44,y:68,className:"ga-t",children:"api-server"}),a.jsx("text",{x:44,y:83,className:"ga-s ga-warn",children:"waiting 6m · Bash"}),a.jsx("circle",{cx:33,cy:108,r:3.5,className:"ga-flight"}),a.jsx("text",{x:44,y:112,className:"ga-t",children:"docs-site"}),a.jsx("text",{x:44,y:127,className:"ga-s",children:"running · 12 tools"}),a.jsx("circle",{cx:33,cy:150,r:3.5,className:"ga-ok"}),a.jsx("text",{x:44,y:154,className:"ga-t",children:"billing"}),a.jsx("text",{x:44,y:169,className:"ga-s",children:"done · $0.84"}),a.jsx("path",{d:"M216 71C234 71 230 100 244 100",className:"ga-arc"}),a.jsx("path",{d:"M239 96l5 4-5 4",className:"ga-arrow"}),a.jsx("rect",{x:248,y:44,width:178,height:112,rx:10,className:"ga-screen"}),a.jsx("text",{x:262,y:64,className:"ga-cap",children:"API-SERVER"}),a.jsx("line",{x1:248,y1:74,x2:426,y2:74,className:"ga-line"}),a.jsx("text",{x:262,y:96,className:"ga-s ga-mono",children:"Bash(npm test)"}),a.jsx("text",{x:262,y:116,className:"ga-t ga-mono ga-warn",children:"Allow this command?"}),a.jsx("text",{x:262,y:136,className:"ga-s ga-mono",children:"> 1. Yes 2. No"})]})}function cK(){return a.jsxs(Hn,{children:[a.jsx("path",{d:"M136 100C166 100 166 38 196 38",className:"ga-edge ga-flow"}),a.jsx("path",{d:"M136 100H196",className:"ga-edge ga-flow"}),a.jsx("path",{d:"M136 100C166 100 166 162 196 162",className:"ga-edge-done"}),a.jsx("path",{d:"M308 38H326M308 100H326",className:"ga-edge"}),a.jsx(Qo,{x:20,y:80,w:116,title:"main",sub:"Opus 5 · 9 tools",tone:"accent"}),a.jsx(Qo,{x:196,y:18,w:112,title:"explore",sub:"Haiku · 14 tools",tone:"flight"}),a.jsx(Qo,{x:196,y:80,w:112,title:"tests",sub:"Sonnet · 6 tools",tone:"flight"}),a.jsx(Qo,{x:196,y:142,w:112,title:"review",sub:"done · 38s",tone:"ok"}),a.jsx(oi,{x:326,y:28,label:"Read"}),a.jsx(oi,{x:380,y:28,label:"Grep",live:!0}),a.jsx(oi,{x:326,y:90,label:"Bash",live:!0})]})}function BS({x:e,y:t,label:n,pct:r,note:s}){return a.jsxs(a.Fragment,{children:[a.jsx("text",{x:e,y:t,className:"ga-s",children:n}),a.jsxs("text",{x:e+194,y:t,className:"ga-s ga-accent",textAnchor:"end",children:[r,"%"]}),a.jsx("rect",{x:e,y:t+7,width:194,height:5,rx:2.5,className:"ga-track"}),a.jsx("rect",{x:e,y:t+7,width:194*r/100,height:5,rx:2.5,className:"ga-accent"}),a.jsx("text",{x:e,y:t+26,className:"ga-s",children:s})]})}function uK(){return a.jsxs(Hn,{children:[a.jsx("rect",{x:14,y:30,width:172,height:140,rx:10,className:"ga-screen"}),a.jsx("text",{x:30,y:56,className:"ga-cap",children:"THIS SESSION"}),a.jsx("text",{x:30,y:98,className:"ga-big",children:"$3.66"}),a.jsx("text",{x:30,y:122,className:"ga-s",children:"Opus 5 · 1.2M tokens"}),a.jsx("text",{x:30,y:150,className:"ga-s",children:"$21.40 today"}),a.jsx("rect",{x:200,y:30,width:226,height:140,rx:10,className:"ga-screen"}),a.jsx("text",{x:216,y:56,className:"ga-cap",children:"CLAUDE QUOTA"}),a.jsx(BS,{x:216,y:80,label:"5-hour window",pct:24,note:"resets in 53m"}),a.jsx(BS,{x:216,y:124,label:"7-day window",pct:61,note:"resets in 4d"})]})}function dK(){return a.jsxs(Hn,{children:[a.jsx("rect",{x:14,y:40,width:172,height:120,rx:10,className:"ga-canvas"}),a.jsx(Qo,{x:30,y:80,w:140,title:"tests",sub:"Sonnet 5 · 6 tools",tone:"flight"}),a.jsx(S0,{x:156,y:106}),a.jsx("path",{d:"M170 92C186 92 184 60 200 60",className:"ga-arc"}),a.jsx("path",{d:"M195 56l5 4-5 4",className:"ga-arrow"}),a.jsx(Wn,{x:200,y:22,w:226,h:160}),a.jsx("text",{x:214,y:46,className:"ga-t ga-strong",children:"tests"}),a.jsx("text",{x:412,y:46,className:"ga-s",textAnchor:"end",children:"Sonnet 5 · 38s"}),a.jsx("line",{x1:200,y1:56,x2:426,y2:56,className:"ga-line"}),a.jsx("text",{x:214,y:76,className:"ga-cap",children:"PROMPT"}),a.jsx("text",{x:214,y:92,className:"ga-t",children:"Run the suite and fix what fails"}),a.jsx("text",{x:214,y:116,className:"ga-cap",children:"TOOLS · 6"}),a.jsx(oi,{x:214,y:122,label:"Read"}),a.jsx(oi,{x:266,y:122,label:"Edit"}),a.jsx(oi,{x:318,y:122,label:"Bash",live:!0}),a.jsx("text",{x:214,y:164,className:"ga-cap",children:"TOKENS"}),a.jsx("text",{x:214,y:178,className:"ga-s ga-mono",children:"41k in · 2.1k out · $0.12"})]})}function hK(){const e=[18,24,28,14,22,26,30,16,24,28,20,26];return a.jsxs(Hn,{children:[a.jsx(Wn,{x:14,y:20,w:412,h:160}),a.jsx("text",{x:28,y:44,className:"ga-t ga-strong",children:"This machine"}),a.jsx("text",{x:412,y:44,className:"ga-s",textAnchor:"end",children:"12 cores · up 10d"}),a.jsx("line",{x1:14,y1:56,x2:426,y2:56,className:"ga-line"}),a.jsx("text",{x:28,y:76,className:"ga-cap",children:"CORES"}),e.map((t,n)=>a.jsxs("g",{children:[a.jsx("rect",{x:28+n*15,y:82,width:10,height:30,rx:2,className:"ga-track"}),a.jsx("rect",{x:28+n*15,y:112-t,width:10,height:t,rx:2,className:"ga-accent"})]},n)),a.jsx("text",{x:28,y:136,className:"ga-cap",children:"MEMORY"}),a.jsx("rect",{x:28,y:143,width:178,height:5,rx:2.5,className:"ga-track"}),a.jsx("rect",{x:28,y:143,width:105,height:5,rx:2.5,className:"ga-accent"}),a.jsx("text",{x:28,y:165,className:"ga-s",children:"18.9 GB of 32.0 GB"}),a.jsx("text",{x:240,y:76,className:"ga-cap",children:"THERMAL"}),a.jsx("text",{x:240,y:100,className:"ga-big",children:"66 °C"}),a.jsx("text",{x:240,y:118,className:"ga-s ga-ok",children:"running at full speed"}),a.jsx("text",{x:240,y:142,className:"ga-cap",children:"BUSIEST PROCESSES"}),a.jsx("text",{x:240,y:160,className:"ga-s ga-mono",children:"node · claude"}),a.jsx("text",{x:412,y:160,className:"ga-s ga-mono",textAnchor:"end",children:"38%"}),a.jsx("text",{x:240,y:176,className:"ga-s ga-mono",children:"esbuild"}),a.jsx("text",{x:412,y:176,className:"ga-s ga-mono",textAnchor:"end",children:"21%"})]})}function fK(){return a.jsxs(Hn,{children:[a.jsx("rect",{x:14,y:40,width:188,height:120,rx:10,className:"ga-screen"}),a.jsx("text",{x:28,y:60,className:"ga-cap",children:"~/MY-PROJECT"}),a.jsx("line",{x1:14,y1:70,x2:202,y2:70,className:"ga-line"}),a.jsxs("text",{x:28,y:100,className:"ga-t ga-mono",children:[a.jsx("tspan",{className:"ga-accent",children:"$"})," claude"]}),a.jsx("rect",{x:86,y:90,width:7,height:13,className:"ga-caret ga-blink"}),a.jsx("text",{x:28,y:130,className:"ga-s ga-mono",children:"or: codex"}),a.jsx("path",{d:"M210 100H238",className:"ga-arc"}),a.jsx("path",{d:"M233 95l6 5-6 5",className:"ga-arrow"}),a.jsx("rect",{x:250,y:40,width:176,height:120,rx:10,className:"ga-canvas"}),a.jsx("g",{className:"ga-pop",children:a.jsx(Qo,{x:278,y:80,w:120,title:"my-project",sub:"Opus 5 · live",tone:"accent"})})]})}function pK(){return a.jsxs(Hn,{children:[a.jsx(Wn,{x:14,y:16,w:232,h:170}),a.jsx("text",{x:28,y:40,className:"ga-t ga-strong",children:"Claude accounts"}),a.jsx(FS,{x:196,y:33,d:"M7 2.2v9.6M2.2 7h9.6"}),a.jsx(FS,{x:220,y:33,d:"M3.3 10.7L10.7 3.3M5.2 3.3h5.5v5.5"}),a.jsx("line",{x1:14,y1:52,x2:246,y2:52,className:"ga-line"}),a.jsx(ur,{x:28,y:74,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),a.jsx("rect",{x:190,y:62,width:44,height:18,rx:9,className:"ga-accent"}),a.jsx("text",{x:212,y:74,className:"ga-s ga-on-accent",textAnchor:"middle",children:"active"}),a.jsx("line",{x1:14,y1:140,x2:246,y2:140,className:"ga-line"}),a.jsx(ur,{x:28,y:160,email:"personal@me.dev",state:"signed in",tone:"ok"}),a.jsx("rect",{x:188,y:148,width:46,height:18,rx:9,className:"ga-chip"}),a.jsx("text",{x:211,y:160,className:"ga-s",textAnchor:"middle",children:"switch"}),a.jsx(S0,{x:221,y:161}),a.jsx("path",{d:"M250 40C270 40 262 78 282 78",className:"ga-arc"}),a.jsx("path",{d:"M277 74l5 4-5 4",className:"ga-arrow"}),a.jsx(Wn,{x:282,y:62,w:144,h:64,label:"ANOTHER MACHINE"}),a.jsx("g",{className:"ga-pop",children:a.jsx(ur,{x:296,y:92,email:"work@team.dev",state:"shared here",tone:"ok"})})]})}function mK(){return a.jsxs(Hn,{children:[a.jsx(Wn,{x:14,label:"THIS MACHINE"}),a.jsx(Ad,{x:28,y:60}),a.jsx("g",{className:"ga-swap-out",children:a.jsx(ur,{x:28,y:98,email:"work@team.dev",state:"login expired",tone:"warn"})}),a.jsx("g",{className:"ga-swap-in",children:a.jsx(ur,{x:28,y:98,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),a.jsx(Wn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(Ad,{x:264,y:60}),a.jsx(ur,{x:264,y:98,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),a.jsx("path",{d:"M246 120C234 80 206 80 194 120",className:"ga-arc"}),a.jsx("g",{className:"ga-travel ga-travel-low",transform:"translate(220 90)",children:a.jsx(_0,{})})]})}const gK=[{art:a.jsx(lK,{}),line:"Sessions waiting on you top the session list, longest wait first.",tip:"A tone and a system notification when one stops to ask. The speaker in the topbar."},{art:a.jsx(cK,{}),line:"Every agent and subagent is a node. Tool calls light up as they run."},{art:a.jsx(dK,{}),line:"Double-click any node: its prompt, every tool call, tokens and timing."},{art:a.jsx(uK,{}),line:"What each session costs, and how much quota is left."},{art:a.jsx(hK,{}),line:"Cores, memory and heat while the agents run, and what is hogging them."},{art:a.jsx(pK,{}),line:"Several Claude accounts: switch, add one, share one to another machine."},{art:a.jsx(mK,{}),line:"Your machines repair each other's expired logins over the local network.",tip:"Open it from the row at the foot of the Claude accounts panel."},{art:a.jsx(fK,{}),line:"Run claude or codex in any folder. It shows up here on its own."}];function yK(){return a.jsxs(Hn,{children:[a.jsx(Wn,{x:14,label:"THIS MACHINE"}),a.jsx(ur,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"}),a.jsx("rect",{x:40,y:94,width:86,height:20,rx:10,className:"ga-pill-warn"}),a.jsx("text",{x:83,y:108,className:"ga-s ga-warn",textAnchor:"middle",children:"sign in again"}),a.jsx("line",{x1:198,y1:100,x2:242,y2:100,className:"ga-off"}),a.jsx(Wn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(ur,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]})]})}function wK(){return a.jsxs(Hn,{children:[a.jsx(Wn,{x:14,label:"THIS MACHINE"}),a.jsx(Ad,{x:28,y:60}),a.jsx(Uu,{x:28,y:92,name:"Ana's MacBook"}),a.jsx(Uu,{x:28,y:114,name:"Dorin's PC"}),a.jsx(Wn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(Ad,{x:264,y:60}),a.jsx(Uu,{x:264,y:92,name:"Your MacBook"}),a.jsx(Uu,{x:264,y:114,name:"Dorin's PC"}),a.jsx("line",{x1:196,y1:100,x2:244,y2:100,className:"ga-arc"}),a.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping"}),a.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping ga-ping-2"}),a.jsx("circle",{cx:220,cy:100,r:3,className:"ga-accent"})]})}function vK(){return a.jsxs(Hn,{children:[a.jsx("rect",{x:90,y:18,width:260,height:164,rx:10,className:"ga-screen"}),a.jsx("text",{x:106,y:42,className:"ga-t ga-strong",children:"This deck on the network"}),a.jsx("line",{x1:90,y1:54,x2:350,y2:54,className:"ga-line"}),a.jsx("text",{x:106,y:76,className:"ga-cap",children:"SHARE THESE ACCOUNTS"}),a.jsx(DS,{x:106,y:88,on:!0}),a.jsx("text",{x:126,y:98,className:"ga-t ga-mono",children:"work@team.dev"}),a.jsx(DS,{x:106,y:112}),a.jsx("text",{x:126,y:122,className:"ga-s ga-mono",children:"personal@me.dev"}),a.jsx("text",{x:106,y:150,className:"ga-cap",children:"PAIRING"}),a.jsx("text",{x:106,y:168,className:"ga-s",children:"Say yes to every deck that asks"}),a.jsx(zI,{x:304,y:157,on:!0}),a.jsx(S0,{x:115,y:97})]})}function xK(){return a.jsxs(Hn,{children:[a.jsx(Wn,{x:14,label:"THIS MACHINE"}),a.jsx("g",{className:"ga-swap-out",children:a.jsx(ur,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"})}),a.jsx("g",{className:"ga-swap-in",children:a.jsx(ur,{x:28,y:64,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),a.jsx(Wn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(ur,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),a.jsx("path",{d:"M246 96C234 56 206 56 194 96",className:"ga-arc"}),a.jsx("g",{className:"ga-travel",transform:"translate(220 66)",children:a.jsx(_0,{})})]})}const bK=[{art:a.jsx(yK,{}),line:"A login can expire on one machine while it still works on another."},{art:a.jsx(wK,{}),line:"Both decks are on. They find each other and ask to pair.",tip:"Not showing up? Add a deck, the link at the top, takes an address or invite."},{art:a.jsx(vK,{}),line:"Tick which logins this machine may hand out. Nothing is shared until you do."},{art:a.jsx(xK,{}),line:"An expired login is copied from a paired machine within a minute."}];function kK(){return a.jsxs("svg",{className:"guide-art",viewBox:"0 0 232 60","aria-hidden":!0,focusable:"false",children:[a.jsx("rect",{x:1,y:14,width:78,height:42,rx:7,className:"ga-screen"}),a.jsx("circle",{cx:13,cy:29,r:3,className:"ga-warn"}),a.jsx("rect",{x:21,y:27,width:46,height:4,rx:2,className:"ga-track"}),a.jsx("rect",{x:13,y:39,width:40,height:3,rx:1.5,className:"ga-track"}),a.jsx("rect",{x:153,y:14,width:78,height:42,rx:7,className:"ga-screen"}),a.jsx("circle",{cx:165,cy:29,r:3,className:"ga-ok"}),a.jsx("rect",{x:173,y:27,width:46,height:4,rx:2,className:"ga-track"}),a.jsx("rect",{x:165,y:39,width:40,height:3,rx:1.5,className:"ga-accent"}),a.jsx("path",{d:"M150 36C138 6 94 6 82 36",className:"ga-arc"}),a.jsx("g",{transform:"translate(116 13)",children:a.jsx(_0,{})})]})}const NK={panel:"Nothing here is stuck: whoever pastes an invite is the one dialling out. Ask them for one and paste it behind Add a deck, the link above, where an address can be typed too.",dialog:"Nothing here is stuck: whoever pastes an invite is the one dialling out. Ask them for one and paste it below, or type their address."},jK=1600;function WI({reach:e,where:t}){const[n,r]=y.useState(!1),s=y.useRef(!0);y.useEffect(()=>()=>{s.current=!1},[]);const o=(e==null?void 0:e.steps)??[],l=y.useCallback(async()=>{await eo(o.join(`
91
- `))&&s.current&&(r(!0),window.setTimeout(()=>{s.current&&r(!1)},jK))},[o]);if(!(e!=null&&e.blocked))return null;const c=e.shell==="sh",d=!!e.tool;return a.jsxs("div",{className:"ap-lan-reach",children:[a.jsx("p",{className:"lan-warn",children:e.text}),a.jsx("p",{className:"lan-note",children:NK[t]}),o.length>0&&a.jsxs("details",{className:"ap-lan-reach-fix",children:[a.jsx("summary",{children:"or let them find this deck on their own"}),a.jsxs("p",{className:"lan-note",children:[d?a.jsx(a.Fragment,{children:"Run this in a terminal on this machine. It applies at once, and this note goes away when another deck connects."}):c?a.jsx(a.Fragment,{children:"Run this in a terminal on this machine, then restart the deck."}):a.jsxs(a.Fragment,{children:["Run this in PowerShell ",a.jsx("strong",{children:"as Administrator"}),", then restart the deck."]}),e.category==="Public"&&a.jsx(a.Fragment,{children:" The first line marks this network as a home or office one — leave it out on a network you do not trust."}),e.unsure&&a.jsxs(a.Fragment,{children:[" ",e.unsure]})]}),a.jsx("pre",{className:"ap-lan-cmd",children:a.jsx("code",{children:o.join(`
92
- `)})}),a.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>void l(),title:c?"Copy these lines, then paste them into a terminal":"Copy these lines, then paste them into an elevated PowerShell",children:n?"copied":"copy command"})]})]})}function SK(e){const t=(e??"").trim(),n=t.lastIndexOf(":");if(n<=0||n===t.length-1)return null;const r=t.slice(0,n).trim(),s=Number(t.slice(n+1).trim());return!r||!Number.isInteger(s)||s<1||s>65535||r.includes(":")&&!(r.startsWith("[")&&r.endsWith("]"))?null:{addr:r,port:s}}function _K(e,t){const n=Math.max(0,Math.round((e-t)/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}async function Up(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}const EK={not_an_invite:"That is not an invite — paste the whole line they sent you.",expired:"That invite has run out. Ask them for a fresh one.",not_running:"This deck is not on the network yet. Turn Local network on, then try again."},TK={not_running:"This deck is not on the network yet. Turn Local network on, then make one."};function qS(e,t,n){return(t==null?void 0:t.reason)&&e[t.reason]||Tt(n,t)}function CK({status:e,manual:t,startWith:n,onClose:r,onChanged:s}){const o=y.useRef(null),l=y.useRef(null),c=y.useRef(null),d=y.useRef(null),h=e.pairingMode==="invite",f=ut(r,{focusRef:h?l:o}),p=gt(r),[g,v]=y.useState(""),[N,k]=y.useState(""),[x,j]=y.useState(null),[b,_]=y.useState(null),[E,R]=y.useState(null),[C,A]=y.useState(null),[U,L]=y.useState(()=>Date.now());y.useEffect(()=>{const Y=window.setInterval(()=>L(Date.now()),1e3);return()=>window.clearInterval(Y)},[]);const F=y.useRef(!0);y.useEffect(()=>()=>{F.current=!1},[]);const O=y.useRef(null),I=y.useRef(null),B=y.useCallback(Y=>lh(O.current)?(O.current=Y,R(Y),!0):!1,[]),M=y.useCallback(()=>{O.current=null,F.current&&R(null)},[]),$=Y=>{const Z=ia(E,Y);return{disabled:Z.disabled,"aria-busy":Z.busy}},P=Y=>(x==null?void 0:x.field)===Y?{"aria-invalid":!0,"aria-describedby":"lan-add-failure"}:{},G=Y=>j(Z=>Z&&Z.field===Y?null:Z),K=y.useCallback(async()=>{if(h)return;const Y=SK(g);if(!Y){j({text:AK(g),field:"addr"});return}const Z=`${Y.addr}:${Y.port}`,ee=e.peers.find(ne=>ne.addr===Y.addr&&ne.port===Y.port&&ne.paired);if(ee){j({text:`Already paired with ${ee.name} at that address.`,field:"addr"});return}if(t.includes(Z)){j({text:"This deck already calls that address.",field:"addr"});return}if(B("add"))try{const ne=await Up("/api/prefs",{lan:{manual:[...t,Z]}});if(!F.current)return;ne!=null&&ne.ok?(j(null),v(""),s(),r()):j({text:Tt("add that address",ne),field:"addr"})}catch{F.current&&j({text:Tt("add that address",null),field:"addr"})}finally{M()}},[g,h,t,e.peers,s,r,B,M]),q=y.useCallback(async Y=>{if(!B(`invite:${Y}`))return;const Z=Y==="make"?"make an invite":"cancel that invite";try{const ee=await Up("/api/lan/invite",{action:Y});if(!F.current)return;ee!=null&&ee.ok?(I.current=Y,j(null),_(null),s()):j({text:qS(TK,ee,Z)})}catch{F.current&&j({text:Tt(Z,null)})}finally{M()}},[s,B,M]),H=y.useCallback(async()=>{const Y=N.trim();if(!(!Y||!B("join"))){A(null);try{const Z=await Up("/api/lan/invite",{action:"join",token:Y});if(!F.current)return;Z!=null&&Z.ok?(k(""),j(null),s(),r()):(Z==null?void 0:Z.reason)==="unreachable"&&Array.isArray(Z.tried)&&Z.tried.length?(A(Z.tried),j(null)):(A(null),j({text:qS(EK,Z,"use that invite"),field:"join"}))}catch{F.current&&j({text:Tt("use that invite",null),field:"join"})}finally{M()}}},[N,s,r,B,M]),D=y.useCallback(async(Y,Z)=>{try{await navigator.clipboard.writeText(Y),_(Z),window.setTimeout(()=>{F.current&&_(ee=>ee===Z?null:ee)},1600)}catch{j({text:"Could not copy it — select the text and copy it by hand."})}},[]),W=e.invite&&e.invite.expiresAt>U?e.invite:null,J=y.useRef(!1);y.useEffect(()=>{n!=="invite"||J.current||W||(J.current=!0,q("make"))},[n,W,q]);const V=y.useRef(!1);y.useEffect(()=>{var Y;n!=="invite"||V.current||!W||(V.current=!0,(Y=c.current)==null||Y.focus())},[n,W]),y.useEffect(()=>{var Z,ee;const Y=I.current;!Y||Y==="make"!=!!W||(I.current=null,Tn(((Z=document.activeElement)==null?void 0:Z.tagName)??null)&&((ee=(Y==="make"?c:d).current)==null||ee.focus()))},[W]);const X=e.port!=null?(e.addrs??[]).map(Y=>`${Y}:${e.port}`):[];return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...p,role:"presentation",children:a.jsxs("div",{ref:f,className:"modal lan-add",onClick:Y=>Y.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-add-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"lan-add-title",className:"modal-tool-name",children:"Add a deck"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{className:"glyph-btn",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[x&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{id:"lan-add-failure",className:"ap-failure-text",children:x.text}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>j(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),a.jsx(WI,{reach:e.reach,where:"dialog"}),h&&a.jsx("div",{className:"modal-section",children:a.jsx("p",{className:"lan-note",children:"Adding by address is off while this deck pairs only by invite."})}),!h&&a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"By address"}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("input",{ref:o,className:"ap-manage-input ap-lan-input","aria-label":"Another deck's address",value:g,placeholder:"192.168.1.5:54340",spellCheck:!1,...P("addr"),onChange:Y=>{v(Y.target.value),G("addr")},onKeyDown:Y=>{Y.key==="Enter"&&K()}}),g.trim()!==""&&a.jsx("button",{type:"button",className:"ap-manage-btn",...$("add"),onClick:()=>void K(),title:"Add it to the decks this one calls, starting now.",children:"add"})]}),a.jsx("p",{className:"lan-note",children:"This deck calls that address until somebody there accepts."}),e.port!=null&&X.length>0&&a.jsxs("p",{className:"lan-note",children:["They type this deck’s own address into the same field on theirs:"," ",X.map((Y,Z)=>a.jsxs("span",{children:[Z>0&&" or ",a.jsx("code",{className:"ap-lan-code",children:Y})]},Y)),a.jsx("button",{type:"button",className:"ap-lan-word lan-copy",...$("copy:mine"),onClick:()=>void D(X.join(" "),"mine"),title:"Copy this deck's address, to send to whoever is adding it",children:b==="mine"?"copied":"copy"})]})]}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("h3",{className:"lan-h",children:["With an invite",!W&&a.jsx("button",{type:"button",className:"ap-lan-word lan-h-act",ref:d,...$("invite:make"),onClick:()=>void q("make"),title:"One piece of text you send them. They paste it, and the two decks pair — nobody has to press anything here.",children:E==="invite:make"?"making…":"make one to send"})]}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("input",{ref:l,className:"ap-manage-input ap-lan-input","aria-label":"An invite you were sent",value:N,placeholder:"paste one you were sent",spellCheck:!1,...P("join"),onChange:Y=>{k(Y.target.value),A(null),G("join")},onKeyDown:Y=>{Y.key==="Enter"&&H()}}),N.trim()!==""&&a.jsx("button",{type:"button",className:"ap-manage-btn",...$("join"),onClick:()=>void H(),title:"Reach that deck and pair with it. Nobody has to press anything there.",children:E==="join"?"joining…":"join"})]}),a.jsx("p",{className:"lan-note",children:"Pasting one pairs both decks on the spot — nobody has to accept."}),C&&a.jsxs("div",{className:"ap-lan-tried",children:[a.jsx("span",{className:"lan-note",children:"Nothing answered at any address in that invite. Check that deck is running with its Local network switch on."}),C.map(Y=>a.jsxs("span",{className:"ap-lan-tried-row",children:[a.jsx("code",{className:"ap-lan-code",children:Y.addr}),a.jsx("span",{className:"ap-lan-bad",children:Y.why})]},Y.addr))]}),W&&a.jsxs("div",{className:"ap-lan-invite",children:[a.jsxs("div",{className:"ap-lan-invite-head",children:[a.jsx("span",{className:"ap-lan-invite-title",children:"Send this to them"}),a.jsxs("span",{className:"ap-lan-invite-left",id:"lan-invite-left",children:[_K(W.expiresAt,U)," left"]})]}),a.jsx("code",{className:"ap-lan-token",children:W.token}),a.jsxs("div",{className:"ap-lan-acts",children:[a.jsx("button",{type:"button",className:"ap-manage-btn",ref:c,...$("copy:invite"),"aria-label":b==="invite"?"Invite copied":"Copy invite","aria-describedby":"lan-invite-left",onClick:()=>void D(W.token,"invite"),title:"Copy it, and send it however you already talk to them",children:b==="invite"?"copied":"copy"}),a.jsx("button",{type:"button",className:"ap-manage-btn",...$("invite:withdraw"),onClick:()=>void q("withdraw"),title:"Cancel it. Anybody already holding the text can no longer use it.",children:"cancel"})]}),a.jsx("p",{className:"lan-warn",children:"Anyone who gets this text can pair with this deck until it runs out."})]})]})]})]})}),document.body)}function AK(e){const t=(e??"").trim();if(t==="")return"Type an address and a port, like 192.168.1.5:54340.";if(!t.startsWith("[")&&(t.match(/:/g)??[]).length>1)return"Too many colons to split. Use that deck's IPv4 address or its name, like 192.168.1.5:54340.";if(!t.includes(":"))return`Add the port too, like ${t}:54340.`;const n=t.slice(t.lastIndexOf(":")+1).trim();return n===""?"That is missing its port — try 192.168.1.5:54340.":/^\d+$/.test(n)?`A port runs from 1 to 65535, and this one is ${n}.`:`A port is a number, and this one is "${n}".`}function RK({asks:e,pressProps:t,answer:n}){return a.jsx("div",{className:"ap-lan-asks",role:"alert",children:e.map(r=>a.jsxs("div",{className:"ap-lan-ask",children:[a.jsxs("span",{className:"ap-lan-ask-what",children:[a.jsx("strong",{className:"ap-lan-peer-name",children:r.name})," at ",a.jsx("code",{className:"ap-lan-code",children:r.addr})," wants to pair"]}),a.jsxs("span",{className:"ap-lan-ask-fp",id:`lan-ask-fp-${r.fp}`,children:["fingerprint ",a.jsx("code",{className:"ap-lan-code",children:r.fp})]}),a.jsxs("span",{className:"ap-lan-ask-acts",children:[a.jsx("button",{type:"button",className:"ap-manage-btn",...t(`accept:${r.fp}`),"aria-label":`Accept ${r.name}`,"aria-describedby":`lan-ask-fp-${r.fp}`,onClick:()=>void n("accept",r.fp,"accept that deck"),title:`Talk to this deck from now on. Its fingerprint is ${r.fp} — check it matches the one on their screen before you accept.`,children:"accept"}),a.jsx("button",{type:"button",className:"ap-manage-btn",...t(`dismiss:${r.fp}`),"aria-label":`Decline ${r.name}`,"aria-describedby":`lan-ask-fp-${r.fp}`,onClick:()=>void n("dismiss",r.fp,"decline that request"),title:"Say no. Nothing is shared, and that deck is told rather than left waiting.",children:"decline"})]})]},r.fp))})}function MK({rows:e,pairingMode:t,armed:n,pressProps:r,answer:s,dropAddress:o,onUnpair:l,onOpenPeer:c,onInvite:d}){return a.jsx("ul",{className:"ap-lan-here",children:e.map((h,f)=>a.jsxs("li",{className:"ap-lan-who","data-tone":h.tone,children:[a.jsx("i",{className:h.here?"ap-pulse":"ap-dot","aria-hidden":!0}),a.jsxs("span",{className:"ap-lan-who-name","aria-hidden":!0,children:[h.name,h.via==="tailscale"&&a.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]}),a.jsx("button",{type:"button",className:"ap-lan-who-open","aria-haspopup":"dialog","aria-describedby":`lan-who-state-${f}`,onClick:()=>c(h.fp),children:a.jsxs("span",{className:"vis-hidden",children:[h.name,h.via==="tailscale"?", over Tailscale":"",", details"]})}),a.jsx("span",{id:`lan-who-state-${f}`,className:h.quiet?"vis-hidden":"ap-lan-who-when",children:h.state}),h.kind==="nearby"&&t!=="invite"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...r(`accept:${h.fp}`),onClick:()=>void s("accept",h.fp,"reach that deck"),"aria-label":`Ask ${h.name} to pair`,title:`Send ${h.name} a request. Somebody at that machine has to accept it before anything is shared. Its fingerprint is ${h.fp}.`,children:"ask"}),(h.kind==="nearby"||h.kind==="declined")&&t==="invite"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do","aria-haspopup":"dialog",onClick:d,"aria-label":`Invite ${h.name} to pair`,title:`This deck pairs only by invite. Make one and send it to whoever is at ${h.name}.`,children:"invite"}),h.kind==="paired"&&a.jsx("button",{type:"button",className:`ap-manage-btn ap-lan-do danger${n===h.fp?" armed":""}`,...r(`unpair:${h.fp}`),onClick:()=>l(h),"aria-label":n===h.fp?`Confirm unpairing ${h.name}`:`Unpair ${h.name}`,title:n===h.fp?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this deck from now on",children:n===h.fp?"confirm":"unpair"}),h.kind==="dialling"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...r(`drop:${h.fp}`),onClick:()=>void o(h.fp),"aria-label":`Stop dialling ${h.name}`,title:"Stop trying this address. Nothing was ever paired here.",children:"stop"}),h.kind==="declined"&&t!=="invite"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...r(`allow:${h.fp}`),onClick:()=>void s("allow",h.fp,"let that deck ask again"),"aria-label":`Let ${h.name} ask again`,title:"Take the no back. That deck is still trying, so the request comes round again on its own.",children:"allow"})]},`${h.kind}:${h.fp}`))})}function $K(e){var t;return(t=e.tailscale)!=null&&t.exitNode?"Tailscale sends this machine's local network through an exit node, so decks on this network cannot find this one. Turn on Allow local network access in Tailscale's exit node menu to bring them back.":"This machine sends its local network through a VPN, so decks on this network cannot find this one. Allowing local network access in the VPN brings them back."}function IK({on:e,status:t}){return a.jsxs(a.Fragment,{children:[e&&a.jsx(WI,{reach:t==null?void 0:t.reach,where:"panel"}),e&&(t==null?void 0:t.deaf)&&a.jsx("p",{className:"ap-lan-fine",children:t.deaf}),e&&(t==null?void 0:t.lanTunneled)&&a.jsx("p",{className:"ap-lan-fine",children:$K(t)})]})}const US=["online","offline","loose"],OK={online:0,offline:1,loose:2};function LK(e){return e.kind==="declined"?null:e.kind==="paired"?e.here?"online":"offline":"loose"}const PK=76,DK=62,Rd=96,FK={1:[.62],2:[.58,1],3:[.42,.72,1]},BK=.2,qK=.16,UK=.05,zK=20,WK=17,zu=7,HK=30,VK=116,GK=6.6,KK=6,YK=e=>E0(e,null),XK=1.5,ZK=80,JK=.45,zS=40,QK=64,eY=150,WS=.3,HS=84,VS=8,tY=1.3,Md=6,nY=5.94,GS=7,KS=16,xl=4,YS=.16;function ab(e,t){return Math.PI*(3*(e+t)-Math.sqrt((3*e+t)*(e+3*t)))}function HI(e,t){return t<-Math.abs(e)*.6?"top":"bottom"}function rY(e,t){if(e<=2)return t%2===0?0:90;const n=360/e;return-90+(t%2===0?0:n/2)}function sY(e){return e.map((t,n)=>({...t,i:n})).sort((t,n)=>US.indexOf(t.tier)-US.indexOf(n.tier)||+(t.row.via==="tailscale")-+(n.row.via==="tailscale")||t.i-n.i).map(({row:t,tier:n})=>({row:t,tier:n}))}function XS(e,t){let n=2166136261^t;for(let r=0;r<e.length;r++)n^=e.charCodeAt(r),n=Math.imul(n,16777619);return(n>>>0)%2e4/1e4-1}function aY(e,t,n){const r=[...FK[e.length]??[]];for(let s=0;s<r.length;s++){const o=e[s];if(o<2)continue;const l=ab(t*r[s],n*r[s])/o;if(!(l>0)||l>=Rd)continue;const c=s+1<r.length?r[s+1]-BK:1;r[s]=Math.max(r[s],Math.min(c,r[s]*(Rd/l)*1.02))}return r}const Pa=(e,t)=>e.x0<t.x1&&t.x0<e.x1&&e.y0<t.y1&&t.y0<e.y1,zp={h:16,ch:6.1,maxW:100};function oY(e){const t=e?Math.max(80,e.length*7.2+16):128;return{x0:-t/2,y0:32,x1:t/2,y1:66}}function VI(e,t,n,r,s,o){const l=t==="loose"?WK:zK,c=!s||e.kind==="asks",d=c?HK:zp.h,h=s?zp.ch:GK,f=c?o.length:0,p=Math.min(s?zp.maxW:VK,Math.max(2*l,KI(e).length*h,f*KK)),g={x0:n-l,y0:r-l,x1:n+l,y1:r+l},v=HI(n,r)==="top"?{x0:n-p/2,y0:r-l-zu-d,x1:n+p/2,y1:r-l-zu}:{x0:n-p/2,y0:r+l+zu,x1:n+p/2,y1:r+l+zu+d};return[g,v]}const ob=e=>{const t=e.theta*Math.PI/180;return[Math.cos(t)*e.ring.rx*e.reach,Math.sin(t)*e.ring.ry*e.reach]},Wu=(e,t)=>((e-t)%360+540)%360-180;function ZS(e,t,n){const r=new Map;for(const f of e)r.has(f.ring)||r.set(f.ring,[]),r.get(f.ring).push(f);const s=()=>e.map(f=>{const[p,g]=ob(f);return VI(f.row,f.tier,p,g,t,f.caption)}),o=(f,p,g=!1)=>{if(f.count<=2&&!g)return!1;const v=f.theta+p*XK,N=r.get(f.ring),k=(f.count>2?360/f.count:f.turn)*JK,x=N[(f.index+1)%f.count],j=N[(f.index-1+f.count)%f.count];return!(x===f||(p>0?Wu(x.theta,v)>=k:Wu(v,j.theta)>=k))||v<f.lo||v>f.hi?!1:(f.theta=v,!0)},l=([f,p],[g,v])=>Pa(p,g)||Pa(v,f)||Pa(p,v)||Pa(f,g),c=([f,p])=>Pa(f,n)||Pa(p,n);for(let f=0;f<ZK;f++){const p=s();let g=!1;for(let v=0;v<e.length;v++){c(p[v])&&(g=o(e[v],Wu(e[v].theta,90)>=0?1:-1,!0)||g);for(let N=v+1;N<e.length;N++){if(!l(p[v],p[N]))continue;const k=e[v],x=e[N],j=x.ring.ring>k.ring.ring||x.ring===k.ring&&N>v?x:k,b=j===x?k:x,_=Wu(j.theta,b.theta)>=0?1:-1;g=o(j,_)||o(b,-_)||g}}if(!g)break}const d=s();let h=0;for(let f=0;f<d.length;f++){c(d[f])&&h++;for(let p=f+1;p<d.length;p++)l(d[f],d[p])&&h++}return h}const iY={online:0,offline:1,loose:1};function lY(e,t,n,r="",s=YK){const o=[];for(const l of[!0,!1]){const c=JS(e,t,n,r,OK,s,l);if(c.clashes===0)return c.named();if(o.push(c),c.layout.rings.length===3){const d=JS(e,t,n,r,iY,s,l),h={clashes:d.clashes,named:()=>({...d.named(),folded:!0})};if(h.clashes===0)return h.named();o.push(h)}if(!c.layout.zone)break}return o.reduce((l,c)=>c.clashes<l.clashes?c:l).named()}function JS(e,t,n,r,s,o,l=!0){const c=new Map;for(const B of e){const M=LK(B);if(!M)continue;const $=s[M];c.has($)||c.set($,[]),c.get($).push({row:B,tier:M})}const d=[...c.keys()].sort((B,M)=>B-M),h=Math.max(0,t/2-PK),f=Math.max(0,n/2-DK),p=aY(d.map(B=>c.get(B).length),h,f),g=d.map((B,M)=>({ring:B,rx:h*p[M],ry:f*p[M],count:c.get(B).length})),v=g.reduce((B,M)=>B+M.count,0),N=B=>B.row.via==="tailscale",k=[...c.values()].flat().filter(N).length,x=Math.max(0,...g.map(B=>{const M=c.get(B.ring).filter(N).length,$=ab(B.rx,B.ry);return M>0&&$>0?M*Rd*tY/$*360:0})),j=l&&k>0&&k<v?Math.min(eY,Math.max(QK,k/v*360,x)):0,b=zS-j/2,_=zS+j/2,E=[];let R=!1;g.forEach((B,M)=>{const $=sY(c.get(B.ring)),P=$.length,G=P>1&&ab(B.rx,B.ry)/P<Rd;G&&(R=!0);const K=M===g.length-1,q=K?-YS*(p[M]-(p[M-1]??0)):YS*(p[M+1]-p[M]),H=j>0?[{members:$.filter(W=>W.row.via!=="tailscale"),from:_,width:360-j},{members:$.filter(W=>W.row.via==="tailscale"),from:b+360,width:j}]:[{members:$,from:null,width:360}];let D=0;for(const W of H){const J=W.members.length;if(J===0)continue;const V=W.width/J,X=J>2;W.members.forEach(({row:Y,tier:Z},ee)=>{const ne=rr(Y),se=W.from==null?rY(J,M)+V*ee:W.from+V*(ee+.5),pe=X?XS(ne,1)*qK*V:0,ke=G&&D%2===1?1+q/p[M]:1,ae=X?XS(ne,2)*UK:0,fe=V*.3;E.push({row:Y,tier:Z,ring:B,index:D,count:P,theta:se+pe,reach:ke*(1+(K?-Math.abs(ae):ae)),lo:W.from==null?-1/0:W.from+fe,hi:W.from==null?1/0:W.from+W.width-fe,turn:V,caption:o(Y)}),D++})}});const C=oY(r);let A=ZS(E,R,C);A>0&&!R&&(R=!0,A=ZS(E,!0,C));const U=E.map((B,M)=>{const[$,P]=ob(B);return{row:B.row,tier:B.tier,ring:B.ring.ring,x:$,y:P,angle:cY(Math.atan2(P,$)*180/Math.PI),dist:Math.hypot($,P),side:HI($,P),order:M}}),L=g.reduce((B,M,$)=>c.get(M.ring).some(N)?Math.max(B,p[$]):B,0),F=B=>({from:b,to:_,inner:{rx:h*WS,ry:f*WS},outer:{rx:Math.min(t/2-8,h*L+B),ry:Math.min(n/2-8,f*L+B)},count:k}),O={nodes:U,rings:g,dense:R,zone:j>0?{...F(HS),labelAt:null}:null};return{layout:O,clashes:A,named:()=>{if(!O.zone)return O;const B=E.flatMap(P=>{const[G,K]=ob(P);return VI(P.row,P.tier,G,K,R,P.caption)});let M={...O.zone,labelAt:QS(O.zone,B)},$=M.outer;for(let P=HS+VS;M.labelAt==null;P+=VS){const G=F(P);if(G.outer.rx===$.rx&&G.outer.ry===$.ry)break;$=G.outer;const K=QS(G,B);K!=null&&(M={...G,labelAt:K})}return{...O,zone:M}}}}function GI(e){return`Tailscale · ${e} deck${e===1?"":"s"}`}function QS(e,t){const n={rx:e.outer.rx-Md,ry:e.outer.ry-Md};if(!(n.rx>0&&n.ry>0))return null;const r=Math.min(.5,2/Math.max(n.rx,n.ry)*(180/Math.PI)),s=[];for(let b=e.to;b>=e.from;b-=r){const _=b*Math.PI/180;s.push([Math.cos(_)*n.rx,Math.sin(_)*n.ry])}const o=GS+xl,l={x0:Math.min(...s.map(b=>b[0]))-o,x1:Math.max(...s.map(b=>b[0]))+o,y0:Math.min(...s.map(b=>b[1]))-o,y1:Math.max(...s.map(b=>b[1]))+o},c=t.map(b=>({x0:b.x0-xl,y0:b.y0-xl,x1:b.x1+xl,y1:b.y1+xl})).filter(b=>Pa(b,l)),d=(b,_)=>c.some(E=>b>E.x0&&b<E.x1&&_>E.y0&&_<E.y1),h=[],f=[];let p=0;s.forEach(([b,_],E)=>{E>0&&(p+=Math.hypot(b-s[E-1][0],_-s[E-1][1]));const R=Math.hypot(b,_)||1;let C=!1;for(let A=0;A<=GS&&!C;A+=1.75)C=d(b-b/R*A,_-_/R*A);h.push(p),f.push((f.at(-1)??0)+(C?1:0))});const g=GI(e.count).length*nY/2,v=g+KS,N=p-g-KS;if(!(p>0)||N<v)return null;const k=b=>{let _=0,E=h.length;for(;_<E;){const R=_+E>>1;h[R]<b?_=R+1:E=R}return _},x=b=>{const _=k(b-g),E=k(b+g+1e-9)-1;return E<_||f[E]-(_>0?f[_-1]:0)===0},j=p/2;for(let b=0;j-b>=v;b+=2)for(const _ of b===0?[j]:[j-b,j+b])if(x(_))return _/p;return null}function cY(e){return(e%360+360)%360}function uY(e){const t=n=>e.filter(n).length;return{paired:t(n=>n.kind==="paired"),online:t(n=>n.kind==="paired"&&n.here),offline:t(n=>n.kind==="paired"&&!n.here),nearby:t(n=>n.kind==="nearby"),asks:t(n=>n.kind==="asks"),dialling:t(n=>n.kind==="dialling"),declined:t(n=>n.kind==="declined"),tailnet:t(n=>n.kind!=="declined"&&n.via==="tailscale"),oneWay:t(n=>n.kind==="paired"&&!n.here&&n.state.startsWith("one-way"))}}function dY(e){const t=[];return e.asks&&t.push(e.asks===1?"1 deck wants to pair":`${e.asks} decks want to pair`),e.paired===0?t.push("no paired decks yet"):e.paired===1?t.push(e.online?"1 paired deck, online":"1 paired deck, away"):e.online===e.paired?t.push(`${e.paired} paired decks, all online`):t.push(`${e.online} of ${e.paired} paired decks online`),e.nearby&&t.push(`${e.nearby} nearby, not paired`),e.dialling&&t.push(`${e.dialling} still dialling`),t.join(" · ")}function E0(e,t){switch(e.kind){case"asks":return"wants to pair";case"nearby":return e.state;case"dialling":return YI(e)?`${e.name.slice(e.addr.length)} · dialling`:"dialling";case"declined":return"declined";case"paired":{if(e.here)return t?hY(t):"online";const n=ZI(e);return n?n==="now"?"away · just now":`away · ${n}`:e.state.startsWith("one-way")?"has not called yet":"away"}}}function KI(e){return YI(e)?e.addr:e.name}function YI(e){return e.kind==="dialling"&&!!e.addr&&e.name.startsWith(`${e.addr}:`)}function XI(e){if(e.kind!=="paired")return e.via==="tailscale"?`${e.state}, over Tailscale`:e.state;if(e.here)return e.via==="tailscale"?"online, over Tailscale":"online";const t=ZI(e),n=t?t==="now"?"away · last online just now":`away · last online ${t}`:e.state.startsWith("one-way")?e.state:"away";return e.via==="tailscale"?`${n}, over Tailscale`:n}function ZI(e){var t;return((t=/last online (.+)$/.exec(e.state))==null?void 0:t[1])??null}function hY(e){return e.trim().split(/\s+/).slice(0,2).join(" ")}function fY(e){var r;if(!e)return[];const t=(e.addrs??[]).map(s=>`${s}:${e.port}`),n=(r=e.tailscale)==null?void 0:r.addr;return n&&!(e.addrs??[]).includes(n)&&t.push(`${n}:${e.port}`),t}function rr(e){let t=e.fp;for(const n of e.twins??[])n.fp<t&&(t=n.fp);return t}function pY(e,t){if(e==null)return t;const n=((t-e)%360+540)%360-180;return e+n}function mY(e,t){if(e.asks)return e.asks===1?"1 deck wants to pair. Answer it in the Local network list, behind this map.":`${e.asks} decks want to pair. Answer them in the Local network list, behind this map.`;if(e.oneWay)return`${e.oneWay} away deck${e.oneWay===1?" only calls":"s only call"} in, and this deck has no address to call ${e.oneWay===1?"it":"them"} on. Add ${e.oneWay===1?"its address":"their addresses"} through Add a deck to reach ${e.oneWay===1?"it":"them"} both ways.`;if(e.dialling)return e.dialling===1?"1 address has never answered. Open it to stop dialling it.":`${e.dialling} addresses have never answered. Open one to stop dialling it.`;if(e.nearby){const n=e.nearby===1?"1 deck nearby is not paired.":`${e.nearby} decks nearby are not paired.`;return t==="invite"?`${n} ${JI}`:e.nearby===1?`${n} Open it to ask to pair.`:`${n} Open one to ask to pair.`}return null}const JI="This deck pairs by invite only. Send one from Add a deck.";function gY(e,t){switch(e.kind){case"asks":return"Waiting for your answer, in the Local network list behind this map.";case"dialling":return"Nothing has answered here yet. Its dialog can stop dialling it.";case"nearby":return t==="invite"?JI:"Not paired yet. Its dialog can ask to pair.";case"paired":return!e.here&&e.state.startsWith("one-way")?"It can reach this deck, not the other way. Add its address through Add a deck.":null;default:return null}}function yY(e){const t={bad:0,wait:1,idle:2,ok:3};return e.map((n,r)=>({l:n,i:r})).sort((n,r)=>t[n.l.tone]-t[r.l.tone]||n.i-r.i).map(({l:n})=>n)}function wY(e,t){const n=/^(\d+)\.(\d+)\.(\d+)/.exec(e??""),r=/^(\d+)\.(\d+)\.(\d+)/.exec(t??"");if(!n||!r)return null;for(let s=1;s<=3;s++){const o=Number(n[s])-Number(r[s]);if(o)return Math.sign(o)}return 0}function vY(e,t){const n=t?t.alive?t.shareable===!1?"cannot share here":"works here":"expired here":"not on this deck";if(e.alive&&e.shareable===!1)return{there:"cannot share there",here:n,note:null,tone:"idle"};if(!e.alive){const r=t&&!t.alive?"neither copy works — sign in again here":null;return{there:"broken there",here:n,note:r,tone:r?"bad":"idle"}}return t?t.alive?{there:"works there",here:n,note:null,tone:t.shareable===!1?"idle":"ok"}:{there:"works there",here:n,note:"repairs next round",tone:"wait"}:{there:"works there",here:n,note:"arrives next round",tone:"wait"}}function xY(e,t,n,r=null){var d;const s=new Map;for(const h of t)(d=s.get(h.key))!=null&&d.alive||s.set(h.key,h);const o=new Set(n),l=[],c=new Set;for(const h of e??[]){if(c.has(h.key))continue;c.add(h.key);const f=s.get(h.key)??null,p=o.has(h.key),g=vY(h,f),v=f?f.alive?f.shareable===!1?"unavailable":"works":"expired":"missing",N=!h.alive&&f&&!f.alive?g.note:[v==="works"?null:g.here,h.alive&&h.shareable!==!1?null:g.there,g.note].filter(Boolean).join(" · ")||null;l.push({key:h.key,email:h.email,here:v,there:h.alive?h.shareable===!1?"unavailable":"works":"broken",in:!h.alive||h.shareable===!1?"cut":g.tone==="wait"?"wait":"live",out:p&&f?f.alive&&f.shareable!==!1?"live":"cut":null,caption:N,tone:g.tone,usedThere:r===h.key})}for(const h of n){const f=s.get(h);!f||c.has(h)||(c.add(h),l.push({key:h,email:f.email,here:f.alive?f.shareable===!1?"unavailable":"works":"expired",there:"unknown",in:null,out:f.alive&&f.shareable!==!1?"live":"cut",caption:f.alive?f.shareable===!1?"cannot share here":null:"expired here",tone:f.alive?f.shareable===!1?"idle":"ok":"bad",usedThere:!1}))}return l}const bY=1e3;function kY(e,t){const n=new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),r=Fr(e,t);return`${n} · ${r==="now"?"just now":r}`}function ib(e){return e&&[e.version,e.os,e.arch].filter(Boolean).join(" · ")||null}const QI={works:"works here",expired:"expired here",missing:"not on this deck",unavailable:"cannot share here"},eO={works:"works there",broken:"broken there",unavailable:"cannot share there",unknown:"not offered by that deck"};function tO(e){const t=e.in&&e.out?"offered both ways":e.in?"offered by that deck":"offered by this deck";return`${QI[e.here]}, ${eO[e.there]}, ${t}${e.usedThere?", in use there":""}.`}function nO({row:e,source:t,status:n,accounts:r,now:s}){var V,X,Y,Z,ee;const{peer:o,stranger:l}=t,c=e.kind==="paired",d=e.self??e.name,h=e.kind!=="dialling",f=e.kind==="dialling"?null:e.fp,p=o?o.addr?`${o.addr}:${o.port}`:"":l?l.port?`${l.addr}:${l.port}`:l.addr:e.addr,g=(o==null?void 0:o.about)??null,v=((V=n.about)==null?void 0:V.version)??null,N=c?o!=null&&o.waiting?o.lastSeen!=null?"not said — it runs an older version":"not said yet — it says when it next calls":o!=null&&o.offers?"not said — it runs an older version":"not reached yet":"shown once paired",k=ib(n.about),x=ib(g),j=g!=null&&g.version&&v?wY(g.version,v):null,b=o?fh(o.last,s):null,_=o&&((X=o.last)!=null&&X.error)?OG({error:o.last.error,host:o.addr,port:o.port},[...n.strangers??[],...n.pending??[],...(n.peers??[]).filter(ne=>!ne.manual&&ne.addr).map(ne=>({fp:ne.fp,name:ne.name,addr:ne.addr,port:ne.port,at:ne.lastSeen??0}))],s):null,E=(Y=o==null?void 0:o.last)!=null&&Y.error&&b&&b.text!==o.last.error?o.last.error:null,R=((Z=o==null?void 0:o.last)==null?void 0:Z.done)??[],C=!!b&&!!E&&!e.quiet&&e.state.startsWith(b.text),A=c||e.kind==="dialling",U=((o==null?void 0:o.via)??e.via)==="tailscale",L=o?o.waiting?null:o.manual?U?"added by its Tailscale address":"added by address":U?"over Tailscale":"on this network":e.kind==="nearby"?U?"heard over Tailscale":"heard on this network":U?"asked this deck to pair, over Tailscale":"asked this deck to pair",F=e.tone==="bad"?"bad":c?e.here?"up":"down":"loose",O=(o==null?void 0:o.offers)??null,I=F==="up"?(O==null?void 0:O.current)??null:null,B=I&&"key"in I?I.key:null,M=!!I&&"hidden"in I,$=!!I&&"other"in I,P=c?xY((O==null?void 0:O.accounts)??null,r,n.shared??[],B):[],G=P.filter(ne=>ne.in==null&&ne.out==="cut"),K=P.some(ne=>ne.in!=null),q=P.some(ne=>ne.out!=null),H=new Map(R.map(ne=>[ne.email,ne])),D=R.filter(ne=>!P.some(se=>se.email===ne.email)),W=c?O?O.accounts.length===0?"That deck offers nothing. Nobody there has chosen a login to share.":null:o!=null&&o.waiting?"What that deck offers is not known yet. A deck that calls in says so each time it calls — one on an older version never does.":(ee=o==null?void 0:o.last)!=null&&ee.error?"What that deck offers is not known — the last attempt to ask it did not get through.":"Nobody has asked that deck what it offers yet. The next round asks it.":null,J=O&&(o!=null&&o.last)&&o.last.at-O.at>bY?Fr(O.at,s):null;return{peer:o,stranger:l,paired:c,own:d,canRename:h,fp:f,where:p,about:g,unsaid:N,hereRuns:k,thereRuns:x,order:j,line:b,silence:_,raw:E,echoed:C,showRound:A,how:L,link:F,hiddenThere:M,otherThere:$,lanes:P,spent:G,taking:K,giving:q,told:H,unplaced:D,unknown:W,stale:J}}function lb(){return a.jsxs("svg",{className:"lan-machine",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("rect",{x:"2.5",y:"3",width:"11",height:"7.5",rx:"1.2"}),a.jsx("path",{d:"M1 13h14"})]})}function Hu({dir:e}){return a.jsx("svg",{className:"lan-chev","data-dir":e,width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:e==="out"?"M2.8 1L6 4 2.8 7":"M5.2 1L2 4l3.2 3"})})}function NY({view:e,row:t,status:n,asking:r,drawn:s,onSettings:o}){const{peer:l,paired:c,where:d,about:h,unsaid:f,hereRuns:p,thereRuns:g,order:v,line:N,silence:k,raw:x,echoed:j,showRound:b,how:_,link:E,hiddenThere:R,otherThere:C,lanes:A,spent:U,taking:L,giving:F,told:O,unplaced:I,unknown:B,stale:M}=e;return a.jsxs("div",{className:"lan-map","data-link":E,"data-asking":r||void 0,"data-bus":A.length>0||void 0,children:[a.jsxs("div",{className:"lan-ends",children:[a.jsxs("p",{className:"lan-end",children:[a.jsx("span",{className:"lan-end-name",children:"This deck"}),p&&a.jsx("span",{className:"lan-end-runs",children:p}),c&&n.shareActive===!1&&a.jsx("span",{className:"lan-end-note",children:"current account hidden"})]}),a.jsxs("p",{className:"lan-end","data-side":"there",children:[a.jsx("span",{className:"lan-end-name",children:t.name}),t.kind!=="dialling"&&a.jsxs("span",{className:"lan-end-runs",children:[g??(h?"not said":f),v?` · ${v<0?"older":"newer"}`:null]}),R&&a.jsx("span",{className:"lan-end-note",children:"current account hidden"}),C&&a.jsx("span",{className:"lan-end-note",children:"on another account"})]})]}),a.jsxs("div",{className:"lan-link",children:[a.jsx(lb,{}),a.jsxs("span",{className:"lan-span",children:[a.jsxs("span",{className:"lan-wire","aria-hidden":!0,children:[a.jsx("i",{className:"lan-glint","data-dir":"out"}),a.jsx("i",{className:"lan-glint","data-dir":"in"})]}),a.jsx("span",{className:"lan-link-label",children:d?a.jsx("code",{className:"ap-lan-code",children:d}):"none here — it calls this deck"})]}),a.jsx(lb,{}),(d&&_||b)&&a.jsxs("p",{className:"lan-link-sub",children:[d&&_,d&&_&&b&&" · ",b&&(N?j?a.jsx("code",{className:"ap-lan-code",children:x}):a.jsx("span",{className:"lan-round","data-tone":N.tone,children:N.text.replace(/ · now$/," · just now")}):"not asked yet"),b&&x&&!j&&a.jsx("code",{className:"lan-fact-raw",children:x})]}),I.length>0&&a.jsx("ul",{className:"lan-done",children:I.map($=>{const P=eb($);return a.jsxs("li",{"data-ok":$.ok&&!P,children:[$.email," ",a.jsxs("span",{className:"lan-done-what",children:[$.ok?"arrived":"did not arrive",P&&` — ${P.long}`]})]},`${$.email}:${$.action}`)})}),k&&a.jsx("p",{className:"lan-note lan-link-note",children:k}),(l==null?void 0:l.waiting)&&a.jsx("p",{className:"lan-note lan-link-note",children:t.hint}),(N==null?void 0:N.hint)&&a.jsx("p",{className:"lan-note lan-link-note",children:N.hint})]}),A.length>0&&a.jsx("ul",{className:"lan-lanes",role:"list","aria-label":`Logins between this deck and ${t.name}`,children:A.map(($,P)=>{const G=O.get($.email),K=G?eb(G):null,q=$.out==="live"||$.in!=null&&$.in!=="cut";return a.jsxs("li",{role:"listitem",className:"lan-lane","data-tone":$.tone,"data-draw":$.in&&$.out?"both":$.in?"in":"out","data-used-there":$.usedThere||void 0,style:{"--i":P},children:[a.jsx("i",{className:"lan-pip","data-end":"here","data-state":$.here,"aria-hidden":!0}),a.jsxs("span",{className:"lan-track",children:[a.jsxs("span",{className:"lan-wire","data-flow":q?"live":"cut","aria-hidden":!0,children:[($.in==="live"||$.in==="wait")&&a.jsx("i",{className:"lan-glint","data-dir":"in","data-tone":$.in}),$.out==="live"&&a.jsx("i",{className:"lan-glint","data-dir":"out"})]}),$.in&&$.in!=="cut"&&a.jsx(Hu,{dir:"in"}),$.out==="live"&&a.jsx(Hu,{dir:"out"}),a.jsx("span",{className:"lan-lane-email",children:$.email})]}),a.jsx("i",{className:"lan-pip","data-end":"there","data-state":$.there,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:tO($)}),($.caption||G)&&a.jsxs("span",{className:"lan-lane-note",children:[$.caption,$.caption&&G&&" · ",G&&a.jsxs("span",{className:"lan-lane-done","data-ok":G.ok&&!K,children:[G.ok?"arrived last round":"did not arrive last round",K&&` — ${K.long}`]})]})]},$.key)})},s),c&&a.jsxs(a.Fragment,{children:[U.length>0&&a.jsxs("p",{className:"lan-spent",children:["Paired decks get nothing from ",U.length===1?U[0].email:"the expired ones"," until you sign in again here."]}),B&&a.jsx("p",{className:"lan-empty",children:B}),M&&a.jsxs("p",{className:"lan-stale",children:["As of ",M==="now"?"just now":M,", when it last answered."]}),a.jsxs("div",{className:"lan-legend",children:[L&&a.jsxs("span",{className:"lan-key",children:[a.jsx("span",{className:"lan-key-wire","data-dir":"in","aria-hidden":!0,children:a.jsx(Hu,{dir:"in"})}),"from ",t.name]}),F?a.jsxs("span",{className:"lan-key",children:[a.jsx("span",{className:"lan-key-wire","data-dir":"out","aria-hidden":!0,children:a.jsx(Hu,{dir:"out"})}),"from this deck, to every paired deck"]}):a.jsx("span",{className:"lan-key",children:"This deck offers nothing yet."}),a.jsx("button",{type:"button",className:"ap-lan-word lan-legend-act",onClick:o,"aria-label":"Change what this deck offers",children:"change"})]})]})]})}const jY=20,SY=17,e_=34,_Y=160,EY=80,TY=200,CY=8,AY=14,RY=10,MY=.61803398875;function $Y({status:e,rows:t,accounts:n,now:r,covered:s,onOpenDeck:o,onClose:l}){const c=y.useRef(null),d=ut(l,{focusRef:c}),h=gt(l),f=y.useRef(null),[p,g]=y.useState(null),[v,N]=y.useState(!1),k=y.useRef(null);y.useLayoutEffect(()=>{const ae=f.current;if(!ae)return;let fe=null;const me=()=>{const ge=Math.round(ae.clientWidth),ue=Math.round(ae.clientHeight);fe&&fe.w===ge&&fe.h===ue||(fe&&(N(!0),k.current!=null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>N(!1),TY)),fe={w:ge,h:ue},g(fe))};if(me(),typeof ResizeObserver>"u")return;const he=new ResizeObserver(me);return he.observe(ae),()=>{he.disconnect(),k.current!=null&&window.clearTimeout(k.current)}},[]);const x=y.useMemo(()=>p?lY(t,p.w,p.h,(e==null?void 0:e.name)??"",ae=>{var fe,me;return E0(ae,(me=(fe=ec(e,ae).peer)==null?void 0:fe.about)==null?void 0:me.os)}):null,[t,p,e]),j=y.useMemo(()=>uY(t),[t]),b=(x==null?void 0:x.nodes)??[],_=y.useRef(new Map),E=y.useMemo(()=>{const ae=new Map;for(const fe of b){const me=rr(fe.row);ae.set(me,pY(_.current.get(me),fe.angle))}return _.current=ae,ae},[b]),[R,C]=y.useState(null),[A,U]=y.useState(null),[L,F]=y.useState("none"),O=y.useRef(null),I=y.useCallback((ae,fe)=>{O.current!==ae&&(O.current=ae,F(fe),U(ae))},[]),B=y.useRef(null),M=y.useRef(null),$=y.useCallback(()=>{M.current!=null&&window.clearTimeout(M.current),M.current=null},[]),P=y.useCallback((ae,fe)=>{if(B.current!=null&&window.clearTimeout(B.current),B.current=null,$(),C(ae),fe==="keyboard"){I(ae,"none");return}M.current=window.setTimeout(()=>I(ae,O.current?"swap":"full"),EY)},[I,$]),G=y.useCallback(()=>{B.current!=null&&window.clearTimeout(B.current),$(),B.current=window.setTimeout(()=>C(null),_Y)},[$]);y.useEffect(()=>()=>{B.current!=null&&window.clearTimeout(B.current),$()},[$]);const K=R&&b.some(ae=>rr(ae.row)===R)?R:null,q=A?t.find(ae=>rr(ae)===A)??null:null;y.useEffect(()=>{A&&!q&&I(null,"swap")},[A,q,I]);const[H,D]=y.useState(null),W=y.useRef(new Map),J=b.findIndex(ae=>rr(ae.row)===H),V=J<0?0:J,X=ae=>{var ge;if(b.length===0)return;const fe=ae.key==="ArrowRight"||ae.key==="ArrowDown"?1:ae.key==="ArrowLeft"||ae.key==="ArrowUp"?-1:0,me=ae.key==="Home"?0:ae.key==="End"?b.length-1:fe?(V+fe+b.length)%b.length:null;if(me==null)return;ae.preventDefault();const he=rr(b[me].row);D(he),(ge=W.current.get(he))==null||ge.focus()},[Y,Z]=y.useState(()=>typeof document<"u"&&document.hidden);y.useEffect(()=>{const ae=()=>Z(document.hidden);return document.addEventListener("visibilitychange",ae),()=>document.removeEventListener("visibilitychange",ae)},[]);const ee=(e==null?void 0:e.enabled)===!0,ne=e?ee?dY(j):"Local network is off":"checking…",se=()=>{$(),I(null,"swap"),C(null)},pe=K?b.find(ae=>rr(ae.row)===K)??null:null,ke=()=>{var ae;A&&((ae=W.current.get(A))==null||ae.focus()),se()};return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...h,role:"presentation",children:a.jsxs("div",{ref:d,className:"modal nm-modal",onClick:ae=>ae.stopPropagation(),"data-paused":s||Y||void 0,role:"dialog","aria-modal":"true","aria-labelledby":"nm-title","aria-describedby":"nm-sub",children:[a.jsxs("header",{className:"modal-head nm-head",children:[a.jsxs("div",{className:"nm-heading",children:[a.jsx("h2",{id:"nm-title",className:"modal-title nm-title",children:"Network map"}),a.jsx("p",{id:"nm-sub",className:"nm-sub",children:ne})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:c,type:"button",className:"glyph-btn",onClick:l,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("div",{className:"nm-body",children:[a.jsxs("div",{className:"nm-view",children:[a.jsx("div",{ref:f,className:"nm-stage","data-focus":K?"":void 0,"data-focus-via":pe==null?void 0:pe.row.via,"data-dense":(x==null?void 0:x.dense)||void 0,"data-still":v||void 0,onClick:ae=>{ae.target===ae.currentTarget&&se()},children:p&&x&&a.jsxs(a.Fragment,{children:[a.jsx(IY,{layout:x,w:p.w,h:p.h}),b.map(ae=>{const fe=rr(ae.row);return a.jsx(PY,{node:ae,angle:E.get(fe)??ae.angle,lit:K===fe},fe)}),a.jsx(DY,{status:e}),a.jsx("span",{id:"nm-ring-hint",className:"vis-hidden",children:"Arrow keys move between decks. Enter opens the deck's own dialog."}),a.jsx("div",{className:"nm-ring",role:"group","aria-label":`Decks around this deck, ${b.length}`,"aria-describedby":"nm-ring-hint",onKeyDown:X,children:b.map((ae,fe)=>{var he,ge;const me=rr(ae.row);return a.jsx(FY,{node:ae,angle:E.get(me)??ae.angle,os:(ge=(he=ec(e,ae.row).peer)==null?void 0:he.about)==null?void 0:ge.os,lit:K===me,shown:A===me,tabbable:fe===V,register:ue=>{ue?W.current.set(me,ue):W.current.delete(me)},onHold:ue=>{D(me),P(me,ue)},onRelease:G,onOpen:()=>o(ae.row.fp)},me)})}),b.length===0&&a.jsx(BY,{status:e})]})}),a.jsx(qY,{slice:(x==null?void 0:x.zone)!=null})]}),a.jsx("aside",{className:"nm-side","aria-label":"Details",children:q&&e?a.jsx(zY,{row:q,status:e,accounts:n,now:r,entrance:L,onOpen:()=>o(q.fp),onBack:ke},rr(q)):a.jsx(UY,{status:e,summary:j,entrance:L,slice:(x==null?void 0:x.zone)!=null})})]})]})}),document.body)}function rO(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("circle",{cx:"7",cy:"7.4",r:"1.8"}),a.jsx("circle",{cx:"2.4",cy:"2.9",r:"1.2"}),a.jsx("circle",{cx:"11.6",cy:"2.9",r:"1.2"}),a.jsx("circle",{cx:"7",cy:"12.4",r:"1.1"}),a.jsx("path",{d:"M5.7 6.1 3.3 3.8M8.3 6.1l2.4-2.3M7 9.2v2.1"})]})}function IY({layout:e,w:t,h:n}){const{zone:r}=e;return a.jsxs("svg",{className:"nm-orbits",width:t,height:n,viewBox:`0 0 ${t} ${n}`,"aria-hidden":!0,children:[r&&a.jsxs(a.Fragment,{children:[a.jsxs("defs",{children:[a.jsx("path",{id:"nm-zone-arc",d:LY(r,t/2,n/2)}),a.jsxs("radialGradient",{id:"nm-zone-fill",gradientUnits:"userSpaceOnUse",cx:t/2,cy:n/2,r:Math.max(r.outer.rx,r.outer.ry),children:[a.jsx("stop",{className:"nm-zone-stop",offset:"0.2","data-at":"in"}),a.jsx("stop",{className:"nm-zone-stop",offset:"0.5","data-at":"mid"}),a.jsx("stop",{className:"nm-zone-stop",offset:"1","data-at":"out"})]})]}),a.jsx("path",{className:"nm-zone",d:OY(r,t/2,n/2),fill:"url(#nm-zone-fill)"}),r.labelAt!=null&&a.jsx("text",{className:"nm-zone-label",children:a.jsx("textPath",{href:"#nm-zone-arc",startOffset:`${(r.labelAt*100).toFixed(2)}%`,textAnchor:"middle",children:GI(r.count)})})]}),e.rings.map((s,o)=>a.jsx("ellipse",{className:"nm-orbit","data-ring":s.ring,"data-folded":e.folded&&s.ring===1||void 0,cx:t/2,cy:n/2,rx:s.rx,ry:s.ry,style:{"--ring":o}},s.ring))]})}function t_(e,t,n,r){const s=r*Math.PI/180;return`${(t+Math.cos(s)*e.rx).toFixed(1)},${(n+Math.sin(s)*e.ry).toFixed(1)}`}function OY(e,t,n){const r=e.to-e.from>180?1:0,s=(j,b)=>{const _=b*Math.PI/180;return[t+Math.cos(_)*j.rx,n+Math.sin(_)*j.ry]},o=(j,b)=>b/((j.rx+j.ry)/2)*(180/Math.PI),l=(j,b,_)=>{const E=Math.hypot(b[0]-j[0],b[1]-j[1])||1,R=Math.min(.5,_/E);return[j[0]+(b[0]-j[0])*R,j[1]+(b[1]-j[1])*R]},c=([j,b])=>`${j.toFixed(1)},${b.toFixed(1)}`,d=RY,h=AY,f=o(e.inner,d),p=o(e.outer,h),g=s(e.inner,e.from),v=s(e.outer,e.from),N=s(e.outer,e.to),k=s(e.inner,e.to),x=j=>`${j.rx.toFixed(1)},${j.ry.toFixed(1)}`;return[`M${c(s(e.inner,e.from+f))}`,`Q${c(g)} ${c(l(g,v,d))}`,`L${c(l(v,g,h))}`,`Q${c(v)} ${c(s(e.outer,e.from+p))}`,`A${x(e.outer)} 0 ${r} 1 ${c(s(e.outer,e.to-p))}`,`Q${c(N)} ${c(l(N,k,h))}`,`L${c(l(k,N,d))}`,`Q${c(k)} ${c(s(e.inner,e.to-f))}`,`A${x(e.inner)} 0 ${r} 0 ${c(s(e.inner,e.from+f))}`,"Z"].join(" ")}function LY(e,t,n){const r={rx:e.outer.rx-Md,ry:e.outer.ry-Md},s=e.to-e.from>180?1:0;return`M${t_(r,t,n,e.to)} A${r.rx.toFixed(1)},${r.ry.toFixed(1)} 0 ${s} 0 ${t_(r,t,n,e.from)}`}function PY({node:e,angle:t,lit:n}){const r=e.row.kind==="paired"&&e.row.here,s=e.order*MY%1*CY;return a.jsx("span",{className:"nm-wire","aria-hidden":!0,"data-tier":e.tier,"data-via":e.row.via,"data-on":n||void 0,style:{"--nm-a":`${t.toFixed(2)}deg`,"--nm-d":`${e.dist.toFixed(1)}px`,"--from":`${e_}px`,"--gap":`${e_+(e.tier==="loose"?SY:jY)}px`,"--i":e.order,"--phase":`${s.toFixed(2)}s`},children:r&&a.jsx("i",{className:"nm-glint"})})}function DY({status:e}){const t=(e==null?void 0:e.enabled)===!0&&e.running;return a.jsxs("div",{className:"nm-core","data-listening":t||void 0,children:[a.jsx("span",{className:"nm-core-orb","aria-hidden":!0}),a.jsxs("span",{className:"nm-core-label",children:[a.jsx("span",{className:"nm-core-name",children:(e==null?void 0:e.name)??"…"}),a.jsx("span",{className:"nm-core-what",children:"this deck"})]})]})}function FY({node:e,angle:t,os:n,lit:r,shown:s,tabbable:o,register:l,onHold:c,onRelease:d,onOpen:h}){const{row:f}=e,p=`nm-d-${WY(rr(f))}`,g=e.angle*Math.PI/180,v=E0(f,n);return a.jsxs("button",{ref:l,type:"button",className:"nm-node",tabIndex:o?0:-1,"data-tier":e.tier,"data-kind":f.kind,"data-side":e.side,"data-via":f.via,"data-on":r||void 0,"data-shown":s||void 0,"aria-label":`${f.name}: ${XI(f)}`,"aria-describedby":e.tier==="online"?p:void 0,style:{"--nm-a":`${t.toFixed(2)}deg`,"--nm-d":`${e.dist.toFixed(1)}px`,"--i":e.order,"--in-x":`${(-Math.cos(g)*14).toFixed(1)}px`,"--in-y":`${(-Math.sin(g)*14).toFixed(1)}px`},onPointerEnter:N=>{N.pointerType==="mouse"&&c("pointer")},onPointerLeave:d,onFocus:N=>c(N.currentTarget.matches(":focus-visible")?"keyboard":"pointer"),onBlur:d,onClick:h,children:[a.jsx("i",{className:"nm-halo","data-tier":e.tier,"aria-hidden":!0}),f.kind==="dialling"?a.jsx("i",{className:"nm-addr-dot","aria-hidden":!0}):a.jsx(lb,{}),e.tier!=="online"&&a.jsx("i",{className:"nm-mark","data-tier":e.tier,"data-kind":f.kind,"aria-hidden":!0}),a.jsxs("span",{className:"nm-label","aria-hidden":!0,children:[a.jsx("span",{className:"nm-name",children:KI(f)}),a.jsx("span",{className:"nm-cap",children:v})]}),e.tier==="online"&&a.jsx("span",{id:p,className:"vis-hidden",children:v})]})}function BY({status:e}){const t=(e==null?void 0:e.enabled)===!0;return a.jsx("p",{className:"nm-empty",children:e?t?"No other deck yet. Decks on one network usually find each other within a minute; one on another network needs its address, through Add a deck in Local network.":"Local network is off, so this deck is not looking for any other.":"Asking this deck about the network…"})}function qY({slice:e}){return a.jsxs("ul",{className:"nm-legend",children:[a.jsxs("li",{children:[a.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[a.jsx("i",{className:"nm-key-wire","data-tier":"online"}),a.jsx("i",{className:"nm-key-mark","data-tier":"online"})]}),"online"]}),a.jsxs("li",{children:[a.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[a.jsx("i",{className:"nm-key-wire","data-tier":"offline"}),a.jsx("i",{className:"nm-key-mark","data-tier":"offline"})]}),"away"]}),a.jsxs("li",{children:[a.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[a.jsx("i",{className:"nm-key-wire","data-tier":"loose"}),a.jsx("i",{className:"nm-key-mark","data-tier":"loose"})]}),"not paired"]}),e&&a.jsxs("li",{children:[a.jsx("i",{className:"nm-key-zone","aria-hidden":!0}),"over Tailscale"]})]})}function sO({facts:e}){return a.jsx("dl",{className:"lan-facts nm-facts",children:e.map(t=>a.jsxs("div",{className:"lan-fact","data-tone":t.quiet?"quiet":void 0,children:[a.jsx("dt",{children:t.label}),a.jsx("dd",{children:t.value})]},t.label))})}function UY({status:e,summary:t,entrance:n,slice:r}){const s=fY(e),o=ib(e==null?void 0:e.about),l=[];o&&l.push({label:"Runs",value:o}),l.push({label:s.length>1?"Addresses":"Address",value:s.length?a.jsx("span",{className:"nm-addrs",children:s.map(h=>a.jsx("code",{className:"ap-lan-code",children:h},h))}):"none yet",quiet:s.length===0}),e!=null&&e.pairingMode&&l.push({label:"Pairing",value:e.pairingMode==="invite"?"by invite only":"asks and answers"});const c=[{key:"online",n:t.online,words:"online",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"online","aria-hidden":!0})},{key:"away",n:t.offline,words:"away",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"offline","aria-hidden":!0})},{key:"asks",n:t.asks,words:"asking to pair",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"loose","data-kind":"asks","aria-hidden":!0})},{key:"nearby",n:t.nearby,words:"nearby, not paired",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"loose","aria-hidden":!0})},{key:"dialling",n:t.dialling,words:"still dialling",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"loose","aria-hidden":!0})},{key:"declined",n:t.declined,words:"declined, not drawn",mark:a.jsx("i",{"aria-hidden":!0})}],d=mY(t,e==null?void 0:e.pairingMode);return a.jsxs("div",{className:"nm-panel","data-view":"network","data-entrance":n,children:[a.jsx("h3",{className:"nm-panel-name",children:(e==null?void 0:e.name)??"…"}),a.jsx("p",{className:"nm-panel-self",children:"this deck, at the centre of the map"}),a.jsx("ul",{className:"nm-counts",children:c.filter(h=>h.n>0).map(h=>a.jsxs("li",{"data-count":h.key,children:[h.mark,a.jsx("span",{className:"nm-count-n",children:h.n}),a.jsx("span",{className:"nm-count-words",children:h.words})]},h.key))}),t.tailnet>0&&a.jsxs("p",{className:"nm-counts-note",children:[t.tailnet," reached over Tailscale",r?" — the shaded slice, lower right":""]}),d&&a.jsx("p",{className:"nm-next",children:d}),a.jsx(sO,{facts:l}),a.jsx("p",{className:"nm-panel-hint",children:"Point at a deck, or reach one with the arrow keys, to see it here. Press it to open its own dialog."})]})}function zY({row:e,status:t,accounts:n,now:r,entrance:s,onOpen:o,onBack:l}){var x;const c=nO({row:e,source:ec(t,e),status:t,accounts:n,now:r}),d=[];c.where&&d.push({label:"Address",value:a.jsx("code",{className:"ap-lan-code",children:c.where})}),c.thereRuns&&d.push({label:"Runs",value:`${c.thereRuns}${c.order?` · ${c.order<0?"older than this deck":"newer than this deck"}`:""}`}),c.hiddenThere&&d.push({label:"Signed in to",value:"not said — its owner hides it",quiet:!0}),c.otherThere&&d.push({label:"Signed in to",value:"an account it does not share",quiet:!0});const h=e.kind==="paired"&&e.here||e.kind==="asks",f=gY(e,t.pairingMode),p=yY(c.lanes),g=p.length,v=p.filter(j=>j.tone==="ok").length,N=g===0?"No shared logins":v===g?`${g} shared login${g===1?", fine":"s, all fine"}`:`${g} shared login${g===1?"":"s"} · ${v} fine`,k=c.unknown&&((x=c.peer)!=null&&x.waiting)&&!c.peer.offers?"Its side is not known until it next calls.":c.unknown;return a.jsxs("div",{className:"nm-panel","data-view":"deck","data-entrance":s,"data-tier":e.kind==="paired"?e.here?"online":"offline":"loose",children:[a.jsxs("button",{type:"button",className:"ap-lan-word nm-back",onClick:l,children:[a.jsx("span",{"aria-hidden":!0,children:"‹ "}),"the whole network"]}),a.jsxs("div",{className:"nm-panel-head",children:[a.jsxs("h3",{className:"nm-panel-name",children:[a.jsx("i",{className:h?"ap-pulse":"ap-dot","data-kind":e.kind,"aria-hidden":!0}),a.jsx("span",{className:"nm-panel-title",children:e.name})]}),a.jsx("button",{type:"button",className:"btn nm-open",onClick:o,"aria-label":`Open ${e.name}`,children:"Open"})]}),e.self&&a.jsxs("p",{className:"nm-panel-self",children:["calls itself ",e.self]}),a.jsx("p",{className:"nm-panel-state","data-kind":e.kind,children:XI(e)}),f&&a.jsx("p",{className:"nm-next",children:f}),d.length>0&&a.jsx(sO,{facts:d}),c.paired&&a.jsxs("section",{className:"nm-logins","aria-label":"Logins the two decks share",children:[a.jsx("p",{className:"nm-logins-title",children:N}),g>0&&a.jsx("ul",{className:"nm-lanes",children:p.map((j,b)=>a.jsxs("li",{className:"nm-lane","data-tone":j.tone,style:{"--k":b},children:[a.jsx("i",{className:"nm-lane-dot","aria-hidden":!0}),a.jsx("span",{className:"nm-lane-email","aria-hidden":!0,children:j.email}),n_(j)&&a.jsx("span",{className:"nm-lane-said","aria-hidden":!0,children:n_(j)}),j.usedThere&&a.jsx("span",{className:"nm-lane-used","aria-hidden":!0,children:"in use there"}),a.jsxs("span",{className:"vis-hidden",children:[j.email,": ",tO(j)]})]},j.key))}),k&&a.jsx("p",{className:"nm-panel-hint",children:k})]})]})}function n_(e){return e.caption?e.caption:e.tone==="ok"?null:`${QI[e.here]} · ${eO[e.there]}`}function WY(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}const HY=6;function VY({anchorId:e,id:t,rows:n,onHold:r,onLet:s}){const o=y.useRef(null),l=n.filter(g=>g.kind==="paired"),c=l.filter(g=>g.here),d=c.slice(0,HY),h=l.length-c.length,f=c.length>d.length?`and ${c.length-d.length} more`:h>0?`${h} not on right now`:null,p=y.useCallback(()=>{const g=o.current,v=document.getElementById(e);if(!g||!v)return;const N=m0(v.getBoundingClientRect(),{width:g.offsetWidth,height:g.offsetHeight},{width:window.innerWidth,height:window.innerHeight});g.style.top=`${N.top}px`,g.style.left=`${N.left}px`,g.style.maxHeight=N.maxHeight==null?"":`${N.maxHeight}px`,g.dataset.side=N.side},[e]);return y.useLayoutEffect(()=>{p()}),y.useEffect(()=>(window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}),[p]),Lt.createPortal(a.jsxs("div",{ref:o,id:t,className:"ap-peek",role:"tooltip",onPointerEnter:r,onPointerLeave:s,children:[a.jsx("p",{className:"ap-peek-title",children:c.length?"On the network now":"Nobody on the network"}),d.length>0&&a.jsx("div",{className:"ap-peek-list",children:d.map(g=>a.jsxs("span",{className:"ap-peek-who",children:[a.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),a.jsxs("span",{children:[g.name,g.via==="tailscale"&&a.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]})]},`${g.kind}:${g.fp}`))}),f&&a.jsx("p",{className:"ap-peek-rest",children:f})]}),document.body)}function GY({entry:e,rows:t,onOpen:n,onMap:r,peek:s,openPeek:o,shutPeek:l,holdPeek:c,dropPeek:d}){return a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",id:"ap-lan-entry",className:"ap-nav",onClick:()=>{d(),n()},"aria-describedby":s?"ap-lan-peek":void 0,onPointerEnter:h=>{h.pointerType==="mouse"&&o(FI)},onPointerLeave:l,onFocus:h=>{h.target.matches(":focus-visible")&&o(0)},onBlur:l,children:[a.jsxs("svg",{className:"ap-nav-glyph",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("rect",{x:"1.8",y:"2.3",width:"10.4",height:"7.2",rx:"1.2"}),a.jsx("path",{d:"M5 11.9h4M7 9.5v2.4"})]}),a.jsxs("span",{className:"ap-nav-text",children:[a.jsx("span",{className:"ap-nav-name",children:"Local network"}),a.jsxs("span",{className:"ap-nav-state","data-tone":e.tone,children:[e.live&&a.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),e.text]})]}),a.jsx("svg",{className:"ap-nav-chev",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),r&&a.jsx("button",{type:"button",className:"ap-lan-map",onClick:()=>{d(),r()},"aria-label":"Show the network map",title:"Network map — every deck this one knows, drawn around it",children:a.jsx(rO,{})}),s&&a.jsx(VY,{anchorId:"ap-lan-entry",id:"ap-lan-peek",rows:t,onHold:c,onLet:l})]})}function KY({row:e,run:t,onVerb:n,onUnpair:r}){const[s,o]=y.useState(!1),l=y.useRef(0),[c,d]=y.useState(null);return y.useEffect(()=>{if(!s)return;const p=window.setTimeout(()=>o(!1),4e3);return()=>window.clearTimeout(p)},[s]),y.useEffect(()=>{if(!c)return;const p=window.setTimeout(()=>d(null),4e3);return()=>window.clearTimeout(p)},[c]),{armed:s,armedTwin:c,pressOwn:()=>{const p=Date.now(),g=Yl({armedFor:s?e.fp:null,target:e.fp,armedAt:l.current,now:p,gapMs:Kl});if(g==="arm"){o(!0),d(null),l.current=p;return}g!=="ignore"&&(o(!1),t(n))},pressTwin:p=>{if(!r)return;const g=Date.now(),v=Yl({armedFor:c,target:p,armedAt:l.current,now:g,gapMs:Kl});if(v==="arm"){d(p),o(!1),l.current=g;return}v!=="ignore"&&(d(null),t(()=>r(p)))}}}function YY({row:e,paired:t,peer:n,status:r,busy:s,press:o,checkNow:l,armed:c,pressOwn:d,run:h,onVerb:f,onInvite:p}){return a.jsxs("footer",{className:"lan-peer-foot",children:[e.kind==="asks"&&a.jsx("p",{className:"lan-foot-note",children:"This deck is now asking to pair. Answer it from the panel behind this."}),t&&!(n!=null&&n.waiting)&&a.jsx("button",{type:"button",className:"btn",...o(`check:${e.fp}`),onClick:l,title:"Ask this deck now instead of waiting for the next round",children:s===`check:${e.fp}`?"Checking…":"Check now"}),e.kind==="paired"&&a.jsx("button",{type:"button",className:`btn danger lan-peer-verb${c?" armed":""}`,...o(`unpair:${e.fp}`),onKeyDown:g=>{g.repeat&&g.preventDefault()},onClick:()=>d(),"aria-label":c?`Confirm unpairing ${e.name}`:`Unpair ${e.name}`,title:c?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this deck from now on",children:s===`unpair:${e.fp}`?"Unpairing…":c?"Confirm unpair":"Unpair"}),e.kind==="nearby"&&r.pairingMode!=="invite"&&a.jsx("button",{type:"button",className:"btn primary lan-peer-verb",...o(`accept:${e.fp}`),onClick:()=>void h(f),title:"Send it a request. Somebody at that machine has to accept it before anything is shared.",children:s===`accept:${e.fp}`?"Asking…":"Ask to pair"}),e.kind==="dialling"&&a.jsx("button",{type:"button",className:"btn lan-peer-verb",...o(`drop:${e.fp}`),onClick:()=>void h(f),title:"Stop trying this address. Nothing was ever paired here.",children:s===`drop:${e.fp}`?"Stopping…":"Stop dialling"}),e.kind==="declined"&&r.pairingMode!=="invite"&&a.jsx("button",{type:"button",className:"btn lan-peer-verb",...o(`allow:${e.fp}`),onClick:()=>void h(f),title:"Take the no back. That deck is still trying, so its request comes round again on its own.",children:s===`allow:${e.fp}`?"Allowing…":"Let it ask again"}),(e.kind==="nearby"||e.kind==="declined")&&r.pairingMode==="invite"&&p&&a.jsx("button",{type:"button",className:"btn primary lan-peer-verb",onClick:p,title:"This deck pairs only by invite. Make one and send it to whoever is at that machine.",children:"Invite to pair"})]})}function XY({instances:e,now:t,busy:n,press:r,armedTwin:s,pressTwin:o,onUnpair:l}){return a.jsxs("div",{className:"modal-section",children:[a.jsxs("h3",{className:"lan-h",children:[e.length," decks on this machine"]}),a.jsx("ul",{className:"lan-twins",role:"list",children:e.map((c,d)=>{var N,k,x,j;const h=(N=c.peer)!=null&&N.addr?`${c.peer.addr}:${c.peer.port}`:c.row.addr,f=h||c.row.fp,p=(k=c.peer)!=null&&k.pairedAt?Fr(c.peer.pairedAt,t):null,g=[(j=(x=c.peer)==null?void 0:x.about)!=null&&j.version?`runs ${c.peer.about.version}`:null,p?`paired ${p==="now"?"just now":p}`:null,c.row.state].filter(Boolean).join(" · "),v=c.row.fp;return a.jsxs("li",{role:"listitem",className:"lan-twin","data-tone":c.row.tone,children:[a.jsx("i",{className:c.row.here?"ap-pulse":"ap-dot","aria-hidden":!0}),h?a.jsx("code",{className:"ap-lan-code lan-twin-at",children:h}):a.jsx("span",{className:"lan-twin-at lan-twin-none",children:"no address here"}),a.jsx("code",{className:"ap-lan-code lan-twin-fp",children:v}),d>0&&l&&a.jsx("button",{type:"button",className:`ap-manage-btn danger lan-twin-do${s===v?" armed":""}`,...r(`unpair:${v}`),onKeyDown:b=>{b.repeat&&b.preventDefault()},onClick:()=>o(v),"aria-label":s===v?`Confirm unpairing ${f}`:`Unpair ${f}`,title:s===v?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this one of the machine's decks",children:n===`unpair:${v}`?"unpairing…":s===v?"confirm":"unpair"}),a.jsx("span",{className:"lan-twin-meta",children:d===0?`${g} · shown above`:g})]},v)})})]})}function ZY(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M9.6 2.4l2 2L5 11l-2.6.6L3 9z"}),a.jsx("path",{d:"M8.4 3.6l2 2"})]})}function JY({row:e,source:t,status:n,accounts:r,now:s,busy:o,onClose:l,onRename:c,onCheck:d,onVerb:h,onSettings:f,onInvite:p,twins:g=[],onUnpair:v}){const N=y.useRef(null),k=ut(l,{focusRef:N}),x=gt(l),[j,b]=y.useState(null),[_,E]=y.useState(null),[R,C]=y.useState(!1),[A,U]=y.useState(0),L=y.useRef(null),F=y.useRef(null),O=y.useRef(!0);y.useEffect(()=>()=>{O.current=!1},[]);const I=j!=null;y.useEffect(()=>{var ae;I&&((ae=L.current)==null||ae.select())},[I]);const B=y.useRef(!1);y.useEffect(()=>{var ae,fe;B.current&&!I&&Tn(((ae=document.activeElement)==null?void 0:ae.tagName)??null)&&((fe=F.current)==null||fe.focus()),B.current=I},[I]);const M=ae=>{const fe=ia(o,ae);return{disabled:fe.disabled,"aria-busy":fe.busy}},$=async ae=>{const fe=await ae();return O.current&&E(fe),fe==null},{armed:P,armedTwin:G,pressOwn:K,pressTwin:q}=KY({row:e,run:$,onVerb:h,onUnpair:v}),H=nO({row:e,source:t,status:n,accounts:r,now:s}),{peer:D,stranger:W,paired:J,own:V,canRename:X,fp:Y}=H,Z=o===`check:${e.fp}`,ee=async ae=>{const fe=ae.trim()===V?"":ae;await $(()=>c(fe))&&b(null)},ne=()=>void $(d).then(ae=>{ae&&O.current&&U(fe=>fe+1)}),se=async()=>{if(Y)try{if(await navigator.clipboard.writeText(Y),!O.current)return;C(!0),window.setTimeout(()=>{O.current&&C(!1)},1600)}catch{O.current&&E("Could not copy it — select the fingerprint and copy it by hand.")}},pe=[];J&&(D!=null&&D.pairedAt)?pe.push({label:"Paired",value:kY(D.pairedAt,s),tone:"meta"}):e.kind==="declined"&&W&&pe.push({label:"Paired",value:`no · you said no ${j0(W.at,s)}`,tone:"meta"}),pe.push({label:"Fingerprint",value:Y?a.jsxs("span",{className:"lan-fp",children:[a.jsx("code",{className:"ap-lan-code",children:Y}),a.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void se(),"aria-label":R?"Fingerprint copied":"Copy the fingerprint",children:R?"copied":"copy"})]}):"not known — nothing has answered there",tone:Y?void 0:"quiet"});const ke=g.length?[{row:e,peer:D??null},...g]:[];return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...x,role:"presentation",children:a.jsxs("div",{ref:k,className:"modal lan-peer","data-tone":e.tone,onClick:ae=>ae.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-peer-title","aria-describedby":"lan-peer-sub",children:[a.jsxs("header",{className:"modal-head lan-peer-head",children:[a.jsx("i",{className:e.here?"ap-pulse":"ap-dot","aria-hidden":!0}),a.jsxs("div",{className:"lan-peer-id",children:[I?a.jsxs("form",{className:"lan-peer-edit",onSubmit:ae=>{ae.preventDefault(),ee(j??"")},children:[a.jsx("span",{id:"lan-peer-title",className:"vis-hidden",children:e.name}),a.jsx("input",{ref:L,className:"ap-manage-input lan-peer-input",value:j??"",maxLength:48,placeholder:V,"aria-label":"Name for this deck, shown on this deck only",onChange:ae=>b(ae.target.value)}),a.jsx("button",{type:"submit",className:"ap-manage-btn",...M(`alias:${e.fp}`),children:"save"}),a.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>b(null),children:"cancel"})]}):a.jsxs("span",{className:"lan-peer-title",children:[a.jsx("span",{id:"lan-peer-title",className:"lan-peer-name",children:e.name}),X&&a.jsx("button",{type:"button",className:"glyph-btn lan-peer-rename",ref:F,onClick:()=>{E(null),b(e.name)},"aria-label":`Rename ${e.name} on this deck`,title:"Give it a name of your own. Only this deck sees it.",children:a.jsx(ZY,{})})]}),a.jsxs("p",{id:"lan-peer-sub",className:"lan-peer-sub",children:[e.self&&a.jsxs(a.Fragment,{children:["calls itself ",a.jsx("span",{className:"lan-peer-self",children:e.self}),I&&a.jsx("button",{type:"button",className:"ap-lan-word lan-peer-restore",...M(`alias:${e.fp}`),onClick:()=>void ee(""),children:"use this name"}),a.jsx("span",{className:"vis-hidden",children:". "}),!e.quiet&&a.jsx("span",{"aria-hidden":!0,children:" · "})]}),a.jsx("span",{className:e.quiet?"vis-hidden":"lan-peer-state",children:e.state})]})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:N,type:"button",className:"glyph-btn",onClick:l,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body lan-peer-body",children:[_&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",children:_}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>E(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),a.jsx(NY,{view:H,row:e,status:n,asking:Z,drawn:A,onSettings:f}),a.jsx("dl",{className:"lan-facts",children:pe.map(ae=>a.jsxs("div",{className:"lan-fact","data-tone":ae.tone,children:[a.jsx("dt",{children:ae.label}),a.jsx("dd",{children:ae.value})]},ae.label))}),ke.length>1&&a.jsx(XY,{instances:ke,now:s,busy:o,press:M,armedTwin:G,pressTwin:q,onUnpair:v})]}),a.jsx(YY,{row:e,paired:J,peer:D,status:n,busy:o,press:M,checkNow:ne,armed:P,pressOwn:K,run:$,onVerb:h,onInvite:p})]})}),document.body)}function is(e,t){const n=y.useRef(!1);return y.useEffect(()=>{var r,s;!e||!n.current||(n.current=!1,Tn(((r=document.activeElement)==null?void 0:r.tagName)??null)&&(typeof t=="function"?t():(s=t.current)==null||s.focus()))},[e]),()=>{n.current=!0}}function QY(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(r=>n.has(r))}function eX(e,t,n,r){const s=new Set(e??t);return r?s.add(n):s.delete(n),[...s]}function r_(e,t,n){return e==null||n!=null&&!n.ok||QY(e,t)?null:e}function aO({line:e,onDismiss:t,onAnswer:n}){const[r,s]=y.useState(!1),o=y.useRef(!1),l=y.useRef(!0);y.useEffect(()=>(l.current=!0,()=>{l.current=!1}),[]);const c=y.useRef(null),d=y.useRef(null),h=y.useRef(!1);if(y.useEffect(()=>{var p;h.current&&(h.current=!1,e!=null&&e.giveBack||(p=d.current)==null||p.focus())},[e]),!e)return null;const f=async()=>{if(o.current)return;o.current=!0,s(!0);const p=await QG();o.current=!1,l.current&&(s(!1),h.current=document.activeElement===c.current,n(tK(p)))};return a.jsxs("div",{className:e.done?"ap-failure ap-failure-done":"ap-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",children:e.text}),e.giveBack&&a.jsx("button",{ref:c,type:"button",className:"ap-fix ap-give-back","aria-busy":r,onClick:f,title:"Opens macOS's password dialog to make the settings folder yours again",children:r?"waiting for macOS…":"give it back"}),a.jsx("button",{ref:d,type:"button",className:"ap-failure-x",onClick:t,"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]})}function tX(e){if(!e.running)return`Tailscale is ${e.state==="Stopped"?"turned off":e.state==="NeedsLogin"||e.state==="NeedsMachineAuth"?"signed out":e.state==="Starting"?"still starting":"not answering"} on this machine`;const t=e.login??"your Tailscale account";return e.on?`${e.devices} online · ${t}`:t}const Vu="Paused while this deck pairs only by invite. Turn that off above to use it.";function nX({status:e,accounts:t,onClose:n,onChanged:r}){qt("lan-setup");const s=ut(n),o=gt(n),[l,c]=y.useState(null),[d,h]=y.useState(null),[f,p]=y.useState(!1),[g,v]=y.useState(null),N=y.useRef(null),k=q=>{const H=ia(g,q);return{disabled:H.disabled,"aria-busy":H.busy}},x=y.useRef(null),j=y.useRef(!0);y.useEffect(()=>()=>{j.current=!1},[]),y.useEffect(()=>{x.current=r_(x.current,e.shared??[],null)},[e.shared]);const b=y.useCallback(async(q,H,D="write")=>{N.current=D,v(D);try{const J=await(await fetch("/api/prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:q})})).json().catch(()=>null);return j.current?(J!=null&&J.ok?h(null):h(sr(Tt(H,J),J)),r(),(J==null?void 0:J.ok)===!0):!1}catch{return j.current&&h(sr(Tt(H,null))),!1}finally{N.current=null,j.current&&v(null)}},[r]),_=y.useCallback(async q=>{const H=await b({name:q},"save the name","name");return H&&j.current&&c(D=>D===q?null:D),H},[b]),E=y.useRef(null),R=l!=null&&l!==(e.name??""),C=is(!R,E),A=y.useCallback(async()=>{R&&!await _(l)||n()},[R,l,_,n]),U=async()=>{if(!e.fp)return;const q=await eo(e.fp);if(j.current){if(!q){h(sr("Could not copy it — select the fingerprint and copy it by hand."));return}p(!0),window.setTimeout(()=>{j.current&&p(!1)},1600)}},L=new Set(x.current??e.shared??[]),F=e.autoAsk!==!1,O=e.autoAccept!==!1,I=e.pairingMode==="invite",B=q=>{const H=k(q);return{...H,disabled:H.disabled||I}},M=e.shareActive!==!1,$=e.tailscale??null,P=!!($!=null&&$.on),G=($==null?void 0:$.ask)!==!1,K=($==null?void 0:$.accept)!==!1;return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal lan-modal",onClick:q=>q.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-modal-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"lan-modal-title",className:"modal-tool-name",children:"This deck on the network"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsx(aO,{line:d,onDismiss:()=>h(null),onAnswer:q=>{h(q),q.done&&r()}}),a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"Name"}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("span",{className:"ap-lan-label",children:"appear as"}),a.jsx("input",{ref:E,className:"ap-manage-input ap-lan-input","aria-label":"This deck's name on the network",value:l??e.name??"",placeholder:"this machine",onChange:q=>c(q.target.value),onKeyDown:q=>{q.key!=="Enter"||l==null||_(l)}}),R&&a.jsx("button",{type:"button",className:"ap-manage-btn",...k("name"),onClick:()=>{C(),_(l)},title:"Save it. This is the name other decks show for this one.",children:"save"})]}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("span",{className:"ap-lan-label",children:"fingerprint"}),e.fp?a.jsxs("span",{className:"lan-fp",children:[a.jsx("code",{className:"ap-lan-code",children:e.fp}),a.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void U(),"aria-label":f?"Fingerprint copied":"Copy this deck's fingerprint",children:f?"copied":"copy"})]}):a.jsx("span",{className:"ap-lan-label",children:"not known yet"})]})]}),a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"Share these accounts"}),a.jsxs("div",{className:"ap-lan-picks",children:[t.length===0&&a.jsx("span",{className:"ap-lan-empty",children:"No Claude accounts on this deck yet — add one with + at the top of this panel."}),t.map(q=>a.jsxs("label",{className:"ap-lan-pick",title:q.alive?"Offer this account to the decks you have paired with, so one whose copy has died can heal from yours. Unticking stops it being offered from now on; it does not take back a copy somebody already has.":"This deck cannot use this login, so it has nothing to offer — a deck that can will heal it",children:[a.jsx("input",{type:"checkbox",checked:L.has(q.key),onChange:H=>{const D=eX(x.current,e.shared??[],q.key,H.target.checked);x.current=D,b({shared:D},H.target.checked?"share that account":"stop sharing that account").then(W=>{x.current===D&&(x.current=r_(D,e.shared??[],{ok:W}))})}}),a.jsx("span",{className:"ap-lan-pick-name",children:q.email}),!q.alive&&a.jsx("span",{className:"ap-lan-dead",children:"not working here"})]},q.key))]}),t.length>0&&a.jsxs("div",{className:"lan-switch",children:[a.jsx("span",{className:"lan-switch-what",children:"Show paired decks which of these this deck is using"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":M,"aria-label":"Show paired decks which of these this deck is using",...k("current"),onClick:()=>void b({shareActive:!M},M?"stop showing which account this deck is using":"show which account this deck is using","current"),title:M?"Stop telling paired decks which account this one is on. They read “current account hidden” instead.":"Tell paired decks which of the ticked accounts this one is on. An unticked account is never named.",children:a.jsx("span",{className:"switch-knob"})})]})]}),a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",id:"lan-pairing-h",children:"Pairing"}),a.jsx("div",{className:"lan-switches lan-switches-lead",role:"group","aria-labelledby":"lan-pairing-h",children:a.jsxs("div",{className:"lan-switch",children:[a.jsxs("span",{className:"lan-switch-what",children:["Pair new decks only by invite",I&&a.jsx("span",{id:"lan-invite-only-detail",className:"lan-switch-detail",children:"A new deck needs an invite from Add a deck, the link at the top of Local network. Paired decks stay paired."})]}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":I,"aria-label":"Pair new decks only by invite","aria-describedby":I?"lan-invite-only-detail":void 0,...k("mode"),onKeyDown:q=>{q.repeat&&q.preventDefault()},onClick:()=>void b({pairingMode:I?"automatic":"invite"},I?"let decks pair on their own again":"pair new decks only by invite","mode"),title:I?"Let decks on this network pair as the two switches below say again.":"Only a deck you send an invite to can pair with this one. Nearby decks can't ask, and requests waiting now are turned away.",children:a.jsx("span",{className:"switch-knob"})})]})}),a.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-auto-h",children:[a.jsxs("p",{className:"lan-sub",id:"lan-auto-h",children:["Automatic pairing",I&&a.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),a.jsxs("div",{className:"lan-switches","data-paused":I||void 0,children:[a.jsxs("div",{className:"lan-switch",children:[a.jsx("span",{className:"lan-switch-what",children:"Ask every deck this one finds"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":F,"aria-label":"Ask every deck this one finds",...B("ask"),onClick:()=>void b({autoAsk:!F},F?"stop asking automatically":"ask every deck this one finds","ask"),title:I?Vu:F?"Stop sending requests on their own. You press ask on the row instead.":"Send a pairing request to every deck heard on this network. Somebody over there still has to say yes.",children:a.jsx("span",{className:"switch-knob"})})]}),a.jsxs("div",{className:"lan-switch",children:[a.jsx("span",{className:"lan-switch-what",children:"Say yes to every deck that asks"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":O,"aria-label":"Say yes to every deck that asks","data-tone":"warn",...B("accept"),onKeyDown:q=>{q.repeat&&q.preventDefault()},onClick:()=>void b({autoAccept:!O},O?"stop accepting automatically":"accept every deck that asks","accept"),title:I?Vu:O?"Stop saying yes for you. A deck that asks waits in the panel again.":"Say yes for you. Every deck on this network that asks is paired without anybody being asked here.",children:a.jsx("span",{className:"switch-knob"})})]})]})]})]}),($==null?void 0:$.found)&&a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"Tailscale"}),a.jsxs("div",{className:"lan-switches",children:[a.jsxs("div",{className:"lan-switch",children:[a.jsxs("span",{className:"lan-switch-what",children:["Look for my devices",a.jsx("span",{id:"lan-ts-detail",className:"lan-switch-detail",children:tX($)})]}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":P,"aria-label":"Look for my devices over Tailscale","aria-describedby":"lan-ts-detail",...k("tailscale"),onClick:()=>void b({tailscale:!P},P?"stop looking over Tailscale":"look for your devices over Tailscale","tailscale"),title:P?"Stop. Nothing is looked for or answered over the tailnet; decks already paired stay paired.":"Find the decks on your other machines on Tailscale, wherever they are. Only machines signed in to your Tailscale account are asked.",children:a.jsx("span",{className:"switch-knob"})})]}),P&&a.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-ts-auto-h",children:[a.jsxs("p",{className:"lan-sub",id:"lan-ts-auto-h",children:["Automatic pairing with my devices",I&&a.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),a.jsxs("div",{className:"lan-switches",children:[a.jsxs("div",{className:"lan-switch","data-paused":I||void 0,children:[a.jsx("span",{className:"lan-switch-what",children:"Ask each device it finds"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":G,"aria-label":"Ask each of my devices it finds over Tailscale",...B("tailscale-ask"),onClick:()=>void b({tailscaleAsk:!G},G?"stop asking your devices automatically":"ask your devices automatically","tailscale-ask"),title:I?Vu:G?"Stop sending requests on their own. You press ask on the row instead.":"Send a pairing request to every deck found on your devices over Tailscale.",children:a.jsx("span",{className:"switch-knob"})})]}),a.jsxs("div",{className:"lan-switch","data-paused":I||void 0,children:[a.jsx("span",{className:"lan-switch-what",children:"Say yes to each device that asks"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":K,"aria-label":"Say yes to my devices when they ask over Tailscale","data-tone":"warn",...B("tailscale-accept"),onKeyDown:q=>{q.repeat&&q.preventDefault()},onClick:()=>void b({tailscaleAccept:!K},K?"stop accepting your devices automatically":"accept your devices automatically","tailscale-accept"),title:I?Vu:K?"Stop saying yes for you. A device that asks waits in the panel again.":"Say yes for you when a deck on one of your own devices asks. Anybody else on the tailnet still waits for a press.",children:a.jsx("span",{className:"switch-knob"})})]})]})]})]})]})]}),a.jsxs("footer",{className:"lan-setup-foot",children:[a.jsx("span",{className:"lan-foot-note",children:"Changes are saved as you make them."}),a.jsx("button",{type:"button",className:"btn primary",...k("name"),onClick:()=>void A(),children:"Done"})]})]})}),document.body)}function rX({on:e,status:t,paired:n,busy:r,pressProps:s,checkNow:o,setAddOpen:l,setSetupOpen:c,setMapOpen:d,onBack:h,closeButton:f}){return a.jsxs("div",{className:"ap-header",children:[a.jsx("button",{type:"button",id:"ap-lan-back",className:"glyph-btn ap-back",onClick:h,"aria-label":"Back to Claude accounts",title:"Back to Claude accounts",children:a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M8.4 3.4 4.8 7l3.6 3.6"})})}),a.jsx("h2",{id:"ap-lan-title",children:"Local network"}),a.jsxs("div",{className:"ap-header-right",children:[e&&a.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>d(!0),"aria-label":"Show the network map",title:"Network map — every deck this one knows, drawn around it",children:a.jsx(rO,{})}),e&&a.jsx("button",{type:"button",className:"glyph-btn ap-lan-plus",onClick:()=>l("add"),"aria-label":"Add a deck",title:(t==null?void 0:t.pairingMode)==="invite"?"Send an invite, or use one you were sent. This deck pairs only by invite.":"Reach a deck that has not turned up on its own — by address, or with an invite",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M6.1 7.9a2.6 2.6 0 0 0 3.7 0l1.9-1.9a2.6 2.6 0 0 0-3.7-3.7l-.9.9"}),a.jsx("path",{d:"M7.9 6.1a2.6 2.6 0 0 0-3.7 0L2.3 8a2.6 2.6 0 0 0 3.7 3.7l.9-.9"})]})}),e&&n>0&&a.jsx("button",{type:"button",className:"glyph-btn ap-lan-check",...s("check"),onClick:()=>void o(),"aria-label":r==="check"?"Checking every paired deck":"Check every paired deck now",title:"Ask every paired deck now for anything this deck's expired logins need, instead of waiting for the next round",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("circle",{cx:"7",cy:"7",r:"1.1",fill:"currentColor",stroke:"none"}),a.jsx("path",{d:"M4.6 4.6a3.4 3.4 0 0 0 0 4.8M9.4 4.6a3.4 3.4 0 0 1 0 4.8"}),a.jsx("path",{d:"M2.6 2.6a6.2 6.2 0 0 0 0 8.8M11.4 2.6a6.2 6.2 0 0 1 0 8.8"})]})}),e&&a.jsx("button",{type:"button",className:"glyph-btn ap-lan-set",...s("setup"),onClick:()=>c(!0),"aria-label":"This deck's name and shared logins",title:"This deck's name on the network, and which of its logins it offers",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M1.8 4.7h10.4M1.8 9.3h10.4"}),a.jsx("circle",{cx:"9.1",cy:"4.7",r:"1.6",fill:"var(--panel)"}),a.jsx("circle",{cx:"4.9",cy:"9.3",r:"1.6",fill:"var(--panel)"})]})}),f]})]})}function sX({accounts:e,onChanged:t,onNoCopy:n,view:r,onOpen:s,onBack:o,closeButton:l}){const[c,d]=y.useState(!1),[h,f]=y.useState(!1),[p,g]=y.useState(!1),v=ZG(),[N,k]=y.useState(!1),{status:x,manual:j,now:b,busy:_,failure:E,dismissFailure:R,answerGiveBack:C,pressProps:A,load:U,toggle:L,answer:F,dropAddress:O,rename:I,checkOne:B,checkNow:M}=oK(t,()=>d(!0)),{armed:$,pressUnpair:P}=iK(F),[G,K]=y.useState(null),[q,H]=y.useState(!1),D=y.useMemo(()=>e.filter(me=>YG(me.key,x??null,b)).map(me=>me.key).sort().join(`
93
- `),[e,x,b]);y.useEffect(()=>{n==null||n(D?D.split(`
94
- `):[])},[D,n]);const W=(x==null?void 0:x.enabled)===!0,J=y.useMemo(()=>FG((x==null?void 0:x.pairingMode)==="invite"&&x?{...x,pending:[]}:x,b),[x,b]),V=G?J.find(me=>{var he;return me.fp===G||((he=me.twins)==null?void 0:he.some(ge=>ge.fp===G))})??null:null;y.useEffect(()=>{G&&x&&!V&&K(null)},[G,x,V]);const{asks:X,rest:Y,live:Z,folded:ee,troubled:ne,shown:se,paired:pe}=KG(J,N),ke=LG(x,b),ae=GG(x,J),fe=a.jsxs(a.Fragment,{children:[h&&x&&a.jsx(CK,{status:x,manual:j,startWith:h==="invite"?"invite":void 0,onClose:()=>f(!1),onChanged:()=>{U(),t()}}),p&&a.jsx(UI,{title:"How Local network works",steps:bK,finish:W?void 0:{label:"Turn it on",act:()=>{g(!1),L()}},onClose:()=>g(!1)}),c&&x&&a.jsx(nX,{status:{...x,manualRows:j},accounts:e,manual:j,onClose:()=>d(!1),onChanged:()=>{U(),t()}}),q&&a.jsx($Y,{status:x,rows:J,accounts:e,now:b,covered:!!V||c||!!h||p,onOpenDeck:K,onClose:()=>H(!1)}),V&&x&&a.jsx(JY,{row:V,source:ec(x,V),status:x,accounts:e,now:b,busy:_,onClose:()=>K(null),onRename:me=>I(V.fp,me),onCheck:()=>B(V.fp),onVerb:()=>{switch(V.kind){case"paired":return F("unpair",V.fp,"unpair that deck");case"nearby":return F("accept",V.fp,"reach that deck");case"declined":return F("allow",V.fp,"let that deck ask again");case"dialling":return O(V.fp);default:return Promise.resolve(null)}},onSettings:()=>{K(null),d(!0)},onInvite:()=>{K(null),f("invite")},twins:(V.twins??[]).map(me=>({row:me,peer:ec(x,me).peer??null})),onUnpair:me=>F("unpair",me,"unpair that deck")})]});return r?a.jsxs("div",{className:"ap-lan-view",children:[a.jsx(rX,{on:W,status:x,paired:pe,busy:_,pressProps:A,checkNow:M,setAddOpen:f,setSetupOpen:d,setMapOpen:H,onBack:o,closeButton:l}),a.jsx("div",{className:"ap-scroll",id:"ap-lan-scroll",children:a.jsxs("div",{className:"ap-lan",children:[a.jsxs("div",{className:"ap-policy",children:[a.jsx("h3",{className:"ap-auto-title",children:"Sync with paired decks"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":W,"aria-label":"Sync with paired decks",...A("switch"),onClick:()=>void L(),title:W?"Stop talking to other decks. Nothing is shared while this is off.":"Let the decks you pair with repair this one's expired logins",children:a.jsx("span",{className:"switch-knob"})})]}),a.jsx(IK,{on:W,status:x}),!W&&a.jsxs("div",{className:"ap-lan-intro-row",children:[a.jsxs("button",{type:"button",className:"ap-lan-intro",onClick:()=>g(!0),title:"Four pictures: what this does, and what to do on each machine",children:[a.jsx(kK,{}),a.jsx("span",{className:"ap-lan-intro-text",children:"Paired machines repair each other's expired logins."}),a.jsx("span",{className:"ap-lan-intro-go",children:"See how it works"})]}),a.jsx(Gl,{film:"localNetwork"})]}),a.jsx("p",{className:`ap-lan-status ${ke.tone}`,role:"status",children:ke.tone==="ok"?"":ke.text}),a.jsx(aO,{line:E,onDismiss:R,onAnswer:C}),W&&a.jsxs(a.Fragment,{children:[X.length>0&&a.jsx(RK,{asks:X,pressProps:A,answer:F}),se.length>0&&a.jsx(MK,{rows:se,pairingMode:x==null?void 0:x.pairingMode,armed:$,pressProps:A,answer:F,dropAddress:O,onUnpair:P,onOpenPeer:K,onInvite:()=>f("invite")}),(Z.length>0&&ee.length>0||W&&pe>0)&&a.jsxs("div",{className:"ap-lan-tail",children:[Z.length>0&&ee.length>0&&a.jsxs("button",{type:"button",className:"ap-lan-word ap-lan-more","aria-expanded":N,onClick:()=>k(me=>!me),title:N?"Show only the decks that are on":`Show the ${ee.length} deck${ee.length===1?"":"s"} that are not responding right now`,children:[a.jsx("span",{className:`ap-lan-chev${N?" open":""}`,"aria-hidden":!0,children:"›"}),N?"fewer":`${ee.length} more`,!N&&ne>0&&a.jsxs("span",{className:"ap-lan-more-bad",children:[" · ",ne," not responding"]})]}),W&&pe>0&&a.jsx("span",{className:"ap-lan-checked",children:PG(x==null?void 0:x.checkedAt,b,_==="check")})]}),Y.length===0&&X.length===0&&!(x!=null&&x.stalled)&&!(x!=null&&x.deaf)&&!(x!=null&&x.lanTunneled)&&a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"ap-lan-fine",children:"No other deck yet. Decks on one network usually find each other on their own; when that has not happened, the link at the top of this view reaches one by address or by invite."}),a.jsx("button",{type:"button",className:"ap-lan-word ap-lan-how",onClick:()=>g(!0),children:"How it works"}),a.jsx(Gl,{film:"localNetwork"})]})]})]})}),fe]}):a.jsxs("div",{className:"ap-foot",children:[a.jsx(GY,{entry:ae,rows:J,onOpen:s,onMap:W?()=>H(!0):void 0,...v}),a.jsx("p",{className:"vis-hidden",role:"status",children:ke.tone==="ok"?"":ke.text}),fe]})}function aX({anchorId:e,id:t,peers:n,onHold:r,onLet:s}){const o=y.useRef(null),{title:l,shown:c,rest:d}=AG(n),h=y.useCallback(()=>{const f=o.current,p=document.getElementById(e);if(!f||!p)return;const g=m0(p.getBoundingClientRect(),{width:f.offsetWidth,height:f.offsetHeight},{width:window.innerWidth,height:window.innerHeight});f.style.top=`${g.top}px`,f.style.left=`${g.left}px`,f.style.maxHeight=g.maxHeight==null?"":`${g.maxHeight}px`,f.dataset.side=g.side},[e]);return y.useLayoutEffect(()=>{h()}),y.useEffect(()=>(window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}),[h]),Lt.createPortal(a.jsxs("div",{ref:o,id:t,className:"ap-peek ap-fold-peek",role:"tooltip",onPointerEnter:r,onPointerLeave:s,children:[a.jsx("p",{className:"ap-peek-title",children:l}),a.jsx("div",{className:"ap-peek-list",children:c.map(f=>a.jsxs("span",{className:"ap-peek-who ap-fold-who",children:[a.jsx("span",{className:"ap-fold-name",children:f.name}),a.jsx("span",{className:"ap-fold-state","data-tone":f.ready?"ok":f.warn?"warn":"idle",children:f.ready?f.headroom==null?"not read yet":`${Math.round(f.headroom)}% free`:f.why})]},f.key))}),d&&a.jsx("p",{className:"ap-peek-rest",children:d})]}),document.body)}function oX({peers:e,strained:t,armed:n,threshold:r,open:s,onToggle:o,order:l,choices:c,onOrder:d,allOpen:h,onToggleAll:f,held:p=!1}){const[g,v]=y.useState(!1),N=y.useRef(0);y.useEffect(()=>()=>window.clearTimeout(N.current),[]),y.useEffect(()=>{s&&(window.clearTimeout(N.current),v(!1))},[s]);const k=E=>{s||(window.clearTimeout(N.current),N.current=window.setTimeout(()=>v(!0),E))},x=()=>{window.clearTimeout(N.current),N.current=window.setTimeout(()=>v(!1),BI)},j=()=>window.clearTimeout(N.current),b=()=>{window.clearTimeout(N.current),v(!1)},_=TG(e,{strained:t&&!s,armed:n,threshold:r});return a.jsxs("div",{className:"ap-rest",children:[a.jsxs("button",{type:"button",id:"ap-rest-entry",className:"ap-nav","aria-expanded":s,"aria-controls":s?"ap-rest-panel":void 0,"aria-describedby":g?"ap-rest-peek":void 0,onClick:()=>{b(),o()},onPointerEnter:E=>{E.pointerType==="mouse"&&k(FI)},onPointerLeave:x,onFocus:E=>{E.target.matches(":focus-visible")&&k(0)},onBlur:x,children:[a.jsxs("span",{className:"ap-nav-text",children:[a.jsx("span",{className:"ap-nav-name",children:"Other accounts"}),a.jsx("span",{className:"ap-nav-state","data-tone":_.tone,children:_.text})]}),a.jsx("svg",{className:"ap-nav-chev",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),g&&a.jsx(aX,{anchorId:"ap-rest-entry",id:"ap-rest-peek",peers:e,onHold:j,onLet:x}),s&&a.jsx(iX,{order:l,choices:c,onOrder:d,allOpen:h,onToggleAll:f,held:p})]})}function iX({order:e,choices:t,onOrder:n,allOpen:r,onToggleAll:s,held:o}){var d;const l=y.useRef(null);y.useLayoutEffect(()=>{const h=l.current,f=h==null?void 0:h.parentElement;if(!h||!f)return;const p=()=>f.style.setProperty("--rest-tools-w",`${Math.ceil(h.offsetWidth)}px`);if(p(),typeof ResizeObserver>"u")return;const g=new ResizeObserver(p);return g.observe(h),()=>{g.disconnect(),f.style.removeProperty("--rest-tools-w")}},[]);const c=((d=t.find(h=>h.id===e))==null?void 0:d.label)??"Slot";return a.jsxs("div",{className:"ap-rest-tools",ref:l,children:[a.jsxs("span",{className:"ap-rest-sort",children:[a.jsx("select",{value:e,onChange:h=>n(h.target.value),"aria-label":"Order of the other accounts",title:o?`${c} — held where it was while you are in the list`:c,"data-sorted":e===hh?void 0:"","data-held":o?"":void 0,children:t.map(h=>a.jsx("option",{value:h.id,children:h.label},h.id))}),a.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M2.5 3.8 5 6.3l2.5-2.5"})})]}),a.jsx("button",{type:"button",className:"ap-rest-all","aria-label":"Expand every account","aria-pressed":r,"aria-controls":"ap-rest-list",title:r?"Collapse every account":"Expand every account",onClick:s,children:a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:r?"M2 7h10M7 1.5V5M5.2 3.2 7 5l1.8-1.8M7 12.5V9M5.2 10.8 7 9l1.8 1.8":"M2 7h10M7 1.5V5M5.2 3.3 7 1.5l1.8 1.8M7 12.5V9M5.2 10.7 7 12.5l1.8-1.8"})})})]})}async function lX(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const cX=1800;function uX({accounts:e,onClose:t,copyText:n}){qt("share-accounts");const[r,s]=y.useState([]),[o,l]=y.useState(null),[c,d]=y.useState(!1),[h,f]=y.useState(null),[p,g]=y.useState(!1),[v,N]=y.useState(()=>Math.floor(Date.now()/1e3)),k=y.useRef(null),x=y.useRef(!1),j=ut(t,{focusRef:k}),b=gt(t),_=is(o!=null,k),E=is(o==null,k);y.useEffect(()=>{if(!o)return;N(Math.floor(Date.now()/1e3));const P=window.setInterval(()=>N(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval(P)},[o]);const R=uG(e),C=dG(e,r),A=C.length===e.length,U=P=>s(G=>hG(G,P)),L=y.useCallback(async()=>{const P=fG(C);if(!lr(x.current)||!P)return;x.current=!0,d(!0),f(null),g(!1);const G=await lX(P).catch(()=>null);if(x.current=!1,d(!1),!(G!=null&&G.ok)){f(Jo(G,"the share could not be made"));return}l({blob:G.blob,expiresAt:G.expiresAt,shared:G.shared??[],failed:G.failed??[]})},[e,C]),F=o?II(o.expiresAt,v):null,O=(F==null?void 0:F.tone)==="gone",I=(o==null?void 0:o.shared.length)??0,B=O?"This share has expired":I===1?"1 account, ready to paste":`${I} accounts, ready to paste`,M=I===1?"this is the password":`this is ${I} passwords`,$=o?O?B:`${B} — ${M}`:"";return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...b,role:"presentation",children:a.jsxs("div",{ref:j,className:"modal sa-modal",onClick:P=>P.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Share accounts with another deck",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("h3",{children:"Share accounts"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body sa-body",children:[a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:$}),o?a.jsxs("div",{className:"sa-step",children:[a.jsx("h4",{children:B}),a.jsx("code",{className:"ap-share-blob",children:o.blob}),a.jsxs("div",{className:"ap-share-foot",children:[a.jsx("button",{type:"button",className:"ap-manage-btn",ref:k,onClick:async()=>{if(O){E(),_(),l(null),L();return}await n(o.blob)&&(g(!0),window.setTimeout(()=>g(!1),cX))},children:O?"make a new share":p?"copied":`copy ${I===1?"the share":"all "+I}`}),a.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:[a.jsx("span",{className:"ap-share-warn",children:M})," · ",a.jsx("span",{className:`ap-share-expiry ${F==null?void 0:F.tone}`,children:F==null?void 0:F.text})]})]}),o.failed.length>0&&a.jsxs("div",{className:"sa-failed",role:"alert",children:[a.jsx("p",{className:"sa-failed-head",children:o.failed.length===1?"One account is not in this bundle:":`${o.failed.length} accounts are not in this bundle:`}),a.jsx("ul",{className:"sa-list",children:o.failed.map(P=>{var K;const G=!!(P.email&&((K=P.detail)!=null&&K.includes(P.email)));return a.jsxs("li",{children:[!G&&a.jsx("span",{className:"sa-who",children:P.email||`account ${P.num}`}),a.jsx("span",{className:"sa-why",children:P.detail||"could not be exported"})]},`${P.num}-${P.email}`)})})]}),a.jsx("p",{className:"sa-note",children:O?a.jsx(a.Fragment,{children:"Another deck will refuse this text now. Make a new one — the same accounts are still picked."}):a.jsxs(a.Fragment,{children:["Paste it into the other deck with ",a.jsx("strong",{children:"+"})," → ",a.jsx("strong",{children:"Paste a share"}),". Accounts it already holds are left exactly as they are."]})}),a.jsxs("div",{className:"sa-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>{E(),l(null),g(!1)},children:"Pick again"}),a.jsx("button",{type:"button",className:"btn primary",onClick:t,children:"Done"})]})]}):e.length===0?a.jsxs("div",{className:"sa-step",children:[a.jsx("h4",{children:"Nothing to share"}),a.jsxs("p",{className:"sa-note",children:["This deck is not holding any accounts right now. Sign one in with ",a.jsx("strong",{children:"+"}),", or wait — the panel is still reading the store."]}),a.jsx("div",{className:"sa-actions",children:a.jsx("button",{type:"button",className:"btn primary",ref:k,onClick:t,children:"Close"})})]}):a.jsxs("div",{className:"sa-step",children:[a.jsxs("h4",{children:["Which accounts go to the other ",kt,"?"]}),a.jsx("p",{className:`sa-count${C.length?"":" empty"}`,children:pG(C.length)}),a.jsx("ul",{className:"sa-list sa-pick",children:R.map(P=>a.jsx("li",{children:a.jsxs("label",{className:"sa-row",children:[a.jsx("input",{type:"checkbox",checked:C.includes(P.num),onChange:()=>U(P.num)}),a.jsx("span",{className:"sa-who",children:P.label}),P.sub&&a.jsx("span",{className:"sa-sub",children:P.sub})]})},P.num))}),h&&a.jsx("p",{className:"aa-err",role:"alert",children:h}),a.jsxs("div",{className:"sa-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>s(A?e.map(P=>P.num):[]),children:A?"Clear all":"Select all"}),a.jsx("button",{type:"button",className:"btn primary",ref:k,...Dr(c,!C.length),onClick:()=>{_(),L()},children:c?"making the share…":C.length===0?"Share":C.length===1?"Share 1 account":`Share ${C.length} accounts`})]})]})]})]})}),document.body)}function oO(e,t){var n;return!e.disabled&&!((n=wi(e,t))!=null&&n.blocksSwitch)}function dX(e,t,n){return e.map(r=>{const s=wi(r,t,n==null?void 0:n(r));return{key:Lr(r),name:r.alias??r.email??`account ${r.num}`,ready:oO(r,t),why:r.disabled?"held out":s!=null&&s.blocksSwitch?s.text:null,warn:(s==null?void 0:s.tone)==="warn",headroom:w0(r,t)}})}function hX(e,t,n){const r=Number(t),s=e&&(n==null?e.headroom:w0(e,n));return s!=null&&Number.isFinite(r)&&100-s>=r}function fX(e){return(e==null?void 0:e.ok)===!0&&(e.enabled||e.external)}const iO="agent-dag.otherAccountsOrder",lO="agent-dag.otherAccountsOpen";function pX(){const e=Qe(iO);return typeof e=="string"&&e.length>0&&e.length<=64?e:hh}function mX(e){Ze(iO,e)}function gX(){const e=Qe(lO);if(!e)return Zx;try{const t=JSON.parse(e);if(((t==null?void 0:t.mode)==="some"||(t==null?void 0:t.mode)==="all")&&Array.isArray(t.keys)&&t.keys.every(n=>typeof n=="string"))return{mode:t.mode,keys:t.keys.slice(0,200)}}catch{}return Zx}function yX(e){Ze(lO,JSON.stringify({mode:e.mode,keys:e.keys.filter(t=>!t.startsWith("slot:"))}))}function wX(){const[e,t]=y.useState(null),n=y.useRef(null),r=y.useCallback(l=>lh(n.current)?(n.current=l,t(l),!0):!1,[]),s=y.useCallback(()=>{n.current=null,t(null)},[]);return{busy:e,claim:r,release:s,pressProps:(l,c=!1)=>{const d=ia(e,l);return{disabled:d.disabled,"aria-busy":d.busy||c}}}}const vX=8e3,xX=1800,bX=4e3;function kX({claim:e,release:t,load:n,clearFailure:r,rescueFocus:s}){const[o,l]=y.useState(null),c=(o==null?void 0:o.num)??null,d=y.useRef(o);d.current=o;const[h,f]=y.useState(null),[p,g]=y.useState(""),[v,N]=y.useState(null),k=y.useRef(0);y.useEffect(()=>{if(v==null)return;const J=window.setTimeout(()=>N(null),bX);return()=>window.clearTimeout(J)},[v]);const[x,j]=y.useState(null),[b,_]=y.useState(!1),[E,R]=y.useState(null),[C,A]=y.useState(null),U=y.useCallback(async(J,V)=>{if(!e(V))return null;r(),f(null);try{const X=await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(J)}),Y=await X.json().catch(()=>null);return Y!=null&&Y.ok||f({text:Jo(Y,"command failed",X.status)}),Y}catch{return f({text:"server unreachable"}),null}finally{t()}},[e,t,r]),L=y.useCallback(()=>{l(null),f(null),N(null),j(null),_(!1)},[]),F=(J,V="first")=>{L(),A(null),l({num:J,view:"menu",start:V})},O=y.useCallback(J=>{var Y,Z;const V=d.current;if(!V||J!=null&&V.num!==J)return;const X=document.getElementById(`ap-menu-${V.num}`);(X!=null&&X.contains(document.activeElement)||Tn(((Y=document.activeElement)==null?void 0:Y.tagName)??null))&&((Z=document.getElementById(`ap-more-${V.num}`))==null||Z.focus()),L()},[L]),I=y.useCallback(J=>f(J),[]),B=(J,V)=>{g(V??""),f(null),l({num:J,view:"rename"})},M=J=>g(J),$=J=>{A(null),f(null),l({num:J,view:"move"})},P=J=>A(J),G=async J=>{var X;_(!1);const V=await U({action:"share",account:J},`share-${J}`);!(V!=null&&V.ok)||((X=d.current)==null?void 0:X.num)!==J||(j({num:J,blob:V.blob,expiresAt:V.expiresAt}),l({num:J,view:"share"}))},K=async J=>{await eo(J)&&(_(!0),window.setTimeout(()=>_(!1),xX))},q=async(J,V)=>{const{commit:X,alias:Y}=kG(p,V);if(X){const Z=await U({action:"alias",account:J,alias:Y},`alias-${J}`);if(await n(!0),!(Z!=null&&Z.ok))return}O(J)},H=async(J,V)=>{var Z,ee,ne;const X=await U({action:"move",account:J,slot:V},`move-${J}`),Y=xG({menuFor:((Z=d.current)==null?void 0:Z.num)??null,shareFor:(x==null?void 0:x.num)??null},J,X);if(await n(!0),Y){if(Y.menuFor!=null){const pe=document.getElementById(`ap-menu-${J}`),ke=document.getElementById(`ap-more-${Y.menuFor}`);ke&&(pe!=null&&pe.contains(document.activeElement)||Tn(((ee=document.activeElement)==null?void 0:ee.tagName)??null))&&ke.focus()}((ne=d.current)==null?void 0:ne.num)===J&&L(),N(Y.confirmRemove),Y.shareFor==null&&(j(null),_(!1)),R(Y.swapNote);const se=Y.swapNote;se&&window.setTimeout(()=>R(pe=>pe===se?null:pe),vX),A(null),s(Y.menuFor)}return X};return{menu:o,menuFor:c,menuError:h,aliasDraft:p,confirmRemove:v,share:x,shareCopied:b,slotDraft:C,swapNote:E,showMenu:F,dropMenu:L,closeMenu:O,sayInMenu:I,startRename:B,typeAlias:M,doAlias:q,startMove:$,pickSlot:P,doSlot:async(J,V,X)=>{if(!X.sends){O(J);return}await H(J,V)},makeShare:G,copyShare:K,pressRemove:J=>{const V=Date.now(),X=Yl({armedFor:v,target:J,armedAt:k.current,now:V,gapMs:Kl});if(X==="arm"){N(J),k.current=V;return}X!=="ignore"&&(N(null),U({action:"remove",account:J},`rm-${J}`).then(Y=>{var Z;n(!0),Y!=null&&Y.ok&&(((Z=d.current)==null?void 0:Z.num)===J&&L(),s(null))}))}}}function NX(e,t){return!e||!t||t.some(n=>n.num===e.num&&n.active)?e:null}function jX({data:e,claim:t,release:n,load:r,sayFailure:s,clearFailure:o,sayInMenu:l,rescueFocus:c}){const[d,h]=y.useState(null),f=y.useCallback(async(g,v,N="panel")=>{if(!t(v))return null;const k=N==="menu"?l:s;k(null);try{const x=await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)}),j=await x.json().catch(()=>null);return j!=null&&j.ok||k({text:Jx(j,"command failed",x.status),raw:Ql(j)}),j}catch{return k({text:"server unreachable"}),null}finally{n()}},[t,n,l,s]);return y.useEffect(()=>{!(e!=null&&e.ok)||!e.accounts||h(g=>NX(g,e.accounts))},[e]),{switched:d,post:f,doSwitch:async(g,v)=>{if(t(`switch-${g}`)){o(),h(null);try{const k=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:g})})).json().catch(()=>null);k!=null&&k.ok?h({num:g,name:v}):s({text:Jx(k,"the switch failed"),raw:Ql(k),row:g}),await r(!0)}catch{s({text:"server unreachable",row:g})}finally{n(),c(g)}}}}}const SX=1800;function _X({auto:e,post:t,load:n}){var N;const[r,s]=y.useState(null),[o,l]=y.useState(!1),c=y.useRef(null),d=y.useRef(null),h=((N=e==null?void 0:e.settings["autoswitch.threshold"])==null?void 0:N.value)??"90",f=r??h,p=SG(f,h);return{threshold:h,thresholdPick:f,thresholdCtl:p,thresholdSaved:o,thresholdRef:c,thresholdSaveRef:d,proposeThreshold:k=>s(k),doThreshold:async(k,x)=>{if(x.sends){const j=await t({action:"setting",key:"autoswitch.threshold",value:k},"threshold");if(await n(!0),!(j!=null&&j.ok))return;s(null)}l(!0),window.setTimeout(()=>{var j;document.activeElement===d.current&&((j=c.current)==null||j.focus()),l(!1)},SX)}}}const EX=Object.freeze({text:"couldn't reach the deck server",reload:!0}),TX=Object.freeze({text:"still waiting on the deck server — claude-swap can be slow to answer",reload:!0});async function s_(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function CX(e){const t=e.find(r=>!r.ok);if(!t)return null;const n=Ql(t.body);return{text:Jx(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function a_(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 cO=15e3,AX=3e4;function RX(e){const[t,n]=y.useState(null),[r,s]=y.useState(null),[o,l]=y.useState(!1),[c,d]=y.useState(null),h=y.useRef(null),f=y.useCallback(async(v=!1)=>{v&&l(!0);const N=new AbortController,k=window.setTimeout(()=>N.abort(),AX);try{const[x,j]=await Promise.all([fetch(`/api/claude-accounts${v?"?refresh=1":""}`,{signal:N.signal}),fetch("/api/cswap-auto",{signal:N.signal})]);if(x.ok){const _=await x.json();n(_),e(_)}j.ok&&s(await j.json());const b=CX([await s_(x),await s_(j)]);d(_=>a_(_,b))}catch{d(x=>a_(x,N.signal.aborted?TX:EX))}finally{window.clearTimeout(k),v&&l(!1)}},[e]);y.useEffect(()=>(f(!0),h.current=window.setInterval(()=>f(!1),cO),()=>{h.current!=null&&window.clearInterval(h.current)}),[f]);const p=y.useCallback(v=>d(v),[]),g=y.useCallback(()=>d(null),[]);return{data:t,auto:r,reloading:o,failure:c,load:f,sayFailure:p,clearFailure:g}}const MX="#ap-rest-entry";function $X(e){return[`#${e}`,MX,...aI(null)]}function IX(e){const t=y.useRef(null),n=s=>{t.current=s.target.id||null},r=s=>{s.target.isConnected&&(t.current=null)};return y.useLayoutEffect(()=>{var o;const s=t.current;if(!(!s||!Tn(((o=document.activeElement)==null?void 0:o.tagName)??null)))for(const l of $X(s)){const c=document.querySelector(l);if(c){c.focus();return}}},[e]),{onFocus:n,onBlur:r}}function OX({onClose:e,leaving:t,onReport:n,onRoster:r}){var Gt,bs,Vr;qt("accounts-panel");const{busy:s,claim:o,release:l,pressProps:c}=wX(),[d,h]=y.useState("accounts"),[f,p]=y.useState(!1),[g,v]=y.useState(null),N=y.useRef(g);N.current=g;const[k,x]=y.useState(!1),[j,b]=y.useState(!1),[_,E]=y.useState([]),[R,C]=y.useState(!1),[A,U]=y.useState(null),[L,F]=y.useState(gX),[O,I]=y.useState(pX),[B,M]=y.useState(null),[$,P]=y.useState(!1),G=y.useRef(r);G.current=r;const K=y.useCallback(ye=>{var Fe;F(Ge=>hV(Ge,ye.accounts)),(Fe=G.current)==null||Fe.call(G,ye)},[]),{data:q,auto:H,reloading:D,failure:W,load:J,sayFailure:V,clearFailure:X}=RX(K),Y=IX(q),Z=y.useCallback(ye=>{window.requestAnimationFrame(()=>{var Fe;if(Tn(((Fe=document.activeElement)==null?void 0:Fe.tagName)??null))for(const Ge of aI(ye)){const rn=document.querySelector(Ge);if(rn){rn.focus();return}}})},[]),ee=kX({claim:o,release:l,load:J,clearFailure:X,rescueFocus:Z}),{menu:ne,menuFor:se,swapNote:pe,showMenu:ke,dropMenu:ae,closeMenu:fe,sayInMenu:me}=ee,{switched:he,post:ge,doSwitch:ue}=jX({data:q,claim:o,release:l,load:J,sayFailure:V,clearFailure:X,sayInMenu:me,rescueFocus:Z}),{threshold:be,thresholdPick:oe,thresholdCtl:je,thresholdSaved:$e,thresholdRef:Oe,thresholdSaveRef:Ue,proposeThreshold:Be,doThreshold:We}=_X({auto:H,post:ge,load:J}),He=hI();y.useEffect(()=>{yX(L)},[L]),y.useEffect(()=>{mX(O)},[O]);const[rt,lt]=y.useState(()=>new Set),Rt=y.useCallback(ye=>lt(new Set(ye)),[]),De=ye=>({noCopyWorksNearby:rt.has(PS([ye])[0].key)}),et=(Gt=q==null?void 0:q.accounts)==null?void 0:Gt.find(ye=>ye.active),Je=et?wi(et,He,De(et)):null,tt=(q==null?void 0:q.accounts)??[],yt=et?tt.filter(ye=>!ye.active):[],Pt=jI(yt),wt=lV(O,yt),st=Xx(iV(yt,wt,ye=>oO(ye,He),He),B),zt=y.useRef(!1),Wt=y.useRef(!1),Dt=y.useRef(!1),Ht=y.useCallback(()=>{!zt.current&&!Wt.current&&!Dt.current&&M(null)},[]),Vt=()=>M(ye=>ye??st.map(Lr)),vs={onPointerEnter:()=>{zt.current=!0,Vt()},onPointerLeave:()=>{zt.current=!1,Ht()},onFocus:ye=>{ye.target.matches(":focus-visible")&&(Wt.current=!0,Vt())},onBlur:ye=>{ye.currentTarget.contains(ye.relatedTarget)||(Wt.current=!1,Ht())}},Cn=se!=null&&yt.some(ye=>ye.num===se)||g!=null&&yt.some(ye=>ye.num===g.num);y.useEffect(()=>{Dt.current=Cn,Cn||Ht()},[Cn,Ht]);const mr=$&&yt.length>0;y.useEffect(()=>{mr||(zt.current=Wt.current=Dt.current=!1,M(null))},[mr]);const zr=y.useRef(!1);y.useEffect(()=>{zr.current&&yt.length===0&&Z(null),zr.current=yt.length>0},[yt.length,Z]);const gr=st.length?tt.filter(ye=>ye.active):tt,Wr=dX(st,He,De),mn=hX(et,be,He),Hr=fX(H),An=ye=>$&&st.some(Fe=>Fe.num===ye)?"ap-rest-list":"ap-scroll",da=(ye,Fe="first")=>{ke(ye,Fe),v(null)},gn=(ye,Fe)=>{ae(),v(Ge=>(Ge==null?void 0:Ge.anchor)===Fe?null:{num:ye,anchor:Fe})},yr=y.useCallback((ye=!1)=>{var Ge;const Fe=N.current;ye&&Fe&&((Ge=document.getElementById(Fe.anchor))==null||Ge.focus()),v(null)},[]),wr=()=>{ae(),v(null),h("lan")},xt=y.useRef(d);y.useEffect(()=>{xt.current!==d&&(xt.current=d,window.requestAnimationFrame(()=>{var ye;(ye=document.getElementById(d==="lan"?"ap-lan-back":"ap-lan-entry"))==null||ye.focus()}))},[d]),y.useEffect(()=>{q!=null&&q.ok&&p(!0)},[q==null?void 0:q.ok]),y.useEffect(()=>{t&&(ae(),v(null))},[t,ae]),y.useEffect(()=>{ne&&(q!=null&&q.accounts)&&!q.accounts.some(ye=>ye.num===ne.num)&&ae(),g&&(q!=null&&q.accounts)&&!q.accounts.some(ye=>ye.num===g.num)&&v(null)},[q,ne,g,ae]),y.useEffect(()=>{A==null||!(q!=null&&q.accounts)||q.accounts.some(ye=>ye.num===A.num)||(U(null),Z(null))},[q,A,Z]);const xs=a.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:a.jsx("path",{d:"M3.4 3.4l7.2 7.2M10.6 3.4l-7.2 7.2"})})}),vr=ye=>{const Fe=SI(L,ye),Ge=se===ye.num,rn=(W==null?void 0:W.row)===ye.num?W:null,Gr=(he==null?void 0:he.num)===ye.num,br=(pe==null?void 0:pe.at)===ye.num?pe:null,ha=br?tt.find(Kr=>Kr.num===br.displaced):void 0,Ke=(g==null?void 0:g.anchor)===`ap-issue-${ye.num}`;return a.jsx(mV,{a:ye,nowSec:He,lan:De(ye),opened:Fe,onToggleLanes:()=>F(Kr=>uV(Kr,ye)),busy:s,pressProps:c,onSwitch:ue,menuOpen:Ge,onOpenMenu:da,onCloseMenu:fe,refusal:rn,onDismissRefusal:()=>X(),switchedHere:Gr,swapped:br,displaced:ha,issueExpanded:Ke,onOpenIssue:gn,sortKey:ye.active?null:oV(wt)},ye.num)},xr=q!=null&&q.ok&&(H!=null&&H.ok)?a.jsx(DV,{auto:H,threshold:be,thresholdPick:oe,thresholdCtl:je,thresholdSaved:$e,thresholdRef:Oe,thresholdSaveRef:Ue,proposeThreshold:Be,doThreshold:We,pressProps:c,post:ge,load:J}):null;return a.jsxs("aside",{className:`accounts-panel${t?" leaving":""}`,id:"accounts-panel","aria-label":"Claude accounts",onFocus:Y.onFocus,onBlur:Y.onBlur,children:[d==="accounts"&&a.jsx(yV,{canShare:(((bs=q==null?void 0:q.accounts)==null?void 0:bs.length)??0)>0,canReport:(((Vr=q==null?void 0:q.accounts)==null?void 0:Vr.length)??0)>1||j,onAdd:()=>x(!0),onReport:()=>{E([...gr,...st].map(Lr)),b(!0)},onShareSet:()=>C(!0),onReload:()=>J(!0),pressProps:c,reloading:D,closeButton:xs}),d==="accounts"&&a.jsxs("div",{className:"ap-scroll",id:"ap-scroll",children:[q==null?W?a.jsxs("div",{className:"ap-empty",role:"alert",children:[a.jsx("span",{title:W.raw||void 0,children:W.text}),a.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",cO/1e3," seconds."]}),a.jsx("button",{type:"button",className:"ap-fix",...c("reload",D),onClick:()=>J(!0).then(()=>Z(null)),children:D?"trying…":"try again"})]}):a.jsx("div",{className:"ap-empty",children:"Checking…"}):q.ok?a.jsxs(a.Fragment,{children:[et&&(Je==null?void 0:Je.tone)==="warn"&&a.jsxs("div",{className:"ap-notice",children:[a.jsxs("button",{type:"button",id:"ap-notice",className:"ap-issue","data-tone":"warn","aria-haspopup":"dialog","aria-expanded":(g==null?void 0:g.anchor)==="ap-notice","aria-controls":(g==null?void 0:g.anchor)==="ap-notice"?"ap-issue-pop":void 0,onClick:()=>gn(et.num,"ap-notice"),children:[a.jsx(y0,{}),a.jsx("span",{className:"ap-issue-text",children:"Current account needs attention"})]}),Je.fix&&a.jsx("button",{type:"button",className:"ap-notice-fix",onClick:()=>x(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"Sign in"})]}),a.jsx("ul",{className:"ap-list",children:gr.map(vr)}),st.length>0&&a.jsx(oX,{peers:Wr,strained:mn,armed:Hr,threshold:H!=null&&H.ok?be:null,open:$,onToggle:()=>P(ye=>!ye),order:wt,choices:Pt,onOrder:I,allOpen:_I(L,st),onToggleAll:()=>F(ye=>dV(ye,st)),held:B!=null}),st.length>0&&$&&a.jsxs("div",{className:"ap-rest-panel",id:"ap-rest-panel",children:[a.jsx("ul",{className:"ap-list ap-others",id:"ap-rest-list",...vs,children:st.map(vr)}),xr]}),st.length===0&&xr,W&&W.row==null&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",title:W.raw||void 0,children:W.text}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>X(),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),ne&&(()=>{var Fe;const ye=(Fe=q.accounts)==null?void 0:Fe.find(Ge=>Ge.num===ne.num);return ye?a.jsx(_G,{a:ye,accountMenu:ee,slots:(q.accounts??[]).map(Ge=>Ge.num),boundaryId:An(ye.num),nowSec:He,busy:s,pressProps:c,rotating:!!(H!=null&&H.enabled||H!=null&&H.external),onProjects:()=>{U({num:ye.num,name:ye.alias??ye.email??`account ${ye.num}`}),fe(ye.num)},onRotation:()=>ge({action:"account",account:ye.num,enabled:ye.disabled},`rot-${ye.num}`,"menu").then(Ge=>{J(!0),Ge!=null&&Ge.ok&&fe(ye.num)})}):null})(),g&&(()=>{var Ge;const ye=(Ge=q.accounts)==null?void 0:Ge.find(rn=>rn.num===g.num),Fe=ye?wi(ye,He,De(ye)):null;return!ye||!Fe?null:a.jsx(Z9,{anchorId:g.anchor,boundaryId:g.anchor==="ap-notice"?"ap-scroll":An(ye.num),issue:Fe,who:ye.alias??ye.email??`account ${ye.num}`,fetchedAt:ye.fetchedAt,nowSec:He,onClose:yr,onSignIn:()=>x(!0),onReport:n&&(()=>n({initialKind:Fe.tone==="warn"?"bug":"other",initialBody:`Account issue: ${Fe.text}. ${Fe.hint}`}))})})()]}):a.jsx(gV,{data:q}),a.jsx("div",{className:"film-foot",children:a.jsx(Gl,{film:"claudeAccounts"})})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:he?`Now active: ${he.name}`:""}),f&&a.jsx(sX,{accounts:PS((q==null?void 0:q.accounts)??[]),onChanged:()=>J(!0),onNoCopy:Rt,view:d==="lan",onOpen:wr,onBack:()=>h("accounts"),closeButton:xs}),k&&a.jsx(OI,{onClose:()=>x(!1),onChanged:()=>J(!0)}),R&&a.jsx(uX,{accounts:((q==null?void 0:q.accounts)??[]).map(ye=>({num:ye.num,email:ye.email,alias:ye.alias,org:ye.org})),onClose:()=>C(!1),copyText:eo}),A!=null&&(()=>{var Fe;const ye=(Fe=q==null?void 0:q.accounts)==null?void 0:Fe.find(Ge=>Ge.num===A.num);return q!=null&&q.accounts&&!ye?null:a.jsx(Y9,{num:A.num,name:ye?ye.alias??ye.email??`account ${ye.num}`:A.name,onClose:()=>U(null)})})(),j&&a.jsx(LV,{accounts:(q==null?void 0:q.accounts)??null,order:_,failed:W!=null&&W.reload?W.text:null,nowSec:He,onClose:()=>b(!1)})]})}const LX=16,PX=120;function DX(e,t,n=0){return e.clientX>=t.left-n&&e.clientX<=t.right+n&&e.clientY>=t.top-n&&e.clientY<=t.bottom+n}function FX(e,t){const n=Math.max(t.left-e.clientX,0,e.clientX-t.right),r=Math.max(t.top-e.clientY,0,e.clientY-t.bottom);return Math.hypot(n,r)}function BX(e,t){return DX(e,t,LX)?"over":FX(e,t)<=PX?"near":"far"}function qX(e){var n,r;if(typeof e.clientX=="number"&&typeof e.clientY=="number")return{clientX:e.clientX,clientY:e.clientY};const t=((n=e.changedTouches)==null?void 0:n[0])??((r=e.touches)==null?void 0:r[0]);return t?{clientX:t.clientX,clientY:t.clientY}:null}function UX(){const[e,t]=y.useState(!1),[n,r]=y.useState(""),[s,o]=y.useState("far"),l=y.useRef(null),c=td(e,140),d=y.useCallback(g=>{var k;const v=(k=l.current)==null?void 0:k.getBoundingClientRect(),N=qX(g);return v&&N?BX(N,v):"far"},[]),h=y.useCallback(g=>{g!==null&&(r(g),t(!0)),o("far")},[]),f=y.useCallback(g=>{o(d(g))},[d]),p=y.useCallback((g,v)=>{const N=v&&d(g)==="over";return t(!1),N},[d]);return{trashDragging:e,trashLabel:n,trashState:s,trashZoneRef:l,trashPhase:c,beginTrashDrag:h,trackTrashDrag:f,endTrashDrag:p}}const zX=420;function WX(){const[e,t]=y.useState(!1),n=y.useRef(null),r=y.useCallback(()=>{n.current&&(window.clearTimeout(n.current),n.current=null),t(!1)},[]),s=y.useCallback(o=>{o.length!==0&&queueMicrotask(()=>{t(!0),n.current&&window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!1),zX+80)})},[]);return y.useEffect(()=>()=>{n.current&&window.clearTimeout(n.current)},[]),{bubbling:e,endBubble:r,onBubble:s}}const T0=11,uO=7.2,dO=6.6,HX={width:104,height:48},o_={width:96,height:44},hO={width:220,height:103};function VX(e){let t=1/0,n=1/0;for(const r of e)!(r.width>0)||!(r.height>0)||(t=Math.min(t,r.width),n=Math.min(n,r.height));return!Number.isFinite(t)||!Number.isFinite(n)?hO:{width:Math.max(160,t),height:Math.max(72,n)}}function Wp(e,t,n){return e.width*t>=n.width&&e.height*t>=n.height}function GX(e,t,n=hO){if(!Number.isFinite(t)||t<=0)return e??"detail";const r=T0*t;return e==="detail"?r>=dO?"detail":Wp(n,t,o_)?"compact":"overview":r>=uO?"detail":e==="compact"?Wp(n,t,o_)?"compact":"overview":Wp(n,t,HX)?"compact":"overview"}const KX=uO/T0,YX=dO/T0;function XX(e,t){return e>=KX?e:Math.max(e,Math.min(t,YX-.001))}const ZX=.8,JX=1;function QX({stateRef:e,measuredRef:t,measuredVersionRef:n,canvasRef:r}){const[s,o]=y.useState("detail"),l=y.useRef(null),c=y.useRef(null),d=y.useCallback(()=>{var v;const f=n.current;if(((v=c.current)==null?void 0:v.version)===f)return c.current.card;const p=[];for(const N of e.current.agents.keys()){const k=t.current.get(N);k&&p.push(k)}const g=VX(p);return c.current={version:f,card:g},g},[]),h=y.useCallback(f=>{var g;const p=GX(l.current,f,d());return p===l.current?null:(l.current=p,(g=r.current)==null||g.setAttribute("data-lod",p),o(p),p)},[d,r]);return{lod:s,lodRef:l,applyZoom:h}}const eZ=40,tZ=120;function nZ(e,t){let n=null,r=0,s=Number.NEGATIVE_INFINITY;const o=()=>{n=null,s=t.now(),e()},l=()=>{n!=null&&(t.clearTimeout(n),n=null)},c=(d,h,f)=>{if(n!=null){if(r<=d)return;l()}const p=Math.min(f,Math.max(0,d-h));r=d,n=t.setTimeout(o,p)};return{live(d=eZ){const h=t.now(),f=Math.max(s+d,h);if(f<=h){l(),o();return}c(f,h,d)},replay(d=tZ){l(),r=t.now()+d,n=t.setTimeout(o,d)},flush(){l(),o()},cancel(){l()}}}const rZ=1024*1024,i_=5,fO=.8,cb=24,sZ="agent-dag.soundCustom.done",aZ="agent-dag.soundCustom.needs-input",Il={done:sZ,"needs-input":aZ};function tc(e){if(e.kind!=="audio")return e;const{bytes:t,...n}=e;return n}function l_(e){return!e||!/^[a-zA-Z0-9._-]{1,96}$/.test(e)?null:e}function oZ(e){return{done:l_(e(Il.done)),"needs-input":l_(e(Il["needs-input"]))}}function iZ(e,t){return{done:e.done===t?null:e.done,"needs-input":e["needs-input"]===t?null:e["needs-input"]}}function lZ(e){return e.done&&e.done===e["needs-input"]?e.done:null}const cZ={wav:"audio/wav",wave:"audio/wav",mp3:"audio/mpeg",ogg:"audio/ogg",oga:"audio/ogg",webm:"audio/webm",m4a:"audio/mp4",mp4:"audio/mp4"},pO=new Set(["audio/wav","audio/x-wav","audio/mpeg","audio/mp3","audio/ogg","audio/webm","audio/mp4"]);function mO(e,t){const n=t.toLowerCase().split(";")[0].trim();if(pO.has(n))return n;const r=e.toLowerCase().split(".").pop()??"";return cZ[r]??n}function c_(e,t){const n=mO(e.name,e.type);if(!pO.has(n))return"Use a WAV, MP3, OGG, or browser-recorded audio file.";if(!Number.isFinite(e.size)||e.size<=0)return"The audio file is empty.";if(e.size>rZ)return"Audio must be 1 MB or smaller.";if(t!==void 0){if(!Number.isFinite(t)||t<=0)return"The audio file could not be decoded.";if(t>i_)return`Audio must be ${i_} seconds or shorter.`}return null}function ub(e){return e>=cb?`There are already ${cb} custom sounds. Delete one first.`:null}function uZ(e,t){const n=e.indexOf(t);return n<0?null:e[n+1]??e[n-1]??null}function dZ(e){let t=0;for(const n of e)for(let r=0;r<n.length;r++)t=Math.max(t,Math.abs(n[r]));return t<=1e-5?1:Math.min(16,fO/t)}function gO(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}async function hZ(e,t,n=gO()){var h;const r=((h=e.name)==null?void 0:h.trim())||"Custom sound",s=c_({name:r,type:e.type,size:e.size});if(s)throw new Error(s);const o=await e.arrayBuffer();let l;try{l=await t(o.slice(0))}catch{throw new Error("The audio file could not be decoded.")}const c=c_({name:r,type:e.type,size:e.size},l.duration);if(c)throw new Error(c);const d=Array.from({length:l.numberOfChannels},(f,p)=>l.getChannelData(p));return{id:n,name:r.replace(/\.(wav|wave|mp3|ogg|oga|webm|m4a|mp4)$/i,"")||"Custom sound",kind:"audio",mime:mO(r,e.type),duration:l.duration,normalizationGain:dZ(d),bytes:o}}function fZ(e,t=gO()){const n=e.name.trim()||"Custom voice",r=e.text.trim();if(!r)throw new Error("Enter the words this voice should say.");const s=Number.isFinite(e.rate)?e.rate:1,o=Number.isFinite(e.pitch)?e.pitch:1;return{id:t,name:n,kind:"tts",text:r.slice(0,180),voiceURI:e.voiceURI??"",rate:Math.min(2,Math.max(.5,s)),pitch:Math.min(2,Math.max(.5,o))}}const pZ="ccdeck-notification-audio",mZ=2,dr="assets",Br="summaries";function fc(){return typeof window<"u"?window.ccdeckNotificationAudio??null:null}function gZ(){return new Promise((e,t)=>{const n=indexedDB.open(pZ,mZ);n.onupgradeneeded=r=>{const s=n.result,o=s.objectStoreNames.contains(dr)?n.transaction.objectStore(dr):s.createObjectStore(dr,{keyPath:"id"});if(s.objectStoreNames.contains(Br))return;const l=s.createObjectStore(Br,{keyPath:"id"});if(r.oldVersion<1)return;const c=o.openCursor();c.onsuccess=()=>{const d=c.result;d&&(l.put(tc(d.value)),d.continue())}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??new Error("Could not open local audio storage."))})}async function pc(e,t,n){const r=await gZ();try{return await new Promise((s,o)=>{const l=r.transaction(e,t),c=n(l),d=()=>o(l.error??new Error("Local audio storage failed."));l.oncomplete=()=>s(c?c.result:void 0),l.onerror=d,l.onabort=d})}finally{r.close()}}async function yZ(){const e=fc();return e?e.list():typeof indexedDB>"u"?[]:await pc([Br],"readonly",t=>t.objectStore(Br).getAll())??[]}async function wZ(e){const t=fc();return t?t.get(e):typeof indexedDB>"u"?null:await pc([dr],"readonly",n=>n.objectStore(dr).get(e))??null}async function u_(e){const t=fc();if(t){await t.put(e);return}if(typeof indexedDB>"u")throw new Error("Local audio storage is unavailable in this browser.");await pc([dr,Br],"readwrite",n=>{n.objectStore(dr).put(e),n.objectStore(Br).put(tc(e))})}async function vZ(e,t){const n=fc();if(n){const r=await n.get(e);r&&await n.put({...r,name:t});return}if(typeof indexedDB>"u")throw new Error("Local audio storage is unavailable in this browser.");await pc([dr,Br],"readwrite",r=>{const s=r.objectStore(dr),o=s.get(e);o.onsuccess=()=>{const l=o.result;if(!l)return;const c={...l,name:t};s.put(c),r.objectStore(Br).put(tc(c))}})}async function xZ(e){const t=fc();if(t){await t.remove(e);return}typeof indexedDB>"u"||await pc([dr,Br],"readwrite",n=>{n.objectStore(dr).delete(e),n.objectStore(Br).delete(e)})}const ad=["done","needs-input"],bZ=[{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}]}],kZ=[{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}]}],C0={done:bZ,"needs-input":kZ},jn="two";function db(e,t){const n=C0[e];return n.find(r=>r.id===t)??n.find(r=>r.id===jn)??n[0]}function yO(e,t){return C0[e].some(r=>r.id===t)?t:jn}db("done",jn).notes,db("needs-input",jn).notes;const d_=.04,wO=.24,od=0,$d=100,hb=5,Qa=50;function vi(e){if(!Number.isFinite(e))return Qa;const t=Math.round(e/hb)*hb;return Math.min($d,Math.max(od,t))}function vO(e){if(e==null)return Qa;const t=e.trim();return/^-?\d+(\.\d+)?$/.test(t)?vi(Number(t)):Qa}function A0(e){const t=vi(e),n=d_+(wO-d_)*(t/$d);return Math.round(n*1e4)/1e4}function NZ(e,t){const n=t.trim,r=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(A0(e)*r*1e4)/1e4}const jZ=.012,h_=1e-4;function SZ(e){return Math.min(1,A0(e)/wO)}function _Z(e,t){const n=e*(A0(t)/fO);return Math.max(1e-4,n)}const EZ=160,TZ="agent-dag.soundLevel.done",CZ="agent-dag.soundLevel.needs-input",AZ="agent-dag.soundFigure.done",RZ="agent-dag.soundFigure.needs-input",xO={done:TZ,"needs-input":CZ},Id={done:AZ,"needs-input":RZ},fb={done:{level:Qa,figure:jn},"needs-input":{level:Qa,figure:jn}};function MZ(e){const t=n=>({level:vO(e(xO[n])),figure:yO(n,e(Id[n]))});return{done:t("done"),"needs-input":t("needs-input")}}function $Z(e,t){return(e??fb)[t]??fb[t]}const IZ={Stop:"done",Notification:"needs-input"};function OZ(e,t){var r;if(t)return null;const n=(r=e==null?void 0:e.payload)==null?void 0:r.hook_event_name;return typeof n!="string"?null:Ot(IZ,n)??null}const LZ=6,PZ="ccdeck-tabs";function DZ(e){return e>=LZ}function FZ(e,t,n){const r=s=>{const o=s.data;(o==null?void 0:o.kind)==="who"&&o.from!==t&&e.postMessage({kind:"here",from:t,to:o.from,streaming:n()})};return e.addEventListener("message",r),{ask(s,o=(l,c)=>setTimeout(l,c)){return new Promise(l=>{const c=new Set,d=h=>{const f=h.data;(f==null?void 0:f.kind)==="here"&&f.to===t&&f.streaming&&c.add(f.from)};e.addEventListener("message",d),e.postMessage({kind:"who",from:t}),o(()=>{e.removeEventListener("message",d),l(c.size)},s)})},leave(){var s;e.removeEventListener("message",r),(s=e.close)==null||s.call(e)}}}function BZ({stateRef:e,rerender:t,pauseGate:n,chimesRef:r,desktopUpdateRef:s}){const[o,l]=y.useState(!1),[c,d]=y.useState(!1),[h,f]=y.useState(!1),p=y.useRef(!0),[g,v]=y.useState(null);return y.useEffect(()=>{const N=new EventSource("/events"),k=nZ(t,{now:()=>Date.now(),setTimeout:(_,E)=>window.setTimeout(_,E),clearTimeout:_=>window.clearTimeout(_)});let x=!1;const j=typeof BroadcastChannel=="function"?FZ(new BroadcastChannel(PZ),Math.random().toString(36).slice(2),()=>x):null,b=window.setInterval(()=>{x||!j||j.ask(600).then(_=>{x||d(DZ(_))})},3e3);return N.addEventListener("open",()=>{l(!0),f(!0)}),N.addEventListener("error",()=>{l(!1),v(null)}),N.addEventListener("open",()=>{x=!0,d(!1)}),N.addEventListener("error",()=>{x=!1}),N.addEventListener("replay-end",()=>{p.current=!1,k.flush(),v(Date.now())}),N.addEventListener("desktop-update",_=>s.current(_.data)),N.addEventListener("hook",_=>{var E;try{const R=JSON.parse(_.data);if(!n.accept(R))return;e.current=h$(e.current,R);const C=R.replay===!0||p.current||Date.now()-R.receivedAt>3e4;C?k.replay():k.live();const A=OZ(R,C);A&&((E=r.current)==null||E.play(A))}catch{}}),()=>{N.close(),k.cancel(),window.clearInterval(b),j==null||j.leave()}},[t]),{live:o,tabCapped:c,everConnected:h,liveSince:g}}const qZ=200,UZ=5*6e4,zZ=6,WZ=2*6e4;function Gu(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function HZ(e,t){let n=!1;for(const s of e)if(!t.has(s)){n=!0;break}if(!n)return e;const r=new Set;for(const s of e)t.has(s)&&r.add(s);return r}function VZ(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`),n.kind==="root"&&t.add(s0(n.id));return t}function GZ(e){const t=new Set;for(const n of e)t.add(n.id),n.kind==="root"&&t.add(s0(n.id));return t}function KZ(e,t){let n=Mq(e,t,Sj);$q(e,t,Sj)&&(n=!0);const r=[],s=o=>{r.push(o)};return Cq(e,t,qZ,UZ,s)&&(n=!0),Aq(e,t,zZ,WZ,s)&&(n=!0),{changed:n,forgotten:r}}function YZ(e,t,n){if(!n)return{ids:new Set([t]),primary:t};const r=new Set(e.ids);if(!r.has(t))return r.add(t),{ids:r,primary:t};if(r.delete(t),e.primary!==t)return{ids:r,primary:e.primary};let s=null;for(const o of r)s=o;return{ids:r,primary:s}}function XZ(e,t){const[n,r]=y.useState(()=>({ids:new Set,primary:null})),{ids:s,primary:o}=n,l=y.useCallback((h,f,p=!f)=>{r(g=>YZ(g,h,f)),!f&&p&&t(!0)},[]),c=y.useCallback(()=>{r({ids:new Set,primary:null})},[]),d=y.useCallback(()=>{r(h=>{const f=HZ(h.ids,e.current.agents),p=h.primary!=null&&!e.current.agents.has(h.primary)?null:h.primary;return f===h.ids&&p===h.primary?h:{ids:f,primary:p}})},[e]);return{selectedIds:s,primarySelectedId:o,selectAgent:l,clearSelection:c,pruneSelectionToBoard:d}}function ZZ({stateRef:e,rerender:t,pruneSelectionToBoard:n,setContextFor:r,setSummaryFor:s}){const[o,l]=y.useState(Date.now());return y.useEffect(()=>{const c=setInterval(()=>{const d=Date.now();l(d);const{changed:h,forgotten:f}=KZ(e.current,d);f.length>0&&fetch("/api/forget",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ids:f})}).catch(()=>{}),n(),r(p=>p!=null&&!e.current.agents.has(p)?null:p),s(p=>p!=null&&!e.current.agents.has(p)?null:p),h&&t()},250);return()=>clearInterval(c)},[t]),o}function R0(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 Hp,f_;function JZ(){if(f_)return Hp;f_=1;function e(){this.__data__=[],this.size=0}return Hp=e,Hp}var Vp,p_;function Ei(){if(p_)return Vp;p_=1;function e(t,n){return t===n||t!==t&&n!==n}return Vp=e,Vp}var Gp,m_;function yh(){if(m_)return Gp;m_=1;var e=Ei();function t(n,r){for(var s=n.length;s--;)if(e(n[s][0],r))return s;return-1}return Gp=t,Gp}var Kp,g_;function QZ(){if(g_)return Kp;g_=1;var e=yh(),t=Array.prototype,n=t.splice;function r(s){var o=this.__data__,l=e(o,s);if(l<0)return!1;var c=o.length-1;return l==c?o.pop():n.call(o,l,1),--this.size,!0}return Kp=r,Kp}var Yp,y_;function eJ(){if(y_)return Yp;y_=1;var e=yh();function t(n){var r=this.__data__,s=e(r,n);return s<0?void 0:r[s][1]}return Yp=t,Yp}var Xp,w_;function tJ(){if(w_)return Xp;w_=1;var e=yh();function t(n){return e(this.__data__,n)>-1}return Xp=t,Xp}var Zp,v_;function nJ(){if(v_)return Zp;v_=1;var e=yh();function t(n,r){var s=this.__data__,o=e(s,n);return o<0?(++this.size,s.push([n,r])):s[o][1]=r,this}return Zp=t,Zp}var Jp,x_;function wh(){if(x_)return Jp;x_=1;var e=JZ(),t=QZ(),n=eJ(),r=tJ(),s=nJ();function o(l){var c=-1,d=l==null?0:l.length;for(this.clear();++c<d;){var h=l[c];this.set(h[0],h[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=r,o.prototype.set=s,Jp=o,Jp}var Qp,b_;function rJ(){if(b_)return Qp;b_=1;var e=wh();function t(){this.__data__=new e,this.size=0}return Qp=t,Qp}var em,k_;function sJ(){if(k_)return em;k_=1;function e(t){var n=this.__data__,r=n.delete(t);return this.size=n.size,r}return em=e,em}var tm,N_;function aJ(){if(N_)return tm;N_=1;function e(t){return this.__data__.get(t)}return tm=e,tm}var nm,j_;function oJ(){if(j_)return nm;j_=1;function e(t){return this.__data__.has(t)}return nm=e,nm}var rm,S_;function bO(){if(S_)return rm;S_=1;var e=typeof Nu=="object"&&Nu&&Nu.Object===Object&&Nu;return rm=e,rm}var sm,__;function pr(){if(__)return sm;__=1;var e=bO(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return sm=n,sm}var am,E_;function Ti(){if(E_)return am;E_=1;var e=pr(),t=e.Symbol;return am=t,am}var om,T_;function iJ(){if(T_)return om;T_=1;var e=Ti(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,s=e?e.toStringTag:void 0;function o(l){var c=n.call(l,s),d=l[s];try{l[s]=void 0;var h=!0}catch{}var f=r.call(l);return h&&(c?l[s]=d:delete l[s]),f}return om=o,om}var im,C_;function lJ(){if(C_)return im;C_=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return im=n,im}var lm,A_;function to(){if(A_)return lm;A_=1;var e=Ti(),t=iJ(),n=lJ(),r="[object Null]",s="[object Undefined]",o=e?e.toStringTag:void 0;function l(c){return c==null?c===void 0?s:r:o&&o in Object(c)?t(c):n(c)}return lm=l,lm}var cm,R_;function Vn(){if(R_)return cm;R_=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return cm=e,cm}var um,M_;function mc(){if(M_)return um;M_=1;var e=to(),t=Vn(),n="[object AsyncFunction]",r="[object Function]",s="[object GeneratorFunction]",o="[object Proxy]";function l(c){if(!t(c))return!1;var d=e(c);return d==r||d==s||d==n||d==o}return um=l,um}var dm,$_;function cJ(){if($_)return dm;$_=1;var e=pr(),t=e["__core-js_shared__"];return dm=t,dm}var hm,I_;function uJ(){if(I_)return hm;I_=1;var e=cJ(),t=(function(){var r=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""})();function n(r){return!!t&&t in r}return hm=n,hm}var fm,O_;function kO(){if(O_)return fm;O_=1;var e=Function.prototype,t=e.toString;function n(r){if(r!=null){try{return t.call(r)}catch{}try{return r+""}catch{}}return""}return fm=n,fm}var pm,L_;function dJ(){if(L_)return pm;L_=1;var e=mc(),t=uJ(),n=Vn(),r=kO(),s=/[\\^$.*+?()[\]{}|]/g,o=/^\[object .+?Constructor\]$/,l=Function.prototype,c=Object.prototype,d=l.toString,h=c.hasOwnProperty,f=RegExp("^"+d.call(h).replace(s,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function p(g){if(!n(g)||t(g))return!1;var v=e(g)?f:o;return v.test(r(g))}return pm=p,pm}var mm,P_;function hJ(){if(P_)return mm;P_=1;function e(t,n){return t==null?void 0:t[n]}return mm=e,mm}var gm,D_;function no(){if(D_)return gm;D_=1;var e=dJ(),t=hJ();function n(r,s){var o=t(r,s);return e(o)?o:void 0}return gm=n,gm}var ym,F_;function M0(){if(F_)return ym;F_=1;var e=no(),t=pr(),n=e(t,"Map");return ym=n,ym}var wm,B_;function vh(){if(B_)return wm;B_=1;var e=no(),t=e(Object,"create");return wm=t,wm}var vm,q_;function fJ(){if(q_)return vm;q_=1;var e=vh();function t(){this.__data__=e?e(null):{},this.size=0}return vm=t,vm}var xm,U_;function pJ(){if(U_)return xm;U_=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return xm=e,xm}var bm,z_;function mJ(){if(z_)return bm;z_=1;var e=vh(),t="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function s(o){var l=this.__data__;if(e){var c=l[o];return c===t?void 0:c}return r.call(l,o)?l[o]:void 0}return bm=s,bm}var km,W_;function gJ(){if(W_)return km;W_=1;var e=vh(),t=Object.prototype,n=t.hasOwnProperty;function r(s){var o=this.__data__;return e?o[s]!==void 0:n.call(o,s)}return km=r,km}var Nm,H_;function yJ(){if(H_)return Nm;H_=1;var e=vh(),t="__lodash_hash_undefined__";function n(r,s){var o=this.__data__;return this.size+=this.has(r)?0:1,o[r]=e&&s===void 0?t:s,this}return Nm=n,Nm}var jm,V_;function wJ(){if(V_)return jm;V_=1;var e=fJ(),t=pJ(),n=mJ(),r=gJ(),s=yJ();function o(l){var c=-1,d=l==null?0:l.length;for(this.clear();++c<d;){var h=l[c];this.set(h[0],h[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=r,o.prototype.set=s,jm=o,jm}var Sm,G_;function vJ(){if(G_)return Sm;G_=1;var e=wJ(),t=wh(),n=M0();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return Sm=r,Sm}var _m,K_;function xJ(){if(K_)return _m;K_=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return _m=e,_m}var Em,Y_;function xh(){if(Y_)return Em;Y_=1;var e=xJ();function t(n,r){var s=n.__data__;return e(r)?s[typeof r=="string"?"string":"hash"]:s.map}return Em=t,Em}var Tm,X_;function bJ(){if(X_)return Tm;X_=1;var e=xh();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return Tm=t,Tm}var Cm,Z_;function kJ(){if(Z_)return Cm;Z_=1;var e=xh();function t(n){return e(this,n).get(n)}return Cm=t,Cm}var Am,J_;function NJ(){if(J_)return Am;J_=1;var e=xh();function t(n){return e(this,n).has(n)}return Am=t,Am}var Rm,Q_;function jJ(){if(Q_)return Rm;Q_=1;var e=xh();function t(n,r){var s=e(this,n),o=s.size;return s.set(n,r),this.size+=s.size==o?0:1,this}return Rm=t,Rm}var Mm,eE;function $0(){if(eE)return Mm;eE=1;var e=vJ(),t=bJ(),n=kJ(),r=NJ(),s=jJ();function o(l){var c=-1,d=l==null?0:l.length;for(this.clear();++c<d;){var h=l[c];this.set(h[0],h[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=r,o.prototype.set=s,Mm=o,Mm}var $m,tE;function SJ(){if(tE)return $m;tE=1;var e=wh(),t=M0(),n=$0(),r=200;function s(o,l){var c=this.__data__;if(c instanceof e){var d=c.__data__;if(!t||d.length<r-1)return d.push([o,l]),this.size=++c.size,this;c=this.__data__=new n(d)}return c.set(o,l),this.size=c.size,this}return $m=s,$m}var Im,nE;function bh(){if(nE)return Im;nE=1;var e=wh(),t=rJ(),n=sJ(),r=aJ(),s=oJ(),o=SJ();function l(c){var d=this.__data__=new e(c);this.size=d.size}return l.prototype.clear=t,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=s,l.prototype.set=o,Im=l,Im}var Om,rE;function I0(){if(rE)return Om;rE=1;function e(t,n){for(var r=-1,s=t==null?0:t.length;++r<s&&n(t[r],r,t)!==!1;);return t}return Om=e,Om}var Lm,sE;function NO(){if(sE)return Lm;sE=1;var e=no(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return Lm=t,Lm}var Pm,aE;function kh(){if(aE)return Pm;aE=1;var e=NO();function t(n,r,s){r=="__proto__"&&e?e(n,r,{configurable:!0,enumerable:!0,value:s,writable:!0}):n[r]=s}return Pm=t,Pm}var Dm,oE;function Nh(){if(oE)return Dm;oE=1;var e=kh(),t=Ei(),n=Object.prototype,r=n.hasOwnProperty;function s(o,l,c){var d=o[l];(!(r.call(o,l)&&t(d,c))||c===void 0&&!(l in o))&&e(o,l,c)}return Dm=s,Dm}var Fm,iE;function gc(){if(iE)return Fm;iE=1;var e=Nh(),t=kh();function n(r,s,o,l){var c=!o;o||(o={});for(var d=-1,h=s.length;++d<h;){var f=s[d],p=l?l(o[f],r[f],f,o,r):void 0;p===void 0&&(p=r[f]),c?t(o,f,p):e(o,f,p)}return o}return Fm=n,Fm}var Bm,lE;function _J(){if(lE)return Bm;lE=1;function e(t,n){for(var r=-1,s=Array(t);++r<t;)s[r]=n(r);return s}return Bm=e,Bm}var qm,cE;function Ur(){if(cE)return qm;cE=1;function e(t){return t!=null&&typeof t=="object"}return qm=e,qm}var Um,uE;function EJ(){if(uE)return Um;uE=1;var e=to(),t=Ur(),n="[object Arguments]";function r(s){return t(s)&&e(s)==n}return Um=r,Um}var zm,dE;function yc(){if(dE)return zm;dE=1;var e=EJ(),t=Ur(),n=Object.prototype,r=n.hasOwnProperty,s=n.propertyIsEnumerable,o=e((function(){return arguments})())?e:function(l){return t(l)&&r.call(l,"callee")&&!s.call(l,"callee")};return zm=o,zm}var Wm,hE;function jt(){if(hE)return Wm;hE=1;var e=Array.isArray;return Wm=e,Wm}var _l={exports:{}},Hm,fE;function TJ(){if(fE)return Hm;fE=1;function e(){return!1}return Hm=e,Hm}_l.exports;var pE;function Ci(){return pE||(pE=1,(function(e,t){var n=pr(),r=TJ(),s=t&&!t.nodeType&&t,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,c=l?n.Buffer:void 0,d=c?c.isBuffer:void 0,h=d||r;e.exports=h})(_l,_l.exports)),_l.exports}var Vm,mE;function jh(){if(mE)return Vm;mE=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(r,s){var o=typeof r;return s=s??e,!!s&&(o=="number"||o!="symbol"&&t.test(r))&&r>-1&&r%1==0&&r<s}return Vm=n,Vm}var Gm,gE;function O0(){if(gE)return Gm;gE=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return Gm=t,Gm}var Km,yE;function CJ(){if(yE)return Km;yE=1;var e=to(),t=O0(),n=Ur(),r="[object Arguments]",s="[object Array]",o="[object Boolean]",l="[object Date]",c="[object Error]",d="[object Function]",h="[object Map]",f="[object Number]",p="[object Object]",g="[object RegExp]",v="[object Set]",N="[object String]",k="[object WeakMap]",x="[object ArrayBuffer]",j="[object DataView]",b="[object Float32Array]",_="[object Float64Array]",E="[object Int8Array]",R="[object Int16Array]",C="[object Int32Array]",A="[object Uint8Array]",U="[object Uint8ClampedArray]",L="[object Uint16Array]",F="[object Uint32Array]",O={};O[b]=O[_]=O[E]=O[R]=O[C]=O[A]=O[U]=O[L]=O[F]=!0,O[r]=O[s]=O[x]=O[o]=O[j]=O[l]=O[c]=O[d]=O[h]=O[f]=O[p]=O[g]=O[v]=O[N]=O[k]=!1;function I(B){return n(B)&&t(B.length)&&!!O[e(B)]}return Km=I,Km}var Ym,wE;function Sh(){if(wE)return Ym;wE=1;function e(t){return function(n){return t(n)}}return Ym=e,Ym}var El={exports:{}};El.exports;var vE;function L0(){return vE||(vE=1,(function(e,t){var n=bO(),r=t&&!t.nodeType&&t,s=r&&!0&&e&&!e.nodeType&&e,o=s&&s.exports===r,l=o&&n.process,c=(function(){try{var d=s&&s.require&&s.require("util").types;return d||l&&l.binding&&l.binding("util")}catch{}})();e.exports=c})(El,El.exports)),El.exports}var Xm,xE;function wc(){if(xE)return Xm;xE=1;var e=CJ(),t=Sh(),n=L0(),r=n&&n.isTypedArray,s=r?t(r):e;return Xm=s,Xm}var Zm,bE;function jO(){if(bE)return Zm;bE=1;var e=_J(),t=yc(),n=jt(),r=Ci(),s=jh(),o=wc(),l=Object.prototype,c=l.hasOwnProperty;function d(h,f){var p=n(h),g=!p&&t(h),v=!p&&!g&&r(h),N=!p&&!g&&!v&&o(h),k=p||g||v||N,x=k?e(h.length,String):[],j=x.length;for(var b in h)(f||c.call(h,b))&&!(k&&(b=="length"||v&&(b=="offset"||b=="parent")||N&&(b=="buffer"||b=="byteLength"||b=="byteOffset")||s(b,j)))&&x.push(b);return x}return Zm=d,Zm}var Jm,kE;function _h(){if(kE)return Jm;kE=1;var e=Object.prototype;function t(n){var r=n&&n.constructor,s=typeof r=="function"&&r.prototype||e;return n===s}return Jm=t,Jm}var Qm,NE;function SO(){if(NE)return Qm;NE=1;function e(t,n){return function(r){return t(n(r))}}return Qm=e,Qm}var eg,jE;function AJ(){if(jE)return eg;jE=1;var e=SO(),t=e(Object.keys,Object);return eg=t,eg}var tg,SE;function P0(){if(SE)return tg;SE=1;var e=_h(),t=AJ(),n=Object.prototype,r=n.hasOwnProperty;function s(o){if(!e(o))return t(o);var l=[];for(var c in Object(o))r.call(o,c)&&c!="constructor"&&l.push(c);return l}return tg=s,tg}var ng,_E;function ys(){if(_E)return ng;_E=1;var e=mc(),t=O0();function n(r){return r!=null&&t(r.length)&&!e(r)}return ng=n,ng}var rg,EE;function ua(){if(EE)return rg;EE=1;var e=jO(),t=P0(),n=ys();function r(s){return n(s)?e(s):t(s)}return rg=r,rg}var sg,TE;function RJ(){if(TE)return sg;TE=1;var e=gc(),t=ua();function n(r,s){return r&&e(s,t(s),r)}return sg=n,sg}var ag,CE;function MJ(){if(CE)return ag;CE=1;function e(t){var n=[];if(t!=null)for(var r in Object(t))n.push(r);return n}return ag=e,ag}var og,AE;function $J(){if(AE)return og;AE=1;var e=Vn(),t=_h(),n=MJ(),r=Object.prototype,s=r.hasOwnProperty;function o(l){if(!e(l))return n(l);var c=t(l),d=[];for(var h in l)h=="constructor"&&(c||!s.call(l,h))||d.push(h);return d}return og=o,og}var ig,RE;function ro(){if(RE)return ig;RE=1;var e=jO(),t=$J(),n=ys();function r(s){return n(s)?e(s,!0):t(s)}return ig=r,ig}var lg,ME;function IJ(){if(ME)return lg;ME=1;var e=gc(),t=ro();function n(r,s){return r&&e(s,t(s),r)}return lg=n,lg}var Tl={exports:{}};Tl.exports;var $E;function _O(){return $E||($E=1,(function(e,t){var n=pr(),r=t&&!t.nodeType&&t,s=r&&!0&&e&&!e.nodeType&&e,o=s&&s.exports===r,l=o?n.Buffer:void 0,c=l?l.allocUnsafe:void 0;function d(h,f){if(f)return h.slice();var p=h.length,g=c?c(p):new h.constructor(p);return h.copy(g),g}e.exports=d})(Tl,Tl.exports)),Tl.exports}var cg,IE;function EO(){if(IE)return cg;IE=1;function e(t,n){var r=-1,s=t.length;for(n||(n=Array(s));++r<s;)n[r]=t[r];return n}return cg=e,cg}var ug,OE;function TO(){if(OE)return ug;OE=1;function e(t,n){for(var r=-1,s=t==null?0:t.length,o=0,l=[];++r<s;){var c=t[r];n(c,r,t)&&(l[o++]=c)}return l}return ug=e,ug}var dg,LE;function CO(){if(LE)return dg;LE=1;function e(){return[]}return dg=e,dg}var hg,PE;function D0(){if(PE)return hg;PE=1;var e=TO(),t=CO(),n=Object.prototype,r=n.propertyIsEnumerable,s=Object.getOwnPropertySymbols,o=s?function(l){return l==null?[]:(l=Object(l),e(s(l),function(c){return r.call(l,c)}))}:t;return hg=o,hg}var fg,DE;function OJ(){if(DE)return fg;DE=1;var e=gc(),t=D0();function n(r,s){return e(r,t(r),s)}return fg=n,fg}var pg,FE;function F0(){if(FE)return pg;FE=1;function e(t,n){for(var r=-1,s=n.length,o=t.length;++r<s;)t[o+r]=n[r];return t}return pg=e,pg}var mg,BE;function Eh(){if(BE)return mg;BE=1;var e=SO(),t=e(Object.getPrototypeOf,Object);return mg=t,mg}var gg,qE;function AO(){if(qE)return gg;qE=1;var e=F0(),t=Eh(),n=D0(),r=CO(),s=Object.getOwnPropertySymbols,o=s?function(l){for(var c=[];l;)e(c,n(l)),l=t(l);return c}:r;return gg=o,gg}var yg,UE;function LJ(){if(UE)return yg;UE=1;var e=gc(),t=AO();function n(r,s){return e(r,t(r),s)}return yg=n,yg}var wg,zE;function RO(){if(zE)return wg;zE=1;var e=F0(),t=jt();function n(r,s,o){var l=s(r);return t(r)?l:e(l,o(r))}return wg=n,wg}var vg,WE;function MO(){if(WE)return vg;WE=1;var e=RO(),t=D0(),n=ua();function r(s){return e(s,n,t)}return vg=r,vg}var xg,HE;function PJ(){if(HE)return xg;HE=1;var e=RO(),t=AO(),n=ro();function r(s){return e(s,n,t)}return xg=r,xg}var bg,VE;function DJ(){if(VE)return bg;VE=1;var e=no(),t=pr(),n=e(t,"DataView");return bg=n,bg}var kg,GE;function FJ(){if(GE)return kg;GE=1;var e=no(),t=pr(),n=e(t,"Promise");return kg=n,kg}var Ng,KE;function $O(){if(KE)return Ng;KE=1;var e=no(),t=pr(),n=e(t,"Set");return Ng=n,Ng}var jg,YE;function BJ(){if(YE)return jg;YE=1;var e=no(),t=pr(),n=e(t,"WeakMap");return jg=n,jg}var Sg,XE;function Ai(){if(XE)return Sg;XE=1;var e=DJ(),t=M0(),n=FJ(),r=$O(),s=BJ(),o=to(),l=kO(),c="[object Map]",d="[object Object]",h="[object Promise]",f="[object Set]",p="[object WeakMap]",g="[object DataView]",v=l(e),N=l(t),k=l(n),x=l(r),j=l(s),b=o;return(e&&b(new e(new ArrayBuffer(1)))!=g||t&&b(new t)!=c||n&&b(n.resolve())!=h||r&&b(new r)!=f||s&&b(new s)!=p)&&(b=function(_){var E=o(_),R=E==d?_.constructor:void 0,C=R?l(R):"";if(C)switch(C){case v:return g;case N:return c;case k:return h;case x:return f;case j:return p}return E}),Sg=b,Sg}var _g,ZE;function qJ(){if(ZE)return _g;ZE=1;var e=Object.prototype,t=e.hasOwnProperty;function n(r){var s=r.length,o=new r.constructor(s);return s&&typeof r[0]=="string"&&t.call(r,"index")&&(o.index=r.index,o.input=r.input),o}return _g=n,_g}var Eg,JE;function IO(){if(JE)return Eg;JE=1;var e=pr(),t=e.Uint8Array;return Eg=t,Eg}var Tg,QE;function B0(){if(QE)return Tg;QE=1;var e=IO();function t(n){var r=new n.constructor(n.byteLength);return new e(r).set(new e(n)),r}return Tg=t,Tg}var Cg,eT;function UJ(){if(eT)return Cg;eT=1;var e=B0();function t(n,r){var s=r?e(n.buffer):n.buffer;return new n.constructor(s,n.byteOffset,n.byteLength)}return Cg=t,Cg}var Ag,tT;function zJ(){if(tT)return Ag;tT=1;var e=/\w*$/;function t(n){var r=new n.constructor(n.source,e.exec(n));return r.lastIndex=n.lastIndex,r}return Ag=t,Ag}var Rg,nT;function WJ(){if(nT)return Rg;nT=1;var e=Ti(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function r(s){return n?Object(n.call(s)):{}}return Rg=r,Rg}var Mg,rT;function OO(){if(rT)return Mg;rT=1;var e=B0();function t(n,r){var s=r?e(n.buffer):n.buffer;return new n.constructor(s,n.byteOffset,n.length)}return Mg=t,Mg}var $g,sT;function HJ(){if(sT)return $g;sT=1;var e=B0(),t=UJ(),n=zJ(),r=WJ(),s=OO(),o="[object Boolean]",l="[object Date]",c="[object Map]",d="[object Number]",h="[object RegExp]",f="[object Set]",p="[object String]",g="[object Symbol]",v="[object ArrayBuffer]",N="[object DataView]",k="[object Float32Array]",x="[object Float64Array]",j="[object Int8Array]",b="[object Int16Array]",_="[object Int32Array]",E="[object Uint8Array]",R="[object Uint8ClampedArray]",C="[object Uint16Array]",A="[object Uint32Array]";function U(L,F,O){var I=L.constructor;switch(F){case v:return e(L);case o:case l:return new I(+L);case N:return t(L,O);case k:case x:case j:case b:case _:case E:case R:case C:case A:return s(L,O);case c:return new I;case d:case p:return new I(L);case h:return n(L);case f:return new I;case g:return r(L)}}return $g=U,$g}var Ig,aT;function LO(){if(aT)return Ig;aT=1;var e=Vn(),t=Object.create,n=(function(){function r(){}return function(s){if(!e(s))return{};if(t)return t(s);r.prototype=s;var o=new r;return r.prototype=void 0,o}})();return Ig=n,Ig}var Og,oT;function PO(){if(oT)return Og;oT=1;var e=LO(),t=Eh(),n=_h();function r(s){return typeof s.constructor=="function"&&!n(s)?e(t(s)):{}}return Og=r,Og}var Lg,iT;function VJ(){if(iT)return Lg;iT=1;var e=Ai(),t=Ur(),n="[object Map]";function r(s){return t(s)&&e(s)==n}return Lg=r,Lg}var Pg,lT;function GJ(){if(lT)return Pg;lT=1;var e=VJ(),t=Sh(),n=L0(),r=n&&n.isMap,s=r?t(r):e;return Pg=s,Pg}var Dg,cT;function KJ(){if(cT)return Dg;cT=1;var e=Ai(),t=Ur(),n="[object Set]";function r(s){return t(s)&&e(s)==n}return Dg=r,Dg}var Fg,uT;function YJ(){if(uT)return Fg;uT=1;var e=KJ(),t=Sh(),n=L0(),r=n&&n.isSet,s=r?t(r):e;return Fg=s,Fg}var Bg,dT;function DO(){if(dT)return Bg;dT=1;var e=bh(),t=I0(),n=Nh(),r=RJ(),s=IJ(),o=_O(),l=EO(),c=OJ(),d=LJ(),h=MO(),f=PJ(),p=Ai(),g=qJ(),v=HJ(),N=PO(),k=jt(),x=Ci(),j=GJ(),b=Vn(),_=YJ(),E=ua(),R=ro(),C=1,A=2,U=4,L="[object Arguments]",F="[object Array]",O="[object Boolean]",I="[object Date]",B="[object Error]",M="[object Function]",$="[object GeneratorFunction]",P="[object Map]",G="[object Number]",K="[object Object]",q="[object RegExp]",H="[object Set]",D="[object String]",W="[object Symbol]",J="[object WeakMap]",V="[object ArrayBuffer]",X="[object DataView]",Y="[object Float32Array]",Z="[object Float64Array]",ee="[object Int8Array]",ne="[object Int16Array]",se="[object Int32Array]",pe="[object Uint8Array]",ke="[object Uint8ClampedArray]",ae="[object Uint16Array]",fe="[object Uint32Array]",me={};me[L]=me[F]=me[V]=me[X]=me[O]=me[I]=me[Y]=me[Z]=me[ee]=me[ne]=me[se]=me[P]=me[G]=me[K]=me[q]=me[H]=me[D]=me[W]=me[pe]=me[ke]=me[ae]=me[fe]=!0,me[B]=me[M]=me[J]=!1;function he(ge,ue,be,oe,je,$e){var Oe,Ue=ue&C,Be=ue&A,We=ue&U;if(be&&(Oe=je?be(ge,oe,je,$e):be(ge)),Oe!==void 0)return Oe;if(!b(ge))return ge;var He=k(ge);if(He){if(Oe=g(ge),!Ue)return l(ge,Oe)}else{var rt=p(ge),lt=rt==M||rt==$;if(x(ge))return o(ge,Ue);if(rt==K||rt==L||lt&&!je){if(Oe=Be||lt?{}:N(ge),!Ue)return Be?d(ge,s(Oe,ge)):c(ge,r(Oe,ge))}else{if(!me[rt])return je?ge:{};Oe=v(ge,rt,Ue)}}$e||($e=new e);var Rt=$e.get(ge);if(Rt)return Rt;$e.set(ge,Oe),_(ge)?ge.forEach(function(Je){Oe.add(he(Je,ue,be,Je,ge,$e))}):j(ge)&&ge.forEach(function(Je,tt){Oe.set(tt,he(Je,ue,be,tt,ge,$e))});var De=We?Be?f:h:Be?R:E,et=He?void 0:De(ge);return t(et||ge,function(Je,tt){et&&(tt=Je,Je=ge[tt]),n(Oe,tt,he(Je,ue,be,tt,ge,$e))}),Oe}return Bg=he,Bg}var qg,hT;function XJ(){if(hT)return qg;hT=1;var e=DO(),t=4;function n(r){return e(r,t)}return qg=n,qg}var Ug,fT;function q0(){if(fT)return Ug;fT=1;function e(t){return function(){return t}}return Ug=e,Ug}var zg,pT;function ZJ(){if(pT)return zg;pT=1;function e(t){return function(n,r,s){for(var o=-1,l=Object(n),c=s(n),d=c.length;d--;){var h=c[t?d:++o];if(r(l[h],h,l)===!1)break}return n}}return zg=e,zg}var Wg,mT;function U0(){if(mT)return Wg;mT=1;var e=ZJ(),t=e();return Wg=t,Wg}var Hg,gT;function z0(){if(gT)return Hg;gT=1;var e=U0(),t=ua();function n(r,s){return r&&e(r,s,t)}return Hg=n,Hg}var Vg,yT;function JJ(){if(yT)return Vg;yT=1;var e=ys();function t(n,r){return function(s,o){if(s==null)return s;if(!e(s))return n(s,o);for(var l=s.length,c=r?l:-1,d=Object(s);(r?c--:++c<l)&&o(d[c],c,d)!==!1;);return s}}return Vg=t,Vg}var Gg,wT;function Th(){if(wT)return Gg;wT=1;var e=z0(),t=JJ(),n=t(e);return Gg=n,Gg}var Kg,vT;function so(){if(vT)return Kg;vT=1;function e(t){return t}return Kg=e,Kg}var Yg,xT;function FO(){if(xT)return Yg;xT=1;var e=so();function t(n){return typeof n=="function"?n:e}return Yg=t,Yg}var Xg,bT;function BO(){if(bT)return Xg;bT=1;var e=I0(),t=Th(),n=FO(),r=jt();function s(o,l){var c=r(o)?e:t;return c(o,n(l))}return Xg=s,Xg}var Zg,kT;function qO(){return kT||(kT=1,Zg=BO()),Zg}var Jg,NT;function QJ(){if(NT)return Jg;NT=1;var e=Th();function t(n,r){var s=[];return e(n,function(o,l,c){r(o,l,c)&&s.push(o)}),s}return Jg=t,Jg}var Qg,jT;function eQ(){if(jT)return Qg;jT=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return Qg=t,Qg}var ey,ST;function tQ(){if(ST)return ey;ST=1;function e(t){return this.__data__.has(t)}return ey=e,ey}var ty,_T;function UO(){if(_T)return ty;_T=1;var e=$0(),t=eQ(),n=tQ();function r(s){var o=-1,l=s==null?0:s.length;for(this.__data__=new e;++o<l;)this.add(s[o])}return r.prototype.add=r.prototype.push=t,r.prototype.has=n,ty=r,ty}var ny,ET;function nQ(){if(ET)return ny;ET=1;function e(t,n){for(var r=-1,s=t==null?0:t.length;++r<s;)if(n(t[r],r,t))return!0;return!1}return ny=e,ny}var ry,TT;function zO(){if(TT)return ry;TT=1;function e(t,n){return t.has(n)}return ry=e,ry}var sy,CT;function WO(){if(CT)return sy;CT=1;var e=UO(),t=nQ(),n=zO(),r=1,s=2;function o(l,c,d,h,f,p){var g=d&r,v=l.length,N=c.length;if(v!=N&&!(g&&N>v))return!1;var k=p.get(l),x=p.get(c);if(k&&x)return k==c&&x==l;var j=-1,b=!0,_=d&s?new e:void 0;for(p.set(l,c),p.set(c,l);++j<v;){var E=l[j],R=c[j];if(h)var C=g?h(R,E,j,c,l,p):h(E,R,j,l,c,p);if(C!==void 0){if(C)continue;b=!1;break}if(_){if(!t(c,function(A,U){if(!n(_,U)&&(E===A||f(E,A,d,h,p)))return _.push(U)})){b=!1;break}}else if(!(E===R||f(E,R,d,h,p))){b=!1;break}}return p.delete(l),p.delete(c),b}return sy=o,sy}var ay,AT;function rQ(){if(AT)return ay;AT=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(s,o){r[++n]=[o,s]}),r}return ay=e,ay}var oy,RT;function W0(){if(RT)return oy;RT=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(s){r[++n]=s}),r}return oy=e,oy}var iy,MT;function sQ(){if(MT)return iy;MT=1;var e=Ti(),t=IO(),n=Ei(),r=WO(),s=rQ(),o=W0(),l=1,c=2,d="[object Boolean]",h="[object Date]",f="[object Error]",p="[object Map]",g="[object Number]",v="[object RegExp]",N="[object Set]",k="[object String]",x="[object Symbol]",j="[object ArrayBuffer]",b="[object DataView]",_=e?e.prototype:void 0,E=_?_.valueOf:void 0;function R(C,A,U,L,F,O,I){switch(U){case b:if(C.byteLength!=A.byteLength||C.byteOffset!=A.byteOffset)return!1;C=C.buffer,A=A.buffer;case j:return!(C.byteLength!=A.byteLength||!O(new t(C),new t(A)));case d:case h:case g:return n(+C,+A);case f:return C.name==A.name&&C.message==A.message;case v:case k:return C==A+"";case p:var B=s;case N:var M=L&l;if(B||(B=o),C.size!=A.size&&!M)return!1;var $=I.get(C);if($)return $==A;L|=c,I.set(C,A);var P=r(B(C),B(A),L,F,O,I);return I.delete(C),P;case x:if(E)return E.call(C)==E.call(A)}return!1}return iy=R,iy}var ly,$T;function aQ(){if($T)return ly;$T=1;var e=MO(),t=1,n=Object.prototype,r=n.hasOwnProperty;function s(o,l,c,d,h,f){var p=c&t,g=e(o),v=g.length,N=e(l),k=N.length;if(v!=k&&!p)return!1;for(var x=v;x--;){var j=g[x];if(!(p?j in l:r.call(l,j)))return!1}var b=f.get(o),_=f.get(l);if(b&&_)return b==l&&_==o;var E=!0;f.set(o,l),f.set(l,o);for(var R=p;++x<v;){j=g[x];var C=o[j],A=l[j];if(d)var U=p?d(A,C,j,l,o,f):d(C,A,j,o,l,f);if(!(U===void 0?C===A||h(C,A,c,d,f):U)){E=!1;break}R||(R=j=="constructor")}if(E&&!R){var L=o.constructor,F=l.constructor;L!=F&&"constructor"in o&&"constructor"in l&&!(typeof L=="function"&&L instanceof L&&typeof F=="function"&&F instanceof F)&&(E=!1)}return f.delete(o),f.delete(l),E}return ly=s,ly}var cy,IT;function oQ(){if(IT)return cy;IT=1;var e=bh(),t=WO(),n=sQ(),r=aQ(),s=Ai(),o=jt(),l=Ci(),c=wc(),d=1,h="[object Arguments]",f="[object Array]",p="[object Object]",g=Object.prototype,v=g.hasOwnProperty;function N(k,x,j,b,_,E){var R=o(k),C=o(x),A=R?f:s(k),U=C?f:s(x);A=A==h?p:A,U=U==h?p:U;var L=A==p,F=U==p,O=A==U;if(O&&l(k)){if(!l(x))return!1;R=!0,L=!1}if(O&&!L)return E||(E=new e),R||c(k)?t(k,x,j,b,_,E):n(k,x,A,j,b,_,E);if(!(j&d)){var I=L&&v.call(k,"__wrapped__"),B=F&&v.call(x,"__wrapped__");if(I||B){var M=I?k.value():k,$=B?x.value():x;return E||(E=new e),_(M,$,j,b,E)}}return O?(E||(E=new e),r(k,x,j,b,_,E)):!1}return cy=N,cy}var uy,OT;function HO(){if(OT)return uy;OT=1;var e=oQ(),t=Ur();function n(r,s,o,l,c){return r===s?!0:r==null||s==null||!t(r)&&!t(s)?r!==r&&s!==s:e(r,s,o,l,n,c)}return uy=n,uy}var dy,LT;function iQ(){if(LT)return dy;LT=1;var e=bh(),t=HO(),n=1,r=2;function s(o,l,c,d){var h=c.length,f=h,p=!d;if(o==null)return!f;for(o=Object(o);h--;){var g=c[h];if(p&&g[2]?g[1]!==o[g[0]]:!(g[0]in o))return!1}for(;++h<f;){g=c[h];var v=g[0],N=o[v],k=g[1];if(p&&g[2]){if(N===void 0&&!(v in o))return!1}else{var x=new e;if(d)var j=d(N,k,v,o,l,x);if(!(j===void 0?t(k,N,n|r,d,x):j))return!1}}return!0}return dy=s,dy}var hy,PT;function VO(){if(PT)return hy;PT=1;var e=Vn();function t(n){return n===n&&!e(n)}return hy=t,hy}var fy,DT;function lQ(){if(DT)return fy;DT=1;var e=VO(),t=ua();function n(r){for(var s=t(r),o=s.length;o--;){var l=s[o],c=r[l];s[o]=[l,c,e(c)]}return s}return fy=n,fy}var py,FT;function GO(){if(FT)return py;FT=1;function e(t,n){return function(r){return r==null?!1:r[t]===n&&(n!==void 0||t in Object(r))}}return py=e,py}var my,BT;function cQ(){if(BT)return my;BT=1;var e=iQ(),t=lQ(),n=GO();function r(s){var o=t(s);return o.length==1&&o[0][2]?n(o[0][0],o[0][1]):function(l){return l===s||e(l,s,o)}}return my=r,my}var gy,qT;function Ri(){if(qT)return gy;qT=1;var e=to(),t=Ur(),n="[object Symbol]";function r(s){return typeof s=="symbol"||t(s)&&e(s)==n}return gy=r,gy}var yy,UT;function H0(){if(UT)return yy;UT=1;var e=jt(),t=Ri(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function s(o,l){if(e(o))return!1;var c=typeof o;return c=="number"||c=="symbol"||c=="boolean"||o==null||t(o)?!0:r.test(o)||!n.test(o)||l!=null&&o in Object(l)}return yy=s,yy}var wy,zT;function uQ(){if(zT)return wy;zT=1;var e=$0(),t="Expected a function";function n(r,s){if(typeof r!="function"||s!=null&&typeof s!="function")throw new TypeError(t);var o=function(){var l=arguments,c=s?s.apply(this,l):l[0],d=o.cache;if(d.has(c))return d.get(c);var h=r.apply(this,l);return o.cache=d.set(c,h)||d,h};return o.cache=new(n.Cache||e),o}return n.Cache=e,wy=n,wy}var vy,WT;function dQ(){if(WT)return vy;WT=1;var e=uQ(),t=500;function n(r){var s=e(r,function(l){return o.size===t&&o.clear(),l}),o=s.cache;return s}return vy=n,vy}var xy,HT;function hQ(){if(HT)return xy;HT=1;var e=dQ(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=e(function(s){var o=[];return s.charCodeAt(0)===46&&o.push(""),s.replace(t,function(l,c,d,h){o.push(d?h.replace(n,"$1"):c||l)}),o});return xy=r,xy}var by,VT;function Ch(){if(VT)return by;VT=1;function e(t,n){for(var r=-1,s=t==null?0:t.length,o=Array(s);++r<s;)o[r]=n(t[r],r,t);return o}return by=e,by}var ky,GT;function fQ(){if(GT)return ky;GT=1;var e=Ti(),t=Ch(),n=jt(),r=Ri(),s=e?e.prototype:void 0,o=s?s.toString:void 0;function l(c){if(typeof c=="string")return c;if(n(c))return t(c,l)+"";if(r(c))return o?o.call(c):"";var d=c+"";return d=="0"&&1/c==-1/0?"-0":d}return ky=l,ky}var Ny,KT;function KO(){if(KT)return Ny;KT=1;var e=fQ();function t(n){return n==null?"":e(n)}return Ny=t,Ny}var jy,YT;function Ah(){if(YT)return jy;YT=1;var e=jt(),t=H0(),n=hQ(),r=KO();function s(o,l){return e(o)?o:t(o,l)?[o]:n(r(o))}return jy=s,jy}var Sy,XT;function vc(){if(XT)return Sy;XT=1;var e=Ri();function t(n){if(typeof n=="string"||e(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}return Sy=t,Sy}var _y,ZT;function Rh(){if(ZT)return _y;ZT=1;var e=Ah(),t=vc();function n(r,s){s=e(s,r);for(var o=0,l=s.length;r!=null&&o<l;)r=r[t(s[o++])];return o&&o==l?r:void 0}return _y=n,_y}var Ey,JT;function pQ(){if(JT)return Ey;JT=1;var e=Rh();function t(n,r,s){var o=n==null?void 0:e(n,r);return o===void 0?s:o}return Ey=t,Ey}var Ty,QT;function mQ(){if(QT)return Ty;QT=1;function e(t,n){return t!=null&&n in Object(t)}return Ty=e,Ty}var Cy,eC;function YO(){if(eC)return Cy;eC=1;var e=Ah(),t=yc(),n=jt(),r=jh(),s=O0(),o=vc();function l(c,d,h){d=e(d,c);for(var f=-1,p=d.length,g=!1;++f<p;){var v=o(d[f]);if(!(g=c!=null&&h(c,v)))break;c=c[v]}return g||++f!=p?g:(p=c==null?0:c.length,!!p&&s(p)&&r(v,p)&&(n(c)||t(c)))}return Cy=l,Cy}var Ay,tC;function XO(){if(tC)return Ay;tC=1;var e=mQ(),t=YO();function n(r,s){return r!=null&&t(r,s,e)}return Ay=n,Ay}var Ry,nC;function gQ(){if(nC)return Ry;nC=1;var e=HO(),t=pQ(),n=XO(),r=H0(),s=VO(),o=GO(),l=vc(),c=1,d=2;function h(f,p){return r(f)&&s(p)?o(l(f),p):function(g){var v=t(g,f);return v===void 0&&v===p?n(g,f):e(p,v,c|d)}}return Ry=h,Ry}var My,rC;function ZO(){if(rC)return My;rC=1;function e(t){return function(n){return n==null?void 0:n[t]}}return My=e,My}var $y,sC;function yQ(){if(sC)return $y;sC=1;var e=Rh();function t(n){return function(r){return e(r,n)}}return $y=t,$y}var Iy,aC;function wQ(){if(aC)return Iy;aC=1;var e=ZO(),t=yQ(),n=H0(),r=vc();function s(o){return n(o)?e(r(o)):t(o)}return Iy=s,Iy}var Oy,oC;function ws(){if(oC)return Oy;oC=1;var e=cQ(),t=gQ(),n=so(),r=jt(),s=wQ();function o(l){return typeof l=="function"?l:l==null?n:typeof l=="object"?r(l)?t(l[0],l[1]):e(l):s(l)}return Oy=o,Oy}var Ly,iC;function JO(){if(iC)return Ly;iC=1;var e=TO(),t=QJ(),n=ws(),r=jt();function s(o,l){var c=r(o)?e:t;return c(o,n(l,3))}return Ly=s,Ly}var Py,lC;function vQ(){if(lC)return Py;lC=1;var e=Object.prototype,t=e.hasOwnProperty;function n(r,s){return r!=null&&t.call(r,s)}return Py=n,Py}var Dy,cC;function QO(){if(cC)return Dy;cC=1;var e=vQ(),t=YO();function n(r,s){return r!=null&&t(r,s,e)}return Dy=n,Dy}var Fy,uC;function xQ(){if(uC)return Fy;uC=1;var e=P0(),t=Ai(),n=yc(),r=jt(),s=ys(),o=Ci(),l=_h(),c=wc(),d="[object Map]",h="[object Set]",f=Object.prototype,p=f.hasOwnProperty;function g(v){if(v==null)return!0;if(s(v)&&(r(v)||typeof v=="string"||typeof v.splice=="function"||o(v)||c(v)||n(v)))return!v.length;var N=t(v);if(N==d||N==h)return!v.size;if(l(v))return!e(v).length;for(var k in v)if(p.call(v,k))return!1;return!0}return Fy=g,Fy}var By,dC;function eL(){if(dC)return By;dC=1;function e(t){return t===void 0}return By=e,By}var qy,hC;function tL(){if(hC)return qy;hC=1;var e=Th(),t=ys();function n(r,s){var o=-1,l=t(r)?Array(r.length):[];return e(r,function(c,d,h){l[++o]=s(c,d,h)}),l}return qy=n,qy}var Uy,fC;function nL(){if(fC)return Uy;fC=1;var e=Ch(),t=ws(),n=tL(),r=jt();function s(o,l){var c=r(o)?e:n;return c(o,t(l,3))}return Uy=s,Uy}var zy,pC;function bQ(){if(pC)return zy;pC=1;function e(t,n,r,s){var o=-1,l=t==null?0:t.length;for(s&&l&&(r=t[++o]);++o<l;)r=n(r,t[o],o,t);return r}return zy=e,zy}var Wy,mC;function kQ(){if(mC)return Wy;mC=1;function e(t,n,r,s,o){return o(t,function(l,c,d){r=s?(s=!1,l):n(r,l,c,d)}),r}return Wy=e,Wy}var Hy,gC;function rL(){if(gC)return Hy;gC=1;var e=bQ(),t=Th(),n=ws(),r=kQ(),s=jt();function o(l,c,d){var h=s(l)?e:r,f=arguments.length<3;return h(l,n(c,4),d,f,t)}return Hy=o,Hy}var Vy,yC;function NQ(){if(yC)return Vy;yC=1;var e=to(),t=jt(),n=Ur(),r="[object String]";function s(o){return typeof o=="string"||!t(o)&&n(o)&&e(o)==r}return Vy=s,Vy}var Gy,wC;function jQ(){if(wC)return Gy;wC=1;var e=ZO(),t=e("length");return Gy=t,Gy}var Ky,vC;function SQ(){if(vC)return Ky;vC=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",s=t+n+r,o="\\ufe0e\\ufe0f",l="\\u200d",c=RegExp("["+l+e+s+o+"]");function d(h){return c.test(h)}return Ky=d,Ky}var Yy,xC;function _Q(){if(xC)return Yy;xC=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",s=t+n+r,o="\\ufe0e\\ufe0f",l="["+e+"]",c="["+s+"]",d="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+d+")",f="[^"+e+"]",p="(?:\\ud83c[\\udde6-\\uddff]){2}",g="[\\ud800-\\udbff][\\udc00-\\udfff]",v="\\u200d",N=h+"?",k="["+o+"]?",x="(?:"+v+"(?:"+[f,p,g].join("|")+")"+k+N+")*",j=k+N+x,b="(?:"+[f+c+"?",c,p,g,l].join("|")+")",_=RegExp(d+"(?="+d+")|"+b+j,"g");function E(R){for(var C=_.lastIndex=0;_.test(R);)++C;return C}return Yy=E,Yy}var Xy,bC;function EQ(){if(bC)return Xy;bC=1;var e=jQ(),t=SQ(),n=_Q();function r(s){return t(s)?n(s):e(s)}return Xy=r,Xy}var Zy,kC;function TQ(){if(kC)return Zy;kC=1;var e=P0(),t=Ai(),n=ys(),r=NQ(),s=EQ(),o="[object Map]",l="[object Set]";function c(d){if(d==null)return 0;if(n(d))return r(d)?s(d):d.length;var h=t(d);return h==o||h==l?d.size:e(d).length}return Zy=c,Zy}var Jy,NC;function CQ(){if(NC)return Jy;NC=1;var e=I0(),t=LO(),n=z0(),r=ws(),s=Eh(),o=jt(),l=Ci(),c=mc(),d=Vn(),h=wc();function f(p,g,v){var N=o(p),k=N||l(p)||h(p);if(g=r(g,4),v==null){var x=p&&p.constructor;k?v=N?new x:[]:d(p)?v=c(x)?t(s(p)):{}:v={}}return(k?e:n)(p,function(j,b,_){return g(v,j,b,_)}),v}return Jy=f,Jy}var Qy,jC;function AQ(){if(jC)return Qy;jC=1;var e=Ti(),t=yc(),n=jt(),r=e?e.isConcatSpreadable:void 0;function s(o){return n(o)||t(o)||!!(r&&o&&o[r])}return Qy=s,Qy}var ew,SC;function V0(){if(SC)return ew;SC=1;var e=F0(),t=AQ();function n(r,s,o,l,c){var d=-1,h=r.length;for(o||(o=t),c||(c=[]);++d<h;){var f=r[d];s>0&&o(f)?s>1?n(f,s-1,o,l,c):e(c,f):l||(c[c.length]=f)}return c}return ew=n,ew}var tw,_C;function RQ(){if(_C)return tw;_C=1;function e(t,n,r){switch(r.length){case 0:return t.call(n);case 1:return t.call(n,r[0]);case 2:return t.call(n,r[0],r[1]);case 3:return t.call(n,r[0],r[1],r[2])}return t.apply(n,r)}return tw=e,tw}var nw,EC;function sL(){if(EC)return nw;EC=1;var e=RQ(),t=Math.max;function n(r,s,o){return s=t(s===void 0?r.length-1:s,0),function(){for(var l=arguments,c=-1,d=t(l.length-s,0),h=Array(d);++c<d;)h[c]=l[s+c];c=-1;for(var f=Array(s+1);++c<s;)f[c]=l[c];return f[s]=o(h),e(r,this,f)}}return nw=n,nw}var rw,TC;function MQ(){if(TC)return rw;TC=1;var e=q0(),t=NO(),n=so(),r=t?function(s,o){return t(s,"toString",{configurable:!0,enumerable:!1,value:e(o),writable:!0})}:n;return rw=r,rw}var sw,CC;function $Q(){if(CC)return sw;CC=1;var e=800,t=16,n=Date.now;function r(s){var o=0,l=0;return function(){var c=n(),d=t-(c-l);if(l=c,d>0){if(++o>=e)return arguments[0]}else o=0;return s.apply(void 0,arguments)}}return sw=r,sw}var aw,AC;function aL(){if(AC)return aw;AC=1;var e=MQ(),t=$Q(),n=t(e);return aw=n,aw}var ow,RC;function Mh(){if(RC)return ow;RC=1;var e=so(),t=sL(),n=aL();function r(s,o){return n(t(s,o,e),s+"")}return ow=r,ow}var iw,MC;function oL(){if(MC)return iw;MC=1;function e(t,n,r,s){for(var o=t.length,l=r+(s?1:-1);s?l--:++l<o;)if(n(t[l],l,t))return l;return-1}return iw=e,iw}var lw,$C;function IQ(){if($C)return lw;$C=1;function e(t){return t!==t}return lw=e,lw}var cw,IC;function OQ(){if(IC)return cw;IC=1;function e(t,n,r){for(var s=r-1,o=t.length;++s<o;)if(t[s]===n)return s;return-1}return cw=e,cw}var uw,OC;function LQ(){if(OC)return uw;OC=1;var e=oL(),t=IQ(),n=OQ();function r(s,o,l){return o===o?n(s,o,l):e(s,t,l)}return uw=r,uw}var dw,LC;function PQ(){if(LC)return dw;LC=1;var e=LQ();function t(n,r){var s=n==null?0:n.length;return!!s&&e(n,r,0)>-1}return dw=t,dw}var hw,PC;function DQ(){if(PC)return hw;PC=1;function e(t,n,r){for(var s=-1,o=t==null?0:t.length;++s<o;)if(r(n,t[s]))return!0;return!1}return hw=e,hw}var fw,DC;function FQ(){if(DC)return fw;DC=1;function e(){}return fw=e,fw}var pw,FC;function BQ(){if(FC)return pw;FC=1;var e=$O(),t=FQ(),n=W0(),r=1/0,s=e&&1/n(new e([,-0]))[1]==r?function(o){return new e(o)}:t;return pw=s,pw}var mw,BC;function qQ(){if(BC)return mw;BC=1;var e=UO(),t=PQ(),n=DQ(),r=zO(),s=BQ(),o=W0(),l=200;function c(d,h,f){var p=-1,g=t,v=d.length,N=!0,k=[],x=k;if(f)N=!1,g=n;else if(v>=l){var j=h?null:s(d);if(j)return o(j);N=!1,g=r,x=new e}else x=h?[]:k;e:for(;++p<v;){var b=d[p],_=h?h(b):b;if(b=f||b!==0?b:0,N&&_===_){for(var E=x.length;E--;)if(x[E]===_)continue e;h&&x.push(_),k.push(b)}else g(x,_,f)||(x!==k&&x.push(_),k.push(b))}return k}return mw=c,mw}var gw,qC;function iL(){if(qC)return gw;qC=1;var e=ys(),t=Ur();function n(r){return t(r)&&e(r)}return gw=n,gw}var yw,UC;function UQ(){if(UC)return yw;UC=1;var e=V0(),t=Mh(),n=qQ(),r=iL(),s=t(function(o){return n(e(o,1,r,!0))});return yw=s,yw}var ww,zC;function zQ(){if(zC)return ww;zC=1;var e=Ch();function t(n,r){return e(r,function(s){return n[s]})}return ww=t,ww}var vw,WC;function lL(){if(WC)return vw;WC=1;var e=zQ(),t=ua();function n(r){return r==null?[]:e(r,t(r))}return vw=n,vw}var xw,HC;function Gn(){if(HC)return xw;HC=1;var e;if(typeof R0=="function")try{e={clone:XJ(),constant:q0(),each:qO(),filter:JO(),has:QO(),isArray:jt(),isEmpty:xQ(),isFunction:mc(),isUndefined:eL(),keys:ua(),map:nL(),reduce:rL(),size:TQ(),transform:CQ(),union:UQ(),values:lL()}}catch{}return e||(e=window._),xw=e,xw}var bw,VC;function G0(){if(VC)return bw;VC=1;var e=Gn();bw=s;var t="\0",n="\0",r="";function s(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={}}s.prototype._nodeCount=0,s.prototype._edgeCount=0,s.prototype.isDirected=function(){return this._isDirected},s.prototype.isMultigraph=function(){return this._isMultigraph},s.prototype.isCompound=function(){return this._isCompound},s.prototype.setGraph=function(f){return this._label=f,this},s.prototype.graph=function(){return this._label},s.prototype.setDefaultNodeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultNodeLabelFn=f,this},s.prototype.nodeCount=function(){return this._nodeCount},s.prototype.nodes=function(){return e.keys(this._nodes)},s.prototype.sources=function(){var f=this;return e.filter(this.nodes(),function(p){return e.isEmpty(f._in[p])})},s.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(p){return e.isEmpty(f._out[p])})},s.prototype.setNodes=function(f,p){var g=arguments,v=this;return e.each(f,function(N){g.length>1?v.setNode(N,p):v.setNode(N)}),this},s.prototype.setNode=function(f,p){return e.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=p),this):(this._nodes[f]=arguments.length>1?p: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)},s.prototype.node=function(f){return this._nodes[f]},s.prototype.hasNode=function(f){return e.has(this._nodes,f)},s.prototype.removeNode=function(f){var p=this;if(e.has(this._nodes,f)){var g=function(v){p.removeEdge(p._edgeObjs[v])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(v){p.setParent(v)}),delete this._children[f]),e.each(e.keys(this._in[f]),g),delete this._in[f],delete this._preds[f],e.each(e.keys(this._out[f]),g),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},s.prototype.setParent=function(f,p){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(p))p=n;else{p+="";for(var g=p;!e.isUndefined(g);g=this.parent(g))if(g===f)throw new Error("Setting "+p+" as parent of "+f+" would create a cycle");this.setNode(p)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=p,this._children[p][f]=!0,this},s.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},s.prototype.parent=function(f){if(this._isCompound){var p=this._parent[f];if(p!==n)return p}},s.prototype.children=function(f){if(e.isUndefined(f)&&(f=n),this._isCompound){var p=this._children[f];if(p)return e.keys(p)}else{if(f===n)return this.nodes();if(this.hasNode(f))return[]}},s.prototype.predecessors=function(f){var p=this._preds[f];if(p)return e.keys(p)},s.prototype.successors=function(f){var p=this._sucs[f];if(p)return e.keys(p)},s.prototype.neighbors=function(f){var p=this.predecessors(f);if(p)return e.union(p,this.successors(f))},s.prototype.isLeaf=function(f){var p;return this.isDirected()?p=this.successors(f):p=this.neighbors(f),p.length===0},s.prototype.filterNodes=function(f){var p=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});p.setGraph(this.graph());var g=this;e.each(this._nodes,function(k,x){f(x)&&p.setNode(x,k)}),e.each(this._edgeObjs,function(k){p.hasNode(k.v)&&p.hasNode(k.w)&&p.setEdge(k,g.edge(k))});var v={};function N(k){var x=g.parent(k);return x===void 0||p.hasNode(x)?(v[k]=x,x):x in v?v[x]:N(x)}return this._isCompound&&e.each(p.nodes(),function(k){p.setParent(k,N(k))}),p},s.prototype.setDefaultEdgeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultEdgeLabelFn=f,this},s.prototype.edgeCount=function(){return this._edgeCount},s.prototype.edges=function(){return e.values(this._edgeObjs)},s.prototype.setPath=function(f,p){var g=this,v=arguments;return e.reduce(f,function(N,k){return v.length>1?g.setEdge(N,k,p):g.setEdge(N,k),k}),this},s.prototype.setEdge=function(){var f,p,g,v,N=!1,k=arguments[0];typeof k=="object"&&k!==null&&"v"in k?(f=k.v,p=k.w,g=k.name,arguments.length===2&&(v=arguments[1],N=!0)):(f=k,p=arguments[1],g=arguments[3],arguments.length>2&&(v=arguments[2],N=!0)),f=""+f,p=""+p,e.isUndefined(g)||(g=""+g);var x=c(this._isDirected,f,p,g);if(e.has(this._edgeLabels,x))return N&&(this._edgeLabels[x]=v),this;if(!e.isUndefined(g)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(p),this._edgeLabels[x]=N?v:this._defaultEdgeLabelFn(f,p,g);var j=d(this._isDirected,f,p,g);return f=j.v,p=j.w,Object.freeze(j),this._edgeObjs[x]=j,o(this._preds[p],f),o(this._sucs[f],p),this._in[p][x]=j,this._out[f][x]=j,this._edgeCount++,this},s.prototype.edge=function(f,p,g){var v=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,p,g);return this._edgeLabels[v]},s.prototype.hasEdge=function(f,p,g){var v=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,p,g);return e.has(this._edgeLabels,v)},s.prototype.removeEdge=function(f,p,g){var v=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,p,g),N=this._edgeObjs[v];return N&&(f=N.v,p=N.w,delete this._edgeLabels[v],delete this._edgeObjs[v],l(this._preds[p],f),l(this._sucs[f],p),delete this._in[p][v],delete this._out[f][v],this._edgeCount--),this},s.prototype.inEdges=function(f,p){var g=this._in[f];if(g){var v=e.values(g);return p?e.filter(v,function(N){return N.v===p}):v}},s.prototype.outEdges=function(f,p){var g=this._out[f];if(g){var v=e.values(g);return p?e.filter(v,function(N){return N.w===p}):v}},s.prototype.nodeEdges=function(f,p){var g=this.inEdges(f,p);if(g)return g.concat(this.outEdges(f,p))};function o(f,p){f[p]?f[p]++:f[p]=1}function l(f,p){--f[p]||delete f[p]}function c(f,p,g,v){var N=""+p,k=""+g;if(!f&&N>k){var x=N;N=k,k=x}return N+r+k+r+(e.isUndefined(v)?t:v)}function d(f,p,g,v){var N=""+p,k=""+g;if(!f&&N>k){var x=N;N=k,k=x}var j={v:N,w:k};return v&&(j.name=v),j}function h(f,p){return c(f,p.v,p.w,p.name)}return bw}var kw,GC;function WQ(){return GC||(GC=1,kw="2.1.8"),kw}var Nw,KC;function HQ(){return KC||(KC=1,Nw={Graph:G0(),version:WQ()}),Nw}var jw,YC;function VQ(){if(YC)return jw;YC=1;var e=Gn(),t=G0();jw={write:n,read:o};function n(l){var c={options:{directed:l.isDirected(),multigraph:l.isMultigraph(),compound:l.isCompound()},nodes:r(l),edges:s(l)};return e.isUndefined(l.graph())||(c.value=e.clone(l.graph())),c}function r(l){return e.map(l.nodes(),function(c){var d=l.node(c),h=l.parent(c),f={v:c};return e.isUndefined(d)||(f.value=d),e.isUndefined(h)||(f.parent=h),f})}function s(l){return e.map(l.edges(),function(c){var d=l.edge(c),h={v:c.v,w:c.w};return e.isUndefined(c.name)||(h.name=c.name),e.isUndefined(d)||(h.value=d),h})}function o(l){var c=new t(l.options).setGraph(l.value);return e.each(l.nodes,function(d){c.setNode(d.v,d.value),d.parent&&c.setParent(d.v,d.parent)}),e.each(l.edges,function(d){c.setEdge({v:d.v,w:d.w,name:d.name},d.value)}),c}return jw}var Sw,XC;function GQ(){if(XC)return Sw;XC=1;var e=Gn();Sw=t;function t(n){var r={},s=[],o;function l(c){e.has(r,c)||(r[c]=!0,o.push(c),e.each(n.successors(c),l),e.each(n.predecessors(c),l))}return e.each(n.nodes(),function(c){o=[],l(c),o.length&&s.push(o)}),s}return Sw}var _w,ZC;function cL(){if(ZC)return _w;ZC=1;var e=Gn();_w=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 r=this._keyIndices[n];if(r!==void 0)return this._arr[r].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(n,r){var s=this._keyIndices;if(n=String(n),!e.has(s,n)){var o=this._arr,l=o.length;return s[n]=l,o.push({key:n,priority:r}),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,r){var s=this._keyIndices[n];if(r>this._arr[s].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[s].priority+" New: "+r);this._arr[s].priority=r,this._decrease(s)},t.prototype._heapify=function(n){var r=this._arr,s=2*n,o=s+1,l=n;s<r.length&&(l=r[s].priority<r[l].priority?s:l,o<r.length&&(l=r[o].priority<r[l].priority?o:l),l!==n&&(this._swap(n,l),this._heapify(l)))},t.prototype._decrease=function(n){for(var r=this._arr,s=r[n].priority,o;n!==0&&(o=n>>1,!(r[o].priority<s));)this._swap(n,o),n=o},t.prototype._swap=function(n,r){var s=this._arr,o=this._keyIndices,l=s[n],c=s[r];s[n]=c,s[r]=l,o[c.key]=n,o[l.key]=r},_w}var Ew,JC;function uL(){if(JC)return Ew;JC=1;var e=Gn(),t=cL();Ew=r;var n=e.constant(1);function r(o,l,c,d){return s(o,String(l),c||n,d||function(h){return o.outEdges(h)})}function s(o,l,c,d){var h={},f=new t,p,g,v=function(N){var k=N.v!==p?N.v:N.w,x=h[k],j=c(N),b=g.distance+j;if(j<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+N+" Weight: "+j);b<x.distance&&(x.distance=b,x.predecessor=p,f.decrease(k,b))};for(o.nodes().forEach(function(N){var k=N===l?0:Number.POSITIVE_INFINITY;h[N]={distance:k},f.add(N,k)});f.size()>0&&(p=f.removeMin(),g=h[p],g.distance!==Number.POSITIVE_INFINITY);)d(p).forEach(v);return h}return Ew}var Tw,QC;function KQ(){if(QC)return Tw;QC=1;var e=uL(),t=Gn();Tw=n;function n(r,s,o){return t.transform(r.nodes(),function(l,c){l[c]=e(r,c,s,o)},{})}return Tw}var Cw,eA;function dL(){if(eA)return Cw;eA=1;var e=Gn();Cw=t;function t(n){var r=0,s=[],o={},l=[];function c(d){var h=o[d]={onStack:!0,lowlink:r,index:r++};if(s.push(d),n.successors(d).forEach(function(g){e.has(o,g)?o[g].onStack&&(h.lowlink=Math.min(h.lowlink,o[g].index)):(c(g),h.lowlink=Math.min(h.lowlink,o[g].lowlink))}),h.lowlink===h.index){var f=[],p;do p=s.pop(),o[p].onStack=!1,f.push(p);while(d!==p);l.push(f)}}return n.nodes().forEach(function(d){e.has(o,d)||c(d)}),l}return Cw}var Aw,tA;function YQ(){if(tA)return Aw;tA=1;var e=Gn(),t=dL();Aw=n;function n(r){return e.filter(t(r),function(s){return s.length>1||s.length===1&&r.hasEdge(s[0],s[0])})}return Aw}var Rw,nA;function XQ(){if(nA)return Rw;nA=1;var e=Gn();Rw=n;var t=e.constant(1);function n(s,o,l){return r(s,o||t,l||function(c){return s.outEdges(c)})}function r(s,o,l){var c={},d=s.nodes();return d.forEach(function(h){c[h]={},c[h][h]={distance:0},d.forEach(function(f){h!==f&&(c[h][f]={distance:Number.POSITIVE_INFINITY})}),l(h).forEach(function(f){var p=f.v===h?f.w:f.v,g=o(f);c[h][p]={distance:g,predecessor:h}})}),d.forEach(function(h){var f=c[h];d.forEach(function(p){var g=c[p];d.forEach(function(v){var N=g[h],k=f[v],x=g[v],j=N.distance+k.distance;j<x.distance&&(x.distance=j,x.predecessor=k.predecessor)})})}),c}return Rw}var Mw,rA;function hL(){if(rA)return Mw;rA=1;var e=Gn();Mw=t,t.CycleException=n;function t(r){var s={},o={},l=[];function c(d){if(e.has(o,d))throw new n;e.has(s,d)||(o[d]=!0,s[d]=!0,e.each(r.predecessors(d),c),delete o[d],l.push(d))}if(e.each(r.sinks(),c),e.size(s)!==r.nodeCount())throw new n;return l}function n(){}return n.prototype=new Error,Mw}var $w,sA;function ZQ(){if(sA)return $w;sA=1;var e=hL();$w=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return $w}var Iw,aA;function fL(){if(aA)return Iw;aA=1;var e=Gn();Iw=t;function t(r,s,o){e.isArray(s)||(s=[s]);var l=(r.isDirected()?r.successors:r.neighbors).bind(r),c=[],d={};return e.each(s,function(h){if(!r.hasNode(h))throw new Error("Graph does not have node: "+h);n(r,h,o==="post",d,l,c)}),c}function n(r,s,o,l,c,d){e.has(l,s)||(l[s]=!0,o||d.push(s),e.each(c(s),function(h){n(r,h,o,l,c,d)}),o&&d.push(s))}return Iw}var Ow,oA;function JQ(){if(oA)return Ow;oA=1;var e=fL();Ow=t;function t(n,r){return e(n,r,"post")}return Ow}var Lw,iA;function QQ(){if(iA)return Lw;iA=1;var e=fL();Lw=t;function t(n,r){return e(n,r,"pre")}return Lw}var Pw,lA;function eee(){if(lA)return Pw;lA=1;var e=Gn(),t=G0(),n=cL();Pw=r;function r(s,o){var l=new t,c={},d=new n,h;function f(g){var v=g.v===h?g.w:g.v,N=d.priority(v);if(N!==void 0){var k=o(g);k<N&&(c[v]=h,d.decrease(v,k))}}if(s.nodeCount()===0)return l;e.each(s.nodes(),function(g){d.add(g,Number.POSITIVE_INFINITY),l.setNode(g)}),d.decrease(s.nodes()[0],0);for(var p=!1;d.size()>0;){if(h=d.removeMin(),e.has(c,h))l.setEdge(h,c[h]);else{if(p)throw new Error("Input graph is not connected: "+s);p=!0}s.nodeEdges(h).forEach(f)}return l}return Pw}var Dw,cA;function tee(){return cA||(cA=1,Dw={components:GQ(),dijkstra:uL(),dijkstraAll:KQ(),findCycles:YQ(),floydWarshall:XQ(),isAcyclic:ZQ(),postorder:JQ(),preorder:QQ(),prim:eee(),tarjan:dL(),topsort:hL()}),Dw}var Fw,uA;function nee(){if(uA)return Fw;uA=1;var e=HQ();return Fw={Graph:e.Graph,json:VQ(),alg:tee(),version:e.version},Fw}var Bw,dA;function hr(){if(dA)return Bw;dA=1;var e;if(typeof R0=="function")try{e=nee()}catch{}return e||(e=window.graphlib),Bw=e,Bw}var qw,hA;function ree(){if(hA)return qw;hA=1;var e=DO(),t=1,n=4;function r(s){return e(s,t|n)}return qw=r,qw}var Uw,fA;function $h(){if(fA)return Uw;fA=1;var e=Ei(),t=ys(),n=jh(),r=Vn();function s(o,l,c){if(!r(c))return!1;var d=typeof l;return(d=="number"?t(c)&&n(l,c.length):d=="string"&&l in c)?e(c[l],o):!1}return Uw=s,Uw}var zw,pA;function see(){if(pA)return zw;pA=1;var e=Mh(),t=Ei(),n=$h(),r=ro(),s=Object.prototype,o=s.hasOwnProperty,l=e(function(c,d){c=Object(c);var h=-1,f=d.length,p=f>2?d[2]:void 0;for(p&&n(d[0],d[1],p)&&(f=1);++h<f;)for(var g=d[h],v=r(g),N=-1,k=v.length;++N<k;){var x=v[N],j=c[x];(j===void 0||t(j,s[x])&&!o.call(c,x))&&(c[x]=g[x])}return c});return zw=l,zw}var Ww,mA;function aee(){if(mA)return Ww;mA=1;var e=ws(),t=ys(),n=ua();function r(s){return function(o,l,c){var d=Object(o);if(!t(o)){var h=e(l,3);o=n(o),l=function(p){return h(d[p],p,d)}}var f=s(o,l,c);return f>-1?d[h?o[f]:f]:void 0}}return Ww=r,Ww}var Hw,gA;function oee(){if(gA)return Hw;gA=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return Hw=t,Hw}var Vw,yA;function iee(){if(yA)return Vw;yA=1;var e=oee(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return Vw=n,Vw}var Gw,wA;function lee(){if(wA)return Gw;wA=1;var e=iee(),t=Vn(),n=Ri(),r=NaN,s=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,l=/^0o[0-7]+$/i,c=parseInt;function d(h){if(typeof h=="number")return h;if(n(h))return r;if(t(h)){var f=typeof h.valueOf=="function"?h.valueOf():h;h=t(f)?f+"":f}if(typeof h!="string")return h===0?h:+h;h=e(h);var p=o.test(h);return p||l.test(h)?c(h.slice(2),p?2:8):s.test(h)?r:+h}return Gw=d,Gw}var Kw,vA;function pL(){if(vA)return Kw;vA=1;var e=lee(),t=1/0,n=17976931348623157e292;function r(s){if(!s)return s===0?s:0;if(s=e(s),s===t||s===-t){var o=s<0?-1:1;return o*n}return s===s?s:0}return Kw=r,Kw}var Yw,xA;function cee(){if(xA)return Yw;xA=1;var e=pL();function t(n){var r=e(n),s=r%1;return r===r?s?r-s:r:0}return Yw=t,Yw}var Xw,bA;function uee(){if(bA)return Xw;bA=1;var e=oL(),t=ws(),n=cee(),r=Math.max;function s(o,l,c){var d=o==null?0:o.length;if(!d)return-1;var h=c==null?0:n(c);return h<0&&(h=r(d+h,0)),e(o,t(l,3),h)}return Xw=s,Xw}var Zw,kA;function dee(){if(kA)return Zw;kA=1;var e=aee(),t=uee(),n=e(t);return Zw=n,Zw}var Jw,NA;function mL(){if(NA)return Jw;NA=1;var e=V0();function t(n){var r=n==null?0:n.length;return r?e(n,1):[]}return Jw=t,Jw}var Qw,jA;function hee(){if(jA)return Qw;jA=1;var e=U0(),t=FO(),n=ro();function r(s,o){return s==null?s:e(s,t(o),n)}return Qw=r,Qw}var ev,SA;function fee(){if(SA)return ev;SA=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return ev=e,ev}var tv,_A;function pee(){if(_A)return tv;_A=1;var e=kh(),t=z0(),n=ws();function r(s,o){var l={};return o=n(o,3),t(s,function(c,d,h){e(l,d,o(c,d,h))}),l}return tv=r,tv}var nv,EA;function K0(){if(EA)return nv;EA=1;var e=Ri();function t(n,r,s){for(var o=-1,l=n.length;++o<l;){var c=n[o],d=r(c);if(d!=null&&(h===void 0?d===d&&!e(d):s(d,h)))var h=d,f=c}return f}return nv=t,nv}var rv,TA;function mee(){if(TA)return rv;TA=1;function e(t,n){return t>n}return rv=e,rv}var sv,CA;function gee(){if(CA)return sv;CA=1;var e=K0(),t=mee(),n=so();function r(s){return s&&s.length?e(s,n,t):void 0}return sv=r,sv}var av,AA;function gL(){if(AA)return av;AA=1;var e=kh(),t=Ei();function n(r,s,o){(o!==void 0&&!t(r[s],o)||o===void 0&&!(s in r))&&e(r,s,o)}return av=n,av}var ov,RA;function yee(){if(RA)return ov;RA=1;var e=to(),t=Eh(),n=Ur(),r="[object Object]",s=Function.prototype,o=Object.prototype,l=s.toString,c=o.hasOwnProperty,d=l.call(Object);function h(f){if(!n(f)||e(f)!=r)return!1;var p=t(f);if(p===null)return!0;var g=c.call(p,"constructor")&&p.constructor;return typeof g=="function"&&g instanceof g&&l.call(g)==d}return ov=h,ov}var iv,MA;function yL(){if(MA)return iv;MA=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return iv=e,iv}var lv,$A;function wee(){if($A)return lv;$A=1;var e=gc(),t=ro();function n(r){return e(r,t(r))}return lv=n,lv}var cv,IA;function vee(){if(IA)return cv;IA=1;var e=gL(),t=_O(),n=OO(),r=EO(),s=PO(),o=yc(),l=jt(),c=iL(),d=Ci(),h=mc(),f=Vn(),p=yee(),g=wc(),v=yL(),N=wee();function k(x,j,b,_,E,R,C){var A=v(x,b),U=v(j,b),L=C.get(U);if(L){e(x,b,L);return}var F=R?R(A,U,b+"",x,j,C):void 0,O=F===void 0;if(O){var I=l(U),B=!I&&d(U),M=!I&&!B&&g(U);F=U,I||B||M?l(A)?F=A:c(A)?F=r(A):B?(O=!1,F=t(U,!0)):M?(O=!1,F=n(U,!0)):F=[]:p(U)||o(U)?(F=A,o(A)?F=N(A):(!f(A)||h(A))&&(F=s(U))):O=!1}O&&(C.set(U,F),E(F,U,_,R,C),C.delete(U)),e(x,b,F)}return cv=k,cv}var uv,OA;function xee(){if(OA)return uv;OA=1;var e=bh(),t=gL(),n=U0(),r=vee(),s=Vn(),o=ro(),l=yL();function c(d,h,f,p,g){d!==h&&n(h,function(v,N){if(g||(g=new e),s(v))r(d,h,N,f,c,p,g);else{var k=p?p(l(d,N),v,N+"",d,h,g):void 0;k===void 0&&(k=v),t(d,N,k)}},o)}return uv=c,uv}var dv,LA;function bee(){if(LA)return dv;LA=1;var e=Mh(),t=$h();function n(r){return e(function(s,o){var l=-1,c=o.length,d=c>1?o[c-1]:void 0,h=c>2?o[2]:void 0;for(d=r.length>3&&typeof d=="function"?(c--,d):void 0,h&&t(o[0],o[1],h)&&(d=c<3?void 0:d,c=1),s=Object(s);++l<c;){var f=o[l];f&&r(s,f,l,d)}return s})}return dv=n,dv}var hv,PA;function kee(){if(PA)return hv;PA=1;var e=xee(),t=bee(),n=t(function(r,s,o){e(r,s,o)});return hv=n,hv}var fv,DA;function wL(){if(DA)return fv;DA=1;function e(t,n){return t<n}return fv=e,fv}var pv,FA;function Nee(){if(FA)return pv;FA=1;var e=K0(),t=wL(),n=so();function r(s){return s&&s.length?e(s,n,t):void 0}return pv=r,pv}var mv,BA;function jee(){if(BA)return mv;BA=1;var e=K0(),t=ws(),n=wL();function r(s,o){return s&&s.length?e(s,t(o,2),n):void 0}return mv=r,mv}var gv,qA;function See(){if(qA)return gv;qA=1;var e=pr(),t=function(){return e.Date.now()};return gv=t,gv}var yv,UA;function _ee(){if(UA)return yv;UA=1;var e=Nh(),t=Ah(),n=jh(),r=Vn(),s=vc();function o(l,c,d,h){if(!r(l))return l;c=t(c,l);for(var f=-1,p=c.length,g=p-1,v=l;v!=null&&++f<p;){var N=s(c[f]),k=d;if(N==="__proto__"||N==="constructor"||N==="prototype")return l;if(f!=g){var x=v[N];k=h?h(x,N,v):void 0,k===void 0&&(k=r(x)?x:n(c[f+1])?[]:{})}e(v,N,k),v=v[N]}return l}return yv=o,yv}var wv,zA;function Eee(){if(zA)return wv;zA=1;var e=Rh(),t=_ee(),n=Ah();function r(s,o,l){for(var c=-1,d=o.length,h={};++c<d;){var f=o[c],p=e(s,f);l(p,f)&&t(h,n(f,s),p)}return h}return wv=r,wv}var vv,WA;function Tee(){if(WA)return vv;WA=1;var e=Eee(),t=XO();function n(r,s){return e(r,s,function(o,l){return t(r,l)})}return vv=n,vv}var xv,HA;function Cee(){if(HA)return xv;HA=1;var e=mL(),t=sL(),n=aL();function r(s){return n(t(s,void 0,e),s+"")}return xv=r,xv}var bv,VA;function Aee(){if(VA)return bv;VA=1;var e=Tee(),t=Cee(),n=t(function(r,s){return r==null?{}:e(r,s)});return bv=n,bv}var kv,GA;function Ree(){if(GA)return kv;GA=1;var e=Math.ceil,t=Math.max;function n(r,s,o,l){for(var c=-1,d=t(e((s-r)/(o||1)),0),h=Array(d);d--;)h[l?d:++c]=r,r+=o;return h}return kv=n,kv}var Nv,KA;function Mee(){if(KA)return Nv;KA=1;var e=Ree(),t=$h(),n=pL();function r(s){return function(o,l,c){return c&&typeof c!="number"&&t(o,l,c)&&(l=c=void 0),o=n(o),l===void 0?(l=o,o=0):l=n(l),c=c===void 0?o<l?1:-1:n(c),e(o,l,c,s)}}return Nv=r,Nv}var jv,YA;function $ee(){if(YA)return jv;YA=1;var e=Mee(),t=e();return jv=t,jv}var Sv,XA;function Iee(){if(XA)return Sv;XA=1;function e(t,n){var r=t.length;for(t.sort(n);r--;)t[r]=t[r].value;return t}return Sv=e,Sv}var _v,ZA;function Oee(){if(ZA)return _v;ZA=1;var e=Ri();function t(n,r){if(n!==r){var s=n!==void 0,o=n===null,l=n===n,c=e(n),d=r!==void 0,h=r===null,f=r===r,p=e(r);if(!h&&!p&&!c&&n>r||c&&d&&f&&!h&&!p||o&&d&&f||!s&&f||!l)return 1;if(!o&&!c&&!p&&n<r||p&&s&&l&&!o&&!c||h&&s&&l||!d&&l||!f)return-1}return 0}return _v=t,_v}var Ev,JA;function Lee(){if(JA)return Ev;JA=1;var e=Oee();function t(n,r,s){for(var o=-1,l=n.criteria,c=r.criteria,d=l.length,h=s.length;++o<d;){var f=e(l[o],c[o]);if(f){if(o>=h)return f;var p=s[o];return f*(p=="desc"?-1:1)}}return n.index-r.index}return Ev=t,Ev}var Tv,QA;function Pee(){if(QA)return Tv;QA=1;var e=Ch(),t=Rh(),n=ws(),r=tL(),s=Iee(),o=Sh(),l=Lee(),c=so(),d=jt();function h(f,p,g){p.length?p=e(p,function(k){return d(k)?function(x){return t(x,k.length===1?k[0]:k)}:k}):p=[c];var v=-1;p=e(p,o(n));var N=r(f,function(k,x,j){var b=e(p,function(_){return _(k)});return{criteria:b,index:++v,value:k}});return s(N,function(k,x){return l(k,x,g)})}return Tv=h,Tv}var Cv,eR;function Dee(){if(eR)return Cv;eR=1;var e=V0(),t=Pee(),n=Mh(),r=$h(),s=n(function(o,l){if(o==null)return[];var c=l.length;return c>1&&r(o,l[0],l[1])?l=[]:c>2&&r(l[0],l[1],l[2])&&(l=[l[0]]),t(o,e(l,1),[])});return Cv=s,Cv}var Av,tR;function Fee(){if(tR)return Av;tR=1;var e=KO(),t=0;function n(r){var s=++t;return e(r)+s}return Av=n,Av}var Rv,nR;function Bee(){if(nR)return Rv;nR=1;function e(t,n,r){for(var s=-1,o=t.length,l=n.length,c={};++s<o;){var d=s<l?n[s]:void 0;r(c,t[s],d)}return c}return Rv=e,Rv}var Mv,rR;function qee(){if(rR)return Mv;rR=1;var e=Nh(),t=Bee();function n(r,s){return t(r||[],s||[],e)}return Mv=n,Mv}var $v,sR;function dt(){if(sR)return $v;sR=1;var e;if(typeof R0=="function")try{e={cloneDeep:ree(),constant:q0(),defaults:see(),each:qO(),filter:JO(),find:dee(),flatten:mL(),forEach:BO(),forIn:hee(),has:QO(),isUndefined:eL(),last:fee(),map:nL(),mapValues:pee(),max:gee(),merge:kee(),min:Nee(),minBy:jee(),now:See(),pick:Aee(),range:$ee(),reduce:rL(),sortBy:Dee(),uniqueId:Fee(),values:lL(),zipObject:qee()}}catch{}return e||(e=window._),$v=e,$v}var Iv,aR;function Uee(){if(aR)return Iv;aR=1,Iv=e;function e(){var r={};r._next=r._prev=r,this._sentinel=r}e.prototype.dequeue=function(){var r=this._sentinel,s=r._prev;if(s!==r)return t(s),s},e.prototype.enqueue=function(r){var s=this._sentinel;r._prev&&r._next&&t(r),r._next=s._next,s._next._prev=r,s._next=r,r._prev=s},e.prototype.toString=function(){for(var r=[],s=this._sentinel,o=s._prev;o!==s;)r.push(JSON.stringify(o,n)),o=o._prev;return"["+r.join(", ")+"]"};function t(r){r._prev._next=r._next,r._next._prev=r._prev,delete r._next,delete r._prev}function n(r,s){if(r!=="_next"&&r!=="_prev")return s}return Iv}var Ov,oR;function zee(){if(oR)return Ov;oR=1;var e=dt(),t=hr().Graph,n=Uee();Ov=s;var r=e.constant(1);function s(h,f){if(h.nodeCount()<=1)return[];var p=c(h,f||r),g=o(p.graph,p.buckets,p.zeroIdx);return e.flatten(e.map(g,function(v){return h.outEdges(v.v,v.w)}),!0)}function o(h,f,p){for(var g=[],v=f[f.length-1],N=f[0],k;h.nodeCount();){for(;k=N.dequeue();)l(h,f,p,k);for(;k=v.dequeue();)l(h,f,p,k);if(h.nodeCount()){for(var x=f.length-2;x>0;--x)if(k=f[x].dequeue(),k){g=g.concat(l(h,f,p,k,!0));break}}}return g}function l(h,f,p,g,v){var N=v?[]:void 0;return e.forEach(h.inEdges(g.v),function(k){var x=h.edge(k),j=h.node(k.v);v&&N.push({v:k.v,w:k.w}),j.out-=x,d(f,p,j)}),e.forEach(h.outEdges(g.v),function(k){var x=h.edge(k),j=k.w,b=h.node(j);b.in-=x,d(f,p,b)}),h.removeNode(g.v),N}function c(h,f){var p=new t,g=0,v=0;e.forEach(h.nodes(),function(x){p.setNode(x,{v:x,in:0,out:0})}),e.forEach(h.edges(),function(x){var j=p.edge(x.v,x.w)||0,b=f(x),_=j+b;p.setEdge(x.v,x.w,_),v=Math.max(v,p.node(x.v).out+=b),g=Math.max(g,p.node(x.w).in+=b)});var N=e.range(v+g+3).map(function(){return new n}),k=g+1;return e.forEach(p.nodes(),function(x){d(N,k,p.node(x))}),{graph:p,buckets:N,zeroIdx:k}}function d(h,f,p){p.out?p.in?h[p.out-p.in+f].enqueue(p):h[h.length-1].enqueue(p):h[0].enqueue(p)}return Ov}var Lv,iR;function Wee(){if(iR)return Lv;iR=1;var e=dt(),t=zee();Lv={run:n,undo:s};function n(o){var l=o.graph().acyclicer==="greedy"?t(o,c(o)):r(o);e.forEach(l,function(d){var h=o.edge(d);o.removeEdge(d),h.forwardName=d.name,h.reversed=!0,o.setEdge(d.w,d.v,h,e.uniqueId("rev"))});function c(d){return function(h){return d.edge(h).weight}}}function r(o){var l=[],c={},d={};function h(f){e.has(d,f)||(d[f]=!0,c[f]=!0,e.forEach(o.outEdges(f),function(p){e.has(c,p.w)?l.push(p):h(p.w)}),delete c[f])}return e.forEach(o.nodes(),h),l}function s(o){e.forEach(o.edges(),function(l){var c=o.edge(l);if(c.reversed){o.removeEdge(l);var d=c.forwardName;delete c.reversed,delete c.forwardName,o.setEdge(l.w,l.v,c,d)}})}return Lv}var Pv,lR;function fn(){if(lR)return Pv;lR=1;var e=dt(),t=hr().Graph;Pv={addDummyNode:n,simplify:r,asNonCompoundGraph:s,successorWeights:o,predecessorWeights:l,intersectRect:c,buildLayerMatrix:d,normalizeRanks:h,removeEmptyRanks:f,addBorderNode:p,maxRank:g,partition:v,time:N,notime:k};function n(x,j,b,_){var E;do E=e.uniqueId(_);while(x.hasNode(E));return b.dummy=j,x.setNode(E,b),E}function r(x){var j=new t().setGraph(x.graph());return e.forEach(x.nodes(),function(b){j.setNode(b,x.node(b))}),e.forEach(x.edges(),function(b){var _=j.edge(b.v,b.w)||{weight:0,minlen:1},E=x.edge(b);j.setEdge(b.v,b.w,{weight:_.weight+E.weight,minlen:Math.max(_.minlen,E.minlen)})}),j}function s(x){var j=new t({multigraph:x.isMultigraph()}).setGraph(x.graph());return e.forEach(x.nodes(),function(b){x.children(b).length||j.setNode(b,x.node(b))}),e.forEach(x.edges(),function(b){j.setEdge(b,x.edge(b))}),j}function o(x){var j=e.map(x.nodes(),function(b){var _={};return e.forEach(x.outEdges(b),function(E){_[E.w]=(_[E.w]||0)+x.edge(E).weight}),_});return e.zipObject(x.nodes(),j)}function l(x){var j=e.map(x.nodes(),function(b){var _={};return e.forEach(x.inEdges(b),function(E){_[E.v]=(_[E.v]||0)+x.edge(E).weight}),_});return e.zipObject(x.nodes(),j)}function c(x,j){var b=x.x,_=x.y,E=j.x-b,R=j.y-_,C=x.width/2,A=x.height/2;if(!E&&!R)throw new Error("Not possible to find intersection inside of the rectangle");var U,L;return Math.abs(R)*C>Math.abs(E)*A?(R<0&&(A=-A),U=A*E/R,L=A):(E<0&&(C=-C),U=C,L=C*R/E),{x:b+U,y:_+L}}function d(x){var j=e.map(e.range(g(x)+1),function(){return[]});return e.forEach(x.nodes(),function(b){var _=x.node(b),E=_.rank;e.isUndefined(E)||(j[E][_.order]=b)}),j}function h(x){var j=e.min(e.map(x.nodes(),function(b){return x.node(b).rank}));e.forEach(x.nodes(),function(b){var _=x.node(b);e.has(_,"rank")&&(_.rank-=j)})}function f(x){var j=e.min(e.map(x.nodes(),function(R){return x.node(R).rank})),b=[];e.forEach(x.nodes(),function(R){var C=x.node(R).rank-j;b[C]||(b[C]=[]),b[C].push(R)});var _=0,E=x.graph().nodeRankFactor;e.forEach(b,function(R,C){e.isUndefined(R)&&C%E!==0?--_:_&&e.forEach(R,function(A){x.node(A).rank+=_})})}function p(x,j,b,_){var E={width:0,height:0};return arguments.length>=4&&(E.rank=b,E.order=_),n(x,"border",E,j)}function g(x){return e.max(e.map(x.nodes(),function(j){var b=x.node(j).rank;if(!e.isUndefined(b))return b}))}function v(x,j){var b={lhs:[],rhs:[]};return e.forEach(x,function(_){j(_)?b.lhs.push(_):b.rhs.push(_)}),b}function N(x,j){var b=e.now();try{return j()}finally{console.log(x+" time: "+(e.now()-b)+"ms")}}function k(x,j){return j()}return Pv}var Dv,cR;function Hee(){if(cR)return Dv;cR=1;var e=dt(),t=fn();Dv={run:n,undo:s};function n(o){o.graph().dummyChains=[],e.forEach(o.edges(),function(l){r(o,l)})}function r(o,l){var c=l.v,d=o.node(c).rank,h=l.w,f=o.node(h).rank,p=l.name,g=o.edge(l),v=g.labelRank;if(f!==d+1){o.removeEdge(l);var N,k,x;for(x=0,++d;d<f;++x,++d)g.points=[],k={width:0,height:0,edgeLabel:g,edgeObj:l,rank:d},N=t.addDummyNode(o,"edge",k,"_d"),d===v&&(k.width=g.width,k.height=g.height,k.dummy="edge-label",k.labelpos=g.labelpos),o.setEdge(c,N,{weight:g.weight},p),x===0&&o.graph().dummyChains.push(N),c=N;o.setEdge(c,h,{weight:g.weight},p)}}function s(o){e.forEach(o.graph().dummyChains,function(l){var c=o.node(l),d=c.edgeLabel,h;for(o.setEdge(c.edgeObj,d);c.dummy;)h=o.successors(l)[0],o.removeNode(l),d.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(d.x=c.x,d.y=c.y,d.width=c.width,d.height=c.height),l=h,c=o.node(l)})}return Dv}var Fv,uR;function Od(){if(uR)return Fv;uR=1;var e=dt();Fv={longestPath:t,slack:n};function t(r){var s={};function o(l){var c=r.node(l);if(e.has(s,l))return c.rank;s[l]=!0;var d=e.min(e.map(r.outEdges(l),function(h){return o(h.w)-r.edge(h).minlen}));return(d===Number.POSITIVE_INFINITY||d===void 0||d===null)&&(d=0),c.rank=d}e.forEach(r.sources(),o)}function n(r,s){return r.node(s.w).rank-r.node(s.v).rank-r.edge(s).minlen}return Fv}var Bv,dR;function vL(){if(dR)return Bv;dR=1;var e=dt(),t=hr().Graph,n=Od().slack;Bv=r;function r(c){var d=new t({directed:!1}),h=c.nodes()[0],f=c.nodeCount();d.setNode(h,{});for(var p,g;s(d,c)<f;)p=o(d,c),g=d.hasNode(p.v)?n(c,p):-n(c,p),l(d,c,g);return d}function s(c,d){function h(f){e.forEach(d.nodeEdges(f),function(p){var g=p.v,v=f===g?p.w:g;!c.hasNode(v)&&!n(d,p)&&(c.setNode(v,{}),c.setEdge(f,v,{}),h(v))})}return e.forEach(c.nodes(),h),c.nodeCount()}function o(c,d){return e.minBy(d.edges(),function(h){if(c.hasNode(h.v)!==c.hasNode(h.w))return n(d,h)})}function l(c,d,h){e.forEach(c.nodes(),function(f){d.node(f).rank+=h})}return Bv}var qv,hR;function Vee(){if(hR)return qv;hR=1;var e=dt(),t=vL(),n=Od().slack,r=Od().longestPath,s=hr().alg.preorder,o=hr().alg.postorder,l=fn().simplify;qv=c,c.initLowLimValues=p,c.initCutValues=d,c.calcCutValue=f,c.leaveEdge=v,c.enterEdge=N,c.exchangeEdges=k;function c(_){_=l(_),r(_);var E=t(_);p(E),d(E,_);for(var R,C;R=v(E);)C=N(E,_,R),k(E,_,R,C)}function d(_,E){var R=o(_,_.nodes());R=R.slice(0,R.length-1),e.forEach(R,function(C){h(_,E,C)})}function h(_,E,R){var C=_.node(R),A=C.parent;_.edge(R,A).cutvalue=f(_,E,R)}function f(_,E,R){var C=_.node(R),A=C.parent,U=!0,L=E.edge(R,A),F=0;return L||(U=!1,L=E.edge(A,R)),F=L.weight,e.forEach(E.nodeEdges(R),function(O){var I=O.v===R,B=I?O.w:O.v;if(B!==A){var M=I===U,$=E.edge(O).weight;if(F+=M?$:-$,j(_,R,B)){var P=_.edge(R,B).cutvalue;F+=M?-P:P}}}),F}function p(_,E){arguments.length<2&&(E=_.nodes()[0]),g(_,{},1,E)}function g(_,E,R,C,A){var U=R,L=_.node(C);return E[C]=!0,e.forEach(_.neighbors(C),function(F){e.has(E,F)||(R=g(_,E,R,F,C))}),L.low=U,L.lim=R++,A?L.parent=A:delete L.parent,R}function v(_){return e.find(_.edges(),function(E){return _.edge(E).cutvalue<0})}function N(_,E,R){var C=R.v,A=R.w;E.hasEdge(C,A)||(C=R.w,A=R.v);var U=_.node(C),L=_.node(A),F=U,O=!1;U.lim>L.lim&&(F=L,O=!0);var I=e.filter(E.edges(),function(B){return O===b(_,_.node(B.v),F)&&O!==b(_,_.node(B.w),F)});return e.minBy(I,function(B){return n(E,B)})}function k(_,E,R,C){var A=R.v,U=R.w;_.removeEdge(A,U),_.setEdge(C.v,C.w,{}),p(_),d(_,E),x(_,E)}function x(_,E){var R=e.find(_.nodes(),function(A){return!E.node(A).parent}),C=s(_,R);C=C.slice(1),e.forEach(C,function(A){var U=_.node(A).parent,L=E.edge(A,U),F=!1;L||(L=E.edge(U,A),F=!0),E.node(A).rank=E.node(U).rank+(F?L.minlen:-L.minlen)})}function j(_,E,R){return _.hasEdge(E,R)}function b(_,E,R){return R.low<=E.lim&&E.lim<=R.lim}return qv}var Uv,fR;function Gee(){if(fR)return Uv;fR=1;var e=Od(),t=e.longestPath,n=vL(),r=Vee();Uv=s;function s(d){switch(d.graph().ranker){case"network-simplex":c(d);break;case"tight-tree":l(d);break;case"longest-path":o(d);break;default:c(d)}}var o=t;function l(d){t(d),n(d)}function c(d){r(d)}return Uv}var zv,pR;function Kee(){if(pR)return zv;pR=1;var e=dt();zv=t;function t(s){var o=r(s);e.forEach(s.graph().dummyChains,function(l){for(var c=s.node(l),d=c.edgeObj,h=n(s,o,d.v,d.w),f=h.path,p=h.lca,g=0,v=f[g],N=!0;l!==d.w;){if(c=s.node(l),N){for(;(v=f[g])!==p&&s.node(v).maxRank<c.rank;)g++;v===p&&(N=!1)}if(!N){for(;g<f.length-1&&s.node(v=f[g+1]).minRank<=c.rank;)g++;v=f[g]}s.setParent(l,v),l=s.successors(l)[0]}})}function n(s,o,l,c){var d=[],h=[],f=Math.min(o[l].low,o[c].low),p=Math.max(o[l].lim,o[c].lim),g,v;g=l;do g=s.parent(g),d.push(g);while(g&&(o[g].low>f||p>o[g].lim));for(v=g,g=c;(g=s.parent(g))!==v;)h.push(g);return{path:d.concat(h.reverse()),lca:v}}function r(s){var o={},l=0;function c(d){var h=l;e.forEach(s.children(d),c),o[d]={low:h,lim:l++}}return e.forEach(s.children(),c),o}return zv}var Wv,mR;function Yee(){if(mR)return Wv;mR=1;var e=dt(),t=fn();Wv={run:n,cleanup:l};function n(c){var d=t.addDummyNode(c,"root",{},"_root"),h=s(c),f=e.max(e.values(h))-1,p=2*f+1;c.graph().nestingRoot=d,e.forEach(c.edges(),function(v){c.edge(v).minlen*=p});var g=o(c)+1;e.forEach(c.children(),function(v){r(c,d,p,g,f,h,v)}),c.graph().nodeRankFactor=p}function r(c,d,h,f,p,g,v){var N=c.children(v);if(!N.length){v!==d&&c.setEdge(d,v,{weight:0,minlen:h});return}var k=t.addBorderNode(c,"_bt"),x=t.addBorderNode(c,"_bb"),j=c.node(v);c.setParent(k,v),j.borderTop=k,c.setParent(x,v),j.borderBottom=x,e.forEach(N,function(b){r(c,d,h,f,p,g,b);var _=c.node(b),E=_.borderTop?_.borderTop:b,R=_.borderBottom?_.borderBottom:b,C=_.borderTop?f:2*f,A=E!==R?1:p-g[v]+1;c.setEdge(k,E,{weight:C,minlen:A,nestingEdge:!0}),c.setEdge(R,x,{weight:C,minlen:A,nestingEdge:!0})}),c.parent(v)||c.setEdge(d,k,{weight:0,minlen:p+g[v]})}function s(c){var d={};function h(f,p){var g=c.children(f);g&&g.length&&e.forEach(g,function(v){h(v,p+1)}),d[f]=p}return e.forEach(c.children(),function(f){h(f,1)}),d}function o(c){return e.reduce(c.edges(),function(d,h){return d+c.edge(h).weight},0)}function l(c){var d=c.graph();c.removeNode(d.nestingRoot),delete d.nestingRoot,e.forEach(c.edges(),function(h){var f=c.edge(h);f.nestingEdge&&c.removeEdge(h)})}return Wv}var Hv,gR;function Xee(){if(gR)return Hv;gR=1;var e=dt(),t=fn();Hv=n;function n(s){function o(l){var c=s.children(l),d=s.node(l);if(c.length&&e.forEach(c,o),e.has(d,"minRank")){d.borderLeft=[],d.borderRight=[];for(var h=d.minRank,f=d.maxRank+1;h<f;++h)r(s,"borderLeft","_bl",l,d,h),r(s,"borderRight","_br",l,d,h)}}e.forEach(s.children(),o)}function r(s,o,l,c,d,h){var f={width:0,height:0,rank:h,borderType:o},p=d[o][h-1],g=t.addDummyNode(s,"border",f,l);d[o][h]=g,s.setParent(g,c),p&&s.setEdge(p,g,{weight:1})}return Hv}var Vv,yR;function Zee(){if(yR)return Vv;yR=1;var e=dt();Vv={adjust:t,undo:n};function t(h){var f=h.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&r(h)}function n(h){var f=h.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&o(h),(f==="lr"||f==="rl")&&(c(h),r(h))}function r(h){e.forEach(h.nodes(),function(f){s(h.node(f))}),e.forEach(h.edges(),function(f){s(h.edge(f))})}function s(h){var f=h.width;h.width=h.height,h.height=f}function o(h){e.forEach(h.nodes(),function(f){l(h.node(f))}),e.forEach(h.edges(),function(f){var p=h.edge(f);e.forEach(p.points,l),e.has(p,"y")&&l(p)})}function l(h){h.y=-h.y}function c(h){e.forEach(h.nodes(),function(f){d(h.node(f))}),e.forEach(h.edges(),function(f){var p=h.edge(f);e.forEach(p.points,d),e.has(p,"x")&&d(p)})}function d(h){var f=h.x;h.x=h.y,h.y=f}return Vv}var Gv,wR;function Jee(){if(wR)return Gv;wR=1;var e=dt();Gv=t;function t(n){var r={},s=e.filter(n.nodes(),function(h){return!n.children(h).length}),o=e.max(e.map(s,function(h){return n.node(h).rank})),l=e.map(e.range(o+1),function(){return[]});function c(h){if(!e.has(r,h)){r[h]=!0;var f=n.node(h);l[f.rank].push(h),e.forEach(n.successors(h),c)}}var d=e.sortBy(s,function(h){return n.node(h).rank});return e.forEach(d,c),l}return Gv}var Kv,vR;function Qee(){if(vR)return Kv;vR=1;var e=dt();Kv=t;function t(r,s){for(var o=0,l=1;l<s.length;++l)o+=n(r,s[l-1],s[l]);return o}function n(r,s,o){for(var l=e.zipObject(o,e.map(o,function(g,v){return v})),c=e.flatten(e.map(s,function(g){return e.sortBy(e.map(r.outEdges(g),function(v){return{pos:l[v.w],weight:r.edge(v).weight}}),"pos")}),!0),d=1;d<o.length;)d<<=1;var h=2*d-1;d-=1;var f=e.map(new Array(h),function(){return 0}),p=0;return e.forEach(c.forEach(function(g){var v=g.pos+d;f[v]+=g.weight;for(var N=0;v>0;)v%2&&(N+=f[v+1]),v=v-1>>1,f[v]+=g.weight;p+=g.weight*N})),p}return Kv}var Yv,xR;function ete(){if(xR)return Yv;xR=1;var e=dt();Yv=t;function t(n,r){return e.map(r,function(s){var o=n.inEdges(s);if(o.length){var l=e.reduce(o,function(c,d){var h=n.edge(d),f=n.node(d.v);return{sum:c.sum+h.weight*f.order,weight:c.weight+h.weight}},{sum:0,weight:0});return{v:s,barycenter:l.sum/l.weight,weight:l.weight}}else return{v:s}})}return Yv}var Xv,bR;function tte(){if(bR)return Xv;bR=1;var e=dt();Xv=t;function t(s,o){var l={};e.forEach(s,function(d,h){var f=l[d.v]={indegree:0,in:[],out:[],vs:[d.v],i:h};e.isUndefined(d.barycenter)||(f.barycenter=d.barycenter,f.weight=d.weight)}),e.forEach(o.edges(),function(d){var h=l[d.v],f=l[d.w];!e.isUndefined(h)&&!e.isUndefined(f)&&(f.indegree++,h.out.push(l[d.w]))});var c=e.filter(l,function(d){return!d.indegree});return n(c)}function n(s){var o=[];function l(h){return function(f){f.merged||(e.isUndefined(f.barycenter)||e.isUndefined(h.barycenter)||f.barycenter>=h.barycenter)&&r(h,f)}}function c(h){return function(f){f.in.push(h),--f.indegree===0&&s.push(f)}}for(;s.length;){var d=s.pop();o.push(d),e.forEach(d.in.reverse(),l(d)),e.forEach(d.out,c(d))}return e.map(e.filter(o,function(h){return!h.merged}),function(h){return e.pick(h,["vs","i","barycenter","weight"])})}function r(s,o){var l=0,c=0;s.weight&&(l+=s.barycenter*s.weight,c+=s.weight),o.weight&&(l+=o.barycenter*o.weight,c+=o.weight),s.vs=o.vs.concat(s.vs),s.barycenter=l/c,s.weight=c,s.i=Math.min(o.i,s.i),o.merged=!0}return Xv}var Zv,kR;function nte(){if(kR)return Zv;kR=1;var e=dt(),t=fn();Zv=n;function n(o,l){var c=t.partition(o,function(k){return e.has(k,"barycenter")}),d=c.lhs,h=e.sortBy(c.rhs,function(k){return-k.i}),f=[],p=0,g=0,v=0;d.sort(s(!!l)),v=r(f,h,v),e.forEach(d,function(k){v+=k.vs.length,f.push(k.vs),p+=k.barycenter*k.weight,g+=k.weight,v=r(f,h,v)});var N={vs:e.flatten(f,!0)};return g&&(N.barycenter=p/g,N.weight=g),N}function r(o,l,c){for(var d;l.length&&(d=e.last(l)).i<=c;)l.pop(),o.push(d.vs),c++;return c}function s(o){return function(l,c){return l.barycenter<c.barycenter?-1:l.barycenter>c.barycenter?1:o?c.i-l.i:l.i-c.i}}return Zv}var Jv,NR;function rte(){if(NR)return Jv;NR=1;var e=dt(),t=ete(),n=tte(),r=nte();Jv=s;function s(c,d,h,f){var p=c.children(d),g=c.node(d),v=g?g.borderLeft:void 0,N=g?g.borderRight:void 0,k={};v&&(p=e.filter(p,function(R){return R!==v&&R!==N}));var x=t(c,p);e.forEach(x,function(R){if(c.children(R.v).length){var C=s(c,R.v,h,f);k[R.v]=C,e.has(C,"barycenter")&&l(R,C)}});var j=n(x,h);o(j,k);var b=r(j,f);if(v&&(b.vs=e.flatten([v,b.vs,N],!0),c.predecessors(v).length)){var _=c.node(c.predecessors(v)[0]),E=c.node(c.predecessors(N)[0]);e.has(b,"barycenter")||(b.barycenter=0,b.weight=0),b.barycenter=(b.barycenter*b.weight+_.order+E.order)/(b.weight+2),b.weight+=2}return b}function o(c,d){e.forEach(c,function(h){h.vs=e.flatten(h.vs.map(function(f){return d[f]?d[f].vs:f}),!0)})}function l(c,d){e.isUndefined(c.barycenter)?(c.barycenter=d.barycenter,c.weight=d.weight):(c.barycenter=(c.barycenter*c.weight+d.barycenter*d.weight)/(c.weight+d.weight),c.weight+=d.weight)}return Jv}var Qv,jR;function ste(){if(jR)return Qv;jR=1;var e=dt(),t=hr().Graph;Qv=n;function n(s,o,l){var c=r(s),d=new t({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(h){return s.node(h)});return e.forEach(s.nodes(),function(h){var f=s.node(h),p=s.parent(h);(f.rank===o||f.minRank<=o&&o<=f.maxRank)&&(d.setNode(h),d.setParent(h,p||c),e.forEach(s[l](h),function(g){var v=g.v===h?g.w:g.v,N=d.edge(v,h),k=e.isUndefined(N)?0:N.weight;d.setEdge(v,h,{weight:s.edge(g).weight+k})}),e.has(f,"minRank")&&d.setNode(h,{borderLeft:f.borderLeft[o],borderRight:f.borderRight[o]}))}),d}function r(s){for(var o;s.hasNode(o=e.uniqueId("_root")););return o}return Qv}var ex,SR;function ate(){if(SR)return ex;SR=1;var e=dt();ex=t;function t(n,r,s){var o={},l;e.forEach(s,function(c){for(var d=n.parent(c),h,f;d;){if(h=n.parent(d),h?(f=o[h],o[h]=d):(f=l,l=d),f&&f!==d){r.setEdge(f,d);return}d=h}})}return ex}var tx,_R;function ote(){if(_R)return tx;_R=1;var e=dt(),t=Jee(),n=Qee(),r=rte(),s=ste(),o=ate(),l=hr().Graph,c=fn();tx=d;function d(g){var v=c.maxRank(g),N=h(g,e.range(1,v+1),"inEdges"),k=h(g,e.range(v-1,-1,-1),"outEdges"),x=t(g);p(g,x);for(var j=Number.POSITIVE_INFINITY,b,_=0,E=0;E<4;++_,++E){f(_%2?N:k,_%4>=2),x=c.buildLayerMatrix(g);var R=n(g,x);R<j&&(E=0,b=e.cloneDeep(x),j=R)}p(g,b)}function h(g,v,N){return e.map(v,function(k){return s(g,k,N)})}function f(g,v){var N=new l;e.forEach(g,function(k){var x=k.graph().root,j=r(k,x,N,v);e.forEach(j.vs,function(b,_){k.node(b).order=_}),o(k,N,j.vs)})}function p(g,v){e.forEach(v,function(N){e.forEach(N,function(k,x){g.node(k).order=x})})}return tx}var nx,ER;function ite(){if(ER)return nx;ER=1;var e=dt(),t=hr().Graph,n=fn();nx={positionX:N,findType1Conflicts:r,findType2Conflicts:s,addConflict:l,hasConflict:c,verticalAlignment:d,horizontalCompaction:h,alignCoordinates:g,findSmallestWidthAlignment:p,balance:v};function r(j,b){var _={};function E(R,C){var A=0,U=0,L=R.length,F=e.last(C);return e.forEach(C,function(O,I){var B=o(j,O),M=B?j.node(B).order:L;(B||O===F)&&(e.forEach(C.slice(U,I+1),function($){e.forEach(j.predecessors($),function(P){var G=j.node(P),K=G.order;(K<A||M<K)&&!(G.dummy&&j.node($).dummy)&&l(_,P,$)})}),U=I+1,A=M)}),C}return e.reduce(b,E),_}function s(j,b){var _={};function E(C,A,U,L,F){var O;e.forEach(e.range(A,U),function(I){O=C[I],j.node(O).dummy&&e.forEach(j.predecessors(O),function(B){var M=j.node(B);M.dummy&&(M.order<L||M.order>F)&&l(_,B,O)})})}function R(C,A){var U=-1,L,F=0;return e.forEach(A,function(O,I){if(j.node(O).dummy==="border"){var B=j.predecessors(O);B.length&&(L=j.node(B[0]).order,E(A,F,I,U,L),F=I,U=L)}E(A,F,A.length,L,C.length)}),A}return e.reduce(b,R),_}function o(j,b){if(j.node(b).dummy)return e.find(j.predecessors(b),function(_){return j.node(_).dummy})}function l(j,b,_){if(b>_){var E=b;b=_,_=E}var R=j[b];R||(j[b]=R={}),R[_]=!0}function c(j,b,_){if(b>_){var E=b;b=_,_=E}return e.has(j[b],_)}function d(j,b,_,E){var R={},C={},A={};return e.forEach(b,function(U){e.forEach(U,function(L,F){R[L]=L,C[L]=L,A[L]=F})}),e.forEach(b,function(U){var L=-1;e.forEach(U,function(F){var O=E(F);if(O.length){O=e.sortBy(O,function(P){return A[P]});for(var I=(O.length-1)/2,B=Math.floor(I),M=Math.ceil(I);B<=M;++B){var $=O[B];C[F]===F&&L<A[$]&&!c(_,F,$)&&(C[$]=F,C[F]=R[F]=R[$],L=A[$])}}})}),{root:R,align:C}}function h(j,b,_,E,R){var C={},A=f(j,b,_,R),U=R?"borderLeft":"borderRight";function L(I,B){for(var M=A.nodes(),$=M.pop(),P={};$;)P[$]?I($):(P[$]=!0,M.push($),M=M.concat(B($))),$=M.pop()}function F(I){C[I]=A.inEdges(I).reduce(function(B,M){return Math.max(B,C[M.v]+A.edge(M))},0)}function O(I){var B=A.outEdges(I).reduce(function($,P){return Math.min($,C[P.w]-A.edge(P))},Number.POSITIVE_INFINITY),M=j.node(I);B!==Number.POSITIVE_INFINITY&&M.borderType!==U&&(C[I]=Math.max(C[I],B))}return L(F,A.predecessors.bind(A)),L(O,A.successors.bind(A)),e.forEach(E,function(I){C[I]=C[_[I]]}),C}function f(j,b,_,E){var R=new t,C=j.graph(),A=k(C.nodesep,C.edgesep,E);return e.forEach(b,function(U){var L;e.forEach(U,function(F){var O=_[F];if(R.setNode(O),L){var I=_[L],B=R.edge(I,O);R.setEdge(I,O,Math.max(A(j,F,L),B||0))}L=F})}),R}function p(j,b){return e.minBy(e.values(b),function(_){var E=Number.NEGATIVE_INFINITY,R=Number.POSITIVE_INFINITY;return e.forIn(_,function(C,A){var U=x(j,A)/2;E=Math.max(C+U,E),R=Math.min(C-U,R)}),E-R})}function g(j,b){var _=e.values(b),E=e.min(_),R=e.max(_);e.forEach(["u","d"],function(C){e.forEach(["l","r"],function(A){var U=C+A,L=j[U],F;if(L!==b){var O=e.values(L);F=A==="l"?E-e.min(O):R-e.max(O),F&&(j[U]=e.mapValues(L,function(I){return I+F}))}})})}function v(j,b){return e.mapValues(j.ul,function(_,E){if(b)return j[b.toLowerCase()][E];var R=e.sortBy(e.map(j,E));return(R[1]+R[2])/2})}function N(j){var b=n.buildLayerMatrix(j),_=e.merge(r(j,b),s(j,b)),E={},R;e.forEach(["u","d"],function(A){R=A==="u"?b:e.values(b).reverse(),e.forEach(["l","r"],function(U){U==="r"&&(R=e.map(R,function(I){return e.values(I).reverse()}));var L=(A==="u"?j.predecessors:j.successors).bind(j),F=d(j,R,_,L),O=h(j,R,F.root,F.align,U==="r");U==="r"&&(O=e.mapValues(O,function(I){return-I})),E[A+U]=O})});var C=p(j,E);return g(E,C),v(E,j.graph().align)}function k(j,b,_){return function(E,R,C){var A=E.node(R),U=E.node(C),L=0,F;if(L+=A.width/2,e.has(A,"labelpos"))switch(A.labelpos.toLowerCase()){case"l":F=-A.width/2;break;case"r":F=A.width/2;break}if(F&&(L+=_?F:-F),F=0,L+=(A.dummy?b:j)/2,L+=(U.dummy?b:j)/2,L+=U.width/2,e.has(U,"labelpos"))switch(U.labelpos.toLowerCase()){case"l":F=U.width/2;break;case"r":F=-U.width/2;break}return F&&(L+=_?F:-F),F=0,L}}function x(j,b){return j.node(b).width}return nx}var rx,TR;function lte(){if(TR)return rx;TR=1;var e=dt(),t=fn(),n=ite().positionX;rx=r;function r(o){o=t.asNonCompoundGraph(o),s(o),e.forEach(n(o),function(l,c){o.node(c).x=l})}function s(o){var l=t.buildLayerMatrix(o),c=o.graph().ranksep,d=0;e.forEach(l,function(h){var f=e.max(e.map(h,function(p){return o.node(p).height}));e.forEach(h,function(p){o.node(p).y=d+f/2}),d+=f+c})}return rx}var sx,CR;function cte(){if(CR)return sx;CR=1;var e=dt(),t=Wee(),n=Hee(),r=Gee(),s=fn().normalizeRanks,o=Kee(),l=fn().removeEmptyRanks,c=Yee(),d=Xee(),h=Zee(),f=ote(),p=lte(),g=fn(),v=hr().Graph;sx=N;function N(V,X){var Y=X&&X.debugTiming?g.time:g.notime;Y("layout",function(){var Z=Y(" buildLayoutGraph",function(){return L(V)});Y(" runLayout",function(){k(Z,Y)}),Y(" updateInputGraph",function(){x(V,Z)})})}function k(V,X){X(" makeSpaceForEdgeLabels",function(){F(V)}),X(" removeSelfEdges",function(){q(V)}),X(" acyclic",function(){t.run(V)}),X(" nestingGraph.run",function(){c.run(V)}),X(" rank",function(){r(g.asNonCompoundGraph(V))}),X(" injectEdgeLabelProxies",function(){O(V)}),X(" removeEmptyRanks",function(){l(V)}),X(" nestingGraph.cleanup",function(){c.cleanup(V)}),X(" normalizeRanks",function(){s(V)}),X(" assignRankMinMax",function(){I(V)}),X(" removeEdgeLabelProxies",function(){B(V)}),X(" normalize.run",function(){n.run(V)}),X(" parentDummyChains",function(){o(V)}),X(" addBorderSegments",function(){d(V)}),X(" order",function(){f(V)}),X(" insertSelfEdges",function(){H(V)}),X(" adjustCoordinateSystem",function(){h.adjust(V)}),X(" position",function(){p(V)}),X(" positionSelfEdges",function(){D(V)}),X(" removeBorderNodes",function(){K(V)}),X(" normalize.undo",function(){n.undo(V)}),X(" fixupEdgeLabelCoords",function(){P(V)}),X(" undoCoordinateSystem",function(){h.undo(V)}),X(" translateGraph",function(){M(V)}),X(" assignNodeIntersects",function(){$(V)}),X(" reversePoints",function(){G(V)}),X(" acyclic.undo",function(){t.undo(V)})}function x(V,X){e.forEach(V.nodes(),function(Y){var Z=V.node(Y),ee=X.node(Y);Z&&(Z.x=ee.x,Z.y=ee.y,X.children(Y).length&&(Z.width=ee.width,Z.height=ee.height))}),e.forEach(V.edges(),function(Y){var Z=V.edge(Y),ee=X.edge(Y);Z.points=ee.points,e.has(ee,"x")&&(Z.x=ee.x,Z.y=ee.y)}),V.graph().width=X.graph().width,V.graph().height=X.graph().height}var j=["nodesep","edgesep","ranksep","marginx","marginy"],b={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},_=["acyclicer","ranker","rankdir","align"],E=["width","height"],R={width:0,height:0},C=["minlen","weight","width","height","labeloffset"],A={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},U=["labelpos"];function L(V){var X=new v({multigraph:!0,compound:!0}),Y=J(V.graph());return X.setGraph(e.merge({},b,W(Y,j),e.pick(Y,_))),e.forEach(V.nodes(),function(Z){var ee=J(V.node(Z));X.setNode(Z,e.defaults(W(ee,E),R)),X.setParent(Z,V.parent(Z))}),e.forEach(V.edges(),function(Z){var ee=J(V.edge(Z));X.setEdge(Z,e.merge({},A,W(ee,C),e.pick(ee,U)))}),X}function F(V){var X=V.graph();X.ranksep/=2,e.forEach(V.edges(),function(Y){var Z=V.edge(Y);Z.minlen*=2,Z.labelpos.toLowerCase()!=="c"&&(X.rankdir==="TB"||X.rankdir==="BT"?Z.width+=Z.labeloffset:Z.height+=Z.labeloffset)})}function O(V){e.forEach(V.edges(),function(X){var Y=V.edge(X);if(Y.width&&Y.height){var Z=V.node(X.v),ee=V.node(X.w),ne={rank:(ee.rank-Z.rank)/2+Z.rank,e:X};g.addDummyNode(V,"edge-proxy",ne,"_ep")}})}function I(V){var X=0;e.forEach(V.nodes(),function(Y){var Z=V.node(Y);Z.borderTop&&(Z.minRank=V.node(Z.borderTop).rank,Z.maxRank=V.node(Z.borderBottom).rank,X=e.max(X,Z.maxRank))}),V.graph().maxRank=X}function B(V){e.forEach(V.nodes(),function(X){var Y=V.node(X);Y.dummy==="edge-proxy"&&(V.edge(Y.e).labelRank=Y.rank,V.removeNode(X))})}function M(V){var X=Number.POSITIVE_INFINITY,Y=0,Z=Number.POSITIVE_INFINITY,ee=0,ne=V.graph(),se=ne.marginx||0,pe=ne.marginy||0;function ke(ae){var fe=ae.x,me=ae.y,he=ae.width,ge=ae.height;X=Math.min(X,fe-he/2),Y=Math.max(Y,fe+he/2),Z=Math.min(Z,me-ge/2),ee=Math.max(ee,me+ge/2)}e.forEach(V.nodes(),function(ae){ke(V.node(ae))}),e.forEach(V.edges(),function(ae){var fe=V.edge(ae);e.has(fe,"x")&&ke(fe)}),X-=se,Z-=pe,e.forEach(V.nodes(),function(ae){var fe=V.node(ae);fe.x-=X,fe.y-=Z}),e.forEach(V.edges(),function(ae){var fe=V.edge(ae);e.forEach(fe.points,function(me){me.x-=X,me.y-=Z}),e.has(fe,"x")&&(fe.x-=X),e.has(fe,"y")&&(fe.y-=Z)}),ne.width=Y-X+se,ne.height=ee-Z+pe}function $(V){e.forEach(V.edges(),function(X){var Y=V.edge(X),Z=V.node(X.v),ee=V.node(X.w),ne,se;Y.points?(ne=Y.points[0],se=Y.points[Y.points.length-1]):(Y.points=[],ne=ee,se=Z),Y.points.unshift(g.intersectRect(Z,ne)),Y.points.push(g.intersectRect(ee,se))})}function P(V){e.forEach(V.edges(),function(X){var Y=V.edge(X);if(e.has(Y,"x"))switch((Y.labelpos==="l"||Y.labelpos==="r")&&(Y.width-=Y.labeloffset),Y.labelpos){case"l":Y.x-=Y.width/2+Y.labeloffset;break;case"r":Y.x+=Y.width/2+Y.labeloffset;break}})}function G(V){e.forEach(V.edges(),function(X){var Y=V.edge(X);Y.reversed&&Y.points.reverse()})}function K(V){e.forEach(V.nodes(),function(X){if(V.children(X).length){var Y=V.node(X),Z=V.node(Y.borderTop),ee=V.node(Y.borderBottom),ne=V.node(e.last(Y.borderLeft)),se=V.node(e.last(Y.borderRight));Y.width=Math.abs(se.x-ne.x),Y.height=Math.abs(ee.y-Z.y),Y.x=ne.x+Y.width/2,Y.y=Z.y+Y.height/2}}),e.forEach(V.nodes(),function(X){V.node(X).dummy==="border"&&V.removeNode(X)})}function q(V){e.forEach(V.edges(),function(X){if(X.v===X.w){var Y=V.node(X.v);Y.selfEdges||(Y.selfEdges=[]),Y.selfEdges.push({e:X,label:V.edge(X)}),V.removeEdge(X)}})}function H(V){var X=g.buildLayerMatrix(V);e.forEach(X,function(Y){var Z=0;e.forEach(Y,function(ee,ne){var se=V.node(ee);se.order=ne+Z,e.forEach(se.selfEdges,function(pe){g.addDummyNode(V,"selfedge",{width:pe.label.width,height:pe.label.height,rank:se.rank,order:ne+ ++Z,e:pe.e,label:pe.label},"_se")}),delete se.selfEdges})})}function D(V){e.forEach(V.nodes(),function(X){var Y=V.node(X);if(Y.dummy==="selfedge"){var Z=V.node(Y.e.v),ee=Z.x+Z.width/2,ne=Z.y,se=Y.x-ee,pe=Z.height/2;V.setEdge(Y.e,Y.label),V.removeNode(X),Y.label.points=[{x:ee+2*se/3,y:ne-pe},{x:ee+5*se/6,y:ne-pe},{x:ee+se,y:ne},{x:ee+5*se/6,y:ne+pe},{x:ee+2*se/3,y:ne+pe}],Y.label.x=Y.x,Y.label.y=Y.y}})}function W(V,X){return e.mapValues(e.pick(V,X),Number)}function J(V){var X={};return e.forEach(V,function(Y,Z){X[Z.toLowerCase()]=Y}),X}return sx}var ax,AR;function ute(){if(AR)return ax;AR=1;var e=dt(),t=fn(),n=hr().Graph;ax={debugOrdering:r};function r(s){var o=t.buildLayerMatrix(s),l=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(s.nodes(),function(c){l.setNode(c,{label:c}),l.setParent(c,"layer"+s.node(c).rank)}),e.forEach(s.edges(),function(c){l.setEdge(c.v,c.w,{},c.name)}),e.forEach(o,function(c,d){var h="layer"+d;l.setNode(h,{rank:"same"}),e.reduce(c,function(f,p){return l.setEdge(f,p,{style:"invis"}),p})}),l}return ax}var ox,RR;function dte(){return RR||(RR=1,ox="0.8.5"),ox}var ix,MR;function hte(){return MR||(MR=1,ix={graphlib:hr(),layout:cte(),debug:ute(),util:{time:fn().time,notime:fn().notime},version:dte()}),ix}var fte=hte();const $R=Tb(fte),nc=240,xL=130,pb=Ua*2+qx+K$,pte=72,ii=pb+pte,id=24,bL=Ua*2+id,Ld=ii;function kL(e,t){var r;let n=nc;for(const s of e)n=Math.max(n,((r=t.get(s.id))==null?void 0:r.width)??nc);return n}const Pd=420,NL=1;function mte(e,t,n,r){return Math.min(NL,n/Math.max(1,e),r/Math.max(1,t))}function Ih(e){var n;return((n=e.data)==null?void 0:n.sessionId)??"_default"}function Oh(e,t=()=>!0){const n=new Map;for(const r of e){if(!t(r))continue;const s=Ih(r),o=n.get(s);o?o.push(r):n.set(s,[r])}return n}function gte(e,t){return((t==null?void 0:t.get(e))??0)>0?Pd:0}function yte(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function Dd(e,t){const n=t.get(e);return{w:(n==null?void 0:n.width)??nc,h:(n==null?void 0:n.height)??xL}}function rc(e,t,n){const r=Dd(e,t);return{w:r.w+gte(e,n),h:Math.max(r.h,yte(e,n))}}function wte(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function vte(e,t,n){const r=Oh(e,s=>!t.has(s.id)&&n(s.id)!=null);if(r.size===0)return e;for(const s of r.values())s.sort((o,l)=>o.id.localeCompare(l.id));return e.map(s=>{var h;if(t.has(s.id)||n(s.id))return s;const o=r.get(Ih(s));if(!o)return s;const l=(h=s.data)==null?void 0:h.parentId,c=o.find(f=>f.id===l)??o[0],d=n(c.id);return{...s,position:{x:s.position.x+d.x-c.position.x,y:s.position.y+d.y-c.position.y}}})}function xte(e,t,n,r,s,o,l){const c=_=>rc(_,r,o),d=_=>n.get(_)??t.get(_),h=_=>{const{w:E,h:R}=Dd(_,r);return{cw:E,ch:R}},f=l!=null&&l.width>0&&l.height>0,p=Oh(e,_=>d(_.id)!=null),g=new Set;for(const[_,E]of p)E.every(R=>s.has(R.id)&&!n.has(R.id))&&g.add(_);const v=new Map,N=[];for(const _ of e){const E=d(_.id);if(!E)continue;const{w:R,h:C}=c(_.id),A=Ih(_);g.has(A)?(v.get(A)??v.set(A,[]).get(A)).push(_):N.push({x:E.x,y:E.y,w:R,h:C,...h(_.id)})}if(v.size===0||f&&N.length===0)return[];const k=Ld,x=(_,E,R,C)=>N.some(A=>_<A.x+A.w+pb&&A.x<_+R+pb&&E<A.y+A.h+k&&A.y<E+C+k),j=kL(e,r),b=[];for(const _ of[...v.keys()].sort()){const E=v.get(_);let R=1/0,C=1/0,A=-1/0,U=-1/0,L=-1/0,F=-1/0;for(const G of E){const K=d(G.id),{w:q,h:H}=c(G.id),{cw:D,ch:W}=h(G.id);R=Math.min(R,K.x),C=Math.min(C,K.y),A=Math.max(A,K.x+q),U=Math.max(U,K.y+H),L=Math.max(L,K.x+D),F=Math.max(F,K.y+W)}const O=A-R,I=U-C,B=[...new Set(N.map(G=>Math.round(G.x)))].sort((G,K)=>G-K),M=B.length?B:[R],$=[0,...N.map(G=>G.y+G.h+k)].sort((G,K)=>G-K);let P=null;if(f){let G=1/0,K=1/0,q=-1/0,H=-1/0;for(const Y of N)G=Math.min(G,Y.x),K=Math.min(K,Y.y),q=Math.max(q,Y.x+Y.cw),H=Math.max(H,Y.y+Y.ch);const D=(Y,Z)=>{const ee=l.width/(Math.max(q,Y+L-R)-Math.min(G,Y)+Pd),ne=l.height/(Math.max(H,Z+F-C)-Math.min(K,Z));return[Math.min(NL,ee,ne),Math.min(ee,ne),Math.max(ee,ne)]},W=(Y,Z)=>{for(let ee=0;ee<Y.length;ee++){if(Y[ee]>Z[ee]+1e-9)return!0;if(Y[ee]<Z[ee]-1e-9)return!1}return!1},J=Math.round(q+Pd+j),V=[...new Set([...$,K])].sort((Y,Z)=>Y-Z);let X=null;for(const Y of[...M,J])for(const Z of V){if(x(Y,Z,O,I))continue;const ee=D(Y,Z);(X===null||W(ee,X))&&(X=ee,P={x:Y,y:Z})}P&&P.x===R&&P.y===C&&(P=null)}else e:for(const G of M)for(const K of $){if(K>=C)break;if(!x(G,K,O,I)){P={x:G,y:K};break e}}if(P){const G=P.x-R,K=P.y-C;for(const q of E){const H=d(q.id);t.set(q.id,{x:H.x+G,y:H.y+K})}b.push(_)}for(const G of E){const K=d(G.id),{w:q,h:H}=c(G.id);N.push({x:K.x,y:K.y,w:q,h:H,...h(G.id)})}}return b}function bte(e,t,n,r,s,o){const l=g=>rc(g,r,s),c=new Map(e.map(g=>[g.id,Ih(g)])),d=[],h=e.map(g=>({id:g.id,pos:n.get(g.id)??t.get(g.id)})).filter(g=>g.pos!=null).sort((g,v)=>g.pos.y-v.pos.y||g.pos.x-v.pos.x||g.id.localeCompare(v.id)),f=g=>(o==null?void 0:o.has(g))===!0&&!n.has(g);for(const{id:g,pos:v}of h){if(!f(g))continue;const{w:N,h:k}=l(g);d.push({x:v.x,y:v.y,w:N,h:k,sid:c.get(g)??"_default"})}const p=[];for(const{id:g,pos:v}of h){if(f(g))continue;const{w:N,h:k}=l(g),x=c.get(g)??"_default";if(n.has(g)){d.push({x:v.x,y:v.y,w:N,h:k,sid:x});continue}let j=v.y;for(let b=0;b<d.length+1;b++){const _=d.find(E=>{const R=E.sid===x?id:bL,C=E.sid===x?id:Ld;return v.x<E.x+E.w+R&&E.x<v.x+N+R&&j<E.y+E.h+C&&E.y<j+k+C});if(!_)break;j=_.y+_.h+(_.sid===x?id:Ld)}j!==v.y&&(t.set(g,{x:v.x,y:j}),p.push(g)),d.push({x:v.x,y:j,w:N,h:k,sid:x})}return p}function kte(e,t,n,r,s,o=!1,l){const d=bL+1,h=Ld+1,f=8,p=1.75,g=200,v=.7,N=.01,k=I=>rc(I,r,l),x=I=>n.get(I)??t.get(I),j=Oh(e,I=>x(I.id)!=null),b=[],_=new Set,E=new Set,R=s.size===0;for(const I of[...j.keys()].sort()){const B=j.get(I);let M=1/0,$=1/0,P=-1/0,G=-1/0,K=!1;for(const W of B){const J=x(W.id),{w:V,h:X}=k(W.id);M=Math.min(M,J.x),$=Math.min($,J.y),P=Math.max(P,J.x+V),G=Math.max(G,J.y+X),n.has(W.id)&&(K=!0)}const q=P-M,H=G-$;E.add(I);const D=s.get(I);D&&(q>D.w+f||H>D.h+f)&&_.add(I),s.set(I,{w:q,h:H}),b.push({sid:I,members:B.map(W=>W.id),x:M,y:$,w:q,h:H,anchored:K,mass:1})}for(const I of[...s.keys()])E.has(I)||s.delete(I);if(o||R)return[];let C=!1;for(let I=0;I<b.length&&!C;I++)for(let B=I+1;B<b.length;B++){const M=b[I],$=b[B];if(!(M.anchored&&$.anchored)&&Math.abs(M.x+M.w/2-($.x+$.w/2))<(M.w+$.w)/2+d&&Math.abs(M.y+M.h/2-($.y+$.h/2))<(M.h+$.h)/2+h){C=!0;break}}if(_.size===0&&!C)return[];if(_.size>0)for(const I of b)_.has(I.sid)&&(I.mass=8);else for(const I of b)I.mass=Math.max(1,I.w*I.h/(nc*xL));const A=new Map(b.map(I=>[I.sid,I.x])),U=new Map(b.map(I=>[I.sid,I.y])),L=new Map(b.map(I=>[I.sid,Math.min(0,I.x)])),F=new Map(b.map(I=>[I.sid,Math.min(0,I.y)]));for(let I=0;I<g;I++){const B=new Map,M=new Map;let $=0;for(let P=0;P<b.length;P++)for(let G=P+1;G<b.length;G++){const K=b[P],q=b[G];if(K.anchored&&q.anchored)continue;const H=K.x+K.w/2,D=K.y+K.h/2,W=q.x+q.w/2,J=q.y+q.h/2,V=(K.w+q.w)/2+d-Math.abs(H-W),X=(K.h+q.h)/2+h-Math.abs(D-J);if(V<=0||X<=0)continue;const Y=(Be,We)=>!Be.anchored&&!(We<0&&Be.x<=L.get(Be.sid)),Z=(Be,We)=>!Be.anchored&&!(We<0&&Be.y<=F.get(Be.sid)),ee=(Be,We,He)=>{const rt=Be===We,lt=rt?K.sid<q.sid?-1:1:Math.sign(Be-We);return He(K,lt)||He(q,-lt)?lt:rt&&(He(K,-lt)||He(q,lt))?-lt:0},ne=ee(H,W,Y),se=ee(D,J,Z),pe=ne!==0,ke=se!==0;if(!pe&&!ke)continue;const ae=pe&&(!ke||V*p<X),[fe,me,he,ge]=ae?[ne,V,B,Y]:[se,X,M,Z],ue=ge(K,fe),be=ge(q,-fe),oe=K.mass,je=q.mass,$e=ue?be?je/(oe+je):1:0,Oe=be?ue?oe/(oe+je):1:0,Ue=me*v;he.set(K.sid,(he.get(K.sid)??0)+fe*Ue*$e),he.set(q.sid,(he.get(q.sid)??0)-fe*Ue*Oe),$+=Ue}for(const P of b)P.anchored||(P.x=Math.max(L.get(P.sid),P.x+(B.get(P.sid)??0)),P.y=Math.max(F.get(P.sid),P.y+(M.get(P.sid)??0)));if($<N)break}const O=[];for(const I of b){const B=I.x-A.get(I.sid),M=I.y-U.get(I.sid);if(!(Math.abs(B)<1&&Math.abs(M)<1)){for(const $ of I.members){if(n.has($))continue;const P=t.get($);P&&t.set($,{x:P.x+B,y:P.y+M})}O.push(I.sid)}}return O}function Nte(e,t,n,r,s,o){const l=new $R.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const c=e.filter(j=>!s.has(j)),d=new Set(c);for(const j of c){const{w:b,h:_}=rc(j,r,o);l.setNode(j,{width:b,height:_})}for(const j of t)d.has(j.source)&&d.has(j.target)&&l.setEdge(j.source,j.target);$R.layout(l);const h=new Map;let f=1/0,p=1/0,g=-1/0,v=-1/0;for(const j of c){const b=l.node(j);if(!b)continue;const{w:_,h:E}=Dd(j,r),R=rc(j,r,o),C=b.x-R.w/2,A=b.y-R.h/2;h.set(j,{x:C,y:A}),C<f&&(f=C),A<p&&(p=A),C+_>g&&(g=C+_),A+E>v&&(v=A+E)}if(Number.isFinite(f)&&Number.isFinite(p))for(const[j,b]of h)h.set(j,{x:b.x-f,y:b.y-p});const N=Number.isFinite(g)?g-f:0,k=Number.isFinite(v)?v-p:0;let x=null;for(const j of e){const b=s.get(j);if(!b)continue;const{w:_,h:E}=Dd(j,r);x=x===null?{minX:b.x,minY:b.y,maxX:b.x+_,maxY:b.y+E}:{minX:Math.min(x.minX,b.x),minY:Math.min(x.minY,b.y),maxX:Math.max(x.maxX,b.x+_),maxY:Math.max(x.maxY,b.y+E)}}return{positions:h,width:N,height:k,pinnedBox:x}}function jL(e,t,n){const r=n.direction??"LR",s=n.pinned??new Map,o=n.measured??new Map,l=n.lanes,c=Oh(e);return{laid:Array.from(c.keys()).sort().map(f=>({sid:f,...Nte(c.get(f).map(p=>p.id),t,r,o,s,l)})),gap:kL(e,o)}}const SL=e=>e.reduce((t,n)=>Math.max(t,n.width),0)+Pd,jte=e=>e.reduce((t,n)=>t+n.height,0)+ii*Math.max(0,e.length-1);function mb(e,t,n,r){const s=d=>{const h=[[]];let f=0;for(const p of e)f>0&&f+p.height>d&&(h.push([]),f=0),h[h.length-1].push(p),f+=p.height+ii;return h},o=[];for(let d=0;d<e.length;d++){let h=-ii;for(let f=d;f<e.length;f++)o.push(h+=e[f].height+ii)}o.sort((d,h)=>d-h);const l=d=>{let h=0,f=o.length-1;for(;h<f;){const p=h+f>>1;s(o[p]).length<=d?f=p:h=p+1}return s(o[h])};let c=[e];if(n>0&&r>0){const d=f=>mte(f.reduce((p,g)=>p+SL(g),0)+t*(f.length-1),Math.max(...f.map(jte)),n,r);let h=d(c);for(let f=2;f<=e.length;f++){const p=l(f),g=d(p);g>h+1e-9&&(h=g,c=p)}}return c}function Ste(e,t,n,r,s){if(!(r.width>0&&r.height>0&&s.width>0&&s.height>0))return!1;const{laid:o,gap:l}=jL(e,t,n);return o.length<2?!1:mb(o,l,r.width,r.height).length!==mb(o,l,s.width,s.height).length}function _te(e,t,n={}){const r=n.pinned??new Map,{laid:s,gap:o}=jL(e,t,n),l=mb(s,o,n.availableWidth??0,n.availableHeight??0),c=new Map;let d=0;for(const h of l){const f=SL(h);let p=0;for(const{positions:g,height:v,pinnedBox:N}of h){for(const[x,j]of g)c.set(x,{x:j.x+d,y:j.y+p});let k=p+v;N&&N.maxY>k&&N.minX<d+f&&d<N.maxX&&(k=N.maxY),p=k+ii}d+=f+o}return e.map(h=>{const f=r.get(h.id);if(f)return{...h,position:f};const p=c.get(h.id);return p?{...h,position:p}:h})}function ld(e,t,n){return!t.has(e)||n.has(e)}function Ete(e,t,n,r){return!t.has(e)&&ld(e,n,r)}function Tte(e,t,n){const r={x:0,y:0};return t.set(e,r),n.add(e),r}function IR(e,t,n,r){n.set(e,t),r.delete(e)}const Cte=300,OR=130,Ate=160,LR=new WeakMap;function Rte(e,t){let n=LR.get(e);(!n||n.revision!==e.revision||n.open!==t)&&(n={revision:e.revision,open:t,byId:new Map,branches:FU(e.agents.values())},LR.set(e,n));const{byId:r,branches:s}=n;return o=>{let l=r.get(o.id);if(!l){const c=o.kind==="root"?s.get(o.sessionId):void 0;l=c?{...o,onOpenContext:t,branch:c}:{...o,onOpenContext:t},r.set(o.id,l)}return l}}function Y0(e){const t=new Map;for(const n of e.agents.values())n.tools.length>0&&t.set(n.id,Math.min(4,n.tools.length));return t}function Mte(e,t){const n=l=>{var c;return((c=l.data)==null?void 0:c.sessionId)??l.id},r=new Map;for(const l of e){const c=n(l),d=l.position.x+(l.width??nc),h=r.get(c);h?(h.minX=Math.min(h.minX,l.position.x),h.maxX=Math.max(h.maxX,d),h.minY=Math.min(h.minY,l.position.y)):r.set(c,{minX:l.position.x,maxX:d,minY:l.position.y})}const s=[];for(const[l,c]of[...r].sort((d,h)=>d[1].minX-h[1].minX)){const d=s[s.length-1];d&&c.minX<d.maxX?(d.maxX=Math.max(d.maxX,c.maxX),d.sessions.push({sid:l,top:c.minY})):s.push({maxX:c.maxX,sessions:[{sid:l,top:c.minY}]})}const o=new Map;for(const l of s)for(const{sid:c}of l.sessions.sort((d,h)=>d.top-h.top))o.set(c,o.size);return e.slice().sort((l,c)=>o.get(n(l))-o.get(n(c))||t(l)-t(c)||l.position.y-c.position.y||l.position.x-c.position.x)}function $te(e,t){var r;let n=0;for(let s=t.parentId;s!=null&&n<e.agents.size;s=(r=e.agents.get(s))==null?void 0:r.parentId)n++;return n}function Ite(e,t,n,r,s,o,l,c,d,h,f,p,g,v,N,k,x,j,b,_){var G,K,q,H;const E=[],R=[],C=Rte(e,j);for(const D of e.agents.values()){if(!x.has(D.id))continue;const W=D.exitAt!=null,J=k!=null&&!k.has(D.id),V=[W?"rf-exiting":"",J?"rf-spotlit-out":"",N.has(D.id)?"rf-selected":""].filter(Boolean).join(" ")||void 0,X=o.get(D.id);if(E.push({id:D.id,type:"agent",position:{x:0,y:0},data:C(D),className:V,ariaLabel:tU(D,t,N.has(D.id)),...X?{width:X.width,height:X.height}:null}),D.parentId&&x.has(D.parentId)){const ee=xd(D.sessionId),ne=W,se=N.size>0&&(N.has(D.id)||N.has(D.parentId)),pe=k!=null&&!k.has(D.id)&&!k.has(D.parentId),ke=D.state==="active"?2:1.5,ae=se?ke+1.5:ke,fe=ne?.2:pe?.12:1,me=["sess-edge",D.state==="active"?"sess-live":"sess-idle",ne?"rf-edge-exiting":"",se?"rf-edge-selected":""].filter(Boolean).join(" ");R.push({id:`e:${D.parentId}->${D.id}`,source:D.parentId,target:D.id,animated:(D.state==="active"||se)&&!ne,type:"smoothstep",style:{"--session-hue":ee,strokeWidth:`calc(${ae}px * var(--edge-k, 1))`,opacity:fe,transition:"var(--edge-transition)"},className:me})}const Y=D.kind==="root"?th(D):null,Z=Y?C$(D.sessionId,Y.at):null;if(Y&&Z&&!$U(Z)){const ee=s0(D.id),ne=xd(D.sessionId),se=o.get(ee);E.push({id:ee,type:"recapNote",position:{x:0,y:0},data:{sessionId:D.sessionId,parentId:D.id,recap:Y,noteKey:Z,hue:ne},className:J?"rf-spotlit-out":void 0,selectable:!1,focusable:!1,ariaLabel:`Claude Code's recap for ${D.label}`,...se?{width:se.width,height:se.height}:null}),R.push({id:`e:recap:${D.id}`,source:ee,target:D.id,type:"recapTie",className:"recap-edge",focusable:!1,style:{"--session-hue":ne}})}}const A=Y0(e),U=_.size>0&&!(d&&b);U||_.clear();const L=`${g}#lanes:${wte(A)}${U?"#held":""}`,F=new Set(E.filter(D=>D.type==="recapNote").map(D=>D.id));for(const D of Array.from(f.keys()))b&&PU(D)&&!F.has(D)&&!s.has(D)&&(f.delete(D),p.delete(D));const O=E.filter(D=>Ete(D.id,s,f,p));if(O.length>0||L!==v.current){if(O.length>0){for(const W of O)_.delete(W.id);const D=vte(_te(E,R,{direction:"LR",pinned:s,measured:o,availableWidth:n,availableHeight:r,lanes:A}),s,W=>ld(W,f,p)?void 0:f.get(W));for(const W of D)ld(W.id,f,p)&&IR(W.id,W.position,f,p);xte(E,f,s,o,new Set(O.filter(W=>W.type!=="recapNote").map(W=>W.id)),A,{width:n,height:r});for(const W of O){if(W.type!=="recapNote")continue;const J=(G=W.data)==null?void 0:G.parentId;if(!J)continue;const V=s.get(J)??(ld(J,f,p)?void 0:f.get(J));if(!V)continue;const X=((K=o.get(W.id))==null?void 0:K.width)??Cte,Y=((q=o.get(W.id))==null?void 0:q.height)??OR,Z=((H=o.get(J))==null?void 0:H.height)??OR;IR(W.id,{x:V.x-Ate-X,y:V.y+(Z-Y)/2},f,p)}}bte(E,f,s,o,A,U?_:void 0),v.current=L}const I=kte(E,f,s,o,l,!d||h,A);I.length>0&&c(I);const B=GZ(e.agents.values());b&&Gu(f,B),Gu(p,B),b&&Gu(s,B),Gu(o,VZ(e.agents.values()));const M=[];let $=!1;for(const D of E){let W=s.get(D.id)??f.get(D.id);W||(W=Tte(D.id,f,p),$=!0),M.push({...D,position:W})}return $&&(v.current=""),{nodes:Mte(M,D=>{if(D.type==="recapNote")return-1;const W=e.agents.get(D.id);return W?$te(e,W):0}),edges:R}}function Ote(e){return e.slice().sort((t,n)=>t.y-n.y||t.x-n.x)}function Lte(e,t,n){var l;if(e.length===0)return null;const r=Ote(e),s=t?r.findIndex(c=>c.id===t):-1,o=s===-1?n===1?0:r.length-1:(s+n+r.length)%r.length;return((l=r[o])==null?void 0:l.id)??null}const Pte=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Backspace"]);function Dte(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:Pte.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const Fte=new Set(["","BODY","HTML","#DOCUMENT"]);function Bte(e){return!e||hc(e)?!1:!Fte.has(String(e.tagName??"").toUpperCase())}const _L="react-flow__node";function X0(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,_L))===!0}function EL(e){try{const t=document.querySelector(`.${_L}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}let Ga=null,ei=null;const gb=new Set,yb=()=>{for(const e of gb)e()},qte=e=>(gb.add(e),()=>{gb.delete(e)}),PR=()=>Ga,Ute=90;function TL(e){!ei||e!=null&&ei.at.id!==e||(clearTimeout(ei.timer),ei=null)}function CL(e,t,n="pointer"){TL();const r={id:e,anchor:t,by:n};if(Ga||n==="focus"){Ga=r,yb();return}ei={at:r,timer:setTimeout(()=>{ei=null,Ga=r,yb()},Ute)}}function la(e){TL(e),!(!Ga||e!=null&&Ga.id!==e)&&(Ga=null,yb())}function zte({agentFor:e,recapFor:t,labelFor:n,bounds:r}){const s=y.useSyncExternalStore(qte,PR,PR),o=s?e(s.id):void 0,l=s&&!o?t(s.id):void 0,c=s!=null&&(!o&&!l||!s.anchor.isConnected);return y.useEffect(()=>{c&&s&&la(s.id)},[c,s]),!s||c?null:o?a.jsx(Hte,{a:o,anchor:s.anchor,parentLabel:o.parentId?n(o.parentId):void 0,bounds:r},s.id):l?a.jsx(Wte,{r:l,anchor:s.anchor,bounds:r},s.id):null}function AL(e,t){const n=y.useRef(null),r=y.useCallback(()=>{const s=n.current;if(!s||!e.isConnected)return;const o=m0(e.getBoundingClientRect(),{width:s.offsetWidth,height:s.offsetHeight},t());s.style.top=`${o.top}px`,s.style.left=`${o.left}px`,s.style.maxHeight=o.maxHeight==null?"":`${o.maxHeight}px`,s.dataset.side=o.side},[e,t]);return y.useLayoutEffect(()=>{r()}),n}function Wte({r:e,anchor:t,bounds:n}){const r=AL(t,n),s=_i(3e4),o=Sd(e.recap.at,s);return Lt.createPortal(a.jsxs("div",{ref:r,className:"ap-peek node-peek recap-peek",role:"tooltip",id:"node-peek",style:{"--session-hue":e.hue},children:[a.jsxs("div",{className:"node-peek-head",children:[a.jsxs("span",{className:"recap-peek-mark",children:[a.jsx(Vl,{}),"recap"]}),a.jsx("span",{className:"node-peek-time",title:o.title,children:o.label})]}),e.sessionLabel&&a.jsx("div",{className:"node-peek-kind",children:a.jsxs("span",{children:["Claude Code's recap of ",e.sessionLabel]})}),a.jsx("p",{className:"recap-peek-text",children:e.recap.text}),a.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for its details"})]}),document.body)}function Hte({a:e,anchor:t,parentLabel:n,bounds:r}){const s=AL(t,r),o=_i(1e3),l=n0(e.sessionName,e.sessionTitle),c=e.toolErrorCount??0,d=e.tools.filter(N=>!N.endedAt).length,h=pn(e,o).total,f=e.usage.inputTokens+e.usage.outputTokens,p=e.kind==="root"&&Sn(e.waiting),g=e.kind==="root"?"session":n?`subagent of ${n}`:"subagent",v=[`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,d>0?`${d} in-flight`:null,f>0?`${it(f)} tok`:null,h>0?`${qe(h)}${Hl(e,o)>0?"+":""}`:null].filter(Boolean).join(" · ");return Lt.createPortal(a.jsxs("div",{ref:s,className:"ap-peek node-peek",role:"tooltip",id:"node-peek",children:[a.jsxs("div",{className:"node-peek-head",children:[a.jsx("span",{className:"node-peek-name",children:e.label}),a.jsxs("span",{className:"node-peek-time",children:[e.synthetic?"≥ ":"",mi(e.startedAt,e.endedAt,o)]})]}),a.jsxs("div",{className:"node-peek-kind",children:[a.jsxs("span",{className:"node-peek-state","data-kind":Lx(e.state),children:[a.jsx(P$,{kind:Lx(e.state)}),fi(e.state)]}),a.jsx("span",{children:g}),e.model?a.jsx("span",{children:oa(e.model)}):null]}),e.kind==="root"&&l.face&&a.jsx("p",{className:"node-peek-title",children:l.face}),e.kind==="root"&&e.waiting&&a.jsxs("p",{className:`node-peek-wait${p?" warn":""}`,children:[p&&a.jsx(i0,{}),a.jsx("span",{children:t0(e.waiting)}),a.jsx("b",{children:mi(e.waiting.since,void 0,o)})]}),a.jsxs("p",{className:"node-peek-facts",children:[v,c>0&&a.jsxs("span",{className:"node-peek-failed",children:[" · ",c," failed"]})]}),e.branch&&e.branch.total>0&&a.jsx("p",{className:"node-peek-branch",children:A$(e.branch)}),a.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for details"})]}),document.body)}function Vte(e){const t=e.minZoom??ZX,n=e.maxZoom??JX,r=e.fill??.9,s=e.insets.left,o=e.insets.top,l=Math.max(1,e.pane.width-e.insets.left-e.insets.right),c=Math.max(1,e.pane.height-e.insets.top-e.insets.bottom),d=e.context,h=e.anchor,f=Math.min(l/Math.max(1,d.width),c/Math.max(1,d.height))*r,p=Math.max(t,Math.min(n,f)),g=(v,N,k,x,j,b)=>{let _=v+(N-x*p)/2-k*p;const E=j*p+_,R=(j+b)*p+_;return b*p<=N?E<v?_+=v-E:R>v+N&&(_-=R-(v+N)):_+=v-E,_};return{x:g(s,l,d.x,d.width,h.x,h.width),y:g(o,c,d.y,d.height,h.y,h.height),zoom:p}}function Gte(e){let t=1/0,n=1/0,r=-1/0,s=-1/0;for(const o of e)t=Math.min(t,o.x),n=Math.min(n,o.y),r=Math.max(r,o.x+o.width),s=Math.max(s,o.y+o.height);return Number.isFinite(t)?{x:t,y:n,width:r-t,height:s-n}:null}function _n(e){const t=y.useRef(e);return t.current=e,t}const wb=80,vb=.86;function RL(e){if(!e)return 0;const t=e.getBoundingClientRect();let n=t.right;for(const r of document.querySelectorAll(".sysdetail:not(.leaving), .usage-panel:not(.leaving)")){const s=r.getBoundingClientRect();s.width>0&&s.left>t.left&&(n=Math.min(n,s.left))}return Math.max(0,t.right-n)}function Kte({canvasRef:e,canvasSize:t,machinePhase:n,usagePhase:r,usagePanelOpen:s,detailShown:o}){const[l,c]=y.useState(0);y.useEffect(()=>{const p=RL(e.current);c(g=>Math.abs(g-p)>40?p:g)},[n,r,s,o,t.w]);const d=_n(l),h=t.w>0?Math.max(0,(t.w-l-wb*2)*vb):0,f=t.h>0?Math.max(0,(t.h-wb*2)*vb):0;return{railInsetRef:d,availableWidth:h,availableHeight:f}}const ML=420;function Yte(){const e=ki(),t=Nt(),n=y.useCallback((d,h)=>{if($x({durationMs:h,documentHidden:document.hidden})){e.setViewport(d,{duration:h});return}const{d3Zoom:f,d3Selection:p}=t.getState(),g=p==null?void 0:p.property("__zoom");if(f&&p&&g&&g.k>0&&d.zoom>0){f.transform(p,g.scale(d.zoom/g.k).translate((d.x-g.x)/d.zoom,(d.y-g.y)/d.zoom));return}e.setViewport(d,{duration:0})},[e,t]),r=y.useRef(null),s=y.useRef(0),o=y.useRef(0),l=y.useCallback((d,h)=>{const f=++s.current;return n(d,h),o.current=Date.now(),r.current=$x({durationMs:h,documentHidden:document.hidden})?{target:d,until:Date.now()+h+60}:null,f},[n]),c=y.useCallback((d=500)=>{const h=wb,f=1,p=.2,g=vb;try{const v=document.querySelector(".canvas-wrap"),N=Array.from(document.querySelectorAll(".react-flow__node")).filter($=>$.offsetWidth>0);if(!v||N.length===0)return;const k=v.getBoundingClientRect(),x=e.getViewport();if(!Number.isFinite(x.zoom)||x.zoom<=0)return;const j=$=>($-k.left-x.x)/x.zoom,b=$=>($-k.top-x.y)/x.zoom,_=N.map($=>$.getBoundingClientRect()),E=Math.min(..._.map($=>j($.left))),R=Math.max(..._.map($=>j($.right))),C=Math.min(..._.map($=>b($.top))),A=Math.max(..._.map($=>b($.bottom))),U=R-E,L=A-C;if(!(U>0&&L>0))return;const F=RL(v),O=$=>Math.max(p,Math.min(f,(k.width-F-h*2)/(U+$)*g,(k.height-h*2)/L*g)),I=XX(O(ML),O(0)),B={x:h-E*I,y:Math.max(h,(k.height-L*I)/2)-C*I,zoom:I},M=l(B,d);window.setTimeout(()=>{var $;try{if((($=r.current)==null?void 0:$.target)===B&&(r.current=null),s.current!==M)return;const P=e.getViewport();(Math.abs(P.zoom-I)>.01||Math.abs(P.x-B.x)>2)&&n(B,0)}catch{}},d+60)}catch{}},[e,n,l]);return y.useEffect(()=>{const d=()=>{if(!document.hidden)return;const h=r.current;if(r.current=null,!(!h||Date.now()>h.until)){try{n(h.target,0)}catch{}o.current=Date.now()}};return document.addEventListener("visibilitychange",d),()=>document.removeEventListener("visibilitychange",d)},[n]),{applyViewport:n,moveCamera:l,fitLeft:c,cameraEpochRef:s,lastFitTimeRef:o}}const Xte=450;function Zte({canvasRef:e,stateRef:t,measuredRef:n,nodesRef:r,railInsetRef:s,moveCamera:o,disableAutoFit:l,lastFocusRef:c,focusAgentRef:d,selectAgent:h,primarySelectedIdRef:f}){const p=y.useCallback(N=>{var U;const k=e.current,x=t.current.agents.get(N);if(!k||!x)return;const j=Y0(t.current),b=(L,F)=>{const O=n.current.get(L.id);if(!O)return null;const I=F&&j.has(L.id)?ML:0;return{x:L.position.x,y:L.position.y,width:O.width+I,height:O.height}},_=r.current.find(L=>L.id===N),E=_?b(_,!1):null;if(!E)return;const R=[];for(const L of r.current){if(L.type!=="agent"&&L.type!=="recapNote"||((U=L.data)==null?void 0:U.sessionId)!==x.sessionId)continue;const F=b(L,L.type==="agent");F&&R.push(F)}const C=k.getBoundingClientRect(),A=Vte({pane:{width:C.width,height:C.height},insets:{top:56,left:72,bottom:32,right:s.current+32},context:Gte(R)??E,anchor:E});la(),l(),c.current={id:N,at:Date.now()},o(A,Xte)},[o,l]);d.current=p;const g=y.useCallback(N=>{const k=r.current.filter(_=>_.type==="agent"),x=Lte(k.map(_=>({id:_.id,x:_.position.x,y:_.position.y})),f.current,N),j=x?k.find(_=>_.id===x):void 0;if(!j)return;const b=X0(document.activeElement);h(j.id,!1),window.setTimeout(()=>{try{p(j.id)}catch{}b&&EL(j.id)},30)},[h,p]),v=y.useCallback(N=>{h(N,!1),window.setTimeout(()=>{try{p(N)}catch{}},60)},[h,p]);return{focusAgent:p,stepAgent:g,focusSession:v}}function Jte({nodesRef:e,stateRef:t,canvasRef:n,railInsetRef:r}){const s=y.useCallback(d=>{const h=e.current.find(f=>f.id===d&&f.type==="agent");return h?h.data:void 0},[]),o=y.useCallback(d=>{var h;return(h=t.current.agents.get(d))==null?void 0:h.label},[]),l=y.useCallback(d=>{var p;const h=e.current.find(g=>g.id===d&&g.type==="recapNote");if(!h)return;const f=h.data;return{recap:f.recap,hue:f.hue,sessionLabel:(p=t.current.agents.get(f.parentId))==null?void 0:p.label}},[]),c=y.useCallback(()=>{var f;const d=(f=n.current)==null?void 0:f.getBoundingClientRect(),h=document.documentElement;return d?{width:d.right-r.current,height:d.bottom}:{width:h.clientWidth,height:h.clientHeight}},[]);return{peekAgent:s,peekLabel:o,peekRecap:l,peekBounds:c}}function Qte(e){const t=new Set(e.pins),n=new Map,r=new Map;for(const[s,o]of e.positions)n.set(s,o),t.has(s)&&r.set(s,o);return{positions:n,pinned:r,restored:new Set(n.keys())}}function DR(e){return Object.entries(e??{}).filter(([,t])=>t&&typeof t.x=="number"&&typeof t.y=="number")}function ene(e){const t={positions:[],pins:[]};if(!e)return t;let n;try{n=JSON.parse(e)}catch{return t}if(!n||typeof n!="object")return t;if(!("v"in n)){const s=DR(n);return{positions:s,pins:s.map(([o])=>o)}}const r=n;return{positions:DR(r.positions),pins:Array.isArray(r.pins)?r.pins:[]}}function tne(e,t){const n={};for(const[r,s]of e)n[r]=s;for(const[r,s]of t)n[r]=s;return JSON.stringify({v:2,positions:n,pins:Array.from(t.keys())})}function nne(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}return!(typeof(t==null?void 0:t.width)=="number"&&typeof(t==null?void 0:t.height)=="number")||!(t.width>0&&t.height>0)?null:{width:t.width,height:t.height}}const Z0="agent-dag.layout",J0="agent-dag.layoutFrame",Q0="agent-dag.viewport";function rne(){return ene(Qe(Z0))}function sc(e,t){Ze(Z0,tne(e,t))}function sne(){return nne(Qe(J0))}function $L(e){Ze(J0,JSON.stringify(e))}function ane(){return y8(Qe(Q0))}function one(e){Ze(Q0,JSON.stringify(e))}function IL(){hs(Z0),hs(Q0),hs(J0)}function ine(e){const t=y.useState(()=>Qte(rne()))[0],n=y.useRef(t.pinned),r=y.useRef(t.positions),s=y.useRef(new Set),o=y.useRef(""),[l,c]=y.useState(0),d=y.useState(sne)[0],h=y.useRef(d),f=y.useCallback(()=>{n.current.clear(),r.current.clear(),o.current="",IL(),c(p=>p+1),window.setTimeout(()=>{sc(r.current,n.current),h.current&&$L(h.current),e(500)},80)},[e]);return{restoredLayout:t,pinnedRef:n,positionsRef:r,provisionalRef:s,lastLayoutSigRef:o,layoutEpoch:l,setLayoutEpoch:c,lastLayoutFrameRef:h,handleRelayout:f}}function lne(e,t){const{positionsRef:n,pinnedRef:r}=t,s=y.useRef(null);y.useEffect(()=>(s.current!=null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{sc(n.current,r.current)},1500),()=>{s.current!=null&&window.clearTimeout(s.current)}),[e])}function cne({nodes:e,edges:t,settled:n,dragging:r,availableWidth:s,availableHeight:o,layout:l,camera:c,rf:d,measuredRef:h,stateRef:f,lastFocusRef:p,primarySelectedIdRef:g,focusAgentRef:v,autoFitDisabledRef:N}){const{lastLayoutFrameRef:k,pinnedRef:x,positionsRef:j,provisionalRef:b,lastLayoutSigRef:_,setLayoutEpoch:E}=l,{applyViewport:R,fitLeft:C,cameraEpochRef:A,lastFitTimeRef:U}=c;y.useEffect(()=>{if(!n||r)return;const L={width:s,height:o};if(!(L.width>0&&L.height>0))return;const F=k.current;if(k.current=L,$L(L),!F||F.width===L.width&&F.height===L.height)return;const O={direction:"LR",pinned:x.current,measured:h.current,lanes:Y0(f.current)};if(!Ste(e,t,O,F,L))return;const I=p.current&&Date.now()-p.current.at<1500?p.current.id:null,B=I??g.current,M=B?x.current.get(B)??j.current.get(B):void 0;for(const $ of Array.from(j.current.keys()))x.current.has($)||j.current.delete($);b.current.clear(),_.current="",E($=>$+1),window.setTimeout(()=>{if(sc(j.current,x.current),N.current){if(I){v.current(I);return}const $=B?x.current.get(B)??j.current.get(B):void 0;if(M&&$&&($.x!==M.x||$.y!==M.y)){const P=d.getViewport();A.current+=1,R({x:P.x-($.x-M.x)*P.zoom,y:P.y-($.y-M.y)*P.zoom,zoom:P.zoom},0),U.current=Date.now()}return}C(500)},80)},[s,o,n,r,C,d,R])}function une(e,t,n,r,s){const o=[];for(const l of e)!ah(l,t)||n.has(l.id)||o.push(l.id+(l.parentId?`>${l.parentId}`:""));return o.sort(),`${o.join("|")}#sv${r}.${s}`}const ek="agent-dag.removedNodes";function dne(e){try{const t=JSON.parse((e==null?void 0:e.getItem(ek))??"[]");return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function FR(e,t){try{e==null||e.setItem(ek,JSON.stringify([...t]))}catch{}}function OL(e,t){const n=new Map(e.map(o=>[o.id,o.parentId])),r=new Set(t),s=o=>{if(r.has(o))return!0;const l=new Set([o]);let c=n.get(o);for(;c&&!l.has(c);){if(r.has(c))return r.add(o),!0;l.add(c),c=n.get(c)}return!1};return o=>s(o.id)||s(o.sessionId??o.id)}function hne(e,t){if(t.size===0)return new Set;const n=[...e],r=OL(n,t);return new Set(n.filter(r).map(s=>s.id))}function fne(e,t,n){const r=c=>({id:c.id,parentId:c.data.parentId,sessionId:c.data.sessionId}),s=OL(e.map(r),n),o=e.filter(c=>!s(r(c))),l=new Set(o.map(c=>c.id));return{nodes:o,edges:t.filter(c=>l.has(c.source)&&l.has(c.target))}}function pne(e,t){let n=null;for(const r of t)e.has(r)&&(n??(n=new Set(e)),n.delete(r));return n??e}function mne(e,t){return t.size===0?[]:[...e].filter(n=>t.has(n.id)).map(n=>n.id)}function gne(e){let t=e.kind==="subagent"?e.startedAt:-1/0;const n=e.tools[e.tools.length-1];n&&n.startedAt>t&&(t=n.startedAt);const r=e.prompts[e.prompts.length-1];return r&&r.at>t&&(t=r.at),e.lastOutputAt!=null&&e.lastOutputAt>t&&(t=e.lastOutputAt),t}function yne(e,t,n){let r=null;for(const s of t)e.has(s)||(r??(r=new Map(e)),r.set(s,n));for(const s of e.keys())t.has(s)||(r??(r=new Map(e)),r.delete(s));return r??e}function wne(e,t,n,r){if(n.size===0)return[];let s=1/0;for(const l of r.values())l<s&&(s=l);const o=new Set;for(const l of t){const c=e.get(l);if(!c)continue;const d=gne(c);if(d<=s)continue;const h=[],f=new Set,p=v=>{var N;for(let k=v;k&&!f.has(k);k=(N=e.get(k))==null?void 0:N.parentId)f.add(k),n.has(k)&&h.push(k)};p(c.id),p(c.sessionId);let g=-1/0;for(const v of h)g=Math.max(g,r.get(v)??1/0);if(d>g)for(const v of h)o.add(v)}return[...o]}const LL="sessionGroup";function vne(e,t){var r,s;if(e.type===LL)return"transparent";if(Sn((r=e.data)==null?void 0:r.waiting))return t("--warn");if(e.type==="recapNote")return t("--muted");const n=(s=e.data)==null?void 0:s.state;return t(n==="err"?"--err":n==="active"?"--inflight":"--ok")}const Ku=Ua;function xne(e){const t=new Map;for(const r of e){const s=r.data;if(!(s!=null&&s.sessionId)||s.exitAt!=null)continue;const o=r.width,l=r.height;if(o==null||l==null)continue;const c=r.position.x,d=r.position.y,h=c+o,f=d+l,p=t.get(s.sessionId);p?(p.minX=Math.min(p.minX,c),p.minY=Math.min(p.minY,d),p.maxX=Math.max(p.maxX,h),p.maxY=Math.max(p.maxY,f)):t.set(s.sessionId,{minX:c,minY:d,maxX:h,maxY:f})}const n=[];for(const[r,s]of t){const o=s.maxX-s.minX+Ku*2,l=s.maxY-s.minY+Ku*2;n.push({id:`group:${r}`,type:LL,position:{x:s.minX-Ku,y:s.minY-Ku},data:{sessionId:r,w:o,h:l},width:o,height:l,style:{width:o,height:l},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return n}function bne(e,t){if(!t||!e.agents.get(t))return null;const r=new Set([t]);let s=t;for(;s;){const l=e.agents.get(s);if(!(l!=null&&l.parentId)||r.has(l.parentId))break;r.add(l.parentId),s=l.parentId}let o=!0;for(;o;){o=!1;for(const l of e.agents.values())l.parentId&&r.has(l.parentId)&&!r.has(l.id)&&(r.add(l.id),o=!0)}return r}function kne(e,t){const n=new Set;for(const r of t){const s=bne(e,r);if(s)for(const o of s)n.add(o)}return n.size>0?n:null}function Nne({stateRef:e,now:t,removedAgentIds:n,sizeVersion:r,domSizeVersion:s}){return y.useMemo(()=>une(e.current.agents.values(),t,n,r,s),[e.current,e.current.revision,t,r,s,n])}function jne({stateRef:e,now:t,availableWidth:n,availableHeight:r,layout:s,measuredRef:o,onBubble:l,settled:c,dragging:d,layoutSig:h,selectedIds:f,openContext:p,historyReplayed:g,removedNodes:v,removedAgentIds:N,dragTick:k,dragPatchRef:x,dragMoveTick:j}){const{pinnedRef:b,positionsRef:_,provisionalRef:E,lastLayoutSigRef:R,restoredLayout:C,layoutEpoch:A}=s,U=y.useMemo(()=>kne(e.current,f),[e.current,e.current.revision,f]),L=y.useMemo(()=>{const P=FH(e.current,t);for(const G of N)P.delete(G);return P},[e.current,e.current.revision,t,N]),F=y.useRef(new Map),O=DU(),{nodes:I,edges:B}=y.useMemo(()=>{const P=Ite(e.current,t,n,r,b.current,o.current,F.current,l,c,d,_.current,E.current,h,R,f,U,L,p,g,C.restored);return fne(P.nodes,P.edges,v)},[e.current,e.current.revision,t,n,r,c,d,h,f,U,L,p,k,O,v,A,g]),M=y.useMemo(()=>xne(I),[I]),$=y.useMemo(()=>{const P=[...M,...I],G=x.current;return!G||G.size===0?P:P.map(K=>{const q=G.get(K.id);return q?{...K,position:q}:K})},[M,I,j]);return{spotlightSet:U,visibleAgentIds:L,nodes:I,edges:B,allNodes:$}}function Sne(e,t,n){const r=e.x*t.zoom+t.x,s=e.y*t.zoom+t.y,o=(e.x+e.width)*t.zoom+t.x,l=(e.y+e.height)*t.zoom+t.y;return o>0&&r<n.width&&l>0&&s<n.height}function _ne({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 r=!1;for(const s of n)if(r=!0,Sne(s,t,e))return!1;return r}function Ene({layoutSig:e,rf:t,stateRef:n,measuredRef:r,pinnedRef:s,positionsRef:o,paneSizeRef:l,lastInteractRef:c,autoFitDisabledRef:d,lastFitTimeRef:h,fitLeft:f}){const p=y.useRef(null),g=y.useRef("");y.useEffect(()=>{const v=setInterval(()=>{if(d.current||Date.now()-c.current<800)return;const N=n.current,k=Date.now(),x=[];for(const b of N.agents.values())ah(b,k)&&x.push({id:b.id});if(x.length===0)return;const j=[];for(const{id:b}of x){const _=r.current.get(b),E=s.current.get(b)??o.current.get(b);!_||!E||j.push({x:E.x,y:E.y,width:_.width,height:_.height})}_ne({pane:l.current,viewport:t.getViewport(),boxes:j})&&f(600)},1500);return()=>clearInterval(v)},[t]),y.useEffect(()=>{if(g.current===e)return;const v=g.current;if(g.current=e,!v||d.current)return;Date.now()-h.current>1200&&f(400),p.current&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{d.current||f(500)},280)},[e,t,f])}function Tne({stateRef:e,pinnedRef:t,positionsRef:n,canvasRef:r,clearSelection:s,primarySelectedId:o}){const[l,c]=y.useState(()=>dne(Ml())),[d,h]=y.useState(null),f=y.useMemo(()=>hne(e.current.agents.values(),l),[e.current,e.current.revision,l]),p=y.useCallback(j=>{const b=e.current.agents.get(j);b&&(c(_=>{const E=new Set(_);return E.add(j),FR(Ml(),E),E}),h({id:j,label:b.label}),t.current.delete(j),n.current.delete(j),s())},[s]),g=y.useCallback(()=>{o&&p(o)},[o,p]),v=d&&l.has(d.id)?d:null;y.useEffect(()=>{var j;d&&((j=r.current)==null||j.focus())},[d]);const N=y.useCallback(j=>{const b=[...j];c(_=>{const E=pne(_,b);return E!==_&&FR(Ml(),E),E})},[]),k=y.useCallback(()=>{N([...l]),h(null)},[N,l]),x=y.useCallback(()=>{c(new Set),h(null),hs(ek)},[]);return{removedNodes:l,lastRemoval:d,removedAgentIds:f,removeNode:p,removeSelectedNode:g,removalNotice:v,bringBack:N,bringBackAll:k,forgetRemovals:x}}function Cne({stateRef:e,waitingSessions:t,removedAgentIds:n,removedNodes:r,bringBack:s}){const o=y.useRef(new Map);y.useEffect(()=>{o.current=yne(o.current,r,Date.now());const l=[...mne(t,n),...wne(e.current.agents,n,r,o.current)];l.length>0&&s(l)},[t,n,r,s])}function Ane({waiting:e,running:t,connected:n=!0}){return{title:e>0?`(${e}) ${kt}`:kt,icon:n?e>0?"waiting":t>0?"running":"idle":"offline"}}const PL=Object.freeze({offline:"/state/favicon-error.svg",waiting:"/state/favicon-waiting.svg",running:"/state/favicon-syncing.svg",idle:"/favicon.svg"}),DL=Object.freeze({offline:"/state/favicon-error-32.png",waiting:"/state/favicon-waiting-32.png",running:"/state/favicon-syncing-32.png",idle:"/favicon.ico"}),Rne=Object.freeze([...new Set([...Object.values(PL),...Object.values(DL)])]),xb=new Map;function BR(e){return xb.get(e)??e}async function Mne(e,t=n=>fetch(n)){await Promise.all(e.map(async n=>{if(!xb.has(n))try{const r=await t(n),s=(r.headers.get("Content-Type")??"").split(";")[0].trim();if(!r.ok||!s.startsWith("image/"))return;xb.set(n,`data:${s};base64,${$ne(new Uint8Array(await r.arrayBuffer()))}`)}catch{}}))}function $ne(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function Ine({stateRef:e,waitingSessions:t,live:n}){const r=y.useMemo(()=>Gq(e.current.agents.values()),[e.current,e.current.revision]),s=y.useRef(null);y.useEffect(()=>{n&&Mne(Rne)},[n]),y.useEffect(()=>{const o=Ane({waiting:t.length,running:r,connected:n}),l=s.current;s.current=o,(l==null?void 0:l.title)!==o.title&&(document.title=o.title),(l==null?void 0:l.icon)!==o.icon&&FL(o.icon)},[t.length,r,n])}function FL(e){const t=document.querySelector('link[rel="icon"][type="image/svg+xml"]');t&&(t.href=BR(PL[e]));const n=document.querySelector('link[rel="icon"][sizes="32x32"]');n&&(n.href=BR(DL[e]))}const One=1200,Lne=1e3;function lx(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<One?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<Lne}function Pne({applyViewport:e,lastFitTimeRef:t,cameraEpochRef:n,disableAutoFit:r,markInteract:s,canvasRef:o,applyZoom:l}){const c=y.useState(()=>ane())[0];y.useEffect(()=>{if(!c)return;const N=window.setTimeout(()=>{try{e(c,0)}catch{}t.current=Date.now()},60);return()=>window.clearTimeout(N)},[e,c]);const d=y.useRef(null),h=y.useRef(0),f=y.useCallback(()=>{h.current=Date.now()},[]),p=y.useCallback(N=>({hasSourceEvent:!!N,at:Date.now(),lastDeckFitAt:t.current,lastCanvasInputAt:h.current}),[]);return{restoredViewport:c,markCanvasInput:f,onMoveStart:N=>{la(),lx(p(N))&&(n.current+=1),lx(p(N))&&r()},onMove:(N,k)=>{var x;s(),lx(p(N))&&r(),(x=o.current)==null||x.style.setProperty("--zoom",String(k.zoom)),l(k.zoom)==="detail"&&la(),d.current&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>one(k),250)}}}function Dne({clearSelection:e,selectAgent:t,detailOpen:n,setDetailOpen:r,detailShown:s,focusAgent:o,draggingRef:l,lodRef:c}){return{onNodeClick:(v,N)=>{if(N.type==="sessionGroup"){e();return}const k=N.type==="recapNote"?N.data.parentId:N.id;t(k,v.shiftKey,!1),!v.shiftKey&&(n&&r(!1),s?window.setTimeout(()=>{try{o(k)}catch{}},80):o(k))},onPaneClick:()=>{la(),e()},onNodeDoubleClick:(v,N)=>{if(N.type!=="agent"&&N.type!=="recapNote")return;const k=N.type==="recapNote"?N.data.parentId:N.id;t(k,!1),window.setTimeout(()=>{try{o(k)}catch{}},80)},onNodeMouseEnter:(v,N)=>{N.type!=="agent"&&N.type!=="recapNote"||l.current||c.current==null||c.current==="detail"||CL(N.id,v.currentTarget)},onNodeMouseLeave:(v,N)=>la(N.id)}}function Fne(){const e=y.useRef(null),t=y.useRef(null),[n,r]=y.useState({w:0,h:0});return y.useEffect(()=>{const s=t.current;if(!s||typeof ResizeObserver>"u")return;const o=new ResizeObserver(l=>{var d;const c=(d=l[0])==null?void 0:d.contentRect;c&&(e.current={width:c.width,height:c.height},r(h=>Math.abs(h.w-c.width)>40||Math.abs(h.h-c.height)>40?{w:c.width,h:c.height}:h))});return o.observe(s),e.current={width:s.clientWidth,height:s.clientHeight},r({w:s.clientWidth,h:s.clientHeight}),()=>o.disconnect()},[]),{canvasRef:t,canvasSize:n,paneSizeRef:e}}function Bne(e){const t=y.useRef(new Map),n=y.useRef(0),r=y.useCallback(c=>{const d=t.current;let h=!1;for(const f of c.nodeInternals.values()){const p=f.width,g=f.height;if(p==null||g==null)continue;const v=d.get(f.id);v?(Math.abs(v.height-g)>4||Math.abs(v.width-p)>4)&&(d.set(f.id,{width:p,height:g}),h=!0):(d.set(f.id,{width:p,height:g}),h=!0)}return h&&(n.current+=1),n.current},[]),s=Xe(r),[o,l]=y.useState(0);return y.useEffect(()=>{let c=0;const d=()=>{const f=t.current;let p=!1;for(const g of document.querySelectorAll(".react-flow__node[data-id]")){const v=g.getAttribute("data-id");if(!v)continue;const N=g.offsetWidth,k=g.offsetHeight;if(!N||!k)continue;const x=f.get(v);(!x||Math.abs(x.width-N)>4||Math.abs(x.height-k)>4)&&(f.set(v,{width:N,height:k}),p=!0)}p&&l(g=>g+1)};if(e.current)return;let h=0;return document.visibilityState==="hidden"?h=window.setTimeout(d,32):c=requestAnimationFrame(d),()=>{cancelAnimationFrame(c),window.clearTimeout(h)}}),{measuredRef:t,measuredVersionRef:n,sizeVersion:s,domSizeVersion:o}}function qne(){const[e,t]=y.useState(!1);return y.useEffect(()=>{const n=window.setTimeout(()=>t(!0),2500);return()=>window.clearTimeout(n)},[]),e}function Une(){const e=y.useRef(null);return y.useEffect(()=>{let t=-1/0;const n=()=>{t=performance.now()},r=s=>{e.current=performance.now()-t<250?s.target:null};return window.addEventListener("pointerdown",n,!0),window.addEventListener("focusin",r,!0),()=>{window.removeEventListener("pointerdown",n,!0),window.removeEventListener("focusin",r,!0)}},[]),e}function zne({pointerFocusRef:e,nodesRef:t,stateRef:n,primarySelectedIdRef:r,providersRef:s,soundOnRef:o,keyHelpOpenRef:l,modalOpenRef:c,waitingCursorRef:d,removeSelectedRef:h,activateSoundRef:f,clearSelection:p,selectAgent:g,focusAgent:v,stepAgent:N,focusSession:k,requestClear:x,handleRelayout:j,handleFit:b,togglePause:_,toggleSessionList:E,toggleAccountsPanel:R,setDetailOpen:C,setUsageHistoryOpen:A,setUsagePanelOpen:U,setMachinePanelOpen:L,setBrowserWatchOpen:F,setSoundMenuOpen:O,setKeyHelpOpen:I,setTheme:B}){y.useEffect(()=>{const M=$=>{var D,W;const P=$.target,G={tagName:P==null?void 0:P.tagName,isContentEditable:P==null?void 0:P.isContentEditable,role:(D=P==null?void 0:P.getAttribute)==null?void 0:D.call(P,"role"),type:P==null?void 0:P.type,pointerFocused:P!=null&&P===e.current};if($.key==="Escape"){const J=cU({overlayOpen:ds.depth()>0,typing:hc(G)});J==="dismiss"?ds.dismissTop():J==="blur"?P==null||P.blur():(Bte(G)&&(P==null||P.blur()),p());return}if(eh($))return;const K=X0(P)?(W=P==null?void 0:P.getAttribute)==null?void 0:W.call(P,"data-id"):null,q=K&&t.current.some(J=>J.id===K)?K:null,H=Dte($,q);if(H.kind==="activate"){$.preventDefault(),g(H.nodeId,H.additive);return}if(H.kind!=="node"){if(xU({key:$.key,sheetOpen:l.current,target:G})){$.repeat||I(!1);return}if(!(H.nodeId==null&&wU(G,$.key))&&!vU({key:$.key,modalOpen:k$({appModal:c.current,dialogDepth:ds.dialogDepth()}),sheetOpen:l.current})&&!($.repeat&&!/^[ jkJK]$/.test($.key))){if($.key===" "&&($.preventDefault(),$.repeat||_()),($.key==="c"||$.key==="C")&&x("shortcut"),($.key==="r"||$.key==="R")&&j(),($.key==="f"||$.key==="F")&&b(),($.key==="z"||$.key==="Z")&&r.current&&v(r.current),$.key==="Delete"&&h.current(),($.key==="l"||$.key==="L")&&E(),$.key==="d"||$.key==="D")if(r.current)C(J=>!J);else{const J=Ix(n.current.agents.values());J.length>0?k(J[0].id):N(1)}if(($.key==="h"||$.key==="H")&&A(J=>!J),($.key==="u"||$.key==="U")&&U(J=>!J),($.key==="a"||$.key==="A")&&s.current.claude&&R(),($.key==="j"||$.key==="J")&&N(1),($.key==="k"||$.key==="K")&&N(-1),$.key==="w"||$.key==="W"){const J=Vq(Ix(n.current.agents.values()),d.current);J&&(d.current=J.id,k(J.id))}($.key==="t"||$.key==="T")&&B(J=>J==="dark"?"light":"dark"),($.key==="m"||$.key==="M")&&s.current.claude&&o.current!==null&&f.current($.shiftKey),($.key==="s"||$.key==="S")&&L(J=>!J),($.key==="b"||$.key==="B")&&F(J=>!J),($.key==="v"||$.key==="V")&&s.current.claude&&o.current!==null&&O(J=>!J),$.key==="?"&&I(J=>!J)}}};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[x,j,b,p,g,N,k,v,_])}function Wne(){var e,t;return((t=(e=document.activeElement)==null?void 0:e.matches)==null?void 0:t.call(e,":focus-visible"))===!0}function Hne({sessionListShown:e,usageShown:t,machineShown:n,accountsShown:r,detailShown:s,primarySelectedId:o,canvasRef:l}){const c={sessionList:y.useRef(null),usage:y.useRef(null),accounts:y.useRef(null),machine:y.useRef(null)},d=h=>()=>{Wne()&&h()};return{toggles:c,sessionList:d(is(!e,c.sessionList)),usage:d(is(!t,c.usage)),machine:d(is(!n,c.machine)),accounts:d(is(!r,c.accounts)),detail:d(is(!s,()=>{var h,f;o&&EL(o),Tn(((h=document.activeElement)==null?void 0:h.tagName)??null)&&((f=l.current)==null||f.focus({preventScroll:!0}))}))}}function Vne({nodes:e,stateRef:t,pinnedRef:n,positionsRef:r,draggingRef:s,dragPatchRef:o,setDragging:l,setDragMoveTick:c,setDragTick:d,endBubble:h,markInteract:f,disableAutoFit:p,beginTrashDrag:g,trackTrashDrag:v,endTrashDrag:N,removeNode:k}){const x=y.useRef(null);return{onNodeDragStart:(E,R)=>{var C,A;if(la(),h(),s.current=!0,o.current=new Map,l(!0),g(R.type==="agent"?((C=t.current.agents.get(R.id))==null?void 0:C.label)??"":null),f(),p(),R.type==="sessionGroup"){const U=(A=R.data)==null?void 0:A.sessionId,L=new Map;if(U)for(const F of e){const O=F.data;(O==null?void 0:O.sessionId)===U&&L.set(F.id,{x:F.position.x,y:F.position.y})}x.current={start:{x:R.position.x,y:R.position.y},members:L};return}n.current.set(R.id,{x:R.position.x,y:R.position.y})},onNodeDrag:(E,R)=>{var C;if(f(),R.type==="agent"&&v(E),R.type==="sessionGroup"){const A=x.current;if(!A)return;const U=R.position.x-A.start.x,L=R.position.y-A.start.y;for(const[O,I]of A.members){const B={x:I.x+U,y:I.y+L};n.current.set(O,B),r.current.set(O,B)}const F=o.current;if(F){for(const[O,I]of A.members)F.set(O,{x:I.x+U,y:I.y+L});F.set(R.id,{x:R.position.x,y:R.position.y})}c(O=>O+1);return}n.current.set(R.id,{x:R.position.x,y:R.position.y}),r.current.set(R.id,{x:R.position.x,y:R.position.y}),(C=o.current)==null||C.set(R.id,{x:R.position.x,y:R.position.y}),c(A=>A+1)},onNodeDragStop:(E,R)=>{f();const C=N(E,R.type==="agent");if(s.current=!1,o.current=null,l(!1),d(A=>A+1),R.type==="sessionGroup"){const A=x.current;if(A){const U=R.position.x-A.start.x,L=R.position.y-A.start.y;for(const[F,O]of A.members){const I={x:O.x+U,y:O.y+L};n.current.set(F,I),r.current.set(F,I)}}x.current=null,sc(r.current,n.current),d(U=>U+1);return}if(n.current.set(R.id,{x:R.position.x,y:R.position.y}),r.current.set(R.id,{x:R.position.x,y:R.position.y}),C){k(R.id);return}sc(r.current,n.current)}}}function Gne(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const Kne={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent",zcode:"ZCode"};function Yne(e){const t=e.toLowerCase(),n=Ot(Kne,t);return n!==void 0?n:t?t[0].toUpperCase()+t.slice(1):""}function Xne(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Vle(e,t=[]){const n=t.length?Xne(t.map(Yne)):Gne(e);return n?`via ccusage · local ${n} logs`:"via ccusage · local agent logs"}function Zne(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 Jne(e,t){const n=t.prefs??fb,r=vi(n.done.level),s=vi(n["needs-input"].level),o=r===s?`${r}%`:`${r}% and ${s}%`,l=t.on?`Sound: on at ${o} — 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)",c=e.codex?`
95
-
96
- 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.`:"",d=t.on&&t.locked?`
97
-
98
- 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+c+d+`
99
-
100
- Click to set the volume and the sound of each tone, and to hear either one.`}function Qne(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."}}function ere(){return a.jsxs("div",{className:"empty-hero",children:[a.jsxs("div",{className:"orbit-stack","aria-hidden":!0,children:[a.jsx("div",{className:"core"}),a.jsxs("div",{className:"orbit r1",children:[a.jsx("span",{className:"dot"}),a.jsx("span",{className:"dot b"})]}),a.jsxs("div",{className:"orbit r2",children:[a.jsx("span",{className:"dot"}),a.jsx("span",{className:"dot b"})]}),a.jsxs("div",{className:"orbit r3",children:[a.jsx("span",{className:"dot"}),a.jsx("span",{className:"dot b"})]})]}),a.jsxs("h2",{children:["Too many ",kt," tabs are open"]}),a.jsxs("p",{children:["This browser keeps at most six live connections to one address, and other ",a.jsx("code",{children:kt})," tabs are holding them. Close one and this tab connects on its own."]})]})}function tre({live:e,everConnected:t,providers:n,workspace:r,onTour:s}){const o=!e;return a.jsxs("div",{className:"empty-hero",children:[a.jsxs("div",{className:"orbit-stack","aria-hidden":!0,children:[a.jsx("div",{className:"core"}),a.jsxs("div",{className:"orbit r1",children:[a.jsx("span",{className:"dot"}),a.jsx("span",{className:"dot b"})]}),a.jsxs("div",{className:"orbit r2",children:[a.jsx("span",{className:"dot"}),a.jsx("span",{className:"dot b"})]}),a.jsxs("div",{className:"orbit r3",children:[a.jsx("span",{className:"dot"}),a.jsx("span",{className:"dot b"})]})]}),o?a.jsxs(a.Fragment,{children:[a.jsx("h2",{children:t?"Disconnected from server":"Server unreachable"}),a.jsxs("p",{children:[t?"This page lost its connection to ":"This page cannot reach ",a.jsx("code",{children:kt}),". Check that it is still running in your terminal — the page picks up again on its own."]})]}):nre(n,r),!o&&a.jsx("button",{type:"button",className:"btn empty-tour",onClick:s,children:"Take the tour"}),!o&&a.jsx(Gl,{film:"tour"})]})}function nre(e,t){const n=Qne(t);return a.jsxs(a.Fragment,{children:[a.jsx("h2",{children:"Waiting for Claude Code or Codex"}),n.kind==="scoped"?a.jsxs("p",{children:[n.lead," ",a.jsx("code",{children:n.workspace}),n.tail]}):a.jsxs("p",{children:["Run ",a.jsx("code",{children:"claude"})," or ",a.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."]}),Zne(e).map(r=>a.jsx("p",{className:"hint-row",children:r.spans.map((s,o)=>s.code?a.jsx("code",{children:s.text},o):a.jsx("span",{children:s.text},o))},r.provider))]})}const rre=1;function sre(e){return{id:e.id,name:e.name,inputPreview:e.inputPreview,startedAt:e.startedAt,endedAt:e.endedAt,ok:e.ok,errorPreview:e.errorPreview,usage:e.usage}}function are(e,t,n){const r=e.agents.get(t);if(!r)return null;const s=[];for(const o of e.agents.values())o.sessionId===t&&s.push(o);return{schemaVersion:rre,exportedAt:n,sessionId:t,label:r.label,cwd:r.cwd,startedAt:r.startedAt,endedAt:r.endedAt,model:r.model,agents:s.map(o=>({id:o.id,kind:o.kind,label:o.label,parentId:o.parentId,state:o.state,startedAt:o.startedAt,endedAt:o.endedAt,model:o.model,cwd:o.cwd,usage:o.usage,prompts:o.prompts,tools:o.tools.map(sre)}))}}function ore(e,t){const n=(e||"session").replace(/[^a-z0-9._-]/gi,"_");return`${kt}-${n}-${c0(t,8)}.json`}const BL={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},ire={file:"M3.4 1.8h4.5l2.7 2.7v7.7H3.4z M7.9 1.8v2.7h2.7",shell:"M2.4 3.8 5.6 7l-3.2 3.2 M7.4 10.6h4.2",web:"M7 1.8a5.2 5.2 0 1 0 0 10.4A5.2 5.2 0 1 0 7 1.8z M1.8 7h10.4 M7 1.8c-1.5 1.4-2.3 3.1-2.3 5.2s.8 3.8 2.3 5.2c1.5-1.4 2.3-3.1 2.3-5.2S8.5 3.2 7 1.8z",agent:"M3.3 4.8h7.4a1.2 1.2 0 0 1 1.2 1.2v4.8a1.2 1.2 0 0 1-1.2 1.2H3.3a1.2 1.2 0 0 1-1.2-1.2V6a1.2 1.2 0 0 1 1.2-1.2z M7 4.8V2.4 M5.3 8.2h.01 M8.7 8.2h.01",task:"M2.2 4l1.2 1.2 2-2.2 M7.4 4.2h4.4 M2.2 9.4l1.2 1.2 2-2.2 M7.4 9.6h4.4",plan:"M7 1.8a5.2 5.2 0 1 0 0 10.4A5.2 5.2 0 1 0 7 1.8z M9 5 8 8 5 9l1-3z",mcp:"M5 1.8v2.6 M9 1.8v2.6 M3.6 4.4h6.8v2.2a3.4 3.4 0 0 1-6.8 0z M7 10v2.2",other:"M3.5 7h.01 M7 7h.01 M10.5 7h.01"};function lre({cat:e}){return a.jsx("svg",{className:"cat-glyph",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:ire[e]})})}const Fd={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},qL=M$;function cre({agent:e,now:t,onOpenTool:n,onShowSummary:r,onExportSession:s,onRemove:o}){var k;const l=`${e.synthetic?"≥ ":""}${mi(e.startedAt,e.endedAt,t)}`,c=pn(e),d=c.total>0,h=e.usage.inputTokens+e.usage.outputTokens,f=new Map;for(const[x,j]of e.toolCountByName??[]){const b=qL(x);f.set(b,(f.get(b)??0)+j)}const p=e.toolErrorCount??0,g=e.tools.filter(x=>!x.endedAt).length,v=Array.from(f.entries()).sort((x,j)=>j[1]-x[1]),N=f.has("mcp")?mz(((k=e.toolCountByName)==null?void 0:k.keys())??[]):null;return a.jsxs(a.Fragment,{children:[a.jsxs("header",{className:"detail-hero",children:[a.jsxs("div",{className:"hero-line",children:[a.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),a.jsx("h2",{className:"hero-title",title:e.cwd??e.label,children:e.label})]}),a.jsxs("div",{className:"hero-meta",children:[a.jsx("span",{className:"hero-meta-item",children:e.kind==="root"?"session":"subagent"}),a.jsx("span",{className:"hero-sep",children:"·"}),a.jsx("span",{className:"hero-meta-item",title:`started ${new Date(e.startedAt).toLocaleString()}`,children:l}),e.model&&(()=>{const x=y$(e);return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"hero-sep",children:"·"}),a.jsxs("span",{className:"model-chip","data-family":Jd(e.model),title:x.length>0?`${e.model}
101
- spend on this panel also covers:
102
- ${x.join(`
103
- `)}`:e.model,children:[oa(e.model),x.length>0?` +${x.length}`:""]})]})})()]}),d&&a.jsxs("div",{className:"hero-cost",children:[a.jsxs("div",{className:"hero-cost-headline",children:[a.jsx("span",{className:"hero-cost-value",children:qe(c.total)}),a.jsx("span",{className:"hero-cost-label",children:"spend"})]}),a.jsx(u0,{cost:c})]}),a.jsxs("div",{className:"hero-actions",children:[e.kind==="root"&&e.state==="done"&&r&&a.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>r(e.sessionId),title:"Reopen the end-of-session recap modal",children:"Show recap"}),s&&a.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>s(e.sessionId),title:"Download this session as JSON",children:"Export JSON"}),o&&a.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:o,title:e.kind==="root"?"Take this session's cards off the board (Delete). The session carries on; the session list (L) brings it back":"Take this card and the ones under it off the board (Delete). The session list (L) brings it back",children:"Remove from board"})]})]}),(()=>{const x=th(e);if(!x)return null;const j=Sd(x.at,t);return a.jsxs("section",{className:"detail-section",children:[a.jsxs("h3",{children:["Recap ",a.jsx("span",{className:"section-count",title:j.title,children:j.label})]}),a.jsx("p",{className:"detail-recap",children:x.text})]})})(),e.tools.length>0&&a.jsxs("section",{className:"detail-section",children:[a.jsx("h3",{children:"Activity"}),a.jsxs("div",{className:"activity-row",children:[a.jsxs("div",{className:"activity-counters",children:[a.jsxs("span",{className:"ac-item",children:[a.jsx("b",{children:e.toolCount})," calls"]}),g>0&&a.jsxs("span",{className:"ac-item ac-live",children:[a.jsx("b",{children:g})," live"]}),p>0&&a.jsxs("span",{className:"ac-item ac-err",children:[a.jsx("b",{children:p})," err"]})]}),a.jsx("div",{className:"cat-strip",children:v.map(([x,j])=>{const b=x==="mcp"?N:null,_=b==null?void 0:b.hue,E=`${j} ${Fd[x]} call${j===1?"":"s"}`;return a.jsxs("span",{className:`cat-chip cat-${x}${_!=null?" mcp-hue":""}`,style:_!=null?{"--mcp-hue":_}:void 0,title:b?`${E}, all to ${b.label}`:E,children:[a.jsx("span",{className:"cat-emoji","aria-hidden":!0,children:BL[x]}),a.jsx("span",{className:"cat-name",children:Fd[x]}),a.jsx("span",{className:"cat-count",children:j}),b&&a.jsx("span",{className:"cat-server",children:b.label})]},x)})})]})]}),h>0&&a.jsxs("section",{className:"detail-section",children:[a.jsx("h3",{children:"Tokens"}),a.jsxs("div",{className:"tokens-grid",children:[a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"in"}),a.jsx("b",{title:e.usage.inputTokens.toLocaleString(),children:it(e.usage.inputTokens)})]}),a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"out"}),a.jsx("b",{title:e.usage.outputTokens.toLocaleString(),children:it(e.usage.outputTokens)})]}),a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"cache r"}),a.jsx("b",{title:e.usage.cacheReadTokens.toLocaleString(),children:it(e.usage.cacheReadTokens)})]}),a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"cache c"}),a.jsx("b",{title:e.usage.cacheCreateTokens.toLocaleString(),children:it(e.usage.cacheCreateTokens)})]})]})]}),a.jsxs("section",{className:"detail-section",children:[a.jsx("h3",{children:"Identity"}),a.jsxs("div",{children:[e.cwd&&a.jsxs("div",{className:"row",children:[a.jsx("span",{className:"k",children:"cwd"}),a.jsx("span",{className:"v",title:e.cwd,children:e.cwd})]}),a.jsxs("div",{className:"row",children:[a.jsx("span",{className:"k",children:"session"}),a.jsxs("span",{className:"v",children:[e.sessionId.slice(0,12),"…"]})]}),e.parentId&&a.jsxs("div",{className:"row",children:[a.jsx("span",{className:"k",children:"parent"}),a.jsxs("span",{className:"v",children:[e.parentId.slice(0,12),"…"]})]})]})]}),e.prompts.length>0&&a.jsxs("section",{className:"detail-section",children:[a.jsxs("h3",{children:["Prompts ",a.jsx("span",{className:"section-count",children:t$(e.prompts).length})]}),a.jsx("div",{className:"prompts",children:ure(e.prompts).reverse().map(({pr:x,key:j})=>{const b=Sd(x.at,t),_=Qb(x.text);return _?a.jsxs("details",{className:"prompt-entry prompt-injected",children:[a.jsxs("summary",{children:[a.jsx("span",{className:"prompt-time",title:b.title,children:b.label}),a.jsx("span",{className:"prompt-injected-label",children:_.label})]}),_.detail&&a.jsx("div",{className:"prompt-injected-detail",children:_.detail})]},j):a.jsxs("div",{className:"prompt-entry",children:[a.jsx("div",{className:"prompt-time",title:b.title,children:b.label}),a.jsx("div",{className:"prompt-text",children:x.text})]},j)})})]}),a.jsxs("section",{className:"detail-section",children:[a.jsxs("h3",{children:["Tool calls ",a.jsx("span",{className:"section-count",children:e.tools.length})]}),e.tools.length===0&&a.jsx("div",{className:"empty",children:"No tool calls yet."}),a.jsx("div",{children:e.tools.slice().reverse().map(x=>a.jsx(hre,{t:x,onClick:()=>n(e.id,x.id)},x.id))})]})]})}function ure(e){const t=new Map;return e.map(n=>{const r=t.get(n.at)??0;return t.set(n.at,r+1),{pr:n,key:r===0?String(n.at):`${n.at}:${r}`}})}const dre={inflight:"in-flight",done:"done",err:"error"};function hre({t:e,onClick:t}){const n=e.endedAt==null?"inflight":e.ok===!1?"err":"done",r=v$(e,"…");return a.jsxs("button",{className:"tool clickable",title:e.inputPreview||e.name,onClick:t,children:[a.jsxs("span",{className:"name",children:[a.jsx("span",{className:`status-dot ${n}`,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:dre[n]}),e.name]}),a.jsx("span",{style:{color:"var(--muted)"},children:r})]})}function fre(e,t){const n=are(e,t,new Date().toISOString());if(!n)return;const r=JSON.stringify(n,null,2),s=new Blob([r],{type:"application/json"}),o=URL.createObjectURL(s),l=document.createElement("a");l.href=o,l.download=ore(n.label,t),document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(o),1e3)}function pre({selected:e,now:t,openTool:n,setSummaryFor:r,onClose:s,stateRef:o,removeSelectedNode:l}){return qt("detail-panel"),a.jsxs("aside",{className:"detail","aria-label":"Detail",children:[a.jsx("button",{type:"button",className:"glyph-btn detail-close",title:"Close panel","aria-label":"Close detail panel",onClick:s,children:"×"}),a.jsx(cre,{agent:e,now:t,onOpenTool:n,onShowSummary:r,onExportSession:c=>fre(o.current,c),onRemove:l})]})}function UL({id:e,value:t,onLevel:n,"aria-describedby":r}){return a.jsxs("div",{className:"sm-row",children:[a.jsx("label",{htmlFor:e,children:"Volume"}),a.jsx("input",{id:e,type:"range",min:od,max:$d,step:hb,value:t,"aria-describedby":r,onChange:s=>n(Number(s.target.value)),style:{"--sm-level":`${(t-od)/($d-od)*100}%`}}),a.jsxs("span",{className:"sm-read",children:[t,"%"]})]})}const zL="agent-dag.character-enabled",WL="agent-dag.fm-volume",qR="agent-dag.fm-source",mre=[{value:"claude-fm",label:"🎧 Claude FM"},{group:"📻 Lofi Girl",value:"lofi-relax",label:"📚 Relax / study"},{group:"📻 Lofi Girl",value:"lofi-game",label:"🎮 Chill / game"},{group:"📻 Lofi Girl",value:"lofi-vibe",label:"🌅 Vibe / chill"},{group:"📻 Lofi Girl",value:"lofi-sleep",label:"💤 Sleep / chill"},{group:"📻 Radio Mix",value:"radio-mix",label:"📡 Live radio mix"},{group:"📻 Best of Nostalgia",value:"best-of-nostalgia",label:"📼 Best of nostalgia live"},{group:"📻 The Good Life Radio",value:"good-life-radio",label:"🌴 The Good Life Radio"},{group:"☕ Cafe Music BGM",value:"cafe-music-bgm",label:"☕ Cafe music BGM"}];function gre(e){return e==="lofi-relax"||e==="lofi-game"||e==="lofi-vibe"||e==="lofi-sleep"||e==="radio-mix"||e==="best-of-nostalgia"||e==="good-life-radio"||e==="cafe-music-bgm"?e:"claude-fm"}function yre(e){return e!=="0"}function wre(){return yre(Qe(zL))}function vre(e){return vO(e)}function xre(){return vre(Qe(WL))}const Ko=["light","dark"],bre={light:"Light",dark:"Dark"},UR=mre,Yo="Give the station a name.",kre="Use an https YouTube live or channel link, or a .mp3, .aac, .ogg or .m3u8 stream.";function Nre({theme:e}){return a.jsx("span",{className:"appearance-preview","data-swatch":e,children:a.jsxs("svg",{viewBox:"0 0 112 56","aria-hidden":!0,focusable:"false",children:[a.jsx("rect",{className:"tp-canvas",width:"112",height:"56"}),a.jsx("rect",{className:"tp-surface",width:"112",height:"7"}),a.jsx("rect",{className:"tp-rule",y:"7",width:"112",height:"1"}),a.jsx("rect",{className:"tp-surface",y:"8",width:"25",height:"48"}),a.jsx("rect",{className:"tp-rule",x:"25",y:"8",width:"1",height:"48"}),a.jsx("rect",{className:"tp-card",x:"36.5",y:"27.5",width:"28",height:"14",rx:"2.5"}),a.jsx("rect",{className:"tp-tag",x:"39.5",y:"25.5",width:"13",height:"4",rx:"2"}),a.jsx("rect",{className:"tp-card",x:"76.5",y:"14.5",width:"29",height:"20",rx:"2.5"}),a.jsx("rect",{className:"tp-rule",x:"81",y:"23",width:"20",height:"2",rx:"1"}),a.jsx("rect",{className:"tp-accent",x:"81",y:"23",width:"12",height:"2",rx:"1"})]})})}function jre({theme:e,onTheme:t,characterEnabled:n,onToggleCharacter:r,fmVolume:s,onFmVolume:o,fmMuted:l,onFmMuted:c,fmSource:d,onFmSource:h,customFmStations:f,unavailableFmStations:p,onAddFmStation:g,onRenameFmStation:v,onRemoveFmStation:N,onClose:k}){var be;const x=ut(k),j=gt(k),b=[...UR.map(oe=>({...oe,label:p.has(oe.value)?`${oe.label} · not live`:oe.label,unavailable:p.has(oe.value)})),...f.map(oe=>({group:"🎵 Your stations",value:Za(oe.id),label:p.has(oe.id)?`${oe.name} · unavailable`:oe.name,unavailable:p.has(oe.id)}))],_=b.some(oe=>oe.value===d&&oe.unavailable),E=[];b.forEach((oe,je)=>{const $e=E[E.length-1];$e&&$e.group===oe.group?$e.indexes.push(je):E.push({group:oe.group,indexes:[je]})});const[R,C]=y.useState(!1),[A,U]=y.useState(()=>Math.max(0,b.findIndex(oe=>oe.value===d))),[L,F]=y.useState(!1),[O,I]=y.useState(""),[B,M]=y.useState(""),[$,P]=y.useState(""),[G,K]=y.useState(!1),[q,H]=y.useState(""),[D,W]=y.useState(""),J=y.useRef(null),V=y.useRef(null),X=y.useRef(null),Y=y.useRef(null),Z=y.useRef(null),ee=di(d),ne=ee?f.find(oe=>oe.id===ee):void 0;y.useEffect(()=>{const oe=b.findIndex(je=>je.value===d);U(oe<0?0:oe)},[d,f,p]),y.useEffect(()=>{K(!1),H((ne==null?void 0:ne.name)??"")},[ne==null?void 0:ne.id,ne==null?void 0:ne.name]),y.useEffect(()=>{var oe;R&&((oe=document.getElementById(`appearance-fm-option-${A}`))==null||oe.scrollIntoView({block:"nearest"}))},[A,R]),y.useEffect(()=>{if(!R)return;const oe=je=>{var Oe,Ue;const $e=je.target;!((Oe=J.current)!=null&&Oe.contains($e))&&!((Ue=Z.current)!=null&&Ue.contains($e))&&C(!1)};return document.addEventListener("pointerdown",oe),()=>document.removeEventListener("pointerdown",oe)},[R]);const se=oe=>{const je=oe.relatedTarget;je&&!oe.currentTarget.contains(je)&&C(!1)},pe=oe=>{var $e;const je=b[oe];je&&(U(oe),h(je.value),C(!1),($e=J.current)==null||$e.focus())},ke=oe=>{if(b$(oe.key)){if(!R)return;oe.preventDefault(),oe.stopPropagation(),C(!1);return}if(oe.key==="Tab"){C(!1);return}if(oe.key==="Enter"||oe.key===" "){oe.preventDefault(),R?pe(A):C(!0);return}oe.key!=="ArrowDown"&&oe.key!=="ArrowUp"&&oe.key!=="Home"&&oe.key!=="End"||(oe.preventDefault(),C(!0),U(je=>oe.key==="Home"?0:oe.key==="End"?b.length-1:Math.min(b.length-1,Math.max(0,je+(oe.key==="ArrowDown"?1:-1)))))},ae=()=>{var oe;return(oe=J.current)==null?void 0:oe.focus()},fe=oe=>{var $e,Oe;if(oe.preventDefault(),!O.trim()){P(Yo),($e=V.current)==null||$e.focus();return}const je=g8(O,B);if(!je){P(kre),(Oe=X.current)==null||Oe.focus();return}g(je),h(Za(je.id)),I(""),M(""),P(""),F(!1),ae()},me=oe=>{var je;if(oe.preventDefault(),!!ee){if(!q.trim()){W(Yo),(je=Y.current)==null||je.focus();return}v(ee,q),K(!1),ae()}},he=oe=>{var Oe;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(oe.key))return;oe.preventDefault();const $e=(Ko.indexOf(e)+(oe.key==="ArrowLeft"||oe.key==="ArrowUp"?-1:1)+Ko.length)%Ko.length;t(Ko[$e]),(Oe=oe.currentTarget.querySelectorAll('[role="radio"]')[$e])==null||Oe.focus()},ge=oe=>{var $e;if(oe.key===" "){oe.stopPropagation();return}if(hc(oe.target)||oe.key!=="t"&&oe.key!=="T"||oe.ctrlKey||oe.metaKey||oe.altKey)return;oe.preventDefault(),oe.stopPropagation();const je=e==="dark"?"light":"dark";t(je),oe.target.getAttribute("role")==="radio"&&(($e=oe.currentTarget.querySelectorAll('[role="radio"]')[Ko.indexOf(je)])==null||$e.focus())},ue=oe=>{const je=b[oe],$e="unavailable"in je&&je.unavailable;return a.jsxs("div",{className:"appearance-source-option",role:"option",id:`appearance-fm-option-${oe}`,"aria-selected":d===je.value,"data-highlighted":A===oe||void 0,"data-unavailable":$e||void 0,onMouseEnter:()=>U(oe),onClick:()=>pe(oe),children:[a.jsx("span",{children:je.label}),d===je.value&&a.jsx("span",{"aria-hidden":!0,children:"✓"})]},je.value)};return Lt.createPortal(a.jsx("div",{className:"modal-backdrop appearance-backdrop",...j,role:"presentation",children:a.jsxs("div",{ref:x,id:"appearance-menu",className:"modal appearance-menu appearance-modal",role:"dialog","aria-modal":"true","aria-labelledby":"appearance-title",onClick:oe=>oe.stopPropagation(),onKeyDown:ge,children:[a.jsxs("div",{className:"appearance-head",children:[a.jsxs("div",{className:"appearance-heading",children:[a.jsx("h2",{id:"appearance-title",className:"appearance-title",children:"Appearance"}),a.jsx("p",{className:"appearance-subtitle",children:"Tune the deck to your workspace."})]}),a.jsx("button",{type:"button",className:"glyph-btn appearance-close",onClick:k,"aria-label":"Close appearance settings",title:"Close (Esc)",children:"×"})]}),a.jsxs("section",{className:"appearance-section","aria-labelledby":"appearance-theme-caption",children:[a.jsxs("div",{className:"appearance-caption",children:[a.jsxs("div",{children:[a.jsx("h3",{id:"appearance-theme-caption",children:"Color theme"}),a.jsx("p",{className:"appearance-section-note",children:"Choose how the dashboard looks."})]}),a.jsx("kbd",{className:"appearance-key","aria-hidden":!0,title:"Press T anywhere to switch themes",children:"T"})]}),a.jsx("div",{className:"appearance-themes",role:"radiogroup","aria-labelledby":"appearance-theme-caption","aria-keyshortcuts":"T",onKeyDown:he,children:Ko.map(oe=>a.jsxs("button",{type:"button",className:"appearance-theme",role:"radio","aria-checked":e===oe,tabIndex:e===oe?0:-1,onClick:()=>t(oe),children:[a.jsx(Nre,{theme:oe}),a.jsxs("span",{className:"appearance-theme-name",children:[bre[oe],a.jsx("svg",{className:"appearance-check",viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 6.4 4.9 8.7 9.5 3.6"})})]})]},oe))})]}),a.jsxs("section",{className:"appearance-section","aria-labelledby":"appearance-fm-caption",children:[a.jsx("div",{className:"appearance-caption",children:a.jsx("h3",{id:"appearance-fm-caption",children:"Music source"})}),a.jsxs("div",{className:"appearance-controls",children:[a.jsxs("div",{className:"appearance-source-row",children:[a.jsx("label",{htmlFor:"appearance-fm-source",children:"Station"}),a.jsxs("div",{className:`appearance-source-picker${R?" is-open":""}`,onBlur:se,children:[a.jsxs("button",{ref:J,type:"button",id:"appearance-fm-source",className:"appearance-source-trigger",role:"combobox","aria-haspopup":"listbox","aria-expanded":R,"aria-controls":R?"appearance-fm-source-list":void 0,"aria-activedescendant":R?`appearance-fm-option-${A}`:void 0,"aria-describedby":"appearance-fm-source-note",onClick:()=>C(oe=>!oe),onKeyDown:ke,children:[a.jsx("span",{children:((be=b.find(oe=>oe.value===d))==null?void 0:be.label)??UR[0].label}),a.jsx("svg",{viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"m2.5 4.5 3.5 3 3.5-3"})})]}),R&&a.jsx("div",{ref:Z,id:"appearance-fm-source-list",className:"appearance-source-list",role:"listbox","aria-label":"Music stations",children:E.map((oe,je)=>oe.group?a.jsxs("div",{role:"group","aria-labelledby":`appearance-fm-group-${je}`,children:[a.jsx("div",{id:`appearance-fm-group-${je}`,className:"appearance-source-group",role:"presentation",children:oe.group}),oe.indexes.map(ue)]},`group-${je}`):oe.indexes.map(ue))})]})]}),a.jsx("span",{id:"appearance-fm-source-note",className:"vis-hidden",children:"Changing station starts live playback automatically."}),a.jsx("p",{className:"appearance-fm-status",role:"status",children:_?u8(di(d)!==null):""}),a.jsxs("div",{className:"appearance-station-manage",children:[a.jsx("button",{type:"button",className:"btn appearance-station-action","aria-expanded":L,onClick:()=>{F(oe=>!oe),P("")},children:L?"Cancel":"+ Add station"}),ne&&!G&&a.jsxs("span",{className:"appearance-station-edit",children:[a.jsx("button",{type:"button",className:"btn appearance-station-action",onClick:()=>{H(ne.name),W(""),K(!0)},children:"Rename"}),a.jsx("button",{type:"button",className:"btn danger appearance-station-action",onClick:()=>{N(ne.id),ae()},children:"Remove"})]})]}),L&&a.jsxs("form",{className:"appearance-station-form",onSubmit:fe,noValidate:!0,children:[a.jsxs("label",{className:"appearance-station-field",children:[a.jsx("span",{children:"Station name"}),a.jsx("input",{ref:V,className:"ap-manage-input",value:O,onChange:oe=>I(oe.target.value),"aria-invalid":$===Yo||void 0,"aria-describedby":$===Yo?"appearance-station-error":void 0,maxLength:zl,autoFocus:!0})]}),a.jsxs("label",{className:"appearance-station-field",children:[a.jsx("span",{children:"Link"}),a.jsx("input",{ref:X,className:"ap-manage-input",value:B,onChange:oe=>M(oe.target.value),placeholder:"https://…","aria-invalid":$!==""&&$!==Yo||void 0,"aria-describedby":$&&$!==Yo?"appearance-station-error":void 0,inputMode:"url",autoComplete:"off",spellCheck:!1,maxLength:z2})]}),a.jsx("button",{type:"submit",className:"btn primary",children:"Add"}),$&&a.jsx("p",{id:"appearance-station-error",className:"appearance-station-error",role:"alert",children:$})]}),ne&&G&&a.jsxs("form",{className:"appearance-station-form is-rename",onSubmit:me,noValidate:!0,children:[a.jsxs("label",{className:"appearance-station-field",children:[a.jsx("span",{children:"Station name"}),a.jsx("input",{ref:Y,className:"ap-manage-input",value:q,onChange:oe=>H(oe.target.value),"aria-invalid":D!==""||void 0,"aria-describedby":D?"appearance-rename-error":void 0,maxLength:zl,autoFocus:!0})]}),a.jsx("button",{type:"submit",className:"btn primary",children:"Save"}),a.jsx("button",{type:"button",className:"btn",onClick:()=>{K(!1),ae()},children:"Cancel"}),D&&a.jsx("p",{id:"appearance-rename-error",className:"appearance-station-error",role:"alert",children:D})]}),a.jsxs("label",{className:"appearance-row",children:[a.jsx("span",{className:"appearance-row-label",id:"appearance-character-label",children:"Show character on minimap"}),a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":n,"aria-labelledby":"appearance-character-label","aria-describedby":"appearance-character-note",onClick:r,children:a.jsx("span",{className:"switch-knob"})}),a.jsx("span",{id:"appearance-character-note",className:"vis-hidden",children:"Shows the animated minimap character and enables music playback."})]}),a.jsx(UL,{id:"appearance-fm-volume",value:s,"aria-describedby":"appearance-fm-volume-note",onLevel:o}),a.jsxs("label",{className:"appearance-row",children:[a.jsx("span",{className:"appearance-row-label",id:"appearance-fm-mute-label",children:"Mute music"}),a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":l,"aria-labelledby":"appearance-fm-mute-label",onClick:c,children:a.jsx("span",{className:"switch-knob"})})]})]}),a.jsx("span",{id:"appearance-fm-volume-note",className:"vis-hidden",children:"Controls live music volume."})]})]})}),document.body)}const Sre="With no deck tab open, get a notification wherever a sound would have played.",_re="With the ccdeck window closed, get a notification wherever a sound would have played.";function Ere(e){return e?_re:Sre}const Tre="Held off for this run — the deck was started with alerts disabled. Your choice is saved for the next start.",zR="Get notified when you're away from this tab.";function Cre(e){switch(e){case"granted":return{status:"Enabled",ask:!1,ok:!0,note:zR};case"default":return{status:null,ask:!0,ok:!1,note:zR};case"denied":return{status:"Blocked",ask:!1,ok:!1,note:"Your browser is blocking them; only its own site settings can undo that. You'll still be told once this tab is closed."};default:return{status:"Unavailable",ask:!1,ok:!1,note:"This browser cannot show them. You'll still be told once this tab is closed."}}}function ac(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}const Are=["audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4"];function Rre(e){return Are.find(t=>e(t))}const Mre=4400;function $re(e){const t=e.split(";")[0];return{name:`Recorded voice.${t==="audio/mp4"?"m4a":t==="audio/ogg"?"ogg":"webm"}`,type:t}}function Ire({full:e,setCustomError:t,runCustom:n,onImportCustom:r}){const[s,o]=y.useState(!1),l=y.useRef(null),c=y.useRef(null),d=y.useRef(!1),h=()=>{var p;c.current!==null&&clearTimeout(c.current),c.current=null,((p=l.current)==null?void 0:p.state)==="recording"&&l.current.stop()},f=async()=>{var g;if(e)return;if(t(""),!((g=navigator.mediaDevices)!=null&&g.getUserMedia)||typeof MediaRecorder>"u"){t("Microphone recording is unavailable in this browser.");return}let p;try{p=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{d.current||t("Microphone access was denied or unavailable.");return}if(d.current||l.current){p.getTracks().forEach(v=>v.stop());return}try{const v=Rre(x=>MediaRecorder.isTypeSupported(x)),N=new MediaRecorder(p,v?{mimeType:v}:void 0),k=[];l.current=N,N.ondataavailable=x=>{x.data.size&&k.push(x.data)},N.onerror=()=>t("Recording failed. Please try again."),N.onstop=()=>{p.getTracks().forEach(_=>_.stop()),c.current!==null&&clearTimeout(c.current),c.current=null;const x=l.current===N;if(x&&(l.current=null),o(!1),!x||!k.length)return;const j=$re(N.mimeType),b=new File(k,j.name,{type:j.type});n(()=>r(b))},N.start(200),o(!0),c.current=setTimeout(h,Mre)}catch{l.current=null,p.getTracks().forEach(v=>v.stop()),t("This browser cannot record a supported audio format.")}};return y.useEffect(()=>(d.current=!1,()=>{d.current=!0,c.current!==null&&clearTimeout(c.current);const p=l.current;l.current=null,(p==null?void 0:p.state)==="recording"&&p.stop()}),[]),{recording:s,startRecording:f,stopRecording:h}}function Ore({full:e,fullProps:t,runCustom:n,onCreateVoice:r}){const[s,o]=y.useState("Custom voice"),[l,c]=y.useState("Your turn"),[d,h]=y.useState(""),[f,p]=y.useState("1"),[g,v]=y.useState("1"),[N,k]=y.useState([]);return y.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const x=()=>{k(window.speechSynthesis.getVoices())};return x(),window.speechSynthesis.addEventListener("voiceschanged",x),()=>window.speechSynthesis.removeEventListener("voiceschanged",x)},[]),a.jsxs("details",{className:"sm-voice",children:[a.jsxs("summary",{...t,onClick:x=>{const j=x.currentTarget.parentElement;e&&j&&!j.open&&x.preventDefault()},children:[a.jsx("span",{children:"Spoken voice"}),a.jsx("span",{children:"Create from text"})]}),a.jsxs("div",{className:"sm-voice-fields",children:[a.jsxs("label",{children:[a.jsx("span",{children:"Name"}),a.jsx("input",{className:"ap-manage-input",value:s,maxLength:80,onChange:x=>o(x.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Text"}),a.jsx("input",{className:"ap-manage-input",value:l,maxLength:180,onChange:x=>c(x.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Voice"}),a.jsxs("select",{className:"sm-select",value:d,onChange:x=>h(x.target.value),children:[a.jsx("option",{value:"",children:"System default"}),N.map(x=>a.jsx("option",{value:x.voiceURI,children:x.name},x.voiceURI))]})]}),a.jsxs("div",{className:"sm-voice-pair",children:[a.jsxs("label",{children:[a.jsx("span",{children:"Rate"}),a.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:f,onChange:x=>p(x.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Pitch"}),a.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:g,onChange:x=>v(x.target.value)})]})]}),a.jsx("button",{type:"button",className:"btn sm-custom-action",...t,onClick:()=>{e||n(async()=>{await r({name:s,text:l,voiceURI:d,rate:parseFloat(f),pitch:parseFloat(g)}),c("Your turn")})},children:"Add spoken voice"})]})]})}function Lre({customAssets:e,onImportCustom:t,onCreateVoice:n,onRenameCustom:r,onPreviewCustom:s,onDeleteCustom:o}){const[l,c]=y.useState(""),d=e.length,h=ub(d),f=h!==null,p=f?{"aria-disabled":!0,"aria-describedby":"sm-custom-full"}:{},[g,v]=y.useState(null),N=y.useRef(0),k=y.useRef(new Map),x=y.useRef(null);y.useEffect(()=>{if(!g)return;const C=window.setTimeout(()=>v(null),4e3);return()=>window.clearTimeout(C)},[g]);const j=async C=>{c("");try{await C()}catch(A){c(A instanceof Error?A.message:"Custom audio could not be saved.")}},b=(C,A)=>{const U=Date.now(),L=Yl({armedFor:g,target:C,armedAt:N.current,now:U,gapMs:Kl});if(L==="arm"){v(C),N.current=U;return}if(L==="ignore")return;v(null);const F=uZ(e.map(O=>O.id),C);j(async()=>{var I;await o(C);const O=document.activeElement;O!==A&&!Tn((O==null?void 0:O.tagName)??null)||(I=F?k.current.get(F):x.current)==null||I.focus()})},{recording:_,startRecording:E,stopRecording:R}=Ire({full:f,setCustomError:c,runCustom:j,onImportCustom:t});return a.jsxs("section",{className:"sm-custom","aria-labelledby":"sm-custom-title",children:[a.jsxs("div",{className:"sm-custom-head",children:[a.jsx("h3",{className:"sm-tone-name",id:"sm-custom-title",children:"Custom sounds"}),a.jsxs("span",{children:[d," of ",cb,", kept on this machine"]})]}),f&&a.jsx("p",{className:"sm-note",id:"sm-custom-full",children:h}),a.jsxs("div",{className:"sm-custom-actions",children:[a.jsxs("label",{className:"sm-custom-card sm-file",children:[a.jsxs("span",{className:"sm-custom-card-copy",children:[a.jsx("strong",{children:"Import audio"}),a.jsx("span",{children:"WAV, MP3 or OGG"})]}),a.jsx("span",{className:"btn sm-custom-action","aria-hidden":"true",children:"Choose file"}),a.jsx("input",{ref:x,type:"file",accept:"audio/wav,audio/x-wav,audio/mpeg,audio/mp3,audio/ogg,.wav,.mp3,.ogg",...p,onClick:C=>{f&&C.preventDefault()},onChange:C=>{var U;const A=(U=C.target.files)==null?void 0:U[0];C.currentTarget.value="",A&&!f&&j(()=>t(A))}})]}),a.jsxs("div",{className:"sm-custom-card",children:[a.jsxs("span",{className:"sm-custom-card-copy",children:[a.jsx("strong",{children:"Record a clip"}),a.jsx("span",{children:_?"Recording…":"Up to 5 seconds"})]}),_?a.jsx("button",{type:"button",className:"btn sm-custom-action",onClick:R,children:"Stop & save"}):a.jsx("button",{type:"button",className:"btn sm-custom-action",...p,onClick:()=>void E(),children:"Record"})]})]}),a.jsx(Ore,{full:f,fullProps:p,runCustom:j,onCreateVoice:n}),e.length>0&&a.jsx("div",{className:"sm-custom-list",children:e.map(C=>a.jsxs("div",{className:"sm-custom-item",children:[a.jsx("input",{className:"ap-manage-input","aria-label":`Rename ${C.name}`,defaultValue:C.name,maxLength:80,onBlur:A=>{if(!A.target.value.trim()){A.target.value=C.name;return}j(()=>r(C.id,A.target.value))},onKeyDown:A=>{A.key==="Enter"&&A.currentTarget.blur()}}),a.jsx("span",{children:C.kind==="audio"?`${C.duration.toFixed(1)}s`:"Voice"}),a.jsx("button",{type:"button",className:"btn sm-custom-icon","aria-label":`Play ${C.name}`,onClick:()=>s(C.id),children:"Play"}),a.jsx("button",{type:"button",ref:A=>{A?k.current.set(C.id,A):k.current.delete(C.id)},className:`btn sm-custom-icon${g===C.id?" armed":""}`,onKeyDown:A=>{A.repeat&&A.preventDefault()},onClick:A=>b(C.id,A.currentTarget),"aria-label":g===C.id?`Confirm deleting ${C.name}`:`Delete ${C.name}`,title:g===C.id?"Press again to delete this sound. It cannot be brought back.":"Delete this sound",children:g===C.id?"Confirm":"Delete"})]},C.id))}),l&&a.jsx("p",{className:"sm-custom-error",role:"alert",children:l})]})}const bb="custom:";function WR(e){return`${bb}${e}`}function Pre(e){return e.startsWith(bb)?e.slice(bb.length):null}const HR={done:"Turn finished","needs-input":"Claude is asking"},Dre={done:"Plays when Claude or Codex finishes a turn.","needs-input":"Available in Claude Code only."};function Fre({chime:e,tone:t,soundOn:n,customAssets:r,customSelections:s,onLevel:o,onFigure:l,onPreview:c,onBuiltInSelected:d,onCustomSelected:h}){const f=`sm-level-${e}`,p=`sm-figure-${e}`,g=s[e];return a.jsxs("section",{className:"sm-tone","aria-labelledby":`sm-name-${e}`,children:[a.jsxs("div",{className:"sm-tone-head",children:[a.jsx("h3",{className:"sm-tone-name",id:`sm-name-${e}`,children:HR[e]}),a.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>c(e),"aria-label":`Hear the ${HR[e].toLowerCase()} tone`,title:n?"Play this tone now, at what it is set to":"Plays even when Sounds is off","aria-describedby":n?void 0:"sm-preview-note",children:[a.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:a.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),"Hear it"]})]}),a.jsx(UL,{id:f,value:t.level,onLevel:v=>o(e,v)}),a.jsxs("div",{className:"sm-row",children:[a.jsx("label",{htmlFor:p,children:"Tone"}),a.jsxs("select",{id:p,className:"sm-select",value:g?WR(g):t.figure,onChange:v=>{const N=v.target.value,k=Pre(N);k!==null?h(e,k):(d(e),l(e,N))},children:[C0[e].map(v=>a.jsx("option",{value:v.id,children:v.label},v.id)),r.length>0&&a.jsx("optgroup",{label:"Custom",children:r.map(v=>a.jsx("option",{value:WR(v.id),children:v.name},v.id))})]})]}),a.jsx("p",{className:"sm-note",children:Dre[e]})]})}function Bre({onClose:e,soundOn:t,onToggleSound:n,prefs:r,onLevel:s,onFigure:o,onPreview:l,openerRef:c,customAssets:d,customSelections:h,onBuiltInSelected:f,onCustomSelected:p,onImportCustom:g,onCreateVoice:v,onRenameCustom:N,onPreviewCustom:k,onDeleteCustom:x,notifyOn:j,onToggleNotify:b,notifyVetoed:_,notifyPermission:E,onAskNotify:R}){var $;const C=Cre(E),A=ac(),U=j&&!_&&!A,L=lZ(h),F=(($=d.find(P=>P.id===L))==null?void 0:$.name)??"the same custom sound",O=L?`Both tones use “${F}”. They may be harder to tell apart.`:"",I=ut(e,{popover:!0});wI(I,()=>c.current,e);const B=y.useRef(null),M=is(!C.ask,B);return a.jsxs("div",{ref:I,id:"sound-menu",className:"sound-menu",role:"dialog","aria-label":"Sound settings",children:[a.jsxs("div",{className:"sm-switches",children:[a.jsxs("label",{className:"sm-switch",children:[a.jsx("span",{className:"sm-switch-label",id:"sm-sound-label",children:"Sounds"}),a.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-labelledby":"sm-sound-label",className:"switch",onClick:n,title:"A tone when a turn finishes, and when Claude asks for something",children:a.jsx("span",{className:"switch-knob"})})]}),a.jsxs("div",{className:"sm-setting",children:[a.jsxs("label",{className:"sm-switch",children:[a.jsx("span",{className:"sm-switch-label",id:"sm-notify-label",children:"Notifications while closed"}),a.jsx("button",{ref:B,type:"button",role:"switch","aria-checked":j,"aria-labelledby":"sm-notify-label",className:"switch",onClick:b,title:"With no deck tab open, a notification wherever a sound would play",children:a.jsx("span",{className:"switch-knob"})})]}),a.jsx("p",{className:"sm-note",children:_?Tre:Ere(A)})]})]}),U&&a.jsxs("section",{className:"sm-channel","aria-labelledby":"sm-channel-name",children:[a.jsxs("div",{className:"sm-channel-head",children:[a.jsx("h3",{className:"sm-channel-name",id:"sm-channel-name",children:"Browser notifications"}),C.ask?a.jsx("button",{type:"button",className:"btn sm-channel-action",onClick:()=>{M(),R()},children:"Enable"}):a.jsxs("span",{className:"sm-channel-state","data-ok":C.ok||void 0,children:[C.ok&&a.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M1.5 5.2 3.9 7.6 8.5 2.4"})}),C.status]})]}),a.jsx("p",{className:"sm-note",children:C.note})]}),!t&&a.jsx("span",{id:"sm-preview-note",className:"vis-hidden",children:"Plays even when Sounds is off, so you can set a tone before turning sounds back on."}),a.jsx("div",{className:"sm-tones",children:ad.map(P=>a.jsx(Fre,{chime:P,tone:r[P],soundOn:t,customAssets:d,customSelections:h,onLevel:s,onFigure:o,onPreview:l,onBuiltInSelected:f,onCustomSelected:p},P))}),O&&a.jsx("p",{className:"sm-note","aria-hidden":!0,children:O}),a.jsx("p",{className:"vis-hidden",role:"status",children:O}),a.jsx(Lre,{customAssets:d,onImportCustom:g,onCreateVoice:v,onRenameCustom:N,onPreviewCustom:k,onDeleteCustom:x}),a.jsxs("p",{className:"sm-foot",children:[a.jsx("kbd",{children:"M"}),"Mute or unmute sounds anywhere."]})]})}const Yu="tb-more",kb="tb-more-menu";function qre(){const e=Array.from(document.querySelectorAll(`#${kb} [role="menuitem"]`));return document.querySelectorAll(".topbar .tb-fold")[Math.max(0,e.indexOf(document.activeElement))]??null}function Ure({watchUnseen:e,setUsageHistoryOpen:t,setBrowserWatchOpen:n,onFeedback:r}){const[s,o]=y.useState(null),l=s!==null,c=d=>()=>{var h;(h=document.getElementById(Yu))==null||h.focus(),o(null),d()};return a.jsxs(a.Fragment,{children:[a.jsxs("button",{id:Yu,className:"btn icon-btn tb-more",onClick:()=>o(l?null:"first"),onKeyDown:d=>{d.key!=="ArrowDown"&&d.key!=="ArrowUp"||(d.preventDefault(),o(d.key==="ArrowUp"?"last":"first"))},title:"More — usage history, Browser watch and feedback","aria-label":`More: usage history, Browser watch, feedback${e>0?`, ${e} unread`:""}`,"aria-haspopup":"menu","aria-expanded":l,"aria-controls":l?kb:void 0,children:[a.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:[a.jsx("circle",{cx:"2.8",cy:"7",r:"0.7"}),a.jsx("circle",{cx:"7",cy:"7",r:"0.7"}),a.jsx("circle",{cx:"11.2",cy:"7",r:"0.7"})]}),e>0&&a.jsx("span",{className:"bw-badge","aria-hidden":!0,children:e})]}),l&&a.jsxs(dh,{anchorId:Yu,id:kb,className:"ap-pop",role:"menu",labelledBy:Yu,start:s,fallbackFocus:qre,onClose:()=>o(null),children:[a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:c(()=>t(!0)),children:"Usage history"}),a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:c(()=>n(!0)),children:e>0?`Browser watch · ${e} unread`:"Browser watch"}),a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:c(r),children:"Send feedback"})]})]})}function zre({sessionListOpen:e,toggleSessionList:t,usagePanelOpen:n,setUsagePanelOpen:r,setUsageHistoryOpen:s,toggles:o}){return a.jsxs("div",{className:"action-run",children:[a.jsxs("button",{ref:o.sessionList,className:"btn icon-btn",onClick:t,title:`${e?"Hide":"Show"} session list (L)`,"aria-label":"Toggle session list","aria-expanded":e,"aria-controls":e?"session-list":void 0,children:[a.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:[a.jsx("path",{d:"M5.4 3.6h6.6M5.4 7h6.6M5.4 10.4h6.6"}),a.jsx("path",{d:"M2.2 3.6h.2M2.2 7h.2M2.2 10.4h.2"})]}),a.jsx("span",{className:"tb-word",children:"Session list"})]}),a.jsxs("button",{ref:o.usage,className:"btn icon-btn",onClick:()=>r(l=>!l),title:`${n?"Hide":"Show"} usage panel (U)`,"aria-label":"Toggle usage panel","aria-expanded":n,"aria-controls":n?"usage-panel":void 0,children:[a.jsxs("svg",{className:"tb-glyph-narrow",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M9.4 4.5C9 3.6 8.1 3.1 7 3.1c-1.4 0-2.4.8-2.4 1.9 0 1.2 1.2 1.6 2.4 2s2.4.8 2.4 2c0 1.1-1 1.9-2.4 1.9-1.1 0-2-.5-2.4-1.4"}),a.jsx("path",{d:"M7 1.6v1.5M7 10.9v1.5"})]}),a.jsx("span",{className:"tb-word",children:"Usage"})]}),a.jsxs("button",{className:"btn icon-btn tb-fold",onClick:()=>s(l=>!l),title:"Usage history — ccusage (H)","aria-label":"Open usage history","aria-haspopup":"dialog",children:[a.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:[a.jsx("line",{x1:"3",y1:"11.5",x2:"3",y2:"7"}),a.jsx("line",{x1:"7",y1:"11.5",x2:"7",y2:"3"}),a.jsx("line",{x1:"11",y1:"11.5",x2:"11",y2:"8.5"})]}),a.jsx("span",{className:"tb-word",children:"History"})]})]})}function Wre({providers:e,accountsPanelOpen:t,toggleAccountsPanel:n,machinePanelOpen:r,setMachinePanelOpen:s,watchOn:o,watchUnseen:l,setBrowserWatchOpen:c,toggles:d}){return a.jsxs("div",{className:"action-run",children:[e.claude&&a.jsxs("button",{ref:d.accounts,className:"btn icon-btn",onClick:n,title:`${t?"Hide":"Show"} accounts (A)`,"aria-label":"Toggle accounts panel","aria-expanded":t,"aria-controls":t?"accounts-panel":void 0,children:[a.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:[a.jsx("circle",{cx:"7",cy:"4.6",r:"2.4"}),a.jsx("path",{d:"M2.4 12c0-2.3 2.1-3.7 4.6-3.7s4.6 1.4 4.6 3.7"})]}),a.jsx("span",{className:"tb-word",children:"Accounts"})]}),a.jsxs("button",{ref:d.machine,className:"btn icon-btn",onClick:()=>s(h=>!h),title:`${r?"Hide":"Show"} this machine — cores, memory, temperature (S)`,"aria-label":"Toggle machine detail","aria-expanded":r,"aria-controls":r?"system-panel":void 0,children:[a.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:[a.jsx("rect",{x:"3.6",y:"3.6",width:"6.8",height:"6.8",rx:"1.2"}),a.jsx("path",{d:"M5.8 1.4v2.2M8.2 1.4v2.2M5.8 10.4v2.2M8.2 10.4v2.2M1.4 5.8h2.2M1.4 8.2h2.2M10.4 5.8h2.2M10.4 8.2h2.2"})]}),a.jsx("span",{className:"tb-word",children:"Machine"})]}),a.jsxs("button",{className:"btn icon-btn bw-btn tb-fold",onClick:()=>c(h=>!h),title:o?"Browser watch — watching; the deck is keeping its own copy (B)":"Browser watch — not watching; reading the browser's history live (B)","aria-label":`Browser watch, ${o?"watching":"not watching"}`+(l>0?`, ${l} unread`:""),"aria-haspopup":"dialog",children:[a.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:[a.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"}),o||l>0?a.jsx("circle",{cx:"7",cy:"7",r:"1.8",fill:"currentColor",stroke:"none"}):a.jsx("line",{x1:"2.4",y1:"11.6",x2:"11.6",y2:"2.4"})]}),a.jsx("span",{className:"tb-word",children:"Browser watch"}),l>0&&a.jsx("span",{className:"bw-badge","aria-hidden":!0,children:l})]})]})}function Hre({providers:e,sound:t,tones:n,customTones:r,notify:s,chimeState:o,menus:l,appearance:c,fm:d,onFeedback:h,watchUnseen:f,setUsageHistoryOpen:p,setBrowserWatchOpen:g}){const{soundOn:v,toggleSound:N}=t,{tonePrefs:k,previewTone:x,changeTone:j}=n,{customSelections:b,customAssets:_,clearCustomOnly:E,selectCustomTone:R,importNotificationAudio:C,createNotificationVoice:A,renameCustomAsset:U,deleteCustomAsset:L,previewCustomAsset:F}=r,{notifyPermission:O,notifyOn:I,notifyVetoed:B,toggleNotify:M,notifySupported:$,askForNotifications:P}=s,{soundMenuOpen:G,setSoundMenuOpen:K,soundButtonRef:q,appearanceMenuOpen:H,setAppearanceMenuOpen:D,appearanceButtonRef:W}=l,{theme:J,setTheme:V,characterEnabled:X,setCharacterEnabled:Y}=c,{fmVolume:Z,setFmVolume:ee,fmMuted:ne,setFmMuted:se,fmSource:pe,customFmStations:ke,unavailableFmStations:ae,addFmStation:fe,renameFmStation:me,removeFmStation:he,pickFmSource:ge}=d;return a.jsxs("div",{className:"action-run action-run-utility",children:[e.claude&&v!==null&&a.jsxs("div",{className:"sound-slot",children:[a.jsxs("button",{ref:q,className:"btn icon-btn",onClick:()=>K(ue=>!ue),...Dr(!1),title:Jne(e,{on:v===!0,locked:o==="locked",prefs:k}),"aria-label":`Sound settings, ${v?"on":"off"}`,"aria-haspopup":"dialog","aria-expanded":G,"aria-controls":G?"sound-menu":void 0,children:[a.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:[a.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),v?a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M9.8 5.4a2.4 2.4 0 0 1 0 3.2"}),a.jsx("path",{d:"M11.3 3.9a4.6 4.6 0 0 1 0 6.2"})]}):a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M10 5.6l2.6 2.8"}),a.jsx("path",{d:"M12.6 5.6L10 8.4"})]})]}),a.jsx("span",{className:"tb-word",children:"Sound"})]}),G&&a.jsx(Bre,{onClose:()=>K(!1),soundOn:v===!0,onToggleSound:N,prefs:k,onLevel:(ue,be)=>j(ue,{level:be}),onFigure:(ue,be)=>j(ue,{figure:be}),onPreview:ue=>x(ue),customAssets:_,customSelections:b,onBuiltInSelected:E,onCustomSelected:R,onImportCustom:C,onCreateVoice:A,onRenameCustom:U,onPreviewCustom:F,onDeleteCustom:L,notifyOn:I,onToggleNotify:M,notifyVetoed:B,notifyPermission:$?O:"unsupported",onAskNotify:P,openerRef:q})]}),a.jsxs("div",{className:"appearance-slot",children:[a.jsx("button",{ref:W,className:"btn icon-btn",onClick:()=>{K(!1),D(ue=>!ue)},title:"Appearance settings","aria-label":`Appearance settings, ${J} theme, character ${X?"shown":"hidden"}`,"aria-haspopup":"dialog","aria-expanded":H,"aria-controls":H?"appearance-menu":void 0,children:J==="dark"?a.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:[a.jsx("circle",{cx:"7",cy:"7",r:"2.5"}),a.jsx("path",{d:"M7 1.5v1.2M7 11.3v1.2M1.5 7h1.2M11.3 7h1.2M3.1 3.1l.85.85M10.05 10.05l.85.85M3.1 10.9l.85-.85M10.05 3.95l.85-.85"})]}):a.jsx("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:a.jsx("path",{d:"M11.8 8.4A5 5 0 1 1 5.6 2.2a4 4 0 0 0 6.2 6.2Z"})})}),H&&a.jsx(jre,{theme:J,onTheme:V,characterEnabled:X,onToggleCharacter:()=>Y(ue=>!ue),fmVolume:Z,onFmVolume:ee,fmMuted:ne,onFmMuted:()=>se(ue=>!ue),fmSource:pe,onFmSource:ge,customFmStations:ke,unavailableFmStations:ae,onAddFmStation:fe,onRenameFmStation:me,onRemoveFmStation:he,onClose:()=>D(!1)})]}),a.jsxs("button",{className:"btn icon-btn tb-fold",onClick:h,title:"Send feedback — a problem, an idea or anything else, to the people who make ccdeck","aria-label":"Send feedback","aria-haspopup":"dialog",children:[a.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:[a.jsx("path",{d:"M2.2 3.3h9.6v5.3H6.1L3.5 10.8V8.6H2.2Z"}),a.jsx("path",{d:"M7 4.9v1.7"}),a.jsx("path",{d:"M7 7.7v.05"})]}),a.jsx("span",{className:"tb-word-wide",children:"Feedback"})]}),a.jsx(Ure,{watchUnseen:f,setUsageHistoryOpen:p,setBrowserWatchOpen:g,onFeedback:h})]})}const Vre=5*6e4,Gre=6e4;function Kre({shown:e,tabVisible:t,lastReadAt:n,now:r,lastSince:s,since:o}){return!e||!t?!1:s&&o&&s!==o?!0:n===null||r-n>=Vre}function VR(e=new Date){return Z$("month",e)}function Yre(e){const t=ih(e);return{cost:t.cost,tokens:t.tokens}}function GR(e){return e>0?qe(e):"$0.00"}const Xre=new Set(["idle","checking","current","downloading","ready","error"]);function KR(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.status!="string"||!Xre.has(t.status))return null;const n=typeof t.version=="string"&&t.version.trim()?t.version.trim():null;return t.status==="ready"&&!n?null:{status:t.status,version:n}}function Zre(e){return(e==null?void 0:e.status)==="ready"&&e.version?{version:e.version}:null}function Jre(e=typeof navigator>"u"?"":navigator.userAgent){var t;return((t=/\bccdeck-desktop\/(\d[^\s]*)/.exec(e))==null?void 0:t[1])??null}const Bd="Restart to update",HL=3e4;function Qre(e=typeof navigator>"u"?"":navigator.userAgent){return/\bMac OS X\b|\bMacintosh\b/.test(e)?"the ccdeck menu in the menu bar":"the ccdeck tray menu"}function ese(e,t){const n=`v${e} → v${t}`;return{text:n,label:`${n}, update downloaded and verified`,title:`ccdeck v${t} is downloaded and verified · click to open What's new, where ${Bd} comes first`}}function tse(e){const t=e==null?void 0:e.reason;return t==="app_disconnected"||t==="update_not_ready"?t:"refused"}function nse(e,t,n=typeof navigator>"u"?"":navigator.userAgent){const r=Qre(n),s=`Use ${Bd} in ${r}.`;switch(e){case"app_disconnected":return`Nothing restarted: the app is not connected to this deck, so the request had nowhere to go. ${s}`;case"update_not_ready":return`Nothing restarted: the app no longer has v${t} ready. When it has one, ${Bd} is in ${r}.`;case"timeout":return`ccdeck has not restarted after ${HL/1e3} seconds. ${s}`;case"refused":return`Nothing restarted: the deck turned the request down. ${s}`;case"unreachable":return`Nothing restarted: the request did not reach the deck. ${s}`}}const rse="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",cx="click for what's new";function sse(e){if(e.checkDisabled)return`${rse} · ${cx}`;if(e.checking)return`Asking npm for the newest release… · ${cx}`;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.checkFailedAgo?` · could not reach npm ${e.checkFailedAgo}`:e.checkedAgo?` · checked ${e.checkedAgo}`:"";return`${t}${n} · re-checked periodically · ${cx}, and to check npm now`}function ase(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`:e.checkFailedAgo?`${t} — npm could not be reached ${e.checkFailedAgo}, check again`:`${t} and check npm for a newer release`}function ose(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 VL(e){return e?`${e.kind}:${e.to}`:""}function ise(e,t){return e!=null&&t!==VL(e)}function lse({readyAppUpdate:e,notice:t,noticeOpen:n,version:r,chipVersion:s,versionChecking:o,now:l,openReleaseNotes:c,showNotice:d,loadVersion:h}){return a.jsx(a.Fragment,{children:e?(()=>{const f=ese(Jre()??s,e.version);return a.jsxs("button",{type:"button",className:"v ready",onClick:c,"aria-haspopup":"dialog","aria-label":f.label,title:f.title,children:[f.text,a.jsx("span",{className:"v-dot","aria-hidden":!0})]})})():t?a.jsxs("button",{type:"button",className:"v stale",onClick:()=>{c(),d()},"aria-haspopup":"dialog","aria-label":ose({...t,open:n}),title:t.kind==="restart"?`Running v${t.from}; v${t.to} is installed on disk. Restart to pick it up · click for what's new`:`Running v${t.from}; v${t.to} is on npm · click for what's new`,children:["v",t.from,a.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const f={running:s,latest:r==null?void 0:r.latest,latestPending:r==null?void 0:r.latestPending,checkedAgo:r!=null&&r.checkedAt?jd(l-r.checkedAt):null,checkFailedAgo:r!=null&&r.checkFailedAt&&r.checkFailedAt>(r.checkedAt??0)?jd(l-r.checkFailedAt):null,checkDisabled:r==null?void 0:r.checkDisabled,checking:o};return a.jsxs("button",{type:"button",className:o?"v checking":"v",onClick:()=>{c(),h(!0)},"aria-busy":o||void 0,"aria-haspopup":"dialog","aria-label":ase(f),title:sse(f),children:["v",f.running]})})()})}function cse({live:e,paused:t,pauseGate:n,monthUsageRef:r,monthlyUsage:s,monthlyUsageUnavailable:o}){return a.jsxs("span",{className:"status",children:[(()=>{const l=Mz({connected:e,paused:t,held:n.size,dropped:n.dropped});return l.resting?null:a.jsx("span",{className:`pill ${l.tone}`,title:l.title,children:a.jsxs("span",{className:"pill-box",children:[a.jsx("span",{className:"pill-widest","aria-hidden":!0,children:l.widest}),a.jsx("span",{className:"pill-label",children:l.label})]})})})(),a.jsxs("span",{ref:r,className:"month-usage",title:s?`${s.tokens.toLocaleString()} tokens · ${GR(s.cost)} spent since the 1st of this local calendar month`:o?"Monthly usage is unavailable — ccusage could not be read":"Loading usage since the 1st of this local calendar month",children:[a.jsx("span",{className:"month-usage-label",children:"this month"}),s?a.jsxs(a.Fragment,{children:[a.jsx("b",{children:it(s.tokens)}),a.jsx("span",{className:"month-usage-unit",children:"tokens"}),a.jsx("span",{className:"month-usage-sep","aria-hidden":!0,children:"·"}),a.jsx("b",{children:GR(s.cost)})]}):a.jsx("span",{className:"month-usage-pending",children:o?"unavailable":"…"})]})]})}function use({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:r}){return a.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>{t.current=e[0].id,n(e[0].id)},title:`Blocked waiting for you — click, or press W, to go to the one that has been stuck longest:
104
- ${e.map(s=>` ${s.label}: ${pi(s.waiting)} (${jd(r-s.waiting.since)})`).join(`
105
- `)}`,"aria-label":`${e.length} session${e.length===1?"":"s"} waiting for you`,children:[a.jsx("span",{className:"ap-pulse","aria-hidden":!0}),a.jsx("b",{children:e.length})," ",a.jsx("span",{className:"ws-word",children:"waiting"})]})}const Nb={on:"The deck will raise a system notification when a session blocks on you and this tab is in the background",blocked:"Notifications are blocked for this page. Only your browser can undo that — its site settings for this address"};function dse(e){return e==="on"?`Notifications on. ${Nb.on}.`:e==="blocked"?`${Nb.blocked}.`:""}function hse({notifySaid:e}){return a.jsx("span",{className:e==="on"?"notify-said":"notify-said notify-said-blocked","aria-hidden":!0,title:Nb[e],children:e==="on"?"notifications on":"notifications blocked"})}function fse({versionCheck:e,welcome:t,desktopUpdate:n,pause:r,monthly:s,announcements:o,notify:l,waitingSessions:c,waitingCursorRef:d,focusSession:h,live:f,now:p,incidents:g}){const{version:v,notice:N,noticeOpen:k,showNotice:x,versionChecking:j,loadVersion:b}=e,{chipVersion:_,openReleaseNotes:E}=t,{readyAppUpdate:R}=n,{paused:C,pauseGate:A}=r,{monthlyUsage:U,monthlyUsageUnavailable:L,monthUsageRef:F}=s,{blockedSaid:O,watchSaid:I,incidentSaid:B}=o,{notifySaid:M}=l;return a.jsxs("div",{className:"readout",children:[a.jsxs("div",{className:"brand",children:[a.jsx("img",{className:"logo logo-on-dark",src:o7,width:19,height:16,alt:""}),a.jsx("img",{className:"logo logo-on-light",src:i7,width:19,height:16,alt:""}),a.jsx("h1",{children:kt}),a.jsx(lse,{readyAppUpdate:R,notice:N,noticeOpen:k,version:v,chipVersion:_,versionChecking:j,now:p,openReleaseNotes:E,showNotice:x,loadVersion:b})]}),a.jsx(cse,{live:f,paused:C,pauseGate:A,monthUsageRef:F,monthlyUsage:U,monthlyUsageUnavailable:L}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:O}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:I}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:B}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:dse(M)}),a.jsx(l7,{incidents:g}),c.length>0&&a.jsx(use,{waitingSessions:c,waitingCursorRef:d,focusSession:h,now:p}),M&&a.jsx(hse,{notifySaid:M})]})}function pse({selected:e,now:t,selectedIds:n,focusAgent:r,clearSelection:s}){const o=pn(e),l=Math.max(0,((e.endedAt??t)-e.startedAt)/1e3),c=e.state==="active"&&!e.synthetic?e0(o.total,l):null,d=n.size-1;return a.jsxs("button",{type:"button",className:"selected-ribbon",title:`Zoom to ${e.label} and its session (Z)${o.total>0?`
106
- ${qe(o.total)} spent${c?` · ${c}`:""}`:""}`,onClick:()=>{try{r(e.id)}catch{}},children:[a.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),a.jsx("span",{className:"selected-label",children:e.label}),o.total>0&&a.jsxs("span",{className:"selected-cost",children:[qe(o.total),c?a.jsxs("span",{className:"selected-rate",children:[" · ",c]}):null]}),d>0&&a.jsxs("span",{className:"selected-extra",children:["+",d]}),a.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:h=>{h.stopPropagation(),s()},children:"×"})]})}function mse({catBarRef:e,catBarOccluded:t,presentCats:n,hiddenCats:r,toggleCat:s}){return a.jsx("div",{ref:e,className:`cat-filter-bar${t?" occluded":""}`,role:"group","aria-label":"Filter tools by category",children:n.map(o=>{const l=r.has(o);return a.jsxs("button",{type:"button",className:`cat-filter${l?" off":""}`,onClick:()=>s(o),"aria-pressed":!l,title:`${l?"Show":"Hide"} ${Fd[o]} tools`,children:[a.jsx(lre,{cat:o}),a.jsx("span",{className:"cat-name",children:Fd[o]})]},o)})})}const gse=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(",");function yse(e){var n,r;const t=e.target;!(t!=null&&t.closest)||t.closest(gse)!==e.currentTarget||(e.preventDefault(),(r=(n=document.activeElement)==null?void 0:n.blur)==null||r.call(n))}function wse({trashZoneRef:e,trashState:t,trashPhase:n,trashLabel:r}){return a.jsxs("div",{ref:e,className:`drag-trash-zone ${t}${n==="leaving"?" leaving":""}`,role:"status",children:[a.jsx("svg",{className:"drag-trash-icon",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{d:"M8 7V5.8C8 4.8 8.8 4 9.8 4h4.4c1 0 1.8.8 1.8 1.8V7m-10 0h12M8 10v8m4-8v8m4-8v8M7 7l.7 13h8.6L17 7"})}),a.jsxs("span",{className:"drag-trash-copy",children:[a.jsx("span",{className:"drag-trash-text",children:t==="over"?a.jsxs(a.Fragment,{children:["Release to remove ",a.jsx("strong",{className:"drag-trash-name",children:r||"this card"})]}):"Drop here to remove from the board"}),a.jsx("span",{className:"drag-trash-hint",children:t==="over"?"The session list (L) brings it back":"The session keeps running"})]})]})}function vse({canvasRef:e,bubbling:t,dragging:n,trash:r,zoom:s,viewport:o,stateRef:l,peek:c,children:d}){const{trashDragging:h,trashState:f,trashPhase:p,trashZoneRef:g,trashLabel:v}=r,{lod:N,lodRef:k}=s,{markCanvasInput:x}=o,{peekAgent:j,peekLabel:b,peekRecap:_,peekBounds:E}=c;return a.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${t?" bubbling":""}${n?" dragging-any":""}${h&&f==="over"?" trash-hover":""}`,"data-lod":N,ref:e,onMouseDownCapture:yse,onPointerDownCapture:x,onPointerUpCapture:x,onWheelCapture:x,onFocusCapture:R=>{const C=R.target;if(!X0(C)||k.current==null||k.current==="detail")return;const A=C.getAttribute("data-id");A&&l.current.agents.has(A)&&C.matches(":focus-visible")&&CL(A,C,"focus")},onBlurCapture:R=>{var A,U;const C=(U=(A=R.target).getAttribute)==null?void 0:U.call(A,"data-id");C&&la(C)},children:[d,La(p)&&a.jsx(wse,{trashZoneRef:g,trashState:f,trashPhase:p,trashLabel:v}),a.jsx(zte,{agentFor:j,recapFor:_,labelFor:b,bounds:E})]})}function xse({restarting:e,restartMode:t,live:n,paused:r}){return a.jsxs("div",{className:"conn-banner",role:"alert",children:[a.jsx("span",{className:"conn-dot"}),e?t==="npx"?"Fetching the new version with npx — this can take a minute…":`Restarting ${kt}…`:(()=>{const s=Az({connected:n,paused:r});return a.jsxs(a.Fragment,{children:[`Lost connection to the ${kt} server. Reconnecting…`,s&&a.jsx("span",{className:"conn-sub",children:s})]})})()]})}function bse({oldName:e,version:t,dismissOldName:n}){return a.jsxs("div",{className:"ver-banner",role:"status",children:[a.jsx("span",{className:"ver-dot"}),a.jsxs("strong",{children:[e," still works — the deck is called ",kt," now."]}),t!=null&&t.renameFix?a.jsx("span",{className:"ver-sub",children:t.renameFix}):null,a.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}const GL="Thanks — that helps.",kse=Array.from({length:11},(e,t)=>t);function Nse(e){return e===0?"0 out of 10, not useful":e===10?"10 out of 10, extremely useful":`${e} out of 10`}const jse=6;function Sse(e){const t=y.useRef(null);return y.useLayoutEffect(()=>{const n=t.current,r=n==null?void 0:n.closest(".app");if(!n||!r)return;const s=()=>r.style.setProperty("--rating-h",`${Math.ceil(n.getBoundingClientRect().height)}px`);s();const o=typeof ResizeObserver>"u"?null:new ResizeObserver(s);return o==null||o.observe(n),()=>{o==null||o.disconnect(),r.style.removeProperty("--rating-h")}},[e]),t}function _se(){var e;(e=document.getElementById("canvas"))==null||e.focus()}function Ese({phase:e,score:t,onAnswer:n,onLater:r,onClose:s,onFeedback:o,onHold:l}){const c=Sse(e),d=y.useRef(null),h=y.useRef(null),f=y.useRef(!1);y.useEffect(()=>{var g,v;e!=="thanks"||!f.current||(f.current=!1,Tn(((g=document.activeElement)==null?void 0:g.tagName)??null)&&((v=d.current??h.current)==null||v.focus()))},[e]);const p=g=>{var v;(v=c.current)!=null&&v.contains(document.activeElement)&&_se(),g()};return e==="thanks"?a.jsxs("div",{ref:c,className:"ver-banner note rating-banner",onFocus:()=>l(!0),onBlur:g=>{g.currentTarget.contains(g.relatedTarget)||l(!1)},children:[a.jsx("span",{className:"ver-dot"}),a.jsx("strong",{children:GL}),t!==null&&t<=jse?a.jsx("button",{ref:d,type:"button",className:"ver-act",onClick:o,children:"Tell us what would make it better"}):null,a.jsx("button",{ref:h,type:"button","aria-label":"Dismiss",className:"ver-close",onClick:()=>p(s),children:"×"})]}):a.jsxs("div",{ref:c,className:"ver-banner note rating-banner",role:"group","aria-labelledby":"rating-question",children:[a.jsx("span",{className:"ver-dot"}),a.jsx("strong",{id:"rating-question",children:"How useful is ccdeck to you?"}),a.jsx("span",{className:"rating-scale",children:kse.map(g=>a.jsx("button",{type:"button",className:"rating-pick","aria-label":Nse(g),onClick:v=>{f.current=v.detail===0||v.currentTarget.matches(":focus-visible"),n(g)},children:g},g))}),a.jsx("span",{className:"ver-sub rating-ends","aria-hidden":"true",children:"0 not at all · 10 extremely"}),a.jsx("button",{type:"button",className:"ver-act",onClick:()=>p(r),children:"Not now"})]})}const Tse=3e4;function Cse({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function Ase({bundle:e,running:t,pending:n,lastTried:r}){return t?Cse({bundle:e,running:t,lastTried:r})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function Rse(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function Mse({asked:e,reported:t}){return t?t!==e:!1}function KL(e){const t=e.thresholdMs??Tse;return!e.enabled||e.kind!=="restart"||!e.canRestart||!e.noticeOpen||!e.visible||e.busy?null:e.idleSince==null||e.now<e.idleSince?t:Math.max(0,t-(e.now-e.idleSince))}function $se(e){const t=Math.max(0,Math.ceil(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`}function Ise(e,t){return e?t==null?"auto when idle":`auto in ${$se(t)}`:"auto-restart off"}function YR(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function Ose(e,t=!1){return e<=0&&t?{label:"Restart anyway",clause:"the canvas is paused — running agents cannot be seen"}:e<=0?{label:"Restart now",clause:"nothing is running"}:{label:"Restart anyway",clause:`${e===1?"1 agent is running":`${e} agents are running`} — their events during the restart are lost`}}function Lse(e){const t=KL(e);return t==null?{idleSince:null,restart:!1,remainingMs:null}:e.idleSince==null||e.now<e.idleSince?{idleSince:e.now,restart:!1,remainingMs:t}:{idleSince:e.idleSince,restart:t===0,remainingMs:t}}const XR={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — run:",one_off:"this deck runs from a one-off pnpm dlx, bunx or yarn dlx copy that cannot be upgraded in place — to keep one, run:",not_writable:"the install directory is not writable by this user — run:",opted_out:"installs are off (AGENTS_DECK_NO_INSTALL=1) — run:",retired_name:"this install came from a name that is no longer published — run:"};function Pse({notice:e,version:t,dismissNotice:n,upgradeState:r,startUpgrade:s,copyCommand:o,cmdCopied:l,autoRestart:c,toggleAutoRestart:d,askRestart:h,restartCopy:f,restartFuseMs:p,restarting:g}){var v,N,k;return a.jsxs("div",{className:`ver-banner ${e.kind}`,role:"status",children:[a.jsx("span",{className:`ver-dot${p==null?"":" armed"}`}),e.kind==="restart"?a.jsxs(a.Fragment,{children:[a.jsxs("strong",{children:["v",e.to," is installed — this deck still runs v",e.from,"."]}),t!=null&&t.canRestart?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:"ver-act",onClick:()=>h(),...Dr(g),title:`Stop this process and bring it back on the same port. The canvas replays from the event log.
107
-
108
- 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:g?"restarting…":f.label}),!g&&a.jsx("span",{className:"ver-sub",children:f.clause}),a.jsxs("label",{className:"ver-auto",children:[a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":c,onClick:d,"aria-label":"Auto-restart when idle",title:c?"Updates on its own. While you are here it restarts once nothing has been running for 30 seconds; while you are away it also installs the new version first. Click to require a click instead.":"Only updates when you click. Click to let it update itself when idle or while you are away.",children:a.jsx("span",{className:"switch-knob"})}),a.jsx("span",{"aria-hidden":!0,children:Ise(c,p)})]})]}):a.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."})]}):a.jsxs(a.Fragment,{children:[a.jsxs("strong",{children:[kt," v",e.to," is out — you are on v",e.from,"."]}),(t==null?void 0:t.upgradeMode)==="install"&&r!=="failed"&&a.jsx("button",{type:"button",className:"ver-act",onClick:s,...Dr(r==="running",r==="done"),title:`Runs ${((v=t==null?void 0:t.upgrade)==null?void 0:v.command)??(t==null?void 0:t.command)??"npm i -g"} here, then restarts once nothing is running.`,children:r==="running"?"installing…":r==="done"?"installed":"Update now"}),(t==null?void 0:t.upgradeMode)==="npx"&&(t==null?void 0:t.canRestart)&&a.jsx("button",{type:"button",className:"ver-act",onClick:()=>h({upgrade:!0}),...Dr(g),title:`Runs ${t==null?void 0:t.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`,children:g?"fetching…":r==="failed"?"Retry update":"Update & restart"}),r==="failed"?a.jsxs("span",{className:"ver-sub fail",title:((N=t==null?void 0:t.upgrade)==null?void 0:N.error)??"",children:[(t==null?void 0:t.upgradeMode)==="npx"?"update failed":"install failed",": ",((k=t==null?void 0:t.upgrade)==null?void 0:k.error)??"unknown error"," — run it yourself:"]}):(t==null?void 0:t.upgradeMode)==="npx"?a.jsx("span",{className:"ver-sub",children:t!=null&&t.canRestart?"npx cannot upgrade in place, so the deck re-runs:":XR.npx}):t!=null&&t.upgradeBlocked?a.jsx("span",{className:"ver-sub",children:Ot(XR,t.upgradeBlocked)??"cannot install from here"}):null,a.jsxs("button",{type:"button",className:"ver-cmd",onClick:o,title:"Copy to clipboard",children:[a.jsx("code",{children:t==null?void 0:t.command}),a.jsx("span",{className:"ver-cmd-hint",children:l?"copied":"copy"})]})]}),a.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}function Dse({restart:e,versionCheck:t,upgrade:n,oldNameNotice:r,rating:s,onFeedback:o,everConnected:l,live:c,paused:d}){const{autoRestart:h,toggleAutoRestart:f,restarting:p,restartMode:g,restartedTo:v,askRestart:N,restartCopy:k,restartFuseMs:x}=e,{version:j,notice:b,noticeOpen:_,dismissNotice:E}=t,{upgradeState:R,startUpgrade:C,copyCommand:A,cmdCopied:U}=n,{oldName:L,oldNameOpen:F,dismissOldName:O}=r,{ratingPhase:I,ratingScore:B,answerRating:M,rateLater:$,closeRating:P,holdThanks:G}=s,K=v?a.jsxs("div",{className:"ver-banner done",role:"status",children:[a.jsx("span",{className:"ver-dot"}),a.jsxs("strong",{children:["Restarted — now running v",v,"."]}),a.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):l&&!c?a.jsx(xse,{restarting:p,restartMode:g,live:c,paused:d}):_&&b?a.jsx(Pse,{notice:b,version:j,dismissNotice:E,upgradeState:R,startUpgrade:C,copyCommand:A,cmdCopied:U,autoRestart:h,toggleAutoRestart:f,askRestart:N,restartCopy:k,restartFuseMs:x,restarting:p}):F&&L?a.jsx(bse,{oldName:L,version:j,dismissOldName:O}):I!=="hidden"?a.jsx(Ese,{phase:I,score:B,onAnswer:M,onLater:$,onClose:P,onFeedback:o,onHold:G}):null;return a.jsxs(a.Fragment,{children:[K,a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:I==="thanks"?GL:""})]})}function Fse(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function Bse(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 qse(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function Use(e,t){const n=qse(e),r=(...l)=>[n?`${n} on the canvas`:null,...l,"layout, pins and selection"].filter(c=>c!==null),s="This cannot be undone.";if(!t)return{goes:r("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"),stays:[],final:s,confirm:"Clear everything"};if(!t.path)return{goes:r(),stays:[],final:`This deck keeps no event log, so nothing on disk changes — and nothing can bring the canvas back. ${s}`,confirm:"Clear everything"};if(!t.mine){const l=t.ownerPort===null?"another running deck owns that file":`the deck on port ${t.ownerPort} owns that file`,c=t.decks>2?`, one of ${t.decks} decks sharing it`:"";return{goes:r(),stays:[`the event log — ${l}${c}`,"restart this deck and the log replays back onto it"],final:null,confirm:"Clear this canvas"}}if(t.decks<=1)return{goes:r("this deck's event log — the file a restarted deck replays to rebuild what you see"),stays:[],final:s,confirm:"Clear everything"};const o=t.decks-1;return{goes:r(`the event log ${o===1?"1 other running deck shares":`${o} other running decks share`} with this one — every session recorded in it, not just the ones drawn here`),stays:[o===1?"what that deck shows, until it restarts — then it is gone there too":"what those decks show, until they restart — then it is gone there too"],final:s,confirm:"Clear everything"}}function zse({agentCount:e,onConfirm:t,onCancel:n}){const r=y.useRef(null),s=ut(n,{focusRef:r,layer:iU}),o=gt(n),[l,c]=y.useState(null);y.useEffect(()=>{let g=!1;return fetch("/api/clear").then(v=>v.ok?v.json():null).then(v=>{g||c(Bse(v))}).catch(()=>{}),()=>{g=!0}},[]);const{goes:d,stays:h,final:f,confirm:p}=Use(e,l);return a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal clear-confirm",onClick:g=>g.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:"status-dot err","aria-hidden":!0}),a.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("dl",{className:"cc-plan",children:[a.jsx("dt",{children:"Goes"}),a.jsx("dd",{children:d.map(g=>a.jsx("span",{children:g},g))}),a.jsx("dt",{children:"Stays"}),a.jsx("dd",{children:h.length>0?h.map(g=>a.jsx("span",{children:g},g)):a.jsx("span",{children:"nothing"})})]}),f&&a.jsx("p",{className:"cc-final",children:f}),a.jsxs("div",{className:"cc-actions",children:[a.jsx("button",{type:"button",ref:r,className:"btn",onClick:n,children:"Cancel"}),a.jsx("button",{type:"button",className:"btn danger",onClick:t,children:p})]})]})]})})}const jb=[{value:"bug",label:"Bug",question:"What happened?",placeholder:`I was trying to…
109
- What did you expect to happen?`},{value:"idea",label:"Idea",question:"What would make ccdeck better?",placeholder:"It would be useful if…"},{value:"other",label:"Other",question:"What would you like to tell us?",placeholder:"Write anything…"}];function YL(e){return jb.find(t=>t.value===e)??jb[0]}const Sb=3,ux=120,Wse=1e4,Hse=200,Vse="Write something first.";function ZR(e){return e.trim()!==""}function Gse(e){var o;const t=e.trim();if(t==="")return"";const n=JR(t.split(/\r?\n/,1)[0]),r=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,s=dx(r).length>=Sb?dx(r):dx(n);return Yse(s.length>=Sb?s:JR(t))}function Kse(e,t){const n=Gse(t);return n.length>=Sb?n:`${YL(e).label}: ${n}`}function JR(e){return e.replace(/\s+/g," ").trim()}function dx(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function Yse(e){if(e.length<=ux)return e;const t=e.slice(0,ux-1),n=t.lastIndexOf(" ");return`${(n>=ux/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function Xse({kind:e,body:t,contact:n}){const r={kind:e,title:Kse(e,t),body:t.trim()};return n.trim()!==""&&(r.contact=n.trim()),r}function Zse(e){const t=e;return(t==null?void 0:t.ok)!==!0||typeof t.appVersion!="string"||typeof t.platform!="string"||t.appVersion===""||t.platform===""?null:{appVersion:t.appVersion,platform:t.platform}}const Jse={darwin:"macOS",win32:"Windows",linux:"Linux"};function Qse(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),r=t===-1?"":e.slice(t+1),s=Jse[n]??n;return r?`${s} · ${r}`:s}function eae(e){return e?`ccdeck ${e.appVersion} · ${Qse(e.platform)}`:null}const tae="sent with it",nae="Your ccdeck version and system are sent with it.",rae="Add details",sae="How to reach you",aae="Email or GitHub @name",oae="Only if you would like an answer.",iae=["It all goes to the people who make ccdeck, with the version and system below.","Nothing becomes public by being sent. They may open a public GitHub issue from it, choosing its title and text; your contact and screenshots are never put on one."];function lae(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function XL(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function cae(e){return/mac|iphone|ipad/i.test(e)?["⌘","Enter"]:["Ctrl","Enter"]}function uae(e){return[...e].length===1}const ZL="Thanks — feedback sent.";function QR(e,t,n){if(t==="vetoed")return"This deck was started with AGENTS_DECK_NO_INSTALL=1, which keeps it off the network, so nothing was sent.";if(e===429||t==="too_many")return"Too much feedback from this network in the last hour. Try again later; your text is still here.";if(e===413||t==="too_large")return"The images are too large to send together. Remove one and send again; your text is still here.";const r=n==null?void 0:n.images;return e===400&&Array.isArray(r)&&typeof r[0]=="string"?`The server did not accept an image. ${r[0]} Remove it and send again; your text is still here.`:e===400?"The server did not accept the message. It is still here; check it and send again.":"ccdeck's server could not be reached. Nothing was sent; your text is still here, so try again in a moment."}function dae(e){return e==="sending"?"Sending…":e==="sent"?ZL:""}const eM=1400,hae=160;function fae({kind:e,onChange:t}){return a.jsxs("fieldset",{className:"fb-kinds",children:[a.jsx("legend",{className:"vis-hidden",children:"Kind of feedback"}),jb.map(n=>a.jsxs("label",{className:"fb-kind",children:[a.jsx("input",{type:"radio",name:"feedback-kind",value:n.value,checked:e===n.value,onChange:()=>t(n.value),onKeyDown:r=>{XL(r.nativeEvent)&&r.preventDefault()}}),n.label]},n.value))]})}const JL="fb-details";function pae({open:e,onToggle:t}){return a.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":JL,onClick:t,children:[rae,a.jsx("svg",{className:"fb-chev",width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 3.75 5 6.25l2.5-2.5"})})]})}function mae({open:e,contact:t,onContact:n}){const r=y.useId();return a.jsx("div",{id:JL,className:"fb-details","data-open":e||void 0,children:a.jsx("div",{className:"fb-details-clip",children:a.jsxs("div",{className:"fb-details-body",children:[a.jsxs("div",{className:"fb-field",children:[a.jsxs("label",{className:"fb-field-label",htmlFor:"fb-contact",children:[sae,a.jsx("span",{className:"fb-optional",children:"optional"})]}),a.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:Hse,autoComplete:"email",placeholder:aae,"aria-describedby":r,onChange:s=>n(s.target.value),onKeyDown:s=>{XL(s.nativeEvent)&&s.preventDefault()}}),a.jsx("p",{id:r,className:"fb-hint",children:oae})]}),a.jsx("div",{className:"fb-where",children:iae.map(s=>a.jsx("p",{children:s},s))})]})})})}const ti=3,gae=5*1024*1024,yae=12*1024*1024,_b=8192,wae=64*1024,vae=256*1024,xae=.92,bae=640,QL=.9,kae=.85,Nae=6,jae=512*1024,qd={png:"image/png",jpeg:"image/jpeg"},Sae={png:"png",jpeg:"jpg"},_ae=[137,80,78,71,13,10,26,10],Eae=[255,216,255];function eP(e){const t=n=>e.length>=n.length&&n.every((r,s)=>e[s]===r);return t(_ae)?"png":t(Eae)?"jpeg":null}function Tae(e){const t=eP(e);return t==="png"?Cae(e):t==="jpeg"?Rae(e):null}function Cae(e){const t=[73,72,68,82];if(e.length<24||!t.every((r,s)=>e[12+s]===r))return null;const n=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:n.getUint32(16),height:n.getUint32(20)}}function Aae(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function Rae(e){let t=2;for(;t<e.length;){if(e[t]!==255)return null;for(;t<e.length&&e[t]===255;)t++;const n=e[t++];if(n===void 0||n===217||n===218)return null;if(n===1||n>=208&&n<=215)continue;if(t+2>e.length)return null;const r=e[t]<<8|e[t+1];if(r<2)return null;if(Aae(n))return t+7>e.length?null:{height:e[t+3]<<8|e[t+4],width:e[t+5]<<8|e[t+6]};t+=r}return null}function tM(e,t){return e.bytes>t||e.width>_b||e.height>_b}function Mae(e){return Math.min(gae,yae-wae-e)}function tP(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function $ae(e,t){const n=_b/Math.max(e.width,e.height),r=e.bytes>t?Math.sqrt(t/e.bytes)*QL:1;return tP(e,Math.min(1,n,r))}async function Iae(e,t,n){let r=$ae(e,t),s=e.format;for(let o=0;o<Nae;o++){const l=await n(r,s,s==="jpeg"?xae:void 0);if(!l)return null;if(l.size<=t)return{...r,blob:l,format:s};if(s==="png"){s="jpeg";continue}if(r=tP(r,Math.min(kae,Math.sqrt(t/l.size)*QL)),Math.max(r.width,r.height)<bae)return null}return null}async function Oae(e,t,n){const r=new Uint8Array(await e.slice(0,jae).arrayBuffer()),s=eP(r);if(!s)return{ok:!1,problem:"type"};if(t<vae)return{ok:!1,problem:"no_room"};const o=e.type===qd[s]?e:new Blob([e],{type:qd[s]}),l=Tae(r);if(l&&!tM({...l,bytes:e.size},t))return{ok:!0,blob:o,resized:null};const c=await n(e).catch(()=>null);if(!c)return{ok:!1,problem:"unreadable"};try{const d={width:c.width,height:c.height,bytes:e.size,format:s};if(!tM(d,t))return{ok:!0,blob:o,resized:null};const h=await Iae(d,t,c.encoder);return h?{ok:!0,blob:h.blob,resized:{width:h.width,height:h.height}}:{ok:!1,problem:"too_large"}}finally{c.release()}}function Lae(e){return({width:t,height:n},r,s)=>new Promise(o=>{const l=document.createElement("canvas");l.width=t,l.height=n;const c=l.getContext("2d");if(!c)return o(null);r==="jpeg"&&(c.fillStyle="white",c.fillRect(0,0,t,n)),c.imageSmoothingQuality="high",c.drawImage(e,0,0,t,n),l.toBlob(d=>{l.width=0,l.height=0,o(d)},qd[r],s)})}const Pae=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:Lae(t),release:()=>t.close()}};function Dae(e){return e.includes("Files")}function Fae({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function Bae(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function qae(e,t){if(t.length===0)return{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)};const n=new FormData;return n.append("kind",e.kind),n.append("title",e.title),n.append("body",e.body),e.contact!==void 0&&n.append("contact",e.contact),t.forEach((r,s)=>{const o=r.type===qd.jpeg?"jpeg":"png";n.append("images",r,`image-${s+1}.${Sae[o]}`)}),{method:"POST",body:n}}const Uae="Add screenshot",nM="PNG or JPEG, up to three. You can also paste one, or drop it on this dialog.",zae="A screenshot can show emails, costs and paths. Crop out what should not be seen.",rM="Three images at most. Remove one to add another.",Wae="An image could not be attached, so nothing was sent. Check the images and send again; your text is still here.";function Hae(e,t,n){const r=n?`, resized to ${n.width} × ${n.height} to fit`:"";return`Replace image ${e+1}: ${t}${r}`}function Vae(e,t){const n=`${e} of ${ti}`;return t>0?`${n} · ${t} resized to fit`:n}function Gae(e){return`Three images at most, so ${e===1?"one was":`${e} were`} left out.`}function Kae(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function Yae(e,t){const n=Kae(t);return e==="type"?`${n} is not a PNG or a JPEG, so it was not added. GIF, WebP and HEIC are not converted; save it as a PNG or a JPEG first.`:e==="no_room"?`There is no room left for ${n}: images go at up to 12 MB in all. Remove one to add it.`:e==="unreadable"?`${n} could not be read as an image.`:`${n} could not be made small enough to send: images go at up to 5 MB each.`}const nP="image/png,image/jpeg";function rP({className:e="fb-glyph"}){return a.jsxs("svg",{className:e,width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:[a.jsx("rect",{x:"1.8",y:"2.4",width:"10.4",height:"9.2",rx:"1.6"}),a.jsx("circle",{cx:"5",cy:"5.6",r:"1"}),a.jsx("path",{d:"M2.4 10.4 5.5 7.6l2.1 1.8 1.5-1.3 2.5 2.2"})]})}function Xae({images:e,buttonRef:t}){const n=y.useRef(null),r=e.shots.length>=ti;return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:t,type:"button",className:"fb-tool",title:nM,"aria-describedby":"fb-attach-hint",onClick:()=>{var s;return r?e.sayFull():(s=n.current)==null?void 0:s.click()},children:[a.jsx(rP,{}),Uae]}),a.jsx("span",{id:"fb-attach-hint",hidden:!0,children:nM}),a.jsx("input",{ref:n,type:"file",accept:nP,multiple:!0,hidden:!0,onChange:s=>{e.add(Array.from(s.target.files??[])),s.target.value=""}})]})}function Zae({images:e,addRef:t}){const n=y.useRef(new Map),r=y.useRef(null),s=y.useRef(null),o=y.useRef(null),[l,c]=y.useState(null),{shots:d}=e,h=Vae(d.length,d.filter(g=>g.resized).length);y.useLayoutEffect(()=>{var g;l!==null&&((g=l==="add"?t.current:n.current.get(l))==null||g.focus(),c(null))},[l,t]),y.useEffect(()=>{var g;e.problem&&((g=r.current)==null||g.scrollIntoView({block:"nearest"}))},[e.problem,e.problemId]);function f(g){c(Bae(d.map(v=>v.id),g)??"add"),e.remove(g)}function p(g){var v;o.current=g,(v=s.current)==null||v.click()}return a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"vis-hidden",role:"status",children:e.announcement}),a.jsx("input",{ref:s,type:"file",accept:nP,hidden:!0,onChange:g=>{const v=o.current;v!==null&&e.replace(v,Array.from(g.target.files??[])),o.current=null,g.target.value=""}}),d.length>0&&a.jsxs("div",{className:"fb-shots",children:[a.jsxs("div",{className:"fb-shots-row",children:[a.jsx("ul",{className:"fb-shots-list",children:d.map((g,v)=>a.jsxs("li",{className:"fb-shot","data-fitting":g.blob?void 0:!0,children:[a.jsxs("button",{type:"button",className:"fb-shot-pick","aria-label":Hae(v,g.name,g.resized),onClick:()=>p(g.id),children:[a.jsx("img",{className:"fb-shot-img",src:g.url,alt:""}),g.blob?a.jsx("span",{className:"fb-shot-cue","aria-hidden":"true",children:"Replace"}):a.jsx("span",{className:"fb-shot-busy","aria-hidden":"true",children:"Resizing…"})]}),a.jsx("button",{ref:N=>{N?n.current.set(g.id,N):n.current.delete(g.id)},type:"button",className:"glyph-btn fb-shot-remove","aria-label":`Remove image ${v+1}`,title:`Remove image ${v+1}`,onClick:()=>f(g.id),children:a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 2.5 7.5 7.5M7.5 2.5 2.5 7.5"})})})]},g.id))}),a.jsx("span",{className:"fb-shots-count",children:h})]}),a.jsx("p",{className:"fb-hint",children:zae})]}),e.problem&&a.jsx("p",{ref:r,className:"fb-error",role:"alert",children:e.problem},e.problemId)]})}function Jae(e,t,n){return n?e.map(r=>r.id===t.id?t:r):[...e,t]}function Qae(e,t,n){return n?e.map(r=>r.id===t?n:r):e.filter(r=>r.id!==t)}function eoe(){const[e,t]=y.useState([]),[n,r]=y.useState({problem:"",id:0}),s=y.useRef(0),o=y.useCallback(C=>{C&&s.current++,r(A=>C?{problem:C,id:A.id+1}:A.problem?{problem:"",id:A.id}:A)},[]),[l,c]=y.useState(""),d=y.useRef([]),h=y.useRef(null),f=y.useRef(1),p=y.useRef(!0),g=y.useCallback(C=>{d.current=C(d.current),t(d.current)},[]);y.useEffect(()=>(p.current=!0,()=>{p.current=!1;for(const C of d.current)URL.revokeObjectURL(C.url)}),[]);const v=y.useCallback(async(C,A)=>{const U=d.current.reduce((P,G)=>{var K;return P+(G.id===(A==null?void 0:A.id)?0:((K=G.blob)==null?void 0:K.size)??0)},0),L=(A==null?void 0:A.id)??f.current++,F=URL.createObjectURL(C),O={id:L,name:C.name||"image",url:F,blob:null,resized:null};let I=!1;const B=()=>{I||(I=!0,g(P=>Jae(P,O,A!==void 0)))},M=await Oae(C,Mae(U),async P=>(B(),Pae(P))).catch(()=>({ok:!1,problem:"unreadable"})),$=d.current.some(P=>P.id===L);return!p.current||!$&&(I||A)?(URL.revokeObjectURL(F),A&&URL.revokeObjectURL(A.url),""):M.ok?(B(),A&&URL.revokeObjectURL(A.url),g(P=>P.map(G=>G.id===L?{...G,blob:M.blob,resized:M.resized}:G)),""):(URL.revokeObjectURL(F),I&&g(P=>Qae(P,L,A)),Yae(M.problem,C.name||"image"))},[g]),N=y.useCallback(async C=>{o("");const A=[];let U=0,L=0;for(const O of C){if(!p.current)return;if(d.current.length>=ti){U++;continue}const I=d.current.length,B=await v(O);B&&A.push(B),d.current.length>I&&L++}if(!p.current)return;U>0&&A.push(L===0&&A.length===0?rM:Gae(U)),o(A.join(" "));const F=d.current.length;L>0&&c(`${L===1?"Image":`${L} images`} added, ${F} of ${ti}.`)},[v,o]),k=y.useCallback(async(C,A)=>{o("");const U=d.current.find(O=>O.id===C);if(!U)return N([A]);const L=await v(A,U);if(!p.current)return;o(L);const F=d.current.findIndex(O=>O.id===C);!L&&F!==-1&&c(`Image ${F+1} replaced, ${d.current.length} of ${ti}.`)},[N,v,o]),x=y.useCallback(C=>{h.current=(h.current??Promise.resolve()).then(C).catch(()=>{})},[]),j=y.useCallback(C=>{C.length>0&&x(()=>N(C))},[N,x]),b=y.useCallback((C,A)=>{const U=A[0];U&&x(()=>k(C,U))},[x,k]),_=y.useCallback(C=>{const A=d.current.find(U=>U.id===C);A&&(URL.revokeObjectURL(A.url),g(U=>U.filter(L=>L.id!==C)),o(""),c(`Image removed, ${d.current.length} of ${ti}.`))},[g,o]),E=y.useCallback(()=>o(rM),[o]),R=y.useCallback(async()=>{const C=s.current;return await h.current,s.current!==C?null:d.current.flatMap(A=>A.blob?[A.blob]:[])},[]);return{shots:e,problem:n.problem,problemId:n.id,announcement:l,add:j,replace:b,remove:_,sayFull:E,ready:R}}function toe(){const[e,t]=y.useState(null);return y.useEffect(()=>{let n=!0;return fetch("/api/feedback").then(r=>r.ok?r.json():null).then(r=>{n&&t(Zse(r))}).catch(()=>{}),()=>{n=!1}},[]),e}function noe(e){const[t,n]=y.useState({state:"idle"}),r=y.useRef(!1),s=y.useRef(null);y.useEffect(()=>()=>{var l;return(l=s.current)==null?void 0:l.abort()},[]);async function o(l){if(!lr(r.current))return;r.current=!0;const{signal:c}=s.current=new AbortController;n({state:"sending"});try{const d=await e.ready();if(c.aborted)return;if(!d){n({state:"failed",message:Wae});return}const h=await fetch("/api/feedback",{...qae(Xse(l),d),signal:c}),f=await h.json().catch(()=>null);n(h.ok&&(f!=null&&f.ok)?{state:"sent"}:{state:"failed",message:QR(h.status,f==null?void 0:f.reason,f==null?void 0:f.errors)})}catch{c.aborted||n({state:"failed",message:QR(0,null)})}finally{r.current=!1}}return{outcome:t,sending:t.state==="sending",send:o}}function roe(e,t){const[n,r]=y.useState(!1),s=y.useRef(t);return s.current=t,y.useEffect(()=>{if(!e)return;const o=window.setTimeout(()=>r(!0),eM),l=window.setTimeout(()=>s.current(),eM+hae);return()=>{window.clearTimeout(o),window.clearTimeout(l)}},[e]),n}function soe(){var t;return typeof navigator>"u"?"":((t=navigator.userAgentData)==null?void 0:t.platform)||navigator.platform||""}function sP({onClose:e,initialKind:t,initialBody:n}){const r=y.useRef(null),s=y.useRef(null),o=y.useRef(null),l=y.useRef(null),c=y.useRef(null),d=y.useRef(null),h=y.useRef(null),f=y.useRef(0),p=ut(e,{focusRef:r}),g=gt(e),[v,N]=y.useState(t??"bug"),[k,x]=y.useState(n??""),[j,b]=y.useState(""),[_,E]=y.useState(!1),[R,C]=y.useState(!1),[A,U]=y.useState(!1),L=eoe(),F=eae(toe()),{outcome:O,sending:I,send:B}=noe(L),M=O.state==="sent",$=roe(M,e),P=YL(v),G=R&&!ZR(k),[K,q]=cae(soe());y.useEffect(()=>{var ke,ae;const se=l.current;if(!se)return;const pe=se.contains(document.activeElement)||Tn(((ke=document.activeElement)==null?void 0:ke.tagName)??null);se.inert=M,M&&pe&&((ae=s.current)==null||ae.focus())},[M]),y.useEffect(()=>{var ae,fe;const se=c.current;if(!se)return;if(I){const me=document.activeElement;h.current=me&&se.contains(me)?me:null,se.inert=!0,h.current&&((ae=d.current)==null||ae.focus());return}se.inert=!1;const pe=h.current;h.current=null;const ke=document.activeElement===d.current||Tn(((fe=document.activeElement)==null?void 0:fe.tagName)??null);!M&&pe&&ke&&pe.focus()},[I,M]);function H(se){var pe;if(se.preventDefault(),!ZR(k)){C(!0),(pe=r.current)==null||pe.focus();return}B({kind:v,body:k,contact:j})}const D=!M&&!I,W=se=>Dae(Array.from(se.dataTransfer.types));function J(se){!W(se)||!D||(se.preventDefault(),f.current++,U(!0))}function V(se){W(se)&&(se.preventDefault(),se.dataTransfer.dropEffect=D?"copy":"none")}function X(se){W(se)&&(f.current=Math.max(0,f.current-1),f.current===0&&U(!1))}function Y(se){W(se)&&(se.preventDefault(),f.current=0,U(!1),D&&L.add(Array.from(se.dataTransfer.files)))}function Z(se){se.target!==se.currentTarget||!W(se)||(se.preventDefault(),se.dataTransfer.dropEffect="none")}function ee(se){W(se)&&se.preventDefault()}function ne(se){if(!D)return;const pe=Array.from(se.clipboardData.files),ke=se.target,ae=ke instanceof HTMLTextAreaElement||ke instanceof HTMLInputElement,fe=Array.from(se.clipboardData.types).includes("text/plain");Fae({files:pe.length,hasText:fe,intoTextField:ae})&&(se.preventDefault(),L.add(pe))}return a.jsx("div",{className:"modal-backdrop",...g,role:"presentation",onDragOver:Z,onDrop:ee,"data-leaving":$||void 0,children:a.jsxs("div",{ref:p,className:"modal feedback-dialog",onClick:se=>se.stopPropagation(),onDragEnter:J,onDragOver:V,onDragLeave:X,onDrop:Y,onPaste:ne,role:"dialog","aria-modal":"true","aria-labelledby":"feedback-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"feedback-title",className:"modal-tool-name",children:"Send feedback"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:s,type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsx("p",{className:"vis-hidden",role:"status",children:dae(O.state)}),a.jsxs("div",{className:"fb-stage",children:[a.jsxs("form",{ref:l,className:"fb-form",onSubmit:H,onKeyDown:se=>{lae(se.nativeEvent)&&(se.preventDefault(),se.currentTarget.requestSubmit())},noValidate:!0,children:[a.jsxs("section",{ref:c,className:"modal-body fb-body",children:[a.jsx(fae,{kind:v,onChange:N}),a.jsxs("div",{className:"fb-compose",children:[a.jsx("label",{className:"fb-label",htmlFor:"fb-body",children:P.question}),a.jsx("textarea",{ref:r,id:"fb-body",className:"ap-manage-input fb-message",value:k,maxLength:Wse,rows:5,placeholder:P.placeholder,onChange:se=>x(se.target.value),"aria-invalid":G||void 0,"aria-describedby":G?"fb-body-error":void 0,required:!0}),G&&a.jsx("p",{id:"fb-body-error",className:"fb-error",children:Vse}),a.jsx(Zae,{images:L,addRef:o}),a.jsxs("div",{className:"fb-tools",children:[a.jsx(Xae,{images:L,buttonRef:o}),a.jsx(pae,{open:_,onToggle:()=>E(se=>!se)})]}),a.jsx(mae,{open:_,contact:j,onContact:b})]}),a.jsx("p",{className:"fb-facts",children:F?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"fb-facts-value",children:F})," — ",tae]}):nae}),O.state==="failed"&&a.jsx("p",{className:"fb-error",role:"alert",children:O.message})]}),a.jsxs("div",{className:"fb-foot",children:[a.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[a.jsx("kbd",{"data-symbol":uae(K)||void 0,children:K}),a.jsx("kbd",{children:q})," to send"]}),a.jsx("button",{type:"button",className:"btn",onClick:e,children:"Cancel"}),a.jsx("button",{ref:d,type:"submit",className:"btn primary fb-send","aria-keyshortcuts":"Meta+Enter Control+Enter",...Dr(I),children:a.jsxs("span",{className:"fb-send-label",children:[a.jsx("span",{className:"fb-send-idle",children:"Send feedback"}),a.jsx("span",{className:"fb-send-busy",children:"Sending…"})]})})]})]}),M&&a.jsxs("div",{className:"fb-done",children:[a.jsx(Td,{}),a.jsx("p",{className:"fb-done-line",children:ZL})]})]}),a.jsx("div",{className:"fb-drop","aria-hidden":"true","data-active":A||void 0,children:a.jsxs("div",{className:"fb-drop-frame",children:[a.jsx(rP,{className:"fb-drop-glyph"}),a.jsx("p",{className:"fb-drop-title",children:"Drop to attach"}),a.jsx("p",{className:"fb-drop-note",children:"PNG or JPEG, up to three"})]})})]})})}const aoe="Press Esc first if a key does nothing.",ooe=[{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:"W",action:"the session waiting on you — oldest first, again for the next",binds:["w","W"]},{cap:"F",action:"fit every agent on screen",binds:["f","F"]},{cap:"Z",action:"zoom to the selected agent and its session",binds:["z","Z"]},{cap:"Delete",action:"take the selected card off the board — the session list (L) brings it back",binds:["Delete"]},{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:"D",action:"detail panel",binds:["d","D"]},{cap:"H",action:"usage history",binds:["h","H"]},{cap:"A",action:"Claude accounts, where Claude Code is installed",binds:["a","A"]},{cap:"S",action:"this machine — cores, memory, temperature",binds:["s","S"]},{cap:"B",action:"Browser Watch",binds:["b","B"]},{cap:"V",action:"the sound menu — volume, tones, notifications",binds:["v","V"]},{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:"a card: go to it and its session",binds:[]},{cap:"double-click",action:"a card: its prompt, every tool call, tokens and timing",binds:[]},{cap:"hover",action:"zoomed out, a card's name, state and numbers",binds:[]},{cap:"click",action:"the topbar speaker opens volume and sound settings",binds:[]}]}];function ioe({onClose:e,onTour:t}){const n=ut(e),r=gt(e);return a.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:a.jsxs("div",{ref:n,className:"modal key-help",onClick:s=>s.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[t&&a.jsxs("div",{className:"guide-door",children:[a.jsx("span",{children:"Eight pictures of what the deck shows."}),a.jsx("button",{type:"button",className:"btn",onClick:t,children:"Take the tour"})]}),a.jsx("div",{className:"shortcuts",children:ooe.map(s=>a.jsxs(y.Fragment,{children:[a.jsx("h3",{className:"kh-group",children:s.title}),s.rows.map(o=>a.jsxs("div",{className:"sc",children:[a.jsx("kbd",{children:o.cap}),a.jsx("span",{children:o.action})]},`${s.title}:${o.cap}:${o.action}`))]},s.title))}),a.jsx("p",{className:"kh-foot",children:aoe})]})]})})}function aP(e,t){return y.lazy(()=>e().catch(n=>(console.warn(`ccdeck could not load ${t}`,n),{default:({onClose:r})=>a.jsx(loe,{name:t,onClose:r})})))}function loe({name:e,onClose:t}){const n=y.useRef(null),r=ut(t,{focusRef:n}),s=gt(t);return a.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal dialog-missing",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"dialog-missing-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"dialog-missing-title",className:"modal-tool-name",children:e})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("p",{className:"dm-note",children:[e," did not load. The deck has most likely been updated since this tab opened, and a reload picks up the new version."]}),a.jsxs("div",{className:"dm-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"}),a.jsx("button",{type:"button",ref:n,className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"})]})]})]})})}function coe(e,t){return`${e}#${t}`}function uoe(e,{lan:t,now:n,closed:r}){if(t===void 0)return[];const s=[];for(const o of e??[]){const l=o.reauth;if(!l||l.dismissed||o.origin!=="ccdeck_signin")continue;const c=coe(l.key,l.since);if(r.has(c)||XG(l.key,o.email,t,n))continue;const d=o.email??"";s.push({id:c,key:l.key,since:l.since,num:o.num,email:d,name:d||o.alias||`Account ${o.num}`,alias:d&&o.alias?o.alias:null})}return s}function doe(e,t){const n=String((t==null?void 0:t.email)??"").trim().toLowerCase();return n?e.filter(r=>r.email.toLowerCase()===n&&((t==null?void 0:t.num)==null||String(r.num)===String(t.num))).map(r=>r.id):[]}function oP({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function hoe(e){return e===1?"Account needs your attention":"Accounts need your attention"}function foe(e){return`${e===1?"One Claude account needs":`${e} Claude accounts need`} you to sign in again.`}const poe="Login expired",moe="Until then the deck cannot read its usage or switch to it. Signing in again brings it back — it keeps its slot, its alias and its history.",goe="The account stays marked in the Accounts panel. This will not ask again until it has worked and stopped again.";function yoe(e,t){const n=(e??[]).filter(s=>s&&typeof s.fp=="string"&&!t.has(s.fp));if(!n.length)return{request:null,waiting:0};const r=[...n].sort((s,o)=>(s.at??0)-(o.at??0));return{request:r[0],waiting:r.length-1}}function woe({request:e,waiting:t,busy:n,now:r,onAccept:s,onDecline:o,onLater:l}){const c=y.useRef(null),d=ut(l,{focusRef:c}),h=gt(l),f=ia(n,"accept"),p=ia(n,"dismiss");return a.jsx("div",{className:"modal-backdrop",...h,role:"presentation",children:a.jsxs("div",{ref:d,className:"modal lan-ask",onClick:g=>g.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-ask-title","aria-describedby":"lan-ask-who",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("i",{className:"ap-pulse","aria-hidden":!0}),a.jsx("span",{id:"lan-ask-title",className:"modal-tool-name",children:"A deck wants to pair"})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:l,"aria-label":"Answer later (Esc)",title:"Answer later (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("p",{id:"lan-ask-who",className:"lan-ask-who",children:[a.jsx("strong",{className:"lan-ask-name",children:e.name})," at ",a.jsx("code",{className:"ap-lan-code",children:e.addr})," · asked ",j0(e.at,r)]}),a.jsx("p",{className:"modal-note",children:"Paired decks repair each other's expired logins. Accept only if you know this machine — what it shares is an account, not a screen."}),a.jsxs("p",{className:"lan-ask-fp",children:["Its fingerprint is ",a.jsx("code",{className:"ap-lan-code",children:e.fp})," — that machine shows its own under This deck on the network; the two should match."]}),t>0&&a.jsx("p",{className:"lan-ask-more",children:t===1?"One more deck is waiting behind this one.":`${t} more decks are waiting behind this one.`}),a.jsxs("div",{className:"lan-ask-acts",children:[a.jsx("button",{type:"button",ref:c,className:"btn",disabled:p.disabled,"aria-busy":p.busy,onClick:o,title:"Nothing is shared. If that deck asks again, this comes back.",children:n==="dismiss"?"declining…":"Decline"}),a.jsx("button",{type:"button",className:"btn primary",disabled:f.disabled,"aria-busy":f.busy,onClick:s,title:"Talk to this deck from now on, and repair its expired logins with this deck's own.",children:n==="accept"?"accepting…":"Accept"})]})]})]})})}function voe(e){const t=y.useRef(!1),n=xoe(e),r=oP({rows:n?1:0,ours:t.current,dialogs:ds.dialogDepth()});return t.current=r,r?n:null}function xoe({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:r,deferLanPair:s}){const{request:o,waiting:l}=yoe(e,t.current);return o?a.jsx(woe,{request:o,waiting:l,busy:n,now:Date.now(),onAccept:()=>void r("accept",o.fp),onDecline:()=>void r("dismiss",o.fp),onLater:()=>s(o.fp)},o.fp):null}function boe({rows:e,onSignIn:t,onLater:n,firstRef:r}){const s=e.length===1?e[0]:null;return a.jsxs("section",{className:"modal-body",children:[s?a.jsxs(a.Fragment,{children:[a.jsxs("p",{id:"reauth-lead",className:"reauth-lead",children:["The Claude login for ",a.jsx("strong",{className:"reauth-name",children:s.name}),s.alias?a.jsxs("span",{className:"reauth-alias",children:[" (",s.alias,")"]}):null," ","has expired and needs a new sign","‑","in."]}),a.jsx("p",{className:"reauth-note",children:moe})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:foe(e.length)}),a.jsx("ul",{className:"reauth-list",children:e.map((o,l)=>a.jsxs("li",{className:"reauth-row",children:[a.jsxs("span",{className:"reauth-who",title:o.alias?`${o.alias} — ${o.name}`:o.name,children:[o.name,o.alias?a.jsxs("span",{className:"reauth-alias",children:[" ",o.alias]}):null]}),a.jsx("span",{className:"reauth-what",children:poe}),a.jsx("button",{type:"button",className:"btn",ref:l===0?r:void 0,"aria-label":`Sign in again as ${o.name}`,onClick:()=>t(o),children:"Sign in again"})]},o.id))}),a.jsx("p",{className:"reauth-note",children:"Each keeps its slot, its alias and its history."})]}),a.jsxs("div",{className:"reauth-acts",children:[a.jsx("button",{type:"button",className:"btn",title:goe,onClick:n,children:"Not now"}),s&&a.jsx("button",{type:"button",className:"btn primary",ref:r,onClick:()=>t(s),children:"Sign in again"})]})]})}function koe({rows:e,onSignIn:t,onLater:n}){const r=y.useRef(null),s=ut(n,{focusRef:r}),o=gt(n);return a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal reauth-ask",onClick:l=>l.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"reauth-title","aria-describedby":"reauth-lead",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"reauth-title",className:"modal-tool-name",children:hoe(e.length)})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Not now (Esc)",title:"Not now (Esc)",children:"×"})})]}),a.jsx(boe,{rows:e,onSignIn:t,onLater:n,firstRef:r})]})})}function Noe({rows:e,signingIn:t,signIn:n,signedIn:r,refresh:s,closeSignIn:o,later:l,pairing:c=!1}){const d=y.useRef(!1),h=ds.dialogDepth()+(c?1:0),f=t!=null||oP({rows:e.length,ours:d.current,dialogs:h});return d.current=f,t?a.jsx(OI,{email:t.email||null,onClose:o,onChanged:s,onSignedIn:r}):f?a.jsx(koe,{rows:e,onSignIn:n,onLater:l},e.length===1?"one":"many"):null}const joe={"//":["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.","","A release that genuinely has nothing to say is spelled TWICE: no key here,",'and its version written into "//nothing-to-say" below. One spelling on its',"own is ambiguous — a missing key reads the same whether it was a decision","or a forgotten step, and five releases in a row were once forgotten. The list","is what tells the two apart, and release-notes-current-version.test.ts fails","the release whose version is in neither place. Any key opening with // is a","note to the author and never a release."],"//nothing-to-say":["3.23.1","3.23.2","3.23.3","3.23.4","3.26.0","3.26.1","3.26.3","3.26.4","3.26.5","3.27.6","3.27.7","3.28.0","3.28.1","3.29.3","3.29.4","3.29.6","3.29.7","3.29.9","3.33.1","3.35.0","3.35.1","3.36.0","3.36.1","3.36.4","3.36.5","3.36.6","3.36.7","3.36.8","3.36.9","3.37.0","3.38.0","3.38.1"],"3.37.1":[{title:"🔁 Expired logins repair from your other machines",body:"When a login stops working on this machine and a machine you paired with still has it working and ticked, Local network now copies it back on the next round, whether or not the account is ticked here. Before, it stayed marked expired until the account was ticked here as well, or deleted so that it arrived again. A machine that paired on its own, through Say yes to every deck that asks, still repairs only the accounts ticked here."}],"3.36.3":[{title:"🔑 An expired login asks to be signed in again",body:"When an account you added with + → Sign in stops working, the deck now tells you in one dialog, with every affected account together and Sign in again beside each. That opens the usual sign-in with the address already filled in, and the account keeps its slot, its alias and its history. Not now leaves it marked in the Accounts panel and does not ask again until it has worked and stopped again. A paired deck holding a working copy gets to repair it first, and accounts that came from a share or Local network are never asked about."}],"3.34.1":[{title:"🗂️ The tray menu stays open while you read it",body:"On Linux the menu behind the tray icon could close by itself while agents were working, often before the row you pressed took the click, so it had to be opened and pressed again. It now changes only when something it says has changed, and stays open while you choose."}],"3.34.0":[{title:"🗺️ The network map shows who you are connected to",body:"Paired decks that are on stand closest to this one, and a light runs along their wires. Paired decks that are away come next, in a colour of their own, with how long they have been gone, and machines that are not paired stand outside in grey. Decks reached over Tailscale sit together in their own shaded slice instead of on dashed wires. Pointing at a deck opens its details beside the map: whether it is there, what to do next if anything, its address and what it runs, and every login the two share, the ones that need a look first."},{title:"🔑 A login that expired everywhere says so",body:`When a shared login expired on this deck and every paired deck that is on held an expired copy too, the row said "Login expired" and waited for a repair that could never come. It now says "Login expired on all online decks". Claude retires a login's other copies each time one machine refreshes it, so shared copies expire together: sign in again on any one machine and the others repair from it on their next round.`},{title:"💬 Send feedback from inside the deck",body:'Appearance settings has a "Send feedback…" button: pick what kind it is, write a title and a few lines, and add a way to reach you if you want an answer. It goes to the people who make ccdeck, who may open a public issue from it, never with your contact in it. If it cannot be sent, the form stays filled in and says why.'}],"3.33.0":[{title:"🪝 Hooks you add in Claude Code are no longer removed",body:"Claude Code's hook editor often files a new hook into the same group as the deck's own. Starting the deck, or uninstalling it, then removed the whole group, and your hook went with it without a word. The deck now takes out only its own command and leaves yours where it was, and the same goes for the old finish-sound hook. `ccdeck --uninstall` also stops the decks that are running, so an update in the background cannot put the hooks back."},{title:"🧵 Resumed Codex sessions show up again",body:"A Codex session picked up with `codex resume`, or one that ran for days, could go dark on the canvas and drop out of the 5-hour and 7-day usage, because the deck only looked in the two newest day folders. It now follows those sessions and counts their tokens. Two Codex sessions in the same folder get different id suffixes, and a `bash -lc` call shows the command it runs."},{title:"🤝 A deck paired by the accept switch brings in less",body:'A deck that paired through the automatic accept switch, and not through an invite, now brings in only the logins you have ticked on this deck, and nothing from it is ticked for sharing onward. Its dialog says "paired automatically — pair by invite to take it". Pairing by invite works as before. A typed address is no longer dropped after one failed round, and the sync port stays the same after a rename.'},{title:"⬆️ Desktop updates install when you expect them",body:'On Windows and Linux a downloaded update now installs when you quit. On a Mac, Quit installs it and the app stays closed. The Linux .deb needs an administrator password to install, so it no longer does that by itself: it waits for "Restart to update" and says a password is coming. "Start at login" now works on Linux, and "Restart ccdeck" stops a deck that has hung.'},{title:"🕵️ Browser Watch waits before it acts, and quits only its own browser",body:"A program's visit is now logged and reacted to once its quiet window has closed, about 16 minutes after it, and not on the first poll, so a visit that is withdrawn no longer quits the browser. On Linux the quit reaction ends only the browser that holds the watched profile; other Chrome channels and headless browsers keep running. When it cannot tell which process that is, it does nothing and says so, which includes a Flatpak Brave."},{title:"🧮 Figures that were off are right",body:`Spend by labelled and workflow subagents counts toward a session's tokens and cost. The Projects report prices 1-hour cache writes the way ccusage does, so its dollars match the Usage panel. After a restart the deck rebuilds its whole event history, where it used to rebuild about a third. On Linux the process list shows what each process is using now, not its lifetime average. A count near a boundary reads "1.00M", and a full quota window says "used up".`},{title:"🔑 The Usage panel's reads answer the deck's own page only",body:"The routes behind the Usage panel (/api/quota, /api/ccusage, /api/codex-usage, /api/codex-quota and /api/cswap-auto) now answer the deck's own page, or a client that sends the deck's token. A script that read them with a plain request gets 401 from this version on. The hook, the desktop app and the `ccdeck` command are not affected."},{title:"🛠️ Smaller fixes you may notice",body:"With the canvas paused, an update no longer restarts the server while an agent is working: it waits until no turn is open. `ccdeck --stop -p4317` stops that one deck. A deck started at login can update itself on Homebrew and nvm setups. Dialogs keep keyboard focus after a button goes away, screen readers hear pairing requests by deck name and the machine panel's readings, dim text is readable in both themes, Windows High Contrast shows what is selected, and below 640px the detail panel opens over the canvas."}],"3.32.2":[{title:"🔒 Self-updates wait until your screen is unlocked",body:"On Linux with GNOME, the app installs an update by itself when you leave it alone, which is often while your screen is locked. GNOME switches the panel's tray off under the lock screen, and a version that started then never showed its icon. The app now waits until you are back before restarting by itself, so its icon comes back with it."}],"3.32.1":[{title:"🔔 The tray icon comes back on Linux",body:"On Linux the app could lose its icon in the panel, after it updated itself or when the panel restarted, and stay without it until it was quit. It now notices within a minute and restarts by itself the next time you are away from its window, the way it installs an update. It does this at most once every six hours, and not again if a restart did not help."},{title:"🔕 A window you closed stays closed after a self-update",body:"When the app restarted by itself to install an update, it opened its window again even if you had closed it, and while that window was open the deck held back its notifications. A window you closed now stays closed."},{title:"🪟 No empty icon when ccdeck is already open",body:'Opening ccdeck again while it was running flashed an empty "…" icon in the Linux panel before bringing the window forward. It now only brings the window forward.'}],"3.32.0":[{title:"🗺️ A map of your network",body:"A new button on the Local network row, and in its view's header, opens a map of every deck around this one. This deck is at the centre and the paired decks that are on stand around it. Further out are the quiet ones, the machines nearby and any deck asking to pair. Wires are solid on your local network and dashed over Tailscale. Pointing at a deck says how it is reached, what it runs and which logins the two share, and pressing it opens that deck's own dialog."}],"3.31.0":[{title:"📊 Account capacity",body:"A gauge button in the accounts panel's header opens Account capacity: how many of your Claude accounts are ready now, what the 5-hour and 7-day windows have left across all of them, and a row for each account with its use, its state (Ready, Limited, Exhausted or Stale) and when it was last read. Each window also says whose reset comes next."},{title:"🚦 Claude and Codex incidents",body:"When Anthropic's or OpenAI's status page reports an incident on something your sessions use, the deck says so in the topbar, the Usage panel and the tray, and every mark links to the status page. A provider with nothing wrong draws nothing."},{title:"↕️ Order your other accounts",body:"The Other accounts row can sort the list by slot, by how full a window is, or by most room, and open every account at once. Both stay as you left them after a reload."},{title:"🔐 A settings folder left by sudo can be given back",body:'On a Mac, running ccdeck once with sudo left its settings folder owned by another user, and every settings change was refused, sharing an account included. The message now offers "give it back": macOS asks for your password, the folder is yours again, and the deck reads its settings back without a restart.'}],"3.30.0":[{title:"🧮 Token counts and costs are no longer doubled",body:"Claude Code writes a reply that has thinking, text and tool calls as several transcript lines, each carrying the whole request's usage. The deck added up every line, so a session's tokens and cost on its card came out close to twice what it was billed, and the context panel counted each part of a reply as its own message. Each request is now counted once. Expect the totals on your cards to come down."},{title:"⏳ Claude's saved limit resets on the Usage panel",body:`When your Claude account has free limit resets to spend ("Reset for free" in Claude's Settings → Usage), the Claude card now says how many there are and when the first one expires, the way the Codex card already did. The deck only reports them; you spend them in Claude's own settings.`},{title:"🔑 LAN invites need the other deck updated",body:`An invite's code is now a long random secret instead of six digits, so nobody else on the network can work it out and pair in your place, and a wrong code is refused by name. An invite made on this version can only be joined from a deck on this version or later: an older deck answers "That is not an invite". Update that deck, or make the invite on the older one and join it here.`},{title:"🔕 AGENTS_DECK_NO_NOTIFY keeps Browser Watch quiet too",body:"A deck started with AGENTS_DECK_NO_NOTIFY=1 still raised a desktop notification for every new Browser Watch finding. It no longer does. The finding is still in the Browser Watch panel and its log, which says why no notification came."},{title:"🛠️ Smaller fixes",body:'Delete removes the card you just clicked. A LAN address you typed stays in the list when a round cannot reach it, and the status line under the LAN switch now agrees with the rows below it. In the desktop app, a dismissed "update is ready" notice stays dismissed after you answer the first-launch question. Sizes read the same in every panel ("1.1 KB"). Faded text stays readable, a keyboard can see the scrollbar, and numbers use a monospaced font on Windows and Linux as well.'}],"3.29.11":[{title:"💲 Claude Sonnet 5.5 has a price",body:`Sessions on Claude Sonnet 5.5 showed "not priced" on the board, and the Projects report could only show a minimum for them. They are now priced at Anthropic's published rate, the same as Sonnet 5: $2 per million input tokens and $10 per million output tokens.`}],"3.29.10":[{title:"💲 Claude Opus 5.5 has a price",body:`Sessions on Claude Opus 5.5 showed "not priced" on the board, and the Projects report counted them as costing nothing, so its totals read far too low. They are now priced at Anthropic's published rate. If a model still has no price, Projects shows its total as a minimum, like $11.19+, and names the model, instead of a total that looks complete.`}],"3.29.8":[{title:"🔁 Removed cards come back when their agent works again",body:"Remove from board is for finished work. If the agent behind a card you removed starts a tool call, gets a new prompt or starts a subagent, the card returns on its own, together with the card it hangs from, and it stays back after a reload. Cards whose agents stay idle stay removed."}],"3.29.1":[{title:"🗂️ One row per project in Projects",body:"The Projects report now counts a session's work under the folder you started it in, the same name its card has on the canvas, instead of adding a row for every folder the agent moved into. The first start after updating re-reads your transcripts once to regroup the report."},{title:"🔔 Tidier custom sounds",body:"Importing a sound, recording one and choosing a spoken voice now sit in compact cards that respond to clicks and focus like the rest of the deck."}],"3.29.0":[{title:"🎵 Your own stations in Claude FM",body:"Add any YouTube live link or radio stream as a station in Appearance, next to the built-in ones, and mute the music without losing your volume. When a station is not live, the picker now says so instead of staying silent."},{title:"🔔 Notification sounds and voices of your own",body:"Pick a local audio file or a spoken voice for each alert, so the sound that means an agent is waiting is one you will recognise."},{title:"🗑️ Drag a card off the board to remove it",body:"Drag a card to the target at the bottom of the canvas to take it off the board, or use Remove from board in the detail panel (Delete). The session keeps running, and the session list (L) brings it back."},{title:"🔐 Optional invite-only pairing",body:"Pairing works as before, with or without an invite. If you want, Local network can now be set to accept only decks that join with an invite you created, so a nearby machine cannot ask to pair on its own."},{title:"🌐 Account sharing between your machines is more reliable",body:"A locked macOS Keychain is explained instead of failing silently, a login that is broken or belongs to another account is never shared, and a sync that stops partway keeps what already arrived."},{title:"📅 Projects opens on Today",body:"The Projects report per account starts with today's work, and an empty window offers the next wider one. The topbar also shows this month's usage, and the desktop app can restart into an update from its own window."}],"3.27.0":[{title:"📊 Projects: where each account spent its work",body:"Each account card's ⋯ menu now breaks its cost down by project, over 7d / 30d / all."}],"3.27.1":[{title:"🎨 Make Appearance easier to tune",body:"The Appearance dialog now has clearer sections, stronger selection states, and a calmer layout for choosing a theme and configuring music. Your existing settings and keyboard shortcuts continue to work."}],"3.27.2":[{title:"💰 Project costs now match Usage",body:"Project cost totals no longer count the same Claude request once for every content block. Existing project history is rebuilt automatically so the totals align with the Usage panel."}],"3.27.3":[{title:"🎵 Station selection works in the desktop app",body:"The music station picker now opens inside ccdeck instead of relying on the operating system popup, so choosing a station works reliably in the Electron app."}],"3.27.4":[{title:"✅ Desktop picker release checks are green",body:"The station picker now keeps the same keyboard, motion, focus, and layout behavior as the rest of ccdeck across desktop and browser builds."}],"3.27.5":[{title:"🧭 The welcome tour stays dismissed",body:"Electron now remembers that you completed the onboarding tour at the deck level, so an update or loopback port change no longer shows the same tour again."},{title:"🎵 The station picker has a clearer finish",body:"The music selector has a tighter trigger, a purposeful chevron, and more deliberate option spacing so it reads like a native part of Appearance."}],"3.25.0":[{title:"🖱️ A click goes to the session, a double-click opens the details",body:"Clicking a card frames it with the rest of its session and leaves the detail panel shut. Double-click a card to open its details; `j`/`k`, the session list, Enter and `D` still open them too."},{title:"🔭 Cards stay readable when you zoom out",body:"At every zoom a card shows its name, its state and anything waiting on you, instead of shrinking to a coloured pill. Hover or focus a card to see it whole. Recap notes read at a distance too, and show the full recap on hover."},{title:"🌐 The Machine panel shows your network",body:"A new Network section shows download, upload and the round trip to Claude's API, and names the route when traffic goes through a VPN or a Tailscale exit node. Those checks run only while the panel is open. The panel is regrouped into CPU, Memory, Network and Thermal, with a flag at the top when something needs attention."},{title:"🎨 See each theme before you pick it",body:"The Appearance menu shows a small preview of the deck in Light and in Dark. Claude FM also keeps its volume when a notification chime plays, instead of dipping under it."}],"3.24.1":[{title:"🎛️ Appearance is one small menu now",body:"The topbar's appearance control opens a compact menu where you can choose Light or Dark and show or hide the character. The character stays on by default, and your choice is remembered."}],"3.24.0":[{title:"🎧 Claude FM plays from the minimap",body:"A small character stands on the minimap's top edge. Press it and the Claude channel's live stream plays; press it again and it stops. It only turns up when the channel is actually broadcasting, so a deck with no network never shows it at all."},{title:"🤠 And it gets on with its day",body:"It walks that edge, tidies up what it finds, kicks a ball along it, sits with its legs over the side, and watches the board through a scope. Now and then it drops onto the canvas and ropes its way back up. Headphones on while the music plays, a hat when it does not."}],"3.23.5":[{title:"🧭 The accounts panel opens on the account you are on",body:"Its windows, its resets and how old the numbers are — whole, at the top of the column. Every other account stands behind one row that says how many of them a switch could actually reach; press it to see them, or rest on it to be shown their names and how much room each has left."},{title:"⚙️ Auto-switch moved in there with them",body:"It is behind that same row now, after the accounts it switches between, rather than at the foot of the panel. The row says `auto 90%` or `auto off` so you can tell what the policy is doing without opening it — and says so in amber when it is armed with nowhere left to go."}],"3.23.0":[{title:"🧭 The accounts column leads with accounts",body:`The live account is the open row: its windows as bars, when each one resets, and how old the numbers are. Every other account rests on the two figures a switch is decided by, and opens with a click when you want the rest.
110
-
111
- A problem stays on the row — an expired login, one that was never stored, a keychain the deck cannot open — with the reason and the sign-in one press away. Auto-switch is one row now: its threshold and its switch. Local network moved out of the column into a view of its own, reached from a row at the foot that says how many of the paired machines are on right now, and shows which ones when you hover it.`},{title:"💬 A resting session shows Claude Code's recap beside its card",body:"When a session stops, Claude Code's own recap of what it did is drawn beside the card — so a board you come back to says what happened without opening anything."},{title:"🪟 The chrome went quiet",body:`The topbar is borderless, one set of corners runs through the app, the canvas ground is flat, and the minimap, the zoom controls, the type filter and the Machine and Usage panels read as tooling rather than as cards.
112
-
113
- The canvas also says when auto-fit is off, with one press to bring new sessions back into view.`},{title:"🔍 A tool call's detail reads as the call",body:"A tool call's arguments are shown as the call rather than as escaped JSON, and can be copied."},{title:"🔐 Saying yes to every deck that asks takes two presses",body:"The switch that accepts every pairing request arms first and says what it hands over, so one stray click cannot put this machine's logins on another deck."},{title:"🖐️ Targets, themes and contrast",body:"The panel's smallest controls reach the 24px target floor, and grow further under a finger. A first run follows the system's light or dark setting instead of picking one. Status dots, meters and switch knobs survive a Windows Contrast theme."}],"3.22.15":[{title:"🖱️ Clicking a card opens its details",body:"Selecting an agent is inspecting it: a click, `j`/`k`, a session picked from the list and Enter on a focused card all open the detail panel — prompt, every tool call, tokens, timing. It used to open only with `D`, so anybody who closed it with its × and never found the key did not get it back. The × still closes it until the next selection, and `D` still toggles it.\n\n`D` with nothing selected now picks a card first — the session that has waited longest, or the one `j` would land on — instead of flipping a switch with nothing on screen to show for it."},{title:"⌨️ The keyboard and screen readers reach the whole deck",body:`Shortcuts keep working after a mouse click on a button. A click left focus on the button it pressed, and the key handler leaves a focused control its own keys, so every single-key shortcut was dead until you pressed Esc — with nothing on screen to say so.
114
-
115
- Tab follows the page now — topbar, the accounts column, the canvas, usage, machine — instead of zig-zagging left and right across it, and a canvas card reached by Tab draws the focus ring. A screen reader hears each card by name, with its kind, state, model and cost, rather than every word on it run together; the machine panel has a heading its region is named by; and the theme button is named for the theme it switches to.
116
-
117
- With **Reduce motion** set, the camera no longer flies across the canvas to a card.`},{title:"💵 The money figures say what they measure",body:"The usage header's **$/min** is spend over a trailing window, and says which span it measured: `$3.54/min · 2 min`. It used to divide the live agents' cost by how long the longest of them had been running, so one deck read $2.39/min in a tab left open and $19.49/min in a tab opened minutes later.\n\nA quota bar's pace says **over pace** or **under pace**. It said `ahead`, which is how plain English says winning, on the very line meant to warn you that you are burning the window faster than it lasts.\n\nA card's clock reads `≥ 53m 52s` for a session this page joined after it had started, instead of presenting the part it saw as the whole of it — and that card's per-minute burn is left out rather than divided by the short clock."},{title:"↔️ Narrow windows keep every topbar control on screen",body:`At 400px six of the topbar's buttons sat past the right edge and the page scrolled sideways. The readouts give way first now and the controls stay; below 640px the side panels span the window instead of leaving the canvas a sliver; and the category filter wraps inside the canvas rather than being clipped by it.
118
-
119
- Zoomed out, a card's name and a cluster's label stay readable instead of shrinking to about four pixels — which is the view a board of any size actually sits at.`},{title:"🔑 A paired deck's dialog says which account that machine is on",body:`The lane of the account the other machine is working on takes the accent and a slow ring on that machine's end. An account is named only if that deck shares it: on one it does not share, the dialog reads "on another account" and never which. A new switch under **SHARE THESE ACCOUNTS**, on by default, turns the telling off, and paired decks then read "current account hidden".
120
-
121
- **This deck on the network** prints this deck's own fingerprint again. A pairing request asks you to match it against the one on the other machine's screen, and no screen here was showing it — so the one check a person can make against a rogue deck could not be made, on the step that hands over logins.`},{title:"💬 The deck's messages send you somewhere worth going",body:'An empty canvas no longer ends with "Make sure ccdeck is running" while the page is plainly connected to it. The capture hints under that line, one per CLI, are the real reasons a canvas stays empty, and they stay. With the stream down the screen says whether this page lost a deck that was there or never found one, in those words, rather than naming the `/events` route nobody who typed `npx ccdeck` has seen.\n\nAnd a slow `claude-swap` now reads as a slow answer — "still waiting on the deck server" — instead of "couldn\'t reach the deck server", which sent people off to restart a server that was fine.'}],"3.22.10":[{title:"🖱️ Icon buttons are easier to hit",body:"Icon buttons react when the pointer is near them — no need to hit the icon exactly."},{title:"🧩 Sessions spread across the canvas",body:"Sessions now spread across the canvas in columns instead of one tall column, and new sessions and subagents land in the free space beside them. Nothing is placed under the Machine or Usage panels. Press R once to rearrange a board you already have."}],"3.21.0":[{title:"🖼️ The deck explains itself in pictures",body:"🎬 First run opens an eight-picture tour instead of the changelog — who is waiting on you, the tree, a node's inside, cost and quota, this machine, accounts, local network, how to start. `Take the tour` on an empty canvas brings it back.\n\n📡 **Local network** has a guide: a card while it is off, `How it works` under an empty list, four pictures ending on `Turn it on`. A machine's row opens its own dialog — address, version and system, the logins it offers, and a name of your own for it. Setup ends on Done.\n\n🔄 The deck updates itself when nobody is looking: no tab focused, no agent mid-turn, thirty seconds quiet. The banner's `auto when idle` switch governs it.\n\n🔑 An account whose numbers were paused resumes on its own, and the panel is titled **Claude accounts** — a Codex login is not in it."}],"3.20.0":[{title:"🟢 The deck keeps running after you close the terminal",body:"`ccdeck` prints the same boot report and gives you the prompt back. The deck stays up, and starts again when you log in.\n\n🛑 **`ccdeck --stop` is the off switch now** — Ctrl+C only cancels a start that is still printing. `--status` says what is running, `--logs` shows what the deck wrote while you were away, and `--foreground` holds the terminal the way every version before this one did.\n\n🔁 Typing `ccdeck` beside a deck that is already up opens **that deck's tab** instead of building a second one. `ccdeck --stop --all` clears any older deck still running from before this version. An `npx` run cannot start at login — `npx ccdeck --install` puts it on your PATH and sets that up.\n\n🔑 An account that will not collect now says which of three things is wrong: **no stored login**, a **login that expired**, or a **keychain the deck cannot open** — with the fix beside it. One with no stored login is filled over the local network by a paired deck that has it.\n\n📡 And decks find each other again on a machine with a VPN up: the beacon was going to an address that never left the machine, so this deck could hear colleagues and none of them could hear it."}],"3.19.0":[{title:"🟢 Local network: fixes and improvements",body:`The list of decks is quiet now. A deck that is **on**, with nothing to repair, is a name and a green mark — no sentence under it. Every healthy row used to carry the same words, so the one row worth reading looked like all the others. A failure, a login that arrived, a machine that is away, still say so, and they are now the only rows with anything written on them.
122
-
123
- \`unpair\` arrives when you point at a row rather than sitting on every one of them, two machines that share a name show their addresses, and the ↻ turns while a round is out.
124
-
125
- **Add a deck** is two ways in — by address, or with an invite — with \`make one to send\` beside the invite heading instead of under the paste field, where it read as that field's button. A refused address now says which mistake it was, and an invite that will not work says whether it ran out, was not an invite, or reached nothing.
126
-
127
- Switching **Local network** on opens your name and shared logins, every time, so nothing goes on the network without you having just seen what goes with it.`}],"3.18.3":[{title:"🟢 The list shows what is on, and folds the rest",body:'A machine that is off, or nearby and unpaired, or one you said no to, is context rather than an answer to "who can I use right now" — so the decks that are **on** lead the list and everything else is one line: `2 more`. Nothing worrying is hidden by it: a deck that cannot be reached is counted in that line, in the warning colour, so the fold says whether it is worth opening.\n\nThe round moved to a **↻ beside the switch**, where the accounts header has kept the same act since it was written, and the line under the state now says when it last ran — `checked 2m ago`, or `not checked yet`. A list that refreshes itself and a list that has stopped used to look identical, and pressing the button to find out was the only way to tell.'}],"3.18.1":[{title:"🔁 A deck stops asking to pair over and over",body:"Several decks on one computer share a config directory, so they start with one key. Each read the others' beacons as somebody wearing its name, took a fresh key, and wrote it to the file the others read — a loop that never settles. Every new key is a **new deck** to everyone else on the network, so one machine sent a fresh pairing request every few seconds and accepting one accomplished nothing: the deck that asked no longer existed by the time the answer arrived.\n\nDecks on one computer now recognise each other as the same machine and leave the key alone. The clash still worth healing — a `~/.claude` copied to a second machine — is unchanged.\n\nThis also collapses the rows: a computer that has run the deck a few times appeared several times on everybody else's panel and is one row now. **Both machines need this version** for that to take effect on the other one's screen.\n\nA deck that answered is no longer counted as unreachable, the list refreshes itself in seconds while somebody is deciding rather than at the next minute, and a failed round says what happened — `not listening`, `no route to it` — with the address and the raw error on the hover."}],"3.18.0":[{title:"🟢 A deck that is switched off no longer reads as on",body:"A paired deck this one has no address for was drawn **live** on the strength of being paired — a machine closed an hour ago still sat under `1 deck ready`. Every row now leads with whether that machine is actually there, and when it last was: `online · 1 login arrived`, `no answer · last online 20m ago`, `never reached`. The mark beside the name is a traffic light — green for a deck that answered, amber for one that cannot be reached, grey for one nothing has heard from.\n\n**+ add a deck** opens a dialog now instead of unfolding inside the panel. An address, an invite and the firewall note never fitted a 288px column, and unfolded they turned a list of machines into a form."}],"3.17.0":[{title:"🔔 Pairing is two presses",body:`When another deck asks to pair, the question now arrives **over the deck** rather than in a row three sections down a panel: its name, its address, the fingerprint to compare, **Accept** or **Decline**. Escape means later — the request stays in the panel until you answer it.
128
-
129
- The rest is one list. Every deck you are paired with, every deck on the network, and every one you turned away, each a row with its state under the name and one verb at the end — and a deck that cannot be reached now reads differently from one that is fine. Saying no also reaches the other machine now, instead of leaving it waiting forever; you can take it back.
130
-
131
- The dialog behind **setup** is down to the two things it is really about: what this deck is called, and which logins it offers.`}],"3.15.0":[{title:"🔗 Decks on one network heal each other's dead logins",body:`A login dies on the machine that has not used it while the same account keeps working on the machine that has. The fix was a blob copied out of one deck and pasted into another. Now: **Accounts ▸ Local network**, the same passphrase on each deck — it offers you six words — and they find each other and repair themselves.
132
-
133
- A deck only **adds** an account it does not have, or **replaces one it has proven dead** — proven by Anthropic refusing the token, not guessed. A credential that works is never touched. The passphrase is the only gate; a stranger on the same wifi sees that a deck exists and nothing else.`},{title:"⚠️ What sharing a login actually means",body:`**A login you share is a live one, and it cannot be taken back.** Turning the switch off stops what has not happened yet; a credential that has left your machine is gone, and the only real revocation is signing in again at Anthropic — which ends the session everywhere at once.
134
-
135
- Sharing a Claude account may also be against Anthropic's terms. Your call; the deck says it once and does not nag.`}],"3.14.0":[{title:"📊 The machine comes back beside the list that covers it",body:`**Busiest processes** opens over the machine panel and hides the very readings that sent you looking. They are back beside the list — cores, memory, swap, queued work, temperature — with up to an hour behind each: a column down the side on a wide screen, a band under the table on a narrow one.
136
-
137
- Each is drawn against the line it is measured to — memory and swap at 90%, load at your core count, the GPU at 75° and again at 90° — so swap sitting *on* its line is something you see rather than work out. The processor readings get no line on purpose: a CPU at 90% is your machine doing what you asked for. Throttling appears only once your machine has actually been held back, and the band says how much history it really has rather than claiming an hour it has not had.`},{title:"📋 The process dialog's footnote moved onto the columns it was about",body:"A band ran along the bottom of **Busiest processes** saying three things. Two were worth keeping and are now on the header of the column they describe — hover `memory` to read what that number measures, `process` to read that the command-line redaction is a filter rather than a promise.\n\nThe third said the list is the busiest by processor and memory, refreshed every four seconds. The heading, the count beside it and the moving numbers were already saying that."},{title:"📝 These notes render what they were written in",body:`Every note in this dialog is written in Markdown — **bold** for the sentence that carries the change, backticks for a flag or a path — and the dialog printed the string raw. So the first window you see after an upgrade has been showing you \`**this**\`, backticks and all, since the feature shipped: 25 of 52 notes, 52 bold spans, 54 code spans.
138
-
139
- What you are reading is the first version that does not.
140
-
141
- No Markdown library came along for it. Counted in the file: bold 52, code 54, links 0, headings 0, lists 0 — and the smallest library that reads all of Markdown is 40KB on a bundle the deck fetches while you wait for it to start.`},{title:"⎋ Esc leaves the machine panel where it is",body:"The × on **This machine** read `Close (Esc)`, so Escape put the panel away. Escape belongs to the canvas — it deselects and hands the keyboard back — and pressing it while you are reading your instruments should not close them.\n\nThe panel now closes the two ways it opens: its ×, and the meter in the topbar. The × says `Close`, and names no key it does not answer."},{title:"🖥 The machine moved out of the topbar and into a button",body:"The small CPU sparkline and memory bar in the topbar are gone. A chip glyph in the icon row beside `$` and the accounts silhouette opens the same **This machine** panel — cores, memory, swap, load, temperature, busiest processes — and the bar stops moving in the corner of your eye.\n\nIt also stops asking. The deck read your machine every three seconds for the life of every tab to feed that meter; it now reads only while the panel is open, and the history behind the readings is kept by the deck itself, so a panel opened an hour from now still has the hour behind it."},{title:"🔎 The panel's eight process rows became one way in",body:"The machine panel drew eight processes in a 280px box: three columns, names cut off mid-word, and a `ps` run every four seconds to keep them moving. **Busiest processes** is a single row you press now, and the dialog behind it is what it always was — every candidate the deck sees, its memory in bytes, threads, user, pid, and the command line that tells you which `node` this one is.\n\nWith that dialog closed, the deck reads no process list at all."},{title:"⏱ The restart banner says whether the press is safe, and shows the fuse",body:"The button read `Restart now` whether the machine was idle or five agents were mid-turn — and the events fired while the server is down are lost for good. It reads **`Restart anyway`** now when something is running, with the count beside it, and `Restart now` with *nothing is running* when the machine is quiet.\n\nThe automatic restart said only `auto when idle`, while a 30-second clock ran where nobody could see it. It counts — **`auto in 18s`** — which is also how you stop it, since the switch is the label. The amber dot pulses only while that clock runs.\n\nThe switch also says `auto-restart off` in words rather than in a colour, both its label and the button are readable in the light theme now, and a tab you are not looking at no longer restarts the deck under the tab you are."}],"3.13.0":[{title:"📊 Usage history stops jumping out from under you",body:`Pressing **H** put \`running ccusage…\` in a box 186px tall. Two to four seconds later the chart, the totals and the legend arrived and the box became 429px — and because the dialog is centred, that growth moved the whole thing **121px upward**, under the cursor that had just pressed something.
142
-
143
- The chart's place is now reserved from the first frame: the 168px the chart is tall plus the 16px it keeps for its day labels, both taken from the chart's own rule so the placeholder and the thing it holds room for cannot drift apart. The jump goes from 243px to 156px. It deliberately stops there — the totals and the legend are content, the legend's height depends on how many models ran, and reserving those would have meant drawing four plausible empty cards for a reading that had not arrived.
144
-
145
- What is drawn in the reserved space is **the chart's baseline and nothing else**: one line, in the same colour, at the height the columns will land on. Not a skeleton of grey bars — a skeleton stands in for content, an axis is furniture, and furniture is honest before the data exists. The light on it travels rather than fills, because the deck knows a subprocess is running and does not know how far through your transcripts it has got.
146
-
147
- Then the days rise out of that line, **oldest first**. The stagger is divided rather than fixed — 200ms of spread whether the range is 7 days or 90 — so the longest range is not also the slowest to appear.
148
-
149
- With reduced motion both loops and both entrances are off. The reserved space is layout, not animation, and stays outside that rule: asking for less movement gets you the same dialog that does not jump.`},{title:"⏳ The period mark says it is being read",body:"The first read of **today**, **month** or **all** takes two to three seconds — it walks the transcripts on this machine, and the cost is the walk, not the size of the range you asked for. Until now the panel said nothing for the whole of it, so pressing `month` looked like pressing nothing, and the honest response was to press it again.\n\nThe mark under the period now pulses while that read is in flight, and it **pulses rather than fills**: nothing measures how far through the transcripts ccusage has got, so a bar that filled would be inventing a number. Hovering the pending period says which one is being read, and screen readers are told the same thing through a live region rather than being left with a silent button."}],"3.12.0":[{title:"🔍 Busiest processes tells you which one",body:"The list could say what was eating the machine and not **which** of nine identical `Google Chrome Helper` rows was the headless Chrome you left running. It now shows the arguments after the name — `--type=renderer` beside one, `serve admin-portal --port 44440` beside a node — and four columns it did not have: **memory in MB and GB** instead of a percentage, **threads**, **how long it has been up**, and **user**. Every column sorts; press its heading.\n\n**Command lines have anything secret-shaped removed before they leave your machine** — the value of any flag whose name says token, password, key or secret, the password in a URL, and the shapes that identify themselves. It is a filter and not a guarantee: a secret that looks like an ordinary word looks like an ordinary word. The reading happens only while this modal is open, so a deck whose process list you never open never reads a command line at all.\n\n**Memory is resident set size** — what `ps` and Windows Task Manager report. On macOS this is *not* the number Activity Monitor shows in its Memory column; that one is the physical footprint, and on the machine this was built on the two disagree by up to fourteen times on the same process. No unprivileged command reports the footprint quickly, so the deck shows the figure that means the same thing on all three platforms and says which one it is.\n\n**There is no Ports column**, and the reason is the same kind of honesty: Mach ports do not exist on Linux, are not what Windows calls a handle, and on macOS the only way to count them takes four seconds — against a list that refreshes every four."},{title:"🔢 A token count that stays a whole number",body:"Switching the Usage panel from **month** to **today** counted down smoothly and then, for a fraction of a second, showed something like `in 594.3268260610639` where a token count belongs.\n\nThe count was never wrong; the printing was. The figures animate between two readings, so the formatter is handed a fraction on most of its frames — every size above a thousand was already rounded and the one below it was not."}],"3.11.0":[{title:"🗂 The session list waits to be asked for",body:`**BY SESSION in the Usage panel now starts collapsed.** It is the one block in that panel with no ceiling — every other section is two or three rows, or a model table bounded by the models that exist — and it was the reason the panel scrolled at all. Shut, the whole panel is one screen: quota, period, money, models. Press the heading to open it, and it stays open; ccdeck remembers your answer from then on.
150
-
151
- The count of what is behind it is on the heading's tooltip, so collapsing it does not hide how much there is.
152
-
153
- **Scrollbars are also gone until you point at the thing that scrolls.** Nothing moves when they appear — the track keeps its width in both states, so no text shifts under the pointer as it arrives.`},{title:"📊 today · month · all, as tabs that remember",body:"**The Usage panel's period switcher is a full-width row of tabs** rather than a pill floating over the column, with a thin cyan mark under the word it belongs to. It governs the figures beneath it, so it now looks like it does.\n\n**Your chosen period survives a reload.** It was the one preference in that panel that did not.\n\n**It costs one Tab stop instead of three.** Tab into the strip, then move with ←/→ or Home/End, and press Enter to choose. Arrowing past a period no longer starts reading it — moving and choosing are separate now, which matters on `all`.\n\nAnd **`month` says which month.** Hover it: this is the calendar month, from the 1st — not the last 30 days. `today` and `all` say what they cover too."},{title:"🔔 Sounds and Notifications are two switches, and Browser notifications is a channel",body:`**The sound menu has been rebuilt.** Sounds and Notifications are real switches now instead of words that read like status. Under them, **Browser notifications** is named as what it is — one of the two ways ccdeck can reach you — rather than sitting there as a third setting that seemed to contradict the one above it.
154
-
155
- There are two notifiers and they never both fire: the page raises one when the deck is open but hidden, and the server raises one when no page is open at all. Only the first needs a browser permission, which is why the permission belongs to a channel and not to the feature. **Turning Notifications on now asks the browser on that same press** — no second control to hunt for.
156
-
157
- \`M\` mutes and unmutes sounds from anywhere. **Hear it** plays the tone even when Sounds is off, so you can pick one before turning them back on.`},{title:"🧹 No agent, no empty panel",body:`**The detail panel no longer appears when nothing is selected.** It used to sit there empty, and a tab on the edge of the canvas existed to bring it back after you closed it — both are gone. Select an agent and the panel is there; press **D** to toggle it yourself.
158
-
159
- The canvas is that much wider whenever you are not reading one agent.`}],"3.10.0":[{title:"🔌 Who else can drive your browser, and where to see it",body:"**Browser Watch has a Remote control section.** The Claude in Chrome extension holds a connection open to Anthropic's relay, and that connection is registered against your **account**, not against this machine — so any Claude Code session signed in to the same account, running anywhere, can enumerate and drive this browser, and nothing prompts you on the machine being driven.\n\nThe panel now says whether that is the case here, and what the extension is actually allowed to do in each profile — enabled or switched off, every site or only the ones it was granted, and which of the powerful APIs it holds. That last part is not what `chrome://extensions` shows you: the per-site list there is enforced by the extension, on itself, while the grant underneath stays exactly as wide as it was.\n\nIf you want it closed, the section hands you the one command that closes it — as text, to paste in your own terminal. **ccdeck never runs it and never asks for your password**, and it never will: no part of this deck elevates, and a dashboard that could raise a password box on request would be a gift to anything else running on the machine. If the block is already in place, the section offers the command that takes it back out. And if something else in your hosts file already points that name somewhere, it says so and leaves the line alone — ccdeck only removes the line ccdeck wrote.\n\nAll of this is two file reads and no network call. It was written some releases ago and, until now, was not connected to any screen.\n\n**Also:** the README said `share` produces a `ccdeck1:` blob. It produces `ccdeck2:` — `ccdeck1:` has been read-only legacy for a while."}],"3.9.0":[{title:"🎛️ Five switches that were not where the thing they control is",body:'**The session list has a button again.** It lost one a while back and only the `L` key was left — and `L` is written down in one place, a shortcuts sheet behind a small `?` in the corner of the canvas. If you use a mouse there was no way to open the list at all. The `☰` is back at the left of the top bar.\n\n**The Notifications switch now tells you whether the browser will actually show one.** It said `on` while this browser had never been asked for permission, which is not the same thing. It now says so on that row and offers the ask right there. Before, the only place to grant it was a button that appears solely while a session is stuck waiting — so on a machine where that rarely happens you could not switch notifications on at all.\n\n**Started with `--workspace` or `--scope` and seeing nothing?** The empty screen used to tell everyone to "run `claude` or `codex` in any folder", which is the one thing that cannot work for you. It now names the folder the deck is actually watching.\n\n**Browser Watch says when a setting did not save.** Flipping the switch and having it fail showed a red line reading "Could not read" — about reading history, not about your press — and ten seconds later the panel wiped it and looked perfectly healthy with the setting unchanged. A failed save now says so, in its own words, and stays until you dismiss it. The "nobody browsing for" menu also follows the stored value again: change it in a second tab and this one never caught up.\n\n**The deck no longer restarts itself when nothing on screen offers to stop it.** Thirty seconds after the last agent went quiet, with a new version on disk, the server would exit, come back and reload the page. The `auto when idle` switch that controls that lives inside the update banner — so if you had closed the banner with its `×`, it happened with no visible setting anywhere. Closing the banner now also stands down the restart; clicking the version chip brings back both together.'}],"3.8.9":[{title:"🖥️ Four things that only went wrong on somebody else's operating system",body:"**Ubuntu:** the deck knew where Chromium and Brave keep their profiles when installed as a snap or a flatpak — which on a default Ubuntu is the only place Chromium is — but not what those programs are called. So it reported them as not running while they were, and refused to quit them. Both now work.\n\n**Windows:** the deck asked the system whether it could write to the folder an update installs into, and Windows always answers yes for a folder whatever the permissions say. It offered you an update that then died inside npm with a permission error. It now finds out by trying, and declines up front with the command to run yourself — which is what every other platform already got.\n\n**Linux:** if `XDG_DATA_HOME` was set to something starting with `~`, as it is from a systemd unit or a Dockerfile, the deck and claude-swap looked in two different places for your accounts. The panel said you had none while `cswap list` showed them all.\n\n**Plain terminals:** six messages used a typographic dash the old Windows console and the Linux text console cannot draw, so a box appeared mid-sentence — including in the line that explains why no events are arriving. They use the plain form on those terminals now, like everything else already did."}],"3.8.8":[{title:"📉 A false 99% on the memory chart, and three other quiet failures",body:`**The machine meter no longer invents a reading.** When the deck could not measure memory — a subprocess that would not start under load, or one that took too long — it substituted a number that means something else, and on a Mac that reads as about 99% used. The meter went red for half a minute, and because the chart keeps the highest value in each minute, that false peak stayed on it for a full day. A poll that cannot measure now keeps the last reading and records nothing: a gap in the chart is honest.
160
-
161
- **A failed ccusage repair no longer disables the repair.** If the deck found a half-installed copy it removes it and starts again. On Windows that removal can fail for a few seconds because the program it just ran still has the folder open — and the deck then treated the attempt as spent and never tried again for the rest of the session, leaving the panel permanently unable to read your usage. It now only counts a repair that happened.
162
-
163
- **Changing the auto-switch interval takes effect even during startup.** Set it in the first seconds after launch and the timer kept the old value for the life of the process, while the panel showed the new one.
164
-
165
- **Codex sessions with very large histories no longer cost hundreds of megabytes to read.** The deck read the whole file to find four values that live at its two ends — measured at 185 MB of memory and 95ms of frozen interface for one 44 MB session. It now reads only the ends.`}],"3.8.7":[{title:"🧠 Four things in the panel that behaved wrongly",body:`**Today's figure no longer overshoots.** Once a minute, when a fresh reading landed, the headline briefly counted past the true number and back down — it was measuring the last minute of spend from a starting point one moment out of date. The reading and its starting point are now recorded together, so there is no moment where they can disagree.
166
-
167
- **Browser Watch marks findings read when you close it, not when you open it.** It was clearing the badge immediately, and stamping every new finding as read the moment it arrived — so anything that turned up while you were reading was never badged at all. It was also writing to storage four times a second the whole time the panel was open.
168
-
169
- **A hidden tool category can always be brought back.** Hide one, leave the deck running, and once the canvas had turned over the row of chips disappeared while the filter stayed on — no bubbles, and nothing to press. Only reloading fixed it. The chips now stay for as long as anything is hidden.
170
-
171
- **Clicking a session's name no longer switches auto-fit off.** The deck was reading its own camera move as you grabbing the canvas, and remembered it across restarts, with nothing said.`}],"3.8.6":[{title:"🗂️ Two decks can no longer both claim the same log",body:"When several decks share one events log they elect a single writer for it, so nothing is recorded twice. That election compared the path as typed — so two decks reaching the SAME file by different spellings each thought they were alone, both wrote every event, and each believed the log was theirs to clear.\n\nDifferent spellings are ordinary, not exotic: a shortened Windows home directory, a mapped or substituted drive, a junction, or on macOS `/tmp` against `/private/tmp`. The visible symptoms were duplicated tool calls after a restart, and Clear wiping history belonging to another deck.\n\nThe path is now canonicalised the same way the watched folder already was. It works on a first run too, before the log file exists."}],"3.8.5":[{title:"⛔ Cancelling a sign-in no longer adds the account anyway",body:`Press Escape while adding a Claude account and the deck killed the sign-in — and then, sometimes, registered the account regardless, switched to it, and told you it had worked.
172
-
173
- The deck asks the tools it runs whether they finished cleanly. A program that is well behaved about being cancelled tidies up and exits with a success code, and the deck was reading that as "it finished" rather than "I stopped it". \`claude auth login\` is exactly that kind of program.
174
-
175
- A cancelled run now reports as cancelled. Everything that was not cancelled is unaffected.`}],"3.8.4":[{title:"🧷 Your own hooks can no longer be eaten by two decks starting together",body:'If you keep hooks of your own in `settings.json`, the deck parks them while it installs and puts them back afterwards. Two decks starting at the same moment could interleave inside that, and the loser wrote a version of the file computed before the restore — so your hook was gone from `settings.json` and gone from the park, which was its only other copy.\n\nThere was already a check for this, and it had a hole: if the last-moment re-read of the file failed, it read that as "nothing changed" and wrote anyway. A failed read is the one moment that check was most needed, because the usual reason a file cannot be read for a few milliseconds is that something else has just written it.\n\n`ccdeck --uninstall` had no such check at all and could overwrite a deck that was starting, then exit 0 saying it had succeeded. It has one now, and when it declines it says so and tells you to run it again rather than reporting that there was nothing to remove.'}],"3.8.3":[{title:"🪟 Windows: two settings files that could refuse to save",body:`On Windows a file cannot be moved into place while anything else has it open, and Defender and the search indexer open a file the instant it is written. The deck has had a retry for that for a long time, and two files written in the last few days were not using it: the notifications preference, and Browser Watch's episode archive.
176
-
177
- When it bit, the notifications switch silently did not stick, and Browser Watch answered an error and showed an empty panel. Both now retry the way everything else in the deck already did.
178
-
179
- Nothing changes on macOS or Linux, where the operating system never refused the move in the first place — which is why this got past a green test suite on both.`}],"3.8.2":[{title:"⌨️ A closed-behind-your-back dialog no longer kills every keyboard shortcut",body:`Open the context ring on a session's card and leave it open. The session finishes, and a couple of minutes later the canvas evicts it — or you press Clear. The dialog vanished, and from that moment every shortcut in the deck stopped working: Space, C, R, F, L, H, U, A, J, K, T, M, and the trash button too. Only reloading the page brought them back.
180
-
181
- The deck was still counting the dialog as open, because it remembered which session you had opened it for rather than whether anything was on screen. It now closes the dialog when its session leaves the board, which is what should have happened in the first place. The end-of-session recap had the same problem and is fixed with it.`}],"3.8.1":[{title:"🔒 Security: update if the deck runs on a Mac",body:"A local process able to reach the deck's port — no token, no browser, no tab — could get a string of its choosing compiled as AppleScript when the deck raised a desktop notification with no page open. On macOS that is code running as you.\n\nThe strings were already passed as arguments rather than pasted into the script, which is normally the whole defence. It is not enough for `osascript`: its option parser reads any argument starting with a dash as an option, so a name beginning with `-e` was taken as more script instead of as text. Every place the deck hands `osascript` or `notify-send` something from outside now carries an explicit end-of-options marker, so nothing from outside can be read as an instruction again.\n\nNothing to change on your side beyond updating. If you would rather keep the deck off the desktop entirely, the Notifications switch in the sound menu does that, and `AGENTS_DECK_NO_NOTIFY=1` does it at launch — but the fix is the thing to have."}],"3.8.0":[{title:"🔕 Notifications now have an off switch",body:`3.7.0 gave you a "notify me" button and no way back. Turning them off meant digging into your browser's site settings — which no page can do for you — and that still left the other notifier, the one the deck raises when no page is open at all. Silencing that one meant quitting the deck and starting it again with \`AGENTS_DECK_NO_NOTIFY=1\` in front. The person who wanted quiet was the one doing the work.
182
-
183
- There is a **Notifications** switch in the sound menu now, beside the one for sound — that menu is already "how loudly does this deck interrupt me". One switch governs both notifiers, it takes effect immediately without a restart, and it is remembered across restarts.
184
-
185
- It is kept by the deck rather than by your browser, because the second notifier runs when no page exists and a setting living in a page could never reach it. \`AGENTS_DECK_NO_NOTIFY=1\` still wins over the switch — a machine told at launch to stay off the desktop stays off it — and when that is the case the menu says so instead of showing an "on" that will not happen.`}],"3.7.1":[{title:"🔔 The notifications now fire on the thing that actually stops your agent",body:`3.7.0 could tell you a session was waiting — but only when Claude Code asked permission to run a tool. If you work with permissions bypassed, that never happens, and the whole feature was silent for you. Measured on one real log: 1683 events, every one of them in bypassPermissions, and a single permission prompt in the entire history.
186
-
187
- What fires constantly on that setup is the other kind: the agent asking you a question and stopping for the answer. The deck was throwing those away — no amber chip, no row in the sidebar, no notification, and no "notify me" button, because the button only appears while something is actually blocked.
188
-
189
- Now they count. The card carries the question itself rather than a generic "Your turn" — "paycore needs your input: merge both branches to main, or just one?" — and so does the notification, on the desktop, whether the tab is behind something or not open at all.
190
-
191
- An idle prompt still stays quiet: a turn that ended is not a session that is stuck, and a channel that cries wolf is one you switch off.`}],"3.7.0":[{title:"🔔 The deck can reach you when you are not looking at it",body:`The deck's whole point is telling you which agent is waiting on you, and until now it could only say so on screen — the amber chip, the tab title, the favicon. Every one of those is drawn inside a page, so the one moment it matters, when you have walked away and four agents have gone quiet, the deck was silent.
192
-
193
- Now it reaches the desktop, two ways that never overlap. With the deck open behind something, the page raises the notification itself: a "notify me" button appears in the top bar the first time a session blocks, and the browser asks you — nothing is requested before there is something to notify you about. With no page open at all, the server raises it, because it can see that nobody is connected and therefore that no other surface is saying anything.
194
-
195
- One notification per session, replaced rather than stacked if a second deck raises it too. Clicking it brings the tab forward. \`AGENTS_DECK_NO_NOTIFY=1\` turns the desktop side off entirely, and if you refuse the browser prompt the deck says so plainly instead of leaving you thinking you switched something on — after a refusal only your browser's site settings can undo it, which no page is allowed to touch.`},{title:"🧩 A blocked session now says what it is asking for",body:'"Waiting on you" told you to go and look. The session row and the card now carry the tool the prompt is most likely about, and the tooltip carries the one line of its input that a person actually reads — `rm -rf node_modules` rather than `{"command":"rm -rf node_modules"}`.\n\nIt is a guess and it is worded as one: the deck sees the tool calls, not the permission dialog, so it says "likely on". The deck still cannot allow, deny or answer anything for your agent, and it never will.'},{title:"🧮 Today's figure was counting some sessions twice",body:`The panel reads your usage from ccusage once a minute and fills the gap in between from what the deck is watching. The filling-in was wrong: any session that reached the canvas after the reading had landed was added in full, and since the canvas is still loading when the first reading arrives, that was most of them.
196
-
197
- Measured on a deck four seconds old: ccusage said $450 for today and the panel said $1,006. The table underneath it said $450 the whole time, which is the disagreement to trust.
198
-
199
- The deck now adds only work it has actually watched happen. A session that starts while you are looking shows up at the next reading instead of instantly — up to a minute — which is how the panel behaved before the live figure existed at all. Everything already on screen keeps moving as it did.`}],"3.6.0":[{title:"✂️ The two figures at the end of the top bar are gone",body:`The bar used to end with a token count and a dollar figure. Both were sums over what is on the canvas at that moment, and the canvas drops finished sessions a couple of minutes after they end — so both numbers fell on their own, with nothing on screen to explain the fall. They carried the word "board" and a three-line tooltip for exactly that reason.
200
-
201
- The usage panel answers the same question without the apology: it reads the logs on disk, it covers sessions this deck never watched, and it does not forget. Press U for the panel, or H for the full history.
202
-
203
- What is left in the bar is what is true right now — whether the stream is alive, and what your machine is doing.`}],"3.5.0":[{title:"⚡ The figures move when the work happens",body:`Reading your usage off the logs is not free — measured here, one reading is 7.8 seconds of CPU, because ccusage walks every transcript on the machine whatever period you asked for. Once a minute is affordable; once every ten seconds would be three quarters of a core, permanently, for numbers that move slowly.
204
-
205
- So the reading stays on a minute and the deck fills the gap with what it already knows. Every hook event carries its session's running total, so the panel adds whatever has been spent since the last reading and counts up to it. The headline now moves when a turn finishes rather than on the clock, and it costs nothing extra.
206
-
207
- It only ever adds. A session leaving the canvas cannot pull the figure down, and the next reading corrects whatever the estimate got wrong — the tokens are exact, and the dollars in between are priced by the deck's own table.
208
-
209
- Two smaller things with it: pressing today, month or all now counts between the two figures instead of swapping them, and coming back to the tab only re-reads if what is on screen is actually stale.`}],"3.4.0":[{title:"🔢 The figures count to their new value, once a minute",body:`The Usage panel re-reads its numbers every minute now rather than every five, and it is a real minute — the server used to hold a reading for two, so a shorter poll would have handed the same figure back.
210
-
211
- And they no longer teleport. Replaced in a single frame, $170 → $269 says only "this is different now": no direction, no sense of how much, and nothing at all if your eye was a few pixels away. Counted over a fifth of a second, the same change says up, and roughly how far.
212
-
213
- What deliberately does not count: the first paint, a change of period — "today" and "all time" are different quantities rather than one that moved — the tables, a change too small to read, and anything at all if you have reduced motion on or the tab is in the background.`},{title:"🧹 The board's own figure is out of the Usage panel",body:`3.3.0 put the canvas's live spend on its own labelled line, under whichever period you had chosen. In front of a panel that answers today, this month and all time from the logs on disk, that second money figure answers a question nobody asked at that moment — and it invited a comparison it could never win, $7,385 on the board beneath $170 for today.
214
-
215
- It is gone. The board's tokens and cost are still on the topbar, with the sentence that explains why they fall on their own, and the panel still shows them when ccusage cannot answer at all.`}],"3.3.0":[{title:"📊 The Usage panel answers for a period, not just for the board",body:`It used to add up the sessions drawn on the canvas — which is an honest number with a scope nobody reads it as having: finished sessions are evicted a couple of minutes after they end, so the figure fell on its own while nothing had happened and nothing was refunded.
216
-
217
- It now reads ccusage, the same source the H modal uses, and offers today, this month and all time. BY MODEL and BY SESSION come from there too, and each session is named by the project the board knows it as rather than by a uuid.
218
-
219
- The live figure is still there, on its own line and labelled — what the sessions currently on the board have spent — because that is a different question from what the month cost.
220
-
221
- One thing worth knowing about the source: ccusage reports a session's LIFETIME total, so the rows under "active today" can add up to more than the day above them. The heading says so.`},{title:"🪟 Windows: a deck started from an elevated terminal was being treated as dead",body:"The hook decides whether a deck is still running by trying to signal it. On POSIX a process you may not signal answers EPERM; on Windows it answers EACCES, and only EPERM was accepted — so a deck started from an elevated terminal, or under another account, read as gone. Its registration was deleted on every event and rewritten five seconds later, while its banner went on saying it was connected and almost nothing arrived.\n\nThree more Windows-only faults went with it: a read-only settings.json made every hook install fail for good (the atomic write could not replace the file); the machine panel answered 500 every four seconds whenever the process read failed; and a bare command name was looked for in the working directory before PATH, which is where `npx ccdeck` was run."},{title:"👁 Browser Watch reads nothing while it is switched off",body:`The switch used to control only what was KEPT. The read happened anyway — every five minutes, on every deck, the panel's badge poll discovered each Chromium profile and copied its whole History database to a temp file to query it. A switch that says off while that continues is not a switch.
222
-
223
- With the watch off, nothing touches a browser now. Opening the panel still reads live, because that is you looking, and a watch that is ON still records in the background — that is the feature. The trade is that the topbar badge no longer counts findings while the watch is off; open the panel to see them.
224
-
225
- The README has a Browser Watch section now: what is read, when, where the copy goes, and that only visits after the deck started are ever considered.`},{title:"🔒 The deck's own data is no longer readable by anything on the machine",body:"Changing an account needed the deck's credential; reading the event ring did not. Anything running on your machine could `curl` the events — prompt text, the commands an agent ran, the paths and contents it touched — plus the account list and the browsing episodes.\n\nThose reads now answer to the same rule the mutations do: the deck's own page, or its token. Nothing changes for you in the browser. A script of yours that reads those routes needs the token from `~/.claude/agent-dag/<pid>.json`, sent as `x-ccdeck-token`."},{title:"💳 An API-key, Bedrock or Vertex install is told there is no quota window",body:`Those installs are billed per token and have no five-hour window. The CLI ran, printed no quota lines, and the deck read that as a genuine "under 1%" — drawing two empty bars for a measurement nobody had taken, or telling you to run /usage, which cannot help there.
226
-
227
- It now says what it is, in one line, the way the Codex half already did.`},{title:"🎨 The model chip is coloured by its model again",body:`A session that switched model — Sonnet, then Opus — drew a chip reading "Opus 5 +1" in Sonnet blue, because the colour was picked from the tooltip and the tooltip lists every model the card's spend covers. Add a Fable turn and it went yellow.
228
-
229
- Also fixed on the way past: an account import the CLI rejected could take the whole deck down with it, and a corrupt compressed Codex rollout leaked a file handle on every poll.`}],"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.
230
-
231
- 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.
232
-
233
- 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.
234
-
235
- 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.
236
-
237
- 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.
238
-
239
- It is only ever a read. Nothing is installed, nothing is asked of you, and a machine without it shows no section, exactly as before.`}],"3.1.0":[{title:"🚀 The first run stops looking like it hung",body:`\`npx ccdeck\` on a machine that has never run it used to sit on a spinner at "checking claude-swap" and say nothing else. Measured on a Windows box: seventeen and a half seconds before it told you where to point a browser. It is now one and a half.
240
-
241
- The deck was waiting for an install nobody asked for during that boot — a Python toolchain being fetched so the accounts panel would work. The port had been open the whole time; there was just nothing on screen to say so.
242
-
243
- It no longer waits. Anything still working past the boot says so on its own line and keeps going in the background, and the deck comes up without it.`},{title:"⚡ Every start is quicker, and stays quicker",body:`The event log was read from the beginning on every boot to fill a buffer that only keeps the last two thousand events — so four fifths of that reading existed to be thrown away, and it got slower the longer you had been using the deck. It reads from the end now and stops when the buffer is full: 258ms down to 20ms here, on a 34 MB log, and it no longer grows.
244
-
245
- The accounts tool is also asked for its version once instead of twice, which on this machine was the single largest thing in an ordinary boot.`},{title:"📉 Ten fewer packages to install",body:"Opening your browser used to cost a dependency that brought nine more with it — ten downloads on a cold `npx ccdeck` before the deck's own files were unpacked. It is now done with the commands the operating system already has.\n\nThe package has no runtime dependencies at all."},{title:"🌡️ Temperature, on the machines that could not show it",body:`On Windows the deck was asking somewhere it is not allowed to look: that reading lives behind a namespace that needs administrator, so it failed for everybody and the section never appeared. It reads a performance counter now, which needs nothing.
246
-
247
- On Apple Silicon there is no command that ships with macOS which prints a temperature at all — the sensors are behind an interface only native code can reach. The deck fetches a small signed tool for it, verified against the checksum its release publishes, in the background and only on the Macs that need it. You do not have to install anything. \`AGENTS_DECK_NO_DOWNLOAD=1\` turns that off.
248
-
249
- A machine with no sensor still shows no section, which includes every virtual machine. Nothing is drawn that was not measured.`},{title:"😌 The terminal goes quiet when there is nothing happening",body:`The dot at the bottom blinked every 800ms for as long as the deck ran, which is what a terminal does while it is working — so a deck that had finished in a second looked like one that never finished.
250
-
251
- It now moves only while something actually is: a job still running, or hooks that cannot find the deck. Otherwise it is drawn once and left alone, and it says what the job is rather than just blinking. A step that takes more than three seconds shows how long it has been going, which is the whole of "is this stuck".
252
-
253
- And a machine with no Claude Code installed stops being told about it every few seconds — that one is said once now, on its own line instead of across the status line.`}],"3.0.0":[{title:"📈 The machine panel now shows what it DID, not just what it is",body:`Click any section of the machine panel — Cores, Memory, Load average, Thermal — and it opens a chart of what that reading has done since the deck started.
254
-
255
- The panel could always tell you the machine is busy now. It could not tell you whether it got hot while that three-hour build was running, or how deep the queue went while you were away, and those are the questions you actually have afterwards.
256
-
257
- Thermal is new as well. Where the machine will give degrees, it gives degrees; on a Mac it also reports whether the CPU is being held back to cool down, which is the consequence a temperature has to be interpreted into anyway. Nothing is drawn that was not measured — a machine with no sensor gets no section at all, rather than a zero.`},{title:"🔍 The whole process list, not just the busiest eight",body:`"more" beside Busiest processes opens the full list the deck is watching — around fifty processes rather than eight — with the pid and the untruncated name.
258
-
259
- This closes a gap. The panel's eight rows are the busiest, so sorting them by name only reorders those eight: "is my test runner still going" could not be answered if the test runner was not already on screen. Now it can.
260
-
261
- It is deliberately not a task manager. Nothing here ends a process; Activity Monitor and Task Manager are better at that and it is not a thing this deck should own.`},{title:"🔤 Process names in Cyrillic, Greek or with accents read correctly",body:`An application named Яндекс Музыка was showing up as M-PM-/M-PM-=M-PM-4M-PM-5… in the process list, and so was every other name the deck could not spell in plain ASCII.
262
-
263
- The deck was forcing a fixed locale on the commands it runs, to guarantee that a decimal point stays a point on a machine set to German or Russian — and that also forced the character set. It forces only the number format now. Your own character set is left alone, which is what makes the name arrive intact.`},{title:"📦 The text you copy to share accounts is a third of its size",body:`Sharing three accounts used to produce 6168 characters. It is now 1896.
264
-
265
- Most of that text was never the credentials — two OAuth tokens are about two hundred characters between them, and the rest was the envelope, whose field names repeated in full for every account added. So the saving grows with the number of accounts rather than shrinking.
266
-
267
- A blob you copied before this still imports until it expires. One made now cannot be read by a deck older than this version — that is the one thing in this release that older decks cannot follow.`}],"1.48.0":[{title:"👁 Browser Watch — see what a program opened while you were away",body:`There is a new eye in the top bar. It watches the browsers on this machine and tells you when a program — an extension, an agent, a command — opened pages while nobody was touching the browser.
268
-
269
- Usually that is your own agent doing what you asked, and the panel says so rather than crying intrusion. What it gives you is the evidence: which pages, in which browser, at what time, with every address written out in full.
270
-
271
- It is off until you switch it on, and nothing leaves this machine. It reads a copy of the browser's own history and only pages newer than the moment the deck started — never anything from before, never cookies, never saved passwords. Open ⚙ inside the panel and "What Browser Watch can access" says exactly what it reads, keeps and sends.
272
-
273
- When it finds something the eye turns amber with a count. You can dismiss a finding once you have looked at it and it stays gone, while the log file on disk keeps the record. On a Mac it can also close the tab it found, or quit the browser.`},{title:"🔑 Move all your accounts to another machine in one paste",body:`Sharing accounts between two decks used to be one account at a time, and step four of six is where people stop — leaving the second deck half set up with nothing saying so.
274
-
275
- Pick the accounts you want, copy one blob, paste it into the other deck. The import adds what is missing, leaves what already works alone, heals an account whose token has died, and tells you which of those happened to each one.
276
-
277
- The blob carries real credentials, so it expires ten minutes after you make it and the deck refuses an expired one before it unwraps anything.`}],"1.47.0":[{title:"🔌 The top bar goes quiet when everything is fine",body:`The green "live" pill used to sit up there permanently to tell you nothing was broken. It is gone while things are working.
278
-
279
- You will still see a pill when it matters: amber when you pause the canvas, with how many events are waiting, and red when the deck loses its connection to the server. No pill means all is well.`},{title:"🔴 The browser tab tells you when the connection drops",body:`The little icon in the tab has always shown what your sessions are doing — grey when it is quiet, blue when something is working, amber when a session is waiting on you.
280
-
281
- It could not say the one thing that matters most: that the deck has stopped hearing from the server. Until now it just kept showing whatever it had last seen. It turns into a broken red ring instead, so you can spot it from another tab without switching over.`}],"1.46.0":[{title:"🔊 Pick a volume and a sound for each of the two tones",body:`Click the speaker in the top bar and a small menu opens. There are two tones — one when a turn finishes, one when Claude is waiting for you — and each has its own volume and its own sound, six to choose from. Press "Hear it" to try one straight away, without waiting for a real turn.
282
-
283
- The two lists are separate on purpose, so you can never end up with both tones sounding the same. A finish tone always falls; an asking tone always rises. That is how you tell them apart without looking at the screen.
284
-
285
- 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.
286
-
287
- 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."}],"3.16.0":[{title:"🤝 Pair two decks with one piece of text",body:`**Accounts ▸ Local network ▸ setup… ▸ make an invite.** Send the text however you already talk to them; they paste it and the two decks are paired. Nobody presses accept, and neither of you has to know which of your addresses the other can reach — the invite carries them all and their deck tries each one.
288
-
289
- Decks on the same router still find each other on their own and appear under **on this network right now**. An invite is for the case that does not work: another subnet, a VPN, a firewall.
290
-
291
- The invite lasts 10 minutes and is used once. Anyone who gets hold of the text can pair with your deck until it runs out, so send it the way you would send anything else you would not want forwarded.`},{title:"⚠️ Both machines have to be on this version",body:`The two decks no longer speak the old protocol, and there is no fallback: a 3.15 deck and a 3.16 deck cannot see each other at all. Update both.
292
-
293
- The group passphrase is gone. If you had one set, that pairing is not carried over — make an invite and pair again. It was replaced because a passphrase that differs by one character produced a closed socket and no other symptom on either machine, and a secret is the one thing a panel must never print, so neither person could check theirs against the other's.`}],"3.22.1":[{title:"🖥️ A first run now opens This machine too",body:`Accounts and usage already opened themselves the first time you ran the deck; the machine panel did not, and now does. It is the panel that answers "is this box coping" — cores, memory, load, temperature — and somebody meeting the deck for the first time cannot ask for a panel they do not know is there.
294
-
295
- It only does this when you have never said otherwise. Close it once and it stays closed, on that browser, for good — the same rule the other two panels have always followed. Nothing reopens it behind you.
296
-
297
- While it is open it polls this machine once every few seconds, and it stops the moment you close it or switch tabs.`}],"3.22.4":[{title:"📈 A card stops looking idle while it is thinking",body:`The activity chart on each card counted tool calls and nothing else, so the time an agent spends reading, reasoning and writing drew as a flat line — measured on this machine, 16.5% of all working time, more than the time spent inside the tools themselves. A session that was busy looked exactly like one that had died, and the only way to tell them apart was to wait and see whether anything ever appeared.
298
-
299
- It marks that work now. A chart with bars in it means the agent is doing something, whether or not it has called a tool in the last minute; a flat chart means it genuinely is not. Hover it for the split — how many tool calls and how many blocks of thinking and writing landed in the last 60 seconds.
300
-
301
- Nothing was added to the card and nothing new is polled. The deck already reads each session's transcript for its token counts; this reads the same file for what the model has finished writing, and a session that is quiet costs one file check per second and a half.`}]},tk="agent-dag.releaseNotesSeen";function sM(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function xi(e,t){const n=sM(e),r=sM(t);for(let s=0;s<Math.max(n.length,r.length);s++){const o=(n[s]??0)-(r[s]??0);if(o!==0)return o<0?-1:1}return 0}function bi(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function Soe(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 _oe(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,r]of Object.entries(e)){if(!bi(n)||!Array.isArray(r))continue;const s=r.filter(Soe);s.length&&t.push({version:n,notes:s})}return t.sort((n,r)=>xi(r.version,n.version))}const aM=_oe(joe);function iP(e,t,n){return e.filter(r=>xi(r.version,n)<=0&&(t===null||xi(r.version,t)>0))}function Eoe(e,t){return e.filter(n=>xi(n.version,t)===0)}function Toe(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 Coe({since:e,running:t,entries:n,firstRun:r}){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(r&&bi(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 s=n[0].version;if(!bi(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 o=xi(s,t);return o<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.`:o>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 Aoe=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function Roe(e){const t=Aoe.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function Moe(e){if(!e)return null;let t=null;try{t=e.getItem(tk)}catch{return null}return bi(t)?t:null}function $oe(e){if(!e)return!1;try{return e.getItem(tk),!0}catch{return!1}}function Ioe(e,t){if(!e)return!1;try{return e.setItem(tk,t),!0}catch{return!1}}const lP="agent-dag.tourSeen";function Ooe(e){if(!e)return!1;try{return e.getItem(lP)==="1"}catch{return!1}}function Loe(e){if(!e)return!1;try{return e.setItem(lP,"1"),!0}catch{return!1}}function Poe({tourSeen:e,decision:t}){if(t.reason==="no-version"||t.reason==="cannot-remember")return{tour:!1,notes:"none"};if(t.reason==="welcome"||t.reason==="first-run")return{tour:!e,notes:"none"};const n=t.show.length>0;return e?{tour:!1,notes:n?"now":"none"}:{tour:!0,notes:n?"after":"none"}}function Doe({stored:e,running:t,notes:n,remembers:r=!0}){if(!bi(t))return{show:[],record:null,reason:"no-version"};if(!bi(e)){if(!r)return{show:[],record:t,reason:"cannot-remember"};const l=Eoe(n,t);return l.length?{show:l,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const s=xi(e,t);if(s===0)return{show:[],record:null,reason:"seen"};if(s>0)return{show:[],record:null,reason:"ahead"};const o=iP(n,e,t);return o.length?{show:o,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function Foe(e,t){if(/\s|^$/.test(e[t+2]??""))return-1;let n=t+2;for(;n<e.length;){if(e[n]==="`"){const r=e.indexOf("`",n+1);if(r<0)break;n=r+1;continue}if(e.startsWith("**",n)&&!/\s/.test(e[n-1]??" "))return n;n++}return-1}function cP(e,t=!0){const n=[];let r="";const s=()=>{r&&(n.push({kind:"text",text:r}),r="")};let o=0;for(;o<e.length;){if(e[o]==="`"){const l=e.indexOf("`",o+1);if(l>o+1){s(),n.push({kind:"code",text:e.slice(o+1,l)}),o=l+1;continue}}else if(t&&e.startsWith("**",o)){const l=Foe(e,o);if(l>0){s(),n.push({kind:"bold",kids:cP(e.slice(o+2,l),!1)}),o=l+2;continue}}r+=e[o],o+=1}return s(),n}function Boe({entries:e,since:t,running:n,firstRun:r,onClose:s,onTour:o,updateVersion:l,updateBusy:c,onUpdateRestart:d,updateFailure:h,onRestart:f}){const p=ut(s),g=gt(s),v=Toe(e);return a.jsx("div",{className:"modal-backdrop",...g,role:"presentation",children:a.jsxs("div",{ref:p,className:"modal release-notes",onClick:N=>N.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"release-notes-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{id:"release-notes-title",className:"modal-tool-name",children:"What's new"}),v&&a.jsx("span",{className:"modal-tool-id",children:v})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[(l||h)&&a.jsxs("div",{className:"rn-update",children:[l&&d&&a.jsxs("div",{className:"guide-door",children:[a.jsxs("span",{children:["ccdeck v",l," is downloaded and verified."]}),a.jsx("button",{type:"button",className:"btn",onClick:d,"aria-busy":c||void 0,children:c?"Restarting…":Bd})]}),a.jsx("p",{className:"rn-update-said",role:"status",children:h})]}),a.jsx("p",{className:"modal-note",children:Coe({since:t,running:n,firstRun:r,entries:e})}),o&&!l&&a.jsxs("div",{className:"guide-door",children:[a.jsx("span",{children:"Eight pictures of what the deck shows."}),a.jsx("button",{type:"button",className:"btn",onClick:o,children:"Take the tour"})]}),f&&a.jsxs("div",{className:"guide-door",children:[a.jsx("span",{children:"Restart the deck. Sessions, settings and pairings come back as they were."}),a.jsx("button",{type:"button",className:"btn",onClick:f,children:"Restart"})]}),e.map(N=>a.jsxs("section",{className:"modal-section",children:[a.jsxs("h3",{className:"rn-version",children:["v",N.version]}),a.jsx("ul",{className:"rn-notes",children:N.notes.map((k,x)=>{const{icon:j,rest:b}=Roe(k.title);return a.jsxs("li",{className:"rn-note",children:[a.jsxs("p",{className:"rn-note-title",children:[j&&a.jsx("span",{className:"rn-note-icon",children:j}),b]}),a.jsx("p",{className:"rn-note-body",children:uP(cP(k.body))})]},x)})})]},N.version))]})]})})}function uP(e){return e.map((t,n)=>t.kind==="text"?t.text:t.kind==="code"?a.jsx("code",{className:"rn-code",children:t.text},n):a.jsx("strong",{className:"rn-strong",children:uP(t.kids)},n))}function qoe({state:e,sessionId:t,onClose:n}){const r=y.useMemo(()=>Uoe(e,t),[e,e.revision,t]),s=y.useRef(null),o=ut(n,{focusRef:s}),l=gt(n);return r?a.jsx("div",{className:"modal-backdrop",...l,role:"presentation",children:a.jsxs("div",{ref:o,className:"modal session-summary",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[a.jsxs("div",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),a.jsx("span",{id:"ss-title",className:"modal-tool-name",title:r.cwd??r.sessionId,children:r.label}),a.jsxs("span",{className:"modal-tool-id",children:["· ",r.sessionId.slice(0,8)]})]}),a.jsxs("div",{className:"modal-actions",children:[a.jsx("span",{className:"modal-dur",title:"Total wall time",children:r.durationLabel}),a.jsx("button",{type:"button",ref:s,className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),a.jsxs("div",{className:"modal-body",children:[a.jsxs("section",{className:"ss-hero",children:[a.jsxs("div",{className:"ss-hero-left",children:[a.jsx("div",{className:"ss-cost-label",children:X$}),a.jsx("div",{className:"ss-cost",children:qe(r.cost.total)}),r.modelChips.length>0&&a.jsx("div",{className:"ss-models",children:r.modelChips.map(c=>a.jsx("span",{className:"model-chip","data-family":Jd(c),title:c,children:oa(c)},c))})]}),a.jsx("div",{className:"ss-hero-right",children:r.cost.total>0&&a.jsxs(a.Fragment,{children:[a.jsx(u0,{cost:r.cost,size:"lg"}),a.jsxs("div",{className:"ss-cost-legend",children:[a.jsxs("span",{className:"ssl ssl-in",children:["input ",a.jsx("b",{children:qe(r.cost.input)})]}),a.jsxs("span",{className:"ssl ssl-out",children:["output ",a.jsx("b",{children:qe(r.cost.output)})]}),a.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",a.jsx("b",{children:qe(r.cost.cacheRead)})]}),a.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",a.jsx("b",{children:qe(r.cost.cacheWrite)})]})]})]})})]}),a.jsxs("section",{className:"ss-stats",children:[a.jsx(Xo,{label:"agents",value:r.agentCount}),a.jsx(Xo,{label:"subagents",value:r.subagentCount}),a.jsx(Xo,{label:"tool calls",value:r.toolCount}),a.jsx(Xo,{label:"prompts",value:r.promptCount}),a.jsx(Xo,{label:"tokens",value:r.tokensSum.toLocaleString()}),r.errCount>0&&a.jsx(Xo,{label:"errors",value:r.errCount,tone:"err"})]}),r.topTools.length>0&&a.jsxs("section",{className:"modal-section",children:[a.jsx("h4",{children:"Most-used tools"}),a.jsx("div",{className:"ss-top-tools",children:r.topTools.map(([c,d])=>a.jsxs("div",{className:"ss-tt",children:[a.jsx("span",{className:"ss-tt-name",children:c}),a.jsx("span",{className:"ss-tt-bar",children:a.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${d/r.topTools[0][1]*100}%`}})}),a.jsx("span",{className:"ss-tt-count",children:d})]},c))})]}),r.firstPrompt&&a.jsxs("section",{className:"modal-section",children:[a.jsx("h4",{children:"Opening prompt"}),a.jsx("div",{className:"ss-prompt",children:r.firstPrompt})]})]})]})}):null}function Xo({label:e,value:t,tone:n}){return a.jsxs("div",{className:`ss-stat${n?` tone-${n}`:""}`,children:[a.jsx("div",{className:"ss-stat-value",children:t}),a.jsx("div",{className:"ss-stat-label",children:e})]})}function Uoe(e,t){const n=e.agents.get(t);if(!n)return null;const r=[];for(const _ of e.agents.values())_.sessionId===t&&r.push(_);if(r.length===0)return null;const s={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},o=new Set,l=new Map;let c=0,d=0,h=0,f=0,p=0,g,v=1/0,N=0;for(const _ of r){const E=pn(_);s.input+=E.input,s.output+=E.output,s.cacheRead+=E.cacheRead,s.cacheWrite+=E.cacheWrite,s.total+=E.total;for(const C of g$(_))o.add(C);_.model&&o.add(_.model),_.kind==="subagent"&&p++;const R=t$(_.prompts);d+=R.length,!g&&R.length>0&&(g=R[0].text),h+=_.usage.inputTokens+_.usage.outputTokens,c+=_.toolCount,f+=_.toolErrorCount??0;for(const[C,A]of _.toolCountByName??[])l.set(C,(l.get(C)??0)+A);v=Math.min(v,_.startedAt),N=Math.max(N,_.endedAt??Date.now())}const k=Math.max(0,N-v),x=Math.floor(k/1e3),j=x<60?`${x}s`:x<3600?`${Math.floor(x/60)}m ${String(x%60).padStart(2,"0")}s`:`${Math.floor(x/3600)}h ${Math.floor(x%3600/60)}m`,b=Array.from(l.entries()).sort((_,E)=>E[1]-_[1]).slice(0,5);return{sessionId:t,label:n.label||n.cwdBasename||"session",cwd:n.cwd,durationLabel:j,cost:s,modelChips:Array.from(o),agentCount:r.length,subagentCount:p,toolCount:c,promptCount:d,tokensSum:h,errCount:f,topTools:b,firstPrompt:g}}function zoe({tool:e,onClose:t}){const n=ut(t),r=gt(t),s=e.endedAt==null?"inflight":e.ok===!1?"err":"done",o=y.useRef({of:null});o.current.of!==e&&(o.current={of:e}),e.input!==void 0&&(o.current.input=e.input),e.response!==void 0&&(o.current.response=e.response);const l=o.current.input??e.inputPreview,c=o.current.response??e.errorPreview,d=e.trimmed===!0&&o.current.input===void 0&&o.current.response===void 0,h=y.useMemo(()=>{const f=G8(e.name,l,c);return{input:f.input.map((p,g)=>a.jsx(oM,{block:p},g)),response:f.response.map((p,g)=>a.jsx(oM,{block:p},g)),copyInput:bj(e.name,"input",l),copyResponse:bj(e.name,"response",c)}},[e.name,l,c]);return a.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:a.jsxs("div",{ref:n,className:"modal",onClick:f=>f.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:`status-dot ${s}`,"aria-hidden":!0}),a.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),a.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),a.jsxs("div",{className:"modal-actions",children:[a.jsx("span",{className:"modal-dur",children:v$(e,"in-flight…")}),a.jsx("button",{className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),a.jsxs("section",{className:"modal-body",children:[d&&a.jsx("div",{className:"modal-section",children:a.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("div",{className:"tm-head",children:[a.jsx("h4",{children:"Input"}),a.jsx(iM,{text:h.copyInput,what:"input"})]}),h.input]}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("div",{className:"tm-head",children:[a.jsxs("h4",{children:["Response ",s==="err"&&a.jsx("span",{className:"err-tag",children:"error"})]}),e.endedAt!=null&&a.jsx(iM,{text:h.copyResponse,what:"response"})]}),e.endedAt==null?a.jsx("pre",{children:"(waiting…)"}):h.response]})]})]})})}const Woe={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function oM({block:e}){const[t,n]=y.useState(!1);if(e.inline)return a.jsxs("p",{className:"tm-inline",children:[e.label&&a.jsx("span",{className:"tm-label",children:e.label}),a.jsx("code",{children:e.text})]});const r=y.useMemo(()=>B8(e),[e]),{shown:s}=n$(r,t),o=q8(r,t);return a.jsxs("div",{className:"tm-block",children:[e.label&&a.jsx("span",{className:"tm-label",children:e.label}),a.jsx("pre",{className:e.err?"tm-err":void 0,children:e.lines?s.map((l,c)=>a.jsxs("span",{className:l.tone?Woe[l.tone]:void 0,children:[l.text,c<s.length-1?`
302
- `:""]},c)):s.map(l=>l.text).join(`
303
- `)}),o&&a.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":o.expanded,onClick:()=>n(l=>!l),children:o.label})]})}function iM({text:e,what:t}){const[n,r]=y.useState(!1),s=y.useRef(!0);return y.useEffect(()=>()=>{s.current=!1},[]),a.jsx("button",{type:"button",className:"btn tm-copy",disabled:!e,"aria-label":n?`The ${t} was copied`:`Copy the ${t}`,onClick:()=>void eo(e).then(o=>{!o||!s.current||(r(!0),window.setTimeout(()=>{s.current&&r(!1)},1600))}),children:n?"copied":"copy"})}const Hoe=aP(()=>l0(()=>import("./UsageHistoryModal-DaH3RkMw.js"),[]),"Usage history"),Voe=aP(()=>l0(()=>import("./BrowserWatchModal-D2iFbRdJ.js"),[]),"Browser Watch");function Goe({dialogs:e,welcome:t,desktopUpdate:n,versionCheck:r,restart:s,lanPairs:o,attention:l,clearFlow:c,watchBadge:d,announcements:h,appearance:f,providers:p,stateRef:g,agentCount:v}){const{openedTool:N,setOpenedToolKey:k,usageHistoryOpen:x,setUsageHistoryOpen:j,browserWatchOpen:b,setBrowserWatchOpen:_,contextAgent:E,setContextFor:R,summaryFor:C,setSummaryFor:A,keyHelpOpen:U,setKeyHelpOpen:L,feedbackOpen:F,setFeedbackOpen:O,feedbackPrefill:I,setFeedbackPrefill:B}=e,{tourOpen:M,openTour:$,closeTour:P,releaseNotes:G,closeReleaseNotes:K,chipVersion:q}=t,{desktopUpdateRestarting:H,desktopUpdateFailure:D,readyAppUpdate:W,askDesktopUpdateRestart:J}=n,{version:V}=r,{askRestart:X}=s,{clearConfirmOpen:Y,setClearConfirmOpen:Z,requestClear:ee}=c,{setWatchOn:ne,markWatchSeen:se}=d,{setWatchSaid:pe}=h,{palette:ke}=f;return a.jsxs(a.Fragment,{children:[N&&a.jsx(zoe,{tool:N,onClose:()=>k(null)}),x&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(Hoe,{providers:p,onClose:()=>j(!1)})}),b&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(Voe,{onClose:()=>_(!1),onSeen:ae=>{pe(""),se(ae)},onWatching:ne,palette:ke})}),E&&a.jsx(SU,{agent:E,onClose:()=>R(null)}),F&&a.jsx(sP,{initialKind:I==null?void 0:I.initialKind,initialBody:I==null?void 0:I.initialBody,onClose:()=>{O(!1),B(null)}}),C&&a.jsx(qoe,{state:g.current,sessionId:C,onClose:()=>A(null)}),G&&a.jsx(Boe,{entries:G.entries,since:G.since,firstRun:G.firstRun,running:q,onClose:K,onTour:()=>{K(),$()},updateVersion:W==null?void 0:W.version,updateBusy:H,updateFailure:D&&(!W||W.version===D.version)?nse(D.failure,D.version):void 0,onUpdateRestart:W?()=>{J(W.version)}:void 0,onRestart:!W&&(V!=null&&V.canRestart)?()=>{K(),X()}:void 0}),a.jsx(Koe,{lanPairs:o,attention:l}),U&&a.jsx(ioe,{onClose:()=>L(!1),onTour:()=>{L(!1),$()}}),M&&a.jsx(UI,{title:"What the deck shows you",steps:gK,onClose:P}),Y&&a.jsx(zse,{agentCount:v,onConfirm:()=>ee("confirmation"),onCancel:()=>Z(!1)})]})}function Koe({lanPairs:e,attention:t}){const n=voe(e);return a.jsxs(a.Fragment,{children:[n,a.jsx(Noe,{...t,pairing:n!=null})]})}const Yoe=10,dP=500,hP=4e3,Xoe=[/ResizeObserver loop/i,/^Script error\.?$/i],Ud=String.raw`[^\s\\/:'"\`<>|?*;,]`,Zoe=String.raw`${Ud}(?:[^\\/\r\n:'"\`<>|?*;,]*${Ud})?[\\/]`,Joe=String.raw`[^\s\\/:'"\`<>|?*;,()]+`,bl=String.raw`(?:${Zoe})*(?:${Joe})?`,Qoe=String.raw`(?<![\w.~/\\\]-]|<(?:deck|host)>)(?:file://(?:/[A-Za-z]:)?[^\s:'"\`<>()]*|~[\\/]${bl}|[A-Za-z]:[\\/]${bl}|\\\\(?:[?.]\\)?(?:[A-Za-z]:\\)?${bl}|/(?=${Ud})${bl}|(?<!:)//(?=${Ud})${bl})`,eie=String.raw`(?<![\w-])(?:[A-Za-z]--|-[A-Za-z0-9][\w.]*-)[\w.-]*`,tie=new Set([".claude",".codex"]);function nie(e){if(!e.startsWith("~"))return"<path>";const t=e[1],[n,...r]=e.slice(2).split(/[\\/]/);return n?tie.has(n)?r.join("")?`~${t}${n}${t}<path>`:e:`~${t}<path>`:e}const rie=String.raw`\b(https?|wss?)://[^\s/?#\\'"\x60<>(),;]+(?=(/assets/)?)`;function sie(e,t,n){return n?"<deck>":`${t}://<host>`}const lM=String.raw`(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)`,fP=String.raw`${lM}(?:\.${lM}){3}`,hx=String.raw`[0-9A-Fa-f]{1,4}`,cM=String.raw`(?=[0-9A-Fa-f:]*\d)(?=[0-9A-Fa-f:]*::|(?:${hx}:){7})(?:(?:${hx})?:)+(?:${fP}|${hx})?`,uM=String.raw`%[\w-]+(?:\.[\w-]+)*`,dM=String.raw`(?:::1?|::ffff:(?:127(?:\.\d{1,3}){3}|0\.0\.0\.0))`,aie=String.raw`(?<![\w:.%-])(?:\[(?!${dM}\])${cM}(?:${uM})?\]|(?!${dM}(?::\d{1,5})?(?![\w:%]|\.\d))${cM}(?:${uM})?(?![\w%]|\.\d))|(?<![\w./-])(?!127\.|0\.0\.0\.0\b)${fP}(?![\w-]|\.\d)`,fx=String.raw`(?=[\w.-]*[A-Za-z])[A-Za-z0-9][\w-]*(?:\.[\w-]+)*`,oie=String.raw`(?<![\w.@/\\%-])(?!localhost(?![\w-]|\.\w))(?:(?<=\b(?:(?:getaddrinfo|connect) E[A-Z_]+|ENOTFOUND|EAI_AGAIN) )${fx}|${fx}(?=:\d{1,5}(?![\w:-]|\.\w))|${fx}\.(?:local|lan|home|internal|ts\.net)(?![\w-]|\.\w))`;function hM(e){return String(e??"").replace(/\/(?:home|Users)\/[^/\s:'"]+/g,"~").replace(/[A-Za-z]:\\(?:Users|Documents and Settings)\\[^\\\r\n:'"]+/gi,"~").replace(new RegExp(Qoe,"g"),nie).replace(new RegExp(eie,"g"),"<project>").replace(new RegExp(rie,"g"),sie).replace(new RegExp(aie,"g"),"<host>").replace(new RegExp(oie,"g"),"<host>").replace(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g,"<email>").replace(/\b(?:sk-ant-[A-Za-z0-9_-]{8,}|sk-[A-Za-z0-9_-]{20,}|gh[pousr]_[A-Za-z0-9]{20,}|xox[abpr]-[A-Za-z0-9-]{10,}|eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}|[A-Fa-f0-9]{40,}|[A-Za-z0-9+_=-]{48,})/g,"<secret>")}const pP=e=>{fetch("/api/client-error",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})};function iie(e,t,n=pP){const r=String(e??"").slice(0,dP).trim();r&&n({message:r,stack:typeof t=="string"?t.slice(0,hP):void 0})}function lie(e,t=window,n=pP){let r=0;const s=new Set,o=(d,h)=>{const f=String(d??"").slice(0,dP).trim();!e()||!f||r>=Yoe||s.has(f)||Xoe.some(p=>p.test(f))||(s.add(f),r++,n({message:f,stack:typeof h=="string"?h.slice(0,hP):void 0}))},l=d=>{var h,f;return o(((h=d.error)==null?void 0:h.message)??d.message,(f=d.error)==null?void 0:f.stack)},c=d=>typeof d.reason=="object"&&d.reason!==null?o(d.reason.message,d.reason.stack):o(d.reason,void 0);return t.addEventListener("error",l),t.addEventListener("unhandledrejection",c),()=>{t.removeEventListener("error",l),t.removeEventListener("unhandledrejection",c)}}const cie=12;function uie(e,t){const n=[hM(e).trim()||"The deck threw an error with no message."],r=t==null?void 0:t.trim();if(r){const s=r.split(`
304
- `).slice(0,cie).join(`
305
- `);n.push("",hM(s).trim())}return n.join(`
306
- `)}class die extends y.Component{constructor(){super(...arguments);lp(this,"state",{error:null,componentStack:null,reportOpen:!1});lp(this,"onKey",n=>{b$(n.key)&&ds.dismissTop()})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,r){console.error("ccdeck hit a render error it could not draw past",n,r.componentStack),this.setState({componentStack:r.componentStack??null}),iie(n.message,n.stack),FL("offline")}componentDidUpdate(n,r){this.state.reportOpen!==r.reportOpen&&(this.state.reportOpen?window.addEventListener("keydown",this.onKey):window.removeEventListener("keydown",this.onKey))}componentWillUnmount(){window.removeEventListener("keydown",this.onKey)}render(){const{error:n,componentStack:r,reportOpen:s}=this.state;return n?a.jsxs("div",{className:"error-fallback",children:[a.jsxs("div",{className:"error-fallback-card",role:"alert",children:[a.jsx("p",{className:"error-fallback-title",children:"Something went wrong"}),a.jsx("p",{className:"error-fallback-note",children:"The deck hit an error it could not draw past. Reloading usually clears it — and if it keeps happening, a report tells the people who make ccdeck what broke."}),a.jsxs("div",{className:"error-fallback-actions",children:[a.jsx("button",{type:"button",className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"}),a.jsx("button",{type:"button",className:"btn",onClick:()=>this.setState({reportOpen:!0}),"aria-haspopup":"dialog",children:"Send report"})]})]}),s&&a.jsx(sP,{initialKind:"bug",initialBody:uie(n.message,r),onClose:()=>this.setState({reportOpen:!1})})]}):this.props.children}}const hie=1e3;function fie(e={}){const t=Math.max(1,Math.floor(e.limit??hie)),n=e.protect;let r=!1,s=[],o=new Set,l=0,c=0,d=null;return{get paused(){return r},get size(){return s.length},get dropped(){return l},get overflowed(){return l>0},get through(){return c},accept(h){const f=typeof(h==null?void 0:h.seq)=="number"?h.seq:null,p=(h==null?void 0:h.epoch)??null,g=p!==null&&p!==d;g&&(d=p,c=0);const v=f!==null&&!g&&f<=c;if(f!==null&&f>c&&(c=f),!r)return!0;if(v)return!1;if(s.push(h),n!=null&&n(h)&&o.add(h),s.length>t){let N=0;if(o.size<s.length)for(;o.has(s[N]);)N++;const[k]=s.splice(N,1);o.delete(k),l++}return!1},setPaused(h){if(r=h,h)return[];const f=s;return s=[],o=new Set,l=0,f}}}function pie(e){const t=y.useState(()=>fie({protect:o=>J8(e.current,o)}))[0],[n,r]=y.useState(!1),s=y.useCallback(()=>{const o=t.paused&&t.dropped>0,l=t.setPaused(!t.paused);o&&Rq(e.current);for(const c of l)e.current=h$(e.current,c);r(t.paused)},[t,e]);return{pauseGate:t,paused:n,togglePause:s}}const Eb={kind:"assumed",claude:!0,codex:!0};function mie(e){if(!e||typeof e!="object")return Eb;const t=e.providers;if(!t||typeof t!="object")return Eb;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function gie(e){const[t,n]=y.useState(null),[r,s]=y.useState(Eb);y.useEffect(()=>{let l=!1;return fetch("/api/health").then(c=>c.ok?c.json():null).then(c=>{l||(s(mie(c)),!(!c||typeof c.workspace!="string")&&n(c.workspace))}).catch(()=>{}),()=>{l=!0}},[e]);const o=_n(r);return{workspace:t,providers:r,providersRef:o}}const mP=3*6e4,yie=2e4;function wie({fetchReport:e,visible:t,now:n,onReport:r}){let s=0,o=!0;const l=async()=>{if(!t())return;const c=await e();!o||!c||(s=n(),r(c))};return{tick:l,wake:async()=>{t()&&n()-s>=mP&&await l()},stop:()=>{o=!1}}}async function vie(){try{const e=await fetch("/api/provider-status",{signal:AbortSignal.timeout(yie)});return e.ok?await e.json():null}catch{return null}}function xie(e){const[t,n]=y.useState(null);return y.useEffect(()=>{if(!e){n(null);return}const r=wie({fetchReport:vie,visible:()=>document.visibilityState==="visible",now:()=>Date.now(),onReport:n});r.tick();const s=window.setInterval(r.tick,mP),o=()=>{r.wake()};return document.addEventListener("visibilitychange",o),()=>{r.stop(),window.clearInterval(s),document.removeEventListener("visibilitychange",o)}},[e]),t}const bie={degraded:"degraded performance",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},kie={degraded:"degraded",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},Nie={degraded:"degraded",partial_outage:"outage",major_outage:"outage",maintenance:"maint."},jie={claude:"Claude",codex:"Codex"},Sie=new Set(["status.claude.com","status.openai.com"]),_ie=30*6e4,Eie=10*6e4;function Tie(e){if(typeof e!="string")return null;try{const t=new URL(e);return t.protocol==="https:"&&Sie.has(t.hostname)?t:null}catch{return null}}function fM(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}function Cie(e){const t=Math.floor(e/6e4);return t<1?"just now":t<60?`${t} min ago`:`${Math.floor(t/60)} h ago`}function Aie(e,t){if(!e||typeof e!="object")return null;const n=Ot(bie,e.state),r=Ot(jie,e.provider);if(!n||!r||typeof e.checkedAt!="number"||t-e.checkedAt>_ie)return null;const s=Tie(e.statusPageUrl);if(!s)return null;const o=Array.isArray(e.components)?e.components:[],l=e.stale===!0||t-e.checkedAt>Eie,c=[`${r}: ${n}${e.summary?` — ${e.summary}`:""}`,o.length>0?`Affected: ${o.join(", ")}`:null,e.scope==="page"?`The page's overall status: it names none of ${r}'s components`:null,l?`Last read from ${s.hostname} at ${fM(e.checkedAt)}; this is the last thing it said`:`Reported by ${s.hostname}, checked ${Cie(t-e.checkedAt)}`,"Opens the status page"],d=l?fM(e.checkedAt):null;return{provider:e.provider,state:e.state,name:r,label:`${r} · ${n}${d?` · as of ${d}`:""}`,words:n,chipWords:Ot(kie,e.state)??n,shortWords:Ot(Nie,e.state)??n,asOf:d,what:e.summary||(o.length>0?o.join(", "):null),href:s.href,host:s.hostname,stale:l,detail:c.filter(Boolean).join(`
307
- `)}}function Rie(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>Aie(n,t)).filter(n=>n!==null)}function Mie(e){return e.map(t=>`${t.name}'s status page reports ${t.state.endsWith("outage")?`a ${t.words}`:t.words}.`).join(" ")}const $ie="The providers' status pages report no incident.";function Iie({version:e,loadVersion:t}){var h;const[n,r]=y.useState(!1),s=((h=e==null?void 0:e.upgrade)==null?void 0:h.state)??"idle",o=Rse(e==null?void 0:e.upgrade),l=y.useRef(!1),c=y.useCallback(async()=>{if(lr(l.current||s==="running")){l.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await t(),l.current=!1}},[s,t]);y.useEffect(()=>{if(s!=="running")return;const f=window.setInterval(t,3e3);return()=>window.clearInterval(f)},[s,t]);const d=y.useCallback(async()=>{const f=e==null?void 0:e.command;!f||!await eo(f)||(r(!0),window.setTimeout(()=>r(!1),1600))},[e==null?void 0:e.command]);return{upgradeState:s,upgradeFailure:o,startUpgrade:c,copyCommand:d,cmdCopied:n}}const pM="agent-dag.browserWatch.seenMs";function Oie(e,t){return e.filter(n=>n.startMs>t)}function Lie(){const[e,t]=y.useState(()=>Number(Qe(pM))||0),[n,r]=y.useState([]),[s,o]=y.useState(!1);y.useEffect(()=>{let d=!0;const h=()=>{fetch("/api/browser-watch?live=0").then(p=>p.ok?p.json():null).then(p=>{var g;!d||!(p!=null&&p.ok)||(r(p.episodes??[]),o(((g=p.settings)==null?void 0:g.enabled)===!0))}).catch(()=>{})};h();const f=setInterval(h,5*6e4);return()=>{d=!1,clearInterval(f)}},[]);const l=y.useMemo(()=>Oie(n,e).length,[n,e]),c=y.useCallback(d=>{t(d),Ze(pM,String(d))},[]);return{watchOn:s,setWatchOn:o,watchUnseen:l,markWatchSeen:c}}const gP=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function mM(e){const t={};for(const n of gP)t[n]=e(n);return t}function Pie(e){return t=>e[t]??""}function Die(e,t){return gP.every(n=>e[n]===t[n])}const yP="agent-dag.theme";function Fie(e,t=!1){return e==="light"||e==="dark"?e:t?"light":"dark"}function Bie(){try{return window.matchMedia("(prefers-color-scheme: light)").matches}catch{return!1}}function qie(){return Fie(Qe(yP),Bie())}function gM(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function Uie(){const[e,t]=y.useState(qie),[n,r]=y.useState(wre),[s,o]=y.useState(()=>mM(gM)),l=y.useMemo(()=>Pie(s),[s]),c=y.useCallback(d=>vne(d,l),[l]);return y.useEffect(()=>{document.documentElement.dataset.theme=e,Ze(yP,e),o(d=>{const h=mM(gM);return Die(d,h)?d:h})},[e]),y.useEffect(()=>{Ze(zL,n?"1":"0")},[n]),y.useEffect(()=>{const d=document.querySelector('meta[name="theme-color"]'),h=s["--panel"];d&&h&&d.setAttribute("content",h)},[s]),{theme:e,setTheme:t,characterEnabled:n,setCharacterEnabled:r,palette:s,minimapNodeFill:c}}function zie(e){const t=y.useRef(null),[n,r]=y.useState(!1),[s,o]=y.useState(()=>new Set),l=y.useMemo(()=>{const d=new Set;for(const h of e.current.agents.values())for(const f of h.tools)d.add(qL(f.name));return Object.keys(BL).filter(h=>d.has(h))},[e.current,e.current.revision]);y.useEffect(()=>{if(l.length<=1){r(!1);return}let d=0;const h=()=>{const f=t.current;if(f&&!document.hidden){const p=f.getBoundingClientRect(),g=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(N=>N.getBoundingClientRect()),v=qH(p,g,8);r(N=>N===v?N:v)}d=window.setTimeout(h,300)};return h(),()=>window.clearTimeout(d)},[l.length]);const c=y.useCallback(d=>{o(h=>{const f=new Set(h);return f.has(d)?f.delete(d):f.add(d),f})},[]);return{presentCats:l,hiddenCats:s,toggleCat:c,catBarRef:t,catBarOccluded:n}}function Wie(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null;const r=new Set,s=()=>e.enabled()?(n==null?void 0:n.state)==="running"?"ready":"locked":"off",o=()=>{var g;return(g=e.onState)==null?void 0:g.call(e,s())};function l(){var g,v;if(!(!t||(n==null?void 0:n.state)==="running"))try{n||(n=new t,(g=n.addEventListener)==null||g.call(n,"statechange",o)),(v=n.resume)==null||v.call(n).then(o,()=>{}),o()}catch{}}function c(g,v,N=v.figure){if(!n||n.state!=="running")return!1;const k=db(g,N),x=NZ(v.level,k),j=n.currentTime;for(const b of k.notes){const _=n.createOscillator(),E=n.createGain();_.type=k.type??"sine",_.frequency.value=b.hz;const R=j+b.at,C=R+b.ms/1e3;E.gain.setValueAtTime(h_,R),E.gain.exponentialRampToValueAtTime(x,R+jZ),E.gain.exponentialRampToValueAtTime(h_,C),_.connect(E).connect(n.destination),_.start(R),_.stop(C+.02)}return!0}async function d(g,v){var x;if(!e.loadCustom)return"unavailable";let N;try{N=await e.loadCustom(g)}catch{return"unavailable"}if(!N)return"missing";if(N.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const j=new SpeechSynthesisUtterance(N.text),b=window.speechSynthesis.getVoices();j.voice=b.find(_=>_.voiceURI===N.voiceURI)??null,j.rate=N.rate,j.pitch=N.pitch,j.volume=SZ(v.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(j),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let k;try{k=await n.decodeAudioData(N.bytes.slice(0))}catch{return"broken"}try{const j=n.createBufferSource(),b=n.createGain();return j.buffer=k,b.gain.setValueAtTime(_Z(N.normalizationGain,v.level),n.currentTime),j.connect(b).connect(n.destination),r.add(j),(x=j.addEventListener)==null||x.call(j,"ended",()=>r.delete(j)),j.start(n.currentTime),"played"}catch{return"unavailable"}}function h(g,v=!1){var x,j;if(!v&&!e.enabled())return!1;const N=$Z((x=e.prefs)==null?void 0:x.call(e),g),k=((j=e.customSelection)==null?void 0:j.call(e)[g])??null;return k&&e.loadCustom?(d(k,N).then(b=>{var _;b==="played"||b==="locked"||((b==="missing"||b==="broken")&&((_=e.onCustomFailure)==null||_.call(e,g,k)),c(g,{...N,figure:jn},jn))}),!0):!n||n.state!=="running"?!1:c(g,N)}function f(g,v=Qa){return d(g,{level:vi(v),figure:jn}),!0}function p(){try{typeof window<"u"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()}catch{}for(const g of r)try{g.stop()}catch{}r.clear()}return{unlock:l,play:h,previewCustom:f,silence:p,state:s,get context(){return n}}}function Hie({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:r,fallbackCustomRef:s}){const[o,l]=y.useState("locked");return y.useEffect(()=>{const c=Wie({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>r.current,loadCustom:wZ,onCustomFailure:(p,g)=>s.current(p,g),onState:l});e.current=c,l(c.state());const d=["pointerdown","pointerup","keydown"],h=()=>{for(const p of d)window.removeEventListener(p,f,{capture:!0})},f=()=>{var p;c.unlock(),((p=c.context)==null?void 0:p.state)==="running"&&h()};for(const p of d)window.addEventListener(p,f,{capture:!0});return h},[]),{chimeState:o}}function Vie(){const[e,t]=y.useState(xre),[n,r]=y.useState(()=>h8(Qe(pj))),[s,o]=y.useState(()=>d8(Qe(mj))),[l,c]=y.useState(()=>f8(Qe(qR),n,gre)),[d,h]=y.useState(()=>new Set),[f,p]=y.useState(0);y.useEffect(()=>{Ze(WL,String(e))},[e]),y.useEffect(()=>{Ze(mj,s?"1":"0")},[s]),y.useEffect(()=>{Ze(pj,JSON.stringify(n))},[n]),y.useEffect(()=>{Ze(qR,l)},[l]);const g=y.useCallback(j=>{r(b=>b.some(_=>_.id===j.id)?b:[...b,j]),h(b=>{if(!b.has(j.id))return b;const _=new Set(b);return _.delete(j.id),_})},[]),v=y.useCallback((j,b)=>{const _=b.trim();!_||_.length>zl||r(E=>E.map(R=>R.id===j?{...R,name:_}:R))},[]),N=y.useCallback(j=>{r(b=>b.filter(_=>_.id!==j)),c(b=>p8(b,j)),h(b=>{if(!b.has(j))return b;const _=new Set(b);return _.delete(j),_})},[]),k=y.useCallback(j=>{const b=gj(j),_=d.has(b);j===l&&!_||(_&&h(E=>{const R=new Set(E);return R.delete(b),R}),c(j),p(E=>E+1))},[l,d]),x=y.useCallback((j,b)=>{const _=gj(j);h(E=>{if(E.has(_)===b)return E;const C=new Set(E);return b?C.add(_):C.delete(_),C})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:s,setFmMuted:o,fmSource:l,customFmStations:n,unavailableFmStations:d,fmPlayRequest:f,addFmStation:g,renameFmStation:v,removeFmStation:N,pickFmSource:k,markFmStationAvailability:x}}function Gie(e){const[t,n]=y.useState(null),[r,s]=y.useState(!1),[o,l]=y.useState(null),c=y.useRef(0);y.useEffect(()=>{if(!e||!ac())return;let N=!1;const k=c.current;return fetch("/api/desktop-update").then(x=>x.ok?x.json():null).then(x=>{if(N||c.current!==k)return;const j=KR(x);j&&n(j)}).catch(()=>{}),()=>{N=!0}},[e]);const d=Zre(t),h=y.useRef(!1),f=y.useRef(0),p=y.useRef(0);y.useEffect(()=>()=>window.clearTimeout(f.current),[]);const g=y.useCallback(async N=>{if(!lr(h.current))return;const k=++p.current;window.clearTimeout(f.current),h.current=!0,s(!0),l(null);const x=j=>{k===p.current&&(window.clearTimeout(f.current),h.current=!1,s(!1),l({failure:j,version:N}))};try{const j=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:N})});if(!j.ok)return x(tse(await j.json().catch(()=>null)))}catch{return x("unreachable")}k===p.current&&(f.current=window.setTimeout(()=>x("timeout"),HL))},[]),v=y.useCallback(N=>{if(ac())try{const k=KR(JSON.parse(N));k&&(c.current++,n(k),k.status!=="ready"&&(p.current++,window.clearTimeout(f.current),h.current=!1,s(!1)))}catch{}},[]);return{desktopUpdateRestarting:r,desktopUpdateFailure:o,readyAppUpdate:d,askDesktopUpdateRestart:g,onDesktopUpdateEvent:v}}const Xu="agent-dag.autoRestart",yM="agent-dag.bundleReloadedFor";function Kie({now:e,stateRef:t,version:n,notice:r,noticeOpen:s,upgradeFailure:o,paused:l}){const[c,d]=y.useState(()=>Qe(Xu)!=="0"),h=y.useRef(!1),f=y.useCallback(()=>{const F=!c;h.current=!0,hs(Xu),d(F),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:F})}).then(O=>O.ok?O.json():null).then(O=>{var I;O!=null&&O.ok&&d(((I=O.prefs)==null?void 0:I.autoUpdate)!==!1)}).catch(()=>{})},[c]),[p,g]=y.useState(!1),[v,N]=y.useState("restart"),[k,x]=y.useState(null),j=y.useRef(!1),b=y.useRef(null),_=y.useRef(0),E=y.useRef(null),R=y.useCallback(async F=>{if(!lr(j.current))return;const O=(F==null?void 0:F.upgrade)===!0,I=(F==null?void 0:F.whenIdle)===!0;j.current=!0,b.current=o;const B=++_.current,M=()=>{N(O?"npx":"restart"),g(!0)};I||M();try{window.sessionStorage.setItem("agent-dag.restartPending",(r==null?void 0:r.to)??"")}catch{}let $=!1;try{const P=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(I?{upgrade:O,whenIdle:I}:{upgrade:O})});$=I&&P.status===409}catch{}if($){j.current=!1,E.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}I&&M(),window.setTimeout(()=>{if(_.current===B&&j.current){j.current=!1,g(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},O?18e4:3e4)},[r==null?void 0:r.to,o]);y.useEffect(()=>{const F=YR(t.current.agents.values())>0,O=Lse({enabled:c,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:F,idleSince:E.current,now:e});E.current=O.idleSince,O.restart&&R({whenIdle:!0})},[c,r==null?void 0:r.kind,n==null?void 0:n.canRestart,s,e,R]);const C=YR(t.current.agents.values()),A=Ose(C,l),U=KL({enabled:c,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:C>0,idleSince:E.current,now:e});y.useEffect(()=>{const F=n==null?void 0:n.running;let O=null,I=null;try{O=window.sessionStorage.getItem("agent-dag.restartPending"),I=window.sessionStorage.getItem(yM)}catch{return}const B=Ase({bundle:"3.38.1",running:F,pending:O,lastTried:I});if(B==="reload"){try{window.sessionStorage.setItem(yM,F??"")}catch{return}window.location.reload();return}if(B!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}j.current=!1,g(!1),x(F??null);const M=window.setTimeout(()=>x(null),6e3);return()=>window.clearTimeout(M)},[n==null?void 0:n.running]),y.useEffect(()=>{if(p&&Mse({asked:b.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}j.current=!1,g(!1)}},[p,o]);const L=y.useCallback(F=>{var O,I;if(!h.current){const B=Qe(Xu)==="0";hs(Xu),B&&((O=F.prefs)==null?void 0:O.autoUpdate)!==!1?(d(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):d(((I=F.prefs)==null?void 0:I.autoUpdate)!==!1)}},[]);return{autoRestart:c,toggleAutoRestart:f,restarting:p,restartMode:v,restartedTo:k,askRestart:R,restartCopy:A,restartFuseMs:U,loadAutoRestartPrefs:L}}function Yie(){const[e,t]=y.useState([]),n=y.useRef(new Set),[r,s]=y.useState(null),[o,l]=y.useState(void 0);y.useEffect(()=>{let h=!0,f=0;const p=()=>{fetch("/api/lan").then(g=>g.ok?g.json():null).then(g=>h?(g!=null&&g.ok&&t(LS(Array.isArray(g.pending)?g.pending:[],g.aliases)),g):null).catch(()=>null).then(g=>{h&&(l(v=>g!=null&&g.ok?g:v===void 0?null:v),f=window.setTimeout(p,(g==null?void 0:g.enabled)===!0?rb:qI))})};return p(),()=>{h=!1,window.clearTimeout(f)}},[]);const c=y.useCallback(async(h,f)=>{if(!r){s(h);try{const g=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:h,fp:f})})).json().catch(()=>null);g&&Array.isArray(g.pending)?t(LS(g.pending,g.aliases)):t(v=>v.filter(N=>N.fp!==f))}catch{}finally{s(null)}}},[r]),d=y.useCallback(h=>{r||(n.current.add(h),t(f=>[...f]))},[r]);return{lanPending:e,lanDeferred:n,lanBusy:r,answerLanPair:c,deferLanPair:d,lanStatus:o}}const Xie=6e4;function Zie({enabled:e,lanStatus:t,now:n}){const[r,s]=y.useState(null),[o,l]=y.useState(()=>new Set),[c,d]=y.useState(null),h=y.useCallback(j=>{j!=null&&j.ok&&Array.isArray(j.accounts)&&s(j.accounts)},[]),f=y.useCallback(async j=>{try{const b=await fetch(`/api/claude-accounts${j?"?refresh=1":""}`);b.ok&&h(await b.json())}catch{}},[h]);y.useEffect(()=>{e&&f(!1)},[e,f]),y.useEffect(()=>{if(!e)return;let j=Date.now();const b=()=>{document.visibilityState!=="visible"||Date.now()-j<Xie||(j=Date.now(),f(!1))};return document.addEventListener("visibilitychange",b),window.addEventListener("focus",b),()=>{document.removeEventListener("visibilitychange",b),window.removeEventListener("focus",b)}},[e,f]);const p=y.useMemo(()=>e?uoe(r,{lan:t,now:n,closed:o}):[],[e,r,t,n,o]),g=y.useRef(p);g.current=p;const v=y.useCallback(j=>{j.length&&l(b=>new Set([...b,...j]))},[]),N=y.useCallback(()=>{const j=g.current;j.length&&(v(j.map(b=>b.id)),fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reauth-later",incidents:j.map(b=>({key:b.key,since:b.since}))})}).catch(()=>{}))},[v]),k=y.useRef(c);k.current=c;const x=y.useCallback(j=>{const b=k.current;v(doe(b?[b,...g.current]:g.current,j))},[v]);return{rows:p,signingIn:c,observe:h,signIn:d,signedIn:x,refresh:y.useCallback(()=>{f(!0)},[f]),closeSignIn:y.useCallback(()=>d(null),[]),later:N}}const wP="agent-dag.sessionListOpen",vP="agent-dag.accountsPanelOpen";function Jie(){return Qe(wP)==="1"}function Qie(e){Ze(wP,e?"1":"0")}function ele(){const e=Qe(vP);return e===null?!0:e==="1"}function tle(){const[e,t]=y.useState(Jie);y.useEffect(()=>{Qie(e)},[e]);const n=y.useRef(!1),[r,s]=y.useState(()=>{const h=ele();return h&&e?(n.current=!0,!1):h});y.useEffect(()=>{!r&&n.current||Ze(vP,r?"1":"0")},[r]),y.useEffect(()=>{!e&&n.current&&(n.current=!1,s(!0))},[e]);const o=y.useCallback(()=>{t(h=>(h||s(f=>(f&&(n.current=!0),!1)),!h))},[]),l=y.useCallback(()=>{n.current=!1,s(h=>(h||t(!1),!h))},[]),c=y.useCallback(()=>t(!1),[]),d=y.useCallback(()=>s(!1),[]);return{sessionListOpen:e,accountsPanelOpen:r,toggleSessionList:o,toggleAccountsPanel:l,closeSessionList:c,closeAccountsPanel:d}}const xP="agent-dag.detailOpen",bP="agent-dag.usagePanelOpen",kP="agent-dag.systemPanelOpen";function nle(){return Qe(xP)==="1"}function rle(e){Ze(xP,e?"1":"0")}function sle(){const e=Qe(bP);return e===null?!0:e==="1"}function ale(e){Ze(bP,e?"1":"0")}function ole(){const e=Qe(kP);return e===null?!0:e==="1"}function ile(e){Ze(kP,e?"1":"0")}function lle(){const[e,t]=y.useState(nle);y.useEffect(()=>{rle(e)},[e]);const[n,r]=y.useState(sle);y.useEffect(()=>{ale(n)},[n]);const[s,o]=y.useState(ole);return y.useEffect(()=>{ile(s)},[s]),qt("usage-panel",n),qt("machine-panel",s),{detailOpen:e,setDetailOpen:t,usagePanelOpen:n,setUsagePanelOpen:r,machinePanelOpen:s,setMachinePanelOpen:o}}const cle={permission:"your permission",asked:"your answer"},ule="No sessions are waiting for you.";function dle(e){if(e.length===0)return"";const[t,...n]=e,r=t.waiting.kind,s=n.every(l=>l.waiting.kind===r)?cle[r]??"you":"you";if(n.length===0)return`${t.label} is waiting for ${s}.`;const o=`${n.length} more session${n.length===1?"":"s"}`;return`${t.label} and ${o} are waiting for ${s}.`}function px(e,t,n=ule){return t!==""?t:e===""?"":n}function hle({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[r,s]=y.useState(""),o=dle(e);y.useEffect(()=>{s(g=>px(g,o))},[o]);const[l,c]=y.useState(""),d=t>0?`Browser watch has ${t} unread ${t===1?"finding":"findings"}.`:"";y.useEffect(()=>{c(g=>px(g,d,"Browser watch has no unread findings."))},[d]);const[h,f]=y.useState(""),p=Mie(n);return y.useEffect(()=>{f(g=>px(g,p,$ie))},[p]),{blockedSaid:r,watchSaid:l,setWatchSaid:c,incidentSaid:h}}const fle="/icon-192.png";function ple({waitingSessions:e,liveSince:t,focusSession:n}){const[r,s]=y.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[o,l]=y.useState(null),[c,d]=y.useState(!1),[h,f]=y.useState(!1),p=y.useRef(()=>{}),g=y.useRef(new Set),v=_n(e),N=y.useCallback(()=>{const R=!c;d(R),R&&(g.current=Iu(v.current)),R&&typeof Notification<"u"&&Notification.permission==="default"&&p.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:R})}).then(C=>C.ok?C.json():null).then(C=>{var A;C!=null&&C.ok&&(d(((A=C.prefs)==null?void 0:A.notifications)===!0),f(C.notificationsVetoed===!0))}).catch(()=>{})},[c]),k=typeof Notification<"u";y.useEffect(()=>{if(!o)return;const C=setTimeout(()=>l(null),o==="blocked"?8e3:4e3);return()=>clearTimeout(C)},[o]);const x=y.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(R=>{const C=R;s(C),C==="granted"?l("on"):C==="denied"&&l("blocked")})},[]);p.current=x;const j=y.useRef(null),b=e.map(R=>Qd(R.id,R.waiting)).join("|");y.useEffect(()=>{Zq(j.current,r)&&(j.current=r,g.current=Iu(e))},[r]);const _=y.useRef(!1);y.useEffect(()=>{Jq(_.current,t)&&(_.current=!0,g.current=Iu(e))},[t]),y.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!Qq(j.current,t))return;const R=typeof document>"u"||!document.hidden,C=Yq(e,g.current,R,c);for(const A of C)try{const U=new Notification(A.title,{body:A.body,tag:A.key,icon:fle});U.onclick=()=>{window.focus(),n(A.sessionId),U.close()}}catch{}g.current=R?Iu(e):Xq(e,C,g.current)},[b,t]);const E=y.useCallback(R=>{var C;d(((C=R.prefs)==null?void 0:C.notifications)===!0),f(R.notificationsVetoed===!0)},[]);return{notifyPermission:r,notifySaid:o,notifyOn:c,notifyVetoed:h,toggleNotify:N,notifySupported:k,askForNotifications:x,loadNotifyPrefs:E}}function mle({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:r,summaryFor:s,browserWatchOpen:o,keyHelpOpen:l,releaseNotes:c,feedbackOpen:d}){const h=_n(l),f=y.useRef(!1);return f.current=e!=null||t||n!=null||r||s!=null||o||l||c!=null||d,{keyHelpOpenRef:h,modalOpenRef:f}}function gle({stateRef:e,tourOpen:t,releaseNotes:n}){const[r,s]=y.useState(null),o=y.useCallback((F,O)=>s({agentId:F,toolId:O}),[]),[l,c]=y.useState(null),[d,h]=y.useState(null),f=y.useCallback(F=>h(F),[]),[p,g]=y.useState(!1),[v,N]=y.useState(!1),[k,x]=y.useState(!1),[j,b]=y.useState(!1),[_,E]=y.useState(null),R=y.useCallback(F=>{E(F??null),b(!0)},[]);qt("tool-detail",r!==null),qt("session-summary",l!==null),qt("context-window",d!==null),qt("keyboard-help",p),qt("usage-history",v),qt("browser-watch",k),qt("feedback",j);const C=r?K8(e.current.agents,r.agentId,r.toolId):null,A=d?e.current.agents.get(d):void 0,{keyHelpOpenRef:U,modalOpenRef:L}=mle({openedTool:C,usageHistoryOpen:v,contextFor:d,tourOpen:t,summaryFor:l,browserWatchOpen:k,keyHelpOpen:p,releaseNotes:n,feedbackOpen:j});return{setOpenedToolKey:s,openTool:o,openedTool:C,summaryFor:l,setSummaryFor:c,contextFor:d,setContextFor:h,openContext:f,contextAgent:A,keyHelpOpen:p,setKeyHelpOpen:g,usageHistoryOpen:v,setUsageHistoryOpen:N,browserWatchOpen:k,setBrowserWatchOpen:x,feedbackOpen:j,setFeedbackOpen:b,feedbackPrefill:_,setFeedbackPrefill:E,openFeedback:R,keyHelpOpenRef:U,modalOpenRef:L}}function yle({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:r,lastLayoutSigRef:s,forgetRemovals:o,clearSelection:l,rerender:c,modalOpenRef:d}){const[h,f]=y.useState(!1),p=y.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}e.current=Yb(),t.current.clear(),n.current.clear(),r.current.clear(),s.current="",IL(),o(),l(),c()},[c,l,o]),g=_n(h),v=y.useCallback(N=>{const k=Fse(N,{confirmOpen:g.current,modalOpen:d.current});k==="confirm"?f(!0):k==="clear"&&(f(!1),p())},[p]);return{clearConfirmOpen:h,setClearConfirmOpen:f,requestClear:v}}const wM="agent-dag.oldNameNoticeDismissed";function wle(e){const[t,n]=y.useState(()=>Qe(wM)??""),r=e!=null&&e.invokedAs&&e.invokedAs!==kt?e.invokedAs:null,s=r!=null&&t!==r,o=y.useCallback(()=>{r&&(n(r),Ze(wM,r))},[r]);return{oldName:r,oldNameOpen:s,dismissOldName:o}}const vle=300*1e3,xle=1800*1e3,ble=8e3,kle=3e4;function vM(e){return fetch("/api/rating",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}).catch(()=>null)}function Nle({modalOpenRef:e}){const t=y.useCallback(()=>k$({appModal:e.current,dialogDepth:ds.dialogDepth()}),[e]),[n,r]=y.useState("hidden"),[s,o]=y.useState(null),[l,c]=y.useState(!1),d=y.useRef(n);d.current=n,y.useEffect(()=>{let v=!1;const N=async()=>{if(d.current==="thanks"||d.current==="hidden"&&(document.hidden||t()))return;const j=await fetch("/api/rating").then(b=>b.ok?b.json():null).catch(()=>null);v||!j||r(b=>b==="thanks"?b:j.ask===!0?"asking":"hidden")},k=window.setTimeout(N,vle),x=window.setInterval(N,xle);return()=>{v=!0,window.clearTimeout(k),window.clearInterval(x)}},[t]),y.useEffect(()=>{if(n!=="thanks"||l)return;const v=s!==null&&s<=6?kle:ble;let N=0;const k=()=>{t()?N=window.setTimeout(k,v):r("hidden")};return N=window.setTimeout(k,v),()=>window.clearTimeout(N)},[n,s,l,t]);const h=y.useCallback(v=>{o(v),c(!1),r("thanks"),vM({score:v})},[]),f=y.useCallback(v=>c(v),[]),p=y.useCallback(()=>{r("hidden"),vM({later:!0})},[]),g=y.useCallback(()=>r("hidden"),[]);return{ratingPhase:n,ratingScore:s,answerRating:h,rateLater:p,closeRating:g,holdThanks:f}}function jle({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:r}){const[s,o]=y.useState(()=>oZ(Qe)),l=_n(s),[c,d]=y.useState([]),h=y.useCallback(b=>{o(_=>{const E={..._,[b]:null};return l.current=E,E}),hs(Il[b])},[]),f=y.useCallback((b,_)=>{const E=l.current[b];_&&E!==_||(h(b),t(R=>{const C={...R,[b]:{...R[b],figure:jn}};return n.current=C,C}),Ze(Id[b],jn))},[h]),p=_n(f);y.useEffect(()=>{let b=!0;return yZ().then(_=>{if(!b)return;d(_);const E=new Set(_.map(R=>R.id));for(const R of ad){const C=l.current[R];C&&!E.has(C)&&p.current(R,C)}},()=>{}),()=>{b=!1}},[]);const g=y.useCallback((b,_)=>{if(!c.some(R=>R.id===_))return;const E={...l.current,[b]:_};l.current=E,o(E),Ze(Il[b],_),r(b,!0)},[c,r]),v=y.useCallback(async b=>{var C;const _=ub(c.length);if(_)throw new Error(_);const E=window.AudioContext??window.webkitAudioContext;if(!E)throw new Error("This browser cannot decode audio files.");const R=new E;try{const A=await hZ(b,L=>R.decodeAudioData(L));await u_(A);const U=tc(A);d(L=>[...L.filter(F=>F.id!==U.id),U])}finally{(C=R.close)==null||C.call(R)}},[c.length]),N=y.useCallback(async b=>{const _=ub(c.length);if(_)throw new Error(_);const E=fZ(b);await u_(E);const R=tc(E);d(C=>[...C.filter(A=>A.id!==R.id),R])},[c.length]),k=y.useCallback(async(b,_)=>{const E=c.find(C=>C.id===b),R=_.trim().slice(0,80);!E||!R||R===E.name||(await vZ(b,R),d(C=>C.map(A=>A.id===b?{...A,name:R}:A)))},[c]),x=y.useCallback(async b=>{await xZ(b),d(C=>C.filter(A=>A.id!==b));const _=l.current,E=iZ(_,b);l.current=E,o(E);const R=ad.filter(C=>_[C]===b);for(const C of R)hs(Il[C]),Ze(Id[C],jn);R.length>0&&t(C=>{const A={...C};for(const U of R)A[U]={...A[U],figure:jn};return n.current=A,A})},[]),j=y.useCallback(b=>{var R,C;const _=ad.find(A=>l.current[A]===b),E=_?n.current[_].level:Qa;(R=e.current)==null||R.unlock(),(C=e.current)==null||C.previewCustom(b,E)},[]);return{customSelections:s,customSelectionsRef:l,customAssets:c,clearCustomOnly:h,fallbackCustomRef:p,selectCustomTone:g,importNotificationAudio:v,createNotificationVoice:N,renameCustomAsset:k,deleteCustomAsset:x,previewCustomAsset:j}}function Sle(e){const[t,n]=y.useState(()=>MZ(Qe)),r=_n(t),s=y.useRef(null),o=y.useCallback((c,d=!1)=>{var h,f;if((h=e.current)==null||h.unlock(),s.current!==null&&clearTimeout(s.current),s.current=null,!d){(f=e.current)==null||f.play(c,!0);return}s.current=setTimeout(()=>{var p;s.current=null,(p=e.current)==null||p.play(c,!0)},EZ)},[]),l=y.useCallback((c,d)=>{n(h=>{const f={level:vi(d.level??h[c].level),figure:yO(c,d.figure??h[c].figure)};return Ze(xO[c],String(f.level)),Ze(Id[c],f.figure),{...h,[c]:f}}),o(c,!0)},[o]);return y.useEffect(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]),{tonePrefs:t,setTonePrefs:n,tonePrefsRef:r,previewTone:o,changeTone:l}}const _le=15e3;function Ele(e){return e.visibilityState==="visible"&&e.hasFocus()}function Tle(e,t){return t||e===!0}function Cle(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Ale(){y.useEffect(()=>{const e=Cle();let t=null;const n=l=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:e,looking:l}),keepalive:!0}).catch(()=>{})},r=()=>{const l=Ele(document);Tle(t,l)&&n(l),t=l},s=()=>{t&&n(!1),t=!1};r();const o=window.setInterval(r,_le);return window.addEventListener("focus",r),window.addEventListener("blur",r),document.addEventListener("visibilitychange",r),window.addEventListener("pagehide",s),()=>{window.clearInterval(o),window.removeEventListener("focus",r),window.removeEventListener("blur",r),document.removeEventListener("visibilitychange",r),window.removeEventListener("pagehide",s),s()}},[])}function Rle({loadAutoRestartPrefs:e,loadNotifyPrefs:t,loadReportsPrefs:n}){y.useEffect(()=>{let r=!0;return fetch("/api/prefs").then(s=>s.ok?s.json():null).then(s=>{!r||!(s!=null&&s.ok)||(e(s),t(s),n(s))}).catch(()=>{}),()=>{r=!1}},[])}const mx="agent-dag.versionNoticeDismissed",Mle=15*6e4;function $le(e){const[t,n]=y.useState(null),[r,s]=y.useState(()=>Qe(mx)??""),o=y.useRef(0),[l,c]=y.useState(!1),d=y.useCallback((k=!1)=>(k&&(o.current=Date.now(),c(!0)),fetch(k?"/api/version?refresh=1":"/api/version").then(x=>x.ok?x.json():null).then(x=>{x&&n(x)}).catch(()=>{}).finally(()=>{k&&c(!1)})),[]),h=y.useCallback(()=>{d(Date.now()-o.current>=Mle)},[d]);y.useEffect(()=>{d();const k=window.setInterval(h,5*6e4),x=()=>{document.visibilityState==="visible"&&h()};return document.addEventListener("visibilitychange",x),()=>{window.clearInterval(k),document.removeEventListener("visibilitychange",x)}},[d,h]),y.useEffect(()=>{e&&d()},[e,d]);const f=(t==null?void 0:t.notice)??null,p=VL(f),g=ise(f,r),v=y.useCallback(()=>{s(""),Ze(mx,"")},[]),N=y.useCallback(()=>{f&&(s(p),Ze(mx,p))},[f,p]);return{version:t,notice:f,noticeOpen:g,showNotice:v,dismissNotice:N,versionChecking:l,loadVersion:d}}function Ile({version:e,readyAppUpdate:t}){const[n,r]=y.useState(!1),s=y.useRef(null),[o,l]=y.useState(null),c=o&&t?t.version:null,d=y.useRef(null);y.useEffect(()=>{!c||d.current===c||(d.current=c,fetch("/api/desktop-update/seen",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:c})}).catch(()=>{}))},[c]);const h=y.useRef(!1);y.useEffect(()=>{if(h.current)return;const x=Ml(),j=Moe(x),b=Doe({stored:j,running:(e==null?void 0:e.running)??null,notes:aM,remembers:$oe(x)});if(b.reason==="no-version")return;h.current=!0,b.record&&Ioe(x,b.record);let _=!0;return(async()=>{var U;let R=Ooe(x);if(ac())try{const L=await fetch("/api/prefs");if(!L.ok)throw new Error("desktop tour preferences unavailable");const F=await L.json();if(!(F!=null&&F.ok))throw new Error("desktop tour preferences unavailable");const O=((U=F.prefs)==null?void 0:U.tourSeen)===!0;R&&!O&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{}),R=R||O}catch{R=!0}if(!_)return;const C=Poe({tourSeen:R,decision:b}),A=b.show.length?{entries:b.show,since:j,firstRun:!1}:null;C.tour&&r(!0),C.notes==="now"?l(A):C.notes==="after"&&(s.current=A)})(),()=>{_=!1}},[e==null?void 0:e.running]);const f=(e==null?void 0:e.running)??"3.38.1",p=y.useMemo(()=>iP(aM,null,f),[f]),g=y.useCallback(()=>{l({entries:p,since:null,firstRun:!1})},[p]),v=y.useCallback(()=>r(!0),[]),N=y.useCallback(()=>l(null),[]),k=y.useCallback(()=>{r(!1),Loe(Ml()),ac()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const x=s.current;s.current=null,x&&l(x)},[]);return{tourOpen:n,openTour:v,closeTour:k,releaseNotes:o,closeReleaseNotes:N,chipVersion:f,openReleaseNotes:g}}function Ole(){const[e,t]=y.useState(void 0),[n,r]=y.useState(!1),s=y.useRef(!1);return s.current=e===!0&&!n,y.useEffect(()=>lie(()=>s.current),[]),{loadReportsPrefs:y.useCallback(l=>{var c;t(((c=l.prefs)==null?void 0:c.reports)!==!1),r(l.reportsVetoed===!0)},[])}}function Lle(){const[e,t]=y.useState(null),[n,r]=y.useState(!1),s=y.useRef(null);return y.useEffect(()=>{let o=!0,l=!1,c=null,d=null,h="";const f=k=>{o&&(r(!0),k!==h&&t(null))},p=()=>{if(l)return;l=!0,c=Date.now();const k=VR();d=k,fetch(`/api/ccusage?since=${k}`).then(x=>x.ok?x.json():null).then(x=>{if(o){if(!(x!=null&&x.ok)){f(k);return}h=k,t(Yre(x)),r(!1)}}).catch(()=>f(k)).finally(()=>{l=!1})},g=()=>{const k=s.current;Kre({shown:!!k&&k.getClientRects().length>0,tabVisible:document.visibilityState==="visible",lastSince:d,since:VR(),lastReadAt:c,now:Date.now()})&&p()};g();const v=window.setInterval(g,Gre);document.addEventListener("visibilitychange",g);let N=null;return s.current&&typeof ResizeObserver<"u"&&(N=new ResizeObserver(g),N.observe(s.current)),()=>{o=!1,window.clearInterval(v),document.removeEventListener("visibilitychange",g),N==null||N.disconnect()}},[]),{monthlyUsage:e,monthlyUsageUnavailable:n,monthUsageRef:s}}function Ple(e){const[t,n]=y.useState(null);y.useEffect(()=>{const c=Qe("agent-dag.sound");n(c===null?!0:c==="on")},[]);const r=y.useCallback(()=>{n(c=>{var h,f;const d=c!==!0;return Ze("agent-dag.sound",d?"on":"off"),d?(h=e.current)==null||h.unlock():(f=e.current)==null||f.silence(),d})},[]),s=y.useCallback(c=>{r()},[r]),o=_n(s),l=_n(t);return{soundOn:t,toggleSound:r,activateSoundRef:o,soundOnRef:l}}function Dle(){const[e,t]=y.useState(!1),n=y.useRef(null),[r,s]=y.useState(!1),o=y.useRef(null);return y.useEffect(()=>{e&&s(!1)},[e]),{soundMenuOpen:e,setSoundMenuOpen:t,soundButtonRef:n,appearanceMenuOpen:r,setAppearanceMenuOpen:s,appearanceButtonRef:o}}const Fle="agent-dag.autoFitDisabled";function Ble(e){const t=y.useRef(!1),[n,r]=y.useState(!1);y.useEffect(()=>{hs(Fle)},[]);const s=y.useCallback(()=>{t.current||(t.current=!0,r(!0))},[]),o=y.useCallback(()=>{t.current=!1,r(!1),e(400)},[e]);return{autoFitDisabled:n,autoFitDisabledRef:t,disableAutoFit:s,enableAutoFitAndRefit:o}}function qle(){return a.jsx(Vb,{children:a.jsx(die,{children:a.jsx(Ule,{})})})}function Ule(){const e=ki(),t=y.useState(Yb)[0],n=y.useRef(t),[,r]=y.useState(0),s=y.useCallback(()=>r(ba=>ba+1),[]),{detailOpen:o,setDetailOpen:l,usagePanelOpen:c,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f}=lle(),{selectedIds:p,primarySelectedId:g,selectAgent:v,clearSelection:N,pruneSelectionToBoard:k}=XZ(n,l),{sessionListOpen:x,accountsPanelOpen:j,toggleSessionList:b,toggleAccountsPanel:_,closeSessionList:E,closeAccountsPanel:R}=tle(),C=Lle(),A=td(j,200),U=td(c,130),L=td(h,130),F=y.useRef(null),O=Ple(F),{activateSoundRef:I,soundOnRef:B}=O,M=Sle(F),{setTonePrefs:$,tonePrefsRef:P,previewTone:G}=M,K=jle({chimesRef:F,setTonePrefs:$,tonePrefsRef:P,previewTone:G}),{customSelectionsRef:q,fallbackCustomRef:H}=K,D=Dle(),{setSoundMenuOpen:W}=D,{chimeState:J}=Hie({chimesRef:F,soundOnRef:B,tonePrefsRef:P,customSelectionsRef:q,fallbackCustomRef:H}),V=pie(n),{pauseGate:X,paused:Y,togglePause:Z}=V,ee=y.useRef(()=>{}),{live:ne,tabCapped:se,everConnected:pe,liveSince:ke}=BZ({stateRef:n,rerender:s,pauseGate:X,chimesRef:F,desktopUpdateRef:ee}),ae=$le(ne),{version:fe,notice:me,noticeOpen:he,loadVersion:ge}=ae,ue=Gie(ne),{readyAppUpdate:be,onDesktopUpdateEvent:oe}=ue;ee.current=oe,Ale();const je=Ile({version:fe,readyAppUpdate:be}),{tourOpen:$e,openTour:Oe,releaseNotes:Ue}=je,{workspace:Be,providers:We,providersRef:He}=gie(ne),rt=wle(fe),lt=Iie({version:fe,loadVersion:ge}),{upgradeFailure:Rt}=lt,De=gle({stateRef:n,tourOpen:$e,releaseNotes:Ue}),et=Nle({modalOpenRef:De.modalOpenRef}),{openTool:Je,setSummaryFor:tt,setContextFor:yt,openContext:Pt,setKeyHelpOpen:wt,setUsageHistoryOpen:st,setBrowserWatchOpen:zt,keyHelpOpenRef:Wt,modalOpenRef:Dt}=De,Ht=Ole(),Vt=Lie(),{watchOn:vs,watchUnseen:Cn}=Vt,mr=Yie(),[zr,gr]=y.useState(0),{presentCats:Wr,hiddenCats:mn,toggleCat:Hr,catBarRef:An,catBarOccluded:da}=zie(n),gn=y.useRef(null),[yr,wr]=y.useState(0),xt=ZZ({stateRef:n,rerender:s,pruneSelectionToBoard:k,setContextFor:yt,setSummaryFor:tt}),xs=xie(We.claude||We.codex),vr=Rie(xs,xt),xr=Zie({enabled:We.claude,lanStatus:mr.lanStatus,now:xt}),Gt=Kie({now:xt,stateRef:n,version:fe,notice:me,noticeOpen:he,upgradeFailure:Rt,paused:V.paused}),{askRestart:bs,loadAutoRestartPrefs:Vr}=Gt,ye=Uie(),{setTheme:Fe,palette:Ge}=ye,rn=Vie(),Gr=Yte(),{applyViewport:br,moveCamera:ha,fitLeft:Ke,cameraEpochRef:Kr,lastFitTimeRef:ks}=Gr,kr=ine(Ke),{pinnedRef:Kn,positionsRef:Yr,lastLayoutSigRef:ao,handleRelayout:Ns}=kr,Jt=y.useRef(null),js=y.useRef(()=>{}),yn=ke!==null,xc=y.useRef(0),bc=y.useCallback(()=>{xc.current=Date.now()},[]),{canvasRef:Nr,canvasSize:oo,paneSizeRef:io}=Fne(),Ss=Ble(Ke),{autoFitDisabledRef:fa,disableAutoFit:Mi}=Ss,$i=y.useRef(!1),{measuredRef:Yn,measuredVersionRef:kc,sizeVersion:Ii,domSizeVersion:pa}=Bne($i),{removedNodes:Nc,removedAgentIds:jr,removeNode:Ye,removeSelectedNode:Oi,removalNotice:Li,bringBack:ma,bringBackAll:jc,forgetRemovals:Sc}=Tne({stateRef:n,pinnedRef:Kn,positionsRef:Yr,canvasRef:Nr,clearSelection:N,primarySelectedId:g}),lo=Nne({stateRef:n,now:xt,removedAgentIds:jr,sizeVersion:Ii,domSizeVersion:pa});lne(lo,kr),Ene({layoutSig:lo,rf:e,stateRef:n,measuredRef:Yn,pinnedRef:Kn,positionsRef:Yr,paneSizeRef:io,lastInteractRef:xc,autoFitDisabledRef:fa,lastFitTimeRef:ks,fitLeft:Ke});const co=qne(),{bubbling:uo,endBubble:Sr,onBubble:_r}=WX(),[Rn,ga]=y.useState(!1),_s=UX(),{beginTrashDrag:Er,trackTrashDrag:Lh,endTrashDrag:_c}=_s,Es=QX({stateRef:n,measuredRef:Yn,measuredVersionRef:kc,canvasRef:Nr}),{lodRef:Ph,applyZoom:Ec}=Es,ya=Pne({applyViewport:br,lastFitTimeRef:ks,cameraEpochRef:Kr,disableAutoFit:Mi,markInteract:bc,canvasRef:Nr,applyZoom:Ec}),Ts=g?n.current.agents.get(g):null,Pi=o&&Ts!=null,wn=Hne({sessionListShown:x,usageShown:La(U),machineShown:La(L),accountsShown:La(A)&&We.claude,detailShown:Pi,primarySelectedId:g,canvasRef:Nr}),{railInsetRef:Cs,availableWidth:Xr,availableHeight:wa}=Kte({canvasRef:Nr,canvasSize:oo,machinePhase:L,usagePhase:U,usagePanelOpen:c,detailShown:Pi}),Tc=jne({stateRef:n,now:xt,availableWidth:Xr,availableHeight:wa,layout:kr,measuredRef:Yn,onBubble:_r,settled:co,dragging:Rn,layoutSig:lo,selectedIds:p,openContext:Pt,historyReplayed:yn,removedNodes:Nc,removedAgentIds:jr,dragTick:zr,dragPatchRef:gn,dragMoveTick:yr}),{nodes:Di,edges:Fi}=Tc,As=_n(g);cne({nodes:Di,edges:Fi,settled:co,dragging:Rn,availableWidth:Xr,availableHeight:wa,layout:kr,camera:Gr,rf:e,measuredRef:Yn,stateRef:n,lastFocusRef:Jt,primarySelectedIdRef:As,focusAgentRef:js,autoFitDisabledRef:fa});const ho=yle({stateRef:n,pinnedRef:Kn,measuredRef:Yn,positionsRef:Yr,lastLayoutSigRef:ao,forgetRemovals:Sc,clearSelection:N,rerender:s,modalOpenRef:Dt}),{requestClear:Bi}=ho,Tr=Vne({nodes:Di,stateRef:n,pinnedRef:Kn,positionsRef:Yr,draggingRef:$i,dragPatchRef:gn,setDragging:ga,setDragMoveTick:wr,setDragTick:gr,endBubble:Sr,markInteract:bc,disableAutoFit:Mi,beginTrashDrag:Er,trackTrashDrag:Lh,endTrashDrag:_c,removeNode:Ye}),qi=y.useCallback(()=>Ke(500),[Ke]),Rs=_n(Di),{focusAgent:va,stepAgent:fo,focusSession:Cr}=Zte({canvasRef:Nr,stateRef:n,measuredRef:Yn,nodesRef:Rs,railInsetRef:Cs,moveCamera:ha,disableAutoFit:Mi,lastFocusRef:Jt,focusAgentRef:js,selectAgent:v,primarySelectedIdRef:As}),Cc=Dne({clearSelection:N,selectAgent:v,detailOpen:o,setDetailOpen:l,detailShown:Pi,focusAgent:va,draggingRef:$i,lodRef:Ph}),Qt=Jte({nodesRef:Rs,stateRef:n,canvasRef:Nr,railInsetRef:Cs}),Ms=_n(Oi),po=y.useRef(null),xa=y.useCallback(ba=>{jr.has(ba)&&ma([ba]),Cr(ba)},[jr,ma,Cr]),Dh=Une();zne({pointerFocusRef:Dh,nodesRef:Rs,stateRef:n,primarySelectedIdRef:As,providersRef:He,soundOnRef:B,keyHelpOpenRef:Wt,modalOpenRef:Dt,waitingCursorRef:po,removeSelectedRef:Ms,activateSoundRef:I,clearSelection:N,selectAgent:v,focusAgent:va,stepAgent:fo,focusSession:Cr,requestClear:Bi,handleRelayout:Ns,handleFit:qi,togglePause:Z,toggleSessionList:b,toggleAccountsPanel:_,setDetailOpen:l,setUsageHistoryOpen:st,setUsagePanelOpen:d,setMachinePanelOpen:f,setBrowserWatchOpen:zt,setSoundMenuOpen:W,setKeyHelpOpen:wt,setTheme:Fe});const mo=n.current.agents.size,Zr=y.useMemo(()=>Ix(n.current.agents.values()),[n.current,n.current.revision]);Cne({stateRef:n,waitingSessions:Zr,removedAgentIds:jr,removedNodes:Nc,bringBack:ma}),Ine({stateRef:n,waitingSessions:Zr,live:ne});const $s=hle({waitingSessions:Zr,watchUnseen:Cn,incidents:vr}),Is=ple({waitingSessions:Zr,liveSince:ke,focusSession:Cr}),{loadNotifyPrefs:Ac}=Is;return Rle({loadAutoRestartPrefs:Vr,loadNotifyPrefs:Ac,loadReportsPrefs:Ht.loadReportsPrefs}),a.jsxs("div",{className:"app",children:[a.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),a.jsxs("header",{className:"topbar",children:[a.jsx(fse,{versionCheck:ae,welcome:je,desktopUpdate:ue,pause:V,monthly:C,announcements:$s,notify:Is,waitingSessions:Zr,waitingCursorRef:po,focusSession:Cr,live:ne,now:xt,incidents:vr}),Ts&&a.jsx(pse,{selected:Ts,now:xt,selectedIds:p,focusAgent:va,clearSelection:N}),a.jsxs("div",{className:"actions",children:[a.jsx(zre,{sessionListOpen:x,toggleSessionList:b,usagePanelOpen:c,setUsagePanelOpen:d,setUsageHistoryOpen:st,toggles:wn.toggles}),a.jsx(Wre,{providers:We,accountsPanelOpen:j,toggleAccountsPanel:_,machinePanelOpen:h,setMachinePanelOpen:f,watchOn:vs,watchUnseen:Cn,setBrowserWatchOpen:zt,toggles:wn.toggles}),a.jsx(Hre,{providers:We,sound:O,tones:M,customTones:K,notify:Is,chimeState:J,menus:D,appearance:ye,fm:rn,onFeedback:()=>De.openFeedback(),watchUnseen:Cn,setUsageHistoryOpen:st,setBrowserWatchOpen:zt})]})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Li?`${Li.label} removed from the board.`:""}),a.jsx(Dse,{restart:Gt,versionCheck:ae,upgrade:lt,oldNameNotice:rt,rating:et,onFeedback:De.openFeedback,everConnected:pe,live:ne,paused:Y}),La(A)&&We.claude&&a.jsx(OX,{leaving:A==="leaving",onReport:De.openFeedback,onRoster:xr.observe,onClose:()=>{wn.accounts(),R()}}),x&&a.jsx(WH,{state:n.current,now:xt,selectedIds:p,onSelect:xa,onClose:()=>{wn.sessionList(),E()},removedIds:jr,onBringBackAll:jc}),a.jsxs(vse,{canvasRef:Nr,bubbling:uo,dragging:Rn,trash:_s,zoom:Es,viewport:ya,stateRef:n,peek:Qt,children:[mo===0&&(!ne&&se?a.jsx(ere,{}):a.jsx(tre,{live:ne,everConnected:pe,providers:We,workspace:Be,onTour:Oe})),(Wr.length>1||mn.size>0)&&a.jsx(mse,{catBarRef:An,catBarOccluded:da,presentCats:Wr,hiddenCats:mn,toggleCat:Hr}),a.jsx(EH,{graph:Tc,layout:kr,viewport:ya,clicks:Cc,drag:Tr,appearance:ye,fm:rn,autoFit:Ss,pause:V,stateRef:n,measuredRef:Yn,hiddenCats:mn,now:xt,openTool:Je,focusAgent:va,requestClear:Bi,setKeyHelpOpen:wt})]}),La(U)&&a.jsx(F7,{state:n.current,now:xt,providers:We,incidents:vr,liveSince:ke,leaving:U==="leaving",onClose:()=>{wn.usage(),d(!1)}}),La(L)&&a.jsx(k9,{usageOpen:c,leaving:L==="leaving",onClose:()=>{wn.machine(),f(!1)}}),o&&Ts?a.jsx(pre,{selected:Ts,now:xt,openTool:Je,setSummaryFor:tt,stateRef:n,removeSelectedNode:Oi,onClose:()=>{wn.detail(),l(!1)}}):null,a.jsx(Goe,{dialogs:De,welcome:je,desktopUpdate:ue,versionCheck:ae,restart:Gt,lanPairs:mr,attention:xr,clearFlow:ho,watchBadge:Vt,announcements:$s,appearance:ye,providers:We,stateRef:n,agentCount:mo})]})}try{RU(window.localStorage)}catch{}const zle=r4.createRoot(document.getElementById("root"));zle.render(a.jsx(qle,{}));export{Yne as a,it as b,oa as c,gt as d,is as e,qe as f,Vle as g,Dr as h,Hle as i,a as j,Ql as k,Tn as l,uZ as m,ea as n,eo as o,Vx as p,y as r,lr as s,ut as u};