ccdeck 3.36.7 → 3.36.8

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.
@@ -0,0 +1,306 @@
1
+ var J3=Object.defineProperty;var Q3=(e,t,n)=>t in e?J3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var W1=(e,t,n)=>Q3(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 uu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ob(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Hf={exports:{}},ul={},Vf={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 H1;function eP(){if(H1)return Le;H1=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"),u=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(F){return F===null||typeof F!="object"?null:(F=p&&F[p]||F["@@iterator"],typeof F=="function"?F:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,b={};function x(F,Y,J){this.props=F,this.context=Y,this.refs=b,this.updater=J||v}x.prototype.isReactComponent={},x.prototype.setState=function(F,Y){if(typeof F!="object"&&typeof F!="function"&&F!=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,F,Y,"setState")},x.prototype.forceUpdate=function(F){this.updater.enqueueForceUpdate(this,F,"forceUpdate")};function N(){}N.prototype=x.prototype;function S(F,Y,J){this.props=F,this.context=Y,this.refs=b,this.updater=J||v}var _=S.prototype=new N;_.constructor=S,k(_,x.prototype),_.isPureReactComponent=!0;var E=Array.isArray,T=Object.prototype.hasOwnProperty,A={current:null},R={key:!0,ref:!0,__self:!0,__source:!0};function B(F,Y,J){var V,G={},K=null,Z=null;if(Y!=null)for(V in Y.ref!==void 0&&(Z=Y.ref),Y.key!==void 0&&(K=""+Y.key),Y)T.call(Y,V)&&!R.hasOwnProperty(V)&&(G[V]=Y[V]);var ee=arguments.length-2;if(ee===1)G.children=J;else if(1<ee){for(var re=Array(ee),ue=0;ue<ee;ue++)re[ue]=arguments[ue+2];G.children=re}if(F&&F.defaultProps)for(V in ee=F.defaultProps,ee)G[V]===void 0&&(G[V]=ee[V]);return{$$typeof:e,type:F,key:K,ref:Z,props:G,_owner:A.current}}function P(F,Y){return{$$typeof:e,type:F.type,key:Y,ref:F.ref,props:F.props,_owner:F._owner}}function D(F){return typeof F=="object"&&F!==null&&F.$$typeof===e}function I(F){var Y={"=":"=0",":":"=2"};return"$"+F.replace(/[=:]/g,function(J){return Y[J]})}var O=/\/+/g;function z(F,Y){return typeof F=="object"&&F!==null&&F.key!=null?I(""+F.key):Y.toString(36)}function M(F,Y,J,V,G){var K=typeof F;(K==="undefined"||K==="boolean")&&(F=null);var Z=!1;if(F===null)Z=!0;else switch(K){case"string":case"number":Z=!0;break;case"object":switch(F.$$typeof){case e:case t:Z=!0}}if(Z)return Z=F,G=G(Z),F=V===""?"."+z(Z,0):V,E(G)?(J="",F!=null&&(J=F.replace(O,"$&/")+"/"),M(G,Y,J,"",function(ue){return ue})):G!=null&&(D(G)&&(G=P(G,J+(!G.key||Z&&Z.key===G.key?"":(""+G.key).replace(O,"$&/")+"/")+F)),Y.push(G)),1;if(Z=0,V=V===""?".":V+":",E(F))for(var ee=0;ee<F.length;ee++){K=F[ee];var re=V+z(K,ee);Z+=M(K,Y,J,re,G)}else if(re=g(F),typeof re=="function")for(F=re.call(F),ee=0;!(K=F.next()).done;)K=K.value,re=V+z(K,ee++),Z+=M(K,Y,J,re,G);else if(K==="object")throw Y=String(F),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(F).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.");return Z}function $(F,Y,J){if(F==null)return F;var V=[],G=0;return M(F,V,"","",function(K){return Y.call(J,K,G++)}),V}function q(F){if(F._status===-1){var Y=F._result;Y=Y(),Y.then(function(J){(F._status===0||F._status===-1)&&(F._status=1,F._result=J)},function(J){(F._status===0||F._status===-1)&&(F._status=2,F._result=J)}),F._status===-1&&(F._status=0,F._result=Y)}if(F._status===1)return F._result.default;throw F._result}var X={current:null},H={transition:null},L={ReactCurrentDispatcher:X,ReactCurrentBatchConfig:H,ReactCurrentOwner:A};function W(){throw Error("act(...) is not supported in production builds of React.")}return Le.Children={map:$,forEach:function(F,Y,J){$(F,function(){Y.apply(this,arguments)},J)},count:function(F){var Y=0;return $(F,function(){Y++}),Y},toArray:function(F){return $(F,function(Y){return Y})||[]},only:function(F){if(!D(F))throw Error("React.Children.only expected to receive a single React element child.");return F}},Le.Component=x,Le.Fragment=n,Le.Profiler=s,Le.PureComponent=S,Le.StrictMode=r,Le.Suspense=d,Le.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=L,Le.act=W,Le.cloneElement=function(F,Y,J){if(F==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+F+".");var V=k({},F.props),G=F.key,K=F.ref,Z=F._owner;if(Y!=null){if(Y.ref!==void 0&&(K=Y.ref,Z=A.current),Y.key!==void 0&&(G=""+Y.key),F.type&&F.type.defaultProps)var ee=F.type.defaultProps;for(re in Y)T.call(Y,re)&&!R.hasOwnProperty(re)&&(V[re]=Y[re]===void 0&&ee!==void 0?ee[re]:Y[re])}var re=arguments.length-2;if(re===1)V.children=J;else if(1<re){ee=Array(re);for(var ue=0;ue<re;ue++)ee[ue]=arguments[ue+2];V.children=ee}return{$$typeof:e,type:F.type,key:G,ref:K,props:V,_owner:Z}},Le.createContext=function(F){return F={$$typeof:l,_currentValue:F,_currentValue2:F,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},F.Provider={$$typeof:o,_context:F},F.Consumer=F},Le.createElement=B,Le.createFactory=function(F){var Y=B.bind(null,F);return Y.type=F,Y},Le.createRef=function(){return{current:null}},Le.forwardRef=function(F){return{$$typeof:u,render:F}},Le.isValidElement=D,Le.lazy=function(F){return{$$typeof:f,_payload:{_status:-1,_result:F},_init:q}},Le.memo=function(F,Y){return{$$typeof:h,type:F,compare:Y===void 0?null:Y}},Le.startTransition=function(F){var Y=H.transition;H.transition={};try{F()}finally{H.transition=Y}},Le.unstable_act=W,Le.useCallback=function(F,Y){return X.current.useCallback(F,Y)},Le.useContext=function(F){return X.current.useContext(F)},Le.useDebugValue=function(){},Le.useDeferredValue=function(F){return X.current.useDeferredValue(F)},Le.useEffect=function(F,Y){return X.current.useEffect(F,Y)},Le.useId=function(){return X.current.useId()},Le.useImperativeHandle=function(F,Y,J){return X.current.useImperativeHandle(F,Y,J)},Le.useInsertionEffect=function(F,Y){return X.current.useInsertionEffect(F,Y)},Le.useLayoutEffect=function(F,Y){return X.current.useLayoutEffect(F,Y)},Le.useMemo=function(F,Y){return X.current.useMemo(F,Y)},Le.useReducer=function(F,Y,J){return X.current.useReducer(F,Y,J)},Le.useRef=function(F){return X.current.useRef(F)},Le.useState=function(F){return X.current.useState(F)},Le.useSyncExternalStore=function(F,Y,J){return X.current.useSyncExternalStore(F,Y,J)},Le.useTransition=function(){return X.current.useTransition()},Le.version="18.3.1",Le}var V1;function Jl(){return V1||(V1=1,Vf.exports=eP()),Vf.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 G1;function tP(){if(G1)return ul;G1=1;var e=Jl(),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(u,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(u&&u.defaultProps)for(f in d=u.defaultProps,d)p[f]===void 0&&(p[f]=d[f]);return{$$typeof:t,type:u,key:g,ref:v,props:p,_owner:s.current}}return ul.Fragment=n,ul.jsx=l,ul.jsxs=l,ul}var K1;function nP(){return K1||(K1=1,Hf.exports=tP()),Hf.exports}var a=nP(),du={},Gf={exports:{}},cn={},Kf={exports:{}},Yf={};/**
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 Y1;function rP(){return Y1||(Y1=1,(function(e){function t(H,L){var W=H.length;H.push(L);e:for(;0<W;){var F=W-1>>>1,Y=H[F];if(0<s(Y,L))H[F]=L,H[W]=Y,W=F;else break e}}function n(H){return H.length===0?null:H[0]}function r(H){if(H.length===0)return null;var L=H[0],W=H.pop();if(W!==L){H[0]=W;e:for(var F=0,Y=H.length,J=Y>>>1;F<J;){var V=2*(F+1)-1,G=H[V],K=V+1,Z=H[K];if(0>s(G,W))K<Y&&0>s(Z,G)?(H[F]=Z,H[K]=W,F=K):(H[F]=G,H[V]=W,F=V);else if(K<Y&&0>s(Z,W))H[F]=Z,H[K]=W,F=K;else break e}}return L}function s(H,L){var W=H.sortIndex-L.sortIndex;return W!==0?W:H.id-L.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var l=Date,u=l.now();e.unstable_now=function(){return l.now()-u}}var d=[],h=[],f=1,p=null,g=3,v=!1,k=!1,b=!1,x=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function _(H){for(var L=n(h);L!==null;){if(L.callback===null)r(h);else if(L.startTime<=H)r(h),L.sortIndex=L.expirationTime,t(d,L);else break;L=n(h)}}function E(H){if(b=!1,_(H),!k)if(n(d)!==null)k=!0,q(T);else{var L=n(h);L!==null&&X(E,L.startTime-H)}}function T(H,L){k=!1,b&&(b=!1,N(B),B=-1),v=!0;var W=g;try{for(_(L),p=n(d);p!==null&&(!(p.expirationTime>L)||H&&!I());){var F=p.callback;if(typeof F=="function"){p.callback=null,g=p.priorityLevel;var Y=F(p.expirationTime<=L);L=e.unstable_now(),typeof Y=="function"?p.callback=Y:p===n(d)&&r(d),_(L)}else r(d);p=n(d)}if(p!==null)var J=!0;else{var V=n(h);V!==null&&X(E,V.startTime-L),J=!1}return J}finally{p=null,g=W,v=!1}}var A=!1,R=null,B=-1,P=5,D=-1;function I(){return!(e.unstable_now()-D<P)}function O(){if(R!==null){var H=e.unstable_now();D=H;var L=!0;try{L=R(!0,H)}finally{L?z():(A=!1,R=null)}}else A=!1}var z;if(typeof S=="function")z=function(){S(O)};else if(typeof MessageChannel<"u"){var M=new MessageChannel,$=M.port2;M.port1.onmessage=O,z=function(){$.postMessage(null)}}else z=function(){x(O,0)};function q(H){R=H,A||(A=!0,z())}function X(H,L){B=x(function(){H(e.unstable_now())},L)}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(H){H.callback=null},e.unstable_continueExecution=function(){k||v||(k=!0,q(T))},e.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):P=0<H?Math.floor(1e3/H):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(H){switch(g){case 1:case 2:case 3:var L=3;break;default:L=g}var W=g;g=L;try{return H()}finally{g=W}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(H,L){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var W=g;g=H;try{return L()}finally{g=W}},e.unstable_scheduleCallback=function(H,L,W){var F=e.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?F+W:F):W=F,H){case 1:var Y=-1;break;case 2:Y=250;break;case 5:Y=1073741823;break;case 4:Y=1e4;break;default:Y=5e3}return Y=W+Y,H={id:f++,callback:L,priorityLevel:H,startTime:W,expirationTime:Y,sortIndex:-1},W>F?(H.sortIndex=W,t(h,H),n(d)===null&&H===n(h)&&(b?(N(B),B=-1):b=!0,X(E,W-F))):(H.sortIndex=Y,t(d,H),k||v||(k=!0,q(T))),H},e.unstable_shouldYield=I,e.unstable_wrapCallback=function(H){var L=g;return function(){var W=g;g=L;try{return H.apply(this,arguments)}finally{g=W}}}})(Yf)),Yf}var X1;function sP(){return X1||(X1=1,Kf.exports=rP()),Kf.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 Z1;function aP(){if(Z1)return cn;Z1=1;var e=Jl(),t=sP();function n(i){for(var c="https://reactjs.org/docs/error-decoder.html?invariant="+i,m=1;m<arguments.length;m++)c+="&args[]="+encodeURIComponent(arguments[m]);return"Minified React error #"+i+"; visit "+c+" 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,c){l(i,c),l(i+"Capture",c)}function l(i,c){for(s[i]=c,i=0;i<c.length;i++)r.add(c[i])}var u=!(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,c,m,y){if(m!==null&&m.type===0)return!1;switch(typeof c){case"function":case"symbol":return!0;case"boolean":return y?!1:m!==null?!m.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function k(i,c,m,y){if(c===null||typeof c>"u"||v(i,c,m,y))return!0;if(y)return!1;if(m!==null)switch(m.type){case 3:return!c;case 4:return c===!1;case 5:return isNaN(c);case 6:return isNaN(c)||1>c}return!1}function b(i,c,m,y,j,C,U){this.acceptsBooleans=c===2||c===3||c===4,this.attributeName=y,this.attributeNamespace=j,this.mustUseProperty=m,this.propertyName=i,this.type=c,this.sanitizeURL=C,this.removeEmptyString=U}var x={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){x[i]=new b(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var c=i[0];x[c]=new b(c,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){x[i]=new b(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){x[i]=new b(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 b(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){x[i]=new b(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){x[i]=new b(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){x[i]=new b(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){x[i]=new b(i,5,!1,i.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function S(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 c=i.replace(N,S);x[c]=new b(c,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var c=i.replace(N,S);x[c]=new b(c,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var c=i.replace(N,S);x[c]=new b(c,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){x[i]=new b(i,1,!1,i.toLowerCase(),null,!1,!1)}),x.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){x[i]=new b(i,1,!1,i.toLowerCase(),null,!0,!0)});function _(i,c,m,y){var j=x.hasOwnProperty(c)?x[c]:null;(j!==null?j.type!==0:y||!(2<c.length)||c[0]!=="o"&&c[0]!=="O"||c[1]!=="n"&&c[1]!=="N")&&(k(c,m,j,y)&&(m=null),y||j===null?g(c)&&(m===null?i.removeAttribute(c):i.setAttribute(c,""+m)):j.mustUseProperty?i[j.propertyName]=m===null?j.type===3?!1:"":m:(c=j.attributeName,y=j.attributeNamespace,m===null?i.removeAttribute(c):(j=j.type,m=j===3||j===4&&m===!0?"":""+m,y?i.setAttributeNS(y,c,m):i.setAttribute(c,m))))}var E=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,T=Symbol.for("react.element"),A=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),B=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),D=Symbol.for("react.provider"),I=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),z=Symbol.for("react.suspense"),M=Symbol.for("react.suspense_list"),$=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),X=Symbol.for("react.offscreen"),H=Symbol.iterator;function L(i){return i===null||typeof i!="object"?null:(i=H&&i[H]||i["@@iterator"],typeof i=="function"?i:null)}var W=Object.assign,F;function Y(i){if(F===void 0)try{throw Error()}catch(m){var c=m.stack.trim().match(/\n( *(at )?)/);F=c&&c[1]||""}return`
34
+ `+F+i}var J=!1;function V(i,c){if(!i||J)return"";J=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(c)if(c=function(){throw Error()},Object.defineProperty(c.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(c,[])}catch(ce){var y=ce}Reflect.construct(i,[],c)}else{try{c.call()}catch(ce){y=ce}i.call(c.prototype)}else{try{throw Error()}catch(ce){y=ce}i()}}catch(ce){if(ce&&y&&typeof ce.stack=="string"){for(var j=ce.stack.split(`
35
+ `),C=y.stack.split(`
36
+ `),U=j.length-1,Q=C.length-1;1<=U&&0<=Q&&j[U]!==C[Q];)Q--;for(;1<=U&&0<=Q;U--,Q--)if(j[U]!==C[Q]){if(U!==1||Q!==1)do if(U--,Q--,0>Q||j[U]!==C[Q]){var te=`
37
+ `+j[U].replace(" at new "," at ");return i.displayName&&te.includes("<anonymous>")&&(te=te.replace("<anonymous>",i.displayName)),te}while(1<=U&&0<=Q);break}}}finally{J=!1,Error.prepareStackTrace=m}return(i=i?i.displayName||i.name:"")?Y(i):""}function G(i){switch(i.tag){case 5:return Y(i.type);case 16:return Y("Lazy");case 13:return Y("Suspense");case 19:return Y("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 K(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 R:return"Fragment";case A:return"Portal";case P:return"Profiler";case B:return"StrictMode";case z:return"Suspense";case M:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case I:return(i.displayName||"Context")+".Consumer";case D:return(i._context.displayName||"Context")+".Provider";case O:var c=i.render;return i=i.displayName,i||(i=c.displayName||c.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case $:return c=i.displayName||null,c!==null?c:K(i.type)||"Memo";case q:c=i._payload,i=i._init;try{return K(i(c))}catch{}}return null}function Z(i){var c=i.type;switch(i.tag){case 24:return"Cache";case 9:return(c.displayName||"Context")+".Consumer";case 10:return(c._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return i=c.render,i=i.displayName||i.name||"",c.displayName||(i!==""?"ForwardRef("+i+")":"ForwardRef");case 7:return"Fragment";case 5:return c;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return K(c);case 8:return c===B?"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 c=="function")return c.displayName||c.name||null;if(typeof c=="string")return c}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 re(i){var c=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(c==="checkbox"||c==="radio")}function ue(i){var c=re(i)?"checked":"value",m=Object.getOwnPropertyDescriptor(i.constructor.prototype,c),y=""+i[c];if(!i.hasOwnProperty(c)&&typeof m<"u"&&typeof m.get=="function"&&typeof m.set=="function"){var j=m.get,C=m.set;return Object.defineProperty(i,c,{configurable:!0,get:function(){return j.call(this)},set:function(U){y=""+U,C.call(this,U)}}),Object.defineProperty(i,c,{enumerable:m.enumerable}),{getValue:function(){return y},setValue:function(U){y=""+U},stopTracking:function(){i._valueTracker=null,delete i[c]}}}}function me(i){i._valueTracker||(i._valueTracker=ue(i))}function ie(i){if(!i)return!1;var c=i._valueTracker;if(!c)return!0;var m=c.getValue(),y="";return i&&(y=re(i)?i.checked?"true":"false":i.value),i=y,i!==m?(c.setValue(i),!0):!1}function fe(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 ve(i,c){var m=c.checked;return W({},c,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:m??i._wrapperState.initialChecked})}function se(i,c){var m=c.defaultValue==null?"":c.defaultValue,y=c.checked!=null?c.checked:c.defaultChecked;m=ee(c.value!=null?c.value:m),i._wrapperState={initialChecked:y,initialValue:m,controlled:c.type==="checkbox"||c.type==="radio"?c.checked!=null:c.value!=null}}function ke(i,c){c=c.checked,c!=null&&_(i,"checked",c,!1)}function pe(i,c){ke(i,c);var m=ee(c.value),y=c.type;if(m!=null)y==="number"?(m===0&&i.value===""||i.value!=m)&&(i.value=""+m):i.value!==""+m&&(i.value=""+m);else if(y==="submit"||y==="reset"){i.removeAttribute("value");return}c.hasOwnProperty("value")?ae(i,c.type,m):c.hasOwnProperty("defaultValue")&&ae(i,c.type,ee(c.defaultValue)),c.checked==null&&c.defaultChecked!=null&&(i.defaultChecked=!!c.defaultChecked)}function he(i,c,m){if(c.hasOwnProperty("value")||c.hasOwnProperty("defaultValue")){var y=c.type;if(!(y!=="submit"&&y!=="reset"||c.value!==void 0&&c.value!==null))return;c=""+i._wrapperState.initialValue,m||c===i.value||(i.value=c),i.defaultValue=c}m=i.name,m!==""&&(i.name=""),i.defaultChecked=!!i._wrapperState.initialChecked,m!==""&&(i.name=m)}function ae(i,c,m){(c!=="number"||fe(i.ownerDocument)!==i)&&(m==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+m&&(i.defaultValue=""+m))}var Ne=Array.isArray;function Te(i,c,m,y){if(i=i.options,c){c={};for(var j=0;j<m.length;j++)c["$"+m[j]]=!0;for(m=0;m<i.length;m++)j=c.hasOwnProperty("$"+i[m].value),i[m].selected!==j&&(i[m].selected=j),j&&y&&(i[m].defaultSelected=!0)}else{for(m=""+ee(m),c=null,j=0;j<i.length;j++){if(i[j].value===m){i[j].selected=!0,y&&(i[j].defaultSelected=!0);return}c!==null||i[j].disabled||(c=i[j])}c!==null&&(c.selected=!0)}}function Ie(i,c){if(c.dangerouslySetInnerHTML!=null)throw Error(n(91));return W({},c,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function Oe(i,c){var m=c.value;if(m==null){if(m=c.children,c=c.defaultValue,m!=null){if(c!=null)throw Error(n(92));if(Ne(m)){if(1<m.length)throw Error(n(93));m=m[0]}c=m}c==null&&(c=""),m=c}i._wrapperState={initialValue:ee(m)}}function He(i,c){var m=ee(c.value),y=ee(c.defaultValue);m!=null&&(m=""+m,m!==i.value&&(i.value=m),c.defaultValue==null&&i.defaultValue!==m&&(i.defaultValue=m)),y!=null&&(i.defaultValue=""+y)}function Ye(i){var c=i.textContent;c===i._wrapperState.initialValue&&c!==""&&c!==null&&(i.value=c)}function Ve(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 Ke(i,c){return i==null||i==="http://www.w3.org/1999/xhtml"?Ve(c):i==="http://www.w3.org/2000/svg"&&c==="foreignObject"?"http://www.w3.org/1999/xhtml":i}var nt,it=(function(i){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(c,m,y,j){MSApp.execUnsafeLocalFunction(function(){return i(c,m,y,j)})}:i})(function(i,c){if(i.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in i)i.innerHTML=c;else{for(nt=nt||document.createElement("div"),nt.innerHTML="<svg>"+c.valueOf().toString()+"</svg>",c=nt.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;c.firstChild;)i.appendChild(c.firstChild)}});function At(i,c){if(c){var m=i.firstChild;if(m&&m===i.lastChild&&m.nodeType===3){m.nodeValue=c;return}}i.textContent=c}var Be={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},Ze=["Webkit","ms","Moz","O"];Object.keys(Be).forEach(function(i){Ze.forEach(function(c){c=c+i.charAt(0).toUpperCase()+i.substring(1),Be[c]=Be[i]})});function Je(i,c,m){return c==null||typeof c=="boolean"||c===""?"":m||typeof c!="number"||c===0||Be.hasOwnProperty(i)&&Be[i]?(""+c).trim():c+"px"}function rt(i,c){i=i.style;for(var m in c)if(c.hasOwnProperty(m)){var y=m.indexOf("--")===0,j=Je(m,c[m],y);m==="float"&&(m="cssFloat"),y?i.setProperty(m,j):i[m]=j}}var gt=W({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 Rt(i,c){if(c){if(gt[i]&&(c.children!=null||c.dangerouslySetInnerHTML!=null))throw Error(n(137,i));if(c.dangerouslySetInnerHTML!=null){if(c.children!=null)throw Error(n(60));if(typeof c.dangerouslySetInnerHTML!="object"||!("__html"in c.dangerouslySetInnerHTML))throw Error(n(61))}if(c.style!=null&&typeof c.style!="object")throw Error(n(62))}}function yt(i,c){if(i.indexOf("-")===-1)return typeof c.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 lt=null;function en(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Pt=null,zt=null,Dt=null;function Yt(i){if(i=Yi(i)){if(typeof Pt!="function")throw Error(n(280));var c=i.stateNode;c&&(c=Sc(c),Pt(i.stateNode,i.type,c))}}function Ur(i){zt?Dt?Dt.push(i):Dt=[i]:zt=i}function zn(){if(zt){var i=zt,c=Dt;if(Dt=zt=null,Yt(i),c)for(i=0;i<c.length;i++)Yt(c[i])}}function zr(i,c){return i(c)}function Wr(){}var Wn=!1;function gr(i,c,m){if(Wn)return i(c,m);Wn=!0;try{return zr(i,c,m)}finally{Wn=!1,(zt!==null||Dt!==null)&&(Wr(),zn())}}function Hn(i,c){var m=i.stateNode;if(m===null)return null;var y=Sc(m);if(y===null)return null;m=y[c];e:switch(c){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(y=!y.disabled)||(i=i.type,y=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!y;break e;default:i=!1}if(i)return null;if(m&&typeof m!="function")throw Error(n(231,c,typeof m));return m}var Hr=!1;if(u)try{var Nn={};Object.defineProperty(Nn,"passive",{get:function(){Hr=!0}}),window.addEventListener("test",Nn,Nn),window.removeEventListener("test",Nn,Nn)}catch{Hr=!1}function gs(i,c,m,y,j,C,U,Q,te){var ce=Array.prototype.slice.call(arguments,3);try{c.apply(m,ce)}catch(ye){this.onError(ye)}}var jn=!1,yr=null,vt=!1,wr=null,vr={onError:function(i){jn=!0,yr=i}};function Vr(i,c,m,y,j,C,U,Q,te){jn=!1,yr=null,gs.apply(vr,arguments)}function Vn(i,c,m,y,j,C,U,Q,te){if(Vr.apply(this,arguments),jn){if(jn){var ce=yr;jn=!1,yr=null}else throw Error(n(198));vt||(vt=!0,wr=ce)}}function pn(i){var c=i,m=i;if(i.alternate)for(;c.return;)c=c.return;else{i=c;do c=i,(c.flags&4098)!==0&&(m=c.return),i=c.return;while(i)}return c.tag===3?m:null}function Gr(i){if(i.tag===13){var c=i.memoizedState;if(c===null&&(i=i.alternate,i!==null&&(c=i.memoizedState)),c!==null)return c.dehydrated}return null}function Sn(i){if(pn(i)!==i)throw Error(n(188))}function we(i){var c=i.alternate;if(!c){if(c=pn(i),c===null)throw Error(n(188));return c!==i?null:i}for(var m=i,y=c;;){var j=m.return;if(j===null)break;var C=j.alternate;if(C===null){if(y=j.return,y!==null){m=y;continue}break}if(j.child===C.child){for(C=j.child;C;){if(C===m)return Sn(j),i;if(C===y)return Sn(j),c;C=C.sibling}throw Error(n(188))}if(m.return!==y.return)m=j,y=C;else{for(var U=!1,Q=j.child;Q;){if(Q===m){U=!0,m=j,y=C;break}if(Q===y){U=!0,y=j,m=C;break}Q=Q.sibling}if(!U){for(Q=C.child;Q;){if(Q===m){U=!0,m=C,y=j;break}if(Q===y){U=!0,y=C,m=j;break}Q=Q.sibling}if(!U)throw Error(n(189))}}if(m.alternate!==y)throw Error(n(190))}if(m.tag!==3)throw Error(n(188));return m.stateNode.current===m?i:c}function De(i){return i=we(i),i!==null?qe(i):null}function qe(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var c=qe(i);if(c!==null)return c;i=i.sibling}return null}var tn=t.unstable_scheduleCallback,ys=t.unstable_cancelCallback,xr=t.unstable_shouldYield,Gn=t.unstable_requestPaint,Qe=t.unstable_now,br=t.unstable_getCurrentPriorityLevel,Kn=t.unstable_ImmediatePriority,Kr=t.unstable_UserBlockingPriority,Yn=t.unstable_NormalPriority,Xa=t.unstable_LowPriority,Za=t.unstable_IdlePriority,Yr=null,Xt=null;function sa(i){if(Xt&&typeof Xt.onCommitFiberRoot=="function")try{Xt.onCommitFiberRoot(Yr,i,void 0,(i.current.flags&128)===128)}catch{}}var nn=Math.clz32?Math.clz32:wh,hc=Math.log,Xr=Math.LN2;function wh(i){return i>>>=0,i===0?32:31-(hc(i)/Xr|0)|0}var Ja=64,aa=4194304;function ws(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 vs(i,c){var m=i.pendingLanes;if(m===0)return 0;var y=0,j=i.suspendedLanes,C=i.pingedLanes,U=m&268435455;if(U!==0){var Q=U&~j;Q!==0?y=ws(Q):(C&=U,C!==0&&(y=ws(C)))}else U=m&~j,U!==0?y=ws(U):C!==0&&(y=ws(C));if(y===0)return 0;if(c!==0&&c!==y&&(c&j)===0&&(j=y&-y,C=c&-c,j>=C||j===16&&(C&4194240)!==0))return c;if((y&4)!==0&&(y|=m&16),c=i.entangledLanes,c!==0)for(i=i.entanglements,c&=y;0<c;)m=31-nn(c),j=1<<m,y|=i[m],c&=~j;return y}function _i(i,c){switch(i){case 1:case 2:case 4:return c+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 c+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 Zr(i,c){for(var m=i.suspendedLanes,y=i.pingedLanes,j=i.expirationTimes,C=i.pendingLanes;0<C;){var U=31-nn(C),Q=1<<U,te=j[U];te===-1?((Q&m)===0||(Q&y)!==0)&&(j[U]=_i(Q,c)):te<=c&&(i.expiredLanes|=Q),C&=~Q}}function Ei(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function fc(){var i=Ja;return Ja<<=1,(Ja&4194240)===0&&(Ja=64),i}function Ci(i){for(var c=[],m=0;31>m;m++)c.push(i);return c}function xs(i,c,m){i.pendingLanes|=c,c!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,c=31-nn(c),i[c]=m}function bs(i,c){var m=i.pendingLanes&~c;i.pendingLanes=c,i.suspendedLanes=0,i.pingedLanes=0,i.expiredLanes&=c,i.mutableReadLanes&=c,i.entangledLanes&=c,c=i.entanglements;var y=i.eventTimes;for(i=i.expirationTimes;0<m;){var j=31-nn(m),C=1<<j;c[j]=0,y[j]=-1,i[j]=-1,m&=~C}}function Ti(i,c){var m=i.entangledLanes|=c;for(i=i.entanglements;m;){var y=31-nn(m),j=1<<y;j&c|i[y]&c&&(i[y]|=c),m&=~j}}var ze=0;function Ai(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var Qa,Ri,pc,eo,Mi,$i=!1,to=[],kr=null,_n=null,Nr=null,ks=new Map,oa=new Map,jr=[],vh="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 Ii(i,c){switch(i){case"focusin":case"focusout":kr=null;break;case"dragenter":case"dragleave":_n=null;break;case"mouseover":case"mouseout":Nr=null;break;case"pointerover":case"pointerout":ks.delete(c.pointerId);break;case"gotpointercapture":case"lostpointercapture":oa.delete(c.pointerId)}}function ia(i,c,m,y,j,C){return i===null||i.nativeEvent!==C?(i={blockedOn:c,domEventName:m,eventSystemFlags:y,nativeEvent:C,targetContainers:[j]},c!==null&&(c=Yi(c),c!==null&&Ri(c)),i):(i.eventSystemFlags|=y,c=i.targetContainers,j!==null&&c.indexOf(j)===-1&&c.push(j),i)}function xh(i,c,m,y,j){switch(c){case"focusin":return kr=ia(kr,i,c,m,y,j),!0;case"dragenter":return _n=ia(_n,i,c,m,y,j),!0;case"mouseover":return Nr=ia(Nr,i,c,m,y,j),!0;case"pointerover":var C=j.pointerId;return ks.set(C,ia(ks.get(C)||null,i,c,m,y,j)),!0;case"gotpointercapture":return C=j.pointerId,oa.set(C,ia(oa.get(C)||null,i,c,m,y,j)),!0}return!1}function Oi(i){var c=ha(i.target);if(c!==null){var m=pn(c);if(m!==null){if(c=m.tag,c===13){if(c=Gr(m),c!==null){i.blockedOn=c,Mi(i.priority,function(){pc(m)});return}}else if(c===3&&m.stateNode.current.memoizedState.isDehydrated){i.blockedOn=m.tag===3?m.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Sr(i){if(i.blockedOn!==null)return!1;for(var c=i.targetContainers;0<c.length;){var m=Di(i.domEventName,i.eventSystemFlags,c[0],i.nativeEvent);if(m===null){m=i.nativeEvent;var y=new m.constructor(m.type,m);lt=y,m.target.dispatchEvent(y),lt=null}else return c=Yi(m),c!==null&&Ri(c),i.blockedOn=m,!1;c.shift()}return!0}function Li(i,c,m){Sr(i)&&m.delete(c)}function mc(){$i=!1,kr!==null&&Sr(kr)&&(kr=null),_n!==null&&Sr(_n)&&(_n=null),Nr!==null&&Sr(Nr)&&(Nr=null),ks.forEach(Li),oa.forEach(Li)}function Ns(i,c){i.blockedOn===c&&(i.blockedOn=null,$i||($i=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,mc)))}function js(i){function c(j){return Ns(j,i)}if(0<to.length){Ns(to[0],i);for(var m=1;m<to.length;m++){var y=to[m];y.blockedOn===i&&(y.blockedOn=null)}}for(kr!==null&&Ns(kr,i),_n!==null&&Ns(_n,i),Nr!==null&&Ns(Nr,i),ks.forEach(c),oa.forEach(c),m=0;m<jr.length;m++)y=jr[m],y.blockedOn===i&&(y.blockedOn=null);for(;0<jr.length&&(m=jr[0],m.blockedOn===null);)Oi(m),m.blockedOn===null&&jr.shift()}var Jr=E.ReactCurrentBatchConfig,Ss=!0;function bh(i,c,m,y){var j=ze,C=Jr.transition;Jr.transition=null;try{ze=1,no(i,c,m,y)}finally{ze=j,Jr.transition=C}}function Pi(i,c,m,y){var j=ze,C=Jr.transition;Jr.transition=null;try{ze=4,no(i,c,m,y)}finally{ze=j,Jr.transition=C}}function no(i,c,m,y){if(Ss){var j=Di(i,c,m,y);if(j===null)Ih(i,c,y,la,m),Ii(i,y);else if(xh(j,i,c,m,y))y.stopPropagation();else if(Ii(i,y),c&4&&-1<vh.indexOf(i)){for(;j!==null;){var C=Yi(j);if(C!==null&&Qa(C),C=Di(i,c,m,y),C===null&&Ih(i,c,y,la,m),C===j)break;j=C}j!==null&&y.stopPropagation()}else Ih(i,c,y,null,m)}}var la=null;function Di(i,c,m,y){if(la=null,i=en(y),i=ha(i),i!==null)if(c=pn(i),c===null)i=null;else if(m=c.tag,m===13){if(i=Gr(c),i!==null)return i;i=null}else if(m===3){if(c.stateNode.current.memoizedState.isDehydrated)return c.tag===3?c.stateNode.containerInfo:null;i=null}else c!==i&&(i=null);return la=i,null}function gc(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(br()){case Kn:return 1;case Kr:return 4;case Yn:case Xa:return 16;case Za:return 536870912;default:return 16}default:return 16}}var En=null,_s=null,ro=null;function Es(){if(ro)return ro;var i,c=_s,m=c.length,y,j="value"in En?En.value:En.textContent,C=j.length;for(i=0;i<m&&c[i]===j[i];i++);var U=m-i;for(y=1;y<=U&&c[m-y]===j[C-y];y++);return ro=j.slice(i,1<y?1-y:void 0)}function so(i){var c=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&c===13&&(i=13)):i=c,i===10&&(i=13),32<=i||i===13?i:0}function ao(){return!0}function yc(){return!1}function Wt(i){function c(m,y,j,C,U){this._reactName=m,this._targetInst=j,this.type=y,this.nativeEvent=C,this.target=U,this.currentTarget=null;for(var Q in i)i.hasOwnProperty(Q)&&(m=i[Q],this[Q]=m?m(C):C[Q]);return this.isDefaultPrevented=(C.defaultPrevented!=null?C.defaultPrevented:C.returnValue===!1)?ao:yc,this.isPropagationStopped=yc,this}return W(c.prototype,{preventDefault:function(){this.defaultPrevented=!0;var m=this.nativeEvent;m&&(m.preventDefault?m.preventDefault():typeof m.returnValue!="unknown"&&(m.returnValue=!1),this.isDefaultPrevented=ao)},stopPropagation:function(){var m=this.nativeEvent;m&&(m.stopPropagation?m.stopPropagation():typeof m.cancelBubble!="unknown"&&(m.cancelBubble=!0),this.isPropagationStopped=ao)},persist:function(){},isPersistent:ao}),c}var Cs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Fi=Wt(Cs),Ts=W({},Cs,{view:0,detail:0}),ca=Wt(Ts),oo,ua,da,_r=W({},Ts,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Nh,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!==da&&(da&&i.type==="mousemove"?(oo=i.screenX-da.screenX,ua=i.screenY-da.screenY):ua=oo=0,da=i),oo)},movementY:function(i){return"movementY"in i?i.movementY:ua}}),$0=Wt(_r),_L=W({},_r,{dataTransfer:0}),EL=Wt(_L),CL=W({},Ts,{relatedTarget:0}),kh=Wt(CL),TL=W({},Cs,{animationName:0,elapsedTime:0,pseudoElement:0}),AL=Wt(TL),RL=W({},Cs,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),ML=Wt(RL),$L=W({},Cs,{data:0}),I0=Wt($L),IL={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},OL={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"},LL={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function PL(i){var c=this.nativeEvent;return c.getModifierState?c.getModifierState(i):(i=LL[i])?!!c[i]:!1}function Nh(){return PL}var DL=W({},Ts,{key:function(i){if(i.key){var c=IL[i.key]||i.key;if(c!=="Unidentified")return c}return i.type==="keypress"?(i=so(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?OL[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Nh,charCode:function(i){return i.type==="keypress"?so(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?so(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),FL=Wt(DL),BL=W({},_r,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),O0=Wt(BL),qL=W({},Ts,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Nh}),UL=Wt(qL),zL=W({},Cs,{propertyName:0,elapsedTime:0,pseudoElement:0}),WL=Wt(zL),HL=W({},_r,{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}),VL=Wt(HL),GL=[9,13,27,32],jh=u&&"CompositionEvent"in window,Bi=null;u&&"documentMode"in document&&(Bi=document.documentMode);var KL=u&&"TextEvent"in window&&!Bi,L0=u&&(!jh||Bi&&8<Bi&&11>=Bi),P0=" ",D0=!1;function F0(i,c){switch(i){case"keyup":return GL.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function B0(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var io=!1;function YL(i,c){switch(i){case"compositionend":return B0(c);case"keypress":return c.which!==32?null:(D0=!0,P0);case"textInput":return i=c.data,i===P0&&D0?null:i;default:return null}}function XL(i,c){if(io)return i==="compositionend"||!jh&&F0(i,c)?(i=Es(),ro=_s=En=null,io=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(c.ctrlKey||c.altKey||c.metaKey)||c.ctrlKey&&c.altKey){if(c.char&&1<c.char.length)return c.char;if(c.which)return String.fromCharCode(c.which)}return null;case"compositionend":return L0&&c.locale!=="ko"?null:c.data;default:return null}}var ZL={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 q0(i){var c=i&&i.nodeName&&i.nodeName.toLowerCase();return c==="input"?!!ZL[i.type]:c==="textarea"}function U0(i,c,m,y){Ur(y),c=kc(c,"onChange"),0<c.length&&(m=new Fi("onChange","change",null,m,y),i.push({event:m,listeners:c}))}var qi=null,Ui=null;function JL(i){ok(i,0)}function wc(i){var c=fo(i);if(ie(c))return i}function QL(i,c){if(i==="change")return c}var z0=!1;if(u){var Sh;if(u){var _h="oninput"in document;if(!_h){var W0=document.createElement("div");W0.setAttribute("oninput","return;"),_h=typeof W0.oninput=="function"}Sh=_h}else Sh=!1;z0=Sh&&(!document.documentMode||9<document.documentMode)}function H0(){qi&&(qi.detachEvent("onpropertychange",V0),Ui=qi=null)}function V0(i){if(i.propertyName==="value"&&wc(Ui)){var c=[];U0(c,Ui,i,en(i)),gr(JL,c)}}function e3(i,c,m){i==="focusin"?(H0(),qi=c,Ui=m,qi.attachEvent("onpropertychange",V0)):i==="focusout"&&H0()}function t3(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return wc(Ui)}function n3(i,c){if(i==="click")return wc(c)}function r3(i,c){if(i==="input"||i==="change")return wc(c)}function s3(i,c){return i===c&&(i!==0||1/i===1/c)||i!==i&&c!==c}var Xn=typeof Object.is=="function"?Object.is:s3;function zi(i,c){if(Xn(i,c))return!0;if(typeof i!="object"||i===null||typeof c!="object"||c===null)return!1;var m=Object.keys(i),y=Object.keys(c);if(m.length!==y.length)return!1;for(y=0;y<m.length;y++){var j=m[y];if(!d.call(c,j)||!Xn(i[j],c[j]))return!1}return!0}function G0(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function K0(i,c){var m=G0(i);i=0;for(var y;m;){if(m.nodeType===3){if(y=i+m.textContent.length,i<=c&&y>=c)return{node:m,offset:c-i};i=y}e:{for(;m;){if(m.nextSibling){m=m.nextSibling;break e}m=m.parentNode}m=void 0}m=G0(m)}}function Y0(i,c){return i&&c?i===c?!0:i&&i.nodeType===3?!1:c&&c.nodeType===3?Y0(i,c.parentNode):"contains"in i?i.contains(c):i.compareDocumentPosition?!!(i.compareDocumentPosition(c)&16):!1:!1}function X0(){for(var i=window,c=fe();c instanceof i.HTMLIFrameElement;){try{var m=typeof c.contentWindow.location.href=="string"}catch{m=!1}if(m)i=c.contentWindow;else break;c=fe(i.document)}return c}function Eh(i){var c=i&&i.nodeName&&i.nodeName.toLowerCase();return c&&(c==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||c==="textarea"||i.contentEditable==="true")}function a3(i){var c=X0(),m=i.focusedElem,y=i.selectionRange;if(c!==m&&m&&m.ownerDocument&&Y0(m.ownerDocument.documentElement,m)){if(y!==null&&Eh(m)){if(c=y.start,i=y.end,i===void 0&&(i=c),"selectionStart"in m)m.selectionStart=c,m.selectionEnd=Math.min(i,m.value.length);else if(i=(c=m.ownerDocument||document)&&c.defaultView||window,i.getSelection){i=i.getSelection();var j=m.textContent.length,C=Math.min(y.start,j);y=y.end===void 0?C:Math.min(y.end,j),!i.extend&&C>y&&(j=y,y=C,C=j),j=K0(m,C);var U=K0(m,y);j&&U&&(i.rangeCount!==1||i.anchorNode!==j.node||i.anchorOffset!==j.offset||i.focusNode!==U.node||i.focusOffset!==U.offset)&&(c=c.createRange(),c.setStart(j.node,j.offset),i.removeAllRanges(),C>y?(i.addRange(c),i.extend(U.node,U.offset)):(c.setEnd(U.node,U.offset),i.addRange(c)))}}for(c=[],i=m;i=i.parentNode;)i.nodeType===1&&c.push({element:i,left:i.scrollLeft,top:i.scrollTop});for(typeof m.focus=="function"&&m.focus(),m=0;m<c.length;m++)i=c[m],i.element.scrollLeft=i.left,i.element.scrollTop=i.top}}var o3=u&&"documentMode"in document&&11>=document.documentMode,lo=null,Ch=null,Wi=null,Th=!1;function Z0(i,c,m){var y=m.window===m?m.document:m.nodeType===9?m:m.ownerDocument;Th||lo==null||lo!==fe(y)||(y=lo,"selectionStart"in y&&Eh(y)?y={start:y.selectionStart,end:y.selectionEnd}:(y=(y.ownerDocument&&y.ownerDocument.defaultView||window).getSelection(),y={anchorNode:y.anchorNode,anchorOffset:y.anchorOffset,focusNode:y.focusNode,focusOffset:y.focusOffset}),Wi&&zi(Wi,y)||(Wi=y,y=kc(Ch,"onSelect"),0<y.length&&(c=new Fi("onSelect","select",null,c,m),i.push({event:c,listeners:y}),c.target=lo)))}function vc(i,c){var m={};return m[i.toLowerCase()]=c.toLowerCase(),m["Webkit"+i]="webkit"+c,m["Moz"+i]="moz"+c,m}var co={animationend:vc("Animation","AnimationEnd"),animationiteration:vc("Animation","AnimationIteration"),animationstart:vc("Animation","AnimationStart"),transitionend:vc("Transition","TransitionEnd")},Ah={},J0={};u&&(J0=document.createElement("div").style,"AnimationEvent"in window||(delete co.animationend.animation,delete co.animationiteration.animation,delete co.animationstart.animation),"TransitionEvent"in window||delete co.transitionend.transition);function xc(i){if(Ah[i])return Ah[i];if(!co[i])return i;var c=co[i],m;for(m in c)if(c.hasOwnProperty(m)&&m in J0)return Ah[i]=c[m];return i}var Q0=xc("animationend"),ek=xc("animationiteration"),tk=xc("animationstart"),nk=xc("transitionend"),rk=new Map,sk="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 As(i,c){rk.set(i,c),o(c,[i])}for(var Rh=0;Rh<sk.length;Rh++){var Mh=sk[Rh],i3=Mh.toLowerCase(),l3=Mh[0].toUpperCase()+Mh.slice(1);As(i3,"on"+l3)}As(Q0,"onAnimationEnd"),As(ek,"onAnimationIteration"),As(tk,"onAnimationStart"),As("dblclick","onDoubleClick"),As("focusin","onFocus"),As("focusout","onBlur"),As(nk,"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 Hi="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(" "),c3=new Set("cancel close invalid load scroll toggle".split(" ").concat(Hi));function ak(i,c,m){var y=i.type||"unknown-event";i.currentTarget=m,Vn(y,c,void 0,i),i.currentTarget=null}function ok(i,c){c=(c&4)!==0;for(var m=0;m<i.length;m++){var y=i[m],j=y.event;y=y.listeners;e:{var C=void 0;if(c)for(var U=y.length-1;0<=U;U--){var Q=y[U],te=Q.instance,ce=Q.currentTarget;if(Q=Q.listener,te!==C&&j.isPropagationStopped())break e;ak(j,Q,ce),C=te}else for(U=0;U<y.length;U++){if(Q=y[U],te=Q.instance,ce=Q.currentTarget,Q=Q.listener,te!==C&&j.isPropagationStopped())break e;ak(j,Q,ce),C=te}}}if(vt)throw i=wr,vt=!1,wr=null,i}function st(i,c){var m=c[Bh];m===void 0&&(m=c[Bh]=new Set);var y=i+"__bubble";m.has(y)||(ik(c,i,2,!1),m.add(y))}function $h(i,c,m){var y=0;c&&(y|=4),ik(m,i,y,c)}var bc="_reactListening"+Math.random().toString(36).slice(2);function Vi(i){if(!i[bc]){i[bc]=!0,r.forEach(function(m){m!=="selectionchange"&&(c3.has(m)||$h(m,!1,i),$h(m,!0,i))});var c=i.nodeType===9?i:i.ownerDocument;c===null||c[bc]||(c[bc]=!0,$h("selectionchange",!1,c))}}function ik(i,c,m,y){switch(gc(c)){case 1:var j=bh;break;case 4:j=Pi;break;default:j=no}m=j.bind(null,c,m,i),j=void 0,!Hr||c!=="touchstart"&&c!=="touchmove"&&c!=="wheel"||(j=!0),y?j!==void 0?i.addEventListener(c,m,{capture:!0,passive:j}):i.addEventListener(c,m,!0):j!==void 0?i.addEventListener(c,m,{passive:j}):i.addEventListener(c,m,!1)}function Ih(i,c,m,y,j){var C=y;if((c&1)===0&&(c&2)===0&&y!==null)e:for(;;){if(y===null)return;var U=y.tag;if(U===3||U===4){var Q=y.stateNode.containerInfo;if(Q===j||Q.nodeType===8&&Q.parentNode===j)break;if(U===4)for(U=y.return;U!==null;){var te=U.tag;if((te===3||te===4)&&(te=U.stateNode.containerInfo,te===j||te.nodeType===8&&te.parentNode===j))return;U=U.return}for(;Q!==null;){if(U=ha(Q),U===null)return;if(te=U.tag,te===5||te===6){y=C=U;continue e}Q=Q.parentNode}}y=y.return}gr(function(){var ce=C,ye=en(m),xe=[];e:{var ge=rk.get(i);if(ge!==void 0){var je=Fi,_e=i;switch(i){case"keypress":if(so(m)===0)break e;case"keydown":case"keyup":je=FL;break;case"focusin":_e="focus",je=kh;break;case"focusout":_e="blur",je=kh;break;case"beforeblur":case"afterblur":je=kh;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":je=$0;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":je=EL;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":je=UL;break;case Q0:case ek:case tk:je=AL;break;case nk:je=WL;break;case"scroll":je=ca;break;case"wheel":je=VL;break;case"copy":case"cut":case"paste":je=ML;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":je=O0}var Ee=(c&4)!==0,wt=!Ee&&i==="scroll",oe=Ee?ge!==null?ge+"Capture":null:ge;Ee=[];for(var ne=ce,le;ne!==null;){le=ne;var be=le.stateNode;if(le.tag===5&&be!==null&&(le=be,oe!==null&&(be=Hn(ne,oe),be!=null&&Ee.push(Gi(ne,be,le)))),wt)break;ne=ne.return}0<Ee.length&&(ge=new je(ge,_e,null,m,ye),xe.push({event:ge,listeners:Ee}))}}if((c&7)===0){e:{if(ge=i==="mouseover"||i==="pointerover",je=i==="mouseout"||i==="pointerout",ge&&m!==lt&&(_e=m.relatedTarget||m.fromElement)&&(ha(_e)||_e[Qr]))break e;if((je||ge)&&(ge=ye.window===ye?ye:(ge=ye.ownerDocument)?ge.defaultView||ge.parentWindow:window,je?(_e=m.relatedTarget||m.toElement,je=ce,_e=_e?ha(_e):null,_e!==null&&(wt=pn(_e),_e!==wt||_e.tag!==5&&_e.tag!==6)&&(_e=null)):(je=null,_e=ce),je!==_e)){if(Ee=$0,be="onMouseLeave",oe="onMouseEnter",ne="mouse",(i==="pointerout"||i==="pointerover")&&(Ee=O0,be="onPointerLeave",oe="onPointerEnter",ne="pointer"),wt=je==null?ge:fo(je),le=_e==null?ge:fo(_e),ge=new Ee(be,ne+"leave",je,m,ye),ge.target=wt,ge.relatedTarget=le,be=null,ha(ye)===ce&&(Ee=new Ee(oe,ne+"enter",_e,m,ye),Ee.target=le,Ee.relatedTarget=wt,be=Ee),wt=be,je&&_e)t:{for(Ee=je,oe=_e,ne=0,le=Ee;le;le=uo(le))ne++;for(le=0,be=oe;be;be=uo(be))le++;for(;0<ne-le;)Ee=uo(Ee),ne--;for(;0<le-ne;)oe=uo(oe),le--;for(;ne--;){if(Ee===oe||oe!==null&&Ee===oe.alternate)break t;Ee=uo(Ee),oe=uo(oe)}Ee=null}else Ee=null;je!==null&&lk(xe,ge,je,Ee,!1),_e!==null&&wt!==null&&lk(xe,wt,_e,Ee,!0)}}e:{if(ge=ce?fo(ce):window,je=ge.nodeName&&ge.nodeName.toLowerCase(),je==="select"||je==="input"&&ge.type==="file")var Ce=QL;else if(q0(ge))if(z0)Ce=r3;else{Ce=t3;var Re=e3}else(je=ge.nodeName)&&je.toLowerCase()==="input"&&(ge.type==="checkbox"||ge.type==="radio")&&(Ce=n3);if(Ce&&(Ce=Ce(i,ce))){U0(xe,Ce,m,ye);break e}Re&&Re(i,ge,ce),i==="focusout"&&(Re=ge._wrapperState)&&Re.controlled&&ge.type==="number"&&ae(ge,"number",ge.value)}switch(Re=ce?fo(ce):window,i){case"focusin":(q0(Re)||Re.contentEditable==="true")&&(lo=Re,Ch=ce,Wi=null);break;case"focusout":Wi=Ch=lo=null;break;case"mousedown":Th=!0;break;case"contextmenu":case"mouseup":case"dragend":Th=!1,Z0(xe,m,ye);break;case"selectionchange":if(o3)break;case"keydown":case"keyup":Z0(xe,m,ye)}var Me;if(jh)e:{switch(i){case"compositionstart":var $e="onCompositionStart";break e;case"compositionend":$e="onCompositionEnd";break e;case"compositionupdate":$e="onCompositionUpdate";break e}$e=void 0}else io?F0(i,m)&&($e="onCompositionEnd"):i==="keydown"&&m.keyCode===229&&($e="onCompositionStart");$e&&(L0&&m.locale!=="ko"&&(io||$e!=="onCompositionStart"?$e==="onCompositionEnd"&&io&&(Me=Es()):(En=ye,_s="value"in En?En.value:En.textContent,io=!0)),Re=kc(ce,$e),0<Re.length&&($e=new I0($e,i,null,m,ye),xe.push({event:$e,listeners:Re}),Me?$e.data=Me:(Me=B0(m),Me!==null&&($e.data=Me)))),(Me=KL?YL(i,m):XL(i,m))&&(ce=kc(ce,"onBeforeInput"),0<ce.length&&(ye=new I0("onBeforeInput","beforeinput",null,m,ye),xe.push({event:ye,listeners:ce}),ye.data=Me))}ok(xe,c)})}function Gi(i,c,m){return{instance:i,listener:c,currentTarget:m}}function kc(i,c){for(var m=c+"Capture",y=[];i!==null;){var j=i,C=j.stateNode;j.tag===5&&C!==null&&(j=C,C=Hn(i,m),C!=null&&y.unshift(Gi(i,C,j)),C=Hn(i,c),C!=null&&y.push(Gi(i,C,j))),i=i.return}return y}function uo(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function lk(i,c,m,y,j){for(var C=c._reactName,U=[];m!==null&&m!==y;){var Q=m,te=Q.alternate,ce=Q.stateNode;if(te!==null&&te===y)break;Q.tag===5&&ce!==null&&(Q=ce,j?(te=Hn(m,C),te!=null&&U.unshift(Gi(m,te,Q))):j||(te=Hn(m,C),te!=null&&U.push(Gi(m,te,Q)))),m=m.return}U.length!==0&&i.push({event:c,listeners:U})}var u3=/\r\n?/g,d3=/\u0000|\uFFFD/g;function ck(i){return(typeof i=="string"?i:""+i).replace(u3,`
38
+ `).replace(d3,"")}function Nc(i,c,m){if(c=ck(c),ck(i)!==c&&m)throw Error(n(425))}function jc(){}var Oh=null,Lh=null;function Ph(i,c){return i==="textarea"||i==="noscript"||typeof c.children=="string"||typeof c.children=="number"||typeof c.dangerouslySetInnerHTML=="object"&&c.dangerouslySetInnerHTML!==null&&c.dangerouslySetInnerHTML.__html!=null}var Dh=typeof setTimeout=="function"?setTimeout:void 0,h3=typeof clearTimeout=="function"?clearTimeout:void 0,uk=typeof Promise=="function"?Promise:void 0,f3=typeof queueMicrotask=="function"?queueMicrotask:typeof uk<"u"?function(i){return uk.resolve(null).then(i).catch(p3)}:Dh;function p3(i){setTimeout(function(){throw i})}function Fh(i,c){var m=c,y=0;do{var j=m.nextSibling;if(i.removeChild(m),j&&j.nodeType===8)if(m=j.data,m==="/$"){if(y===0){i.removeChild(j),js(c);return}y--}else m!=="$"&&m!=="$?"&&m!=="$!"||y++;m=j}while(m);js(c)}function Rs(i){for(;i!=null;i=i.nextSibling){var c=i.nodeType;if(c===1||c===3)break;if(c===8){if(c=i.data,c==="$"||c==="$!"||c==="$?")break;if(c==="/$")return null}}return i}function dk(i){i=i.previousSibling;for(var c=0;i;){if(i.nodeType===8){var m=i.data;if(m==="$"||m==="$!"||m==="$?"){if(c===0)return i;c--}else m==="/$"&&c++}i=i.previousSibling}return null}var ho=Math.random().toString(36).slice(2),Er="__reactFiber$"+ho,Ki="__reactProps$"+ho,Qr="__reactContainer$"+ho,Bh="__reactEvents$"+ho,m3="__reactListeners$"+ho,g3="__reactHandles$"+ho;function ha(i){var c=i[Er];if(c)return c;for(var m=i.parentNode;m;){if(c=m[Qr]||m[Er]){if(m=c.alternate,c.child!==null||m!==null&&m.child!==null)for(i=dk(i);i!==null;){if(m=i[Er])return m;i=dk(i)}return c}i=m,m=i.parentNode}return null}function Yi(i){return i=i[Er]||i[Qr],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function fo(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(n(33))}function Sc(i){return i[Ki]||null}var qh=[],po=-1;function Ms(i){return{current:i}}function at(i){0>po||(i.current=qh[po],qh[po]=null,po--)}function tt(i,c){po++,qh[po]=i.current,i.current=c}var $s={},Ht=Ms($s),rn=Ms(!1),fa=$s;function mo(i,c){var m=i.type.contextTypes;if(!m)return $s;var y=i.stateNode;if(y&&y.__reactInternalMemoizedUnmaskedChildContext===c)return y.__reactInternalMemoizedMaskedChildContext;var j={},C;for(C in m)j[C]=c[C];return y&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=c,i.__reactInternalMemoizedMaskedChildContext=j),j}function sn(i){return i=i.childContextTypes,i!=null}function _c(){at(rn),at(Ht)}function hk(i,c,m){if(Ht.current!==$s)throw Error(n(168));tt(Ht,c),tt(rn,m)}function fk(i,c,m){var y=i.stateNode;if(c=c.childContextTypes,typeof y.getChildContext!="function")return m;y=y.getChildContext();for(var j in y)if(!(j in c))throw Error(n(108,Z(i)||"Unknown",j));return W({},m,y)}function Ec(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||$s,fa=Ht.current,tt(Ht,i),tt(rn,rn.current),!0}function pk(i,c,m){var y=i.stateNode;if(!y)throw Error(n(169));m?(i=fk(i,c,fa),y.__reactInternalMemoizedMergedChildContext=i,at(rn),at(Ht),tt(Ht,i)):at(rn),tt(rn,m)}var es=null,Cc=!1,Uh=!1;function mk(i){es===null?es=[i]:es.push(i)}function y3(i){Cc=!0,mk(i)}function Is(){if(!Uh&&es!==null){Uh=!0;var i=0,c=ze;try{var m=es;for(ze=1;i<m.length;i++){var y=m[i];do y=y(!0);while(y!==null)}es=null,Cc=!1}catch(j){throw es!==null&&(es=es.slice(i+1)),tn(Kn,Is),j}finally{ze=c,Uh=!1}}return null}var go=[],yo=0,Tc=null,Ac=0,Cn=[],Tn=0,pa=null,ts=1,ns="";function ma(i,c){go[yo++]=Ac,go[yo++]=Tc,Tc=i,Ac=c}function gk(i,c,m){Cn[Tn++]=ts,Cn[Tn++]=ns,Cn[Tn++]=pa,pa=i;var y=ts;i=ns;var j=32-nn(y)-1;y&=~(1<<j),m+=1;var C=32-nn(c)+j;if(30<C){var U=j-j%5;C=(y&(1<<U)-1).toString(32),y>>=U,j-=U,ts=1<<32-nn(c)+j|m<<j|y,ns=C+i}else ts=1<<C|m<<j|y,ns=i}function zh(i){i.return!==null&&(ma(i,1),gk(i,1,0))}function Wh(i){for(;i===Tc;)Tc=go[--yo],go[yo]=null,Ac=go[--yo],go[yo]=null;for(;i===pa;)pa=Cn[--Tn],Cn[Tn]=null,ns=Cn[--Tn],Cn[Tn]=null,ts=Cn[--Tn],Cn[Tn]=null}var mn=null,gn=null,ct=!1,Zn=null;function yk(i,c){var m=$n(5,null,null,0);m.elementType="DELETED",m.stateNode=c,m.return=i,c=i.deletions,c===null?(i.deletions=[m],i.flags|=16):c.push(m)}function wk(i,c){switch(i.tag){case 5:var m=i.type;return c=c.nodeType!==1||m.toLowerCase()!==c.nodeName.toLowerCase()?null:c,c!==null?(i.stateNode=c,mn=i,gn=Rs(c.firstChild),!0):!1;case 6:return c=i.pendingProps===""||c.nodeType!==3?null:c,c!==null?(i.stateNode=c,mn=i,gn=null,!0):!1;case 13:return c=c.nodeType!==8?null:c,c!==null?(m=pa!==null?{id:ts,overflow:ns}:null,i.memoizedState={dehydrated:c,treeContext:m,retryLane:1073741824},m=$n(18,null,null,0),m.stateNode=c,m.return=i,i.child=m,mn=i,gn=null,!0):!1;default:return!1}}function Hh(i){return(i.mode&1)!==0&&(i.flags&128)===0}function Vh(i){if(ct){var c=gn;if(c){var m=c;if(!wk(i,c)){if(Hh(i))throw Error(n(418));c=Rs(m.nextSibling);var y=mn;c&&wk(i,c)?yk(y,m):(i.flags=i.flags&-4097|2,ct=!1,mn=i)}}else{if(Hh(i))throw Error(n(418));i.flags=i.flags&-4097|2,ct=!1,mn=i}}}function vk(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;mn=i}function Rc(i){if(i!==mn)return!1;if(!ct)return vk(i),ct=!0,!1;var c;if((c=i.tag!==3)&&!(c=i.tag!==5)&&(c=i.type,c=c!=="head"&&c!=="body"&&!Ph(i.type,i.memoizedProps)),c&&(c=gn)){if(Hh(i))throw xk(),Error(n(418));for(;c;)yk(i,c),c=Rs(c.nextSibling)}if(vk(i),i.tag===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(317));e:{for(i=i.nextSibling,c=0;i;){if(i.nodeType===8){var m=i.data;if(m==="/$"){if(c===0){gn=Rs(i.nextSibling);break e}c--}else m!=="$"&&m!=="$!"&&m!=="$?"||c++}i=i.nextSibling}gn=null}}else gn=mn?Rs(i.stateNode.nextSibling):null;return!0}function xk(){for(var i=gn;i;)i=Rs(i.nextSibling)}function wo(){gn=mn=null,ct=!1}function Gh(i){Zn===null?Zn=[i]:Zn.push(i)}var w3=E.ReactCurrentBatchConfig;function Xi(i,c,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 y=m.stateNode}if(!y)throw Error(n(147,i));var j=y,C=""+i;return c!==null&&c.ref!==null&&typeof c.ref=="function"&&c.ref._stringRef===C?c.ref:(c=function(U){var Q=j.refs;U===null?delete Q[C]:Q[C]=U},c._stringRef=C,c)}if(typeof i!="string")throw Error(n(284));if(!m._owner)throw Error(n(290,i))}return i}function Mc(i,c){throw i=Object.prototype.toString.call(c),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(c).join(", ")+"}":i))}function bk(i){var c=i._init;return c(i._payload)}function kk(i){function c(oe,ne){if(i){var le=oe.deletions;le===null?(oe.deletions=[ne],oe.flags|=16):le.push(ne)}}function m(oe,ne){if(!i)return null;for(;ne!==null;)c(oe,ne),ne=ne.sibling;return null}function y(oe,ne){for(oe=new Map;ne!==null;)ne.key!==null?oe.set(ne.key,ne):oe.set(ne.index,ne),ne=ne.sibling;return oe}function j(oe,ne){return oe=Us(oe,ne),oe.index=0,oe.sibling=null,oe}function C(oe,ne,le){return oe.index=le,i?(le=oe.alternate,le!==null?(le=le.index,le<ne?(oe.flags|=2,ne):le):(oe.flags|=2,ne)):(oe.flags|=1048576,ne)}function U(oe){return i&&oe.alternate===null&&(oe.flags|=2),oe}function Q(oe,ne,le,be){return ne===null||ne.tag!==6?(ne=Ff(le,oe.mode,be),ne.return=oe,ne):(ne=j(ne,le),ne.return=oe,ne)}function te(oe,ne,le,be){var Ce=le.type;return Ce===R?ye(oe,ne,le.props.children,be,le.key):ne!==null&&(ne.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===q&&bk(Ce)===ne.type)?(be=j(ne,le.props),be.ref=Xi(oe,ne,le),be.return=oe,be):(be=nu(le.type,le.key,le.props,null,oe.mode,be),be.ref=Xi(oe,ne,le),be.return=oe,be)}function ce(oe,ne,le,be){return ne===null||ne.tag!==4||ne.stateNode.containerInfo!==le.containerInfo||ne.stateNode.implementation!==le.implementation?(ne=Bf(le,oe.mode,be),ne.return=oe,ne):(ne=j(ne,le.children||[]),ne.return=oe,ne)}function ye(oe,ne,le,be,Ce){return ne===null||ne.tag!==7?(ne=Na(le,oe.mode,be,Ce),ne.return=oe,ne):(ne=j(ne,le),ne.return=oe,ne)}function xe(oe,ne,le){if(typeof ne=="string"&&ne!==""||typeof ne=="number")return ne=Ff(""+ne,oe.mode,le),ne.return=oe,ne;if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case T:return le=nu(ne.type,ne.key,ne.props,null,oe.mode,le),le.ref=Xi(oe,null,ne),le.return=oe,le;case A:return ne=Bf(ne,oe.mode,le),ne.return=oe,ne;case q:var be=ne._init;return xe(oe,be(ne._payload),le)}if(Ne(ne)||L(ne))return ne=Na(ne,oe.mode,le,null),ne.return=oe,ne;Mc(oe,ne)}return null}function ge(oe,ne,le,be){var Ce=ne!==null?ne.key:null;if(typeof le=="string"&&le!==""||typeof le=="number")return Ce!==null?null:Q(oe,ne,""+le,be);if(typeof le=="object"&&le!==null){switch(le.$$typeof){case T:return le.key===Ce?te(oe,ne,le,be):null;case A:return le.key===Ce?ce(oe,ne,le,be):null;case q:return Ce=le._init,ge(oe,ne,Ce(le._payload),be)}if(Ne(le)||L(le))return Ce!==null?null:ye(oe,ne,le,be,null);Mc(oe,le)}return null}function je(oe,ne,le,be,Ce){if(typeof be=="string"&&be!==""||typeof be=="number")return oe=oe.get(le)||null,Q(ne,oe,""+be,Ce);if(typeof be=="object"&&be!==null){switch(be.$$typeof){case T:return oe=oe.get(be.key===null?le:be.key)||null,te(ne,oe,be,Ce);case A:return oe=oe.get(be.key===null?le:be.key)||null,ce(ne,oe,be,Ce);case q:var Re=be._init;return je(oe,ne,le,Re(be._payload),Ce)}if(Ne(be)||L(be))return oe=oe.get(le)||null,ye(ne,oe,be,Ce,null);Mc(ne,be)}return null}function _e(oe,ne,le,be){for(var Ce=null,Re=null,Me=ne,$e=ne=0,It=null;Me!==null&&$e<le.length;$e++){Me.index>$e?(It=Me,Me=null):It=Me.sibling;var We=ge(oe,Me,le[$e],be);if(We===null){Me===null&&(Me=It);break}i&&Me&&We.alternate===null&&c(oe,Me),ne=C(We,ne,$e),Re===null?Ce=We:Re.sibling=We,Re=We,Me=It}if($e===le.length)return m(oe,Me),ct&&ma(oe,$e),Ce;if(Me===null){for(;$e<le.length;$e++)Me=xe(oe,le[$e],be),Me!==null&&(ne=C(Me,ne,$e),Re===null?Ce=Me:Re.sibling=Me,Re=Me);return ct&&ma(oe,$e),Ce}for(Me=y(oe,Me);$e<le.length;$e++)It=je(Me,oe,$e,le[$e],be),It!==null&&(i&&It.alternate!==null&&Me.delete(It.key===null?$e:It.key),ne=C(It,ne,$e),Re===null?Ce=It:Re.sibling=It,Re=It);return i&&Me.forEach(function(zs){return c(oe,zs)}),ct&&ma(oe,$e),Ce}function Ee(oe,ne,le,be){var Ce=L(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=ne,$e=ne=0,It=null,We=le.next();Me!==null&&!We.done;$e++,We=le.next()){Me.index>$e?(It=Me,Me=null):It=Me.sibling;var zs=ge(oe,Me,We.value,be);if(zs===null){Me===null&&(Me=It);break}i&&Me&&zs.alternate===null&&c(oe,Me),ne=C(zs,ne,$e),Re===null?Ce=zs:Re.sibling=zs,Re=zs,Me=It}if(We.done)return m(oe,Me),ct&&ma(oe,$e),Ce;if(Me===null){for(;!We.done;$e++,We=le.next())We=xe(oe,We.value,be),We!==null&&(ne=C(We,ne,$e),Re===null?Ce=We:Re.sibling=We,Re=We);return ct&&ma(oe,$e),Ce}for(Me=y(oe,Me);!We.done;$e++,We=le.next())We=je(Me,oe,$e,We.value,be),We!==null&&(i&&We.alternate!==null&&Me.delete(We.key===null?$e:We.key),ne=C(We,ne,$e),Re===null?Ce=We:Re.sibling=We,Re=We);return i&&Me.forEach(function(Z3){return c(oe,Z3)}),ct&&ma(oe,$e),Ce}function wt(oe,ne,le,be){if(typeof le=="object"&&le!==null&&le.type===R&&le.key===null&&(le=le.props.children),typeof le=="object"&&le!==null){switch(le.$$typeof){case T:e:{for(var Ce=le.key,Re=ne;Re!==null;){if(Re.key===Ce){if(Ce=le.type,Ce===R){if(Re.tag===7){m(oe,Re.sibling),ne=j(Re,le.props.children),ne.return=oe,oe=ne;break e}}else if(Re.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===q&&bk(Ce)===Re.type){m(oe,Re.sibling),ne=j(Re,le.props),ne.ref=Xi(oe,Re,le),ne.return=oe,oe=ne;break e}m(oe,Re);break}else c(oe,Re);Re=Re.sibling}le.type===R?(ne=Na(le.props.children,oe.mode,be,le.key),ne.return=oe,oe=ne):(be=nu(le.type,le.key,le.props,null,oe.mode,be),be.ref=Xi(oe,ne,le),be.return=oe,oe=be)}return U(oe);case A:e:{for(Re=le.key;ne!==null;){if(ne.key===Re)if(ne.tag===4&&ne.stateNode.containerInfo===le.containerInfo&&ne.stateNode.implementation===le.implementation){m(oe,ne.sibling),ne=j(ne,le.children||[]),ne.return=oe,oe=ne;break e}else{m(oe,ne);break}else c(oe,ne);ne=ne.sibling}ne=Bf(le,oe.mode,be),ne.return=oe,oe=ne}return U(oe);case q:return Re=le._init,wt(oe,ne,Re(le._payload),be)}if(Ne(le))return _e(oe,ne,le,be);if(L(le))return Ee(oe,ne,le,be);Mc(oe,le)}return typeof le=="string"&&le!==""||typeof le=="number"?(le=""+le,ne!==null&&ne.tag===6?(m(oe,ne.sibling),ne=j(ne,le),ne.return=oe,oe=ne):(m(oe,ne),ne=Ff(le,oe.mode,be),ne.return=oe,oe=ne),U(oe)):m(oe,ne)}return wt}var vo=kk(!0),Nk=kk(!1),$c=Ms(null),Ic=null,xo=null,Kh=null;function Yh(){Kh=xo=Ic=null}function Xh(i){var c=$c.current;at($c),i._currentValue=c}function Zh(i,c,m){for(;i!==null;){var y=i.alternate;if((i.childLanes&c)!==c?(i.childLanes|=c,y!==null&&(y.childLanes|=c)):y!==null&&(y.childLanes&c)!==c&&(y.childLanes|=c),i===m)break;i=i.return}}function bo(i,c){Ic=i,Kh=xo=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&c)!==0&&(an=!0),i.firstContext=null)}function An(i){var c=i._currentValue;if(Kh!==i)if(i={context:i,memoizedValue:c,next:null},xo===null){if(Ic===null)throw Error(n(308));xo=i,Ic.dependencies={lanes:0,firstContext:i}}else xo=xo.next=i;return c}var ga=null;function Jh(i){ga===null?ga=[i]:ga.push(i)}function jk(i,c,m,y){var j=c.interleaved;return j===null?(m.next=m,Jh(c)):(m.next=j.next,j.next=m),c.interleaved=m,rs(i,y)}function rs(i,c){i.lanes|=c;var m=i.alternate;for(m!==null&&(m.lanes|=c),m=i,i=i.return;i!==null;)i.childLanes|=c,m=i.alternate,m!==null&&(m.childLanes|=c),m=i,i=i.return;return m.tag===3?m.stateNode:null}var Os=!1;function Qh(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Sk(i,c){i=i.updateQueue,c.updateQueue===i&&(c.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,effects:i.effects})}function ss(i,c){return{eventTime:i,lane:c,tag:0,payload:null,callback:null,next:null}}function Ls(i,c,m){var y=i.updateQueue;if(y===null)return null;if(y=y.shared,(Ue&2)!==0){var j=y.pending;return j===null?c.next=c:(c.next=j.next,j.next=c),y.pending=c,rs(i,m)}return j=y.interleaved,j===null?(c.next=c,Jh(y)):(c.next=j.next,j.next=c),y.interleaved=c,rs(i,m)}function Oc(i,c,m){if(c=c.updateQueue,c!==null&&(c=c.shared,(m&4194240)!==0)){var y=c.lanes;y&=i.pendingLanes,m|=y,c.lanes=m,Ti(i,m)}}function _k(i,c){var m=i.updateQueue,y=i.alternate;if(y!==null&&(y=y.updateQueue,m===y)){var j=null,C=null;if(m=m.firstBaseUpdate,m!==null){do{var U={eventTime:m.eventTime,lane:m.lane,tag:m.tag,payload:m.payload,callback:m.callback,next:null};C===null?j=C=U:C=C.next=U,m=m.next}while(m!==null);C===null?j=C=c:C=C.next=c}else j=C=c;m={baseState:y.baseState,firstBaseUpdate:j,lastBaseUpdate:C,shared:y.shared,effects:y.effects},i.updateQueue=m;return}i=m.lastBaseUpdate,i===null?m.firstBaseUpdate=c:i.next=c,m.lastBaseUpdate=c}function Lc(i,c,m,y){var j=i.updateQueue;Os=!1;var C=j.firstBaseUpdate,U=j.lastBaseUpdate,Q=j.shared.pending;if(Q!==null){j.shared.pending=null;var te=Q,ce=te.next;te.next=null,U===null?C=ce:U.next=ce,U=te;var ye=i.alternate;ye!==null&&(ye=ye.updateQueue,Q=ye.lastBaseUpdate,Q!==U&&(Q===null?ye.firstBaseUpdate=ce:Q.next=ce,ye.lastBaseUpdate=te))}if(C!==null){var xe=j.baseState;U=0,ye=ce=te=null,Q=C;do{var ge=Q.lane,je=Q.eventTime;if((y&ge)===ge){ye!==null&&(ye=ye.next={eventTime:je,lane:0,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null});e:{var _e=i,Ee=Q;switch(ge=c,je=m,Ee.tag){case 1:if(_e=Ee.payload,typeof _e=="function"){xe=_e.call(je,xe,ge);break e}xe=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ee.payload,ge=typeof _e=="function"?_e.call(je,xe,ge):_e,ge==null)break e;xe=W({},xe,ge);break e;case 2:Os=!0}}Q.callback!==null&&Q.lane!==0&&(i.flags|=64,ge=j.effects,ge===null?j.effects=[Q]:ge.push(Q))}else je={eventTime:je,lane:ge,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null},ye===null?(ce=ye=je,te=xe):ye=ye.next=je,U|=ge;if(Q=Q.next,Q===null){if(Q=j.shared.pending,Q===null)break;ge=Q,Q=ge.next,ge.next=null,j.lastBaseUpdate=ge,j.shared.pending=null}}while(!0);if(ye===null&&(te=xe),j.baseState=te,j.firstBaseUpdate=ce,j.lastBaseUpdate=ye,c=j.shared.interleaved,c!==null){j=c;do U|=j.lane,j=j.next;while(j!==c)}else C===null&&(j.shared.lanes=0);va|=U,i.lanes=U,i.memoizedState=xe}}function Ek(i,c,m){if(i=c.effects,c.effects=null,i!==null)for(c=0;c<i.length;c++){var y=i[c],j=y.callback;if(j!==null){if(y.callback=null,y=m,typeof j!="function")throw Error(n(191,j));j.call(y)}}}var Zi={},Cr=Ms(Zi),Ji=Ms(Zi),Qi=Ms(Zi);function ya(i){if(i===Zi)throw Error(n(174));return i}function ef(i,c){switch(tt(Qi,c),tt(Ji,i),tt(Cr,Zi),i=c.nodeType,i){case 9:case 11:c=(c=c.documentElement)?c.namespaceURI:Ke(null,"");break;default:i=i===8?c.parentNode:c,c=i.namespaceURI||null,i=i.tagName,c=Ke(c,i)}at(Cr),tt(Cr,c)}function ko(){at(Cr),at(Ji),at(Qi)}function Ck(i){ya(Qi.current);var c=ya(Cr.current),m=Ke(c,i.type);c!==m&&(tt(Ji,i),tt(Cr,m))}function tf(i){Ji.current===i&&(at(Cr),at(Ji))}var dt=Ms(0);function Pc(i){for(var c=i;c!==null;){if(c.tag===13){var m=c.memoizedState;if(m!==null&&(m=m.dehydrated,m===null||m.data==="$?"||m.data==="$!"))return c}else if(c.tag===19&&c.memoizedProps.revealOrder!==void 0){if((c.flags&128)!==0)return c}else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===i)break;for(;c.sibling===null;){if(c.return===null||c.return===i)return null;c=c.return}c.sibling.return=c.return,c=c.sibling}return null}var nf=[];function rf(){for(var i=0;i<nf.length;i++)nf[i]._workInProgressVersionPrimary=null;nf.length=0}var Dc=E.ReactCurrentDispatcher,sf=E.ReactCurrentBatchConfig,wa=0,ht=null,jt=null,Mt=null,Fc=!1,el=!1,tl=0,v3=0;function Vt(){throw Error(n(321))}function af(i,c){if(c===null)return!1;for(var m=0;m<c.length&&m<i.length;m++)if(!Xn(i[m],c[m]))return!1;return!0}function of(i,c,m,y,j,C){if(wa=C,ht=c,c.memoizedState=null,c.updateQueue=null,c.lanes=0,Dc.current=i===null||i.memoizedState===null?N3:j3,i=m(y,j),el){C=0;do{if(el=!1,tl=0,25<=C)throw Error(n(301));C+=1,Mt=jt=null,c.updateQueue=null,Dc.current=S3,i=m(y,j)}while(el)}if(Dc.current=Uc,c=jt!==null&&jt.next!==null,wa=0,Mt=jt=ht=null,Fc=!1,c)throw Error(n(300));return i}function lf(){var i=tl!==0;return tl=0,i}function Tr(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Mt===null?ht.memoizedState=Mt=i:Mt=Mt.next=i,Mt}function Rn(){if(jt===null){var i=ht.alternate;i=i!==null?i.memoizedState:null}else i=jt.next;var c=Mt===null?ht.memoizedState:Mt.next;if(c!==null)Mt=c,jt=i;else{if(i===null)throw Error(n(310));jt=i,i={memoizedState:jt.memoizedState,baseState:jt.baseState,baseQueue:jt.baseQueue,queue:jt.queue,next:null},Mt===null?ht.memoizedState=Mt=i:Mt=Mt.next=i}return Mt}function nl(i,c){return typeof c=="function"?c(i):c}function cf(i){var c=Rn(),m=c.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=i;var y=jt,j=y.baseQueue,C=m.pending;if(C!==null){if(j!==null){var U=j.next;j.next=C.next,C.next=U}y.baseQueue=j=C,m.pending=null}if(j!==null){C=j.next,y=y.baseState;var Q=U=null,te=null,ce=C;do{var ye=ce.lane;if((wa&ye)===ye)te!==null&&(te=te.next={lane:0,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null}),y=ce.hasEagerState?ce.eagerState:i(y,ce.action);else{var xe={lane:ye,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null};te===null?(Q=te=xe,U=y):te=te.next=xe,ht.lanes|=ye,va|=ye}ce=ce.next}while(ce!==null&&ce!==C);te===null?U=y:te.next=Q,Xn(y,c.memoizedState)||(an=!0),c.memoizedState=y,c.baseState=U,c.baseQueue=te,m.lastRenderedState=y}if(i=m.interleaved,i!==null){j=i;do C=j.lane,ht.lanes|=C,va|=C,j=j.next;while(j!==i)}else j===null&&(m.lanes=0);return[c.memoizedState,m.dispatch]}function uf(i){var c=Rn(),m=c.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=i;var y=m.dispatch,j=m.pending,C=c.memoizedState;if(j!==null){m.pending=null;var U=j=j.next;do C=i(C,U.action),U=U.next;while(U!==j);Xn(C,c.memoizedState)||(an=!0),c.memoizedState=C,c.baseQueue===null&&(c.baseState=C),m.lastRenderedState=C}return[C,y]}function Tk(){}function Ak(i,c){var m=ht,y=Rn(),j=c(),C=!Xn(y.memoizedState,j);if(C&&(y.memoizedState=j,an=!0),y=y.queue,df($k.bind(null,m,y,i),[i]),y.getSnapshot!==c||C||Mt!==null&&Mt.memoizedState.tag&1){if(m.flags|=2048,rl(9,Mk.bind(null,m,y,j,c),void 0,null),$t===null)throw Error(n(349));(wa&30)!==0||Rk(m,c,j)}return j}function Rk(i,c,m){i.flags|=16384,i={getSnapshot:c,value:m},c=ht.updateQueue,c===null?(c={lastEffect:null,stores:null},ht.updateQueue=c,c.stores=[i]):(m=c.stores,m===null?c.stores=[i]:m.push(i))}function Mk(i,c,m,y){c.value=m,c.getSnapshot=y,Ik(c)&&Ok(i)}function $k(i,c,m){return m(function(){Ik(c)&&Ok(i)})}function Ik(i){var c=i.getSnapshot;i=i.value;try{var m=c();return!Xn(i,m)}catch{return!0}}function Ok(i){var c=rs(i,1);c!==null&&tr(c,i,1,-1)}function Lk(i){var c=Tr();return typeof i=="function"&&(i=i()),c.memoizedState=c.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:nl,lastRenderedState:i},c.queue=i,i=i.dispatch=k3.bind(null,ht,i),[c.memoizedState,i]}function rl(i,c,m,y){return i={tag:i,create:c,destroy:m,deps:y,next:null},c=ht.updateQueue,c===null?(c={lastEffect:null,stores:null},ht.updateQueue=c,c.lastEffect=i.next=i):(m=c.lastEffect,m===null?c.lastEffect=i.next=i:(y=m.next,m.next=i,i.next=y,c.lastEffect=i)),i}function Pk(){return Rn().memoizedState}function Bc(i,c,m,y){var j=Tr();ht.flags|=i,j.memoizedState=rl(1|c,m,void 0,y===void 0?null:y)}function qc(i,c,m,y){var j=Rn();y=y===void 0?null:y;var C=void 0;if(jt!==null){var U=jt.memoizedState;if(C=U.destroy,y!==null&&af(y,U.deps)){j.memoizedState=rl(c,m,C,y);return}}ht.flags|=i,j.memoizedState=rl(1|c,m,C,y)}function Dk(i,c){return Bc(8390656,8,i,c)}function df(i,c){return qc(2048,8,i,c)}function Fk(i,c){return qc(4,2,i,c)}function Bk(i,c){return qc(4,4,i,c)}function qk(i,c){if(typeof c=="function")return i=i(),c(i),function(){c(null)};if(c!=null)return i=i(),c.current=i,function(){c.current=null}}function Uk(i,c,m){return m=m!=null?m.concat([i]):null,qc(4,4,qk.bind(null,c,i),m)}function hf(){}function zk(i,c){var m=Rn();c=c===void 0?null:c;var y=m.memoizedState;return y!==null&&c!==null&&af(c,y[1])?y[0]:(m.memoizedState=[i,c],i)}function Wk(i,c){var m=Rn();c=c===void 0?null:c;var y=m.memoizedState;return y!==null&&c!==null&&af(c,y[1])?y[0]:(i=i(),m.memoizedState=[i,c],i)}function Hk(i,c,m){return(wa&21)===0?(i.baseState&&(i.baseState=!1,an=!0),i.memoizedState=m):(Xn(m,c)||(m=fc(),ht.lanes|=m,va|=m,i.baseState=!0),c)}function x3(i,c){var m=ze;ze=m!==0&&4>m?m:4,i(!0);var y=sf.transition;sf.transition={};try{i(!1),c()}finally{ze=m,sf.transition=y}}function Vk(){return Rn().memoizedState}function b3(i,c,m){var y=Bs(i);if(m={lane:y,action:m,hasEagerState:!1,eagerState:null,next:null},Gk(i))Kk(c,m);else if(m=jk(i,c,m,y),m!==null){var j=Jt();tr(m,i,y,j),Yk(m,c,y)}}function k3(i,c,m){var y=Bs(i),j={lane:y,action:m,hasEagerState:!1,eagerState:null,next:null};if(Gk(i))Kk(c,j);else{var C=i.alternate;if(i.lanes===0&&(C===null||C.lanes===0)&&(C=c.lastRenderedReducer,C!==null))try{var U=c.lastRenderedState,Q=C(U,m);if(j.hasEagerState=!0,j.eagerState=Q,Xn(Q,U)){var te=c.interleaved;te===null?(j.next=j,Jh(c)):(j.next=te.next,te.next=j),c.interleaved=j;return}}catch{}finally{}m=jk(i,c,j,y),m!==null&&(j=Jt(),tr(m,i,y,j),Yk(m,c,y))}}function Gk(i){var c=i.alternate;return i===ht||c!==null&&c===ht}function Kk(i,c){el=Fc=!0;var m=i.pending;m===null?c.next=c:(c.next=m.next,m.next=c),i.pending=c}function Yk(i,c,m){if((m&4194240)!==0){var y=c.lanes;y&=i.pendingLanes,m|=y,c.lanes=m,Ti(i,m)}}var Uc={readContext:An,useCallback:Vt,useContext:Vt,useEffect:Vt,useImperativeHandle:Vt,useInsertionEffect:Vt,useLayoutEffect:Vt,useMemo:Vt,useReducer:Vt,useRef:Vt,useState:Vt,useDebugValue:Vt,useDeferredValue:Vt,useTransition:Vt,useMutableSource:Vt,useSyncExternalStore:Vt,useId:Vt,unstable_isNewReconciler:!1},N3={readContext:An,useCallback:function(i,c){return Tr().memoizedState=[i,c===void 0?null:c],i},useContext:An,useEffect:Dk,useImperativeHandle:function(i,c,m){return m=m!=null?m.concat([i]):null,Bc(4194308,4,qk.bind(null,c,i),m)},useLayoutEffect:function(i,c){return Bc(4194308,4,i,c)},useInsertionEffect:function(i,c){return Bc(4,2,i,c)},useMemo:function(i,c){var m=Tr();return c=c===void 0?null:c,i=i(),m.memoizedState=[i,c],i},useReducer:function(i,c,m){var y=Tr();return c=m!==void 0?m(c):c,y.memoizedState=y.baseState=c,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:c},y.queue=i,i=i.dispatch=b3.bind(null,ht,i),[y.memoizedState,i]},useRef:function(i){var c=Tr();return i={current:i},c.memoizedState=i},useState:Lk,useDebugValue:hf,useDeferredValue:function(i){return Tr().memoizedState=i},useTransition:function(){var i=Lk(!1),c=i[0];return i=x3.bind(null,i[1]),Tr().memoizedState=i,[c,i]},useMutableSource:function(){},useSyncExternalStore:function(i,c,m){var y=ht,j=Tr();if(ct){if(m===void 0)throw Error(n(407));m=m()}else{if(m=c(),$t===null)throw Error(n(349));(wa&30)!==0||Rk(y,c,m)}j.memoizedState=m;var C={value:m,getSnapshot:c};return j.queue=C,Dk($k.bind(null,y,C,i),[i]),y.flags|=2048,rl(9,Mk.bind(null,y,C,m,c),void 0,null),m},useId:function(){var i=Tr(),c=$t.identifierPrefix;if(ct){var m=ns,y=ts;m=(y&~(1<<32-nn(y)-1)).toString(32)+m,c=":"+c+"R"+m,m=tl++,0<m&&(c+="H"+m.toString(32)),c+=":"}else m=v3++,c=":"+c+"r"+m.toString(32)+":";return i.memoizedState=c},unstable_isNewReconciler:!1},j3={readContext:An,useCallback:zk,useContext:An,useEffect:df,useImperativeHandle:Uk,useInsertionEffect:Fk,useLayoutEffect:Bk,useMemo:Wk,useReducer:cf,useRef:Pk,useState:function(){return cf(nl)},useDebugValue:hf,useDeferredValue:function(i){var c=Rn();return Hk(c,jt.memoizedState,i)},useTransition:function(){var i=cf(nl)[0],c=Rn().memoizedState;return[i,c]},useMutableSource:Tk,useSyncExternalStore:Ak,useId:Vk,unstable_isNewReconciler:!1},S3={readContext:An,useCallback:zk,useContext:An,useEffect:df,useImperativeHandle:Uk,useInsertionEffect:Fk,useLayoutEffect:Bk,useMemo:Wk,useReducer:uf,useRef:Pk,useState:function(){return uf(nl)},useDebugValue:hf,useDeferredValue:function(i){var c=Rn();return jt===null?c.memoizedState=i:Hk(c,jt.memoizedState,i)},useTransition:function(){var i=uf(nl)[0],c=Rn().memoizedState;return[i,c]},useMutableSource:Tk,useSyncExternalStore:Ak,useId:Vk,unstable_isNewReconciler:!1};function Jn(i,c){if(i&&i.defaultProps){c=W({},c),i=i.defaultProps;for(var m in i)c[m]===void 0&&(c[m]=i[m]);return c}return c}function ff(i,c,m,y){c=i.memoizedState,m=m(y,c),m=m==null?c:W({},c,m),i.memoizedState=m,i.lanes===0&&(i.updateQueue.baseState=m)}var zc={isMounted:function(i){return(i=i._reactInternals)?pn(i)===i:!1},enqueueSetState:function(i,c,m){i=i._reactInternals;var y=Jt(),j=Bs(i),C=ss(y,j);C.payload=c,m!=null&&(C.callback=m),c=Ls(i,C,j),c!==null&&(tr(c,i,j,y),Oc(c,i,j))},enqueueReplaceState:function(i,c,m){i=i._reactInternals;var y=Jt(),j=Bs(i),C=ss(y,j);C.tag=1,C.payload=c,m!=null&&(C.callback=m),c=Ls(i,C,j),c!==null&&(tr(c,i,j,y),Oc(c,i,j))},enqueueForceUpdate:function(i,c){i=i._reactInternals;var m=Jt(),y=Bs(i),j=ss(m,y);j.tag=2,c!=null&&(j.callback=c),c=Ls(i,j,y),c!==null&&(tr(c,i,y,m),Oc(c,i,y))}};function Xk(i,c,m,y,j,C,U){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(y,C,U):c.prototype&&c.prototype.isPureReactComponent?!zi(m,y)||!zi(j,C):!0}function Zk(i,c,m){var y=!1,j=$s,C=c.contextType;return typeof C=="object"&&C!==null?C=An(C):(j=sn(c)?fa:Ht.current,y=c.contextTypes,C=(y=y!=null)?mo(i,j):$s),c=new c(m,C),i.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,c.updater=zc,i.stateNode=c,c._reactInternals=i,y&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=j,i.__reactInternalMemoizedMaskedChildContext=C),c}function Jk(i,c,m,y){i=c.state,typeof c.componentWillReceiveProps=="function"&&c.componentWillReceiveProps(m,y),typeof c.UNSAFE_componentWillReceiveProps=="function"&&c.UNSAFE_componentWillReceiveProps(m,y),c.state!==i&&zc.enqueueReplaceState(c,c.state,null)}function pf(i,c,m,y){var j=i.stateNode;j.props=m,j.state=i.memoizedState,j.refs={},Qh(i);var C=c.contextType;typeof C=="object"&&C!==null?j.context=An(C):(C=sn(c)?fa:Ht.current,j.context=mo(i,C)),j.state=i.memoizedState,C=c.getDerivedStateFromProps,typeof C=="function"&&(ff(i,c,C,m),j.state=i.memoizedState),typeof c.getDerivedStateFromProps=="function"||typeof j.getSnapshotBeforeUpdate=="function"||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(c=j.state,typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount(),c!==j.state&&zc.enqueueReplaceState(j,j.state,null),Lc(i,m,j,y),j.state=i.memoizedState),typeof j.componentDidMount=="function"&&(i.flags|=4194308)}function No(i,c){try{var m="",y=c;do m+=G(y),y=y.return;while(y);var j=m}catch(C){j=`
39
+ Error generating stack: `+C.message+`
40
+ `+C.stack}return{value:i,source:c,stack:j,digest:null}}function mf(i,c,m){return{value:i,source:null,stack:m??null,digest:c??null}}function gf(i,c){try{console.error(c.value)}catch(m){setTimeout(function(){throw m})}}var _3=typeof WeakMap=="function"?WeakMap:Map;function Qk(i,c,m){m=ss(-1,m),m.tag=3,m.payload={element:null};var y=c.value;return m.callback=function(){Xc||(Xc=!0,Rf=y),gf(i,c)},m}function e1(i,c,m){m=ss(-1,m),m.tag=3;var y=i.type.getDerivedStateFromError;if(typeof y=="function"){var j=c.value;m.payload=function(){return y(j)},m.callback=function(){gf(i,c)}}var C=i.stateNode;return C!==null&&typeof C.componentDidCatch=="function"&&(m.callback=function(){gf(i,c),typeof y!="function"&&(Ds===null?Ds=new Set([this]):Ds.add(this));var U=c.stack;this.componentDidCatch(c.value,{componentStack:U!==null?U:""})}),m}function t1(i,c,m){var y=i.pingCache;if(y===null){y=i.pingCache=new _3;var j=new Set;y.set(c,j)}else j=y.get(c),j===void 0&&(j=new Set,y.set(c,j));j.has(m)||(j.add(m),i=B3.bind(null,i,c,m),c.then(i,i))}function n1(i){do{var c;if((c=i.tag===13)&&(c=i.memoizedState,c=c!==null?c.dehydrated!==null:!0),c)return i;i=i.return}while(i!==null);return null}function r1(i,c,m,y,j){return(i.mode&1)===0?(i===c?i.flags|=65536:(i.flags|=128,m.flags|=131072,m.flags&=-52805,m.tag===1&&(m.alternate===null?m.tag=17:(c=ss(-1,1),c.tag=2,Ls(m,c,1))),m.lanes|=1),i):(i.flags|=65536,i.lanes=j,i)}var E3=E.ReactCurrentOwner,an=!1;function Zt(i,c,m,y){c.child=i===null?Nk(c,null,m,y):vo(c,i.child,m,y)}function s1(i,c,m,y,j){m=m.render;var C=c.ref;return bo(c,j),y=of(i,c,m,y,C,j),m=lf(),i!==null&&!an?(c.updateQueue=i.updateQueue,c.flags&=-2053,i.lanes&=~j,as(i,c,j)):(ct&&m&&zh(c),c.flags|=1,Zt(i,c,y,j),c.child)}function a1(i,c,m,y,j){if(i===null){var C=m.type;return typeof C=="function"&&!Df(C)&&C.defaultProps===void 0&&m.compare===null&&m.defaultProps===void 0?(c.tag=15,c.type=C,o1(i,c,C,y,j)):(i=nu(m.type,null,y,c,c.mode,j),i.ref=c.ref,i.return=c,c.child=i)}if(C=i.child,(i.lanes&j)===0){var U=C.memoizedProps;if(m=m.compare,m=m!==null?m:zi,m(U,y)&&i.ref===c.ref)return as(i,c,j)}return c.flags|=1,i=Us(C,y),i.ref=c.ref,i.return=c,c.child=i}function o1(i,c,m,y,j){if(i!==null){var C=i.memoizedProps;if(zi(C,y)&&i.ref===c.ref)if(an=!1,c.pendingProps=y=C,(i.lanes&j)!==0)(i.flags&131072)!==0&&(an=!0);else return c.lanes=i.lanes,as(i,c,j)}return yf(i,c,m,y,j)}function i1(i,c,m){var y=c.pendingProps,j=y.children,C=i!==null?i.memoizedState:null;if(y.mode==="hidden")if((c.mode&1)===0)c.memoizedState={baseLanes:0,cachePool:null,transitions:null},tt(So,yn),yn|=m;else{if((m&1073741824)===0)return i=C!==null?C.baseLanes|m:m,c.lanes=c.childLanes=1073741824,c.memoizedState={baseLanes:i,cachePool:null,transitions:null},c.updateQueue=null,tt(So,yn),yn|=i,null;c.memoizedState={baseLanes:0,cachePool:null,transitions:null},y=C!==null?C.baseLanes:m,tt(So,yn),yn|=y}else C!==null?(y=C.baseLanes|m,c.memoizedState=null):y=m,tt(So,yn),yn|=y;return Zt(i,c,j,m),c.child}function l1(i,c){var m=c.ref;(i===null&&m!==null||i!==null&&i.ref!==m)&&(c.flags|=512,c.flags|=2097152)}function yf(i,c,m,y,j){var C=sn(m)?fa:Ht.current;return C=mo(c,C),bo(c,j),m=of(i,c,m,y,C,j),y=lf(),i!==null&&!an?(c.updateQueue=i.updateQueue,c.flags&=-2053,i.lanes&=~j,as(i,c,j)):(ct&&y&&zh(c),c.flags|=1,Zt(i,c,m,j),c.child)}function c1(i,c,m,y,j){if(sn(m)){var C=!0;Ec(c)}else C=!1;if(bo(c,j),c.stateNode===null)Hc(i,c),Zk(c,m,y),pf(c,m,y,j),y=!0;else if(i===null){var U=c.stateNode,Q=c.memoizedProps;U.props=Q;var te=U.context,ce=m.contextType;typeof ce=="object"&&ce!==null?ce=An(ce):(ce=sn(m)?fa:Ht.current,ce=mo(c,ce));var ye=m.getDerivedStateFromProps,xe=typeof ye=="function"||typeof U.getSnapshotBeforeUpdate=="function";xe||typeof U.UNSAFE_componentWillReceiveProps!="function"&&typeof U.componentWillReceiveProps!="function"||(Q!==y||te!==ce)&&Jk(c,U,y,ce),Os=!1;var ge=c.memoizedState;U.state=ge,Lc(c,y,U,j),te=c.memoizedState,Q!==y||ge!==te||rn.current||Os?(typeof ye=="function"&&(ff(c,m,ye,y),te=c.memoizedState),(Q=Os||Xk(c,m,Q,y,ge,te,ce))?(xe||typeof U.UNSAFE_componentWillMount!="function"&&typeof U.componentWillMount!="function"||(typeof U.componentWillMount=="function"&&U.componentWillMount(),typeof U.UNSAFE_componentWillMount=="function"&&U.UNSAFE_componentWillMount()),typeof U.componentDidMount=="function"&&(c.flags|=4194308)):(typeof U.componentDidMount=="function"&&(c.flags|=4194308),c.memoizedProps=y,c.memoizedState=te),U.props=y,U.state=te,U.context=ce,y=Q):(typeof U.componentDidMount=="function"&&(c.flags|=4194308),y=!1)}else{U=c.stateNode,Sk(i,c),Q=c.memoizedProps,ce=c.type===c.elementType?Q:Jn(c.type,Q),U.props=ce,xe=c.pendingProps,ge=U.context,te=m.contextType,typeof te=="object"&&te!==null?te=An(te):(te=sn(m)?fa:Ht.current,te=mo(c,te));var je=m.getDerivedStateFromProps;(ye=typeof je=="function"||typeof U.getSnapshotBeforeUpdate=="function")||typeof U.UNSAFE_componentWillReceiveProps!="function"&&typeof U.componentWillReceiveProps!="function"||(Q!==xe||ge!==te)&&Jk(c,U,y,te),Os=!1,ge=c.memoizedState,U.state=ge,Lc(c,y,U,j);var _e=c.memoizedState;Q!==xe||ge!==_e||rn.current||Os?(typeof je=="function"&&(ff(c,m,je,y),_e=c.memoizedState),(ce=Os||Xk(c,m,ce,y,ge,_e,te)||!1)?(ye||typeof U.UNSAFE_componentWillUpdate!="function"&&typeof U.componentWillUpdate!="function"||(typeof U.componentWillUpdate=="function"&&U.componentWillUpdate(y,_e,te),typeof U.UNSAFE_componentWillUpdate=="function"&&U.UNSAFE_componentWillUpdate(y,_e,te)),typeof U.componentDidUpdate=="function"&&(c.flags|=4),typeof U.getSnapshotBeforeUpdate=="function"&&(c.flags|=1024)):(typeof U.componentDidUpdate!="function"||Q===i.memoizedProps&&ge===i.memoizedState||(c.flags|=4),typeof U.getSnapshotBeforeUpdate!="function"||Q===i.memoizedProps&&ge===i.memoizedState||(c.flags|=1024),c.memoizedProps=y,c.memoizedState=_e),U.props=y,U.state=_e,U.context=te,y=ce):(typeof U.componentDidUpdate!="function"||Q===i.memoizedProps&&ge===i.memoizedState||(c.flags|=4),typeof U.getSnapshotBeforeUpdate!="function"||Q===i.memoizedProps&&ge===i.memoizedState||(c.flags|=1024),y=!1)}return wf(i,c,m,y,C,j)}function wf(i,c,m,y,j,C){l1(i,c);var U=(c.flags&128)!==0;if(!y&&!U)return j&&pk(c,m,!1),as(i,c,C);y=c.stateNode,E3.current=c;var Q=U&&typeof m.getDerivedStateFromError!="function"?null:y.render();return c.flags|=1,i!==null&&U?(c.child=vo(c,i.child,null,C),c.child=vo(c,null,Q,C)):Zt(i,c,Q,C),c.memoizedState=y.state,j&&pk(c,m,!0),c.child}function u1(i){var c=i.stateNode;c.pendingContext?hk(i,c.pendingContext,c.pendingContext!==c.context):c.context&&hk(i,c.context,!1),ef(i,c.containerInfo)}function d1(i,c,m,y,j){return wo(),Gh(j),c.flags|=256,Zt(i,c,m,y),c.child}var vf={dehydrated:null,treeContext:null,retryLane:0};function xf(i){return{baseLanes:i,cachePool:null,transitions:null}}function h1(i,c,m){var y=c.pendingProps,j=dt.current,C=!1,U=(c.flags&128)!==0,Q;if((Q=U)||(Q=i!==null&&i.memoizedState===null?!1:(j&2)!==0),Q?(C=!0,c.flags&=-129):(i===null||i.memoizedState!==null)&&(j|=1),tt(dt,j&1),i===null)return Vh(c),i=c.memoizedState,i!==null&&(i=i.dehydrated,i!==null)?((c.mode&1)===0?c.lanes=1:i.data==="$!"?c.lanes=8:c.lanes=1073741824,null):(U=y.children,i=y.fallback,C?(y=c.mode,C=c.child,U={mode:"hidden",children:U},(y&1)===0&&C!==null?(C.childLanes=0,C.pendingProps=U):C=ru(U,y,0,null),i=Na(i,y,m,null),C.return=c,i.return=c,C.sibling=i,c.child=C,c.child.memoizedState=xf(m),c.memoizedState=vf,i):bf(c,U));if(j=i.memoizedState,j!==null&&(Q=j.dehydrated,Q!==null))return C3(i,c,U,y,Q,j,m);if(C){C=y.fallback,U=c.mode,j=i.child,Q=j.sibling;var te={mode:"hidden",children:y.children};return(U&1)===0&&c.child!==j?(y=c.child,y.childLanes=0,y.pendingProps=te,c.deletions=null):(y=Us(j,te),y.subtreeFlags=j.subtreeFlags&14680064),Q!==null?C=Us(Q,C):(C=Na(C,U,m,null),C.flags|=2),C.return=c,y.return=c,y.sibling=C,c.child=y,y=C,C=c.child,U=i.child.memoizedState,U=U===null?xf(m):{baseLanes:U.baseLanes|m,cachePool:null,transitions:U.transitions},C.memoizedState=U,C.childLanes=i.childLanes&~m,c.memoizedState=vf,y}return C=i.child,i=C.sibling,y=Us(C,{mode:"visible",children:y.children}),(c.mode&1)===0&&(y.lanes=m),y.return=c,y.sibling=null,i!==null&&(m=c.deletions,m===null?(c.deletions=[i],c.flags|=16):m.push(i)),c.child=y,c.memoizedState=null,y}function bf(i,c){return c=ru({mode:"visible",children:c},i.mode,0,null),c.return=i,i.child=c}function Wc(i,c,m,y){return y!==null&&Gh(y),vo(c,i.child,null,m),i=bf(c,c.pendingProps.children),i.flags|=2,c.memoizedState=null,i}function C3(i,c,m,y,j,C,U){if(m)return c.flags&256?(c.flags&=-257,y=mf(Error(n(422))),Wc(i,c,U,y)):c.memoizedState!==null?(c.child=i.child,c.flags|=128,null):(C=y.fallback,j=c.mode,y=ru({mode:"visible",children:y.children},j,0,null),C=Na(C,j,U,null),C.flags|=2,y.return=c,C.return=c,y.sibling=C,c.child=y,(c.mode&1)!==0&&vo(c,i.child,null,U),c.child.memoizedState=xf(U),c.memoizedState=vf,C);if((c.mode&1)===0)return Wc(i,c,U,null);if(j.data==="$!"){if(y=j.nextSibling&&j.nextSibling.dataset,y)var Q=y.dgst;return y=Q,C=Error(n(419)),y=mf(C,y,void 0),Wc(i,c,U,y)}if(Q=(U&i.childLanes)!==0,an||Q){if(y=$t,y!==null){switch(U&-U){case 4:j=2;break;case 16:j=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:j=32;break;case 536870912:j=268435456;break;default:j=0}j=(j&(y.suspendedLanes|U))!==0?0:j,j!==0&&j!==C.retryLane&&(C.retryLane=j,rs(i,j),tr(y,i,j,-1))}return Pf(),y=mf(Error(n(421))),Wc(i,c,U,y)}return j.data==="$?"?(c.flags|=128,c.child=i.child,c=q3.bind(null,i),j._reactRetry=c,null):(i=C.treeContext,gn=Rs(j.nextSibling),mn=c,ct=!0,Zn=null,i!==null&&(Cn[Tn++]=ts,Cn[Tn++]=ns,Cn[Tn++]=pa,ts=i.id,ns=i.overflow,pa=c),c=bf(c,y.children),c.flags|=4096,c)}function f1(i,c,m){i.lanes|=c;var y=i.alternate;y!==null&&(y.lanes|=c),Zh(i.return,c,m)}function kf(i,c,m,y,j){var C=i.memoizedState;C===null?i.memoizedState={isBackwards:c,rendering:null,renderingStartTime:0,last:y,tail:m,tailMode:j}:(C.isBackwards=c,C.rendering=null,C.renderingStartTime=0,C.last=y,C.tail=m,C.tailMode=j)}function p1(i,c,m){var y=c.pendingProps,j=y.revealOrder,C=y.tail;if(Zt(i,c,y.children,m),y=dt.current,(y&2)!==0)y=y&1|2,c.flags|=128;else{if(i!==null&&(i.flags&128)!==0)e:for(i=c.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&f1(i,m,c);else if(i.tag===19)f1(i,m,c);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===c)break e;for(;i.sibling===null;){if(i.return===null||i.return===c)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}y&=1}if(tt(dt,y),(c.mode&1)===0)c.memoizedState=null;else switch(j){case"forwards":for(m=c.child,j=null;m!==null;)i=m.alternate,i!==null&&Pc(i)===null&&(j=m),m=m.sibling;m=j,m===null?(j=c.child,c.child=null):(j=m.sibling,m.sibling=null),kf(c,!1,j,m,C);break;case"backwards":for(m=null,j=c.child,c.child=null;j!==null;){if(i=j.alternate,i!==null&&Pc(i)===null){c.child=j;break}i=j.sibling,j.sibling=m,m=j,j=i}kf(c,!0,m,null,C);break;case"together":kf(c,!1,null,null,void 0);break;default:c.memoizedState=null}return c.child}function Hc(i,c){(c.mode&1)===0&&i!==null&&(i.alternate=null,c.alternate=null,c.flags|=2)}function as(i,c,m){if(i!==null&&(c.dependencies=i.dependencies),va|=c.lanes,(m&c.childLanes)===0)return null;if(i!==null&&c.child!==i.child)throw Error(n(153));if(c.child!==null){for(i=c.child,m=Us(i,i.pendingProps),c.child=m,m.return=c;i.sibling!==null;)i=i.sibling,m=m.sibling=Us(i,i.pendingProps),m.return=c;m.sibling=null}return c.child}function T3(i,c,m){switch(c.tag){case 3:u1(c),wo();break;case 5:Ck(c);break;case 1:sn(c.type)&&Ec(c);break;case 4:ef(c,c.stateNode.containerInfo);break;case 10:var y=c.type._context,j=c.memoizedProps.value;tt($c,y._currentValue),y._currentValue=j;break;case 13:if(y=c.memoizedState,y!==null)return y.dehydrated!==null?(tt(dt,dt.current&1),c.flags|=128,null):(m&c.child.childLanes)!==0?h1(i,c,m):(tt(dt,dt.current&1),i=as(i,c,m),i!==null?i.sibling:null);tt(dt,dt.current&1);break;case 19:if(y=(m&c.childLanes)!==0,(i.flags&128)!==0){if(y)return p1(i,c,m);c.flags|=128}if(j=c.memoizedState,j!==null&&(j.rendering=null,j.tail=null,j.lastEffect=null),tt(dt,dt.current),y)break;return null;case 22:case 23:return c.lanes=0,i1(i,c,m)}return as(i,c,m)}var m1,Nf,g1,y1;m1=function(i,c){for(var m=c.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===c)break;for(;m.sibling===null;){if(m.return===null||m.return===c)return;m=m.return}m.sibling.return=m.return,m=m.sibling}},Nf=function(){},g1=function(i,c,m,y){var j=i.memoizedProps;if(j!==y){i=c.stateNode,ya(Cr.current);var C=null;switch(m){case"input":j=ve(i,j),y=ve(i,y),C=[];break;case"select":j=W({},j,{value:void 0}),y=W({},y,{value:void 0}),C=[];break;case"textarea":j=Ie(i,j),y=Ie(i,y),C=[];break;default:typeof j.onClick!="function"&&typeof y.onClick=="function"&&(i.onclick=jc)}Rt(m,y);var U;m=null;for(ce in j)if(!y.hasOwnProperty(ce)&&j.hasOwnProperty(ce)&&j[ce]!=null)if(ce==="style"){var Q=j[ce];for(U in Q)Q.hasOwnProperty(U)&&(m||(m={}),m[U]="")}else ce!=="dangerouslySetInnerHTML"&&ce!=="children"&&ce!=="suppressContentEditableWarning"&&ce!=="suppressHydrationWarning"&&ce!=="autoFocus"&&(s.hasOwnProperty(ce)?C||(C=[]):(C=C||[]).push(ce,null));for(ce in y){var te=y[ce];if(Q=j!=null?j[ce]:void 0,y.hasOwnProperty(ce)&&te!==Q&&(te!=null||Q!=null))if(ce==="style")if(Q){for(U in Q)!Q.hasOwnProperty(U)||te&&te.hasOwnProperty(U)||(m||(m={}),m[U]="");for(U in te)te.hasOwnProperty(U)&&Q[U]!==te[U]&&(m||(m={}),m[U]=te[U])}else m||(C||(C=[]),C.push(ce,m)),m=te;else ce==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,Q=Q?Q.__html:void 0,te!=null&&Q!==te&&(C=C||[]).push(ce,te)):ce==="children"?typeof te!="string"&&typeof te!="number"||(C=C||[]).push(ce,""+te):ce!=="suppressContentEditableWarning"&&ce!=="suppressHydrationWarning"&&(s.hasOwnProperty(ce)?(te!=null&&ce==="onScroll"&&st("scroll",i),C||Q===te||(C=[])):(C=C||[]).push(ce,te))}m&&(C=C||[]).push("style",m);var ce=C;(c.updateQueue=ce)&&(c.flags|=4)}},y1=function(i,c,m,y){m!==y&&(c.flags|=4)};function sl(i,c){if(!ct)switch(i.tailMode){case"hidden":c=i.tail;for(var m=null;c!==null;)c.alternate!==null&&(m=c),c=c.sibling;m===null?i.tail=null:m.sibling=null;break;case"collapsed":m=i.tail;for(var y=null;m!==null;)m.alternate!==null&&(y=m),m=m.sibling;y===null?c||i.tail===null?i.tail=null:i.tail.sibling=null:y.sibling=null}}function Gt(i){var c=i.alternate!==null&&i.alternate.child===i.child,m=0,y=0;if(c)for(var j=i.child;j!==null;)m|=j.lanes|j.childLanes,y|=j.subtreeFlags&14680064,y|=j.flags&14680064,j.return=i,j=j.sibling;else for(j=i.child;j!==null;)m|=j.lanes|j.childLanes,y|=j.subtreeFlags,y|=j.flags,j.return=i,j=j.sibling;return i.subtreeFlags|=y,i.childLanes=m,c}function A3(i,c,m){var y=c.pendingProps;switch(Wh(c),c.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Gt(c),null;case 1:return sn(c.type)&&_c(),Gt(c),null;case 3:return y=c.stateNode,ko(),at(rn),at(Ht),rf(),y.pendingContext&&(y.context=y.pendingContext,y.pendingContext=null),(i===null||i.child===null)&&(Rc(c)?c.flags|=4:i===null||i.memoizedState.isDehydrated&&(c.flags&256)===0||(c.flags|=1024,Zn!==null&&(If(Zn),Zn=null))),Nf(i,c),Gt(c),null;case 5:tf(c);var j=ya(Qi.current);if(m=c.type,i!==null&&c.stateNode!=null)g1(i,c,m,y,j),i.ref!==c.ref&&(c.flags|=512,c.flags|=2097152);else{if(!y){if(c.stateNode===null)throw Error(n(166));return Gt(c),null}if(i=ya(Cr.current),Rc(c)){y=c.stateNode,m=c.type;var C=c.memoizedProps;switch(y[Er]=c,y[Ki]=C,i=(c.mode&1)!==0,m){case"dialog":st("cancel",y),st("close",y);break;case"iframe":case"object":case"embed":st("load",y);break;case"video":case"audio":for(j=0;j<Hi.length;j++)st(Hi[j],y);break;case"source":st("error",y);break;case"img":case"image":case"link":st("error",y),st("load",y);break;case"details":st("toggle",y);break;case"input":se(y,C),st("invalid",y);break;case"select":y._wrapperState={wasMultiple:!!C.multiple},st("invalid",y);break;case"textarea":Oe(y,C),st("invalid",y)}Rt(m,C),j=null;for(var U in C)if(C.hasOwnProperty(U)){var Q=C[U];U==="children"?typeof Q=="string"?y.textContent!==Q&&(C.suppressHydrationWarning!==!0&&Nc(y.textContent,Q,i),j=["children",Q]):typeof Q=="number"&&y.textContent!==""+Q&&(C.suppressHydrationWarning!==!0&&Nc(y.textContent,Q,i),j=["children",""+Q]):s.hasOwnProperty(U)&&Q!=null&&U==="onScroll"&&st("scroll",y)}switch(m){case"input":me(y),he(y,C,!0);break;case"textarea":me(y),Ye(y);break;case"select":case"option":break;default:typeof C.onClick=="function"&&(y.onclick=jc)}y=j,c.updateQueue=y,y!==null&&(c.flags|=4)}else{U=j.nodeType===9?j:j.ownerDocument,i==="http://www.w3.org/1999/xhtml"&&(i=Ve(m)),i==="http://www.w3.org/1999/xhtml"?m==="script"?(i=U.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof y.is=="string"?i=U.createElement(m,{is:y.is}):(i=U.createElement(m),m==="select"&&(U=i,y.multiple?U.multiple=!0:y.size&&(U.size=y.size))):i=U.createElementNS(i,m),i[Er]=c,i[Ki]=y,m1(i,c,!1,!1),c.stateNode=i;e:{switch(U=yt(m,y),m){case"dialog":st("cancel",i),st("close",i),j=y;break;case"iframe":case"object":case"embed":st("load",i),j=y;break;case"video":case"audio":for(j=0;j<Hi.length;j++)st(Hi[j],i);j=y;break;case"source":st("error",i),j=y;break;case"img":case"image":case"link":st("error",i),st("load",i),j=y;break;case"details":st("toggle",i),j=y;break;case"input":se(i,y),j=ve(i,y),st("invalid",i);break;case"option":j=y;break;case"select":i._wrapperState={wasMultiple:!!y.multiple},j=W({},y,{value:void 0}),st("invalid",i);break;case"textarea":Oe(i,y),j=Ie(i,y),st("invalid",i);break;default:j=y}Rt(m,j),Q=j;for(C in Q)if(Q.hasOwnProperty(C)){var te=Q[C];C==="style"?rt(i,te):C==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,te!=null&&it(i,te)):C==="children"?typeof te=="string"?(m!=="textarea"||te!=="")&&At(i,te):typeof te=="number"&&At(i,""+te):C!=="suppressContentEditableWarning"&&C!=="suppressHydrationWarning"&&C!=="autoFocus"&&(s.hasOwnProperty(C)?te!=null&&C==="onScroll"&&st("scroll",i):te!=null&&_(i,C,te,U))}switch(m){case"input":me(i),he(i,y,!1);break;case"textarea":me(i),Ye(i);break;case"option":y.value!=null&&i.setAttribute("value",""+ee(y.value));break;case"select":i.multiple=!!y.multiple,C=y.value,C!=null?Te(i,!!y.multiple,C,!1):y.defaultValue!=null&&Te(i,!!y.multiple,y.defaultValue,!0);break;default:typeof j.onClick=="function"&&(i.onclick=jc)}switch(m){case"button":case"input":case"select":case"textarea":y=!!y.autoFocus;break e;case"img":y=!0;break e;default:y=!1}}y&&(c.flags|=4)}c.ref!==null&&(c.flags|=512,c.flags|=2097152)}return Gt(c),null;case 6:if(i&&c.stateNode!=null)y1(i,c,i.memoizedProps,y);else{if(typeof y!="string"&&c.stateNode===null)throw Error(n(166));if(m=ya(Qi.current),ya(Cr.current),Rc(c)){if(y=c.stateNode,m=c.memoizedProps,y[Er]=c,(C=y.nodeValue!==m)&&(i=mn,i!==null))switch(i.tag){case 3:Nc(y.nodeValue,m,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&Nc(y.nodeValue,m,(i.mode&1)!==0)}C&&(c.flags|=4)}else y=(m.nodeType===9?m:m.ownerDocument).createTextNode(y),y[Er]=c,c.stateNode=y}return Gt(c),null;case 13:if(at(dt),y=c.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(ct&&gn!==null&&(c.mode&1)!==0&&(c.flags&128)===0)xk(),wo(),c.flags|=98560,C=!1;else if(C=Rc(c),y!==null&&y.dehydrated!==null){if(i===null){if(!C)throw Error(n(318));if(C=c.memoizedState,C=C!==null?C.dehydrated:null,!C)throw Error(n(317));C[Er]=c}else wo(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;Gt(c),C=!1}else Zn!==null&&(If(Zn),Zn=null),C=!0;if(!C)return c.flags&65536?c:null}return(c.flags&128)!==0?(c.lanes=m,c):(y=y!==null,y!==(i!==null&&i.memoizedState!==null)&&y&&(c.child.flags|=8192,(c.mode&1)!==0&&(i===null||(dt.current&1)!==0?St===0&&(St=3):Pf())),c.updateQueue!==null&&(c.flags|=4),Gt(c),null);case 4:return ko(),Nf(i,c),i===null&&Vi(c.stateNode.containerInfo),Gt(c),null;case 10:return Xh(c.type._context),Gt(c),null;case 17:return sn(c.type)&&_c(),Gt(c),null;case 19:if(at(dt),C=c.memoizedState,C===null)return Gt(c),null;if(y=(c.flags&128)!==0,U=C.rendering,U===null)if(y)sl(C,!1);else{if(St!==0||i!==null&&(i.flags&128)!==0)for(i=c.child;i!==null;){if(U=Pc(i),U!==null){for(c.flags|=128,sl(C,!1),y=U.updateQueue,y!==null&&(c.updateQueue=y,c.flags|=4),c.subtreeFlags=0,y=m,m=c.child;m!==null;)C=m,i=y,C.flags&=14680066,U=C.alternate,U===null?(C.childLanes=0,C.lanes=i,C.child=null,C.subtreeFlags=0,C.memoizedProps=null,C.memoizedState=null,C.updateQueue=null,C.dependencies=null,C.stateNode=null):(C.childLanes=U.childLanes,C.lanes=U.lanes,C.child=U.child,C.subtreeFlags=0,C.deletions=null,C.memoizedProps=U.memoizedProps,C.memoizedState=U.memoizedState,C.updateQueue=U.updateQueue,C.type=U.type,i=U.dependencies,C.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),m=m.sibling;return tt(dt,dt.current&1|2),c.child}i=i.sibling}C.tail!==null&&Qe()>_o&&(c.flags|=128,y=!0,sl(C,!1),c.lanes=4194304)}else{if(!y)if(i=Pc(U),i!==null){if(c.flags|=128,y=!0,m=i.updateQueue,m!==null&&(c.updateQueue=m,c.flags|=4),sl(C,!0),C.tail===null&&C.tailMode==="hidden"&&!U.alternate&&!ct)return Gt(c),null}else 2*Qe()-C.renderingStartTime>_o&&m!==1073741824&&(c.flags|=128,y=!0,sl(C,!1),c.lanes=4194304);C.isBackwards?(U.sibling=c.child,c.child=U):(m=C.last,m!==null?m.sibling=U:c.child=U,C.last=U)}return C.tail!==null?(c=C.tail,C.rendering=c,C.tail=c.sibling,C.renderingStartTime=Qe(),c.sibling=null,m=dt.current,tt(dt,y?m&1|2:m&1),c):(Gt(c),null);case 22:case 23:return Lf(),y=c.memoizedState!==null,i!==null&&i.memoizedState!==null!==y&&(c.flags|=8192),y&&(c.mode&1)!==0?(yn&1073741824)!==0&&(Gt(c),c.subtreeFlags&6&&(c.flags|=8192)):Gt(c),null;case 24:return null;case 25:return null}throw Error(n(156,c.tag))}function R3(i,c){switch(Wh(c),c.tag){case 1:return sn(c.type)&&_c(),i=c.flags,i&65536?(c.flags=i&-65537|128,c):null;case 3:return ko(),at(rn),at(Ht),rf(),i=c.flags,(i&65536)!==0&&(i&128)===0?(c.flags=i&-65537|128,c):null;case 5:return tf(c),null;case 13:if(at(dt),i=c.memoizedState,i!==null&&i.dehydrated!==null){if(c.alternate===null)throw Error(n(340));wo()}return i=c.flags,i&65536?(c.flags=i&-65537|128,c):null;case 19:return at(dt),null;case 4:return ko(),null;case 10:return Xh(c.type._context),null;case 22:case 23:return Lf(),null;case 24:return null;default:return null}}var Vc=!1,Kt=!1,M3=typeof WeakSet=="function"?WeakSet:Set,Se=null;function jo(i,c){var m=i.ref;if(m!==null)if(typeof m=="function")try{m(null)}catch(y){pt(i,c,y)}else m.current=null}function jf(i,c,m){try{m()}catch(y){pt(i,c,y)}}var w1=!1;function $3(i,c){if(Oh=Ss,i=X0(),Eh(i)){if("selectionStart"in i)var m={start:i.selectionStart,end:i.selectionEnd};else e:{m=(m=i.ownerDocument)&&m.defaultView||window;var y=m.getSelection&&m.getSelection();if(y&&y.rangeCount!==0){m=y.anchorNode;var j=y.anchorOffset,C=y.focusNode;y=y.focusOffset;try{m.nodeType,C.nodeType}catch{m=null;break e}var U=0,Q=-1,te=-1,ce=0,ye=0,xe=i,ge=null;t:for(;;){for(var je;xe!==m||j!==0&&xe.nodeType!==3||(Q=U+j),xe!==C||y!==0&&xe.nodeType!==3||(te=U+y),xe.nodeType===3&&(U+=xe.nodeValue.length),(je=xe.firstChild)!==null;)ge=xe,xe=je;for(;;){if(xe===i)break t;if(ge===m&&++ce===j&&(Q=U),ge===C&&++ye===y&&(te=U),(je=xe.nextSibling)!==null)break;xe=ge,ge=xe.parentNode}xe=je}m=Q===-1||te===-1?null:{start:Q,end:te}}else m=null}m=m||{start:0,end:0}}else m=null;for(Lh={focusedElem:i,selectionRange:m},Ss=!1,Se=c;Se!==null;)if(c=Se,i=c.child,(c.subtreeFlags&1028)!==0&&i!==null)i.return=c,Se=i;else for(;Se!==null;){c=Se;try{var _e=c.alternate;if((c.flags&1024)!==0)switch(c.tag){case 0:case 11:case 15:break;case 1:if(_e!==null){var Ee=_e.memoizedProps,wt=_e.memoizedState,oe=c.stateNode,ne=oe.getSnapshotBeforeUpdate(c.elementType===c.type?Ee:Jn(c.type,Ee),wt);oe.__reactInternalSnapshotBeforeUpdate=ne}break;case 3:var le=c.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(be){pt(c,c.return,be)}if(i=c.sibling,i!==null){i.return=c.return,Se=i;break}Se=c.return}return _e=w1,w1=!1,_e}function al(i,c,m){var y=c.updateQueue;if(y=y!==null?y.lastEffect:null,y!==null){var j=y=y.next;do{if((j.tag&i)===i){var C=j.destroy;j.destroy=void 0,C!==void 0&&jf(c,m,C)}j=j.next}while(j!==y)}}function Gc(i,c){if(c=c.updateQueue,c=c!==null?c.lastEffect:null,c!==null){var m=c=c.next;do{if((m.tag&i)===i){var y=m.create;m.destroy=y()}m=m.next}while(m!==c)}}function Sf(i){var c=i.ref;if(c!==null){var m=i.stateNode;switch(i.tag){case 5:i=m;break;default:i=m}typeof c=="function"?c(i):c.current=i}}function v1(i){var c=i.alternate;c!==null&&(i.alternate=null,v1(c)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(c=i.stateNode,c!==null&&(delete c[Er],delete c[Ki],delete c[Bh],delete c[m3],delete c[g3])),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 x1(i){return i.tag===5||i.tag===3||i.tag===4}function b1(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||x1(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 _f(i,c,m){var y=i.tag;if(y===5||y===6)i=i.stateNode,c?m.nodeType===8?m.parentNode.insertBefore(i,c):m.insertBefore(i,c):(m.nodeType===8?(c=m.parentNode,c.insertBefore(i,m)):(c=m,c.appendChild(i)),m=m._reactRootContainer,m!=null||c.onclick!==null||(c.onclick=jc));else if(y!==4&&(i=i.child,i!==null))for(_f(i,c,m),i=i.sibling;i!==null;)_f(i,c,m),i=i.sibling}function Ef(i,c,m){var y=i.tag;if(y===5||y===6)i=i.stateNode,c?m.insertBefore(i,c):m.appendChild(i);else if(y!==4&&(i=i.child,i!==null))for(Ef(i,c,m),i=i.sibling;i!==null;)Ef(i,c,m),i=i.sibling}var Ft=null,Qn=!1;function Ps(i,c,m){for(m=m.child;m!==null;)k1(i,c,m),m=m.sibling}function k1(i,c,m){if(Xt&&typeof Xt.onCommitFiberUnmount=="function")try{Xt.onCommitFiberUnmount(Yr,m)}catch{}switch(m.tag){case 5:Kt||jo(m,c);case 6:var y=Ft,j=Qn;Ft=null,Ps(i,c,m),Ft=y,Qn=j,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?Fh(i.parentNode,m):i.nodeType===1&&Fh(i,m),js(i)):Fh(Ft,m.stateNode));break;case 4:y=Ft,j=Qn,Ft=m.stateNode.containerInfo,Qn=!0,Ps(i,c,m),Ft=y,Qn=j;break;case 0:case 11:case 14:case 15:if(!Kt&&(y=m.updateQueue,y!==null&&(y=y.lastEffect,y!==null))){j=y=y.next;do{var C=j,U=C.destroy;C=C.tag,U!==void 0&&((C&2)!==0||(C&4)!==0)&&jf(m,c,U),j=j.next}while(j!==y)}Ps(i,c,m);break;case 1:if(!Kt&&(jo(m,c),y=m.stateNode,typeof y.componentWillUnmount=="function"))try{y.props=m.memoizedProps,y.state=m.memoizedState,y.componentWillUnmount()}catch(Q){pt(m,c,Q)}Ps(i,c,m);break;case 21:Ps(i,c,m);break;case 22:m.mode&1?(Kt=(y=Kt)||m.memoizedState!==null,Ps(i,c,m),Kt=y):Ps(i,c,m);break;default:Ps(i,c,m)}}function N1(i){var c=i.updateQueue;if(c!==null){i.updateQueue=null;var m=i.stateNode;m===null&&(m=i.stateNode=new M3),c.forEach(function(y){var j=U3.bind(null,i,y);m.has(y)||(m.add(y),y.then(j,j))})}}function er(i,c){var m=c.deletions;if(m!==null)for(var y=0;y<m.length;y++){var j=m[y];try{var C=i,U=c,Q=U;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));k1(C,U,j),Ft=null,Qn=!1;var te=j.alternate;te!==null&&(te.return=null),j.return=null}catch(ce){pt(j,c,ce)}}if(c.subtreeFlags&12854)for(c=c.child;c!==null;)j1(c,i),c=c.sibling}function j1(i,c){var m=i.alternate,y=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(er(c,i),Ar(i),y&4){try{al(3,i,i.return),Gc(3,i)}catch(Ee){pt(i,i.return,Ee)}try{al(5,i,i.return)}catch(Ee){pt(i,i.return,Ee)}}break;case 1:er(c,i),Ar(i),y&512&&m!==null&&jo(m,m.return);break;case 5:if(er(c,i),Ar(i),y&512&&m!==null&&jo(m,m.return),i.flags&32){var j=i.stateNode;try{At(j,"")}catch(Ee){pt(i,i.return,Ee)}}if(y&4&&(j=i.stateNode,j!=null)){var C=i.memoizedProps,U=m!==null?m.memoizedProps:C,Q=i.type,te=i.updateQueue;if(i.updateQueue=null,te!==null)try{Q==="input"&&C.type==="radio"&&C.name!=null&&ke(j,C),yt(Q,U);var ce=yt(Q,C);for(U=0;U<te.length;U+=2){var ye=te[U],xe=te[U+1];ye==="style"?rt(j,xe):ye==="dangerouslySetInnerHTML"?it(j,xe):ye==="children"?At(j,xe):_(j,ye,xe,ce)}switch(Q){case"input":pe(j,C);break;case"textarea":He(j,C);break;case"select":var ge=j._wrapperState.wasMultiple;j._wrapperState.wasMultiple=!!C.multiple;var je=C.value;je!=null?Te(j,!!C.multiple,je,!1):ge!==!!C.multiple&&(C.defaultValue!=null?Te(j,!!C.multiple,C.defaultValue,!0):Te(j,!!C.multiple,C.multiple?[]:"",!1))}j[Ki]=C}catch(Ee){pt(i,i.return,Ee)}}break;case 6:if(er(c,i),Ar(i),y&4){if(i.stateNode===null)throw Error(n(162));j=i.stateNode,C=i.memoizedProps;try{j.nodeValue=C}catch(Ee){pt(i,i.return,Ee)}}break;case 3:if(er(c,i),Ar(i),y&4&&m!==null&&m.memoizedState.isDehydrated)try{js(c.containerInfo)}catch(Ee){pt(i,i.return,Ee)}break;case 4:er(c,i),Ar(i);break;case 13:er(c,i),Ar(i),j=i.child,j.flags&8192&&(C=j.memoizedState!==null,j.stateNode.isHidden=C,!C||j.alternate!==null&&j.alternate.memoizedState!==null||(Af=Qe())),y&4&&N1(i);break;case 22:if(ye=m!==null&&m.memoizedState!==null,i.mode&1?(Kt=(ce=Kt)||ye,er(c,i),Kt=ce):er(c,i),Ar(i),y&8192){if(ce=i.memoizedState!==null,(i.stateNode.isHidden=ce)&&!ye&&(i.mode&1)!==0)for(Se=i,ye=i.child;ye!==null;){for(xe=Se=ye;Se!==null;){switch(ge=Se,je=ge.child,ge.tag){case 0:case 11:case 14:case 15:al(4,ge,ge.return);break;case 1:jo(ge,ge.return);var _e=ge.stateNode;if(typeof _e.componentWillUnmount=="function"){y=ge,m=ge.return;try{c=y,_e.props=c.memoizedProps,_e.state=c.memoizedState,_e.componentWillUnmount()}catch(Ee){pt(y,m,Ee)}}break;case 5:jo(ge,ge.return);break;case 22:if(ge.memoizedState!==null){E1(xe);continue}}je!==null?(je.return=ge,Se=je):E1(xe)}ye=ye.sibling}e:for(ye=null,xe=i;;){if(xe.tag===5){if(ye===null){ye=xe;try{j=xe.stateNode,ce?(C=j.style,typeof C.setProperty=="function"?C.setProperty("display","none","important"):C.display="none"):(Q=xe.stateNode,te=xe.memoizedProps.style,U=te!=null&&te.hasOwnProperty("display")?te.display:null,Q.style.display=Je("display",U))}catch(Ee){pt(i,i.return,Ee)}}}else if(xe.tag===6){if(ye===null)try{xe.stateNode.nodeValue=ce?"":xe.memoizedProps}catch(Ee){pt(i,i.return,Ee)}}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;ye===xe&&(ye=null),xe=xe.return}ye===xe&&(ye=null),xe.sibling.return=xe.return,xe=xe.sibling}}break;case 19:er(c,i),Ar(i),y&4&&N1(i);break;case 21:break;default:er(c,i),Ar(i)}}function Ar(i){var c=i.flags;if(c&2){try{e:{for(var m=i.return;m!==null;){if(x1(m)){var y=m;break e}m=m.return}throw Error(n(160))}switch(y.tag){case 5:var j=y.stateNode;y.flags&32&&(At(j,""),y.flags&=-33);var C=b1(i);Ef(i,C,j);break;case 3:case 4:var U=y.stateNode.containerInfo,Q=b1(i);_f(i,Q,U);break;default:throw Error(n(161))}}catch(te){pt(i,i.return,te)}i.flags&=-3}c&4096&&(i.flags&=-4097)}function I3(i,c,m){Se=i,S1(i)}function S1(i,c,m){for(var y=(i.mode&1)!==0;Se!==null;){var j=Se,C=j.child;if(j.tag===22&&y){var U=j.memoizedState!==null||Vc;if(!U){var Q=j.alternate,te=Q!==null&&Q.memoizedState!==null||Kt;Q=Vc;var ce=Kt;if(Vc=U,(Kt=te)&&!ce)for(Se=j;Se!==null;)U=Se,te=U.child,U.tag===22&&U.memoizedState!==null?C1(j):te!==null?(te.return=U,Se=te):C1(j);for(;C!==null;)Se=C,S1(C),C=C.sibling;Se=j,Vc=Q,Kt=ce}_1(i)}else(j.subtreeFlags&8772)!==0&&C!==null?(C.return=j,Se=C):_1(i)}}function _1(i){for(;Se!==null;){var c=Se;if((c.flags&8772)!==0){var m=c.alternate;try{if((c.flags&8772)!==0)switch(c.tag){case 0:case 11:case 15:Kt||Gc(5,c);break;case 1:var y=c.stateNode;if(c.flags&4&&!Kt)if(m===null)y.componentDidMount();else{var j=c.elementType===c.type?m.memoizedProps:Jn(c.type,m.memoizedProps);y.componentDidUpdate(j,m.memoizedState,y.__reactInternalSnapshotBeforeUpdate)}var C=c.updateQueue;C!==null&&Ek(c,C,y);break;case 3:var U=c.updateQueue;if(U!==null){if(m=null,c.child!==null)switch(c.child.tag){case 5:m=c.child.stateNode;break;case 1:m=c.child.stateNode}Ek(c,U,m)}break;case 5:var Q=c.stateNode;if(m===null&&c.flags&4){m=Q;var te=c.memoizedProps;switch(c.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(c.memoizedState===null){var ce=c.alternate;if(ce!==null){var ye=ce.memoizedState;if(ye!==null){var xe=ye.dehydrated;xe!==null&&js(xe)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Kt||c.flags&512&&Sf(c)}catch(ge){pt(c,c.return,ge)}}if(c===i){Se=null;break}if(m=c.sibling,m!==null){m.return=c.return,Se=m;break}Se=c.return}}function E1(i){for(;Se!==null;){var c=Se;if(c===i){Se=null;break}var m=c.sibling;if(m!==null){m.return=c.return,Se=m;break}Se=c.return}}function C1(i){for(;Se!==null;){var c=Se;try{switch(c.tag){case 0:case 11:case 15:var m=c.return;try{Gc(4,c)}catch(te){pt(c,m,te)}break;case 1:var y=c.stateNode;if(typeof y.componentDidMount=="function"){var j=c.return;try{y.componentDidMount()}catch(te){pt(c,j,te)}}var C=c.return;try{Sf(c)}catch(te){pt(c,C,te)}break;case 5:var U=c.return;try{Sf(c)}catch(te){pt(c,U,te)}}}catch(te){pt(c,c.return,te)}if(c===i){Se=null;break}var Q=c.sibling;if(Q!==null){Q.return=c.return,Se=Q;break}Se=c.return}}var O3=Math.ceil,Kc=E.ReactCurrentDispatcher,Cf=E.ReactCurrentOwner,Mn=E.ReactCurrentBatchConfig,Ue=0,$t=null,xt=null,Bt=0,yn=0,So=Ms(0),St=0,ol=null,va=0,Yc=0,Tf=0,il=null,on=null,Af=0,_o=1/0,os=null,Xc=!1,Rf=null,Ds=null,Zc=!1,Fs=null,Jc=0,ll=0,Mf=null,Qc=-1,eu=0;function Jt(){return(Ue&6)!==0?Qe():Qc!==-1?Qc:Qc=Qe()}function Bs(i){return(i.mode&1)===0?1:(Ue&2)!==0&&Bt!==0?Bt&-Bt:w3.transition!==null?(eu===0&&(eu=fc()),eu):(i=ze,i!==0||(i=window.event,i=i===void 0?16:gc(i.type)),i)}function tr(i,c,m,y){if(50<ll)throw ll=0,Mf=null,Error(n(185));xs(i,m,y),((Ue&2)===0||i!==$t)&&(i===$t&&((Ue&2)===0&&(Yc|=m),St===4&&qs(i,Bt)),ln(i,y),m===1&&Ue===0&&(c.mode&1)===0&&(_o=Qe()+500,Cc&&Is()))}function ln(i,c){var m=i.callbackNode;Zr(i,c);var y=vs(i,i===$t?Bt:0);if(y===0)m!==null&&ys(m),i.callbackNode=null,i.callbackPriority=0;else if(c=y&-y,i.callbackPriority!==c){if(m!=null&&ys(m),c===1)i.tag===0?y3(A1.bind(null,i)):mk(A1.bind(null,i)),f3(function(){(Ue&6)===0&&Is()}),m=null;else{switch(Ai(y)){case 1:m=Kn;break;case 4:m=Kr;break;case 16:m=Yn;break;case 536870912:m=Za;break;default:m=Yn}m=D1(m,T1.bind(null,i))}i.callbackPriority=c,i.callbackNode=m}}function T1(i,c){if(Qc=-1,eu=0,(Ue&6)!==0)throw Error(n(327));var m=i.callbackNode;if(Eo()&&i.callbackNode!==m)return null;var y=vs(i,i===$t?Bt:0);if(y===0)return null;if((y&30)!==0||(y&i.expiredLanes)!==0||c)c=tu(i,y);else{c=y;var j=Ue;Ue|=2;var C=M1();($t!==i||Bt!==c)&&(os=null,_o=Qe()+500,ba(i,c));do try{D3();break}catch(Q){R1(i,Q)}while(!0);Yh(),Kc.current=C,Ue=j,xt!==null?c=0:($t=null,Bt=0,c=St)}if(c!==0){if(c===2&&(j=Ei(i),j!==0&&(y=j,c=$f(i,j))),c===1)throw m=ol,ba(i,0),qs(i,y),ln(i,Qe()),m;if(c===6)qs(i,y);else{if(j=i.current.alternate,(y&30)===0&&!L3(j)&&(c=tu(i,y),c===2&&(C=Ei(i),C!==0&&(y=C,c=$f(i,C))),c===1))throw m=ol,ba(i,0),qs(i,y),ln(i,Qe()),m;switch(i.finishedWork=j,i.finishedLanes=y,c){case 0:case 1:throw Error(n(345));case 2:ka(i,on,os);break;case 3:if(qs(i,y),(y&130023424)===y&&(c=Af+500-Qe(),10<c)){if(vs(i,0)!==0)break;if(j=i.suspendedLanes,(j&y)!==y){Jt(),i.pingedLanes|=i.suspendedLanes&j;break}i.timeoutHandle=Dh(ka.bind(null,i,on,os),c);break}ka(i,on,os);break;case 4:if(qs(i,y),(y&4194240)===y)break;for(c=i.eventTimes,j=-1;0<y;){var U=31-nn(y);C=1<<U,U=c[U],U>j&&(j=U),y&=~C}if(y=j,y=Qe()-y,y=(120>y?120:480>y?480:1080>y?1080:1920>y?1920:3e3>y?3e3:4320>y?4320:1960*O3(y/1960))-y,10<y){i.timeoutHandle=Dh(ka.bind(null,i,on,os),y);break}ka(i,on,os);break;case 5:ka(i,on,os);break;default:throw Error(n(329))}}}return ln(i,Qe()),i.callbackNode===m?T1.bind(null,i):null}function $f(i,c){var m=il;return i.current.memoizedState.isDehydrated&&(ba(i,c).flags|=256),i=tu(i,c),i!==2&&(c=on,on=m,c!==null&&If(c)),i}function If(i){on===null?on=i:on.push.apply(on,i)}function L3(i){for(var c=i;;){if(c.flags&16384){var m=c.updateQueue;if(m!==null&&(m=m.stores,m!==null))for(var y=0;y<m.length;y++){var j=m[y],C=j.getSnapshot;j=j.value;try{if(!Xn(C(),j))return!1}catch{return!1}}}if(m=c.child,c.subtreeFlags&16384&&m!==null)m.return=c,c=m;else{if(c===i)break;for(;c.sibling===null;){if(c.return===null||c.return===i)return!0;c=c.return}c.sibling.return=c.return,c=c.sibling}}return!0}function qs(i,c){for(c&=~Tf,c&=~Yc,i.suspendedLanes|=c,i.pingedLanes&=~c,i=i.expirationTimes;0<c;){var m=31-nn(c),y=1<<m;i[m]=-1,c&=~y}}function A1(i){if((Ue&6)!==0)throw Error(n(327));Eo();var c=vs(i,0);if((c&1)===0)return ln(i,Qe()),null;var m=tu(i,c);if(i.tag!==0&&m===2){var y=Ei(i);y!==0&&(c=y,m=$f(i,y))}if(m===1)throw m=ol,ba(i,0),qs(i,c),ln(i,Qe()),m;if(m===6)throw Error(n(345));return i.finishedWork=i.current.alternate,i.finishedLanes=c,ka(i,on,os),ln(i,Qe()),null}function Of(i,c){var m=Ue;Ue|=1;try{return i(c)}finally{Ue=m,Ue===0&&(_o=Qe()+500,Cc&&Is())}}function xa(i){Fs!==null&&Fs.tag===0&&(Ue&6)===0&&Eo();var c=Ue;Ue|=1;var m=Mn.transition,y=ze;try{if(Mn.transition=null,ze=1,i)return i()}finally{ze=y,Mn.transition=m,Ue=c,(Ue&6)===0&&Is()}}function Lf(){yn=So.current,at(So)}function ba(i,c){i.finishedWork=null,i.finishedLanes=0;var m=i.timeoutHandle;if(m!==-1&&(i.timeoutHandle=-1,h3(m)),xt!==null)for(m=xt.return;m!==null;){var y=m;switch(Wh(y),y.tag){case 1:y=y.type.childContextTypes,y!=null&&_c();break;case 3:ko(),at(rn),at(Ht),rf();break;case 5:tf(y);break;case 4:ko();break;case 13:at(dt);break;case 19:at(dt);break;case 10:Xh(y.type._context);break;case 22:case 23:Lf()}m=m.return}if($t=i,xt=i=Us(i.current,null),Bt=yn=c,St=0,ol=null,Tf=Yc=va=0,on=il=null,ga!==null){for(c=0;c<ga.length;c++)if(m=ga[c],y=m.interleaved,y!==null){m.interleaved=null;var j=y.next,C=m.pending;if(C!==null){var U=C.next;C.next=j,y.next=U}m.pending=y}ga=null}return i}function R1(i,c){do{var m=xt;try{if(Yh(),Dc.current=Uc,Fc){for(var y=ht.memoizedState;y!==null;){var j=y.queue;j!==null&&(j.pending=null),y=y.next}Fc=!1}if(wa=0,Mt=jt=ht=null,el=!1,tl=0,Cf.current=null,m===null||m.return===null){St=1,ol=c,xt=null;break}e:{var C=i,U=m.return,Q=m,te=c;if(c=Bt,Q.flags|=32768,te!==null&&typeof te=="object"&&typeof te.then=="function"){var ce=te,ye=Q,xe=ye.tag;if((ye.mode&1)===0&&(xe===0||xe===11||xe===15)){var ge=ye.alternate;ge?(ye.updateQueue=ge.updateQueue,ye.memoizedState=ge.memoizedState,ye.lanes=ge.lanes):(ye.updateQueue=null,ye.memoizedState=null)}var je=n1(U);if(je!==null){je.flags&=-257,r1(je,U,Q,C,c),je.mode&1&&t1(C,ce,c),c=je,te=ce;var _e=c.updateQueue;if(_e===null){var Ee=new Set;Ee.add(te),c.updateQueue=Ee}else _e.add(te);break e}else{if((c&1)===0){t1(C,ce,c),Pf();break e}te=Error(n(426))}}else if(ct&&Q.mode&1){var wt=n1(U);if(wt!==null){(wt.flags&65536)===0&&(wt.flags|=256),r1(wt,U,Q,C,c),Gh(No(te,Q));break e}}C=te=No(te,Q),St!==4&&(St=2),il===null?il=[C]:il.push(C),C=U;do{switch(C.tag){case 3:C.flags|=65536,c&=-c,C.lanes|=c;var oe=Qk(C,te,c);_k(C,oe);break e;case 1:Q=te;var ne=C.type,le=C.stateNode;if((C.flags&128)===0&&(typeof ne.getDerivedStateFromError=="function"||le!==null&&typeof le.componentDidCatch=="function"&&(Ds===null||!Ds.has(le)))){C.flags|=65536,c&=-c,C.lanes|=c;var be=e1(C,Q,c);_k(C,be);break e}}C=C.return}while(C!==null)}I1(m)}catch(Ce){c=Ce,xt===m&&m!==null&&(xt=m=m.return);continue}break}while(!0)}function M1(){var i=Kc.current;return Kc.current=Uc,i===null?Uc:i}function Pf(){(St===0||St===3||St===2)&&(St=4),$t===null||(va&268435455)===0&&(Yc&268435455)===0||qs($t,Bt)}function tu(i,c){var m=Ue;Ue|=2;var y=M1();($t!==i||Bt!==c)&&(os=null,ba(i,c));do try{P3();break}catch(j){R1(i,j)}while(!0);if(Yh(),Ue=m,Kc.current=y,xt!==null)throw Error(n(261));return $t=null,Bt=0,St}function P3(){for(;xt!==null;)$1(xt)}function D3(){for(;xt!==null&&!xr();)$1(xt)}function $1(i){var c=P1(i.alternate,i,yn);i.memoizedProps=i.pendingProps,c===null?I1(i):xt=c,Cf.current=null}function I1(i){var c=i;do{var m=c.alternate;if(i=c.return,(c.flags&32768)===0){if(m=A3(m,c,yn),m!==null){xt=m;return}}else{if(m=R3(m,c),m!==null){m.flags&=32767,xt=m;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{St=6,xt=null;return}}if(c=c.sibling,c!==null){xt=c;return}xt=c=i}while(c!==null);St===0&&(St=5)}function ka(i,c,m){var y=ze,j=Mn.transition;try{Mn.transition=null,ze=1,F3(i,c,m,y)}finally{Mn.transition=j,ze=y}return null}function F3(i,c,m,y){do Eo();while(Fs!==null);if((Ue&6)!==0)throw Error(n(327));m=i.finishedWork;var j=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 C=m.lanes|m.childLanes;if(bs(i,C),i===$t&&(xt=$t=null,Bt=0),(m.subtreeFlags&2064)===0&&(m.flags&2064)===0||Zc||(Zc=!0,D1(Yn,function(){return Eo(),null})),C=(m.flags&15990)!==0,(m.subtreeFlags&15990)!==0||C){C=Mn.transition,Mn.transition=null;var U=ze;ze=1;var Q=Ue;Ue|=4,Cf.current=null,$3(i,m),j1(m,i),a3(Lh),Ss=!!Oh,Lh=Oh=null,i.current=m,I3(m),Gn(),Ue=Q,ze=U,Mn.transition=C}else i.current=m;if(Zc&&(Zc=!1,Fs=i,Jc=j),C=i.pendingLanes,C===0&&(Ds=null),sa(m.stateNode),ln(i,Qe()),c!==null)for(y=i.onRecoverableError,m=0;m<c.length;m++)j=c[m],y(j.value,{componentStack:j.stack,digest:j.digest});if(Xc)throw Xc=!1,i=Rf,Rf=null,i;return(Jc&1)!==0&&i.tag!==0&&Eo(),C=i.pendingLanes,(C&1)!==0?i===Mf?ll++:(ll=0,Mf=i):ll=0,Is(),null}function Eo(){if(Fs!==null){var i=Ai(Jc),c=Mn.transition,m=ze;try{if(Mn.transition=null,ze=16>i?16:i,Fs===null)var y=!1;else{if(i=Fs,Fs=null,Jc=0,(Ue&6)!==0)throw Error(n(331));var j=Ue;for(Ue|=4,Se=i.current;Se!==null;){var C=Se,U=C.child;if((Se.flags&16)!==0){var Q=C.deletions;if(Q!==null){for(var te=0;te<Q.length;te++){var ce=Q[te];for(Se=ce;Se!==null;){var ye=Se;switch(ye.tag){case 0:case 11:case 15:al(8,ye,C)}var xe=ye.child;if(xe!==null)xe.return=ye,Se=xe;else for(;Se!==null;){ye=Se;var ge=ye.sibling,je=ye.return;if(v1(ye),ye===ce){Se=null;break}if(ge!==null){ge.return=je,Se=ge;break}Se=je}}}var _e=C.alternate;if(_e!==null){var Ee=_e.child;if(Ee!==null){_e.child=null;do{var wt=Ee.sibling;Ee.sibling=null,Ee=wt}while(Ee!==null)}}Se=C}}if((C.subtreeFlags&2064)!==0&&U!==null)U.return=C,Se=U;else e:for(;Se!==null;){if(C=Se,(C.flags&2048)!==0)switch(C.tag){case 0:case 11:case 15:al(9,C,C.return)}var oe=C.sibling;if(oe!==null){oe.return=C.return,Se=oe;break e}Se=C.return}}var ne=i.current;for(Se=ne;Se!==null;){U=Se;var le=U.child;if((U.subtreeFlags&2064)!==0&&le!==null)le.return=U,Se=le;else e:for(U=ne;Se!==null;){if(Q=Se,(Q.flags&2048)!==0)try{switch(Q.tag){case 0:case 11:case 15:Gc(9,Q)}}catch(Ce){pt(Q,Q.return,Ce)}if(Q===U){Se=null;break e}var be=Q.sibling;if(be!==null){be.return=Q.return,Se=be;break e}Se=Q.return}}if(Ue=j,Is(),Xt&&typeof Xt.onPostCommitFiberRoot=="function")try{Xt.onPostCommitFiberRoot(Yr,i)}catch{}y=!0}return y}finally{ze=m,Mn.transition=c}}return!1}function O1(i,c,m){c=No(m,c),c=Qk(i,c,1),i=Ls(i,c,1),c=Jt(),i!==null&&(xs(i,1,c),ln(i,c))}function pt(i,c,m){if(i.tag===3)O1(i,i,m);else for(;c!==null;){if(c.tag===3){O1(c,i,m);break}else if(c.tag===1){var y=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof y.componentDidCatch=="function"&&(Ds===null||!Ds.has(y))){i=No(m,i),i=e1(c,i,1),c=Ls(c,i,1),i=Jt(),c!==null&&(xs(c,1,i),ln(c,i));break}}c=c.return}}function B3(i,c,m){var y=i.pingCache;y!==null&&y.delete(c),c=Jt(),i.pingedLanes|=i.suspendedLanes&m,$t===i&&(Bt&m)===m&&(St===4||St===3&&(Bt&130023424)===Bt&&500>Qe()-Af?ba(i,0):Tf|=m),ln(i,c)}function L1(i,c){c===0&&((i.mode&1)===0?c=1:(c=aa,aa<<=1,(aa&130023424)===0&&(aa=4194304)));var m=Jt();i=rs(i,c),i!==null&&(xs(i,c,m),ln(i,m))}function q3(i){var c=i.memoizedState,m=0;c!==null&&(m=c.retryLane),L1(i,m)}function U3(i,c){var m=0;switch(i.tag){case 13:var y=i.stateNode,j=i.memoizedState;j!==null&&(m=j.retryLane);break;case 19:y=i.stateNode;break;default:throw Error(n(314))}y!==null&&y.delete(c),L1(i,m)}var P1;P1=function(i,c,m){if(i!==null)if(i.memoizedProps!==c.pendingProps||rn.current)an=!0;else{if((i.lanes&m)===0&&(c.flags&128)===0)return an=!1,T3(i,c,m);an=(i.flags&131072)!==0}else an=!1,ct&&(c.flags&1048576)!==0&&gk(c,Ac,c.index);switch(c.lanes=0,c.tag){case 2:var y=c.type;Hc(i,c),i=c.pendingProps;var j=mo(c,Ht.current);bo(c,m),j=of(null,c,y,i,j,m);var C=lf();return c.flags|=1,typeof j=="object"&&j!==null&&typeof j.render=="function"&&j.$$typeof===void 0?(c.tag=1,c.memoizedState=null,c.updateQueue=null,sn(y)?(C=!0,Ec(c)):C=!1,c.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,Qh(c),j.updater=zc,c.stateNode=j,j._reactInternals=c,pf(c,y,i,m),c=wf(null,c,y,!0,C,m)):(c.tag=0,ct&&C&&zh(c),Zt(null,c,j,m),c=c.child),c;case 16:y=c.elementType;e:{switch(Hc(i,c),i=c.pendingProps,j=y._init,y=j(y._payload),c.type=y,j=c.tag=W3(y),i=Jn(y,i),j){case 0:c=yf(null,c,y,i,m);break e;case 1:c=c1(null,c,y,i,m);break e;case 11:c=s1(null,c,y,i,m);break e;case 14:c=a1(null,c,y,Jn(y.type,i),m);break e}throw Error(n(306,y,""))}return c;case 0:return y=c.type,j=c.pendingProps,j=c.elementType===y?j:Jn(y,j),yf(i,c,y,j,m);case 1:return y=c.type,j=c.pendingProps,j=c.elementType===y?j:Jn(y,j),c1(i,c,y,j,m);case 3:e:{if(u1(c),i===null)throw Error(n(387));y=c.pendingProps,C=c.memoizedState,j=C.element,Sk(i,c),Lc(c,y,null,m);var U=c.memoizedState;if(y=U.element,C.isDehydrated)if(C={element:y,isDehydrated:!1,cache:U.cache,pendingSuspenseBoundaries:U.pendingSuspenseBoundaries,transitions:U.transitions},c.updateQueue.baseState=C,c.memoizedState=C,c.flags&256){j=No(Error(n(423)),c),c=d1(i,c,y,m,j);break e}else if(y!==j){j=No(Error(n(424)),c),c=d1(i,c,y,m,j);break e}else for(gn=Rs(c.stateNode.containerInfo.firstChild),mn=c,ct=!0,Zn=null,m=Nk(c,null,y,m),c.child=m;m;)m.flags=m.flags&-3|4096,m=m.sibling;else{if(wo(),y===j){c=as(i,c,m);break e}Zt(i,c,y,m)}c=c.child}return c;case 5:return Ck(c),i===null&&Vh(c),y=c.type,j=c.pendingProps,C=i!==null?i.memoizedProps:null,U=j.children,Ph(y,j)?U=null:C!==null&&Ph(y,C)&&(c.flags|=32),l1(i,c),Zt(i,c,U,m),c.child;case 6:return i===null&&Vh(c),null;case 13:return h1(i,c,m);case 4:return ef(c,c.stateNode.containerInfo),y=c.pendingProps,i===null?c.child=vo(c,null,y,m):Zt(i,c,y,m),c.child;case 11:return y=c.type,j=c.pendingProps,j=c.elementType===y?j:Jn(y,j),s1(i,c,y,j,m);case 7:return Zt(i,c,c.pendingProps,m),c.child;case 8:return Zt(i,c,c.pendingProps.children,m),c.child;case 12:return Zt(i,c,c.pendingProps.children,m),c.child;case 10:e:{if(y=c.type._context,j=c.pendingProps,C=c.memoizedProps,U=j.value,tt($c,y._currentValue),y._currentValue=U,C!==null)if(Xn(C.value,U)){if(C.children===j.children&&!rn.current){c=as(i,c,m);break e}}else for(C=c.child,C!==null&&(C.return=c);C!==null;){var Q=C.dependencies;if(Q!==null){U=C.child;for(var te=Q.firstContext;te!==null;){if(te.context===y){if(C.tag===1){te=ss(-1,m&-m),te.tag=2;var ce=C.updateQueue;if(ce!==null){ce=ce.shared;var ye=ce.pending;ye===null?te.next=te:(te.next=ye.next,ye.next=te),ce.pending=te}}C.lanes|=m,te=C.alternate,te!==null&&(te.lanes|=m),Zh(C.return,m,c),Q.lanes|=m;break}te=te.next}}else if(C.tag===10)U=C.type===c.type?null:C.child;else if(C.tag===18){if(U=C.return,U===null)throw Error(n(341));U.lanes|=m,Q=U.alternate,Q!==null&&(Q.lanes|=m),Zh(U,m,c),U=C.sibling}else U=C.child;if(U!==null)U.return=C;else for(U=C;U!==null;){if(U===c){U=null;break}if(C=U.sibling,C!==null){C.return=U.return,U=C;break}U=U.return}C=U}Zt(i,c,j.children,m),c=c.child}return c;case 9:return j=c.type,y=c.pendingProps.children,bo(c,m),j=An(j),y=y(j),c.flags|=1,Zt(i,c,y,m),c.child;case 14:return y=c.type,j=Jn(y,c.pendingProps),j=Jn(y.type,j),a1(i,c,y,j,m);case 15:return o1(i,c,c.type,c.pendingProps,m);case 17:return y=c.type,j=c.pendingProps,j=c.elementType===y?j:Jn(y,j),Hc(i,c),c.tag=1,sn(y)?(i=!0,Ec(c)):i=!1,bo(c,m),Zk(c,y,j),pf(c,y,j,m),wf(null,c,y,!0,i,m);case 19:return p1(i,c,m);case 22:return i1(i,c,m)}throw Error(n(156,c.tag))};function D1(i,c){return tn(i,c)}function z3(i,c,m,y){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=c,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=y,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function $n(i,c,m,y){return new z3(i,c,m,y)}function Df(i){return i=i.prototype,!(!i||!i.isReactComponent)}function W3(i){if(typeof i=="function")return Df(i)?1:0;if(i!=null){if(i=i.$$typeof,i===O)return 11;if(i===$)return 14}return 2}function Us(i,c){var m=i.alternate;return m===null?(m=$n(i.tag,c,i.key,i.mode),m.elementType=i.elementType,m.type=i.type,m.stateNode=i.stateNode,m.alternate=i,i.alternate=m):(m.pendingProps=c,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,c=i.dependencies,m.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext},m.sibling=i.sibling,m.index=i.index,m.ref=i.ref,m}function nu(i,c,m,y,j,C){var U=2;if(y=i,typeof i=="function")Df(i)&&(U=1);else if(typeof i=="string")U=5;else e:switch(i){case R:return Na(m.children,j,C,c);case B:U=8,j|=8;break;case P:return i=$n(12,m,c,j|2),i.elementType=P,i.lanes=C,i;case z:return i=$n(13,m,c,j),i.elementType=z,i.lanes=C,i;case M:return i=$n(19,m,c,j),i.elementType=M,i.lanes=C,i;case X:return ru(m,j,C,c);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case D:U=10;break e;case I:U=9;break e;case O:U=11;break e;case $:U=14;break e;case q:U=16,y=null;break e}throw Error(n(130,i==null?i:typeof i,""))}return c=$n(U,m,c,j),c.elementType=i,c.type=y,c.lanes=C,c}function Na(i,c,m,y){return i=$n(7,i,y,c),i.lanes=m,i}function ru(i,c,m,y){return i=$n(22,i,y,c),i.elementType=X,i.lanes=m,i.stateNode={isHidden:!1},i}function Ff(i,c,m){return i=$n(6,i,null,c),i.lanes=m,i}function Bf(i,c,m){return c=$n(4,i.children!==null?i.children:[],i.key,c),c.lanes=m,c.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},c}function H3(i,c,m,y,j){this.tag=c,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=Ci(0),this.expirationTimes=Ci(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ci(0),this.identifierPrefix=y,this.onRecoverableError=j,this.mutableSourceEagerHydrationData=null}function qf(i,c,m,y,j,C,U,Q,te){return i=new H3(i,c,m,Q,te),c===1?(c=1,C===!0&&(c|=8)):c=0,C=$n(3,null,null,c),i.current=C,C.stateNode=i,C.memoizedState={element:y,isDehydrated:m,cache:null,transitions:null,pendingSuspenseBoundaries:null},Qh(C),i}function V3(i,c,m){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:A,key:y==null?null:""+y,children:i,containerInfo:c,implementation:m}}function F1(i){if(!i)return $s;i=i._reactInternals;e:{if(pn(i)!==i||i.tag!==1)throw Error(n(170));var c=i;do{switch(c.tag){case 3:c=c.stateNode.context;break e;case 1:if(sn(c.type)){c=c.stateNode.__reactInternalMemoizedMergedChildContext;break e}}c=c.return}while(c!==null);throw Error(n(171))}if(i.tag===1){var m=i.type;if(sn(m))return fk(i,m,c)}return c}function B1(i,c,m,y,j,C,U,Q,te){return i=qf(m,y,!0,i,j,C,U,Q,te),i.context=F1(null),m=i.current,y=Jt(),j=Bs(m),C=ss(y,j),C.callback=c??null,Ls(m,C,j),i.current.lanes=j,xs(i,j,y),ln(i,y),i}function su(i,c,m,y){var j=c.current,C=Jt(),U=Bs(j);return m=F1(m),c.context===null?c.context=m:c.pendingContext=m,c=ss(C,U),c.payload={element:i},y=y===void 0?null:y,y!==null&&(c.callback=y),i=Ls(j,c,U),i!==null&&(tr(i,j,U,C),Oc(i,j,U)),U}function au(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 q1(i,c){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var m=i.retryLane;i.retryLane=m!==0&&m<c?m:c}}function Uf(i,c){q1(i,c),(i=i.alternate)&&q1(i,c)}function G3(){return null}var U1=typeof reportError=="function"?reportError:function(i){console.error(i)};function zf(i){this._internalRoot=i}ou.prototype.render=zf.prototype.render=function(i){var c=this._internalRoot;if(c===null)throw Error(n(409));su(i,c,null,null)},ou.prototype.unmount=zf.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var c=i.containerInfo;xa(function(){su(null,i,null,null)}),c[Qr]=null}};function ou(i){this._internalRoot=i}ou.prototype.unstable_scheduleHydration=function(i){if(i){var c=eo();i={blockedOn:null,target:i,priority:c};for(var m=0;m<jr.length&&c!==0&&c<jr[m].priority;m++);jr.splice(m,0,i),m===0&&Oi(i)}};function Wf(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function iu(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function z1(){}function K3(i,c,m,y,j){if(j){if(typeof y=="function"){var C=y;y=function(){var ce=au(U);C.call(ce)}}var U=B1(c,y,i,0,null,!1,!1,"",z1);return i._reactRootContainer=U,i[Qr]=U.current,Vi(i.nodeType===8?i.parentNode:i),xa(),U}for(;j=i.lastChild;)i.removeChild(j);if(typeof y=="function"){var Q=y;y=function(){var ce=au(te);Q.call(ce)}}var te=qf(i,0,!1,null,null,!1,!1,"",z1);return i._reactRootContainer=te,i[Qr]=te.current,Vi(i.nodeType===8?i.parentNode:i),xa(function(){su(c,te,m,y)}),te}function lu(i,c,m,y,j){var C=m._reactRootContainer;if(C){var U=C;if(typeof j=="function"){var Q=j;j=function(){var te=au(U);Q.call(te)}}su(c,U,i,j)}else U=K3(m,c,i,j,y);return au(U)}Qa=function(i){switch(i.tag){case 3:var c=i.stateNode;if(c.current.memoizedState.isDehydrated){var m=ws(c.pendingLanes);m!==0&&(Ti(c,m|1),ln(c,Qe()),(Ue&6)===0&&(_o=Qe()+500,Is()))}break;case 13:xa(function(){var y=rs(i,1);if(y!==null){var j=Jt();tr(y,i,1,j)}}),Uf(i,1)}},Ri=function(i){if(i.tag===13){var c=rs(i,134217728);if(c!==null){var m=Jt();tr(c,i,134217728,m)}Uf(i,134217728)}},pc=function(i){if(i.tag===13){var c=Bs(i),m=rs(i,c);if(m!==null){var y=Jt();tr(m,i,c,y)}Uf(i,c)}},eo=function(){return ze},Mi=function(i,c){var m=ze;try{return ze=i,c()}finally{ze=m}},Pt=function(i,c,m){switch(c){case"input":if(pe(i,m),c=m.name,m.type==="radio"&&c!=null){for(m=i;m.parentNode;)m=m.parentNode;for(m=m.querySelectorAll("input[name="+JSON.stringify(""+c)+'][type="radio"]'),c=0;c<m.length;c++){var y=m[c];if(y!==i&&y.form===i.form){var j=Sc(y);if(!j)throw Error(n(90));ie(y),pe(y,j)}}}break;case"textarea":He(i,m);break;case"select":c=m.value,c!=null&&Te(i,!!m.multiple,c,!1)}},zr=Of,Wr=xa;var Y3={usingClientEntryPoint:!1,Events:[Yi,fo,Sc,Ur,zn,Of]},cl={findFiberByHostInstance:ha,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},X3={bundleType:cl.bundleType,version:cl.version,rendererPackageName:cl.rendererPackageName,rendererConfig:cl.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=De(i),i===null?null:i.stateNode},findFiberByHostInstance:cl.findFiberByHostInstance||G3,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 cu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!cu.isDisabled&&cu.supportsFiber)try{Yr=cu.inject(X3),Xt=cu}catch{}}return cn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Y3,cn.createPortal=function(i,c){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Wf(c))throw Error(n(200));return V3(i,c,null,m)},cn.createRoot=function(i,c){if(!Wf(i))throw Error(n(299));var m=!1,y="",j=U1;return c!=null&&(c.unstable_strictMode===!0&&(m=!0),c.identifierPrefix!==void 0&&(y=c.identifierPrefix),c.onRecoverableError!==void 0&&(j=c.onRecoverableError)),c=qf(i,1,!1,null,null,m,!1,y,j),i[Qr]=c.current,Vi(i.nodeType===8?i.parentNode:i),new zf(c)},cn.findDOMNode=function(i){if(i==null)return null;if(i.nodeType===1)return i;var c=i._reactInternals;if(c===void 0)throw typeof i.render=="function"?Error(n(188)):(i=Object.keys(i).join(","),Error(n(268,i)));return i=De(c),i=i===null?null:i.stateNode,i},cn.flushSync=function(i){return xa(i)},cn.hydrate=function(i,c,m){if(!iu(c))throw Error(n(200));return lu(null,i,c,!0,m)},cn.hydrateRoot=function(i,c,m){if(!Wf(i))throw Error(n(405));var y=m!=null&&m.hydratedSources||null,j=!1,C="",U=U1;if(m!=null&&(m.unstable_strictMode===!0&&(j=!0),m.identifierPrefix!==void 0&&(C=m.identifierPrefix),m.onRecoverableError!==void 0&&(U=m.onRecoverableError)),c=B1(c,null,i,1,m??null,j,!1,C,U),i[Qr]=c.current,Vi(i),y)for(i=0;i<y.length;i++)m=y[i],j=m._getVersion,j=j(m._source),c.mutableSourceEagerHydrationData==null?c.mutableSourceEagerHydrationData=[m,j]:c.mutableSourceEagerHydrationData.push(m,j);return new ou(c)},cn.render=function(i,c,m){if(!iu(c))throw Error(n(200));return lu(null,i,c,!1,m)},cn.unmountComponentAtNode=function(i){if(!iu(i))throw Error(n(40));return i._reactRootContainer?(xa(function(){lu(null,null,i,!1,function(){i._reactRootContainer=null,i[Qr]=null})}),!0):!1},cn.unstable_batchedUpdates=Of,cn.unstable_renderSubtreeIntoContainer=function(i,c,m,y){if(!iu(m))throw Error(n(200));if(i==null||i._reactInternals===void 0)throw Error(n(38));return lu(i,c,m,!1,y)},cn.version="18.3.1-next-f1338f8080-20240426",cn}var J1;function DR(){if(J1)return Gf.exports;J1=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(),Gf.exports=aP(),Gf.exports}var Q1;function oP(){if(Q1)return du;Q1=1;var e=DR();return du.createRoot=e.createRoot,du.hydrateRoot=e.hydrateRoot,du}var iP=oP(),w=Jl();const de=ob(w);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 Xf={exports:{}},Zf={},Jf={exports:{}},Qf={};/**
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 eN;function lP(){if(eN)return Qf;eN=1;var e=Jl();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 u(p,g){var v=g(),k=r({inst:{value:v,getSnapshot:g}}),b=k[0].inst,x=k[1];return o(function(){b.value=v,b.getSnapshot=g,d(b)&&x({inst:b})},[p,v,g]),s(function(){return d(b)&&x({inst:b}),p(function(){d(b)&&x({inst:b})})},[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:u;return Qf.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,Qf}var tN;function cP(){return tN||(tN=1,Jf.exports=lP()),Jf.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 uP(){if(nN)return Zf;nN=1;var e=Jl(),t=cP();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,u=e.useMemo,d=e.useDebugValue;return Zf.useSyncExternalStoreWithSelector=function(h,f,p,g,v){var k=o(null);if(k.current===null){var b={hasValue:!1,value:null};k.current=b}else b=k.current;k=u(function(){function N(A){if(!S){if(S=!0,_=A,A=g(A),v!==void 0&&b.hasValue){var R=b.value;if(v(R,A))return E=R}return E=A}if(R=E,r(_,A))return R;var B=g(A);return v!==void 0&&v(R,B)?(_=A,R):(_=A,E=B)}var S=!1,_,E,T=p===void 0?null:p;return[function(){return N(f())},T===null?void 0:function(){return N(T())}]},[f,p,g,v]);var x=s(h,k[0],k[1]);return l(function(){b.hasValue=!0,b.value=x},[x]),d(x),x},Zf}var rN;function dP(){return rN||(rN=1,Xf.exports=uP()),Xf.exports}var hP=dP();const fP=ob(hP),pP={},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(k=>k(t,v))}},s=()=>t,d={setState:r,getState:s,getInitialState:()=>h,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(pP?"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},mP=e=>e?sN(e):sN,{useDebugValue:gP}=de,{useSyncExternalStoreWithSelector:yP}=fP,wP=e=>e;function FR(e,t=wP,n){const r=yP(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return gP(r),r}const aN=(e,t)=>{const n=mP(e),r=(s,o=t)=>FR(n,s,o);return Object.assign(r,n),r},vP=(e,t)=>e?aN(e,t):aN;function Tt(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 xP={value:()=>{}};function Cd(){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 Lu(n)}function Lu(e){this._=e}function bP(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}})}Lu.prototype=Cd.prototype={constructor:Lu,on:function(e,t){var n=this._,r=bP(e+"",n),s,o=-1,l=r.length;if(arguments.length<2){for(;++o<l;)if((s=(e=r[o]).type)&&(s=kP(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]=oN(n[s],e.name,t);else if(t==null)for(s in n)n[s]=oN(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 Lu(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 kP(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function oN(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=xP,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Zv="http://www.w3.org/1999/xhtml";const iN={svg:"http://www.w3.org/2000/svg",xhtml:Zv,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Td(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),iN.hasOwnProperty(t)?{space:iN[t],local:e}:e}function NP(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Zv&&t.documentElement.namespaceURI===Zv?t.createElement(e):t.createElementNS(n,e)}}function jP(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function BR(e){var t=Td(e);return(t.local?jP:NP)(t)}function SP(){}function ib(e){return e==null?SP:function(){return this.querySelector(e)}}function _P(e){typeof e!="function"&&(e=ib(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,u=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__),u[f]=h);return new kn(r,this._parents)}function EP(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function CP(){return[]}function qR(e){return e==null?CP:function(){return this.querySelectorAll(e)}}function TP(e){return function(){return EP(e.apply(this,arguments))}}function AP(e){typeof e=="function"?e=TP(e):e=qR(e);for(var t=this._groups,n=t.length,r=[],s=[],o=0;o<n;++o)for(var l=t[o],u=l.length,d,h=0;h<u;++h)(d=l[h])&&(r.push(e.call(d,d.__data__,h,l)),s.push(d));return new kn(r,s)}function UR(e){return function(){return this.matches(e)}}function zR(e){return function(t){return t.matches(e)}}var RP=Array.prototype.find;function MP(e){return function(){return RP.call(this.children,e)}}function $P(){return this.firstElementChild}function IP(e){return this.select(e==null?$P:MP(typeof e=="function"?e:zR(e)))}var OP=Array.prototype.filter;function LP(){return Array.from(this.children)}function PP(e){return function(){return OP.call(this.children,e)}}function DP(e){return this.selectAll(e==null?LP:PP(typeof e=="function"?e:zR(e)))}function FP(e){typeof e!="function"&&(e=UR(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,u=r[s]=[],d,h=0;h<l;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&u.push(d);return new kn(r,this._parents)}function WR(e){return new Array(e.length)}function BP(){return new kn(this._enter||this._groups.map(WR),this._parents)}function Yu(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Yu.prototype={constructor:Yu,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 qP(e){return function(){return e}}function UP(e,t,n,r,s,o){for(var l=0,u,d=t.length,h=o.length;l<h;++l)(u=t[l])?(u.__data__=o[l],r[l]=u):n[l]=new Yu(e,o[l]);for(;l<d;++l)(u=t[l])&&(s[l]=u)}function zP(e,t,n,r,s,o,l){var u,d,h=new Map,f=t.length,p=o.length,g=new Array(f),v;for(u=0;u<f;++u)(d=t[u])&&(g[u]=v=l.call(d,d.__data__,u,t)+"",h.has(v)?s[u]=d:h.set(v,d));for(u=0;u<p;++u)v=l.call(e,o[u],u,o)+"",(d=h.get(v))?(r[u]=d,d.__data__=o[u],h.delete(v)):n[u]=new Yu(e,o[u]);for(u=0;u<f;++u)(d=t[u])&&h.get(g[u])===d&&(s[u]=d)}function WP(e){return e.__data__}function HP(e,t){if(!arguments.length)return Array.from(this,WP);var n=t?zP:UP,r=this._parents,s=this._groups;typeof e!="function"&&(e=qP(e));for(var o=s.length,l=new Array(o),u=new Array(o),d=new Array(o),h=0;h<o;++h){var f=r[h],p=s[h],g=p.length,v=VP(e.call(f,f&&f.__data__,h,r)),k=v.length,b=u[h]=new Array(k),x=l[h]=new Array(k),N=d[h]=new Array(g);n(f,p,b,x,N,v,t);for(var S=0,_=0,E,T;S<k;++S)if(E=b[S]){for(S>=_&&(_=S+1);!(T=x[_])&&++_<k;);E._next=T||null}}return l=new kn(l,r),l._enter=u,l._exit=d,l}function VP(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function GP(){return new kn(this._exit||this._groups.map(WR),this._parents)}function KP(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 YP(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),u=new Array(s),d=0;d<l;++d)for(var h=n[d],f=r[d],p=h.length,g=u[d]=new Array(p),v,k=0;k<p;++k)(v=h[k]||f[k])&&(g[k]=v);for(;d<s;++d)u[d]=n[d];return new kn(u,this._parents)}function XP(){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 ZP(e){e||(e=JP);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],u=l.length,d=s[o]=new Array(u),h,f=0;f<u;++f)(h=l[f])&&(d[f]=h);d.sort(t)}return new kn(s,this._parents).order()}function JP(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function QP(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function e4(){return Array.from(this)}function t4(){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 n4(){let e=0;for(const t of this)++e;return e}function r4(){return!this.node()}function s4(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var s=t[n],o=0,l=s.length,u;o<l;++o)(u=s[o])&&e.call(u,u.__data__,o,s);return this}function a4(e){return function(){this.removeAttribute(e)}}function o4(e){return function(){this.removeAttributeNS(e.space,e.local)}}function i4(e,t){return function(){this.setAttribute(e,t)}}function l4(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function c4(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function u4(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 d4(e,t){var n=Td(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?o4:a4:typeof t=="function"?n.local?u4:c4:n.local?l4:i4)(n,t))}function HR(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function h4(e){return function(){this.style.removeProperty(e)}}function f4(e,t,n){return function(){this.style.setProperty(e,t,n)}}function p4(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function m4(e,t,n){return arguments.length>1?this.each((t==null?h4:typeof t=="function"?p4:f4)(e,t,n??"")):ri(this.node(),e)}function ri(e,t){return e.style.getPropertyValue(t)||HR(e).getComputedStyle(e,null).getPropertyValue(t)}function g4(e){return function(){delete this[e]}}function y4(e,t){return function(){this[e]=t}}function w4(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function v4(e,t){return arguments.length>1?this.each((t==null?g4:typeof t=="function"?w4:y4)(e,t)):this.node()[e]}function VR(e){return e.trim().split(/^|\s+/)}function lb(e){return e.classList||new GR(e)}function GR(e){this._node=e,this._names=VR(e.getAttribute("class")||"")}GR.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 KR(e,t){for(var n=lb(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function YR(e,t){for(var n=lb(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function x4(e){return function(){KR(this,e)}}function b4(e){return function(){YR(this,e)}}function k4(e,t){return function(){(t.apply(this,arguments)?KR:YR)(this,e)}}function N4(e,t){var n=VR(e+"");if(arguments.length<2){for(var r=lb(this.node()),s=-1,o=n.length;++s<o;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?k4:t?x4:b4)(n,t))}function j4(){this.textContent=""}function S4(e){return function(){this.textContent=e}}function _4(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function E4(e){return arguments.length?this.each(e==null?j4:(typeof e=="function"?_4:S4)(e)):this.node().textContent}function C4(){this.innerHTML=""}function T4(e){return function(){this.innerHTML=e}}function A4(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function R4(e){return arguments.length?this.each(e==null?C4:(typeof e=="function"?A4:T4)(e)):this.node().innerHTML}function M4(){this.nextSibling&&this.parentNode.appendChild(this)}function $4(){return this.each(M4)}function I4(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function O4(){return this.each(I4)}function L4(e){var t=typeof e=="function"?e:BR(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function P4(){return null}function D4(e,t){var n=typeof e=="function"?e:BR(e),r=t==null?P4:typeof t=="function"?t:ib(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function F4(){var e=this.parentNode;e&&e.removeChild(this)}function B4(){return this.each(F4)}function q4(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function U4(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function z4(e){return this.select(e?U4:q4)}function W4(e){return arguments.length?this.property("__data__",e):this.node().__data__}function H4(e){return function(t){e.call(this,t,this.__data__)}}function V4(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 G4(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 K4(e,t,n){return function(){var r=this.__on,s,o=H4(t);if(r){for(var l=0,u=r.length;l<u;++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 Y4(e,t,n){var r=V4(e+""),s,o=r.length,l;if(arguments.length<2){var u=this.node().__on;if(u){for(var d=0,h=u.length,f;d<h;++d)for(s=0,f=u[d];s<o;++s)if((l=r[s]).type===f.type&&l.name===f.name)return f.value}return}for(u=t?K4:G4,s=0;s<o;++s)this.each(u(r[s],t,n));return this}function XR(e,t,n){var r=HR(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 X4(e,t){return function(){return XR(this,e,t)}}function Z4(e,t){return function(){return XR(this,e,t.apply(this,arguments))}}function J4(e,t){return this.each((typeof t=="function"?Z4:X4)(e,t))}function*Q4(){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 ZR=[null];function kn(e,t){this._groups=e,this._parents=t}function Ql(){return new kn([[document.documentElement]],ZR)}function eD(){return this}kn.prototype=Ql.prototype={constructor:kn,select:_P,selectAll:AP,selectChild:IP,selectChildren:DP,filter:FP,data:HP,enter:BP,exit:GP,join:KP,merge:YP,selection:eD,order:XP,sort:ZP,call:QP,nodes:e4,node:t4,size:n4,empty:r4,each:s4,attr:d4,style:m4,property:v4,classed:N4,text:E4,html:R4,raise:$4,lower:O4,append:L4,insert:D4,remove:B4,clone:z4,datum:W4,on:Y4,dispatch:J4,[Symbol.iterator]:Q4};function Pn(e){return typeof e=="string"?new kn([[document.querySelector(e)]],[document.documentElement]):new kn([[e]],ZR)}function tD(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ar(e,t){if(e=tD(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 nD={passive:!1},Al={capture:!0,passive:!1};function ep(e){e.stopImmediatePropagation()}function Yo(e){e.preventDefault(),e.stopImmediatePropagation()}function JR(e){var t=e.document.documentElement,n=Pn(e).on("dragstart.drag",Yo,Al);"onselectstart"in t?n.on("selectstart.drag",Yo,Al):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function QR(e,t){var n=e.document.documentElement,r=Pn(e).on("dragstart.drag",null);t&&(r.on("click.drag",Yo,Al),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 hu=e=>()=>e;function Jv(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:o,x:l,y:u,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:u,enumerable:!0,configurable:!0},dx:{value:d,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:f}})}Jv.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function rD(e){return!e.ctrlKey&&!e.button}function sD(){return this.parentNode}function aD(e,t){return t??{x:e.x,y:e.y}}function oD(){return navigator.maxTouchPoints||"ontouchstart"in this}function iD(){var e=rD,t=sD,n=aD,r=oD,s={},o=Cd("start","drag","end"),l=0,u,d,h,f,p=0;function g(E){E.on("mousedown.drag",v).filter(r).on("touchstart.drag",x).on("touchmove.drag",N,nD).on("touchend.drag touchcancel.drag",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(E,T){if(!(f||!e.call(this,E,T))){var A=_(this,t.call(this,E,T),E,T,"mouse");A&&(Pn(E.view).on("mousemove.drag",k,Al).on("mouseup.drag",b,Al),JR(E.view),ep(E),h=!1,u=E.clientX,d=E.clientY,A("start",E))}}function k(E){if(Yo(E),!h){var T=E.clientX-u,A=E.clientY-d;h=T*T+A*A>p}s.mouse("drag",E)}function b(E){Pn(E.view).on("mousemove.drag mouseup.drag",null),QR(E.view,h),Yo(E),s.mouse("end",E)}function x(E,T){if(e.call(this,E,T)){var A=E.changedTouches,R=t.call(this,E,T),B=A.length,P,D;for(P=0;P<B;++P)(D=_(this,R,E,T,A[P].identifier,A[P]))&&(ep(E),D("start",E,A[P]))}}function N(E){var T=E.changedTouches,A=T.length,R,B;for(R=0;R<A;++R)(B=s[T[R].identifier])&&(Yo(E),B("drag",E,T[R]))}function S(E){var T=E.changedTouches,A=T.length,R,B;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),R=0;R<A;++R)(B=s[T[R].identifier])&&(ep(E),B("end",E,T[R]))}function _(E,T,A,R,B,P){var D=o.copy(),I=ar(P||A,T),O,z,M;if((M=n.call(E,new Jv("beforestart",{sourceEvent:A,target:g,identifier:B,active:l,x:I[0],y:I[1],dx:0,dy:0,dispatch:D}),R))!=null)return O=M.x-I[0]||0,z=M.y-I[1]||0,function $(q,X,H){var L=I,W;switch(q){case"start":s[B]=$,W=l++;break;case"end":delete s[B],--l;case"drag":I=ar(H||X,T),W=l;break}D.call(q,E,new Jv(q,{sourceEvent:X,subject:M,target:g,identifier:B,active:W,x:I[0]+O,y:I[1]+z,dx:I[0]-L[0],dy:I[1]-L[1],dispatch:D}),R)}}return g.filter=function(E){return arguments.length?(e=typeof E=="function"?E:hu(!!E),g):e},g.container=function(E){return arguments.length?(t=typeof E=="function"?E:hu(E),g):t},g.subject=function(E){return arguments.length?(n=typeof E=="function"?E:hu(E),g):n},g.touchable=function(E){return arguments.length?(r=typeof E=="function"?E:hu(!!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 cb(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function e2(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function ec(){}var Rl=.7,Xu=1/Rl,Xo="\\s*([+-]?\\d+)\\s*",Ml="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ir="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",lD=/^#([0-9a-f]{3,8})$/,cD=new RegExp(`^rgb\\(${Xo},${Xo},${Xo}\\)$`),uD=new RegExp(`^rgb\\(${Ir},${Ir},${Ir}\\)$`),dD=new RegExp(`^rgba\\(${Xo},${Xo},${Xo},${Ml}\\)$`),hD=new RegExp(`^rgba\\(${Ir},${Ir},${Ir},${Ml}\\)$`),fD=new RegExp(`^hsl\\(${Ml},${Ir},${Ir}\\)$`),pD=new RegExp(`^hsla\\(${Ml},${Ir},${Ir},${Ml}\\)$`),lN={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};cb(ec,$l,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:cN,formatHex:cN,formatHex8:mD,formatHsl:gD,formatRgb:uN,toString:uN});function cN(){return this.rgb().formatHex()}function mD(){return this.rgb().formatHex8()}function gD(){return t2(this).formatHsl()}function uN(){return this.rgb().formatRgb()}function $l(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=lD.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?dN(t):n===3?new dn(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?fu(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?fu(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=cD.exec(e))?new dn(t[1],t[2],t[3],1):(t=uD.exec(e))?new dn(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=dD.exec(e))?fu(t[1],t[2],t[3],t[4]):(t=hD.exec(e))?fu(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=fD.exec(e))?pN(t[1],t[2]/100,t[3]/100,1):(t=pD.exec(e))?pN(t[1],t[2]/100,t[3]/100,t[4]):lN.hasOwnProperty(e)?dN(lN[e]):e==="transparent"?new dn(NaN,NaN,NaN,0):null}function dN(e){return new dn(e>>16&255,e>>8&255,e&255,1)}function fu(e,t,n,r){return r<=0&&(e=t=n=NaN),new dn(e,t,n,r)}function yD(e){return e instanceof ec||(e=$l(e)),e?(e=e.rgb(),new dn(e.r,e.g,e.b,e.opacity)):new dn}function Qv(e,t,n,r){return arguments.length===1?yD(e):new dn(e,t,n,r??1)}function dn(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}cb(dn,Qv,e2(ec,{brighter(e){return e=e==null?Xu:Math.pow(Xu,e),new dn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Rl:Math.pow(Rl,e),new dn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new dn(Ma(this.r),Ma(this.g),Ma(this.b),Zu(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:hN,formatHex:hN,formatHex8:wD,formatRgb:fN,toString:fN}));function hN(){return`#${Ta(this.r)}${Ta(this.g)}${Ta(this.b)}`}function wD(){return`#${Ta(this.r)}${Ta(this.g)}${Ta(this.b)}${Ta((isNaN(this.opacity)?1:this.opacity)*255)}`}function fN(){const e=Zu(this.opacity);return`${e===1?"rgb(":"rgba("}${Ma(this.r)}, ${Ma(this.g)}, ${Ma(this.b)}${e===1?")":`, ${e})`}`}function Zu(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ma(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ta(e){return e=Ma(e),(e<16?"0":"")+e.toString(16)}function pN(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 t2(e){if(e instanceof or)return new or(e.h,e.s,e.l,e.opacity);if(e instanceof ec||(e=$l(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,u=o-s,d=(o+s)/2;return u?(t===o?l=(n-r)/u+(n<r)*6:n===o?l=(r-t)/u+2:l=(t-n)/u+4,u/=d<.5?o+s:2-o-s,l*=60):u=d>0&&d<1?0:l,new or(l,u,d,e.opacity)}function vD(e,t,n,r){return arguments.length===1?t2(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}cb(or,vD,e2(ec,{brighter(e){return e=e==null?Xu:Math.pow(Xu,e),new or(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Rl:Math.pow(Rl,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 dn(tp(e>=240?e-240:e+120,s,r),tp(e,s,r),tp(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new or(mN(this.h),pu(this.s),pu(this.l),Zu(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=Zu(this.opacity);return`${e===1?"hsl(":"hsla("}${mN(this.h)}, ${pu(this.s)*100}%, ${pu(this.l)*100}%${e===1?")":`, ${e})`}`}}));function mN(e){return e=(e||0)%360,e<0?e+360:e}function pu(e){return Math.max(0,Math.min(1,e||0))}function tp(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 n2=e=>()=>e;function xD(e,t){return function(n){return e+n*t}}function bD(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 kD(e){return(e=+e)==1?r2:function(t,n){return n-t?bD(t,n,e):n2(isNaN(t)?n:t)}}function r2(e,t){var n=t-e;return n?xD(e,n):n2(isNaN(e)?t:e)}const gN=(function e(t){var n=kD(t);function r(s,o){var l=n((s=Qv(s)).r,(o=Qv(o)).r),u=n(s.g,o.g),d=n(s.b,o.b),h=r2(s.opacity,o.opacity);return function(f){return s.r=l(f),s.g=u(f),s.b=d(f),s.opacity=h(f),s+""}}return r.gamma=e,r})(1);function Vs(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var ex=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,np=new RegExp(ex.source,"g");function ND(e){return function(){return e}}function jD(e){return function(t){return e(t)+""}}function SD(e,t){var n=ex.lastIndex=np.lastIndex=0,r,s,o,l=-1,u=[],d=[];for(e=e+"",t=t+"";(r=ex.exec(e))&&(s=np.exec(t));)(o=s.index)>n&&(o=t.slice(n,o),u[l]?u[l]+=o:u[++l]=o),(r=r[0])===(s=s[0])?u[l]?u[l]+=s:u[++l]=s:(u[++l]=null,d.push({i:l,x:Vs(r,s)})),n=np.lastIndex;return n<t.length&&(o=t.slice(n),u[l]?u[l]+=o:u[++l]=o),u.length<2?d[0]?jD(d[0].x):ND(t):(t=d.length,function(h){for(var f=0,p;f<t;++f)u[(p=d[f]).i]=p.x(h);return u.join("")})}var yN=180/Math.PI,tx={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function s2(e,t,n,r,s,o){var l,u,d;return(l=Math.sqrt(e*e+t*t))&&(e/=l,t/=l),(d=e*n+t*r)&&(n-=e*d,r-=t*d),(u=Math.sqrt(n*n+r*r))&&(n/=u,r/=u,d/=u),e*r<t*n&&(e=-e,t=-t,d=-d,l=-l),{translateX:s,translateY:o,rotate:Math.atan2(t,e)*yN,skewX:Math.atan(d)*yN,scaleX:l,scaleY:u}}var mu;function _D(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?tx:s2(t.a,t.b,t.c,t.d,t.e,t.f)}function ED(e){return e==null||(mu||(mu=document.createElementNS("http://www.w3.org/2000/svg","g")),mu.setAttribute("transform",e),!(e=mu.transform.baseVal.consolidate()))?tx:(e=e.matrix,s2(e.a,e.b,e.c,e.d,e.e,e.f))}function a2(e,t,n,r){function s(h){return h.length?h.pop()+" ":""}function o(h,f,p,g,v,k){if(h!==p||f!==g){var b=v.push("translate(",null,t,null,n);k.push({i:b-4,x:Vs(h,p)},{i:b-2,x:Vs(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:Vs(h,f)})):f&&p.push(s(p)+"rotate("+f+r)}function u(h,f,p,g){h!==f?g.push({i:p.push(s(p)+"skewX(",null,r)-2,x:Vs(h,f)}):f&&p.push(s(p)+"skewX("+f+r)}function d(h,f,p,g,v,k){if(h!==p||f!==g){var b=v.push(s(v)+"scale(",null,",",null,")");k.push({i:b-4,x:Vs(h,p)},{i:b-2,x:Vs(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),u(h.skewX,f.skewX,p,g),d(h.scaleX,h.scaleY,f.scaleX,f.scaleY,p,g),h=f=null,function(v){for(var k=-1,b=g.length,x;++k<b;)p[(x=g[k]).i]=x.x(v);return p.join("")}}}var CD=a2(_D,"px, ","px)","deg)"),TD=a2(ED,", ",")",")"),AD=1e-12;function wN(e){return((e=Math.exp(e))+1/e)/2}function RD(e){return((e=Math.exp(e))-1/e)/2}function MD(e){return((e=Math.exp(2*e))-1)/(e+1)}const $D=(function e(t,n,r){function s(o,l){var u=o[0],d=o[1],h=o[2],f=l[0],p=l[1],g=l[2],v=f-u,k=p-d,b=v*v+k*k,x,N;if(b<AD)N=Math.log(g/h)/t,x=function(R){return[u+R*v,d+R*k,h*Math.exp(t*R*N)]};else{var S=Math.sqrt(b),_=(g*g-h*h+r*b)/(2*h*n*S),E=(g*g-h*h-r*b)/(2*g*n*S),T=Math.log(Math.sqrt(_*_+1)-_),A=Math.log(Math.sqrt(E*E+1)-E);N=(A-T)/t,x=function(R){var B=R*N,P=wN(T),D=h/(n*S)*(P*MD(t*B+T)-RD(T));return[u+D*v,d+D*k,h*P/wN(t*B+T)]}}return x.duration=N*1e3*t/Math.SQRT2,x}return s.rho=function(o){var l=Math.max(.001,+o),u=l*l,d=u*u;return e(l,u,d)},s})(Math.SQRT2,2,4);var si=0,wl=0,dl=0,o2=1e3,Ju,vl,Qu=0,Pa=0,Ad=0,Il=typeof performance=="object"&&performance.now?performance:Date,i2=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ub(){return Pa||(i2(ID),Pa=Il.now()+Ad)}function ID(){Pa=0}function ed(){this._call=this._time=this._next=null}ed.prototype=l2.prototype={constructor:ed,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ub():+n)+(t==null?0:+t),!this._next&&vl!==this&&(vl?vl._next=this:Ju=this,vl=this),this._call=e,this._time=n,nx()},stop:function(){this._call&&(this._call=null,this._time=1/0,nx())}};function l2(e,t,n){var r=new ed;return r.restart(e,t,n),r}function OD(){ub(),++si;for(var e=Ju,t;e;)(t=Pa-e._time)>=0&&e._call.call(void 0,t),e=e._next;--si}function vN(){Pa=(Qu=Il.now())+Ad,si=wl=0;try{OD()}finally{si=0,PD(),Pa=0}}function LD(){var e=Il.now(),t=e-Qu;t>o2&&(Ad-=t,Qu=e)}function PD(){for(var e,t=Ju,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:Ju=n);vl=e,nx(r)}function nx(e){if(!si){wl&&(wl=clearTimeout(wl));var t=e-Pa;t>24?(e<1/0&&(wl=setTimeout(vN,e-Il.now()-Ad)),dl&&(dl=clearInterval(dl))):(dl||(Qu=Il.now(),dl=setInterval(LD,o2)),si=1,i2(vN))}}function xN(e,t,n){var r=new ed;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var DD=Cd("start","end","cancel","interrupt"),FD=[],c2=0,bN=1,rx=2,Pu=3,kN=4,sx=5,Du=6;function Rd(e,t,n,r,s,o){var l=e.__transition;if(!l)e.__transition={};else if(n in l)return;BD(e,n,{name:t,index:r,group:s,on:DD,tween:FD,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:c2})}function db(e,t){var n=fr(e,t);if(n.state>c2)throw new Error("too late; already scheduled");return n}function Br(e,t){var n=fr(e,t);if(n.state>Pu)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 BD(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=l2(o,0,n.time);function o(h){n.state=bN,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!==bN)return d();for(f in r)if(v=r[f],v.name===n.name){if(v.state===Pu)return xN(l);v.state===kN?(v.state=Du,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete r[f]):+f<t&&(v.state=Du,v.timer.stop(),v.on.call("cancel",e,e.__data__,v.index,v.group),delete r[f])}if(xN(function(){n.state===Pu&&(n.state=kN,n.timer.restart(u,n.delay,n.time),u(h))}),n.state=rx,n.on.call("start",e,e.__data__,n.index,n.group),n.state===rx){for(n.state=Pu,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 u(h){for(var f=h<n.duration?n.ease.call(null,h/n.duration):(n.timer.restart(d),n.state=sx,1),p=-1,g=s.length;++p<g;)s[p].call(e,f);n.state===sx&&(n.on.call("end",e,e.__data__,n.index,n.group),d())}function d(){n.state=Du,n.timer.stop(),delete r[t];for(var h in r)return;delete e.__transition}}function Fu(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>rx&&r.state<sx,r.state=Du,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[l]}o&&delete e.__transition}}function qD(e){return this.each(function(){Fu(this,e)})}function UD(e,t){var n,r;return function(){var s=Br(this,e),o=s.tween;if(o!==n){r=n=o;for(var l=0,u=r.length;l<u;++l)if(r[l].name===t){r=r.slice(),r.splice(l,1);break}}s.tween=r}}function zD(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var o=Br(this,e),l=o.tween;if(l!==r){s=(r=l).slice();for(var u={name:t,value:n},d=0,h=s.length;d<h;++d)if(s[d].name===t){s[d]=u;break}d===h&&s.push(u)}o.tween=s}}function WD(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?UD:zD)(n,e,t))}function hb(e,t,n){var r=e._id;return e.each(function(){var s=Br(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return fr(s,r).value[t]}}function u2(e,t){var n;return(typeof t=="number"?Vs:t instanceof $l?gN:(n=$l(t))?(t=n,gN):SD)(e,t)}function HD(e){return function(){this.removeAttribute(e)}}function VD(e){return function(){this.removeAttributeNS(e.space,e.local)}}function GD(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 KD(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 YD(e,t,n){var r,s,o;return function(){var l,u=n(this),d;return u==null?void this.removeAttribute(e):(l=this.getAttribute(e),d=u+"",l===d?null:l===r&&d===s?o:(s=d,o=t(r=l,u)))}}function XD(e,t,n){var r,s,o;return function(){var l,u=n(this),d;return u==null?void this.removeAttributeNS(e.space,e.local):(l=this.getAttributeNS(e.space,e.local),d=u+"",l===d?null:l===r&&d===s?o:(s=d,o=t(r=l,u)))}}function ZD(e,t){var n=Td(e),r=n==="transform"?TD:u2;return this.attrTween(e,typeof t=="function"?(n.local?XD:YD)(n,r,hb(this,"attr."+e,t)):t==null?(n.local?VD:HD)(n):(n.local?KD:GD)(n,r,t))}function JD(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function QD(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function eF(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&QD(e,o)),n}return s._value=t,s}function tF(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&JD(e,o)),n}return s._value=t,s}function nF(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=Td(e);return this.tween(n,(r.local?eF:tF)(r,t))}function rF(e,t){return function(){db(this,e).delay=+t.apply(this,arguments)}}function sF(e,t){return t=+t,function(){db(this,e).delay=t}}function aF(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?rF:sF)(t,e)):fr(this.node(),t).delay}function oF(e,t){return function(){Br(this,e).duration=+t.apply(this,arguments)}}function iF(e,t){return t=+t,function(){Br(this,e).duration=t}}function lF(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?oF:iF)(t,e)):fr(this.node(),t).duration}function cF(e,t){if(typeof t!="function")throw new Error;return function(){Br(this,e).ease=t}}function uF(e){var t=this._id;return arguments.length?this.each(cF(t,e)):fr(this.node(),t).ease}function dF(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Br(this,e).ease=n}}function hF(e){if(typeof e!="function")throw new Error;return this.each(dF(this._id,e))}function fF(e){typeof e!="function"&&(e=UR(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,u=r[s]=[],d,h=0;h<l;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&u.push(d);return new ds(r,this._parents,this._name,this._id)}function pF(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),u=0;u<o;++u)for(var d=t[u],h=n[u],f=d.length,p=l[u]=new Array(f),g,v=0;v<f;++v)(g=d[v]||h[v])&&(p[v]=g);for(;u<r;++u)l[u]=t[u];return new ds(l,this._parents,this._name,this._id)}function mF(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 gF(e,t,n){var r,s,o=mF(t)?db:Br;return function(){var l=o(this,e),u=l.on;u!==r&&(s=(r=u).copy()).on(t,n),l.on=s}}function yF(e,t){var n=this._id;return arguments.length<2?fr(this.node(),n).on.on(e):this.each(gF(n,e,t))}function wF(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function vF(){return this.on("end.remove",wF(this._id))}function xF(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ib(e));for(var r=this._groups,s=r.length,o=new Array(s),l=0;l<s;++l)for(var u=r[l],d=u.length,h=o[l]=new Array(d),f,p,g=0;g<d;++g)(f=u[g])&&(p=e.call(f,f.__data__,g,u))&&("__data__"in f&&(p.__data__=f.__data__),h[g]=p,Rd(h[g],t,n,g,h,fr(f,n)));return new ds(o,this._parents,t,n)}function bF(e){var t=this._name,n=this._id;typeof e!="function"&&(e=qR(e));for(var r=this._groups,s=r.length,o=[],l=[],u=0;u<s;++u)for(var d=r[u],h=d.length,f,p=0;p<h;++p)if(f=d[p]){for(var g=e.call(f,f.__data__,p,d),v,k=fr(f,n),b=0,x=g.length;b<x;++b)(v=g[b])&&Rd(v,t,n,b,g,k);o.push(g),l.push(f)}return new ds(o,l,t,n)}var kF=Ql.prototype.constructor;function NF(){return new kF(this._groups,this._parents)}function jF(e,t){var n,r,s;return function(){var o=ri(this,e),l=(this.style.removeProperty(e),ri(this,e));return o===l?null:o===n&&l===r?s:s=t(n=o,r=l)}}function d2(e){return function(){this.style.removeProperty(e)}}function SF(e,t,n){var r,s=n+"",o;return function(){var l=ri(this,e);return l===s?null:l===r?o:o=t(r=l,n)}}function _F(e,t,n){var r,s,o;return function(){var l=ri(this,e),u=n(this),d=u+"";return u==null&&(d=u=(this.style.removeProperty(e),ri(this,e))),l===d?null:l===r&&d===s?o:(s=d,o=t(r=l,u))}}function EF(e,t){var n,r,s,o="style."+t,l="end."+o,u;return function(){var d=Br(this,e),h=d.on,f=d.value[o]==null?u||(u=d2(t)):void 0;(h!==n||s!==f)&&(r=(n=h).copy()).on(l,s=f),d.on=r}}function CF(e,t,n){var r=(e+="")=="transform"?CD:u2;return t==null?this.styleTween(e,jF(e,r)).on("end.style."+e,d2(e)):typeof t=="function"?this.styleTween(e,_F(e,r,hb(this,"style."+e,t))).each(EF(this._id,e)):this.styleTween(e,SF(e,r,t),n).on("end.style."+e,null)}function TF(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function AF(e,t,n){var r,s;function o(){var l=t.apply(this,arguments);return l!==s&&(r=(s=l)&&TF(e,l,n)),r}return o._value=t,o}function RF(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,AF(e,t,n??""))}function MF(e){return function(){this.textContent=e}}function $F(e){return function(){var t=e(this);this.textContent=t??""}}function IF(e){return this.tween("text",typeof e=="function"?$F(hb(this,"text",e)):MF(e==null?"":e+""))}function OF(e){return function(t){this.textContent=e.call(this,t)}}function LF(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&OF(s)),t}return r._value=e,r}function PF(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,LF(e))}function DF(){for(var e=this._name,t=this._id,n=h2(),r=this._groups,s=r.length,o=0;o<s;++o)for(var l=r[o],u=l.length,d,h=0;h<u;++h)if(d=l[h]){var f=fr(d,t);Rd(d,e,n,h,l,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new ds(r,this._parents,e,n)}function FF(){var e,t,n=this,r=n._id,s=n.size();return new Promise(function(o,l){var u={value:l},d={value:function(){--s===0&&o()}};n.each(function(){var h=Br(this,r),f=h.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(u),t._.interrupt.push(u),t._.end.push(d)),h.on=t}),s===0&&o()})}var BF=0;function ds(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function h2(){return++BF}var is=Ql.prototype;ds.prototype={constructor:ds,select:xF,selectAll:bF,selectChild:is.selectChild,selectChildren:is.selectChildren,filter:fF,merge:pF,selection:NF,transition:DF,call:is.call,nodes:is.nodes,node:is.node,size:is.size,empty:is.empty,each:is.each,on:yF,attr:ZD,attrTween:nF,style:CF,styleTween:RF,text:IF,textTween:PF,remove:vF,tween:WD,delay:aF,duration:lF,ease:uF,easeVarying:hF,end:FF,[Symbol.iterator]:is[Symbol.iterator]};function qF(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var UF={time:null,delay:0,duration:250,ease:qF};function zF(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 WF(e){var t,n;e instanceof ds?(t=e._id,e=e._name):(t=h2(),(n=UF).time=ub(),e=e==null?null:e+"");for(var r=this._groups,s=r.length,o=0;o<s;++o)for(var l=r[o],u=l.length,d,h=0;h<u;++h)(d=l[h])&&Rd(d,e,t,h,l,n||zF(d,t));return new ds(r,this._parents,e,t)}Ql.prototype.interrupt=qD;Ql.prototype.transition=WF;const gu=e=>()=>e;function HF(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 cs=new ls(1,0,0);ls.prototype;function rp(e){e.stopImmediatePropagation()}function hl(e){e.preventDefault(),e.stopImmediatePropagation()}function VF(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function GF(){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 NN(){return this.__zoom||cs}function KF(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function YF(){return navigator.maxTouchPoints||"ontouchstart"in this}function XF(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 f2(){var e=VF,t=GF,n=XF,r=KF,s=YF,o=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],u=250,d=$D,h=Cd("start","zoom","end"),f,p,g,v=500,k=150,b=0,x=10;function N(M){M.property("__zoom",NN).on("wheel.zoom",B,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",D).filter(s).on("touchstart.zoom",I).on("touchmove.zoom",O).on("touchend.zoom touchcancel.zoom",z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}N.transform=function(M,$,q,X){var H=M.selection?M.selection():M;H.property("__zoom",NN),M!==H?T(M,$,q,X):H.interrupt().each(function(){A(this,arguments).event(X).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},N.scaleBy=function(M,$,q,X){N.scaleTo(M,function(){var H=this.__zoom.k,L=typeof $=="function"?$.apply(this,arguments):$;return H*L},q,X)},N.scaleTo=function(M,$,q,X){N.transform(M,function(){var H=t.apply(this,arguments),L=this.__zoom,W=q==null?E(H):typeof q=="function"?q.apply(this,arguments):q,F=L.invert(W),Y=typeof $=="function"?$.apply(this,arguments):$;return n(_(S(L,Y),W,F),H,l)},q,X)},N.translateBy=function(M,$,q,X){N.transform(M,function(){return n(this.__zoom.translate(typeof $=="function"?$.apply(this,arguments):$,typeof q=="function"?q.apply(this,arguments):q),t.apply(this,arguments),l)},null,X)},N.translateTo=function(M,$,q,X,H){N.transform(M,function(){var L=t.apply(this,arguments),W=this.__zoom,F=X==null?E(L):typeof X=="function"?X.apply(this,arguments):X;return n(cs.translate(F[0],F[1]).scale(W.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof q=="function"?-q.apply(this,arguments):-q),L,l)},X,H)};function S(M,$){return $=Math.max(o[0],Math.min(o[1],$)),$===M.k?M:new ls($,M.x,M.y)}function _(M,$,q){var X=$[0]-q[0]*M.k,H=$[1]-q[1]*M.k;return X===M.x&&H===M.y?M:new ls(M.k,X,H)}function E(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function T(M,$,q,X){M.on("start.zoom",function(){A(this,arguments).event(X).start()}).on("interrupt.zoom end.zoom",function(){A(this,arguments).event(X).end()}).tween("zoom",function(){var H=this,L=arguments,W=A(H,L).event(X),F=t.apply(H,L),Y=q==null?E(F):typeof q=="function"?q.apply(H,L):q,J=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),V=H.__zoom,G=typeof $=="function"?$.apply(H,L):$,K=d(V.invert(Y).concat(J/V.k),G.invert(Y).concat(J/G.k));return function(Z){if(Z===1)Z=G;else{var ee=K(Z),re=J/ee[2];Z=new ls(re,Y[0]-ee[0]*re,Y[1]-ee[1]*re)}W.zoom(null,Z)}})}function A(M,$,q){return!q&&M.__zooming||new R(M,$)}function R(M,$){this.that=M,this.args=$,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,$),this.taps=0}R.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 $=Pn(this.that).datum();h.call(M,this.that,new HF(M,{sourceEvent:this.sourceEvent,target:N,transform:this.that.__zoom,dispatch:h}),$)}};function B(M,...$){if(!e.apply(this,arguments))return;var q=A(this,$).event(M),X=this.__zoom,H=Math.max(o[0],Math.min(o[1],X.k*Math.pow(2,r.apply(this,arguments)))),L=ar(M);if(q.wheel)(q.mouse[0][0]!==L[0]||q.mouse[0][1]!==L[1])&&(q.mouse[1]=X.invert(q.mouse[0]=L)),clearTimeout(q.wheel);else{if(X.k===H)return;q.mouse=[L,X.invert(L)],Fu(this),q.start()}hl(M),q.wheel=setTimeout(W,k),q.zoom("mouse",n(_(S(X,H),q.mouse[0],q.mouse[1]),q.extent,l));function W(){q.wheel=null,q.end()}}function P(M,...$){if(g||!e.apply(this,arguments))return;var q=M.currentTarget,X=A(this,$,!0).event(M),H=Pn(M.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",J,!0),L=ar(M,q),W=M.clientX,F=M.clientY;JR(M.view),rp(M),X.mouse=[L,this.__zoom.invert(L)],Fu(this),X.start();function Y(V){if(hl(V),!X.moved){var G=V.clientX-W,K=V.clientY-F;X.moved=G*G+K*K>b}X.event(V).zoom("mouse",n(_(X.that.__zoom,X.mouse[0]=ar(V,q),X.mouse[1]),X.extent,l))}function J(V){H.on("mousemove.zoom mouseup.zoom",null),QR(V.view,X.moved),hl(V),X.event(V).end()}}function D(M,...$){if(e.apply(this,arguments)){var q=this.__zoom,X=ar(M.changedTouches?M.changedTouches[0]:M,this),H=q.invert(X),L=q.k*(M.shiftKey?.5:2),W=n(_(S(q,L),X,H),t.apply(this,$),l);hl(M),u>0?Pn(this).transition().duration(u).call(T,W,X,M):Pn(this).call(N.transform,W,X,M)}}function I(M,...$){if(e.apply(this,arguments)){var q=M.touches,X=q.length,H=A(this,$,M.changedTouches.length===X).event(M),L,W,F,Y;for(rp(M),W=0;W<X;++W)F=q[W],Y=ar(F,this),Y=[Y,this.__zoom.invert(Y),F.identifier],H.touch0?!H.touch1&&H.touch0[2]!==Y[2]&&(H.touch1=Y,H.taps=0):(H.touch0=Y,L=!0,H.taps=1+!!f);f&&(f=clearTimeout(f)),L&&(H.taps<2&&(p=Y[0],f=setTimeout(function(){f=null},v)),Fu(this),H.start())}}function O(M,...$){if(this.__zooming){var q=A(this,$).event(M),X=M.changedTouches,H=X.length,L,W,F,Y;for(hl(M),L=0;L<H;++L)W=X[L],F=ar(W,this),q.touch0&&q.touch0[2]===W.identifier?q.touch0[0]=F:q.touch1&&q.touch1[2]===W.identifier&&(q.touch1[0]=F);if(W=q.that.__zoom,q.touch1){var J=q.touch0[0],V=q.touch0[1],G=q.touch1[0],K=q.touch1[1],Z=(Z=G[0]-J[0])*Z+(Z=G[1]-J[1])*Z,ee=(ee=K[0]-V[0])*ee+(ee=K[1]-V[1])*ee;W=S(W,Math.sqrt(Z/ee)),F=[(J[0]+G[0])/2,(J[1]+G[1])/2],Y=[(V[0]+K[0])/2,(V[1]+K[1])/2]}else if(q.touch0)F=q.touch0[0],Y=q.touch0[1];else return;q.zoom("touch",n(_(W,F,Y),q.extent,l))}}function z(M,...$){if(this.__zooming){var q=A(this,$).event(M),X=M.changedTouches,H=X.length,L,W;for(rp(M),g&&clearTimeout(g),g=setTimeout(function(){g=null},v),L=0;L<H;++L)W=X[L],q.touch0&&q.touch0[2]===W.identifier?delete q.touch0:q.touch1&&q.touch1[2]===W.identifier&&delete q.touch1;if(q.touch1&&!q.touch0&&(q.touch0=q.touch1,delete q.touch1),q.touch0)q.touch0[1]=this.__zoom.invert(q.touch0[0]);else if(q.end(),q.taps===2&&(W=ar(W,this),Math.hypot(p[0]-W[0],p[1]-W[1])<x)){var F=Pn(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return N.wheelDelta=function(M){return arguments.length?(r=typeof M=="function"?M:gu(+M),N):r},N.filter=function(M){return arguments.length?(e=typeof M=="function"?M:gu(!!M),N):e},N.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:gu(!!M),N):s},N.extent=function(M){return arguments.length?(t=typeof M=="function"?M:gu([[+M[0][0],+M[0][1]],[+M[1][0],+M[1][1]]]),N):t},N.scaleExtent=function(M){return arguments.length?(o[0]=+M[0],o[1]=+M[1],N):[o[0],o[1]]},N.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],N):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},N.constrain=function(M){return arguments.length?(n=M,N):n},N.duration=function(M){return arguments.length?(u=+M,N):u},N.interpolate=function(M){return arguments.length?(d=M,N):d},N.on=function(){var M=h.on.apply(h,arguments);return M===h?N:M},N.clickDistance=function(M){return arguments.length?(b=(M=+M)*M,N):Math.sqrt(b)},N.tapDistance=function(M){return arguments.length?(x=+M,N):x},N}var Lt=DR();const Md=w.createContext(null),ZF=Md.Provider,hs={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.`},p2=hs.error001();function Ge(e,t){const n=w.useContext(Md);if(n===null)throw new Error(p2);return FR(n,e,t)}const kt=()=>{const e=w.useContext(Md);if(e===null)throw new Error(p2);return w.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},JF=e=>e.userSelectionActive?"none":"all";function fb({position:e,children:t,className:n,style:r,...s}){const o=Ge(JF),l=`${e}`.split("-");return de.createElement("div",{className:Ut(["react-flow__panel",n,...l]),style:{...r,pointerEvents:o},...s},t)}function QF({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:de.createElement(fb,{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 e5=({x:e,y:t,label:n,labelStyle:r={},labelShowBg:s=!0,labelBgStyle:o={},labelBgPadding:l=[2,4],labelBgBorderRadius:u=2,children:d,className:h,...f})=>{const p=w.useRef(null),[g,v]=w.useState({x:0,y:0,width:0,height:0}),k=Ut(["react-flow__edge-textwrapper",h]);return w.useEffect(()=>{if(p.current){const b=p.current.getBBox();v({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),typeof n>"u"||!n?null:de.createElement("g",{transform:`translate(${e-g.width/2} ${t-g.height/2})`,className:k,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:u,ry:u}),de.createElement("text",{className:"react-flow__edge-text",y:g.height/2,dy:"0.3em",ref:p,style:r},n),d)};var t5=w.memo(e5);const pb=e=>({width:e.offsetWidth,height:e.offsetHeight}),ai=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),mb=(e={x:0,y:0},t)=>({x:ai(e.x,t[0][0],t[1][0]),y:ai(e.y,t[0][1],t[1][1])}),jN=(e,t,n)=>e<t?ai(Math.abs(e-t),1,50)/50:e>n?-ai(Math.abs(e-n),1,50)/50:0,m2=(e,t)=>{const n=jN(e.x,35,t.width-35)*20,r=jN(e.y,35,t.height-35)*20;return[n,r]},g2=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},y2=(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)}),Ol=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),w2=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),SN=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),n5=(e,t)=>w2(y2(Ol(e),Ol(t))),ax=(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)},r5=e=>Dn(e.width)&&Dn(e.height)&&Dn(e.x)&&Dn(e.y),Dn=e=>!isNaN(e)&&isFinite(e),mt=Symbol.for("internals"),v2=["Enter"," ","Escape"],s5=(e,t)=>{},a5=e=>"nativeEvent"in e;function ox(e){var s,o;const t=a5(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 x2=e=>"clientX"in e,Js=(e,t)=>{var o,l;const n=x2(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)}},td=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},tc=({id:e,path:t,labelX:n,labelY:r,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:u,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&&Dn(n)&&Dn(r)?de.createElement(t5,{x:n,y:r,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h}):null);tc.displayName="BaseEdge";function fl(e,t,n){return n===void 0?n:r=>{const s=t().edges.find(o=>o.id===e);s&&n(r,{...s})}}function b2({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,u=r<t?r+l:r-l;return[o,u,s,l]}function k2({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:o,targetControlX:l,targetControlY:u}){const d=e*.125+s*.375+l*.375+n*.125,h=t*.125+o*.375+u*.375+r*.125,f=Math.abs(d-e),p=Math.abs(h-t);return[d,h,f,p]}var Da;(function(e){e.Strict="strict",e.Loose="loose"})(Da||(Da={}));var Aa;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Aa||(Aa={}));var Ll;(function(e){e.Partial="partial",e.Full="full"})(Ll||(Ll={}));var Ks;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ks||(Ks={}));var nd;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(nd||(nd={}));var Ae;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ae||(Ae={}));function _N({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 N2({sourceX:e,sourceY:t,sourcePosition:n=Ae.Bottom,targetX:r,targetY:s,targetPosition:o=Ae.Top}){const[l,u]=_N({pos:n,x1:e,y1:t,x2:r,y2:s}),[d,h]=_N({pos:o,x1:r,y1:s,x2:e,y2:t}),[f,p,g,v]=k2({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:u,targetControlX:d,targetControlY:h});return[`M${e},${t} C${l},${u} ${d},${h} ${r},${s}`,f,p,g,v]}const gb=w.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s=Ae.Bottom,targetPosition:o=Ae.Top,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:k,interactionWidth:b})=>{const[x,N,S]=N2({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o});return de.createElement(tc,{path:x,labelX:N,labelY:S,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:k,interactionWidth:b})});gb.displayName="SimpleBezierEdge";const EN={[Ae.Left]:{x:-1,y:0},[Ae.Right]:{x:1,y:0},[Ae.Top]:{x:0,y:-1},[Ae.Bottom]:{x:0,y:1}},o5=({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},CN=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function i5({source:e,sourcePosition:t=Ae.Bottom,target:n,targetPosition:r=Ae.Top,center:s,offset:o}){const l=EN[t],u=EN[r],d={x:e.x+l.x*o,y:e.y+l.y*o},h={x:n.x+u.x*o,y:n.y+u.y*o},f=o5({source:d,sourcePosition:t,target:h}),p=f.x!==0?"x":"y",g=f[p];let v=[],k,b;const x={x:0,y:0},N={x:0,y:0},[S,_,E,T]=b2({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*u[p]===-1){k=s.x??S,b=s.y??_;const R=[{x:k,y:d.y},{x:k,y:h.y}],B=[{x:d.x,y:b},{x:h.x,y:b}];l[p]===g?v=p==="x"?R:B:v=p==="x"?B:R}else{const R=[{x:d.x,y:h.y}],B=[{x:h.x,y:d.y}];if(p==="x"?v=l.x===g?B:R:v=l.y===g?R:B,t===r){const z=Math.abs(e[p]-n[p]);if(z<=o){const M=Math.min(o-1,o-z);l[p]===g?x[p]=(d[p]>e[p]?-1:1)*M:N[p]=(h[p]>n[p]?-1:1)*M}}if(t!==r){const z=p==="x"?"y":"x",M=l[p]===u[z],$=d[z]>h[z],q=d[z]<h[z];(l[p]===1&&(!M&&$||M&&q)||l[p]!==1&&(!M&&q||M&&$))&&(v=p==="x"?R:B)}const P={x:d.x+x.x,y:d.y+x.y},D={x:h.x+N.x,y:h.y+N.y},I=Math.max(Math.abs(P.x-v[0].x),Math.abs(D.x-v[0].x)),O=Math.max(Math.abs(P.y-v[0].y),Math.abs(D.y-v[0].y));I>=O?(k=(P.x+D.x)/2,b=v[0].y):(k=v[0].x,b=(P.y+D.y)/2)}return[[e,{x:d.x+x.x,y:d.y+x.y},...v,{x:h.x+N.x,y:h.y+N.y},n],k,b,E,T]}function l5(e,t,n,r){const s=Math.min(CN(e,t)/2,CN(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 u=e.x<n.x?1:-1,d=e.y<n.y?-1:1;return`L ${o},${l+s*d}Q ${o},${l} ${o+s*u},${l}`}function ix({sourceX:e,sourceY:t,sourcePosition:n=Ae.Bottom,targetX:r,targetY:s,targetPosition:o=Ae.Top,borderRadius:l=5,centerX:u,centerY:d,offset:h=20}){const[f,p,g,v,k]=i5({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:o,center:{x:u,y:d},offset:h});return[f.reduce((x,N,S)=>{let _="";return S>0&&S<f.length-1?_=l5(f[S-1],N,f[S+1],l):_=`${S===0?"M":"L"}${N.x} ${N.y}`,x+=_,x},""),p,g,v,k]}const $d=w.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:f,sourcePosition:p=Ae.Bottom,targetPosition:g=Ae.Top,markerEnd:v,markerStart:k,pathOptions:b,interactionWidth:x})=>{const[N,S,_]=ix({sourceX:e,sourceY:t,sourcePosition:p,targetX:n,targetY:r,targetPosition:g,borderRadius:b==null?void 0:b.borderRadius,offset:b==null?void 0:b.offset});return de.createElement(tc,{path:N,labelX:S,labelY:_,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:v,markerStart:k,interactionWidth:x})});$d.displayName="SmoothStepEdge";const yb=w.memo(e=>{var t;return de.createElement($d,{...e,pathOptions:w.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});yb.displayName="StepEdge";function c5({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,o,l,u]=b2({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,o,l,u]}const wb=w.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:g,interactionWidth:v})=>{const[k,b,x]=c5({sourceX:e,sourceY:t,targetX:n,targetY:r});return de.createElement(tc,{path:k,labelX:b,labelY:x,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:g,interactionWidth:v})});wb.displayName="StraightEdge";function yu(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function TN({pos:e,x1:t,y1:n,x2:r,y2:s,c:o}){switch(e){case Ae.Left:return[t-yu(t-r,o),n];case Ae.Right:return[t+yu(r-t,o),n];case Ae.Top:return[t,n-yu(n-s,o)];case Ae.Bottom:return[t,n+yu(s-n,o)]}}function vb({sourceX:e,sourceY:t,sourcePosition:n=Ae.Bottom,targetX:r,targetY:s,targetPosition:o=Ae.Top,curvature:l=.25}){const[u,d]=TN({pos:n,x1:e,y1:t,x2:r,y2:s,c:l}),[h,f]=TN({pos:o,x1:r,y1:s,x2:e,y2:t,c:l}),[p,g,v,k]=k2({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:u,sourceControlY:d,targetControlX:h,targetControlY:f});return[`M${e},${t} C${u},${d} ${h},${f} ${r},${s}`,p,g,v,k]}const rd=w.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s=Ae.Bottom,targetPosition:o=Ae.Top,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:k,pathOptions:b,interactionWidth:x})=>{const[N,S,_]=vb({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o,curvature:b==null?void 0:b.curvature});return de.createElement(tc,{path:N,labelX:S,labelY:_,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:k,interactionWidth:x})});rd.displayName="BezierEdge";const xb=w.createContext(null),u5=xb.Provider;xb.Consumer;const d5=()=>w.useContext(xb),h5=e=>"id"in e&&"source"in e&&"target"in e,f5=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,lx=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`,p5=(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)),m5=(e,t)=>{if(!e.source||!e.target)return t;let n;return h5(e)?n={...e}:n={...e,id:f5(e)},p5(n,t)?t:t.concat(n)},cx=({x:e,y:t},[n,r,s],o,[l,u])=>{const d={x:(e-n)/s,y:(t-r)/s};return o?{x:l*Math.round(d.x/l),y:u*Math.round(d.y/u)}:d},j2=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r}),$a=(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}},Id=(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}=$a(s,t).positionAbsolute;return y2(r,Ol({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 w2(n)},S2=(e,t,[n,r,s]=[0,0,1],o=!1,l=!1,u=[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:k=!1}=f;if(l&&!v||k)return!1;const{positionAbsolute:b}=$a(f,u),x={x:b.x,y:b.y,width:p||0,height:g||0},N=ax(d,x),S=typeof p>"u"||typeof g>"u"||p===null||g===null,_=o&&N>0,E=(p||0)*(g||0);(S||_||N>=E||f.dragging)&&h.push(f)}),h},_2=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},E2=(e,t,n,r,s,o=.1)=>{const l=t/(e.width*(1+o)),u=n/(e.height*(1+o)),d=Math.min(l,u),h=ai(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}},Sa=(e,t=0)=>e.transition().duration(t);function AN(e,t,n,r){return(t[n]||[]).reduce((s,o)=>{var l,u;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:(((u=e.positionAbsolute)==null?void 0:u.y)??0)+o.y+o.height/2}),s},[])}function g5(e,t,n,r,s,o){const{x:l,y:u}=Js(e),h=t.elementsFromPoint(l,u).find(k=>k.classList.contains("react-flow__handle"));if(h){const k=h.getAttribute("data-nodeid");if(k){const b=bb(void 0,h),x=h.getAttribute("data-handleid"),N=o({nodeId:k,id:x,type:b});if(N){const S=s.find(_=>_.nodeId===k&&_.type===b&&_.id===x);return{handle:{id:x,type:b,nodeId:k,x:(S==null?void 0:S.x)||n.x,y:(S==null?void 0:S.y)||n.y},validHandleResult:N}}}}let f=[],p=1/0;if(s.forEach(k=>{const b=Math.sqrt((k.x-n.x)**2+(k.y-n.y)**2);if(b<=r){const x=o(k);b<=p&&(b<p?f=[{handle:k,validHandleResult:x}]:b===p&&f.push({handle:k,validHandleResult:x}),p=b)}}),!f.length)return{handle:null,validHandleResult:C2()};if(f.length===1)return f[0];const g=f.some(({validHandleResult:k})=>k.isValid),v=f.some(({handle:k})=>k.type==="target");return f.find(({handle:k,validHandleResult:b})=>v?k.type==="target":g?b.isValid:!0)||f[0]}const y5={source:null,target:null,sourceHandle:null,targetHandle:null},C2=()=>({handleDomNode:null,isValid:!1,connection:y5,endHandle:null});function T2(e,t,n,r,s,o,l){const u=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={...C2(),handleDomNode:d};if(d){const f=bb(void 0,d),p=d.getAttribute("data-nodeid"),g=d.getAttribute("data-handleid"),v=d.classList.contains("connectable"),k=d.classList.contains("connectableend"),b={source:u?p:n,sourceHandle:u?g:r,target:u?n:p,targetHandle:u?r:g};h.connection=b,v&&k&&(t===Da.Strict?u&&f==="source"||!u&&f==="target":p!==n||g!==r)&&(h.endHandle={nodeId:p,handleId:g,type:f},h.isValid=o(b))}return h}function w5({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((s,o)=>{if(o[mt]){const{handleBounds:l}=o[mt];let u=[],d=[];l&&(u=AN(o,l,"source",`${t}-${n}-${r}`),d=AN(o,l,"target",`${t}-${n}-${r}`)),s.push(...u,...d)}return s},[])}function bb(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function sp(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function v5(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function A2({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:s,getState:o,setState:l,isValidConnection:u,edgeUpdaterType:d,onReconnectEnd:h}){const f=g2(e.target),{connectionMode:p,domNode:g,autoPanOnConnect:v,connectionRadius:k,onConnectStart:b,panBy:x,getNodes:N,cancelConnection:S}=o();let _=0,E;const{x:T,y:A}=Js(e),R=f==null?void 0:f.elementFromPoint(T,A),B=bb(d,R),P=g==null?void 0:g.getBoundingClientRect();if(!P||!B)return;let D,I=Js(e,P),O=!1,z=null,M=!1,$=null;const q=w5({nodes:N(),nodeId:n,handleId:t,handleType:B}),X=()=>{if(!v)return;const[W,F]=m2(I,P);x({x:W,y:F}),_=requestAnimationFrame(X)};l({connectionPosition:I,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:B,connectionStartHandle:{nodeId:n,handleId:t,type:B},connectionEndHandle:null}),b==null||b(e,{nodeId:n,handleId:t,handleType:B});function H(W){const{transform:F}=o();I=Js(W,P);const{handle:Y,validHandleResult:J}=g5(W,f,cx(I,F,!1,[1,1]),k,q,V=>T2(V,p,n,t,s?"target":"source",u,f));if(E=Y,O||(X(),O=!0),$=J.handleDomNode,z=J.connection,M=J.isValid,l({connectionPosition:E&&M?j2({x:E.x,y:E.y},F):I,connectionStatus:v5(!!E,M),connectionEndHandle:J.endHandle}),!E&&!M&&!$)return sp(D);z.source!==z.target&&$&&(sp(D),D=$,$.classList.add("connecting","react-flow__handle-connecting"),$.classList.toggle("valid",M),$.classList.toggle("react-flow__handle-valid",M))}function L(W){var F,Y;(E||$)&&z&&M&&(r==null||r(z)),(Y=(F=o()).onConnectEnd)==null||Y.call(F,W),d&&(h==null||h(W)),sp(D),S(),cancelAnimationFrame(_),O=!1,M=!1,z=null,$=null,f.removeEventListener("mousemove",H),f.removeEventListener("mouseup",L),f.removeEventListener("touchmove",H),f.removeEventListener("touchend",L)}f.addEventListener("mousemove",H),f.addEventListener("mouseup",L),f.addEventListener("touchmove",H),f.addEventListener("touchend",L)}const RN=()=>!0,x5=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),b5=(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}},R2=w.forwardRef(({type:e="source",position:t=Ae.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:o=!0,id:l,onConnect:u,children:d,className:h,onMouseDown:f,onTouchStart:p,...g},v)=>{var P,D;const k=l||null,b=e==="target",x=kt(),N=d5(),{connectOnClick:S,noPanClassName:_}=Ge(x5,Tt),{connecting:E,clickConnecting:T}=Ge(b5(N,k,e),Tt);N||(D=(P=x.getState()).onError)==null||D.call(P,"010",hs.error010());const A=I=>{const{defaultEdgeOptions:O,onConnect:z,hasDefaultEdges:M}=x.getState(),$={...O,...I};if(M){const{edges:q,setEdges:X}=x.getState();X(m5($,q))}z==null||z($),u==null||u($)},R=I=>{if(!N)return;const O=x2(I);s&&(O&&I.button===0||!O)&&A2({event:I,handleId:k,nodeId:N,onConnect:A,isTarget:b,getState:x.getState,setState:x.setState,isValidConnection:n||x.getState().isValidConnection||RN}),O?f==null||f(I):p==null||p(I)},B=I=>{const{onClickConnectStart:O,onClickConnectEnd:z,connectionClickStartHandle:M,connectionMode:$,isValidConnection:q}=x.getState();if(!N||!M&&!s)return;if(!M){O==null||O(I,{nodeId:N,handleId:k,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:N,type:e,handleId:k}});return}const X=g2(I.target),H=n||q||RN,{connection:L,isValid:W}=T2({nodeId:N,id:k,type:e},$,M.nodeId,M.handleId||null,M.type,H,X);W&&A(L),z==null||z(I),x.setState({connectionClickStartHandle:null})};return de.createElement("div",{"data-handleid":k,"data-nodeid":N,"data-handlepos":t,"data-id":`${N}-${k}-${e}`,className:Ut(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",_,h,{source:!b,target:b,connectable:r,connectablestart:s,connectableend:o,connecting:T,connectionindicator:r&&(s&&!E||o&&E)}]),onMouseDown:R,onTouchStart:R,onClick:S?B:void 0,ref:v,...g},d)});R2.displayName="Handle";var Fa=w.memo(R2);const M2=({data:e,isConnectable:t,targetPosition:n=Ae.Top,sourcePosition:r=Ae.Bottom})=>de.createElement(de.Fragment,null,de.createElement(Fa,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,de.createElement(Fa,{type:"source",position:r,isConnectable:t}));M2.displayName="DefaultNode";var ux=w.memo(M2);const $2=({data:e,isConnectable:t,sourcePosition:n=Ae.Bottom})=>de.createElement(de.Fragment,null,e==null?void 0:e.label,de.createElement(Fa,{type:"source",position:n,isConnectable:t}));$2.displayName="InputNode";var I2=w.memo($2);const O2=({data:e,isConnectable:t,targetPosition:n=Ae.Top})=>de.createElement(de.Fragment,null,de.createElement(Fa,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);O2.displayName="OutputNode";var L2=w.memo(O2);const kb=()=>null;kb.displayName="GroupNode";const k5=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),wu=e=>e.id;function N5(e,t){return Tt(e.selectedNodes.map(wu),t.selectedNodes.map(wu))&&Tt(e.selectedEdges.map(wu),t.selectedEdges.map(wu))}const P2=w.memo(({onSelectionChange:e})=>{const t=kt(),{selectedNodes:n,selectedEdges:r}=Ge(k5,N5);return w.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChange.forEach(o=>o(s))},[n,r,e]),null});P2.displayName="SelectionListener";const j5=e=>!!e.onSelectionChange;function S5({onSelectionChange:e}){const t=Ge(j5);return e||t?de.createElement(P2,{onSelectionChange:e}):null}const _5=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 Co(e,t){w.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function Pe(e,t,n){w.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const E5=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:s,onConnectStart:o,onConnectEnd:l,onClickConnectStart:u,onClickConnectEnd:d,nodesDraggable:h,nodesConnectable:f,nodesFocusable:p,edgesFocusable:g,edgesUpdatable:v,elevateNodesOnSelect:k,minZoom:b,maxZoom:x,nodeExtent:N,onNodesChange:S,onEdgesChange:_,elementsSelectable:E,connectionMode:T,snapGrid:A,snapToGrid:R,translateExtent:B,connectOnClick:P,defaultEdgeOptions:D,fitView:I,fitViewOptions:O,onNodesDelete:z,onEdgesDelete:M,onNodeDrag:$,onNodeDragStart:q,onNodeDragStop:X,onSelectionDrag:H,onSelectionDragStart:L,onSelectionDragStop:W,noPanClassName:F,nodeOrigin:Y,rfId:J,autoPanOnConnect:V,autoPanOnNodeDrag:G,onError:K,connectionRadius:Z,isValidConnection:ee,nodeDragThreshold:re})=>{const{setNodes:ue,setEdges:me,setDefaultNodesAndEdges:ie,setMinZoom:fe,setMaxZoom:ve,setTranslateExtent:se,setNodeExtent:ke,reset:pe}=Ge(_5,Tt),he=kt();return w.useEffect(()=>{const ae=r==null?void 0:r.map(Ne=>({...Ne,...D}));return ie(n,ae),()=>{pe()}},[]),Pe("defaultEdgeOptions",D,he.setState),Pe("connectionMode",T,he.setState),Pe("onConnect",s,he.setState),Pe("onConnectStart",o,he.setState),Pe("onConnectEnd",l,he.setState),Pe("onClickConnectStart",u,he.setState),Pe("onClickConnectEnd",d,he.setState),Pe("nodesDraggable",h,he.setState),Pe("nodesConnectable",f,he.setState),Pe("nodesFocusable",p,he.setState),Pe("edgesFocusable",g,he.setState),Pe("edgesUpdatable",v,he.setState),Pe("elementsSelectable",E,he.setState),Pe("elevateNodesOnSelect",k,he.setState),Pe("snapToGrid",R,he.setState),Pe("snapGrid",A,he.setState),Pe("onNodesChange",S,he.setState),Pe("onEdgesChange",_,he.setState),Pe("connectOnClick",P,he.setState),Pe("fitViewOnInit",I,he.setState),Pe("fitViewOnInitOptions",O,he.setState),Pe("onNodesDelete",z,he.setState),Pe("onEdgesDelete",M,he.setState),Pe("onNodeDrag",$,he.setState),Pe("onNodeDragStart",q,he.setState),Pe("onNodeDragStop",X,he.setState),Pe("onSelectionDrag",H,he.setState),Pe("onSelectionDragStart",L,he.setState),Pe("onSelectionDragStop",W,he.setState),Pe("noPanClassName",F,he.setState),Pe("nodeOrigin",Y,he.setState),Pe("rfId",J,he.setState),Pe("autoPanOnConnect",V,he.setState),Pe("autoPanOnNodeDrag",G,he.setState),Pe("onError",K,he.setState),Pe("connectionRadius",Z,he.setState),Pe("isValidConnection",ee,he.setState),Pe("nodeDragThreshold",re,he.setState),Co(e,ue),Co(t,me),Co(b,fe),Co(x,ve),Co(B,se),Co(N,ke),null},MN={display:"none"},C5={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},D2="react-flow__node-desc",F2="react-flow__edge-desc",T5="react-flow__aria-live",A5=e=>e.ariaLiveMessage;function R5({rfId:e}){const t=Ge(A5);return de.createElement("div",{id:`${T5}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:C5},t)}function M5({rfId:e,disableKeyboardA11y:t}){return de.createElement(de.Fragment,null,de.createElement("div",{id:`${D2}-${e}`,style:MN},"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:`${F2}-${e}`,style:MN},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&de.createElement(R5,{rfId:e}))}var Pl=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,r]=w.useState(!1),s=w.useRef(!1),o=w.useRef(new Set([])),[l,u]=w.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 w.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)&&ox(v))return!1;const b=IN(v.code,u);o.current.add(v[b]),$N(l,o.current,!1)&&(v.preventDefault(),r(!0))},p=v=>{if((!s.current||s.current&&!t.actInsideInputWithModifier)&&ox(v))return!1;const b=IN(v.code,u);$N(l,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(v[b]),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 $N(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function IN(e,t){return t.includes(e)?"code":"key"}function B2(e,t,n,r){var u,d;const s=e.parentNode||e.parentId;if(!s)return n;const o=t.get(s),l=$a(o,r);return B2(o,t,{x:(n.x??0)+l.x,y:(n.y??0)+l.y,z:(((u=o[mt])==null?void 0:u.z)??0)>(n.z??0)?((d=o[mt])==null?void 0:d.z)??0:n.z??0},r)}function q2(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:u,z:d}=B2(r,e,{...r.position,z:((o=r[mt])==null?void 0:o.z)??0},t);r.positionAbsolute={x:l,y:u},r[mt].z=d,n!=null&&n[r.id]&&(r[mt].isParent=!0)}})}function ap(e,t,n,r){const s=new Map,o={},l=r?1e3:0;return e.forEach(u=>{var v;const d=(Dn(u.zIndex)?u.zIndex:0)+(u.selected?l:0),h=t.get(u.id),f={...u,positionAbsolute:{x:u.position.x,y:u.position.y}},p=u.parentNode||u.parentId;p&&(o[p]=!0);const g=(h==null?void 0:h.type)&&(h==null?void 0:h.type)!==u.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(u.id,f)}),q2(s,n,o),s}function U2(e,t={}){const{getNodes:n,width:r,height:s,minZoom:o,maxZoom:l,d3Zoom:u,d3Selection:d,fitViewOnInitDone:h,fitViewOnInit:f,nodeOrigin:p}=e(),g=t.initial&&!h&&f;if(u&&d&&(g||!t.initial)){const k=n().filter(x=>{var S;const N=t.includeHiddenNodes?x.width&&x.height:!x.hidden;return(S=t.nodes)!=null&&S.length?N&&t.nodes.some(_=>_.id===x.id):N}),b=k.every(x=>x.width&&x.height);if(k.length>0&&b){const x=Id(k,p),{x:N,y:S,zoom:_}=E2(x,r,s,t.minZoom??o,t.maxZoom??l,t.padding??.1),E=cs.translate(N,S).scale(_);return typeof t.duration=="number"&&t.duration>0?u.transform(Sa(d,t.duration),E):u.transform(d,E),!0}}return!1}function $5(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 I5(e,t){return t.map(n=>{const r=e.find(s=>s.id===n.id);return r&&(n.selected=r.selected),n})}function vu({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:s,edges:o,onNodesChange:l,onEdgesChange:u,hasDefaultNodes:d,hasDefaultEdges:h}=n();e!=null&&e.length&&(d&&r({nodeInternals:$5(e,s)}),l==null||l(e)),t!=null&&t.length&&(h&&r({edges:I5(t,o)}),u==null||u(t))}const To=()=>{},O5={zoomIn:To,zoomOut:To,zoomTo:To,getZoom:()=>1,setViewport:To,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:To,fitBounds:To,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},L5=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),P5=()=>{const e=kt(),{d3Zoom:t,d3Selection:n}=Ge(L5,Tt);return w.useMemo(()=>n&&t?{zoomIn:s=>t.scaleBy(Sa(n,s==null?void 0:s.duration),1.2),zoomOut:s=>t.scaleBy(Sa(n,s==null?void 0:s.duration),1/1.2),zoomTo:(s,o)=>t.scaleTo(Sa(n,o==null?void 0:o.duration),s),getZoom:()=>e.getState().transform[2],setViewport:(s,o)=>{const[l,u,d]=e.getState().transform,h=cs.translate(s.x??l,s.y??u).scale(s.zoom??d);t.transform(Sa(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=>U2(e.getState,s),setCenter:(s,o,l)=>{const{width:u,height:d,maxZoom:h}=e.getState(),f=typeof(l==null?void 0:l.zoom)<"u"?l.zoom:h,p=u/2-s*f,g=d/2-o*f,v=cs.translate(p,g).scale(f);t.transform(Sa(n,l==null?void 0:l.duration),v)},fitBounds:(s,o)=>{const{width:l,height:u,minZoom:d,maxZoom:h}=e.getState(),{x:f,y:p,zoom:g}=E2(s,l,u,d,h,(o==null?void 0:o.padding)??.1),v=cs.translate(f,p).scale(g);t.transform(Sa(n,o==null?void 0:o.duration),v)},project:s=>{const{transform:o,snapToGrid:l,snapGrid:u}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),cx(s,o,l,u)},screenToFlowPosition:s=>{const{transform:o,snapToGrid:l,snapGrid:u,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 cx(p,o,l,u)},flowToScreenPosition:s=>{const{transform:o,domNode:l}=e.getState();if(!l)return s;const{x:u,y:d}=l.getBoundingClientRect(),h=j2(s,o);return{x:h.x+u,y:h.y+d}},viewportInitialized:!0}:O5,[t,n])};function gi(){const e=P5(),t=kt(),n=w.useCallback(()=>t.getState().getNodes().map(b=>({...b})),[]),r=w.useCallback(b=>t.getState().nodeInternals.get(b),[]),s=w.useCallback(()=>{const{edges:b=[]}=t.getState();return b.map(x=>({...x}))},[]),o=w.useCallback(b=>{const{edges:x=[]}=t.getState();return x.find(N=>N.id===b)},[]),l=w.useCallback(b=>{const{getNodes:x,setNodes:N,hasDefaultNodes:S,onNodesChange:_}=t.getState(),E=x(),T=typeof b=="function"?b(E):b;if(S)N(T);else if(_){const A=T.length===0?E.map(R=>({type:"remove",id:R.id})):T.map(R=>({item:R,type:"reset"}));_(A)}},[]),u=w.useCallback(b=>{const{edges:x=[],setEdges:N,hasDefaultEdges:S,onEdgesChange:_}=t.getState(),E=typeof b=="function"?b(x):b;if(S)N(E);else if(_){const T=E.length===0?x.map(A=>({type:"remove",id:A.id})):E.map(A=>({item:A,type:"reset"}));_(T)}},[]),d=w.useCallback(b=>{const x=Array.isArray(b)?b:[b],{getNodes:N,setNodes:S,hasDefaultNodes:_,onNodesChange:E}=t.getState();if(_){const A=[...N(),...x];S(A)}else if(E){const T=x.map(A=>({item:A,type:"add"}));E(T)}},[]),h=w.useCallback(b=>{const x=Array.isArray(b)?b:[b],{edges:N=[],setEdges:S,hasDefaultEdges:_,onEdgesChange:E}=t.getState();if(_)S([...N,...x]);else if(E){const T=x.map(A=>({item:A,type:"add"}));E(T)}},[]),f=w.useCallback(()=>{const{getNodes:b,edges:x=[],transform:N}=t.getState(),[S,_,E]=N;return{nodes:b().map(T=>({...T})),edges:x.map(T=>({...T})),viewport:{x:S,y:_,zoom:E}}},[]),p=w.useCallback(({nodes:b,edges:x})=>{const{nodeInternals:N,getNodes:S,edges:_,hasDefaultNodes:E,hasDefaultEdges:T,onNodesDelete:A,onEdgesDelete:R,onNodesChange:B,onEdgesChange:P}=t.getState(),D=(b||[]).map($=>$.id),I=(x||[]).map($=>$.id),O=S().reduce(($,q)=>{const X=q.parentNode||q.parentId,H=!D.includes(q.id)&&X&&$.find(W=>W.id===X);return(typeof q.deletable=="boolean"?q.deletable:!0)&&(D.includes(q.id)||H)&&$.push(q),$},[]),z=_.filter($=>typeof $.deletable=="boolean"?$.deletable:!0),M=z.filter($=>I.includes($.id));if(O||M){const $=_2(O,z),q=[...M,...$],X=q.reduce((H,L)=>(H.includes(L.id)||H.push(L.id),H),[]);if((T||E)&&(T&&t.setState({edges:_.filter(H=>!X.includes(H.id))}),E&&(O.forEach(H=>{N.delete(H.id)}),t.setState({nodeInternals:new Map(N)}))),X.length>0&&(R==null||R(q),P&&P(X.map(H=>({id:H,type:"remove"})))),O.length>0&&(A==null||A(O),B)){const H=O.map(L=>({id:L.id,type:"remove"}));B(H)}}},[]),g=w.useCallback(b=>{const x=r5(b),N=x?null:t.getState().nodeInternals.get(b.id);return!x&&!N?[null,null,x]:[x?b:SN(N),N,x]},[]),v=w.useCallback((b,x=!0,N)=>{const[S,_,E]=g(b);return S?(N||t.getState().getNodes()).filter(T=>{if(!E&&(T.id===_.id||!T.positionAbsolute))return!1;const A=SN(T),R=ax(A,S);return x&&R>0||R>=S.width*S.height}):[]},[]),k=w.useCallback((b,x,N=!0)=>{const[S]=g(b);if(!S)return!1;const _=ax(S,x);return N&&_>0||_>=S.width*S.height},[]);return w.useMemo(()=>({...e,getNodes:n,getNode:r,getEdges:s,getEdge:o,setNodes:l,setEdges:u,addNodes:d,addEdges:h,toObject:f,deleteElements:p,getIntersectingNodes:v,isNodeIntersecting:k}),[e,n,r,s,o,l,u,d,h,f,p,v,k])}const D5={actInsideInputWithModifier:!1};var F5=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=kt(),{deleteElements:r}=gi(),s=Pl(e,D5),o=Pl(t);w.useEffect(()=>{if(s){const{edges:l,getNodes:u}=n.getState(),d=u().filter(f=>f.selected),h=l.filter(f=>f.selected);r({nodes:d,edges:h}),n.setState({nodesSelectionActive:!1})}},[s]),w.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])};function B5(e){const t=kt();w.useEffect(()=>{let n;const r=()=>{var o,l;if(!e.current)return;const s=pb(e.current);(s.height===0||s.width===0)&&((l=(o=t.getState()).onError)==null||l.call(o,"004",hs.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 Nb={position:"absolute",width:"100%",height:"100%",top:0,left:0},q5=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,xu=e=>({x:e.x,y:e.y,zoom:e.k}),Ao=(e,t)=>e.target.closest(`.${t}`),ON=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),LN=e=>{const t=e.ctrlKey&&td()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},U5=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),z5=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:s=!0,zoomOnPinch:o=!0,panOnScroll:l=!1,panOnScrollSpeed:u=.5,panOnScrollMode:d=Aa.Free,zoomOnDoubleClick:h=!0,elementsSelectable:f,panOnDrag:p=!0,defaultViewport:g,translateExtent:v,minZoom:k,maxZoom:b,zoomActivationKeyCode:x,preventScrolling:N=!0,children:S,noWheelClassName:_,noPanClassName:E})=>{const T=w.useRef(),A=kt(),R=w.useRef(!1),B=w.useRef(!1),P=w.useRef(null),D=w.useRef({x:0,y:0,zoom:0}),{d3Zoom:I,d3Selection:O,d3ZoomHandler:z,userSelectionActive:M}=Ge(U5,Tt),$=Pl(x),q=w.useRef(0),X=w.useRef(!1),H=w.useRef();return B5(P),w.useEffect(()=>{if(P.current){const L=P.current.getBoundingClientRect(),W=f2().scaleExtent([k,b]).translateExtent(v),F=Pn(P.current).call(W),Y=cs.translate(g.x,g.y).scale(ai(g.zoom,k,b)),J=[[0,0],[L.width,L.height]],V=W.constrain()(Y,J,v);W.transform(F,V),W.wheelDelta(LN),A.setState({d3Zoom:W,d3Selection:F,d3ZoomHandler:F.on("wheel.zoom"),transform:[V.x,V.y,V.k],domNode:P.current.closest(".react-flow")})}},[]),w.useEffect(()=>{O&&I&&(l&&!$&&!M?O.on("wheel.zoom",L=>{if(Ao(L,_))return!1;L.preventDefault(),L.stopImmediatePropagation();const W=O.property("__zoom").k||1;if(L.ctrlKey&&o){const ee=ar(L),re=LN(L),ue=W*Math.pow(2,re);I.scaleTo(O,ue,ee,L);return}const F=L.deltaMode===1?20:1;let Y=d===Aa.Vertical?0:L.deltaX*F,J=d===Aa.Horizontal?0:L.deltaY*F;!td()&&L.shiftKey&&d!==Aa.Vertical&&(Y=L.deltaY*F,J=0),I.translateBy(O,-(Y/W)*u,-(J/W)*u,{internal:!0});const V=xu(O.property("__zoom")),{onViewportChangeStart:G,onViewportChange:K,onViewportChangeEnd:Z}=A.getState();clearTimeout(H.current),X.current||(X.current=!0,t==null||t(L,V),G==null||G(V)),X.current&&(e==null||e(L,V),K==null||K(V),H.current=setTimeout(()=>{n==null||n(L,V),Z==null||Z(V),X.current=!1},150))},{passive:!1}):typeof z<"u"&&O.on("wheel.zoom",function(L,W){if(!N&&L.type==="wheel"&&!L.ctrlKey||Ao(L,_))return null;L.preventDefault(),z.call(this,L,W)},{passive:!1}))},[M,l,d,O,I,z,$,o,N,_,t,e,n]),w.useEffect(()=>{I&&I.on("start",L=>{var Y,J;if(!L.sourceEvent||L.sourceEvent.internal)return null;q.current=(Y=L.sourceEvent)==null?void 0:Y.button;const{onViewportChangeStart:W}=A.getState(),F=xu(L.transform);R.current=!0,D.current=F,((J=L.sourceEvent)==null?void 0:J.type)==="mousedown"&&A.setState({paneDragging:!0}),W==null||W(F),t==null||t(L.sourceEvent,F)})},[I,t]),w.useEffect(()=>{I&&(M&&!R.current?I.on("zoom",null):M||I.on("zoom",L=>{var F;const{onViewportChange:W}=A.getState();if(A.setState({transform:[L.transform.x,L.transform.y,L.transform.k]}),B.current=!!(r&&ON(p,q.current??0)),(e||W)&&!((F=L.sourceEvent)!=null&&F.internal)){const Y=xu(L.transform);W==null||W(Y),e==null||e(L.sourceEvent,Y)}}))},[M,I,e,p,r]),w.useEffect(()=>{I&&I.on("end",L=>{if(!L.sourceEvent||L.sourceEvent.internal)return null;const{onViewportChangeEnd:W}=A.getState();if(R.current=!1,A.setState({paneDragging:!1}),r&&ON(p,q.current??0)&&!B.current&&r(L.sourceEvent),B.current=!1,(n||W)&&q5(D.current,L.transform)){const F=xu(L.transform);D.current=F,clearTimeout(T.current),T.current=setTimeout(()=>{W==null||W(F),n==null||n(L.sourceEvent,F)},l?150:0)}})},[I,l,p,n,r]),w.useEffect(()=>{I&&I.filter(L=>{const W=$||s,F=o&&L.ctrlKey;if((p===!0||Array.isArray(p)&&p.includes(1))&&L.button===1&&L.type==="mousedown"&&(Ao(L,"react-flow__node")||Ao(L,"react-flow__edge")))return!0;if(!p&&!W&&!l&&!h&&!o||M||!h&&L.type==="dblclick"||Ao(L,_)&&L.type==="wheel"||Ao(L,E)&&(L.type!=="wheel"||l&&L.type==="wheel"&&!$)||!o&&L.ctrlKey&&L.type==="wheel"||!W&&!l&&!F&&L.type==="wheel"||!p&&(L.type==="mousedown"||L.type==="touchstart")||Array.isArray(p)&&!p.includes(L.button)&&L.type==="mousedown")return!1;const Y=Array.isArray(p)&&p.includes(L.button)||!L.button||L.button<=1;return(!L.ctrlKey||L.type==="wheel")&&Y})},[M,I,s,o,l,h,p,f,$]),de.createElement("div",{className:"react-flow__renderer",ref:P,style:Nb},S)},W5=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function H5(){const{userSelectionActive:e,userSelectionRect:t}=Ge(W5,Tt);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 PN(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 V5(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(u=>u.id===s.id);if(o.length===0)return r.push(s),r;const l={...s};for(const u of o)if(u)switch(u.type){case"select":{l.selected=u.selected;break}case"position":{typeof u.position<"u"&&(l.position=u.position),typeof u.positionAbsolute<"u"&&(l.positionAbsolute=u.positionAbsolute),typeof u.dragging<"u"&&(l.dragging=u.dragging),l.expandParent&&PN(r,l);break}case"dimensions":{typeof u.dimensions<"u"&&(l.width=u.dimensions.width,l.height=u.dimensions.height),typeof u.updateStyle<"u"&&(l.style={...l.style||{},...u.dimensions}),typeof u.resizing=="boolean"&&(l.resizing=u.resizing),l.expandParent&&PN(r,l);break}case"remove":return r}return r.push(l),r},n)}function G5(e,t){return V5(e,t)}const Gs=(e,t)=>({id:e,type:"select",selected:t});function Wo(e,t){return e.reduce((n,r)=>{const s=t.includes(r.id);return!r.selected&&s?(r.selected=!0,n.push(Gs(r.id,!0))):r.selected&&!s&&(r.selected=!1,n.push(Gs(r.id,!1))),n},[])}const op=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},K5=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),z2=w.memo(({isSelecting:e,selectionMode:t=Ll.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:s,onPaneClick:o,onPaneContextMenu:l,onPaneScroll:u,onPaneMouseEnter:d,onPaneMouseMove:h,onPaneMouseLeave:f,children:p})=>{const g=w.useRef(null),v=kt(),k=w.useRef(0),b=w.useRef(0),x=w.useRef(),{userSelectionActive:N,elementsSelectable:S,dragging:_}=Ge(K5,Tt),E=()=>{v.setState({userSelectionActive:!1,userSelectionRect:null}),k.current=0,b.current=0},T=z=>{o==null||o(z),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},A=z=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){z.preventDefault();return}l==null||l(z)},R=u?z=>u(z):void 0,B=z=>{const{resetSelectedElements:M,domNode:$}=v.getState();if(x.current=$==null?void 0:$.getBoundingClientRect(),!S||!e||z.button!==0||z.target!==g.current||!x.current)return;const{x:q,y:X}=Js(z,x.current);M(),v.setState({userSelectionRect:{width:0,height:0,startX:q,startY:X,x:q,y:X}}),r==null||r(z)},P=z=>{const{userSelectionRect:M,nodeInternals:$,edges:q,transform:X,onNodesChange:H,onEdgesChange:L,nodeOrigin:W,getNodes:F}=v.getState();if(!e||!x.current||!M)return;v.setState({userSelectionActive:!0,nodesSelectionActive:!1});const Y=Js(z,x.current),J=M.startX??0,V=M.startY??0,G={...M,x:Y.x<J?Y.x:J,y:Y.y<V?Y.y:V,width:Math.abs(Y.x-J),height:Math.abs(Y.y-V)},K=F(),Z=S2($,G,X,t===Ll.Partial,!0,W),ee=_2(Z,q).map(ue=>ue.id),re=Z.map(ue=>ue.id);if(k.current!==re.length){k.current=re.length;const ue=Wo(K,re);ue.length&&(H==null||H(ue))}if(b.current!==ee.length){b.current=ee.length;const ue=Wo(q,ee);ue.length&&(L==null||L(ue))}v.setState({userSelectionRect:G})},D=z=>{if(z.button!==0)return;const{userSelectionRect:M}=v.getState();!N&&M&&z.target===g.current&&(T==null||T(z)),v.setState({nodesSelectionActive:k.current>0}),E(),s==null||s(z)},I=z=>{N&&(v.setState({nodesSelectionActive:k.current>0}),s==null||s(z)),E()},O=S&&(e||N);return de.createElement("div",{className:Ut(["react-flow__pane",{dragging:_,selection:e}]),onClick:O?void 0:op(T,g),onContextMenu:op(A,g),onWheel:op(R,g),onMouseEnter:O?void 0:d,onMouseDown:O?B:void 0,onMouseMove:O?P:h,onMouseUp:O?D:void 0,onMouseLeave:O?I:f,ref:g,style:Nb},p,de.createElement(H5,null))});z2.displayName="Pane";function W2(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return r?r.selected?!0:W2(r,t):!1}function DN(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 Y5(e,t,n,r){return Array.from(e.values()).filter(s=>(s.selected||s.id===r)&&(!s.parentNode||s.parentId||!W2(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 X5(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function H2(e,t,n,r,s=[0,0],o){const l=X5(e,e.extent||r);let u=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}=$a(p,s).positionAbsolute;u=p&&Dn(g)&&Dn(v)&&Dn(p.width)&&Dn(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]]]:u}else o==null||o("005",hs.error005()),u=l;else if(e.extent&&d&&e.extent!=="parent"){const p=n.get(d),{x:g,y:v}=$a(p,s).positionAbsolute;u=[[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=$a(p,s).positionAbsolute}const f=u&&u!=="parent"?mb(t,u):t;return{position:{x:f.x-h.x,y:f.y-h.y},positionAbsolute:f}}function ip({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 FN=(e,t,n,r)=>{const s=t.querySelectorAll(e);if(!s||!s.length)return null;const o=Array.from(s),l=t.getBoundingClientRect(),u={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-u.x)/n,y:(h.top-l.top-u.y)/n,...pb(d)}})};function pl(e,t,n){return n===void 0?n:r=>{const s=t().nodeInternals.get(e);s&&n(r,{...s})}}function dx({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:o,multiSelectionActive:l,nodeInternals:u,onError:d}=t.getState(),h=u.get(e);if(!h){d==null||d("012",hs.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 Z5(){const e=kt();return w.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:s,snapToGrid:o}=e.getState(),l=n.touches?n.touches[0].clientX:n.clientX,u=n.touches?n.touches[0].clientY:n.clientY,d={x:(l-r[0])/r[2],y:(u-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 lp(e){return(t,n,r)=>e==null?void 0:e(t,r)}function V2({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:o,selectNodesOnDrag:l}){const u=kt(),[d,h]=w.useState(!1),f=w.useRef([]),p=w.useRef({x:null,y:null}),g=w.useRef(0),v=w.useRef(null),k=w.useRef({x:0,y:0}),b=w.useRef(null),x=w.useRef(!1),N=w.useRef(!1),S=w.useRef(!1),_=Z5();return w.useEffect(()=>{if(e!=null&&e.current){const E=Pn(e.current),T=({x:B,y:P})=>{const{nodeInternals:D,onNodeDrag:I,onSelectionDrag:O,updateNodePositions:z,nodeExtent:M,snapGrid:$,snapToGrid:q,nodeOrigin:X,onError:H}=u.getState();p.current={x:B,y:P};let L=!1,W={x:0,y:0,x2:0,y2:0};if(f.current.length>1&&M){const Y=Id(f.current,X);W=Ol(Y)}if(f.current=f.current.map(Y=>{const J={x:B-Y.distance.x,y:P-Y.distance.y};q&&(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&&!Y.extent&&(V[0][0]=Y.positionAbsolute.x-W.x+M[0][0],V[1][0]=Y.positionAbsolute.x+(Y.width??0)-W.x2+M[1][0],V[0][1]=Y.positionAbsolute.y-W.y+M[0][1],V[1][1]=Y.positionAbsolute.y+(Y.height??0)-W.y2+M[1][1]);const G=H2(Y,J,D,V,X,H);return L=L||Y.position.x!==G.position.x||Y.position.y!==G.position.y,Y.position=G.position,Y.positionAbsolute=G.positionAbsolute,Y}),!L)return;z(f.current,!0,!0),h(!0);const F=s?I:lp(O);if(F&&b.current){const[Y,J]=ip({nodeId:s,dragItems:f.current,nodeInternals:D});F(b.current,Y,J)}},A=()=>{if(!v.current)return;const[B,P]=m2(k.current,v.current);if(B!==0||P!==0){const{transform:D,panBy:I}=u.getState();p.current.x=(p.current.x??0)-B/D[2],p.current.y=(p.current.y??0)-P/D[2],I({x:B,y:P})&&T(p.current)}g.current=requestAnimationFrame(A)},R=B=>{var X;const{nodeInternals:P,multiSelectionActive:D,nodesDraggable:I,unselectNodesAndEdges:O,onNodeDragStart:z,onSelectionDragStart:M}=u.getState();N.current=!0;const $=s?z:lp(M);(!l||!o)&&!D&&s&&((X=P.get(s))!=null&&X.selected||O()),s&&o&&l&&dx({id:s,store:u,nodeRef:e});const q=_(B);if(p.current=q,f.current=Y5(P,I,q,s),$&&f.current){const[H,L]=ip({nodeId:s,dragItems:f.current,nodeInternals:P});$(B.sourceEvent,H,L)}};if(t)E.on(".drag",null);else{const B=iD().on("start",P=>{const{domNode:D,nodeDragThreshold:I}=u.getState();I===0&&R(P),S.current=!1;const O=_(P);p.current=O,v.current=(D==null?void 0:D.getBoundingClientRect())||null,k.current=Js(P.sourceEvent,v.current)}).on("drag",P=>{var z,M;const D=_(P),{autoPanOnNodeDrag:I,nodeDragThreshold:O}=u.getState();if(P.sourceEvent.type==="touchmove"&&P.sourceEvent.touches.length>1&&(S.current=!0),!S.current){if(!x.current&&N.current&&I&&(x.current=!0,A()),!N.current){const $=D.xSnapped-(((z=p==null?void 0:p.current)==null?void 0:z.x)??0),q=D.ySnapped-(((M=p==null?void 0:p.current)==null?void 0:M.y)??0);Math.sqrt($*$+q*q)>O&&R(P)}(p.current.x!==D.xSnapped||p.current.y!==D.ySnapped)&&f.current&&N.current&&(b.current=P.sourceEvent,k.current=Js(P.sourceEvent,v.current),T(D))}}).on("end",P=>{if(!(!N.current||S.current)&&(h(!1),x.current=!1,N.current=!1,cancelAnimationFrame(g.current),f.current)){const{updateNodePositions:D,nodeInternals:I,onNodeDragStop:O,onSelectionDragStop:z}=u.getState(),M=s?O:lp(z);if(D(f.current,!1,!1),M){const[$,q]=ip({nodeId:s,dragItems:f.current,nodeInternals:I});M(P.sourceEvent,$,q)}}}).filter(P=>{const D=P.target;return!P.button&&(!n||!DN(D,`.${n}`,e))&&(!r||DN(D,r,e))});return E.call(B),()=>{E.on(".drag",null)}}}},[e,t,n,r,o,u,s,l,_]),d}function G2(){const e=kt();return w.useCallback(n=>{const{nodeInternals:r,nodeExtent:s,updateNodePositions:o,getNodes:l,snapToGrid:u,snapGrid:d,onError:h,nodesDraggable:f}=e.getState(),p=l().filter(S=>S.selected&&(S.draggable||f&&typeof S.draggable>"u")),g=u?d[0]:5,v=u?d[1]:5,k=n.isShiftPressed?4:1,b=n.x*g*k,x=n.y*v*k,N=p.map(S=>{if(S.positionAbsolute){const _={x:S.positionAbsolute.x+b,y:S.positionAbsolute.y+x};u&&(_.x=d[0]*Math.round(_.x/d[0]),_.y=d[1]*Math.round(_.y/d[1]));const{positionAbsolute:E,position:T}=H2(S,_,r,s,void 0,h);S.position=T,S.positionAbsolute=E}return S});o(N,!0,!1)},[])}const Zo={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var ml=e=>{const t=({id:n,type:r,data:s,xPos:o,yPos:l,xPosOrigin:u,yPosOrigin:d,selected:h,onClick:f,onMouseEnter:p,onMouseMove:g,onMouseLeave:v,onContextMenu:k,onDoubleClick:b,style:x,className:N,isDraggable:S,isSelectable:_,isConnectable:E,isFocusable:T,selectNodesOnDrag:A,sourcePosition:R,targetPosition:B,hidden:P,resizeObserver:D,dragHandle:I,zIndex:O,isParent:z,noDragClassName:M,noPanClassName:$,initialized:q,disableKeyboardA11y:X,ariaLabel:H,rfId:L,hasHandleBounds:W})=>{const F=kt(),Y=w.useRef(null),J=w.useRef(null),V=w.useRef(R),G=w.useRef(B),K=w.useRef(r),Z=_||S||f||p||g||v,ee=G2(),re=pl(n,F.getState,p),ue=pl(n,F.getState,g),me=pl(n,F.getState,v),ie=pl(n,F.getState,k),fe=pl(n,F.getState,b),ve=pe=>{const{nodeDragThreshold:he}=F.getState();if(_&&(!A||!S||he>0)&&dx({id:n,store:F,nodeRef:Y}),f){const ae=F.getState().nodeInternals.get(n);ae&&f(pe,{...ae})}},se=pe=>{if(!ox(pe)&&!X)if(v2.includes(pe.key)&&_){const he=pe.key==="Escape";dx({id:n,store:F,unselect:he,nodeRef:Y})}else S&&h&&Object.prototype.hasOwnProperty.call(Zo,pe.key)&&(F.setState({ariaLiveMessage:`Moved selected node ${pe.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~l}`}),ee({x:Zo[pe.key].x,y:Zo[pe.key].y,isShiftPressed:pe.shiftKey}))};w.useEffect(()=>()=>{J.current&&(D==null||D.unobserve(J.current),J.current=null)},[]),w.useEffect(()=>{if(Y.current&&!P){const pe=Y.current;(!q||!W||J.current!==pe)&&(J.current&&(D==null||D.unobserve(J.current)),D==null||D.observe(pe),J.current=pe)}},[P,q,W]),w.useEffect(()=>{const pe=K.current!==r,he=V.current!==R,ae=G.current!==B;Y.current&&(pe||he||ae)&&(pe&&(K.current=r),he&&(V.current=R),ae&&(G.current=B),F.getState().updateNodeDimensions([{id:n,nodeElement:Y.current,forceUpdate:!0}]))},[n,r,R,B]);const ke=V2({nodeRef:Y,disabled:P||!S,noDragClassName:M,handleSelector:I,nodeId:n,isSelectable:_,selectNodesOnDrag:A});return P?null:de.createElement("div",{className:Ut(["react-flow__node",`react-flow__node-${r}`,{[$]:S},N,{selected:h,selectable:_,parent:z,dragging:ke}]),ref:Y,style:{zIndex:O,transform:`translate(${u}px,${d}px)`,pointerEvents:Z?"all":"none",visibility:q?"visible":"hidden",...x},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:re,onMouseMove:ue,onMouseLeave:me,onContextMenu:ie,onClick:ve,onDoubleClick:fe,onKeyDown:T?se:void 0,tabIndex:T?0:void 0,role:T?"button":void 0,"aria-describedby":X?void 0:`${D2}-${L}`,"aria-label":H},de.createElement(u5,{value:n},de.createElement(e,{id:n,data:s,type:r,xPos:o,yPos:l,selected:h,isConnectable:E,sourcePosition:R,targetPosition:B,dragging:ke,dragHandle:I,zIndex:O})))};return t.displayName="NodeWrapper",w.memo(t)};const J5=e=>{const t=e.getNodes().filter(n=>n.selected);return{...Id(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function Q5({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=kt(),{width:s,height:o,x:l,y:u,transformString:d,userSelectionActive:h}=Ge(J5,Tt),f=G2(),p=w.useRef(null);if(w.useEffect(()=>{var k;n||(k=p.current)==null||k.focus({preventScroll:!0})},[n]),V2({nodeRef:p}),h||!s||!o)return null;const g=e?k=>{const b=r.getState().getNodes().filter(x=>x.selected);e(k,b)}:void 0,v=k=>{Object.prototype.hasOwnProperty.call(Zo,k.key)&&f({x:Zo[k.key].x,y:Zo[k.key].y,isShiftPressed:k.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:u,left:l}}))}var e6=w.memo(Q5);const t6=e=>e.nodesSelectionActive,K2=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:l,deleteKeyCode:u,onMove:d,onMoveStart:h,onMoveEnd:f,selectionKeyCode:p,selectionOnDrag:g,selectionMode:v,onSelectionStart:k,onSelectionEnd:b,multiSelectionKeyCode:x,panActivationKeyCode:N,zoomActivationKeyCode:S,elementsSelectable:_,zoomOnScroll:E,zoomOnPinch:T,panOnScroll:A,panOnScrollSpeed:R,panOnScrollMode:B,zoomOnDoubleClick:P,panOnDrag:D,defaultViewport:I,translateExtent:O,minZoom:z,maxZoom:M,preventScrolling:$,onSelectionContextMenu:q,noWheelClassName:X,noPanClassName:H,disableKeyboardA11y:L})=>{const W=Ge(t6),F=Pl(p),Y=Pl(N),J=Y||D,V=Y||A,G=F||g&&J!==!0;return F5({deleteKeyCode:u,multiSelectionKeyCode:x}),de.createElement(z5,{onMove:d,onMoveStart:h,onMoveEnd:f,onPaneContextMenu:o,elementsSelectable:_,zoomOnScroll:E,zoomOnPinch:T,panOnScroll:V,panOnScrollSpeed:R,panOnScrollMode:B,zoomOnDoubleClick:P,panOnDrag:!F&&J,defaultViewport:I,translateExtent:O,minZoom:z,maxZoom:M,zoomActivationKeyCode:S,preventScrolling:$,noWheelClassName:X,noPanClassName:H},de.createElement(z2,{onSelectionStart:k,onSelectionEnd:b,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:l,panOnDrag:J,isSelecting:!!G,selectionMode:v},e,W&&de.createElement(e6,{onSelectionContextMenu:q,noPanClassName:H,disableKeyboardA11y:L})))};K2.displayName="FlowRenderer";var n6=w.memo(K2);function r6(e){return Ge(w.useCallback(n=>e?S2(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function s6(e){const t={input:ml(e.input||I2),default:ml(e.default||ux),output:ml(e.output||L2),group:ml(e.group||kb)},n={},r=Object.keys(e).filter(s=>!["input","default","output","group"].includes(s)).reduce((s,o)=>(s[o]=ml(e[o]||ux),s),n);return{...t,...r}}const a6=({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]},o6=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),Y2=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,updateNodeDimensions:o,onError:l}=Ge(o6,Tt),u=r6(e.onlyRenderVisibleElements),d=w.useRef(),h=w.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 w.useEffect(()=>()=>{var f;(f=d==null?void 0:d.current)==null||f.disconnect()},[]),de.createElement("div",{className:"react-flow__nodes",style:Nb},u.map(f=>{var T,A,R;let p=f.type||"default";e.nodeTypes[p]||(l==null||l("003",hs.error003(p)),p="default");const g=e.nodeTypes[p]||e.nodeTypes.default,v=!!(f.draggable||t&&typeof f.draggable>"u"),k=!!(f.selectable||s&&typeof f.selectable>"u"),b=!!(f.connectable||n&&typeof f.connectable>"u"),x=!!(f.focusable||r&&typeof f.focusable>"u"),N=e.nodeExtent?mb(f.positionAbsolute,e.nodeExtent):f.positionAbsolute,S=(N==null?void 0:N.x)??0,_=(N==null?void 0:N.y)??0,E=a6({x:S,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:S,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:k,isConnectable:b,isFocusable:x,resizeObserver:h,dragHandle:f.dragHandle,zIndex:((T=f[mt])==null?void 0:T.z)??0,isParent:!!((A=f[mt])!=null&&A.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!f.width&&!!f.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:f.ariaLabel,hasHandleBounds:!!((R=f[mt])!=null&&R.handleBounds)})}))};Y2.displayName="NodeRenderer";var i6=w.memo(Y2);const l6=(e,t,n)=>n===Ae.Left?e-t:n===Ae.Right?e+t:e,c6=(e,t,n)=>n===Ae.Top?e-t:n===Ae.Bottom?e+t:e,BN="react-flow__edgeupdater",qN=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:o,onMouseOut:l,type:u})=>de.createElement("circle",{onMouseDown:s,onMouseEnter:o,onMouseOut:l,className:Ut([BN,`${BN}-${u}`]),cx:l6(t,r,e),cy:c6(n,r,e),r,stroke:"transparent",fill:"transparent"}),u6=()=>!0;var Ro=e=>{const t=({id:n,className:r,type:s,data:o,onClick:l,onEdgeDoubleClick:u,selected:d,animated:h,label:f,labelStyle:p,labelShowBg:g,labelBgStyle:v,labelBgPadding:k,labelBgBorderRadius:b,style:x,source:N,target:S,sourceX:_,sourceY:E,targetX:T,targetY:A,sourcePosition:R,targetPosition:B,elementsSelectable:P,hidden:D,sourceHandleId:I,targetHandleId:O,onContextMenu:z,onMouseEnter:M,onMouseMove:$,onMouseLeave:q,reconnectRadius:X,onReconnect:H,onReconnectStart:L,onReconnectEnd:W,markerEnd:F,markerStart:Y,rfId:J,ariaLabel:V,isFocusable:G,isReconnectable:K,pathOptions:Z,interactionWidth:ee,disableKeyboardA11y:re})=>{const ue=w.useRef(null),[me,ie]=w.useState(!1),[fe,ve]=w.useState(!1),se=kt(),ke=w.useMemo(()=>`url('#${lx(Y,J)}')`,[Y,J]),pe=w.useMemo(()=>`url('#${lx(F,J)}')`,[F,J]);if(D)return null;const he=Be=>{var yt;const{edges:Ze,addSelectedEdges:Je,unselectNodesAndEdges:rt,multiSelectionActive:gt}=se.getState(),Rt=Ze.find(lt=>lt.id===n);Rt&&(P&&(se.setState({nodesSelectionActive:!1}),Rt.selected&&gt?(rt({nodes:[],edges:[Rt]}),(yt=ue.current)==null||yt.blur()):Je([n])),l&&l(Be,Rt))},ae=fl(n,se.getState,u),Ne=fl(n,se.getState,z),Te=fl(n,se.getState,M),Ie=fl(n,se.getState,$),Oe=fl(n,se.getState,q),He=(Be,Ze)=>{if(Be.button!==0)return;const{edges:Je,isValidConnection:rt}=se.getState(),gt=Ze?S:N,Rt=(Ze?O:I)||null,yt=Ze?"target":"source",lt=rt||u6,en=Ze,Pt=Je.find(Yt=>Yt.id===n);ve(!0),L==null||L(Be,Pt,yt);const zt=Yt=>{ve(!1),W==null||W(Yt,Pt,yt)};A2({event:Be,handleId:Rt,nodeId:gt,onConnect:Yt=>H==null?void 0:H(Pt,Yt),isTarget:en,getState:se.getState,setState:se.setState,isValidConnection:lt,edgeUpdaterType:yt,onReconnectEnd:zt})},Ye=Be=>He(Be,!0),Ve=Be=>He(Be,!1),Ke=()=>ie(!0),nt=()=>ie(!1),it=!P&&!l,At=Be=>{var Ze;if(!re&&v2.includes(Be.key)&&P){const{unselectNodesAndEdges:Je,addSelectedEdges:rt,edges:gt}=se.getState();Be.key==="Escape"?((Ze=ue.current)==null||Ze.blur(),Je({edges:[gt.find(yt=>yt.id===n)]})):rt([n])}};return de.createElement("g",{className:Ut(["react-flow__edge",`react-flow__edge-${s}`,r,{selected:d,animated:h,inactive:it,updating:me}]),onClick:he,onDoubleClick:ae,onContextMenu:Ne,onMouseEnter:Te,onMouseMove:Ie,onMouseLeave:Oe,onKeyDown:G?At:void 0,tabIndex:G?0:void 0,role:G?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":V===null?void 0:V||`Edge from ${N} to ${S}`,"aria-describedby":G?`${F2}-${J}`:void 0,ref:ue},!fe&&de.createElement(e,{id:n,source:N,target:S,selected:d,animated:h,label:f,labelStyle:p,labelShowBg:g,labelBgStyle:v,labelBgPadding:k,labelBgBorderRadius:b,data:o,style:x,sourceX:_,sourceY:E,targetX:T,targetY:A,sourcePosition:R,targetPosition:B,sourceHandleId:I,targetHandleId:O,markerStart:ke,markerEnd:pe,pathOptions:Z,interactionWidth:ee}),K&&de.createElement(de.Fragment,null,(K==="source"||K===!0)&&de.createElement(qN,{position:R,centerX:_,centerY:E,radius:X,onMouseDown:Ye,onMouseEnter:Ke,onMouseOut:nt,type:"source"}),(K==="target"||K===!0)&&de.createElement(qN,{position:B,centerX:T,centerY:A,radius:X,onMouseDown:Ve,onMouseEnter:Ke,onMouseOut:nt,type:"target"})))};return t.displayName="EdgeWrapper",w.memo(t)};function d6(e){const t={default:Ro(e.default||rd),straight:Ro(e.bezier||wb),step:Ro(e.step||yb),smoothstep:Ro(e.step||$d),simplebezier:Ro(e.simplebezier||gb)},n={},r=Object.keys(e).filter(s=>!["default","bezier"].includes(s)).reduce((s,o)=>(s[o]=Ro(e[o]||rd),s),n);return{...t,...r}}function UN(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 zN(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const h6=(e,t,n,r,s,o)=>{const l=UN(n,e,t),u=UN(o,r,s);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y}};function f6({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:s,targetHeight:o,width:l,height:u,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=Ol({x:(0-d[0])/d[2],y:(0-d[1])/d[2],width:l/d[2],height:u/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 WN(e){var r,s,o,l,u;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:((u=e==null?void 0:e.positionAbsolute)==null?void 0:u.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}const p6=[{level:0,isMaxLevel:!0,edges:[]}];function m6(e,t,n=!1){let r=-1;const s=e.reduce((l,u)=>{var f,p;const d=Dn(u.zIndex);let h=d?u.zIndex:0;if(n){const g=t.get(u.target),v=t.get(u.source),k=u.selected||(g==null?void 0:g.selected)||(v==null?void 0:v.selected),b=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?u.zIndex:0)+(k?b:0)}return l[h]?l[h].push(u):l[h]=[u],r=h>r?h:r,l},{}),o=Object.entries(s).map(([l,u])=>{const d=+l;return{edges:u,level:d,isMaxLevel:d===r}});return o.length===0?p6:o}function g6(e,t,n){const r=Ge(w.useCallback(s=>e?s.edges.filter(o=>{const l=t.get(o.source),u=t.get(o.target);return(l==null?void 0:l.width)&&(l==null?void 0:l.height)&&(u==null?void 0:u.width)&&(u==null?void 0:u.height)&&f6({sourcePos:l.positionAbsolute||{x:0,y:0},targetPos:u.positionAbsolute||{x:0,y:0},sourceWidth:l.width,sourceHeight:l.height,targetWidth:u.width,targetHeight:u.height,width:s.width,height:s.height,transform:s.transform})}):s.edges,[e,t]));return m6(r,t,n)}const y6=({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"}),w6=({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"}),HN={[nd.Arrow]:y6,[nd.ArrowClosed]:w6};function v6(e){const t=kt();return w.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(HN,e)?HN[e]:((o=(s=t.getState()).onError)==null||o.call(s,"009",hs.error009(e)),null)},[e])}const x6=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:o="strokeWidth",strokeWidth:l,orient:u="auto-start-reverse"})=>{const d=v6(t);return d?de.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:u,refX:"0",refY:"0"},de.createElement(d,{color:n,strokeWidth:l})):null},b6=({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 u=lx(l,t);r.includes(u)||(s.push({id:u,color:l.color||e,...l}),r.push(u))}}),s),[]).sort((s,o)=>s.id.localeCompare(o.id))},X2=({defaultColor:e,rfId:t})=>{const n=Ge(w.useCallback(b6({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(x6,{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})))};X2.displayName="MarkerDefinitions";var k6=w.memo(X2);const N6=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}),Z2=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:s,noPanClassName:o,onEdgeContextMenu:l,onEdgeMouseEnter:u,onEdgeMouseMove:d,onEdgeMouseLeave:h,onEdgeClick:f,onEdgeDoubleClick:p,onReconnect:g,onReconnectStart:v,onReconnectEnd:k,reconnectRadius:b,children:x,disableKeyboardA11y:N})=>{const{edgesFocusable:S,edgesUpdatable:_,elementsSelectable:E,width:T,height:A,connectionMode:R,nodeInternals:B,onError:P}=Ge(N6,Tt),D=g6(t,B,n);return T?de.createElement(de.Fragment,null,D.map(({level:I,edges:O,isMaxLevel:z})=>de.createElement("svg",{key:I,style:{zIndex:I},width:T,height:A,className:"react-flow__edges react-flow__container"},z&&de.createElement(k6,{defaultColor:e,rfId:r}),de.createElement("g",null,O.map(M=>{const[$,q,X]=WN(B.get(M.source)),[H,L,W]=WN(B.get(M.target));if(!X||!W)return null;let F=M.type||"default";s[F]||(P==null||P("011",hs.error011(F)),F="default");const Y=s[F]||s.default,J=R===Da.Strict?L.target:(L.target??[]).concat(L.source??[]),V=zN(q.source,M.sourceHandle),G=zN(J,M.targetHandle),K=(V==null?void 0:V.position)||Ae.Bottom,Z=(G==null?void 0:G.position)||Ae.Top,ee=!!(M.focusable||S&&typeof M.focusable>"u"),re=M.reconnectable||M.updatable,ue=typeof g<"u"&&(re||_&&typeof re>"u");if(!V||!G)return P==null||P("008",hs.error008(V,M)),null;const{sourceX:me,sourceY:ie,targetX:fe,targetY:ve}=h6($,V,K,H,G,Z);return de.createElement(Y,{key:M.id,id:M.id,className:Ut([M.className,o]),type:F,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:me,sourceY:ie,targetX:fe,targetY:ve,sourcePosition:K,targetPosition:Z,elementsSelectable:E,onContextMenu:l,onMouseEnter:u,onMouseMove:d,onMouseLeave:h,onClick:f,onEdgeDoubleClick:p,onReconnect:g,onReconnectStart:v,onReconnectEnd:k,reconnectRadius:b,rfId:r,ariaLabel:M.ariaLabel,isFocusable:ee,isReconnectable:ue,pathOptions:"pathOptions"in M?M.pathOptions:void 0,interactionWidth:M.interactionWidth,disableKeyboardA11y:N})})))),x):null};Z2.displayName="EdgeRenderer";var j6=w.memo(Z2);const S6=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function _6({children:e}){const t=Ge(S6);return de.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function E6(e){const t=gi(),n=w.useRef(!1);w.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const C6={[Ae.Left]:Ae.Right,[Ae.Right]:Ae.Left,[Ae.Top]:Ae.Bottom,[Ae.Bottom]:Ae.Top},J2=({nodeId:e,handleType:t,style:n,type:r=Ks.Bezier,CustomComponent:s,connectionStatus:o})=>{var A,R,B;const{fromNode:l,handleId:u,toX:d,toY:h,connectionMode:f}=Ge(w.useCallback(P=>({fromNode:P.nodeInternals.get(e),handleId:P.connectionHandleId,toX:(P.connectionPosition.x-P.transform[0])/P.transform[2],toY:(P.connectionPosition.y-P.transform[1])/P.transform[2],connectionMode:P.connectionMode}),[e]),Tt),p=(A=l==null?void 0:l[mt])==null?void 0:A.handleBounds;let g=p==null?void 0:p[t];if(f===Da.Loose&&(g=g||(p==null?void 0:p[t==="source"?"target":"source"])),!l||!g)return null;const v=u?g.find(P=>P.id===u):g[0],k=v?v.x+v.width/2:(l.width??0)/2,b=v?v.y+v.height/2:l.height??0,x=(((R=l.positionAbsolute)==null?void 0:R.x)??0)+k,N=(((B=l.positionAbsolute)==null?void 0:B.y)??0)+b,S=v==null?void 0:v.position,_=S?C6[S]:null;if(!S||!_)return null;if(s)return de.createElement(s,{connectionLineType:r,connectionLineStyle:n,fromNode:l,fromHandle:v,fromX:x,fromY:N,toX:d,toY:h,fromPosition:S,toPosition:_,connectionStatus:o});let E="";const T={sourceX:x,sourceY:N,sourcePosition:S,targetX:d,targetY:h,targetPosition:_};return r===Ks.Bezier?[E]=vb(T):r===Ks.Step?[E]=ix({...T,borderRadius:0}):r===Ks.SmoothStep?[E]=ix(T):r===Ks.SimpleBezier?[E]=N2(T):E=`M${x},${N} ${d},${h}`,de.createElement("path",{d:E,fill:"none",className:"react-flow__connection-path",style:n})};J2.displayName="ConnectionLine";const T6=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function A6({containerStyle:e,style:t,type:n,component:r}){const{nodeId:s,handleType:o,nodesConnectable:l,width:u,height:d,connectionStatus:h}=Ge(T6,Tt);return!(s&&o&&u&&l)?null:de.createElement("svg",{style:e,width:u,height:d,className:"react-flow__edges react-flow__connectionline react-flow__container"},de.createElement("g",{className:Ut(["react-flow__connection",h])},de.createElement(J2,{nodeId:s,handleType:o,style:t,type:n,CustomComponent:r,connectionStatus:h})))}function VN(e,t){return w.useRef(null),kt(),w.useMemo(()=>t(e),[e])}const Q2=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:s,onInit:o,onNodeClick:l,onEdgeClick:u,onNodeDoubleClick:d,onEdgeDoubleClick:h,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:g,onNodeContextMenu:v,onSelectionContextMenu:k,onSelectionStart:b,onSelectionEnd:x,connectionLineType:N,connectionLineStyle:S,connectionLineComponent:_,connectionLineContainerStyle:E,selectionKeyCode:T,selectionOnDrag:A,selectionMode:R,multiSelectionKeyCode:B,panActivationKeyCode:P,zoomActivationKeyCode:D,deleteKeyCode:I,onlyRenderVisibleElements:O,elementsSelectable:z,selectNodesOnDrag:M,defaultViewport:$,translateExtent:q,minZoom:X,maxZoom:H,preventScrolling:L,defaultMarkerColor:W,zoomOnScroll:F,zoomOnPinch:Y,panOnScroll:J,panOnScrollSpeed:V,panOnScrollMode:G,zoomOnDoubleClick:K,panOnDrag:Z,onPaneClick:ee,onPaneMouseEnter:re,onPaneMouseMove:ue,onPaneMouseLeave:me,onPaneScroll:ie,onPaneContextMenu:fe,onEdgeContextMenu:ve,onEdgeMouseEnter:se,onEdgeMouseMove:ke,onEdgeMouseLeave:pe,onReconnect:he,onReconnectStart:ae,onReconnectEnd:Ne,reconnectRadius:Te,noDragClassName:Ie,noWheelClassName:Oe,noPanClassName:He,elevateEdgesOnSelect:Ye,disableKeyboardA11y:Ve,nodeOrigin:Ke,nodeExtent:nt,rfId:it})=>{const At=VN(e,s6),Be=VN(t,d6);return E6(o),de.createElement(n6,{onPaneClick:ee,onPaneMouseEnter:re,onPaneMouseMove:ue,onPaneMouseLeave:me,onPaneContextMenu:fe,onPaneScroll:ie,deleteKeyCode:I,selectionKeyCode:T,selectionOnDrag:A,selectionMode:R,onSelectionStart:b,onSelectionEnd:x,multiSelectionKeyCode:B,panActivationKeyCode:P,zoomActivationKeyCode:D,elementsSelectable:z,onMove:n,onMoveStart:r,onMoveEnd:s,zoomOnScroll:F,zoomOnPinch:Y,zoomOnDoubleClick:K,panOnScroll:J,panOnScrollSpeed:V,panOnScrollMode:G,panOnDrag:Z,defaultViewport:$,translateExtent:q,minZoom:X,maxZoom:H,onSelectionContextMenu:k,preventScrolling:L,noDragClassName:Ie,noWheelClassName:Oe,noPanClassName:He,disableKeyboardA11y:Ve},de.createElement(_6,null,de.createElement(j6,{edgeTypes:Be,onEdgeClick:u,onEdgeDoubleClick:h,onlyRenderVisibleElements:O,onEdgeContextMenu:ve,onEdgeMouseEnter:se,onEdgeMouseMove:ke,onEdgeMouseLeave:pe,onReconnect:he,onReconnectStart:ae,onReconnectEnd:Ne,reconnectRadius:Te,defaultMarkerColor:W,noPanClassName:He,elevateEdgesOnSelect:!!Ye,disableKeyboardA11y:Ve,rfId:it},de.createElement(A6,{style:S,type:N,component:_,containerStyle:E})),de.createElement("div",{className:"react-flow__edgelabel-renderer"}),de.createElement(i6,{nodeTypes:At,onNodeClick:l,onNodeDoubleClick:d,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:g,onNodeContextMenu:v,selectNodesOnDrag:M,onlyRenderVisibleElements:O,noPanClassName:He,noDragClassName:Ie,disableKeyboardA11y:Ve,nodeOrigin:Ke,nodeExtent:nt,rfId:it})))};Q2.displayName="GraphView";var R6=w.memo(Q2);const hx=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ws={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:hx,nodeExtent:hx,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Da.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:s5,isValidConnection:void 0},M6=()=>vP((e,t)=>({...Ws,setNodes:n=>{const{nodeInternals:r,nodeOrigin:s,elevateNodesOnSelect:o}=t();e({nodeInternals:ap(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?ap(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:u,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((b,x)=>{const N=s.get(x.id);if(N!=null&&N.hidden)s.set(N.id,{...N,[mt]:{...N[mt],handleBounds:void 0}});else if(N){const S=pb(x.nodeElement);!!(S.width&&S.height&&(N.width!==S.width||N.height!==S.height||x.forceUpdate))&&(s.set(N.id,{...N,[mt]:{...N[mt],handleBounds:{source:FN(".source",x.nodeElement,g,h),target:FN(".target",x.nodeElement,g,h)}},...S}),b.push({id:N.id,type:"dimensions",dimensions:S}))}return b},[]);q2(s,h);const k=l||o&&!l&&U2(t,{initial:!0,...u});e({nodeInternals:new Map(s),fitViewOnInitDone:k}),(v==null?void 0:v.length)>0&&(r==null||r(v))},updateNodePositions:(n,r=!0,s=!1)=>{const{triggerNodeChanges:o}=t(),l=n.map(u=>{const d={id:u.id,type:"position",dragging:s};return r&&(d.positionAbsolute=u.positionAbsolute,d.position=u.position),d});o(l)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:s,hasDefaultNodes:o,nodeOrigin:l,getNodes:u,elevateNodesOnSelect:d}=t();if(n!=null&&n.length){if(o){const h=G5(n,u()),f=ap(h,s,l,d);e({nodeInternals:f})}r==null||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:s,getNodes:o}=t();let l,u=null;r?l=n.map(d=>Gs(d,!0)):(l=Wo(o(),n),u=Wo(s,[])),vu({changedNodes:l,changedEdges:u,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:s,getNodes:o}=t();let l,u=null;r?l=n.map(d=>Gs(d,!0)):(l=Wo(s,n),u=Wo(o(),[])),vu({changedNodes:u,changedEdges:l,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:s,getNodes:o}=t(),l=n||o(),u=r||s,d=l.map(f=>(f.selected=!1,Gs(f.id,!1))),h=u.map(f=>Gs(f.id,!1));vu({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(u=>u.selected).map(u=>Gs(u.id,!1)),l=n.filter(u=>u.selected).map(u=>Gs(u.id,!1));vu({changedNodes:o,changedEdges:l,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach(s=>{s.positionAbsolute=mb(s.position,n)}),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:s,height:o,d3Zoom:l,d3Selection:u,translateExtent:d}=t();if(!l||!u||!n.x&&!n.y)return!1;const h=cs.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(u,p),r[0]!==p.x||r[1]!==p.y||r[2]!==p.k},cancelConnection:()=>e({connectionNodeId:Ws.connectionNodeId,connectionHandleId:Ws.connectionHandleId,connectionHandleType:Ws.connectionHandleType,connectionStatus:Ws.connectionStatus,connectionStartHandle:Ws.connectionStartHandle,connectionEndHandle:Ws.connectionEndHandle}),reset:()=>e({...Ws})}),Object.is),jb=({children:e})=>{const t=w.useRef(null);return t.current||(t.current=M6()),de.createElement(ZF,{value:t.current},e)};jb.displayName="ReactFlowProvider";const eM=({children:e})=>w.useContext(Md)?de.createElement(de.Fragment,null,e):de.createElement(jb,null,e);eM.displayName="ReactFlowWrapper";const $6={input:I2,default:ux,output:L2,group:kb},I6={default:rd,straight:wb,step:yb,smoothstep:$d,simplebezier:gb},O6=[0,0],L6=[15,15],P6={x:0,y:0,zoom:1},D6={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},tM=w.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:o=$6,edgeTypes:l=I6,onNodeClick:u,onEdgeClick:d,onInit:h,onMove:f,onMoveStart:p,onMoveEnd:g,onConnect:v,onConnectStart:k,onConnectEnd:b,onClickConnectStart:x,onClickConnectEnd:N,onNodeMouseEnter:S,onNodeMouseMove:_,onNodeMouseLeave:E,onNodeContextMenu:T,onNodeDoubleClick:A,onNodeDragStart:R,onNodeDrag:B,onNodeDragStop:P,onNodesDelete:D,onEdgesDelete:I,onSelectionChange:O,onSelectionDragStart:z,onSelectionDrag:M,onSelectionDragStop:$,onSelectionContextMenu:q,onSelectionStart:X,onSelectionEnd:H,connectionMode:L=Da.Strict,connectionLineType:W=Ks.Bezier,connectionLineStyle:F,connectionLineComponent:Y,connectionLineContainerStyle:J,deleteKeyCode:V="Backspace",selectionKeyCode:G="Shift",selectionOnDrag:K=!1,selectionMode:Z=Ll.Full,panActivationKeyCode:ee="Space",multiSelectionKeyCode:re=td()?"Meta":"Control",zoomActivationKeyCode:ue=td()?"Meta":"Control",snapToGrid:me=!1,snapGrid:ie=L6,onlyRenderVisibleElements:fe=!1,selectNodesOnDrag:ve=!0,nodesDraggable:se,nodesConnectable:ke,nodesFocusable:pe,nodeOrigin:he=O6,edgesFocusable:ae,edgesUpdatable:Ne,elementsSelectable:Te,defaultViewport:Ie=P6,minZoom:Oe=.5,maxZoom:He=2,translateExtent:Ye=hx,preventScrolling:Ve=!0,nodeExtent:Ke,defaultMarkerColor:nt="#b1b1b7",zoomOnScroll:it=!0,zoomOnPinch:At=!0,panOnScroll:Be=!1,panOnScrollSpeed:Ze=.5,panOnScrollMode:Je=Aa.Free,zoomOnDoubleClick:rt=!0,panOnDrag:gt=!0,onPaneClick:Rt,onPaneMouseEnter:yt,onPaneMouseMove:lt,onPaneMouseLeave:en,onPaneScroll:Pt,onPaneContextMenu:zt,children:Dt,onEdgeContextMenu:Yt,onEdgeDoubleClick:Ur,onEdgeMouseEnter:zn,onEdgeMouseMove:zr,onEdgeMouseLeave:Wr,onEdgeUpdate:Wn,onEdgeUpdateStart:gr,onEdgeUpdateEnd:Hn,onReconnect:Hr,onReconnectStart:Nn,onReconnectEnd:gs,reconnectRadius:jn=10,edgeUpdaterRadius:yr=10,onNodesChange:vt,onEdgesChange:wr,noDragClassName:vr="nodrag",noWheelClassName:Vr="nowheel",noPanClassName:Vn="nopan",fitView:pn=!1,fitViewOptions:Gr,connectOnClick:Sn=!0,attributionPosition:we,proOptions:De,defaultEdgeOptions:qe,elevateNodesOnSelect:tn=!0,elevateEdgesOnSelect:ys=!1,disableKeyboardA11y:xr=!1,autoPanOnConnect:Gn=!0,autoPanOnNodeDrag:Qe=!0,connectionRadius:br=20,isValidConnection:Kn,onError:Kr,style:Yn,id:Xa,nodeDragThreshold:Za,...Yr},Xt)=>{const sa=Xa||"1";return de.createElement("div",{...Yr,style:{...Yn,...D6},ref:Xt,className:Ut(["react-flow",s]),"data-testid":"rf__wrapper",id:Xa},de.createElement(eM,null,de.createElement(R6,{onInit:h,onMove:f,onMoveStart:p,onMoveEnd:g,onNodeClick:u,onEdgeClick:d,onNodeMouseEnter:S,onNodeMouseMove:_,onNodeMouseLeave:E,onNodeContextMenu:T,onNodeDoubleClick:A,nodeTypes:o,edgeTypes:l,connectionLineType:W,connectionLineStyle:F,connectionLineComponent:Y,connectionLineContainerStyle:J,selectionKeyCode:G,selectionOnDrag:K,selectionMode:Z,deleteKeyCode:V,multiSelectionKeyCode:re,panActivationKeyCode:ee,zoomActivationKeyCode:ue,onlyRenderVisibleElements:fe,selectNodesOnDrag:ve,defaultViewport:Ie,translateExtent:Ye,minZoom:Oe,maxZoom:He,preventScrolling:Ve,zoomOnScroll:it,zoomOnPinch:At,zoomOnDoubleClick:rt,panOnScroll:Be,panOnScrollSpeed:Ze,panOnScrollMode:Je,panOnDrag:gt,onPaneClick:Rt,onPaneMouseEnter:yt,onPaneMouseMove:lt,onPaneMouseLeave:en,onPaneScroll:Pt,onPaneContextMenu:zt,onSelectionContextMenu:q,onSelectionStart:X,onSelectionEnd:H,onEdgeContextMenu:Yt,onEdgeDoubleClick:Ur,onEdgeMouseEnter:zn,onEdgeMouseMove:zr,onEdgeMouseLeave:Wr,onReconnect:Hr??Wn,onReconnectStart:Nn??gr,onReconnectEnd:gs??Hn,reconnectRadius:jn??yr,defaultMarkerColor:nt,noDragClassName:vr,noWheelClassName:Vr,noPanClassName:Vn,elevateEdgesOnSelect:ys,rfId:sa,disableKeyboardA11y:xr,nodeOrigin:he,nodeExtent:Ke}),de.createElement(E5,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:v,onConnectStart:k,onConnectEnd:b,onClickConnectStart:x,onClickConnectEnd:N,nodesDraggable:se,nodesConnectable:ke,nodesFocusable:pe,edgesFocusable:ae,edgesUpdatable:Ne,elementsSelectable:Te,elevateNodesOnSelect:tn,minZoom:Oe,maxZoom:He,nodeExtent:Ke,onNodesChange:vt,onEdgesChange:wr,snapToGrid:me,snapGrid:ie,connectionMode:L,translateExtent:Ye,connectOnClick:Sn,defaultEdgeOptions:qe,fitView:pn,fitViewOptions:Gr,onNodesDelete:D,onEdgesDelete:I,onNodeDragStart:R,onNodeDrag:B,onNodeDragStop:P,onSelectionDrag:M,onSelectionDragStart:z,onSelectionDragStop:$,noPanClassName:Vn,nodeOrigin:he,rfId:sa,autoPanOnConnect:Gn,autoPanOnNodeDrag:Qe,onError:Kr,connectionRadius:br,isValidConnection:Kn,nodeDragThreshold:Za}),de.createElement(S5,{onSelectionChange:O}),Dt,de.createElement(QF,{proOptions:De,position:we}),de.createElement(M5,{rfId:sa,disableKeyboardA11y:xr})))});tM.displayName="ReactFlow";const F6=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function nM(){return Ge(F6,Tt)}const rM=({id:e,x:t,y:n,width:r,height:s,style:o,color:l,strokeColor:u,strokeWidth:d,className:h,borderRadius:f,shapeRendering:p,onClick:g,selected:v})=>{const{background:k,backgroundColor:b}=o||{},x=l||k||b;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:u,strokeWidth:d,shapeRendering:p,onClick:g?N=>g(N,e):void 0})};rM.displayName="MiniMapNode";var B6=w.memo(rM);const q6=e=>e.nodeOrigin,U6=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),cp=e=>e instanceof Function?e:()=>e;function z6({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s=2,nodeComponent:o=B6,onClick:l}){const u=Ge(U6,Tt),d=Ge(q6),h=cp(t),f=cp(e),p=cp(n),g=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return de.createElement(de.Fragment,null,u.map(v=>{const{x:k,y:b}=$a(v,d).positionAbsolute;return de.createElement(o,{key:v.id,x:k,y:b,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 W6=w.memo(z6);const H6=200,V6=150,G6=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?n5(Id(t,e.nodeOrigin),n):n,rfId:e.rfId}},K6="react-flow__minimap-desc";function sM({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:r="#e2e2e2",nodeClassName:s="",nodeBorderRadius:o=5,nodeStrokeWidth:l=2,nodeComponent:u,maskColor:d="rgb(240, 240, 240, 0.6)",maskStrokeColor:h="none",maskStrokeWidth:f=1,position:p="bottom-right",onClick:g,onNodeClick:v,pannable:k=!1,zoomable:b=!1,ariaLabel:x="React Flow mini map",inversePan:N=!1,zoomStep:S=10,offsetScale:_=5}){const E=kt(),T=w.useRef(null),{boundingRect:A,viewBB:R,rfId:B}=Ge(G6,Tt),P=(e==null?void 0:e.width)??H6,D=(e==null?void 0:e.height)??V6,I=A.width/P,O=A.height/D,z=Math.max(I,O),M=z*P,$=z*D,q=_*z,X=A.x-(M-A.width)/2-q,H=A.y-($-A.height)/2-q,L=M+q*2,W=$+q*2,F=`${K6}-${B}`,Y=w.useRef(0);Y.current=z,w.useEffect(()=>{if(T.current){const G=Pn(T.current),K=re=>{const{transform:ue,d3Selection:me,d3Zoom:ie}=E.getState();if(re.sourceEvent.type!=="wheel"||!me||!ie)return;const fe=-re.sourceEvent.deltaY*(re.sourceEvent.deltaMode===1?.05:re.sourceEvent.deltaMode?1:.002)*S,ve=ue[2]*Math.pow(2,fe);ie.scaleTo(me,ve)},Z=re=>{const{transform:ue,d3Selection:me,d3Zoom:ie,translateExtent:fe,width:ve,height:se}=E.getState();if(re.sourceEvent.type!=="mousemove"||!me||!ie)return;const ke=Y.current*Math.max(1,ue[2])*(N?-1:1),pe={x:ue[0]-re.sourceEvent.movementX*ke,y:ue[1]-re.sourceEvent.movementY*ke},he=[[0,0],[ve,se]],ae=cs.translate(pe.x,pe.y).scale(ue[2]),Ne=ie.constrain()(ae,he,fe);ie.transform(me,Ne)},ee=f2().on("zoom",k?Z:null).on("zoom.wheel",b?K:null);return G.call(ee),()=>{G.on("zoom",null)}}},[k,b,N,S]);const J=g?G=>{const K=ar(G);g(G,{x:K[0],y:K[1]})}:void 0,V=v?(G,K)=>{const Z=E.getState().nodeInternals.get(K);v(G,Z)}:void 0;return de.createElement(fb,{position:p,style:e,className:Ut(["react-flow__minimap",t]),"data-testid":"rf__minimap"},de.createElement("svg",{width:P,height:D,viewBox:`${X} ${H} ${L} ${W}`,role:"img","aria-labelledby":F,ref:T,onClick:J},x&&de.createElement("title",{id:F},x),de.createElement(W6,{onClick:V,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:s,nodeStrokeWidth:l,nodeComponent:u}),de.createElement("path",{className:"react-flow__minimap-mask",d:`M${X-q},${H-q}h${L+q*2}v${W+q*2}h${-L-q*2}z
57
+ M${R.x},${R.y}h${R.width}v${R.height}h${-R.width}z`,fill:d,fillRule:"evenodd",stroke:h,strokeWidth:f,pointerEvents:"none"})))}sM.displayName="MiniMap";var Y6=w.memo(sM);function X6(){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 Z6(){return de.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},de.createElement("path",{d:"M0 0h32v4.2H0z"}))}function J6(){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 Q6(){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 eB(){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 On=({children:e,className:t,...n})=>de.createElement("button",{type:"button",className:Ut(["react-flow__controls-button",t]),...n},e);On.displayName="ControlButton";const tB=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),aM=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:o,onZoomOut:l,onFitView:u,onInteractiveChange:d,className:h,children:f,position:p="bottom-left"})=>{const g=kt(),[v,k]=w.useState(!1),{isInteractive:b,minZoomReached:x,maxZoomReached:N}=Ge(tB,Tt),{zoomIn:S,zoomOut:_,fitView:E}=gi();if(w.useEffect(()=>{k(!0)},[]),!v)return null;const T=()=>{S(),o==null||o()},A=()=>{_(),l==null||l()},R=()=>{E(s),u==null||u()},B=()=>{g.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),d==null||d(!b)};return de.createElement(fb,{className:Ut(["react-flow__controls",h]),position:p,style:e,"data-testid":"rf__controls"},t&&de.createElement(de.Fragment,null,de.createElement(On,{onClick:T,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:N},de.createElement(X6,null)),de.createElement(On,{onClick:A,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:x},de.createElement(Z6,null))),n&&de.createElement(On,{className:"react-flow__controls-fitview",onClick:R,title:"fit view","aria-label":"fit view"},de.createElement(J6,null)),r&&de.createElement(On,{className:"react-flow__controls-interactive",onClick:B,title:"toggle interactivity","aria-label":"toggle interactivity"},b?de.createElement(eB,null):de.createElement(Q6,null)),f)};aM.displayName="Controls";var nB=w.memo(aM),cr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(cr||(cr={}));function rB({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 sB({color:e,radius:t}){return de.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const aB={[cr.Dots]:"#91919a",[cr.Lines]:"#eee",[cr.Cross]:"#e2e2e2"},oB={[cr.Dots]:1,[cr.Lines]:1,[cr.Cross]:6},iB=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function oM({id:e,variant:t=cr.Dots,gap:n=20,size:r,lineWidth:s=1,offset:o=2,color:l,style:u,className:d}){const h=w.useRef(null),{transform:f,patternId:p}=Ge(iB,Tt),g=l||aB[t],v=r||oB[t],k=t===cr.Dots,b=t===cr.Cross,x=Array.isArray(n)?n:[n,n],N=[x[0]*f[2]||1,x[1]*f[2]||1],S=v*f[2],_=b?[S,S]:N,E=k?[S/o,S/o]:[_[0]/o,_[1]/o];return de.createElement("svg",{className:Ut(["react-flow__background",d]),style:{...u,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]%N[0],y:f[1]%N[1],width:N[0],height:N[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${E[0]},-${E[1]})`},k?de.createElement(sB,{color:g,radius:S/o}):de.createElement(rB,{dimensions:_,color:g,lineWidth:s})),de.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${p+e})`}))}oM.displayName="Background";var lB=w.memo(oM);function cB(e,t){return e?t==="gone"?"entering":t==="leaving"?"here":t:t==="gone"?"gone":"leaving"}function Bu(e){return e!=="gone"}function qu(e,t){const[n,r]=w.useState(()=>e?"here":"gone"),s=w.useRef(null);return w.useEffect(()=>{r(o=>cB(e,o))},[e]),w.useEffect(()=>{if(n==="leaving")return s.current=window.setTimeout(()=>r("gone"),t),()=>{s.current!=null&&window.clearTimeout(s.current)}},[n,t]),w.useEffect(()=>{n==="entering"&&r("here")},[n]),n}const GN="agent-dag.fm-custom-stations",KN="agent-dag.fm-muted",fx="custom:",uB=/^UC[A-Za-z0-9_-]{22}$/,dB=/^[A-Za-z0-9_-]{11}$/,Sb=/^[A-Za-z0-9_-]{1,80}$/,hB=/\.(mp3|aac|ogg)$/i,fB=/\.m3u8$/i,iM=2048,Dl=80;function Ba(e){return`${fx}${e}`}function oi(e){if(!e.startsWith(fx))return null;const t=e.slice(fx.length);return Sb.test(t)?t:null}function YN(e){return oi(e)??e}function pB(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 _b(e){var l,u;const t=e.trim();if(t.length>iM)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&&uB.test(d))return{kind:"youtube-channel",url:r,channel:d};const h=(u=/^\/@([^/]+)\/live\/?$/.exec(n.pathname))==null?void 0:u[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(dB.test(f))return{kind:"youtube-video",url:r,video:f}}return null}return fB.test(n.pathname)?{kind:"direct-audio",url:r,format:"hls"}:hB.test(n.pathname)?{kind:"direct-audio",url:r,format:"audio"}:null}function mB(e){return e==="1"}function gB(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():"",u=typeof s.url=="string"?s.url.trim():"",d=_b(u);!Sb.test(o)||n.has(o)||!l||l.length>Dl||!d||(n.add(o),r.push({id:o,name:l,url:d.url}))}return r}function yB(e,t,n){const r=oi(e??"");return r&&t.some(s=>s.id===r)?Ba(r):n(e)}function wB(e,t){return e===Ba(t)?"claude-fm":e}function vB(){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 xB(e,t,n=vB()){const r=e.trim(),s=_b(t);return!r||r.length>Dl||!Sb.test(n)||!s?null:{id:n,name:r,url:s.url}}const lM=.2,cM=1.6;function bB(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<lM||s>cM?null:{x:n,y:r,zoom:s}}function px({durationMs:e,documentHidden:t,reducedMotion:n=kB()}){return t||n?!1:Number.isFinite(e)&&e>0}function kB(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}const NB=["us-gov","global","apac","us","eu","jp","au"],jB=new RegExp(`^(?:(?:${NB.join("|")})\\.)?anthropic\\.`,"i");function yi(e){return e.replace(jB,"")}const SB=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i,_B=new Set(["tool_input","tool_response"]);function uM(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.model=="string"&&SB.test(yi(n.model)))return n.model;for(const[r,s]of Object.entries(n)){if(_B.has(r))continue;const o=uM(s,t+1);if(o)return o}return null}function Eb(){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 na(e,t){return`${e}::${t}`}function wi(e,t){return`${e}\0${t}`}const EB=/[0-9a-f]{16,}/i,CB=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function dM(e){return EB.test(e)||CB.test(e)}function TB(e){if(!e)return;const t=e.replace(/\\/g,"/").split("/").filter(Boolean);for(let n=t.length-1;n>=0;n--)if(!dM(t[n]))return t[n];return t[t.length-1]}function hM(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function fM(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 Cb(e){const t=fM(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 AB(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]=Cb(s);const o=RB(s.speeds);o&&(t[n].bySpeed=o)}return Object.keys(t).length?t:void 0}function RB(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,Cb(r)]);return t.length?Object.fromEntries(t):void 0}function pM(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),...fM(n)};for(const r of Object.values(n)){const s=pM(r,t+1);if(s)return s}return null}function Tb(e){return TB(e)}function Ab(e){const t=e.agent_type??e.subagent_type;return t&&!dM(t)?t:"subagent"}function nc(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function Fl(e,t){!e.cwd&&t.cwd&&(e.cwd=t.cwd,e.cwdBasename=Tb(t.cwd))}function mM(e,t){e.label==="session"&&t.cwd&&(e.label=Tb(t.cwd)??"session")}function gM(e,t){const n=Ab(t);n&&(e.label==="subagent"||!e.label)&&(e.label=n)}function vi(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:hM()},e.agents.set(s,o),o)}function yM(e,t,n,r){const s=na(t,n),o=e.agents.get(s);return o?(Fl(o,r),gM(o,r),o):null}function MB(e,t,n){const r=t.session_id??"unknown",s=nc(t);if(s){const d=yM(e,r,s,t);if(d)return d}const o=e.activeSubagentStack.get(r),l=o&&o.length>0?o[o.length-1]:null;if(l){const d=e.agents.get(na(r,l));if(d)return Fl(d,t),d}const u=vi(e,r,n,t.hook_event_name!=="SessionStart");return Fl(u,t),mM(u,t),u}function $B(e,t,n,r,s){const o=na(t,n),l=vi(e,t,s,!0);let u=e.agents.get(o);if(u)return Fl(u,r),gM(u,r),u;u={id:o,sessionId:t,label:Ab(r),kind:"subagent",parentId:l.id,state:"active",startedAt:s,tools:[],prompts:[],cwd:r.cwd,cwdBasename:Tb(r.cwd),toolCount:0,childCount:0,usage:hM()},e.agents.set(o,u);const d=e.pendingSubagentModels.get(o);return d&&(u.model=d,e.pendingSubagentModels.delete(o)),l.childCount+=1,u}function IB(e,t,n){const r=e.activeSubagentStack.get(t)??[];r.includes(n)||(r.push(n),e.activeSubagentStack.set(t,r))}function wM(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 OB=/^\s*<task-notification>([\s\S]*?)<\/task-notification>/;function XN(e,t){var n;return((n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`).exec(e))==null?void 0:n[1].trim())||void 0}const LB={completed:"background task finished",failed:"background task failed",killed:"background task stopped"};function Rb(e){const t=OB.exec(e);if(!t)return null;const n=XN(t[1],"status");return{label:(n?Ot(LB,n):void 0)??"background task update",detail:XN(t[1],"summary")}}function vM(e){return e.filter(t=>!Rb(t.text))}const ZN=2e3;function PB(e,t,n){for(let r=e.length-1;r>=0;r--){const s=e[r];if(s.at<t-ZN)return!1;if(s.text===n&&s.at<=t+ZN)return!0}return!1}function DB(e,t,n){if(PB(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 sd=2e3;function FB(e){const t=e.prompts[e.prompts.length-1];return t&&t.at>e.startedAt?t.at:e.startedAt}function ad(e,t=80){if(e==null)return"";if(typeof e=="string")return e.length>t?e.slice(0,t-1)+"…":e;try{const n=JSON.stringify(e);return n.length>t?n.slice(0,t-1)+"…":n}catch{return String(e)}}const JN=200;function xM(e,t,n){const r=t.ok===!1;t.ok=n,e&&r===n&&(e.toolErrorCount=(e.toolErrorCount??0)+(n?-1:1))}function bM(e,t){return t.agentId==null?void 0:e.agents.get(t.agentId)}function up(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 BB(e,t,n){var r;return((r=e.get(t))==null?void 0:r.tools.find(s=>s.id===n))??null}const qB=25;function UB(e,t){const n=t.tools;if(n.length>JN){const r=n.splice(0,n.length-JN);for(const s of r)NM(e,t,s)}for(let r=n.length-qB-1;r>=0;r--){const s=n[r];if(s.trimmed)break;s.input=void 0,s.response=void 0,s.trimmed=!0}}function zB(e,t,n){const r=e.toolIndex.get(wi(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 kM(e,t){for(const n of t.tools)NM(e,t,n)}function NM(e,t,n){const r=wi(t.sessionId,n.id);e.toolIndex.get(r)===n&&e.toolIndex.delete(r)}const WB="no result reached the deck — events were dropped while the deck was paused";function jM(e,t,n,r,s){n.endedAt=r,xM(t,n,!1),n.errorPreview=n.outcomeGap?WB:s,e.toolIndex.delete(wi(t.sessionId,n.id))}function HB(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(wi((n==null?void 0:n.session_id)??"unknown",s))}function VB(e,t,n,r,s){const o=t.tool_use_id?zB(e,r,t.tool_use_id):null;if(o){if(t.tool_name&&o.name==="?"){o.name=t.tool_name;const h=bM(e,o);h&&(up(h,"?",-1),up(h,o.name,1))}o.endedAt==null&&!o.trimmed&&t.tool_input!==void 0&&(o.input=t.tool_input,o.inputPreview=ad(t.tool_input));return}const l=t.tool_use_id??`${r.id}:${r.toolCount}`,u=nc(t),d={id:l,name:t.tool_name??"?",input:t.tool_input,inputPreview:ad(t.tool_input),agentId:r.id,explicitSubagentId:u?na(n,u):void 0,startedAt:s};r.tools.push(d),r.toolCount+=1,up(r,d.name,1),r.state="active",e.toolIndex.set(wi(r.sessionId,l),d),UB(e,r)}function GB(e,t,n,r,s){const o=t.tool_use_id;if(!o)return;const l=wi(r,o);let u=e.toolIndex.get(l),d=!1;if(!u)for(const f of e.agents.values()){if(f.sessionId!==r)continue;const p=f.tools.find(g=>g.id===o);if(p){u=p,d=!0;break}}if(!u||u.outcomeApplied)return;u.outcomeApplied=!0,u.outcomeGap=void 0,u.endedAt=s,xM(bM(e,u),u,n==="PostToolUse"),u.trimmed||(u.response=t.tool_response),n==="PostToolUseFailure"?u.errorPreview=ad(t.tool_response):d&&(u.errorPreview=void 0);const h=pM(t.tool_response);h&&(u.usage=h),e.toolIndex.delete(l)}function KB(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 YB(e,t,n,r){const s=vi(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),Fl(s,t),mM(s,t)}function XB(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=vi(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&&DB(s.prompts,r,o)&&!s.firstPrompt&&!Rb(o)&&(s.firstPrompt=ad(o,120))}function ZB(e,t,n,r){const s=vi(e,n,r,!1),o=FB(s);if(r<o)return;const l=s.lastTurnEndAt;if(!(l!=null&&o>l&&r<=l+sd)){s.state="done",s.endedAt=r,s.lastTurnEndAt=r;for(const u of s.provider==="codex"?[]:e.agents.values())if(u.sessionId===n)for(const d of u.tools)d.endedAt==null&&d.explicitSubagentId==null&&jM(e,u,d,r,"the turn ended before this call returned");t==="SessionEnd"&&(s.closedAt=r),e.activeSubagentStack.delete(n)}}function JB(e,t,n,r){const s=nc(t);if(!s)return;const o=$B(e,n,s,t,r),l=Ab(t);l&&(o.label=l);const u=e.subagentTombstones.get(o.id);u!=null&&e.subagentTombstones.delete(o.id);const d=o.endedAt!=null&&r-o.endedAt<=sd,h=u!=null&&r-u<=sd;if(d||h){const f=h?u:o.endedAt;o.state="done",o.endedAt=f,o.startedAt=Math.min(o.startedAt,f),wM(e,n,s);return}o.state="active",o.startedAt=o.startedAt||r,o.exitAt=void 0,o.endedAt=void 0,IB(e,n,s)}function QB(e,t,n,r){const s=nc(t);if(!s)return;const o=yM(e,n,s,t);if(!o){for(const[l,u]of e.subagentTombstones)r-u>sd&&e.subagentTombstones.delete(l);e.subagentTombstones.set(na(n,s),r);return}o.state="done",o.endedAt=Math.min(o.endedAt??r,r),wM(e,n,s)}function SM(){return{msgsUser:0,msgsAssistant:0,toolUses:0,toolResults:0,systemReminders:0,currentContextTokens:0,memoryFiles:[]}}function eq(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??SM(),currentContextTokens:t.context_tokens})}}const tq=6e4,QN=64;function nq(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 u=na(n,o),d=e.agents.get(u);if(d)d.model=l,e.pendingSubagentModels.delete(u);else if(e.pendingSubagentModels.delete(u),e.pendingSubagentModels.set(u,l),e.pendingSubagentModels.size>256){const h=e.pendingSubagentModels.keys().next().value;h!==void 0&&e.pendingSubagentModels.delete(h)}}}function rq(e,t,n){const r=t.context??null;if(r){const s=e.agents.get(n);if(s){const o=s.context??SM(),l=(d,h)=>typeof r[d]=="number"?r[d]:h,u=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:u??o.memoryFiles}}}}function sq(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 aq(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 oq(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 u=(l.outputs??[]).filter(d=>o-d<tq);u.push(o),l.outputs=u.length>QN?u.slice(-QN):u}e.revision+=1}}function iq(e,t,n){const r=t.usage??null;if(r){const s=e.agents.get(n);s&&(Object.assign(s.usage,Cb(r)),s.usageByModel=AB(t.usageByModel))}}const lq=["command","cmd","file_path","path","url","pattern","notebook_path"],ej=120,dp=e=>e.length>ej?`${e.slice(0,ej-1)}…`:e;function cq(e){if(typeof e=="string")return e.trim()?dp(e.trim()):null;if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;for(const n of lq){const r=t[n];if(typeof r=="string"&&r.trim())return dp(r.trim());if(Array.isArray(r)&&r.length>0&&r.every(s=>typeof s=="string")){const s=r.join(" ").trim();if(s)return dp(s)}}return null}function uq(e){return e==="permission_prompt"?"permission":e==="agent_needs_input"?"asked":e==="idle_prompt"?"idle":null}const dq=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved","SessionNamed","SessionRecapped","OutputObserved"]);function hq(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 fq=3e4;function pq(e,t){if(!(!e||!e.name)&&!(t-e.startedAt>fq)&&!(e.startedAt>t))return{name:e.name,preview:cq(e.input)??""}}function mq(e,t,n,r,s){if(n!=="permission")return{kind:n,message:r,since:s};const o=hq(e,t),l={kind:n,message:r,since:s};o!=null&&o.explicitSubagentId&&(l.subagentId=o.explicitSubagentId);const u=pq(o,s);return u&&(l.tool=u),l}function gq(e,t,n){if(e.kind==="idle")return!0;const r=nc(t);return r==null?!0:e.subagentId!=null&&na(n,r)===e.subagentId}function yq(e,t,n,r){if(!dq.has(t)){const s=e.agents.get(r);s!=null&&s.waiting&&gq(s.waiting,n,r)&&(s.waiting=null)}}function wq(e,t,n,r){const s=uq(t.notification_type);if(!s)return;const o=vi(e,n,r,!1),l=typeof t.message=="string"?t.message:"",u=o.waiting;o.waiting=u&&u.kind===s&&u.message===l?{...u,since:Math.min(u.since,r)}:mq(e,n,s,l,r)}function rc(e,t){return t&&(e.revision+=1),t}function vq(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=[],u=new Map;for(const[p,g]of e.agents){if(g.parentId!=null){const v=u.get(g.parentId);v?v.push(p):u.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&&(kM(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=(u.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 rc(e,d>0)}function xq(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 k=e.agents.get(v);k&&kM(e,k),e.agents.delete(v)}const g=na(f,"");for(const v of e.pendingSubagentModels.keys())v.startsWith(g)&&e.pendingSubagentModels.delete(v);s==null||s(f),d--,h=!0}return rc(e,h)}function bq(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 rc(e,t)}function kq(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 u of s.tools){const d=Math.max(u.startedAt,l??u.startedAt);u.endedAt==null&&t-d>n&&(jM(e,s,u,d,"session ended before this call returned"),r=!0)}}return rc(e,r)}const tj=90*6e4;function Nq(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 rc(e,r)}function od(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 _M(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{...Eb(),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(yq(e,o,r,l),KB(e,l,s),eq(e,r,l),o){case"ModelObserved":return nq(e,r,l),e;case"ContextObserved":return rq(e,r,l),e;case"SessionNamed":return sq(e,r,l),e;case"SessionRecapped":return aq(e,r,l),e;case"OutputObserved":return oq(e,r,l,s),e;case"UsageObserved":return iq(e,r,l),e}const u=MB(e,r,s);u.provider||(u.provider=r.provider==="codex"?"codex":"claude");const d=uM(r);switch(d&&(u.model=d),o){case"SessionStart":YB(e,r,l,s);break;case"UserPromptSubmit":XB(e,r,l,s);break;case"PreToolUse":VB(e,r,l,u,s);break;case"PostToolUse":case"PostToolUseFailure":GB(e,r,o,l,s);break;case"SubagentStart":JB(e,r,l,s);break;case"SubagentStop":QB(e,r,l,s);break;case"Stop":case"SessionEnd":ZB(e,o,l,s);break;case"Notification":wq(e,r,l,s);break}return e}const jq={input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4},Sq=[{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:jq},{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}}],_q=[{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 Eq(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function Wa(e,t=Date.now(),n=qa){if(!e)return null;const r=Cq.get(n);if(!r)return null;const s=yi(e);for(const o of r)if(o.match.test(s))return typeof o.rates=="function"?o.rates(t):o.rates;return null}const qa="standard",Cq=new Map([[qa,Sq],["fast",_q]]);function Sl(e,t){return e*t/1e6}function EM(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:Sl(o,t.cacheWrite),usd1h:Sl(n,l)}}function CM(e,t,n=Date.now()){if(!Eq(t))return e.inputTokens;const r=Wa(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 Jo(e,t,n=Date.now()){const r={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const s of Mb(e)){const o=TM(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 TM(e,t,n,r=Date.now()){const s=Wa(t,r,n);if(!s)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const o=Sl(CM(e,t,r),s.input),l=Sl(e.outputTokens,s.output),u=Sl(e.cacheReadTokens,s.cacheRead),d=EM(e,s),h=d.usd5m+d.usd1h;return{input:o,output:l,cacheRead:u,cacheWrite:h,total:o+l+u+h}}function Mb(e){const t=e.bySpeed?Object.entries(e.bySpeed):[];return t.length===0?[{speed:qa,usage:e}]:[{speed:qa,usage:Tq(e,t.map(([,n])=>n))},...t.map(([n,r])=>({speed:n,usage:r}))]}function Tq(e,t){const n=o=>t.reduce((l,u)=>l+(o(u)??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 fs="not priced";function _l(e,t,n){const r=e.toFixed(t);return Number(r)<n?r:null}function Fe(e){if(e<=0)return"—";if(e<.005)return"<1¢";if(e<1){const t=_l(e*100,e<.1?1:0,100);if(t!==null)return`${t}¢`}if(e<100){const t=_l(e,2,100);if(t!==null)return`$${t}`}if(e<1e4){const t=_l(e,0,1e4);if(t!==null)return`$${t}`}return`$${(e/1e3).toFixed(1)}k`}function $b(e,t){if(e<=0||t<10)return null;const n=e/t,r=n*60;return r>=.01?`${Fe(r)}/min`:`${Fe(n*3600)}/hr`}function AM(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?AM(l,o):o)}n.bySpeed=Object.fromEntries(r)}return n}function Aq(e,t){let n=0,r=0,s=0,o=0,l=0,u=0;for(const p of t)n+=p.inputTokens,r+=p.outputTokens,s+=p.cacheReadTokens,o+=p.cacheCreateTokens,l+=p.cacheCreate1hTokens??0,u+=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,u)),h.inputTokens+h.outputTokens+h.cacheReadTokens+h.cacheCreateTokens>0?h:null}function sc(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=Aq(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:AM(r[o].usage,s)}:r.push({model:e.model,usage:s})}return r}function fn(e,t=Date.now()){const n={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const r of sc(e)){const s=Jo(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 Bl(e,t=Date.now()){let n=0;for(const r of sc(e))for(const s of Mb(r.usage))Wa(r.model,t,s.speed)==null&&(n+=s.usage.inputTokens+s.usage.outputTokens);return n}function RM(e){const t=[];for(const n of sc(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 MM(e){return RM(e).filter(t=>t!==e.model)}function nj(e,t){if(!e.bySpeed)return hp(e,t,qa);const n=Mb(e).filter(r=>r.speed!==qa||Rq(r.usage));return n.length===1?hp(n[0].usage,t,n[0].speed):[...n.map(r=>hp(r.usage,t,r.speed)),"═════════════════════════════════════════",`all speeds = ${Fe(Jo(e,t).total)}`].join(`
58
+ `)}function Rq(e){return e.inputTokens+e.outputTokens+e.cacheReadTokens+e.cacheCreateTokens>0}function hp(e,t,n){const r=Wa(t,Date.now(),n),s=n===qa?`model: ${t}`:`model: ${t} · ${n}`;if(!r)return`${s}
59
+ no published rate in this build — the tokens are counted, the dollars are not`;const o=g=>g.toLocaleString(),l=g=>`$${g}/MTok`,u=TM(e,t,n),d=EM(e,r),h=d.tokens1h>0?[`cache w5m${o(d.tokens5m).padStart(14)} × ${l(r.cacheWrite).padEnd(11)} = ${Fe(d.usd5m)}`,`cache w1h${o(d.tokens1h).padStart(14)} × ${l(r.cacheWrite1h??r.cacheWrite).padEnd(11)} = ${Fe(d.usd1h)}`]:[`cache w ${o(d.tokens5m).padStart(14)} × ${l(r.cacheWrite).padEnd(11)} = ${Fe(d.usd5m)}`],f=CM(e,t),p=f===e.inputTokens?"input":"uncached";return[s,`${p.padEnd(9)}${o(f).padStart(14)} × ${l(r.input).padEnd(11)} = ${Fe(u.input)}`,`output ${o(e.outputTokens).padStart(14)} × ${l(r.output).padEnd(11)} = ${Fe(u.output)}`,`cache r ${o(e.cacheReadTokens).padStart(14)} × ${l(r.cacheRead).padEnd(11)} = ${Fe(u.cacheRead)}`,...h,"─────────────────────────────────────────",`total = ${Fe(u.total)}`].join(`
60
+ `)}function rj(e){const t=sc(e),[n]=t;return t.length<=1?nj(n.usage,n.model):[...t.map(r=>nj(r.usage,r.model)),"═════════════════════════════════════════",`all models = ${Fe(fn(e).total)}`].join(`
61
+ `)}function Mq(e){if(!e.model)return null;const t=Wa(e.model),n=fn(e),r=Bl(e);if(!t&&n.total<=0)return e.usage.inputTokens+e.usage.outputTokens<=0?null:{kind:"unpriced",tt:rj(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?$b(n.total,s):null,l=rj(e)+(o?`
62
+ burn: ${o}`:"");return{kind:"spent",total:n.total,floor:r>0,tt:l}}const $q=new Set(["untrusted","on-request","on-failure"]);function Iq(e){return typeof e!="string"||!e?null:$q.has(e)?!0:e==="never"?!1:null}function Oq(e){if(e.provider!=="codex"||e.kind!=="root"||e.waiting||e.state!=="active")return null;const t=Iq(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."}
63
+
64
+ 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 sj(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function Qs(e){const t=yi(e).replace(/[-_]\d{8}(?!\d)/,""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const s=sj(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(sj);return[`GPT-${s}`,...o].join(" ")}return e}function Od(e){const t=yi(e??""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_]/i);return n?n[1].toLowerCase():/^gpt[-_]/i.test(t)?"gpt":""}function pr(e){return(e==null?void 0:e.kind)==="permission"||(e==null?void 0:e.kind)==="asked"}function mx(e){const t=[];for(const n of e)n.kind==="root"&&pr(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 Lq(e,t){if(e.length===0)return null;const n=e.findIndex(r=>r.id===t);return e[(n+1)%e.length]}function Pq(e){const t=new Set;for(const n of e)n.state==="active"&&t.add(n.sessionId);return t.size}function Ld(e,t){return`${e}@${t.since}`}function $M(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 Dq(e){const t=e.message||"Needs your permission",n=$M(e,t);return n?`${t}
65
+ Likely on: ${n}`:t}function Fq(e,t,n,r=!0){if(!r)return[];if(n)return[];const s=[];for(const o of e){if(!pr(o.waiting))continue;const l=Ld(o.id,o.waiting);t.has(l)||s.push({key:l,title:o.label,body:Dq(o.waiting),sessionId:o.id})}return s}function Bq(e,t,n){const r=new Set;for(const o of e)r.add(Ld(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 bu(e){return new Set(e.map(t=>Ld(t.id,t.waiting)))}function qq(e,t){return e!==t}function Uq(e,t){return!e&&t!=null}function zq(e,t){return e!==null&&t!=null}function ii(e){return e==="active"?"live":e==="done"?"done":"err"}function li(e){return e.message?e.message:e.kind==="permission"?"Needs your permission":"Waiting for your input"}function Wq(e){return`${e} subagent${e===1?"":"s"} spawned`}function Hq(e,t=Date.now(),n=!1){const r=e.tools.filter(o=>o.ok===!1).length,s=fn(e,t).total;return[e.label,e.kind==="root"?"session":"subagent",ii(e.state),pr(e.waiting)?li(e.waiting):null,e.model?Qs(e.model):null,`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,r>0?`${r} failed`:null,s>0?`${Fe(s)}${Bl(e,t)>0?"+":""}`:null,n?"selected":null].filter(Boolean).join(", ")}function Vq(e,t){const n=$M(e,t);return n?`Likely on: ${n}`:null}function Ib(e){return e.kind==="idle"?"Your turn":li(e)}function ot(e){const t=Math.round(e);if(t<1e3)return`${t}`;if(t<1e6){const n=_l(t/1e3,1,1e3);if(n!==null)return`${n}k`}if(t<1e9){const n=_l(t/1e6,2,1e3);if(n!==null)return`${n}M`}return`${(t/1e9).toFixed(2)}B`}function ci(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 IM(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 Ob(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 aj=["B","KB","MB","GB","TB"];function _a(e){if(e==null||!Number.isFinite(e)||e<0)return"—";if(e===0)return"0 B";let t=e,n=0;for(;n<aj.length-1&&Number(t.toFixed(1))>=1024;)t/=1024,n++;return`${t.toFixed(1)} ${aj[n]}`}const oj=2e5,Gq=1e6,Kq=[/\[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],Yq=[{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 Xq(e){if(!e)return oj;const t=yi(e);for(const n of Kq)if(n.test(t))return Gq;for(const n of Yq)if(n.match.test(t))return n.window;return oj}function OM(e,t){return typeof e=="number"&&e>0?e:Xq(t)}const Zq=1;function Jq(){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 u=e.indexOf(l);u!==-1&&e.splice(u,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 Qo=Jq(),Qq=e=>e==="Escape";function e8(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function ij(e){return String(e.tagName??"").toUpperCase()==="BODY"}function t8(e,t){return!e||!e.isConnected||ij(e)?!1:t==null||ij(t)}const lj="a[href], button, input, select, textarea, [tabindex]";function n8(e){return!e||e.disabled||e.rendered===!1?!1:(e.tabIndex??0)>=0}function r8(e){if(!e||!e.overflowing||e.hasFocusable)return!1;const t=String(e.overflow??"").toLowerCase();return t==="auto"||t==="scroll"}function s8({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 Pd(e){return e.ctrlKey||e.metaKey||e.altKey}const a8=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),o8=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),i8=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function Lb(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function l8(e){return Lb(e)==="BUTTON"?!0:(typeof e.role=="string"?e.role.trim().toLowerCase():"").split(/\s+/).includes("button")}function Dd(e){if(!e)return!1;if(e.isContentEditable)return!0;const t=Lb(e);return t==="TEXTAREA"?!0:t!=="INPUT"?!1:!a8.has(String(e.type??"text").toLowerCase())}function c8(e,t){if(!e)return!1;if(Dd(e))return!0;if(t!=null&&t.length===1&&t!==" "&&e.pointerFocused&&l8(e))return!1;if(o8.has(Lb(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(r=>i8.has(r))}function u8({key:e,modalOpen:t,sheetOpen:n}){return t?!(e==="?"&&n):!1}function d8({appModal:e,dialogDepth:t}){return e||t>0}function LM(e){return e?Array.from(e.querySelectorAll("*")).filter(t=>{if(t.matches(lj))return n8({disabled:t.disabled,tabIndex:t.tabIndex,rendered:t.getClientRects().length>0});const n=t.scrollHeight>t.clientHeight;return n&&r8({overflowing:n,overflow:getComputedStyle(t).overflowY,hasFocusable:t.querySelector(lj)!=null})}):[]}function h8(e,t){const n=LM(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 ft(e,t={}){const{focusRef:n,layer:r,popover:s}=t,o=s?"popover":"dialog",l=w.useRef(null),u=w.useRef(e);u.current=e;const d=w.useRef(null);d.current===null&&(d.current=()=>u.current());const h=d.current;return w.useEffect(()=>Qo.push(h,r,o),[h,r,o]),w.useEffect(()=>{var p;const f=document.activeElement;return(p=(n==null?void 0:n.current)??LM(l.current)[0])==null||p.focus(),()=>{t8(f,document.activeElement)&&f.focus()}},[]),w.useEffect(()=>{const f=p=>{var N;if(p.key!=="Tab"||Pd(p))return;const g=l.current;if(!g)return;const v=document.activeElement;if(!(v!=null&&g.contains(v))&&!Qo.isTop(h))return;const b=h8(g,v),x=s8({count:b.length,index:v?b.indexOf(v):-1,shiftKey:p.shiftKey});x.kind!=="allow"&&(p.preventDefault(),x.kind==="focus"&&((N=b[x.index])==null||N.focus()))};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[h]),l}function f8(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 In(e){return e.toLocaleString()}const p8=60;function m8(e,t=p8){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 g8({agent:e,onClose:t}){var g;const n=w.useRef(null),r=ft(t,{focusRef:n}),s=e.context,o=e.usage,l=(s==null?void 0:s.currentContextTokens)??0,u=OM(e.contextWindow,e.model),d=Math.min(100,l/u*100),h=fn(e),f=e.provider==="codex"?o.inputTokens+o.outputTokens:o.inputTokens+o.outputTokens+o.cacheReadTokens+o.cacheCreateTokens,p=f8(e.provider);return a.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal ctx-modal",onClick:v=>v.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:p.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(d),children:a.jsx("div",{className:"ctx-window-fill",style:{transform:`scaleX(${Math.min(100,Math.max(0,d))/100})`}})}),a.jsxs("div",{className:"ctx-window-meta",children:[a.jsxs("span",{className:"ctx-window-pct",children:[d.toFixed(1),"%"]}),a.jsxs("span",{children:[In(l)," / ",In(u)," tok (",p.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:In(o.inputTokens)}),a.jsx(nr,{label:"output tokens",val:In(o.outputTokens)}),a.jsx(nr,{label:"cache reads",val:In(o.cacheReadTokens)}),a.jsx(nr,{label:"cache writes",val:In(o.cacheCreateTokens)}),a.jsx(nr,{label:"cumulative total",val:In(f)}),a.jsx(nr,{label:"estimated cost",val:Fe(h.total),accent:!0})]}),a.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),p.compositionCounted?a.jsxs("div",{className:"ctx-grid",children:[a.jsx(nr,{label:"user messages",val:In((s==null?void 0:s.msgsUser)??0)}),a.jsx(nr,{label:"assistant messages",val:In((s==null?void 0:s.msgsAssistant)??0)}),a.jsx(nr,{label:"tool uses",val:In((s==null?void 0:s.toolUses)??0)}),a.jsx(nr,{label:"tool results",val:In((s==null?void 0:s.toolResults)??0)}),a.jsx(nr,{label:"system-reminders",val:In((s==null?void 0:s.systemReminders)??0)})]}):a.jsx("div",{className:"ctx-empty",children:p.compositionUncounted}),a.jsx("h3",{className:"ctx-section-title",children:p.memoryHeading}),(((g=s==null?void 0:s.memoryFiles)==null?void 0:g.length)??0)===0?a.jsx("div",{className:"ctx-empty",children:p.memoryEmpty}):a.jsx("ul",{className:"ctx-md-list",children:s.memoryFiles.map(v=>a.jsxs("li",{children:[a.jsx("span",{className:"ctx-md-path",title:v.path,children:m8(v.path)}),a.jsx("span",{className:"ctx-md-size",children:_a(v.bytes)})]},v.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 y8({currentContextTokens:e,modelId:t,contextWindow:n,size:r=26,onClick:s}){const o=OM(n,t),l=Math.min(1,e/o),u=r/2-3,d=r/2,h=2*Math.PI*u,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:u,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),a.jsx("circle",{cx:d,cy:d,r:u,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 cj=new Map;function PM(e){let t=cj.get(e);return t||(t={now:Date.now(),listeners:new Set,timer:null},cj.set(e,t)),t}function w8(e,t){const n=PM(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 v8(e){return PM(e).now}const uj=new Map,dj=new Map;function xi(e=1e3){let t=uj.get(e);t||(t=r=>w8(e,r),uj.set(e,t));let n=dj.get(e);return n||(n=()=>v8(e),dj.set(e,n)),w.useSyncExternalStore(t,n,n)}function Fd(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 x8="1",hj="agent-dag.schema",b8=["agent-dag.layout","agent-dag.viewport"];function et(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function Xe(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}function us(e){if(!(typeof window>"u"))try{window.localStorage.removeItem(e)}catch{}}function El(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function k8(e,t=x8){let n=null;try{n=e.getItem(hj)}catch{return[]}if(n===t)return[];const r=[];if(n!==null)for(const s of b8)try{e.getItem(s)!==null&&(e.removeItem(s),r.push(s))}catch{}try{e.setItem(hj,t)}catch{}return r}const DM="agent-dag.recapsDismissed",fj=200;function N8(){const e=et(DM);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}let ui=new Set(N8());const gx=new Set;let FM=0;function BM(e){return gx.add(e),()=>{gx.delete(e)}}function qM(e){ui=e,FM++;const t=Array.from(e);Xe(DM,JSON.stringify(t.length>fj?t.slice(-fj):t));for(const n of gx)n()}function UM(e,t){return`${e}@${t}`}function j8(e){return ui.has(e)}function S8(e){if(ui.has(e))return;const t=new Set(ui);t.add(e),qM(t)}function _8(e){const t=new Set(ui);t.delete(e)||t.add(e),qM(t)}function E8(e){return w.useSyncExternalStore(BM,()=>e!=null&&ui.has(e),()=>!1)}function Pb(e){return`recap:${e}`}function C8(e){return e.startsWith("recap:")}function T8(){return w.useSyncExternalStore(BM,()=>FM,()=>0)}function A8(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;for(const s of n.tools)s.ok===!1&&(r.failed+=1)}return t}function zM(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 WM(e){return e.live>0?`→ ${e.total} · ${e.live} live`:`→ ${e.total} · done`}function R8(e,t,n){const r=e.kind==="root"?e.waiting:null;if(r&&pr(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.tools.filter(o=>o.ok===!1).length;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:zM(t),short:WM(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:u,subject:d}=n.describeCall(l);return{tone:"muted",long:d?`${u} · ${d}`:u,short:u}}return null}function yx(e){return e==="active"?"live":e==="done"?"done":"err"}const Bd={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"}},M8=Object.fromEntries(Object.entries(Bd).map(([e,t])=>[e,t.category])),$8=Object.fromEntries(Object.entries(Bd).map(([e,t])=>[e,t.emoji])),I8=Object.fromEntries(Object.entries(Bd).map(([e,t])=>[e,t.label])),O8=new Set(Object.entries(Bd).filter(([,e])=>e.shell).map(([e])=>e)),L8={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",...M8};function HM(e){return e.startsWith("mcp__")?"mcp":Ot(L8,e)??"other"}const P8=/\btools\.exec_command\s*\(\s*\{[^{}]*?\bcmd\s*:\s*(["'`])((?:\\.|(?!\1)[^\\])*)\1/,D8=/\btools\.([A-Za-z_$][\w$]*)\s*\(/;function F8(e){if(typeof e!="string"||!e)return null;const t=P8.exec(e);if(t){const r=B8(t[2]);if(r.trim())return r}const n=D8.exec(e);return n?n[1]:null}function B8(e){return e.replace(/\\(["'`\\nrt])/g,(t,n)=>n==="n"?`
66
+ `:n==="r"?"\r":n==="t"?" ":n)}const q8={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:"📡",...$8};function pj(e){return e.startsWith("mcp__")?"🔌":Ot(q8,e)??"✨"}const U8={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 VM(e){return/^-(?:Command|c)$/i.test(e)||/^-[a-z]+c$/.test(e)}function GM(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=>VM(o)||/^-(?:NoProfile|NonInteractive)$/i.test(o)))return GM(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 z8(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const t=e;if(typeof t.script=="string"){const n=F8(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(VM);if(r>=0&&r+1<n.length)return n[r+1]}return n.join(" ")}return typeof t.script=="string"?t.script:null}const W8=new Set(["Bash","PowerShell",...O8]);function H8(e,t){if(!W8.has(e))return null;const n=z8(t);if(!n)return null;const r=GM(n);return r?{emoji:Ot(U8,r)??"⚙️",label:r,category:"shell",detail:n}:null}const V8=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),G8={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:"🗄️"},K8={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 Y8(e){const n=e.replace(/\\/g,"/").replace(/\/+$/,""),r=n.lastIndexOf("/");return r>=0?n.slice(r+1):n}function X8(e){const t=e.toLowerCase(),n=Ot(K8,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(G8,t.slice(r+1));if(s!==void 0)return s}return"📄"}function Z8(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 J8(e,t){if(!V8.has(e))return null;const n=Z8(e,t);if(!n)return null;const r=Y8(n);return r?{emoji:e==="LS"?"📂":X8(r),label:r,category:"file",detail:n}:null}const Q8={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 Db(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 eU(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 KM(e){return Ot(Q8,e.toLowerCase())}function tU(e,t){const n=Db(e);if(!n)return null;const{server:r,method:s}=n;if(!s)return null;const o=KM(r);return{emoji:(o==null?void 0:o.emoji)??"🔌",label:s,category:"mcp",detail:o?`${o.name} · ${s}`:`${r} · ${s}`}}function YM(e,t){return H8(e,t)??J8(e,t)??tU(e)}function nU(e,t){var n;return((n=YM(e,t))==null?void 0:n.label)??null}const rU=I8,mj=18;function ku(e){const t=[...e];return t.length<=mj?e:t.slice(0,mj-1).join("")+"…"}const fp=13,sU=6;function aU(e,t){const n=[...e];if(n.length<=fp)return e;const r=n.lastIndexOf("."),s=r>0?n.slice(r):[];return t==="file"&&s.length>1&&s.length<=sU?n.slice(0,fp-1-s.length).join("")+"…"+s.join(""):n.slice(0,fp-1).join("")+"…"}function Fb(e){const t=Db(e);if(t){const r=KM(t.server);return r?{emoji:r.emoji,label:ku(r.name)}:{emoji:"🔌",label:ku(t.server),hue:eU(t.server)}}const n=Ot(rU,e)??"";return n?{emoji:pj(e),label:ku(n)}:{emoji:pj(e),label:ku(e)}}function oU(e){let t=null,n="";for(const r of e){const s=Db(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:Fb(n)}const wx=6e4,ei=24,gj=wx/ei,pp=132,Uu=14;function iU(e,t,n){const r=new Array(ei).fill(0);let s=0;const o=g=>{const v=n-g;if(v<0||v>=wx)return;const k=ei-1-Math.floor(v/gj);k>=0&&k<ei&&(r[k]+=1,s+=1)};for(const g of e)o(g.startedAt);for(const g of t??[])o(g);const u=Math.max(0,...r)/(gj/1e3),d=e.filter(g=>n-g.startedAt>=0&&n-g.startedAt<wx).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 ${u.toFixed(1)}/s`;return{counts:r,title:p}}const lU=2;function cU(e){return e===0?1.5:Math.max(1.5,Math.min(1,e/lU)*Uu)}function XM({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 Bb(){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 ql(){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 uU({data:e,selected:t}){var N,S;const n=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":"",t?"selected":""].filter(Boolean).join(" "),r=e.tools.filter(_=>!_.endedAt).length,s=e.tools.filter(_=>_.ok===!1).length,o=od(e.sessionId),l=((N=e.context)==null?void 0:N.currentContextTokens)??0,u=e.kind==="root"&&l>0,d=e.sessionTitle?e.cwd?`${e.cwd}
67
+ ${e.sessionTitle}`:e.sessionTitle:e.cwd,h=MM(e),f=h.length>0?`${e.model}
68
+ spend on this card also covers:
69
+ ${h.join(`
70
+ `)}`:e.model,p=Ob(e.sessionName,e.sessionTitle),g=Fd(e),v=g?UM(e.sessionId,g.at):null,k=E8(v),b=g!=null&&!k,x=Mq(e);return a.jsxs("div",{className:n,style:{"--session-hue":o},children:[a.jsx("span",{className:"accent-stripe"}),a.jsx(Fa,{type:"target",position:Ae.Left,style:{background:"transparent",border:"none"}}),a.jsxs("div",{className:"head",children:[a.jsxs("div",{className:"title",children:[a.jsx(pU,{state:e.state}),a.jsx("span",{className:"label",title:d,children:e.label}),e.synthetic&&a.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"}),g&&v&&a.jsx("button",{type:"button",className:"glyph-btn recap-pin","aria-label":"Claude Code's recap","aria-expanded":b,title:b?"Hide the recap":"Show Claude Code's recap",onClick:_=>{_.stopPropagation(),_8(v)},children:a.jsx(ql,{})})]}),a.jsxs("div",{className:"head-right",children:[u&&e.onOpenContext&&a.jsx(y8,{currentContextTokens:l,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(fU,{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:Wq(e.childCount),children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model?a.jsxs("span",{className:"model-chip","data-family":Od(e.model),title:f,children:[Qs(e.model),h.length>0?` +${h.length}`:""]}):e.provider==="codex"?a.jsx("span",{className:"model-chip",title:"OpenAI Codex — no model reported yet",children:"Codex"}):null]}),e.kind==="root"&&p.face&&a.jsx("div",{className:"session-name",title:p.tooltip,children:p.face}),e.waiting&&a.jsx(mU,{waiting:e.waiting}),(()=>{const _=Oq(e);return _?a.jsxs("div",{className:"approval-blind-row",title:_.detail,children:[a.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),a.jsx("span",{className:"approval-blind-said",children:_.label})]}):null})(),(e.tools.length>0||(((S=e.outputs)==null?void 0:S.length)??0)>0)&&a.jsx(gU,{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"]}),s>0&&a.jsxs("span",{className:"failed-meta",title:`${s} tool ${s===1?"call":"calls"} returned an error`,children:[a.jsx("b",{children:s})," err"]}),r>0&&a.jsxs("span",{className:"inflight-meta",children:[a.jsx("b",{children:r})," 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:ot(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),(x==null?void 0:x.kind)==="unpriced"&&a.jsx("span",{className:"cost-unpriced",title:x.tt,children:fs}),(x==null?void 0:x.kind)==="spent"&&a.jsx("span",{className:"cost-meta",title:x.tt,children:a.jsxs("b",{children:[Fe(x.total),x.floor?"+":""]})})]}),a.jsx(hU,{data:e,title:e.kind==="root"?p.face:void 0}),a.jsx(Fa,{type:"source",position:Ae.Right,style:{background:"transparent",border:"none"}})]})}const dU=w.memo(uU);function hU({data:e,title:t}){const n=e.kind==="root"&&pr(e.waiting),r=R8(e,e.branch,{sayWaiting:Ib,describeCall:s=>({name:Fb(s.name).label,subject:nU(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(XM,{kind:yx(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(Bb,{})]}),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 fU({start:e,end:t}){const n=xi(1e3);return a.jsx(a.Fragment,{children:ci(e,t,n)})}function pU({state:e}){return a.jsx("span",{className:`state-pill state-${e}`,children:ii(e)})}function mU({waiting:e}){const t=xi(1e3),n=pr(e),r=li(e);return a.jsxs("div",{className:n?"waiting-row permission":"waiting-row idle",title:`${r}
71
+ Blocked for ${ci(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:Ib(e)}),a.jsx("b",{children:ci(e.since,void 0,t)})]})}function gU({tools:e,outputs:t}){const n=xi(1e3),{counts:r,title:s}=iU(e,t,n),o=pp/ei;return a.jsxs("div",{className:"tool-spark-row",title:s,children:[a.jsx("svg",{className:"tool-spark",width:pp,height:Uu,viewBox:`0 0 ${pp} ${Uu}`,"aria-hidden":!0,children:r.map((l,u)=>{const d=cU(l),h=u===ei-1&&l>0,p=`tool-spark-bar${l>0?" active":""}${h?" latest":""}`;return a.jsx("rect",{x:u*o+.4,y:Uu-d,width:Math.max(.5,o-1),height:d,rx:.8,className:p},h?`landed:${l}`:u)})}),a.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function yU({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 id(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const yj=99;function wU(e){const t=Math.max(0,Math.floor(e));return t>yj?`${yj}+`:String(t)}const vU="Pause the canvas";function xU(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 — ${id(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)":`${id(e.held)} arrived while paused and will be applied in order when you resume (Space)`}function bU(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 ZM="paused · full",kU=(e,t)=>t>0?ZM:e>0?`paused · ${wU(e)}`:"paused";function NU(e){const t=Math.max(0,Math.floor(e.dropped??0));return e.connected?e.paused?{tone:"paused",resting:!1,label:kU(e.held,t),widest:ZM,title:t>0?`Connected — the pause is full at ${id(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up (Space)`:e.held>0?`Connected — ${id(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 jU=e=>e.transform[2]>=e.maxZoom,SU=e=>e.transform[2]<=e.minZoom;function _U({autoFitDisabled:e,enableAutoFitAndRefit:t,paused:n,pauseGate:r,togglePause:s,handleRelayout:o,requestClear:l,setKeyHelpOpen:u}){const d=gi(),h=Ge(jU),f=Ge(SU);return a.jsxs(nB,{showInteractive:!1,showFitView:!1,showZoom:!1,children:[a.jsx(On,{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(On,{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(On,{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(On,{"data-group-start":"",onClick:s,title:xU({paused:n,held:r.size,dropped:r.dropped}),"aria-label":vU,"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(On,{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(On,{"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(On,{"data-group-start":"",onClick:()=>u(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 Ia=148,wj=6e3,EU=16e3,JM=46,Xs=34;function CU(e,t,n=Ia){let r=-Math.round(t()*n);if(Math.abs(r-e)<Xs){const s=e-Xs>=-n?-Xs:Xs;r=Math.max(-n,Math.min(0,Math.round(e+s)))}return{to:r,ms:Math.round(Math.abs(r-e)*JM)}}function TU(e){return Math.round(wj+e()*(EU-wj))}const vj=[{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 AU(e){const t=vj.reduce((r,s)=>r+s.weight,0);let n=e()*t;for(const r of vj)if(n-=r.weight,n<0)return r.kind;return"stroll"}const RU=720,MU=260,$U=620,IU=220,xj=520,QM=1600,bj=7e3,OU=15e3,kj=6e3,LU=14e3;function Mo(e,t,n=Ia){let r=-Math.round(t()*n);if(Math.abs(r-e)<Xs){const s=e-Xs>=-n?-Xs:Xs;r=Math.max(-n,Math.min(0,Math.round(e+s)))}return r}const Ct=(e,t)=>Math.round(Math.abs(t-e)*JM),PU=120,Nu=0;function DU(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:RU},{x:Nu,prop:n({held:!0}),act:"carry",ms:Ct(t,Nu)},{x:Nu,prop:n({held:!0}),act:"windup",ms:MU},{x:Nu,prop:n({held:!0,leaving:!0}),act:"toss",ms:$U}]}function FU(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:IU,facing:n>0?"right":"left"},{x:r,prop:s({leaving:!0}),act:"kick",ms:xj,facing:n>0?"right":"left"},{x:r,prop:s({leaving:!0}),act:"stand",ms:QM-xj}]}const e$=640;function BU(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 qU(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:e$*(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 UU(e,t,n){return[{x:t,prop:null,act:"walk",ms:Ct(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(kj+n()*(LU-kj))},{x:t,prop:null,act:"stand",ms:400}]}function zU(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(bj+n()*(OU-bj))},{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 WU=1500,HU=e=>Math.round(1e3*Math.sqrt(2*e/WU)),VU=115,GU=e=>Math.round(e/VU*1e3),KU=620,YU=200,XU=760,ZU=600,JU=240;function QU(e,t,n){const s=-(t.ledgeSpan??Ia),o=HU(t.ledgeH),l=GU(t.ledgeH),u=n(),d=n(),h=-Math.round(u*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:KU},{x:s,act:"fall",prop:null,ms:o,place:"floor"},{x:s,act:"land",prop:null,ms:YU,place:"floor"},{x:h,act:"walk",prop:null,ms:Ct(s,h),place:"floor",floorFrac:u},{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:XU,place:"floor"},{x:s,act:"rope-throw",prop:null,ms:ZU,place:"floor"},{x:s,act:"rope-catch",prop:null,ms:JU,place:"floor"},{x:s,act:"climb",prop:null,ms:l},{x:s,act:"pull-up",prop:null,ms:480}]}function ez(e,t,n){const r=(n==null?void 0:n.ledgeSpan)??Ia;switch(AU(t)){case"tidy":return DU(e,Mo(e,t,r));case"kick":return FU(e,Mo(e,t,r));case"sit":return UU(e,Mo(e,t,r),t);case"watch":return zU(e,Mo(e,t,r),t);case"fish":return BU(e,Mo(e,t,r),t);case"skip":return qU(e,Mo(e,t,r),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return QU(e,n,t)}}const o=CU(e,t,r);return[{x:o.to,prop:null,act:"walk",ms:o.ms}]}const tz=420;function nz(e,t,n){const r=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(tz,Math.max(0,r))}const rz=260,sz=200;function az(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,u=l?n.left:n.right,d=l?n.right:n.left,h={place:"floor",riser:n.height,prop:null};return[r(u,Ct(e,u)),{...h,x:u,act:"mount",ms:rz},{...h,x:d,act:"walk",ms:Ct(u,d)},{x:d,prop:null,act:"dismount",ms:sz,place:"floor"},{x:t,prop:null,act:"walk",ms:Ct(d,t),place:"floor"}]}const t$=["bob","sway","groove"],Nj=9e3,oz=16e3,n$=1e3,iz=.08;function lz(e,t){const n=t$.filter(o=>o!==e),r=n[Math.min(n.length-1,Math.floor(t()*n.length))],s=(t()*2-1)*iz;return{dance:r,beatMs:Math.round(n$*(1+s))}}function cz(e){return Math.round(Nj+e()*(oz-Nj))}const r$=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],jj=18,uz=r$.length,s$=new Set(["a","c","p"]);function qd(e=r$){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 dz=[".xx.","xxxx",".xx."],hz=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],fz=["...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."],gp={litter:dz,ball:hz,scope:fz},pz=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],mz=3,gz=-1,vx=11,Sj=9,xx="https://www.youtube-nocookie.com";function yz(e,t,n){const r=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${xx}/embed/${n?encodeURIComponent(n):"live_stream"}?${r.toString()}`}function $o(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function wz(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const vz=[1,3],xz=[0,2],bz=[2,5,100,101,150];function kz(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:vz.includes(s)?{kind:"playing",playing:!0}:xz.includes(s)?{kind:"playing",playing:!1}:null}return null}const Nz="modulepreload",jz=function(e){return"/"+e},_j={},qb=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 u=document.querySelector("meta[property=csp-nonce]"),d=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));s=l(n.map(h=>{if(h=jz(h),h in _j)return;_j[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":Nz,f||(g.as="script"),g.crossOrigin="",g.href=h,d&&g.setAttribute("nonce",d),document.head.appendChild(g),f)return new Promise((v,k)=>{g.addEventListener("load",v),g.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(l){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=l,window.dispatchEvent(u),!u.defaultPrevented)throw l}return s.then(l=>{for(const u of l||[])u.status==="rejected"&&o(u.reason);return t().catch(o)})},gl=new Set;let Ej="";function Sz(e){const t=new Date().toISOString().slice(0,10);if(t!==Ej&&(gl.clear(),Ej=t),!gl.has(e)){gl.add(e);try{const n=typeof navigator>"u"?void 0:navigator;(!n||typeof n.sendBeacon!="function"||!n.sendBeacon("/api/feature",JSON.stringify({name:e})))&&gl.delete(e)}catch{gl.delete(e)}}}function qt(e,t=!0){w.useEffect(()=>{t&&Sz(e)},[e,t])}const _z={"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 Ez({fetchImpl:e,volume:t,muted:n,source:r,playRequest:s,customStation:o,onAvailabilityChange:l}){const[u,d]=w.useState(null),[h,f]=w.useState(!1),[p,g]=w.useState(!1),[v,k]=w.useState(!1);qt("claude-fm",v);const b=w.useRef(s),x=w.useRef(null),N=w.useRef(null),S=w.useRef(null),_=w.useCallback(()=>{var D;(D=N.current)==null||D.destroy(),N.current=null;const P=x.current;P&&(P.pause(),P.removeAttribute("src"),P.load(),x.current=null)},[]),E=w.useCallback(P=>{var D,I;(I=(D=S.current)==null?void 0:D.contentWindow)==null||I.postMessage(P,xx)},[]),T=w.useRef(t);T.current=t;const A=w.useRef(n);A.current=n;const R=w.useCallback((P,D,I)=>{_();const O=new Audio;O.preload="none",O.volume=T.current/100,O.muted=A.current,x.current=O,g(!0),k(!0);const z=()=>x.current===O,M=()=>{_(),g(!1),k(!1)},$=()=>{z()&&(M(),f(!0),l==null||l(I,!0))},q=X=>{if(z()){if(X instanceof DOMException&&X.name==="NotAllowedError"){M();return}$()}};O.addEventListener("playing",()=>{z()&&(k(!0),l==null||l(I,!1))}),O.addEventListener("ended",()=>{z()&&M()}),O.addEventListener("error",$,{once:!0}),D&&!O.canPlayType("application/vnd.apple.mpegurl")?qb(async()=>{const{default:X}=await import("./hls-BFpXDghs.js");return{default:X}},[]).then(({default:X})=>{if(!z())return;if(!X.isSupported()){$();return}const H=new X;N.current=H,H.on(X.Events.ERROR,(L,W)=>{W.fatal&&$()}),H.on(X.Events.MEDIA_ATTACHED,()=>H.loadSource(P)),H.on(X.Events.MANIFEST_PARSED,()=>{O.play().catch(q)}),H.attachMedia(O)},$):(O.src=P,O.play().catch(q))},[l,_]);return w.useEffect(()=>{p&&(E($o("setVolume",[t])),E($o(n?"mute":"unMute")),x.current&&(x.current.volume=t/100,x.current.muted=n))},[t,n,p,E]),w.useEffect(()=>{let P=!0;const D=e??fetch,I=b.current!==s;b.current=s,d(null),f(!1),g(I),k(I),_();const O=o&&Ba(o.id)===r?_b(o.url):null;if(O)return O.kind==="direct-audio"?(d({live:!0,channel:"",audio:O.url,hls:O.format==="hls"}),l==null||l(r,!1),I&&R(O.url,O.format==="hls",r),()=>{P=!1}):(D(`/api/fm-station?url=${encodeURIComponent(O.url)}`).then($=>$.ok?$.json():null).then($=>{P&&($!=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(()=>{P&&(f(!0),l==null||l(r,!0))}),()=>{P=!1});if(oi(r))return f(!0),l==null||l(r,!0),()=>{P=!1};const z=r,M=_z[z];if(M)D(M).then($=>$.ok?$.json():null).then($=>{P&&($!=null&&$.video&&d({live:!0,channel:"",video:$.video}),l==null||l(r,!($!=null&&$.video)))}).catch(()=>{P&&(l==null||l(r,!0))});else if(z!=="claude-fm"){const $=z.replace("lofi-","");D(`/api/lofi-girl?station=${encodeURIComponent($)}`).then(q=>q.ok?q.json():null).then(q=>{P&&(q!=null&&q.video&&d({live:!0,channel:"",video:q.video}),l==null||l(r,!(q!=null&&q.video)))}).catch(()=>{P&&(l==null||l(r,!0))})}else D("/api/claude-fm").then($=>$.ok?$.json():null).then($=>{if(!P)return;const q=!!($!=null&&$.live&&($!=null&&$.channel));q&&d({live:!0,channel:$.channel}),l==null||l(r,!q)}).catch(()=>{P&&(l==null||l(r,!0))});return()=>{P=!1}},[o==null?void 0:o.id,o==null?void 0:o.url,e,l,s,r,R,_]),w.useEffect(()=>()=>_(),[_]),w.useEffect(()=>{if(!p)return;const P=D=>{var O;if(D.origin!==xx||D.source!==((O=S.current)==null?void 0:O.contentWindow))return;const I=kz(D.data);if(I){if(I.kind==="ready"){E($o("setVolume",[T.current])),E($o(n?"mute":"unMute")),E($o("playVideo"));return}if(I.kind==="playing"){k(I.playing);return}bz.includes(I.code)&&(g(!1),k(!1),f(!0),l==null||l(r,!0))}};return window.addEventListener("message",P),()=>window.removeEventListener("message",P)},[p,n,l,E,r]),{probe:u,dead:h,armed:p,playing:v,frame:S,say:E,press:()=>{if(!u)return;if(u.audio){if(p){_(),g(!1),k(!1);return}R(u.audio,u.hls===!0,r);return}if(!p){g(!0),k(!0);return}const P=!v;k(P),E($o(P?"playVideo":"pauseVideo")),P||g(!1)}}}function Cj(e){let t=null,n=null,r=0,s=0,o=!1;const l=()=>{t!==null&&clearTimeout(t),t=null},u=()=>{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||u()};return e.addEventListener("visibilitychange",d),{schedule(h,f){o||(l(),n=h,r=Math.max(0,f),u())},dispose(){o=!0,l(),n=null,e.removeEventListener("visibilitychange",d)}}}function Cz(e,t,n){const[r,s]=w.useState(0),[o,l]=w.useState(0),[u,d]=w.useState(null),[h,f]=w.useState(null),[p,g]=w.useState({x:0,drop:0}),[v,k]=w.useState("ledge"),[b,x]=w.useState("left"),[N,S]=w.useState(0),_=w.useRef(null),[E,T]=w.useState(()=>document.hidden);w.useEffect(()=>{const O=new Set,z=()=>{var M;if(document.hidden){for(const $ of((M=_.current)==null?void 0:M.getAnimations({subtree:!0}))??[])if($.playState==="running"||$.pending){const q=$.currentTime;$.pause(),q!==null&&($.currentTime=q),O.add($)}}else{for(const $ of O)$.playState==="paused"&&$.play();O.clear()}T(document.hidden)};return z(),document.addEventListener("visibilitychange",z),()=>document.removeEventListener("visibilitychange",z)},[e,t]);const[A,R]=w.useState(null),[B,P]=w.useState(n$),[D,I]=w.useState(()=>{var O;return((O=window.matchMedia)==null?void 0:O.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});return w.useEffect(()=>{var M;const O=(M=window.matchMedia)==null?void 0:M.call(window,"(prefers-reduced-motion: reduce)");if(!O)return;const z=()=>I(O.matches);return z(),O.addEventListener("change",z),()=>O.removeEventListener("change",z)},[]),w.useEffect(()=>{var K;if(!e||t||D)return;const O=Cj(document);let z=0;s(Z=>z=Z);let M=null,$=0,q=0;const X=Z=>{var ie,fe;const[ee,...re]=Z;if(!ee){M=null,d(null),f(null),J();return}d(ee.act),f(ee.prop),k(ee.place??"ledge"),S(ee.riser??0);const ue=z,me=F(ee);if(ee.act==="kick"){const ve=(fe=(ie=_.current)==null?void 0:ie.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:fe.getBoundingClientRect();ve&&g({x:nz(ve.x,mp(ee,ue,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-ve.y+24)})}q=ee.act==="walk"?Math.max(Ct(ue,me),PU):ee.ms,ee.act==="carry"&&(q=Ct(ue,me)),l(q),x(ve=>mp({...ee,x:me},ue,ve)),s(me),z=me,M=ee,$=Date.now(),O.schedule(()=>X(re),q)},H=()=>{const Z=_.current,ee=Z==null?void 0:Z.querySelector(".fm-sprite"),re=Z==null?void 0:Z.parentElement;if(!Z||!ee||!re)return null;const ue=Z.getBoundingClientRect(),me=re.getBoundingClientRect(),ie=me.right-ue.right,fe=me.width-ie*2-ee.offsetWidth;return fe>0?fe:null},L=()=>{const Z=_.current,ee=Z==null?void 0:Z.querySelector(".fm-walker"),re=H();if(!Z||!ee||re==null)return;const ue=Z.getBoundingClientRect().bottom-ee.getBoundingClientRect().bottom;if(ue>0)return{ledgeH:ue,floorSpan:re}},W=()=>{const Z=_.current,ee=document.querySelector(".autofit-chip");if(!Z||!ee)return null;const re=Z.getBoundingClientRect(),ue=ee.getBoundingClientRect();return ue.width<=0||ue.height<=0?null:{left:ue.left-re.right,right:ue.right-re.right,height:ue.height}},F=Z=>{const ee=(Z.place??"ledge")==="floor",re=ee?H()??Ia:Ia,ue=ee&&Z.floorFrac!=null?-Math.round(Z.floorFrac*re):Z.x;return Math.max(-re,Math.min(0,ue))},Y=()=>{if(!M)return;const Z=F(M);Z!==z&&(l(Math.max(0,$+q-Date.now())),x(ee=>mp({...M,x:Z},z,ee)),s(Z),z=Z)},J=()=>{O.schedule(()=>{const Z=ez(z,Math.random,L()),ee=Z.some(me=>me.place==="floor")?W():null;let re=z;const ue=Z.flatMap(me=>{const ie=re;if(re=me.x,!(me.place==="floor"&&me.act==="walk"))return[me];const fe=az(ie,me.x,ee),ve=fe.length-1;return me.floorFrac==null?fe:fe.map((se,ke)=>ke===ve?{...se,floorFrac:me.floorFrac}:se)});X(ue)},TU(Math.random))},V=(K=_.current)==null?void 0:K.parentElement,G=typeof ResizeObserver>"u"?null:new ResizeObserver(Y);return V&&G&&G.observe(V),J(),()=>{O.dispose(),G==null||G.disconnect(),k("ledge"),s(Z=>Math.max(-Ia,Math.min(0,Z))),l(0),d(null),f(null),S(0)}},[e,t,D]),w.useEffect(()=>{if(!n||D){R(null);return}const O=Cj(document),z=M=>{const $=lz(M,Math.random);R($.dance),P($.beatMs),O.schedule(()=>z($.dance),cz(Math.random))};return z(null),()=>O.dispose()},[n,D]),{scene:_,suspended:E,x:r,walkMs:o,act:u,prop:h,ballFlight:p,place:v,facing:b,riser:N,dance:A,beatMs:B}}const yp={e:"fm-eye",s:"fm-shade",p:"fm-pad"},ld=qd().filter(e=>!s$.has(e.cell)),Tz=qd().filter(e=>s$.has(e.cell)),Tj=ld.filter(e=>e.cell==="e"),Az=qd(pz),Rz=ld.filter(e=>e.y<vx&&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),Mz={left:ld.filter(e=>e.y>=vx&&e.x<Sj),right:ld.filter(e=>e.y>=vx&&e.x>=Sj)},$z=w.memo(function({act:t,facing:n}){return a.jsxs("svg",{viewBox:`0 0 ${jj} ${uz}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:Tz.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:yp[r.cell]},`g${r.y}-${r.x}`))})}),a.jsxs("g",{className:"fm-body",children:[Tj.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:"var(--accent)"},`eye-bed-${r.x}`)),Rz.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:yp[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"})]}),Tj.map(r=>a.jsx("rect",{x:r.x-(r.x>=jj/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:Az.map(r=>a.jsx("rect",{x:mz+r.x,y:gz+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:Mz[r].map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:yp[s.cell]},`${r}${s.y}-${s.x}`))},r))]})}),Iz={"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 Oz(e,t){return t&&Ba(t.id)===e?t.name:oi(e)?"Custom FM":Iz[e]}function wp(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:qd(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 Aj={litter:wp(gp.litter,"litter"),ball:wp(gp.ball,"ball"),scope:wp(gp.scope,"scope")};function Lz(e){try{return new URL(e).host}catch{return"the station's server"}}const Pz=w.memo(function({fetchImpl:t,volume:n,muted:r=!1,source:s="claude-fm",playRequest:o=0,customStation:l,onAvailabilityChange:u}){const{probe:d,dead:h,armed:f,playing:p,frame:g,say:v,press:k}=Ez({fetchImpl:t,volume:n,muted:r,source:s,playRequest:o,customStation:l,onAvailabilityChange:u}),{scene:b,suspended:x,x:N,walkMs:S,act:_,prop:E,ballFlight:T,place:A,facing:R,riser:B,dance:P,beatMs:D}=Cz(d,h,p);if(!d||h)return null;const I=Oz(s,l),O=d.audio?Lz(d.audio):"YouTube";return a.jsxs("div",{ref:b,className:"fm","data-suspended":x?"":void 0,"data-place":A,style:{"--fm-beat":`${D}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":`${T.x}px`,"--fm-ball-drop":`${T.drop}px`,"--fm-ball-flight-ms":`${QM}ms`,"--fm-ball-turn":R==="right"?"1080deg":"-1080deg"},children:Aj[E.kind]}),(_==="lasso"||_==="rope-throw"||_==="rope-catch"||_==="climb"||_==="pull-up")&&a.jsxs("div",{className:"fm-rope","data-act":_,style:{"--fm-rope-x":`${N}px`,"--fm-rope-ms":`${S}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":A,"data-facing":R,style:{"--fm-x":`${N}px`,"--fm-walk-ms":`${S}ms`,"--fm-riser":`${B}px`,"--fm-skip-beat":`${e$}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:Aj[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?P??t$[0]:void 0,onClick:k,title:p?`Stop ${I}`:`Play ${I} — streams from ${O}`,"aria-label":p?`Stop ${I}`:`Play ${I}`,children:a.jsx($z,{act:_,facing:R})})]}),f&&!d.audio&&(d.channel||d.video)&&a.jsx("iframe",{ref:g,className:"fm-frame",title:I,src:yz(d.channel,window.location.origin,d.video),onLoad:()=>v(wz()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})]})});function a$(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 cd(e){return a$(Math.floor(e/1e3))}function Ud(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 Dz(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function ud(e,t,n){const r=new Date(e),s=cd(t-e);return{label:Dz(r,new Date(t))?s:`${s} · ${r.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:r.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function Fz({data:e}){const t=xi(3e4),n=ud(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(ql,{}),"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(),S8(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(ql,{}),"recap"]}),a.jsx("span",{className:"recap-face-age",children:n.label})]}),a.jsx("p",{className:"recap-face-text",children:e.recap.text})]}),a.jsx(Fa,{type:"source",position:Ae.Right,style:{background:"transparent",border:"none"}})]})}function Bz({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s,targetPosition:o,style:l}){const[u]=vb({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:u}),a.jsx("path",{className:"recap-tie-beads",d:u}),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 Ub(e,t){const n=bx(e);return n?n.slice(-t):e.slice(-t)}function o$(e,t,n=4){const r=bx(e);if(!r)return Ub(e,n);let s=n;for(const o of t){if(o===e)continue;const l=bx(o);let u=0;for(;u<r.length&&u<l.length&&r[r.length-1-u]===l[l.length-1-u];)u++;s=Math.max(s,u+1)}return r.slice(-s)}const zu=" · ",qz=32,Uz=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function Rj(e){return Uz.test(e)?2:1}function Mj(e,t=qz){const n=[...e];let r=0;for(const l of n)r+=Rj(l);if(r<=t)return e;const s=[];let o=0;for(const l of n){const u=Rj(l);if(o+u>t-1)break;s.push(l),o+=u}for(;s.length&&/[\s\-_.:/]/.test(s[s.length-1]);)s.pop();return`${s.join("")}…`}function zz(e,t,n,r,s=[]){const o=(t==null?void 0:t.trim())??"",l=r?o$(n,s):void 0,u=[e,o||void 0,l].filter(Boolean);return{label:Mj(e),name:o?Mj(o):void 0,shortId:l,fullLabel:u.join(zu)}}const Ra=18,kx=26,i$=12,Wz=240;function Hz(e,t){return(e+Wz)*(t||1)}function Vz(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 Gz(e,t,n){return{position:"absolute",left:e.x+16,top:e.y-i$/(t||1),transform:`scale(${1/(t||1)})`,transformOrigin:"left top",maxWidth:Hz(e.w,t),"--session-hue":n}}function Kz(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,u=s.position.y,d=l+s.width,h=u+s.height,f=t.get(o.sessionId),p=Yz(o);f?(f.minX=Math.min(f.minX,l),f.minY=Math.min(f.minY,u),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:u,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)??[],u=l.length>1;r.push({sessionId:s,...zz(o.label,o.name,s,u,l),x:o.minX-Ra,y:o.minY-Ra-kx,w:o.maxX-o.minX+Ra*2,h:o.maxY-o.minY+Ra*2+kx,...o.alarm?{alarm:!0}:null,...o.branch?{branch:o.branch}:null})}return r}function Yz(e){if(e.kind!=="root")return null;const t=e.branch;return{label:e.label,name:Ob(e.sessionName,e.sessionTitle).face,alarm:pr(e.waiting),branch:t&&t.total>0?WM(t):void 0}}function Xz(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 Zz(e){return Kz(e.nodeInternals.values())}function Jz({onFocusSession:e}){const{x:t,y:n,zoom:r}=nM(),s=Ge(Zz,Xz);if(s.length<=1)return null;const o=u=>{try{e==null||e(u)}catch{}},l={transform:`translate(${t}px, ${n}px) scale(${r})`};return a.jsx("div",{className:"session-clusters",style:l,children:s.map(u=>{const d=od(u.sessionId),h=Vz(u,d),f=Gz(u,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":u.alarm?"":void 0,style:f,title:`${u.alarm?`Waiting on you
72
+ `:""}Zoom to ${u.fullLabel}
73
+ drag the wrapper to move the whole session`,onClick:()=>o(u.sessionId),children:[u.alarm?a.jsxs(a.Fragment,{children:[a.jsx(Bb,{}),a.jsx("span",{className:"cluster-label-said",children:"waiting on you: "})]}):null,u.label,u.branch?a.jsx("span",{className:"cluster-label-branch",children:zu+u.branch}):null,u.name?a.jsx("span",{className:"cluster-label-name",children:zu+u.name}):null,u.shortId?a.jsx("span",{className:"cluster-label-id",children:zu+u.shortId}):null]})]},u.sessionId)})})}function Qz({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 l$=600,eW=4,tW=36,Nx=16,nW=60,rW=6,$j=220,sW=96,aW=28;function oW(e,t){return Math.max(sW,61+[...t].length*6.8)}function iW(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function lW(e,t){if(t==null)return 1;const n=e-t;return n<0?1:Math.max(0,1-n/l$)}function cW(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 uW(e,t,n,r,s,o){const l=[];for(const u of e.values()){if(!t.has(u.id)||u.exitAt!=null&&o-u.exitAt>l$)continue;const d=r.get(u.id)??n.get(u.id);if(!d)continue;const h=cW(u.tools,eW);if(h.length===0)continue;const f=u.exitAt??null,p=s.get(u.id),g=Math.max((p==null?void 0:p.width)??$j,$j),v=(p==null?void 0:p.height)??130,k=d.x,b=d.y,x=k+g,N=b+v/2;h.forEach((S,_)=>{const E=_*tW,T=k+g+nW,A=b+rW+E,R=lW(o,f),B=S.inputPreview??"",P=iW(S),D=R<.999,I=Fb(S.name);l.push({id:`${u.id}::${S.id}`,toolId:S.id,agentId:u.id,toolName:S.name,name:I.label,emoji:I.emoji,status:P,category:HM(S.name),mcpHue:I.hue,inputPreview:B,fade:R,fading:D,worldX:T,worldY:A,anchorX:x,anchorY:N,spawnDx:x-T,spawnDy:N-(A+Nx)});const O=YM(S.name,S.input);if(O){const z=oW(S.name,I.label),M=T+z+aW,$=A,q=T+z,X=A+Nx;l.push({id:`sub:${u.id}::${S.id}`,toolId:S.id,agentId:u.id,toolName:S.name,name:aU(O.label,O.category),fullName:O.label,emoji:O.emoji,isSub:!0,status:P,category:O.category,inputPreview:O.detail??B,fade:R,fading:D,worldX:M,worldY:$,anchorX:q,anchorY:X,spawnDx:q-M,spawnDy:0})}})}return l}function dW({agents:e,visibleAgentIds:t,positions:n,pinned:r,measured:s,spotlight:o,hiddenCategories:l,now:u,onOpenTool:d}){const h=uW(e,t,n,r,s,u),f=l&&l.size>0?h.filter(p=>!l.has(p.category)):h;return a.jsx(hW,{bursts:f,spotlight:o,onOpenTool:d})}function hW({bursts:e,spotlight:t,onOpenTool:n}){const{x:r,y:s,zoom:o}=nM();return a.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[a.jsx("svg",{className:"tool-bursts-svg",children:e.map(l=>{const u=l.anchorX*o+r,d=l.anchorY*o+s,h=(l.worldX+6)*o+r,f=(l.worldY+Nx)*o+s,p=Math.max(1,h-u),g=Math.min(1,Math.abs(f-d)/p),v=u+p*(.55-.22*g),k=t!=null&&!t.has(l.agentId),b=l.fade*(k?.14:1);return a.jsx("path",{d:`M ${u} ${d} Q ${v} ${d}, ${h} ${f}`,className:`tool-conn status-${l.status}${l.fading?" fading":""}`,opacity:b},`l:${l.id}`)})}),e.map(l=>a.jsx(pW,{b:l,x:r,y:s,zoom:o,dim:t!=null&&!t.has(l.agentId),onOpenTool:n},l.id))]})}function fW(e,t){const n=e.b,r=t.b;return e.x===t.x&&e.y===t.y&&e.zoom===t.zoom&&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 pW=w.memo(function({b:t,x:n,y:r,zoom:s,dim:o,onOpenTool:l}){const u=t.worldX*s+n,d=t.worldY*s+r,h={left:`${u}px`,top:`${d}px`,transform:`scale(${s})`,transformOrigin:"left top","--spawn-dx":`${t.spawnDx}px`,"--spawn-dy":`${t.spawnDy}px`},f=t.isSub?`${t.toolName} · ${t.fullName??t.name}`:t.toolName,p=t.inputPreview?`${f} · ${t.inputPreview}`:f,g=l!=null,v=t.mcpHue!=null?{"--mcp-hue":t.mcpHue}:{},k=o?" dim":"";return a.jsx("div",{className:"tool-burst-wrap",style:h,children:a.jsxs("div",{className:`tool-burst cat-${t.category}${t.mcpHue!=null?" mcp-hue":""} status-${t.status}${t.fading?" fading":""}${g?" clickable":""}${t.isSub?" sub":""}${k}`,style:v,title:p,onClick:g?()=>l(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:"×"})]})})},fW),mW={agent:dU,sessionGroup:Qz,recapNote:Fz},gW={recapTie:Bz},Ij=400;function yW({graph:e,layout:t,viewport:n,clicks:r,drag:s,appearance:o,fm:l,autoFit:u,pause:d,stateRef:h,measuredRef:f,hiddenCats:p,now:g,openTool:v,focusAgent:k,requestClear:b,setKeyHelpOpen:x}){const{allNodes:N,edges:S,visibleAgentIds:_,spotlightSet:E}=e,{positionsRef:T,pinnedRef:A,handleRelayout:R}=t,{restoredViewport:B,onMoveStart:P,onMove:D}=n,{onNodeClick:I,onPaneClick:O,onNodeDoubleClick:z,onNodeMouseEnter:M,onNodeMouseLeave:$}=r,{onNodeDragStart:q,onNodeDrag:X,onNodeDragStop:H}=s,{palette:L,minimapNodeFill:W,characterEnabled:F}=o,{fmVolume:Y,fmMuted:J,fmSource:V,fmPlayRequest:G,customFmStations:K,markFmStationAvailability:Z}=l,{autoFitDisabled:ee,enableAutoFitAndRefit:re}=u,{paused:ue,pauseGate:me,togglePause:ie}=d;return a.jsxs(tM,{nodes:N,edges:S,nodeTypes:mW,edgesFocusable:!1,edgeTypes:gW,fitView:!B,fitViewOptions:{padding:.25,duration:px({durationMs:Ij,documentHidden:document.hidden})?Ij:0},minZoom:lM,maxZoom:cM,panOnScroll:!0,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,disableKeyboardA11y:!0,deleteKeyCode:null,onNodeClick:I,onPaneClick:O,onNodeDoubleClick:z,onNodeMouseEnter:M,onNodeMouseLeave:$,onMoveStart:P,onMove:D,onNodeDragStart:q,onNodeDrag:X,onNodeDragStop:H,children:[a.jsx(lB,{gap:28,size:1,color:L["--grid-line"]}),a.jsx(Jz,{onFocusSession:k}),a.jsx(dW,{agents:h.current.agents,visibleAgentIds:_,positions:T.current,pinned:A.current,measured:f.current,spotlight:E,hiddenCategories:p,now:g,onOpenTool:v}),ee&&a.jsx(yU,{enableAutoFitAndRefit:re}),a.jsx(_U,{autoFitDisabled:ee,enableAutoFitAndRefit:re,paused:ue,pauseGate:me,togglePause:ie,handleRelayout:R,requestClear:b,setKeyHelpOpen:x}),a.jsx(Y6,{zoomable:!0,pannable:!0,nodeColor:W,nodeStrokeWidth:2,maskColor:L["--minimap-mask"],maskStrokeColor:L["--line"]}),F&&a.jsx(Pz,{volume:Y,muted:J,source:V,playRequest:G,customStation:K.find(fe=>Ba(fe.id)===V),onAvailabilityChange:Z})]})}function wW(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 u=fn(l);t.input+=u.input,t.output+=u.output,t.cacheRead+=u.cacheRead,t.cacheWrite+=u.cacheWrite,t.total+=u.total,n+=l.usage.inputTokens,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 vW="spend on this board",xW="on this board",Oj=`Everything on the board right now, and only that.
74
+ 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.
75
+ Press H for the totals ccusage reads off the logs on disk, which do not forget.`,c$="session spend",jx="__unknown__",bW=12;function kW(e,t=Date.now()){const n=new Map;for(const r of e)for(const s of sc(r)){const o=s.model??jx,l=Jo(s.usage,s.model,t),u=n.get(o);u?(u.inputTokens+=s.usage.inputTokens,u.outputTokens+=s.usage.outputTokens,u.cacheReadTokens+=s.usage.cacheReadTokens,u.cacheCreateTokens+=s.usage.cacheCreateTokens,u.cost.total+=l.total,u.cost.input+=l.input,u.cost.output+=l.output,u.cost.cacheRead+=l.cacheRead,u.cost.cacheWrite+=l.cacheWrite,u.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:Wa(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 NW(e,t=Date.now()){const n=[...e],r=[];for(const s of n){if(s.kind!=="root")continue;let o=fn(s,t).total,l=s.usage.inputTokens,u=s.usage.outputTokens,d=Bl(s,t);for(const h of n)h.sessionId!==s.sessionId||h.kind==="root"||(o+=fn(h,t).total,l+=h.usage.inputTokens,u+=h.usage.outputTokens,d+=Bl(h,t));r.push({sessionId:s.sessionId,label:s.label||s.cwdBasename||"session",state:s.state,cost:o,inputTokens:l,outputTokens:u,unpricedTokens:d})}return r.sort((s,o)=>o.cost-s.cost||o.inputTokens+o.outputTokens-(s.inputTokens+s.outputTokens)).slice(0,bW)}function Lj(e){return e.waiting?pr(e.waiting)?0:1:e.state==="active"?2:3}function jW(e,t){const n=[];for(const r of e.agents.values()){if(r.kind!=="root")continue;let s=r.toolCount,o=fn(r).total,l=r.endedAt??r.startedAt;for(const u of e.agents.values()){if(u.sessionId!==r.sessionId||u.kind==="root")continue;s+=u.toolCount,o+=fn(u).total;const d=u.endedAt??u.startedAt;d>l&&(l=d)}n.push({sessionId:r.sessionId,label:r.label||r.cwdBasename||"session",cwdBasename:r.cwdBasename,state:r.state,waiting:r.waiting,recap:Fd(r),modelId:r.model,toolCount:s,cost:o,startedAt:r.startedAt,lastActivity:l})}return n.sort((r,s)=>{const o=Lj(r),l=Lj(s);return o!==l?o-l:r.waiting&&s.waiting?r.waiting.since-s.waiting.since:s.lastActivity-r.lastActivity}),n}function Pj(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 SW({state:e,now:t,selectedIds:n,onSelect:r,onClose:s,removedIds:o,onBringBackAll:l}){const u=w.useMemo(()=>jW(e),[e,e.revision,t]),d=u.filter(f=>f.state==="active").length,h=u.filter(f=>pr(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:u.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:[u.length===0&&a.jsx("li",{className:"sl-empty",children:"No sessions yet."}),u.map(f=>{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:ii(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":Od(f.modelId),title:f.modelId,children:Qs(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:c$,children:a.jsx("b",{children:Fe(f.cost)})}),f.waiting?a.jsxs("span",{className:"sl-waiting",title:[li(f.waiting),Vq(f.waiting,li(f.waiting)),`Blocked since ${new Date(f.waiting.since).toLocaleTimeString()} · started ${new Date(f.startedAt).toLocaleString()}`].filter(Boolean).join(`
76
+ `),children:["waiting ",Pj(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:Pj(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(ql,{}),f.recap.text]})]})]})},f.sessionId)})]}),(()=>{const f=(o==null?void 0:o.size)??0;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 Sx={cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,sessions:0};function _W(e){if(!e.synthetic)return!1;const t=e.usage;return t.inputTokens+t.outputTokens+t.cacheReadTokens+t.cacheCreateTokens<=0}function _x(e,t){const n=new Map;for(const r of e){if(r.kind!=="root"||!r.sessionId||_W(r))continue;const s=fn(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 EW(e,t){if(!e)return Sx;const n={...Sx};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 Ex(e,t=new Date){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}const zd=[{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 CW(e,t,n=zd.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 u$(e,t=new Date){return e==="today"?Ex(1,t):e==="month"?Ex(t.getDate(),t):"20200101"}const un=e=>typeof e=="number"&&Number.isFinite(e)?e:0,Wu=e=>typeof e=="string"?e:"";function d$(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=Wu(o==null?void 0:o.modelName);if(!l)continue;let u=n.get(l);u||(u={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,u)),u.cost+=un(o==null?void 0:o.cost),u.inputTokens+=un(o==null?void 0:o.inputTokens),u.outputTokens+=un(o==null?void 0:o.outputTokens),u.cacheReadTokens+=un(o==null?void 0:o.cacheReadTokens),u.cacheCreateTokens+=un(o==null?void 0:o.cacheCreationTokens)}}return[...n.values()].sort((r,s)=>s.cost-r.cost||s.tokens-r.tokens)}const TW=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function AW(e){var t;return((t=TW.exec(e))==null?void 0:t[0])??e}function RW(e,t=new Map){const n=Array.isArray(e==null?void 0:e.sessions)?e.sessions:[],r=[];for(const s of n){const o=Wu(s==null?void 0:s.period);if(!o)continue;const l=AW(o),u=s==null?void 0:s.metadata,d=typeof(u==null?void 0:u.lastActivity)=="string"?Date.parse(u.lastActivity):NaN;r.push({sessionId:l,label:t.get(l)??null,agent:Wu(s==null?void 0:s.agent)||"claude",cost:un(s==null?void 0:s.totalCost),tokens:un(s==null?void 0:s.totalTokens),models:Array.isArray(s==null?void 0:s.modelsUsed)?s.modelsUsed.map(Wu).filter(Boolean):[],lastActivityMs:Number.isFinite(d)?d:null})}return r.sort((s,o)=>o.cost-s.cost||o.tokens-s.tokens)}function MW(e,t=Wd(e).cost){const r=(Array.isArray(e==null?void 0:e.sessions)?e.sessions:[]).reduce((o,l)=>o+un(l==null?void 0:l.totalCost),0),s=Math.max(.01,t*.01);return{sum:r,total:t,over:r>t+s}}function $W(e,t,n){const r=`Sessions with activity ${e}, and what ccusage puts against each one.`;return t.over?`${r}
77
+ 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 Wd(e){const t=e==null?void 0:e.totals;if(t&&typeof t=="object"){const d=un(t.cacheReadTokens),h=un(t.cacheCreationTokens),f=un(t.inputTokens),p=un(t.outputTokens);return{cost:un(t.totalCost),inputTokens:f,outputTokens:p,cacheReadTokens:d,cacheCreateTokens:h,tokens:un(t.totalTokens)||f+p+d+h}}const n=d$(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),u=r(d=>d.cacheCreateTokens);return{cost:r(d=>d.cost),inputTokens:s,outputTokens:o,cacheReadTokens:l,cacheCreateTokens:u,tokens:s+o+l+u}}function IW(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 h$(e,t){var n;return((n=zd.find(r=>r.key===(e??t)))==null?void 0:n.noun)??"today"}function OW(e,t,n){const r=e!=null,s=Wd(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 f$="agent-dag.usagePeriod";function LW(){const e=et(f$);return zd.some(t=>t.key===e)?e:"today"}function PW(e){Xe(f$,e)}const p$="agent-dag.usageSessionsOpen";function DW(){return et(p$)==="1"}function FW(e){Xe(p$,e?"1":"0")}function zb({cost:e,size:t="md"}){const n=e.total;if(n<=0)return null;const r=(o,l,u)=>{if(o<=0)return null;const d=o/n*100;return a.jsx("span",{className:`cb-seg ${l}`,style:{width:`${d}%`},title:`${u}: ${Fe(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 bt="ccdeck",BW="/brand/ccdeck-mark-gradient-small-optical.svg",qW="/brand/ccdeck-mark-mono-dark-small-optical.svg";function m$(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 UW({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 g$({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 zW(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 u=Math.min(100,l/n*100),d=e-u;if(s||e>=100)return{label:"used up",color:"var(--warn)",expectedPct:u,isDeficit:!0};if(Math.abs(d)<3)return{label:"on pace",color:"var(--ok)",expectedPct:u,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:u,isDeficit:!0};if(p<o&&p<86400){const v=Math.floor(p/3600),k=Math.floor(p%3600/60);g.runsOutIn=v>0?`${v}h ${k}m`:`${k}m`}return g}return{label:`${Math.round(-d)}% under pace`,color:"var(--ok)",expectedPct:u,isDeficit:!1}}function Ys({pct:e,label:t,reset:n,resetAt:r,windowSec:s,limitReached:o,nowSec:l}){const u=e!=null,d=u?Math.min(100,Math.max(0,e)):0,f=o||d>=90?"var(--err)":d>=70?"var(--warn)":"var(--accent)",p=d<1,g=u?p?"< 1%":`${Math.round(d)}%`:"no reading",v=p?2:d,k=r?Ud(r,l):null,b=u&&r&&s?zW(d,r,s,l,o):null,[x,N]=w.useState(!1),S=w.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&&a.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),a.jsx("span",{className:"qb-pct",style:{color:u?f:"var(--muted)"},children:g})]}),a.jsxs("div",{className:"qb-track",children:[u&&a.jsx("div",{className:"qb-fill",style:{transform:`scaleX(${v/100})`,background:f,opacity:p?.4:1}}),b&&a.jsx("div",{className:"qb-pace-rail",style:{transform:`translateX(${b.expectedPct}%)`},children:a.jsx("div",{"aria-hidden":!0,className:"qb-pace-marker",style:{background:b.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(b.expectedPct)}% by now`})})]}),a.jsxs("div",{className:"qb-reset-row",children:[k?a.jsxs("span",{className:"qb-reset",children:["resets in ",k]}):n?a.jsxs("span",{className:"qb-reset",children:["resets ",n]}):null,b&&a.jsxs("button",{type:"button",className:"qb-pace",style:{color:b.color},"aria-expanded":x,"aria-controls":x?S:void 0,onClick:()=>N(_=>!_),children:[a.jsx("i",{className:"qb-pace-key","aria-hidden":!0,style:{background:b.isDeficit?"var(--err)":"var(--ok)"}}),b.runsOutIn?`runs out in ${b.runsOutIn}`:b.label]})]}),x&&b&&a.jsxs("div",{id:S,className:"qb-why",children:["To last until reset, stay near ",Math.round(b.expectedPct),"% by now."]})]})}function y$(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 WW(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 HW(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 VW(e){switch(e){case"no_token":return"Run codex login to authenticate.";case"api_key_mode":return"API-key login — ChatGPT quota is only available for codex login.";case"refresh_rejected":return"Codex session expired — run codex login.";case"refresh_failed":return"Couldn't refresh the Codex token — click ↻ to retry.";case"untrusted_base_url":return"chatgpt_base_url in ~/.codex/config.toml is not an https OpenAI host, so the token was not sent.";default:return"ChatGPT API unreachable — click ↻ to retry."}}function GW({quota:e,quotaLoading:t,nowSec:n,incident:r}){const s=y$(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.jsx("span",{className:"up-section-age",title:WW(e==null?void 0:e.source),children:s})]}),a.jsx(g$,{incident:r}),e!=null&&e.ok?a.jsxs("div",{className:"up-quota-bars",children:[e.session5hPct!=null&&a.jsx(Ys,{label:"5-hour window",pct:e.session5hPct,reset:e.session5hReset,resetAt:e.session5hResetAt,windowSec:e.session5hWindowSec,nowSec:n}),a.jsx(Ys,{label:"7-day window",pct:e.week7dPct??null,reset:e.week7dReset,resetAt:e.week7dResetAt,windowSec:e.week7dWindowSec,nowSec:n}),e.weekSonnetPct!=null&&a.jsx(Ys,{label:"Sonnet (7d)",pct:e.weekSonnetPct,nowSec:n}),e.weekOpusPct!=null&&a.jsx(Ys,{label:"Opus (7d)",pct:e.weekOpusPct,nowSec:n}),e.extraEnabled&&e.extraUsedCredits!=null&&e.extraMonthlyLimit?a.jsx(Ys,{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 — ${bt} only reports them`,children:m$("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:HW(e.reason)})]}):a.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]})}function KW({codexQuota:e,codexLoading:t,codexUsage:n,nowSec:r,incident:s}){var l,u;const o=y$(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(g$,{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(Ys,{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)),(u=e.extraWindows)==null?void 0:u.map(d=>a.jsx(Ys,{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(Ys,{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 — ${bt} only reports them`,children:m$("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:VW(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?`
78
+ last 5h: ${ot(n.window5h.totalTokens)} tokens · ${n.window5h.sessionCount} session${n.window5h.sessionCount!==1?"s":""}`:""}`,children:[ot(n.window7d.totalTokens)," tokens · ",n.window7d.sessionCount," session",n.window7d.sessionCount!==1?"s":""," (7d)"]})]})}function YW({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:Qs(r.model)}),a.jsx("td",{className:"up-num",children:ot(r.tokens)}),r.cost>0?a.jsx("td",{className:"up-num up-cost-val",children:Fe(r.cost)}):a.jsx("td",{className:"up-num up-unpriced",children:fs})]},r.model)):n.map(r=>a.jsxs("tr",{children:[a.jsx("td",{className:"up-model-name",title:r.model===jx?"no model reported yet":r.model,children:r.model===jx?"unknown":Qs(r.model)}),a.jsx("td",{className:"up-num",children:ot(r.inputTokens+r.outputTokens)}),r.priced?a.jsx("td",{className:"up-num up-cost-val",children:Fe(r.cost.total)}):a.jsx("td",{className:"up-num up-unpriced",children:fs})]},r.model))})]})]})}function XW({period:e,rangePending:t,setPeriod:n}){const r=w.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 u;const o=r.current.indexOf(s.target);if(o<0)return;const l=CW(s.key,o);l!==null&&(s.preventDefault(),(u=r.current[l])==null||u.focus())},children:zd.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 ${h$(e,e)}…`:""})]})}function ZW({fromRange:e,rangeSessionRows:t,boardSessionRows:n,boardStates:r,sessionsOpen:s,setSessionsOpen:o,periodNoun:l,sessionScale:u}){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:$W(l,u,Fe),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:ii(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}
79
+ ${h.sessionId}`:h.sessionId,children:h.label??Ub(h.sessionId,8)}),a.jsx("span",{className:"up-session-tokens",children:ot(h.tokens)}),h.cost>0?a.jsx("span",{className:"up-session-cost",title:h.models.join(", ")||void 0,children:Fe(h.cost)}):a.jsx("span",{className:"up-session-cost up-unpriced",children:fs})]},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:ii(h.state)}),a.jsx("span",{className:"up-session-label",children:h.label}),a.jsx("span",{className:"up-session-tokens",children:ot(h.inputTokens+h.outputTokens)}),h.cost>0?a.jsxs("span",{className:"up-session-cost",title:h.unpricedTokens>0?`${ot(h.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[Fe(h.cost),h.unpricedTokens>0?"+":""]}):a.jsx("span",{className:"up-session-cost up-unpriced",children:fs})]},h.sessionId))]})]})}function ea(e,t){return{disabled:e!=null&&e!==t,busy:e===t}}function Hd(e){return e==null}const Cx="self";function Or(e,t=!1){const n=ea(e?Cx:null,Cx);return{disabled:t||n.disabled,"aria-busy":n.busy}}function lr(e){return Hd(e?Cx:null)}const Ul=400;function zl({armedFor:e,target:t,armedAt:n,now:r,gapMs:s}){return e!==t?"arm":r-n<s?"ignore":"fire"}function w$(e){return[...e==null?[]:[`#ap-more-${e}`],".accounts-panel .ap-refresh"]}function Dr(e){return e==null||e==="BODY"||e==="HTML"}const JW=6e4,QW=2e4;function eH(e){const[t,n]=w.useState(null),[r,s]=w.useState(!1),o=w.useRef(null),l=w.useRef(!1),u=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(QW)});p.ok&&n(await p.json())}catch{}finally{h&&(l.current=!1,s(!1))}}};return w.useEffect(()=>{if(e)return u(!0),o.current=window.setInterval(()=>u(!1),JW),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{quota:t,loading:r,refresh:()=>{e&&u(!0)}}}const v$=6e4;function tH(e){const[t,n]=w.useState(null),[r,s]=w.useState(!1),o=w.useRef(null),l=w.useRef(!1),u=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 w.useEffect(()=>{if(e)return u(!0),o.current=window.setInterval(()=>u(!1),v$),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{data:t,loading:r,refresh:()=>{e&&u(!0)}}}function nH(e){const[t,n]=w.useState(null),r=w.useRef(null),s=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return w.useEffect(()=>{if(e)return s(),r.current=window.setInterval(s,v$),()=>{r.current!=null&&window.clearInterval(r.current)}},[e]),{data:t}}const Dj=6e4;function rH(e,t,n){const[r,s]=w.useState(null),[o,l]=w.useState(!1),[u,d]=w.useState(0),h=w.useRef(0);w.useEffect(()=>{const p=()=>document.visibilityState==="visible",g=()=>{p()&&d(b=>b+1)},v=window.setInterval(g,Dj),k=()=>{p()&&Date.now()-h.current>=Dj&&d(b=>b+1)};return document.addEventListener("visibilitychange",k),()=>{window.clearInterval(v),document.removeEventListener("visibilitychange",k)}},[]);const f=w.useRef(t);return w.useEffect(()=>{let p=!0;const g=t!==f.current;f.current=t;const v=e,k=u$(v);return l(!0),fetch(`/api/ccusage?since=${k}${g?"&refresh=1":""}`).then(b=>b.ok?b.json():null).then(b=>{!p||!(b!=null&&b.ok)||(h.current=Date.now(),s({period:v,data:b,baseline:n()}))}).catch(()=>{}).finally(()=>{p&&l(!1)}),()=>{p=!1}},[e,t,u]),{...IW(r,e),loading:o}}const sH=e=>1-Math.pow(1-e,5),x$=420;function aH(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 oH(e,t,n,r=x$){return n>=r?t:n<=0?e:e+(t-e)*sH(n/r)}function b$(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function Fj(e,t,n,r={}){const s=r.now??(()=>performance.now()),o=r.raf??(v=>requestAnimationFrame(v)),l=r.cancel??(v=>cancelAnimationFrame(v)),u=r.reducedMotion??b$,d=r.hidden??(()=>typeof document=="object"&&document.hidden===!0);if(u()||d()||!aH(e,t))return n(t),()=>{};const h=s();let f=0,p=!0;const g=()=>{if(!p)return;const v=s()-h;n(oH(e,t,v)),v<x$&&(f=o(g))};return f=o(g),()=>{p=!1,f&&l(f)}}const iH=typeof window>"u"?w.useEffect:w.useLayoutEffect;function Ea(e,{countIn:t=!1}={}){const[n,r]=w.useState(e),s=w.useRef(e),o=w.useRef(!0);return w.useEffect(()=>{s.current=n},[n]),iH(()=>{!t||b$()||(s.current=0,r(0))},[]),w.useEffect(()=>{if(o.current){if(o.current=!1,t)return Fj(0,e,u=>{s.current=u,r(u)});s.current=e,r(e);return}return Fj(s.current,e,u=>{s.current=u,r(u)})},[e]),n}function k$(e,t,n){const r=cH*Math.max(1,n/j$);let s=0;for(const[o,l]of t){const u=e.get(o);if(u===void 0)continue;const d=l.cost-u.cost;d>0&&d<=r&&(s+=d)}return s}const Bj={samples:[],last:new Map,watched:0},N$=10*6e4,lH=6e4,j$=5e3,cH=20;function uH(e,t,n){const r=e.samples[e.samples.length-1];if(r&&t-r.t<j$)return e;const s=e.watched+k$(e.last,n,r?t-r.t:0),o=e.samples.filter(l=>t-l.t<=N$);return o.push({t,watched:s}),{samples:o,last:n,watched:s}}function dH(e,t,n){const r=e.samples[0];if(!r)return null;const s=t-r.t;if(s<lH)return null;const o=e.samples[e.samples.length-1].t,l=e.watched+k$(e.last,n,t-o)-r.watched;return l>0?{spent:l,spanSec:s/1e3,spanMin:Math.min(N$/6e4,Math.ceil(s/6e4))}:null}function hH(e,t,n){const r=w.useRef(Bj),s=w.useRef(null);return w.useMemo(()=>{const o=kW(e.agents.values()),l=wW(e.agents.values());s.current!==n&&(s.current=n,r.current=Bj);const u=_x(e.agents.values(),t);n!=null&&(r.current=uH(r.current,t,u));const d=n==null?null:dH(r.current,t,u),h=d?{label:$b(d.spent,d.spanSec),spanMin:d.spanMin}:null;return{byModel:o,totalCost:l.cost,totalTokens:l,burnRate:h}},[e,e.revision,t,n])}const fH=3e4;function S$(){const[e,t]=w.useState(()=>Math.floor(Date.now()/1e3));return w.useEffect(()=>{const n=window.setInterval(()=>t(Math.floor(Date.now()/1e3)),fH);return()=>window.clearInterval(n)},[]),e}function qj(e){return(typeof e.cost=="number"?e.cost:e.cost.total)>0||e.inputTokens+e.outputTokens>0}function pH(e,t,n){return e?t.some(r=>r.cost<=0&&r.tokens>0):n.some(r=>!r.priced)}function mH(e){return e.claude&&e.codex?"Refresh Claude + Codex quota":e.codex?"Refresh Codex quota":"Refresh Claude quota"}function gH(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 yH(e){const t=new Map;for(const n of e)n.kind!=="root"||!n.sessionId||t.set(n.sessionId,n.state);return t}function wH(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} ${o$(n.sessionId,r)}`}:n})}function vH({state:e,now:t,providers:n,incidents:r=[],leaving:s,onClose:o,liveSince:l=null}){const{quota:u,loading:d,refresh:h}=eH(n.claude),{data:f,loading:p,refresh:g}=tH(n.codex),{data:v}=nH(n.codex),k=S$(),{byModel:b,totalCost:x,totalTokens:N,burnRate:S}=hH(e,t,l),_=w.useMemo(()=>NW(e.agents.values()),[e,e.revision]),[E,T]=w.useState(LW);w.useEffect(()=>{PW(E)},[E]);const[A,R]=w.useState(DW);w.useEffect(()=>{FW(A)},[A]);const[B,P]=w.useState(0),D=w.useRef(()=>new Map);D.current=()=>l==null?null:_x(e.agents.values(),t);const I=w.useCallback(()=>D.current(),[]),{data:O,shown:z,stale:M,loading:$,baseline:q}=rH(E,B,I),X=O!=null,H=$&&M,L=w.useMemo(()=>gH(e.agents.values()),[e,e.revision]),W=w.useMemo(()=>yH(e.agents.values()),[e,e.revision]),F=w.useMemo(()=>X?d$(O):[],[O,X]),Y=w.useMemo(()=>X?wH(RW(O,L).slice(0,12)):[],[O,X,L]),J=w.useMemo(()=>Wd(O),[O]),V=w.useMemo(()=>MW(O,J.cost),[O,J.cost]),G=h$(z,E),K=w.useMemo(()=>X?EW(q,_x(e.agents.values(),t)):Sx,[e,e.revision,q,X,t]),Z=OW(O,{...N,cost:x},K),ee=Z.hasCost,re=Z.tokenSum,ue=Ea(Z.cost),me=Ea(Z.inputTokens),ie=Ea(Z.outputTokens),fe=Ea(Z.cacheReadTokens),ve=Ea(Z.cacheCreateTokens),se=b.filter(qj),ke=_.filter(qj),pe=pH(X,F,se),he=d||p,ae=()=>{h(),g(),P(Te=>Te+1)},Ne=mH(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"}),S&&a.jsxs("span",{className:"up-rate",title:`Spend on this board over the last ${S.spanMin} min`,children:[S.label,a.jsxs("span",{className:"up-rate-span",children:[" · ",S.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:ae,...Or(he),"aria-label":Ne,title:Ne,children:he?"…":"↻"}),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(GW,{quota:u,quotaLoading:d,nowSec:k,incident:r.find(Te=>Te.provider==="claude")}),n.codex&&a.jsx(KW,{codexQuota:f,codexLoading:p,codexUsage:v,nowSec:k,incident:r.find(Te=>Te.provider==="codex")}),X&&a.jsx(XW,{period:E,rangePending:H,setPeriod:T}),re>0?a.jsxs(a.Fragment,{children:[ee&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"up-total",title:X?void 0:Oj,children:[a.jsx("span",{className:"up-total-value",children:Fe(ue)}),a.jsx("span",{className:"up-total-label",children:X?G:vW})]}),Z.showCostBar&&a.jsx(zb,{cost:x})]}),a.jsxs("div",{className:"up-tokens-row",title:X?void 0:Oj,children:[a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"in"}),ot(me)]}),a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"out"}),ot(ie)]}),Z.cacheReadTokens>0&&a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"cache r"}),ot(fe)]}),Z.cacheCreateTokens>0&&a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"cache c"}),ot(ve)]}),!ee&&a.jsx("span",{className:"up-tok up-scope",children:xW})]}),(X?F.length:se.length)>0&&a.jsx(YW,{fromRange:X,rangeModelRows:F,boardModelRows:se}),X&&Y.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 ",G," yet — ccusage dates sessions in UTC, and the totals above are your local day."]})]}),(X?Y.length:ke.length)>0&&a.jsx(ZW,{fromRange:X,rangeSessionRows:Y,boardSessionRows:ke,boardStates:W,sessionsOpen:A,setSessionsOpen:R,periodNoun:G,sessionScale:V}),pe&&a.jsxs("div",{className:"up-hint",children:["“",fs,"” 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:X?(z??E)==="all"?a.jsx(a.Fragment,{children:"No usage in any transcript on this machine."}):a.jsxs(a.Fragment,{children:["No usage ",G,".",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."]})})]})}function xH(e,t,n){return e>=n?"hot":e>=t?"warn":"calm"}function bH(e,t,n=Date.now()){const r=Math.max(0,Math.min(100,100-e));return{pct:r,value:`${r}%`,tone:r===0?"calm":r>=30?"hot":"warn",note:r>0?`CPU held to ${e}% of full speed to cool down`:t?`at full speed · held to ${100-t.peak}% ${kH(t.lastMs,n)}`:"running at full speed, and never held back"}}function kH(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 NH(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 jH(e){var n,r,s;const t=(r=(n=e.thermal)==null?void 0:n.throttle)==null?void 0:r.speedLimit;return t!=null&&t<100?`throttled to ${t}% 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 SH(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 _H=3e3;function EH(){const[e,t]=w.useState(null),n=w.useRef(null);return w.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,_H))},l=()=>{n.current!=null&&(window.clearInterval(n.current),n.current=null)},u=()=>{if(document.visibilityState==="hidden"){l();return}o(),s()};return o(),document.addEventListener("visibilitychange",u),()=>{r=!1,l(),document.removeEventListener("visibilitychange",u)}},[]),e}function CH(e,t){return!e||e.key!==t?"none":e.dir==="asc"?"ascending":"descending"}function xl({col:e,label:t,note:n,sort:r,next:s,onSort:o,className:l}){const u=CH(r,e);return a.jsx("th",{scope:"col","aria-sort":u,className:l,children:a.jsxs("button",{type:"button",className:"sd-sort",title:n?`Sort by ${t}
80
+
81
+ ${n}`:`Sort by ${t}`,onClick:()=>o(s(r,e)),children:[t,a.jsx("span",{className:"sd-sort-dir","aria-hidden":!0,children:u==="none"?"":u==="ascending"?"↑":"↓"})]})})}function vp(e){return e<9.95?e.toFixed(1):String(Math.round(e))}function Wb(e){const t=Number.isFinite(e)?Math.max(0,e):0;return t<50?{value:"0",unit:"KB/s"}:t<999500?{value:vp(t/1e3),unit:"KB/s"}:t<9995e5?{value:vp(t/1e6),unit:"MB/s"}:{value:vp(t/1e9),unit:"GB/s"}}function Vd(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 Wl(e){return e.unit?e.unit==="%"||e.unit==="°C"?`${e.value}${e.unit}`:`${e.value} ${e.unit}`:e.value}function xp(e,t){return t==="B/s"?Wb(e):t==="ms"?Vd(e):{value:String(e),unit:t==="C"?"°C":t}}const _t={l:30,r:6,t:6,b:2},Hs={l:0,r:0,t:2,b:1},Gd=104,TH=64;function ir(e,t=100,n=Gd,r=_t){const s=n-r.t-r.b;return r.t+s*(1-Math.max(0,Math.min(t,e))/t)}function _$(e,t,n,r=100,s=Gd,o=_t){if(!e.length)return"";const l=e[e.length-1].t-e[0].t,u=f=>{const p=t-o.l-o.r;return o.l+(l>0?p*(f-e[0].t)/l:p/2)};let d="",h=null;for(const f of e){const p=h&&f.t-h.t<=n*2?"L":"M";d+=`${p}${u(f.t).toFixed(1)} ${ir(f.v,r,s,o).toFixed(1)}`,h=f}return d}function E$(e,t,n,r=100,s=Gd,o=_t){if(e.length<2)return"";const l=s-o.b,u=e[e.length-1].t-e[0].t,d=t-o.l-o.r,h=v=>o.l+(u>0?d*(v-e[0].t)/u:d/2);let f="",p=[];const g=()=>{if(p.length>=2){let v=`M${h(p[0].t).toFixed(1)} ${l}`;for(const k of p)v+=`L${h(k.t).toFixed(1)} ${ir(k.v,r,s,o).toFixed(1)}`;f+=`${v}L${h(p[p.length-1].t).toFixed(1)} ${l}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 AH(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 C$(e,t,n){return n!=null&&e>=n?"hot":t!=null&&e>=t?"warn":""}function RH(e,t,n=r=>Ca(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 Ca(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function Hb(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 MH({group:e,title:t,onClose:n}){const r=ft(n),[s,o]=w.useState(null);w.useEffect(()=>{let h=!0;const f=async()=>{try{const g=await fetch(`/api/system/history?group=${e}`);if(!g.ok)return;const v=await g.json();h&&(v!=null&&v.ok)&&o(v)}catch{}};f();const p=window.setInterval(f,2e4);return()=>{h=!1,window.clearInterval(p)}},[e]);const l=(s==null?void 0:s.series)??[],[u,d]=w.useMemo(()=>{let h=1/0,f=0;for(const p of l)p.points.length&&(h=Math.min(h,p.points[0].t),f=Math.max(f,p.points[p.points.length-1].t));return[Number.isFinite(h)?Math.max(h,(s==null?void 0:s.sinceMs)??0):(s==null?void 0:s.sinceMs)??0,f]},[l,s==null?void 0:s.sinceMs]);return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal hist-modal",onClick:h=>h.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}),s&&u>0&&a.jsxs("span",{className:"hist-since",children:["since ",Ca(u)," · ",Hb(u,d||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:s==null?a.jsx("p",{className:"hist-empty",children:"Reading…"}):l.length===0?a.jsx("p",{className:"hist-empty",children:"Nothing has been measured yet."}):l.map(h=>a.jsx($H,{series:h,stepMs:s.stepMs},h.label))})]})}),document.body)}function $H({series:e,stepMs:t}){const n=w.useRef(null),[r,s]=w.useState(560),[o,l]=w.useState(null);w.useEffect(()=>{const P=n.current;if(!P||typeof ResizeObserver>"u")return;const D=new ResizeObserver(([I])=>s(Math.max(160,I.contentRect.width)));return D.observe(P),()=>D.disconnect()},[]);const{points:u,unit:d,warnAt:h,critAt:f,label:p,top:g,restsAtZero:v,changes:k}=e,b=v?TH:Gd,{now:x,peak:N}=AH(u),S=x!=null?xp(x,d):null,_=N!=null?xp(N,d):null,E=p==="Throttling"?RH(u,t):null,T=o!=null?u[o]:null,A=u.length>1?u[u.length-1].t-u[0].t:0,R=P=>{const D=r-_t.l-_t.r;return _t.l+(A>0?D*(P-u[0].t)/A:D/2)},B=P=>{if(u.length<2)return;const D=P.currentTarget.getBoundingClientRect(),I=(P.clientX-D.left-_t.l)/Math.max(1,D.width-_t.l-_t.r),O=u[0].t+A*Math.max(0,Math.min(1,I));let z=0;for(let M=1;M<u.length;M++)Math.abs(u[M].t-O)<Math.abs(u[z].t-O)&&(z=M);l(z)};return a.jsxs("section",{className:"hist-series","aria-label":`${p} history`,children:[a.jsxs("div",{className:"hist-head",children:[a.jsx("span",{className:"hist-label",children:p}),a.jsxs("span",{className:"hist-stats",children:[S&&a.jsxs(a.Fragment,{children:[a.jsx("b",{children:S.value}),a.jsxs("span",{children:[S.unit," now"]})]}),N!=null&&_&&a.jsxs(a.Fragment,{children:[a.jsx("b",{className:C$(N,h,f),children:_.value}),a.jsxs("span",{children:[_.unit," peak"]})]})]})]}),a.jsx("div",{className:"hist-plot",ref:n,children:a.jsxs("svg",{className:"hist-chart",width:"100%",height:b,viewBox:`0 0 ${r} ${b}`,preserveAspectRatio:"none",role:"img","aria-label":S==null||_==null?`${p}: nothing measured yet`:`${p}: ${Wl(S)} now, peak ${Wl(_)}, over ${Hb(u[0].t,u[u.length-1].t)}`,onPointerMove:B,onPointerLeave:()=>l(null),children:[[["warn",h],["hot",f]].map(([P,D])=>D==null||D>g?null:a.jsxs("g",{children:[a.jsx("line",{className:`hist-rule ${P}`,x1:_t.l,x2:r-_t.r,y1:ir(D,g,b),y2:ir(D,g,b)}),a.jsx("text",{className:`hist-rule-tag ${P}`,x:2,y:ir(D,g,b)+3,children:D})]},P)),a.jsx("line",{className:"hist-floor",x1:_t.l,x2:r-_t.r,y1:b-_t.b,y2:b-_t.b}),(k??[]).filter(P=>P.from!=null&&u.length>1&&P.t>=u[0].t&&P.t<=u[u.length-1].t).map(P=>a.jsx("line",{className:"hist-mark",x1:R(P.t),x2:R(P.t),y1:_t.t,y2:b-_t.b},P.t)),a.jsx("path",{className:"hist-area",d:E$(u,r,t,g,b)}),a.jsx("path",{className:"hist-line",d:_$(u,r,t,g,b)}),u.length===1&&a.jsx("circle",{className:"hist-dot",cx:R(u[0].t),cy:ir(u[0].v,g,b),r:3}),T&&a.jsxs("g",{children:[a.jsx("line",{className:"hist-cross",x1:R(T.t),x2:R(T.t),y1:_t.t,y2:b-_t.b}),a.jsx("circle",{className:"hist-dot",cx:R(T.t),cy:ir(T.v,g,b),r:3})]})]})}),a.jsx("div",{className:"hist-axis",children:T?a.jsxs("span",{className:"hist-at",children:[Ca(T.t)," — ",(()=>{const P=xp(T.v,d);return a.jsxs(a.Fragment,{children:[a.jsx("b",{children:P.value}),P.unit==="%"||P.unit==="°C"||!P.unit?P.unit:` ${P.unit}`]})})()]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{children:u.length?Ca(u[0].t):""}),a.jsx("span",{children:u.length?Ca(u[u.length-1].t):""})]})}),E&&a.jsx("div",{className:"hist-note",children:E}),k==null?void 0:k.slice(-3).map(P=>a.jsx("div",{className:"hist-note hist-route",children:P.from==null?`Since ${Ca(P.t)} — ${P.label}`:`${Ca(P.t)} — ${P.label.charAt(0).toUpperCase()+P.label.slice(1)}`},P.t))]})}const IH="thermal:Throttling";function OH(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[IH]=Math.max(0,100-e.thermal.throttle.speedLimit)),t}function Cl(e,t){return t==="B/s"?Wl(Wb(e)):t==="ms"?Wl(Vd(e)):t==="C"?`${Math.round(e)}°`:t==="%"?`${Math.round(e)}%`:e.toFixed(2)}function ju(e,t){return t==="B/s"||t==="ms"||!Number.isInteger(e)?Cl(e,t):t==="C"?`${e}°`:t==="%"?`${e}%`:`${e}`}const Uj=["cores","memory","load","thermal"],ja=116,Rr=24,LH=60,PH=6e4;function DH(e){return e.points.length?e.restsAtZero?e.points.some(t=>t.v>0):!0:!1}function FH(e){return e.unit==="C"?`${e.label} temp`:e.key==="mem:physical"?"Physical RAM":e.key==="mem:swap"?`${e.label} memory`:e.label}function BH(e,t=LH){return e.points.length<=t?e:{...e,points:e.points.slice(-t)}}function qH({sys:e}){const[t,n]=w.useState({});w.useEffect(()=>{let l=!0;const u=async()=>{const h=await Promise.all(Uj.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})};u();const d=setInterval(()=>void u(),PH);return()=>{l=!1,clearInterval(d)}},[]);const r=w.useMemo(()=>OH(e),[e]),s=w.useMemo(()=>Uj.flatMap(l=>{const u=t[l];return u?u.series.filter(DH).map(d=>({series:BH(d),stepMs:u.stepMs})):[]}),[t]),o=w.useMemo(()=>{let l=1/0,u=-1/0;for(const{series:d}of s){const h=d.points;h.length&&(l=Math.min(l,h[0].t),u=Math.max(u,h[h.length-1].t))}return Number.isFinite(l)?Hb(l,u):"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:u})=>a.jsx(UH,{series:l,stepMs:u,now:r[l.key],span:o},l.key))}):null}function UH({series:e,stepMs:t,now:n,span:r}){var v;const{points:s,top:o,unit:l,warnAt:u,critAt:d}=e,h=FH(e),f=n??((v=s[s.length-1])==null?void 0:v.v),p=f==null?"":C$(f,u,d),g=Math.max(...s.map(k=>k.v));return a.jsxs("div",{className:`pl-cell${p?` ${p}`:""}`,title:[`${h} · peak ${Cl(g,l)} over the last ${r}`,u!=null?`over ${ju(u,l)} is uncomfortable`:"",d!=null?`over ${ju(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?"—":Cl(f,l)})]}),a.jsxs("svg",{className:"pl-spark",width:ja,height:Rr,viewBox:`0 0 ${ja} ${Rr}`,preserveAspectRatio:"none","aria-hidden":!0,children:[a.jsx("line",{className:"pl-spark-floor",x1:0,x2:ja,y1:Rr-Hs.b,y2:Rr-Hs.b}),a.jsx("path",{className:"pl-spark-area",d:E$(s,ja,t,o,Rr,Hs)}),u!=null&&a.jsx("line",{className:"pl-rule warn",x1:0,x2:ja,y1:ir(u,o,Rr,Hs),y2:ir(u,o,Rr,Hs)}),d!=null&&a.jsx("line",{className:"pl-rule hot",x1:0,x2:ja,y1:ir(d,o,Rr,Hs),y2:ir(d,o,Rr,Hs)}),a.jsx("path",{className:"pl-spark-line",d:_$(s,ja,t,o,Rr,Hs)})]}),a.jsxs("span",{className:"vis-hidden",children:["peak ",Cl(g,l)," over the last ",r,u!=null&&`, uncomfortable over ${ju(u,l)}`,d!=null&&`, the machine acts over ${ju(d,l)}`]})]})}const T$={key:"cpu",dir:"desc"};function zH(e,t){return e.key===t?{...e,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:t==="name"||t==="user"?"asc":"desc"}}function WH(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 u=r(o),d=r(l);return u==null||d==null?u==null?d==null?0:1:-1:n*(u-d)};return[...e].sort((o,l)=>s(o,l)||(l.cpu??-1)-(o.cpu??-1)||l.mem-o.mem||o.pid-l.pid)}const HH=4e3;function VH(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 GH(){const[e,t]=w.useState(null);return w.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(u=>VH(u,l))}catch{}};r();const s=window.setInterval(r,HH);return()=>{n=!1,window.clearInterval(s)}},[]),e}function KH(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 YH({sys:e,onClose:t}){qt("process-list");const n=ft(t),[r,s]=w.useState(T$),o=GH();return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:a.jsx("div",{ref:n,className:"modal pl-modal",onClick:l=>l.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"pl-modal-title",children:a.jsx(XH,{read:o,sort:r,onSort:s,sys:e,onClose:t})})}),document.body)}function XH({read:e,sort:t,onSort:n,sys:r,onClose:s}){const o=e?WH(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(Io,{col:"cpu",label:"cpu",sort:t,onSort:n}),a.jsx(Io,{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(Io,{col:"threads",label:"threads",sort:t,onSort:n}),a.jsx(Io,{col:"uptime",label:"up",sort:t,onSort:n}),a.jsx(Io,{col:"user",label:"user",sort:t,onSort:n}),a.jsx("th",{scope:"col",className:"pl-pid-h",children:"pid"}),a.jsx(Io,{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:_a(l.rssBytes)}),a.jsx("td",{className:"sd-num sd-dim",children:l.threads??"—"}),a.jsx("td",{className:"sd-num sd-dim",children:KH(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(qH,{sys:r})]})]})}function Io(e){return a.jsx(xl,{...e,next:(t,n)=>zH(t??T$,n)})}function Tx({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})]})}function Hl({group:e,title:t,action:n,label:r,value:s,hint:o,children:l}){const[u,d]=w.useState(!1),h=w.useRef(null),f=()=>{var p,g;((p=window.getSelection())==null?void 0:p.isCollapsed)!==!1&&((g=h.current)==null||g.focus({preventScroll:!0}),d(!0))};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"sd-reading",onClick:f,children:[a.jsx("button",{ref:h,type:"button",className:"sd-open",onClick:()=>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}),u&&a.jsx(MH,{group:e,title:t,onClose:()=>d(!1)})]})}function dd({label:e,value:t,pct:n,tone:r="calm",note:s,mark:o,title:l,trackLabel:u}){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:u?"img":void 0,"aria-label":u,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 ZH(e,t,n){if(n<=0||Pd(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 Zs=4,Ln=8;function Vb(e,t,n){const r=n.width-Ln-(e.right+Zs),s=e.left-Zs-Ln,o=t.width<=r||r>=s?"right":"left",l=o==="right"?e.right+Zs:e.left-Zs-t.width,u=n.height-Ln*2,d=t.height<=u,h=d?t.height:Math.max(0,u),f=Math.max(Ln,Math.min(e.top,n.height-Ln-h)),p=Math.max(Ln,Math.min(l,n.width-Ln-t.width));return{top:f,left:p,side:o,maxHeight:d?null:h}}function JH(e,t,n){const r=n.height-Ln-(e.bottom+Zs),s=e.top-Zs-Ln,o=t.height<=r||r>=s?"below":"above",l=o==="below"?r:s,u=t.height<=l,d=u?t.height:Math.max(0,l),h=o==="below"?e.bottom+Zs:e.top-Zs-d,f=Math.max(Ln,Math.min(e.right-t.width,n.width-Ln-t.width));return{top:Math.max(Ln,h),left:f,side:o,maxHeight:u?null:d}}function QH(e,t,n){return!(!e||t!=null&&t.contains(e)||n!=null&&n.contains(e))}function A$(e,t,n){const r=w.useRef(t);r.current=t;const s=w.useRef(n);s.current=n,w.useEffect(()=>{const o=l=>{QH(l.target,e.current,r.current())&&s.current()};return window.addEventListener("pointerdown",o,!0),()=>window.removeEventListener("pointerdown",o,!0)},[e])}const R$='[role="menuitem"]';function zj(e){return e?Array.from(e.querySelectorAll(R$)).filter(t=>!t.disabled):[]}function Gb({anchorId:e,boundaryId:t,id:n,className:r,role:s,labelledBy:o,start:l="first",onClose:u,children:d}){const h=w.useRef(u);h.current=u;const f=ft(()=>{var b;(b=document.getElementById(e))==null||b.focus(),h.current()},{popover:!0}),p=w.useCallback(()=>{var E;const b=f.current;if(!b)return;const x=document.getElementById(e);if(!x){h.current();return}const N=x.getBoundingClientRect(),S=t?(E=document.getElementById(t))==null?void 0:E.getBoundingClientRect():null;if(S&&(N.bottom<=S.top||N.top>=S.bottom)){b.contains(document.activeElement)&&x.focus({preventScroll:!0}),h.current();return}b.style.maxHeight="";const _=JH(N,{width:b.offsetWidth,height:b.offsetHeight},{width:window.innerWidth,height:window.innerHeight});b.style.top=`${_.top}px`,b.style.left=`${_.left}px`,b.style.maxHeight=_.maxHeight==null?"":`${_.maxHeight}px`,b.dataset.side=_.side},[e,t,f]);w.useLayoutEffect(()=>{p()}),w.useEffect(()=>{const b=x=>{var N;(N=f.current)!=null&&N.contains(x.target)||p()};return window.addEventListener("scroll",b,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",p)}},[p,f]),A$(f,()=>document.getElementById(e),u),w.useEffect(()=>{var x;if(s!=="menu")return;const b=zj(f.current);(x=l==="last"?b[b.length-1]:b[0])==null||x.focus()},[]);const g=b=>{var x;if(s==="menu"&&b.key==="Tab"){b.stopPropagation(),(x=document.getElementById(e))==null||x.focus(),b.shiftKey&&b.preventDefault(),h.current();return}if(s==="menu"){const N=zj(f.current),S=ZH(b,N.indexOf(document.activeElement),N.length);S.kind==="focus"&&(b.preventDefault(),N[S.index].focus())}b.key.length===1&&b.stopPropagation()},v=b=>{b.target.closest("button, input, select, textarea, code")||b.preventDefault()},k=b=>{if(s!=="menu"||b.pointerType==="touch")return;const x=b.target.closest(R$);x&&!x.disabled&&document.activeElement!==x&&x.focus({preventScroll:!0})};return Lt.createPortal(a.jsx("div",{ref:f,id:n,className:`anchored-popover${r?` ${r}`:""}`,role:s,"aria-labelledby":o,onKeyDown:g,onMouseDown:v,onPointerMove:k,children:d}),document.body)}function e7({network:e}){const{down:t,up:n,api:r,route:s}=e,[o,l]=w.useState(!1),u=r&&r.ms!=null?Vd(r.ms):null,d=t!=null&&n!=null;return a.jsxs("div",{className:"sd-section",role:"group","aria-label":"Network",children:[a.jsxs(Hl,{group:"network",title:"Network history",action:"Show network history",label:"Network",children:[(d||u)&&a.jsxs("div",{className:"sd-figs sd-figs-named",children:[d&&[["Download",t],["Upload",n]].map(([h,f])=>{const p=Wb(f);return a.jsx(Tx,{value:p.value,unit:p.unit,cap:h},h)}),u&&a.jsx(Tx,{value:u.value,unit:u.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(t7,{route:s,api:r,onClose:()=>l(!1)})]})]})}function t7({route:e,api:t,onClose:n}){return a.jsxs(Gb,{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 ",SH(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`:`${Wl(Vd(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 Wj({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 n7({usageOpen:e,leaving:t,onClose:n}){const r=EH();if(!r||r.cpu==null||!r.memory)return a.jsx(Wj,{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:u,cores:d,uptimeSec:h,platform:f,thermal:p,network:g,cpu:v}=r;return a.jsxs(Wj,{usageOpen:e,leaving:t,sub:`up ${NH(h)} · ${d} cores`,flag:jH(r),onClose:n,children:[a.jsx(r7,{cpu:v,perCore:l,loadavg:u,cores:d}),a.jsx(s7,{memory:s,swap:o,platform:f}),g&&a.jsx(e7,{network:g}),a.jsx(a7,{thermal:p}),a.jsx(o7,{sys:r})]})}function r7({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(Hl,{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(Hl,{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(Tx,{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 s7({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(Hl,{group:"memory",title:"Memory history",action:"Show memory history",label:"Memory",children:[a.jsx(dd,{label:"Physical",value:a.jsxs(a.Fragment,{children:[a.jsx("b",{children:_a(r)})," of ",_a(e.total)]}),pct:e.usedPct,tone:e.usedPct>=90?"warn":"calm",note:`${_a(e.available)} available`}),t&&t.total>0&&a.jsx(dd,{label:s,value:a.jsxs(a.Fragment,{children:[a.jsx("b",{children:_a(t.used)})," of ",_a(t.total)]}),pct:o,tone:o>=90?"warn":"calm"})]})})}function a7({thermal:e}){if(!e)return null;const t=e.throttle?bH(e.throttle.speedLimit,e.heldBack):null;return a.jsx("div",{className:"sd-section",role:"group","aria-label":"Thermal",children:a.jsxs(Hl,{group:"thermal",title:"Thermal history",action:"Show thermal history",label:"Thermal",children:[e.celsius.map(n=>a.jsx(dd,{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:xH(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(dd,{label:"Throttling",value:a.jsx("b",{children:t.value}),pct:t.pct,tone:t.tone,note:t.note})]})})}function o7({sys:e}){const[t,n]=w.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(YH,{sys:e,onClose:()=>n(!1)})]})}function M$(e){return{inputTokens:e.i,outputTokens:e.o,cacheReadTokens:e.cr,cacheCreateTokens:e.cc,cacheCreate1hTokens:e.c1h,cacheCreate5mTokens:e.c5m}}function i7(e){return{...M$(e),cacheCreate1hTokens:0,cacheCreate5mTokens:0}}function $$(e){return e.i+e.o+e.cr+e.cc}function Hj(e){let t=0;for(const n of Object.values(e))t+=$$(n);return t}function l7(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 u of l){const d=typeof u.modelName=="string"?u.modelName:"";if(!o||!/claude/i.test(d)||u.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(u.inputTokens),p.outputTokens+=t(u.outputTokens),p.cacheReadTokens+=t(u.cacheReadTokens),p.cacheCreateTokens+=t(u.cacheCreationTokens),f?f.cost+=t(u.cost):n.set(h,{cost:t(u.cost),usage:p})}}return n}function c7(e,t,n,r=Date.now()){const s=new Map;let o=0,l=0;for(const[T,A]of n){const R=T.indexOf("|"),B=T.slice(0,R),P=T.slice(R+1),D=Jo(A.usage,P,r).total;if(!(D>0&&A.cost>0))continue;o+=A.cost,l+=D;let I=s.get(B);I||(I=new Map,s.set(B,I)),I.set(P,A.cost/D)}const u=l>0,d=(T,A)=>{const R=s.get(T);return(R==null?void 0:R.get(A))??(R==null?void 0:R.get(yi(A)))??null},h=new Set,f=(T,A)=>{let R=0,B=0;for(const[P,D]of Object.entries(T)){if(Wa(P,r)){const O=A(P);R+=O===null?Jo(M$(D),P,r).total:Jo(i7(D),P,r).total*O;continue}const I=$$(D);I>0&&(B+=I,h.add(P))}return{cost:R,unpriced:B}},p=new Map,g=[];for(const T of e){const A=new Map,R=new Map;let B=0;for(const P of T.projects){const{cost:D,unpriced:I}=f(P.models,z=>d(T.day,z));A.set(P.path,(A.get(P.path)??0)+D),I>0&&R.set(P.path,(R.get(P.path)??0)+I),B+=D;let O=p.get(P.path);O||(O={path:P.path,cost:0,tokens:0,unpricedTokens:0},p.set(P.path,O)),O.cost+=D,O.tokens+=Hj(P.models),O.unpricedTokens+=I}g.push({day:T.day,total:B,byPath:A,unpricedByPath:R})}const v=[...p.values()].sort((T,A)=>A.cost-T.cost||A.tokens-T.tokens),k=v.reduce((T,A)=>T+A.cost,0),b=v.reduce((T,A)=>T+A.tokens,0),x=v.reduce((T,A)=>T+A.unpricedTokens,0),N=u?o/l:null,S=t?Hj(t):0,_=t?f(t,()=>N):{cost:0,unpriced:0},E=_.cost>0||S>0?{cost:_.cost,tokens:S,unpricedTokens:_.unpriced}:null;return{projects:v,totalCost:k,totalTokens:b,unpricedTokens:x,perDay:g,unattributed:E,unpricedModels:[...h].sort(),calibrated:u,reconciled:u&&x===0}}function Mr(e,t,n=Fe){return t>0?e>0?`${n(e)}+`:fs:n(e)}function Oo(e){return e>0?`${ot(e)} of these tokens are on an unpriced model, so this is a floor`:void 0}function u7(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 ${fs}: this build holds no published rate for it, so its tokens are counted and its dollars are not.`:`${n} are ${fs}: this build holds no published rate for them, so their tokens are counted and their dollars are not.`}const d7={phase:"running"},h7={phase:"failed"},f7={gen:0,report:null,error:null,early:null};function p7(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:d7;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 m7(e){var t;return((t=e.report)==null?void 0:t.gen)!==e.gen&&e.error===null}function g7(e){const t=e;return t&&t.ok!==!1?{phase:"ready",range:t}:h7}function y7(e){return`${e.getFullYear()}${String(e.getMonth()+1).padStart(2,"0")}${String(e.getDate()).padStart(2,"0")}`}function w7(e,t,n=Date.now()){const r=t===0?60:t,s=new Date(n),o=Ex(r,s),l=y7(s);return{report:`/api/account-projects?num=${e}&days=${t}`,ccusage:`/api/ccusage?since=${o}&until=${l}`}}function v7({num:e,days:t,gen:n,dispatch:r,get:s=(l,u)=>fetch(l,u),now:o=Date.now()}){const l=w7(e,t,o),u={credentials:"same-origin"};s(l.report,u).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,u).then(d=>d.ok?d.json():null).catch(()=>null).then(d=>r({type:"cost",gen:n,cost:g7(d)}))}async function Ha(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 I$(e){return/^[A-Za-z]:[\\/]$/.test(e)?e:e.replace(/[\\/]+$/,"")}function bp(e){const t=I$(e).replace(/\\/g,"/");return/^[A-Za-z]:\//.test(t)?t.toLowerCase():t}function Vj(e){if(!e)return e;const t=I$(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 x7(e,t){const n=bp(e);let r;for(const s of t){const o=bp(s.path);!o||o===n||!n.startsWith(`${o}/`)||(!r||bp(r.path).length<o.length)&&(r=s)}return r==null?void 0:r.label}function Ax(e){return e===0?"all time":e===1?"today":`the last ${e} days`}function b7(e){return e===1?"No work attributed to this account yet today.":`No work attributed to this account in ${Ax(e)}.`}function k7(e){return e===1?7:e===7?30:e===30?0:null}function N7(e,t){return e!==1&&t>0}const j7=[{days:1,label:"Today"},{days:7,label:"7d"},{days:30,label:"30d"},{days:0,label:"All"}],Lo=["var(--usage-blue)","var(--usage-teal)","var(--usage-lime)","var(--usage-purple)","var(--usage-indigo)","var(--usage-pink)","var(--usage-orange)","var(--usage-zinc)"],S7="var(--usage-zinc)",kp=6,_7=1600;function E7(e){const t=Fe(e),n=/^\$(\d{4,})$/.exec(t);return n?`$${Number(n[1]).toLocaleString("en-US")}`:t}function Su(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 C7(e){const t=/^\d{4}-(\d{2})-(\d{2})$/.exec(e);return t?`${Number(t[1])}/${Number(t[2])}`:e}function T7(e){const t=Math.max(1,Math.ceil(e/6));return n=>n===0||n===e-1||n%t===0}function Np(e){if(!e)return"";try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function A7({num:e,name:t,onClose:n}){var $,q,X,H;qt("account-projects");const[r,s]=w.useState(1),[o,l]=w.useReducer(p7,f7),u=(($=o.report)==null?void 0:$.data)??null,d=((q=o.report)==null?void 0:q.days)??r,h=((X=o.report)==null?void 0:X.cost.phase)==="ready"?o.report.cost.range:null,f=((H=o.report)==null?void 0:H.cost.phase)==="running",[p,g]=w.useState(null),[v,k]=w.useState(()=>new Set),b=m7(o),x=o.error,[N,S]=w.useState(null),_=w.useRef(void 0),E=w.useRef(!0);w.useEffect(()=>()=>{E.current=!1,window.clearTimeout(_.current)},[]);const T=w.useRef(null),A=ft(n,{focusRef:T}),R=w.useRef(0);w.useEffect(()=>{const L=++R.current;l({type:"start",gen:L}),g(null),k(new Set),v7({num:e,days:r,gen:L,dispatch:l})},[e,r]);const B=w.useMemo(()=>{const L=Date.now();if(!u)return null;const W=c7(u.daily??[],u.unattributed,l7(h),L),F=he=>he.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||he||"(unknown)",Y=new Map;for(const he of W.projects)Y.set(F(he.path),(Y.get(F(he.path))??0)+1);const J=he=>{const ae=F(he);if((Y.get(ae)??0)<=1)return ae;const Ne=he.replace(/[\\/]+$/,"").split(/[\\/]/).slice(-2,-1)[0];return Ne?`${Ne}/${ae}`:ae},V=W.projects.map(he=>({path:he.path,label:J(he.path)})),G=he=>({path:he.path,label:J(he.path),parentLabel:x7(he.path,V),cost:he.cost,tokens:he.tokens,unpricedTokens:he.unpricedTokens}),K=Lo[kp%Lo.length],Z=new Map,ee=[],re=W.projects.slice(0,kp),ue=W.projects.slice(kp);re.forEach((he,ae)=>{Z.set(he.path,Lo[ae%Lo.length]),ee.push({key:he.path,...G(he),color:Lo[ae%Lo.length]})}),ue.length&&ee.push({key:"__other__",label:`Other · ${ue.length} project${ue.length>1?"s":""}`,cost:ue.reduce((he,ae)=>he+ae.cost,0),tokens:ue.reduce((he,ae)=>he+ae.tokens,0),unpricedTokens:ue.reduce((he,ae)=>he+ae.unpricedTokens,0),color:K,muted:!0,members:ue.map(G)});const me=W.totalCost,ie=W.totalTokens,fe=me>0&&W.unpricedTokens===0?"cost":"tokens",ve=fe==="cost"?me:ie,se=ee.map(he=>he.color),ke=W.perDay.map(he=>{const ae=new Map;for(const[Ie,Oe]of he.byPath){const He=Z.get(Ie)??K;ae.set(He,(ae.get(He)??0)+Oe)}const Ne=new Map;let Te=0;for(const[Ie,Oe]of he.unpricedByPath){const He=Z.get(Ie)??K;Ne.set(He,(Ne.get(He)??0)+Oe),Te+=Oe}return{day:he.day,total:he.total,costByColor:ae,unpricedByColor:Ne,unpriced:Te}}),pe=ke.reduce((he,ae)=>Math.max(he,ae.total),0);return{projectCount:W.projects.length,rows:ee,totalCost:me,totalTokens:ie,basis:fe,denom:ve,un:W.unattributed,chart:ke,maxDay:pe,colorOrder:se,unpricedTokens:W.unpricedTokens,unpricedNote:u7(W.unpricedModels),calibrated:W.calibrated,reconciled:W.reconciled}},[u,h]),P=(L,W)=>{Ha(L).then(F=>{E.current&&(window.clearTimeout(_.current),S({path:L,label:W,ok:F}),_.current=window.setTimeout(()=>{E.current&&S(null)},_7))})},D=L=>N!=null&&N.ok&&N.path===L?"Copied":"Copy",I=u!=null&&u.trackedSince?`Tracked since ${Np(u.trackedSince)}`:"Tracking starts with this version",O=Ax(d),z=k7(d),M=b&&!!u;return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:a.jsxs("div",{ref:A,className:"modal ap-proj-modal",onClick:L=>L.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:j7.map(L=>a.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":r===L.days,onClick:()=>s(L.days),children:L.label},L.days))}),a.jsx("button",{ref:T,className:"glyph-btn ap-proj-close",onClick:n,"aria-label":"Close",children:"×"})]}),a.jsxs("div",{className:`ap-proj-body${M?" refreshing":""}`,"aria-busy":b,children:[b&&!u&&a.jsx("div",{className:"ap-proj-state",children:"Loading…"}),!b&&x&&a.jsxs("div",{className:"ap-proj-state ap-proj-error",children:["Couldn’t load this report: ",x]}),!x&&B&&a.jsx(a.Fragment,{children:B.rows.length===0?a.jsxs("div",{className:"ap-proj-state",children:[M?"Updating…":b7(d),z!=null&&a.jsx("div",{className:"ap-proj-widen-wrap",children:a.jsxs("button",{type:"button",className:"ap-proj-copy",onClick:()=>s(z),children:["Show ",Ax(z)]})}),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 ${B.basis==="cost"?Fe(B.totalCost):`${ot(B.totalTokens)} tokens`} across ${B.projectCount} project${B.projectCount>1?"s":""}`,children:B.rows.map(L=>{const W=B.basis==="cost"?L.cost:L.tokens,F=B.denom>0?W/B.denom*100:0;if(F<=0)return null;const Y=B.basis==="cost"?Su(L.cost,B.totalCost):`${Su(L.tokens,B.totalTokens)} of tokens`;return a.jsx("span",{className:"ap-proj-seg",style:{width:`${F}%`,background:L.color},title:`${L.label} · ${Mr(L.cost,L.unpricedTokens)} · ${Y}${L.tokens?` · ${ot(L.tokens)} tokens`:""}`},L.key)})}),a.jsxs("div",{className:"ap-proj-totals",children:[a.jsx("span",{className:"ap-proj-total-cost",title:Oo(B.unpricedTokens),children:Mr(B.totalCost,B.unpricedTokens)}),a.jsxs("span",{className:"ap-proj-total-tok",children:[ot(B.totalTokens)," tokens"]}),a.jsxs("span",{className:"ap-proj-total-win",children:["· ",M?"updating…":O]}),f&&a.jsx("span",{className:"ap-proj-total-pending",children:"Reconciling cost…"})]}),B.unpricedNote&&a.jsx("div",{className:"ap-proj-note",children:B.unpricedNote}),N7(d,B.chart.length)&&a.jsxs("div",{className:"ap-proj-days",children:[a.jsxs("div",{className:"ap-proj-days-cap",children:["By day",B.chart.length>1?" · click a bar":""]}),a.jsx("div",{className:"ap-proj-days-plot",role:"group","aria-label":`Spend across ${B.chart.length} day${B.chart.length>1?"s":""}`,children:B.chart.map(L=>{const W=B.maxDay>0?L.total/B.maxDay*100:0,F=p===L.day,Y=B.rows.map(V=>({label:V.label,c:L.costByColor.get(V.color)??0,u:L.unpricedByColor.get(V.color)??0})).filter(V=>V.c>0||V.u>0),J=`${Np(Date.parse(`${L.day}T00:00:00`))}, ${Mr(L.total,L.unpriced)}. ${Y.map(V=>`${V.label} ${Mr(V.c,V.u)}`).join(", ")}`;return a.jsx("button",{type:"button",className:`ap-proj-day${F?" selected":""}`,"aria-pressed":F,"aria-label":J,title:`${L.day} · ${Mr(L.total,L.unpriced)}`,onClick:()=>g(V=>V===L.day?null:L.day),children:a.jsx("span",{className:"ap-proj-col",style:{height:`${W}%`},children:B.colorOrder.map((V,G)=>{const K=L.costByColor.get(V)??0;return K<=0||L.total<=0?null:a.jsx("span",{className:"ap-proj-colseg",style:{height:`${K/L.total*100}%`,background:V}},G)})})},L.day)})}),(()=>{const L=T7(B.chart.length);return a.jsx("div",{className:"ap-proj-days-axis","aria-hidden":"true",children:B.chart.map((W,F)=>a.jsx("div",{className:"ap-proj-axis-cell",children:L(F)?C7(W.day):""},W.day))})})(),(()=>{const L=p?B.chart.find(F=>F.day===p):null;if(!L)return null;const W=B.rows.map(F=>({r:F,c:L.costByColor.get(F.color)??0,u:L.unpricedByColor.get(F.color)??0})).filter(F=>F.c>0||F.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:Np(Date.parse(`${L.day}T00:00:00`))}),a.jsx("span",{className:"ap-proj-day-detail-total",title:Oo(L.unpriced),children:Mr(L.total,L.unpriced)})]}),W.map(({r:F,c:Y,u:J})=>a.jsxs("div",{className:"ap-proj-day-detail-row",children:[a.jsx("span",{className:"ap-proj-dot",style:{background:F.color},"aria-hidden":"true"}),a.jsx("span",{className:"ap-proj-day-detail-name",children:F.label}),a.jsx("span",{className:"ap-proj-day-detail-cost",title:Oo(J),children:Mr(Y,J)})]},F.key))]})})()]}),a.jsx("ul",{className:"ap-proj-list",children:B.rows.map((L,W)=>{const F=B.basis==="cost"?L.cost:L.tokens,Y=B.denom>0?F/B.denom*100:0,J=v.has(L.key),V=`ap-proj-details-${W}`,G=J&&(!!L.path||!!L.members),K=L.members?`${J?"Hide":"Show"} the ${L.members.length} project${L.members.length>1?"s":""} folded into Other`:`${J?"Hide":"Show"} location for ${L.label}`;return a.jsxs("li",{className:`ap-proj-row${L.muted?" muted":""}${J?" expanded":""}`,children:[a.jsx("span",{className:"ap-proj-dot",style:{background:L.color},"aria-hidden":"true"}),a.jsxs("span",{className:"ap-proj-name",children:[L.label,L.parentLabel&&a.jsxs("span",{className:"ap-proj-parent",children:[" · in ",L.parentLabel]})]}),a.jsx("span",{className:"ap-proj-track",title:B.basis==="cost"?`${Su(L.cost,B.totalCost)} of tracked cost`:`${Su(L.tokens,B.totalTokens)} of tracked tokens`,children:a.jsx("span",{className:"ap-proj-fill",style:{width:`${Y}%`,background:L.color}})}),a.jsx("span",{className:"ap-proj-cost",title:Oo(L.unpricedTokens),children:Mr(L.cost,L.unpricedTokens)}),a.jsx("span",{className:"ap-proj-tok",children:ot(L.tokens)}),a.jsx("button",{type:"button",className:"glyph-btn ap-proj-info","aria-expanded":J,"aria-controls":G?V:void 0,"aria-label":K,onClick:()=>k(Z=>{const ee=new Set(Z);return ee.has(L.key)?ee.delete(L.key):ee.add(L.key),ee}),children:"ⓘ"}),J&&L.path&&a.jsxs("div",{className:"ap-proj-details",id:V,children:[a.jsx("code",{className:"ap-proj-path",children:Vj(L.path)}),a.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${D(L.path)} location for ${L.label}`,onClick:()=>P(L.path,L.label),children:D(L.path)})]}),J&&L.members&&a.jsx("div",{className:"ap-proj-details ap-proj-other-members",id:V,children:L.members.map(Z=>a.jsxs("div",{className:"ap-proj-other-member",children:[a.jsxs("div",{className:"ap-proj-other-name",children:[Z.label,Z.parentLabel&&a.jsxs("span",{className:"ap-proj-parent",children:[" · in ",Z.parentLabel]})]}),a.jsx("code",{className:"ap-proj-path",children:Vj(Z.path)}),a.jsx("span",{className:"ap-proj-cost",title:Oo(Z.unpricedTokens),children:Mr(Z.cost,Z.unpricedTokens)}),a.jsx("span",{className:"ap-proj-tok",children:ot(Z.tokens)}),a.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${D(Z.path)} location for ${Z.label}`,onClick:()=>P(Z.path,Z.label),children:D(Z.path)})]},Z.path))})]},L.key)})}),B.un&&a.jsxs("div",{className:"ap-proj-unattributed",children:[a.jsx("span",{className:"ap-proj-dot",style:{background:S7},"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:Oo(B.un.unpricedTokens),children:Mr(B.un.cost,B.un.unpricedTokens,E7)}),a.jsx("span",{className:"ap-proj-un-tok",children:ot(B.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:N&&(N.ok?`Copied the location of ${N.label}`:`Could not copy the location of ${N.label} — select it and copy it by hand`)}),a.jsxs("div",{className:"ap-proj-foot",children:[f?"Dollars estimated · ccusage still running":B.reconciled?"Dollars from ccusage · split by activity":B.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 di(e,t){return a$(t-Math.floor(e/1e3))}function R7(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 Kb(){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 M7({anchorId:e,boundaryId:t,issue:n,who:r,fetchedAt:s,nowSec:o,onClose:l,onSignIn:u,onReport:d}){return a.jsx(Gb,{anchorId:e,boundaryId:t,id:"ap-issue-pop",className:"ap-pop ap-issue-pop",role:"dialog",labelledBy:"ap-issue-title",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(Kb,{}),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 ${di(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",className:"btn",onClick:()=>l(!0),children:"Done"}),n.fix&&a.jsx("button",{type:"button",className:"btn primary",onClick:()=>{l(!0),u()},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 bl(e){return e.charAt(0).toUpperCase()+e.slice(1)}function $7(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 I7(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 O7(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 Gj={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 hi(e,t,n){const r=P7(e,t);return!r||!(n!=null&&n.noCopyWorksNearby)||!L7(e)?r:{...r,text:Gj.text,hint:Gj.hint}}function L7(e){return e.staleCopy?!1:e.stopped?e.collector==="relogin_required":e.error==="invalid_grant"||e.error==="no_refresh_token"}function P7(e,t){if(e.staleCopy){const n=$7(e.repair??null,t);return{text:bl(n.text),hint:n.hint,fix:null,tone:"quiet",blocksSwitch:!1}}if(e.stopped){const n=O7(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:bl(n.text),hint:n.hint,fix:n.fix?bl(n.fix):null,tone:r||e.collector==="keychain_unavailable"?"warn":"quiet",blocksSwitch:r}}if(e.error){const n=I7(e.error);return{text:bl(n.text),hint:n.hint,fix:n.fixable?"Sign in again":null,tone:n.fixable?"warn":"quiet",blocksSwitch:n.fixable}}return null}function Kj(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function D7(e){const t=e.filter(u=>!Kj(u)),n=e.filter(u=>Kj(u)),r=t.length?t:n,s=t.length?n:[],o=r.reduce((u,d)=>u&&u.pct>=d.pct?u:d,null);let l=null;for(const u of s)o&&u.pct<=o.pct||(!l||u.pct>l.pct)&&(l=u);return{shown:r,rest:s,fuller:l,peak:l??o}}const F7="\0";function $r(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}${F7}${n}`}function B7(e,t,n=$r){const r=n(t);return e.includes(r)?e.filter(s=>s!==r):[...e,r]}const Kd="slot",Yb=[{lane:"five_hour",name:"5h"},{lane:"seven_day",name:"7d"}],O$=e=>e.id.startsWith("scoped-");function q7(e){var t;return((t=Yb.find(n=>n.lane===e.id))==null?void 0:t.name)??e.label}function U7(e){if(e==="room")return"room";const t=/^(.+):(full|empty)$/.exec(e);return t?t[1]:null}function L$(e){const t=[...new Set(e.flatMap(r=>(r.lanes??[]).filter(O$).map(s=>s.label)))].sort((r,s)=>r.localeCompare(s)),n=[...Yb.map(r=>r.name),...t];return[{id:Kd,label:"Slot"},...n.flatMap(r=>[{id:`${r}:full`,label:`${r} · fullest`},{id:`${r}:empty`,label:`${r} · emptiest`}]),{id:"room",label:"Most room"}]}function Yj(e,t){const n=Yb.find(s=>s.name===t),r=(e.lanes??[]).find(s=>n?s.id===n.lane:O$(s)&&s.label===t);return r&&Number.isFinite(r.pct)?r.pct:null}function z7(e,t,n=()=>!0){const r=[...e],s=h=>[...h.filter(n),...h.filter(f=>!n(f))];if(t==="room")return s(Xj(r,h=>Number.isFinite(h.headroom)?h.headroom:null,"desc"));const o=/^(.+):(full|empty)$/.exec(t);if(!o)return r;const[,l,u]=o;if(!r.some(h=>Yj(h,l)!=null))return r;const d=Xj(r,h=>Yj(h,l),u==="full"?"desc":"asc");return u==="empty"?s(d):d}function Xj(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 W7(e,t){return L$(t).some(n=>n.id===e)?e:Kd}function Rx(e,t){if(!t)return[...e];const n=new Map(t.map((o,l)=>[o,l])),r=e.filter(o=>n.has($r(o))).sort((o,l)=>n.get($r(o))-n.get($r(l))),s=e.filter(o=>!n.has($r(o)));return[...r,...s]}function Xb(e){const t=$r(e);return t.startsWith("slot:")?t:`h:${H7(t)}`}function H7(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 Mx={mode:"some",keys:[]};function P$(e,t){const n=e.keys.includes(Xb(t));return e.mode==="all"?!n:n}function V7(e,t){return{mode:e.mode,keys:B7(e.keys,t,Xb)}}function D$(e,t){return t.length>0&&t.every(n=>P$(e,n))}function G7(e,t){return D$(e,t)?Mx:{mode:"all",keys:[]}}function K7(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map(Xb)),r=e.keys.filter(s=>n.has(s));return r.length===e.keys.length?e:{mode:e.mode,keys:r}}function Y7(e){return e>=90?"hi":e>=70?"mid":void 0}function X7({lane:e,nowSec:t,frozen:n,sortedBy:r}){const s=Math.min(100,Math.max(0,e.pct)),o=n?"var(--muted)":s>=90?"var(--err)":s>=70?"var(--warn)":"var(--accent)",l=e.resetAt&&!n?Ud(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:o,opacity:s===0||n?.4:1}})}),a.jsxs("span",{className:"ap-lane-pct",style:{color:o},children:[s,"%"]}),a.jsx("span",{className:"ap-lane-reset",title:l?`${e.label} resets in ${l}`:void 0,children:l&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"vis-hidden",children:"resets in "}),l]})})]})}function Z7({a:e,nowSec:t,lan:n,opened:r,onToggleLanes:s,busy:o,pressProps:l,onSwitch:u,menuOpen:d,onOpenMenu:h,onCloseMenu:f,refusal:p,onDismissRefusal:g,switchedHere:v,swapped:k,displaced:b,issueExpanded:x,onOpenIssue:N,sortKey:S=null}){const{shown:_,fuller:E}=D7(e.lanes),T=S==="room"?e.lanes.reduce((z,M)=>z&&z.pct>=M.pct?z:M,null):S?e.lanes.find(z=>q7(z)===S)??null:null,A=hi(e,t,n),R=e.active||r,B=e.alias??e.email??`account ${e.num}`,P=e.alias&&e.email?`${e.alias} · ${e.email}`:B,D=e.stale||(A==null?void 0:A.blocksSwitch)===!0,I=E?[..._,E]:_,O=e.fetchedAt?di(e.fetchedAt,t):null;return a.jsxs("li",{className:`ap-account${e.active?" active":""}`,"aria-current":e.active?"true":void 0,"data-open":R?"":void 0,"data-frozen":D?"":void 0,children:[!e.active&&a.jsx("button",{type:"button",className:"ap-row-open",id:`ap-row-${e.num}`,title:P,"aria-expanded":R,"aria-controls":R?`ap-detail-${e.num}`:void 0,"aria-describedby":[e.alias&&e.email?`ap-email-${e.num}`:null,!R&&!(A!=null&&A.blocksSwitch)?`ap-quota-${e.num}`:null].filter(Boolean).join(" ")||void 0,onClick:()=>s(),children:a.jsxs("span",{className:"vis-hidden",children:[B,", ",R?"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:()=>u(e.num,B),"aria-label":`Switch to ${B}`,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:z=>{z.key!=="ArrowDown"&&z.key!=="ArrowUp"||(z.preventDefault(),h(e.num,z.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."}),k&&(()=>{const z=(b==null?void 0:b.alias)??(b==null?void 0:b.email)??"the account that was there";return a.jsxs("p",{className:"ap-note ap-swap-note",title:`Slot ${k.at} was taken, so the two accounts traded places: ${z} now holds slot ${k.displaced}.`,children:["swapped with slot ",k.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:()=>N(e.num,`ap-issue-${e.num}`),children:[A.tone==="warn"&&a.jsx(Kb,{}),a.jsx("span",{className:"ap-issue-text",children:A.text})]}),!R&&a.jsx("span",{className:"ap-issue-age",title:"When claude-swap last read this account's usage",children:O??"never collected"})]}),!R&&!(A!=null&&A.blocksSwitch)&&a.jsxs("p",{className:"ap-quota",id:`ap-quota-${e.num}`,children:[I.length?I.map(z=>a.jsxs("span",{className:"ap-q","data-sort-key":z.id===(T==null?void 0:T.id)?"":void 0,children:[a.jsx("span",{className:"ap-q-label",children:z.label})," ",a.jsxs("span",{className:"ap-q-pct","data-level":D?void 0:Y7(z.pct),children:[Math.round(z.pct),"%"]})]},z.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":O?void 0:"",title:"When claude-swap last read this account's usage",children:O??"never collected"})]}),R&&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(z=>a.jsx(X7,{lane:z,nowSec:t,frozen:D,sortedBy:z.id===(T==null?void 0:T.id)},z.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 ",di(e.fetchedAt,t),A!=null&&A.blocksSwitch?"":R7(e.nextAt,t)]}):a.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})})]})]})}function J7({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 Q7({canShare:e,canReport:t,onAdd:n,onReport:r,onShareSet:s,onReload:o,pressProps:l,reloading:u,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 ${bt} 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",u),"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 Oa=[{id:"five_hour",label:"5h",long:"5-hour"},{id:"seven_day",label:"7d",long:"7-day"}];function Zj(e){return e.counted?e.pct:e.why==="login"?null:e.estimate}function e9(e){const t=Zj(e.five_hour),n=Zj(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 t9(e,t){const n=Oa.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:di(e.updatedAt,t),old:!0}}const n9=15*6e4,r9=e=>e.alias??e.email??`account ${e.num}`;function Jj(e,t,n){const r=Oa.find(f=>f.id===t).label,s=(e.lanes??[]).find(f=>f.id===t),o=s&&Number.isFinite(s.pct)?s9(s.pct):null,l=hi(e,n),u=(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:u?0:o,resetAt:u?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>n9?d("stale",e.fetchedAt?`Updated ${di(e.fetchedAt,n)}`:"Never read"):u?d("reset",`Reset ${di(s.resetAt*1e3,n)}, not updated`):{counted:!0,pct:o,resetAt:s.resetAt}}const s9=e=>Math.min(100,Math.max(0,e));function a9(e,t){const n=Oa.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 u=l.reduce((h,f)=>!h||f.at<h.at?f:h,null),d=u&&{...u,more:l.filter(h=>h!==u&&h.at-u.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 F$(e,t){const n=e.map(s=>{const o={five_hour:Jj(s,"five_hour",t),seven_day:Jj(s,"seven_day",t)};return{num:s.num,key:$r(s),name:r9(s),active:s.active,heldOut:s.disabled===!0,cells:o,status:e9(o),updatedAt:s.fetchedAt??null}}),r=n.filter(s=>s.status==="ready").length;return{rows:n,windows:Oa.map(s=>a9(n,s.id)),roomInBoth:r}}function _u(e,t){return(e==null?void 0:e.key)===t?{key:t,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:"asc"}}const o9={ready:0,limited:1,exhausted:2,stale:3};function i9(e){return e.counted?e.pct:e.last}function Qj(e,t){return t==="status"?o9[e.status]:t==="updated"?e.updatedAt==null?null:-e.updatedAt:i9(e.cells[t])}function l9(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 u=Qj(o,t.key),d=Qj(l,t.key);return u==null||d==null?u==null?d==null?0:1:-1:n*(u-d)};return[...e].sort((o,l)=>s(o,l)||r.get(o.num)-r.get(l.num))}function hd(e){return e>=100?100:Math.min(99,Math.round(e))}function c9(e){const t=hd(e);return{used:t,available:100-t}}function u9(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 B$(e){return e>=90?"hi":e>=70?"mid":void 0}const q$=(e,t,n)=>`${e} ${e===1?t:n}`;function eS(e){const t=e.more>0?`, and ${q$(e.more,"more account","more accounts")} in the same minute`:"";return`First: ${e.name} (${hd(e.pct)}% used)${t}`}function d9({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}=c9(e.used??0),u=Math.round(Ea(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?Ud(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:[u,"%"]})," remaining"]}),a.jsx("div",{className:"ap-report-meter","data-level":B$(o),"aria-hidden":!0,children:a.jsx("i",{style:{"--left":l/100}})}),d&&e.nextReset&&a.jsxs("p",{className:"ap-report-reset",title:eS(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:[". ",eS(e.nextReset)]})]}),s]})}function h9({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"})]}):`${hd(e.last)}%`}),a.jsx("span",{className:"vis-hidden",children:", not counted"})]});const n=e.resetAt!=null?Ud(e.resetAt,t):null;return a.jsxs("td",{className:"ap-report-cell",children:[a.jsxs("span",{className:"ap-report-pct","data-level":B$(e.pct),children:[hd(e.pct),"%"]}),n&&a.jsxs("span",{className:"ap-report-in",children:[a.jsx("span",{className:"vis-hidden",children:"resets in "}),n]})]})}const f9={ready:"Ready",limited:"Limited",exhausted:"Exhausted",stale:"Stale"};function p9({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}),f9[e.status]]})})}function m9({row:e,nowSec:t}){const n=t9(e,t);return a.jsx("td",{className:"ap-report-upd","data-old":n.old?"":void 0,children:n.text})}function g9(){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 y9({accounts:e,nowSec:t,held:n,sort:r=null,onSort:s=()=>{}}){const o=F$(e,t),l=o.rows.length,u=Math.round(Ea(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:u})," of ",q$(l,"Claude account","Claude accounts")," ready"]}),a.jsx("div",{className:"ap-report-sums",children:o.windows.map(d=>a.jsx(d9,{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",{}),Oa.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(xl,{col:"account",label:"Account",sort:r,next:_u,onSort:s}),Oa.map(d=>a.jsx(xl,{col:d.id,label:`${d.label} used`,sort:r,next:_u,onSort:s},d.id)),a.jsx(xl,{col:"status",label:"Status",sort:r,next:_u,onSort:s}),a.jsx(xl,{col:"updated",label:"Updated",className:"ap-report-upd-h",sort:r,next:_u,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"})]})}),Oa.map(f=>a.jsx(h9,{cell:d.cells[f.id],nowSec:t},f.id)),a.jsx(p9,{row:d}),a.jsx(m9,{row:d,nowSec:t})]},d.num))})]}),a.jsxs("details",{className:"ap-report-how",children:[a.jsxs("summary",{children:[a.jsx(g9,{}),"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 w9({accounts:e,order:t,failed:n,nowSec:r,onClose:s}){const o=w.useRef(null),l=ft(s,{focusRef:o}),[u,d]=w.useState(e??[]);w.useEffect(()=>{e&&e.length>0&&d(e)},[e]);const h=u9(n,!e||e.length===0,u.length>0),[f,p]=w.useState(null),g=Rx(u,(f==null?void 0:f.order)??t),v=k=>{const b=F$(Rx(u,t),r).rows;p({sort:k,order:l9(b,k).map(x=>x.key)})};return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",onClick:s,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:h??""}),a.jsx(y9,{accounts:g,nowSec:r,held:h,sort:(f==null?void 0:f.sort)??null,onSort:v})]})}),document.body)}const jp=[70,80,85,90,95];function v9(e){const t=Number(e);return[...Number.isFinite(t)&&t>0&&!jp.includes(t)?[...jp,t]:jp].sort((r,s)=>r-s)}function x9({auto:e,threshold:t,thresholdPick:n,thresholdCtl:r,thresholdSaved:s,thresholdRef:o,thresholdSaveRef:l,proposeThreshold:u,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=>u(g.target.value),children:v9(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 tS=18,b9=1100,Po=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},k9=Array.from({length:tS},(e,t)=>{const n=-72+144*t/(tS-1)+(Po(t,1)-.5)*9,r=(n-90)*(Math.PI/180),s=(54+32*Math.cos(n*Math.PI/180))*(.74+Po(t,2)*.52);return{dx:Math.cos(r)*s,dy:Math.sin(r)*s,rot:(t%2?1:-1)*(100+Po(t,3)*260),delay:Math.round(Po(t,4)*90),dur:760+Math.round(Po(t,5)*260),scale:.8+Po(t,6)*.45,hue:t%4,round:t%3===0}});function nS({anchor:e}){var s;const[t,n]=w.useState(null),r=typeof window<"u"&&((s=window.matchMedia)==null?void 0:s.call(window,"(prefers-reduced-motion: reduce)").matches);return w.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 u=window.setTimeout(()=>n(null),b9);return()=>window.clearTimeout(u)},[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:k9.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 fd=w.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"})]}));fd.displayName="SuccessMark";const U$=new Set(["awaiting_url","awaiting_code","registering"]);function z$(e){return e!=null&&U$.has(e)}function W$(e){return e!=null&&e!=="done"&&!U$.has(e)}const N9="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",j9="the sign-in did not complete";function S9({state:e,serverError:t,localError:n}){const r=e==="idle";return{title:r?"Sign-in ended":"Sign-in failed",message:n||t||(r?N9:j9)}}function _9({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 E9({started:e,state:t}){return!e||t==="done"?null:{action:"login-cancel"}}function C9({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":W$(e==null?void 0:e.state)||n&&t&&!r?"ended":r||z$(e==null?void 0:e.state)?"asking":"primer"}const T9="done";function A9(){let e=!1;return{shouldAnnounce(t){return t!==T9?(e=!1,!1):e?!1:(e=!0,!0)}}}function Zb(e,t){return t?Ot(e,t):void 0}const R9={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 ${bt}`,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"},M9={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"},Jb=`claude-swap could not read the login keychain — start ${bt} from a Terminal window rather than a background service`,$9={unreadable_here:{short:"Keychain locked on this Mac",long:`${Jb}.`},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 pd(e){return e?Ot($9,e)??null:null}const H$={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 $x(e,t,n){const r=n==null?null:H$[n];if(r)return r;if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(Vl(e)))return Jb;const s=Zb(M9,e==null?void 0:e.reason);return s||(e==null?void 0:e.reason)||t}function Vl(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const I9={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"},O9="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 L9(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const P9="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",D9="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",F9=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),B9=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,q9=/[\\/]_npx[\\/]/i,U9=`the copy of ccusage ${bt} installed for itself`;function z9(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function hie(e,t){const n=W9(e,t),r=z9(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 ${yl(n)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${yl(n)}`;case"managed":return`${U9} failed to run: ${yl(n)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${yl(n)}`:`the ccusage this deck found on your PATH failed to run: ${yl(n)}`;default:return n}}const yl=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function W9(e,t){const n=Vl(e);if(F9(n)){if(q9.test(n))return D9;if(B9.test(n))return P9}if(L9(n))return O9;const r=Zb(I9,e==null?void 0:e.reason);return r||(e==null?void 0:e.reason)||t}function Ho(e,t,n){const r=n==null?null:H$[n];if(r)return r;if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&W$(e.state))return e.error;const s=Zb(R9,e==null?void 0:e.reason);return s||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function H9(e,t,n){if(n<=0||Pd(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 V$(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 V9(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 G9(e,t){return e.filter(n=>!t.includes(n.num)).map(n=>n.num)}function K9(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function Y9(e){return e.length?{action:"share",accounts:[...e]}:null}function X9(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 Ix(e){return`${e.email}|${e.org??""}`}function Z9(e,t,n){return e&&e.map(r=>Ix(r)===t?n:r)}function J9(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 Q9(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 u=n("present");u&&r.push(`${u} already here`);const d=n("failed");d&&r.push(`${d} did not arrive`);const h=[...new Set(e.map(f=>{var p;return(p=pd(f.check))==null?void 0:p.short}).filter(f=>!!f))];return`${r.join(", ")}${h.length?`, ${h.join(", ")}`:""}.`}const eV=1500,Eu=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],rS="aa-panel",sS=e=>`aa-tab-${e}`;async function Do(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}function G$({onClose:e,onChanged:t,email:n=null,onSignedIn:r}){qt("add-account");const[s,o]=w.useState("login"),[l,u]=w.useState(null),[d,h]=w.useState(""),[f,p]=w.useState(""),[g,v]=w.useState(!1),[k,b]=w.useState(!1),[x,N]=w.useState(null),[S,_]=w.useState(null),E=g||k,[T,A]=w.useState(null),[R,B]=w.useState(null),[P,D]=w.useState(null),I=w.useRef(""),O=w.useRef(!1),z=w.useRef(!1),M=w.useRef(null),$=w.useRef(null),q=w.useRef(null),X=w.useRef(null),H=w.useRef([]),L=w.useRef(!1),W=w.useCallback(()=>{const se=E9({started:O.current,state:l==null?void 0:l.state});se&&Do(se).catch(()=>{}),e()},[e,l==null?void 0:l.state]),F=ft(W,{focusRef:q}),Y=w.useCallback(async()=>{if(!lr(z.current))return;z.current=!0,v(!0),N(null),O.current=!0;let se=await Do(n?{action:"login",email:n}:{action:"login"}).catch(()=>null);if(n&&(se==null?void 0:se.reason)==="bad_email"&&(se=await Do({action:"login"}).catch(()=>null)),z.current=!1,v(!1),!(se!=null&&se.ok)){N(Ho(se,"could not start the sign-in"));return}u(se)},[n]);w.useEffect(()=>{if(!z$(l==null?void 0:l.state))return;const se=window.setInterval(async()=>{try{const ke=await fetch("/api/claude-accounts/login");ke.ok&&u(await ke.json())}catch{}},eV);return()=>window.clearInterval(se)},[l]);const J=w.useRef(t);J.current=t;const V=w.useState(A9)[0];w.useEffect(()=>{var se;(l==null?void 0:l.state)==="awaiting_code"&&((se=M.current)==null||se.focus()),V.shouldAnnounce(l==null?void 0:l.state)&&J.current()},[l==null?void 0:l.state,V]);const G=w.useRef(r);G.current=r;const K=w.useRef(null);w.useEffect(()=>{var pe;const se=(l==null?void 0:l.state)==="done"?l.account:null,ke=se?`${se.num??""}|${se.email}`:null;!se||K.current===ke||(K.current=ke,(pe=G.current)==null||pe.call(G,se))},[l]),w.useEffect(()=>{var se;s==="paste"&&!L.current&&((se=$.current)==null||se.focus()),L.current=!1},[s]);const Z=w.useCallback(se=>{var pe;const ke=H9(se,Eu.findIndex(he=>he.id===s),Eu.length);ke.kind!=="pass"&&(se.preventDefault(),L.current=!0,o(Eu[ke.index].id),(pe=H.current[ke.index])==null||pe.focus())},[s]),ee=w.useCallback(async()=>{var ke;if(!lr(z.current))return;z.current=!0,v(!0),N(null);const se=await Do({action:"login-code",code:d}).catch(()=>null);if(z.current=!1,v(!1),!(se!=null&&se.ok)){N(Ho(se,"the code was not accepted")),se!=null&&se.state&&u(se),(ke=M.current)==null||ke.select();return}h(""),u(se)},[d,l]),re=w.useCallback(async()=>{if(!lr(z.current))return;z.current=!0,b(!0),_(null);const se=await Do({action:"import",blob:f}).catch(()=>null);if(z.current=!1,b(!1),!(se!=null&&se.ok)){_(Ho(se,"the import failed"));return}I.current=f,p(""),D(null),A(se.results??[]),t()},[f,t]),ue=w.useCallback(async se=>{const ke=Ix(se);if(!lr(z.current)||!I.current)return;z.current=!0,b(!0),B(ke),D(null);const pe=await Do({action:"import",blob:I.current,force:!0,only:{email:se.email,org:se.org??""}}).catch(()=>null);if(z.current=!1,b(!1),B(null),!(pe!=null&&pe.ok)){D({key:ke,text:Ho(pe,"that account could not be updated")});return}const he=(pe.results??[])[0];he&&A(ae=>Z9(ae,ke,he)),t()},[t]),me=(l==null?void 0:l.state)==="done"?l.account:null,ie=_9({restored:l==null?void 0:l.restored,activeAccount:l==null?void 0:l.activeAccount}),fe=C9({login:l,started:O.current,loginError:x,loginBusy:g}),ve=S9({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",onClick:W,role:"presentation",children:a.jsxs("div",{ref:F,className:"modal aa-modal",onClick:se=>se.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:Z,children:Eu.map((se,ke)=>a.jsx("button",{type:"button",role:"tab",id:sS(se.id),ref:pe=>{H.current[ke]=pe},"aria-selected":s===se.id,"aria-controls":rS,tabIndex:s===se.id?0:-1,className:`aa-tab${s===se.id?" on":""}`,onClick:()=>{L.current=!1,o(se.id)},children:se.label},se.id))})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:W,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsx("section",{className:"modal-body aa-body",id:rS,role:"tabpanel","aria-labelledby":sS(s),children:s==="login"?fe==="done"&&me?a.jsxs("div",{className:"aa-done",children:[a.jsx(fd,{ref:X}),a.jsx(nS,{anchor:X}),a.jsx("h4",{children:me.added?`Account ${me.num} added`:"Credentials refreshed"}),a.jsxs("p",{className:"aa-note",children:[a.jsx("strong",{children:me.email}),me.added?ie?" 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."]}),ie?a.jsx("p",{className:"aa-note aa-warn",role:"status",children:ie}):null,a.jsx("button",{type:"button",className:"btn primary",onClick:W,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:se=>h(se.target.value),onKeyDown:se=>{se.key==="Enter"&&d.trim()&&!E&&ee()},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",...Or(E,!d.trim()||l.state==="registering"),onClick:ee,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:ve.title}),a.jsx("p",{className:"aa-err",children:ve.message}),a.jsx("button",{type:"button",className:"btn",onClick:()=>{O.current=!1,u(null),N(null),Y()},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:q,className:"btn primary",...Or(E),onClick:Y,children:"Open the sign-in page"})})]}):T?(()=>{const se=T.filter(pe=>pe.state==="imported").length,ke=T.some(pe=>pd(pe.check));return a.jsxs("div",{className:"aa-done",children:[!ke&&a.jsx(fd,{ref:X}),se>0&&!ke&&a.jsx(nS,{anchor:X}),a.jsx("h4",{children:Q9(T)}),T.length>0&&a.jsx("ul",{className:"aa-results",children:T.map(pe=>{const he=Ix(pe),ae=pd(pe.check);return a.jsxs("li",{className:`aa-result ${pe.state}`,children:[a.jsx("span",{className:"aa-result-who",children:pe.email||(pe.num?`slot ${pe.num}`:"an account")}),a.jsx("span",{className:"aa-result-what",children:J9(pe.state)}),pe.state==="present"&&a.jsx("button",{type:"button",className:"aa-result-fix","aria-busy":R===he,title:`Overwrite the stored login for ${pe.email} with the one in this share. Do this when that account has stopped working here; if it works, leave it.`,onClick:()=>ue(pe),children:R===he?"updating…":"update anyway"}),ae&&a.jsx("span",{className:"aa-result-err",children:ae.long}),(P==null?void 0:P.key)===he&&a.jsx("span",{className:"aa-result-err",children:P.text})]},he)})}),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:W,children:"Done"}),a.jsx("button",{type:"button",className:"btn",onClick:()=>{I.current="",D(null),A(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:se=>p(se.target.value),onKeyDown:se=>{se.key==="Enter"&&f.trim()&&!E&&re()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),a.jsx("button",{type:"button",className:"btn primary",...Or(E,!f.trim()),onClick:re,children:k?"importing…":"Import"})]}),S&&a.jsx("p",{className:"aa-err",children:S}),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 tV(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 nV(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 rV=64;function sV(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}function aV(e,t,n){return t!=null&&e.some(r=>r.slot===t)?t:n}function oV(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 iV(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 lV({a:e,slots:t,nowSec:n,boundaryId:r,accountMenu:s,busy:o,pressProps:l,rotating:u,onProjects:d,onRotation:h}){const{menu:f,menuError:p,aliasDraft:g,confirmRemove:v,share:k,shareCopied:b,slotDraft:x,dropMenu:N,closeMenu:S,startRename:_,typeAlias:E,doAlias:T,startMove:A,pickSlot:R,doSlot:B,makeShare:P,copyShare:D,pressRemove:I}=s;if(!f)return null;const O=`ap-pop-title-${e.num}`,z=p&&a.jsx("p",{className:"ap-pop-error",role:"alert",title:p.raw||void 0,children:p.text});return a.jsxs(Gb,{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}`:O,start:f.start,onClose:N,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:()=>A(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 ${bt}. 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:()=>P(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"}),(u&&!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:()=>I(e.num),children:o===`rm-${e.num}`?"Removing…":v===e.num?"Confirm":"Remove"}),z]}),f.view==="rename"&&a.jsxs("form",{className:"ap-pop-form",onSubmit:M=>{M.preventDefault(),T(e.num,e.alias)},children:[a.jsx("label",{className:"ap-pop-title",id:O,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:rV,placeholder:"e.g. work",spellCheck:!1,autoComplete:"off",autoFocus:!0,onFocus:M=>M.currentTarget.select()}),z,a.jsxs("div",{className:"ap-pop-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>S(),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=tV(t,e.num),$=aV(M,x,e.num),q=oV(M,$,e.num);return a.jsxs("div",{className:"ap-pop-form",children:[a.jsx("label",{className:"ap-pop-title",id:O,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:X=>R(Number(X.target.value)),autoFocus:!0,children:M.map(X=>a.jsx("option",{value:X.slot,children:X.label},X.slot))})}),z,a.jsxs("div",{className:"ap-pop-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>S(),children:"Cancel"}),a.jsx("button",{type:"button",className:"btn primary",...l(`move-${e.num}`),title:q.title,onClick:()=>B(e.num,$,q),children:o===`move-${e.num}`?"…":bl(q.label)})]})]})})(),f.view==="share"&&(k==null?void 0:k.num)===e.num&&(()=>{const M=V$(k.expiresAt,n),$=M.tone==="gone";return a.jsxs("div",{className:"ap-pop-form",children:[a.jsx("p",{className:"ap-pop-title",id:O,children:"Share account"}),a.jsx("code",{className:"ap-share-blob",children:k.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})]}),z,a.jsxs("div",{className:"ap-pop-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>S(),children:"Done"}),a.jsx("button",{type:"button",className:"btn primary",...l(`share-${e.num}`),autoFocus:!0,onClick:async()=>{if($){await P(e.num);return}await D(k.blob)},children:$?"Make a new share":b?"Copied":"Copy"})]})]})})()]})}const cV=6;function uV(e,t){const n=e.filter(u=>u.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?dV(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 dV(e){const t=e.map(n=>n.headroom).filter(n=>typeof n=="number");return t.length?Math.max(...t):null}function hV(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,u=o.headroom;return l==null&&u==null?s.name.localeCompare(o.name):l==null?1:u==null?-1:u-l}),n=t.slice(0,cV),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 Lr(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 fV={keychain_unavailable:{short:"Keychain locked on the other Mac",long:`the other Mac could not export it. On that Mac: ${Jb}. The next round brings it.`}};function Ox(e){return e.why?Ot(fV,e.why)??pd(e.why):null}const Qb={"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"}},pV={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 aS(e){var r;const t=mV[e];if(t)return t;const n=(r=/\b(E[A-Z]{3,})\b/.exec(e))==null?void 0:r[1];return n&&pV[n]||e}const mV={"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 Yd(e,t){var f;if(!e)return null;if(e.error&&((f=e.done)!=null&&f.length)){const p=Yd({...e,error:void 0},t),g=` · ${Lr(e.at,t)}`;return{...p,text:`${p.text.slice(0,-g.length)}, then ${aS(e.error)}${g}`,tone:"bad"}}if(e.error)return Qb[e.error]??{text:aS(e.error),tone:"bad"};const n=e.done??[];if(!n.length)return{text:`all logins fine · ${Lr(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:Ox(p)})).filter(p=>p.why),l=[...new Set(o.map(p=>p.why.short))],u=l.length?`, ${l.join(", ")}`:"",d=o.length?o.map(p=>`${p.d.email}: ${p.why.long}`).join(" "):void 0,h=Lr(e.at,t);return r.length===n.length?{text:`${r.length} ${s} arrived${u} · ${h}`,tone:o.length?"warn":"ok",...d?{hint:d}:{}}:{text:`${r.length} of ${n.length} logins arrived${u} · ${h}`,tone:"bad",...d?{hint:d}:{}}}const gV=9e4;function yV({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 u=r.filter(h=>h.addr===l&&h.port&&h.at>0&&s-h.at<gV);if(!u.length)return null;const d=[...new Set(u.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 Xd(e,t){var n,r;return(n=e.last)!=null&&n.error&&!Qb[e.last.error]?!1:!!((r=e.last)!=null&&r.at&&t-e.last.at<Lx||e.lastSeen!=null&&t-e.lastSeen<Lx)}const Lx=95e3;function wV(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?K$(p.lastSeen,t):Xd(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 u=0,d=0,h=0;for(const p of X$(r,g=>Y$(g,g.peerFp??g.fp,l).name,g=>g.addr??"")){const g=p.filter(s);if(!g.length){h++;continue}u++,g.every(o)&&d++}if(u&&d===u)return{text:u===1?"1 deck found · waiting for them to accept":`${u} decks found · waiting for them to accept`,tone:"wait"};if(!u)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=u===1?"1 deck ready":`${u} decks ready`;return{text:h?`${f} · ${h} away`:f,tone:"ok"}}function vV(e,t,n){if(n)return"checking…";if(e==null)return"not checked yet";const r=Lr(e,t);return r==="now"?"checked just now":`checked ${r}`}function e0(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 K$(e,t){return e!=null&&t-e<Lx}function xV(e,t){if(e==null)return{text:"one-way · has not called yet",here:!1};const n=K$(e,t);return{text:n?"online · one-way, it calls in":`one-way · last online ${Lr(e,t)}`,here:n}}function oS(e,t,n){return t?"online":e.lastSeen!=null?`last online ${Lr(e.lastSeen,n)}`:e.waiting?"has not called yet":"never reached"}function bV(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(kV(p,o,t)));const l=[],u=[];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?u.push(NV(p,g,t)):l.push(jV(p,g,o,t)))}n.push(...EV(l).sort(s),...u.sort(s));const d=[];for(const p of e.strangers??[])!(p!=null&&p.fp)||r.has(p.fp)||(r.add(p.fp),d.push(SV(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(_V(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 kV(e,t,n){const r=Zd(t,e.fp,e.name||e.fp);return{fp:e.fp,...r,addr:e.addr??"",kind:"asks",state:`wants to pair · ${e0(e.at,n)}`,tone:"wait",here:!0,hint:`${r.name} at ${e.addr}${e.via==="tailscale"?", over Tailscale,":""} is waiting for an answer.`,...Jd(e.via)}}function NV(e,t,n){var o;const r=Yd(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?Px(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.`,...Jd(e.via)}}function jV(e,t,n,r){var v,k,b,x;const s=Yd(e.last,r),o=Xd(e,r),l=e.addr?`${e.addr}:${e.port}`:"",u=e.waiting?xV(e.lastSeen,r):null,d=u?u.here:o,h=!u&&s?d?`online · ${Px(s)}`:`${Px(s)} · ${oS(e,d,r)}`:u?u.text:oS(e,d,r),f=(v=e.last)!=null&&v.error?Qb[e.last.error]:null,p=!u&&d&&!((k=e.last)!=null&&k.error)&&!(((b=e.last)==null?void 0:b.done)??[]).length,g=Y$(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:u?u.here:o,...Jd(e.via),hint:u?`${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 ${Lr(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 Y$(e,t,n){return e.manual&&!e.met?{name:e.addr?`${e.addr}:${e.port}`:""}:Zd(n,t,e.name||t)}function SV(e,t,n){const r=Zd(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.`,...Jd(e.via)}}function _V(e,t){const n=Zd(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 Zd(e,t,n){const r=t?e[t]:void 0;return r&&r!==n?{name:r,self:n}:{name:n}}function Jd(e){return e==="tailscale"?{via:"tailscale"}:{}}function Px(e){return e.text.replace(/ · .*$/,"")}function EV(e){return X$(e,t=>t.name,t=>t.addr).map(CV)}function X$(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 u of l)s.push(o.filter(d=>n(d)===u));for(const u of o)n(u)||s.push([u])}else s.push(o)}return s}function CV(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 iS(e,t){return t?e.map(n=>t[n.fp]?{...n,name:t[n.fp]}:n):e}function Gl(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 TV(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 AV(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,u=t||s.length===0,d=u?[...s,...o]:s,h=r.filter(f=>f.kind==="paired").length;return{asks:n,rest:r,live:s,folded:o,troubled:l,showFolded:u,shown:d,paired:h}}function lS(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 RV(e,t,n){if(!(t!=null&&t.enabled)||!(t.shared??[]).includes(e))return!1;const r=(t.peers??[]).filter(s=>s.paired&&Xd(s,n)).map(s=>{var o,l;return(l=(o=s.offers)==null?void 0:o.accounts)==null?void 0:l.find(u=>u.key===e)}).filter(s=>s!=null);return r.length>0&&r.every(s=>!s.alive)}function MV(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 u,d,h,f;if(!o.paired||!Xd(o,r))return!1;const l=(d=(u=o.offers)==null?void 0:u.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 Z$=160,J$=140;function $V(){const[e,t]=w.useState(!1),n=w.useRef(0);return w.useEffect(()=>()=>window.clearTimeout(n.current),[]),{peek:e,openPeek:u=>{window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!0),u)},shutPeek:()=>{window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!1),J$)},holdPeek:()=>window.clearTimeout(n.current),dropPeek:()=>{window.clearTimeout(n.current),t(!1)}}}function IV(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:IV(t),done:!1}}async function OV(){try{return await(await fetch("/api/prefs/give-back",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json().catch(()=>null)}catch{return null}}const LV={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 PV(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?LV[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 Dx=5e3,Q$=6e4;function Et(e,t){if(t==null)return`Could not ${e} — the deck did not answer.`;const n=t.reason?BV(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 DV={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."},FV=new Set(["EACCES","EPERM"]);function BV(e,t){const n=DV[e];if(!n)return;const r=e==="prefs_unreadable"&&t?qV(t):void 0,s=t!=null&&t.code&&t.code!=="BADJSON"?` Error code: ${t.code}.`:"";return(r??n)+s}function qV({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&&!FV.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 Fo(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}function UV(e,t){const[n,r]=w.useState(null),[s,o]=w.useState([]),[l,u]=w.useState(null),[d,h]=w.useState(null),f=w.useRef(null),p=w.useCallback(I=>Hd(f.current)?(f.current=I,u(I),!0):!1,[]),g=w.useCallback(()=>{f.current=null,x.current&&u(null)},[]),v=I=>{const O=ea(l,I);return{disabled:O.disabled,"aria-busy":O.busy}},[k,b]=w.useState(()=>Date.now()),x=w.useRef(!0),N=w.useRef(Dx),S=w.useCallback(async()=>{var I,O;try{const[z,M]=await Promise.all([fetch("/api/lan").then($=>$.json()),fetch("/api/prefs").then($=>$.json())]);if(!x.current)return;z!=null&&z.ok&&r(z),M!=null&&M.ok&&o(Array.isArray((O=(I=M.prefs)==null?void 0:I.lan)==null?void 0:O.manual)?M.prefs.lan.manual:[]),N.current=(z==null?void 0:z.enabled)===!0?Dx:Q$}catch{}},[]);w.useEffect(()=>{x.current=!0;let I=0;const O=async()=>{b(Date.now()),await S(),x.current&&(I=window.setTimeout(O,N.current))};return O(),()=>{x.current=!1,window.clearTimeout(I)}},[S]);const _=w.useCallback(async()=>{const I=(n==null?void 0:n.enabled)===!0;if(p("switch"))try{const O=await Fo("/api/prefs",{lan:{enabled:!I}});if(!x.current)return;O!=null&&O.ok?(h(null),I||t()):h(sr(Et(I?"turn this off":"turn this on",O),O)),await S()}catch{x.current&&h(sr(Et(I?"turn this off":"turn this on",null)))}finally{g()}},[n==null?void 0:n.enabled,S,p,g,t]),E=w.useCallback(async(I,O,z)=>{if(!p(`${I}:${O}`))return null;let M=null;try{const $=await Fo("/api/lan/peer",{action:I,fp:O});if(!x.current)return null;$!=null&&$.ok?(r($),h(null)):(M=Et(z,$),h(sr(M,$))),await S()}catch{M=Et(z,null),x.current&&h(sr(M))}finally{g()}return M},[S,p,g]),T=w.useCallback(async I=>{if(!p(`drop:${I}`))return null;let O=null;try{const z=await Fo("/api/prefs",{lan:{manual:s.filter(M=>M!==I)}});if(!x.current)return null;z!=null&&z.ok?(h(null),e()):(O=Et("stop dialling that address",z),h(sr(O,z))),await S()}catch{O=Et("stop dialling that address",null),x.current&&h(sr(O))}finally{g()}return O},[s,S,e,p,g]),A=w.useCallback(async(I,O)=>{if(!p(`alias:${I}`))return"Something else is still being saved. Try again in a moment.";try{const z=await Fo("/api/lan/peer",{action:"alias",fp:I,name:O});return x.current?z!=null&&z.ok?(r(z),null):Et("rename that deck",z):null}catch{return Et("rename that deck",null)}finally{g()}},[p,g]),R=w.useCallback(async I=>{if(!p(`check:${I}`))return null;try{const O=await Fo("/api/lan/sync",{fp:I});return x.current?O!=null&&O.ok?(r(O),e(),null):(O==null?void 0:O.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.":Et("check that deck",O):null}catch{return Et("check that deck",null)}finally{g()}},[p,g,e]),B=w.useCallback(async()=>{if(p("check"))try{const I=await Fo("/api/lan/sync",{});if(!x.current)return;I!=null&&I.ok?(r(I),h(null)):h(sr(Et("check the other decks",I),I)),e()}catch{x.current&&h(sr(Et("check the other decks",null)))}finally{g()}},[p,g,e]);return{status:n,manual:s,now:k,busy:l,failure:d,dismissFailure:()=>h(null),answerGiveBack:I=>{h(I),I.done&&(S(),e())},pressProps:v,load:S,toggle:_,answer:E,dropAddress:T,rename:A,checkOne:R,checkNow:B}}function zV(e){const[t,n]=w.useState(null),r=w.useRef(0);return w.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(),u=zl({armedFor:t,target:o.fp,armedAt:r.current,now:l,gapMs:Ul});if(u==="arm"){n(o.fp),r.current=l;return}u!=="ignore"&&(n(null),e("unpair",o.fp,"unpair that deck"))}}}function eI({title:e,steps:t,finish:n,aside:r,onClose:s}){const o=w.useRef(null),l=ft(s,{focusRef:o}),[u,d]=w.useState(0),h=u===t.length-1,f=t[u],p=k=>d(Math.max(0,Math.min(t.length-1,k)));w.useEffect(()=>{var k,b;Dr(((k=document.activeElement)==null?void 0:k.tagName)??null)&&((b=o.current)==null||b.focus())},[u]);const g=k=>{k.key!=="ArrowRight"&&k.key!=="ArrowLeft"||(k.preventDefault(),k.stopPropagation(),p(k.key==="ArrowRight"?u+1:u-1))},v=()=>{if(!h){p(u+1);return}n?n.act():s()};return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",onClick:s,role:"presentation",children:a.jsxs("div",{ref:l,className:"modal guide",onClick:k=>k.stopPropagation(),onKeyDown:g,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:[u+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:f.art},u),a.jsx("p",{className:"guide-line","aria-live":"polite",children:f.line}),a.jsx("p",{className:"guide-tip",children:f.tip??""}),a.jsxs("div",{className:"guide-foot",children:[a.jsx("div",{className:"guide-dots",children:t.map((k,b)=>a.jsx("button",{type:"button",className:"glyph-btn guide-dot","aria-label":`Step ${b+1} of ${t.length}`,"aria-current":b===u?"step":void 0,onClick:()=>p(b)},b))}),h&&r&&a.jsx("button",{type:"button",className:"ap-lan-word guide-aside",onClick:r.act,children:r.label}),u>0&&a.jsx("button",{type:"button",className:"btn",onClick:()=>p(u-1),children:"Back"}),a.jsx("button",{ref:o,type:"button",className:"btn primary",onClick:v,children:h?(n==null?void 0:n.label)??"Done":"Next"})]})]})]})}),document.body)}const Fx={ok:"ga-ok",warn:"ga-warn",accent:"ga-accent",flight:"ga-flight"};function Bn({children:e}){return a.jsx("svg",{className:"guide-art",viewBox:"0 0 440 200","aria-hidden":!0,focusable:"false",children:e})}function Fn({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:Fx[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 ${Fx[s]}`,children:r}),o==null?void 0:o.map((l,u)=>a.jsxs("g",{children:[a.jsx("text",{x:e,y:t+40+u*18,className:"ga-s",children:u?"7d":"5h"}),a.jsx("rect",{x:e+22,y:t+35+u*18,width:96,height:4,rx:2,className:"ga-track"}),a.jsx("rect",{x:e+22,y:t+35+u*18,width:96*l/100,height:4,rx:2,className:"ga-accent"}),a.jsxs("text",{x:e+148,y:t+40+u*18,className:"ga-s ga-accent",textAnchor:"end",children:[l,"%"]})]},u))]})}function tI({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 Cu({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 cS({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 uS({x:e,y:t,d:n}){return a.jsx("path",{d:n,transform:`translate(${e} ${t})`,className:"ga-glyph"})}function t0({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 n0(){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 Vo({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:Fx[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 ti({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 md({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(tI,{x:e+118,y:t-13,on:!0})]})}function WV(){return a.jsxs(Bn,{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 HV(){return a.jsxs(Bn,{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(Vo,{x:20,y:80,w:116,title:"main",sub:"Opus 5 · 9 tools",tone:"accent"}),a.jsx(Vo,{x:196,y:18,w:112,title:"explore",sub:"Haiku · 14 tools",tone:"flight"}),a.jsx(Vo,{x:196,y:80,w:112,title:"tests",sub:"Sonnet · 6 tools",tone:"flight"}),a.jsx(Vo,{x:196,y:142,w:112,title:"review",sub:"done · 38s",tone:"ok"}),a.jsx(ti,{x:326,y:28,label:"Read"}),a.jsx(ti,{x:380,y:28,label:"Grep",live:!0}),a.jsx(ti,{x:326,y:90,label:"Bash",live:!0})]})}function dS({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 VV(){return a.jsxs(Bn,{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(dS,{x:216,y:80,label:"5-hour window",pct:24,note:"resets in 53m"}),a.jsx(dS,{x:216,y:124,label:"7-day window",pct:61,note:"resets in 4d"})]})}function GV(){return a.jsxs(Bn,{children:[a.jsx("rect",{x:14,y:40,width:172,height:120,rx:10,className:"ga-canvas"}),a.jsx(Vo,{x:30,y:80,w:140,title:"tests",sub:"Sonnet 5 · 6 tools",tone:"flight"}),a.jsx(t0,{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(Fn,{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(ti,{x:214,y:122,label:"Read"}),a.jsx(ti,{x:266,y:122,label:"Edit"}),a.jsx(ti,{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 KV(){const e=[18,24,28,14,22,26,30,16,24,28,20,26];return a.jsxs(Bn,{children:[a.jsx(Fn,{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 YV(){return a.jsxs(Bn,{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(Vo,{x:278,y:80,w:120,title:"my-project",sub:"Opus 5 · live",tone:"accent"})})]})}function XV(){return a.jsxs(Bn,{children:[a.jsx(Fn,{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(uS,{x:196,y:33,d:"M7 2.2v9.6M2.2 7h9.6"}),a.jsx(uS,{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(t0,{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(Fn,{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 ZV(){return a.jsxs(Bn,{children:[a.jsx(Fn,{x:14,label:"THIS MACHINE"}),a.jsx(md,{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(Fn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(md,{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(n0,{})})]})}const JV=[{art:a.jsx(WV,{}),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(HV,{}),line:"Every agent and subagent is a node. Tool calls light up as they run."},{art:a.jsx(GV,{}),line:"Double-click any node: its prompt, every tool call, tokens and timing."},{art:a.jsx(VV,{}),line:"What each session costs, and how much quota is left."},{art:a.jsx(KV,{}),line:"Cores, memory and heat while the agents run, and what is hogging them."},{art:a.jsx(XV,{}),line:"Several Claude accounts: switch, add one, share one to another machine."},{art:a.jsx(ZV,{}),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(YV,{}),line:"Run claude or codex in any folder. It shows up here on its own."}];function QV(){return a.jsxs(Bn,{children:[a.jsx(Fn,{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(Fn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(ur,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]})]})}function eG(){return a.jsxs(Bn,{children:[a.jsx(Fn,{x:14,label:"THIS MACHINE"}),a.jsx(md,{x:28,y:60}),a.jsx(Cu,{x:28,y:92,name:"Ana's MacBook"}),a.jsx(Cu,{x:28,y:114,name:"Dorin's PC"}),a.jsx(Fn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(md,{x:264,y:60}),a.jsx(Cu,{x:264,y:92,name:"Your MacBook"}),a.jsx(Cu,{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 tG(){return a.jsxs(Bn,{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(cS,{x:106,y:88,on:!0}),a.jsx("text",{x:126,y:98,className:"ga-t ga-mono",children:"work@team.dev"}),a.jsx(cS,{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(tI,{x:304,y:157,on:!0}),a.jsx(t0,{x:115,y:97})]})}function nG(){return a.jsxs(Bn,{children:[a.jsx(Fn,{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(Fn,{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(n0,{})})]})}const rG=[{art:a.jsx(QV,{}),line:"A login can expire on one machine while it still works on another."},{art:a.jsx(eG,{}),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(tG,{}),line:"Tick which logins this machine may hand out. Nothing is shared until you do."},{art:a.jsx(nG,{}),line:"An expired login is copied from a paired machine within a minute."}];function sG(){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(n0,{})})]})}const aG={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."},oG=1600;function nI({reach:e,where:t}){const[n,r]=w.useState(!1),s=w.useRef(!0);w.useEffect(()=>()=>{s.current=!1},[]);const o=(e==null?void 0:e.steps)??[],l=w.useCallback(async()=>{await Ha(o.join(`
82
+ `))&&s.current&&(r(!0),window.setTimeout(()=>{s.current&&r(!1)},oG))},[o]);if(!(e!=null&&e.blocked))return null;const u=e.shell==="sh";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:aG[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:[u?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(`
83
+ `)})}),a.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>void l(),title:u?"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 iG(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 lG(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 Sp(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}const cG={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."},uG={not_running:"This deck is not on the network yet. Turn Local network on, then make one."};function hS(e,t,n){return(t==null?void 0:t.reason)&&e[t.reason]||Et(n,t)}function dG({status:e,manual:t,startWith:n,onClose:r,onChanged:s}){const o=w.useRef(null),l=w.useRef(null),u=w.useRef(null),d=w.useRef(null),h=e.pairingMode==="invite",f=ft(r,{focusRef:h?l:o}),[p,g]=w.useState(""),[v,k]=w.useState(""),[b,x]=w.useState(null),[N,S]=w.useState(null),[_,E]=w.useState(null),[T,A]=w.useState(null),[R,B]=w.useState(()=>Date.now());w.useEffect(()=>{const G=window.setInterval(()=>B(Date.now()),1e3);return()=>window.clearInterval(G)},[]);const P=w.useRef(!0);w.useEffect(()=>()=>{P.current=!1},[]);const D=w.useRef(null),I=w.useRef(null),O=w.useCallback(G=>Hd(D.current)?(D.current=G,E(G),!0):!1,[]),z=w.useCallback(()=>{D.current=null,P.current&&E(null)},[]),M=G=>{const K=ea(_,G);return{disabled:K.disabled,"aria-busy":K.busy}},$=G=>(b==null?void 0:b.field)===G?{"aria-invalid":!0,"aria-describedby":"lan-add-failure"}:{},q=G=>x(K=>K&&K.field===G?null:K),X=w.useCallback(async()=>{if(h)return;const G=iG(p);if(!G){x({text:hG(p),field:"addr"});return}const K=`${G.addr}:${G.port}`,Z=e.peers.find(ee=>ee.addr===G.addr&&ee.port===G.port&&ee.paired);if(Z){x({text:`Already paired with ${Z.name} at that address.`,field:"addr"});return}if(t.includes(K)){x({text:"This deck already calls that address.",field:"addr"});return}if(O("add"))try{const ee=await Sp("/api/prefs",{lan:{manual:[...t,K]}});if(!P.current)return;ee!=null&&ee.ok?(x(null),g(""),s(),r()):x({text:Et("add that address",ee),field:"addr"})}catch{P.current&&x({text:Et("add that address",null),field:"addr"})}finally{z()}},[p,h,t,e.peers,s,r,O,z]),H=w.useCallback(async G=>{if(!O(`invite:${G}`))return;const K=G==="make"?"make an invite":"cancel that invite";try{const Z=await Sp("/api/lan/invite",{action:G});if(!P.current)return;Z!=null&&Z.ok?(I.current=G,x(null),S(null),s()):x({text:hS(uG,Z,K)})}catch{P.current&&x({text:Et(K,null)})}finally{z()}},[s,O,z]),L=w.useCallback(async()=>{const G=v.trim();if(!(!G||!O("join"))){A(null);try{const K=await Sp("/api/lan/invite",{action:"join",token:G});if(!P.current)return;K!=null&&K.ok?(k(""),x(null),s(),r()):(K==null?void 0:K.reason)==="unreachable"&&Array.isArray(K.tried)&&K.tried.length?(A(K.tried),x(null)):(A(null),x({text:hS(cG,K,"use that invite"),field:"join"}))}catch{P.current&&x({text:Et("use that invite",null),field:"join"})}finally{z()}}},[v,s,r,O,z]),W=w.useCallback(async(G,K)=>{try{await navigator.clipboard.writeText(G),S(K),window.setTimeout(()=>{P.current&&S(Z=>Z===K?null:Z)},1600)}catch{x({text:"Could not copy it — select the text and copy it by hand."})}},[]),F=e.invite&&e.invite.expiresAt>R?e.invite:null,Y=w.useRef(!1);w.useEffect(()=>{n!=="invite"||Y.current||F||(Y.current=!0,H("make"))},[n,F,H]);const J=w.useRef(!1);w.useEffect(()=>{var G;n!=="invite"||J.current||!F||(J.current=!0,(G=u.current)==null||G.focus())},[n,F]),w.useEffect(()=>{var K,Z;const G=I.current;!G||G==="make"!=!!F||(I.current=null,Dr(((K=document.activeElement)==null?void 0:K.tagName)??null)&&((Z=(G==="make"?u:d).current)==null||Z.focus()))},[F]);const V=e.port!=null?(e.addrs??[]).map(G=>`${G}:${e.port}`):[];return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",onClick:r,role:"presentation",children:a.jsxs("div",{ref:f,className:"modal lan-add",onClick:G=>G.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:[b&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{id:"lan-add-failure",className:"ap-failure-text",children:b.text}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>x(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),a.jsx(nI,{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:p,placeholder:"192.168.1.5:54340",spellCheck:!1,...$("addr"),onChange:G=>{g(G.target.value),q("addr")},onKeyDown:G=>{G.key==="Enter"&&X()}}),p.trim()!==""&&a.jsx("button",{type:"button",className:"ap-manage-btn",...M("add"),onClick:()=>void X(),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&&V.length>0&&a.jsxs("p",{className:"lan-note",children:["They type this deck’s own address into the same field on theirs:"," ",V.map((G,K)=>a.jsxs("span",{children:[K>0&&" or ",a.jsx("code",{className:"ap-lan-code",children:G})]},G)),a.jsx("button",{type:"button",className:"ap-lan-word lan-copy",...M("copy:mine"),onClick:()=>void W(V.join(" "),"mine"),title:"Copy this deck's address, to send to whoever is adding it",children:N==="mine"?"copied":"copy"})]})]}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("h3",{className:"lan-h",children:["With an invite",!F&&a.jsx("button",{type:"button",className:"ap-lan-word lan-h-act",ref:d,...M("invite:make"),onClick:()=>void H("make"),title:"One piece of text you send them. They paste it, and the two decks pair — nobody has to press anything here.",children:_==="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:v,placeholder:"paste one you were sent",spellCheck:!1,...$("join"),onChange:G=>{k(G.target.value),A(null),q("join")},onKeyDown:G=>{G.key==="Enter"&&L()}}),v.trim()!==""&&a.jsx("button",{type:"button",className:"ap-manage-btn",...M("join"),onClick:()=>void L(),title:"Reach that deck and pair with it. Nobody has to press anything there.",children:_==="join"?"joining…":"join"})]}),a.jsx("p",{className:"lan-note",children:"Pasting one pairs both decks on the spot — nobody has to accept."}),T&&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."}),T.map(G=>a.jsxs("span",{className:"ap-lan-tried-row",children:[a.jsx("code",{className:"ap-lan-code",children:G.addr}),a.jsx("span",{className:"ap-lan-bad",children:G.why})]},G.addr))]}),F&&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:[lG(F.expiresAt,R)," left"]})]}),a.jsx("code",{className:"ap-lan-token",children:F.token}),a.jsxs("div",{className:"ap-lan-acts",children:[a.jsx("button",{type:"button",className:"ap-manage-btn",ref:u,...M("copy:invite"),"aria-label":N==="invite"?"Invite copied":"Copy invite","aria-describedby":"lan-invite-left",onClick:()=>void W(F.token,"invite"),title:"Copy it, and send it however you already talk to them",children:N==="invite"?"copied":"copy"}),a.jsx("button",{type:"button",className:"ap-manage-btn",...M("invite:withdraw"),onClick:()=>void H("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 hG(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 fG({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 pG({rows:e,pairingMode:t,armed:n,pressProps:r,answer:s,dropAddress:o,onUnpair:l,onOpenPeer:u,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:()=>u(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 mG(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 gG({on:e,status:t}){return a.jsxs(a.Fragment,{children:[e&&a.jsx(nI,{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:mG(t)})]})}const fS=["online","offline","loose"],yG={online:0,offline:1,loose:2};function wG(e){return e.kind==="declined"?null:e.kind==="paired"?e.here?"online":"offline":"loose"}const vG=76,xG=62,gd=96,bG={1:[.62],2:[.58,1],3:[.42,.72,1]},kG=.2,NG=.16,jG=.05,SG=20,_G=17,Tu=7,EG=30,CG=116,TG=6.6,AG=6,RG=e=>r0(e,null),MG=1.5,$G=80,IG=.45,pS=40,OG=64,LG=150,mS=.3,gS=84,PG=1.3,yS=.16;function Bx(e,t){return Math.PI*(3*(e+t)-Math.sqrt((3*e+t)*(e+3*t)))}function rI(e,t){return t<-Math.abs(e)*.6?"top":"bottom"}function DG(e,t){if(e<=2)return t%2===0?0:90;const n=360/e;return-90+(t%2===0?0:n/2)}function FG(e){return e.map((t,n)=>({...t,i:n})).sort((t,n)=>fS.indexOf(t.tier)-fS.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 wS(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 BG(e,t,n){const r=[...bG[e.length]??[]];for(let s=0;s<r.length;s++){const o=e[s];if(o<2)continue;const l=Bx(t*r[s],n*r[s])/o;if(!(l>0)||l>=gd)continue;const u=s+1<r.length?r[s+1]-kG:1;r[s]=Math.max(r[s],Math.min(u,r[s]*(gd/l)*1.02))}return r}const Bo=(e,t)=>e.x0<t.x1&&t.x0<e.x1&&e.y0<t.y1&&t.y0<e.y1,_p={h:16,ch:6.1,maxW:100};function qG(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 UG(e,t,n,r,s,o){const l=t==="loose"?_G:SG,u=!s||e.kind==="asks",d=u?EG:_p.h,h=s?_p.ch:TG,f=u?o.length:0,p=Math.min(s?_p.maxW:CG,Math.max(2*l,aI(e).length*h,f*AG)),g={x0:n-l,y0:r-l,x1:n+l,y1:r+l},v=rI(n,r)==="top"?{x0:n-p/2,y0:r-l-Tu-d,x1:n+p/2,y1:r-l-Tu}:{x0:n-p/2,y0:r+l+Tu,x1:n+p/2,y1:r+l+Tu+d};return[g,v]}const sI=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]},Au=(e,t)=>((e-t)%360+540)%360-180;function vS(e,t,n){const r=new Map;for(const h of e)r.has(h.ring)||r.set(h.ring,[]),r.get(h.ring).push(h);const s=()=>e.map(h=>{const[f,p]=sI(h);return UG(h.row,h.tier,f,p,t,h.caption)}),o=(h,f)=>{if(h.count<=2)return!1;const p=h.theta+f*MG,g=r.get(h.ring),v=360/h.count*IG,k=g[(h.index+1)%h.count],b=g[(h.index-1+h.count)%h.count];return!(f>0?Au(k.theta,p)>=v:Au(p,b.theta)>=v)||p<h.lo||p>h.hi?!1:(h.theta=p,!0)},l=([h,f],[p,g])=>Bo(f,p)||Bo(g,h)||Bo(f,g)||Bo(h,p),u=([h,f])=>Bo(h,n)||Bo(f,n);for(let h=0;h<$G;h++){const f=s();let p=!1;for(let g=0;g<e.length;g++){u(f[g])&&(p=o(e[g],Au(e[g].theta,90)>=0?1:-1)||p);for(let v=g+1;v<e.length;v++){if(!l(f[g],f[v]))continue;const k=e[g],b=e[v],x=b.ring.ring>k.ring.ring||b.ring===k.ring&&v>g?b:k,N=x===b?k:b,S=Au(x.theta,N.theta)>=0?1:-1;p=o(x,S)||o(N,-S)||p}}if(!p)break}const d=s();for(let h=0;h<d.length;h++){if(u(d[h]))return!1;for(let f=h+1;f<d.length;f++)if(l(d[h],d[f]))return!1}return!0}const zG={online:0,offline:1,loose:1};function WG(e,t,n,r="",s=RG){const o=xS(e,t,n,r,yG,s);if(o.clear||o.layout.rings.length<3)return o.layout;const l=xS(e,t,n,r,zG,s);return l.clear?{...l.layout,folded:!0}:o.layout}function xS(e,t,n,r,s,o){const l=new Map;for(const D of e){const I=wG(D);if(!I)continue;const O=s[I];l.has(O)||l.set(O,[]),l.get(O).push({row:D,tier:I})}const u=[...l.keys()].sort((D,I)=>D-I),d=Math.max(0,t/2-vG),h=Math.max(0,n/2-xG),f=BG(u.map(D=>l.get(D).length),d,h),p=u.map((D,I)=>({ring:D,rx:d*f[I],ry:h*f[I],count:l.get(D).length})),g=p.reduce((D,I)=>D+I.count,0),v=D=>D.row.via==="tailscale",k=[...l.values()].flat().filter(v).length,b=Math.max(0,...p.map(D=>{const I=l.get(D.ring).filter(v).length,O=Bx(D.rx,D.ry);return I>0&&O>0?I*gd*PG/O*360:0})),x=k>0&&k<g?Math.min(LG,Math.max(OG,k/g*360,b)):0,N=pS-x/2,S=pS+x/2,_=[];let E=!1;p.forEach((D,I)=>{const O=FG(l.get(D.ring)),z=O.length,M=z>1&&Bx(D.rx,D.ry)/z<gd;M&&(E=!0);const $=I===p.length-1,q=$?-yS*(f[I]-(f[I-1]??0)):yS*(f[I+1]-f[I]),X=x>0?[{members:O.filter(L=>L.row.via!=="tailscale"),from:S,width:360-x},{members:O.filter(L=>L.row.via==="tailscale"),from:N+360,width:x}]:[{members:O,from:null,width:360}];let H=0;for(const L of X){const W=L.members.length;if(W===0)continue;const F=L.width/W,Y=W>2;L.members.forEach(({row:J,tier:V},G)=>{const K=rr(J),Z=L.from==null?DG(W,I)+F*G:L.from+F*(G+.5),ee=Y?wS(K,1)*NG*F:0,re=M&&H%2===1?1+q/f[I]:1,ue=Y?wS(K,2)*jG:0,me=F*.3;_.push({row:J,tier:V,ring:D,index:H,count:z,theta:Z+ee,reach:re*(1+($?-Math.abs(ue):ue)),lo:L.from==null?-1/0:L.from+me,hi:L.from==null?1/0:L.from+L.width-me,caption:o(J)}),H++})}});const T=qG(r);let A=vS(_,E,T);!A&&!E&&(E=!0,A=vS(_,!0,T));const R=_.map((D,I)=>{const[O,z]=sI(D);return{row:D.row,tier:D.tier,ring:D.ring.ring,x:O,y:z,angle:HG(Math.atan2(z,O)*180/Math.PI),dist:Math.hypot(O,z),side:rI(O,z),order:I}}),B=p.reduce((D,I,O)=>l.get(I.ring).some(v)?Math.max(D,f[O]):D,0),P=x>0?{from:N,to:S,inner:{rx:d*mS,ry:h*mS},outer:{rx:Math.min(t/2-8,d*B+gS),ry:Math.min(n/2-8,h*B+gS)},count:k}:null;return{layout:{nodes:R,rings:p,zone:P,dense:E},clear:A}}function HG(e){return(e%360+360)%360}function VG(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 GG(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 r0(e,t){switch(e.kind){case"asks":return"wants to pair";case"nearby":return e.state;case"dialling":return oI(e)?`${e.name.slice(e.addr.length)} · dialling`:"dialling";case"declined":return"declined";case"paired":{if(e.here)return t?KG(t):"online";const n=lI(e);return n?n==="now"?"away · just now":`away · ${n}`:e.state.startsWith("one-way")?"has not called yet":"away"}}}function aI(e){return oI(e)?e.addr:e.name}function oI(e){return e.kind==="dialling"&&!!e.addr&&e.name.startsWith(`${e.addr}:`)}function iI(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=lI(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 lI(e){var t;return((t=/last online (.+)$/.exec(e.state))==null?void 0:t[1])??null}function KG(e){return e.trim().split(/\s+/).slice(0,2).join(" ")}function YG(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 XG(e,t){if(e==null)return t;const n=((t-e)%360+540)%360-180;return e+n}function ZG(e){return e.asks?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.`:e.oneWay?`${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.`:e.dialling?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.`:e.nearby?e.nearby===1?"1 deck nearby is not paired. Open it to ask to pair.":`${e.nearby} decks nearby are not paired. Open one to ask to pair.`:null}function JG(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"?"This deck pairs by invite only. Send one from Add a deck.":"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 QG(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 eK(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 tK(e,t,n,r=!0){const s=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:s,note:null,tone:"idle"};if(!e.alive){const o=t&&!t.alive?"neither copy works — sign in again here":null;return{there:"broken there",here:s,note:o,tone:o?"bad":"idle"}}return t?t.alive?{there:"works there",here:s,note:null,tone:t.shareable===!1?"idle":"ok"}:n?{there:"works there",here:s,note:"repairs next round",tone:"wait"}:{there:"works there",here:s,note:"share it to repair",tone:"bad"}:r||n?{there:"works there",here:s,note:"arrives next round",tone:"wait"}:{there:"works there",here:s,note:"paired automatically — pair by invite to take it",tone:"bad"}}function nK(e,t,n,r=null,s=!0){var h;const o=new Map;for(const f of t)(h=o.get(f.key))!=null&&h.alive||o.set(f.key,f);const l=new Set(n),u=[],d=new Set;for(const f of e??[]){if(d.has(f.key))continue;d.add(f.key);const p=o.get(f.key)??null,g=l.has(f.key),v=tK(f,p,g,s),k=p?p.alive?p.shareable===!1?"unavailable":"works":"expired":"missing",b=!f.alive&&p&&!p.alive?v.note:[k==="works"?null:v.here,f.alive&&f.shareable!==!1?null:v.there,v.note].filter(Boolean).join(" · ")||null;u.push({key:f.key,email:f.email,here:k,there:f.alive?f.shareable===!1?"unavailable":"works":"broken",in:!f.alive||f.shareable===!1?"cut":v.tone==="wait"?"wait":v.tone==="bad"?"blocked":"live",out:g&&p?p.alive&&p.shareable!==!1?"live":"cut":null,caption:b,tone:v.tone,usedThere:r===f.key})}for(const f of n){const p=o.get(f);!p||d.has(f)||(d.add(f),u.push({key:f,email:p.email,here:p.alive?p.shareable===!1?"unavailable":"works":"expired",there:"unknown",in:null,out:p.alive&&p.shareable!==!1?"live":"cut",caption:p.alive?p.shareable===!1?"cannot share here":null:"expired here",tone:p.alive?p.shareable===!1?"idle":"ok":"bad",usedThere:!1}))}return u}const rK=1e3;function sK(e,t){const n=new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),r=Lr(e,t);return`${n} · ${r==="now"?"just now":r}`}function qx(e){return e&&[e.version,e.os,e.arch].filter(Boolean).join(" · ")||null}const cI={works:"works here",expired:"expired here",missing:"not on this deck",unavailable:"cannot share here"},uI={works:"works there",broken:"broken there",unavailable:"cannot share there",unknown:"not offered by that deck"};function dI(e){const t=e.in&&e.out?"offered both ways":e.in?"offered by that deck":"offered by this deck";return`${cI[e.here]}, ${uI[e.there]}, ${t}${e.usedThere?", in use there":""}.`}function hI({row:e,source:t,status:n,accounts:r,now:s}){var V,G,K,Z,ee;const{peer:o,stranger:l}=t,u=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,k=u?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",b=qx(n.about),x=qx(g),N=g!=null&&g.version&&v?eK(g.version,v):null,S=o?Yd(o.last,s):null,_=o&&((G=o.last)!=null&&G.error)?yV({error:o.last.error,host:o.addr,port:o.port},[...n.strangers??[],...n.pending??[],...(n.peers??[]).filter(re=>!re.manual&&re.addr).map(re=>({fp:re.fp,name:re.name,addr:re.addr,port:re.port,at:re.lastSeen??0}))],s):null,E=(K=o==null?void 0:o.last)!=null&&K.error&&S&&S.text!==o.last.error?o.last.error:null,T=((Z=o==null?void 0:o.last)==null?void 0:Z.done)??[],A=!!S&&!!E&&!e.quiet&&e.state.startsWith(S.text),R=u||e.kind==="dialling",B=((o==null?void 0:o.via)??e.via)==="tailscale",P=o?o.waiting?null:o.manual?B?"added by its Tailscale address":"added by address":B?"over Tailscale":"on this network":e.kind==="nearby"?B?"heard over Tailscale":"heard on this network":B?"asked this deck to pair, over Tailscale":"asked this deck to pair",D=e.tone==="bad"?"bad":u?e.here?"up":"down":"loose",I=(o==null?void 0:o.offers)??null,O=D==="up"?(I==null?void 0:I.current)??null:null,z=O&&"key"in O?O.key:null,M=!!O&&"hidden"in O,$=!!O&&"other"in O,q=u?nK((I==null?void 0:I.accounts)??null,r,n.shared??[],z,(o==null?void 0:o.autoPaired)!==!0):[],X=q.filter(re=>re.in==null&&re.out==="cut"),H=q.some(re=>re.in!=null),L=q.some(re=>re.out!=null),W=new Map(T.map(re=>[re.email,re])),F=T.filter(re=>!q.some(ue=>ue.email===re.email)),Y=u?I?I.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=I&&(o!=null&&o.last)&&o.last.at-I.at>rK?Lr(I.at,s):null;return{peer:o,stranger:l,paired:u,own:d,canRename:h,fp:f,where:p,about:g,unsaid:k,hereRuns:b,thereRuns:x,order:N,line:S,silence:_,raw:E,echoed:A,showRound:R,how:P,link:D,hiddenThere:M,otherThere:$,lanes:q,spent:X,taking:H,giving:L,told:W,unplaced:F,unknown:Y,stale:J}}function Ux(){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 Ru({dir:e,gate:t=!1}){const n=t?12:8;return a.jsx("svg",{className:"lan-chev","data-dir":e,"data-gate":t||void 0,width:n,height:"8",viewBox:`0 0 ${n} 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":t?"M1 1v6M9.6 1L6.4 4l3.2 3":"M5.2 1L2 4l3.2 3"})})}function aK({view:e,row:t,status:n,asking:r,drawn:s,onSettings:o}){const{peer:l,paired:u,where:d,about:h,unsaid:f,hereRuns:p,thereRuns:g,order:v,line:k,silence:b,raw:x,echoed:N,showRound:S,how:_,link:E,hiddenThere:T,otherThere:A,lanes:R,spent:B,taking:P,giving:D,told:I,unplaced:O,unknown:z,stale:M}=e;return a.jsxs("div",{className:"lan-map","data-link":E,"data-asking":r||void 0,"data-bus":R.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}),u&&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]}),T&&a.jsx("span",{className:"lan-end-note",children:"current account hidden"}),A&&a.jsx("span",{className:"lan-end-note",children:"on another account"})]})]}),a.jsxs("div",{className:"lan-link",children:[a.jsx(Ux,{}),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(Ux,{}),(d&&_||S)&&a.jsxs("p",{className:"lan-link-sub",children:[d&&_,d&&_&&S&&" · ",S&&(k?N?a.jsx("code",{className:"ap-lan-code",children:x}):a.jsx("span",{className:"lan-round","data-tone":k.tone,children:k.text.replace(/ · now$/," · just now")}):"not asked yet"),S&&x&&!N&&a.jsx("code",{className:"lan-fact-raw",children:x})]}),O.length>0&&a.jsx("ul",{className:"lan-done",children:O.map($=>{const q=Ox($);return a.jsxs("li",{"data-ok":$.ok&&!q,children:[$.email," ",a.jsxs("span",{className:"lan-done-what",children:[$.ok?"arrived":"did not arrive",q&&` — ${q.long}`]})]},`${$.email}:${$.action}`)})}),b&&a.jsx("p",{className:"lan-note lan-link-note",children:b}),(l==null?void 0:l.waiting)&&a.jsx("p",{className:"lan-note lan-link-note",children:t.hint}),(k==null?void 0:k.hint)&&a.jsx("p",{className:"lan-note lan-link-note",children:k.hint})]}),R.length>0&&a.jsx("ul",{className:"lan-lanes",role:"list","aria-label":`Logins between this deck and ${t.name}`,children:R.map(($,q)=>{const X=I.get($.email),H=X?Ox(X):null,L=$.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":q},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":L?"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(Ru,{dir:"in",gate:$.in==="blocked"}),$.out==="live"&&a.jsx(Ru,{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:dI($)}),($.caption||X)&&a.jsxs("span",{className:"lan-lane-note",children:[$.caption,$.caption&&X&&" · ",X&&a.jsxs("span",{className:"lan-lane-done","data-ok":X.ok&&!H,children:[X.ok?"arrived last round":"did not arrive last round",H&&` — ${H.long}`]})]})]},$.key)})},s),u&&a.jsxs(a.Fragment,{children:[B.length>0&&a.jsxs("p",{className:"lan-spent",children:["Paired decks get nothing from ",B.length===1?B[0].email:"the expired ones"," until you sign in again here."]}),z&&a.jsx("p",{className:"lan-empty",children:z}),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:[P&&a.jsxs("span",{className:"lan-key",children:[a.jsx("span",{className:"lan-key-wire","data-dir":"in","aria-hidden":!0,children:a.jsx(Ru,{dir:"in"})}),"from ",t.name]}),D?a.jsxs("span",{className:"lan-key",children:[a.jsx("span",{className:"lan-key-wire","data-dir":"out","aria-hidden":!0,children:a.jsx(Ru,{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 oK=20,iK=17,bS=34,lK=160,cK=80,uK=200,dK=8,kS=6,hK=14,fK=10,pK=.61803398875;function mK({status:e,rows:t,accounts:n,now:r,covered:s,onOpenDeck:o,onClose:l}){const u=w.useRef(null),d=ft(l,{focusRef:u}),h=w.useRef(null),[f,p]=w.useState(null),[g,v]=w.useState(!1),k=w.useRef(null);w.useLayoutEffect(()=>{const ie=h.current;if(!ie)return;let fe=null;const ve=()=>{const ke=Math.round(ie.clientWidth),pe=Math.round(ie.clientHeight);fe&&fe.w===ke&&fe.h===pe||(fe&&(v(!0),k.current!=null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>v(!1),uK)),fe={w:ke,h:pe},p(fe))};if(ve(),typeof ResizeObserver>"u")return;const se=new ResizeObserver(ve);return se.observe(ie),()=>{se.disconnect(),k.current!=null&&window.clearTimeout(k.current)}},[]);const b=w.useMemo(()=>f?WG(t,f.w,f.h,(e==null?void 0:e.name)??"",ie=>{var fe,ve;return r0(ie,(ve=(fe=Gl(e,ie).peer)==null?void 0:fe.about)==null?void 0:ve.os)}):null,[t,f,e]),x=w.useMemo(()=>VG(t),[t]),N=(b==null?void 0:b.nodes)??[],S=w.useRef(new Map),_=w.useMemo(()=>{const ie=new Map;for(const fe of N){const ve=rr(fe.row);ie.set(ve,XG(S.current.get(ve),fe.angle))}return S.current=ie,ie},[N]),[E,T]=w.useState(null),[A,R]=w.useState(null),[B,P]=w.useState("none"),D=w.useRef(null),I=w.useCallback((ie,fe)=>{D.current!==ie&&(D.current=ie,P(fe),R(ie))},[]),O=w.useRef(null),z=w.useRef(null),M=w.useCallback(()=>{z.current!=null&&window.clearTimeout(z.current),z.current=null},[]),$=w.useCallback((ie,fe)=>{if(O.current!=null&&window.clearTimeout(O.current),O.current=null,M(),T(ie),fe==="keyboard"){I(ie,"none");return}z.current=window.setTimeout(()=>I(ie,D.current?"swap":"full"),cK)},[I,M]),q=w.useCallback(()=>{O.current!=null&&window.clearTimeout(O.current),M(),O.current=window.setTimeout(()=>T(null),lK)},[M]);w.useEffect(()=>()=>{O.current!=null&&window.clearTimeout(O.current),M()},[M]);const X=E&&N.some(ie=>rr(ie.row)===E)?E:null,H=A?t.find(ie=>rr(ie)===A)??null:null;w.useEffect(()=>{A&&!H&&I(null,"swap")},[A,H,I]);const[L,W]=w.useState(null),F=w.useRef(new Map),Y=N.findIndex(ie=>rr(ie.row)===L),J=Y<0?0:Y,V=ie=>{var ke;if(N.length===0)return;const fe=ie.key==="ArrowRight"||ie.key==="ArrowDown"?1:ie.key==="ArrowLeft"||ie.key==="ArrowUp"?-1:0,ve=ie.key==="Home"?0:ie.key==="End"?N.length-1:fe?(J+fe+N.length)%N.length:null;if(ve==null)return;ie.preventDefault();const se=rr(N[ve].row);W(se),(ke=F.current.get(se))==null||ke.focus()},[G,K]=w.useState(()=>typeof document<"u"&&document.hidden);w.useEffect(()=>{const ie=()=>K(document.hidden);return document.addEventListener("visibilitychange",ie),()=>document.removeEventListener("visibilitychange",ie)},[]);const Z=(e==null?void 0:e.enabled)===!0,ee=e?Z?GG(x):"Local network is off":"checking…",re=()=>{M(),I(null,"swap"),T(null)},ue=X?N.find(ie=>rr(ie.row)===X)??null:null,me=()=>{var ie;A&&((ie=F.current.get(A))==null||ie.focus()),re()};return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",onClick:l,role:"presentation",children:a.jsxs("div",{ref:d,className:"modal nm-modal",onClick:ie=>ie.stopPropagation(),"data-paused":s||G||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:ee})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:u,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:h,className:"nm-stage","data-focus":X?"":void 0,"data-focus-via":ue==null?void 0:ue.row.via,"data-dense":(b==null?void 0:b.dense)||void 0,"data-still":g||void 0,onClick:ie=>{ie.target===ie.currentTarget&&re()},children:f&&b&&a.jsxs(a.Fragment,{children:[a.jsx(gK,{layout:b,w:f.w,h:f.h}),N.map(ie=>{const fe=rr(ie.row);return a.jsx(vK,{node:ie,angle:_.get(fe)??ie.angle,lit:X===fe},fe)}),a.jsx(xK,{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, ${N.length}`,"aria-describedby":"nm-ring-hint",onKeyDown:V,children:N.map((ie,fe)=>{var se,ke;const ve=rr(ie.row);return a.jsx(bK,{node:ie,angle:_.get(ve)??ie.angle,os:(ke=(se=Gl(e,ie.row).peer)==null?void 0:se.about)==null?void 0:ke.os,lit:X===ve,shown:A===ve,tabbable:fe===J,register:pe=>{pe?F.current.set(ve,pe):F.current.delete(ve)},onHold:pe=>{W(ve),$(ve,pe)},onRelease:q,onOpen:()=>o(ie.row.fp)},ve)})}),N.length===0&&a.jsx(kK,{status:e})]})}),a.jsx(NK,{})]}),a.jsx("aside",{className:"nm-side","aria-label":"Details",children:H&&e?a.jsx(SK,{row:H,status:e,accounts:n,now:r,entrance:B,onOpen:()=>o(H.fp),onBack:me},rr(H)):a.jsx(jK,{status:e,summary:x,entrance:B})})]})]})}),document.body)}function fI(){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 gK({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:wK(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:yK(r,t/2,n/2),fill:"url(#nm-zone-fill)"}),a.jsx("text",{className:"nm-zone-label",children:a.jsx("textPath",{href:"#nm-zone-arc",startOffset:"50%",textAnchor:"middle",children:`Tailscale · ${r.count} deck${r.count===1?"":"s"}`})})]}),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 NS(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 yK(e,t,n){const r=e.to-e.from>180?1:0,s=(N,S)=>{const _=S*Math.PI/180;return[t+Math.cos(_)*N.rx,n+Math.sin(_)*N.ry]},o=(N,S)=>S/((N.rx+N.ry)/2)*(180/Math.PI),l=(N,S,_)=>{const E=Math.hypot(S[0]-N[0],S[1]-N[1])||1,T=Math.min(.5,_/E);return[N[0]+(S[0]-N[0])*T,N[1]+(S[1]-N[1])*T]},u=([N,S])=>`${N.toFixed(1)},${S.toFixed(1)}`,d=fK,h=hK,f=o(e.inner,d),p=o(e.outer,h),g=s(e.inner,e.from),v=s(e.outer,e.from),k=s(e.outer,e.to),b=s(e.inner,e.to),x=N=>`${N.rx.toFixed(1)},${N.ry.toFixed(1)}`;return[`M${u(s(e.inner,e.from+f))}`,`Q${u(g)} ${u(l(g,v,d))}`,`L${u(l(v,g,h))}`,`Q${u(v)} ${u(s(e.outer,e.from+p))}`,`A${x(e.outer)} 0 ${r} 1 ${u(s(e.outer,e.to-p))}`,`Q${u(k)} ${u(l(k,b,h))}`,`L${u(l(b,k,d))}`,`Q${u(b)} ${u(s(e.inner,e.to-f))}`,`A${x(e.inner)} 0 ${r} 0 ${u(s(e.inner,e.from+f))}`,"Z"].join(" ")}function wK(e,t,n){const r={rx:e.outer.rx-kS,ry:e.outer.ry-kS},s=e.to-e.from>180?1:0;return`M${NS(r,t,n,e.to)} A${r.rx.toFixed(1)},${r.ry.toFixed(1)} 0 ${s} 0 ${NS(r,t,n,e.from)}`}function vK({node:e,angle:t,lit:n}){const r=e.row.kind==="paired"&&e.row.here,s=e.order*pK%1*dK;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":`${bS}px`,"--gap":`${bS+(e.tier==="loose"?iK:oK)}px`,"--i":e.order,"--phase":`${s.toFixed(2)}s`},children:r&&a.jsx("i",{className:"nm-glint"})})}function xK({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 bK({node:e,angle:t,os:n,lit:r,shown:s,tabbable:o,register:l,onHold:u,onRelease:d,onOpen:h}){const{row:f}=e,p=`nm-d-${_K(rr(f))}`,g=e.angle*Math.PI/180,v=r0(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}: ${iI(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:k=>{k.pointerType==="mouse"&&u("pointer")},onPointerLeave:d,onFocus:k=>u(k.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(Ux,{}),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:aI(f)}),a.jsx("span",{className:"nm-cap",children:v})]}),e.tier==="online"&&a.jsx("span",{id:p,className:"vis-hidden",children:v})]})}function kK({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 NK(){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"]}),a.jsxs("li",{children:[a.jsx("i",{className:"nm-key-zone","aria-hidden":!0}),"over Tailscale"]})]})}function pI({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 jK({status:e,summary:t,entrance:n}){const r=YG(e),s=qx(e==null?void 0:e.about),o=[];s&&o.push({label:"Runs",value:s}),o.push({label:r.length>1?"Addresses":"Address",value:r.length?a.jsx("span",{className:"nm-addrs",children:r.map(d=>a.jsx("code",{className:"ap-lan-code",children:d},d))}):"none yet",quiet:r.length===0}),e!=null&&e.pairingMode&&o.push({label:"Pairing",value:e.pairingMode==="invite"?"by invite only":"asks and answers"});const l=[{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})}],u=ZG(t);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:l.filter(d=>d.n>0).map(d=>a.jsxs("li",{"data-count":d.key,children:[d.mark,a.jsx("span",{className:"nm-count-n",children:d.n}),a.jsx("span",{className:"nm-count-words",children:d.words})]},d.key))}),t.tailnet>0&&a.jsxs("p",{className:"nm-counts-note",children:[t.tailnet," reached over Tailscale — the shaded slice, lower right"]}),u&&a.jsx("p",{className:"nm-next",children:u}),a.jsx(pI,{facts:o}),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 SK({row:e,status:t,accounts:n,now:r,entrance:s,onOpen:o,onBack:l}){var x;const u=hI({row:e,source:Gl(t,e),status:t,accounts:n,now:r}),d=[];u.where&&d.push({label:"Address",value:a.jsx("code",{className:"ap-lan-code",children:u.where})}),u.thereRuns&&d.push({label:"Runs",value:`${u.thereRuns}${u.order?` · ${u.order<0?"older than this deck":"newer than this deck"}`:""}`}),u.hiddenThere&&d.push({label:"Signed in to",value:"not said — its owner hides it",quiet:!0}),u.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=JG(e,t.pairingMode),p=QG(u.lanes),g=p.length,v=p.filter(N=>N.tone==="ok").length,k=g===0?"No shared logins":v===g?`${g} shared login${g===1?", fine":"s, all fine"}`:`${g} shared login${g===1?"":"s"} · ${v} fine`,b=u.unknown&&((x=u.peer)!=null&&x.waiting)&&!u.peer.offers?"Its side is not known until it next calls.":u.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:iI(e)}),f&&a.jsx("p",{className:"nm-next",children:f}),d.length>0&&a.jsx(pI,{facts:d}),u.paired&&a.jsxs("section",{className:"nm-logins","aria-label":"Logins the two decks share",children:[a.jsx("p",{className:"nm-logins-title",children:k}),g>0&&a.jsx("ul",{className:"nm-lanes",children:p.map((N,S)=>a.jsxs("li",{className:"nm-lane","data-tone":N.tone,style:{"--k":S},children:[a.jsx("i",{className:"nm-lane-dot","aria-hidden":!0}),a.jsx("span",{className:"nm-lane-email","aria-hidden":!0,children:N.email}),jS(N)&&a.jsx("span",{className:"nm-lane-said","aria-hidden":!0,children:jS(N)}),N.usedThere&&a.jsx("span",{className:"nm-lane-used","aria-hidden":!0,children:"in use there"}),a.jsxs("span",{className:"vis-hidden",children:[N.email,": ",dI(N)]})]},N.key))}),b&&a.jsx("p",{className:"nm-panel-hint",children:b})]})]})}function jS(e){return e.caption?e.caption:e.tone==="ok"?null:`${cI[e.here]} · ${uI[e.there]}`}function _K(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 EK=6;function CK({anchorId:e,id:t,rows:n,onHold:r,onLet:s}){const o=w.useRef(null),l=n.filter(g=>g.kind==="paired"),u=l.filter(g=>g.here),d=u.slice(0,EK),h=l.length-u.length,f=u.length>d.length?`and ${u.length-d.length} more`:h>0?`${h} not on right now`:null,p=w.useCallback(()=>{const g=o.current,v=document.getElementById(e);if(!g||!v)return;const k=Vb(v.getBoundingClientRect(),{width:g.offsetWidth,height:g.offsetHeight},{width:window.innerWidth,height:window.innerHeight});g.style.top=`${k.top}px`,g.style.left=`${k.left}px`,g.style.maxHeight=k.maxHeight==null?"":`${k.maxHeight}px`,g.dataset.side=k.side},[e]);return w.useLayoutEffect(()=>{p()}),w.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:u.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 TK({entry:e,rows:t,onOpen:n,onMap:r,peek:s,openPeek:o,shutPeek:l,holdPeek:u,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(Z$)},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(fI,{})}),s&&a.jsx(CK,{anchorId:"ap-lan-entry",id:"ap-lan-peek",rows:t,onHold:u,onLet:l})]})}function AK({row:e,run:t,onVerb:n,onUnpair:r}){const[s,o]=w.useState(!1),l=w.useRef(0),[u,d]=w.useState(null);return w.useEffect(()=>{if(!s)return;const p=window.setTimeout(()=>o(!1),4e3);return()=>window.clearTimeout(p)},[s]),w.useEffect(()=>{if(!u)return;const p=window.setTimeout(()=>d(null),4e3);return()=>window.clearTimeout(p)},[u]),{armed:s,armedTwin:u,pressOwn:()=>{const p=Date.now(),g=zl({armedFor:s?e.fp:null,target:e.fp,armedAt:l.current,now:p,gapMs:Ul});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=zl({armedFor:u,target:p,armedAt:l.current,now:g,gapMs:Ul});if(v==="arm"){d(p),o(!1),l.current=g;return}v!=="ignore"&&(d(null),t(()=>r(p)))}}}function RK({row:e,paired:t,peer:n,status:r,busy:s,press:o,checkNow:l,armed:u,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${u?" armed":""}`,...o(`unpair:${e.fp}`),onKeyDown:g=>{g.repeat&&g.preventDefault()},onClick:()=>d(),"aria-label":u?`Confirm unpairing ${e.name}`:`Unpair ${e.name}`,title:u?"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…":u?"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 MK({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((u,d)=>{var k,b,x,N;const h=(k=u.peer)!=null&&k.addr?`${u.peer.addr}:${u.peer.port}`:u.row.addr,f=h||u.row.fp,p=(b=u.peer)!=null&&b.pairedAt?Lr(u.peer.pairedAt,t):null,g=[(N=(x=u.peer)==null?void 0:x.about)!=null&&N.version?`runs ${u.peer.about.version}`:null,p?`paired ${p==="now"?"just now":p}`:null,u.row.state].filter(Boolean).join(" · "),v=u.row.fp;return a.jsxs("li",{role:"listitem",className:"lan-twin","data-tone":u.row.tone,children:[a.jsx("i",{className:u.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:S=>{S.repeat&&S.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 $K(){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 IK({row:e,source:t,status:n,accounts:r,now:s,busy:o,onClose:l,onRename:u,onCheck:d,onVerb:h,onSettings:f,onInvite:p,twins:g=[],onUnpair:v}){const k=w.useRef(null),b=ft(l,{focusRef:k}),[x,N]=w.useState(null),[S,_]=w.useState(null),[E,T]=w.useState(!1),[A,R]=w.useState(0),B=w.useRef(null),P=w.useRef(null),D=w.useRef(!0);w.useEffect(()=>()=>{D.current=!1},[]);const I=x!=null;w.useEffect(()=>{var ie;I&&((ie=B.current)==null||ie.select())},[I]);const O=w.useRef(!1);w.useEffect(()=>{var ie,fe;O.current&&!I&&Dr(((ie=document.activeElement)==null?void 0:ie.tagName)??null)&&((fe=P.current)==null||fe.focus()),O.current=I},[I]);const z=ie=>{const fe=ea(o,ie);return{disabled:fe.disabled,"aria-busy":fe.busy}},M=async ie=>{const fe=await ie();return D.current&&_(fe),fe==null},{armed:$,armedTwin:q,pressOwn:X,pressTwin:H}=AK({row:e,run:M,onVerb:h,onUnpair:v}),L=hI({row:e,source:t,status:n,accounts:r,now:s}),{peer:W,stranger:F,paired:Y,own:J,canRename:V,fp:G}=L,K=o===`check:${e.fp}`,Z=async ie=>{const fe=ie.trim()===J?"":ie;await M(()=>u(fe))&&N(null)},ee=()=>void M(d).then(ie=>{ie&&D.current&&R(fe=>fe+1)}),re=async()=>{if(G)try{if(await navigator.clipboard.writeText(G),!D.current)return;T(!0),window.setTimeout(()=>{D.current&&T(!1)},1600)}catch{D.current&&_("Could not copy it — select the fingerprint and copy it by hand.")}},ue=[];Y&&(W!=null&&W.pairedAt)?ue.push({label:"Paired",value:sK(W.pairedAt,s),tone:"meta"}):e.kind==="declined"&&F&&ue.push({label:"Paired",value:`no · you said no ${e0(F.at,s)}`,tone:"meta"}),ue.push({label:"Fingerprint",value:G?a.jsxs("span",{className:"lan-fp",children:[a.jsx("code",{className:"ap-lan-code",children:G}),a.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void re(),"aria-label":E?"Fingerprint copied":"Copy the fingerprint",children:E?"copied":"copy"})]}):"not known — nothing has answered there",tone:G?void 0:"quiet"});const me=g.length?[{row:e,peer:W??null},...g]:[];return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",onClick:l,role:"presentation",children:a.jsxs("div",{ref:b,className:"modal lan-peer","data-tone":e.tone,onClick:ie=>ie.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:ie=>{ie.preventDefault(),Z(x??"")},children:[a.jsx("span",{id:"lan-peer-title",className:"vis-hidden",children:e.name}),a.jsx("input",{ref:B,className:"ap-manage-input lan-peer-input",value:x??"",maxLength:48,placeholder:J,"aria-label":"Name for this deck, shown on this deck only",onChange:ie=>N(ie.target.value)}),a.jsx("button",{type:"submit",className:"ap-manage-btn",...z(`alias:${e.fp}`),children:"save"}),a.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>N(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}),V&&a.jsx("button",{type:"button",className:"glyph-btn lan-peer-rename",ref:P,onClick:()=>{_(null),N(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($K,{})})]}),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",...z(`alias:${e.fp}`),onClick:()=>void Z(""),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:k,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:[S&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",children:S}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>_(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),a.jsx(aK,{view:L,row:e,status:n,asking:K,drawn:A,onSettings:f}),a.jsx("dl",{className:"lan-facts",children:ue.map(ie=>a.jsxs("div",{className:"lan-fact","data-tone":ie.tone,children:[a.jsx("dt",{children:ie.label}),a.jsx("dd",{children:ie.value})]},ie.label))}),me.length>1&&a.jsx(MK,{instances:me,now:s,busy:o,press:z,armedTwin:q,pressTwin:H,onUnpair:v})]}),a.jsx(RK,{row:e,paired:Y,peer:W,status:n,busy:o,press:z,checkNow:ee,armed:$,pressOwn:X,run:M,onVerb:h,onInvite:p})]})}),document.body)}function yd(e,t){const n=w.useRef(!1);return w.useEffect(()=>{var r,s;!e||!n.current||(n.current=!1,Dr(((r=document.activeElement)==null?void 0:r.tagName)??null)&&((s=t.current)==null||s.focus()))},[e]),()=>{n.current=!0}}function OK(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(r=>n.has(r))}function LK(e,t,n,r){const s=new Set(e??t);return r?s.add(n):s.delete(n),[...s]}function SS(e,t,n){return e==null||n!=null&&!n.ok||OK(e,t)?null:e}function mI({line:e,onDismiss:t,onAnswer:n}){const[r,s]=w.useState(!1),o=w.useRef(!1),l=w.useRef(!0);w.useEffect(()=>(l.current=!0,()=>{l.current=!1}),[]);const u=w.useRef(null),d=w.useRef(null),h=w.useRef(!1);if(w.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 OV();o.current=!1,l.current&&(s(!1),h.current=document.activeElement===u.current,n(PV(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:u,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 PK(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 Mu="Paused while this deck pairs only by invite. Turn that off above to use it.";function DK({status:e,accounts:t,onClose:n,onChanged:r}){qt("lan-setup");const s=ft(n),[o,l]=w.useState(null),[u,d]=w.useState(null),[h,f]=w.useState(!1),[p,g]=w.useState(null),v=w.useRef(null),k=H=>{const L=ea(p,H);return{disabled:L.disabled,"aria-busy":L.busy}},b=w.useRef(null),x=w.useRef(!0);w.useEffect(()=>()=>{x.current=!1},[]),w.useEffect(()=>{b.current=SS(b.current,e.shared??[],null)},[e.shared]);const N=w.useCallback(async(H,L,W="write")=>{v.current=W,g(W);try{const Y=await(await fetch("/api/prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:H})})).json().catch(()=>null);return x.current?(Y!=null&&Y.ok?d(null):d(sr(Et(L,Y),Y)),r(),(Y==null?void 0:Y.ok)===!0):!1}catch{return x.current&&d(sr(Et(L,null))),!1}finally{v.current=null,x.current&&g(null)}},[r]),S=w.useCallback(async H=>{const L=await N({name:H},"save the name","name");return L&&x.current&&l(W=>W===H?null:W),L},[N]),_=w.useRef(null),E=o!=null&&o!==(e.name??""),T=yd(!E,_),A=w.useCallback(async()=>{E&&!await S(o)||n()},[E,o,S,n]),R=async()=>{if(!e.fp)return;const H=await Ha(e.fp);if(x.current){if(!H){d(sr("Could not copy it — select the fingerprint and copy it by hand."));return}f(!0),window.setTimeout(()=>{x.current&&f(!1)},1600)}},B=new Set(b.current??e.shared??[]),P=e.autoAsk!==!1,D=e.autoAccept!==!1,I=e.pairingMode==="invite",O=H=>{const L=k(H);return{...L,disabled:L.disabled||I}},z=e.shareActive!==!1,M=e.tailscale??null,$=!!(M!=null&&M.on),q=(M==null?void 0:M.ask)!==!1,X=(M==null?void 0:M.accept)!==!1;return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal lan-modal",onClick:H=>H.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(mI,{line:u,onDismiss:()=>d(null),onAnswer:H=>{d(H),H.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:_,className:"ap-manage-input ap-lan-input","aria-label":"This deck's name on the network",value:o??e.name??"",placeholder:"this machine",onChange:H=>l(H.target.value),onKeyDown:H=>{H.key!=="Enter"||o==null||S(o)}}),E&&a.jsx("button",{type:"button",className:"ap-manage-btn",...k("name"),onClick:()=>{T(),S(o)},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 R(),"aria-label":h?"Fingerprint copied":"Copy this deck's fingerprint",children:h?"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(H=>a.jsxs("label",{className:"ap-lan-pick",title:H.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:B.has(H.key),onChange:L=>{const W=LK(b.current,e.shared??[],H.key,L.target.checked);b.current=W,N({shared:W},L.target.checked?"share that account":"stop sharing that account").then(F=>{b.current===W&&(b.current=SS(W,e.shared??[],{ok:F}))})}}),a.jsx("span",{className:"ap-lan-pick-name",children:H.email}),!H.alive&&a.jsx("span",{className:"ap-lan-dead",children:"not working here"})]},H.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":z,"aria-label":"Show paired decks which of these this deck is using",...k("current"),onClick:()=>void N({shareActive:!z},z?"stop showing which account this deck is using":"show which account this deck is using","current"),title:z?"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:H=>{H.repeat&&H.preventDefault()},onClick:()=>void N({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":P,"aria-label":"Ask every deck this one finds",...O("ask"),onClick:()=>void N({autoAsk:!P},P?"stop asking automatically":"ask every deck this one finds","ask"),title:I?Mu:P?"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":D,"aria-label":"Say yes to every deck that asks","data-tone":"warn",...O("accept"),onKeyDown:H=>{H.repeat&&H.preventDefault()},onClick:()=>void N({autoAccept:!D},D?"stop accepting automatically":"accept every deck that asks","accept"),title:I?Mu:D?"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"})})]})]})]})]}),(M==null?void 0:M.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:PK(M)})]}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":$,"aria-label":"Look for my devices over Tailscale","aria-describedby":"lan-ts-detail",...k("tailscale"),onClick:()=>void N({tailscale:!$},$?"stop looking over Tailscale":"look for your devices over Tailscale","tailscale"),title:$?"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"})})]}),$&&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":q,"aria-label":"Ask each of my devices it finds over Tailscale",...O("tailscale-ask"),onClick:()=>void N({tailscaleAsk:!q},q?"stop asking your devices automatically":"ask your devices automatically","tailscale-ask"),title:I?Mu:q?"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":X,"aria-label":"Say yes to my devices when they ask over Tailscale","data-tone":"warn",...O("tailscale-accept"),onKeyDown:H=>{H.repeat&&H.preventDefault()},onClick:()=>void N({tailscaleAccept:!X},X?"stop accepting your devices automatically":"accept your devices automatically","tailscale-accept"),title:I?Mu:X?"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 FK({on:e,status:t,paired:n,busy:r,pressProps:s,checkNow:o,setAddOpen:l,setSetupOpen:u,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(fI,{})}),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:()=>u(!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 BK({accounts:e,onChanged:t,onNoCopy:n,view:r,onOpen:s,onBack:o,closeButton:l}){const[u,d]=w.useState(!1),[h,f]=w.useState(!1),[p,g]=w.useState(!1),v=$V(),[k,b]=w.useState(!1),{status:x,manual:N,now:S,busy:_,failure:E,dismissFailure:T,answerGiveBack:A,pressProps:R,load:B,toggle:P,answer:D,dropAddress:I,rename:O,checkOne:z,checkNow:M}=UV(t,()=>d(!0)),{armed:$,pressUnpair:q}=zV(D),[X,H]=w.useState(null),[L,W]=w.useState(!1),F=w.useMemo(()=>e.filter(se=>RV(se.key,x??null,S)).map(se=>se.key).sort().join(`
84
+ `),[e,x,S]);w.useEffect(()=>{n==null||n(F?F.split(`
85
+ `):[])},[F,n]);const Y=(x==null?void 0:x.enabled)===!0,J=w.useMemo(()=>bV((x==null?void 0:x.pairingMode)==="invite"&&x?{...x,pending:[]}:x,S),[x,S]),V=X?J.find(se=>{var ke;return se.fp===X||((ke=se.twins)==null?void 0:ke.some(pe=>pe.fp===X))})??null:null;w.useEffect(()=>{X&&x&&!V&&H(null)},[X,x,V]);const{asks:G,rest:K,live:Z,folded:ee,troubled:re,shown:ue,paired:me}=AV(J,k),ie=wV(x,S),fe=TV(x,J),ve=a.jsxs(a.Fragment,{children:[h&&x&&a.jsx(dG,{status:x,manual:N,startWith:h==="invite"?"invite":void 0,onClose:()=>f(!1),onChanged:()=>{B(),t()}}),p&&a.jsx(eI,{title:"How Local network works",steps:rG,finish:Y?void 0:{label:"Turn it on",act:()=>{g(!1),P()}},onClose:()=>g(!1)}),u&&x&&a.jsx(DK,{status:{...x,manualRows:N},accounts:e,manual:N,onClose:()=>d(!1),onChanged:()=>{B(),t()}}),L&&a.jsx(mK,{status:x,rows:J,accounts:e,now:S,covered:!!V||u||!!h||p,onOpenDeck:H,onClose:()=>W(!1)}),V&&x&&a.jsx(IK,{row:V,source:Gl(x,V),status:x,accounts:e,now:S,busy:_,onClose:()=>H(null),onRename:se=>O(V.fp,se),onCheck:()=>z(V.fp),onVerb:()=>{switch(V.kind){case"paired":return D("unpair",V.fp,"unpair that deck");case"nearby":return D("accept",V.fp,"reach that deck");case"declined":return D("allow",V.fp,"let that deck ask again");case"dialling":return I(V.fp);default:return Promise.resolve(null)}},onSettings:()=>{H(null),d(!0)},onInvite:()=>{H(null),f("invite")},twins:(V.twins??[]).map(se=>({row:se,peer:Gl(x,se).peer??null})),onUnpair:se=>D("unpair",se,"unpair that deck")})]});return r?a.jsxs("div",{className:"ap-lan-view",children:[a.jsx(FK,{on:Y,status:x,paired:me,busy:_,pressProps:R,checkNow:M,setAddOpen:f,setSetupOpen:d,setMapOpen:W,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":Y,"aria-label":"Sync with paired decks",...R("switch"),onClick:()=>void P(),title:Y?"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(gG,{on:Y,status:x}),!Y&&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(sG,{}),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("p",{className:`ap-lan-status ${ie.tone}`,role:"status",children:ie.tone==="ok"?"":ie.text}),a.jsx(mI,{line:E,onDismiss:T,onAnswer:A}),Y&&a.jsxs(a.Fragment,{children:[G.length>0&&a.jsx(fG,{asks:G,pressProps:R,answer:D}),ue.length>0&&a.jsx(pG,{rows:ue,pairingMode:x==null?void 0:x.pairingMode,armed:$,pressProps:R,answer:D,dropAddress:I,onUnpair:q,onOpenPeer:H,onInvite:()=>f("invite")}),(Z.length>0&&ee.length>0||Y&&me>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":k,onClick:()=>b(se=>!se),title:k?"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${k?" open":""}`,"aria-hidden":!0,children:"›"}),k?"fewer":`${ee.length} more`,!k&&re>0&&a.jsxs("span",{className:"ap-lan-more-bad",children:[" · ",re," not responding"]})]}),Y&&me>0&&a.jsx("span",{className:"ap-lan-checked",children:vV(x==null?void 0:x.checkedAt,S,_==="check")})]}),K.length===0&&G.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"})]})]})]})}),ve]}):a.jsxs("div",{className:"ap-foot",children:[a.jsx(TK,{entry:fe,rows:J,onOpen:s,onMap:Y?()=>W(!0):void 0,...v}),a.jsx("p",{className:"vis-hidden",role:"status",children:ie.tone==="ok"?"":ie.text}),ve]})}function qK({anchorId:e,id:t,peers:n,onHold:r,onLet:s}){const o=w.useRef(null),{title:l,shown:u,rest:d}=hV(n),h=w.useCallback(()=>{const f=o.current,p=document.getElementById(e);if(!f||!p)return;const g=Vb(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 w.useLayoutEffect(()=>{h()}),w.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:u.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":`${f.headroom}% free`:f.why})]},f.key))}),d&&a.jsx("p",{className:"ap-peek-rest",children:d})]}),document.body)}function UK({peers:e,strained:t,armed:n,threshold:r,open:s,onToggle:o,order:l,choices:u,onOrder:d,allOpen:h,onToggleAll:f,held:p=!1}){const[g,v]=w.useState(!1),k=w.useRef(0);w.useEffect(()=>()=>window.clearTimeout(k.current),[]),w.useEffect(()=>{s&&(window.clearTimeout(k.current),v(!1))},[s]);const b=E=>{s||(window.clearTimeout(k.current),k.current=window.setTimeout(()=>v(!0),E))},x=()=>{window.clearTimeout(k.current),k.current=window.setTimeout(()=>v(!1),J$)},N=()=>window.clearTimeout(k.current),S=()=>{window.clearTimeout(k.current),v(!1)},_=uV(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:()=>{S(),o()},onPointerEnter:E=>{E.pointerType==="mouse"&&b(Z$)},onPointerLeave:x,onFocus:E=>{E.target.matches(":focus-visible")&&b(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(qK,{anchorId:"ap-rest-entry",id:"ap-rest-peek",peers:e,onHold:N,onLet:x}),s&&a.jsx(zK,{order:l,choices:u,onOrder:d,allOpen:h,onToggleAll:f,held:p})]})}function zK({order:e,choices:t,onOrder:n,allOpen:r,onToggleAll:s,held:o}){var d;const l=w.useRef(null);w.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 u=((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?`${u} — held where it was while you are in the list`:u,"data-sorted":e===Kd?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 WK(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const HK=1800;function VK({accounts:e,onClose:t,copyText:n}){qt("share-accounts");const[r,s]=w.useState([]),[o,l]=w.useState(null),[u,d]=w.useState(!1),[h,f]=w.useState(null),[p,g]=w.useState(!1),[v,k]=w.useState(()=>Math.floor(Date.now()/1e3)),b=w.useRef(null),x=w.useRef(!1),N=ft(t,{focusRef:b}),S=yd(o!=null,b),_=yd(o==null,b);w.useEffect(()=>{if(!o)return;k(Math.floor(Date.now()/1e3));const $=window.setInterval(()=>k(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval($)},[o]);const E=V9(e),T=G9(e,r),A=T.length===e.length,R=$=>s(q=>K9(q,$)),B=w.useCallback(async()=>{const $=Y9(T);if(!lr(x.current)||!$)return;x.current=!0,d(!0),f(null),g(!1);const q=await WK($).catch(()=>null);if(x.current=!1,d(!1),!(q!=null&&q.ok)){f(Ho(q,"the share could not be made"));return}l({blob:q.blob,expiresAt:q.expiresAt,shared:q.shared??[],failed:q.failed??[]})},[e,T]),P=o?V$(o.expiresAt,v):null,D=(P==null?void 0:P.tone)==="gone",I=(o==null?void 0:o.shared.length)??0,O=D?"This share has expired":I===1?"1 account, ready to paste":`${I} accounts, ready to paste`,z=I===1?"this is the password":`this is ${I} passwords`,M=o?D?O:`${O} — ${z}`:"";return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:a.jsxs("div",{ref:N,className:"modal sa-modal",onClick:$=>$.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:M}),o?a.jsxs("div",{className:"sa-step",children:[a.jsx("h4",{children:O}),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:b,onClick:async()=>{if(D){_(),S(),l(null),B();return}await n(o.blob)&&(g(!0),window.setTimeout(()=>g(!1),HK))},children:D?"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:z})," · ",a.jsx("span",{className:`ap-share-expiry ${P==null?void 0:P.tone}`,children:P==null?void 0:P.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($=>{var X;const q=!!($.email&&((X=$.detail)!=null&&X.includes($.email)));return a.jsxs("li",{children:[!q&&a.jsx("span",{className:"sa-who",children:$.email||`account ${$.num}`}),a.jsx("span",{className:"sa-why",children:$.detail||"could not be exported"})]},`${$.num}-${$.email}`)})})]}),a.jsx("p",{className:"sa-note",children:D?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:()=>{_(),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:b,onClick:t,children:"Close"})})]}):a.jsxs("div",{className:"sa-step",children:[a.jsxs("h4",{children:["Which accounts go to the other ",bt,"?"]}),a.jsx("p",{className:`sa-count${T.length?"":" empty"}`,children:X9(T.length)}),a.jsx("ul",{className:"sa-list sa-pick",children:E.map($=>a.jsx("li",{children:a.jsxs("label",{className:"sa-row",children:[a.jsx("input",{type:"checkbox",checked:T.includes($.num),onChange:()=>R($.num)}),a.jsx("span",{className:"sa-who",children:$.label}),$.sub&&a.jsx("span",{className:"sa-sub",children:$.sub})]})},$.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($=>$.num):[]),children:A?"Clear all":"Select all"}),a.jsx("button",{type:"button",className:"btn primary",ref:b,...Or(u,!T.length),onClick:()=>{S(),B()},children:u?"making the share…":T.length===0?"Share":T.length===1?"Share 1 account":`Share ${T.length} accounts`})]})]})]})]})}),document.body)}function gI(e,t){var n;return!e.disabled&&!((n=hi(e,t))!=null&&n.blocksSwitch)}function GK(e,t,n){return e.map(r=>{const s=hi(r,t,n==null?void 0:n(r));return{key:$r(r),name:r.alias??r.email??`account ${r.num}`,ready:gI(r,t),why:r.disabled?"held out":s!=null&&s.blocksSwitch?s.text:null,warn:(s==null?void 0:s.tone)==="warn",headroom:r.headroom}})}function KK(e,t){const n=Number(t);return(e==null?void 0:e.headroom)!=null&&Number.isFinite(n)&&100-e.headroom>=n}function YK(e){return(e==null?void 0:e.ok)===!0&&(e.enabled||e.external)}const yI="agent-dag.otherAccountsOrder",wI="agent-dag.otherAccountsOpen";function XK(){const e=et(yI);return typeof e=="string"&&e.length>0&&e.length<=64?e:Kd}function ZK(e){Xe(yI,e)}function JK(){const e=et(wI);if(!e)return Mx;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 Mx}function QK(e){Xe(wI,JSON.stringify({mode:e.mode,keys:e.keys.filter(t=>!t.startsWith("slot:"))}))}function eY(){const[e,t]=w.useState(null),n=w.useRef(null),r=w.useCallback(l=>Hd(n.current)?(n.current=l,t(l),!0):!1,[]),s=w.useCallback(()=>{n.current=null,t(null)},[]);return{busy:e,claim:r,release:s,pressProps:(l,u=!1)=>{const d=ea(e,l);return{disabled:d.disabled,"aria-busy":d.busy||u}}}}const tY=8e3,nY=1800,rY=4e3;function sY({claim:e,release:t,load:n,clearFailure:r,rescueFocus:s}){const[o,l]=w.useState(null),u=(o==null?void 0:o.num)??null,d=w.useRef(o);d.current=o;const[h,f]=w.useState(null),[p,g]=w.useState(""),[v,k]=w.useState(null),b=w.useRef(0);w.useEffect(()=>{if(v==null)return;const J=window.setTimeout(()=>k(null),rY);return()=>window.clearTimeout(J)},[v]);const[x,N]=w.useState(null),[S,_]=w.useState(!1),[E,T]=w.useState(null),[A,R]=w.useState(null),B=w.useCallback(async(J,V)=>{if(!e(V))return null;r(),f(null);try{const G=await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(J)}),K=await G.json().catch(()=>null);return K!=null&&K.ok||f({text:Ho(K,"command failed",G.status)}),K}catch{return f({text:"server unreachable"}),null}finally{t()}},[e,t,r]),P=w.useCallback(()=>{l(null),f(null),k(null),N(null),_(!1)},[]),D=(J,V="first")=>{P(),R(null),l({num:J,view:"menu",start:V})},I=w.useCallback(J=>{var K,Z;const V=d.current;if(!V||J!=null&&V.num!==J)return;const G=document.getElementById(`ap-menu-${V.num}`);(G!=null&&G.contains(document.activeElement)||Dr(((K=document.activeElement)==null?void 0:K.tagName)??null))&&((Z=document.getElementById(`ap-more-${V.num}`))==null||Z.focus()),P()},[P]),O=w.useCallback(J=>f(J),[]),z=(J,V)=>{g(V??""),f(null),l({num:J,view:"rename"})},M=J=>g(J),$=J=>{R(null),f(null),l({num:J,view:"move"})},q=J=>R(J),X=async J=>{var G;_(!1);const V=await B({action:"share",account:J},`share-${J}`);!(V!=null&&V.ok)||((G=d.current)==null?void 0:G.num)!==J||(N({num:J,blob:V.blob,expiresAt:V.expiresAt}),l({num:J,view:"share"}))},H=async J=>{await Ha(J)&&(_(!0),window.setTimeout(()=>_(!1),nY))},L=async(J,V)=>{const{commit:G,alias:K}=sV(p,V);if(G){const Z=await B({action:"alias",account:J,alias:K},`alias-${J}`);if(await n(!0),!(Z!=null&&Z.ok))return}I(J)},W=async(J,V)=>{var Z,ee,re;const G=await B({action:"move",account:J,slot:V},`move-${J}`),K=nV({menuFor:((Z=d.current)==null?void 0:Z.num)??null,shareFor:(x==null?void 0:x.num)??null},J,G);if(await n(!0),K){if(K.menuFor!=null){const me=document.getElementById(`ap-menu-${J}`),ie=document.getElementById(`ap-more-${K.menuFor}`);ie&&(me!=null&&me.contains(document.activeElement)||Dr(((ee=document.activeElement)==null?void 0:ee.tagName)??null))&&ie.focus()}((re=d.current)==null?void 0:re.num)===J&&P(),k(K.confirmRemove),K.shareFor==null&&(N(null),_(!1)),T(K.swapNote);const ue=K.swapNote;ue&&window.setTimeout(()=>T(me=>me===ue?null:me),tY),R(null),s(K.menuFor)}return G};return{menu:o,menuFor:u,menuError:h,aliasDraft:p,confirmRemove:v,share:x,shareCopied:S,slotDraft:A,swapNote:E,showMenu:D,dropMenu:P,closeMenu:I,sayInMenu:O,startRename:z,typeAlias:M,doAlias:L,startMove:$,pickSlot:q,doSlot:async(J,V,G)=>{if(!G.sends){I(J);return}await W(J,V)},makeShare:X,copyShare:H,pressRemove:J=>{const V=Date.now(),G=zl({armedFor:v,target:J,armedAt:b.current,now:V,gapMs:Ul});if(G==="arm"){k(J),b.current=V;return}G!=="ignore"&&(k(null),B({action:"remove",account:J},`rm-${J}`).then(K=>{var Z;n(!0),K!=null&&K.ok&&(((Z=d.current)==null?void 0:Z.num)===J&&P(),s(null))}))}}}function aY(e,t){return!e||!t||t.some(n=>n.num===e.num&&n.active)?e:null}function oY({data:e,claim:t,release:n,load:r,sayFailure:s,clearFailure:o,sayInMenu:l,rescueFocus:u}){const[d,h]=w.useState(null),f=w.useCallback(async(g,v,k="panel")=>{if(!t(v))return null;const b=k==="menu"?l:s;b(null);try{const x=await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)}),N=await x.json().catch(()=>null);return N!=null&&N.ok||b({text:$x(N,"command failed",x.status),raw:Vl(N)}),N}catch{return b({text:"server unreachable"}),null}finally{n()}},[t,n,l,s]);return w.useEffect(()=>{!(e!=null&&e.ok)||!e.accounts||h(g=>aY(g,e.accounts))},[e]),{switched:d,post:f,doSwitch:async(g,v)=>{if(t(`switch-${g}`)){o(),h(null);try{const b=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:g})})).json().catch(()=>null);b!=null&&b.ok?h({num:g,name:v}):s({text:$x(b,"the switch failed"),raw:Vl(b),row:g}),await r(!0)}catch{s({text:"server unreachable",row:g})}finally{n(),u(g)}}}}}const iY=1800;function lY({auto:e,post:t,load:n}){var k;const[r,s]=w.useState(null),[o,l]=w.useState(!1),u=w.useRef(null),d=w.useRef(null),h=((k=e==null?void 0:e.settings["autoswitch.threshold"])==null?void 0:k.value)??"90",f=r??h,p=iV(f,h);return{threshold:h,thresholdPick:f,thresholdCtl:p,thresholdSaved:o,thresholdRef:u,thresholdSaveRef:d,proposeThreshold:b=>s(b),doThreshold:async(b,x)=>{if(x.sends){const N=await t({action:"setting",key:"autoswitch.threshold",value:b},"threshold");if(await n(!0),!(N!=null&&N.ok))return;s(null)}l(!0),window.setTimeout(()=>{var N;document.activeElement===d.current&&((N=u.current)==null||N.focus()),l(!1)},iY)}}}const cY=Object.freeze({text:"couldn't reach the deck server",reload:!0}),uY=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 dY(e){const t=e.find(r=>!r.ok);if(!t)return null;const n=Vl(t.body);return{text:$x(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function ES(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 vI=15e3,hY=3e4;function fY(e){const[t,n]=w.useState(null),[r,s]=w.useState(null),[o,l]=w.useState(!1),[u,d]=w.useState(null),h=w.useRef(null),f=w.useCallback(async(v=!1)=>{v&&l(!0);const k=new AbortController,b=window.setTimeout(()=>k.abort(),hY);try{const[x,N]=await Promise.all([fetch(`/api/claude-accounts${v?"?refresh=1":""}`,{signal:k.signal}),fetch("/api/cswap-auto",{signal:k.signal})]);if(x.ok){const _=await x.json();n(_),e(_)}N.ok&&s(await N.json());const S=dY([await _S(x),await _S(N)]);d(_=>ES(_,S))}catch{d(x=>ES(x,k.signal.aborted?uY:cY))}finally{window.clearTimeout(b),v&&l(!1)}},[e]);w.useEffect(()=>(f(!0),h.current=window.setInterval(()=>f(!1),vI),()=>{h.current!=null&&window.clearInterval(h.current)}),[f]);const p=w.useCallback(v=>d(v),[]),g=w.useCallback(()=>d(null),[]);return{data:t,auto:r,reloading:o,failure:u,load:f,sayFailure:p,clearFailure:g}}const pY="#ap-rest-entry";function mY(e){return[`#${e}`,pY,...w$(null)]}function gY(e){const t=w.useRef(null),n=s=>{t.current=s.target.id||null},r=s=>{s.target.isConnected&&(t.current=null)};return w.useLayoutEffect(()=>{var o;const s=t.current;if(!(!s||!Dr(((o=document.activeElement)==null?void 0:o.tagName)??null)))for(const l of mY(s)){const u=document.querySelector(l);if(u){u.focus();return}}},[e]),{onFocus:n,onBlur:r}}function yY({onClose:e,leaving:t,onReport:n,onRoster:r}){var pn,Gr,Sn;qt("accounts-panel");const{busy:s,claim:o,release:l,pressProps:u}=eY(),[d,h]=w.useState("accounts"),[f,p]=w.useState(!1),[g,v]=w.useState(null),k=w.useRef(g);k.current=g;const[b,x]=w.useState(!1),[N,S]=w.useState(!1),[_,E]=w.useState([]),[T,A]=w.useState(!1),[R,B]=w.useState(null),[P,D]=w.useState(JK),[I,O]=w.useState(XK),[z,M]=w.useState(null),[$,q]=w.useState(!1),X=w.useRef(r);X.current=r;const H=w.useCallback(we=>{var De;D(qe=>K7(qe,we.accounts)),(De=X.current)==null||De.call(X,we)},[]),{data:L,auto:W,reloading:F,failure:Y,load:J,sayFailure:V,clearFailure:G}=fY(H),K=gY(L),Z=w.useCallback(we=>{window.requestAnimationFrame(()=>{var De;if(Dr(((De=document.activeElement)==null?void 0:De.tagName)??null))for(const qe of w$(we)){const tn=document.querySelector(qe);if(tn){tn.focus();return}}})},[]),ee=sY({claim:o,release:l,load:J,clearFailure:G,rescueFocus:Z}),{menu:re,menuFor:ue,swapNote:me,showMenu:ie,dropMenu:fe,closeMenu:ve,sayInMenu:se}=ee,{switched:ke,post:pe,doSwitch:he}=oY({data:L,claim:o,release:l,load:J,sayFailure:V,clearFailure:G,sayInMenu:se,rescueFocus:Z}),{threshold:ae,thresholdPick:Ne,thresholdCtl:Te,thresholdSaved:Ie,thresholdRef:Oe,thresholdSaveRef:He,proposeThreshold:Ye,doThreshold:Ve}=lY({auto:W,post:pe,load:J}),Ke=S$();w.useEffect(()=>{QK(P)},[P]),w.useEffect(()=>{ZK(I)},[I]);const[nt,it]=w.useState(()=>new Set),At=w.useCallback(we=>it(new Set(we)),[]),Be=we=>({noCopyWorksNearby:nt.has(lS([we])[0].key)}),Ze=(pn=L==null?void 0:L.accounts)==null?void 0:pn.find(we=>we.active),Je=Ze?hi(Ze,Ke,Be(Ze)):null,rt=(L==null?void 0:L.accounts)??[],gt=Ze?rt.filter(we=>!we.active):[],Rt=L$(gt),yt=W7(I,gt),lt=Rx(z7(gt,yt,we=>gI(we,Ke)),z),en=w.useRef(!1),Pt=w.useRef(!1),zt=w.useRef(!1),Dt=w.useCallback(()=>{!en.current&&!Pt.current&&!zt.current&&M(null)},[]),Yt=()=>M(we=>we??lt.map($r)),Ur={onPointerEnter:()=>{en.current=!0,Yt()},onPointerLeave:()=>{en.current=!1,Dt()},onFocus:we=>{we.target.matches(":focus-visible")&&(Pt.current=!0,Yt())},onBlur:we=>{we.currentTarget.contains(we.relatedTarget)||(Pt.current=!1,Dt())}},zn=ue!=null&&gt.some(we=>we.num===ue)||g!=null&&gt.some(we=>we.num===g.num);w.useEffect(()=>{zt.current=zn,zn||Dt()},[zn,Dt]);const zr=$&&gt.length>0;w.useEffect(()=>{zr||(en.current=Pt.current=zt.current=!1,M(null))},[zr]);const Wr=w.useRef(!1);w.useEffect(()=>{Wr.current&&gt.length===0&&Z(null),Wr.current=gt.length>0},[gt.length,Z]);const Wn=lt.length?rt.filter(we=>we.active):rt,gr=GK(lt,Ke,Be),Hn=KK(Ze,ae),Hr=YK(W),Nn=we=>$&&lt.some(De=>De.num===we)?"ap-rest-list":"ap-scroll",gs=(we,De="first")=>{ie(we,De),v(null)},jn=(we,De)=>{fe(),v(qe=>(qe==null?void 0:qe.anchor)===De?null:{num:we,anchor:De})},yr=w.useCallback((we=!1)=>{var qe;const De=k.current;we&&De&&((qe=document.getElementById(De.anchor))==null||qe.focus()),v(null)},[]),vt=()=>{fe(),v(null),h("lan")},wr=w.useRef(d);w.useEffect(()=>{wr.current!==d&&(wr.current=d,window.requestAnimationFrame(()=>{var we;(we=document.getElementById(d==="lan"?"ap-lan-back":"ap-lan-entry"))==null||we.focus()}))},[d]),w.useEffect(()=>{L!=null&&L.ok&&p(!0)},[L==null?void 0:L.ok]),w.useEffect(()=>{t&&(fe(),v(null))},[t,fe]),w.useEffect(()=>{re&&(L!=null&&L.accounts)&&!L.accounts.some(we=>we.num===re.num)&&fe(),g&&(L!=null&&L.accounts)&&!L.accounts.some(we=>we.num===g.num)&&v(null)},[L,re,g,fe]),w.useEffect(()=>{R==null||!(L!=null&&L.accounts)||L.accounts.some(we=>we.num===R.num)||(B(null),Z(null))},[L,R,Z]);const vr=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=we=>{const De=P$(P,we),qe=ue===we.num,tn=(Y==null?void 0:Y.row)===we.num?Y:null,ys=(ke==null?void 0:ke.num)===we.num,xr=(me==null?void 0:me.at)===we.num?me:null,Gn=xr?rt.find(br=>br.num===xr.displaced):void 0,Qe=(g==null?void 0:g.anchor)===`ap-issue-${we.num}`;return a.jsx(Z7,{a:we,nowSec:Ke,lan:Be(we),opened:De,onToggleLanes:()=>D(br=>V7(br,we)),busy:s,pressProps:u,onSwitch:he,menuOpen:qe,onOpenMenu:gs,onCloseMenu:ve,refusal:tn,onDismissRefusal:()=>G(),switchedHere:ys,swapped:xr,displaced:Gn,issueExpanded:Qe,onOpenIssue:jn,sortKey:we.active?null:U7(yt)},we.num)},Vn=L!=null&&L.ok&&(W!=null&&W.ok)?a.jsx(x9,{auto:W,threshold:ae,thresholdPick:Ne,thresholdCtl:Te,thresholdSaved:Ie,thresholdRef:Oe,thresholdSaveRef:He,proposeThreshold:Ye,doThreshold:Ve,pressProps:u,post:pe,load:J}):null;return a.jsxs("aside",{className:`accounts-panel${t?" leaving":""}`,id:"accounts-panel","aria-label":"Claude accounts",onFocus:K.onFocus,onBlur:K.onBlur,children:[d==="accounts"&&a.jsx(Q7,{canShare:(((Gr=L==null?void 0:L.accounts)==null?void 0:Gr.length)??0)>0,canReport:(((Sn=L==null?void 0:L.accounts)==null?void 0:Sn.length)??0)>1||N,onAdd:()=>x(!0),onReport:()=>{E([...Wn,...lt].map($r)),S(!0)},onShareSet:()=>A(!0),onReload:()=>J(!0),pressProps:u,reloading:F,closeButton:vr}),d==="accounts"&&a.jsx("div",{className:"ap-scroll",id:"ap-scroll",children:L==null?Y?a.jsxs("div",{className:"ap-empty",role:"alert",children:[a.jsx("span",{title:Y.raw||void 0,children:Y.text}),a.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",vI/1e3," seconds."]}),a.jsx("button",{type:"button",className:"ap-fix",...u("reload",F),onClick:()=>J(!0).then(()=>Z(null)),children:F?"trying…":"try again"})]}):a.jsx("div",{className:"ap-empty",children:"Checking…"}):L.ok?a.jsxs(a.Fragment,{children:[Ze&&(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:()=>jn(Ze.num,"ap-notice"),children:[a.jsx(Kb,{}),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:Wn.map(Vr)}),lt.length>0&&a.jsx(UK,{peers:gr,strained:Hn,armed:Hr,threshold:W!=null&&W.ok?ae:null,open:$,onToggle:()=>q(we=>!we),order:yt,choices:Rt,onOrder:O,allOpen:D$(P,lt),onToggleAll:()=>D(we=>G7(we,lt)),held:z!=null}),lt.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",...Ur,children:lt.map(Vr)}),Vn]}),lt.length===0&&Vn,Y&&Y.row==null&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",title:Y.raw||void 0,children:Y.text}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>G(),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),re&&(()=>{var De;const we=(De=L.accounts)==null?void 0:De.find(qe=>qe.num===re.num);return we?a.jsx(lV,{a:we,accountMenu:ee,slots:(L.accounts??[]).map(qe=>qe.num),boundaryId:Nn(we.num),nowSec:Ke,busy:s,pressProps:u,rotating:!!(W!=null&&W.enabled||W!=null&&W.external),onProjects:()=>{B({num:we.num,name:we.alias??we.email??`account ${we.num}`}),ve(we.num)},onRotation:()=>pe({action:"account",account:we.num,enabled:we.disabled},`rot-${we.num}`,"menu").then(qe=>{J(!0),qe!=null&&qe.ok&&ve(we.num)})}):null})(),g&&(()=>{var qe;const we=(qe=L.accounts)==null?void 0:qe.find(tn=>tn.num===g.num),De=we?hi(we,Ke,Be(we)):null;return!we||!De?null:a.jsx(M7,{anchorId:g.anchor,boundaryId:g.anchor==="ap-notice"?"ap-scroll":Nn(we.num),issue:De,who:we.alias??we.email??`account ${we.num}`,fetchedAt:we.fetchedAt,nowSec:Ke,onClose:yr,onSignIn:()=>x(!0),onReport:n&&(()=>n({initialKind:De.tone==="warn"?"bug":"other",initialBody:`Account issue: ${De.text}. ${De.hint}`}))})})()]}):a.jsx(J7,{data:L})}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:ke?`Now active: ${ke.name}`:""}),f&&a.jsx(BK,{accounts:lS((L==null?void 0:L.accounts)??[]),onChanged:()=>J(!0),onNoCopy:At,view:d==="lan",onOpen:vt,onBack:()=>h("accounts"),closeButton:vr}),b&&a.jsx(G$,{onClose:()=>x(!1),onChanged:()=>J(!0)}),T&&a.jsx(VK,{accounts:((L==null?void 0:L.accounts)??[]).map(we=>({num:we.num,email:we.email,alias:we.alias,org:we.org})),onClose:()=>A(!1),copyText:Ha}),R!=null&&(()=>{var De;const we=(De=L==null?void 0:L.accounts)==null?void 0:De.find(qe=>qe.num===R.num);return L!=null&&L.accounts&&!we?null:a.jsx(A7,{num:R.num,name:we?we.alias??we.email??`account ${we.num}`:R.name,onClose:()=>B(null)})})(),N&&a.jsx(w9,{accounts:(L==null?void 0:L.accounts)??null,order:_,failed:Y!=null&&Y.reload?Y.text:null,nowSec:Ke,onClose:()=>S(!1)})]})}const wY=16,vY=120;function xY(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 bY(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 kY(e,t){return xY(e,t,wY)?"over":bY(e,t)<=vY?"near":"far"}function NY(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 jY(){const[e,t]=w.useState(!1),[n,r]=w.useState(""),[s,o]=w.useState("far"),l=w.useRef(null),u=qu(e,140),d=w.useCallback(g=>{var b;const v=(b=l.current)==null?void 0:b.getBoundingClientRect(),k=NY(g);return v&&k?kY(k,v):"far"},[]),h=w.useCallback(g=>{g!==null&&(r(g),t(!0)),o("far")},[]),f=w.useCallback(g=>{o(d(g))},[d]),p=w.useCallback((g,v)=>{const k=v&&d(g)==="over";return t(!1),k},[d]);return{trashDragging:e,trashLabel:n,trashState:s,trashZoneRef:l,trashPhase:u,beginTrashDrag:h,trackTrashDrag:f,endTrashDrag:p}}const SY=420;function _Y(){const[e,t]=w.useState(!1),n=w.useRef(null),r=w.useCallback(()=>{n.current&&(window.clearTimeout(n.current),n.current=null),t(!1)},[]),s=w.useCallback(o=>{o.length!==0&&queueMicrotask(()=>{t(!0),n.current&&window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!1),SY+80)})},[]);return w.useEffect(()=>()=>{n.current&&window.clearTimeout(n.current)},[]),{bubbling:e,endBubble:r,onBubble:s}}const s0=11,xI=7.2,bI=6.6,EY={width:104,height:48},CS={width:96,height:44},kI={width:220,height:103};function CY(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)?kI:{width:Math.max(160,t),height:Math.max(72,n)}}function Ep(e,t,n){return e.width*t>=n.width&&e.height*t>=n.height}function TY(e,t,n=kI){if(!Number.isFinite(t)||t<=0)return e??"detail";const r=s0*t;return e==="detail"?r>=bI?"detail":Ep(n,t,CS)?"compact":"overview":r>=xI?"detail":e==="compact"?Ep(n,t,CS)?"compact":"overview":Ep(n,t,EY)?"compact":"overview"}const AY=xI/s0,RY=bI/s0;function MY(e,t){return e>=AY?e:Math.max(e,Math.min(t,RY-.001))}const $Y=.8,IY=1;function OY({stateRef:e,measuredRef:t,measuredVersionRef:n,canvasRef:r}){const[s,o]=w.useState("detail"),l=w.useRef(null),u=w.useRef(null),d=w.useCallback(()=>{var v;const f=n.current;if(((v=u.current)==null?void 0:v.version)===f)return u.current.card;const p=[];for(const k of e.current.agents.keys()){const b=t.current.get(k);b&&p.push(b)}const g=CY(p);return u.current={version:f,card:g},g},[]),h=w.useCallback(f=>{var g;const p=TY(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 LY=40,PY=120;function DY(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)},u=(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=LY){const h=t.now(),f=Math.max(s+d,h);if(f<=h){l(),o();return}u(f,h,d)},replay(d=PY){l(),r=t.now()+d,n=t.setTimeout(o,d)},flush(){l(),o()},cancel(){l()}}}const FY=1024*1024,TS=5,NI=.8,zx=24,BY="agent-dag.soundCustom.done",qY="agent-dag.soundCustom.needs-input",Tl={done:BY,"needs-input":qY};function Kl(e){if(e.kind!=="audio")return e;const{bytes:t,...n}=e;return n}function AS(e){return!e||!/^[a-zA-Z0-9._-]{1,96}$/.test(e)?null:e}function UY(e){return{done:AS(e(Tl.done)),"needs-input":AS(e(Tl["needs-input"]))}}function zY(e,t){return{done:e.done===t?null:e.done,"needs-input":e["needs-input"]===t?null:e["needs-input"]}}function WY(e){return e.done&&e.done===e["needs-input"]?e.done:null}const HY={wav:"audio/wav",wave:"audio/wav",mp3:"audio/mpeg",ogg:"audio/ogg",oga:"audio/ogg",webm:"audio/webm",m4a:"audio/mp4",mp4:"audio/mp4"},jI=new Set(["audio/wav","audio/x-wav","audio/mpeg","audio/mp3","audio/ogg","audio/webm","audio/mp4"]);function SI(e,t){const n=t.toLowerCase().split(";")[0].trim();if(jI.has(n))return n;const r=e.toLowerCase().split(".").pop()??"";return HY[r]??n}function RS(e,t){const n=SI(e.name,e.type);if(!jI.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>FY)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>TS)return`Audio must be ${TS} seconds or shorter.`}return null}function Wx(e){return e>=zx?`There are already ${zx} custom sounds. Delete one first.`:null}function VY(e,t){const n=e.indexOf(t);return n<0?null:e[n+1]??e[n-1]??null}function GY(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,NI/t)}function _I(){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 KY(e,t,n=_I()){var h;const r=((h=e.name)==null?void 0:h.trim())||"Custom sound",s=RS({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 u=RS({name:r,type:e.type,size:e.size},l.duration);if(u)throw new Error(u);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:SI(r,e.type),duration:l.duration,normalizationGain:GY(d),bytes:o}}function YY(e,t=_I()){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 XY="ccdeck-notification-audio",ZY=2,dr="assets",Fr="summaries";function ac(){return typeof window<"u"?window.ccdeckNotificationAudio??null:null}function JY(){return new Promise((e,t)=>{const n=indexedDB.open(XY,ZY);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(Fr))return;const l=s.createObjectStore(Fr,{keyPath:"id"});if(r.oldVersion<1)return;const u=o.openCursor();u.onsuccess=()=>{const d=u.result;d&&(l.put(Kl(d.value)),d.continue())}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??new Error("Could not open local audio storage."))})}async function oc(e,t,n){const r=await JY();try{return await new Promise((s,o)=>{const l=r.transaction(e,t),u=n(l),d=()=>o(l.error??new Error("Local audio storage failed."));l.oncomplete=()=>s(u?u.result:void 0),l.onerror=d,l.onabort=d})}finally{r.close()}}async function QY(){const e=ac();return e?e.list():typeof indexedDB>"u"?[]:await oc([Fr],"readonly",t=>t.objectStore(Fr).getAll())??[]}async function eX(e){const t=ac();return t?t.get(e):typeof indexedDB>"u"?null:await oc([dr],"readonly",n=>n.objectStore(dr).get(e))??null}async function MS(e){const t=ac();if(t){await t.put(e);return}if(typeof indexedDB>"u")throw new Error("Local audio storage is unavailable in this browser.");await oc([dr,Fr],"readwrite",n=>{n.objectStore(dr).put(e),n.objectStore(Fr).put(Kl(e))})}async function tX(e,t){const n=ac();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 oc([dr,Fr],"readwrite",r=>{const s=r.objectStore(dr),o=s.get(e);o.onsuccess=()=>{const l=o.result;if(!l)return;const u={...l,name:t};s.put(u),r.objectStore(Fr).put(Kl(u))}})}async function nX(e){const t=ac();if(t){await t.remove(e);return}typeof indexedDB>"u"||await oc([dr,Fr],"readwrite",n=>{n.objectStore(dr).delete(e),n.objectStore(Fr).delete(e)})}const Hu=["done","needs-input"],rX=[{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}]}],sX=[{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}]}],a0={done:rX,"needs-input":sX},xn="two";function Hx(e,t){const n=a0[e];return n.find(r=>r.id===t)??n.find(r=>r.id===xn)??n[0]}function EI(e,t){return a0[e].some(r=>r.id===t)?t:xn}Hx("done",xn).notes,Hx("needs-input",xn).notes;const $S=.04,CI=.24,Vu=0,wd=100,Vx=5,Ua=50;function fi(e){if(!Number.isFinite(e))return Ua;const t=Math.round(e/Vx)*Vx;return Math.min(wd,Math.max(Vu,t))}function TI(e){if(e==null)return Ua;const t=e.trim();return/^-?\d+(\.\d+)?$/.test(t)?fi(Number(t)):Ua}function o0(e){const t=fi(e),n=$S+(CI-$S)*(t/wd);return Math.round(n*1e4)/1e4}function aX(e,t){const n=t.trim,r=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(o0(e)*r*1e4)/1e4}const oX=.012,IS=1e-4;function iX(e){return Math.min(1,o0(e)/CI)}function lX(e,t){const n=e*(o0(t)/NI);return Math.max(1e-4,n)}const cX=160,uX="agent-dag.soundLevel.done",dX="agent-dag.soundLevel.needs-input",hX="agent-dag.soundFigure.done",fX="agent-dag.soundFigure.needs-input",AI={done:uX,"needs-input":dX},vd={done:hX,"needs-input":fX},Gx={done:{level:Ua,figure:xn},"needs-input":{level:Ua,figure:xn}};function pX(e){const t=n=>({level:TI(e(AI[n])),figure:EI(n,e(vd[n]))});return{done:t("done"),"needs-input":t("needs-input")}}function mX(e,t){return(e??Gx)[t]??Gx[t]}const gX={Stop:"done",Notification:"needs-input"};function yX(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(gX,n)??null}const wX=6,vX="ccdeck-tabs";function xX(e){return e>=wX}function bX(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,u)=>setTimeout(l,u)){return new Promise(l=>{const u=new Set,d=h=>{const f=h.data;(f==null?void 0:f.kind)==="here"&&f.to===t&&f.streaming&&u.add(f.from)};e.addEventListener("message",d),e.postMessage({kind:"who",from:t}),o(()=>{e.removeEventListener("message",d),l(u.size)},s)})},leave(){var s;e.removeEventListener("message",r),(s=e.close)==null||s.call(e)}}}function kX({stateRef:e,rerender:t,pauseGate:n,chimesRef:r,desktopUpdateRef:s}){const[o,l]=w.useState(!1),[u,d]=w.useState(!1),[h,f]=w.useState(!1),p=w.useRef(!0),[g,v]=w.useState(null);return w.useEffect(()=>{const k=new EventSource("/events"),b=DY(t,{now:()=>Date.now(),setTimeout:(_,E)=>window.setTimeout(_,E),clearTimeout:_=>window.clearTimeout(_)});let x=!1;const N=typeof BroadcastChannel=="function"?bX(new BroadcastChannel(vX),Math.random().toString(36).slice(2),()=>x):null,S=window.setInterval(()=>{x||!N||N.ask(600).then(_=>{x||d(xX(_))})},3e3);return k.addEventListener("open",()=>{l(!0),f(!0)}),k.addEventListener("error",()=>{l(!1),v(null)}),k.addEventListener("open",()=>{x=!0,d(!1)}),k.addEventListener("error",()=>{x=!1}),k.addEventListener("replay-end",()=>{p.current=!1,b.flush(),v(Date.now())}),k.addEventListener("desktop-update",_=>s.current(_.data)),k.addEventListener("hook",_=>{var E;try{const T=JSON.parse(_.data);if(!n.accept(T))return;e.current=_M(e.current,T);const A=T.replay===!0||p.current||Date.now()-T.receivedAt>3e4;A?b.replay():b.live();const R=yX(T,A);R&&((E=r.current)==null||E.play(R))}catch{}}),()=>{k.close(),b.cancel(),window.clearInterval(S),N==null||N.leave()}},[t]),{live:o,tabCapped:u,everConnected:h,liveSince:g}}const NX=200,jX=5*6e4,SX=6,_X=2*6e4;function $u(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function EX(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 CX(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`),n.kind==="root"&&t.add(Pb(n.id));return t}function TX(e){const t=new Set;for(const n of e)t.add(n.id),n.kind==="root"&&t.add(Pb(n.id));return t}function AX(e,t){let n=kq(e,t,tj);Nq(e,t,tj)&&(n=!0);const r=[],s=o=>{r.push(o)};return vq(e,t,NX,jX,s)&&(n=!0),xq(e,t,SX,_X,s)&&(n=!0),{changed:n,forgotten:r}}function RX(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 MX(e,t){const[n,r]=w.useState(()=>({ids:new Set,primary:null})),{ids:s,primary:o}=n,l=w.useCallback((h,f,p=!f)=>{r(g=>RX(g,h,f)),!f&&p&&t(!0)},[]),u=w.useCallback(()=>{r({ids:new Set,primary:null})},[]),d=w.useCallback(()=>{r(h=>{const f=EX(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:u,pruneSelectionToBoard:d}}function $X({stateRef:e,rerender:t,pruneSelectionToBoard:n,setContextFor:r,setSummaryFor:s}){const[o,l]=w.useState(Date.now());return w.useEffect(()=>{const u=setInterval(()=>{const d=Date.now();l(d);const{changed:h,forgotten:f}=AX(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(u)},[t]),o}function i0(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 Cp,OS;function IX(){if(OS)return Cp;OS=1;function e(){this.__data__=[],this.size=0}return Cp=e,Cp}var Tp,LS;function bi(){if(LS)return Tp;LS=1;function e(t,n){return t===n||t!==t&&n!==n}return Tp=e,Tp}var Ap,PS;function Qd(){if(PS)return Ap;PS=1;var e=bi();function t(n,r){for(var s=n.length;s--;)if(e(n[s][0],r))return s;return-1}return Ap=t,Ap}var Rp,DS;function OX(){if(DS)return Rp;DS=1;var e=Qd(),t=Array.prototype,n=t.splice;function r(s){var o=this.__data__,l=e(o,s);if(l<0)return!1;var u=o.length-1;return l==u?o.pop():n.call(o,l,1),--this.size,!0}return Rp=r,Rp}var Mp,FS;function LX(){if(FS)return Mp;FS=1;var e=Qd();function t(n){var r=this.__data__,s=e(r,n);return s<0?void 0:r[s][1]}return Mp=t,Mp}var $p,BS;function PX(){if(BS)return $p;BS=1;var e=Qd();function t(n){return e(this.__data__,n)>-1}return $p=t,$p}var Ip,qS;function DX(){if(qS)return Ip;qS=1;var e=Qd();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 Ip=t,Ip}var Op,US;function eh(){if(US)return Op;US=1;var e=IX(),t=OX(),n=LX(),r=PX(),s=DX();function o(l){var u=-1,d=l==null?0:l.length;for(this.clear();++u<d;){var h=l[u];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,Op=o,Op}var Lp,zS;function FX(){if(zS)return Lp;zS=1;var e=eh();function t(){this.__data__=new e,this.size=0}return Lp=t,Lp}var Pp,WS;function BX(){if(WS)return Pp;WS=1;function e(t){var n=this.__data__,r=n.delete(t);return this.size=n.size,r}return Pp=e,Pp}var Dp,HS;function qX(){if(HS)return Dp;HS=1;function e(t){return this.__data__.get(t)}return Dp=e,Dp}var Fp,VS;function UX(){if(VS)return Fp;VS=1;function e(t){return this.__data__.has(t)}return Fp=e,Fp}var Bp,GS;function RI(){if(GS)return Bp;GS=1;var e=typeof uu=="object"&&uu&&uu.Object===Object&&uu;return Bp=e,Bp}var qp,KS;function mr(){if(KS)return qp;KS=1;var e=RI(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return qp=n,qp}var Up,YS;function ki(){if(YS)return Up;YS=1;var e=mr(),t=e.Symbol;return Up=t,Up}var zp,XS;function zX(){if(XS)return zp;XS=1;var e=ki(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,s=e?e.toStringTag:void 0;function o(l){var u=n.call(l,s),d=l[s];try{l[s]=void 0;var h=!0}catch{}var f=r.call(l);return h&&(u?l[s]=d:delete l[s]),f}return zp=o,zp}var Wp,ZS;function WX(){if(ZS)return Wp;ZS=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return Wp=n,Wp}var Hp,JS;function Va(){if(JS)return Hp;JS=1;var e=ki(),t=zX(),n=WX(),r="[object Null]",s="[object Undefined]",o=e?e.toStringTag:void 0;function l(u){return u==null?u===void 0?s:r:o&&o in Object(u)?t(u):n(u)}return Hp=l,Hp}var Vp,QS;function qn(){if(QS)return Vp;QS=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return Vp=e,Vp}var Gp,e_;function ic(){if(e_)return Gp;e_=1;var e=Va(),t=qn(),n="[object AsyncFunction]",r="[object Function]",s="[object GeneratorFunction]",o="[object Proxy]";function l(u){if(!t(u))return!1;var d=e(u);return d==r||d==s||d==n||d==o}return Gp=l,Gp}var Kp,t_;function HX(){if(t_)return Kp;t_=1;var e=mr(),t=e["__core-js_shared__"];return Kp=t,Kp}var Yp,n_;function VX(){if(n_)return Yp;n_=1;var e=HX(),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 Yp=n,Yp}var Xp,r_;function MI(){if(r_)return Xp;r_=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 Xp=n,Xp}var Zp,s_;function GX(){if(s_)return Zp;s_=1;var e=ic(),t=VX(),n=qn(),r=MI(),s=/[\\^$.*+?()[\]{}|]/g,o=/^\[object .+?Constructor\]$/,l=Function.prototype,u=Object.prototype,d=l.toString,h=u.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 Zp=p,Zp}var Jp,a_;function KX(){if(a_)return Jp;a_=1;function e(t,n){return t==null?void 0:t[n]}return Jp=e,Jp}var Qp,o_;function Ga(){if(o_)return Qp;o_=1;var e=GX(),t=KX();function n(r,s){var o=t(r,s);return e(o)?o:void 0}return Qp=n,Qp}var em,i_;function l0(){if(i_)return em;i_=1;var e=Ga(),t=mr(),n=e(t,"Map");return em=n,em}var tm,l_;function th(){if(l_)return tm;l_=1;var e=Ga(),t=e(Object,"create");return tm=t,tm}var nm,c_;function YX(){if(c_)return nm;c_=1;var e=th();function t(){this.__data__=e?e(null):{},this.size=0}return nm=t,nm}var rm,u_;function XX(){if(u_)return rm;u_=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return rm=e,rm}var sm,d_;function ZX(){if(d_)return sm;d_=1;var e=th(),t="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function s(o){var l=this.__data__;if(e){var u=l[o];return u===t?void 0:u}return r.call(l,o)?l[o]:void 0}return sm=s,sm}var am,h_;function JX(){if(h_)return am;h_=1;var e=th(),t=Object.prototype,n=t.hasOwnProperty;function r(s){var o=this.__data__;return e?o[s]!==void 0:n.call(o,s)}return am=r,am}var om,f_;function QX(){if(f_)return om;f_=1;var e=th(),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 om=n,om}var im,p_;function eZ(){if(p_)return im;p_=1;var e=YX(),t=XX(),n=ZX(),r=JX(),s=QX();function o(l){var u=-1,d=l==null?0:l.length;for(this.clear();++u<d;){var h=l[u];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,im=o,im}var lm,m_;function tZ(){if(m_)return lm;m_=1;var e=eZ(),t=eh(),n=l0();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return lm=r,lm}var cm,g_;function nZ(){if(g_)return cm;g_=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return cm=e,cm}var um,y_;function nh(){if(y_)return um;y_=1;var e=nZ();function t(n,r){var s=n.__data__;return e(r)?s[typeof r=="string"?"string":"hash"]:s.map}return um=t,um}var dm,w_;function rZ(){if(w_)return dm;w_=1;var e=nh();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return dm=t,dm}var hm,v_;function sZ(){if(v_)return hm;v_=1;var e=nh();function t(n){return e(this,n).get(n)}return hm=t,hm}var fm,x_;function aZ(){if(x_)return fm;x_=1;var e=nh();function t(n){return e(this,n).has(n)}return fm=t,fm}var pm,b_;function oZ(){if(b_)return pm;b_=1;var e=nh();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 pm=t,pm}var mm,k_;function c0(){if(k_)return mm;k_=1;var e=tZ(),t=rZ(),n=sZ(),r=aZ(),s=oZ();function o(l){var u=-1,d=l==null?0:l.length;for(this.clear();++u<d;){var h=l[u];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 gm,N_;function iZ(){if(N_)return gm;N_=1;var e=eh(),t=l0(),n=c0(),r=200;function s(o,l){var u=this.__data__;if(u instanceof e){var d=u.__data__;if(!t||d.length<r-1)return d.push([o,l]),this.size=++u.size,this;u=this.__data__=new n(d)}return u.set(o,l),this.size=u.size,this}return gm=s,gm}var ym,j_;function rh(){if(j_)return ym;j_=1;var e=eh(),t=FX(),n=BX(),r=qX(),s=UX(),o=iZ();function l(u){var d=this.__data__=new e(u);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,ym=l,ym}var wm,S_;function u0(){if(S_)return wm;S_=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 wm=e,wm}var vm,__;function $I(){if(__)return vm;__=1;var e=Ga(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return vm=t,vm}var xm,E_;function sh(){if(E_)return xm;E_=1;var e=$I();function t(n,r,s){r=="__proto__"&&e?e(n,r,{configurable:!0,enumerable:!0,value:s,writable:!0}):n[r]=s}return xm=t,xm}var bm,C_;function ah(){if(C_)return bm;C_=1;var e=sh(),t=bi(),n=Object.prototype,r=n.hasOwnProperty;function s(o,l,u){var d=o[l];(!(r.call(o,l)&&t(d,u))||u===void 0&&!(l in o))&&e(o,l,u)}return bm=s,bm}var km,T_;function lc(){if(T_)return km;T_=1;var e=ah(),t=sh();function n(r,s,o,l){var u=!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]),u?t(o,f,p):e(o,f,p)}return o}return km=n,km}var Nm,A_;function lZ(){if(A_)return Nm;A_=1;function e(t,n){for(var r=-1,s=Array(t);++r<t;)s[r]=n(r);return s}return Nm=e,Nm}var jm,R_;function qr(){if(R_)return jm;R_=1;function e(t){return t!=null&&typeof t=="object"}return jm=e,jm}var Sm,M_;function cZ(){if(M_)return Sm;M_=1;var e=Va(),t=qr(),n="[object Arguments]";function r(s){return t(s)&&e(s)==n}return Sm=r,Sm}var _m,$_;function cc(){if($_)return _m;$_=1;var e=cZ(),t=qr(),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 _m=o,_m}var Em,I_;function Nt(){if(I_)return Em;I_=1;var e=Array.isArray;return Em=e,Em}var kl={exports:{}},Cm,O_;function uZ(){if(O_)return Cm;O_=1;function e(){return!1}return Cm=e,Cm}kl.exports;var L_;function Ni(){return L_||(L_=1,(function(e,t){var n=mr(),r=uZ(),s=t&&!t.nodeType&&t,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,u=l?n.Buffer:void 0,d=u?u.isBuffer:void 0,h=d||r;e.exports=h})(kl,kl.exports)),kl.exports}var Tm,P_;function oh(){if(P_)return Tm;P_=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 Tm=n,Tm}var Am,D_;function d0(){if(D_)return Am;D_=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return Am=t,Am}var Rm,F_;function dZ(){if(F_)return Rm;F_=1;var e=Va(),t=d0(),n=qr(),r="[object Arguments]",s="[object Array]",o="[object Boolean]",l="[object Date]",u="[object Error]",d="[object Function]",h="[object Map]",f="[object Number]",p="[object Object]",g="[object RegExp]",v="[object Set]",k="[object String]",b="[object WeakMap]",x="[object ArrayBuffer]",N="[object DataView]",S="[object Float32Array]",_="[object Float64Array]",E="[object Int8Array]",T="[object Int16Array]",A="[object Int32Array]",R="[object Uint8Array]",B="[object Uint8ClampedArray]",P="[object Uint16Array]",D="[object Uint32Array]",I={};I[S]=I[_]=I[E]=I[T]=I[A]=I[R]=I[B]=I[P]=I[D]=!0,I[r]=I[s]=I[x]=I[o]=I[N]=I[l]=I[u]=I[d]=I[h]=I[f]=I[p]=I[g]=I[v]=I[k]=I[b]=!1;function O(z){return n(z)&&t(z.length)&&!!I[e(z)]}return Rm=O,Rm}var Mm,B_;function ih(){if(B_)return Mm;B_=1;function e(t){return function(n){return t(n)}}return Mm=e,Mm}var Nl={exports:{}};Nl.exports;var q_;function h0(){return q_||(q_=1,(function(e,t){var n=RI(),r=t&&!t.nodeType&&t,s=r&&!0&&e&&!e.nodeType&&e,o=s&&s.exports===r,l=o&&n.process,u=(function(){try{var d=s&&s.require&&s.require("util").types;return d||l&&l.binding&&l.binding("util")}catch{}})();e.exports=u})(Nl,Nl.exports)),Nl.exports}var $m,U_;function uc(){if(U_)return $m;U_=1;var e=dZ(),t=ih(),n=h0(),r=n&&n.isTypedArray,s=r?t(r):e;return $m=s,$m}var Im,z_;function II(){if(z_)return Im;z_=1;var e=lZ(),t=cc(),n=Nt(),r=Ni(),s=oh(),o=uc(),l=Object.prototype,u=l.hasOwnProperty;function d(h,f){var p=n(h),g=!p&&t(h),v=!p&&!g&&r(h),k=!p&&!g&&!v&&o(h),b=p||g||v||k,x=b?e(h.length,String):[],N=x.length;for(var S in h)(f||u.call(h,S))&&!(b&&(S=="length"||v&&(S=="offset"||S=="parent")||k&&(S=="buffer"||S=="byteLength"||S=="byteOffset")||s(S,N)))&&x.push(S);return x}return Im=d,Im}var Om,W_;function lh(){if(W_)return Om;W_=1;var e=Object.prototype;function t(n){var r=n&&n.constructor,s=typeof r=="function"&&r.prototype||e;return n===s}return Om=t,Om}var Lm,H_;function OI(){if(H_)return Lm;H_=1;function e(t,n){return function(r){return t(n(r))}}return Lm=e,Lm}var Pm,V_;function hZ(){if(V_)return Pm;V_=1;var e=OI(),t=e(Object.keys,Object);return Pm=t,Pm}var Dm,G_;function f0(){if(G_)return Dm;G_=1;var e=lh(),t=hZ(),n=Object.prototype,r=n.hasOwnProperty;function s(o){if(!e(o))return t(o);var l=[];for(var u in Object(o))r.call(o,u)&&u!="constructor"&&l.push(u);return l}return Dm=s,Dm}var Fm,K_;function ps(){if(K_)return Fm;K_=1;var e=ic(),t=d0();function n(r){return r!=null&&t(r.length)&&!e(r)}return Fm=n,Fm}var Bm,Y_;function ra(){if(Y_)return Bm;Y_=1;var e=II(),t=f0(),n=ps();function r(s){return n(s)?e(s):t(s)}return Bm=r,Bm}var qm,X_;function fZ(){if(X_)return qm;X_=1;var e=lc(),t=ra();function n(r,s){return r&&e(s,t(s),r)}return qm=n,qm}var Um,Z_;function pZ(){if(Z_)return Um;Z_=1;function e(t){var n=[];if(t!=null)for(var r in Object(t))n.push(r);return n}return Um=e,Um}var zm,J_;function mZ(){if(J_)return zm;J_=1;var e=qn(),t=lh(),n=pZ(),r=Object.prototype,s=r.hasOwnProperty;function o(l){if(!e(l))return n(l);var u=t(l),d=[];for(var h in l)h=="constructor"&&(u||!s.call(l,h))||d.push(h);return d}return zm=o,zm}var Wm,Q_;function Ka(){if(Q_)return Wm;Q_=1;var e=II(),t=mZ(),n=ps();function r(s){return n(s)?e(s,!0):t(s)}return Wm=r,Wm}var Hm,eE;function gZ(){if(eE)return Hm;eE=1;var e=lc(),t=Ka();function n(r,s){return r&&e(s,t(s),r)}return Hm=n,Hm}var jl={exports:{}};jl.exports;var tE;function LI(){return tE||(tE=1,(function(e,t){var n=mr(),r=t&&!t.nodeType&&t,s=r&&!0&&e&&!e.nodeType&&e,o=s&&s.exports===r,l=o?n.Buffer:void 0,u=l?l.allocUnsafe:void 0;function d(h,f){if(f)return h.slice();var p=h.length,g=u?u(p):new h.constructor(p);return h.copy(g),g}e.exports=d})(jl,jl.exports)),jl.exports}var Vm,nE;function PI(){if(nE)return Vm;nE=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 Vm=e,Vm}var Gm,rE;function DI(){if(rE)return Gm;rE=1;function e(t,n){for(var r=-1,s=t==null?0:t.length,o=0,l=[];++r<s;){var u=t[r];n(u,r,t)&&(l[o++]=u)}return l}return Gm=e,Gm}var Km,sE;function FI(){if(sE)return Km;sE=1;function e(){return[]}return Km=e,Km}var Ym,aE;function p0(){if(aE)return Ym;aE=1;var e=DI(),t=FI(),n=Object.prototype,r=n.propertyIsEnumerable,s=Object.getOwnPropertySymbols,o=s?function(l){return l==null?[]:(l=Object(l),e(s(l),function(u){return r.call(l,u)}))}:t;return Ym=o,Ym}var Xm,oE;function yZ(){if(oE)return Xm;oE=1;var e=lc(),t=p0();function n(r,s){return e(r,t(r),s)}return Xm=n,Xm}var Zm,iE;function m0(){if(iE)return Zm;iE=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 Zm=e,Zm}var Jm,lE;function ch(){if(lE)return Jm;lE=1;var e=OI(),t=e(Object.getPrototypeOf,Object);return Jm=t,Jm}var Qm,cE;function BI(){if(cE)return Qm;cE=1;var e=m0(),t=ch(),n=p0(),r=FI(),s=Object.getOwnPropertySymbols,o=s?function(l){for(var u=[];l;)e(u,n(l)),l=t(l);return u}:r;return Qm=o,Qm}var eg,uE;function wZ(){if(uE)return eg;uE=1;var e=lc(),t=BI();function n(r,s){return e(r,t(r),s)}return eg=n,eg}var tg,dE;function qI(){if(dE)return tg;dE=1;var e=m0(),t=Nt();function n(r,s,o){var l=s(r);return t(r)?l:e(l,o(r))}return tg=n,tg}var ng,hE;function UI(){if(hE)return ng;hE=1;var e=qI(),t=p0(),n=ra();function r(s){return e(s,n,t)}return ng=r,ng}var rg,fE;function vZ(){if(fE)return rg;fE=1;var e=qI(),t=BI(),n=Ka();function r(s){return e(s,n,t)}return rg=r,rg}var sg,pE;function xZ(){if(pE)return sg;pE=1;var e=Ga(),t=mr(),n=e(t,"DataView");return sg=n,sg}var ag,mE;function bZ(){if(mE)return ag;mE=1;var e=Ga(),t=mr(),n=e(t,"Promise");return ag=n,ag}var og,gE;function zI(){if(gE)return og;gE=1;var e=Ga(),t=mr(),n=e(t,"Set");return og=n,og}var ig,yE;function kZ(){if(yE)return ig;yE=1;var e=Ga(),t=mr(),n=e(t,"WeakMap");return ig=n,ig}var lg,wE;function ji(){if(wE)return lg;wE=1;var e=xZ(),t=l0(),n=bZ(),r=zI(),s=kZ(),o=Va(),l=MI(),u="[object Map]",d="[object Object]",h="[object Promise]",f="[object Set]",p="[object WeakMap]",g="[object DataView]",v=l(e),k=l(t),b=l(n),x=l(r),N=l(s),S=o;return(e&&S(new e(new ArrayBuffer(1)))!=g||t&&S(new t)!=u||n&&S(n.resolve())!=h||r&&S(new r)!=f||s&&S(new s)!=p)&&(S=function(_){var E=o(_),T=E==d?_.constructor:void 0,A=T?l(T):"";if(A)switch(A){case v:return g;case k:return u;case b:return h;case x:return f;case N:return p}return E}),lg=S,lg}var cg,vE;function NZ(){if(vE)return cg;vE=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 cg=n,cg}var ug,xE;function WI(){if(xE)return ug;xE=1;var e=mr(),t=e.Uint8Array;return ug=t,ug}var dg,bE;function g0(){if(bE)return dg;bE=1;var e=WI();function t(n){var r=new n.constructor(n.byteLength);return new e(r).set(new e(n)),r}return dg=t,dg}var hg,kE;function jZ(){if(kE)return hg;kE=1;var e=g0();function t(n,r){var s=r?e(n.buffer):n.buffer;return new n.constructor(s,n.byteOffset,n.byteLength)}return hg=t,hg}var fg,NE;function SZ(){if(NE)return fg;NE=1;var e=/\w*$/;function t(n){var r=new n.constructor(n.source,e.exec(n));return r.lastIndex=n.lastIndex,r}return fg=t,fg}var pg,jE;function _Z(){if(jE)return pg;jE=1;var e=ki(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function r(s){return n?Object(n.call(s)):{}}return pg=r,pg}var mg,SE;function HI(){if(SE)return mg;SE=1;var e=g0();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 gg,_E;function EZ(){if(_E)return gg;_E=1;var e=g0(),t=jZ(),n=SZ(),r=_Z(),s=HI(),o="[object Boolean]",l="[object Date]",u="[object Map]",d="[object Number]",h="[object RegExp]",f="[object Set]",p="[object String]",g="[object Symbol]",v="[object ArrayBuffer]",k="[object DataView]",b="[object Float32Array]",x="[object Float64Array]",N="[object Int8Array]",S="[object Int16Array]",_="[object Int32Array]",E="[object Uint8Array]",T="[object Uint8ClampedArray]",A="[object Uint16Array]",R="[object Uint32Array]";function B(P,D,I){var O=P.constructor;switch(D){case v:return e(P);case o:case l:return new O(+P);case k:return t(P,I);case b:case x:case N:case S:case _:case E:case T:case A:case R:return s(P,I);case u:return new O;case d:case p:return new O(P);case h:return n(P);case f:return new O;case g:return r(P)}}return gg=B,gg}var yg,EE;function VI(){if(EE)return yg;EE=1;var e=qn(),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 yg=n,yg}var wg,CE;function GI(){if(CE)return wg;CE=1;var e=VI(),t=ch(),n=lh();function r(s){return typeof s.constructor=="function"&&!n(s)?e(t(s)):{}}return wg=r,wg}var vg,TE;function CZ(){if(TE)return vg;TE=1;var e=ji(),t=qr(),n="[object Map]";function r(s){return t(s)&&e(s)==n}return vg=r,vg}var xg,AE;function TZ(){if(AE)return xg;AE=1;var e=CZ(),t=ih(),n=h0(),r=n&&n.isMap,s=r?t(r):e;return xg=s,xg}var bg,RE;function AZ(){if(RE)return bg;RE=1;var e=ji(),t=qr(),n="[object Set]";function r(s){return t(s)&&e(s)==n}return bg=r,bg}var kg,ME;function RZ(){if(ME)return kg;ME=1;var e=AZ(),t=ih(),n=h0(),r=n&&n.isSet,s=r?t(r):e;return kg=s,kg}var Ng,$E;function KI(){if($E)return Ng;$E=1;var e=rh(),t=u0(),n=ah(),r=fZ(),s=gZ(),o=LI(),l=PI(),u=yZ(),d=wZ(),h=UI(),f=vZ(),p=ji(),g=NZ(),v=EZ(),k=GI(),b=Nt(),x=Ni(),N=TZ(),S=qn(),_=RZ(),E=ra(),T=Ka(),A=1,R=2,B=4,P="[object Arguments]",D="[object Array]",I="[object Boolean]",O="[object Date]",z="[object Error]",M="[object Function]",$="[object GeneratorFunction]",q="[object Map]",X="[object Number]",H="[object Object]",L="[object RegExp]",W="[object Set]",F="[object String]",Y="[object Symbol]",J="[object WeakMap]",V="[object ArrayBuffer]",G="[object DataView]",K="[object Float32Array]",Z="[object Float64Array]",ee="[object Int8Array]",re="[object Int16Array]",ue="[object Int32Array]",me="[object Uint8Array]",ie="[object Uint8ClampedArray]",fe="[object Uint16Array]",ve="[object Uint32Array]",se={};se[P]=se[D]=se[V]=se[G]=se[I]=se[O]=se[K]=se[Z]=se[ee]=se[re]=se[ue]=se[q]=se[X]=se[H]=se[L]=se[W]=se[F]=se[Y]=se[me]=se[ie]=se[fe]=se[ve]=!0,se[z]=se[M]=se[J]=!1;function ke(pe,he,ae,Ne,Te,Ie){var Oe,He=he&A,Ye=he&R,Ve=he&B;if(ae&&(Oe=Te?ae(pe,Ne,Te,Ie):ae(pe)),Oe!==void 0)return Oe;if(!S(pe))return pe;var Ke=b(pe);if(Ke){if(Oe=g(pe),!He)return l(pe,Oe)}else{var nt=p(pe),it=nt==M||nt==$;if(x(pe))return o(pe,He);if(nt==H||nt==P||it&&!Te){if(Oe=Ye||it?{}:k(pe),!He)return Ye?d(pe,s(Oe,pe)):u(pe,r(Oe,pe))}else{if(!se[nt])return Te?pe:{};Oe=v(pe,nt,He)}}Ie||(Ie=new e);var At=Ie.get(pe);if(At)return At;Ie.set(pe,Oe),_(pe)?pe.forEach(function(Je){Oe.add(ke(Je,he,ae,Je,pe,Ie))}):N(pe)&&pe.forEach(function(Je,rt){Oe.set(rt,ke(Je,he,ae,rt,pe,Ie))});var Be=Ve?Ye?f:h:Ye?T:E,Ze=Ke?void 0:Be(pe);return t(Ze||pe,function(Je,rt){Ze&&(rt=Je,Je=pe[rt]),n(Oe,rt,ke(Je,he,ae,rt,pe,Ie))}),Oe}return Ng=ke,Ng}var jg,IE;function MZ(){if(IE)return jg;IE=1;var e=KI(),t=4;function n(r){return e(r,t)}return jg=n,jg}var Sg,OE;function y0(){if(OE)return Sg;OE=1;function e(t){return function(){return t}}return Sg=e,Sg}var _g,LE;function $Z(){if(LE)return _g;LE=1;function e(t){return function(n,r,s){for(var o=-1,l=Object(n),u=s(n),d=u.length;d--;){var h=u[t?d:++o];if(r(l[h],h,l)===!1)break}return n}}return _g=e,_g}var Eg,PE;function w0(){if(PE)return Eg;PE=1;var e=$Z(),t=e();return Eg=t,Eg}var Cg,DE;function v0(){if(DE)return Cg;DE=1;var e=w0(),t=ra();function n(r,s){return r&&e(r,s,t)}return Cg=n,Cg}var Tg,FE;function IZ(){if(FE)return Tg;FE=1;var e=ps();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,u=r?l:-1,d=Object(s);(r?u--:++u<l)&&o(d[u],u,d)!==!1;);return s}}return Tg=t,Tg}var Ag,BE;function uh(){if(BE)return Ag;BE=1;var e=v0(),t=IZ(),n=t(e);return Ag=n,Ag}var Rg,qE;function Ya(){if(qE)return Rg;qE=1;function e(t){return t}return Rg=e,Rg}var Mg,UE;function YI(){if(UE)return Mg;UE=1;var e=Ya();function t(n){return typeof n=="function"?n:e}return Mg=t,Mg}var $g,zE;function XI(){if(zE)return $g;zE=1;var e=u0(),t=uh(),n=YI(),r=Nt();function s(o,l){var u=r(o)?e:t;return u(o,n(l))}return $g=s,$g}var Ig,WE;function ZI(){return WE||(WE=1,Ig=XI()),Ig}var Og,HE;function OZ(){if(HE)return Og;HE=1;var e=uh();function t(n,r){var s=[];return e(n,function(o,l,u){r(o,l,u)&&s.push(o)}),s}return Og=t,Og}var Lg,VE;function LZ(){if(VE)return Lg;VE=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return Lg=t,Lg}var Pg,GE;function PZ(){if(GE)return Pg;GE=1;function e(t){return this.__data__.has(t)}return Pg=e,Pg}var Dg,KE;function JI(){if(KE)return Dg;KE=1;var e=c0(),t=LZ(),n=PZ();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,Dg=r,Dg}var Fg,YE;function DZ(){if(YE)return Fg;YE=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 Fg=e,Fg}var Bg,XE;function QI(){if(XE)return Bg;XE=1;function e(t,n){return t.has(n)}return Bg=e,Bg}var qg,ZE;function eO(){if(ZE)return qg;ZE=1;var e=JI(),t=DZ(),n=QI(),r=1,s=2;function o(l,u,d,h,f,p){var g=d&r,v=l.length,k=u.length;if(v!=k&&!(g&&k>v))return!1;var b=p.get(l),x=p.get(u);if(b&&x)return b==u&&x==l;var N=-1,S=!0,_=d&s?new e:void 0;for(p.set(l,u),p.set(u,l);++N<v;){var E=l[N],T=u[N];if(h)var A=g?h(T,E,N,u,l,p):h(E,T,N,l,u,p);if(A!==void 0){if(A)continue;S=!1;break}if(_){if(!t(u,function(R,B){if(!n(_,B)&&(E===R||f(E,R,d,h,p)))return _.push(B)})){S=!1;break}}else if(!(E===T||f(E,T,d,h,p))){S=!1;break}}return p.delete(l),p.delete(u),S}return qg=o,qg}var Ug,JE;function FZ(){if(JE)return Ug;JE=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(s,o){r[++n]=[o,s]}),r}return Ug=e,Ug}var zg,QE;function x0(){if(QE)return zg;QE=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(s){r[++n]=s}),r}return zg=e,zg}var Wg,eC;function BZ(){if(eC)return Wg;eC=1;var e=ki(),t=WI(),n=bi(),r=eO(),s=FZ(),o=x0(),l=1,u=2,d="[object Boolean]",h="[object Date]",f="[object Error]",p="[object Map]",g="[object Number]",v="[object RegExp]",k="[object Set]",b="[object String]",x="[object Symbol]",N="[object ArrayBuffer]",S="[object DataView]",_=e?e.prototype:void 0,E=_?_.valueOf:void 0;function T(A,R,B,P,D,I,O){switch(B){case S:if(A.byteLength!=R.byteLength||A.byteOffset!=R.byteOffset)return!1;A=A.buffer,R=R.buffer;case N:return!(A.byteLength!=R.byteLength||!I(new t(A),new t(R)));case d:case h:case g:return n(+A,+R);case f:return A.name==R.name&&A.message==R.message;case v:case b:return A==R+"";case p:var z=s;case k:var M=P&l;if(z||(z=o),A.size!=R.size&&!M)return!1;var $=O.get(A);if($)return $==R;P|=u,O.set(A,R);var q=r(z(A),z(R),P,D,I,O);return O.delete(A),q;case x:if(E)return E.call(A)==E.call(R)}return!1}return Wg=T,Wg}var Hg,tC;function qZ(){if(tC)return Hg;tC=1;var e=UI(),t=1,n=Object.prototype,r=n.hasOwnProperty;function s(o,l,u,d,h,f){var p=u&t,g=e(o),v=g.length,k=e(l),b=k.length;if(v!=b&&!p)return!1;for(var x=v;x--;){var N=g[x];if(!(p?N in l:r.call(l,N)))return!1}var S=f.get(o),_=f.get(l);if(S&&_)return S==l&&_==o;var E=!0;f.set(o,l),f.set(l,o);for(var T=p;++x<v;){N=g[x];var A=o[N],R=l[N];if(d)var B=p?d(R,A,N,l,o,f):d(A,R,N,o,l,f);if(!(B===void 0?A===R||h(A,R,u,d,f):B)){E=!1;break}T||(T=N=="constructor")}if(E&&!T){var P=o.constructor,D=l.constructor;P!=D&&"constructor"in o&&"constructor"in l&&!(typeof P=="function"&&P instanceof P&&typeof D=="function"&&D instanceof D)&&(E=!1)}return f.delete(o),f.delete(l),E}return Hg=s,Hg}var Vg,nC;function UZ(){if(nC)return Vg;nC=1;var e=rh(),t=eO(),n=BZ(),r=qZ(),s=ji(),o=Nt(),l=Ni(),u=uc(),d=1,h="[object Arguments]",f="[object Array]",p="[object Object]",g=Object.prototype,v=g.hasOwnProperty;function k(b,x,N,S,_,E){var T=o(b),A=o(x),R=T?f:s(b),B=A?f:s(x);R=R==h?p:R,B=B==h?p:B;var P=R==p,D=B==p,I=R==B;if(I&&l(b)){if(!l(x))return!1;T=!0,P=!1}if(I&&!P)return E||(E=new e),T||u(b)?t(b,x,N,S,_,E):n(b,x,R,N,S,_,E);if(!(N&d)){var O=P&&v.call(b,"__wrapped__"),z=D&&v.call(x,"__wrapped__");if(O||z){var M=O?b.value():b,$=z?x.value():x;return E||(E=new e),_(M,$,N,S,E)}}return I?(E||(E=new e),r(b,x,N,S,_,E)):!1}return Vg=k,Vg}var Gg,rC;function tO(){if(rC)return Gg;rC=1;var e=UZ(),t=qr();function n(r,s,o,l,u){return r===s?!0:r==null||s==null||!t(r)&&!t(s)?r!==r&&s!==s:e(r,s,o,l,n,u)}return Gg=n,Gg}var Kg,sC;function zZ(){if(sC)return Kg;sC=1;var e=rh(),t=tO(),n=1,r=2;function s(o,l,u,d){var h=u.length,f=h,p=!d;if(o==null)return!f;for(o=Object(o);h--;){var g=u[h];if(p&&g[2]?g[1]!==o[g[0]]:!(g[0]in o))return!1}for(;++h<f;){g=u[h];var v=g[0],k=o[v],b=g[1];if(p&&g[2]){if(k===void 0&&!(v in o))return!1}else{var x=new e;if(d)var N=d(k,b,v,o,l,x);if(!(N===void 0?t(b,k,n|r,d,x):N))return!1}}return!0}return Kg=s,Kg}var Yg,aC;function nO(){if(aC)return Yg;aC=1;var e=qn();function t(n){return n===n&&!e(n)}return Yg=t,Yg}var Xg,oC;function WZ(){if(oC)return Xg;oC=1;var e=nO(),t=ra();function n(r){for(var s=t(r),o=s.length;o--;){var l=s[o],u=r[l];s[o]=[l,u,e(u)]}return s}return Xg=n,Xg}var Zg,iC;function rO(){if(iC)return Zg;iC=1;function e(t,n){return function(r){return r==null?!1:r[t]===n&&(n!==void 0||t in Object(r))}}return Zg=e,Zg}var Jg,lC;function HZ(){if(lC)return Jg;lC=1;var e=zZ(),t=WZ(),n=rO();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 Jg=r,Jg}var Qg,cC;function Si(){if(cC)return Qg;cC=1;var e=Va(),t=qr(),n="[object Symbol]";function r(s){return typeof s=="symbol"||t(s)&&e(s)==n}return Qg=r,Qg}var ey,uC;function b0(){if(uC)return ey;uC=1;var e=Nt(),t=Si(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function s(o,l){if(e(o))return!1;var u=typeof o;return u=="number"||u=="symbol"||u=="boolean"||o==null||t(o)?!0:r.test(o)||!n.test(o)||l!=null&&o in Object(l)}return ey=s,ey}var ty,dC;function VZ(){if(dC)return ty;dC=1;var e=c0(),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,u=s?s.apply(this,l):l[0],d=o.cache;if(d.has(u))return d.get(u);var h=r.apply(this,l);return o.cache=d.set(u,h)||d,h};return o.cache=new(n.Cache||e),o}return n.Cache=e,ty=n,ty}var ny,hC;function GZ(){if(hC)return ny;hC=1;var e=VZ(),t=500;function n(r){var s=e(r,function(l){return o.size===t&&o.clear(),l}),o=s.cache;return s}return ny=n,ny}var ry,fC;function KZ(){if(fC)return ry;fC=1;var e=GZ(),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,u,d,h){o.push(d?h.replace(n,"$1"):u||l)}),o});return ry=r,ry}var sy,pC;function dh(){if(pC)return sy;pC=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 sy=e,sy}var ay,mC;function YZ(){if(mC)return ay;mC=1;var e=ki(),t=dh(),n=Nt(),r=Si(),s=e?e.prototype:void 0,o=s?s.toString:void 0;function l(u){if(typeof u=="string")return u;if(n(u))return t(u,l)+"";if(r(u))return o?o.call(u):"";var d=u+"";return d=="0"&&1/u==-1/0?"-0":d}return ay=l,ay}var oy,gC;function sO(){if(gC)return oy;gC=1;var e=YZ();function t(n){return n==null?"":e(n)}return oy=t,oy}var iy,yC;function hh(){if(yC)return iy;yC=1;var e=Nt(),t=b0(),n=KZ(),r=sO();function s(o,l){return e(o)?o:t(o,l)?[o]:n(r(o))}return iy=s,iy}var ly,wC;function dc(){if(wC)return ly;wC=1;var e=Si();function t(n){if(typeof n=="string"||e(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}return ly=t,ly}var cy,vC;function fh(){if(vC)return cy;vC=1;var e=hh(),t=dc();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 cy=n,cy}var uy,xC;function XZ(){if(xC)return uy;xC=1;var e=fh();function t(n,r,s){var o=n==null?void 0:e(n,r);return o===void 0?s:o}return uy=t,uy}var dy,bC;function ZZ(){if(bC)return dy;bC=1;function e(t,n){return t!=null&&n in Object(t)}return dy=e,dy}var hy,kC;function aO(){if(kC)return hy;kC=1;var e=hh(),t=cc(),n=Nt(),r=oh(),s=d0(),o=dc();function l(u,d,h){d=e(d,u);for(var f=-1,p=d.length,g=!1;++f<p;){var v=o(d[f]);if(!(g=u!=null&&h(u,v)))break;u=u[v]}return g||++f!=p?g:(p=u==null?0:u.length,!!p&&s(p)&&r(v,p)&&(n(u)||t(u)))}return hy=l,hy}var fy,NC;function oO(){if(NC)return fy;NC=1;var e=ZZ(),t=aO();function n(r,s){return r!=null&&t(r,s,e)}return fy=n,fy}var py,jC;function JZ(){if(jC)return py;jC=1;var e=tO(),t=XZ(),n=oO(),r=b0(),s=nO(),o=rO(),l=dc(),u=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,u|d)}}return py=h,py}var my,SC;function iO(){if(SC)return my;SC=1;function e(t){return function(n){return n==null?void 0:n[t]}}return my=e,my}var gy,_C;function QZ(){if(_C)return gy;_C=1;var e=fh();function t(n){return function(r){return e(r,n)}}return gy=t,gy}var yy,EC;function eJ(){if(EC)return yy;EC=1;var e=iO(),t=QZ(),n=b0(),r=dc();function s(o){return n(o)?e(r(o)):t(o)}return yy=s,yy}var wy,CC;function ms(){if(CC)return wy;CC=1;var e=HZ(),t=JZ(),n=Ya(),r=Nt(),s=eJ();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 wy=o,wy}var vy,TC;function lO(){if(TC)return vy;TC=1;var e=DI(),t=OZ(),n=ms(),r=Nt();function s(o,l){var u=r(o)?e:t;return u(o,n(l,3))}return vy=s,vy}var xy,AC;function tJ(){if(AC)return xy;AC=1;var e=Object.prototype,t=e.hasOwnProperty;function n(r,s){return r!=null&&t.call(r,s)}return xy=n,xy}var by,RC;function cO(){if(RC)return by;RC=1;var e=tJ(),t=aO();function n(r,s){return r!=null&&t(r,s,e)}return by=n,by}var ky,MC;function nJ(){if(MC)return ky;MC=1;var e=f0(),t=ji(),n=cc(),r=Nt(),s=ps(),o=Ni(),l=lh(),u=uc(),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)||u(v)||n(v)))return!v.length;var k=t(v);if(k==d||k==h)return!v.size;if(l(v))return!e(v).length;for(var b in v)if(p.call(v,b))return!1;return!0}return ky=g,ky}var Ny,$C;function uO(){if($C)return Ny;$C=1;function e(t){return t===void 0}return Ny=e,Ny}var jy,IC;function dO(){if(IC)return jy;IC=1;var e=uh(),t=ps();function n(r,s){var o=-1,l=t(r)?Array(r.length):[];return e(r,function(u,d,h){l[++o]=s(u,d,h)}),l}return jy=n,jy}var Sy,OC;function hO(){if(OC)return Sy;OC=1;var e=dh(),t=ms(),n=dO(),r=Nt();function s(o,l){var u=r(o)?e:n;return u(o,t(l,3))}return Sy=s,Sy}var _y,LC;function rJ(){if(LC)return _y;LC=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 _y=e,_y}var Ey,PC;function sJ(){if(PC)return Ey;PC=1;function e(t,n,r,s,o){return o(t,function(l,u,d){r=s?(s=!1,l):n(r,l,u,d)}),r}return Ey=e,Ey}var Cy,DC;function fO(){if(DC)return Cy;DC=1;var e=rJ(),t=uh(),n=ms(),r=sJ(),s=Nt();function o(l,u,d){var h=s(l)?e:r,f=arguments.length<3;return h(l,n(u,4),d,f,t)}return Cy=o,Cy}var Ty,FC;function aJ(){if(FC)return Ty;FC=1;var e=Va(),t=Nt(),n=qr(),r="[object String]";function s(o){return typeof o=="string"||!t(o)&&n(o)&&e(o)==r}return Ty=s,Ty}var Ay,BC;function oJ(){if(BC)return Ay;BC=1;var e=iO(),t=e("length");return Ay=t,Ay}var Ry,qC;function iJ(){if(qC)return Ry;qC=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",s=t+n+r,o="\\ufe0e\\ufe0f",l="\\u200d",u=RegExp("["+l+e+s+o+"]");function d(h){return u.test(h)}return Ry=d,Ry}var My,UC;function lJ(){if(UC)return My;UC=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",s=t+n+r,o="\\ufe0e\\ufe0f",l="["+e+"]",u="["+s+"]",d="\\ud83c[\\udffb-\\udfff]",h="(?:"+u+"|"+d+")",f="[^"+e+"]",p="(?:\\ud83c[\\udde6-\\uddff]){2}",g="[\\ud800-\\udbff][\\udc00-\\udfff]",v="\\u200d",k=h+"?",b="["+o+"]?",x="(?:"+v+"(?:"+[f,p,g].join("|")+")"+b+k+")*",N=b+k+x,S="(?:"+[f+u+"?",u,p,g,l].join("|")+")",_=RegExp(d+"(?="+d+")|"+S+N,"g");function E(T){for(var A=_.lastIndex=0;_.test(T);)++A;return A}return My=E,My}var $y,zC;function cJ(){if(zC)return $y;zC=1;var e=oJ(),t=iJ(),n=lJ();function r(s){return t(s)?n(s):e(s)}return $y=r,$y}var Iy,WC;function uJ(){if(WC)return Iy;WC=1;var e=f0(),t=ji(),n=ps(),r=aJ(),s=cJ(),o="[object Map]",l="[object Set]";function u(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 Iy=u,Iy}var Oy,HC;function dJ(){if(HC)return Oy;HC=1;var e=u0(),t=VI(),n=v0(),r=ms(),s=ch(),o=Nt(),l=Ni(),u=ic(),d=qn(),h=uc();function f(p,g,v){var k=o(p),b=k||l(p)||h(p);if(g=r(g,4),v==null){var x=p&&p.constructor;b?v=k?new x:[]:d(p)?v=u(x)?t(s(p)):{}:v={}}return(b?e:n)(p,function(N,S,_){return g(v,N,S,_)}),v}return Oy=f,Oy}var Ly,VC;function hJ(){if(VC)return Ly;VC=1;var e=ki(),t=cc(),n=Nt(),r=e?e.isConcatSpreadable:void 0;function s(o){return n(o)||t(o)||!!(r&&o&&o[r])}return Ly=s,Ly}var Py,GC;function k0(){if(GC)return Py;GC=1;var e=m0(),t=hJ();function n(r,s,o,l,u){var d=-1,h=r.length;for(o||(o=t),u||(u=[]);++d<h;){var f=r[d];s>0&&o(f)?s>1?n(f,s-1,o,l,u):e(u,f):l||(u[u.length]=f)}return u}return Py=n,Py}var Dy,KC;function fJ(){if(KC)return Dy;KC=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 Dy=e,Dy}var Fy,YC;function pO(){if(YC)return Fy;YC=1;var e=fJ(),t=Math.max;function n(r,s,o){return s=t(s===void 0?r.length-1:s,0),function(){for(var l=arguments,u=-1,d=t(l.length-s,0),h=Array(d);++u<d;)h[u]=l[s+u];u=-1;for(var f=Array(s+1);++u<s;)f[u]=l[u];return f[s]=o(h),e(r,this,f)}}return Fy=n,Fy}var By,XC;function pJ(){if(XC)return By;XC=1;var e=y0(),t=$I(),n=Ya(),r=t?function(s,o){return t(s,"toString",{configurable:!0,enumerable:!1,value:e(o),writable:!0})}:n;return By=r,By}var qy,ZC;function mJ(){if(ZC)return qy;ZC=1;var e=800,t=16,n=Date.now;function r(s){var o=0,l=0;return function(){var u=n(),d=t-(u-l);if(l=u,d>0){if(++o>=e)return arguments[0]}else o=0;return s.apply(void 0,arguments)}}return qy=r,qy}var Uy,JC;function mO(){if(JC)return Uy;JC=1;var e=pJ(),t=mJ(),n=t(e);return Uy=n,Uy}var zy,QC;function ph(){if(QC)return zy;QC=1;var e=Ya(),t=pO(),n=mO();function r(s,o){return n(t(s,o,e),s+"")}return zy=r,zy}var Wy,eT;function gO(){if(eT)return Wy;eT=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 Wy=e,Wy}var Hy,tT;function gJ(){if(tT)return Hy;tT=1;function e(t){return t!==t}return Hy=e,Hy}var Vy,nT;function yJ(){if(nT)return Vy;nT=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 Vy=e,Vy}var Gy,rT;function wJ(){if(rT)return Gy;rT=1;var e=gO(),t=gJ(),n=yJ();function r(s,o,l){return o===o?n(s,o,l):e(s,t,l)}return Gy=r,Gy}var Ky,sT;function vJ(){if(sT)return Ky;sT=1;var e=wJ();function t(n,r){var s=n==null?0:n.length;return!!s&&e(n,r,0)>-1}return Ky=t,Ky}var Yy,aT;function xJ(){if(aT)return Yy;aT=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 Yy=e,Yy}var Xy,oT;function bJ(){if(oT)return Xy;oT=1;function e(){}return Xy=e,Xy}var Zy,iT;function kJ(){if(iT)return Zy;iT=1;var e=zI(),t=bJ(),n=x0(),r=1/0,s=e&&1/n(new e([,-0]))[1]==r?function(o){return new e(o)}:t;return Zy=s,Zy}var Jy,lT;function NJ(){if(lT)return Jy;lT=1;var e=JI(),t=vJ(),n=xJ(),r=QI(),s=kJ(),o=x0(),l=200;function u(d,h,f){var p=-1,g=t,v=d.length,k=!0,b=[],x=b;if(f)k=!1,g=n;else if(v>=l){var N=h?null:s(d);if(N)return o(N);k=!1,g=r,x=new e}else x=h?[]:b;e:for(;++p<v;){var S=d[p],_=h?h(S):S;if(S=f||S!==0?S:0,k&&_===_){for(var E=x.length;E--;)if(x[E]===_)continue e;h&&x.push(_),b.push(S)}else g(x,_,f)||(x!==b&&x.push(_),b.push(S))}return b}return Jy=u,Jy}var Qy,cT;function yO(){if(cT)return Qy;cT=1;var e=ps(),t=qr();function n(r){return t(r)&&e(r)}return Qy=n,Qy}var ew,uT;function jJ(){if(uT)return ew;uT=1;var e=k0(),t=ph(),n=NJ(),r=yO(),s=t(function(o){return n(e(o,1,r,!0))});return ew=s,ew}var tw,dT;function SJ(){if(dT)return tw;dT=1;var e=dh();function t(n,r){return e(r,function(s){return n[s]})}return tw=t,tw}var nw,hT;function wO(){if(hT)return nw;hT=1;var e=SJ(),t=ra();function n(r){return r==null?[]:e(r,t(r))}return nw=n,nw}var rw,fT;function Un(){if(fT)return rw;fT=1;var e;if(typeof i0=="function")try{e={clone:MZ(),constant:y0(),each:ZI(),filter:lO(),has:cO(),isArray:Nt(),isEmpty:nJ(),isFunction:ic(),isUndefined:uO(),keys:ra(),map:hO(),reduce:fO(),size:uJ(),transform:dJ(),union:jJ(),values:wO()}}catch{}return e||(e=window._),rw=e,rw}var sw,pT;function N0(){if(pT)return sw;pT=1;var e=Un();sw=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(k){g.length>1?v.setNode(k,p):v.setNode(k)}),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(b,x){f(x)&&p.setNode(x,b)}),e.each(this._edgeObjs,function(b){p.hasNode(b.v)&&p.hasNode(b.w)&&p.setEdge(b,g.edge(b))});var v={};function k(b){var x=g.parent(b);return x===void 0||p.hasNode(x)?(v[b]=x,x):x in v?v[x]:k(x)}return this._isCompound&&e.each(p.nodes(),function(b){p.setParent(b,k(b))}),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(k,b){return v.length>1?g.setEdge(k,b,p):g.setEdge(k,b),b}),this},s.prototype.setEdge=function(){var f,p,g,v,k=!1,b=arguments[0];typeof b=="object"&&b!==null&&"v"in b?(f=b.v,p=b.w,g=b.name,arguments.length===2&&(v=arguments[1],k=!0)):(f=b,p=arguments[1],g=arguments[3],arguments.length>2&&(v=arguments[2],k=!0)),f=""+f,p=""+p,e.isUndefined(g)||(g=""+g);var x=u(this._isDirected,f,p,g);if(e.has(this._edgeLabels,x))return k&&(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]=k?v:this._defaultEdgeLabelFn(f,p,g);var N=d(this._isDirected,f,p,g);return f=N.v,p=N.w,Object.freeze(N),this._edgeObjs[x]=N,o(this._preds[p],f),o(this._sucs[f],p),this._in[p][x]=N,this._out[f][x]=N,this._edgeCount++,this},s.prototype.edge=function(f,p,g){var v=arguments.length===1?h(this._isDirected,arguments[0]):u(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]):u(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]):u(this._isDirected,f,p,g),k=this._edgeObjs[v];return k&&(f=k.v,p=k.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(k){return k.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(k){return k.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 u(f,p,g,v){var k=""+p,b=""+g;if(!f&&k>b){var x=k;k=b,b=x}return k+r+b+r+(e.isUndefined(v)?t:v)}function d(f,p,g,v){var k=""+p,b=""+g;if(!f&&k>b){var x=k;k=b,b=x}var N={v:k,w:b};return v&&(N.name=v),N}function h(f,p){return u(f,p.v,p.w,p.name)}return sw}var aw,mT;function _J(){return mT||(mT=1,aw="2.1.8"),aw}var ow,gT;function EJ(){return gT||(gT=1,ow={Graph:N0(),version:_J()}),ow}var iw,yT;function CJ(){if(yT)return iw;yT=1;var e=Un(),t=N0();iw={write:n,read:o};function n(l){var u={options:{directed:l.isDirected(),multigraph:l.isMultigraph(),compound:l.isCompound()},nodes:r(l),edges:s(l)};return e.isUndefined(l.graph())||(u.value=e.clone(l.graph())),u}function r(l){return e.map(l.nodes(),function(u){var d=l.node(u),h=l.parent(u),f={v:u};return e.isUndefined(d)||(f.value=d),e.isUndefined(h)||(f.parent=h),f})}function s(l){return e.map(l.edges(),function(u){var d=l.edge(u),h={v:u.v,w:u.w};return e.isUndefined(u.name)||(h.name=u.name),e.isUndefined(d)||(h.value=d),h})}function o(l){var u=new t(l.options).setGraph(l.value);return e.each(l.nodes,function(d){u.setNode(d.v,d.value),d.parent&&u.setParent(d.v,d.parent)}),e.each(l.edges,function(d){u.setEdge({v:d.v,w:d.w,name:d.name},d.value)}),u}return iw}var lw,wT;function TJ(){if(wT)return lw;wT=1;var e=Un();lw=t;function t(n){var r={},s=[],o;function l(u){e.has(r,u)||(r[u]=!0,o.push(u),e.each(n.successors(u),l),e.each(n.predecessors(u),l))}return e.each(n.nodes(),function(u){o=[],l(u),o.length&&s.push(o)}),s}return lw}var cw,vT;function vO(){if(vT)return cw;vT=1;var e=Un();cw=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],u=s[r];s[n]=u,s[r]=l,o[u.key]=n,o[l.key]=r},cw}var uw,xT;function xO(){if(xT)return uw;xT=1;var e=Un(),t=vO();uw=r;var n=e.constant(1);function r(o,l,u,d){return s(o,String(l),u||n,d||function(h){return o.outEdges(h)})}function s(o,l,u,d){var h={},f=new t,p,g,v=function(k){var b=k.v!==p?k.v:k.w,x=h[b],N=u(k),S=g.distance+N;if(N<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+k+" Weight: "+N);S<x.distance&&(x.distance=S,x.predecessor=p,f.decrease(b,S))};for(o.nodes().forEach(function(k){var b=k===l?0:Number.POSITIVE_INFINITY;h[k]={distance:b},f.add(k,b)});f.size()>0&&(p=f.removeMin(),g=h[p],g.distance!==Number.POSITIVE_INFINITY);)d(p).forEach(v);return h}return uw}var dw,bT;function AJ(){if(bT)return dw;bT=1;var e=xO(),t=Un();dw=n;function n(r,s,o){return t.transform(r.nodes(),function(l,u){l[u]=e(r,u,s,o)},{})}return dw}var hw,kT;function bO(){if(kT)return hw;kT=1;var e=Un();hw=t;function t(n){var r=0,s=[],o={},l=[];function u(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)):(u(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)||u(d)}),l}return hw}var fw,NT;function RJ(){if(NT)return fw;NT=1;var e=Un(),t=bO();fw=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 fw}var pw,jT;function MJ(){if(jT)return pw;jT=1;var e=Un();pw=n;var t=e.constant(1);function n(s,o,l){return r(s,o||t,l||function(u){return s.outEdges(u)})}function r(s,o,l){var u={},d=s.nodes();return d.forEach(function(h){u[h]={},u[h][h]={distance:0},d.forEach(function(f){h!==f&&(u[h][f]={distance:Number.POSITIVE_INFINITY})}),l(h).forEach(function(f){var p=f.v===h?f.w:f.v,g=o(f);u[h][p]={distance:g,predecessor:h}})}),d.forEach(function(h){var f=u[h];d.forEach(function(p){var g=u[p];d.forEach(function(v){var k=g[h],b=f[v],x=g[v],N=k.distance+b.distance;N<x.distance&&(x.distance=N,x.predecessor=b.predecessor)})})}),u}return pw}var mw,ST;function kO(){if(ST)return mw;ST=1;var e=Un();mw=t,t.CycleException=n;function t(r){var s={},o={},l=[];function u(d){if(e.has(o,d))throw new n;e.has(s,d)||(o[d]=!0,s[d]=!0,e.each(r.predecessors(d),u),delete o[d],l.push(d))}if(e.each(r.sinks(),u),e.size(s)!==r.nodeCount())throw new n;return l}function n(){}return n.prototype=new Error,mw}var gw,_T;function $J(){if(_T)return gw;_T=1;var e=kO();gw=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return gw}var yw,ET;function NO(){if(ET)return yw;ET=1;var e=Un();yw=t;function t(r,s,o){e.isArray(s)||(s=[s]);var l=(r.isDirected()?r.successors:r.neighbors).bind(r),u=[],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,u)}),u}function n(r,s,o,l,u,d){e.has(l,s)||(l[s]=!0,o||d.push(s),e.each(u(s),function(h){n(r,h,o,l,u,d)}),o&&d.push(s))}return yw}var ww,CT;function IJ(){if(CT)return ww;CT=1;var e=NO();ww=t;function t(n,r){return e(n,r,"post")}return ww}var vw,TT;function OJ(){if(TT)return vw;TT=1;var e=NO();vw=t;function t(n,r){return e(n,r,"pre")}return vw}var xw,AT;function LJ(){if(AT)return xw;AT=1;var e=Un(),t=N0(),n=vO();xw=r;function r(s,o){var l=new t,u={},d=new n,h;function f(g){var v=g.v===h?g.w:g.v,k=d.priority(v);if(k!==void 0){var b=o(g);b<k&&(u[v]=h,d.decrease(v,b))}}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(u,h))l.setEdge(h,u[h]);else{if(p)throw new Error("Input graph is not connected: "+s);p=!0}s.nodeEdges(h).forEach(f)}return l}return xw}var bw,RT;function PJ(){return RT||(RT=1,bw={components:TJ(),dijkstra:xO(),dijkstraAll:AJ(),findCycles:RJ(),floydWarshall:MJ(),isAcyclic:$J(),postorder:IJ(),preorder:OJ(),prim:LJ(),tarjan:bO(),topsort:kO()}),bw}var kw,MT;function DJ(){if(MT)return kw;MT=1;var e=EJ();return kw={Graph:e.Graph,json:CJ(),alg:PJ(),version:e.version},kw}var Nw,$T;function hr(){if($T)return Nw;$T=1;var e;if(typeof i0=="function")try{e=DJ()}catch{}return e||(e=window.graphlib),Nw=e,Nw}var jw,IT;function FJ(){if(IT)return jw;IT=1;var e=KI(),t=1,n=4;function r(s){return e(s,t|n)}return jw=r,jw}var Sw,OT;function mh(){if(OT)return Sw;OT=1;var e=bi(),t=ps(),n=oh(),r=qn();function s(o,l,u){if(!r(u))return!1;var d=typeof l;return(d=="number"?t(u)&&n(l,u.length):d=="string"&&l in u)?e(u[l],o):!1}return Sw=s,Sw}var _w,LT;function BJ(){if(LT)return _w;LT=1;var e=ph(),t=bi(),n=mh(),r=Ka(),s=Object.prototype,o=s.hasOwnProperty,l=e(function(u,d){u=Object(u);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),k=-1,b=v.length;++k<b;){var x=v[k],N=u[x];(N===void 0||t(N,s[x])&&!o.call(u,x))&&(u[x]=g[x])}return u});return _w=l,_w}var Ew,PT;function qJ(){if(PT)return Ew;PT=1;var e=ms(),t=ps(),n=ra();function r(s){return function(o,l,u){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,u);return f>-1?d[h?o[f]:f]:void 0}}return Ew=r,Ew}var Cw,DT;function UJ(){if(DT)return Cw;DT=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return Cw=t,Cw}var Tw,FT;function zJ(){if(FT)return Tw;FT=1;var e=UJ(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return Tw=n,Tw}var Aw,BT;function WJ(){if(BT)return Aw;BT=1;var e=zJ(),t=qn(),n=Si(),r=NaN,s=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,l=/^0o[0-7]+$/i,u=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)?u(h.slice(2),p?2:8):s.test(h)?r:+h}return Aw=d,Aw}var Rw,qT;function jO(){if(qT)return Rw;qT=1;var e=WJ(),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 Rw=r,Rw}var Mw,UT;function HJ(){if(UT)return Mw;UT=1;var e=jO();function t(n){var r=e(n),s=r%1;return r===r?s?r-s:r:0}return Mw=t,Mw}var $w,zT;function VJ(){if(zT)return $w;zT=1;var e=gO(),t=ms(),n=HJ(),r=Math.max;function s(o,l,u){var d=o==null?0:o.length;if(!d)return-1;var h=u==null?0:n(u);return h<0&&(h=r(d+h,0)),e(o,t(l,3),h)}return $w=s,$w}var Iw,WT;function GJ(){if(WT)return Iw;WT=1;var e=qJ(),t=VJ(),n=e(t);return Iw=n,Iw}var Ow,HT;function SO(){if(HT)return Ow;HT=1;var e=k0();function t(n){var r=n==null?0:n.length;return r?e(n,1):[]}return Ow=t,Ow}var Lw,VT;function KJ(){if(VT)return Lw;VT=1;var e=w0(),t=YI(),n=Ka();function r(s,o){return s==null?s:e(s,t(o),n)}return Lw=r,Lw}var Pw,GT;function YJ(){if(GT)return Pw;GT=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return Pw=e,Pw}var Dw,KT;function XJ(){if(KT)return Dw;KT=1;var e=sh(),t=v0(),n=ms();function r(s,o){var l={};return o=n(o,3),t(s,function(u,d,h){e(l,d,o(u,d,h))}),l}return Dw=r,Dw}var Fw,YT;function j0(){if(YT)return Fw;YT=1;var e=Si();function t(n,r,s){for(var o=-1,l=n.length;++o<l;){var u=n[o],d=r(u);if(d!=null&&(h===void 0?d===d&&!e(d):s(d,h)))var h=d,f=u}return f}return Fw=t,Fw}var Bw,XT;function ZJ(){if(XT)return Bw;XT=1;function e(t,n){return t>n}return Bw=e,Bw}var qw,ZT;function JJ(){if(ZT)return qw;ZT=1;var e=j0(),t=ZJ(),n=Ya();function r(s){return s&&s.length?e(s,n,t):void 0}return qw=r,qw}var Uw,JT;function _O(){if(JT)return Uw;JT=1;var e=sh(),t=bi();function n(r,s,o){(o!==void 0&&!t(r[s],o)||o===void 0&&!(s in r))&&e(r,s,o)}return Uw=n,Uw}var zw,QT;function QJ(){if(QT)return zw;QT=1;var e=Va(),t=ch(),n=qr(),r="[object Object]",s=Function.prototype,o=Object.prototype,l=s.toString,u=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=u.call(p,"constructor")&&p.constructor;return typeof g=="function"&&g instanceof g&&l.call(g)==d}return zw=h,zw}var Ww,eA;function EO(){if(eA)return Ww;eA=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return Ww=e,Ww}var Hw,tA;function eQ(){if(tA)return Hw;tA=1;var e=lc(),t=Ka();function n(r){return e(r,t(r))}return Hw=n,Hw}var Vw,nA;function tQ(){if(nA)return Vw;nA=1;var e=_O(),t=LI(),n=HI(),r=PI(),s=GI(),o=cc(),l=Nt(),u=yO(),d=Ni(),h=ic(),f=qn(),p=QJ(),g=uc(),v=EO(),k=eQ();function b(x,N,S,_,E,T,A){var R=v(x,S),B=v(N,S),P=A.get(B);if(P){e(x,S,P);return}var D=T?T(R,B,S+"",x,N,A):void 0,I=D===void 0;if(I){var O=l(B),z=!O&&d(B),M=!O&&!z&&g(B);D=B,O||z||M?l(R)?D=R:u(R)?D=r(R):z?(I=!1,D=t(B,!0)):M?(I=!1,D=n(B,!0)):D=[]:p(B)||o(B)?(D=R,o(R)?D=k(R):(!f(R)||h(R))&&(D=s(B))):I=!1}I&&(A.set(B,D),E(D,B,_,T,A),A.delete(B)),e(x,S,D)}return Vw=b,Vw}var Gw,rA;function nQ(){if(rA)return Gw;rA=1;var e=rh(),t=_O(),n=w0(),r=tQ(),s=qn(),o=Ka(),l=EO();function u(d,h,f,p,g){d!==h&&n(h,function(v,k){if(g||(g=new e),s(v))r(d,h,k,f,u,p,g);else{var b=p?p(l(d,k),v,k+"",d,h,g):void 0;b===void 0&&(b=v),t(d,k,b)}},o)}return Gw=u,Gw}var Kw,sA;function rQ(){if(sA)return Kw;sA=1;var e=ph(),t=mh();function n(r){return e(function(s,o){var l=-1,u=o.length,d=u>1?o[u-1]:void 0,h=u>2?o[2]:void 0;for(d=r.length>3&&typeof d=="function"?(u--,d):void 0,h&&t(o[0],o[1],h)&&(d=u<3?void 0:d,u=1),s=Object(s);++l<u;){var f=o[l];f&&r(s,f,l,d)}return s})}return Kw=n,Kw}var Yw,aA;function sQ(){if(aA)return Yw;aA=1;var e=nQ(),t=rQ(),n=t(function(r,s,o){e(r,s,o)});return Yw=n,Yw}var Xw,oA;function CO(){if(oA)return Xw;oA=1;function e(t,n){return t<n}return Xw=e,Xw}var Zw,iA;function aQ(){if(iA)return Zw;iA=1;var e=j0(),t=CO(),n=Ya();function r(s){return s&&s.length?e(s,n,t):void 0}return Zw=r,Zw}var Jw,lA;function oQ(){if(lA)return Jw;lA=1;var e=j0(),t=ms(),n=CO();function r(s,o){return s&&s.length?e(s,t(o,2),n):void 0}return Jw=r,Jw}var Qw,cA;function iQ(){if(cA)return Qw;cA=1;var e=mr(),t=function(){return e.Date.now()};return Qw=t,Qw}var ev,uA;function lQ(){if(uA)return ev;uA=1;var e=ah(),t=hh(),n=oh(),r=qn(),s=dc();function o(l,u,d,h){if(!r(l))return l;u=t(u,l);for(var f=-1,p=u.length,g=p-1,v=l;v!=null&&++f<p;){var k=s(u[f]),b=d;if(k==="__proto__"||k==="constructor"||k==="prototype")return l;if(f!=g){var x=v[k];b=h?h(x,k,v):void 0,b===void 0&&(b=r(x)?x:n(u[f+1])?[]:{})}e(v,k,b),v=v[k]}return l}return ev=o,ev}var tv,dA;function cQ(){if(dA)return tv;dA=1;var e=fh(),t=lQ(),n=hh();function r(s,o,l){for(var u=-1,d=o.length,h={};++u<d;){var f=o[u],p=e(s,f);l(p,f)&&t(h,n(f,s),p)}return h}return tv=r,tv}var nv,hA;function uQ(){if(hA)return nv;hA=1;var e=cQ(),t=oO();function n(r,s){return e(r,s,function(o,l){return t(r,l)})}return nv=n,nv}var rv,fA;function dQ(){if(fA)return rv;fA=1;var e=SO(),t=pO(),n=mO();function r(s){return n(t(s,void 0,e),s+"")}return rv=r,rv}var sv,pA;function hQ(){if(pA)return sv;pA=1;var e=uQ(),t=dQ(),n=t(function(r,s){return r==null?{}:e(r,s)});return sv=n,sv}var av,mA;function fQ(){if(mA)return av;mA=1;var e=Math.ceil,t=Math.max;function n(r,s,o,l){for(var u=-1,d=t(e((s-r)/(o||1)),0),h=Array(d);d--;)h[l?d:++u]=r,r+=o;return h}return av=n,av}var ov,gA;function pQ(){if(gA)return ov;gA=1;var e=fQ(),t=mh(),n=jO();function r(s){return function(o,l,u){return u&&typeof u!="number"&&t(o,l,u)&&(l=u=void 0),o=n(o),l===void 0?(l=o,o=0):l=n(l),u=u===void 0?o<l?1:-1:n(u),e(o,l,u,s)}}return ov=r,ov}var iv,yA;function mQ(){if(yA)return iv;yA=1;var e=pQ(),t=e();return iv=t,iv}var lv,wA;function gQ(){if(wA)return lv;wA=1;function e(t,n){var r=t.length;for(t.sort(n);r--;)t[r]=t[r].value;return t}return lv=e,lv}var cv,vA;function yQ(){if(vA)return cv;vA=1;var e=Si();function t(n,r){if(n!==r){var s=n!==void 0,o=n===null,l=n===n,u=e(n),d=r!==void 0,h=r===null,f=r===r,p=e(r);if(!h&&!p&&!u&&n>r||u&&d&&f&&!h&&!p||o&&d&&f||!s&&f||!l)return 1;if(!o&&!u&&!p&&n<r||p&&s&&l&&!o&&!u||h&&s&&l||!d&&l||!f)return-1}return 0}return cv=t,cv}var uv,xA;function wQ(){if(xA)return uv;xA=1;var e=yQ();function t(n,r,s){for(var o=-1,l=n.criteria,u=r.criteria,d=l.length,h=s.length;++o<d;){var f=e(l[o],u[o]);if(f){if(o>=h)return f;var p=s[o];return f*(p=="desc"?-1:1)}}return n.index-r.index}return uv=t,uv}var dv,bA;function vQ(){if(bA)return dv;bA=1;var e=dh(),t=fh(),n=ms(),r=dO(),s=gQ(),o=ih(),l=wQ(),u=Ya(),d=Nt();function h(f,p,g){p.length?p=e(p,function(b){return d(b)?function(x){return t(x,b.length===1?b[0]:b)}:b}):p=[u];var v=-1;p=e(p,o(n));var k=r(f,function(b,x,N){var S=e(p,function(_){return _(b)});return{criteria:S,index:++v,value:b}});return s(k,function(b,x){return l(b,x,g)})}return dv=h,dv}var hv,kA;function xQ(){if(kA)return hv;kA=1;var e=k0(),t=vQ(),n=ph(),r=mh(),s=n(function(o,l){if(o==null)return[];var u=l.length;return u>1&&r(o,l[0],l[1])?l=[]:u>2&&r(l[0],l[1],l[2])&&(l=[l[0]]),t(o,e(l,1),[])});return hv=s,hv}var fv,NA;function bQ(){if(NA)return fv;NA=1;var e=sO(),t=0;function n(r){var s=++t;return e(r)+s}return fv=n,fv}var pv,jA;function kQ(){if(jA)return pv;jA=1;function e(t,n,r){for(var s=-1,o=t.length,l=n.length,u={};++s<o;){var d=s<l?n[s]:void 0;r(u,t[s],d)}return u}return pv=e,pv}var mv,SA;function NQ(){if(SA)return mv;SA=1;var e=ah(),t=kQ();function n(r,s){return t(r||[],s||[],e)}return mv=n,mv}var gv,_A;function ut(){if(_A)return gv;_A=1;var e;if(typeof i0=="function")try{e={cloneDeep:FJ(),constant:y0(),defaults:BJ(),each:ZI(),filter:lO(),find:GJ(),flatten:SO(),forEach:XI(),forIn:KJ(),has:cO(),isUndefined:uO(),last:YJ(),map:hO(),mapValues:XJ(),max:JJ(),merge:sQ(),min:aQ(),minBy:oQ(),now:iQ(),pick:hQ(),range:mQ(),reduce:fO(),sortBy:xQ(),uniqueId:bQ(),values:wO(),zipObject:NQ()}}catch{}return e||(e=window._),gv=e,gv}var yv,EA;function jQ(){if(EA)return yv;EA=1,yv=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 yv}var wv,CA;function SQ(){if(CA)return wv;CA=1;var e=ut(),t=hr().Graph,n=jQ();wv=s;var r=e.constant(1);function s(h,f){if(h.nodeCount()<=1)return[];var p=u(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],k=f[0],b;h.nodeCount();){for(;b=k.dequeue();)l(h,f,p,b);for(;b=v.dequeue();)l(h,f,p,b);if(h.nodeCount()){for(var x=f.length-2;x>0;--x)if(b=f[x].dequeue(),b){g=g.concat(l(h,f,p,b,!0));break}}}return g}function l(h,f,p,g,v){var k=v?[]:void 0;return e.forEach(h.inEdges(g.v),function(b){var x=h.edge(b),N=h.node(b.v);v&&k.push({v:b.v,w:b.w}),N.out-=x,d(f,p,N)}),e.forEach(h.outEdges(g.v),function(b){var x=h.edge(b),N=b.w,S=h.node(N);S.in-=x,d(f,p,S)}),h.removeNode(g.v),k}function u(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 N=p.edge(x.v,x.w)||0,S=f(x),_=N+S;p.setEdge(x.v,x.w,_),v=Math.max(v,p.node(x.v).out+=S),g=Math.max(g,p.node(x.w).in+=S)});var k=e.range(v+g+3).map(function(){return new n}),b=g+1;return e.forEach(p.nodes(),function(x){d(k,b,p.node(x))}),{graph:p,buckets:k,zeroIdx:b}}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 wv}var vv,TA;function _Q(){if(TA)return vv;TA=1;var e=ut(),t=SQ();vv={run:n,undo:s};function n(o){var l=o.graph().acyclicer==="greedy"?t(o,u(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 u(d){return function(h){return d.edge(h).weight}}}function r(o){var l=[],u={},d={};function h(f){e.has(d,f)||(d[f]=!0,u[f]=!0,e.forEach(o.outEdges(f),function(p){e.has(u,p.w)?l.push(p):h(p.w)}),delete u[f])}return e.forEach(o.nodes(),h),l}function s(o){e.forEach(o.edges(),function(l){var u=o.edge(l);if(u.reversed){o.removeEdge(l);var d=u.forwardName;delete u.reversed,delete u.forwardName,o.setEdge(l.w,l.v,u,d)}})}return vv}var xv,AA;function hn(){if(AA)return xv;AA=1;var e=ut(),t=hr().Graph;xv={addDummyNode:n,simplify:r,asNonCompoundGraph:s,successorWeights:o,predecessorWeights:l,intersectRect:u,buildLayerMatrix:d,normalizeRanks:h,removeEmptyRanks:f,addBorderNode:p,maxRank:g,partition:v,time:k,notime:b};function n(x,N,S,_){var E;do E=e.uniqueId(_);while(x.hasNode(E));return S.dummy=N,x.setNode(E,S),E}function r(x){var N=new t().setGraph(x.graph());return e.forEach(x.nodes(),function(S){N.setNode(S,x.node(S))}),e.forEach(x.edges(),function(S){var _=N.edge(S.v,S.w)||{weight:0,minlen:1},E=x.edge(S);N.setEdge(S.v,S.w,{weight:_.weight+E.weight,minlen:Math.max(_.minlen,E.minlen)})}),N}function s(x){var N=new t({multigraph:x.isMultigraph()}).setGraph(x.graph());return e.forEach(x.nodes(),function(S){x.children(S).length||N.setNode(S,x.node(S))}),e.forEach(x.edges(),function(S){N.setEdge(S,x.edge(S))}),N}function o(x){var N=e.map(x.nodes(),function(S){var _={};return e.forEach(x.outEdges(S),function(E){_[E.w]=(_[E.w]||0)+x.edge(E).weight}),_});return e.zipObject(x.nodes(),N)}function l(x){var N=e.map(x.nodes(),function(S){var _={};return e.forEach(x.inEdges(S),function(E){_[E.v]=(_[E.v]||0)+x.edge(E).weight}),_});return e.zipObject(x.nodes(),N)}function u(x,N){var S=x.x,_=x.y,E=N.x-S,T=N.y-_,A=x.width/2,R=x.height/2;if(!E&&!T)throw new Error("Not possible to find intersection inside of the rectangle");var B,P;return Math.abs(T)*A>Math.abs(E)*R?(T<0&&(R=-R),B=R*E/T,P=R):(E<0&&(A=-A),B=A,P=A*T/E),{x:S+B,y:_+P}}function d(x){var N=e.map(e.range(g(x)+1),function(){return[]});return e.forEach(x.nodes(),function(S){var _=x.node(S),E=_.rank;e.isUndefined(E)||(N[E][_.order]=S)}),N}function h(x){var N=e.min(e.map(x.nodes(),function(S){return x.node(S).rank}));e.forEach(x.nodes(),function(S){var _=x.node(S);e.has(_,"rank")&&(_.rank-=N)})}function f(x){var N=e.min(e.map(x.nodes(),function(T){return x.node(T).rank})),S=[];e.forEach(x.nodes(),function(T){var A=x.node(T).rank-N;S[A]||(S[A]=[]),S[A].push(T)});var _=0,E=x.graph().nodeRankFactor;e.forEach(S,function(T,A){e.isUndefined(T)&&A%E!==0?--_:_&&e.forEach(T,function(R){x.node(R).rank+=_})})}function p(x,N,S,_){var E={width:0,height:0};return arguments.length>=4&&(E.rank=S,E.order=_),n(x,"border",E,N)}function g(x){return e.max(e.map(x.nodes(),function(N){var S=x.node(N).rank;if(!e.isUndefined(S))return S}))}function v(x,N){var S={lhs:[],rhs:[]};return e.forEach(x,function(_){N(_)?S.lhs.push(_):S.rhs.push(_)}),S}function k(x,N){var S=e.now();try{return N()}finally{console.log(x+" time: "+(e.now()-S)+"ms")}}function b(x,N){return N()}return xv}var bv,RA;function EQ(){if(RA)return bv;RA=1;var e=ut(),t=hn();bv={run:n,undo:s};function n(o){o.graph().dummyChains=[],e.forEach(o.edges(),function(l){r(o,l)})}function r(o,l){var u=l.v,d=o.node(u).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 k,b,x;for(x=0,++d;d<f;++x,++d)g.points=[],b={width:0,height:0,edgeLabel:g,edgeObj:l,rank:d},k=t.addDummyNode(o,"edge",b,"_d"),d===v&&(b.width=g.width,b.height=g.height,b.dummy="edge-label",b.labelpos=g.labelpos),o.setEdge(u,k,{weight:g.weight},p),x===0&&o.graph().dummyChains.push(k),u=k;o.setEdge(u,h,{weight:g.weight},p)}}function s(o){e.forEach(o.graph().dummyChains,function(l){var u=o.node(l),d=u.edgeLabel,h;for(o.setEdge(u.edgeObj,d);u.dummy;)h=o.successors(l)[0],o.removeNode(l),d.points.push({x:u.x,y:u.y}),u.dummy==="edge-label"&&(d.x=u.x,d.y=u.y,d.width=u.width,d.height=u.height),l=h,u=o.node(l)})}return bv}var kv,MA;function xd(){if(MA)return kv;MA=1;var e=ut();kv={longestPath:t,slack:n};function t(r){var s={};function o(l){var u=r.node(l);if(e.has(s,l))return u.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),u.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 kv}var Nv,$A;function TO(){if($A)return Nv;$A=1;var e=ut(),t=hr().Graph,n=xd().slack;Nv=r;function r(u){var d=new t({directed:!1}),h=u.nodes()[0],f=u.nodeCount();d.setNode(h,{});for(var p,g;s(d,u)<f;)p=o(d,u),g=d.hasNode(p.v)?n(u,p):-n(u,p),l(d,u,g);return d}function s(u,d){function h(f){e.forEach(d.nodeEdges(f),function(p){var g=p.v,v=f===g?p.w:g;!u.hasNode(v)&&!n(d,p)&&(u.setNode(v,{}),u.setEdge(f,v,{}),h(v))})}return e.forEach(u.nodes(),h),u.nodeCount()}function o(u,d){return e.minBy(d.edges(),function(h){if(u.hasNode(h.v)!==u.hasNode(h.w))return n(d,h)})}function l(u,d,h){e.forEach(u.nodes(),function(f){d.node(f).rank+=h})}return Nv}var jv,IA;function CQ(){if(IA)return jv;IA=1;var e=ut(),t=TO(),n=xd().slack,r=xd().longestPath,s=hr().alg.preorder,o=hr().alg.postorder,l=hn().simplify;jv=u,u.initLowLimValues=p,u.initCutValues=d,u.calcCutValue=f,u.leaveEdge=v,u.enterEdge=k,u.exchangeEdges=b;function u(_){_=l(_),r(_);var E=t(_);p(E),d(E,_);for(var T,A;T=v(E);)A=k(E,_,T),b(E,_,T,A)}function d(_,E){var T=o(_,_.nodes());T=T.slice(0,T.length-1),e.forEach(T,function(A){h(_,E,A)})}function h(_,E,T){var A=_.node(T),R=A.parent;_.edge(T,R).cutvalue=f(_,E,T)}function f(_,E,T){var A=_.node(T),R=A.parent,B=!0,P=E.edge(T,R),D=0;return P||(B=!1,P=E.edge(R,T)),D=P.weight,e.forEach(E.nodeEdges(T),function(I){var O=I.v===T,z=O?I.w:I.v;if(z!==R){var M=O===B,$=E.edge(I).weight;if(D+=M?$:-$,N(_,T,z)){var q=_.edge(T,z).cutvalue;D+=M?-q:q}}}),D}function p(_,E){arguments.length<2&&(E=_.nodes()[0]),g(_,{},1,E)}function g(_,E,T,A,R){var B=T,P=_.node(A);return E[A]=!0,e.forEach(_.neighbors(A),function(D){e.has(E,D)||(T=g(_,E,T,D,A))}),P.low=B,P.lim=T++,R?P.parent=R:delete P.parent,T}function v(_){return e.find(_.edges(),function(E){return _.edge(E).cutvalue<0})}function k(_,E,T){var A=T.v,R=T.w;E.hasEdge(A,R)||(A=T.w,R=T.v);var B=_.node(A),P=_.node(R),D=B,I=!1;B.lim>P.lim&&(D=P,I=!0);var O=e.filter(E.edges(),function(z){return I===S(_,_.node(z.v),D)&&I!==S(_,_.node(z.w),D)});return e.minBy(O,function(z){return n(E,z)})}function b(_,E,T,A){var R=T.v,B=T.w;_.removeEdge(R,B),_.setEdge(A.v,A.w,{}),p(_),d(_,E),x(_,E)}function x(_,E){var T=e.find(_.nodes(),function(R){return!E.node(R).parent}),A=s(_,T);A=A.slice(1),e.forEach(A,function(R){var B=_.node(R).parent,P=E.edge(R,B),D=!1;P||(P=E.edge(B,R),D=!0),E.node(R).rank=E.node(B).rank+(D?P.minlen:-P.minlen)})}function N(_,E,T){return _.hasEdge(E,T)}function S(_,E,T){return T.low<=E.lim&&E.lim<=T.lim}return jv}var Sv,OA;function TQ(){if(OA)return Sv;OA=1;var e=xd(),t=e.longestPath,n=TO(),r=CQ();Sv=s;function s(d){switch(d.graph().ranker){case"network-simplex":u(d);break;case"tight-tree":l(d);break;case"longest-path":o(d);break;default:u(d)}}var o=t;function l(d){t(d),n(d)}function u(d){r(d)}return Sv}var _v,LA;function AQ(){if(LA)return _v;LA=1;var e=ut();_v=t;function t(s){var o=r(s);e.forEach(s.graph().dummyChains,function(l){for(var u=s.node(l),d=u.edgeObj,h=n(s,o,d.v,d.w),f=h.path,p=h.lca,g=0,v=f[g],k=!0;l!==d.w;){if(u=s.node(l),k){for(;(v=f[g])!==p&&s.node(v).maxRank<u.rank;)g++;v===p&&(k=!1)}if(!k){for(;g<f.length-1&&s.node(v=f[g+1]).minRank<=u.rank;)g++;v=f[g]}s.setParent(l,v),l=s.successors(l)[0]}})}function n(s,o,l,u){var d=[],h=[],f=Math.min(o[l].low,o[u].low),p=Math.max(o[l].lim,o[u].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=u;(g=s.parent(g))!==v;)h.push(g);return{path:d.concat(h.reverse()),lca:v}}function r(s){var o={},l=0;function u(d){var h=l;e.forEach(s.children(d),u),o[d]={low:h,lim:l++}}return e.forEach(s.children(),u),o}return _v}var Ev,PA;function RQ(){if(PA)return Ev;PA=1;var e=ut(),t=hn();Ev={run:n,cleanup:l};function n(u){var d=t.addDummyNode(u,"root",{},"_root"),h=s(u),f=e.max(e.values(h))-1,p=2*f+1;u.graph().nestingRoot=d,e.forEach(u.edges(),function(v){u.edge(v).minlen*=p});var g=o(u)+1;e.forEach(u.children(),function(v){r(u,d,p,g,f,h,v)}),u.graph().nodeRankFactor=p}function r(u,d,h,f,p,g,v){var k=u.children(v);if(!k.length){v!==d&&u.setEdge(d,v,{weight:0,minlen:h});return}var b=t.addBorderNode(u,"_bt"),x=t.addBorderNode(u,"_bb"),N=u.node(v);u.setParent(b,v),N.borderTop=b,u.setParent(x,v),N.borderBottom=x,e.forEach(k,function(S){r(u,d,h,f,p,g,S);var _=u.node(S),E=_.borderTop?_.borderTop:S,T=_.borderBottom?_.borderBottom:S,A=_.borderTop?f:2*f,R=E!==T?1:p-g[v]+1;u.setEdge(b,E,{weight:A,minlen:R,nestingEdge:!0}),u.setEdge(T,x,{weight:A,minlen:R,nestingEdge:!0})}),u.parent(v)||u.setEdge(d,b,{weight:0,minlen:p+g[v]})}function s(u){var d={};function h(f,p){var g=u.children(f);g&&g.length&&e.forEach(g,function(v){h(v,p+1)}),d[f]=p}return e.forEach(u.children(),function(f){h(f,1)}),d}function o(u){return e.reduce(u.edges(),function(d,h){return d+u.edge(h).weight},0)}function l(u){var d=u.graph();u.removeNode(d.nestingRoot),delete d.nestingRoot,e.forEach(u.edges(),function(h){var f=u.edge(h);f.nestingEdge&&u.removeEdge(h)})}return Ev}var Cv,DA;function MQ(){if(DA)return Cv;DA=1;var e=ut(),t=hn();Cv=n;function n(s){function o(l){var u=s.children(l),d=s.node(l);if(u.length&&e.forEach(u,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,u,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,u),p&&s.setEdge(p,g,{weight:1})}return Cv}var Tv,FA;function $Q(){if(FA)return Tv;FA=1;var e=ut();Tv={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")&&(u(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 u(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 Tv}var Av,BA;function IQ(){if(BA)return Av;BA=1;var e=ut();Av=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 u(h){if(!e.has(r,h)){r[h]=!0;var f=n.node(h);l[f.rank].push(h),e.forEach(n.successors(h),u)}}var d=e.sortBy(s,function(h){return n.node(h).rank});return e.forEach(d,u),l}return Av}var Rv,qA;function OQ(){if(qA)return Rv;qA=1;var e=ut();Rv=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})),u=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(u.forEach(function(g){var v=g.pos+d;f[v]+=g.weight;for(var k=0;v>0;)v%2&&(k+=f[v+1]),v=v-1>>1,f[v]+=g.weight;p+=g.weight*k})),p}return Rv}var Mv,UA;function LQ(){if(UA)return Mv;UA=1;var e=ut();Mv=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(u,d){var h=n.edge(d),f=n.node(d.v);return{sum:u.sum+h.weight*f.order,weight:u.weight+h.weight}},{sum:0,weight:0});return{v:s,barycenter:l.sum/l.weight,weight:l.weight}}else return{v:s}})}return Mv}var $v,zA;function PQ(){if(zA)return $v;zA=1;var e=ut();$v=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 u=e.filter(l,function(d){return!d.indegree});return n(u)}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 u(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,u(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,u=0;s.weight&&(l+=s.barycenter*s.weight,u+=s.weight),o.weight&&(l+=o.barycenter*o.weight,u+=o.weight),s.vs=o.vs.concat(s.vs),s.barycenter=l/u,s.weight=u,s.i=Math.min(o.i,s.i),o.merged=!0}return $v}var Iv,WA;function DQ(){if(WA)return Iv;WA=1;var e=ut(),t=hn();Iv=n;function n(o,l){var u=t.partition(o,function(b){return e.has(b,"barycenter")}),d=u.lhs,h=e.sortBy(u.rhs,function(b){return-b.i}),f=[],p=0,g=0,v=0;d.sort(s(!!l)),v=r(f,h,v),e.forEach(d,function(b){v+=b.vs.length,f.push(b.vs),p+=b.barycenter*b.weight,g+=b.weight,v=r(f,h,v)});var k={vs:e.flatten(f,!0)};return g&&(k.barycenter=p/g,k.weight=g),k}function r(o,l,u){for(var d;l.length&&(d=e.last(l)).i<=u;)l.pop(),o.push(d.vs),u++;return u}function s(o){return function(l,u){return l.barycenter<u.barycenter?-1:l.barycenter>u.barycenter?1:o?u.i-l.i:l.i-u.i}}return Iv}var Ov,HA;function FQ(){if(HA)return Ov;HA=1;var e=ut(),t=LQ(),n=PQ(),r=DQ();Ov=s;function s(u,d,h,f){var p=u.children(d),g=u.node(d),v=g?g.borderLeft:void 0,k=g?g.borderRight:void 0,b={};v&&(p=e.filter(p,function(T){return T!==v&&T!==k}));var x=t(u,p);e.forEach(x,function(T){if(u.children(T.v).length){var A=s(u,T.v,h,f);b[T.v]=A,e.has(A,"barycenter")&&l(T,A)}});var N=n(x,h);o(N,b);var S=r(N,f);if(v&&(S.vs=e.flatten([v,S.vs,k],!0),u.predecessors(v).length)){var _=u.node(u.predecessors(v)[0]),E=u.node(u.predecessors(k)[0]);e.has(S,"barycenter")||(S.barycenter=0,S.weight=0),S.barycenter=(S.barycenter*S.weight+_.order+E.order)/(S.weight+2),S.weight+=2}return S}function o(u,d){e.forEach(u,function(h){h.vs=e.flatten(h.vs.map(function(f){return d[f]?d[f].vs:f}),!0)})}function l(u,d){e.isUndefined(u.barycenter)?(u.barycenter=d.barycenter,u.weight=d.weight):(u.barycenter=(u.barycenter*u.weight+d.barycenter*d.weight)/(u.weight+d.weight),u.weight+=d.weight)}return Ov}var Lv,VA;function BQ(){if(VA)return Lv;VA=1;var e=ut(),t=hr().Graph;Lv=n;function n(s,o,l){var u=r(s),d=new t({compound:!0}).setGraph({root:u}).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||u),e.forEach(s[l](h),function(g){var v=g.v===h?g.w:g.v,k=d.edge(v,h),b=e.isUndefined(k)?0:k.weight;d.setEdge(v,h,{weight:s.edge(g).weight+b})}),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 Lv}var Pv,GA;function qQ(){if(GA)return Pv;GA=1;var e=ut();Pv=t;function t(n,r,s){var o={},l;e.forEach(s,function(u){for(var d=n.parent(u),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 Pv}var Dv,KA;function UQ(){if(KA)return Dv;KA=1;var e=ut(),t=IQ(),n=OQ(),r=FQ(),s=BQ(),o=qQ(),l=hr().Graph,u=hn();Dv=d;function d(g){var v=u.maxRank(g),k=h(g,e.range(1,v+1),"inEdges"),b=h(g,e.range(v-1,-1,-1),"outEdges"),x=t(g);p(g,x);for(var N=Number.POSITIVE_INFINITY,S,_=0,E=0;E<4;++_,++E){f(_%2?k:b,_%4>=2),x=u.buildLayerMatrix(g);var T=n(g,x);T<N&&(E=0,S=e.cloneDeep(x),N=T)}p(g,S)}function h(g,v,k){return e.map(v,function(b){return s(g,b,k)})}function f(g,v){var k=new l;e.forEach(g,function(b){var x=b.graph().root,N=r(b,x,k,v);e.forEach(N.vs,function(S,_){b.node(S).order=_}),o(b,k,N.vs)})}function p(g,v){e.forEach(v,function(k){e.forEach(k,function(b,x){g.node(b).order=x})})}return Dv}var Fv,YA;function zQ(){if(YA)return Fv;YA=1;var e=ut(),t=hr().Graph,n=hn();Fv={positionX:k,findType1Conflicts:r,findType2Conflicts:s,addConflict:l,hasConflict:u,verticalAlignment:d,horizontalCompaction:h,alignCoordinates:g,findSmallestWidthAlignment:p,balance:v};function r(N,S){var _={};function E(T,A){var R=0,B=0,P=T.length,D=e.last(A);return e.forEach(A,function(I,O){var z=o(N,I),M=z?N.node(z).order:P;(z||I===D)&&(e.forEach(A.slice(B,O+1),function($){e.forEach(N.predecessors($),function(q){var X=N.node(q),H=X.order;(H<R||M<H)&&!(X.dummy&&N.node($).dummy)&&l(_,q,$)})}),B=O+1,R=M)}),A}return e.reduce(S,E),_}function s(N,S){var _={};function E(A,R,B,P,D){var I;e.forEach(e.range(R,B),function(O){I=A[O],N.node(I).dummy&&e.forEach(N.predecessors(I),function(z){var M=N.node(z);M.dummy&&(M.order<P||M.order>D)&&l(_,z,I)})})}function T(A,R){var B=-1,P,D=0;return e.forEach(R,function(I,O){if(N.node(I).dummy==="border"){var z=N.predecessors(I);z.length&&(P=N.node(z[0]).order,E(R,D,O,B,P),D=O,B=P)}E(R,D,R.length,P,A.length)}),R}return e.reduce(S,T),_}function o(N,S){if(N.node(S).dummy)return e.find(N.predecessors(S),function(_){return N.node(_).dummy})}function l(N,S,_){if(S>_){var E=S;S=_,_=E}var T=N[S];T||(N[S]=T={}),T[_]=!0}function u(N,S,_){if(S>_){var E=S;S=_,_=E}return e.has(N[S],_)}function d(N,S,_,E){var T={},A={},R={};return e.forEach(S,function(B){e.forEach(B,function(P,D){T[P]=P,A[P]=P,R[P]=D})}),e.forEach(S,function(B){var P=-1;e.forEach(B,function(D){var I=E(D);if(I.length){I=e.sortBy(I,function(q){return R[q]});for(var O=(I.length-1)/2,z=Math.floor(O),M=Math.ceil(O);z<=M;++z){var $=I[z];A[D]===D&&P<R[$]&&!u(_,D,$)&&(A[$]=D,A[D]=T[D]=T[$],P=R[$])}}})}),{root:T,align:A}}function h(N,S,_,E,T){var A={},R=f(N,S,_,T),B=T?"borderLeft":"borderRight";function P(O,z){for(var M=R.nodes(),$=M.pop(),q={};$;)q[$]?O($):(q[$]=!0,M.push($),M=M.concat(z($))),$=M.pop()}function D(O){A[O]=R.inEdges(O).reduce(function(z,M){return Math.max(z,A[M.v]+R.edge(M))},0)}function I(O){var z=R.outEdges(O).reduce(function($,q){return Math.min($,A[q.w]-R.edge(q))},Number.POSITIVE_INFINITY),M=N.node(O);z!==Number.POSITIVE_INFINITY&&M.borderType!==B&&(A[O]=Math.max(A[O],z))}return P(D,R.predecessors.bind(R)),P(I,R.successors.bind(R)),e.forEach(E,function(O){A[O]=A[_[O]]}),A}function f(N,S,_,E){var T=new t,A=N.graph(),R=b(A.nodesep,A.edgesep,E);return e.forEach(S,function(B){var P;e.forEach(B,function(D){var I=_[D];if(T.setNode(I),P){var O=_[P],z=T.edge(O,I);T.setEdge(O,I,Math.max(R(N,D,P),z||0))}P=D})}),T}function p(N,S){return e.minBy(e.values(S),function(_){var E=Number.NEGATIVE_INFINITY,T=Number.POSITIVE_INFINITY;return e.forIn(_,function(A,R){var B=x(N,R)/2;E=Math.max(A+B,E),T=Math.min(A-B,T)}),E-T})}function g(N,S){var _=e.values(S),E=e.min(_),T=e.max(_);e.forEach(["u","d"],function(A){e.forEach(["l","r"],function(R){var B=A+R,P=N[B],D;if(P!==S){var I=e.values(P);D=R==="l"?E-e.min(I):T-e.max(I),D&&(N[B]=e.mapValues(P,function(O){return O+D}))}})})}function v(N,S){return e.mapValues(N.ul,function(_,E){if(S)return N[S.toLowerCase()][E];var T=e.sortBy(e.map(N,E));return(T[1]+T[2])/2})}function k(N){var S=n.buildLayerMatrix(N),_=e.merge(r(N,S),s(N,S)),E={},T;e.forEach(["u","d"],function(R){T=R==="u"?S:e.values(S).reverse(),e.forEach(["l","r"],function(B){B==="r"&&(T=e.map(T,function(O){return e.values(O).reverse()}));var P=(R==="u"?N.predecessors:N.successors).bind(N),D=d(N,T,_,P),I=h(N,T,D.root,D.align,B==="r");B==="r"&&(I=e.mapValues(I,function(O){return-O})),E[R+B]=I})});var A=p(N,E);return g(E,A),v(E,N.graph().align)}function b(N,S,_){return function(E,T,A){var R=E.node(T),B=E.node(A),P=0,D;if(P+=R.width/2,e.has(R,"labelpos"))switch(R.labelpos.toLowerCase()){case"l":D=-R.width/2;break;case"r":D=R.width/2;break}if(D&&(P+=_?D:-D),D=0,P+=(R.dummy?S:N)/2,P+=(B.dummy?S:N)/2,P+=B.width/2,e.has(B,"labelpos"))switch(B.labelpos.toLowerCase()){case"l":D=B.width/2;break;case"r":D=-B.width/2;break}return D&&(P+=_?D:-D),D=0,P}}function x(N,S){return N.node(S).width}return Fv}var Bv,XA;function WQ(){if(XA)return Bv;XA=1;var e=ut(),t=hn(),n=zQ().positionX;Bv=r;function r(o){o=t.asNonCompoundGraph(o),s(o),e.forEach(n(o),function(l,u){o.node(u).x=l})}function s(o){var l=t.buildLayerMatrix(o),u=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+u})}return Bv}var qv,ZA;function HQ(){if(ZA)return qv;ZA=1;var e=ut(),t=_Q(),n=EQ(),r=TQ(),s=hn().normalizeRanks,o=AQ(),l=hn().removeEmptyRanks,u=RQ(),d=MQ(),h=$Q(),f=UQ(),p=WQ(),g=hn(),v=hr().Graph;qv=k;function k(V,G){var K=G&&G.debugTiming?g.time:g.notime;K("layout",function(){var Z=K(" buildLayoutGraph",function(){return P(V)});K(" runLayout",function(){b(Z,K)}),K(" updateInputGraph",function(){x(V,Z)})})}function b(V,G){G(" makeSpaceForEdgeLabels",function(){D(V)}),G(" removeSelfEdges",function(){L(V)}),G(" acyclic",function(){t.run(V)}),G(" nestingGraph.run",function(){u.run(V)}),G(" rank",function(){r(g.asNonCompoundGraph(V))}),G(" injectEdgeLabelProxies",function(){I(V)}),G(" removeEmptyRanks",function(){l(V)}),G(" nestingGraph.cleanup",function(){u.cleanup(V)}),G(" normalizeRanks",function(){s(V)}),G(" assignRankMinMax",function(){O(V)}),G(" removeEdgeLabelProxies",function(){z(V)}),G(" normalize.run",function(){n.run(V)}),G(" parentDummyChains",function(){o(V)}),G(" addBorderSegments",function(){d(V)}),G(" order",function(){f(V)}),G(" insertSelfEdges",function(){W(V)}),G(" adjustCoordinateSystem",function(){h.adjust(V)}),G(" position",function(){p(V)}),G(" positionSelfEdges",function(){F(V)}),G(" removeBorderNodes",function(){H(V)}),G(" normalize.undo",function(){n.undo(V)}),G(" fixupEdgeLabelCoords",function(){q(V)}),G(" undoCoordinateSystem",function(){h.undo(V)}),G(" translateGraph",function(){M(V)}),G(" assignNodeIntersects",function(){$(V)}),G(" reversePoints",function(){X(V)}),G(" acyclic.undo",function(){t.undo(V)})}function x(V,G){e.forEach(V.nodes(),function(K){var Z=V.node(K),ee=G.node(K);Z&&(Z.x=ee.x,Z.y=ee.y,G.children(K).length&&(Z.width=ee.width,Z.height=ee.height))}),e.forEach(V.edges(),function(K){var Z=V.edge(K),ee=G.edge(K);Z.points=ee.points,e.has(ee,"x")&&(Z.x=ee.x,Z.y=ee.y)}),V.graph().width=G.graph().width,V.graph().height=G.graph().height}var N=["nodesep","edgesep","ranksep","marginx","marginy"],S={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},_=["acyclicer","ranker","rankdir","align"],E=["width","height"],T={width:0,height:0},A=["minlen","weight","width","height","labeloffset"],R={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},B=["labelpos"];function P(V){var G=new v({multigraph:!0,compound:!0}),K=J(V.graph());return G.setGraph(e.merge({},S,Y(K,N),e.pick(K,_))),e.forEach(V.nodes(),function(Z){var ee=J(V.node(Z));G.setNode(Z,e.defaults(Y(ee,E),T)),G.setParent(Z,V.parent(Z))}),e.forEach(V.edges(),function(Z){var ee=J(V.edge(Z));G.setEdge(Z,e.merge({},R,Y(ee,A),e.pick(ee,B)))}),G}function D(V){var G=V.graph();G.ranksep/=2,e.forEach(V.edges(),function(K){var Z=V.edge(K);Z.minlen*=2,Z.labelpos.toLowerCase()!=="c"&&(G.rankdir==="TB"||G.rankdir==="BT"?Z.width+=Z.labeloffset:Z.height+=Z.labeloffset)})}function I(V){e.forEach(V.edges(),function(G){var K=V.edge(G);if(K.width&&K.height){var Z=V.node(G.v),ee=V.node(G.w),re={rank:(ee.rank-Z.rank)/2+Z.rank,e:G};g.addDummyNode(V,"edge-proxy",re,"_ep")}})}function O(V){var G=0;e.forEach(V.nodes(),function(K){var Z=V.node(K);Z.borderTop&&(Z.minRank=V.node(Z.borderTop).rank,Z.maxRank=V.node(Z.borderBottom).rank,G=e.max(G,Z.maxRank))}),V.graph().maxRank=G}function z(V){e.forEach(V.nodes(),function(G){var K=V.node(G);K.dummy==="edge-proxy"&&(V.edge(K.e).labelRank=K.rank,V.removeNode(G))})}function M(V){var G=Number.POSITIVE_INFINITY,K=0,Z=Number.POSITIVE_INFINITY,ee=0,re=V.graph(),ue=re.marginx||0,me=re.marginy||0;function ie(fe){var ve=fe.x,se=fe.y,ke=fe.width,pe=fe.height;G=Math.min(G,ve-ke/2),K=Math.max(K,ve+ke/2),Z=Math.min(Z,se-pe/2),ee=Math.max(ee,se+pe/2)}e.forEach(V.nodes(),function(fe){ie(V.node(fe))}),e.forEach(V.edges(),function(fe){var ve=V.edge(fe);e.has(ve,"x")&&ie(ve)}),G-=ue,Z-=me,e.forEach(V.nodes(),function(fe){var ve=V.node(fe);ve.x-=G,ve.y-=Z}),e.forEach(V.edges(),function(fe){var ve=V.edge(fe);e.forEach(ve.points,function(se){se.x-=G,se.y-=Z}),e.has(ve,"x")&&(ve.x-=G),e.has(ve,"y")&&(ve.y-=Z)}),re.width=K-G+ue,re.height=ee-Z+me}function $(V){e.forEach(V.edges(),function(G){var K=V.edge(G),Z=V.node(G.v),ee=V.node(G.w),re,ue;K.points?(re=K.points[0],ue=K.points[K.points.length-1]):(K.points=[],re=ee,ue=Z),K.points.unshift(g.intersectRect(Z,re)),K.points.push(g.intersectRect(ee,ue))})}function q(V){e.forEach(V.edges(),function(G){var K=V.edge(G);if(e.has(K,"x"))switch((K.labelpos==="l"||K.labelpos==="r")&&(K.width-=K.labeloffset),K.labelpos){case"l":K.x-=K.width/2+K.labeloffset;break;case"r":K.x+=K.width/2+K.labeloffset;break}})}function X(V){e.forEach(V.edges(),function(G){var K=V.edge(G);K.reversed&&K.points.reverse()})}function H(V){e.forEach(V.nodes(),function(G){if(V.children(G).length){var K=V.node(G),Z=V.node(K.borderTop),ee=V.node(K.borderBottom),re=V.node(e.last(K.borderLeft)),ue=V.node(e.last(K.borderRight));K.width=Math.abs(ue.x-re.x),K.height=Math.abs(ee.y-Z.y),K.x=re.x+K.width/2,K.y=Z.y+K.height/2}}),e.forEach(V.nodes(),function(G){V.node(G).dummy==="border"&&V.removeNode(G)})}function L(V){e.forEach(V.edges(),function(G){if(G.v===G.w){var K=V.node(G.v);K.selfEdges||(K.selfEdges=[]),K.selfEdges.push({e:G,label:V.edge(G)}),V.removeEdge(G)}})}function W(V){var G=g.buildLayerMatrix(V);e.forEach(G,function(K){var Z=0;e.forEach(K,function(ee,re){var ue=V.node(ee);ue.order=re+Z,e.forEach(ue.selfEdges,function(me){g.addDummyNode(V,"selfedge",{width:me.label.width,height:me.label.height,rank:ue.rank,order:re+ ++Z,e:me.e,label:me.label},"_se")}),delete ue.selfEdges})})}function F(V){e.forEach(V.nodes(),function(G){var K=V.node(G);if(K.dummy==="selfedge"){var Z=V.node(K.e.v),ee=Z.x+Z.width/2,re=Z.y,ue=K.x-ee,me=Z.height/2;V.setEdge(K.e,K.label),V.removeNode(G),K.label.points=[{x:ee+2*ue/3,y:re-me},{x:ee+5*ue/6,y:re-me},{x:ee+ue,y:re},{x:ee+5*ue/6,y:re+me},{x:ee+2*ue/3,y:re+me}],K.label.x=K.x,K.label.y=K.y}})}function Y(V,G){return e.mapValues(e.pick(V,G),Number)}function J(V){var G={};return e.forEach(V,function(K,Z){G[Z.toLowerCase()]=K}),G}return qv}var Uv,JA;function VQ(){if(JA)return Uv;JA=1;var e=ut(),t=hn(),n=hr().Graph;Uv={debugOrdering:r};function r(s){var o=t.buildLayerMatrix(s),l=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(s.nodes(),function(u){l.setNode(u,{label:u}),l.setParent(u,"layer"+s.node(u).rank)}),e.forEach(s.edges(),function(u){l.setEdge(u.v,u.w,{},u.name)}),e.forEach(o,function(u,d){var h="layer"+d;l.setNode(h,{rank:"same"}),e.reduce(u,function(f,p){return l.setEdge(f,p,{style:"invis"}),p})}),l}return Uv}var zv,QA;function GQ(){return QA||(QA=1,zv="0.8.5"),zv}var Wv,eR;function KQ(){return eR||(eR=1,Wv={graphlib:hr(),layout:HQ(),debug:VQ(),util:{time:hn().time,notime:hn().notime},version:GQ()}),Wv}var YQ=KQ();const tR=ob(YQ),bd=240,AO=130,Kx=Ra*2+kx+i$,XQ=72,ni=Kx+XQ,Gu=24,RO=Ra*2+Gu,kd=ni;function MO(e,t){var r;let n=bd;for(const s of e)n=Math.max(n,((r=t.get(s.id))==null?void 0:r.width)??bd);return n}const Nd=420,$O=1;function ZQ(e,t,n,r){return Math.min($O,n/Math.max(1,e),r/Math.max(1,t))}function gh(e){var n;return((n=e.data)==null?void 0:n.sessionId)??"_default"}function yh(e,t=()=>!0){const n=new Map;for(const r of e){if(!t(r))continue;const s=gh(r),o=n.get(s);o?o.push(r):n.set(s,[r])}return n}function JQ(e,t){return((t==null?void 0:t.get(e))??0)>0?Nd:0}function QQ(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function jd(e,t){const n=t.get(e);return{w:(n==null?void 0:n.width)??bd,h:(n==null?void 0:n.height)??AO}}function Yl(e,t,n){const r=jd(e,t);return{w:r.w+JQ(e,n),h:Math.max(r.h,QQ(e,n))}}function eee(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function tee(e,t,n){const r=yh(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(gh(s));if(!o)return s;const l=(h=s.data)==null?void 0:h.parentId,u=o.find(f=>f.id===l)??o[0],d=n(u.id);return{...s,position:{x:s.position.x+d.x-u.position.x,y:s.position.y+d.y-u.position.y}}})}function nee(e,t,n,r,s,o,l){const u=_=>Yl(_,r,o),d=_=>n.get(_)??t.get(_),h=_=>{const{w:E,h:T}=jd(_,r);return{cw:E,ch:T}},f=l!=null&&l.width>0&&l.height>0,p=yh(e,_=>d(_.id)!=null),g=new Set;for(const[_,E]of p)E.every(T=>s.has(T.id)&&!n.has(T.id))&&g.add(_);const v=new Map,k=[];for(const _ of e){const E=d(_.id);if(!E)continue;const{w:T,h:A}=u(_.id),R=gh(_);g.has(R)?(v.get(R)??v.set(R,[]).get(R)).push(_):k.push({x:E.x,y:E.y,w:T,h:A,...h(_.id)})}if(v.size===0||f&&k.length===0)return[];const b=kd,x=(_,E,T,A)=>k.some(R=>_<R.x+R.w+Kx&&R.x<_+T+Kx&&E<R.y+R.h+b&&R.y<E+A+b),N=MO(e,r),S=[];for(const _ of[...v.keys()].sort()){const E=v.get(_);let T=1/0,A=1/0,R=-1/0,B=-1/0,P=-1/0,D=-1/0;for(const X of E){const H=d(X.id),{w:L,h:W}=u(X.id),{cw:F,ch:Y}=h(X.id);T=Math.min(T,H.x),A=Math.min(A,H.y),R=Math.max(R,H.x+L),B=Math.max(B,H.y+W),P=Math.max(P,H.x+F),D=Math.max(D,H.y+Y)}const I=R-T,O=B-A,z=[...new Set(k.map(X=>Math.round(X.x)))].sort((X,H)=>X-H),M=z.length?z:[T],$=[0,...k.map(X=>X.y+X.h+b)].sort((X,H)=>X-H);let q=null;if(f){let X=1/0,H=1/0,L=-1/0,W=-1/0;for(const K of k)X=Math.min(X,K.x),H=Math.min(H,K.y),L=Math.max(L,K.x+K.cw),W=Math.max(W,K.y+K.ch);const F=(K,Z)=>{const ee=l.width/(Math.max(L,K+P-T)-Math.min(X,K)+Nd),re=l.height/(Math.max(W,Z+D-A)-Math.min(H,Z));return[Math.min($O,ee,re),Math.min(ee,re),Math.max(ee,re)]},Y=(K,Z)=>{for(let ee=0;ee<K.length;ee++){if(K[ee]>Z[ee]+1e-9)return!0;if(K[ee]<Z[ee]-1e-9)return!1}return!1},J=Math.round(L+Nd+N),V=[...new Set([...$,H])].sort((K,Z)=>K-Z);let G=null;for(const K of[...M,J])for(const Z of V){if(x(K,Z,I,O))continue;const ee=F(K,Z);(G===null||Y(ee,G))&&(G=ee,q={x:K,y:Z})}q&&q.x===T&&q.y===A&&(q=null)}else e:for(const X of M)for(const H of $){if(H>=A)break;if(!x(X,H,I,O)){q={x:X,y:H};break e}}if(q){const X=q.x-T,H=q.y-A;for(const L of E){const W=d(L.id);t.set(L.id,{x:W.x+X,y:W.y+H})}S.push(_)}for(const X of E){const H=d(X.id),{w:L,h:W}=u(X.id);k.push({x:H.x,y:H.y,w:L,h:W,...h(X.id)})}}return S}function ree(e,t,n,r,s,o){const l=g=>Yl(g,r,s),u=new Map(e.map(g=>[g.id,gh(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:k,h:b}=l(g);d.push({x:v.x,y:v.y,w:k,h:b,sid:u.get(g)??"_default"})}const p=[];for(const{id:g,pos:v}of h){if(f(g))continue;const{w:k,h:b}=l(g),x=u.get(g)??"_default";if(n.has(g)){d.push({x:v.x,y:v.y,w:k,h:b,sid:x});continue}let N=v.y;for(let S=0;S<d.length+1;S++){const _=d.find(E=>{const T=E.sid===x?Gu:RO,A=E.sid===x?Gu:kd;return v.x<E.x+E.w+T&&E.x<v.x+k+T&&N<E.y+E.h+A&&E.y<N+b+A});if(!_)break;N=_.y+_.h+(_.sid===x?Gu:kd)}N!==v.y&&(t.set(g,{x:v.x,y:N}),p.push(g)),d.push({x:v.x,y:N,w:k,h:b,sid:x})}return p}function see(e,t,n,r,s,o=!1,l){const d=RO+1,h=kd+1,f=8,p=1.75,g=200,v=.7,k=.01,b=O=>Yl(O,r,l),x=O=>n.get(O)??t.get(O),N=yh(e,O=>x(O.id)!=null),S=[],_=new Set,E=new Set,T=s.size===0;for(const O of[...N.keys()].sort()){const z=N.get(O);let M=1/0,$=1/0,q=-1/0,X=-1/0,H=!1;for(const Y of z){const J=x(Y.id),{w:V,h:G}=b(Y.id);M=Math.min(M,J.x),$=Math.min($,J.y),q=Math.max(q,J.x+V),X=Math.max(X,J.y+G),n.has(Y.id)&&(H=!0)}const L=q-M,W=X-$;E.add(O);const F=s.get(O);F&&(L>F.w+f||W>F.h+f)&&_.add(O),s.set(O,{w:L,h:W}),S.push({sid:O,members:z.map(Y=>Y.id),x:M,y:$,w:L,h:W,anchored:H,mass:1})}for(const O of[...s.keys()])E.has(O)||s.delete(O);if(o||T)return[];let A=!1;for(let O=0;O<S.length&&!A;O++)for(let z=O+1;z<S.length;z++){const M=S[O],$=S[z];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){A=!0;break}}if(_.size===0&&!A)return[];if(_.size>0)for(const O of S)_.has(O.sid)&&(O.mass=8);else for(const O of S)O.mass=Math.max(1,O.w*O.h/(bd*AO));const R=new Map(S.map(O=>[O.sid,O.x])),B=new Map(S.map(O=>[O.sid,O.y])),P=new Map(S.map(O=>[O.sid,Math.min(0,O.x)])),D=new Map(S.map(O=>[O.sid,Math.min(0,O.y)]));for(let O=0;O<g;O++){const z=new Map,M=new Map;let $=0;for(let q=0;q<S.length;q++)for(let X=q+1;X<S.length;X++){const H=S[q],L=S[X];if(H.anchored&&L.anchored)continue;const W=H.x+H.w/2,F=H.y+H.h/2,Y=L.x+L.w/2,J=L.y+L.h/2,V=(H.w+L.w)/2+d-Math.abs(W-Y),G=(H.h+L.h)/2+h-Math.abs(F-J);if(V<=0||G<=0)continue;const K=(Ye,Ve)=>!Ye.anchored&&!(Ve<0&&Ye.x<=P.get(Ye.sid)),Z=(Ye,Ve)=>!Ye.anchored&&!(Ve<0&&Ye.y<=D.get(Ye.sid)),ee=(Ye,Ve,Ke)=>{const nt=Ye===Ve,it=nt?H.sid<L.sid?-1:1:Math.sign(Ye-Ve);return Ke(H,it)||Ke(L,-it)?it:nt&&(Ke(H,-it)||Ke(L,it))?-it:0},re=ee(W,Y,K),ue=ee(F,J,Z),me=re!==0,ie=ue!==0;if(!me&&!ie)continue;const fe=me&&(!ie||V*p<G),[ve,se,ke,pe]=fe?[re,V,z,K]:[ue,G,M,Z],he=pe(H,ve),ae=pe(L,-ve),Ne=H.mass,Te=L.mass,Ie=he?ae?Te/(Ne+Te):1:0,Oe=ae?he?Ne/(Ne+Te):1:0,He=se*v;ke.set(H.sid,(ke.get(H.sid)??0)+ve*He*Ie),ke.set(L.sid,(ke.get(L.sid)??0)-ve*He*Oe),$+=He}for(const q of S)q.anchored||(q.x=Math.max(P.get(q.sid),q.x+(z.get(q.sid)??0)),q.y=Math.max(D.get(q.sid),q.y+(M.get(q.sid)??0)));if($<k)break}const I=[];for(const O of S){const z=O.x-R.get(O.sid),M=O.y-B.get(O.sid);if(!(Math.abs(z)<1&&Math.abs(M)<1)){for(const $ of O.members){if(n.has($))continue;const q=t.get($);q&&t.set($,{x:q.x+z,y:q.y+M})}I.push(O.sid)}}return I}function aee(e,t,n,r,s,o){const l=new tR.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const u=e.filter(N=>!s.has(N)),d=new Set(u);for(const N of u){const{w:S,h:_}=Yl(N,r,o);l.setNode(N,{width:S,height:_})}for(const N of t)d.has(N.source)&&d.has(N.target)&&l.setEdge(N.source,N.target);tR.layout(l);const h=new Map;let f=1/0,p=1/0,g=-1/0,v=-1/0;for(const N of u){const S=l.node(N);if(!S)continue;const{w:_,h:E}=jd(N,r),T=Yl(N,r,o),A=S.x-T.w/2,R=S.y-T.h/2;h.set(N,{x:A,y:R}),A<f&&(f=A),R<p&&(p=R),A+_>g&&(g=A+_),R+E>v&&(v=R+E)}if(Number.isFinite(f)&&Number.isFinite(p))for(const[N,S]of h)h.set(N,{x:S.x-f,y:S.y-p});const k=Number.isFinite(g)?g-f:0,b=Number.isFinite(v)?v-p:0;let x=null;for(const N of e){const S=s.get(N);if(!S)continue;const{w:_,h:E}=jd(N,r);x=x===null?{minX:S.x,minY:S.y,maxX:S.x+_,maxY:S.y+E}:{minX:Math.min(x.minX,S.x),minY:Math.min(x.minY,S.y),maxX:Math.max(x.maxX,S.x+_),maxY:Math.max(x.maxY,S.y+E)}}return{positions:h,width:k,height:b,pinnedBox:x}}function IO(e,t,n){const r=n.direction??"LR",s=n.pinned??new Map,o=n.measured??new Map,l=n.lanes,u=yh(e);return{laid:Array.from(u.keys()).sort().map(f=>({sid:f,...aee(u.get(f).map(p=>p.id),t,r,o,s,l)})),gap:MO(e,o)}}const OO=e=>e.reduce((t,n)=>Math.max(t,n.width),0)+Nd,oee=e=>e.reduce((t,n)=>t+n.height,0)+ni*Math.max(0,e.length-1);function Yx(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+ni;return h},o=[];for(let d=0;d<e.length;d++){let h=-ni;for(let f=d;f<e.length;f++)o.push(h+=e[f].height+ni)}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 u=[e];if(n>0&&r>0){const d=f=>ZQ(f.reduce((p,g)=>p+OO(g),0)+t*(f.length-1),Math.max(...f.map(oee)),n,r);let h=d(u);for(let f=2;f<=e.length;f++){const p=l(f),g=d(p);g>h+1e-9&&(h=g,u=p)}}return u}function iee(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}=IO(e,t,n);return o.length<2?!1:Yx(o,l,r.width,r.height).length!==Yx(o,l,s.width,s.height).length}function lee(e,t,n={}){const r=n.pinned??new Map,{laid:s,gap:o}=IO(e,t,n),l=Yx(s,o,n.availableWidth??0,n.availableHeight??0),u=new Map;let d=0;for(const h of l){const f=OO(h);let p=0;for(const{positions:g,height:v,pinnedBox:k}of h){for(const[x,N]of g)u.set(x,{x:N.x+d,y:N.y+p});let b=p+v;k&&k.maxY>b&&k.minX<d+f&&d<k.maxX&&(b=k.maxY),p=b+ni}d+=f+o}return e.map(h=>{const f=r.get(h.id);if(f)return{...h,position:f};const p=u.get(h.id);return p?{...h,position:p}:h})}function Ku(e,t,n){return!t.has(e)||n.has(e)}function cee(e,t,n,r){return!t.has(e)&&Ku(e,n,r)}function uee(e,t,n){const r={x:0,y:0};return t.set(e,r),n.add(e),r}function nR(e,t,n,r){n.set(e,t),r.delete(e)}const dee=300,rR=130,hee=160,sR=new WeakMap;function fee(e,t){let n=sR.get(e);(!n||n.revision!==e.revision||n.open!==t)&&(n={revision:e.revision,open:t,byId:new Map,branches:A8(e.agents.values())},sR.set(e,n));const{byId:r,branches:s}=n;return o=>{let l=r.get(o.id);if(!l){const u=o.kind==="root"?s.get(o.sessionId):void 0;l=u?{...o,onOpenContext:t,branch:u}:{...o,onOpenContext:t},r.set(o.id,l)}return l}}function S0(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 pee(e,t,n,r,s,o,l,u,d,h,f,p,g,v,k,b,x,N,S,_){var q,X,H,L;const E=[],T=[],A=fee(e,N);for(const W of e.agents.values()){if(!x.has(W.id))continue;const F=W.exitAt!=null,Y=b!=null&&!b.has(W.id),J=[F?"rf-exiting":"",Y?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,V=o.get(W.id);if(E.push({id:W.id,type:"agent",position:{x:0,y:0},data:A(W),className:J,ariaLabel:Hq(W,t,k.has(W.id)),...V?{width:V.width,height:V.height}:null}),W.parentId&&x.has(W.parentId)){const Z=od(W.sessionId),ee=F,re=k.size>0&&(k.has(W.id)||k.has(W.parentId)),ue=b!=null&&!b.has(W.id)&&!b.has(W.parentId),me=W.state==="active"?2:1.5,ie=re?me+1.5:me,fe=ee?.2:ue?.12:1,ve=["sess-edge",W.state==="active"?"sess-live":"sess-idle",ee?"rf-edge-exiting":"",re?"rf-edge-selected":""].filter(Boolean).join(" ");T.push({id:`e:${W.parentId}->${W.id}`,source:W.parentId,target:W.id,animated:(W.state==="active"||re)&&!ee,type:"smoothstep",style:{"--session-hue":Z,strokeWidth:`calc(${ie}px * var(--edge-k, 1))`,opacity:fe,transition:"var(--edge-transition)"},className:ve})}const G=W.kind==="root"?Fd(W):null,K=G?UM(W.sessionId,G.at):null;if(G&&K&&!j8(K)){const Z=Pb(W.id),ee=od(W.sessionId),re=o.get(Z);E.push({id:Z,type:"recapNote",position:{x:0,y:0},data:{sessionId:W.sessionId,parentId:W.id,recap:G,noteKey:K,hue:ee},className:Y?"rf-spotlit-out":void 0,selectable:!1,focusable:!1,ariaLabel:`Claude Code's recap for ${W.label}`,...re?{width:re.width,height:re.height}:null}),T.push({id:`e:recap:${W.id}`,source:Z,target:W.id,type:"recapTie",className:"recap-edge",focusable:!1,style:{"--session-hue":ee}})}}const R=S0(e),B=_.size>0&&!(d&&S);B||_.clear();const P=`${g}#lanes:${eee(R)}${B?"#held":""}`,D=new Set(E.filter(W=>W.type==="recapNote").map(W=>W.id));for(const W of Array.from(f.keys()))S&&C8(W)&&!D.has(W)&&!s.has(W)&&(f.delete(W),p.delete(W));const I=E.filter(W=>cee(W.id,s,f,p));if(I.length>0||P!==v.current){if(I.length>0){for(const F of I)_.delete(F.id);const W=tee(lee(E,T,{direction:"LR",pinned:s,measured:o,availableWidth:n,availableHeight:r,lanes:R}),s,F=>Ku(F,f,p)?void 0:f.get(F));for(const F of W)Ku(F.id,f,p)&&nR(F.id,F.position,f,p);nee(E,f,s,o,new Set(I.filter(F=>F.type!=="recapNote").map(F=>F.id)),R,{width:n,height:r});for(const F of I){if(F.type!=="recapNote")continue;const Y=(q=F.data)==null?void 0:q.parentId;if(!Y)continue;const J=s.get(Y)??(Ku(Y,f,p)?void 0:f.get(Y));if(!J)continue;const V=((X=o.get(F.id))==null?void 0:X.width)??dee,G=((H=o.get(F.id))==null?void 0:H.height)??rR,K=((L=o.get(Y))==null?void 0:L.height)??rR;nR(F.id,{x:J.x-hee-V,y:J.y+(K-G)/2},f,p)}}ree(E,f,s,o,R,B?_:void 0),v.current=P}const O=see(E,f,s,o,l,!d||h,R);O.length>0&&u(O);const z=TX(e.agents.values());S&&$u(f,z),$u(p,z),S&&$u(s,z),$u(o,CX(e.agents.values()));const M=[];let $=!1;for(const W of E){let F=s.get(W.id)??f.get(W.id);F||(F=uee(W.id,f,p),$=!0),M.push({...W,position:F})}return $&&(v.current=""),{nodes:M,edges:T}}function mee(e){return e.slice().sort((t,n)=>t.y-n.y||t.x-n.x)}function gee(e,t,n){var l;if(e.length===0)return null;const r=mee(e),s=t?r.findIndex(u=>u.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 yee=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Backspace"]);function wee(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:yee.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const vee=new Set(["","BODY","HTML","#DOCUMENT"]);function xee(e){return!e||Dd(e)?!1:!vee.has(String(e.tagName??"").toUpperCase())}const LO="react-flow__node";function _0(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,LO))===!0}function bee(e){try{const t=document.querySelector(`.${LO}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}let La=null,Go=null;const Xx=new Set,Zx=()=>{for(const e of Xx)e()},kee=e=>(Xx.add(e),()=>{Xx.delete(e)}),aR=()=>La,Nee=90;function PO(e){!Go||e!=null&&Go.at.id!==e||(clearTimeout(Go.timer),Go=null)}function DO(e,t,n="pointer"){PO();const r={id:e,anchor:t,by:n};if(La||n==="focus"){La=r,Zx();return}Go={at:r,timer:setTimeout(()=>{Go=null,La=r,Zx()},Nee)}}function ta(e){PO(e),!(!La||e!=null&&La.id!==e)&&(La=null,Zx())}function jee({agentFor:e,recapFor:t,labelFor:n,bounds:r}){const s=w.useSyncExternalStore(kee,aR,aR),o=s?e(s.id):void 0,l=s&&!o?t(s.id):void 0,u=s!=null&&(!o&&!l||!s.anchor.isConnected);return w.useEffect(()=>{u&&s&&ta(s.id)},[u,s]),!s||u?null:o?a.jsx(_ee,{a:o,anchor:s.anchor,parentLabel:o.parentId?n(o.parentId):void 0,bounds:r},s.id):l?a.jsx(See,{r:l,anchor:s.anchor,bounds:r},s.id):null}function FO(e,t){const n=w.useRef(null),r=w.useCallback(()=>{const s=n.current;if(!s||!e.isConnected)return;const o=Vb(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 w.useLayoutEffect(()=>{r()}),n}function See({r:e,anchor:t,bounds:n}){const r=FO(t,n),s=xi(3e4),o=ud(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(ql,{}),"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 _ee({a:e,anchor:t,parentLabel:n,bounds:r}){const s=FO(t,r),o=xi(1e3),l=Ob(e.sessionName,e.sessionTitle),u=e.tools.filter(k=>k.ok===!1).length,d=e.tools.filter(k=>!k.endedAt).length,h=fn(e,o).total,f=e.usage.inputTokens+e.usage.outputTokens,p=e.kind==="root"&&pr(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?`${ot(f)} tok`:null,h>0?`${Fe(h)}${Bl(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?"≥ ":"",ci(e.startedAt,e.endedAt,o)]})]}),a.jsxs("div",{className:"node-peek-kind",children:[a.jsxs("span",{className:"node-peek-state","data-kind":yx(e.state),children:[a.jsx(XM,{kind:yx(e.state)}),ii(e.state)]}),a.jsx("span",{children:g}),e.model?a.jsx("span",{children:Qs(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(Bb,{}),a.jsx("span",{children:Ib(e.waiting)}),a.jsx("b",{children:ci(e.waiting.since,void 0,o)})]}),a.jsxs("p",{className:"node-peek-facts",children:[v,u>0&&a.jsxs("span",{className:"node-peek-failed",children:[" · ",u," failed"]})]}),e.branch&&e.branch.total>0&&a.jsx("p",{className:"node-peek-branch",children:zM(e.branch)}),a.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for details"})]}),document.body)}function Eee(e){const t=e.minZoom??$Y,n=e.maxZoom??IY,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),u=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),u/Math.max(1,d.height))*r,p=Math.max(t,Math.min(n,f)),g=(v,k,b,x,N,S)=>{let _=v+(k-x*p)/2-b*p;const E=N*p+_,T=(N+S)*p+_;return S*p<=k?E<v?_+=v-E:T>v+k&&(_-=T-(v+k)):_+=v-E,_};return{x:g(s,l,d.x,d.width,h.x,h.width),y:g(o,u,d.y,d.height,h.y,h.height),zoom:p}}function Cee(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 bn(e){const t=w.useRef(e);return t.current=e,t}const Jx=80,Qx=.86;function BO(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 Tee({canvasRef:e,canvasSize:t,machinePhase:n,usagePhase:r,usagePanelOpen:s,detailShown:o}){const[l,u]=w.useState(0);w.useEffect(()=>{const p=BO(e.current);u(g=>Math.abs(g-p)>40?p:g)},[n,r,s,o,t.w]);const d=bn(l),h=t.w>0?Math.max(0,(t.w-l-Jx*2)*Qx):0,f=t.h>0?Math.max(0,(t.h-Jx*2)*Qx):0;return{railInsetRef:d,availableWidth:h,availableHeight:f}}const qO=420;function Aee(){const e=gi(),t=kt(),n=w.useCallback((d,h)=>{if(px({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=w.useRef(null),s=w.useRef(0),o=w.useRef(0),l=w.useCallback((d,h)=>{const f=++s.current;return n(d,h),o.current=Date.now(),r.current=px({durationMs:h,documentHidden:document.hidden})?{target:d,until:Date.now()+h+60}:null,f},[n]),u=w.useCallback((d=500)=>{const h=Jx,f=1,p=.2,g=Qx;try{const v=document.querySelector(".canvas-wrap"),k=Array.from(document.querySelectorAll(".react-flow__node")).filter($=>$.offsetWidth>0);if(!v||k.length===0)return;const b=v.getBoundingClientRect(),x=e.getViewport();if(!Number.isFinite(x.zoom)||x.zoom<=0)return;const N=$=>($-b.left-x.x)/x.zoom,S=$=>($-b.top-x.y)/x.zoom,_=k.map($=>$.getBoundingClientRect()),E=Math.min(..._.map($=>N($.left))),T=Math.max(..._.map($=>N($.right))),A=Math.min(..._.map($=>S($.top))),R=Math.max(..._.map($=>S($.bottom))),B=T-E,P=R-A;if(!(B>0&&P>0))return;const D=BO(v),I=$=>Math.max(p,Math.min(f,(b.width-D-h*2)/(B+$)*g,(b.height-h*2)/P*g)),O=MY(I(qO),I(0)),z={x:h-E*O,y:Math.max(h,(b.height-P*O)/2)-A*O,zoom:O},M=l(z,d);window.setTimeout(()=>{var $;try{if((($=r.current)==null?void 0:$.target)===z&&(r.current=null),s.current!==M)return;const q=e.getViewport();(Math.abs(q.zoom-O)>.01||Math.abs(q.x-z.x)>2)&&n(z,0)}catch{}},d+60)}catch{}},[e,n,l]);return w.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:u,cameraEpochRef:s,lastFitTimeRef:o}}const Ree=450;function Mee({canvasRef:e,stateRef:t,measuredRef:n,nodesRef:r,railInsetRef:s,moveCamera:o,disableAutoFit:l,lastFocusRef:u,focusAgentRef:d,selectAgent:h,primarySelectedIdRef:f}){const p=w.useCallback(k=>{var B;const b=e.current,x=t.current.agents.get(k);if(!b||!x)return;const N=S0(t.current),S=(P,D)=>{const I=n.current.get(P.id);if(!I)return null;const O=D&&N.has(P.id)?qO:0;return{x:P.position.x,y:P.position.y,width:I.width+O,height:I.height}},_=r.current.find(P=>P.id===k),E=_?S(_,!1):null;if(!E)return;const T=[];for(const P of r.current){if(P.type!=="agent"&&P.type!=="recapNote"||((B=P.data)==null?void 0:B.sessionId)!==x.sessionId)continue;const D=S(P,P.type==="agent");D&&T.push(D)}const A=b.getBoundingClientRect(),R=Eee({pane:{width:A.width,height:A.height},insets:{top:56,left:72,bottom:32,right:s.current+32},context:Cee(T)??E,anchor:E});ta(),l(),u.current={id:k,at:Date.now()},o(R,Ree)},[o,l]);d.current=p;const g=w.useCallback(k=>{const b=r.current.filter(_=>_.type==="agent"),x=gee(b.map(_=>({id:_.id,x:_.position.x,y:_.position.y})),f.current,k),N=x?b.find(_=>_.id===x):void 0;if(!N)return;const S=_0(document.activeElement);h(N.id,!1),window.setTimeout(()=>{try{p(N.id)}catch{}S&&bee(N.id)},30)},[h,p]),v=w.useCallback(k=>{h(k,!1),window.setTimeout(()=>{try{p(k)}catch{}},60)},[h,p]);return{focusAgent:p,stepAgent:g,focusSession:v}}function $ee({nodesRef:e,stateRef:t,canvasRef:n,railInsetRef:r}){const s=w.useCallback(d=>{const h=e.current.find(f=>f.id===d&&f.type==="agent");return h?h.data:void 0},[]),o=w.useCallback(d=>{var h;return(h=t.current.agents.get(d))==null?void 0:h.label},[]),l=w.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}},[]),u=w.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:u}}function Iee(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 oR(e){return Object.entries(e??{}).filter(([,t])=>t&&typeof t.x=="number"&&typeof t.y=="number")}function Oee(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=oR(n);return{positions:s,pins:s.map(([o])=>o)}}const r=n;return{positions:oR(r.positions),pins:Array.isArray(r.pins)?r.pins:[]}}function Lee(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 Pee(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 E0="agent-dag.layout",C0="agent-dag.layoutFrame",T0="agent-dag.viewport";function Dee(){return Oee(et(E0))}function Xl(e,t){Xe(E0,Lee(e,t))}function Fee(){return Pee(et(C0))}function UO(e){Xe(C0,JSON.stringify(e))}function Bee(){return bB(et(T0))}function qee(e){Xe(T0,JSON.stringify(e))}function zO(){us(E0),us(T0),us(C0)}function Uee(e){const t=w.useState(()=>Iee(Dee()))[0],n=w.useRef(t.pinned),r=w.useRef(t.positions),s=w.useRef(new Set),o=w.useRef(""),[l,u]=w.useState(0),d=w.useState(Fee)[0],h=w.useRef(d),f=w.useCallback(()=>{n.current.clear(),r.current.clear(),o.current="",zO(),u(p=>p+1),window.setTimeout(()=>{Xl(r.current,n.current),h.current&&UO(h.current),e(500)},80)},[e]);return{restoredLayout:t,pinnedRef:n,positionsRef:r,provisionalRef:s,lastLayoutSigRef:o,layoutEpoch:l,setLayoutEpoch:u,lastLayoutFrameRef:h,handleRelayout:f}}function zee(e,t){const{positionsRef:n,pinnedRef:r}=t,s=w.useRef(null);w.useEffect(()=>(s.current!=null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{Xl(n.current,r.current)},1500),()=>{s.current!=null&&window.clearTimeout(s.current)}),[e])}function Wee({nodes:e,edges:t,settled:n,dragging:r,availableWidth:s,availableHeight:o,layout:l,camera:u,rf:d,measuredRef:h,stateRef:f,lastFocusRef:p,primarySelectedIdRef:g,focusAgentRef:v,autoFitDisabledRef:k}){const{lastLayoutFrameRef:b,pinnedRef:x,positionsRef:N,provisionalRef:S,lastLayoutSigRef:_,setLayoutEpoch:E}=l,{applyViewport:T,fitLeft:A,cameraEpochRef:R,lastFitTimeRef:B}=u;w.useEffect(()=>{if(!n||r)return;const P={width:s,height:o};if(!(P.width>0&&P.height>0))return;const D=b.current;if(b.current=P,UO(P),!D||D.width===P.width&&D.height===P.height)return;const I={direction:"LR",pinned:x.current,measured:h.current,lanes:S0(f.current)};if(!iee(e,t,I,D,P))return;const O=p.current&&Date.now()-p.current.at<1500?p.current.id:null,z=O??g.current,M=z?x.current.get(z)??N.current.get(z):void 0;for(const $ of Array.from(N.current.keys()))x.current.has($)||N.current.delete($);S.current.clear(),_.current="",E($=>$+1),window.setTimeout(()=>{if(Xl(N.current,x.current),k.current){if(O){v.current(O);return}const $=z?x.current.get(z)??N.current.get(z):void 0;if(M&&$&&($.x!==M.x||$.y!==M.y)){const q=d.getViewport();R.current+=1,T({x:q.x-($.x-M.x)*q.zoom,y:q.y-($.y-M.y)*q.zoom,zoom:q.zoom},0),B.current=Date.now()}return}A(500)},80)},[s,o,n,r,A,d,T])}const Hee=600;function A0(e,t){return!(e.exitAt!=null&&t-e.exitAt>Hee||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function Vee(e,t){const n=new Set;for(const r of e.agents.values())A0(r,t)&&n.add(r.id);return n}function Gee(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 Kee(e,t,n=0){if(!e)return!1;for(const r of t)if(Gee(e,r,n))return!0;return!1}function Yee(e,t,n,r,s){const o=[];for(const l of e)!A0(l,t)||n.has(l.id)||o.push(l.id+(l.parentId?`>${l.parentId}`:""));return o.sort(),`${o.join("|")}#sv${r}.${s}`}const R0="agent-dag.removedNodes";function Xee(e){try{const t=JSON.parse((e==null?void 0:e.getItem(R0))??"[]");return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function iR(e,t){try{e==null||e.setItem(R0,JSON.stringify([...t]))}catch{}}function WO(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 u=n.get(o);for(;u&&!l.has(u);){if(r.has(u))return r.add(o),!0;l.add(u),u=n.get(u)}return!1};return o=>s(o.id)||s(o.sessionId??o.id)}function Zee(e,t){if(t.size===0)return new Set;const n=[...e],r=WO(n,t);return new Set(n.filter(r).map(s=>s.id))}function Jee(e,t,n){const r=u=>({id:u.id,parentId:u.data.parentId,sessionId:u.data.sessionId}),s=WO(e.map(r),n),o=e.filter(u=>!s(r(u))),l=new Set(o.map(u=>u.id));return{nodes:o,edges:t.filter(u=>l.has(u.source)&&l.has(u.target))}}function Qee(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 ete(e,t){return t.size===0?[]:[...e].filter(n=>t.has(n.id)).map(n=>n.id)}function tte(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 nte(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 rte(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 u=e.get(l);if(!u)continue;const d=tte(u);if(d<=s)continue;const h=[],f=new Set,p=v=>{var k;for(let b=v;b&&!f.has(b);b=(k=e.get(b))==null?void 0:k.parentId)f.add(b),n.has(b)&&h.push(b)};p(u.id),p(u.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 HO="sessionGroup";function ste(e,t){var r,s;if(e.type===HO)return"transparent";if(pr((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 Iu=Ra;function ate(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 u=r.position.x,d=r.position.y,h=u+o,f=d+l,p=t.get(s.sessionId);p?(p.minX=Math.min(p.minX,u),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:u,minY:d,maxX:h,maxY:f})}const n=[];for(const[r,s]of t){const o=s.maxX-s.minX+Iu*2,l=s.maxY-s.minY+Iu*2;n.push({id:`group:${r}`,type:HO,position:{x:s.minX-Iu,y:s.minY-Iu},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 ote(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 ite(e,t){const n=new Set;for(const r of t){const s=ote(e,r);if(s)for(const o of s)n.add(o)}return n.size>0?n:null}function lte({stateRef:e,now:t,removedAgentIds:n,sizeVersion:r,domSizeVersion:s}){return w.useMemo(()=>Yee(e.current.agents.values(),t,n,r,s),[e.current,e.current.revision,t,r,s,n])}function cte({stateRef:e,now:t,availableWidth:n,availableHeight:r,layout:s,measuredRef:o,onBubble:l,settled:u,dragging:d,layoutSig:h,selectedIds:f,openContext:p,historyReplayed:g,removedNodes:v,removedAgentIds:k,dragTick:b,dragPatchRef:x,dragMoveTick:N}){const{pinnedRef:S,positionsRef:_,provisionalRef:E,lastLayoutSigRef:T,restoredLayout:A,layoutEpoch:R}=s,B=w.useMemo(()=>ite(e.current,f),[e.current,e.current.revision,f]),P=w.useMemo(()=>{const q=Vee(e.current,t);for(const X of k)q.delete(X);return q},[e.current,e.current.revision,t,k]),D=w.useRef(new Map),I=T8(),{nodes:O,edges:z}=w.useMemo(()=>{const q=pee(e.current,t,n,r,S.current,o.current,D.current,l,u,d,_.current,E.current,h,T,f,B,P,p,g,A.restored);return Jee(q.nodes,q.edges,v)},[e.current,e.current.revision,t,n,r,u,d,h,f,B,P,p,b,I,v,R,g]),M=w.useMemo(()=>ate(O),[O]),$=w.useMemo(()=>{const q=[...M,...O],X=x.current;return!X||X.size===0?q:q.map(H=>{const L=X.get(H.id);return L?{...H,position:L}:H})},[M,O,N]);return{spotlightSet:B,visibleAgentIds:P,nodes:O,edges:z,allNodes:$}}function ute(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 dte({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,ute(s,t,e))return!1;return r}function hte({layoutSig:e,rf:t,stateRef:n,measuredRef:r,pinnedRef:s,positionsRef:o,paneSizeRef:l,lastInteractRef:u,autoFitDisabledRef:d,lastFitTimeRef:h,fitLeft:f}){const p=w.useRef(null),g=w.useRef("");w.useEffect(()=>{const v=setInterval(()=>{if(d.current||Date.now()-u.current<800)return;const k=n.current,b=Date.now(),x=[];for(const S of k.agents.values())A0(S,b)&&x.push({id:S.id});if(x.length===0)return;const N=[];for(const{id:S}of x){const _=r.current.get(S),E=s.current.get(S)??o.current.get(S);!_||!E||N.push({x:E.x,y:E.y,width:_.width,height:_.height})}dte({pane:l.current,viewport:t.getViewport(),boxes:N})&&f(600)},1500);return()=>clearInterval(v)},[t]),w.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 fte({stateRef:e,pinnedRef:t,positionsRef:n,canvasRef:r,clearSelection:s,primarySelectedId:o}){const[l,u]=w.useState(()=>Xee(El())),[d,h]=w.useState(null),f=w.useMemo(()=>Zee(e.current.agents.values(),l),[e.current,e.current.revision,l]),p=w.useCallback(N=>{const S=e.current.agents.get(N);S&&(u(_=>{const E=new Set(_);return E.add(N),iR(El(),E),E}),h({id:N,label:S.label}),t.current.delete(N),n.current.delete(N),s())},[s]),g=w.useCallback(()=>{o&&p(o)},[o,p]),v=d&&l.has(d.id)?d:null;w.useEffect(()=>{var N;d&&((N=r.current)==null||N.focus())},[d]);const k=w.useCallback(N=>{const S=[...N];u(_=>{const E=Qee(_,S);return E!==_&&iR(El(),E),E})},[]),b=w.useCallback(()=>{k([...l]),h(null)},[k,l]),x=w.useCallback(()=>{u(new Set),h(null),us(R0)},[]);return{removedNodes:l,lastRemoval:d,removedAgentIds:f,removeNode:p,removeSelectedNode:g,removalNotice:v,bringBack:k,bringBackAll:b,forgetRemovals:x}}function pte({stateRef:e,waitingSessions:t,removedAgentIds:n,removedNodes:r,bringBack:s}){const o=w.useRef(new Map);w.useEffect(()=>{o.current=nte(o.current,r,Date.now());const l=[...ete(t,n),...rte(e.current.agents,n,r,o.current)];l.length>0&&s(l)},[t,n,r,s])}function mte({waiting:e,running:t,connected:n=!0}){return{title:e>0?`(${e}) ${bt}`:bt,icon:n?e>0?"waiting":t>0?"running":"idle":"offline"}}const gte=Object.freeze({offline:"/state/favicon-error.svg",waiting:"/state/favicon-waiting.svg",running:"/state/favicon-syncing.svg",idle:"/favicon.svg"}),yte=Object.freeze({offline:"/state/favicon-error-32.png",waiting:"/state/favicon-waiting-32.png",running:"/state/favicon-syncing-32.png",idle:"/favicon.ico"});function wte({stateRef:e,waitingSessions:t,live:n}){const r=w.useMemo(()=>Pq(e.current.agents.values()),[e.current,e.current.revision]),s=w.useRef(null);w.useEffect(()=>{const o=mte({waiting:t.length,running:r,connected:n}),l=s.current;if(s.current=o,(l==null?void 0:l.title)!==o.title&&(document.title=o.title),(l==null?void 0:l.icon)!==o.icon){const u=document.querySelector('link[rel="icon"][type="image/svg+xml"]');u&&(u.href=gte[o.icon]);const d=document.querySelector('link[rel="icon"][sizes="32x32"]');d&&(d.href=yte[o.icon])}},[t.length,r,n])}const vte=1200,xte=1e3;function Hv(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<vte?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<xte}function bte({applyViewport:e,lastFitTimeRef:t,cameraEpochRef:n,disableAutoFit:r,markInteract:s,canvasRef:o,applyZoom:l}){const u=w.useState(()=>Bee())[0];w.useEffect(()=>{if(!u)return;const k=window.setTimeout(()=>{try{e(u,0)}catch{}t.current=Date.now()},60);return()=>window.clearTimeout(k)},[e,u]);const d=w.useRef(null),h=w.useRef(0),f=w.useCallback(()=>{h.current=Date.now()},[]),p=w.useCallback(k=>({hasSourceEvent:!!k,at:Date.now(),lastDeckFitAt:t.current,lastCanvasInputAt:h.current}),[]);return{restoredViewport:u,markCanvasInput:f,onMoveStart:k=>{ta(),Hv(p(k))&&(n.current+=1),Hv(p(k))&&r()},onMove:(k,b)=>{var x;s(),Hv(p(k))&&r(),(x=o.current)==null||x.style.setProperty("--zoom",String(b.zoom)),l(b.zoom)==="detail"&&ta(),d.current&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>qee(b),250)}}}function kte({clearSelection:e,selectAgent:t,detailOpen:n,setDetailOpen:r,detailShown:s,focusAgent:o,draggingRef:l,lodRef:u}){return{onNodeClick:(v,k)=>{if(k.type==="sessionGroup"){e();return}const b=k.type==="recapNote"?k.data.parentId:k.id;t(b,v.shiftKey,!1),!v.shiftKey&&(n&&r(!1),s?window.setTimeout(()=>{try{o(b)}catch{}},80):o(b))},onPaneClick:()=>{ta(),e()},onNodeDoubleClick:(v,k)=>{if(k.type!=="agent"&&k.type!=="recapNote")return;const b=k.type==="recapNote"?k.data.parentId:k.id;t(b,!1),window.setTimeout(()=>{try{o(b)}catch{}},80)},onNodeMouseEnter:(v,k)=>{k.type!=="agent"&&k.type!=="recapNote"||l.current||u.current==null||u.current==="detail"||DO(k.id,v.currentTarget)},onNodeMouseLeave:(v,k)=>ta(k.id)}}function Nte(){const e=w.useRef(null),t=w.useRef(null),[n,r]=w.useState({w:0,h:0});return w.useEffect(()=>{const s=t.current;if(!s||typeof ResizeObserver>"u")return;const o=new ResizeObserver(l=>{var d;const u=(d=l[0])==null?void 0:d.contentRect;u&&(e.current={width:u.width,height:u.height},r(h=>Math.abs(h.w-u.width)>40||Math.abs(h.h-u.height)>40?{w:u.width,h:u.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 jte(e){const t=w.useRef(new Map),n=w.useRef(0),r=w.useCallback(u=>{const d=t.current;let h=!1;for(const f of u.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=Ge(r),[o,l]=w.useState(0);return w.useEffect(()=>{let u=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 k=g.offsetWidth,b=g.offsetHeight;if(!k||!b)continue;const x=f.get(v);(!x||Math.abs(x.width-k)>4||Math.abs(x.height-b)>4)&&(f.set(v,{width:k,height:b}),p=!0)}p&&l(g=>g+1)};if(e.current)return;let h=0;return document.visibilityState==="hidden"?h=window.setTimeout(d,32):u=requestAnimationFrame(d),()=>{cancelAnimationFrame(u),window.clearTimeout(h)}}),{measuredRef:t,measuredVersionRef:n,sizeVersion:s,domSizeVersion:o}}function Ste(){const[e,t]=w.useState(!1);return w.useEffect(()=>{const n=window.setTimeout(()=>t(!0),2500);return()=>window.clearTimeout(n)},[]),e}function _te(){const e=w.useRef(null);return w.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 Ete({pointerFocusRef:e,nodesRef:t,stateRef:n,primarySelectedIdRef:r,providersRef:s,soundOnRef:o,keyHelpOpenRef:l,modalOpenRef:u,waitingCursorRef:d,removeSelectedRef:h,activateSoundRef:f,clearSelection:p,selectAgent:g,focusAgent:v,stepAgent:k,focusSession:b,requestClear:x,handleRelayout:N,handleFit:S,togglePause:_,toggleSessionList:E,toggleAccountsPanel:T,setDetailOpen:A,setUsageHistoryOpen:R,setUsagePanelOpen:B,setMachinePanelOpen:P,setBrowserWatchOpen:D,setSoundMenuOpen:I,setKeyHelpOpen:O,setTheme:z}){w.useEffect(()=>{const M=$=>{var F,Y;const q=$.target,X={tagName:q==null?void 0:q.tagName,isContentEditable:q==null?void 0:q.isContentEditable,role:(F=q==null?void 0:q.getAttribute)==null?void 0:F.call(q,"role"),type:q==null?void 0:q.type,pointerFocused:q!=null&&q===e.current};if($.key==="Escape"){const J=e8({overlayOpen:Qo.depth()>0,typing:Dd(X)});J==="dismiss"?Qo.dismissTop():J==="blur"?q==null||q.blur():(xee(X)&&(q==null||q.blur()),p());return}if(Pd($))return;const H=_0(q)?(Y=q==null?void 0:q.getAttribute)==null?void 0:Y.call(q,"data-id"):null,L=H&&t.current.some(J=>J.id===H)?H:null,W=wee($,L);if(W.kind==="activate"){$.preventDefault(),g(W.nodeId,W.additive);return}if(W.kind!=="node"&&!(W.nodeId==null&&c8(X,$.key))&&!u8({key:$.key,modalOpen:d8({appModal:u.current,dialogDepth:Qo.dialogDepth()}),sheetOpen:l.current})){if($.key===" "&&($.preventDefault(),_()),($.key==="c"||$.key==="C")&&x("shortcut"),($.key==="r"||$.key==="R")&&N(),($.key==="f"||$.key==="F")&&S(),($.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)A(J=>!J);else{const J=mx(n.current.agents.values());J.length>0?b(J[0].id):k(1)}if(($.key==="h"||$.key==="H")&&R(J=>!J),($.key==="u"||$.key==="U")&&B(J=>!J),($.key==="a"||$.key==="A")&&s.current.claude&&T(),($.key==="j"||$.key==="J")&&k(1),($.key==="k"||$.key==="K")&&k(-1),$.key==="w"||$.key==="W"){const J=Lq(mx(n.current.agents.values()),d.current);J&&(d.current=J.id,b(J.id))}($.key==="t"||$.key==="T")&&z(J=>J==="dark"?"light":"dark"),($.key==="m"||$.key==="M")&&s.current.claude&&o.current!==null&&f.current($.shiftKey),($.key==="s"||$.key==="S")&&P(J=>!J),($.key==="b"||$.key==="B")&&D(J=>!J),($.key==="v"||$.key==="V")&&s.current.claude&&o.current!==null&&I(J=>!J),$.key==="?"&&O(J=>!J)}};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[x,N,S,p,g,k,b,v,_])}function Cte({nodes:e,stateRef:t,pinnedRef:n,positionsRef:r,draggingRef:s,dragPatchRef:o,setDragging:l,setDragMoveTick:u,setDragTick:d,endBubble:h,markInteract:f,disableAutoFit:p,beginTrashDrag:g,trackTrashDrag:v,endTrashDrag:k,removeNode:b}){const x=w.useRef(null);return{onNodeDragStart:(E,T)=>{var A,R;if(ta(),h(),s.current=!0,o.current=new Map,l(!0),g(T.type==="agent"?((A=t.current.agents.get(T.id))==null?void 0:A.label)??"":null),f(),p(),T.type==="sessionGroup"){const B=(R=T.data)==null?void 0:R.sessionId,P=new Map;if(B)for(const D of e){const I=D.data;(I==null?void 0:I.sessionId)===B&&P.set(D.id,{x:D.position.x,y:D.position.y})}x.current={start:{x:T.position.x,y:T.position.y},members:P};return}n.current.set(T.id,{x:T.position.x,y:T.position.y})},onNodeDrag:(E,T)=>{var A;if(f(),T.type==="agent"&&v(E),T.type==="sessionGroup"){const R=x.current;if(!R)return;const B=T.position.x-R.start.x,P=T.position.y-R.start.y;for(const[I,O]of R.members){const z={x:O.x+B,y:O.y+P};n.current.set(I,z),r.current.set(I,z)}const D=o.current;if(D){for(const[I,O]of R.members)D.set(I,{x:O.x+B,y:O.y+P});D.set(T.id,{x:T.position.x,y:T.position.y})}u(I=>I+1);return}n.current.set(T.id,{x:T.position.x,y:T.position.y}),r.current.set(T.id,{x:T.position.x,y:T.position.y}),(A=o.current)==null||A.set(T.id,{x:T.position.x,y:T.position.y}),u(R=>R+1)},onNodeDragStop:(E,T)=>{f();const A=k(E,T.type==="agent");if(s.current=!1,o.current=null,l(!1),d(R=>R+1),T.type==="sessionGroup"){const R=x.current;if(R){const B=T.position.x-R.start.x,P=T.position.y-R.start.y;for(const[D,I]of R.members){const O={x:I.x+B,y:I.y+P};n.current.set(D,O),r.current.set(D,O)}}x.current=null,Xl(r.current,n.current),d(B=>B+1);return}if(n.current.set(T.id,{x:T.position.x,y:T.position.y}),r.current.set(T.id,{x:T.position.x,y:T.position.y}),A){b(T.id);return}Xl(r.current,n.current)}}}function Tte(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const Ate={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent",zcode:"ZCode"};function Rte(e){const t=e.toLowerCase(),n=Ot(Ate,t);return n!==void 0?n:t?t[0].toUpperCase()+t.slice(1):""}function Mte(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function fie(e,t=[]){const n=t.length?Mte(t.map(Rte)):Tte(e);return n?`via ccusage · local ${n} logs`:"via ccusage · local agent logs"}function $te(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 Ite(e,t){const n=t.prefs??Gx,r=fi(n.done.level),s=fi(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)",u=e.codex?`
86
+
87
+ 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?`
88
+
89
+ Waiting for a click: this browser plays no sound until the page has been used at least once. Anything you press unlocks it.`:"";return l+u+d+`
90
+
91
+ Click to set the volume and the sound of each tone, and to hear either one.`}function Ote(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 Lte(){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 ",bt," tabs are open"]}),a.jsxs("p",{children:["This browser keeps at most six live connections to one address, and other ",a.jsx("code",{children:bt})," tabs are holding them. Close one and this tab connects on its own."]})]})}function Pte({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:bt}),". Check that it is still running in your terminal — the page picks up again on its own."]})]}):Dte(n,r),!o&&a.jsx("button",{type:"button",className:"btn empty-tour",onClick:s,children:"Take the tour"})]})}function Dte(e,t){const n=Ote(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."]}),$te(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 Fte=1;function Bte(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 qte(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:Fte,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(Bte)}))}}function Ute(e,t){const n=(e||"session").replace(/[^a-z0-9._-]/gi,"_");return`${bt}-${n}-${Ub(t,8)}.json`}const VO={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},zte={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 Wte({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:zte[e]})})}const Sd={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},GO=HM;function Hte({agent:e,now:t,onOpenTool:n,onShowSummary:r,onExportSession:s,onRemove:o}){var b;const l=`${e.synthetic?"≥ ":""}${ci(e.startedAt,e.endedAt,t)}`,u=fn(e),d=u.total>0,h=e.usage.inputTokens+e.usage.outputTokens,f=new Map;for(const[x,N]of e.toolCountByName??[]){const S=GO(x);f.set(S,(f.get(S)??0)+N)}const p=e.toolErrorCount??0,g=e.tools.filter(x=>!x.endedAt).length,v=Array.from(f.entries()).sort((x,N)=>N[1]-x[1]),k=f.has("mcp")?oU(((b=e.toolCountByName)==null?void 0:b.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=MM(e);return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"hero-sep",children:"·"}),a.jsxs("span",{className:"model-chip","data-family":Od(e.model),title:x.length>0?`${e.model}
92
+ spend on this panel also covers:
93
+ ${x.join(`
94
+ `)}`:e.model,children:[Qs(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:Fe(u.total)}),a.jsx("span",{className:"hero-cost-label",children:"spend"})]}),a.jsx(zb,{cost:u})]}),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=Fd(e);if(!x)return null;const N=ud(x.at,t);return a.jsxs("section",{className:"detail-section",children:[a.jsxs("h3",{children:["Recap ",a.jsx("span",{className:"section-count",title:N.title,children:N.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,N])=>{const S=x==="mcp"?k:null,_=S==null?void 0:S.hue,E=`${N} ${Sd[x]} call${N===1?"":"s"}`;return a.jsxs("span",{className:`cat-chip cat-${x}${_!=null?" mcp-hue":""}`,style:_!=null?{"--mcp-hue":_}:void 0,title:S?`${E}, all to ${S.label}`:E,children:[a.jsx("span",{className:"cat-emoji","aria-hidden":!0,children:VO[x]}),a.jsx("span",{className:"cat-name",children:Sd[x]}),a.jsx("span",{className:"cat-count",children:N}),S&&a.jsx("span",{className:"cat-server",children:S.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:ot(e.usage.inputTokens)})]}),a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"out"}),a.jsx("b",{title:e.usage.outputTokens.toLocaleString(),children:ot(e.usage.outputTokens)})]}),a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"cache r"}),a.jsx("b",{title:e.usage.cacheReadTokens.toLocaleString(),children:ot(e.usage.cacheReadTokens)})]}),a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"cache c"}),a.jsx("b",{title:e.usage.cacheCreateTokens.toLocaleString(),children:ot(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:vM(e.prompts).length})]}),a.jsx("div",{className:"prompts",children:Vte(e.prompts).reverse().map(({pr:x,key:N})=>{const S=ud(x.at,t),_=Rb(x.text);return _?a.jsxs("details",{className:"prompt-entry prompt-injected",children:[a.jsxs("summary",{children:[a.jsx("span",{className:"prompt-time",title:S.title,children:S.label}),a.jsx("span",{className:"prompt-injected-label",children:_.label})]}),_.detail&&a.jsx("div",{className:"prompt-injected-detail",children:_.detail})]},N):a.jsxs("div",{className:"prompt-entry",children:[a.jsx("div",{className:"prompt-time",title:S.title,children:S.label}),a.jsx("div",{className:"prompt-text",children:x.text})]},N)})})]}),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(Kte,{t:x,onClick:()=>n(e.id,x.id)},x.id))})]})]})}function Vte(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 Gte={inflight:"in-flight",done:"done",err:"error"};function Kte({t:e,onClick:t}){const n=e.endedAt==null?"inflight":e.ok===!1?"err":"done",r=IM(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:Gte[n]}),e.name]}),a.jsx("span",{style:{color:"var(--muted)"},children:r})]})}function Yte(e,t){const n=qte(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=Ute(n.label,t),document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(o),1e3)}function Xte({selected:e,now:t,openTool:n,setSummaryFor:r,setDetailOpen:s,stateRef:o,removeSelectedNode:l}){return 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(!1),children:"×"}),a.jsx(Hte,{agent:e,now:t,onOpenTool:n,onShowSummary:r,onExportSession:u=>Yte(o.current,u),onRemove:l})]})}function KO({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:Vu,max:wd,step:Vx,value:t,"aria-describedby":r,onChange:s=>n(Number(s.target.value)),style:{"--sm-level":`${(t-Vu)/(wd-Vu)*100}%`}}),a.jsxs("span",{className:"sm-read",children:[t,"%"]})]})}const YO="agent-dag.character-enabled",XO="agent-dag.fm-volume",lR="agent-dag.fm-source",Zte=[{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 Jte(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 Qte(e){return e!=="0"}function ene(){return Qte(et(YO))}function tne(e){return TI(e)}function nne(){return tne(et(XO))}const qo=["light","dark"],rne={light:"Light",dark:"Dark"},cR=Zte,Uo="Give the station a name.",sne="Use an https YouTube live or channel link, or a .mp3, .aac, .ogg or .m3u8 stream.";function ane({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 one({theme:e,onTheme:t,characterEnabled:n,onToggleCharacter:r,fmVolume:s,onFmVolume:o,fmMuted:l,onFmMuted:u,fmSource:d,onFmSource:h,customFmStations:f,unavailableFmStations:p,onAddFmStation:g,onRenameFmStation:v,onRemoveFmStation:k,onClose:b}){var he;const x=ft(b),N=[...cR.map(ae=>({...ae,label:p.has(ae.value)?`${ae.label} · not live`:ae.label,unavailable:p.has(ae.value)})),...f.map(ae=>({group:"🎵 Your stations",value:Ba(ae.id),label:p.has(ae.id)?`${ae.name} · unavailable`:ae.name,unavailable:p.has(ae.id)}))],S=N.some(ae=>ae.value===d&&ae.unavailable),_=[];N.forEach((ae,Ne)=>{const Te=_[_.length-1];Te&&Te.group===ae.group?Te.indexes.push(Ne):_.push({group:ae.group,indexes:[Ne]})});const[E,T]=w.useState(!1),[A,R]=w.useState(()=>Math.max(0,N.findIndex(ae=>ae.value===d))),[B,P]=w.useState(!1),[D,I]=w.useState(""),[O,z]=w.useState(""),[M,$]=w.useState(""),[q,X]=w.useState(!1),[H,L]=w.useState(""),[W,F]=w.useState(""),Y=w.useRef(null),J=w.useRef(null),V=w.useRef(null),G=w.useRef(null),K=w.useRef(null),Z=oi(d),ee=Z?f.find(ae=>ae.id===Z):void 0;w.useEffect(()=>{const ae=N.findIndex(Ne=>Ne.value===d);R(ae<0?0:ae)},[d,f,p]),w.useEffect(()=>{X(!1),L((ee==null?void 0:ee.name)??"")},[ee==null?void 0:ee.id,ee==null?void 0:ee.name]),w.useEffect(()=>{var ae;E&&((ae=document.getElementById(`appearance-fm-option-${A}`))==null||ae.scrollIntoView({block:"nearest"}))},[A,E]),w.useEffect(()=>{if(!E)return;const ae=Ne=>{var Ie,Oe;const Te=Ne.target;!((Ie=Y.current)!=null&&Ie.contains(Te))&&!((Oe=K.current)!=null&&Oe.contains(Te))&&T(!1)};return document.addEventListener("pointerdown",ae),()=>document.removeEventListener("pointerdown",ae)},[E]);const re=ae=>{const Ne=ae.relatedTarget;Ne&&!ae.currentTarget.contains(Ne)&&T(!1)},ue=ae=>{var Te;const Ne=N[ae];Ne&&(R(ae),h(Ne.value),T(!1),(Te=Y.current)==null||Te.focus())},me=ae=>{if(Qq(ae.key)){if(!E)return;ae.preventDefault(),ae.stopPropagation(),T(!1);return}if(ae.key==="Tab"){T(!1);return}if(ae.key==="Enter"||ae.key===" "){ae.preventDefault(),E?ue(A):T(!0);return}ae.key!=="ArrowDown"&&ae.key!=="ArrowUp"&&ae.key!=="Home"&&ae.key!=="End"||(ae.preventDefault(),T(!0),R(Ne=>ae.key==="Home"?0:ae.key==="End"?N.length-1:Math.min(N.length-1,Math.max(0,Ne+(ae.key==="ArrowDown"?1:-1)))))},ie=()=>{var ae;return(ae=Y.current)==null?void 0:ae.focus()},fe=ae=>{var Te,Ie;if(ae.preventDefault(),!D.trim()){$(Uo),(Te=J.current)==null||Te.focus();return}const Ne=xB(D,O);if(!Ne){$(sne),(Ie=V.current)==null||Ie.focus();return}g(Ne),h(Ba(Ne.id)),I(""),z(""),$(""),P(!1),ie()},ve=ae=>{var Ne;if(ae.preventDefault(),!!Z){if(!H.trim()){F(Uo),(Ne=G.current)==null||Ne.focus();return}v(Z,H),X(!1),ie()}},se=ae=>{var Ie;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(ae.key))return;ae.preventDefault();const Te=(qo.indexOf(e)+(ae.key==="ArrowLeft"||ae.key==="ArrowUp"?-1:1)+qo.length)%qo.length;t(qo[Te]),(Ie=ae.currentTarget.querySelectorAll('[role="radio"]')[Te])==null||Ie.focus()},ke=ae=>{var Te;if(ae.key===" "){ae.stopPropagation();return}if(Dd(ae.target)||ae.key!=="t"&&ae.key!=="T"||ae.ctrlKey||ae.metaKey||ae.altKey)return;ae.preventDefault(),ae.stopPropagation();const Ne=e==="dark"?"light":"dark";t(Ne),ae.target.getAttribute("role")==="radio"&&((Te=ae.currentTarget.querySelectorAll('[role="radio"]')[qo.indexOf(Ne)])==null||Te.focus())},pe=ae=>{const Ne=N[ae],Te="unavailable"in Ne&&Ne.unavailable;return a.jsxs("div",{className:"appearance-source-option",role:"option",id:`appearance-fm-option-${ae}`,"aria-selected":d===Ne.value,"data-highlighted":A===ae||void 0,"data-unavailable":Te||void 0,onMouseEnter:()=>R(ae),onClick:()=>ue(ae),children:[a.jsx("span",{children:Ne.label}),d===Ne.value&&a.jsx("span",{"aria-hidden":!0,children:"✓"})]},Ne.value)};return Lt.createPortal(a.jsx("div",{className:"modal-backdrop appearance-backdrop",onClick:b,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:ae=>ae.stopPropagation(),onKeyDown:ke,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:b,"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:se,children:qo.map(ae=>a.jsxs("button",{type:"button",className:"appearance-theme",role:"radio","aria-checked":e===ae,tabIndex:e===ae?0:-1,onClick:()=>t(ae),children:[a.jsx(ane,{theme:ae}),a.jsxs("span",{className:"appearance-theme-name",children:[rne[ae],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"})})]})]},ae))})]}),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${E?" is-open":""}`,onBlur:re,children:[a.jsxs("button",{ref:Y,type:"button",id:"appearance-fm-source",className:"appearance-source-trigger",role:"combobox","aria-haspopup":"listbox","aria-expanded":E,"aria-controls":E?"appearance-fm-source-list":void 0,"aria-activedescendant":E?`appearance-fm-option-${A}`:void 0,"aria-describedby":"appearance-fm-source-note",onClick:()=>T(ae=>!ae),onKeyDown:me,children:[a.jsx("span",{children:((he=N.find(ae=>ae.value===d))==null?void 0:he.label)??cR[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"})})]}),E&&a.jsx("div",{ref:K,id:"appearance-fm-source-list",className:"appearance-source-list",role:"listbox","aria-label":"Music stations",children:_.map((ae,Ne)=>ae.group?a.jsxs("div",{role:"group","aria-labelledby":`appearance-fm-group-${Ne}`,children:[a.jsx("div",{id:`appearance-fm-group-${Ne}`,className:"appearance-source-group",role:"presentation",children:ae.group}),ae.indexes.map(pe)]},`group-${Ne}`):ae.indexes.map(pe))})]})]}),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:S?pB(oi(d)!==null):""}),a.jsxs("div",{className:"appearance-station-manage",children:[a.jsx("button",{type:"button",className:"btn appearance-station-action","aria-expanded":B,onClick:()=>{P(ae=>!ae),$("")},children:B?"Cancel":"+ Add station"}),ee&&!q&&a.jsxs("span",{className:"appearance-station-edit",children:[a.jsx("button",{type:"button",className:"btn appearance-station-action",onClick:()=>{L(ee.name),F(""),X(!0)},children:"Rename"}),a.jsx("button",{type:"button",className:"btn danger appearance-station-action",onClick:()=>{k(ee.id),ie()},children:"Remove"})]})]}),B&&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:J,className:"ap-manage-input",value:D,onChange:ae=>I(ae.target.value),"aria-invalid":M===Uo||void 0,"aria-describedby":M===Uo?"appearance-station-error":void 0,maxLength:Dl,autoFocus:!0})]}),a.jsxs("label",{className:"appearance-station-field",children:[a.jsx("span",{children:"Link"}),a.jsx("input",{ref:V,className:"ap-manage-input",value:O,onChange:ae=>z(ae.target.value),placeholder:"https://…","aria-invalid":M!==""&&M!==Uo||void 0,"aria-describedby":M&&M!==Uo?"appearance-station-error":void 0,inputMode:"url",autoComplete:"off",spellCheck:!1,maxLength:iM})]}),a.jsx("button",{type:"submit",className:"btn primary",children:"Add"}),M&&a.jsx("p",{id:"appearance-station-error",className:"appearance-station-error",role:"alert",children:M})]}),ee&&q&&a.jsxs("form",{className:"appearance-station-form is-rename",onSubmit:ve,noValidate:!0,children:[a.jsxs("label",{className:"appearance-station-field",children:[a.jsx("span",{children:"Station name"}),a.jsx("input",{ref:G,className:"ap-manage-input",value:H,onChange:ae=>L(ae.target.value),"aria-invalid":W!==""||void 0,"aria-describedby":W?"appearance-rename-error":void 0,maxLength:Dl,autoFocus:!0})]}),a.jsx("button",{type:"submit",className:"btn primary",children:"Save"}),a.jsx("button",{type:"button",className:"btn",onClick:()=>{X(!1),ie()},children:"Cancel"}),W&&a.jsx("p",{id:"appearance-rename-error",className:"appearance-station-error",role:"alert",children:W})]}),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(KO,{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:u,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 ine="With no deck tab open, get a notification wherever a sound would have played.",lne="With the ccdeck window closed, get a notification wherever a sound would have played.";function cne(e){return e?lne:ine}const une="Held off for this run — the deck was started with alerts disabled. Your choice is saved for the next start.",uR="Get notified when you're away from this tab.";function dne(e){switch(e){case"granted":return{status:"Enabled",ask:!1,ok:!0,note:uR};case"default":return{status:null,ask:!0,ok:!1,note:uR};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 Zl(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}const hne=["audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4"];function fne(e){return hne.find(t=>e(t))}const pne=4400;function mne(e){const t=e.split(";")[0];return{name:`Recorded voice.${t==="audio/mp4"?"m4a":t==="audio/ogg"?"ogg":"webm"}`,type:t}}function gne({full:e,setCustomError:t,runCustom:n,onImportCustom:r}){const[s,o]=w.useState(!1),l=w.useRef(null),u=w.useRef(null),d=w.useRef(!1),h=()=>{var p;u.current!==null&&clearTimeout(u.current),u.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=fne(x=>MediaRecorder.isTypeSupported(x)),k=new MediaRecorder(p,v?{mimeType:v}:void 0),b=[];l.current=k,k.ondataavailable=x=>{x.data.size&&b.push(x.data)},k.onerror=()=>t("Recording failed. Please try again."),k.onstop=()=>{p.getTracks().forEach(_=>_.stop()),u.current!==null&&clearTimeout(u.current),u.current=null;const x=l.current===k;if(x&&(l.current=null),o(!1),!x||!b.length)return;const N=mne(k.mimeType),S=new File(b,N.name,{type:N.type});n(()=>r(S))},k.start(200),o(!0),u.current=setTimeout(h,pne)}catch{l.current=null,p.getTracks().forEach(v=>v.stop()),t("This browser cannot record a supported audio format.")}};return w.useEffect(()=>(d.current=!1,()=>{d.current=!0,u.current!==null&&clearTimeout(u.current);const p=l.current;l.current=null,(p==null?void 0:p.state)==="recording"&&p.stop()}),[]),{recording:s,startRecording:f,stopRecording:h}}function yne({full:e,fullProps:t,runCustom:n,onCreateVoice:r}){const[s,o]=w.useState("Custom voice"),[l,u]=w.useState("Your turn"),[d,h]=w.useState(""),[f,p]=w.useState("1"),[g,v]=w.useState("1"),[k,b]=w.useState([]);return w.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const x=()=>{b(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 N=x.currentTarget.parentElement;e&&N&&!N.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=>u(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"}),k.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)}),u("Your turn")})},children:"Add spoken voice"})]})]})}function wne({customAssets:e,onImportCustom:t,onCreateVoice:n,onRenameCustom:r,onPreviewCustom:s,onDeleteCustom:o}){const[l,u]=w.useState(""),d=e.length,h=Wx(d),f=h!==null,p=f?{"aria-disabled":!0,"aria-describedby":"sm-custom-full"}:{},[g,v]=w.useState(null),k=w.useRef(0),b=w.useRef(new Map),x=w.useRef(null);w.useEffect(()=>{if(!g)return;const A=window.setTimeout(()=>v(null),4e3);return()=>window.clearTimeout(A)},[g]);const N=async A=>{u("");try{await A()}catch(R){u(R instanceof Error?R.message:"Custom audio could not be saved.")}},S=(A,R)=>{const B=Date.now(),P=zl({armedFor:g,target:A,armedAt:k.current,now:B,gapMs:Ul});if(P==="arm"){v(A),k.current=B;return}if(P==="ignore")return;v(null);const D=VY(e.map(I=>I.id),A);N(async()=>{var O;await o(A);const I=document.activeElement;I!==R&&!Dr((I==null?void 0:I.tagName)??null)||(O=D?b.current.get(D):x.current)==null||O.focus()})},{recording:_,startRecording:E,stopRecording:T}=gne({full:f,setCustomError:u,runCustom:N,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 ",zx,", 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:A=>{f&&A.preventDefault()},onChange:A=>{var B;const R=(B=A.target.files)==null?void 0:B[0];A.currentTarget.value="",R&&!f&&N(()=>t(R))}})]}),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:T,children:"Stop & save"}):a.jsx("button",{type:"button",className:"btn sm-custom-action",...p,onClick:()=>void E(),children:"Record"})]})]}),a.jsx(yne,{full:f,fullProps:p,runCustom:N,onCreateVoice:n}),e.length>0&&a.jsx("div",{className:"sm-custom-list",children:e.map(A=>a.jsxs("div",{className:"sm-custom-item",children:[a.jsx("input",{className:"ap-manage-input","aria-label":`Rename ${A.name}`,defaultValue:A.name,maxLength:80,onBlur:R=>{if(!R.target.value.trim()){R.target.value=A.name;return}N(()=>r(A.id,R.target.value))},onKeyDown:R=>{R.key==="Enter"&&R.currentTarget.blur()}}),a.jsx("span",{children:A.kind==="audio"?`${A.duration.toFixed(1)}s`:"Voice"}),a.jsx("button",{type:"button",className:"btn sm-custom-icon","aria-label":`Play ${A.name}`,onClick:()=>s(A.id),children:"Play"}),a.jsx("button",{type:"button",ref:R=>{R?b.current.set(A.id,R):b.current.delete(A.id)},className:`btn sm-custom-icon${g===A.id?" armed":""}`,onKeyDown:R=>{R.repeat&&R.preventDefault()},onClick:R=>S(A.id,R.currentTarget),"aria-label":g===A.id?`Confirm deleting ${A.name}`:`Delete ${A.name}`,title:g===A.id?"Press again to delete this sound. It cannot be brought back.":"Delete this sound",children:g===A.id?"Confirm":"Delete"})]},A.id))}),l&&a.jsx("p",{className:"sm-custom-error",role:"alert",children:l})]})}const eb="custom:";function dR(e){return`${eb}${e}`}function vne(e){return e.startsWith(eb)?e.slice(eb.length):null}const hR={done:"Turn finished","needs-input":"Claude is asking"},xne={done:"Plays when Claude or Codex finishes a turn.","needs-input":"Available in Claude Code only."};function bne({chime:e,tone:t,soundOn:n,customAssets:r,customSelections:s,onLevel:o,onFigure:l,onPreview:u,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:()=>u(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(KO,{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?dR(g):t.figure,onChange:v=>{const k=v.target.value,b=vne(k);b!==null?h(e,b):(d(e),l(e,k))},children:[a0[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:dR(v.id),children:v.name},v.id))})]})]}),a.jsx("p",{className:"sm-note",children:xne[e]})]})}function kne({onClose:e,soundOn:t,onToggleSound:n,prefs:r,onLevel:s,onFigure:o,onPreview:l,openerRef:u,customAssets:d,customSelections:h,onBuiltInSelected:f,onCustomSelected:p,onImportCustom:g,onCreateVoice:v,onRenameCustom:k,onPreviewCustom:b,onDeleteCustom:x,notifyOn:N,onToggleNotify:S,notifyVetoed:_,notifyPermission:E,onAskNotify:T}){var $;const A=dne(E),R=Zl(),B=N&&!_&&!R,P=WY(h),D=(($=d.find(q=>q.id===P))==null?void 0:$.name)??"the same custom sound",I=P?`Both tones use “${D}”. They may be harder to tell apart.`:"",O=ft(e,{popover:!0});A$(O,()=>u.current,e);const z=w.useRef(null),M=yd(!A.ask,z);return a.jsxs("div",{ref:O,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:z,type:"button",role:"switch","aria-checked":N,"aria-labelledby":"sm-notify-label",className:"switch",onClick:S,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:_?une:cne(R)})]})]}),B&&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"}),A.ask?a.jsx("button",{type:"button",className:"btn sm-channel-action",onClick:()=>{M(),T()},children:"Enable"}):a.jsxs("span",{className:"sm-channel-state","data-ok":A.ok||void 0,children:[A.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"})}),A.status]})]}),a.jsx("p",{className:"sm-note",children:A.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:Hu.map(q=>a.jsx(bne,{chime:q,tone:r[q],soundOn:t,customAssets:d,customSelections:h,onLevel:s,onFigure:o,onPreview:l,onBuiltInSelected:f,onCustomSelected:p},q))}),I&&a.jsx("p",{className:"sm-note","aria-hidden":!0,children:I}),a.jsx("p",{className:"vis-hidden",role:"status",children:I}),a.jsx(wne,{customAssets:d,onImportCustom:g,onCreateVoice:v,onRenameCustom:k,onPreviewCustom:b,onDeleteCustom:x}),a.jsxs("p",{className:"sm-foot",children:[a.jsx("kbd",{children:"M"}),"Mute or unmute sounds anywhere."]})]})}function Nne({sessionListOpen:e,toggleSessionList:t,usagePanelOpen:n,setUsagePanelOpen:r,setUsageHistoryOpen:s}){return a.jsxs("div",{className:"action-run",children:[a.jsxs("button",{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",{className:"btn icon-btn",onClick:()=>r(o=>!o),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",onClick:()=>s(o=>!o),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 jne({providers:e,accountsPanelOpen:t,toggleAccountsPanel:n,machinePanelOpen:r,setMachinePanelOpen:s,watchOn:o,watchUnseen:l,setBrowserWatchOpen:u}){return a.jsxs("div",{className:"action-run",children:[e.claude&&a.jsxs("button",{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",{className:"btn icon-btn",onClick:()=>s(d=>!d),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",onClick:()=>u(d=>!d),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 Sne({providers:e,sound:t,tones:n,customTones:r,notify:s,chimeState:o,menus:l,appearance:u,fm:d,onFeedback:h}){const{soundOn:f,toggleSound:p}=t,{tonePrefs:g,previewTone:v,changeTone:k}=n,{customSelections:b,customAssets:x,clearCustomOnly:N,selectCustomTone:S,importNotificationAudio:_,createNotificationVoice:E,renameCustomAsset:T,deleteCustomAsset:A,previewCustomAsset:R}=r,{notifyPermission:B,notifyOn:P,notifyVetoed:D,toggleNotify:I,notifySupported:O,askForNotifications:z}=s,{soundMenuOpen:M,setSoundMenuOpen:$,soundButtonRef:q,appearanceMenuOpen:X,setAppearanceMenuOpen:H,appearanceButtonRef:L}=l,{theme:W,setTheme:F,characterEnabled:Y,setCharacterEnabled:J}=u,{fmVolume:V,setFmVolume:G,fmMuted:K,setFmMuted:Z,fmSource:ee,customFmStations:re,unavailableFmStations:ue,addFmStation:me,renameFmStation:ie,removeFmStation:fe,pickFmSource:ve}=d;return a.jsxs("div",{className:"action-run action-run-utility",children:[e.claude&&f!==null&&a.jsxs("div",{className:"sound-slot",children:[a.jsxs("button",{ref:q,className:"btn icon-btn",onClick:()=>$(se=>!se),...Or(!1),title:Ite(e,{on:f===!0,locked:o==="locked",prefs:g}),"aria-label":`Sound settings, ${f?"on":"off"}`,"aria-haspopup":"dialog","aria-expanded":M,"aria-controls":M?"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"}),f?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"})]}),M&&a.jsx(kne,{onClose:()=>$(!1),soundOn:f===!0,onToggleSound:p,prefs:g,onLevel:(se,ke)=>k(se,{level:ke}),onFigure:(se,ke)=>k(se,{figure:ke}),onPreview:se=>v(se),customAssets:x,customSelections:b,onBuiltInSelected:N,onCustomSelected:S,onImportCustom:_,onCreateVoice:E,onRenameCustom:T,onPreviewCustom:R,onDeleteCustom:A,notifyOn:P,onToggleNotify:I,notifyVetoed:D,notifyPermission:O?B:"unsupported",onAskNotify:z,openerRef:q})]}),a.jsxs("div",{className:"appearance-slot",children:[a.jsx("button",{ref:L,className:"btn icon-btn",onClick:()=>{$(!1),H(se=>!se)},title:"Appearance settings","aria-label":`Appearance settings, ${W} theme, character ${Y?"shown":"hidden"}`,"aria-haspopup":"dialog","aria-expanded":X,"aria-controls":X?"appearance-menu":void 0,children:W==="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"})})}),X&&a.jsx(one,{theme:W,onTheme:F,characterEnabled:Y,onToggleCharacter:()=>J(se=>!se),fmVolume:V,onFmVolume:G,fmMuted:K,onFmMuted:()=>Z(se=>!se),fmSource:ee,onFmSource:ve,customFmStations:re,unavailableFmStations:ue,onAddFmStation:me,onRenameFmStation:ie,onRemoveFmStation:fe,onClose:()=>H(!1)})]}),a.jsxs("button",{className:"btn icon-btn",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"})]})]})}const _ne=5*6e4,Ene=6e4;function Cne({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>=_ne}function fR(e=new Date){return u$("month",e)}function Tne(e){const t=Wd(e);return{cost:t.cost,tokens:t.tokens}}function pR(e){return e>0?Fe(e):"$0.00"}const Ane=new Set(["idle","checking","current","downloading","ready","error"]);function mR(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.status!="string"||!Ane.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 Rne(e){return(e==null?void 0:e.status)==="ready"&&e.version?{version:e.version}:null}function Mne(e=typeof navigator>"u"?"":navigator.userAgent){var t;return((t=/\bccdeck-desktop\/(\d[^\s]*)/.exec(e))==null?void 0:t[1])??null}const _d="Restart to update",ZO=3e4;function $ne(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 Ine(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 ${_d} comes first`}}function One(e){const t=e==null?void 0:e.reason;return t==="app_disconnected"||t==="update_not_ready"?t:"refused"}function Lne(e,t,n=typeof navigator>"u"?"":navigator.userAgent){const r=$ne(n),s=`Use ${_d} 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, ${_d} is in ${r}.`;case"timeout":return`ccdeck has not restarted after ${ZO/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 Pne="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",Vv="click for what's new";function Dne(e){if(e.checkDisabled)return`${Pne} · ${Vv}`;if(e.checking)return`Asking npm for the newest release… · ${Vv}`;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 · ${Vv}, and to check npm now`}function Fne(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 Bne(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 JO(e){return e?`${e.kind}:${e.to}`:""}function qne(e,t){return e!=null&&t!==JO(e)}function Une({readyAppUpdate:e,notice:t,noticeOpen:n,version:r,chipVersion:s,versionChecking:o,now:l,openReleaseNotes:u,showNotice:d,loadVersion:h}){return a.jsx(a.Fragment,{children:e?(()=>{const f=Ine(Mne()??s,e.version);return a.jsxs("button",{type:"button",className:"v ready",onClick:u,"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:()=>{u(),d()},"aria-haspopup":"dialog","aria-label":Bne({...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?cd(l-r.checkedAt):null,checkFailedAgo:r!=null&&r.checkFailedAt&&r.checkFailedAt>(r.checkedAt??0)?cd(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:()=>{u(),h(!0)},"aria-busy":o||void 0,"aria-haspopup":"dialog","aria-label":Fne(f),title:Dne(f),children:["v",f.running]})})()})}function zne({live:e,paused:t,pauseGate:n,monthUsageRef:r,monthlyUsage:s,monthlyUsageUnavailable:o}){return a.jsxs("span",{className:"status",children:[(()=>{const l=NU({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 · ${pR(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:ot(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:pR(s.cost)})]}):a.jsx("span",{className:"month-usage-pending",children:o?"unavailable":"…"})]})]})}function Wne({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:
95
+ ${e.map(s=>` ${s.label}: ${li(s.waiting)} (${cd(r-s.waiting.since)})`).join(`
96
+ `)}`,"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 tb={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 Hne(e){return e==="on"?`Notifications on. ${tb.on}.`:e==="blocked"?`${tb.blocked}.`:""}function Vne({notifySaid:e}){return a.jsx("span",{className:e==="on"?"notify-said":"notify-said notify-said-blocked","aria-hidden":!0,title:tb[e],children:e==="on"?"notifications on":"notifications blocked"})}function Gne({versionCheck:e,welcome:t,desktopUpdate:n,pause:r,monthly:s,announcements:o,notify:l,waitingSessions:u,waitingCursorRef:d,focusSession:h,live:f,now:p,incidents:g}){const{version:v,notice:k,noticeOpen:b,showNotice:x,versionChecking:N,loadVersion:S}=e,{chipVersion:_,openReleaseNotes:E}=t,{readyAppUpdate:T}=n,{paused:A,pauseGate:R}=r,{monthlyUsage:B,monthlyUsageUnavailable:P,monthUsageRef:D}=s,{blockedSaid:I,watchSaid:O,incidentSaid:z}=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:BW,width:19,height:16,alt:""}),a.jsx("img",{className:"logo logo-on-light",src:qW,width:19,height:16,alt:""}),a.jsx("h1",{children:bt}),a.jsx(Une,{readyAppUpdate:T,notice:k,noticeOpen:b,version:v,chipVersion:_,versionChecking:N,now:p,openReleaseNotes:E,showNotice:x,loadVersion:S})]}),a.jsx(zne,{live:f,paused:A,pauseGate:R,monthUsageRef:D,monthlyUsage:B,monthlyUsageUnavailable:P}),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:O}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:z}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Hne(M)}),a.jsx(UW,{incidents:g}),u.length>0&&a.jsx(Wne,{waitingSessions:u,waitingCursorRef:d,focusSession:h,now:p}),M&&a.jsx(Vne,{notifySaid:M})]})}function Kne({selected:e,now:t,selectedIds:n,focusAgent:r,clearSelection:s}){const o=fn(e),l=Math.max(0,((e.endedAt??t)-e.startedAt)/1e3),u=e.state==="active"?$b(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?`
97
+ ${Fe(o.total)} spent${u?` · ${u}`:""}`:""}`,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:[Fe(o.total),u?a.jsxs("span",{className:"selected-rate",children:[" · ",u]}):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 Yne({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"} ${Sd[o]} tools`,children:[a.jsx(Wte,{cat:o}),a.jsx("span",{className:"cat-name",children:Sd[o]})]},o)})})}const Xne=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(",");function Zne(e){var n,r;const t=e.target;!(t!=null&&t.closest)||t.closest(Xne)!==e.currentTarget||(e.preventDefault(),(r=(n=document.activeElement)==null?void 0:n.blur)==null||r.call(n))}function Jne({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 Qne({canvasRef:e,bubbling:t,dragging:n,trash:r,zoom:s,viewport:o,stateRef:l,peek:u,children:d}){const{trashDragging:h,trashState:f,trashPhase:p,trashZoneRef:g,trashLabel:v}=r,{lod:k,lodRef:b}=s,{markCanvasInput:x}=o,{peekAgent:N,peekLabel:S,peekRecap:_,peekBounds:E}=u;return a.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${t?" bubbling":""}${n?" dragging-any":""}${h&&f==="over"?" trash-hover":""}`,"data-lod":k,ref:e,onMouseDownCapture:Zne,onPointerDownCapture:x,onPointerUpCapture:x,onWheelCapture:x,onFocusCapture:T=>{const A=T.target;if(!_0(A)||b.current==null||b.current==="detail")return;const R=A.getAttribute("data-id");R&&l.current.agents.has(R)&&A.matches(":focus-visible")&&DO(R,A,"focus")},onBlurCapture:T=>{var R,B;const A=(B=(R=T.target).getAttribute)==null?void 0:B.call(R,"data-id");A&&ta(A)},children:[d,Bu(p)&&a.jsx(Jne,{trashZoneRef:g,trashState:f,trashPhase:p,trashLabel:v}),a.jsx(jee,{agentFor:N,recapFor:_,labelFor:S,bounds:E})]})}function ere({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 ${bt}…`:(()=>{const s=bU({connected:n,paused:r});return a.jsxs(a.Fragment,{children:[`Lost connection to the ${bt} server. Reconnecting…`,s&&a.jsx("span",{className:"conn-sub",children:s})]})})()]})}function tre({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 ",bt," 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 nre=3e4;function rre({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function sre({bundle:e,running:t,pending:n,lastTried:r}){return t?rre({bundle:e,running:t,lastTried:r})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function are(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function ore({asked:e,reported:t}){return t?t!==e:!1}function QO(e){const t=e.thresholdMs??nre;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 ire(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 lre(e,t){return e?t==null?"auto when idle":`auto in ${ire(t)}`:"auto-restart off"}function gR(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function cre(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 ure(e){const t=QO(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 yR={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — run:",not_writable:"the install directory is not writable by this user — run:",opted_out:"installs are off (AGENTS_DECK_NO_INSTALL=1) — run:",retired_name:"this install came from a name that is no longer published — run:"};function dre({notice:e,version:t,dismissNotice:n,upgradeState:r,startUpgrade:s,copyCommand:o,cmdCopied:l,autoRestart:u,toggleAutoRestart:d,askRestart:h,restartCopy:f,restartFuseMs:p,restarting:g}){var v,k,b;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(),...Or(g),title:`Stop this process and bring it back on the same port. The canvas replays from the event log.
98
+
99
+ 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":u,onClick:d,"aria-label":"Auto-restart when idle",title:u?"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:lre(u,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:[bt," 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,...Or(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}),...Or(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:((k=t==null?void 0:t.upgrade)==null?void 0:k.error)??"",children:[(t==null?void 0:t.upgradeMode)==="npx"?"update failed":"install failed",": ",((b=t==null?void 0:t.upgrade)==null?void 0:b.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:":yR.npx}):t!=null&&t.upgradeBlocked?a.jsx("span",{className:"ver-sub",children:Ot(yR,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 hre({restart:e,versionCheck:t,upgrade:n,oldNameNotice:r,everConnected:s,live:o,paused:l}){const{autoRestart:u,toggleAutoRestart:d,restarting:h,restartMode:f,restartedTo:p,askRestart:g,restartCopy:v,restartFuseMs:k}=e,{version:b,notice:x,noticeOpen:N,dismissNotice:S}=t,{upgradeState:_,startUpgrade:E,copyCommand:T,cmdCopied:A}=n,{oldName:R,oldNameOpen:B,dismissOldName:P}=r;return p?a.jsxs("div",{className:"ver-banner done",role:"status",children:[a.jsx("span",{className:"ver-dot"}),a.jsxs("strong",{children:["Restarted — now running v",p,"."]}),a.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):s&&!o?a.jsx(ere,{restarting:h,restartMode:f,live:o,paused:l}):N&&x?a.jsx(dre,{notice:x,version:b,dismissNotice:S,upgradeState:_,startUpgrade:E,copyCommand:T,cmdCopied:A,autoRestart:u,toggleAutoRestart:d,askRestart:g,restartCopy:v,restartFuseMs:k,restarting:h}):B&&R?a.jsx(tre,{oldName:R,version:b,dismissOldName:P}):null}function fre(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function pre(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 mre(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function gre(e,t){const n=mre(e),r=(...l)=>[n?`${n} on the canvas`:null,...l,"layout, pins and selection"].filter(u=>u!==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`,u=t.decks>2?`, one of ${t.decks} decks sharing it`:"";return{goes:r(),stays:[`the event log — ${l}${u}`,"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 yre({agentCount:e,onConfirm:t,onCancel:n}){const r=w.useRef(null),s=ft(n,{focusRef:r,layer:Zq}),[o,l]=w.useState(null);w.useEffect(()=>{let p=!1;return fetch("/api/clear").then(g=>g.ok?g.json():null).then(g=>{p||l(pre(g))}).catch(()=>{}),()=>{p=!0}},[]);const{goes:u,stays:d,final:h,confirm:f}=gre(e,o);return a.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal clear-confirm",onClick:p=>p.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:u.map(p=>a.jsx("span",{children:p},p))}),a.jsx("dt",{children:"Stays"}),a.jsx("dd",{children:d.length>0?d.map(p=>a.jsx("span",{children:p},p)):a.jsx("span",{children:"nothing"})})]}),h&&a.jsx("p",{className:"cc-final",children:h}),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:f})]})]})]})})}const nb=[{value:"bug",label:"Bug",question:"What happened?",placeholder:`I was trying to…
100
+ 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 eL(e){return nb.find(t=>t.value===e)??nb[0]}const rb=3,Gv=120,wre=1e4,vre=200,xre="Write something first.";function wR(e){return e.trim()!==""}function bre(e){var o;const t=e.trim();if(t==="")return"";const n=vR(t.split(/\r?\n/,1)[0]),r=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,s=Kv(r).length>=rb?Kv(r):Kv(n);return Nre(s.length>=rb?s:vR(t))}function kre(e,t){const n=bre(t);return n.length>=rb?n:`${eL(e).label}: ${n}`}function vR(e){return e.replace(/\s+/g," ").trim()}function Kv(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function Nre(e){if(e.length<=Gv)return e;const t=e.slice(0,Gv-1),n=t.lastIndexOf(" ");return`${(n>=Gv/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function jre({kind:e,body:t,contact:n}){const r={kind:e,title:kre(e,t),body:t.trim()};return n.trim()!==""&&(r.contact=n.trim()),r}function Sre(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 _re={darwin:"macOS",win32:"Windows",linux:"Linux"};function Ere(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),r=t===-1?"":e.slice(t+1),s=_re[n]??n;return r?`${s} · ${r}`:s}function Cre(e){return e?`ccdeck ${e.appVersion} · ${Ere(e.platform)}`:null}const Tre="sent with it",Are="Your ccdeck version and system are sent with it.",Rre="Add details",Mre="How to reach you",$re="Email or GitHub @name",Ire="Only if you would like an answer.",Ore=["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 Lre(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function Pre(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function Dre(e){return/mac|iphone|ipad/i.test(e)?["⌘","Enter"]:["Ctrl","Enter"]}function Fre(e){return[...e].length===1}const tL="Thanks — feedback sent.";function xR(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 Bre(e){return e==="sending"?"Sending…":e==="sent"?tL:""}const bR=1400,qre=160;function Ure({kind:e,onChange:t}){return a.jsxs("fieldset",{className:"fb-kinds",children:[a.jsx("legend",{className:"vis-hidden",children:"Kind of feedback"}),nb.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)}),n.label]},n.value))]})}const nL="fb-details";function zre({open:e,onToggle:t}){return a.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":nL,onClick:t,children:[Rre,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 Wre({open:e,contact:t,onContact:n}){const r=w.useId();return a.jsx("div",{id:nL,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:[Mre,a.jsx("span",{className:"fb-optional",children:"optional"})]}),a.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:vre,autoComplete:"email",placeholder:$re,"aria-describedby":r,onChange:s=>n(s.target.value),onKeyDown:s=>{Pre(s.nativeEvent)&&s.preventDefault()}}),a.jsx("p",{id:r,className:"fb-hint",children:Ire})]}),a.jsx("div",{className:"fb-where",children:Ore.map(s=>a.jsx("p",{children:s},s))})]})})})}const Ko=3,Hre=5*1024*1024,Vre=12*1024*1024,sb=8192,Gre=64*1024,Kre=256*1024,Yre=.92,Xre=640,rL=.9,Zre=.85,Jre=6,Qre=512*1024,Ed={png:"image/png",jpeg:"image/jpeg"},ese={png:"png",jpeg:"jpg"},tse=[137,80,78,71,13,10,26,10],nse=[255,216,255];function sL(e){const t=n=>e.length>=n.length&&n.every((r,s)=>e[s]===r);return t(tse)?"png":t(nse)?"jpeg":null}function rse(e){const t=sL(e);return t==="png"?sse(e):t==="jpeg"?ose(e):null}function sse(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 ase(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function ose(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(ase(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 kR(e,t){return e.bytes>t||e.width>sb||e.height>sb}function ise(e){return Math.min(Hre,Vre-Gre-e)}function aL(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function lse(e,t){const n=sb/Math.max(e.width,e.height),r=e.bytes>t?Math.sqrt(t/e.bytes)*rL:1;return aL(e,Math.min(1,n,r))}async function cse(e,t,n){let r=lse(e,t),s=e.format;for(let o=0;o<Jre;o++){const l=await n(r,s,s==="jpeg"?Yre:void 0);if(!l)return null;if(l.size<=t)return{...r,blob:l,format:s};if(s==="png"){s="jpeg";continue}if(r=aL(r,Math.min(Zre,Math.sqrt(t/l.size)*rL)),Math.max(r.width,r.height)<Xre)return null}return null}async function use(e,t,n){const r=new Uint8Array(await e.slice(0,Qre).arrayBuffer()),s=sL(r);if(!s)return{ok:!1,problem:"type"};if(t<Kre)return{ok:!1,problem:"no_room"};const o=e.type===Ed[s]?e:new Blob([e],{type:Ed[s]}),l=rse(r);if(l&&!kR({...l,bytes:e.size},t))return{ok:!0,blob:o,resized:null};const u=await n(e).catch(()=>null);if(!u)return{ok:!1,problem:"unreadable"};try{const d={width:u.width,height:u.height,bytes:e.size,format:s};if(!kR(d,t))return{ok:!0,blob:o,resized:null};const h=await cse(d,t,u.encoder);return h?{ok:!0,blob:h.blob,resized:{width:h.width,height:h.height}}:{ok:!1,problem:"too_large"}}finally{u.release()}}function dse(e){return({width:t,height:n},r,s)=>new Promise(o=>{const l=document.createElement("canvas");l.width=t,l.height=n;const u=l.getContext("2d");if(!u)return o(null);r==="jpeg"&&(u.fillStyle="white",u.fillRect(0,0,t,n)),u.imageSmoothingQuality="high",u.drawImage(e,0,0,t,n),l.toBlob(d=>{l.width=0,l.height=0,o(d)},Ed[r],s)})}const hse=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:dse(t),release:()=>t.close()}};function fse(e){return e.includes("Files")}function pse({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function mse(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function gse(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===Ed.jpeg?"jpeg":"png";n.append("images",r,`image-${s+1}.${ese[o]}`)}),{method:"POST",body:n}}const yse="Add screenshot",NR="PNG or JPEG, up to three. You can also paste one, or drop it on this dialog.",wse="A screenshot can show emails, costs and paths. Crop out what should not be seen.",jR="Three images at most. Remove one to add another.";function vse(e,t,n){const r=n?`, resized to ${n.width} × ${n.height} to fit`:"";return`Replace image ${e+1}: ${t}${r}`}function xse(e,t){const n=`${e} of ${Ko}`;return t>0?`${n} · ${t} resized to fit`:n}function bse(e){return`Three images at most, so ${e===1?"one was":`${e} were`} left out.`}function kse(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function Nse(e,t){const n=kse(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 oL="image/png,image/jpeg";function iL({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 jse({images:e,buttonRef:t}){const n=w.useRef(null),r=e.shots.length>=Ko;return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:t,type:"button",className:"fb-tool",title:NR,"aria-describedby":"fb-attach-hint",onClick:()=>{var s;return r?e.sayFull():(s=n.current)==null?void 0:s.click()},children:[a.jsx(iL,{}),yse]}),a.jsx("span",{id:"fb-attach-hint",hidden:!0,children:NR}),a.jsx("input",{ref:n,type:"file",accept:oL,multiple:!0,hidden:!0,onChange:s=>{e.add(Array.from(s.target.files??[])),s.target.value=""}})]})}function Sse({images:e,addRef:t}){const n=w.useRef(new Map),r=w.useRef(null),s=w.useRef(null),o=w.useRef(null),[l,u]=w.useState(null),{shots:d}=e,h=xse(d.length,d.filter(g=>g.resized).length);w.useLayoutEffect(()=>{var g;l!==null&&((g=l==="add"?t.current:n.current.get(l))==null||g.focus(),u(null))},[l,t]),w.useEffect(()=>{var g;e.problem&&((g=r.current)==null||g.scrollIntoView({block:"nearest"}))},[e.problem]);function f(g){u(mse(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:oL,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":vse(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:k=>{k?n.current.set(g.id,k):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:wse})]}),e.problem&&a.jsx("p",{ref:r,className:"fb-error",role:"alert",children:e.problem})]})}function _se(e,t,n){return n?e.map(r=>r.id===t.id?t:r):[...e,t]}function Ese(e,t,n){return n?e.map(r=>r.id===t?n:r):e.filter(r=>r.id!==t)}function Cse(){const[e,t]=w.useState([]),[n,r]=w.useState(""),[s,o]=w.useState(""),l=w.useRef([]),u=w.useRef(null),d=w.useRef(1),h=w.useRef(!0),f=w.useCallback(E=>{l.current=E(l.current),t(l.current)},[]);w.useEffect(()=>(h.current=!0,()=>{h.current=!1;for(const E of l.current)URL.revokeObjectURL(E.url)}),[]);const p=w.useCallback(async(E,T)=>{const A=l.current.reduce((M,$)=>{var q;return M+($.id===(T==null?void 0:T.id)?0:((q=$.blob)==null?void 0:q.size)??0)},0),R=(T==null?void 0:T.id)??d.current++,B=URL.createObjectURL(E),P={id:R,name:E.name||"image",url:B,blob:null,resized:null};let D=!1;const I=()=>{D||(D=!0,f(M=>_se(M,P,T!==void 0)))},O=await use(E,ise(A),async M=>(I(),hse(M))).catch(()=>({ok:!1,problem:"unreadable"})),z=l.current.some(M=>M.id===R);return!h.current||!z&&(D||T)?(URL.revokeObjectURL(B),T&&URL.revokeObjectURL(T.url),""):O.ok?(I(),T&&URL.revokeObjectURL(T.url),f(M=>M.map($=>$.id===R?{...$,blob:O.blob,resized:O.resized}:$)),""):(URL.revokeObjectURL(B),D&&f(M=>Ese(M,R,T)),Nse(O.problem,E.name||"image"))},[f]),g=w.useCallback(async E=>{r("");const T=[];let A=0,R=0;for(const P of E){if(!h.current)return;if(l.current.length>=Ko){A++;continue}const D=l.current.length,I=await p(P);I&&T.push(I),l.current.length>D&&R++}if(!h.current)return;A>0&&T.push(R===0&&T.length===0?jR:bse(A)),r(T.join(" "));const B=l.current.length;R>0&&o(`${R===1?"Image":`${R} images`} added, ${B} of ${Ko}.`)},[p]),v=w.useCallback(async(E,T)=>{r("");const A=l.current.find(P=>P.id===E);if(!A)return g([T]);const R=await p(T,A);if(!h.current)return;r(R);const B=l.current.findIndex(P=>P.id===E);!R&&B!==-1&&o(`Image ${B+1} replaced, ${l.current.length} of ${Ko}.`)},[g,p]),k=w.useCallback(E=>{u.current=(u.current??Promise.resolve()).then(E).catch(()=>{})},[]),b=w.useCallback(E=>{E.length>0&&k(()=>g(E))},[g,k]),x=w.useCallback((E,T)=>{const A=T[0];A&&k(()=>v(E,A))},[k,v]),N=w.useCallback(E=>{const T=l.current.find(A=>A.id===E);T&&(URL.revokeObjectURL(T.url),f(A=>A.filter(R=>R.id!==E)),r(""),o(`Image removed, ${l.current.length} of ${Ko}.`))},[f]),S=w.useCallback(()=>r(jR),[]),_=w.useCallback(async()=>(await u.current,l.current.flatMap(E=>E.blob?[E.blob]:[])),[]);return{shots:e,problem:n,announcement:s,add:b,replace:x,remove:N,sayFull:S,ready:_}}function Tse(){const[e,t]=w.useState(null);return w.useEffect(()=>{let n=!0;return fetch("/api/feedback").then(r=>r.ok?r.json():null).then(r=>{n&&t(Sre(r))}).catch(()=>{}),()=>{n=!1}},[]),e}function Ase(e){const[t,n]=w.useState({state:"idle"}),r=w.useRef(!1);async function s(o){if(lr(r.current)){r.current=!0,n({state:"sending"});try{const l=await e.ready(),u=await fetch("/api/feedback",gse(jre(o),l)),d=await u.json().catch(()=>null);n(u.ok&&(d!=null&&d.ok)?{state:"sent"}:{state:"failed",message:xR(u.status,d==null?void 0:d.reason,d==null?void 0:d.errors)})}catch{n({state:"failed",message:xR(0,null)})}finally{r.current=!1}}}return{outcome:t,sending:t.state==="sending",send:s}}function Rse(e,t){const[n,r]=w.useState(!1),s=w.useRef(t);return s.current=t,w.useEffect(()=>{if(!e)return;const o=window.setTimeout(()=>r(!0),bR),l=window.setTimeout(()=>s.current(),bR+qre);return()=>{window.clearTimeout(o),window.clearTimeout(l)}},[e]),n}function Mse(){var t;return typeof navigator>"u"?"":((t=navigator.userAgentData)==null?void 0:t.platform)||navigator.platform||""}function lL({onClose:e,initialKind:t,initialBody:n}){const r=w.useRef(null),s=w.useRef(null),o=w.useRef(null),l=w.useRef(null),u=w.useRef(0),d=ft(e,{focusRef:r}),[h,f]=w.useState(t??"bug"),[p,g]=w.useState(n??""),[v,k]=w.useState(""),[b,x]=w.useState(!1),[N,S]=w.useState(!1),[_,E]=w.useState(!1),T=Cse(),A=Cre(Tse()),{outcome:R,sending:B,send:P}=Ase(T),D=R.state==="sent",I=Rse(D,e),O=eL(h),z=N&&!wR(p),[M,$]=Dre(Mse());w.useEffect(()=>{var ee,re;const K=l.current;if(!K)return;const Z=K.contains(document.activeElement)||Dr(((ee=document.activeElement)==null?void 0:ee.tagName)??null);K.inert=D,D&&Z&&((re=s.current)==null||re.focus())},[D]);function q(K){var Z;if(K.preventDefault(),!wR(p)){S(!0),(Z=r.current)==null||Z.focus();return}P({kind:h,body:p,contact:v})}const X=!D,H=K=>fse(Array.from(K.dataTransfer.types));function L(K){!H(K)||!X||(K.preventDefault(),u.current++,E(!0))}function W(K){H(K)&&(K.preventDefault(),K.dataTransfer.dropEffect=X?"copy":"none")}function F(K){H(K)&&(u.current=Math.max(0,u.current-1),u.current===0&&E(!1))}function Y(K){H(K)&&(K.preventDefault(),u.current=0,E(!1),X&&T.add(Array.from(K.dataTransfer.files)))}function J(K){K.target!==K.currentTarget||!H(K)||(K.preventDefault(),K.dataTransfer.dropEffect="none")}function V(K){H(K)&&K.preventDefault()}function G(K){if(!X)return;const Z=Array.from(K.clipboardData.files),ee=K.target,re=ee instanceof HTMLTextAreaElement||ee instanceof HTMLInputElement,ue=Array.from(K.clipboardData.types).includes("text/plain");pse({files:Z.length,hasText:ue,intoTextField:re})&&(K.preventDefault(),T.add(Z))}return a.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",onDragOver:J,onDrop:V,"data-leaving":I||void 0,children:a.jsxs("div",{ref:d,className:"modal feedback-dialog",onClick:K=>K.stopPropagation(),onDragEnter:L,onDragOver:W,onDragLeave:F,onDrop:Y,onPaste:G,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:Bre(R.state)}),a.jsxs("div",{className:"fb-stage",children:[a.jsxs("form",{ref:l,className:"fb-form",onSubmit:q,onKeyDown:K=>{Lre(K.nativeEvent)&&(K.preventDefault(),K.currentTarget.requestSubmit())},noValidate:!0,children:[a.jsxs("section",{className:"modal-body fb-body",children:[a.jsx(Ure,{kind:h,onChange:f}),a.jsxs("div",{className:"fb-compose",children:[a.jsx("label",{className:"fb-label",htmlFor:"fb-body",children:O.question}),a.jsx("textarea",{ref:r,id:"fb-body",className:"ap-manage-input fb-message",value:p,maxLength:wre,rows:5,placeholder:O.placeholder,onChange:K=>g(K.target.value),"aria-invalid":z||void 0,"aria-describedby":z?"fb-body-error":void 0,required:!0}),z&&a.jsx("p",{id:"fb-body-error",className:"fb-error",children:xre}),a.jsx(Sse,{images:T,addRef:o}),a.jsxs("div",{className:"fb-tools",children:[a.jsx(jse,{images:T,buttonRef:o}),a.jsx(zre,{open:b,onToggle:()=>x(K=>!K)})]}),a.jsx(Wre,{open:b,contact:v,onContact:k})]}),a.jsx("p",{className:"fb-facts",children:A?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"fb-facts-value",children:A})," — ",Tre]}):Are}),R.state==="failed"&&a.jsx("p",{className:"fb-error",role:"alert",children:R.message})]}),a.jsxs("div",{className:"fb-foot",children:[a.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[a.jsx("kbd",{"data-symbol":Fre(M)||void 0,children:M}),a.jsx("kbd",{children:$})," to send"]}),a.jsx("button",{type:"button",className:"btn",onClick:e,children:"Cancel"}),a.jsx("button",{type:"submit",className:"btn primary fb-send","aria-keyshortcuts":"Meta+Enter Control+Enter",...Or(B),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…"})]})})]})]}),D&&a.jsxs("div",{className:"fb-done",children:[a.jsx(fd,{}),a.jsx("p",{className:"fb-done-line",children:tL})]})]}),a.jsx("div",{className:"fb-drop","aria-hidden":"true","data-active":_||void 0,children:a.jsxs("div",{className:"fb-drop-frame",children:[a.jsx(iL,{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 $se="Press Esc first if a key does nothing.",Ise=[{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 — Undo 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 Ose({onClose:e,onTour:t}){const n=ft(e);return a.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:a.jsxs("div",{ref:n,className:"modal key-help",onClick:r=>r.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:Ise.map(r=>a.jsxs(w.Fragment,{children:[a.jsx("h3",{className:"kh-group",children:r.title}),r.rows.map(s=>a.jsxs("div",{className:"sc",children:[a.jsx("kbd",{children:s.cap}),a.jsx("span",{children:s.action})]},`${r.title}:${s.cap}:${s.action}`))]},r.title))}),a.jsx("p",{className:"kh-foot",children:$se})]})]})})}function Lse(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 Pse({request:e,waiting:t,busy:n,now:r,onAccept:s,onDecline:o,onLater:l}){const u=w.useRef(null),d=ft(l,{focusRef:u}),h=ea(n,"accept"),f=ea(n,"dismiss");return a.jsx("div",{className:"modal-backdrop",onClick:l,role:"presentation",children:a.jsxs("div",{ref:d,className:"modal lan-ask",onClick:p=>p.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 ",e0(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:u,className:"btn",disabled:f.disabled,"aria-busy":f.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:h.disabled,"aria-busy":h.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 Dse({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:r,deferLanPair:s}){const{request:o,waiting:l}=Lse(e,t.current);return o?a.jsx(Pse,{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 Fse(e,t){return`${e}#${t}`}function Bse(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 u=Fse(l.key,l.since);if(r.has(u)||MV(l.key,o.email,t,n))continue;const d=o.email??"";s.push({id:u,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 qse(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 Use({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function zse(e){return e===1?"Account needs your attention":"Accounts need your attention"}function Wse(e){return`${e===1?"One Claude account needs":`${e} Claude accounts need`} you to sign in again.`}const Hse="Login expired",Vse="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.",Gse="The account stays marked in the Accounts panel. This will not ask again until it has worked and stopped again.";function Kse({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:Vse})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:Wse(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:Hse}),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:Gse,onClick:n,children:"Not now"}),s&&a.jsx("button",{type:"button",className:"btn primary",ref:r,onClick:()=>t(s),children:"Sign in again"})]})]})}function Yse({rows:e,onSignIn:t,onLater:n}){const r=w.useRef(null),s=ft(n,{focusRef:r});return a.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal reauth-ask",onClick:o=>o.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:zse(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(Kse,{rows:e,onSignIn:t,onLater:n,firstRef:r})]})})}function Xse({rows:e,signingIn:t,signIn:n,signedIn:r,refresh:s,closeSignIn:o,later:l}){const u=w.useRef(!1),d=t!=null||Use({rows:e.length,ours:u.current,dialogs:Qo.dialogDepth()});return u.current=d,t?a.jsx(G$,{email:t.email||null,onClose:o,onChanged:s,onSignedIn:r}):d?a.jsx(Yse,{rows:e,onSignIn:n,onLater:l},e.length===1?"one":"many"):null}const Zse={"//":["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.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.
101
+
102
+ 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.
103
+
104
+ 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.
105
+
106
+ 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.
107
+
108
+ 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.
109
+
110
+ 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".
111
+
112
+ **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.
113
+
114
+ \`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.
115
+
116
+ **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.
117
+
118
+ 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.
119
+
120
+ 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.
121
+
122
+ 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.
123
+
124
+ 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.
125
+
126
+ 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.
127
+
128
+ 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.
129
+
130
+ What you are reading is the first version that does not.
131
+
132
+ 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.
133
+
134
+ 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.
135
+
136
+ 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.
137
+
138
+ 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.
139
+
140
+ 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.
141
+
142
+ The count of what is behind it is on the heading's tooltip, so collapsing it does not hide how much there is.
143
+
144
+ **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.
145
+
146
+ 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.
147
+
148
+ \`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.
149
+
150
+ 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.
151
+
152
+ **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.
153
+
154
+ **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.
155
+
156
+ **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.
157
+
158
+ **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.
159
+
160
+ **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.
161
+
162
+ **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.
163
+
164
+ 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.
165
+
166
+ 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.
167
+
168
+ 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.
169
+
170
+ 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.
171
+
172
+ 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.
173
+
174
+ 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.
175
+
176
+ 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.
177
+
178
+ 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.
179
+
180
+ 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.
181
+
182
+ 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.
183
+
184
+ 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.
185
+
186
+ 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.
187
+
188
+ 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.
189
+
190
+ 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.
191
+
192
+ 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.
193
+
194
+ 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.
195
+
196
+ 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.
197
+
198
+ 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.
199
+
200
+ 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.
201
+
202
+ 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.
203
+
204
+ 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.
205
+
206
+ 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.
207
+
208
+ 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.
209
+
210
+ 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.
211
+
212
+ 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.
213
+
214
+ 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.
215
+
216
+ 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.
217
+
218
+ 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.
219
+
220
+ 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.
221
+
222
+ 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.
223
+
224
+ 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.
225
+
226
+ 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.
227
+
228
+ 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.
229
+
230
+ 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.
231
+
232
+ 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.
233
+
234
+ 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.
235
+
236
+ 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.
237
+
238
+ 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.
239
+
240
+ 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.
241
+
242
+ 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".
243
+
244
+ 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.
245
+
246
+ 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.
247
+
248
+ 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.
249
+
250
+ 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.
251
+
252
+ 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.
253
+
254
+ 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.
255
+
256
+ 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.
257
+
258
+ 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.
259
+
260
+ 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.
261
+
262
+ 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.
263
+
264
+ 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.
265
+
266
+ 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.
267
+
268
+ 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.
269
+
270
+ 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.
271
+
272
+ 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.
273
+
274
+ 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.
275
+
276
+ 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.
277
+
278
+ 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.
279
+
280
+ 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.
281
+
282
+ 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.
283
+
284
+ 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.
285
+
286
+ 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.
287
+
288
+ 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.
289
+
290
+ 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.
291
+
292
+ 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.`}]},M0="agent-dag.releaseNotesSeen";function SR(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function pi(e,t){const n=SR(e),r=SR(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 mi(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function Jse(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 Qse(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,r]of Object.entries(e)){if(!mi(n)||!Array.isArray(r))continue;const s=r.filter(Jse);s.length&&t.push({version:n,notes:s})}return t.sort((n,r)=>pi(r.version,n.version))}const _R=Qse(Zse);function cL(e,t,n){return e.filter(r=>pi(r.version,n)<=0&&(t===null||pi(r.version,t)>0))}function eae(e,t){return e.filter(n=>pi(n.version,t)===0)}function tae(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 nae({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&&mi(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(!mi(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=pi(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 rae=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function sae(e){const t=rae.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function aae(e){if(!e)return null;let t=null;try{t=e.getItem(M0)}catch{return null}return mi(t)?t:null}function oae(e){if(!e)return!1;try{return e.getItem(M0),!0}catch{return!1}}function iae(e,t){if(!e)return!1;try{return e.setItem(M0,t),!0}catch{return!1}}const uL="agent-dag.tourSeen";function lae(e){if(!e)return!1;try{return e.getItem(uL)==="1"}catch{return!1}}function cae(e){if(!e)return!1;try{return e.setItem(uL,"1"),!0}catch{return!1}}function uae({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 dae({stored:e,running:t,notes:n,remembers:r=!0}){if(!mi(t))return{show:[],record:null,reason:"no-version"};if(!mi(e)){if(!r)return{show:[],record:t,reason:"cannot-remember"};const l=eae(n,t);return l.length?{show:l,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const s=pi(e,t);if(s===0)return{show:[],record:null,reason:"seen"};if(s>0)return{show:[],record:null,reason:"ahead"};const o=cL(n,e,t);return o.length?{show:o,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function hae(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 dL(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=hae(e,o);if(l>0){s(),n.push({kind:"bold",kids:dL(e.slice(o+2,l),!1)}),o=l+2;continue}}r+=e[o],o+=1}return s(),n}function fae({entries:e,since:t,running:n,firstRun:r,onClose:s,onTour:o,updateVersion:l,updateBusy:u,onUpdateRestart:d,updateFailure:h,onRestart:f}){const p=ft(s),g=tae(e);return a.jsx("div",{className:"modal-backdrop",onClick:s,role:"presentation",children:a.jsxs("div",{ref:p,className:"modal release-notes",onClick:v=>v.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"}),g&&a.jsx("span",{className:"modal-tool-id",children:g})]}),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":u||void 0,children:u?"Restarting…":_d})]}),a.jsx("p",{className:"rn-update-said",role:"status",children:h})]}),a.jsx("p",{className:"modal-note",children:nae({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(v=>a.jsxs("section",{className:"modal-section",children:[a.jsxs("h3",{className:"rn-version",children:["v",v.version]}),a.jsx("ul",{className:"rn-notes",children:v.notes.map((k,b)=>{const{icon:x,rest:N}=sae(k.title);return a.jsxs("li",{className:"rn-note",children:[a.jsxs("p",{className:"rn-note-title",children:[x&&a.jsx("span",{className:"rn-note-icon",children:x}),N]}),a.jsx("p",{className:"rn-note-body",children:hL(dL(k.body))})]},b)})})]},v.version))]})]})})}function hL(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:hL(t.kids)},n))}function pae({state:e,sessionId:t,onClose:n}){const r=w.useMemo(()=>mae(e,t),[e,t]),s=w.useRef(null),o=ft(n,{focusRef:s});return r?a.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:a.jsxs("div",{ref:o,className:"modal session-summary",onClick:l=>l.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:c$}),a.jsx("div",{className:"ss-cost",children:Fe(r.cost.total)}),r.modelChips.length>0&&a.jsx("div",{className:"ss-models",children:r.modelChips.map(l=>a.jsx("span",{className:"model-chip","data-family":Od(l),title:l,children:Qs(l)},l))})]}),a.jsx("div",{className:"ss-hero-right",children:r.cost.total>0&&a.jsxs(a.Fragment,{children:[a.jsx(zb,{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:Fe(r.cost.input)})]}),a.jsxs("span",{className:"ssl ssl-out",children:["output ",a.jsx("b",{children:Fe(r.cost.output)})]}),a.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",a.jsx("b",{children:Fe(r.cost.cacheRead)})]}),a.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",a.jsx("b",{children:Fe(r.cost.cacheWrite)})]})]})]})})]}),a.jsxs("section",{className:"ss-stats",children:[a.jsx(zo,{label:"agents",value:r.agentCount}),a.jsx(zo,{label:"subagents",value:r.subagentCount}),a.jsx(zo,{label:"tool calls",value:r.toolCount}),a.jsx(zo,{label:"prompts",value:r.promptCount}),a.jsx(zo,{label:"tokens",value:r.tokensSum.toLocaleString()}),r.errCount>0&&a.jsx(zo,{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(([l,u])=>a.jsxs("div",{className:"ss-tt",children:[a.jsx("span",{className:"ss-tt-name",children:l}),a.jsx("span",{className:"ss-tt-bar",children:a.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${u/r.topTools[0][1]*100}%`}})}),a.jsx("span",{className:"ss-tt-count",children:u})]},l))})]}),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 zo({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 mae(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 u=0,d=0,h=0,f=0,p=0,g,v=1/0,k=0;for(const _ of r){const E=fn(_);s.input+=E.input,s.output+=E.output,s.cacheRead+=E.cacheRead,s.cacheWrite+=E.cacheWrite,s.total+=E.total;for(const A of RM(_))o.add(A);_.model&&o.add(_.model),_.kind==="subagent"&&p++;const T=vM(_.prompts);d+=T.length,!g&&T.length>0&&(g=T[0].text),h+=_.usage.inputTokens+_.usage.outputTokens,u+=_.toolCount,f+=_.toolErrorCount??0;for(const[A,R]of _.toolCountByName??[])l.set(A,(l.get(A)??0)+R);v=Math.min(v,_.startedAt),k=Math.max(k,_.endedAt??Date.now())}const b=Math.max(0,k-v),x=Math.floor(b/1e3),N=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`,S=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:N,cost:s,modelChips:Array.from(o),agentCount:r.length,subagentCount:p,toolCount:u,promptCount:d,tokensSum:h,errCount:f,topTools:S,firstPrompt:g}}const gae=60,yae=6e3,Pr=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),wn=e=>typeof e=="string"?e:null;function za(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 u=n?`${t}-`:`${t}${o}:`;if(typeof l=="string"&&l.includes(`
293
+ `)){s.push(u);for(const d of l.split(`
294
+ `))s.push(`${t} ${d}`)}else if(l!==null&&typeof l=="object"){const d=za(l,`${t} `);d==="[]"||d==="{}"?s.push(`${u} ${d}`):s.push(u,d)}else s.push(`${u} ${l===void 0?"(none)":String(l)}`)}return s.join(`
295
+ `)}function wae(e){return e.lines??e.text.split(`
296
+ `).map(t=>({text:t}))}function fL(e,t){if(t)return{shown:e,cut:!1};const n=[];let r=0;for(const s of e){if(n.length===gae)return{shown:n,cut:!0};const o=yae-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 vae(e,t){return fL(e,!1).cut?t?{label:"show less",expanded:!0}:{label:"show all",expanded:!1}:null}const Qt=(e,t,n=!1)=>({...e?{label:e}:{},text:t,...n?{err:!0}:{}}),vn=(e,t)=>({label:e,text:t,inline:!0}),pL=(e,t)=>({label:e,text:t.map(n=>n.text).join(`
297
+ `),lines:t});function xae(e,t){return[...e.split(`
298
+ `).map(n=>({text:`- ${n}`,tone:"del"})),...t.split(`
299
+ `).map(n=>({text:`+ ${n}`,tone:"add"}))]}function bae(e){if(!Array.isArray(e)||e.length===0)return null;const t=[];for(const n of e){if(!Pr(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 ER(e){if(typeof e=="string")return[Qt(void 0,e)];if(!Pr(e))return[Qt(void 0,za(e))];const t=[],n=wn(e.type);n==="create"&&t.push(vn("result","created the file"));const r=bae(e.structuredPatch);return r&&t.push(pL("applied",r)),e.userModified===!0&&t.push(vn("note","the user changed it before it was applied")),t.length?t:[vn("result",n==="update"?"updated the file":"done")]}function kae(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 Nae(e){if(typeof e=="string")return[Qt(void 0,e)];const t=Pr(e)&&Pr(e.file)?e.file:null,n=wn(t==null?void 0:t.content);if(t&&n!=null){const s=[],o=Number(t.numLines),l=Number(t.totalLines),u=Number(t.startLine);return Number.isFinite(o)&&Number.isFinite(l)&&l>0&&s.push(vn("lines",o>=l?`all ${l}`:Number.isFinite(u)?`${u}–${u+o-1} of ${l}`:`${o} of ${l}`)),s.push(Qt("content",n)),s}const r=Pr(e)?wn(e.type):null;return r&&r!=="text"?[vn("result",`${/^[aeiou]/i.test(r)?"an":"a"} ${r} file`)]:[Qt(void 0,za(e))]}function jae(e){if(typeof e=="string")return[Qt("output",e)];if(!Pr(e))return[Qt(void 0,za(e))];const t=wn(e.stdout),n=wn(e.stderr);if(t==null&&n==null)return[Qt(void 0,za(e))];const r=[];return t&&r.push(Qt("output",t.replace(/\n$/,""))),n&&r.push(Qt("errors",n.replace(/\n$/,""),!0)),e.interrupted===!0&&r.push(vn("note","interrupted before it finished")),r.length?r:[vn("output","none")]}function Sae(e,t,n){const r=Pr(t)?t:null;if(r&&(e==="Edit"||e==="MultiEdit")){const s=wn(r.file_path),o=(e==="MultiEdit"?Array.isArray(r.edits)?r.edits:[]:[r]).filter(Pr).filter(l=>wn(l.old_string)!=null&&wn(l.new_string)!=null);if(s&&o.length){const l=[vn("file",s)];return o.forEach((u,d)=>{const h=u.replace_all===!0?", every occurrence":"";l.push(pL(o.length>1?`change ${d+1}${h}`:`change${h}`,xae(u.old_string,u.new_string)))}),{input:l,response:ER(n)}}}if(r&&e==="Write"){const s=wn(r.file_path),o=wn(r.content);if(s&&o!=null)return{input:[vn("file",s),Qt("content",o)],response:ER(n)}}if(r&&e==="Read"){const s=wn(r.file_path);if(s){const o=kae(r);return{input:o?[vn("file",s),vn("lines",o)]:[vn("file",s)],response:Nae(n)}}}if(r&&e==="Bash"){const s=wn(r.command);if(s!=null){const o=wn(r.description);return{input:o?[Qt("command",s),vn("why",o)]:[Qt("command",s)],response:jae(n)}}}return{input:[Qt(void 0,za(t))],response:[Qt(void 0,za(n))]}}function CR(e,t,n){if(n==null)return"";if(typeof n=="string")return n;if(Pr(n)){if(e==="Bash"&&t==="input"&&typeof n.command=="string")return n.command;if(e==="Bash"&&t==="response"&&(typeof n.stdout=="string"||typeof n.stderr=="string"))return[n.stdout,n.stderr].filter(r=>typeof r=="string"&&r!=="").join(`
300
+ `);if(e==="Read"&&t==="response"&&Pr(n.file)&&typeof n.file.content=="string")return n.file.content}try{return JSON.stringify(n,null,2)??String(n)}catch{return String(n)}}function _ae({tool:e,onClose:t}){const n=ft(t),r=e.endedAt==null?"inflight":e.ok===!1?"err":"done",s=e.input??e.inputPreview,o=e.response??e.errorPreview,l=Sae(e.name,s,o);return a.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:a.jsxs("div",{ref:n,className:"modal",onClick:u=>u.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 ${r}`,"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:IM(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:[e.trimmed&&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(AR,{text:CR(e.name,"input",s),what:"input"})]}),l.input.map((u,d)=>a.jsx(TR,{block:u},d))]}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("div",{className:"tm-head",children:[a.jsxs("h4",{children:["Response ",r==="err"&&a.jsx("span",{className:"err-tag",children:"error"})]}),e.endedAt!=null&&a.jsx(AR,{text:CR(e.name,"response",o),what:"response"})]}),e.endedAt==null?a.jsx("pre",{children:"(waiting…)"}):l.response.map((u,d)=>a.jsx(TR,{block:u},d))]})]})]})})}const Eae={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function TR({block:e}){const[t,n]=w.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=wae(e),{shown:s}=fL(r,t),o=vae(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,u)=>a.jsxs("span",{className:l.tone?Eae[l.tone]:void 0,children:[l.text,u<s.length-1?`
301
+ `:""]},u)):s.map(l=>l.text).join(`
302
+ `)}),o&&a.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":o.expanded,onClick:()=>n(l=>!l),children:o.label})]})}function AR({text:e,what:t}){const[n,r]=w.useState(!1),s=w.useRef(!0);return w.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 Ha(e).then(o=>{!o||!s.current||(r(!0),window.setTimeout(()=>{s.current&&r(!1)},1600))}),children:n?"copied":"copy"})}const Cae=w.lazy(()=>qb(()=>import("./UsageHistoryModal-BcUzGS2-.js"),[])),Tae=w.lazy(()=>qb(()=>import("./BrowserWatchModal-CeVGLslQ.js"),[]));function Aae({dialogs:e,welcome:t,desktopUpdate:n,versionCheck:r,restart:s,lanPairs:o,attention:l,clearFlow:u,watchBadge:d,announcements:h,appearance:f,providers:p,stateRef:g,agentCount:v}){const{openedTool:k,setOpenedToolKey:b,usageHistoryOpen:x,setUsageHistoryOpen:N,browserWatchOpen:S,setBrowserWatchOpen:_,contextAgent:E,setContextFor:T,summaryFor:A,setSummaryFor:R,keyHelpOpen:B,setKeyHelpOpen:P,feedbackOpen:D,setFeedbackOpen:I,feedbackPrefill:O,setFeedbackPrefill:z}=e,{tourOpen:M,openTour:$,closeTour:q,releaseNotes:X,closeReleaseNotes:H,chipVersion:L}=t,{desktopUpdateRestarting:W,desktopUpdateFailure:F,readyAppUpdate:Y,askDesktopUpdateRestart:J}=n,{version:V}=r,{askRestart:G}=s,{clearConfirmOpen:K,setClearConfirmOpen:Z,requestClear:ee}=u,{setWatchOn:re,markWatchSeen:ue}=d,{setWatchSaid:me}=h,{palette:ie}=f;return a.jsxs(a.Fragment,{children:[k&&a.jsx(_ae,{tool:k,onClose:()=>b(null)}),x&&a.jsx(w.Suspense,{fallback:null,children:a.jsx(Cae,{providers:p,onClose:()=>N(!1)})}),S&&a.jsx(w.Suspense,{fallback:null,children:a.jsx(Tae,{onClose:()=>_(!1),onSeen:fe=>{me(""),ue(fe)},onWatching:re,palette:ie})}),E&&a.jsx(g8,{agent:E,onClose:()=>T(null)}),D&&a.jsx(lL,{initialKind:O==null?void 0:O.initialKind,initialBody:O==null?void 0:O.initialBody,onClose:()=>{I(!1),z(null)}}),A&&a.jsx(pae,{state:g.current,sessionId:A,onClose:()=>R(null)}),X&&a.jsx(fae,{entries:X.entries,since:X.since,firstRun:X.firstRun,running:L,onClose:H,onTour:()=>{H(),$()},updateVersion:Y==null?void 0:Y.version,updateBusy:W,updateFailure:F&&(!Y||Y.version===F.version)?Lne(F.failure,F.version):void 0,onUpdateRestart:Y?()=>{J(Y.version)}:void 0,onRestart:!Y&&(V!=null&&V.canRestart)?()=>{H(),G()}:void 0}),a.jsx(Dse,{...o}),a.jsx(Xse,{...l}),B&&a.jsx(Ose,{onClose:()=>P(!1),onTour:()=>{P(!1),$()}}),M&&a.jsx(eI,{title:"What the deck shows you",steps:JV,onClose:q}),K&&a.jsx(yre,{agentCount:v,onConfirm:()=>ee("confirmation"),onCancel:()=>Z(!1)})]})}const Rae=10,mL=500,gL=4e3,Mae=[/ResizeObserver loop/i,/^Script error\.?$/i];function RR(e){return String(e??"").replace(/\/(?:home|Users)\/[^/\s:'"]+/g,"~").replace(/[A-Za-z]:\\(?:Users|Documents and Settings)\\[^\\\r\n:'"]+/gi,"~").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 yL=e=>{fetch("/api/client-error",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})};function $ae(e,t,n=yL){const r=String(e??"").slice(0,mL).trim();r&&n({message:r,stack:typeof t=="string"?t.slice(0,gL):void 0})}function Iae(e,t=window,n=yL){let r=0;const s=new Set,o=(d,h)=>{const f=String(d??"").slice(0,mL).trim();!e()||!f||r>=Rae||s.has(f)||Mae.some(p=>p.test(f))||(s.add(f),r++,n({message:f,stack:typeof h=="string"?h.slice(0,gL):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)},u=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",u),()=>{t.removeEventListener("error",l),t.removeEventListener("unhandledrejection",u)}}const Oae=12;function Lae(e,t){const n=[RR(e).trim()||"The deck threw an error with no message."],r=t==null?void 0:t.trim();if(r){const s=r.split(`
303
+ `).slice(0,Oae).join(`
304
+ `);n.push("",RR(s).trim())}return n.join(`
305
+ `)}class Pae extends w.Component{constructor(){super(...arguments);W1(this,"state",{error:null,componentStack:null,reportOpen:!1})}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}),$ae(n.message,n.stack)}render(){const{error:n,componentStack:r,reportOpen:s}=this.state;return n?a.jsxs("div",{className:"error-fallback",role:"alert",children:[a.jsxs("div",{className:"error-fallback-card",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(lL,{initialKind:"bug",initialBody:Lae(n.message,r),onClose:()=>this.setState({reportOpen:!1})})]}):this.props.children}}const Dae=1e3;function Fae(e={}){const t=Math.max(1,Math.floor(e.limit??Dae)),n=e.protect;let r=!1,s=[],o=new Set,l=0,u=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 u},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,u=0);const v=f!==null&&!g&&f<=u;if(f!==null&&f>u&&(u=f),!r)return!0;if(v)return!1;if(s.push(h),n!=null&&n(h)&&o.add(h),s.length>t){let k=0;if(o.size<s.length)for(;o.has(s[k]);)k++;const[b]=s.splice(k,1);o.delete(b),l++}return!1},setPaused(h){if(r=h,h)return[];const f=s;return s=[],o=new Set,l=0,f}}}function Bae(e){const t=w.useState(()=>Fae({protect:o=>HB(e.current,o)}))[0],[n,r]=w.useState(!1),s=w.useCallback(()=>{const o=t.paused&&t.dropped>0,l=t.setPaused(!t.paused);o&&bq(e.current);for(const u of l)e.current=_M(e.current,u);r(t.paused)},[t,e]);return{pauseGate:t,paused:n,togglePause:s}}const ab={kind:"assumed",claude:!0,codex:!0};function qae(e){if(!e||typeof e!="object")return ab;const t=e.providers;if(!t||typeof t!="object")return ab;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function Uae(e){const[t,n]=w.useState(null),[r,s]=w.useState(ab);w.useEffect(()=>{let l=!1;return fetch("/api/health").then(u=>u.ok?u.json():null).then(u=>{l||(s(qae(u)),!(!u||typeof u.workspace!="string")&&n(u.workspace))}).catch(()=>{}),()=>{l=!0}},[e]);const o=bn(r);return{workspace:t,providers:r,providersRef:o}}const wL=3*6e4,zae=2e4;function Wae({fetchReport:e,visible:t,now:n,onReport:r}){let s=0,o=!0;const l=async()=>{if(!t())return;const u=await e();!o||!u||(s=n(),r(u))};return{tick:l,wake:async()=>{t()&&n()-s>=wL&&await l()},stop:()=>{o=!1}}}async function Hae(){try{const e=await fetch("/api/provider-status",{signal:AbortSignal.timeout(zae)});return e.ok?await e.json():null}catch{return null}}function Vae(e){const[t,n]=w.useState(null);return w.useEffect(()=>{if(!e){n(null);return}const r=Wae({fetchReport:Hae,visible:()=>document.visibilityState==="visible",now:()=>Date.now(),onReport:n});r.tick();const s=window.setInterval(r.tick,wL),o=()=>{r.wake()};return document.addEventListener("visibilitychange",o),()=>{r.stop(),window.clearInterval(s),document.removeEventListener("visibilitychange",o)}},[e]),t}const Gae={degraded:"degraded performance",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},Kae={degraded:"degraded",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},Yae={degraded:"degraded",partial_outage:"outage",major_outage:"outage",maintenance:"maint."},Xae={claude:"Claude",codex:"Codex"},Zae=new Set(["status.claude.com","status.openai.com"]),Jae=30*6e4,Qae=10*6e4;function eoe(e){if(typeof e!="string")return null;try{const t=new URL(e);return t.protocol==="https:"&&Zae.has(t.hostname)?t:null}catch{return null}}function MR(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}function toe(e){const t=Math.floor(e/6e4);return t<1?"just now":t<60?`${t} min ago`:`${Math.floor(t/60)} h ago`}function noe(e,t){if(!e||typeof e!="object")return null;const n=Ot(Gae,e.state),r=Ot(Xae,e.provider);if(!n||!r||typeof e.checkedAt!="number"||t-e.checkedAt>Jae)return null;const s=eoe(e.statusPageUrl);if(!s)return null;const o=Array.isArray(e.components)?e.components:[],l=e.stale===!0||t-e.checkedAt>Qae,u=[`${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 ${MR(e.checkedAt)}; this is the last thing it said`:`Reported by ${s.hostname}, checked ${toe(t-e.checkedAt)}`,"Opens the status page"],d=l?MR(e.checkedAt):null;return{provider:e.provider,state:e.state,name:r,label:`${r} · ${n}${d?` · as of ${d}`:""}`,words:n,chipWords:Ot(Kae,e.state)??n,shortWords:Ot(Yae,e.state)??n,asOf:d,what:e.summary||(o.length>0?o.join(", "):null),href:s.href,host:s.hostname,stale:l,detail:u.filter(Boolean).join(`
306
+ `)}}function roe(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>noe(n,t)).filter(n=>n!==null)}function soe(e){return e.map(t=>`${t.name}'s status page reports ${t.state.endsWith("outage")?`a ${t.words}`:t.words}.`).join(" ")}const aoe="The providers' status pages report no incident.";function ooe({version:e,loadVersion:t}){var h;const[n,r]=w.useState(!1),s=((h=e==null?void 0:e.upgrade)==null?void 0:h.state)??"idle",o=are(e==null?void 0:e.upgrade),l=w.useRef(!1),u=w.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]);w.useEffect(()=>{if(s!=="running")return;const f=window.setInterval(t,3e3);return()=>window.clearInterval(f)},[s,t]);const d=w.useCallback(async()=>{const f=e==null?void 0:e.command;!f||!await Ha(f)||(r(!0),window.setTimeout(()=>r(!1),1600))},[e==null?void 0:e.command]);return{upgradeState:s,upgradeFailure:o,startUpgrade:u,copyCommand:d,cmdCopied:n}}const $R="agent-dag.browserWatch.seenMs";function ioe(e,t){return e.filter(n=>n.startMs>t)}function loe(){const[e,t]=w.useState(()=>Number(et($R))||0),[n,r]=w.useState([]),[s,o]=w.useState(!1);w.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=w.useMemo(()=>ioe(n,e).length,[n,e]),u=w.useCallback(d=>{t(d),Xe($R,String(d))},[]);return{watchOn:s,setWatchOn:o,watchUnseen:l,markWatchSeen:u}}const vL=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function IR(e){const t={};for(const n of vL)t[n]=e(n);return t}function coe(e){return t=>e[t]??""}function uoe(e,t){return vL.every(n=>e[n]===t[n])}const xL="agent-dag.theme";function doe(e,t=!1){return e==="light"||e==="dark"?e:t?"light":"dark"}function hoe(){try{return window.matchMedia("(prefers-color-scheme: light)").matches}catch{return!1}}function foe(){return doe(et(xL),hoe())}function OR(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function poe(){const[e,t]=w.useState(foe),[n,r]=w.useState(ene),[s,o]=w.useState(()=>IR(OR)),l=w.useMemo(()=>coe(s),[s]),u=w.useCallback(d=>ste(d,l),[l]);return w.useEffect(()=>{document.documentElement.dataset.theme=e,Xe(xL,e),o(d=>{const h=IR(OR);return uoe(d,h)?d:h})},[e]),w.useEffect(()=>{Xe(YO,n?"1":"0")},[n]),w.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:u}}function moe(e){const t=w.useRef(null),[n,r]=w.useState(!1),[s,o]=w.useState(()=>new Set),l=w.useMemo(()=>{const d=new Set;for(const h of e.current.agents.values())for(const f of h.tools)d.add(GO(f.name));return Object.keys(VO).filter(h=>d.has(h))},[e.current,e.current.revision]);w.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(k=>k.getBoundingClientRect()),v=Kee(p,g,8);r(k=>k===v?k:v)}d=window.setTimeout(h,300)};return h(),()=>window.clearTimeout(d)},[l.length]);const u=w.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:u,catBarRef:t,catBarOccluded:n}}function goe(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null;const r=()=>e.enabled()?(n==null?void 0:n.state)==="running"?"ready":"locked":"off",s=()=>{var f;return(f=e.onState)==null?void 0:f.call(e,r())};function o(){var f,p;if(!(!t||(n==null?void 0:n.state)==="running"))try{n||(n=new t,(f=n.addEventListener)==null||f.call(n,"statechange",s)),(p=n.resume)==null||p.call(n).then(s,()=>{}),s()}catch{}}function l(f,p,g=p.figure){if(!n||n.state!=="running")return!1;const v=Hx(f,g),k=aX(p.level,v),b=n.currentTime;for(const x of v.notes){const N=n.createOscillator(),S=n.createGain();N.type=v.type??"sine",N.frequency.value=x.hz;const _=b+x.at,E=_+x.ms/1e3;S.gain.setValueAtTime(IS,_),S.gain.exponentialRampToValueAtTime(k,_+oX),S.gain.exponentialRampToValueAtTime(IS,E),N.connect(S).connect(n.destination),N.start(_),N.stop(E+.02)}return!0}async function u(f,p){if(!e.loadCustom)return"unavailable";let g;try{g=await e.loadCustom(f)}catch{return"unavailable"}if(!g)return"missing";if(g.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const k=new SpeechSynthesisUtterance(g.text),b=window.speechSynthesis.getVoices();k.voice=b.find(x=>x.voiceURI===g.voiceURI)??null,k.rate=g.rate,k.pitch=g.pitch,k.volume=iX(p.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(k),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let v;try{v=await n.decodeAudioData(g.bytes.slice(0))}catch{return"broken"}try{const k=n.createBufferSource(),b=n.createGain();return k.buffer=v,b.gain.setValueAtTime(lX(g.normalizationGain,p.level),n.currentTime),k.connect(b).connect(n.destination),k.start(n.currentTime),"played"}catch{return"unavailable"}}function d(f,p=!1){var k,b;if(!p&&!e.enabled())return!1;const g=mX((k=e.prefs)==null?void 0:k.call(e),f),v=((b=e.customSelection)==null?void 0:b.call(e)[f])??null;return v&&e.loadCustom?(u(v,g).then(x=>{var N;x==="played"||x==="locked"||((x==="missing"||x==="broken")&&((N=e.onCustomFailure)==null||N.call(e,f,v)),l(f,{...g,figure:xn},xn))}),!0):!n||n.state!=="running"?!1:l(f,g)}function h(f,p=Ua){return u(f,{level:fi(p),figure:xn}),!0}return{unlock:o,play:d,previewCustom:h,state:r,get context(){return n}}}function yoe({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:r,fallbackCustomRef:s}){const[o,l]=w.useState("locked");return w.useEffect(()=>{const u=goe({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>r.current,loadCustom:eX,onCustomFailure:(p,g)=>s.current(p,g),onState:l});e.current=u,l(u.state());const d=["pointerdown","pointerup","keydown"],h=()=>{for(const p of d)window.removeEventListener(p,f,{capture:!0})},f=()=>{var p;u.unlock(),((p=u.context)==null?void 0:p.state)==="running"&&h()};for(const p of d)window.addEventListener(p,f,{capture:!0});return h},[]),{chimeState:o}}function woe(){const[e,t]=w.useState(nne),[n,r]=w.useState(()=>gB(et(GN))),[s,o]=w.useState(()=>mB(et(KN))),[l,u]=w.useState(()=>yB(et(lR),n,Jte)),[d,h]=w.useState(()=>new Set),[f,p]=w.useState(0);w.useEffect(()=>{Xe(XO,String(e))},[e]),w.useEffect(()=>{Xe(KN,s?"1":"0")},[s]),w.useEffect(()=>{Xe(GN,JSON.stringify(n))},[n]),w.useEffect(()=>{Xe(lR,l)},[l]);const g=w.useCallback(N=>{r(S=>S.some(_=>_.id===N.id)?S:[...S,N]),h(S=>{if(!S.has(N.id))return S;const _=new Set(S);return _.delete(N.id),_})},[]),v=w.useCallback((N,S)=>{const _=S.trim();!_||_.length>Dl||r(E=>E.map(T=>T.id===N?{...T,name:_}:T))},[]),k=w.useCallback(N=>{r(S=>S.filter(_=>_.id!==N)),u(S=>wB(S,N)),h(S=>{if(!S.has(N))return S;const _=new Set(S);return _.delete(N),_})},[]),b=w.useCallback(N=>{const S=YN(N),_=d.has(S);N===l&&!_||(_&&h(E=>{const T=new Set(E);return T.delete(S),T}),u(N),p(E=>E+1))},[l,d]),x=w.useCallback((N,S)=>{const _=YN(N);h(E=>{if(E.has(_)===S)return E;const A=new Set(E);return S?A.add(_):A.delete(_),A})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:s,setFmMuted:o,fmSource:l,customFmStations:n,unavailableFmStations:d,fmPlayRequest:f,addFmStation:g,renameFmStation:v,removeFmStation:k,pickFmSource:b,markFmStationAvailability:x}}function voe(e){const[t,n]=w.useState(null),[r,s]=w.useState(!1),[o,l]=w.useState(null),u=w.useRef(0);w.useEffect(()=>{if(!e||!Zl())return;let k=!1;const b=u.current;return fetch("/api/desktop-update").then(x=>x.ok?x.json():null).then(x=>{if(k||u.current!==b)return;const N=mR(x);N&&n(N)}).catch(()=>{}),()=>{k=!0}},[e]);const d=Rne(t),h=w.useRef(!1),f=w.useRef(0),p=w.useRef(0);w.useEffect(()=>()=>window.clearTimeout(f.current),[]);const g=w.useCallback(async k=>{if(!lr(h.current))return;const b=++p.current;window.clearTimeout(f.current),h.current=!0,s(!0),l(null);const x=N=>{b===p.current&&(window.clearTimeout(f.current),h.current=!1,s(!1),l({failure:N,version:k}))};try{const N=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:k})});if(!N.ok)return x(One(await N.json().catch(()=>null)))}catch{return x("unreachable")}b===p.current&&(f.current=window.setTimeout(()=>x("timeout"),ZO))},[]),v=w.useCallback(k=>{if(Zl())try{const b=mR(JSON.parse(k));b&&(u.current++,n(b),b.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 Ou="agent-dag.autoRestart",LR="agent-dag.bundleReloadedFor";function xoe({now:e,stateRef:t,version:n,notice:r,noticeOpen:s,upgradeFailure:o,paused:l}){const[u,d]=w.useState(()=>et(Ou)!=="0"),h=w.useRef(!1),f=w.useCallback(()=>{const D=!u;h.current=!0,us(Ou),d(D),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:D})}).then(I=>I.ok?I.json():null).then(I=>{var O;I!=null&&I.ok&&d(((O=I.prefs)==null?void 0:O.autoUpdate)!==!1)}).catch(()=>{})},[u]),[p,g]=w.useState(!1),[v,k]=w.useState("restart"),[b,x]=w.useState(null),N=w.useRef(!1),S=w.useRef(null),_=w.useRef(0),E=w.useRef(null),T=w.useCallback(async D=>{if(!lr(N.current))return;const I=(D==null?void 0:D.upgrade)===!0,O=(D==null?void 0:D.whenIdle)===!0;N.current=!0,S.current=o;const z=++_.current,M=()=>{k(I?"npx":"restart"),g(!0)};O||M();try{window.sessionStorage.setItem("agent-dag.restartPending",(r==null?void 0:r.to)??"")}catch{}let $=!1;try{const q=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O?{upgrade:I,whenIdle:O}:{upgrade:I})});$=O&&q.status===409}catch{}if($){N.current=!1,E.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}O&&M(),window.setTimeout(()=>{if(_.current===z&&N.current){N.current=!1,g(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},I?18e4:3e4)},[r==null?void 0:r.to,o]);w.useEffect(()=>{const D=gR(t.current.agents.values())>0,I=ure({enabled:u,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:D,idleSince:E.current,now:e});E.current=I.idleSince,I.restart&&T({whenIdle:!0})},[u,r==null?void 0:r.kind,n==null?void 0:n.canRestart,s,e,T]);const A=gR(t.current.agents.values()),R=cre(A,l),B=QO({enabled:u,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:A>0,idleSince:E.current,now:e});w.useEffect(()=>{const D=n==null?void 0:n.running;let I=null,O=null;try{I=window.sessionStorage.getItem("agent-dag.restartPending"),O=window.sessionStorage.getItem(LR)}catch{return}const z=sre({bundle:"3.36.8",running:D,pending:I,lastTried:O});if(z==="reload"){try{window.sessionStorage.setItem(LR,D??"")}catch{return}window.location.reload();return}if(z!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}N.current=!1,g(!1),x(D??null);const M=window.setTimeout(()=>x(null),6e3);return()=>window.clearTimeout(M)},[n==null?void 0:n.running]),w.useEffect(()=>{if(p&&ore({asked:S.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}N.current=!1,g(!1)}},[p,o]);const P=w.useCallback(D=>{var I,O;if(!h.current){const z=et(Ou)==="0";us(Ou),z&&((I=D.prefs)==null?void 0:I.autoUpdate)!==!1?(d(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):d(((O=D.prefs)==null?void 0:O.autoUpdate)!==!1)}},[]);return{autoRestart:u,toggleAutoRestart:f,restarting:p,restartMode:v,restartedTo:b,askRestart:T,restartCopy:R,restartFuseMs:B,loadAutoRestartPrefs:P}}function boe(){const[e,t]=w.useState([]),n=w.useRef(new Set),[r,s]=w.useState(null),[o,l]=w.useState(void 0);w.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(iS(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?Dx:Q$))})};return p(),()=>{h=!1,window.clearTimeout(f)}},[]);const u=w.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(iS(g.pending,g.aliases)):t(v=>v.filter(k=>k.fp!==f))}catch{}finally{s(null)}}},[r]),d=w.useCallback(h=>{r||(n.current.add(h),t(f=>[...f]))},[r]);return{lanPending:e,lanDeferred:n,lanBusy:r,answerLanPair:u,deferLanPair:d,lanStatus:o}}const koe=6e4;function Noe({enabled:e,lanStatus:t,now:n}){const[r,s]=w.useState(null),[o,l]=w.useState(()=>new Set),[u,d]=w.useState(null),h=w.useCallback(N=>{N!=null&&N.ok&&Array.isArray(N.accounts)&&s(N.accounts)},[]),f=w.useCallback(async N=>{try{const S=await fetch(`/api/claude-accounts${N?"?refresh=1":""}`);S.ok&&h(await S.json())}catch{}},[h]);w.useEffect(()=>{e&&f(!1)},[e,f]),w.useEffect(()=>{if(!e)return;let N=Date.now();const S=()=>{document.visibilityState!=="visible"||Date.now()-N<koe||(N=Date.now(),f(!1))};return document.addEventListener("visibilitychange",S),window.addEventListener("focus",S),()=>{document.removeEventListener("visibilitychange",S),window.removeEventListener("focus",S)}},[e,f]);const p=w.useMemo(()=>e?Bse(r,{lan:t,now:n,closed:o}):[],[e,r,t,n,o]),g=w.useRef(p);g.current=p;const v=w.useCallback(N=>{N.length&&l(S=>new Set([...S,...N]))},[]),k=w.useCallback(()=>{const N=g.current;N.length&&(v(N.map(S=>S.id)),fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reauth-later",incidents:N.map(S=>({key:S.key,since:S.since}))})}).catch(()=>{}))},[v]),b=w.useRef(u);b.current=u;const x=w.useCallback(N=>{const S=b.current;v(qse(S?[S,...g.current]:g.current,N))},[v]);return{rows:p,signingIn:u,observe:h,signIn:d,signedIn:x,refresh:w.useCallback(()=>{f(!0)},[f]),closeSignIn:w.useCallback(()=>d(null),[]),later:k}}const bL="agent-dag.sessionListOpen",kL="agent-dag.accountsPanelOpen";function joe(){return et(bL)==="1"}function Soe(e){Xe(bL,e?"1":"0")}function _oe(){const e=et(kL);return e===null?!0:e==="1"}function Eoe(){const[e,t]=w.useState(joe);w.useEffect(()=>{Soe(e)},[e]);const n=w.useRef(!1),[r,s]=w.useState(()=>{const h=_oe();return h&&e?(n.current=!0,!1):h});w.useEffect(()=>{!r&&n.current||Xe(kL,r?"1":"0")},[r]),w.useEffect(()=>{!e&&n.current&&(n.current=!1,s(!0))},[e]);const o=w.useCallback(()=>{t(h=>(h||s(f=>(f&&(n.current=!0),!1)),!h))},[]),l=w.useCallback(()=>{n.current=!1,s(h=>(h||t(!1),!h))},[]),u=w.useCallback(()=>t(!1),[]),d=w.useCallback(()=>s(!1),[]);return{sessionListOpen:e,accountsPanelOpen:r,toggleSessionList:o,toggleAccountsPanel:l,closeSessionList:u,closeAccountsPanel:d}}const NL="agent-dag.detailOpen",jL="agent-dag.usagePanelOpen",SL="agent-dag.systemPanelOpen";function Coe(){return et(NL)==="1"}function Toe(e){Xe(NL,e?"1":"0")}function Aoe(){const e=et(jL);return e===null?!0:e==="1"}function Roe(e){Xe(jL,e?"1":"0")}function Moe(){const e=et(SL);return e===null?!0:e==="1"}function $oe(e){Xe(SL,e?"1":"0")}function Ioe(){const[e,t]=w.useState(Coe);w.useEffect(()=>{Toe(e)},[e]);const[n,r]=w.useState(Aoe);w.useEffect(()=>{Roe(n)},[n]);const[s,o]=w.useState(Moe);return w.useEffect(()=>{$oe(s)},[s]),qt("detail-panel",e),qt("usage-panel",n),qt("machine-panel",s),{detailOpen:e,setDetailOpen:t,usagePanelOpen:n,setUsagePanelOpen:r,machinePanelOpen:s,setMachinePanelOpen:o}}const Ooe={permission:"your permission",asked:"your answer"},Loe="No sessions are waiting for you.";function Poe(e){if(e.length===0)return"";const[t,...n]=e,r=t.waiting.kind,s=n.every(l=>l.waiting.kind===r)?Ooe[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 Yv(e,t,n=Loe){return t!==""?t:e===""?"":n}function Doe({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[r,s]=w.useState(""),o=Poe(e);w.useEffect(()=>{s(g=>Yv(g,o))},[o]);const[l,u]=w.useState(""),d=t>0?`Browser watch has ${t} unread ${t===1?"finding":"findings"}.`:"";w.useEffect(()=>{u(g=>Yv(g,d,"Browser watch has no unread findings."))},[d]);const[h,f]=w.useState(""),p=soe(n);return w.useEffect(()=>{f(g=>Yv(g,p,aoe))},[p]),{blockedSaid:r,watchSaid:l,setWatchSaid:u,incidentSaid:h}}const Foe="/icon-192.png";function Boe({waitingSessions:e,liveSince:t,focusSession:n}){const[r,s]=w.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[o,l]=w.useState(null),[u,d]=w.useState(!1),[h,f]=w.useState(!1),p=w.useRef(()=>{}),g=w.useRef(new Set),v=bn(e),k=w.useCallback(()=>{const T=!u;d(T),T&&(g.current=bu(v.current)),T&&typeof Notification<"u"&&Notification.permission==="default"&&p.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:T})}).then(A=>A.ok?A.json():null).then(A=>{var R;A!=null&&A.ok&&(d(((R=A.prefs)==null?void 0:R.notifications)===!0),f(A.notificationsVetoed===!0))}).catch(()=>{})},[u]),b=typeof Notification<"u";w.useEffect(()=>{if(!o)return;const A=setTimeout(()=>l(null),o==="blocked"?8e3:4e3);return()=>clearTimeout(A)},[o]);const x=w.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(T=>{const A=T;s(A),A==="granted"?l("on"):A==="denied"&&l("blocked")})},[]);p.current=x;const N=w.useRef(null),S=e.map(T=>Ld(T.id,T.waiting)).join("|");w.useEffect(()=>{qq(N.current,r)&&(N.current=r,g.current=bu(e))},[r]);const _=w.useRef(!1);w.useEffect(()=>{Uq(_.current,t)&&(_.current=!0,g.current=bu(e))},[t]),w.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!zq(N.current,t))return;const T=typeof document>"u"||!document.hidden,A=Fq(e,g.current,T,u);for(const R of A)try{const B=new Notification(R.title,{body:R.body,tag:R.key,icon:Foe});B.onclick=()=>{window.focus(),n(R.sessionId),B.close()}}catch{}g.current=T?bu(e):Bq(e,A,g.current)},[S,t]);const E=w.useCallback(T=>{var A;d(((A=T.prefs)==null?void 0:A.notifications)===!0),f(T.notificationsVetoed===!0)},[]);return{notifyPermission:r,notifySaid:o,notifyOn:u,notifyVetoed:h,toggleNotify:k,notifySupported:b,askForNotifications:x,loadNotifyPrefs:E}}function qoe({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:r,summaryFor:s,browserWatchOpen:o,keyHelpOpen:l,releaseNotes:u,feedbackOpen:d}){const h=bn(l),f=w.useRef(!1);return f.current=e!=null||t||n!=null||r||s!=null||o||l||u!=null||d,{keyHelpOpenRef:h,modalOpenRef:f}}function Uoe({stateRef:e,tourOpen:t,releaseNotes:n}){const[r,s]=w.useState(null),o=w.useCallback((D,I)=>s({agentId:D,toolId:I}),[]),[l,u]=w.useState(null),[d,h]=w.useState(null),f=w.useCallback(D=>h(D),[]),[p,g]=w.useState(!1),[v,k]=w.useState(!1),[b,x]=w.useState(!1),[N,S]=w.useState(!1),[_,E]=w.useState(null),T=w.useCallback(D=>{E(D??null),S(!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",b),qt("feedback",N);const A=r?BB(e.current.agents,r.agentId,r.toolId):null,R=d?e.current.agents.get(d):void 0,{keyHelpOpenRef:B,modalOpenRef:P}=qoe({openedTool:A,usageHistoryOpen:v,contextFor:d,tourOpen:t,summaryFor:l,browserWatchOpen:b,keyHelpOpen:p,releaseNotes:n,feedbackOpen:N});return{setOpenedToolKey:s,openTool:o,openedTool:A,summaryFor:l,setSummaryFor:u,contextFor:d,setContextFor:h,openContext:f,contextAgent:R,keyHelpOpen:p,setKeyHelpOpen:g,usageHistoryOpen:v,setUsageHistoryOpen:k,browserWatchOpen:b,setBrowserWatchOpen:x,feedbackOpen:N,setFeedbackOpen:S,feedbackPrefill:_,setFeedbackPrefill:E,openFeedback:T,keyHelpOpenRef:B,modalOpenRef:P}}function zoe({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:r,lastLayoutSigRef:s,forgetRemovals:o,clearSelection:l,rerender:u,modalOpenRef:d}){const[h,f]=w.useState(!1),p=w.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}e.current=Eb(),t.current.clear(),n.current.clear(),r.current.clear(),s.current="",zO(),o(),l(),u()},[u,l,o]),g=bn(h),v=w.useCallback(k=>{const b=fre(k,{confirmOpen:g.current,modalOpen:d.current});b==="confirm"?f(!0):b==="clear"&&(f(!1),p())},[p]);return{clearConfirmOpen:h,setClearConfirmOpen:f,requestClear:v}}const PR="agent-dag.oldNameNoticeDismissed";function Woe(e){const[t,n]=w.useState(()=>et(PR)??""),r=e!=null&&e.invokedAs&&e.invokedAs!==bt?e.invokedAs:null,s=r!=null&&t!==r,o=w.useCallback(()=>{r&&(n(r),Xe(PR,r))},[r]);return{oldName:r,oldNameOpen:s,dismissOldName:o}}function Hoe({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:r}){const[s,o]=w.useState(()=>UY(et)),l=bn(s),[u,d]=w.useState([]),h=w.useCallback(S=>{o(_=>{const E={..._,[S]:null};return l.current=E,E}),us(Tl[S])},[]),f=w.useCallback((S,_)=>{const E=l.current[S];_&&E!==_||(h(S),t(T=>{const A={...T,[S]:{...T[S],figure:xn}};return n.current=A,A}),Xe(vd[S],xn))},[h]),p=bn(f);w.useEffect(()=>{let S=!0;return QY().then(_=>{if(!S)return;d(_);const E=new Set(_.map(T=>T.id));for(const T of Hu){const A=l.current[T];A&&!E.has(A)&&p.current(T,A)}},()=>{}),()=>{S=!1}},[]);const g=w.useCallback((S,_)=>{if(!u.some(T=>T.id===_))return;const E={...l.current,[S]:_};l.current=E,o(E),Xe(Tl[S],_),r(S,!0)},[u,r]),v=w.useCallback(async S=>{var A;const _=Wx(u.length);if(_)throw new Error(_);const E=window.AudioContext??window.webkitAudioContext;if(!E)throw new Error("This browser cannot decode audio files.");const T=new E;try{const R=await KY(S,P=>T.decodeAudioData(P));await MS(R);const B=Kl(R);d(P=>[...P.filter(D=>D.id!==B.id),B])}finally{(A=T.close)==null||A.call(T)}},[u.length]),k=w.useCallback(async S=>{const _=Wx(u.length);if(_)throw new Error(_);const E=YY(S);await MS(E);const T=Kl(E);d(A=>[...A.filter(R=>R.id!==T.id),T])},[u.length]),b=w.useCallback(async(S,_)=>{const E=u.find(A=>A.id===S),T=_.trim().slice(0,80);!E||!T||T===E.name||(await tX(S,T),d(A=>A.map(R=>R.id===S?{...R,name:T}:R)))},[u]),x=w.useCallback(async S=>{await nX(S),d(A=>A.filter(R=>R.id!==S));const _=l.current,E=zY(_,S);l.current=E,o(E);const T=Hu.filter(A=>_[A]===S);for(const A of T)us(Tl[A]),Xe(vd[A],xn);T.length>0&&t(A=>{const R={...A};for(const B of T)R[B]={...R[B],figure:xn};return n.current=R,R})},[]),N=w.useCallback(S=>{var T,A;const _=Hu.find(R=>l.current[R]===S),E=_?n.current[_].level:Ua;(T=e.current)==null||T.unlock(),(A=e.current)==null||A.previewCustom(S,E)},[]);return{customSelections:s,customSelectionsRef:l,customAssets:u,clearCustomOnly:h,fallbackCustomRef:p,selectCustomTone:g,importNotificationAudio:v,createNotificationVoice:k,renameCustomAsset:b,deleteCustomAsset:x,previewCustomAsset:N}}function Voe(e){const[t,n]=w.useState(()=>pX(et)),r=bn(t),s=w.useRef(null),o=w.useCallback((u,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(u,!0);return}s.current=setTimeout(()=>{var p;s.current=null,(p=e.current)==null||p.play(u,!0)},cX)},[]),l=w.useCallback((u,d)=>{n(h=>{const f={level:fi(d.level??h[u].level),figure:EI(u,d.figure??h[u].figure)};return Xe(AI[u],String(f.level)),Xe(vd[u],f.figure),{...h,[u]:f}}),o(u,!0)},[o]);return w.useEffect(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]),{tonePrefs:t,setTonePrefs:n,tonePrefsRef:r,previewTone:o,changeTone:l}}const Goe=15e3;function Koe(e){return e.visibilityState==="visible"&&e.hasFocus()}function Yoe(e,t){return t||e===!0}function Xoe(){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 Zoe(){w.useEffect(()=>{const e=Xoe();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=Koe(document);Yoe(t,l)&&n(l),t=l},s=()=>{t&&n(!1),t=!1};r();const o=window.setInterval(r,Goe);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 Joe({loadAutoRestartPrefs:e,loadNotifyPrefs:t,loadReportsPrefs:n}){w.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 Xv="agent-dag.versionNoticeDismissed",Qoe=15*6e4;function eie(e){const[t,n]=w.useState(null),[r,s]=w.useState(()=>et(Xv)??""),o=w.useRef(0),[l,u]=w.useState(!1),d=w.useCallback((b=!1)=>(b&&(o.current=Date.now(),u(!0)),fetch(b?"/api/version?refresh=1":"/api/version").then(x=>x.ok?x.json():null).then(x=>{x&&n(x)}).catch(()=>{}).finally(()=>{b&&u(!1)})),[]),h=w.useCallback(()=>{d(Date.now()-o.current>=Qoe)},[d]);w.useEffect(()=>{d();const b=window.setInterval(h,5*6e4),x=()=>{document.visibilityState==="visible"&&h()};return document.addEventListener("visibilitychange",x),()=>{window.clearInterval(b),document.removeEventListener("visibilitychange",x)}},[d,h]),w.useEffect(()=>{e&&d()},[e,d]);const f=(t==null?void 0:t.notice)??null,p=JO(f),g=qne(f,r),v=w.useCallback(()=>{s(""),Xe(Xv,"")},[]),k=w.useCallback(()=>{f&&(s(p),Xe(Xv,p))},[f,p]);return{version:t,notice:f,noticeOpen:g,showNotice:v,dismissNotice:k,versionChecking:l,loadVersion:d}}function tie({version:e,readyAppUpdate:t}){const[n,r]=w.useState(!1),s=w.useRef(null),[o,l]=w.useState(null),u=o&&t?t.version:null,d=w.useRef(null);w.useEffect(()=>{!u||d.current===u||(d.current=u,fetch("/api/desktop-update/seen",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:u})}).catch(()=>{}))},[u]);const h=w.useRef(!1);w.useEffect(()=>{if(h.current)return;const x=El(),N=aae(x),S=dae({stored:N,running:(e==null?void 0:e.running)??null,notes:_R,remembers:oae(x)});if(S.reason==="no-version")return;h.current=!0,S.record&&iae(x,S.record);let _=!0;return(async()=>{var B;let T=lae(x);if(Zl())try{const P=await fetch("/api/prefs");if(!P.ok)throw new Error("desktop tour preferences unavailable");const D=await P.json();if(!(D!=null&&D.ok))throw new Error("desktop tour preferences unavailable");const I=((B=D.prefs)==null?void 0:B.tourSeen)===!0;T&&!I&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{}),T=T||I}catch{T=!0}if(!_)return;const A=uae({tourSeen:T,decision:S}),R=S.show.length?{entries:S.show,since:N,firstRun:!1}:null;A.tour&&r(!0),A.notes==="now"?l(R):A.notes==="after"&&(s.current=R)})(),()=>{_=!1}},[e==null?void 0:e.running]);const f=(e==null?void 0:e.running)??"3.36.8",p=w.useMemo(()=>cL(_R,null,f),[f]),g=w.useCallback(()=>{l({entries:p,since:null,firstRun:!1})},[p]),v=w.useCallback(()=>r(!0),[]),k=w.useCallback(()=>l(null),[]),b=w.useCallback(()=>{r(!1),cae(El()),Zl()&&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:b,releaseNotes:o,closeReleaseNotes:k,chipVersion:f,openReleaseNotes:g}}function nie(){const[e,t]=w.useState(void 0),[n,r]=w.useState(!1),s=w.useRef(!1);return s.current=e===!0&&!n,w.useEffect(()=>Iae(()=>s.current),[]),{loadReportsPrefs:w.useCallback(l=>{var u;t(((u=l.prefs)==null?void 0:u.reports)!==!1),r(l.reportsVetoed===!0)},[])}}function rie(){const[e,t]=w.useState(null),[n,r]=w.useState(!1),s=w.useRef(null);return w.useEffect(()=>{let o=!0,l=!1,u=null,d=null,h="";const f=b=>{o&&(r(!0),b!==h&&t(null))},p=()=>{if(l)return;l=!0,u=Date.now();const b=fR();d=b,fetch(`/api/ccusage?since=${b}`).then(x=>x.ok?x.json():null).then(x=>{if(o){if(!(x!=null&&x.ok)){f(b);return}h=b,t(Tne(x)),r(!1)}}).catch(()=>f(b)).finally(()=>{l=!1})},g=()=>{const b=s.current;Cne({shown:!!b&&b.getClientRects().length>0,tabVisible:document.visibilityState==="visible",lastSince:d,since:fR(),lastReadAt:u,now:Date.now()})&&p()};g();const v=window.setInterval(g,Ene);document.addEventListener("visibilitychange",g);let k=null;return s.current&&typeof ResizeObserver<"u"&&(k=new ResizeObserver(g),k.observe(s.current)),()=>{o=!1,window.clearInterval(v),document.removeEventListener("visibilitychange",g),k==null||k.disconnect()}},[]),{monthlyUsage:e,monthlyUsageUnavailable:n,monthUsageRef:s}}function sie(e){const[t,n]=w.useState(null);w.useEffect(()=>{const u=et("agent-dag.sound");n(u===null?!0:u==="on")},[]);const r=w.useCallback(()=>{n(u=>{var h;const d=u!==!0;return Xe("agent-dag.sound",d?"on":"off"),d&&((h=e.current)==null||h.unlock()),d})},[]),s=w.useCallback(u=>{r()},[r]),o=bn(s),l=bn(t);return{soundOn:t,toggleSound:r,activateSoundRef:o,soundOnRef:l}}function aie(){const[e,t]=w.useState(!1),n=w.useRef(null),[r,s]=w.useState(!1),o=w.useRef(null);return w.useEffect(()=>{e&&s(!1)},[e]),{soundMenuOpen:e,setSoundMenuOpen:t,soundButtonRef:n,appearanceMenuOpen:r,setAppearanceMenuOpen:s,appearanceButtonRef:o}}const oie="agent-dag.autoFitDisabled";function iie(e){const t=w.useRef(!1),[n,r]=w.useState(!1);w.useEffect(()=>{us(oie)},[]);const s=w.useCallback(()=>{t.current||(t.current=!0,r(!0))},[]),o=w.useCallback(()=>{t.current=!1,r(!1),e(400)},[e]);return{autoFitDisabled:n,autoFitDisabledRef:t,disableAutoFit:s,enableAutoFitAndRefit:o}}function lie(){return a.jsx(jb,{children:a.jsx(Pae,{children:a.jsx(cie,{})})})}function cie(){const e=gi(),t=w.useState(Eb)[0],n=w.useRef(t),[,r]=w.useState(0),s=w.useCallback(()=>r(_r=>_r+1),[]),{detailOpen:o,setDetailOpen:l,usagePanelOpen:u,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f}=Ioe(),{selectedIds:p,primarySelectedId:g,selectAgent:v,clearSelection:k,pruneSelectionToBoard:b}=MX(n,l),{sessionListOpen:x,accountsPanelOpen:N,toggleSessionList:S,toggleAccountsPanel:_,closeSessionList:E,closeAccountsPanel:T}=Eoe(),A=rie(),R=qu(N,200),B=qu(u,130),P=qu(h,130),D=w.useRef(null),I=sie(D),{activateSoundRef:O,soundOnRef:z}=I,M=Voe(D),{setTonePrefs:$,tonePrefsRef:q,previewTone:X}=M,H=Hoe({chimesRef:D,setTonePrefs:$,tonePrefsRef:q,previewTone:X}),{customSelectionsRef:L,fallbackCustomRef:W}=H,F=aie(),{setSoundMenuOpen:Y}=F,{chimeState:J}=yoe({chimesRef:D,soundOnRef:z,tonePrefsRef:q,customSelectionsRef:L,fallbackCustomRef:W}),V=Bae(n),{pauseGate:G,paused:K,togglePause:Z}=V,ee=w.useRef(()=>{}),{live:re,tabCapped:ue,everConnected:me,liveSince:ie}=kX({stateRef:n,rerender:s,pauseGate:G,chimesRef:D,desktopUpdateRef:ee}),fe=eie(re),{version:ve,notice:se,noticeOpen:ke,loadVersion:pe}=fe,he=voe(re),{readyAppUpdate:ae,onDesktopUpdateEvent:Ne}=he;ee.current=Ne,Zoe();const Te=tie({version:ve,readyAppUpdate:ae}),{tourOpen:Ie,openTour:Oe,releaseNotes:He}=Te,{workspace:Ye,providers:Ve,providersRef:Ke}=Uae(re),nt=Woe(ve),it=ooe({version:ve,loadVersion:pe}),{upgradeFailure:At}=it,Be=Uoe({stateRef:n,tourOpen:Ie,releaseNotes:He}),{openTool:Ze,setSummaryFor:Je,setContextFor:rt,openContext:gt,setKeyHelpOpen:Rt,setUsageHistoryOpen:yt,setBrowserWatchOpen:lt,keyHelpOpenRef:en,modalOpenRef:Pt}=Be,zt=nie(),Dt=loe(),{watchOn:Yt,watchUnseen:Ur}=Dt,zn=boe(),[zr,Wr]=w.useState(0),{presentCats:Wn,hiddenCats:gr,toggleCat:Hn,catBarRef:Hr,catBarOccluded:Nn}=moe(n),gs=w.useRef(null),[jn,yr]=w.useState(0),vt=$X({stateRef:n,rerender:s,pruneSelectionToBoard:b,setContextFor:rt,setSummaryFor:Je}),wr=Vae(Ve.claude||Ve.codex),vr=roe(wr,vt),Vr=Noe({enabled:Ve.claude,lanStatus:zn.lanStatus,now:vt}),Vn=xoe({now:vt,stateRef:n,version:ve,notice:se,noticeOpen:ke,upgradeFailure:At,paused:V.paused}),{askRestart:pn,loadAutoRestartPrefs:Gr}=Vn,Sn=poe(),{setTheme:we,palette:De}=Sn,qe=woe(),tn=Aee(),{applyViewport:ys,moveCamera:xr,fitLeft:Gn,cameraEpochRef:Qe,lastFitTimeRef:br}=tn,Kn=Uee(Gn),{pinnedRef:Kr,positionsRef:Yn,lastLayoutSigRef:Xa,handleRelayout:Za}=Kn,Yr=w.useRef(null),Xt=w.useRef(()=>{}),sa=ie!==null,nn=w.useRef(0),hc=w.useCallback(()=>{nn.current=Date.now()},[]),{canvasRef:Xr,canvasSize:wh,paneSizeRef:Ja}=Nte(),aa=iie(Gn),{autoFitDisabledRef:ws,disableAutoFit:vs}=aa,_i=w.useRef(!1),{measuredRef:Zr,measuredVersionRef:Ei,sizeVersion:fc,domSizeVersion:Ci}=jte(_i),{removedNodes:xs,removedAgentIds:bs,removeNode:Ti,removeSelectedNode:ze,removalNotice:Ai,bringBack:Qa,bringBackAll:Ri,forgetRemovals:pc}=fte({stateRef:n,pinnedRef:Kr,positionsRef:Yn,canvasRef:Xr,clearSelection:k,primarySelectedId:g}),eo=lte({stateRef:n,now:vt,removedAgentIds:bs,sizeVersion:fc,domSizeVersion:Ci});zee(eo,Kn),hte({layoutSig:eo,rf:e,stateRef:n,measuredRef:Zr,pinnedRef:Kr,positionsRef:Yn,paneSizeRef:Ja,lastInteractRef:nn,autoFitDisabledRef:ws,lastFitTimeRef:br,fitLeft:Gn});const Mi=Ste(),{bubbling:$i,endBubble:to,onBubble:kr}=_Y(),[_n,Nr]=w.useState(!1),ks=jY(),{beginTrashDrag:oa,trackTrashDrag:jr,endTrashDrag:vh}=ks,Ii=OY({stateRef:n,measuredRef:Zr,measuredVersionRef:Ei,canvasRef:Xr}),{lodRef:ia,applyZoom:xh}=Ii,Oi=bte({applyViewport:ys,lastFitTimeRef:br,cameraEpochRef:Qe,disableAutoFit:vs,markInteract:hc,canvasRef:Xr,applyZoom:xh}),Sr=g?n.current.agents.get(g):null,Li=o&&Sr!=null,{railInsetRef:mc,availableWidth:Ns,availableHeight:js}=Tee({canvasRef:Xr,canvasSize:wh,machinePhase:P,usagePhase:B,usagePanelOpen:u,detailShown:Li}),Jr=cte({stateRef:n,now:vt,availableWidth:Ns,availableHeight:js,layout:Kn,measuredRef:Zr,onBubble:kr,settled:Mi,dragging:_n,layoutSig:eo,selectedIds:p,openContext:gt,historyReplayed:sa,removedNodes:xs,removedAgentIds:bs,dragTick:zr,dragPatchRef:gs,dragMoveTick:jn}),{nodes:Ss,edges:bh}=Jr,Pi=bn(g);Wee({nodes:Ss,edges:bh,settled:Mi,dragging:_n,availableWidth:Ns,availableHeight:js,layout:Kn,camera:tn,rf:e,measuredRef:Zr,stateRef:n,lastFocusRef:Yr,primarySelectedIdRef:Pi,focusAgentRef:Xt,autoFitDisabledRef:ws});const no=zoe({stateRef:n,pinnedRef:Kr,measuredRef:Zr,positionsRef:Yn,lastLayoutSigRef:Xa,forgetRemovals:pc,clearSelection:k,rerender:s,modalOpenRef:Pt}),{requestClear:la}=no,Di=Cte({nodes:Ss,stateRef:n,pinnedRef:Kr,positionsRef:Yn,draggingRef:_i,dragPatchRef:gs,setDragging:Nr,setDragMoveTick:yr,setDragTick:Wr,endBubble:to,markInteract:hc,disableAutoFit:vs,beginTrashDrag:oa,trackTrashDrag:jr,endTrashDrag:vh,removeNode:Ti}),gc=w.useCallback(()=>Gn(500),[Gn]),En=bn(Ss),{focusAgent:_s,stepAgent:ro,focusSession:Es}=Mee({canvasRef:Xr,stateRef:n,measuredRef:Zr,nodesRef:En,railInsetRef:mc,moveCamera:xr,disableAutoFit:vs,lastFocusRef:Yr,focusAgentRef:Xt,selectAgent:v,primarySelectedIdRef:Pi}),so=kte({clearSelection:k,selectAgent:v,detailOpen:o,setDetailOpen:l,detailShown:Li,focusAgent:_s,draggingRef:_i,lodRef:ia}),ao=$ee({nodesRef:En,stateRef:n,canvasRef:Xr,railInsetRef:mc}),yc=bn(ze),Wt=w.useRef(null),Cs=w.useCallback(_r=>{bs.has(_r)&&Qa([_r]),Es(_r)},[bs,Qa,Es]),Fi=_te();Ete({pointerFocusRef:Fi,nodesRef:En,stateRef:n,primarySelectedIdRef:Pi,providersRef:Ke,soundOnRef:z,keyHelpOpenRef:en,modalOpenRef:Pt,waitingCursorRef:Wt,removeSelectedRef:yc,activateSoundRef:O,clearSelection:k,selectAgent:v,focusAgent:_s,stepAgent:ro,focusSession:Es,requestClear:la,handleRelayout:Za,handleFit:gc,togglePause:Z,toggleSessionList:S,toggleAccountsPanel:_,setDetailOpen:l,setUsageHistoryOpen:yt,setUsagePanelOpen:d,setMachinePanelOpen:f,setBrowserWatchOpen:lt,setSoundMenuOpen:Y,setKeyHelpOpen:Rt,setTheme:we});const Ts=n.current.agents.size,ca=w.useMemo(()=>mx(n.current.agents.values()),[n.current,n.current.revision]);pte({stateRef:n,waitingSessions:ca,removedAgentIds:bs,removedNodes:xs,bringBack:Qa}),wte({stateRef:n,waitingSessions:ca,live:re});const oo=Doe({waitingSessions:ca,watchUnseen:Ur,incidents:vr}),ua=Boe({waitingSessions:ca,liveSince:ie,focusSession:Es}),{loadNotifyPrefs:da}=ua;return Joe({loadAutoRestartPrefs:Gr,loadNotifyPrefs:da,loadReportsPrefs:zt.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(Gne,{versionCheck:fe,welcome:Te,desktopUpdate:he,pause:V,monthly:A,announcements:oo,notify:ua,waitingSessions:ca,waitingCursorRef:Wt,focusSession:Es,live:re,now:vt,incidents:vr}),Sr&&a.jsx(Kne,{selected:Sr,now:vt,selectedIds:p,focusAgent:_s,clearSelection:k}),a.jsxs("div",{className:"actions",children:[a.jsx(Nne,{sessionListOpen:x,toggleSessionList:S,usagePanelOpen:u,setUsagePanelOpen:d,setUsageHistoryOpen:yt}),a.jsx(jne,{providers:Ve,accountsPanelOpen:N,toggleAccountsPanel:_,machinePanelOpen:h,setMachinePanelOpen:f,watchOn:Yt,watchUnseen:Ur,setBrowserWatchOpen:lt}),a.jsx(Sne,{providers:Ve,sound:I,tones:M,customTones:H,notify:ua,chimeState:J,menus:F,appearance:Sn,fm:qe,onFeedback:()=>Be.openFeedback()})]})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Ai?`${Ai.label} removed from the board.`:""}),a.jsx(hre,{restart:Vn,versionCheck:fe,upgrade:it,oldNameNotice:nt,everConnected:me,live:re,paused:K}),Bu(R)&&Ve.claude&&a.jsx(yY,{leaving:R==="leaving",onClose:T,onReport:Be.openFeedback,onRoster:Vr.observe}),x&&a.jsx(SW,{state:n.current,now:vt,selectedIds:p,onSelect:Cs,onClose:E,removedIds:bs,onBringBackAll:Ri}),a.jsxs(Qne,{canvasRef:Xr,bubbling:$i,dragging:_n,trash:ks,zoom:Ii,viewport:Oi,stateRef:n,peek:ao,children:[Ts===0&&(!re&&ue?a.jsx(Lte,{}):a.jsx(Pte,{live:re,everConnected:me,providers:Ve,workspace:Ye,onTour:Oe})),(Wn.length>1||gr.size>0)&&a.jsx(Yne,{catBarRef:Hr,catBarOccluded:Nn,presentCats:Wn,hiddenCats:gr,toggleCat:Hn}),a.jsx(yW,{graph:Jr,layout:Kn,viewport:Oi,clicks:so,drag:Di,appearance:Sn,fm:qe,autoFit:aa,pause:V,stateRef:n,measuredRef:Zr,hiddenCats:gr,now:vt,openTool:Ze,focusAgent:_s,requestClear:la,setKeyHelpOpen:Rt})]}),Bu(B)&&a.jsx(vH,{state:n.current,now:vt,providers:Ve,incidents:vr,liveSince:ie,leaving:B==="leaving",onClose:()=>d(!1)}),Bu(P)&&a.jsx(n7,{usageOpen:u,leaving:P==="leaving",onClose:()=>f(!1)}),o&&Sr?a.jsx(Xte,{selected:Sr,now:vt,openTool:Ze,setSummaryFor:Je,setDetailOpen:l,stateRef:n,removeSelectedNode:ze}):null,a.jsx(Aae,{dialogs:Be,welcome:Te,desktopUpdate:he,versionCheck:fe,restart:Vn,lanPairs:zn,attention:Vr,clearFlow:no,watchBadge:Dt,announcements:oo,appearance:Sn,providers:Ve,stateRef:n,agentCount:Ts})]})}try{k8(window.localStorage)}catch{}const uie=iP.createRoot(document.getElementById("root"));uie.render(a.jsx(lie,{}));export{Rte as a,ot as b,Qs as c,yd as d,fie as e,Fe as f,Or as g,hie as h,Vl as i,a as j,Dr as k,VY as l,_a as m,Ha as n,Ex as p,w as r,lr as s,ft as u};