ccdeck 3.30.0 → 3.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,298 +0,0 @@
1
- (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 Yc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function jx(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Nf={exports:{}},Wi={},Sf={exports:{}},Pe={};/**
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 r1;function VO(){if(r1)return Pe;r1=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"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),m=Symbol.iterator;function g(B){return B===null||typeof B!="object"?null:(B=m&&B[m]||B["@@iterator"],typeof B=="function"?B:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,v={};function b(B,X,G){this.props=B,this.context=X,this.refs=v,this.updater=G||w}b.prototype.isReactComponent={},b.prototype.setState=function(B,X){if(typeof B!="object"&&typeof B!="function"&&B!=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,B,X,"setState")},b.prototype.forceUpdate=function(B){this.updater.enqueueForceUpdate(this,B,"forceUpdate")};function S(){}S.prototype=b.prototype;function _(B,X,G){this.props=B,this.context=X,this.refs=v,this.updater=G||w}var j=_.prototype=new S;j.constructor=_,k(j,b.prototype),j.isPureReactComponent=!0;var E=Array.isArray,T=Object.prototype.hasOwnProperty,R={current:null},M={key:!0,ref:!0,__self:!0,__source:!0};function O(B,X,G){var U,Z={},H=null,J=null;if(X!=null)for(U in X.ref!==void 0&&(J=X.ref),X.key!==void 0&&(H=""+X.key),X)T.call(X,U)&&!M.hasOwnProperty(U)&&(Z[U]=X[U]);var ee=arguments.length-2;if(ee===1)Z.children=G;else if(1<ee){for(var re=Array(ee),oe=0;oe<ee;oe++)re[oe]=arguments[oe+2];Z.children=re}if(B&&B.defaultProps)for(U in ee=B.defaultProps,ee)Z[U]===void 0&&(Z[U]=ee[U]);return{$$typeof:e,type:B,key:H,ref:J,props:Z,_owner:R.current}}function I(B,X){return{$$typeof:e,type:B.type,key:X,ref:B.ref,props:B.props,_owner:B._owner}}function A(B){return typeof B=="object"&&B!==null&&B.$$typeof===e}function L(B){var X={"=":"=0",":":"=2"};return"$"+B.replace(/[=:]/g,function(G){return X[G]})}var z=/\/+/g;function V(B,X){return typeof B=="object"&&B!==null&&B.key!=null?L(""+B.key):X.toString(36)}function $(B,X,G,U,Z){var H=typeof B;(H==="undefined"||H==="boolean")&&(B=null);var J=!1;if(B===null)J=!0;else switch(H){case"string":case"number":J=!0;break;case"object":switch(B.$$typeof){case e:case t:J=!0}}if(J)return J=B,Z=Z(J),B=U===""?"."+V(J,0):U,E(Z)?(G="",B!=null&&(G=B.replace(z,"$&/")+"/"),$(Z,X,G,"",function(oe){return oe})):Z!=null&&(A(Z)&&(Z=I(Z,G+(!Z.key||J&&J.key===Z.key?"":(""+Z.key).replace(z,"$&/")+"/")+B)),X.push(Z)),1;if(J=0,U=U===""?".":U+":",E(B))for(var ee=0;ee<B.length;ee++){H=B[ee];var re=U+V(H,ee);J+=$(H,X,G,re,Z)}else if(re=g(B),typeof re=="function")for(B=re.call(B),ee=0;!(H=B.next()).done;)H=H.value,re=U+V(H,ee++),J+=$(H,X,G,re,Z);else if(H==="object")throw X=String(B),Error("Objects are not valid as a React child (found: "+(X==="[object Object]"?"object with keys {"+Object.keys(B).join(", ")+"}":X)+"). If you meant to render a collection of children, use an array instead.");return J}function P(B,X,G){if(B==null)return B;var U=[],Z=0;return $(B,U,"","",function(H){return X.call(G,H,Z++)}),U}function F(B){if(B._status===-1){var X=B._result;X=X(),X.then(function(G){(B._status===0||B._status===-1)&&(B._status=1,B._result=G)},function(G){(B._status===0||B._status===-1)&&(B._status=2,B._result=G)}),B._status===-1&&(B._status=0,B._result=X)}if(B._status===1)return B._result.default;throw B._result}var Y={current:null},K={transition:null},D={ReactCurrentDispatcher:Y,ReactCurrentBatchConfig:K,ReactCurrentOwner:R};function W(){throw Error("act(...) is not supported in production builds of React.")}return Pe.Children={map:P,forEach:function(B,X,G){P(B,function(){X.apply(this,arguments)},G)},count:function(B){var X=0;return P(B,function(){X++}),X},toArray:function(B){return P(B,function(X){return X})||[]},only:function(B){if(!A(B))throw Error("React.Children.only expected to receive a single React element child.");return B}},Pe.Component=b,Pe.Fragment=n,Pe.Profiler=s,Pe.PureComponent=_,Pe.StrictMode=r,Pe.Suspense=d,Pe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=D,Pe.act=W,Pe.cloneElement=function(B,X,G){if(B==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+B+".");var U=k({},B.props),Z=B.key,H=B.ref,J=B._owner;if(X!=null){if(X.ref!==void 0&&(H=X.ref,J=R.current),X.key!==void 0&&(Z=""+X.key),B.type&&B.type.defaultProps)var ee=B.type.defaultProps;for(re in X)T.call(X,re)&&!M.hasOwnProperty(re)&&(U[re]=X[re]===void 0&&ee!==void 0?ee[re]:X[re])}var re=arguments.length-2;if(re===1)U.children=G;else if(1<re){ee=Array(re);for(var oe=0;oe<re;oe++)ee[oe]=arguments[oe+2];U.children=ee}return{$$typeof:e,type:B.type,key:Z,ref:H,props:U,_owner:J}},Pe.createContext=function(B){return B={$$typeof:l,_currentValue:B,_currentValue2:B,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},B.Provider={$$typeof:o,_context:B},B.Consumer=B},Pe.createElement=O,Pe.createFactory=function(B){var X=O.bind(null,B);return X.type=B,X},Pe.createRef=function(){return{current:null}},Pe.forwardRef=function(B){return{$$typeof:u,render:B}},Pe.isValidElement=A,Pe.lazy=function(B){return{$$typeof:h,_payload:{_status:-1,_result:B},_init:F}},Pe.memo=function(B,X){return{$$typeof:f,type:B,compare:X===void 0?null:X}},Pe.startTransition=function(B){var X=K.transition;K.transition={};try{B()}finally{K.transition=X}},Pe.unstable_act=W,Pe.useCallback=function(B,X){return Y.current.useCallback(B,X)},Pe.useContext=function(B){return Y.current.useContext(B)},Pe.useDebugValue=function(){},Pe.useDeferredValue=function(B){return Y.current.useDeferredValue(B)},Pe.useEffect=function(B,X){return Y.current.useEffect(B,X)},Pe.useId=function(){return Y.current.useId()},Pe.useImperativeHandle=function(B,X,G){return Y.current.useImperativeHandle(B,X,G)},Pe.useInsertionEffect=function(B,X){return Y.current.useInsertionEffect(B,X)},Pe.useLayoutEffect=function(B,X){return Y.current.useLayoutEffect(B,X)},Pe.useMemo=function(B,X){return Y.current.useMemo(B,X)},Pe.useReducer=function(B,X,G){return Y.current.useReducer(B,X,G)},Pe.useRef=function(B){return Y.current.useRef(B)},Pe.useState=function(B){return Y.current.useState(B)},Pe.useSyncExternalStore=function(B,X,G){return Y.current.useSyncExternalStore(B,X,G)},Pe.useTransition=function(){return Y.current.useTransition()},Pe.version="18.3.1",Pe}var s1;function Il(){return s1||(s1=1,Sf.exports=VO()),Sf.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 a1;function GO(){if(a1)return Wi;a1=1;var e=Il(),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,f){var h,m={},g=null,w=null;f!==void 0&&(g=""+f),d.key!==void 0&&(g=""+d.key),d.ref!==void 0&&(w=d.ref);for(h in d)r.call(d,h)&&!o.hasOwnProperty(h)&&(m[h]=d[h]);if(u&&u.defaultProps)for(h in d=u.defaultProps,d)m[h]===void 0&&(m[h]=d[h]);return{$$typeof:t,type:u,key:g,ref:w,props:m,_owner:s.current}}return Wi.Fragment=n,Wi.jsx=l,Wi.jsxs=l,Wi}var o1;function KO(){return o1||(o1=1,Nf.exports=GO()),Nf.exports}var i=KO(),Xc={},jf={exports:{}},en={},_f={exports:{}},Ef={};/**
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 i1;function YO(){return i1||(i1=1,(function(e){function t(K,D){var W=K.length;K.push(D);e:for(;0<W;){var B=W-1>>>1,X=K[B];if(0<s(X,D))K[B]=D,K[W]=X,W=B;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var D=K[0],W=K.pop();if(W!==D){K[0]=W;e:for(var B=0,X=K.length,G=X>>>1;B<G;){var U=2*(B+1)-1,Z=K[U],H=U+1,J=K[H];if(0>s(Z,W))H<X&&0>s(J,Z)?(K[B]=J,K[H]=W,B=H):(K[B]=Z,K[U]=W,B=U);else if(H<X&&0>s(J,W))K[B]=J,K[H]=W,B=H;else break e}}return D}function s(K,D){var W=K.sortIndex-D.sortIndex;return W!==0?W:K.id-D.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=[],f=[],h=1,m=null,g=3,w=!1,k=!1,v=!1,b=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function j(K){for(var D=n(f);D!==null;){if(D.callback===null)r(f);else if(D.startTime<=K)r(f),D.sortIndex=D.expirationTime,t(d,D);else break;D=n(f)}}function E(K){if(v=!1,j(K),!k)if(n(d)!==null)k=!0,F(T);else{var D=n(f);D!==null&&Y(E,D.startTime-K)}}function T(K,D){k=!1,v&&(v=!1,S(O),O=-1),w=!0;var W=g;try{for(j(D),m=n(d);m!==null&&(!(m.expirationTime>D)||K&&!L());){var B=m.callback;if(typeof B=="function"){m.callback=null,g=m.priorityLevel;var X=B(m.expirationTime<=D);D=e.unstable_now(),typeof X=="function"?m.callback=X:m===n(d)&&r(d),j(D)}else r(d);m=n(d)}if(m!==null)var G=!0;else{var U=n(f);U!==null&&Y(E,U.startTime-D),G=!1}return G}finally{m=null,g=W,w=!1}}var R=!1,M=null,O=-1,I=5,A=-1;function L(){return!(e.unstable_now()-A<I)}function z(){if(M!==null){var K=e.unstable_now();A=K;var D=!0;try{D=M(!0,K)}finally{D?V():(R=!1,M=null)}}else R=!1}var V;if(typeof _=="function")V=function(){_(z)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,P=$.port2;$.port1.onmessage=z,V=function(){P.postMessage(null)}}else V=function(){b(z,0)};function F(K){M=K,R||(R=!0,V())}function Y(K,D){O=b(function(){K(e.unstable_now())},D)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(K){K.callback=null},e.unstable_continueExecution=function(){k||w||(k=!0,F(T))},e.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<K?Math.floor(1e3/K):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(K){switch(g){case 1:case 2:case 3:var D=3;break;default:D=g}var W=g;g=D;try{return K()}finally{g=W}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(K,D){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var W=g;g=K;try{return D()}finally{g=W}},e.unstable_scheduleCallback=function(K,D,W){var B=e.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?B+W:B):W=B,K){case 1:var X=-1;break;case 2:X=250;break;case 5:X=1073741823;break;case 4:X=1e4;break;default:X=5e3}return X=W+X,K={id:h++,callback:D,priorityLevel:K,startTime:W,expirationTime:X,sortIndex:-1},W>B?(K.sortIndex=W,t(f,K),n(d)===null&&K===n(f)&&(v?(S(O),O=-1):v=!0,Y(E,W-B))):(K.sortIndex=X,t(d,K),k||w||(k=!0,F(T))),K},e.unstable_shouldYield=L,e.unstable_wrapCallback=function(K){var D=g;return function(){var W=g;g=D;try{return K.apply(this,arguments)}finally{g=W}}}})(Ef)),Ef}var l1;function XO(){return l1||(l1=1,_f.exports=YO()),_f.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 c1;function ZO(){if(c1)return en;c1=1;var e=Il(),t=XO();function n(a){for(var c="https://reactjs.org/docs/error-decoder.html?invariant="+a,p=1;p<arguments.length;p++)c+="&args[]="+encodeURIComponent(arguments[p]);return"Minified React error #"+a+"; 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(a,c){l(a,c),l(a+"Capture",c)}function l(a,c){for(s[a]=c,a=0;a<c.length;a++)r.add(c[a])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),d=Object.prototype.hasOwnProperty,f=/^[: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]*$/,h={},m={};function g(a){return d.call(m,a)?!0:d.call(h,a)?!1:f.test(a)?m[a]=!0:(h[a]=!0,!1)}function w(a,c,p,y){if(p!==null&&p.type===0)return!1;switch(typeof c){case"function":case"symbol":return!0;case"boolean":return y?!1:p!==null?!p.acceptsBooleans:(a=a.toLowerCase().slice(0,5),a!=="data-"&&a!=="aria-");default:return!1}}function k(a,c,p,y){if(c===null||typeof c>"u"||w(a,c,p,y))return!0;if(y)return!1;if(p!==null)switch(p.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 v(a,c,p,y,N,C,q){this.acceptsBooleans=c===2||c===3||c===4,this.attributeName=y,this.attributeNamespace=N,this.mustUseProperty=p,this.propertyName=a,this.type=c,this.sanitizeURL=C,this.removeEmptyString=q}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a){b[a]=new v(a,0,!1,a,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){var c=a[0];b[c]=new v(c,1,!1,a[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(a){b[a]=new v(a,2,!1,a.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){b[a]=new v(a,2,!1,a,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(a){b[a]=new v(a,3,!1,a.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(a){b[a]=new v(a,3,!0,a,null,!1,!1)}),["capture","download"].forEach(function(a){b[a]=new v(a,4,!1,a,null,!1,!1)}),["cols","rows","size","span"].forEach(function(a){b[a]=new v(a,6,!1,a,null,!1,!1)}),["rowSpan","start"].forEach(function(a){b[a]=new v(a,5,!1,a.toLowerCase(),null,!1,!1)});var S=/[\-:]([a-z])/g;function _(a){return a[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(a){var c=a.replace(S,_);b[c]=new v(c,1,!1,a,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a){var c=a.replace(S,_);b[c]=new v(c,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(a){var c=a.replace(S,_);b[c]=new v(c,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(a){b[a]=new v(a,1,!1,a.toLowerCase(),null,!1,!1)}),b.xlinkHref=new v("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(a){b[a]=new v(a,1,!1,a.toLowerCase(),null,!0,!0)});function j(a,c,p,y){var N=b.hasOwnProperty(c)?b[c]:null;(N!==null?N.type!==0:y||!(2<c.length)||c[0]!=="o"&&c[0]!=="O"||c[1]!=="n"&&c[1]!=="N")&&(k(c,p,N,y)&&(p=null),y||N===null?g(c)&&(p===null?a.removeAttribute(c):a.setAttribute(c,""+p)):N.mustUseProperty?a[N.propertyName]=p===null?N.type===3?!1:"":p:(c=N.attributeName,y=N.attributeNamespace,p===null?a.removeAttribute(c):(N=N.type,p=N===3||N===4&&p===!0?"":""+p,y?a.setAttributeNS(y,c,p):a.setAttribute(c,p))))}var E=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,T=Symbol.for("react.element"),R=Symbol.for("react.portal"),M=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),I=Symbol.for("react.profiler"),A=Symbol.for("react.provider"),L=Symbol.for("react.context"),z=Symbol.for("react.forward_ref"),V=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),F=Symbol.for("react.lazy"),Y=Symbol.for("react.offscreen"),K=Symbol.iterator;function D(a){return a===null||typeof a!="object"?null:(a=K&&a[K]||a["@@iterator"],typeof a=="function"?a:null)}var W=Object.assign,B;function X(a){if(B===void 0)try{throw Error()}catch(p){var c=p.stack.trim().match(/\n( *(at )?)/);B=c&&c[1]||""}return`
34
- `+B+a}var G=!1;function U(a,c){if(!a||G)return"";G=!0;var p=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(le){var y=le}Reflect.construct(a,[],c)}else{try{c.call()}catch(le){y=le}a.call(c.prototype)}else{try{throw Error()}catch(le){y=le}a()}}catch(le){if(le&&y&&typeof le.stack=="string"){for(var N=le.stack.split(`
35
- `),C=y.stack.split(`
36
- `),q=N.length-1,Q=C.length-1;1<=q&&0<=Q&&N[q]!==C[Q];)Q--;for(;1<=q&&0<=Q;q--,Q--)if(N[q]!==C[Q]){if(q!==1||Q!==1)do if(q--,Q--,0>Q||N[q]!==C[Q]){var te=`
37
- `+N[q].replace(" at new "," at ");return a.displayName&&te.includes("<anonymous>")&&(te=te.replace("<anonymous>",a.displayName)),te}while(1<=q&&0<=Q);break}}}finally{G=!1,Error.prepareStackTrace=p}return(a=a?a.displayName||a.name:"")?X(a):""}function Z(a){switch(a.tag){case 5:return X(a.type);case 16:return X("Lazy");case 13:return X("Suspense");case 19:return X("SuspenseList");case 0:case 2:case 15:return a=U(a.type,!1),a;case 11:return a=U(a.type.render,!1),a;case 1:return a=U(a.type,!0),a;default:return""}}function H(a){if(a==null)return null;if(typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case M:return"Fragment";case R:return"Portal";case I:return"Profiler";case O:return"StrictMode";case V:return"Suspense";case $:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case L:return(a.displayName||"Context")+".Consumer";case A:return(a._context.displayName||"Context")+".Provider";case z:var c=a.render;return a=a.displayName,a||(a=c.displayName||c.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case P:return c=a.displayName||null,c!==null?c:H(a.type)||"Memo";case F:c=a._payload,a=a._init;try{return H(a(c))}catch{}}return null}function J(a){var c=a.type;switch(a.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 a=c.render,a=a.displayName||a.name||"",c.displayName||(a!==""?"ForwardRef("+a+")":"ForwardRef");case 7:return"Fragment";case 5:return c;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return H(c);case 8:return c===O?"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(a){switch(typeof a){case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function re(a){var c=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(c==="checkbox"||c==="radio")}function oe(a){var c=re(a)?"checked":"value",p=Object.getOwnPropertyDescriptor(a.constructor.prototype,c),y=""+a[c];if(!a.hasOwnProperty(c)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var N=p.get,C=p.set;return Object.defineProperty(a,c,{configurable:!0,get:function(){return N.call(this)},set:function(q){y=""+q,C.call(this,q)}}),Object.defineProperty(a,c,{enumerable:p.enumerable}),{getValue:function(){return y},setValue:function(q){y=""+q},stopTracking:function(){a._valueTracker=null,delete a[c]}}}}function fe(a){a._valueTracker||(a._valueTracker=oe(a))}function Ne(a){if(!a)return!1;var c=a._valueTracker;if(!c)return!0;var p=c.getValue(),y="";return a&&(y=re(a)?a.checked?"true":"false":a.value),a=y,a!==p?(c.setValue(a),!0):!1}function ke(a){if(a=a||(typeof document<"u"?document:void 0),typeof a>"u")return null;try{return a.activeElement||a.body}catch{return a.body}}function we(a,c){var p=c.checked;return W({},c,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??a._wrapperState.initialChecked})}function ve(a,c){var p=c.defaultValue==null?"":c.defaultValue,y=c.checked!=null?c.checked:c.defaultChecked;p=ee(c.value!=null?c.value:p),a._wrapperState={initialChecked:y,initialValue:p,controlled:c.type==="checkbox"||c.type==="radio"?c.checked!=null:c.value!=null}}function $e(a,c){c=c.checked,c!=null&&j(a,"checked",c,!1)}function ye(a,c){$e(a,c);var p=ee(c.value),y=c.type;if(p!=null)y==="number"?(p===0&&a.value===""||a.value!=p)&&(a.value=""+p):a.value!==""+p&&(a.value=""+p);else if(y==="submit"||y==="reset"){a.removeAttribute("value");return}c.hasOwnProperty("value")?se(a,c.type,p):c.hasOwnProperty("defaultValue")&&se(a,c.type,ee(c.defaultValue)),c.checked==null&&c.defaultChecked!=null&&(a.defaultChecked=!!c.defaultChecked)}function ue(a,c,p){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=""+a._wrapperState.initialValue,p||c===a.value||(a.value=c),a.defaultValue=c}p=a.name,p!==""&&(a.name=""),a.defaultChecked=!!a._wrapperState.initialChecked,p!==""&&(a.name=p)}function se(a,c,p){(c!=="number"||ke(a.ownerDocument)!==a)&&(p==null?a.defaultValue=""+a._wrapperState.initialValue:a.defaultValue!==""+p&&(a.defaultValue=""+p))}var xe=Array.isArray;function Ae(a,c,p,y){if(a=a.options,c){c={};for(var N=0;N<p.length;N++)c["$"+p[N]]=!0;for(p=0;p<a.length;p++)N=c.hasOwnProperty("$"+a[p].value),a[p].selected!==N&&(a[p].selected=N),N&&y&&(a[p].defaultSelected=!0)}else{for(p=""+ee(p),c=null,N=0;N<a.length;N++){if(a[N].value===p){a[N].selected=!0,y&&(a[N].defaultSelected=!0);return}c!==null||a[N].disabled||(c=a[N])}c!==null&&(c.selected=!0)}}function Le(a,c){if(c.dangerouslySetInnerHTML!=null)throw Error(n(91));return W({},c,{value:void 0,defaultValue:void 0,children:""+a._wrapperState.initialValue})}function Ie(a,c){var p=c.value;if(p==null){if(p=c.children,c=c.defaultValue,p!=null){if(c!=null)throw Error(n(92));if(xe(p)){if(1<p.length)throw Error(n(93));p=p[0]}c=p}c==null&&(c=""),p=c}a._wrapperState={initialValue:ee(p)}}function qe(a,c){var p=ee(c.value),y=ee(c.defaultValue);p!=null&&(p=""+p,p!==a.value&&(a.value=p),c.defaultValue==null&&a.defaultValue!==p&&(a.defaultValue=p)),y!=null&&(a.defaultValue=""+y)}function nt(a){var c=a.textContent;c===a._wrapperState.initialValue&&c!==""&&c!==null&&(a.value=c)}function rt(a){switch(a){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 Ye(a,c){return a==null||a==="http://www.w3.org/1999/xhtml"?rt(c):a==="http://www.w3.org/2000/svg"&&c==="foreignObject"?"http://www.w3.org/1999/xhtml":a}var ct,At=(function(a){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(c,p,y,N){MSApp.execUnsafeLocalFunction(function(){return a(c,p,y,N)})}:a})(function(a,c){if(a.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in a)a.innerHTML=c;else{for(ct=ct||document.createElement("div"),ct.innerHTML="<svg>"+c.valueOf().toString()+"</svg>",c=ct.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;c.firstChild;)a.appendChild(c.firstChild)}});function vt(a,c){if(c){var p=a.firstChild;if(p&&p===a.lastChild&&p.nodeType===3){p.nodeValue=c;return}}a.textContent=c}var Ve={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},ut=["Webkit","ms","Moz","O"];Object.keys(Ve).forEach(function(a){ut.forEach(function(c){c=c+a.charAt(0).toUpperCase()+a.substring(1),Ve[c]=Ve[a]})});function Ze(a,c,p){return c==null||typeof c=="boolean"||c===""?"":p||typeof c!="number"||c===0||Ve.hasOwnProperty(a)&&Ve[a]?(""+c).trim():c+"px"}function ot(a,c){a=a.style;for(var p in c)if(c.hasOwnProperty(p)){var y=p.indexOf("--")===0,N=Ze(p,c[p],y);p==="float"&&(p="cssFloat"),y?a.setProperty(p,N):a[p]=N}}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 ge(a,c){if(c){if(Gt[a]&&(c.children!=null||c.dangerouslySetInnerHTML!=null))throw Error(n(137,a));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 Oe(a,c){if(a.indexOf("-")===-1)return typeof c.is=="string";switch(a){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 Fe=null;function Lt(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var Kt=null,Mt=null,on=null;function Ut(a){if(a=Ri(a)){if(typeof Kt!="function")throw Error(n(280));var c=a.stateNode;c&&(c=uc(c),Kt(a.stateNode,a.type,c))}}function Xn(a){Mt?on?on.push(a):on=[a]:Mt=a}function Ra(){if(Mt){var a=Mt,c=on;if(on=Mt=null,Ut(a),c)for(a=0;a<c.length;a++)Ut(c[a])}}function Aa(a,c){return a(c)}function Rs(){}var br=!1;function Ma(a,c,p){if(br)return a(c,p);br=!0;try{return Aa(a,c,p)}finally{br=!1,(Mt!==null||on!==null)&&(Rs(),Ra())}}function kr(a,c){var p=a.stateNode;if(p===null)return null;var y=uc(p);if(y===null)return null;p=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)||(a=a.type,y=!(a==="button"||a==="input"||a==="select"||a==="textarea")),a=!y;break e;default:a=!1}if(a)return null;if(p&&typeof p!="function")throw Error(n(231,c,typeof p));return p}var As=!1;if(u)try{var Zn={};Object.defineProperty(Zn,"passive",{get:function(){As=!0}}),window.addEventListener("test",Zn,Zn),window.removeEventListener("test",Zn,Zn)}catch{As=!1}function ri(a,c,p,y,N,C,q,Q,te){var le=Array.prototype.slice.call(arguments,3);try{c.apply(p,le)}catch(he){this.onError(he)}}var Nr=!1,Pt=null,Jn=!1,$a=null,si={onError:function(a){Nr=!0,Pt=a}};function Gr(a,c,p,y,N,C,q,Q,te){Nr=!1,Pt=null,ri.apply(si,arguments)}function Ia(a,c,p,y,N,C,q,Q,te){if(Gr.apply(this,arguments),Nr){if(Nr){var le=Pt;Nr=!1,Pt=null}else throw Error(n(198));Jn||(Jn=!0,$a=le)}}function Qn(a){var c=a,p=a;if(a.alternate)for(;c.return;)c=c.return;else{a=c;do c=a,(c.flags&4098)!==0&&(p=c.return),a=c.return;while(a)}return c.tag===3?p:null}function Ms(a){if(a.tag===13){var c=a.memoizedState;if(c===null&&(a=a.alternate,a!==null&&(c=a.memoizedState)),c!==null)return c.dehydrated}return null}function $s(a){if(Qn(a)!==a)throw Error(n(188))}function ai(a){var c=a.alternate;if(!c){if(c=Qn(a),c===null)throw Error(n(188));return c!==a?null:a}for(var p=a,y=c;;){var N=p.return;if(N===null)break;var C=N.alternate;if(C===null){if(y=N.return,y!==null){p=y;continue}break}if(N.child===C.child){for(C=N.child;C;){if(C===p)return $s(N),a;if(C===y)return $s(N),c;C=C.sibling}throw Error(n(188))}if(p.return!==y.return)p=N,y=C;else{for(var q=!1,Q=N.child;Q;){if(Q===p){q=!0,p=N,y=C;break}if(Q===y){q=!0,y=N,p=C;break}Q=Q.sibling}if(!q){for(Q=C.child;Q;){if(Q===p){q=!0,p=C,y=N;break}if(Q===y){q=!0,y=C,p=N;break}Q=Q.sibling}if(!q)throw Error(n(189))}}if(p.alternate!==y)throw Error(n(190))}if(p.tag!==3)throw Error(n(188));return p.stateNode.current===p?a:c}function Oa(a){return a=ai(a),a!==null?er(a):null}function er(a){if(a.tag===5||a.tag===6)return a;for(a=a.child;a!==null;){var c=er(a);if(c!==null)return c;a=a.sibling}return null}var La=t.unstable_scheduleCallback,Is=t.unstable_cancelCallback,tr=t.unstable_shouldYield,Kr=t.unstable_requestPaint,Ge=t.unstable_now,oi=t.unstable_getCurrentPriorityLevel,Os=t.unstable_ImmediatePriority,Ls=t.unstable_UserBlockingPriority,Sr=t.unstable_NormalPriority,Pa=t.unstable_LowPriority,Ps=t.unstable_IdlePriority,jr=null,pt=null;function Ds(a){if(pt&&typeof pt.onCommitFiberRoot=="function")try{pt.onCommitFiberRoot(jr,a,void 0,(a.current.flags&128)===128)}catch{}}var ln=Math.clz32?Math.clz32:ii,Kl=Math.log,Yl=Math.LN2;function ii(a){return a>>>=0,a===0?32:31-(Kl(a)/Yl|0)|0}var Yr=64,gn=4194304;function Fs(a){switch(a&-a){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 a&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return a&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return a}}function Da(a,c){var p=a.pendingLanes;if(p===0)return 0;var y=0,N=a.suspendedLanes,C=a.pingedLanes,q=p&268435455;if(q!==0){var Q=q&~N;Q!==0?y=Fs(Q):(C&=q,C!==0&&(y=Fs(C)))}else q=p&~N,q!==0?y=Fs(q):C!==0&&(y=Fs(C));if(y===0)return 0;if(c!==0&&c!==y&&(c&N)===0&&(N=y&-y,C=c&-c,N>=C||N===16&&(C&4194240)!==0))return c;if((y&4)!==0&&(y|=p&16),c=a.entangledLanes,c!==0)for(a=a.entanglements,c&=y;0<c;)p=31-ln(c),N=1<<p,y|=a[p],c&=~N;return y}function Yd(a,c){switch(a){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 Xl(a,c){for(var p=a.suspendedLanes,y=a.pingedLanes,N=a.expirationTimes,C=a.pendingLanes;0<C;){var q=31-ln(C),Q=1<<q,te=N[q];te===-1?((Q&p)===0||(Q&y)!==0)&&(N[q]=Yd(Q,c)):te<=c&&(a.expiredLanes|=Q),C&=~Q}}function nr(a){return a=a.pendingLanes&-1073741825,a!==0?a:a&1073741824?1073741824:0}function Zl(){var a=Yr;return Yr<<=1,(Yr&4194240)===0&&(Yr=64),a}function Fa(a){for(var c=[],p=0;31>p;p++)c.push(a);return c}function Xr(a,c,p){a.pendingLanes|=c,c!==536870912&&(a.suspendedLanes=0,a.pingedLanes=0),a=a.eventTimes,c=31-ln(c),a[c]=p}function li(a,c){var p=a.pendingLanes&~c;a.pendingLanes=c,a.suspendedLanes=0,a.pingedLanes=0,a.expiredLanes&=c,a.mutableReadLanes&=c,a.entangledLanes&=c,c=a.entanglements;var y=a.eventTimes;for(a=a.expirationTimes;0<p;){var N=31-ln(p),C=1<<N;c[N]=0,y[N]=-1,a[N]=-1,p&=~C}}function ci(a,c){var p=a.entangledLanes|=c;for(a=a.entanglements;p;){var y=31-ln(p),N=1<<y;N&c|a[y]&c&&(a[y]|=c),p&=~N}}var He=0;function qa(a){return a&=-a,1<a?4<a?(a&268435455)!==0?16:536870912:4:1}var ui,di,Jl,Ql,Ba,hi=!1,qs=[],rr=null,sr=null,ar=null,Zr=new Map,Bs=new Map,or=[],ec="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 Jr(a,c){switch(a){case"focusin":case"focusout":rr=null;break;case"dragenter":case"dragleave":sr=null;break;case"mouseover":case"mouseout":ar=null;break;case"pointerover":case"pointerout":Zr.delete(c.pointerId);break;case"gotpointercapture":case"lostpointercapture":Bs.delete(c.pointerId)}}function Qr(a,c,p,y,N,C){return a===null||a.nativeEvent!==C?(a={blockedOn:c,domEventName:p,eventSystemFlags:y,nativeEvent:C,targetContainers:[N]},c!==null&&(c=Ri(c),c!==null&&di(c)),a):(a.eventSystemFlags|=y,c=a.targetContainers,N!==null&&c.indexOf(N)===-1&&c.push(N),a)}function tc(a,c,p,y,N){switch(c){case"focusin":return rr=Qr(rr,a,c,p,y,N),!0;case"dragenter":return sr=Qr(sr,a,c,p,y,N),!0;case"mouseover":return ar=Qr(ar,a,c,p,y,N),!0;case"pointerover":var C=N.pointerId;return Zr.set(C,Qr(Zr.get(C)||null,a,c,p,y,N)),!0;case"gotpointercapture":return C=N.pointerId,Bs.set(C,Qr(Bs.get(C)||null,a,c,p,y,N)),!0}return!1}function fi(a){var c=Ys(a.target);if(c!==null){var p=Qn(c);if(p!==null){if(c=p.tag,c===13){if(c=Ms(p),c!==null){a.blockedOn=c,Ba(a.priority,function(){Jl(p)});return}}else if(c===3&&p.stateNode.current.memoizedState.isDehydrated){a.blockedOn=p.tag===3?p.stateNode.containerInfo:null;return}}}a.blockedOn=null}function zs(a){if(a.blockedOn!==null)return!1;for(var c=a.targetContainers;0<c.length;){var p=gi(a.domEventName,a.eventSystemFlags,c[0],a.nativeEvent);if(p===null){p=a.nativeEvent;var y=new p.constructor(p.type,p);Fe=y,p.target.dispatchEvent(y),Fe=null}else return c=Ri(p),c!==null&&di(c),a.blockedOn=p,!1;c.shift()}return!0}function pi(a,c,p){zs(a)&&p.delete(c)}function mi(){hi=!1,rr!==null&&zs(rr)&&(rr=null),sr!==null&&zs(sr)&&(sr=null),ar!==null&&zs(ar)&&(ar=null),Zr.forEach(pi),Bs.forEach(pi)}function Us(a,c){a.blockedOn===c&&(a.blockedOn=null,hi||(hi=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,mi)))}function _r(a){function c(N){return Us(N,a)}if(0<qs.length){Us(qs[0],a);for(var p=1;p<qs.length;p++){var y=qs[p];y.blockedOn===a&&(y.blockedOn=null)}}for(rr!==null&&Us(rr,a),sr!==null&&Us(sr,a),ar!==null&&Us(ar,a),Zr.forEach(c),Bs.forEach(c),p=0;p<or.length;p++)y=or[p],y.blockedOn===a&&(y.blockedOn=null);for(;0<or.length&&(p=or[0],p.blockedOn===null);)fi(p),p.blockedOn===null&&or.shift()}var Er=E.ReactCurrentBatchConfig,Hs=!0;function Xd(a,c,p,y){var N=He,C=Er.transition;Er.transition=null;try{He=1,Ws(a,c,p,y)}finally{He=N,Er.transition=C}}function Zd(a,c,p,y){var N=He,C=Er.transition;Er.transition=null;try{He=4,Ws(a,c,p,y)}finally{He=N,Er.transition=C}}function Ws(a,c,p,y){if(Hs){var N=gi(a,c,p,y);if(N===null)hh(a,c,y,Cr,p),Jr(a,y);else if(tc(N,a,c,p,y))y.stopPropagation();else if(Jr(a,y),c&4&&-1<ec.indexOf(a)){for(;N!==null;){var C=Ri(N);if(C!==null&&ui(C),C=gi(a,c,p,y),C===null&&hh(a,c,y,Cr,p),C===N)break;N=C}N!==null&&y.stopPropagation()}else hh(a,c,y,null,p)}}var Cr=null;function gi(a,c,p,y){if(Cr=null,a=Lt(y),a=Ys(a),a!==null)if(c=Qn(a),c===null)a=null;else if(p=c.tag,p===13){if(a=Ms(c),a!==null)return a;a=null}else if(p===3){if(c.stateNode.current.memoizedState.isDehydrated)return c.tag===3?c.stateNode.containerInfo:null;a=null}else c!==a&&(a=null);return Cr=a,null}function es(a){switch(a){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(oi()){case Os:return 1;case Ls:return 4;case Sr:case Pa:return 16;case Ps:return 536870912;default:return 16}default:return 16}}var ir=null,yi=null,za=null;function wi(){if(za)return za;var a,c=yi,p=c.length,y,N="value"in ir?ir.value:ir.textContent,C=N.length;for(a=0;a<p&&c[a]===N[a];a++);var q=p-a;for(y=1;y<=q&&c[p-y]===N[C-y];y++);return za=N.slice(a,1<y?1-y:void 0)}function Ua(a){var c=a.keyCode;return"charCode"in a?(a=a.charCode,a===0&&c===13&&(a=13)):a=c,a===10&&(a=13),32<=a||a===13?a:0}function Ha(){return!0}function vi(){return!1}function xt(a){function c(p,y,N,C,q){this._reactName=p,this._targetInst=N,this.type=y,this.nativeEvent=C,this.target=q,this.currentTarget=null;for(var Q in a)a.hasOwnProperty(Q)&&(p=a[Q],this[Q]=p?p(C):C[Q]);return this.isDefaultPrevented=(C.defaultPrevented!=null?C.defaultPrevented:C.returnValue===!1)?Ha:vi,this.isPropagationStopped=vi,this}return W(c.prototype,{preventDefault:function(){this.defaultPrevented=!0;var p=this.nativeEvent;p&&(p.preventDefault?p.preventDefault():typeof p.returnValue!="unknown"&&(p.returnValue=!1),this.isDefaultPrevented=Ha)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=Ha)},persist:function(){},isPersistent:Ha}),c}var Tr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Vs=xt(Tr),Gs=W({},Tr,{view:0,detail:0}),Ks=xt(Gs),Jd,Qd,xi,nc=W({},Gs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:th,button:0,buttons:0,relatedTarget:function(a){return a.relatedTarget===void 0?a.fromElement===a.srcElement?a.toElement:a.fromElement:a.relatedTarget},movementX:function(a){return"movementX"in a?a.movementX:(a!==xi&&(xi&&a.type==="mousemove"?(Jd=a.screenX-xi.screenX,Qd=a.screenY-xi.screenY):Qd=Jd=0,xi=a),Jd)},movementY:function(a){return"movementY"in a?a.movementY:Qd}}),V0=xt(nc),xI=W({},nc,{dataTransfer:0}),bI=xt(xI),kI=W({},Gs,{relatedTarget:0}),eh=xt(kI),NI=W({},Tr,{animationName:0,elapsedTime:0,pseudoElement:0}),SI=xt(NI),jI=W({},Tr,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),_I=xt(jI),EI=W({},Tr,{data:0}),G0=xt(EI),CI={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},TI={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"},RI={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function AI(a){var c=this.nativeEvent;return c.getModifierState?c.getModifierState(a):(a=RI[a])?!!c[a]:!1}function th(){return AI}var MI=W({},Gs,{key:function(a){if(a.key){var c=CI[a.key]||a.key;if(c!=="Unidentified")return c}return a.type==="keypress"?(a=Ua(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?TI[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:th,charCode:function(a){return a.type==="keypress"?Ua(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?Ua(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),$I=xt(MI),II=W({},nc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),K0=xt(II),OI=W({},Gs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:th}),LI=xt(OI),PI=W({},Tr,{propertyName:0,elapsedTime:0,pseudoElement:0}),DI=xt(PI),FI=W({},nc,{deltaX:function(a){return"deltaX"in a?a.deltaX:"wheelDeltaX"in a?-a.wheelDeltaX:0},deltaY:function(a){return"deltaY"in a?a.deltaY:"wheelDeltaY"in a?-a.wheelDeltaY:"wheelDelta"in a?-a.wheelDelta:0},deltaZ:0,deltaMode:0}),qI=xt(FI),BI=[9,13,27,32],nh=u&&"CompositionEvent"in window,bi=null;u&&"documentMode"in document&&(bi=document.documentMode);var zI=u&&"TextEvent"in window&&!bi,Y0=u&&(!nh||bi&&8<bi&&11>=bi),X0=" ",Z0=!1;function J0(a,c){switch(a){case"keyup":return BI.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Q0(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var Wa=!1;function UI(a,c){switch(a){case"compositionend":return Q0(c);case"keypress":return c.which!==32?null:(Z0=!0,X0);case"textInput":return a=c.data,a===X0&&Z0?null:a;default:return null}}function HI(a,c){if(Wa)return a==="compositionend"||!nh&&J0(a,c)?(a=wi(),za=yi=ir=null,Wa=!1,a):null;switch(a){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 Y0&&c.locale!=="ko"?null:c.data;default:return null}}var WI={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 eb(a){var c=a&&a.nodeName&&a.nodeName.toLowerCase();return c==="input"?!!WI[a.type]:c==="textarea"}function tb(a,c,p,y){Xn(y),c=ic(c,"onChange"),0<c.length&&(p=new Vs("onChange","change",null,p,y),a.push({event:p,listeners:c}))}var ki=null,Ni=null;function VI(a){vb(a,0)}function rc(a){var c=Xa(a);if(Ne(c))return a}function GI(a,c){if(a==="change")return c}var nb=!1;if(u){var rh;if(u){var sh="oninput"in document;if(!sh){var rb=document.createElement("div");rb.setAttribute("oninput","return;"),sh=typeof rb.oninput=="function"}rh=sh}else rh=!1;nb=rh&&(!document.documentMode||9<document.documentMode)}function sb(){ki&&(ki.detachEvent("onpropertychange",ab),Ni=ki=null)}function ab(a){if(a.propertyName==="value"&&rc(Ni)){var c=[];tb(c,Ni,a,Lt(a)),Ma(VI,c)}}function KI(a,c,p){a==="focusin"?(sb(),ki=c,Ni=p,ki.attachEvent("onpropertychange",ab)):a==="focusout"&&sb()}function YI(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return rc(Ni)}function XI(a,c){if(a==="click")return rc(c)}function ZI(a,c){if(a==="input"||a==="change")return rc(c)}function JI(a,c){return a===c&&(a!==0||1/a===1/c)||a!==a&&c!==c}var Mn=typeof Object.is=="function"?Object.is:JI;function Si(a,c){if(Mn(a,c))return!0;if(typeof a!="object"||a===null||typeof c!="object"||c===null)return!1;var p=Object.keys(a),y=Object.keys(c);if(p.length!==y.length)return!1;for(y=0;y<p.length;y++){var N=p[y];if(!d.call(c,N)||!Mn(a[N],c[N]))return!1}return!0}function ob(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function ib(a,c){var p=ob(a);a=0;for(var y;p;){if(p.nodeType===3){if(y=a+p.textContent.length,a<=c&&y>=c)return{node:p,offset:c-a};a=y}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=ob(p)}}function lb(a,c){return a&&c?a===c?!0:a&&a.nodeType===3?!1:c&&c.nodeType===3?lb(a,c.parentNode):"contains"in a?a.contains(c):a.compareDocumentPosition?!!(a.compareDocumentPosition(c)&16):!1:!1}function cb(){for(var a=window,c=ke();c instanceof a.HTMLIFrameElement;){try{var p=typeof c.contentWindow.location.href=="string"}catch{p=!1}if(p)a=c.contentWindow;else break;c=ke(a.document)}return c}function ah(a){var c=a&&a.nodeName&&a.nodeName.toLowerCase();return c&&(c==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||c==="textarea"||a.contentEditable==="true")}function QI(a){var c=cb(),p=a.focusedElem,y=a.selectionRange;if(c!==p&&p&&p.ownerDocument&&lb(p.ownerDocument.documentElement,p)){if(y!==null&&ah(p)){if(c=y.start,a=y.end,a===void 0&&(a=c),"selectionStart"in p)p.selectionStart=c,p.selectionEnd=Math.min(a,p.value.length);else if(a=(c=p.ownerDocument||document)&&c.defaultView||window,a.getSelection){a=a.getSelection();var N=p.textContent.length,C=Math.min(y.start,N);y=y.end===void 0?C:Math.min(y.end,N),!a.extend&&C>y&&(N=y,y=C,C=N),N=ib(p,C);var q=ib(p,y);N&&q&&(a.rangeCount!==1||a.anchorNode!==N.node||a.anchorOffset!==N.offset||a.focusNode!==q.node||a.focusOffset!==q.offset)&&(c=c.createRange(),c.setStart(N.node,N.offset),a.removeAllRanges(),C>y?(a.addRange(c),a.extend(q.node,q.offset)):(c.setEnd(q.node,q.offset),a.addRange(c)))}}for(c=[],a=p;a=a.parentNode;)a.nodeType===1&&c.push({element:a,left:a.scrollLeft,top:a.scrollTop});for(typeof p.focus=="function"&&p.focus(),p=0;p<c.length;p++)a=c[p],a.element.scrollLeft=a.left,a.element.scrollTop=a.top}}var eO=u&&"documentMode"in document&&11>=document.documentMode,Va=null,oh=null,ji=null,ih=!1;function ub(a,c,p){var y=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;ih||Va==null||Va!==ke(y)||(y=Va,"selectionStart"in y&&ah(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}),ji&&Si(ji,y)||(ji=y,y=ic(oh,"onSelect"),0<y.length&&(c=new Vs("onSelect","select",null,c,p),a.push({event:c,listeners:y}),c.target=Va)))}function sc(a,c){var p={};return p[a.toLowerCase()]=c.toLowerCase(),p["Webkit"+a]="webkit"+c,p["Moz"+a]="moz"+c,p}var Ga={animationend:sc("Animation","AnimationEnd"),animationiteration:sc("Animation","AnimationIteration"),animationstart:sc("Animation","AnimationStart"),transitionend:sc("Transition","TransitionEnd")},lh={},db={};u&&(db=document.createElement("div").style,"AnimationEvent"in window||(delete Ga.animationend.animation,delete Ga.animationiteration.animation,delete Ga.animationstart.animation),"TransitionEvent"in window||delete Ga.transitionend.transition);function ac(a){if(lh[a])return lh[a];if(!Ga[a])return a;var c=Ga[a],p;for(p in c)if(c.hasOwnProperty(p)&&p in db)return lh[a]=c[p];return a}var hb=ac("animationend"),fb=ac("animationiteration"),pb=ac("animationstart"),mb=ac("transitionend"),gb=new Map,yb="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 ts(a,c){gb.set(a,c),o(c,[a])}for(var ch=0;ch<yb.length;ch++){var uh=yb[ch],tO=uh.toLowerCase(),nO=uh[0].toUpperCase()+uh.slice(1);ts(tO,"on"+nO)}ts(hb,"onAnimationEnd"),ts(fb,"onAnimationIteration"),ts(pb,"onAnimationStart"),ts("dblclick","onDoubleClick"),ts("focusin","onFocus"),ts("focusout","onBlur"),ts(mb,"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 _i="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(" "),rO=new Set("cancel close invalid load scroll toggle".split(" ").concat(_i));function wb(a,c,p){var y=a.type||"unknown-event";a.currentTarget=p,Ia(y,c,void 0,a),a.currentTarget=null}function vb(a,c){c=(c&4)!==0;for(var p=0;p<a.length;p++){var y=a[p],N=y.event;y=y.listeners;e:{var C=void 0;if(c)for(var q=y.length-1;0<=q;q--){var Q=y[q],te=Q.instance,le=Q.currentTarget;if(Q=Q.listener,te!==C&&N.isPropagationStopped())break e;wb(N,Q,le),C=te}else for(q=0;q<y.length;q++){if(Q=y[q],te=Q.instance,le=Q.currentTarget,Q=Q.listener,te!==C&&N.isPropagationStopped())break e;wb(N,Q,le),C=te}}}if(Jn)throw a=$a,Jn=!1,$a=null,a}function Je(a,c){var p=c[wh];p===void 0&&(p=c[wh]=new Set);var y=a+"__bubble";p.has(y)||(xb(c,a,2,!1),p.add(y))}function dh(a,c,p){var y=0;c&&(y|=4),xb(p,a,y,c)}var oc="_reactListening"+Math.random().toString(36).slice(2);function Ei(a){if(!a[oc]){a[oc]=!0,r.forEach(function(p){p!=="selectionchange"&&(rO.has(p)||dh(p,!1,a),dh(p,!0,a))});var c=a.nodeType===9?a:a.ownerDocument;c===null||c[oc]||(c[oc]=!0,dh("selectionchange",!1,c))}}function xb(a,c,p,y){switch(es(c)){case 1:var N=Xd;break;case 4:N=Zd;break;default:N=Ws}p=N.bind(null,c,p,a),N=void 0,!As||c!=="touchstart"&&c!=="touchmove"&&c!=="wheel"||(N=!0),y?N!==void 0?a.addEventListener(c,p,{capture:!0,passive:N}):a.addEventListener(c,p,!0):N!==void 0?a.addEventListener(c,p,{passive:N}):a.addEventListener(c,p,!1)}function hh(a,c,p,y,N){var C=y;if((c&1)===0&&(c&2)===0&&y!==null)e:for(;;){if(y===null)return;var q=y.tag;if(q===3||q===4){var Q=y.stateNode.containerInfo;if(Q===N||Q.nodeType===8&&Q.parentNode===N)break;if(q===4)for(q=y.return;q!==null;){var te=q.tag;if((te===3||te===4)&&(te=q.stateNode.containerInfo,te===N||te.nodeType===8&&te.parentNode===N))return;q=q.return}for(;Q!==null;){if(q=Ys(Q),q===null)return;if(te=q.tag,te===5||te===6){y=C=q;continue e}Q=Q.parentNode}}y=y.return}Ma(function(){var le=C,he=Lt(p),pe=[];e:{var de=gb.get(a);if(de!==void 0){var be=Vs,je=a;switch(a){case"keypress":if(Ua(p)===0)break e;case"keydown":case"keyup":be=$I;break;case"focusin":je="focus",be=eh;break;case"focusout":je="blur",be=eh;break;case"beforeblur":case"afterblur":be=eh;break;case"click":if(p.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":be=V0;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":be=bI;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":be=LI;break;case hb:case fb:case pb:be=SI;break;case mb:be=DI;break;case"scroll":be=Ks;break;case"wheel":be=qI;break;case"copy":case"cut":case"paste":be=_I;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":be=K0}var _e=(c&4)!==0,ft=!_e&&a==="scroll",ae=_e?de!==null?de+"Capture":null:de;_e=[];for(var ne=le,ie;ne!==null;){ie=ne;var me=ie.stateNode;if(ie.tag===5&&me!==null&&(ie=me,ae!==null&&(me=kr(ne,ae),me!=null&&_e.push(Ci(ne,me,ie)))),ft)break;ne=ne.return}0<_e.length&&(de=new be(de,je,null,p,he),pe.push({event:de,listeners:_e}))}}if((c&7)===0){e:{if(de=a==="mouseover"||a==="pointerover",be=a==="mouseout"||a==="pointerout",de&&p!==Fe&&(je=p.relatedTarget||p.fromElement)&&(Ys(je)||je[Rr]))break e;if((be||de)&&(de=he.window===he?he:(de=he.ownerDocument)?de.defaultView||de.parentWindow:window,be?(je=p.relatedTarget||p.toElement,be=le,je=je?Ys(je):null,je!==null&&(ft=Qn(je),je!==ft||je.tag!==5&&je.tag!==6)&&(je=null)):(be=null,je=le),be!==je)){if(_e=V0,me="onMouseLeave",ae="onMouseEnter",ne="mouse",(a==="pointerout"||a==="pointerover")&&(_e=K0,me="onPointerLeave",ae="onPointerEnter",ne="pointer"),ft=be==null?de:Xa(be),ie=je==null?de:Xa(je),de=new _e(me,ne+"leave",be,p,he),de.target=ft,de.relatedTarget=ie,me=null,Ys(he)===le&&(_e=new _e(ae,ne+"enter",je,p,he),_e.target=ie,_e.relatedTarget=ft,me=_e),ft=me,be&&je)t:{for(_e=be,ae=je,ne=0,ie=_e;ie;ie=Ka(ie))ne++;for(ie=0,me=ae;me;me=Ka(me))ie++;for(;0<ne-ie;)_e=Ka(_e),ne--;for(;0<ie-ne;)ae=Ka(ae),ie--;for(;ne--;){if(_e===ae||ae!==null&&_e===ae.alternate)break t;_e=Ka(_e),ae=Ka(ae)}_e=null}else _e=null;be!==null&&bb(pe,de,be,_e,!1),je!==null&&ft!==null&&bb(pe,ft,je,_e,!0)}}e:{if(de=le?Xa(le):window,be=de.nodeName&&de.nodeName.toLowerCase(),be==="select"||be==="input"&&de.type==="file")var Ee=GI;else if(eb(de))if(nb)Ee=ZI;else{Ee=YI;var Te=KI}else(be=de.nodeName)&&be.toLowerCase()==="input"&&(de.type==="checkbox"||de.type==="radio")&&(Ee=XI);if(Ee&&(Ee=Ee(a,le))){tb(pe,Ee,p,he);break e}Te&&Te(a,de,le),a==="focusout"&&(Te=de._wrapperState)&&Te.controlled&&de.type==="number"&&se(de,"number",de.value)}switch(Te=le?Xa(le):window,a){case"focusin":(eb(Te)||Te.contentEditable==="true")&&(Va=Te,oh=le,ji=null);break;case"focusout":ji=oh=Va=null;break;case"mousedown":ih=!0;break;case"contextmenu":case"mouseup":case"dragend":ih=!1,ub(pe,p,he);break;case"selectionchange":if(eO)break;case"keydown":case"keyup":ub(pe,p,he)}var Re;if(nh)e:{switch(a){case"compositionstart":var Me="onCompositionStart";break e;case"compositionend":Me="onCompositionEnd";break e;case"compositionupdate":Me="onCompositionUpdate";break e}Me=void 0}else Wa?J0(a,p)&&(Me="onCompositionEnd"):a==="keydown"&&p.keyCode===229&&(Me="onCompositionStart");Me&&(Y0&&p.locale!=="ko"&&(Wa||Me!=="onCompositionStart"?Me==="onCompositionEnd"&&Wa&&(Re=wi()):(ir=he,yi="value"in ir?ir.value:ir.textContent,Wa=!0)),Te=ic(le,Me),0<Te.length&&(Me=new G0(Me,a,null,p,he),pe.push({event:Me,listeners:Te}),Re?Me.data=Re:(Re=Q0(p),Re!==null&&(Me.data=Re)))),(Re=zI?UI(a,p):HI(a,p))&&(le=ic(le,"onBeforeInput"),0<le.length&&(he=new G0("onBeforeInput","beforeinput",null,p,he),pe.push({event:he,listeners:le}),he.data=Re))}vb(pe,c)})}function Ci(a,c,p){return{instance:a,listener:c,currentTarget:p}}function ic(a,c){for(var p=c+"Capture",y=[];a!==null;){var N=a,C=N.stateNode;N.tag===5&&C!==null&&(N=C,C=kr(a,p),C!=null&&y.unshift(Ci(a,C,N)),C=kr(a,c),C!=null&&y.push(Ci(a,C,N))),a=a.return}return y}function Ka(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5);return a||null}function bb(a,c,p,y,N){for(var C=c._reactName,q=[];p!==null&&p!==y;){var Q=p,te=Q.alternate,le=Q.stateNode;if(te!==null&&te===y)break;Q.tag===5&&le!==null&&(Q=le,N?(te=kr(p,C),te!=null&&q.unshift(Ci(p,te,Q))):N||(te=kr(p,C),te!=null&&q.push(Ci(p,te,Q)))),p=p.return}q.length!==0&&a.push({event:c,listeners:q})}var sO=/\r\n?/g,aO=/\u0000|\uFFFD/g;function kb(a){return(typeof a=="string"?a:""+a).replace(sO,`
38
- `).replace(aO,"")}function lc(a,c,p){if(c=kb(c),kb(a)!==c&&p)throw Error(n(425))}function cc(){}var fh=null,ph=null;function mh(a,c){return a==="textarea"||a==="noscript"||typeof c.children=="string"||typeof c.children=="number"||typeof c.dangerouslySetInnerHTML=="object"&&c.dangerouslySetInnerHTML!==null&&c.dangerouslySetInnerHTML.__html!=null}var gh=typeof setTimeout=="function"?setTimeout:void 0,oO=typeof clearTimeout=="function"?clearTimeout:void 0,Nb=typeof Promise=="function"?Promise:void 0,iO=typeof queueMicrotask=="function"?queueMicrotask:typeof Nb<"u"?function(a){return Nb.resolve(null).then(a).catch(lO)}:gh;function lO(a){setTimeout(function(){throw a})}function yh(a,c){var p=c,y=0;do{var N=p.nextSibling;if(a.removeChild(p),N&&N.nodeType===8)if(p=N.data,p==="/$"){if(y===0){a.removeChild(N),_r(c);return}y--}else p!=="$"&&p!=="$?"&&p!=="$!"||y++;p=N}while(p);_r(c)}function ns(a){for(;a!=null;a=a.nextSibling){var c=a.nodeType;if(c===1||c===3)break;if(c===8){if(c=a.data,c==="$"||c==="$!"||c==="$?")break;if(c==="/$")return null}}return a}function Sb(a){a=a.previousSibling;for(var c=0;a;){if(a.nodeType===8){var p=a.data;if(p==="$"||p==="$!"||p==="$?"){if(c===0)return a;c--}else p==="/$"&&c++}a=a.previousSibling}return null}var Ya=Math.random().toString(36).slice(2),lr="__reactFiber$"+Ya,Ti="__reactProps$"+Ya,Rr="__reactContainer$"+Ya,wh="__reactEvents$"+Ya,cO="__reactListeners$"+Ya,uO="__reactHandles$"+Ya;function Ys(a){var c=a[lr];if(c)return c;for(var p=a.parentNode;p;){if(c=p[Rr]||p[lr]){if(p=c.alternate,c.child!==null||p!==null&&p.child!==null)for(a=Sb(a);a!==null;){if(p=a[lr])return p;a=Sb(a)}return c}a=p,p=a.parentNode}return null}function Ri(a){return a=a[lr]||a[Rr],!a||a.tag!==5&&a.tag!==6&&a.tag!==13&&a.tag!==3?null:a}function Xa(a){if(a.tag===5||a.tag===6)return a.stateNode;throw Error(n(33))}function uc(a){return a[Ti]||null}var vh=[],Za=-1;function rs(a){return{current:a}}function Qe(a){0>Za||(a.current=vh[Za],vh[Za]=null,Za--)}function Xe(a,c){Za++,vh[Za]=a.current,a.current=c}var ss={},Dt=rs(ss),Yt=rs(!1),Xs=ss;function Ja(a,c){var p=a.type.contextTypes;if(!p)return ss;var y=a.stateNode;if(y&&y.__reactInternalMemoizedUnmaskedChildContext===c)return y.__reactInternalMemoizedMaskedChildContext;var N={},C;for(C in p)N[C]=c[C];return y&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=c,a.__reactInternalMemoizedMaskedChildContext=N),N}function Xt(a){return a=a.childContextTypes,a!=null}function dc(){Qe(Yt),Qe(Dt)}function jb(a,c,p){if(Dt.current!==ss)throw Error(n(168));Xe(Dt,c),Xe(Yt,p)}function _b(a,c,p){var y=a.stateNode;if(c=c.childContextTypes,typeof y.getChildContext!="function")return p;y=y.getChildContext();for(var N in y)if(!(N in c))throw Error(n(108,J(a)||"Unknown",N));return W({},p,y)}function hc(a){return a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||ss,Xs=Dt.current,Xe(Dt,a),Xe(Yt,Yt.current),!0}function Eb(a,c,p){var y=a.stateNode;if(!y)throw Error(n(169));p?(a=_b(a,c,Xs),y.__reactInternalMemoizedMergedChildContext=a,Qe(Yt),Qe(Dt),Xe(Dt,a)):Qe(Yt),Xe(Yt,p)}var Ar=null,fc=!1,xh=!1;function Cb(a){Ar===null?Ar=[a]:Ar.push(a)}function dO(a){fc=!0,Cb(a)}function as(){if(!xh&&Ar!==null){xh=!0;var a=0,c=He;try{var p=Ar;for(He=1;a<p.length;a++){var y=p[a];do y=y(!0);while(y!==null)}Ar=null,fc=!1}catch(N){throw Ar!==null&&(Ar=Ar.slice(a+1)),La(Os,as),N}finally{He=c,xh=!1}}return null}var Qa=[],eo=0,pc=null,mc=0,yn=[],wn=0,Zs=null,Mr=1,$r="";function Js(a,c){Qa[eo++]=mc,Qa[eo++]=pc,pc=a,mc=c}function Tb(a,c,p){yn[wn++]=Mr,yn[wn++]=$r,yn[wn++]=Zs,Zs=a;var y=Mr;a=$r;var N=32-ln(y)-1;y&=~(1<<N),p+=1;var C=32-ln(c)+N;if(30<C){var q=N-N%5;C=(y&(1<<q)-1).toString(32),y>>=q,N-=q,Mr=1<<32-ln(c)+N|p<<N|y,$r=C+a}else Mr=1<<C|p<<N|y,$r=a}function bh(a){a.return!==null&&(Js(a,1),Tb(a,1,0))}function kh(a){for(;a===pc;)pc=Qa[--eo],Qa[eo]=null,mc=Qa[--eo],Qa[eo]=null;for(;a===Zs;)Zs=yn[--wn],yn[wn]=null,$r=yn[--wn],yn[wn]=null,Mr=yn[--wn],yn[wn]=null}var cn=null,un=null,st=!1,$n=null;function Rb(a,c){var p=kn(5,null,null,0);p.elementType="DELETED",p.stateNode=c,p.return=a,c=a.deletions,c===null?(a.deletions=[p],a.flags|=16):c.push(p)}function Ab(a,c){switch(a.tag){case 5:var p=a.type;return c=c.nodeType!==1||p.toLowerCase()!==c.nodeName.toLowerCase()?null:c,c!==null?(a.stateNode=c,cn=a,un=ns(c.firstChild),!0):!1;case 6:return c=a.pendingProps===""||c.nodeType!==3?null:c,c!==null?(a.stateNode=c,cn=a,un=null,!0):!1;case 13:return c=c.nodeType!==8?null:c,c!==null?(p=Zs!==null?{id:Mr,overflow:$r}:null,a.memoizedState={dehydrated:c,treeContext:p,retryLane:1073741824},p=kn(18,null,null,0),p.stateNode=c,p.return=a,a.child=p,cn=a,un=null,!0):!1;default:return!1}}function Nh(a){return(a.mode&1)!==0&&(a.flags&128)===0}function Sh(a){if(st){var c=un;if(c){var p=c;if(!Ab(a,c)){if(Nh(a))throw Error(n(418));c=ns(p.nextSibling);var y=cn;c&&Ab(a,c)?Rb(y,p):(a.flags=a.flags&-4097|2,st=!1,cn=a)}}else{if(Nh(a))throw Error(n(418));a.flags=a.flags&-4097|2,st=!1,cn=a}}}function Mb(a){for(a=a.return;a!==null&&a.tag!==5&&a.tag!==3&&a.tag!==13;)a=a.return;cn=a}function gc(a){if(a!==cn)return!1;if(!st)return Mb(a),st=!0,!1;var c;if((c=a.tag!==3)&&!(c=a.tag!==5)&&(c=a.type,c=c!=="head"&&c!=="body"&&!mh(a.type,a.memoizedProps)),c&&(c=un)){if(Nh(a))throw $b(),Error(n(418));for(;c;)Rb(a,c),c=ns(c.nextSibling)}if(Mb(a),a.tag===13){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(n(317));e:{for(a=a.nextSibling,c=0;a;){if(a.nodeType===8){var p=a.data;if(p==="/$"){if(c===0){un=ns(a.nextSibling);break e}c--}else p!=="$"&&p!=="$!"&&p!=="$?"||c++}a=a.nextSibling}un=null}}else un=cn?ns(a.stateNode.nextSibling):null;return!0}function $b(){for(var a=un;a;)a=ns(a.nextSibling)}function to(){un=cn=null,st=!1}function jh(a){$n===null?$n=[a]:$n.push(a)}var hO=E.ReactCurrentBatchConfig;function Ai(a,c,p){if(a=p.ref,a!==null&&typeof a!="function"&&typeof a!="object"){if(p._owner){if(p=p._owner,p){if(p.tag!==1)throw Error(n(309));var y=p.stateNode}if(!y)throw Error(n(147,a));var N=y,C=""+a;return c!==null&&c.ref!==null&&typeof c.ref=="function"&&c.ref._stringRef===C?c.ref:(c=function(q){var Q=N.refs;q===null?delete Q[C]:Q[C]=q},c._stringRef=C,c)}if(typeof a!="string")throw Error(n(284));if(!p._owner)throw Error(n(290,a))}return a}function yc(a,c){throw a=Object.prototype.toString.call(c),Error(n(31,a==="[object Object]"?"object with keys {"+Object.keys(c).join(", ")+"}":a))}function Ib(a){var c=a._init;return c(a._payload)}function Ob(a){function c(ae,ne){if(a){var ie=ae.deletions;ie===null?(ae.deletions=[ne],ae.flags|=16):ie.push(ne)}}function p(ae,ne){if(!a)return null;for(;ne!==null;)c(ae,ne),ne=ne.sibling;return null}function y(ae,ne){for(ae=new Map;ne!==null;)ne.key!==null?ae.set(ne.key,ne):ae.set(ne.index,ne),ne=ne.sibling;return ae}function N(ae,ne){return ae=fs(ae,ne),ae.index=0,ae.sibling=null,ae}function C(ae,ne,ie){return ae.index=ie,a?(ie=ae.alternate,ie!==null?(ie=ie.index,ie<ne?(ae.flags|=2,ne):ie):(ae.flags|=2,ne)):(ae.flags|=1048576,ne)}function q(ae){return a&&ae.alternate===null&&(ae.flags|=2),ae}function Q(ae,ne,ie,me){return ne===null||ne.tag!==6?(ne=yf(ie,ae.mode,me),ne.return=ae,ne):(ne=N(ne,ie),ne.return=ae,ne)}function te(ae,ne,ie,me){var Ee=ie.type;return Ee===M?he(ae,ne,ie.props.children,me,ie.key):ne!==null&&(ne.elementType===Ee||typeof Ee=="object"&&Ee!==null&&Ee.$$typeof===F&&Ib(Ee)===ne.type)?(me=N(ne,ie.props),me.ref=Ai(ae,ne,ie),me.return=ae,me):(me=Bc(ie.type,ie.key,ie.props,null,ae.mode,me),me.ref=Ai(ae,ne,ie),me.return=ae,me)}function le(ae,ne,ie,me){return ne===null||ne.tag!==4||ne.stateNode.containerInfo!==ie.containerInfo||ne.stateNode.implementation!==ie.implementation?(ne=wf(ie,ae.mode,me),ne.return=ae,ne):(ne=N(ne,ie.children||[]),ne.return=ae,ne)}function he(ae,ne,ie,me,Ee){return ne===null||ne.tag!==7?(ne=oa(ie,ae.mode,me,Ee),ne.return=ae,ne):(ne=N(ne,ie),ne.return=ae,ne)}function pe(ae,ne,ie){if(typeof ne=="string"&&ne!==""||typeof ne=="number")return ne=yf(""+ne,ae.mode,ie),ne.return=ae,ne;if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case T:return ie=Bc(ne.type,ne.key,ne.props,null,ae.mode,ie),ie.ref=Ai(ae,null,ne),ie.return=ae,ie;case R:return ne=wf(ne,ae.mode,ie),ne.return=ae,ne;case F:var me=ne._init;return pe(ae,me(ne._payload),ie)}if(xe(ne)||D(ne))return ne=oa(ne,ae.mode,ie,null),ne.return=ae,ne;yc(ae,ne)}return null}function de(ae,ne,ie,me){var Ee=ne!==null?ne.key:null;if(typeof ie=="string"&&ie!==""||typeof ie=="number")return Ee!==null?null:Q(ae,ne,""+ie,me);if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case T:return ie.key===Ee?te(ae,ne,ie,me):null;case R:return ie.key===Ee?le(ae,ne,ie,me):null;case F:return Ee=ie._init,de(ae,ne,Ee(ie._payload),me)}if(xe(ie)||D(ie))return Ee!==null?null:he(ae,ne,ie,me,null);yc(ae,ie)}return null}function be(ae,ne,ie,me,Ee){if(typeof me=="string"&&me!==""||typeof me=="number")return ae=ae.get(ie)||null,Q(ne,ae,""+me,Ee);if(typeof me=="object"&&me!==null){switch(me.$$typeof){case T:return ae=ae.get(me.key===null?ie:me.key)||null,te(ne,ae,me,Ee);case R:return ae=ae.get(me.key===null?ie:me.key)||null,le(ne,ae,me,Ee);case F:var Te=me._init;return be(ae,ne,ie,Te(me._payload),Ee)}if(xe(me)||D(me))return ae=ae.get(ie)||null,he(ne,ae,me,Ee,null);yc(ne,me)}return null}function je(ae,ne,ie,me){for(var Ee=null,Te=null,Re=ne,Me=ne=0,Rt=null;Re!==null&&Me<ie.length;Me++){Re.index>Me?(Rt=Re,Re=null):Rt=Re.sibling;var Ue=de(ae,Re,ie[Me],me);if(Ue===null){Re===null&&(Re=Rt);break}a&&Re&&Ue.alternate===null&&c(ae,Re),ne=C(Ue,ne,Me),Te===null?Ee=Ue:Te.sibling=Ue,Te=Ue,Re=Rt}if(Me===ie.length)return p(ae,Re),st&&Js(ae,Me),Ee;if(Re===null){for(;Me<ie.length;Me++)Re=pe(ae,ie[Me],me),Re!==null&&(ne=C(Re,ne,Me),Te===null?Ee=Re:Te.sibling=Re,Te=Re);return st&&Js(ae,Me),Ee}for(Re=y(ae,Re);Me<ie.length;Me++)Rt=be(Re,ae,Me,ie[Me],me),Rt!==null&&(a&&Rt.alternate!==null&&Re.delete(Rt.key===null?Me:Rt.key),ne=C(Rt,ne,Me),Te===null?Ee=Rt:Te.sibling=Rt,Te=Rt);return a&&Re.forEach(function(ps){return c(ae,ps)}),st&&Js(ae,Me),Ee}function _e(ae,ne,ie,me){var Ee=D(ie);if(typeof Ee!="function")throw Error(n(150));if(ie=Ee.call(ie),ie==null)throw Error(n(151));for(var Te=Ee=null,Re=ne,Me=ne=0,Rt=null,Ue=ie.next();Re!==null&&!Ue.done;Me++,Ue=ie.next()){Re.index>Me?(Rt=Re,Re=null):Rt=Re.sibling;var ps=de(ae,Re,Ue.value,me);if(ps===null){Re===null&&(Re=Rt);break}a&&Re&&ps.alternate===null&&c(ae,Re),ne=C(ps,ne,Me),Te===null?Ee=ps:Te.sibling=ps,Te=ps,Re=Rt}if(Ue.done)return p(ae,Re),st&&Js(ae,Me),Ee;if(Re===null){for(;!Ue.done;Me++,Ue=ie.next())Ue=pe(ae,Ue.value,me),Ue!==null&&(ne=C(Ue,ne,Me),Te===null?Ee=Ue:Te.sibling=Ue,Te=Ue);return st&&Js(ae,Me),Ee}for(Re=y(ae,Re);!Ue.done;Me++,Ue=ie.next())Ue=be(Re,ae,Me,Ue.value,me),Ue!==null&&(a&&Ue.alternate!==null&&Re.delete(Ue.key===null?Me:Ue.key),ne=C(Ue,ne,Me),Te===null?Ee=Ue:Te.sibling=Ue,Te=Ue);return a&&Re.forEach(function(WO){return c(ae,WO)}),st&&Js(ae,Me),Ee}function ft(ae,ne,ie,me){if(typeof ie=="object"&&ie!==null&&ie.type===M&&ie.key===null&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case T:e:{for(var Ee=ie.key,Te=ne;Te!==null;){if(Te.key===Ee){if(Ee=ie.type,Ee===M){if(Te.tag===7){p(ae,Te.sibling),ne=N(Te,ie.props.children),ne.return=ae,ae=ne;break e}}else if(Te.elementType===Ee||typeof Ee=="object"&&Ee!==null&&Ee.$$typeof===F&&Ib(Ee)===Te.type){p(ae,Te.sibling),ne=N(Te,ie.props),ne.ref=Ai(ae,Te,ie),ne.return=ae,ae=ne;break e}p(ae,Te);break}else c(ae,Te);Te=Te.sibling}ie.type===M?(ne=oa(ie.props.children,ae.mode,me,ie.key),ne.return=ae,ae=ne):(me=Bc(ie.type,ie.key,ie.props,null,ae.mode,me),me.ref=Ai(ae,ne,ie),me.return=ae,ae=me)}return q(ae);case R:e:{for(Te=ie.key;ne!==null;){if(ne.key===Te)if(ne.tag===4&&ne.stateNode.containerInfo===ie.containerInfo&&ne.stateNode.implementation===ie.implementation){p(ae,ne.sibling),ne=N(ne,ie.children||[]),ne.return=ae,ae=ne;break e}else{p(ae,ne);break}else c(ae,ne);ne=ne.sibling}ne=wf(ie,ae.mode,me),ne.return=ae,ae=ne}return q(ae);case F:return Te=ie._init,ft(ae,ne,Te(ie._payload),me)}if(xe(ie))return je(ae,ne,ie,me);if(D(ie))return _e(ae,ne,ie,me);yc(ae,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"?(ie=""+ie,ne!==null&&ne.tag===6?(p(ae,ne.sibling),ne=N(ne,ie),ne.return=ae,ae=ne):(p(ae,ne),ne=yf(ie,ae.mode,me),ne.return=ae,ae=ne),q(ae)):p(ae,ne)}return ft}var no=Ob(!0),Lb=Ob(!1),wc=rs(null),vc=null,ro=null,_h=null;function Eh(){_h=ro=vc=null}function Ch(a){var c=wc.current;Qe(wc),a._currentValue=c}function Th(a,c,p){for(;a!==null;){var y=a.alternate;if((a.childLanes&c)!==c?(a.childLanes|=c,y!==null&&(y.childLanes|=c)):y!==null&&(y.childLanes&c)!==c&&(y.childLanes|=c),a===p)break;a=a.return}}function so(a,c){vc=a,_h=ro=null,a=a.dependencies,a!==null&&a.firstContext!==null&&((a.lanes&c)!==0&&(Zt=!0),a.firstContext=null)}function vn(a){var c=a._currentValue;if(_h!==a)if(a={context:a,memoizedValue:c,next:null},ro===null){if(vc===null)throw Error(n(308));ro=a,vc.dependencies={lanes:0,firstContext:a}}else ro=ro.next=a;return c}var Qs=null;function Rh(a){Qs===null?Qs=[a]:Qs.push(a)}function Pb(a,c,p,y){var N=c.interleaved;return N===null?(p.next=p,Rh(c)):(p.next=N.next,N.next=p),c.interleaved=p,Ir(a,y)}function Ir(a,c){a.lanes|=c;var p=a.alternate;for(p!==null&&(p.lanes|=c),p=a,a=a.return;a!==null;)a.childLanes|=c,p=a.alternate,p!==null&&(p.childLanes|=c),p=a,a=a.return;return p.tag===3?p.stateNode:null}var os=!1;function Ah(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Db(a,c){a=a.updateQueue,c.updateQueue===a&&(c.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,effects:a.effects})}function Or(a,c){return{eventTime:a,lane:c,tag:0,payload:null,callback:null,next:null}}function is(a,c,p){var y=a.updateQueue;if(y===null)return null;if(y=y.shared,(ze&2)!==0){var N=y.pending;return N===null?c.next=c:(c.next=N.next,N.next=c),y.pending=c,Ir(a,p)}return N=y.interleaved,N===null?(c.next=c,Rh(y)):(c.next=N.next,N.next=c),y.interleaved=c,Ir(a,p)}function xc(a,c,p){if(c=c.updateQueue,c!==null&&(c=c.shared,(p&4194240)!==0)){var y=c.lanes;y&=a.pendingLanes,p|=y,c.lanes=p,ci(a,p)}}function Fb(a,c){var p=a.updateQueue,y=a.alternate;if(y!==null&&(y=y.updateQueue,p===y)){var N=null,C=null;if(p=p.firstBaseUpdate,p!==null){do{var q={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};C===null?N=C=q:C=C.next=q,p=p.next}while(p!==null);C===null?N=C=c:C=C.next=c}else N=C=c;p={baseState:y.baseState,firstBaseUpdate:N,lastBaseUpdate:C,shared:y.shared,effects:y.effects},a.updateQueue=p;return}a=p.lastBaseUpdate,a===null?p.firstBaseUpdate=c:a.next=c,p.lastBaseUpdate=c}function bc(a,c,p,y){var N=a.updateQueue;os=!1;var C=N.firstBaseUpdate,q=N.lastBaseUpdate,Q=N.shared.pending;if(Q!==null){N.shared.pending=null;var te=Q,le=te.next;te.next=null,q===null?C=le:q.next=le,q=te;var he=a.alternate;he!==null&&(he=he.updateQueue,Q=he.lastBaseUpdate,Q!==q&&(Q===null?he.firstBaseUpdate=le:Q.next=le,he.lastBaseUpdate=te))}if(C!==null){var pe=N.baseState;q=0,he=le=te=null,Q=C;do{var de=Q.lane,be=Q.eventTime;if((y&de)===de){he!==null&&(he=he.next={eventTime:be,lane:0,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null});e:{var je=a,_e=Q;switch(de=c,be=p,_e.tag){case 1:if(je=_e.payload,typeof je=="function"){pe=je.call(be,pe,de);break e}pe=je;break e;case 3:je.flags=je.flags&-65537|128;case 0:if(je=_e.payload,de=typeof je=="function"?je.call(be,pe,de):je,de==null)break e;pe=W({},pe,de);break e;case 2:os=!0}}Q.callback!==null&&Q.lane!==0&&(a.flags|=64,de=N.effects,de===null?N.effects=[Q]:de.push(Q))}else be={eventTime:be,lane:de,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null},he===null?(le=he=be,te=pe):he=he.next=be,q|=de;if(Q=Q.next,Q===null){if(Q=N.shared.pending,Q===null)break;de=Q,Q=de.next,de.next=null,N.lastBaseUpdate=de,N.shared.pending=null}}while(!0);if(he===null&&(te=pe),N.baseState=te,N.firstBaseUpdate=le,N.lastBaseUpdate=he,c=N.shared.interleaved,c!==null){N=c;do q|=N.lane,N=N.next;while(N!==c)}else C===null&&(N.shared.lanes=0);na|=q,a.lanes=q,a.memoizedState=pe}}function qb(a,c,p){if(a=c.effects,c.effects=null,a!==null)for(c=0;c<a.length;c++){var y=a[c],N=y.callback;if(N!==null){if(y.callback=null,y=p,typeof N!="function")throw Error(n(191,N));N.call(y)}}}var Mi={},cr=rs(Mi),$i=rs(Mi),Ii=rs(Mi);function ea(a){if(a===Mi)throw Error(n(174));return a}function Mh(a,c){switch(Xe(Ii,c),Xe($i,a),Xe(cr,Mi),a=c.nodeType,a){case 9:case 11:c=(c=c.documentElement)?c.namespaceURI:Ye(null,"");break;default:a=a===8?c.parentNode:c,c=a.namespaceURI||null,a=a.tagName,c=Ye(c,a)}Qe(cr),Xe(cr,c)}function ao(){Qe(cr),Qe($i),Qe(Ii)}function Bb(a){ea(Ii.current);var c=ea(cr.current),p=Ye(c,a.type);c!==p&&(Xe($i,a),Xe(cr,p))}function $h(a){$i.current===a&&(Qe(cr),Qe($i))}var it=rs(0);function kc(a){for(var c=a;c!==null;){if(c.tag===13){var p=c.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||p.data==="$?"||p.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===a)break;for(;c.sibling===null;){if(c.return===null||c.return===a)return null;c=c.return}c.sibling.return=c.return,c=c.sibling}return null}var Ih=[];function Oh(){for(var a=0;a<Ih.length;a++)Ih[a]._workInProgressVersionPrimary=null;Ih.length=0}var Nc=E.ReactCurrentDispatcher,Lh=E.ReactCurrentBatchConfig,ta=0,lt=null,bt=null,Ct=null,Sc=!1,Oi=!1,Li=0,fO=0;function Ft(){throw Error(n(321))}function Ph(a,c){if(c===null)return!1;for(var p=0;p<c.length&&p<a.length;p++)if(!Mn(a[p],c[p]))return!1;return!0}function Dh(a,c,p,y,N,C){if(ta=C,lt=c,c.memoizedState=null,c.updateQueue=null,c.lanes=0,Nc.current=a===null||a.memoizedState===null?yO:wO,a=p(y,N),Oi){C=0;do{if(Oi=!1,Li=0,25<=C)throw Error(n(301));C+=1,Ct=bt=null,c.updateQueue=null,Nc.current=vO,a=p(y,N)}while(Oi)}if(Nc.current=Ec,c=bt!==null&&bt.next!==null,ta=0,Ct=bt=lt=null,Sc=!1,c)throw Error(n(300));return a}function Fh(){var a=Li!==0;return Li=0,a}function ur(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ct===null?lt.memoizedState=Ct=a:Ct=Ct.next=a,Ct}function xn(){if(bt===null){var a=lt.alternate;a=a!==null?a.memoizedState:null}else a=bt.next;var c=Ct===null?lt.memoizedState:Ct.next;if(c!==null)Ct=c,bt=a;else{if(a===null)throw Error(n(310));bt=a,a={memoizedState:bt.memoizedState,baseState:bt.baseState,baseQueue:bt.baseQueue,queue:bt.queue,next:null},Ct===null?lt.memoizedState=Ct=a:Ct=Ct.next=a}return Ct}function Pi(a,c){return typeof c=="function"?c(a):c}function qh(a){var c=xn(),p=c.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=a;var y=bt,N=y.baseQueue,C=p.pending;if(C!==null){if(N!==null){var q=N.next;N.next=C.next,C.next=q}y.baseQueue=N=C,p.pending=null}if(N!==null){C=N.next,y=y.baseState;var Q=q=null,te=null,le=C;do{var he=le.lane;if((ta&he)===he)te!==null&&(te=te.next={lane:0,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null}),y=le.hasEagerState?le.eagerState:a(y,le.action);else{var pe={lane:he,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null};te===null?(Q=te=pe,q=y):te=te.next=pe,lt.lanes|=he,na|=he}le=le.next}while(le!==null&&le!==C);te===null?q=y:te.next=Q,Mn(y,c.memoizedState)||(Zt=!0),c.memoizedState=y,c.baseState=q,c.baseQueue=te,p.lastRenderedState=y}if(a=p.interleaved,a!==null){N=a;do C=N.lane,lt.lanes|=C,na|=C,N=N.next;while(N!==a)}else N===null&&(p.lanes=0);return[c.memoizedState,p.dispatch]}function Bh(a){var c=xn(),p=c.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=a;var y=p.dispatch,N=p.pending,C=c.memoizedState;if(N!==null){p.pending=null;var q=N=N.next;do C=a(C,q.action),q=q.next;while(q!==N);Mn(C,c.memoizedState)||(Zt=!0),c.memoizedState=C,c.baseQueue===null&&(c.baseState=C),p.lastRenderedState=C}return[C,y]}function zb(){}function Ub(a,c){var p=lt,y=xn(),N=c(),C=!Mn(y.memoizedState,N);if(C&&(y.memoizedState=N,Zt=!0),y=y.queue,zh(Vb.bind(null,p,y,a),[a]),y.getSnapshot!==c||C||Ct!==null&&Ct.memoizedState.tag&1){if(p.flags|=2048,Di(9,Wb.bind(null,p,y,N,c),void 0,null),Tt===null)throw Error(n(349));(ta&30)!==0||Hb(p,c,N)}return N}function Hb(a,c,p){a.flags|=16384,a={getSnapshot:c,value:p},c=lt.updateQueue,c===null?(c={lastEffect:null,stores:null},lt.updateQueue=c,c.stores=[a]):(p=c.stores,p===null?c.stores=[a]:p.push(a))}function Wb(a,c,p,y){c.value=p,c.getSnapshot=y,Gb(c)&&Kb(a)}function Vb(a,c,p){return p(function(){Gb(c)&&Kb(a)})}function Gb(a){var c=a.getSnapshot;a=a.value;try{var p=c();return!Mn(a,p)}catch{return!0}}function Kb(a){var c=Ir(a,1);c!==null&&Pn(c,a,1,-1)}function Yb(a){var c=ur();return typeof a=="function"&&(a=a()),c.memoizedState=c.baseState=a,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Pi,lastRenderedState:a},c.queue=a,a=a.dispatch=gO.bind(null,lt,a),[c.memoizedState,a]}function Di(a,c,p,y){return a={tag:a,create:c,destroy:p,deps:y,next:null},c=lt.updateQueue,c===null?(c={lastEffect:null,stores:null},lt.updateQueue=c,c.lastEffect=a.next=a):(p=c.lastEffect,p===null?c.lastEffect=a.next=a:(y=p.next,p.next=a,a.next=y,c.lastEffect=a)),a}function Xb(){return xn().memoizedState}function jc(a,c,p,y){var N=ur();lt.flags|=a,N.memoizedState=Di(1|c,p,void 0,y===void 0?null:y)}function _c(a,c,p,y){var N=xn();y=y===void 0?null:y;var C=void 0;if(bt!==null){var q=bt.memoizedState;if(C=q.destroy,y!==null&&Ph(y,q.deps)){N.memoizedState=Di(c,p,C,y);return}}lt.flags|=a,N.memoizedState=Di(1|c,p,C,y)}function Zb(a,c){return jc(8390656,8,a,c)}function zh(a,c){return _c(2048,8,a,c)}function Jb(a,c){return _c(4,2,a,c)}function Qb(a,c){return _c(4,4,a,c)}function ek(a,c){if(typeof c=="function")return a=a(),c(a),function(){c(null)};if(c!=null)return a=a(),c.current=a,function(){c.current=null}}function tk(a,c,p){return p=p!=null?p.concat([a]):null,_c(4,4,ek.bind(null,c,a),p)}function Uh(){}function nk(a,c){var p=xn();c=c===void 0?null:c;var y=p.memoizedState;return y!==null&&c!==null&&Ph(c,y[1])?y[0]:(p.memoizedState=[a,c],a)}function rk(a,c){var p=xn();c=c===void 0?null:c;var y=p.memoizedState;return y!==null&&c!==null&&Ph(c,y[1])?y[0]:(a=a(),p.memoizedState=[a,c],a)}function sk(a,c,p){return(ta&21)===0?(a.baseState&&(a.baseState=!1,Zt=!0),a.memoizedState=p):(Mn(p,c)||(p=Zl(),lt.lanes|=p,na|=p,a.baseState=!0),c)}function pO(a,c){var p=He;He=p!==0&&4>p?p:4,a(!0);var y=Lh.transition;Lh.transition={};try{a(!1),c()}finally{He=p,Lh.transition=y}}function ak(){return xn().memoizedState}function mO(a,c,p){var y=ds(a);if(p={lane:y,action:p,hasEagerState:!1,eagerState:null,next:null},ok(a))ik(c,p);else if(p=Pb(a,c,p,y),p!==null){var N=Wt();Pn(p,a,y,N),lk(p,c,y)}}function gO(a,c,p){var y=ds(a),N={lane:y,action:p,hasEagerState:!1,eagerState:null,next:null};if(ok(a))ik(c,N);else{var C=a.alternate;if(a.lanes===0&&(C===null||C.lanes===0)&&(C=c.lastRenderedReducer,C!==null))try{var q=c.lastRenderedState,Q=C(q,p);if(N.hasEagerState=!0,N.eagerState=Q,Mn(Q,q)){var te=c.interleaved;te===null?(N.next=N,Rh(c)):(N.next=te.next,te.next=N),c.interleaved=N;return}}catch{}finally{}p=Pb(a,c,N,y),p!==null&&(N=Wt(),Pn(p,a,y,N),lk(p,c,y))}}function ok(a){var c=a.alternate;return a===lt||c!==null&&c===lt}function ik(a,c){Oi=Sc=!0;var p=a.pending;p===null?c.next=c:(c.next=p.next,p.next=c),a.pending=c}function lk(a,c,p){if((p&4194240)!==0){var y=c.lanes;y&=a.pendingLanes,p|=y,c.lanes=p,ci(a,p)}}var Ec={readContext:vn,useCallback:Ft,useContext:Ft,useEffect:Ft,useImperativeHandle:Ft,useInsertionEffect:Ft,useLayoutEffect:Ft,useMemo:Ft,useReducer:Ft,useRef:Ft,useState:Ft,useDebugValue:Ft,useDeferredValue:Ft,useTransition:Ft,useMutableSource:Ft,useSyncExternalStore:Ft,useId:Ft,unstable_isNewReconciler:!1},yO={readContext:vn,useCallback:function(a,c){return ur().memoizedState=[a,c===void 0?null:c],a},useContext:vn,useEffect:Zb,useImperativeHandle:function(a,c,p){return p=p!=null?p.concat([a]):null,jc(4194308,4,ek.bind(null,c,a),p)},useLayoutEffect:function(a,c){return jc(4194308,4,a,c)},useInsertionEffect:function(a,c){return jc(4,2,a,c)},useMemo:function(a,c){var p=ur();return c=c===void 0?null:c,a=a(),p.memoizedState=[a,c],a},useReducer:function(a,c,p){var y=ur();return c=p!==void 0?p(c):c,y.memoizedState=y.baseState=c,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:c},y.queue=a,a=a.dispatch=mO.bind(null,lt,a),[y.memoizedState,a]},useRef:function(a){var c=ur();return a={current:a},c.memoizedState=a},useState:Yb,useDebugValue:Uh,useDeferredValue:function(a){return ur().memoizedState=a},useTransition:function(){var a=Yb(!1),c=a[0];return a=pO.bind(null,a[1]),ur().memoizedState=a,[c,a]},useMutableSource:function(){},useSyncExternalStore:function(a,c,p){var y=lt,N=ur();if(st){if(p===void 0)throw Error(n(407));p=p()}else{if(p=c(),Tt===null)throw Error(n(349));(ta&30)!==0||Hb(y,c,p)}N.memoizedState=p;var C={value:p,getSnapshot:c};return N.queue=C,Zb(Vb.bind(null,y,C,a),[a]),y.flags|=2048,Di(9,Wb.bind(null,y,C,p,c),void 0,null),p},useId:function(){var a=ur(),c=Tt.identifierPrefix;if(st){var p=$r,y=Mr;p=(y&~(1<<32-ln(y)-1)).toString(32)+p,c=":"+c+"R"+p,p=Li++,0<p&&(c+="H"+p.toString(32)),c+=":"}else p=fO++,c=":"+c+"r"+p.toString(32)+":";return a.memoizedState=c},unstable_isNewReconciler:!1},wO={readContext:vn,useCallback:nk,useContext:vn,useEffect:zh,useImperativeHandle:tk,useInsertionEffect:Jb,useLayoutEffect:Qb,useMemo:rk,useReducer:qh,useRef:Xb,useState:function(){return qh(Pi)},useDebugValue:Uh,useDeferredValue:function(a){var c=xn();return sk(c,bt.memoizedState,a)},useTransition:function(){var a=qh(Pi)[0],c=xn().memoizedState;return[a,c]},useMutableSource:zb,useSyncExternalStore:Ub,useId:ak,unstable_isNewReconciler:!1},vO={readContext:vn,useCallback:nk,useContext:vn,useEffect:zh,useImperativeHandle:tk,useInsertionEffect:Jb,useLayoutEffect:Qb,useMemo:rk,useReducer:Bh,useRef:Xb,useState:function(){return Bh(Pi)},useDebugValue:Uh,useDeferredValue:function(a){var c=xn();return bt===null?c.memoizedState=a:sk(c,bt.memoizedState,a)},useTransition:function(){var a=Bh(Pi)[0],c=xn().memoizedState;return[a,c]},useMutableSource:zb,useSyncExternalStore:Ub,useId:ak,unstable_isNewReconciler:!1};function In(a,c){if(a&&a.defaultProps){c=W({},c),a=a.defaultProps;for(var p in a)c[p]===void 0&&(c[p]=a[p]);return c}return c}function Hh(a,c,p,y){c=a.memoizedState,p=p(y,c),p=p==null?c:W({},c,p),a.memoizedState=p,a.lanes===0&&(a.updateQueue.baseState=p)}var Cc={isMounted:function(a){return(a=a._reactInternals)?Qn(a)===a:!1},enqueueSetState:function(a,c,p){a=a._reactInternals;var y=Wt(),N=ds(a),C=Or(y,N);C.payload=c,p!=null&&(C.callback=p),c=is(a,C,N),c!==null&&(Pn(c,a,N,y),xc(c,a,N))},enqueueReplaceState:function(a,c,p){a=a._reactInternals;var y=Wt(),N=ds(a),C=Or(y,N);C.tag=1,C.payload=c,p!=null&&(C.callback=p),c=is(a,C,N),c!==null&&(Pn(c,a,N,y),xc(c,a,N))},enqueueForceUpdate:function(a,c){a=a._reactInternals;var p=Wt(),y=ds(a),N=Or(p,y);N.tag=2,c!=null&&(N.callback=c),c=is(a,N,y),c!==null&&(Pn(c,a,y,p),xc(c,a,y))}};function ck(a,c,p,y,N,C,q){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(y,C,q):c.prototype&&c.prototype.isPureReactComponent?!Si(p,y)||!Si(N,C):!0}function uk(a,c,p){var y=!1,N=ss,C=c.contextType;return typeof C=="object"&&C!==null?C=vn(C):(N=Xt(c)?Xs:Dt.current,y=c.contextTypes,C=(y=y!=null)?Ja(a,N):ss),c=new c(p,C),a.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,c.updater=Cc,a.stateNode=c,c._reactInternals=a,y&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=N,a.__reactInternalMemoizedMaskedChildContext=C),c}function dk(a,c,p,y){a=c.state,typeof c.componentWillReceiveProps=="function"&&c.componentWillReceiveProps(p,y),typeof c.UNSAFE_componentWillReceiveProps=="function"&&c.UNSAFE_componentWillReceiveProps(p,y),c.state!==a&&Cc.enqueueReplaceState(c,c.state,null)}function Wh(a,c,p,y){var N=a.stateNode;N.props=p,N.state=a.memoizedState,N.refs={},Ah(a);var C=c.contextType;typeof C=="object"&&C!==null?N.context=vn(C):(C=Xt(c)?Xs:Dt.current,N.context=Ja(a,C)),N.state=a.memoizedState,C=c.getDerivedStateFromProps,typeof C=="function"&&(Hh(a,c,C,p),N.state=a.memoizedState),typeof c.getDerivedStateFromProps=="function"||typeof N.getSnapshotBeforeUpdate=="function"||typeof N.UNSAFE_componentWillMount!="function"&&typeof N.componentWillMount!="function"||(c=N.state,typeof N.componentWillMount=="function"&&N.componentWillMount(),typeof N.UNSAFE_componentWillMount=="function"&&N.UNSAFE_componentWillMount(),c!==N.state&&Cc.enqueueReplaceState(N,N.state,null),bc(a,p,N,y),N.state=a.memoizedState),typeof N.componentDidMount=="function"&&(a.flags|=4194308)}function oo(a,c){try{var p="",y=c;do p+=Z(y),y=y.return;while(y);var N=p}catch(C){N=`
39
- Error generating stack: `+C.message+`
40
- `+C.stack}return{value:a,source:c,stack:N,digest:null}}function Vh(a,c,p){return{value:a,source:null,stack:p??null,digest:c??null}}function Gh(a,c){try{console.error(c.value)}catch(p){setTimeout(function(){throw p})}}var xO=typeof WeakMap=="function"?WeakMap:Map;function hk(a,c,p){p=Or(-1,p),p.tag=3,p.payload={element:null};var y=c.value;return p.callback=function(){Oc||(Oc=!0,cf=y),Gh(a,c)},p}function fk(a,c,p){p=Or(-1,p),p.tag=3;var y=a.type.getDerivedStateFromError;if(typeof y=="function"){var N=c.value;p.payload=function(){return y(N)},p.callback=function(){Gh(a,c)}}var C=a.stateNode;return C!==null&&typeof C.componentDidCatch=="function"&&(p.callback=function(){Gh(a,c),typeof y!="function"&&(cs===null?cs=new Set([this]):cs.add(this));var q=c.stack;this.componentDidCatch(c.value,{componentStack:q!==null?q:""})}),p}function pk(a,c,p){var y=a.pingCache;if(y===null){y=a.pingCache=new xO;var N=new Set;y.set(c,N)}else N=y.get(c),N===void 0&&(N=new Set,y.set(c,N));N.has(p)||(N.add(p),a=IO.bind(null,a,c,p),c.then(a,a))}function mk(a){do{var c;if((c=a.tag===13)&&(c=a.memoizedState,c=c!==null?c.dehydrated!==null:!0),c)return a;a=a.return}while(a!==null);return null}function gk(a,c,p,y,N){return(a.mode&1)===0?(a===c?a.flags|=65536:(a.flags|=128,p.flags|=131072,p.flags&=-52805,p.tag===1&&(p.alternate===null?p.tag=17:(c=Or(-1,1),c.tag=2,is(p,c,1))),p.lanes|=1),a):(a.flags|=65536,a.lanes=N,a)}var bO=E.ReactCurrentOwner,Zt=!1;function Ht(a,c,p,y){c.child=a===null?Lb(c,null,p,y):no(c,a.child,p,y)}function yk(a,c,p,y,N){p=p.render;var C=c.ref;return so(c,N),y=Dh(a,c,p,y,C,N),p=Fh(),a!==null&&!Zt?(c.updateQueue=a.updateQueue,c.flags&=-2053,a.lanes&=~N,Lr(a,c,N)):(st&&p&&bh(c),c.flags|=1,Ht(a,c,y,N),c.child)}function wk(a,c,p,y,N){if(a===null){var C=p.type;return typeof C=="function"&&!gf(C)&&C.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(c.tag=15,c.type=C,vk(a,c,C,y,N)):(a=Bc(p.type,null,y,c,c.mode,N),a.ref=c.ref,a.return=c,c.child=a)}if(C=a.child,(a.lanes&N)===0){var q=C.memoizedProps;if(p=p.compare,p=p!==null?p:Si,p(q,y)&&a.ref===c.ref)return Lr(a,c,N)}return c.flags|=1,a=fs(C,y),a.ref=c.ref,a.return=c,c.child=a}function vk(a,c,p,y,N){if(a!==null){var C=a.memoizedProps;if(Si(C,y)&&a.ref===c.ref)if(Zt=!1,c.pendingProps=y=C,(a.lanes&N)!==0)(a.flags&131072)!==0&&(Zt=!0);else return c.lanes=a.lanes,Lr(a,c,N)}return Kh(a,c,p,y,N)}function xk(a,c,p){var y=c.pendingProps,N=y.children,C=a!==null?a.memoizedState:null;if(y.mode==="hidden")if((c.mode&1)===0)c.memoizedState={baseLanes:0,cachePool:null,transitions:null},Xe(lo,dn),dn|=p;else{if((p&1073741824)===0)return a=C!==null?C.baseLanes|p:p,c.lanes=c.childLanes=1073741824,c.memoizedState={baseLanes:a,cachePool:null,transitions:null},c.updateQueue=null,Xe(lo,dn),dn|=a,null;c.memoizedState={baseLanes:0,cachePool:null,transitions:null},y=C!==null?C.baseLanes:p,Xe(lo,dn),dn|=y}else C!==null?(y=C.baseLanes|p,c.memoizedState=null):y=p,Xe(lo,dn),dn|=y;return Ht(a,c,N,p),c.child}function bk(a,c){var p=c.ref;(a===null&&p!==null||a!==null&&a.ref!==p)&&(c.flags|=512,c.flags|=2097152)}function Kh(a,c,p,y,N){var C=Xt(p)?Xs:Dt.current;return C=Ja(c,C),so(c,N),p=Dh(a,c,p,y,C,N),y=Fh(),a!==null&&!Zt?(c.updateQueue=a.updateQueue,c.flags&=-2053,a.lanes&=~N,Lr(a,c,N)):(st&&y&&bh(c),c.flags|=1,Ht(a,c,p,N),c.child)}function kk(a,c,p,y,N){if(Xt(p)){var C=!0;hc(c)}else C=!1;if(so(c,N),c.stateNode===null)Rc(a,c),uk(c,p,y),Wh(c,p,y,N),y=!0;else if(a===null){var q=c.stateNode,Q=c.memoizedProps;q.props=Q;var te=q.context,le=p.contextType;typeof le=="object"&&le!==null?le=vn(le):(le=Xt(p)?Xs:Dt.current,le=Ja(c,le));var he=p.getDerivedStateFromProps,pe=typeof he=="function"||typeof q.getSnapshotBeforeUpdate=="function";pe||typeof q.UNSAFE_componentWillReceiveProps!="function"&&typeof q.componentWillReceiveProps!="function"||(Q!==y||te!==le)&&dk(c,q,y,le),os=!1;var de=c.memoizedState;q.state=de,bc(c,y,q,N),te=c.memoizedState,Q!==y||de!==te||Yt.current||os?(typeof he=="function"&&(Hh(c,p,he,y),te=c.memoizedState),(Q=os||ck(c,p,Q,y,de,te,le))?(pe||typeof q.UNSAFE_componentWillMount!="function"&&typeof q.componentWillMount!="function"||(typeof q.componentWillMount=="function"&&q.componentWillMount(),typeof q.UNSAFE_componentWillMount=="function"&&q.UNSAFE_componentWillMount()),typeof q.componentDidMount=="function"&&(c.flags|=4194308)):(typeof q.componentDidMount=="function"&&(c.flags|=4194308),c.memoizedProps=y,c.memoizedState=te),q.props=y,q.state=te,q.context=le,y=Q):(typeof q.componentDidMount=="function"&&(c.flags|=4194308),y=!1)}else{q=c.stateNode,Db(a,c),Q=c.memoizedProps,le=c.type===c.elementType?Q:In(c.type,Q),q.props=le,pe=c.pendingProps,de=q.context,te=p.contextType,typeof te=="object"&&te!==null?te=vn(te):(te=Xt(p)?Xs:Dt.current,te=Ja(c,te));var be=p.getDerivedStateFromProps;(he=typeof be=="function"||typeof q.getSnapshotBeforeUpdate=="function")||typeof q.UNSAFE_componentWillReceiveProps!="function"&&typeof q.componentWillReceiveProps!="function"||(Q!==pe||de!==te)&&dk(c,q,y,te),os=!1,de=c.memoizedState,q.state=de,bc(c,y,q,N);var je=c.memoizedState;Q!==pe||de!==je||Yt.current||os?(typeof be=="function"&&(Hh(c,p,be,y),je=c.memoizedState),(le=os||ck(c,p,le,y,de,je,te)||!1)?(he||typeof q.UNSAFE_componentWillUpdate!="function"&&typeof q.componentWillUpdate!="function"||(typeof q.componentWillUpdate=="function"&&q.componentWillUpdate(y,je,te),typeof q.UNSAFE_componentWillUpdate=="function"&&q.UNSAFE_componentWillUpdate(y,je,te)),typeof q.componentDidUpdate=="function"&&(c.flags|=4),typeof q.getSnapshotBeforeUpdate=="function"&&(c.flags|=1024)):(typeof q.componentDidUpdate!="function"||Q===a.memoizedProps&&de===a.memoizedState||(c.flags|=4),typeof q.getSnapshotBeforeUpdate!="function"||Q===a.memoizedProps&&de===a.memoizedState||(c.flags|=1024),c.memoizedProps=y,c.memoizedState=je),q.props=y,q.state=je,q.context=te,y=le):(typeof q.componentDidUpdate!="function"||Q===a.memoizedProps&&de===a.memoizedState||(c.flags|=4),typeof q.getSnapshotBeforeUpdate!="function"||Q===a.memoizedProps&&de===a.memoizedState||(c.flags|=1024),y=!1)}return Yh(a,c,p,y,C,N)}function Yh(a,c,p,y,N,C){bk(a,c);var q=(c.flags&128)!==0;if(!y&&!q)return N&&Eb(c,p,!1),Lr(a,c,C);y=c.stateNode,bO.current=c;var Q=q&&typeof p.getDerivedStateFromError!="function"?null:y.render();return c.flags|=1,a!==null&&q?(c.child=no(c,a.child,null,C),c.child=no(c,null,Q,C)):Ht(a,c,Q,C),c.memoizedState=y.state,N&&Eb(c,p,!0),c.child}function Nk(a){var c=a.stateNode;c.pendingContext?jb(a,c.pendingContext,c.pendingContext!==c.context):c.context&&jb(a,c.context,!1),Mh(a,c.containerInfo)}function Sk(a,c,p,y,N){return to(),jh(N),c.flags|=256,Ht(a,c,p,y),c.child}var Xh={dehydrated:null,treeContext:null,retryLane:0};function Zh(a){return{baseLanes:a,cachePool:null,transitions:null}}function jk(a,c,p){var y=c.pendingProps,N=it.current,C=!1,q=(c.flags&128)!==0,Q;if((Q=q)||(Q=a!==null&&a.memoizedState===null?!1:(N&2)!==0),Q?(C=!0,c.flags&=-129):(a===null||a.memoizedState!==null)&&(N|=1),Xe(it,N&1),a===null)return Sh(c),a=c.memoizedState,a!==null&&(a=a.dehydrated,a!==null)?((c.mode&1)===0?c.lanes=1:a.data==="$!"?c.lanes=8:c.lanes=1073741824,null):(q=y.children,a=y.fallback,C?(y=c.mode,C=c.child,q={mode:"hidden",children:q},(y&1)===0&&C!==null?(C.childLanes=0,C.pendingProps=q):C=zc(q,y,0,null),a=oa(a,y,p,null),C.return=c,a.return=c,C.sibling=a,c.child=C,c.child.memoizedState=Zh(p),c.memoizedState=Xh,a):Jh(c,q));if(N=a.memoizedState,N!==null&&(Q=N.dehydrated,Q!==null))return kO(a,c,q,y,Q,N,p);if(C){C=y.fallback,q=c.mode,N=a.child,Q=N.sibling;var te={mode:"hidden",children:y.children};return(q&1)===0&&c.child!==N?(y=c.child,y.childLanes=0,y.pendingProps=te,c.deletions=null):(y=fs(N,te),y.subtreeFlags=N.subtreeFlags&14680064),Q!==null?C=fs(Q,C):(C=oa(C,q,p,null),C.flags|=2),C.return=c,y.return=c,y.sibling=C,c.child=y,y=C,C=c.child,q=a.child.memoizedState,q=q===null?Zh(p):{baseLanes:q.baseLanes|p,cachePool:null,transitions:q.transitions},C.memoizedState=q,C.childLanes=a.childLanes&~p,c.memoizedState=Xh,y}return C=a.child,a=C.sibling,y=fs(C,{mode:"visible",children:y.children}),(c.mode&1)===0&&(y.lanes=p),y.return=c,y.sibling=null,a!==null&&(p=c.deletions,p===null?(c.deletions=[a],c.flags|=16):p.push(a)),c.child=y,c.memoizedState=null,y}function Jh(a,c){return c=zc({mode:"visible",children:c},a.mode,0,null),c.return=a,a.child=c}function Tc(a,c,p,y){return y!==null&&jh(y),no(c,a.child,null,p),a=Jh(c,c.pendingProps.children),a.flags|=2,c.memoizedState=null,a}function kO(a,c,p,y,N,C,q){if(p)return c.flags&256?(c.flags&=-257,y=Vh(Error(n(422))),Tc(a,c,q,y)):c.memoizedState!==null?(c.child=a.child,c.flags|=128,null):(C=y.fallback,N=c.mode,y=zc({mode:"visible",children:y.children},N,0,null),C=oa(C,N,q,null),C.flags|=2,y.return=c,C.return=c,y.sibling=C,c.child=y,(c.mode&1)!==0&&no(c,a.child,null,q),c.child.memoizedState=Zh(q),c.memoizedState=Xh,C);if((c.mode&1)===0)return Tc(a,c,q,null);if(N.data==="$!"){if(y=N.nextSibling&&N.nextSibling.dataset,y)var Q=y.dgst;return y=Q,C=Error(n(419)),y=Vh(C,y,void 0),Tc(a,c,q,y)}if(Q=(q&a.childLanes)!==0,Zt||Q){if(y=Tt,y!==null){switch(q&-q){case 4:N=2;break;case 16:N=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:N=32;break;case 536870912:N=268435456;break;default:N=0}N=(N&(y.suspendedLanes|q))!==0?0:N,N!==0&&N!==C.retryLane&&(C.retryLane=N,Ir(a,N),Pn(y,a,N,-1))}return mf(),y=Vh(Error(n(421))),Tc(a,c,q,y)}return N.data==="$?"?(c.flags|=128,c.child=a.child,c=OO.bind(null,a),N._reactRetry=c,null):(a=C.treeContext,un=ns(N.nextSibling),cn=c,st=!0,$n=null,a!==null&&(yn[wn++]=Mr,yn[wn++]=$r,yn[wn++]=Zs,Mr=a.id,$r=a.overflow,Zs=c),c=Jh(c,y.children),c.flags|=4096,c)}function _k(a,c,p){a.lanes|=c;var y=a.alternate;y!==null&&(y.lanes|=c),Th(a.return,c,p)}function Qh(a,c,p,y,N){var C=a.memoizedState;C===null?a.memoizedState={isBackwards:c,rendering:null,renderingStartTime:0,last:y,tail:p,tailMode:N}:(C.isBackwards=c,C.rendering=null,C.renderingStartTime=0,C.last=y,C.tail=p,C.tailMode=N)}function Ek(a,c,p){var y=c.pendingProps,N=y.revealOrder,C=y.tail;if(Ht(a,c,y.children,p),y=it.current,(y&2)!==0)y=y&1|2,c.flags|=128;else{if(a!==null&&(a.flags&128)!==0)e:for(a=c.child;a!==null;){if(a.tag===13)a.memoizedState!==null&&_k(a,p,c);else if(a.tag===19)_k(a,p,c);else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===c)break e;for(;a.sibling===null;){if(a.return===null||a.return===c)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}y&=1}if(Xe(it,y),(c.mode&1)===0)c.memoizedState=null;else switch(N){case"forwards":for(p=c.child,N=null;p!==null;)a=p.alternate,a!==null&&kc(a)===null&&(N=p),p=p.sibling;p=N,p===null?(N=c.child,c.child=null):(N=p.sibling,p.sibling=null),Qh(c,!1,N,p,C);break;case"backwards":for(p=null,N=c.child,c.child=null;N!==null;){if(a=N.alternate,a!==null&&kc(a)===null){c.child=N;break}a=N.sibling,N.sibling=p,p=N,N=a}Qh(c,!0,p,null,C);break;case"together":Qh(c,!1,null,null,void 0);break;default:c.memoizedState=null}return c.child}function Rc(a,c){(c.mode&1)===0&&a!==null&&(a.alternate=null,c.alternate=null,c.flags|=2)}function Lr(a,c,p){if(a!==null&&(c.dependencies=a.dependencies),na|=c.lanes,(p&c.childLanes)===0)return null;if(a!==null&&c.child!==a.child)throw Error(n(153));if(c.child!==null){for(a=c.child,p=fs(a,a.pendingProps),c.child=p,p.return=c;a.sibling!==null;)a=a.sibling,p=p.sibling=fs(a,a.pendingProps),p.return=c;p.sibling=null}return c.child}function NO(a,c,p){switch(c.tag){case 3:Nk(c),to();break;case 5:Bb(c);break;case 1:Xt(c.type)&&hc(c);break;case 4:Mh(c,c.stateNode.containerInfo);break;case 10:var y=c.type._context,N=c.memoizedProps.value;Xe(wc,y._currentValue),y._currentValue=N;break;case 13:if(y=c.memoizedState,y!==null)return y.dehydrated!==null?(Xe(it,it.current&1),c.flags|=128,null):(p&c.child.childLanes)!==0?jk(a,c,p):(Xe(it,it.current&1),a=Lr(a,c,p),a!==null?a.sibling:null);Xe(it,it.current&1);break;case 19:if(y=(p&c.childLanes)!==0,(a.flags&128)!==0){if(y)return Ek(a,c,p);c.flags|=128}if(N=c.memoizedState,N!==null&&(N.rendering=null,N.tail=null,N.lastEffect=null),Xe(it,it.current),y)break;return null;case 22:case 23:return c.lanes=0,xk(a,c,p)}return Lr(a,c,p)}var Ck,ef,Tk,Rk;Ck=function(a,c){for(var p=c.child;p!==null;){if(p.tag===5||p.tag===6)a.appendChild(p.stateNode);else if(p.tag!==4&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===c)break;for(;p.sibling===null;){if(p.return===null||p.return===c)return;p=p.return}p.sibling.return=p.return,p=p.sibling}},ef=function(){},Tk=function(a,c,p,y){var N=a.memoizedProps;if(N!==y){a=c.stateNode,ea(cr.current);var C=null;switch(p){case"input":N=we(a,N),y=we(a,y),C=[];break;case"select":N=W({},N,{value:void 0}),y=W({},y,{value:void 0}),C=[];break;case"textarea":N=Le(a,N),y=Le(a,y),C=[];break;default:typeof N.onClick!="function"&&typeof y.onClick=="function"&&(a.onclick=cc)}ge(p,y);var q;p=null;for(le in N)if(!y.hasOwnProperty(le)&&N.hasOwnProperty(le)&&N[le]!=null)if(le==="style"){var Q=N[le];for(q in Q)Q.hasOwnProperty(q)&&(p||(p={}),p[q]="")}else le!=="dangerouslySetInnerHTML"&&le!=="children"&&le!=="suppressContentEditableWarning"&&le!=="suppressHydrationWarning"&&le!=="autoFocus"&&(s.hasOwnProperty(le)?C||(C=[]):(C=C||[]).push(le,null));for(le in y){var te=y[le];if(Q=N!=null?N[le]:void 0,y.hasOwnProperty(le)&&te!==Q&&(te!=null||Q!=null))if(le==="style")if(Q){for(q in Q)!Q.hasOwnProperty(q)||te&&te.hasOwnProperty(q)||(p||(p={}),p[q]="");for(q in te)te.hasOwnProperty(q)&&Q[q]!==te[q]&&(p||(p={}),p[q]=te[q])}else p||(C||(C=[]),C.push(le,p)),p=te;else le==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,Q=Q?Q.__html:void 0,te!=null&&Q!==te&&(C=C||[]).push(le,te)):le==="children"?typeof te!="string"&&typeof te!="number"||(C=C||[]).push(le,""+te):le!=="suppressContentEditableWarning"&&le!=="suppressHydrationWarning"&&(s.hasOwnProperty(le)?(te!=null&&le==="onScroll"&&Je("scroll",a),C||Q===te||(C=[])):(C=C||[]).push(le,te))}p&&(C=C||[]).push("style",p);var le=C;(c.updateQueue=le)&&(c.flags|=4)}},Rk=function(a,c,p,y){p!==y&&(c.flags|=4)};function Fi(a,c){if(!st)switch(a.tailMode){case"hidden":c=a.tail;for(var p=null;c!==null;)c.alternate!==null&&(p=c),c=c.sibling;p===null?a.tail=null:p.sibling=null;break;case"collapsed":p=a.tail;for(var y=null;p!==null;)p.alternate!==null&&(y=p),p=p.sibling;y===null?c||a.tail===null?a.tail=null:a.tail.sibling=null:y.sibling=null}}function qt(a){var c=a.alternate!==null&&a.alternate.child===a.child,p=0,y=0;if(c)for(var N=a.child;N!==null;)p|=N.lanes|N.childLanes,y|=N.subtreeFlags&14680064,y|=N.flags&14680064,N.return=a,N=N.sibling;else for(N=a.child;N!==null;)p|=N.lanes|N.childLanes,y|=N.subtreeFlags,y|=N.flags,N.return=a,N=N.sibling;return a.subtreeFlags|=y,a.childLanes=p,c}function SO(a,c,p){var y=c.pendingProps;switch(kh(c),c.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return qt(c),null;case 1:return Xt(c.type)&&dc(),qt(c),null;case 3:return y=c.stateNode,ao(),Qe(Yt),Qe(Dt),Oh(),y.pendingContext&&(y.context=y.pendingContext,y.pendingContext=null),(a===null||a.child===null)&&(gc(c)?c.flags|=4:a===null||a.memoizedState.isDehydrated&&(c.flags&256)===0||(c.flags|=1024,$n!==null&&(hf($n),$n=null))),ef(a,c),qt(c),null;case 5:$h(c);var N=ea(Ii.current);if(p=c.type,a!==null&&c.stateNode!=null)Tk(a,c,p,y,N),a.ref!==c.ref&&(c.flags|=512,c.flags|=2097152);else{if(!y){if(c.stateNode===null)throw Error(n(166));return qt(c),null}if(a=ea(cr.current),gc(c)){y=c.stateNode,p=c.type;var C=c.memoizedProps;switch(y[lr]=c,y[Ti]=C,a=(c.mode&1)!==0,p){case"dialog":Je("cancel",y),Je("close",y);break;case"iframe":case"object":case"embed":Je("load",y);break;case"video":case"audio":for(N=0;N<_i.length;N++)Je(_i[N],y);break;case"source":Je("error",y);break;case"img":case"image":case"link":Je("error",y),Je("load",y);break;case"details":Je("toggle",y);break;case"input":ve(y,C),Je("invalid",y);break;case"select":y._wrapperState={wasMultiple:!!C.multiple},Je("invalid",y);break;case"textarea":Ie(y,C),Je("invalid",y)}ge(p,C),N=null;for(var q in C)if(C.hasOwnProperty(q)){var Q=C[q];q==="children"?typeof Q=="string"?y.textContent!==Q&&(C.suppressHydrationWarning!==!0&&lc(y.textContent,Q,a),N=["children",Q]):typeof Q=="number"&&y.textContent!==""+Q&&(C.suppressHydrationWarning!==!0&&lc(y.textContent,Q,a),N=["children",""+Q]):s.hasOwnProperty(q)&&Q!=null&&q==="onScroll"&&Je("scroll",y)}switch(p){case"input":fe(y),ue(y,C,!0);break;case"textarea":fe(y),nt(y);break;case"select":case"option":break;default:typeof C.onClick=="function"&&(y.onclick=cc)}y=N,c.updateQueue=y,y!==null&&(c.flags|=4)}else{q=N.nodeType===9?N:N.ownerDocument,a==="http://www.w3.org/1999/xhtml"&&(a=rt(p)),a==="http://www.w3.org/1999/xhtml"?p==="script"?(a=q.createElement("div"),a.innerHTML="<script><\/script>",a=a.removeChild(a.firstChild)):typeof y.is=="string"?a=q.createElement(p,{is:y.is}):(a=q.createElement(p),p==="select"&&(q=a,y.multiple?q.multiple=!0:y.size&&(q.size=y.size))):a=q.createElementNS(a,p),a[lr]=c,a[Ti]=y,Ck(a,c,!1,!1),c.stateNode=a;e:{switch(q=Oe(p,y),p){case"dialog":Je("cancel",a),Je("close",a),N=y;break;case"iframe":case"object":case"embed":Je("load",a),N=y;break;case"video":case"audio":for(N=0;N<_i.length;N++)Je(_i[N],a);N=y;break;case"source":Je("error",a),N=y;break;case"img":case"image":case"link":Je("error",a),Je("load",a),N=y;break;case"details":Je("toggle",a),N=y;break;case"input":ve(a,y),N=we(a,y),Je("invalid",a);break;case"option":N=y;break;case"select":a._wrapperState={wasMultiple:!!y.multiple},N=W({},y,{value:void 0}),Je("invalid",a);break;case"textarea":Ie(a,y),N=Le(a,y),Je("invalid",a);break;default:N=y}ge(p,N),Q=N;for(C in Q)if(Q.hasOwnProperty(C)){var te=Q[C];C==="style"?ot(a,te):C==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,te!=null&&At(a,te)):C==="children"?typeof te=="string"?(p!=="textarea"||te!=="")&&vt(a,te):typeof te=="number"&&vt(a,""+te):C!=="suppressContentEditableWarning"&&C!=="suppressHydrationWarning"&&C!=="autoFocus"&&(s.hasOwnProperty(C)?te!=null&&C==="onScroll"&&Je("scroll",a):te!=null&&j(a,C,te,q))}switch(p){case"input":fe(a),ue(a,y,!1);break;case"textarea":fe(a),nt(a);break;case"option":y.value!=null&&a.setAttribute("value",""+ee(y.value));break;case"select":a.multiple=!!y.multiple,C=y.value,C!=null?Ae(a,!!y.multiple,C,!1):y.defaultValue!=null&&Ae(a,!!y.multiple,y.defaultValue,!0);break;default:typeof N.onClick=="function"&&(a.onclick=cc)}switch(p){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 qt(c),null;case 6:if(a&&c.stateNode!=null)Rk(a,c,a.memoizedProps,y);else{if(typeof y!="string"&&c.stateNode===null)throw Error(n(166));if(p=ea(Ii.current),ea(cr.current),gc(c)){if(y=c.stateNode,p=c.memoizedProps,y[lr]=c,(C=y.nodeValue!==p)&&(a=cn,a!==null))switch(a.tag){case 3:lc(y.nodeValue,p,(a.mode&1)!==0);break;case 5:a.memoizedProps.suppressHydrationWarning!==!0&&lc(y.nodeValue,p,(a.mode&1)!==0)}C&&(c.flags|=4)}else y=(p.nodeType===9?p:p.ownerDocument).createTextNode(y),y[lr]=c,c.stateNode=y}return qt(c),null;case 13:if(Qe(it),y=c.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(st&&un!==null&&(c.mode&1)!==0&&(c.flags&128)===0)$b(),to(),c.flags|=98560,C=!1;else if(C=gc(c),y!==null&&y.dehydrated!==null){if(a===null){if(!C)throw Error(n(318));if(C=c.memoizedState,C=C!==null?C.dehydrated:null,!C)throw Error(n(317));C[lr]=c}else to(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;qt(c),C=!1}else $n!==null&&(hf($n),$n=null),C=!0;if(!C)return c.flags&65536?c:null}return(c.flags&128)!==0?(c.lanes=p,c):(y=y!==null,y!==(a!==null&&a.memoizedState!==null)&&y&&(c.child.flags|=8192,(c.mode&1)!==0&&(a===null||(it.current&1)!==0?kt===0&&(kt=3):mf())),c.updateQueue!==null&&(c.flags|=4),qt(c),null);case 4:return ao(),ef(a,c),a===null&&Ei(c.stateNode.containerInfo),qt(c),null;case 10:return Ch(c.type._context),qt(c),null;case 17:return Xt(c.type)&&dc(),qt(c),null;case 19:if(Qe(it),C=c.memoizedState,C===null)return qt(c),null;if(y=(c.flags&128)!==0,q=C.rendering,q===null)if(y)Fi(C,!1);else{if(kt!==0||a!==null&&(a.flags&128)!==0)for(a=c.child;a!==null;){if(q=kc(a),q!==null){for(c.flags|=128,Fi(C,!1),y=q.updateQueue,y!==null&&(c.updateQueue=y,c.flags|=4),c.subtreeFlags=0,y=p,p=c.child;p!==null;)C=p,a=y,C.flags&=14680066,q=C.alternate,q===null?(C.childLanes=0,C.lanes=a,C.child=null,C.subtreeFlags=0,C.memoizedProps=null,C.memoizedState=null,C.updateQueue=null,C.dependencies=null,C.stateNode=null):(C.childLanes=q.childLanes,C.lanes=q.lanes,C.child=q.child,C.subtreeFlags=0,C.deletions=null,C.memoizedProps=q.memoizedProps,C.memoizedState=q.memoizedState,C.updateQueue=q.updateQueue,C.type=q.type,a=q.dependencies,C.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),p=p.sibling;return Xe(it,it.current&1|2),c.child}a=a.sibling}C.tail!==null&&Ge()>co&&(c.flags|=128,y=!0,Fi(C,!1),c.lanes=4194304)}else{if(!y)if(a=kc(q),a!==null){if(c.flags|=128,y=!0,p=a.updateQueue,p!==null&&(c.updateQueue=p,c.flags|=4),Fi(C,!0),C.tail===null&&C.tailMode==="hidden"&&!q.alternate&&!st)return qt(c),null}else 2*Ge()-C.renderingStartTime>co&&p!==1073741824&&(c.flags|=128,y=!0,Fi(C,!1),c.lanes=4194304);C.isBackwards?(q.sibling=c.child,c.child=q):(p=C.last,p!==null?p.sibling=q:c.child=q,C.last=q)}return C.tail!==null?(c=C.tail,C.rendering=c,C.tail=c.sibling,C.renderingStartTime=Ge(),c.sibling=null,p=it.current,Xe(it,y?p&1|2:p&1),c):(qt(c),null);case 22:case 23:return pf(),y=c.memoizedState!==null,a!==null&&a.memoizedState!==null!==y&&(c.flags|=8192),y&&(c.mode&1)!==0?(dn&1073741824)!==0&&(qt(c),c.subtreeFlags&6&&(c.flags|=8192)):qt(c),null;case 24:return null;case 25:return null}throw Error(n(156,c.tag))}function jO(a,c){switch(kh(c),c.tag){case 1:return Xt(c.type)&&dc(),a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 3:return ao(),Qe(Yt),Qe(Dt),Oh(),a=c.flags,(a&65536)!==0&&(a&128)===0?(c.flags=a&-65537|128,c):null;case 5:return $h(c),null;case 13:if(Qe(it),a=c.memoizedState,a!==null&&a.dehydrated!==null){if(c.alternate===null)throw Error(n(340));to()}return a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 19:return Qe(it),null;case 4:return ao(),null;case 10:return Ch(c.type._context),null;case 22:case 23:return pf(),null;case 24:return null;default:return null}}var Ac=!1,Bt=!1,_O=typeof WeakSet=="function"?WeakSet:Set,Se=null;function io(a,c){var p=a.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(y){dt(a,c,y)}else p.current=null}function tf(a,c,p){try{p()}catch(y){dt(a,c,y)}}var Ak=!1;function EO(a,c){if(fh=Hs,a=cb(),ah(a)){if("selectionStart"in a)var p={start:a.selectionStart,end:a.selectionEnd};else e:{p=(p=a.ownerDocument)&&p.defaultView||window;var y=p.getSelection&&p.getSelection();if(y&&y.rangeCount!==0){p=y.anchorNode;var N=y.anchorOffset,C=y.focusNode;y=y.focusOffset;try{p.nodeType,C.nodeType}catch{p=null;break e}var q=0,Q=-1,te=-1,le=0,he=0,pe=a,de=null;t:for(;;){for(var be;pe!==p||N!==0&&pe.nodeType!==3||(Q=q+N),pe!==C||y!==0&&pe.nodeType!==3||(te=q+y),pe.nodeType===3&&(q+=pe.nodeValue.length),(be=pe.firstChild)!==null;)de=pe,pe=be;for(;;){if(pe===a)break t;if(de===p&&++le===N&&(Q=q),de===C&&++he===y&&(te=q),(be=pe.nextSibling)!==null)break;pe=de,de=pe.parentNode}pe=be}p=Q===-1||te===-1?null:{start:Q,end:te}}else p=null}p=p||{start:0,end:0}}else p=null;for(ph={focusedElem:a,selectionRange:p},Hs=!1,Se=c;Se!==null;)if(c=Se,a=c.child,(c.subtreeFlags&1028)!==0&&a!==null)a.return=c,Se=a;else for(;Se!==null;){c=Se;try{var je=c.alternate;if((c.flags&1024)!==0)switch(c.tag){case 0:case 11:case 15:break;case 1:if(je!==null){var _e=je.memoizedProps,ft=je.memoizedState,ae=c.stateNode,ne=ae.getSnapshotBeforeUpdate(c.elementType===c.type?_e:In(c.type,_e),ft);ae.__reactInternalSnapshotBeforeUpdate=ne}break;case 3:var ie=c.stateNode.containerInfo;ie.nodeType===1?ie.textContent="":ie.nodeType===9&&ie.documentElement&&ie.removeChild(ie.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(me){dt(c,c.return,me)}if(a=c.sibling,a!==null){a.return=c.return,Se=a;break}Se=c.return}return je=Ak,Ak=!1,je}function qi(a,c,p){var y=c.updateQueue;if(y=y!==null?y.lastEffect:null,y!==null){var N=y=y.next;do{if((N.tag&a)===a){var C=N.destroy;N.destroy=void 0,C!==void 0&&tf(c,p,C)}N=N.next}while(N!==y)}}function Mc(a,c){if(c=c.updateQueue,c=c!==null?c.lastEffect:null,c!==null){var p=c=c.next;do{if((p.tag&a)===a){var y=p.create;p.destroy=y()}p=p.next}while(p!==c)}}function nf(a){var c=a.ref;if(c!==null){var p=a.stateNode;switch(a.tag){case 5:a=p;break;default:a=p}typeof c=="function"?c(a):c.current=a}}function Mk(a){var c=a.alternate;c!==null&&(a.alternate=null,Mk(c)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(c=a.stateNode,c!==null&&(delete c[lr],delete c[Ti],delete c[wh],delete c[cO],delete c[uO])),a.stateNode=null,a.return=null,a.dependencies=null,a.memoizedProps=null,a.memoizedState=null,a.pendingProps=null,a.stateNode=null,a.updateQueue=null}function $k(a){return a.tag===5||a.tag===3||a.tag===4}function Ik(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||$k(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function rf(a,c,p){var y=a.tag;if(y===5||y===6)a=a.stateNode,c?p.nodeType===8?p.parentNode.insertBefore(a,c):p.insertBefore(a,c):(p.nodeType===8?(c=p.parentNode,c.insertBefore(a,p)):(c=p,c.appendChild(a)),p=p._reactRootContainer,p!=null||c.onclick!==null||(c.onclick=cc));else if(y!==4&&(a=a.child,a!==null))for(rf(a,c,p),a=a.sibling;a!==null;)rf(a,c,p),a=a.sibling}function sf(a,c,p){var y=a.tag;if(y===5||y===6)a=a.stateNode,c?p.insertBefore(a,c):p.appendChild(a);else if(y!==4&&(a=a.child,a!==null))for(sf(a,c,p),a=a.sibling;a!==null;)sf(a,c,p),a=a.sibling}var $t=null,On=!1;function ls(a,c,p){for(p=p.child;p!==null;)Ok(a,c,p),p=p.sibling}function Ok(a,c,p){if(pt&&typeof pt.onCommitFiberUnmount=="function")try{pt.onCommitFiberUnmount(jr,p)}catch{}switch(p.tag){case 5:Bt||io(p,c);case 6:var y=$t,N=On;$t=null,ls(a,c,p),$t=y,On=N,$t!==null&&(On?(a=$t,p=p.stateNode,a.nodeType===8?a.parentNode.removeChild(p):a.removeChild(p)):$t.removeChild(p.stateNode));break;case 18:$t!==null&&(On?(a=$t,p=p.stateNode,a.nodeType===8?yh(a.parentNode,p):a.nodeType===1&&yh(a,p),_r(a)):yh($t,p.stateNode));break;case 4:y=$t,N=On,$t=p.stateNode.containerInfo,On=!0,ls(a,c,p),$t=y,On=N;break;case 0:case 11:case 14:case 15:if(!Bt&&(y=p.updateQueue,y!==null&&(y=y.lastEffect,y!==null))){N=y=y.next;do{var C=N,q=C.destroy;C=C.tag,q!==void 0&&((C&2)!==0||(C&4)!==0)&&tf(p,c,q),N=N.next}while(N!==y)}ls(a,c,p);break;case 1:if(!Bt&&(io(p,c),y=p.stateNode,typeof y.componentWillUnmount=="function"))try{y.props=p.memoizedProps,y.state=p.memoizedState,y.componentWillUnmount()}catch(Q){dt(p,c,Q)}ls(a,c,p);break;case 21:ls(a,c,p);break;case 22:p.mode&1?(Bt=(y=Bt)||p.memoizedState!==null,ls(a,c,p),Bt=y):ls(a,c,p);break;default:ls(a,c,p)}}function Lk(a){var c=a.updateQueue;if(c!==null){a.updateQueue=null;var p=a.stateNode;p===null&&(p=a.stateNode=new _O),c.forEach(function(y){var N=LO.bind(null,a,y);p.has(y)||(p.add(y),y.then(N,N))})}}function Ln(a,c){var p=c.deletions;if(p!==null)for(var y=0;y<p.length;y++){var N=p[y];try{var C=a,q=c,Q=q;e:for(;Q!==null;){switch(Q.tag){case 5:$t=Q.stateNode,On=!1;break e;case 3:$t=Q.stateNode.containerInfo,On=!0;break e;case 4:$t=Q.stateNode.containerInfo,On=!0;break e}Q=Q.return}if($t===null)throw Error(n(160));Ok(C,q,N),$t=null,On=!1;var te=N.alternate;te!==null&&(te.return=null),N.return=null}catch(le){dt(N,c,le)}}if(c.subtreeFlags&12854)for(c=c.child;c!==null;)Pk(c,a),c=c.sibling}function Pk(a,c){var p=a.alternate,y=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:if(Ln(c,a),dr(a),y&4){try{qi(3,a,a.return),Mc(3,a)}catch(_e){dt(a,a.return,_e)}try{qi(5,a,a.return)}catch(_e){dt(a,a.return,_e)}}break;case 1:Ln(c,a),dr(a),y&512&&p!==null&&io(p,p.return);break;case 5:if(Ln(c,a),dr(a),y&512&&p!==null&&io(p,p.return),a.flags&32){var N=a.stateNode;try{vt(N,"")}catch(_e){dt(a,a.return,_e)}}if(y&4&&(N=a.stateNode,N!=null)){var C=a.memoizedProps,q=p!==null?p.memoizedProps:C,Q=a.type,te=a.updateQueue;if(a.updateQueue=null,te!==null)try{Q==="input"&&C.type==="radio"&&C.name!=null&&$e(N,C),Oe(Q,q);var le=Oe(Q,C);for(q=0;q<te.length;q+=2){var he=te[q],pe=te[q+1];he==="style"?ot(N,pe):he==="dangerouslySetInnerHTML"?At(N,pe):he==="children"?vt(N,pe):j(N,he,pe,le)}switch(Q){case"input":ye(N,C);break;case"textarea":qe(N,C);break;case"select":var de=N._wrapperState.wasMultiple;N._wrapperState.wasMultiple=!!C.multiple;var be=C.value;be!=null?Ae(N,!!C.multiple,be,!1):de!==!!C.multiple&&(C.defaultValue!=null?Ae(N,!!C.multiple,C.defaultValue,!0):Ae(N,!!C.multiple,C.multiple?[]:"",!1))}N[Ti]=C}catch(_e){dt(a,a.return,_e)}}break;case 6:if(Ln(c,a),dr(a),y&4){if(a.stateNode===null)throw Error(n(162));N=a.stateNode,C=a.memoizedProps;try{N.nodeValue=C}catch(_e){dt(a,a.return,_e)}}break;case 3:if(Ln(c,a),dr(a),y&4&&p!==null&&p.memoizedState.isDehydrated)try{_r(c.containerInfo)}catch(_e){dt(a,a.return,_e)}break;case 4:Ln(c,a),dr(a);break;case 13:Ln(c,a),dr(a),N=a.child,N.flags&8192&&(C=N.memoizedState!==null,N.stateNode.isHidden=C,!C||N.alternate!==null&&N.alternate.memoizedState!==null||(lf=Ge())),y&4&&Lk(a);break;case 22:if(he=p!==null&&p.memoizedState!==null,a.mode&1?(Bt=(le=Bt)||he,Ln(c,a),Bt=le):Ln(c,a),dr(a),y&8192){if(le=a.memoizedState!==null,(a.stateNode.isHidden=le)&&!he&&(a.mode&1)!==0)for(Se=a,he=a.child;he!==null;){for(pe=Se=he;Se!==null;){switch(de=Se,be=de.child,de.tag){case 0:case 11:case 14:case 15:qi(4,de,de.return);break;case 1:io(de,de.return);var je=de.stateNode;if(typeof je.componentWillUnmount=="function"){y=de,p=de.return;try{c=y,je.props=c.memoizedProps,je.state=c.memoizedState,je.componentWillUnmount()}catch(_e){dt(y,p,_e)}}break;case 5:io(de,de.return);break;case 22:if(de.memoizedState!==null){qk(pe);continue}}be!==null?(be.return=de,Se=be):qk(pe)}he=he.sibling}e:for(he=null,pe=a;;){if(pe.tag===5){if(he===null){he=pe;try{N=pe.stateNode,le?(C=N.style,typeof C.setProperty=="function"?C.setProperty("display","none","important"):C.display="none"):(Q=pe.stateNode,te=pe.memoizedProps.style,q=te!=null&&te.hasOwnProperty("display")?te.display:null,Q.style.display=Ze("display",q))}catch(_e){dt(a,a.return,_e)}}}else if(pe.tag===6){if(he===null)try{pe.stateNode.nodeValue=le?"":pe.memoizedProps}catch(_e){dt(a,a.return,_e)}}else if((pe.tag!==22&&pe.tag!==23||pe.memoizedState===null||pe===a)&&pe.child!==null){pe.child.return=pe,pe=pe.child;continue}if(pe===a)break e;for(;pe.sibling===null;){if(pe.return===null||pe.return===a)break e;he===pe&&(he=null),pe=pe.return}he===pe&&(he=null),pe.sibling.return=pe.return,pe=pe.sibling}}break;case 19:Ln(c,a),dr(a),y&4&&Lk(a);break;case 21:break;default:Ln(c,a),dr(a)}}function dr(a){var c=a.flags;if(c&2){try{e:{for(var p=a.return;p!==null;){if($k(p)){var y=p;break e}p=p.return}throw Error(n(160))}switch(y.tag){case 5:var N=y.stateNode;y.flags&32&&(vt(N,""),y.flags&=-33);var C=Ik(a);sf(a,C,N);break;case 3:case 4:var q=y.stateNode.containerInfo,Q=Ik(a);rf(a,Q,q);break;default:throw Error(n(161))}}catch(te){dt(a,a.return,te)}a.flags&=-3}c&4096&&(a.flags&=-4097)}function CO(a,c,p){Se=a,Dk(a)}function Dk(a,c,p){for(var y=(a.mode&1)!==0;Se!==null;){var N=Se,C=N.child;if(N.tag===22&&y){var q=N.memoizedState!==null||Ac;if(!q){var Q=N.alternate,te=Q!==null&&Q.memoizedState!==null||Bt;Q=Ac;var le=Bt;if(Ac=q,(Bt=te)&&!le)for(Se=N;Se!==null;)q=Se,te=q.child,q.tag===22&&q.memoizedState!==null?Bk(N):te!==null?(te.return=q,Se=te):Bk(N);for(;C!==null;)Se=C,Dk(C),C=C.sibling;Se=N,Ac=Q,Bt=le}Fk(a)}else(N.subtreeFlags&8772)!==0&&C!==null?(C.return=N,Se=C):Fk(a)}}function Fk(a){for(;Se!==null;){var c=Se;if((c.flags&8772)!==0){var p=c.alternate;try{if((c.flags&8772)!==0)switch(c.tag){case 0:case 11:case 15:Bt||Mc(5,c);break;case 1:var y=c.stateNode;if(c.flags&4&&!Bt)if(p===null)y.componentDidMount();else{var N=c.elementType===c.type?p.memoizedProps:In(c.type,p.memoizedProps);y.componentDidUpdate(N,p.memoizedState,y.__reactInternalSnapshotBeforeUpdate)}var C=c.updateQueue;C!==null&&qb(c,C,y);break;case 3:var q=c.updateQueue;if(q!==null){if(p=null,c.child!==null)switch(c.child.tag){case 5:p=c.child.stateNode;break;case 1:p=c.child.stateNode}qb(c,q,p)}break;case 5:var Q=c.stateNode;if(p===null&&c.flags&4){p=Q;var te=c.memoizedProps;switch(c.type){case"button":case"input":case"select":case"textarea":te.autoFocus&&p.focus();break;case"img":te.src&&(p.src=te.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(c.memoizedState===null){var le=c.alternate;if(le!==null){var he=le.memoizedState;if(he!==null){var pe=he.dehydrated;pe!==null&&_r(pe)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Bt||c.flags&512&&nf(c)}catch(de){dt(c,c.return,de)}}if(c===a){Se=null;break}if(p=c.sibling,p!==null){p.return=c.return,Se=p;break}Se=c.return}}function qk(a){for(;Se!==null;){var c=Se;if(c===a){Se=null;break}var p=c.sibling;if(p!==null){p.return=c.return,Se=p;break}Se=c.return}}function Bk(a){for(;Se!==null;){var c=Se;try{switch(c.tag){case 0:case 11:case 15:var p=c.return;try{Mc(4,c)}catch(te){dt(c,p,te)}break;case 1:var y=c.stateNode;if(typeof y.componentDidMount=="function"){var N=c.return;try{y.componentDidMount()}catch(te){dt(c,N,te)}}var C=c.return;try{nf(c)}catch(te){dt(c,C,te)}break;case 5:var q=c.return;try{nf(c)}catch(te){dt(c,q,te)}}}catch(te){dt(c,c.return,te)}if(c===a){Se=null;break}var Q=c.sibling;if(Q!==null){Q.return=c.return,Se=Q;break}Se=c.return}}var TO=Math.ceil,$c=E.ReactCurrentDispatcher,af=E.ReactCurrentOwner,bn=E.ReactCurrentBatchConfig,ze=0,Tt=null,mt=null,It=0,dn=0,lo=rs(0),kt=0,Bi=null,na=0,Ic=0,of=0,zi=null,Jt=null,lf=0,co=1/0,Pr=null,Oc=!1,cf=null,cs=null,Lc=!1,us=null,Pc=0,Ui=0,uf=null,Dc=-1,Fc=0;function Wt(){return(ze&6)!==0?Ge():Dc!==-1?Dc:Dc=Ge()}function ds(a){return(a.mode&1)===0?1:(ze&2)!==0&&It!==0?It&-It:hO.transition!==null?(Fc===0&&(Fc=Zl()),Fc):(a=He,a!==0||(a=window.event,a=a===void 0?16:es(a.type)),a)}function Pn(a,c,p,y){if(50<Ui)throw Ui=0,uf=null,Error(n(185));Xr(a,p,y),((ze&2)===0||a!==Tt)&&(a===Tt&&((ze&2)===0&&(Ic|=p),kt===4&&hs(a,It)),Qt(a,y),p===1&&ze===0&&(c.mode&1)===0&&(co=Ge()+500,fc&&as()))}function Qt(a,c){var p=a.callbackNode;Xl(a,c);var y=Da(a,a===Tt?It:0);if(y===0)p!==null&&Is(p),a.callbackNode=null,a.callbackPriority=0;else if(c=y&-y,a.callbackPriority!==c){if(p!=null&&Is(p),c===1)a.tag===0?dO(Uk.bind(null,a)):Cb(Uk.bind(null,a)),iO(function(){(ze&6)===0&&as()}),p=null;else{switch(qa(y)){case 1:p=Os;break;case 4:p=Ls;break;case 16:p=Sr;break;case 536870912:p=Ps;break;default:p=Sr}p=Zk(p,zk.bind(null,a))}a.callbackPriority=c,a.callbackNode=p}}function zk(a,c){if(Dc=-1,Fc=0,(ze&6)!==0)throw Error(n(327));var p=a.callbackNode;if(uo()&&a.callbackNode!==p)return null;var y=Da(a,a===Tt?It:0);if(y===0)return null;if((y&30)!==0||(y&a.expiredLanes)!==0||c)c=qc(a,y);else{c=y;var N=ze;ze|=2;var C=Wk();(Tt!==a||It!==c)&&(Pr=null,co=Ge()+500,sa(a,c));do try{MO();break}catch(Q){Hk(a,Q)}while(!0);Eh(),$c.current=C,ze=N,mt!==null?c=0:(Tt=null,It=0,c=kt)}if(c!==0){if(c===2&&(N=nr(a),N!==0&&(y=N,c=df(a,N))),c===1)throw p=Bi,sa(a,0),hs(a,y),Qt(a,Ge()),p;if(c===6)hs(a,y);else{if(N=a.current.alternate,(y&30)===0&&!RO(N)&&(c=qc(a,y),c===2&&(C=nr(a),C!==0&&(y=C,c=df(a,C))),c===1))throw p=Bi,sa(a,0),hs(a,y),Qt(a,Ge()),p;switch(a.finishedWork=N,a.finishedLanes=y,c){case 0:case 1:throw Error(n(345));case 2:aa(a,Jt,Pr);break;case 3:if(hs(a,y),(y&130023424)===y&&(c=lf+500-Ge(),10<c)){if(Da(a,0)!==0)break;if(N=a.suspendedLanes,(N&y)!==y){Wt(),a.pingedLanes|=a.suspendedLanes&N;break}a.timeoutHandle=gh(aa.bind(null,a,Jt,Pr),c);break}aa(a,Jt,Pr);break;case 4:if(hs(a,y),(y&4194240)===y)break;for(c=a.eventTimes,N=-1;0<y;){var q=31-ln(y);C=1<<q,q=c[q],q>N&&(N=q),y&=~C}if(y=N,y=Ge()-y,y=(120>y?120:480>y?480:1080>y?1080:1920>y?1920:3e3>y?3e3:4320>y?4320:1960*TO(y/1960))-y,10<y){a.timeoutHandle=gh(aa.bind(null,a,Jt,Pr),y);break}aa(a,Jt,Pr);break;case 5:aa(a,Jt,Pr);break;default:throw Error(n(329))}}}return Qt(a,Ge()),a.callbackNode===p?zk.bind(null,a):null}function df(a,c){var p=zi;return a.current.memoizedState.isDehydrated&&(sa(a,c).flags|=256),a=qc(a,c),a!==2&&(c=Jt,Jt=p,c!==null&&hf(c)),a}function hf(a){Jt===null?Jt=a:Jt.push.apply(Jt,a)}function RO(a){for(var c=a;;){if(c.flags&16384){var p=c.updateQueue;if(p!==null&&(p=p.stores,p!==null))for(var y=0;y<p.length;y++){var N=p[y],C=N.getSnapshot;N=N.value;try{if(!Mn(C(),N))return!1}catch{return!1}}}if(p=c.child,c.subtreeFlags&16384&&p!==null)p.return=c,c=p;else{if(c===a)break;for(;c.sibling===null;){if(c.return===null||c.return===a)return!0;c=c.return}c.sibling.return=c.return,c=c.sibling}}return!0}function hs(a,c){for(c&=~of,c&=~Ic,a.suspendedLanes|=c,a.pingedLanes&=~c,a=a.expirationTimes;0<c;){var p=31-ln(c),y=1<<p;a[p]=-1,c&=~y}}function Uk(a){if((ze&6)!==0)throw Error(n(327));uo();var c=Da(a,0);if((c&1)===0)return Qt(a,Ge()),null;var p=qc(a,c);if(a.tag!==0&&p===2){var y=nr(a);y!==0&&(c=y,p=df(a,y))}if(p===1)throw p=Bi,sa(a,0),hs(a,c),Qt(a,Ge()),p;if(p===6)throw Error(n(345));return a.finishedWork=a.current.alternate,a.finishedLanes=c,aa(a,Jt,Pr),Qt(a,Ge()),null}function ff(a,c){var p=ze;ze|=1;try{return a(c)}finally{ze=p,ze===0&&(co=Ge()+500,fc&&as())}}function ra(a){us!==null&&us.tag===0&&(ze&6)===0&&uo();var c=ze;ze|=1;var p=bn.transition,y=He;try{if(bn.transition=null,He=1,a)return a()}finally{He=y,bn.transition=p,ze=c,(ze&6)===0&&as()}}function pf(){dn=lo.current,Qe(lo)}function sa(a,c){a.finishedWork=null,a.finishedLanes=0;var p=a.timeoutHandle;if(p!==-1&&(a.timeoutHandle=-1,oO(p)),mt!==null)for(p=mt.return;p!==null;){var y=p;switch(kh(y),y.tag){case 1:y=y.type.childContextTypes,y!=null&&dc();break;case 3:ao(),Qe(Yt),Qe(Dt),Oh();break;case 5:$h(y);break;case 4:ao();break;case 13:Qe(it);break;case 19:Qe(it);break;case 10:Ch(y.type._context);break;case 22:case 23:pf()}p=p.return}if(Tt=a,mt=a=fs(a.current,null),It=dn=c,kt=0,Bi=null,of=Ic=na=0,Jt=zi=null,Qs!==null){for(c=0;c<Qs.length;c++)if(p=Qs[c],y=p.interleaved,y!==null){p.interleaved=null;var N=y.next,C=p.pending;if(C!==null){var q=C.next;C.next=N,y.next=q}p.pending=y}Qs=null}return a}function Hk(a,c){do{var p=mt;try{if(Eh(),Nc.current=Ec,Sc){for(var y=lt.memoizedState;y!==null;){var N=y.queue;N!==null&&(N.pending=null),y=y.next}Sc=!1}if(ta=0,Ct=bt=lt=null,Oi=!1,Li=0,af.current=null,p===null||p.return===null){kt=1,Bi=c,mt=null;break}e:{var C=a,q=p.return,Q=p,te=c;if(c=It,Q.flags|=32768,te!==null&&typeof te=="object"&&typeof te.then=="function"){var le=te,he=Q,pe=he.tag;if((he.mode&1)===0&&(pe===0||pe===11||pe===15)){var de=he.alternate;de?(he.updateQueue=de.updateQueue,he.memoizedState=de.memoizedState,he.lanes=de.lanes):(he.updateQueue=null,he.memoizedState=null)}var be=mk(q);if(be!==null){be.flags&=-257,gk(be,q,Q,C,c),be.mode&1&&pk(C,le,c),c=be,te=le;var je=c.updateQueue;if(je===null){var _e=new Set;_e.add(te),c.updateQueue=_e}else je.add(te);break e}else{if((c&1)===0){pk(C,le,c),mf();break e}te=Error(n(426))}}else if(st&&Q.mode&1){var ft=mk(q);if(ft!==null){(ft.flags&65536)===0&&(ft.flags|=256),gk(ft,q,Q,C,c),jh(oo(te,Q));break e}}C=te=oo(te,Q),kt!==4&&(kt=2),zi===null?zi=[C]:zi.push(C),C=q;do{switch(C.tag){case 3:C.flags|=65536,c&=-c,C.lanes|=c;var ae=hk(C,te,c);Fb(C,ae);break e;case 1:Q=te;var ne=C.type,ie=C.stateNode;if((C.flags&128)===0&&(typeof ne.getDerivedStateFromError=="function"||ie!==null&&typeof ie.componentDidCatch=="function"&&(cs===null||!cs.has(ie)))){C.flags|=65536,c&=-c,C.lanes|=c;var me=fk(C,Q,c);Fb(C,me);break e}}C=C.return}while(C!==null)}Gk(p)}catch(Ee){c=Ee,mt===p&&p!==null&&(mt=p=p.return);continue}break}while(!0)}function Wk(){var a=$c.current;return $c.current=Ec,a===null?Ec:a}function mf(){(kt===0||kt===3||kt===2)&&(kt=4),Tt===null||(na&268435455)===0&&(Ic&268435455)===0||hs(Tt,It)}function qc(a,c){var p=ze;ze|=2;var y=Wk();(Tt!==a||It!==c)&&(Pr=null,sa(a,c));do try{AO();break}catch(N){Hk(a,N)}while(!0);if(Eh(),ze=p,$c.current=y,mt!==null)throw Error(n(261));return Tt=null,It=0,kt}function AO(){for(;mt!==null;)Vk(mt)}function MO(){for(;mt!==null&&!tr();)Vk(mt)}function Vk(a){var c=Xk(a.alternate,a,dn);a.memoizedProps=a.pendingProps,c===null?Gk(a):mt=c,af.current=null}function Gk(a){var c=a;do{var p=c.alternate;if(a=c.return,(c.flags&32768)===0){if(p=SO(p,c,dn),p!==null){mt=p;return}}else{if(p=jO(p,c),p!==null){p.flags&=32767,mt=p;return}if(a!==null)a.flags|=32768,a.subtreeFlags=0,a.deletions=null;else{kt=6,mt=null;return}}if(c=c.sibling,c!==null){mt=c;return}mt=c=a}while(c!==null);kt===0&&(kt=5)}function aa(a,c,p){var y=He,N=bn.transition;try{bn.transition=null,He=1,$O(a,c,p,y)}finally{bn.transition=N,He=y}return null}function $O(a,c,p,y){do uo();while(us!==null);if((ze&6)!==0)throw Error(n(327));p=a.finishedWork;var N=a.finishedLanes;if(p===null)return null;if(a.finishedWork=null,a.finishedLanes=0,p===a.current)throw Error(n(177));a.callbackNode=null,a.callbackPriority=0;var C=p.lanes|p.childLanes;if(li(a,C),a===Tt&&(mt=Tt=null,It=0),(p.subtreeFlags&2064)===0&&(p.flags&2064)===0||Lc||(Lc=!0,Zk(Sr,function(){return uo(),null})),C=(p.flags&15990)!==0,(p.subtreeFlags&15990)!==0||C){C=bn.transition,bn.transition=null;var q=He;He=1;var Q=ze;ze|=4,af.current=null,EO(a,p),Pk(p,a),QI(ph),Hs=!!fh,ph=fh=null,a.current=p,CO(p),Kr(),ze=Q,He=q,bn.transition=C}else a.current=p;if(Lc&&(Lc=!1,us=a,Pc=N),C=a.pendingLanes,C===0&&(cs=null),Ds(p.stateNode),Qt(a,Ge()),c!==null)for(y=a.onRecoverableError,p=0;p<c.length;p++)N=c[p],y(N.value,{componentStack:N.stack,digest:N.digest});if(Oc)throw Oc=!1,a=cf,cf=null,a;return(Pc&1)!==0&&a.tag!==0&&uo(),C=a.pendingLanes,(C&1)!==0?a===uf?Ui++:(Ui=0,uf=a):Ui=0,as(),null}function uo(){if(us!==null){var a=qa(Pc),c=bn.transition,p=He;try{if(bn.transition=null,He=16>a?16:a,us===null)var y=!1;else{if(a=us,us=null,Pc=0,(ze&6)!==0)throw Error(n(331));var N=ze;for(ze|=4,Se=a.current;Se!==null;){var C=Se,q=C.child;if((Se.flags&16)!==0){var Q=C.deletions;if(Q!==null){for(var te=0;te<Q.length;te++){var le=Q[te];for(Se=le;Se!==null;){var he=Se;switch(he.tag){case 0:case 11:case 15:qi(8,he,C)}var pe=he.child;if(pe!==null)pe.return=he,Se=pe;else for(;Se!==null;){he=Se;var de=he.sibling,be=he.return;if(Mk(he),he===le){Se=null;break}if(de!==null){de.return=be,Se=de;break}Se=be}}}var je=C.alternate;if(je!==null){var _e=je.child;if(_e!==null){je.child=null;do{var ft=_e.sibling;_e.sibling=null,_e=ft}while(_e!==null)}}Se=C}}if((C.subtreeFlags&2064)!==0&&q!==null)q.return=C,Se=q;else e:for(;Se!==null;){if(C=Se,(C.flags&2048)!==0)switch(C.tag){case 0:case 11:case 15:qi(9,C,C.return)}var ae=C.sibling;if(ae!==null){ae.return=C.return,Se=ae;break e}Se=C.return}}var ne=a.current;for(Se=ne;Se!==null;){q=Se;var ie=q.child;if((q.subtreeFlags&2064)!==0&&ie!==null)ie.return=q,Se=ie;else e:for(q=ne;Se!==null;){if(Q=Se,(Q.flags&2048)!==0)try{switch(Q.tag){case 0:case 11:case 15:Mc(9,Q)}}catch(Ee){dt(Q,Q.return,Ee)}if(Q===q){Se=null;break e}var me=Q.sibling;if(me!==null){me.return=Q.return,Se=me;break e}Se=Q.return}}if(ze=N,as(),pt&&typeof pt.onPostCommitFiberRoot=="function")try{pt.onPostCommitFiberRoot(jr,a)}catch{}y=!0}return y}finally{He=p,bn.transition=c}}return!1}function Kk(a,c,p){c=oo(p,c),c=hk(a,c,1),a=is(a,c,1),c=Wt(),a!==null&&(Xr(a,1,c),Qt(a,c))}function dt(a,c,p){if(a.tag===3)Kk(a,a,p);else for(;c!==null;){if(c.tag===3){Kk(c,a,p);break}else if(c.tag===1){var y=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof y.componentDidCatch=="function"&&(cs===null||!cs.has(y))){a=oo(p,a),a=fk(c,a,1),c=is(c,a,1),a=Wt(),c!==null&&(Xr(c,1,a),Qt(c,a));break}}c=c.return}}function IO(a,c,p){var y=a.pingCache;y!==null&&y.delete(c),c=Wt(),a.pingedLanes|=a.suspendedLanes&p,Tt===a&&(It&p)===p&&(kt===4||kt===3&&(It&130023424)===It&&500>Ge()-lf?sa(a,0):of|=p),Qt(a,c)}function Yk(a,c){c===0&&((a.mode&1)===0?c=1:(c=gn,gn<<=1,(gn&130023424)===0&&(gn=4194304)));var p=Wt();a=Ir(a,c),a!==null&&(Xr(a,c,p),Qt(a,p))}function OO(a){var c=a.memoizedState,p=0;c!==null&&(p=c.retryLane),Yk(a,p)}function LO(a,c){var p=0;switch(a.tag){case 13:var y=a.stateNode,N=a.memoizedState;N!==null&&(p=N.retryLane);break;case 19:y=a.stateNode;break;default:throw Error(n(314))}y!==null&&y.delete(c),Yk(a,p)}var Xk;Xk=function(a,c,p){if(a!==null)if(a.memoizedProps!==c.pendingProps||Yt.current)Zt=!0;else{if((a.lanes&p)===0&&(c.flags&128)===0)return Zt=!1,NO(a,c,p);Zt=(a.flags&131072)!==0}else Zt=!1,st&&(c.flags&1048576)!==0&&Tb(c,mc,c.index);switch(c.lanes=0,c.tag){case 2:var y=c.type;Rc(a,c),a=c.pendingProps;var N=Ja(c,Dt.current);so(c,p),N=Dh(null,c,y,a,N,p);var C=Fh();return c.flags|=1,typeof N=="object"&&N!==null&&typeof N.render=="function"&&N.$$typeof===void 0?(c.tag=1,c.memoizedState=null,c.updateQueue=null,Xt(y)?(C=!0,hc(c)):C=!1,c.memoizedState=N.state!==null&&N.state!==void 0?N.state:null,Ah(c),N.updater=Cc,c.stateNode=N,N._reactInternals=c,Wh(c,y,a,p),c=Yh(null,c,y,!0,C,p)):(c.tag=0,st&&C&&bh(c),Ht(null,c,N,p),c=c.child),c;case 16:y=c.elementType;e:{switch(Rc(a,c),a=c.pendingProps,N=y._init,y=N(y._payload),c.type=y,N=c.tag=DO(y),a=In(y,a),N){case 0:c=Kh(null,c,y,a,p);break e;case 1:c=kk(null,c,y,a,p);break e;case 11:c=yk(null,c,y,a,p);break e;case 14:c=wk(null,c,y,In(y.type,a),p);break e}throw Error(n(306,y,""))}return c;case 0:return y=c.type,N=c.pendingProps,N=c.elementType===y?N:In(y,N),Kh(a,c,y,N,p);case 1:return y=c.type,N=c.pendingProps,N=c.elementType===y?N:In(y,N),kk(a,c,y,N,p);case 3:e:{if(Nk(c),a===null)throw Error(n(387));y=c.pendingProps,C=c.memoizedState,N=C.element,Db(a,c),bc(c,y,null,p);var q=c.memoizedState;if(y=q.element,C.isDehydrated)if(C={element:y,isDehydrated:!1,cache:q.cache,pendingSuspenseBoundaries:q.pendingSuspenseBoundaries,transitions:q.transitions},c.updateQueue.baseState=C,c.memoizedState=C,c.flags&256){N=oo(Error(n(423)),c),c=Sk(a,c,y,p,N);break e}else if(y!==N){N=oo(Error(n(424)),c),c=Sk(a,c,y,p,N);break e}else for(un=ns(c.stateNode.containerInfo.firstChild),cn=c,st=!0,$n=null,p=Lb(c,null,y,p),c.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(to(),y===N){c=Lr(a,c,p);break e}Ht(a,c,y,p)}c=c.child}return c;case 5:return Bb(c),a===null&&Sh(c),y=c.type,N=c.pendingProps,C=a!==null?a.memoizedProps:null,q=N.children,mh(y,N)?q=null:C!==null&&mh(y,C)&&(c.flags|=32),bk(a,c),Ht(a,c,q,p),c.child;case 6:return a===null&&Sh(c),null;case 13:return jk(a,c,p);case 4:return Mh(c,c.stateNode.containerInfo),y=c.pendingProps,a===null?c.child=no(c,null,y,p):Ht(a,c,y,p),c.child;case 11:return y=c.type,N=c.pendingProps,N=c.elementType===y?N:In(y,N),yk(a,c,y,N,p);case 7:return Ht(a,c,c.pendingProps,p),c.child;case 8:return Ht(a,c,c.pendingProps.children,p),c.child;case 12:return Ht(a,c,c.pendingProps.children,p),c.child;case 10:e:{if(y=c.type._context,N=c.pendingProps,C=c.memoizedProps,q=N.value,Xe(wc,y._currentValue),y._currentValue=q,C!==null)if(Mn(C.value,q)){if(C.children===N.children&&!Yt.current){c=Lr(a,c,p);break e}}else for(C=c.child,C!==null&&(C.return=c);C!==null;){var Q=C.dependencies;if(Q!==null){q=C.child;for(var te=Q.firstContext;te!==null;){if(te.context===y){if(C.tag===1){te=Or(-1,p&-p),te.tag=2;var le=C.updateQueue;if(le!==null){le=le.shared;var he=le.pending;he===null?te.next=te:(te.next=he.next,he.next=te),le.pending=te}}C.lanes|=p,te=C.alternate,te!==null&&(te.lanes|=p),Th(C.return,p,c),Q.lanes|=p;break}te=te.next}}else if(C.tag===10)q=C.type===c.type?null:C.child;else if(C.tag===18){if(q=C.return,q===null)throw Error(n(341));q.lanes|=p,Q=q.alternate,Q!==null&&(Q.lanes|=p),Th(q,p,c),q=C.sibling}else q=C.child;if(q!==null)q.return=C;else for(q=C;q!==null;){if(q===c){q=null;break}if(C=q.sibling,C!==null){C.return=q.return,q=C;break}q=q.return}C=q}Ht(a,c,N.children,p),c=c.child}return c;case 9:return N=c.type,y=c.pendingProps.children,so(c,p),N=vn(N),y=y(N),c.flags|=1,Ht(a,c,y,p),c.child;case 14:return y=c.type,N=In(y,c.pendingProps),N=In(y.type,N),wk(a,c,y,N,p);case 15:return vk(a,c,c.type,c.pendingProps,p);case 17:return y=c.type,N=c.pendingProps,N=c.elementType===y?N:In(y,N),Rc(a,c),c.tag=1,Xt(y)?(a=!0,hc(c)):a=!1,so(c,p),uk(c,y,N),Wh(c,y,N,p),Yh(null,c,y,!0,a,p);case 19:return Ek(a,c,p);case 22:return xk(a,c,p)}throw Error(n(156,c.tag))};function Zk(a,c){return La(a,c)}function PO(a,c,p,y){this.tag=a,this.key=p,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 kn(a,c,p,y){return new PO(a,c,p,y)}function gf(a){return a=a.prototype,!(!a||!a.isReactComponent)}function DO(a){if(typeof a=="function")return gf(a)?1:0;if(a!=null){if(a=a.$$typeof,a===z)return 11;if(a===P)return 14}return 2}function fs(a,c){var p=a.alternate;return p===null?(p=kn(a.tag,c,a.key,a.mode),p.elementType=a.elementType,p.type=a.type,p.stateNode=a.stateNode,p.alternate=a,a.alternate=p):(p.pendingProps=c,p.type=a.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=a.flags&14680064,p.childLanes=a.childLanes,p.lanes=a.lanes,p.child=a.child,p.memoizedProps=a.memoizedProps,p.memoizedState=a.memoizedState,p.updateQueue=a.updateQueue,c=a.dependencies,p.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext},p.sibling=a.sibling,p.index=a.index,p.ref=a.ref,p}function Bc(a,c,p,y,N,C){var q=2;if(y=a,typeof a=="function")gf(a)&&(q=1);else if(typeof a=="string")q=5;else e:switch(a){case M:return oa(p.children,N,C,c);case O:q=8,N|=8;break;case I:return a=kn(12,p,c,N|2),a.elementType=I,a.lanes=C,a;case V:return a=kn(13,p,c,N),a.elementType=V,a.lanes=C,a;case $:return a=kn(19,p,c,N),a.elementType=$,a.lanes=C,a;case Y:return zc(p,N,C,c);default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case A:q=10;break e;case L:q=9;break e;case z:q=11;break e;case P:q=14;break e;case F:q=16,y=null;break e}throw Error(n(130,a==null?a:typeof a,""))}return c=kn(q,p,c,N),c.elementType=a,c.type=y,c.lanes=C,c}function oa(a,c,p,y){return a=kn(7,a,y,c),a.lanes=p,a}function zc(a,c,p,y){return a=kn(22,a,y,c),a.elementType=Y,a.lanes=p,a.stateNode={isHidden:!1},a}function yf(a,c,p){return a=kn(6,a,null,c),a.lanes=p,a}function wf(a,c,p){return c=kn(4,a.children!==null?a.children:[],a.key,c),c.lanes=p,c.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},c}function FO(a,c,p,y,N){this.tag=c,this.containerInfo=a,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Fa(0),this.expirationTimes=Fa(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Fa(0),this.identifierPrefix=y,this.onRecoverableError=N,this.mutableSourceEagerHydrationData=null}function vf(a,c,p,y,N,C,q,Q,te){return a=new FO(a,c,p,Q,te),c===1?(c=1,C===!0&&(c|=8)):c=0,C=kn(3,null,null,c),a.current=C,C.stateNode=a,C.memoizedState={element:y,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ah(C),a}function qO(a,c,p){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:R,key:y==null?null:""+y,children:a,containerInfo:c,implementation:p}}function Jk(a){if(!a)return ss;a=a._reactInternals;e:{if(Qn(a)!==a||a.tag!==1)throw Error(n(170));var c=a;do{switch(c.tag){case 3:c=c.stateNode.context;break e;case 1:if(Xt(c.type)){c=c.stateNode.__reactInternalMemoizedMergedChildContext;break e}}c=c.return}while(c!==null);throw Error(n(171))}if(a.tag===1){var p=a.type;if(Xt(p))return _b(a,p,c)}return c}function Qk(a,c,p,y,N,C,q,Q,te){return a=vf(p,y,!0,a,N,C,q,Q,te),a.context=Jk(null),p=a.current,y=Wt(),N=ds(p),C=Or(y,N),C.callback=c??null,is(p,C,N),a.current.lanes=N,Xr(a,N,y),Qt(a,y),a}function Uc(a,c,p,y){var N=c.current,C=Wt(),q=ds(N);return p=Jk(p),c.context===null?c.context=p:c.pendingContext=p,c=Or(C,q),c.payload={element:a},y=y===void 0?null:y,y!==null&&(c.callback=y),a=is(N,c,q),a!==null&&(Pn(a,N,q,C),xc(a,N,q)),q}function Hc(a){if(a=a.current,!a.child)return null;switch(a.child.tag){case 5:return a.child.stateNode;default:return a.child.stateNode}}function e1(a,c){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var p=a.retryLane;a.retryLane=p!==0&&p<c?p:c}}function xf(a,c){e1(a,c),(a=a.alternate)&&e1(a,c)}function BO(){return null}var t1=typeof reportError=="function"?reportError:function(a){console.error(a)};function bf(a){this._internalRoot=a}Wc.prototype.render=bf.prototype.render=function(a){var c=this._internalRoot;if(c===null)throw Error(n(409));Uc(a,c,null,null)},Wc.prototype.unmount=bf.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var c=a.containerInfo;ra(function(){Uc(null,a,null,null)}),c[Rr]=null}};function Wc(a){this._internalRoot=a}Wc.prototype.unstable_scheduleHydration=function(a){if(a){var c=Ql();a={blockedOn:null,target:a,priority:c};for(var p=0;p<or.length&&c!==0&&c<or[p].priority;p++);or.splice(p,0,a),p===0&&fi(a)}};function kf(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function Vc(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11&&(a.nodeType!==8||a.nodeValue!==" react-mount-point-unstable "))}function n1(){}function zO(a,c,p,y,N){if(N){if(typeof y=="function"){var C=y;y=function(){var le=Hc(q);C.call(le)}}var q=Qk(c,y,a,0,null,!1,!1,"",n1);return a._reactRootContainer=q,a[Rr]=q.current,Ei(a.nodeType===8?a.parentNode:a),ra(),q}for(;N=a.lastChild;)a.removeChild(N);if(typeof y=="function"){var Q=y;y=function(){var le=Hc(te);Q.call(le)}}var te=vf(a,0,!1,null,null,!1,!1,"",n1);return a._reactRootContainer=te,a[Rr]=te.current,Ei(a.nodeType===8?a.parentNode:a),ra(function(){Uc(c,te,p,y)}),te}function Gc(a,c,p,y,N){var C=p._reactRootContainer;if(C){var q=C;if(typeof N=="function"){var Q=N;N=function(){var te=Hc(q);Q.call(te)}}Uc(c,q,a,N)}else q=zO(p,c,a,N,y);return Hc(q)}ui=function(a){switch(a.tag){case 3:var c=a.stateNode;if(c.current.memoizedState.isDehydrated){var p=Fs(c.pendingLanes);p!==0&&(ci(c,p|1),Qt(c,Ge()),(ze&6)===0&&(co=Ge()+500,as()))}break;case 13:ra(function(){var y=Ir(a,1);if(y!==null){var N=Wt();Pn(y,a,1,N)}}),xf(a,1)}},di=function(a){if(a.tag===13){var c=Ir(a,134217728);if(c!==null){var p=Wt();Pn(c,a,134217728,p)}xf(a,134217728)}},Jl=function(a){if(a.tag===13){var c=ds(a),p=Ir(a,c);if(p!==null){var y=Wt();Pn(p,a,c,y)}xf(a,c)}},Ql=function(){return He},Ba=function(a,c){var p=He;try{return He=a,c()}finally{He=p}},Kt=function(a,c,p){switch(c){case"input":if(ye(a,p),c=p.name,p.type==="radio"&&c!=null){for(p=a;p.parentNode;)p=p.parentNode;for(p=p.querySelectorAll("input[name="+JSON.stringify(""+c)+'][type="radio"]'),c=0;c<p.length;c++){var y=p[c];if(y!==a&&y.form===a.form){var N=uc(y);if(!N)throw Error(n(90));Ne(y),ye(y,N)}}}break;case"textarea":qe(a,p);break;case"select":c=p.value,c!=null&&Ae(a,!!p.multiple,c,!1)}},Aa=ff,Rs=ra;var UO={usingClientEntryPoint:!1,Events:[Ri,Xa,uc,Xn,Ra,ff]},Hi={findFiberByHostInstance:Ys,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},HO={bundleType:Hi.bundleType,version:Hi.version,rendererPackageName:Hi.rendererPackageName,rendererConfig:Hi.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:E.ReactCurrentDispatcher,findHostInstanceByFiber:function(a){return a=Oa(a),a===null?null:a.stateNode},findFiberByHostInstance:Hi.findFiberByHostInstance||BO,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 Kc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Kc.isDisabled&&Kc.supportsFiber)try{jr=Kc.inject(HO),pt=Kc}catch{}}return en.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=UO,en.createPortal=function(a,c){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!kf(c))throw Error(n(200));return qO(a,c,null,p)},en.createRoot=function(a,c){if(!kf(a))throw Error(n(299));var p=!1,y="",N=t1;return c!=null&&(c.unstable_strictMode===!0&&(p=!0),c.identifierPrefix!==void 0&&(y=c.identifierPrefix),c.onRecoverableError!==void 0&&(N=c.onRecoverableError)),c=vf(a,1,!1,null,null,p,!1,y,N),a[Rr]=c.current,Ei(a.nodeType===8?a.parentNode:a),new bf(c)},en.findDOMNode=function(a){if(a==null)return null;if(a.nodeType===1)return a;var c=a._reactInternals;if(c===void 0)throw typeof a.render=="function"?Error(n(188)):(a=Object.keys(a).join(","),Error(n(268,a)));return a=Oa(c),a=a===null?null:a.stateNode,a},en.flushSync=function(a){return ra(a)},en.hydrate=function(a,c,p){if(!Vc(c))throw Error(n(200));return Gc(null,a,c,!0,p)},en.hydrateRoot=function(a,c,p){if(!kf(a))throw Error(n(405));var y=p!=null&&p.hydratedSources||null,N=!1,C="",q=t1;if(p!=null&&(p.unstable_strictMode===!0&&(N=!0),p.identifierPrefix!==void 0&&(C=p.identifierPrefix),p.onRecoverableError!==void 0&&(q=p.onRecoverableError)),c=Qk(c,null,a,1,p??null,N,!1,C,q),a[Rr]=c.current,Ei(a),y)for(a=0;a<y.length;a++)p=y[a],N=p._getVersion,N=N(p._source),c.mutableSourceEagerHydrationData==null?c.mutableSourceEagerHydrationData=[p,N]:c.mutableSourceEagerHydrationData.push(p,N);return new Wc(c)},en.render=function(a,c,p){if(!Vc(c))throw Error(n(200));return Gc(null,a,c,!1,p)},en.unmountComponentAtNode=function(a){if(!Vc(a))throw Error(n(40));return a._reactRootContainer?(ra(function(){Gc(null,null,a,!1,function(){a._reactRootContainer=null,a[Rr]=null})}),!0):!1},en.unstable_batchedUpdates=ff,en.unstable_renderSubtreeIntoContainer=function(a,c,p,y){if(!Vc(p))throw Error(n(200));if(a==null||a._reactInternals===void 0)throw Error(n(38));return Gc(a,c,p,!1,y)},en.version="18.3.1-next-f1338f8080-20240426",en}var u1;function _2(){if(u1)return jf.exports;u1=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(),jf.exports=ZO(),jf.exports}var d1;function JO(){if(d1)return Xc;d1=1;var e=_2();return Xc.createRoot=e.createRoot,Xc.hydrateRoot=e.hydrateRoot,Xc}var QO=JO(),x=Il();const ce=jx(x);function Ot(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=Ot(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Cf={exports:{}},Tf={},Rf={exports:{}},Af={};/**
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 h1;function eL(){if(h1)return Af;h1=1;var e=Il();function t(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&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(m,g){var w=g(),k=r({inst:{value:w,getSnapshot:g}}),v=k[0].inst,b=k[1];return o(function(){v.value=w,v.getSnapshot=g,d(v)&&b({inst:v})},[m,w,g]),s(function(){return d(v)&&b({inst:v}),m(function(){d(v)&&b({inst:v})})},[m]),l(w),w}function d(m){var g=m.getSnapshot;m=m.value;try{var w=g();return!n(m,w)}catch{return!0}}function f(m,g){return g()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:u;return Af.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:h,Af}var f1;function tL(){return f1||(f1=1,Rf.exports=eL()),Rf.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 p1;function nL(){if(p1)return Tf;p1=1;var e=Il(),t=tL();function n(f,h){return f===h&&(f!==0||1/f===1/h)||f!==f&&h!==h}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 Tf.useSyncExternalStoreWithSelector=function(f,h,m,g,w){var k=o(null);if(k.current===null){var v={hasValue:!1,value:null};k.current=v}else v=k.current;k=u(function(){function S(R){if(!_){if(_=!0,j=R,R=g(R),w!==void 0&&v.hasValue){var M=v.value;if(w(M,R))return E=M}return E=R}if(M=E,r(j,R))return M;var O=g(R);return w!==void 0&&w(M,O)?(j=R,M):(j=R,E=O)}var _=!1,j,E,T=m===void 0?null:m;return[function(){return S(h())},T===null?void 0:function(){return S(T())}]},[h,m,g,w]);var b=s(f,k[0],k[1]);return l(function(){v.hasValue=!0,v.value=b},[b]),d(b),b},Tf}var m1;function rL(){return m1||(m1=1,Cf.exports=nL()),Cf.exports}var sL=rL();const aL=jx(sL),oL={},g1=e=>{let t;const n=new Set,r=(h,m)=>{const g=typeof h=="function"?h(t):h;if(!Object.is(g,t)){const w=t;t=m??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(k=>k(t,w))}},s=()=>t,d={setState:r,getState:s,getInitialState:()=>f,subscribe:h=>(n.add(h),()=>n.delete(h)),destroy:()=>{(oL?"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()}},f=t=e(r,s,d);return d},iL=e=>e?g1(e):g1,{useDebugValue:lL}=ce,{useSyncExternalStoreWithSelector:cL}=aL,uL=e=>e;function E2(e,t=uL,n){const r=cL(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return lL(r),r}const y1=(e,t)=>{const n=iL(e),r=(s,o=t)=>E2(n,s,o);return Object.assign(r,n),r},dL=(e,t)=>e?y1(e,t):y1;function _t(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[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 hL={value:()=>{}};function id(){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 vu(n)}function vu(e){this._=e}function fL(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}})}vu.prototype=id.prototype={constructor:vu,on:function(e,t){var n=this._,r=fL(e+"",n),s,o=-1,l=r.length;if(arguments.length<2){for(;++o<l;)if((s=(e=r[o]).type)&&(s=pL(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]=w1(n[s],e.name,t);else if(t==null)for(s in n)n[s]=w1(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 vu(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 pL(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function w1(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=hL,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var jv="http://www.w3.org/1999/xhtml";const v1={svg:"http://www.w3.org/2000/svg",xhtml:jv,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ld(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),v1.hasOwnProperty(t)?{space:v1[t],local:e}:e}function mL(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===jv&&t.documentElement.namespaceURI===jv?t.createElement(e):t.createElementNS(n,e)}}function gL(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function C2(e){var t=ld(e);return(t.local?gL:mL)(t)}function yL(){}function _x(e){return e==null?yL:function(){return this.querySelector(e)}}function wL(e){typeof e!="function"&&(e=_x(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,f,h=0;h<l;++h)(d=o[h])&&(f=e.call(d,d.__data__,h,o))&&("__data__"in d&&(f.__data__=d.__data__),u[h]=f);return new mn(r,this._parents)}function vL(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function xL(){return[]}function T2(e){return e==null?xL:function(){return this.querySelectorAll(e)}}function bL(e){return function(){return vL(e.apply(this,arguments))}}function kL(e){typeof e=="function"?e=bL(e):e=T2(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,f=0;f<u;++f)(d=l[f])&&(r.push(e.call(d,d.__data__,f,l)),s.push(d));return new mn(r,s)}function R2(e){return function(){return this.matches(e)}}function A2(e){return function(t){return t.matches(e)}}var NL=Array.prototype.find;function SL(e){return function(){return NL.call(this.children,e)}}function jL(){return this.firstElementChild}function _L(e){return this.select(e==null?jL:SL(typeof e=="function"?e:A2(e)))}var EL=Array.prototype.filter;function CL(){return Array.from(this.children)}function TL(e){return function(){return EL.call(this.children,e)}}function RL(e){return this.selectAll(e==null?CL:TL(typeof e=="function"?e:A2(e)))}function AL(e){typeof e!="function"&&(e=R2(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,f=0;f<l;++f)(d=o[f])&&e.call(d,d.__data__,f,o)&&u.push(d);return new mn(r,this._parents)}function M2(e){return new Array(e.length)}function ML(){return new mn(this._enter||this._groups.map(M2),this._parents)}function Mu(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Mu.prototype={constructor:Mu,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 $L(e){return function(){return e}}function IL(e,t,n,r,s,o){for(var l=0,u,d=t.length,f=o.length;l<f;++l)(u=t[l])?(u.__data__=o[l],r[l]=u):n[l]=new Mu(e,o[l]);for(;l<d;++l)(u=t[l])&&(s[l]=u)}function OL(e,t,n,r,s,o,l){var u,d,f=new Map,h=t.length,m=o.length,g=new Array(h),w;for(u=0;u<h;++u)(d=t[u])&&(g[u]=w=l.call(d,d.__data__,u,t)+"",f.has(w)?s[u]=d:f.set(w,d));for(u=0;u<m;++u)w=l.call(e,o[u],u,o)+"",(d=f.get(w))?(r[u]=d,d.__data__=o[u],f.delete(w)):n[u]=new Mu(e,o[u]);for(u=0;u<h;++u)(d=t[u])&&f.get(g[u])===d&&(s[u]=d)}function LL(e){return e.__data__}function PL(e,t){if(!arguments.length)return Array.from(this,LL);var n=t?OL:IL,r=this._parents,s=this._groups;typeof e!="function"&&(e=$L(e));for(var o=s.length,l=new Array(o),u=new Array(o),d=new Array(o),f=0;f<o;++f){var h=r[f],m=s[f],g=m.length,w=DL(e.call(h,h&&h.__data__,f,r)),k=w.length,v=u[f]=new Array(k),b=l[f]=new Array(k),S=d[f]=new Array(g);n(h,m,v,b,S,w,t);for(var _=0,j=0,E,T;_<k;++_)if(E=v[_]){for(_>=j&&(j=_+1);!(T=b[j])&&++j<k;);E._next=T||null}}return l=new mn(l,r),l._enter=u,l._exit=d,l}function DL(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function FL(){return new mn(this._exit||this._groups.map(M2),this._parents)}function qL(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 BL(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 f=n[d],h=r[d],m=f.length,g=u[d]=new Array(m),w,k=0;k<m;++k)(w=f[k]||h[k])&&(g[k]=w);for(;d<s;++d)u[d]=n[d];return new mn(u,this._parents)}function zL(){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 UL(e){e||(e=HL);function t(m,g){return m&&g?e(m.__data__,g.__data__):!m-!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),f,h=0;h<u;++h)(f=l[h])&&(d[h]=f);d.sort(t)}return new mn(s,this._parents).order()}function HL(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function WL(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function VL(){return Array.from(this)}function GL(){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 KL(){let e=0;for(const t of this)++e;return e}function YL(){return!this.node()}function XL(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 ZL(e){return function(){this.removeAttribute(e)}}function JL(e){return function(){this.removeAttributeNS(e.space,e.local)}}function QL(e,t){return function(){this.setAttribute(e,t)}}function eP(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function tP(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function nP(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 rP(e,t){var n=ld(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?JL:ZL:typeof t=="function"?n.local?nP:tP:n.local?eP:QL)(n,t))}function $2(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function sP(e){return function(){this.style.removeProperty(e)}}function aP(e,t,n){return function(){this.style.setProperty(e,t,n)}}function oP(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function iP(e,t,n){return arguments.length>1?this.each((t==null?sP:typeof t=="function"?oP:aP)(e,t,n??"")):Lo(this.node(),e)}function Lo(e,t){return e.style.getPropertyValue(t)||$2(e).getComputedStyle(e,null).getPropertyValue(t)}function lP(e){return function(){delete this[e]}}function cP(e,t){return function(){this[e]=t}}function uP(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function dP(e,t){return arguments.length>1?this.each((t==null?lP:typeof t=="function"?uP:cP)(e,t)):this.node()[e]}function I2(e){return e.trim().split(/^|\s+/)}function Ex(e){return e.classList||new O2(e)}function O2(e){this._node=e,this._names=I2(e.getAttribute("class")||"")}O2.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 L2(e,t){for(var n=Ex(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function P2(e,t){for(var n=Ex(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function hP(e){return function(){L2(this,e)}}function fP(e){return function(){P2(this,e)}}function pP(e,t){return function(){(t.apply(this,arguments)?L2:P2)(this,e)}}function mP(e,t){var n=I2(e+"");if(arguments.length<2){for(var r=Ex(this.node()),s=-1,o=n.length;++s<o;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?pP:t?hP:fP)(n,t))}function gP(){this.textContent=""}function yP(e){return function(){this.textContent=e}}function wP(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function vP(e){return arguments.length?this.each(e==null?gP:(typeof e=="function"?wP:yP)(e)):this.node().textContent}function xP(){this.innerHTML=""}function bP(e){return function(){this.innerHTML=e}}function kP(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function NP(e){return arguments.length?this.each(e==null?xP:(typeof e=="function"?kP:bP)(e)):this.node().innerHTML}function SP(){this.nextSibling&&this.parentNode.appendChild(this)}function jP(){return this.each(SP)}function _P(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function EP(){return this.each(_P)}function CP(e){var t=typeof e=="function"?e:C2(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function TP(){return null}function RP(e,t){var n=typeof e=="function"?e:C2(e),r=t==null?TP:typeof t=="function"?t:_x(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function AP(){var e=this.parentNode;e&&e.removeChild(this)}function MP(){return this.each(AP)}function $P(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function IP(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function OP(e){return this.select(e?IP:$P)}function LP(e){return arguments.length?this.property("__data__",e):this.node().__data__}function PP(e){return function(t){e.call(this,t,this.__data__)}}function DP(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 FP(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 qP(e,t,n){return function(){var r=this.__on,s,o=PP(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 BP(e,t,n){var r=DP(e+""),s,o=r.length,l;if(arguments.length<2){var u=this.node().__on;if(u){for(var d=0,f=u.length,h;d<f;++d)for(s=0,h=u[d];s<o;++s)if((l=r[s]).type===h.type&&l.name===h.name)return h.value}return}for(u=t?qP:FP,s=0;s<o;++s)this.each(u(r[s],t,n));return this}function D2(e,t,n){var r=$2(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 zP(e,t){return function(){return D2(this,e,t)}}function UP(e,t){return function(){return D2(this,e,t.apply(this,arguments))}}function HP(e,t){return this.each((typeof t=="function"?UP:zP)(e,t))}function*WP(){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 F2=[null];function mn(e,t){this._groups=e,this._parents=t}function Ol(){return new mn([[document.documentElement]],F2)}function VP(){return this}mn.prototype=Ol.prototype={constructor:mn,select:wL,selectAll:kL,selectChild:_L,selectChildren:RL,filter:AL,data:PL,enter:ML,exit:FL,join:qL,merge:BL,selection:VP,order:zL,sort:UL,call:WL,nodes:VL,node:GL,size:KL,empty:YL,each:XL,attr:rP,style:iP,property:dP,classed:mP,text:vP,html:NP,raise:jP,lower:EP,append:CP,insert:RP,remove:MP,clone:OP,datum:LP,on:BP,dispatch:HP,[Symbol.iterator]:WP};function jn(e){return typeof e=="string"?new mn([[document.querySelector(e)]],[document.documentElement]):new mn([[e]],F2)}function GP(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Fn(e,t){if(e=GP(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 KP={passive:!1},dl={capture:!0,passive:!1};function Mf(e){e.stopImmediatePropagation()}function Ro(e){e.preventDefault(),e.stopImmediatePropagation()}function q2(e){var t=e.document.documentElement,n=jn(e).on("dragstart.drag",Ro,dl);"onselectstart"in t?n.on("selectstart.drag",Ro,dl):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function B2(e,t){var n=e.document.documentElement,r=jn(e).on("dragstart.drag",null);t&&(r.on("click.drag",Ro,dl),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 Zc=e=>()=>e;function _v(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:o,x:l,y:u,dx:d,dy:f,dispatch:h}){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:f,enumerable:!0,configurable:!0},_:{value:h}})}_v.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function YP(e){return!e.ctrlKey&&!e.button}function XP(){return this.parentNode}function ZP(e,t){return t??{x:e.x,y:e.y}}function JP(){return navigator.maxTouchPoints||"ontouchstart"in this}function QP(){var e=YP,t=XP,n=ZP,r=JP,s={},o=id("start","drag","end"),l=0,u,d,f,h,m=0;function g(E){E.on("mousedown.drag",w).filter(r).on("touchstart.drag",b).on("touchmove.drag",S,KP).on("touchend.drag touchcancel.drag",_).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function w(E,T){if(!(h||!e.call(this,E,T))){var R=j(this,t.call(this,E,T),E,T,"mouse");R&&(jn(E.view).on("mousemove.drag",k,dl).on("mouseup.drag",v,dl),q2(E.view),Mf(E),f=!1,u=E.clientX,d=E.clientY,R("start",E))}}function k(E){if(Ro(E),!f){var T=E.clientX-u,R=E.clientY-d;f=T*T+R*R>m}s.mouse("drag",E)}function v(E){jn(E.view).on("mousemove.drag mouseup.drag",null),B2(E.view,f),Ro(E),s.mouse("end",E)}function b(E,T){if(e.call(this,E,T)){var R=E.changedTouches,M=t.call(this,E,T),O=R.length,I,A;for(I=0;I<O;++I)(A=j(this,M,E,T,R[I].identifier,R[I]))&&(Mf(E),A("start",E,R[I]))}}function S(E){var T=E.changedTouches,R=T.length,M,O;for(M=0;M<R;++M)(O=s[T[M].identifier])&&(Ro(E),O("drag",E,T[M]))}function _(E){var T=E.changedTouches,R=T.length,M,O;for(h&&clearTimeout(h),h=setTimeout(function(){h=null},500),M=0;M<R;++M)(O=s[T[M].identifier])&&(Mf(E),O("end",E,T[M]))}function j(E,T,R,M,O,I){var A=o.copy(),L=Fn(I||R,T),z,V,$;if(($=n.call(E,new _v("beforestart",{sourceEvent:R,target:g,identifier:O,active:l,x:L[0],y:L[1],dx:0,dy:0,dispatch:A}),M))!=null)return z=$.x-L[0]||0,V=$.y-L[1]||0,function P(F,Y,K){var D=L,W;switch(F){case"start":s[O]=P,W=l++;break;case"end":delete s[O],--l;case"drag":L=Fn(K||Y,T),W=l;break}A.call(F,E,new _v(F,{sourceEvent:Y,subject:$,target:g,identifier:O,active:W,x:L[0]+z,y:L[1]+V,dx:L[0]-D[0],dy:L[1]-D[1],dispatch:A}),M)}}return g.filter=function(E){return arguments.length?(e=typeof E=="function"?E:Zc(!!E),g):e},g.container=function(E){return arguments.length?(t=typeof E=="function"?E:Zc(E),g):t},g.subject=function(E){return arguments.length?(n=typeof E=="function"?E:Zc(E),g):n},g.touchable=function(E){return arguments.length?(r=typeof E=="function"?E:Zc(!!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?(m=(E=+E)*E,g):Math.sqrt(m)},g}function Cx(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function z2(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Ll(){}var hl=.7,$u=1/hl,Ao="\\s*([+-]?\\d+)\\s*",fl="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",mr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",e3=/^#([0-9a-f]{3,8})$/,t3=new RegExp(`^rgb\\(${Ao},${Ao},${Ao}\\)$`),n3=new RegExp(`^rgb\\(${mr},${mr},${mr}\\)$`),r3=new RegExp(`^rgba\\(${Ao},${Ao},${Ao},${fl}\\)$`),s3=new RegExp(`^rgba\\(${mr},${mr},${mr},${fl}\\)$`),a3=new RegExp(`^hsl\\(${fl},${mr},${mr}\\)$`),o3=new RegExp(`^hsla\\(${fl},${mr},${mr},${fl}\\)$`),x1={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};Cx(Ll,pl,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:b1,formatHex:b1,formatHex8:i3,formatHsl:l3,formatRgb:k1,toString:k1});function b1(){return this.rgb().formatHex()}function i3(){return this.rgb().formatHex8()}function l3(){return U2(this).formatHsl()}function k1(){return this.rgb().formatRgb()}function pl(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=e3.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?N1(t):n===3?new nn(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Jc(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Jc(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=t3.exec(e))?new nn(t[1],t[2],t[3],1):(t=n3.exec(e))?new nn(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=r3.exec(e))?Jc(t[1],t[2],t[3],t[4]):(t=s3.exec(e))?Jc(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=a3.exec(e))?_1(t[1],t[2]/100,t[3]/100,1):(t=o3.exec(e))?_1(t[1],t[2]/100,t[3]/100,t[4]):x1.hasOwnProperty(e)?N1(x1[e]):e==="transparent"?new nn(NaN,NaN,NaN,0):null}function N1(e){return new nn(e>>16&255,e>>8&255,e&255,1)}function Jc(e,t,n,r){return r<=0&&(e=t=n=NaN),new nn(e,t,n,r)}function c3(e){return e instanceof Ll||(e=pl(e)),e?(e=e.rgb(),new nn(e.r,e.g,e.b,e.opacity)):new nn}function Ev(e,t,n,r){return arguments.length===1?c3(e):new nn(e,t,n,r??1)}function nn(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Cx(nn,Ev,z2(Ll,{brighter(e){return e=e==null?$u:Math.pow($u,e),new nn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?hl:Math.pow(hl,e),new nn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new nn(pa(this.r),pa(this.g),pa(this.b),Iu(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:S1,formatHex:S1,formatHex8:u3,formatRgb:j1,toString:j1}));function S1(){return`#${da(this.r)}${da(this.g)}${da(this.b)}`}function u3(){return`#${da(this.r)}${da(this.g)}${da(this.b)}${da((isNaN(this.opacity)?1:this.opacity)*255)}`}function j1(){const e=Iu(this.opacity);return`${e===1?"rgb(":"rgba("}${pa(this.r)}, ${pa(this.g)}, ${pa(this.b)}${e===1?")":`, ${e})`}`}function Iu(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function pa(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function da(e){return e=pa(e),(e<16?"0":"")+e.toString(16)}function _1(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Bn(e,t,n,r)}function U2(e){if(e instanceof Bn)return new Bn(e.h,e.s,e.l,e.opacity);if(e instanceof Ll||(e=pl(e)),!e)return new Bn;if(e instanceof Bn)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 Bn(l,u,d,e.opacity)}function d3(e,t,n,r){return arguments.length===1?U2(e):new Bn(e,t,n,r??1)}function Bn(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Cx(Bn,d3,z2(Ll,{brighter(e){return e=e==null?$u:Math.pow($u,e),new Bn(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?hl:Math.pow(hl,e),new Bn(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 nn($f(e>=240?e-240:e+120,s,r),$f(e,s,r),$f(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new Bn(E1(this.h),Qc(this.s),Qc(this.l),Iu(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=Iu(this.opacity);return`${e===1?"hsl(":"hsla("}${E1(this.h)}, ${Qc(this.s)*100}%, ${Qc(this.l)*100}%${e===1?")":`, ${e})`}`}}));function E1(e){return e=(e||0)%360,e<0?e+360:e}function Qc(e){return Math.max(0,Math.min(1,e||0))}function $f(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 H2=e=>()=>e;function h3(e,t){return function(n){return e+n*t}}function f3(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 p3(e){return(e=+e)==1?W2:function(t,n){return n-t?f3(t,n,e):H2(isNaN(t)?n:t)}}function W2(e,t){var n=t-e;return n?h3(e,n):H2(isNaN(e)?t:e)}const C1=(function e(t){var n=p3(t);function r(s,o){var l=n((s=Ev(s)).r,(o=Ev(o)).r),u=n(s.g,o.g),d=n(s.b,o.b),f=W2(s.opacity,o.opacity);return function(h){return s.r=l(h),s.g=u(h),s.b=d(h),s.opacity=f(h),s+""}}return r.gamma=e,r})(1);function ys(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Cv=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,If=new RegExp(Cv.source,"g");function m3(e){return function(){return e}}function g3(e){return function(t){return e(t)+""}}function y3(e,t){var n=Cv.lastIndex=If.lastIndex=0,r,s,o,l=-1,u=[],d=[];for(e=e+"",t=t+"";(r=Cv.exec(e))&&(s=If.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:ys(r,s)})),n=If.lastIndex;return n<t.length&&(o=t.slice(n),u[l]?u[l]+=o:u[++l]=o),u.length<2?d[0]?g3(d[0].x):m3(t):(t=d.length,function(f){for(var h=0,m;h<t;++h)u[(m=d[h]).i]=m.x(f);return u.join("")})}var T1=180/Math.PI,Tv={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function V2(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)*T1,skewX:Math.atan(d)*T1,scaleX:l,scaleY:u}}var eu;function w3(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Tv:V2(t.a,t.b,t.c,t.d,t.e,t.f)}function v3(e){return e==null||(eu||(eu=document.createElementNS("http://www.w3.org/2000/svg","g")),eu.setAttribute("transform",e),!(e=eu.transform.baseVal.consolidate()))?Tv:(e=e.matrix,V2(e.a,e.b,e.c,e.d,e.e,e.f))}function G2(e,t,n,r){function s(f){return f.length?f.pop()+" ":""}function o(f,h,m,g,w,k){if(f!==m||h!==g){var v=w.push("translate(",null,t,null,n);k.push({i:v-4,x:ys(f,m)},{i:v-2,x:ys(h,g)})}else(m||g)&&w.push("translate("+m+t+g+n)}function l(f,h,m,g){f!==h?(f-h>180?h+=360:h-f>180&&(f+=360),g.push({i:m.push(s(m)+"rotate(",null,r)-2,x:ys(f,h)})):h&&m.push(s(m)+"rotate("+h+r)}function u(f,h,m,g){f!==h?g.push({i:m.push(s(m)+"skewX(",null,r)-2,x:ys(f,h)}):h&&m.push(s(m)+"skewX("+h+r)}function d(f,h,m,g,w,k){if(f!==m||h!==g){var v=w.push(s(w)+"scale(",null,",",null,")");k.push({i:v-4,x:ys(f,m)},{i:v-2,x:ys(h,g)})}else(m!==1||g!==1)&&w.push(s(w)+"scale("+m+","+g+")")}return function(f,h){var m=[],g=[];return f=e(f),h=e(h),o(f.translateX,f.translateY,h.translateX,h.translateY,m,g),l(f.rotate,h.rotate,m,g),u(f.skewX,h.skewX,m,g),d(f.scaleX,f.scaleY,h.scaleX,h.scaleY,m,g),f=h=null,function(w){for(var k=-1,v=g.length,b;++k<v;)m[(b=g[k]).i]=b.x(w);return m.join("")}}}var x3=G2(w3,"px, ","px)","deg)"),b3=G2(v3,", ",")",")"),k3=1e-12;function R1(e){return((e=Math.exp(e))+1/e)/2}function N3(e){return((e=Math.exp(e))-1/e)/2}function S3(e){return((e=Math.exp(2*e))-1)/(e+1)}const j3=(function e(t,n,r){function s(o,l){var u=o[0],d=o[1],f=o[2],h=l[0],m=l[1],g=l[2],w=h-u,k=m-d,v=w*w+k*k,b,S;if(v<k3)S=Math.log(g/f)/t,b=function(M){return[u+M*w,d+M*k,f*Math.exp(t*M*S)]};else{var _=Math.sqrt(v),j=(g*g-f*f+r*v)/(2*f*n*_),E=(g*g-f*f-r*v)/(2*g*n*_),T=Math.log(Math.sqrt(j*j+1)-j),R=Math.log(Math.sqrt(E*E+1)-E);S=(R-T)/t,b=function(M){var O=M*S,I=R1(T),A=f/(n*_)*(I*S3(t*O+T)-N3(T));return[u+A*w,d+A*k,f*I/R1(t*O+T)]}}return b.duration=S*1e3*t/Math.SQRT2,b}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 Po=0,el=0,Vi=0,K2=1e3,Ou,tl,Lu=0,wa=0,cd=0,ml=typeof performance=="object"&&performance.now?performance:Date,Y2=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Tx(){return wa||(Y2(_3),wa=ml.now()+cd)}function _3(){wa=0}function Pu(){this._call=this._time=this._next=null}Pu.prototype=X2.prototype={constructor:Pu,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Tx():+n)+(t==null?0:+t),!this._next&&tl!==this&&(tl?tl._next=this:Ou=this,tl=this),this._call=e,this._time=n,Rv()},stop:function(){this._call&&(this._call=null,this._time=1/0,Rv())}};function X2(e,t,n){var r=new Pu;return r.restart(e,t,n),r}function E3(){Tx(),++Po;for(var e=Ou,t;e;)(t=wa-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Po}function A1(){wa=(Lu=ml.now())+cd,Po=el=0;try{E3()}finally{Po=0,T3(),wa=0}}function C3(){var e=ml.now(),t=e-Lu;t>K2&&(cd-=t,Lu=e)}function T3(){for(var e,t=Ou,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:Ou=n);tl=e,Rv(r)}function Rv(e){if(!Po){el&&(el=clearTimeout(el));var t=e-wa;t>24?(e<1/0&&(el=setTimeout(A1,e-ml.now()-cd)),Vi&&(Vi=clearInterval(Vi))):(Vi||(Lu=ml.now(),Vi=setInterval(C3,K2)),Po=1,Y2(A1))}}function M1(e,t,n){var r=new Pu;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var R3=id("start","end","cancel","interrupt"),A3=[],Z2=0,$1=1,Av=2,xu=3,I1=4,Mv=5,bu=6;function ud(e,t,n,r,s,o){var l=e.__transition;if(!l)e.__transition={};else if(n in l)return;M3(e,n,{name:t,index:r,group:s,on:R3,tween:A3,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:Z2})}function Rx(e,t){var n=Gn(e,t);if(n.state>Z2)throw new Error("too late; already scheduled");return n}function vr(e,t){var n=Gn(e,t);if(n.state>xu)throw new Error("too late; already running");return n}function Gn(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function M3(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=X2(o,0,n.time);function o(f){n.state=$1,n.timer.restart(l,n.delay,n.time),n.delay<=f&&l(f-n.delay)}function l(f){var h,m,g,w;if(n.state!==$1)return d();for(h in r)if(w=r[h],w.name===n.name){if(w.state===xu)return M1(l);w.state===I1?(w.state=bu,w.timer.stop(),w.on.call("interrupt",e,e.__data__,w.index,w.group),delete r[h]):+h<t&&(w.state=bu,w.timer.stop(),w.on.call("cancel",e,e.__data__,w.index,w.group),delete r[h])}if(M1(function(){n.state===xu&&(n.state=I1,n.timer.restart(u,n.delay,n.time),u(f))}),n.state=Av,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Av){for(n.state=xu,s=new Array(g=n.tween.length),h=0,m=-1;h<g;++h)(w=n.tween[h].value.call(e,e.__data__,n.index,n.group))&&(s[++m]=w);s.length=m+1}}function u(f){for(var h=f<n.duration?n.ease.call(null,f/n.duration):(n.timer.restart(d),n.state=Mv,1),m=-1,g=s.length;++m<g;)s[m].call(e,h);n.state===Mv&&(n.on.call("end",e,e.__data__,n.index,n.group),d())}function d(){n.state=bu,n.timer.stop(),delete r[t];for(var f in r)return;delete e.__transition}}function ku(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>Av&&r.state<Mv,r.state=bu,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[l]}o&&delete e.__transition}}function $3(e){return this.each(function(){ku(this,e)})}function I3(e,t){var n,r;return function(){var s=vr(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 O3(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var o=vr(this,e),l=o.tween;if(l!==r){s=(r=l).slice();for(var u={name:t,value:n},d=0,f=s.length;d<f;++d)if(s[d].name===t){s[d]=u;break}d===f&&s.push(u)}o.tween=s}}function L3(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Gn(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?I3:O3)(n,e,t))}function Ax(e,t,n){var r=e._id;return e.each(function(){var s=vr(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return Gn(s,r).value[t]}}function J2(e,t){var n;return(typeof t=="number"?ys:t instanceof pl?C1:(n=pl(t))?(t=n,C1):y3)(e,t)}function P3(e){return function(){this.removeAttribute(e)}}function D3(e){return function(){this.removeAttributeNS(e.space,e.local)}}function F3(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 q3(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 B3(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 z3(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 U3(e,t){var n=ld(e),r=n==="transform"?b3:J2;return this.attrTween(e,typeof t=="function"?(n.local?z3:B3)(n,r,Ax(this,"attr."+e,t)):t==null?(n.local?D3:P3)(n):(n.local?q3:F3)(n,r,t))}function H3(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function W3(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function V3(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&W3(e,o)),n}return s._value=t,s}function G3(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&H3(e,o)),n}return s._value=t,s}function K3(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=ld(e);return this.tween(n,(r.local?V3:G3)(r,t))}function Y3(e,t){return function(){Rx(this,e).delay=+t.apply(this,arguments)}}function X3(e,t){return t=+t,function(){Rx(this,e).delay=t}}function Z3(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Y3:X3)(t,e)):Gn(this.node(),t).delay}function J3(e,t){return function(){vr(this,e).duration=+t.apply(this,arguments)}}function Q3(e,t){return t=+t,function(){vr(this,e).duration=t}}function e4(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?J3:Q3)(t,e)):Gn(this.node(),t).duration}function t4(e,t){if(typeof t!="function")throw new Error;return function(){vr(this,e).ease=t}}function n4(e){var t=this._id;return arguments.length?this.each(t4(t,e)):Gn(this.node(),t).ease}function r4(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;vr(this,e).ease=n}}function s4(e){if(typeof e!="function")throw new Error;return this.each(r4(this._id,e))}function a4(e){typeof e!="function"&&(e=R2(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,f=0;f<l;++f)(d=o[f])&&e.call(d,d.__data__,f,o)&&u.push(d);return new zr(r,this._parents,this._name,this._id)}function o4(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],f=n[u],h=d.length,m=l[u]=new Array(h),g,w=0;w<h;++w)(g=d[w]||f[w])&&(m[w]=g);for(;u<r;++u)l[u]=t[u];return new zr(l,this._parents,this._name,this._id)}function i4(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 l4(e,t,n){var r,s,o=i4(t)?Rx:vr;return function(){var l=o(this,e),u=l.on;u!==r&&(s=(r=u).copy()).on(t,n),l.on=s}}function c4(e,t){var n=this._id;return arguments.length<2?Gn(this.node(),n).on.on(e):this.each(l4(n,e,t))}function u4(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function d4(){return this.on("end.remove",u4(this._id))}function h4(e){var t=this._name,n=this._id;typeof e!="function"&&(e=_x(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,f=o[l]=new Array(d),h,m,g=0;g<d;++g)(h=u[g])&&(m=e.call(h,h.__data__,g,u))&&("__data__"in h&&(m.__data__=h.__data__),f[g]=m,ud(f[g],t,n,g,f,Gn(h,n)));return new zr(o,this._parents,t,n)}function f4(e){var t=this._name,n=this._id;typeof e!="function"&&(e=T2(e));for(var r=this._groups,s=r.length,o=[],l=[],u=0;u<s;++u)for(var d=r[u],f=d.length,h,m=0;m<f;++m)if(h=d[m]){for(var g=e.call(h,h.__data__,m,d),w,k=Gn(h,n),v=0,b=g.length;v<b;++v)(w=g[v])&&ud(w,t,n,v,g,k);o.push(g),l.push(h)}return new zr(o,l,t,n)}var p4=Ol.prototype.constructor;function m4(){return new p4(this._groups,this._parents)}function g4(e,t){var n,r,s;return function(){var o=Lo(this,e),l=(this.style.removeProperty(e),Lo(this,e));return o===l?null:o===n&&l===r?s:s=t(n=o,r=l)}}function Q2(e){return function(){this.style.removeProperty(e)}}function y4(e,t,n){var r,s=n+"",o;return function(){var l=Lo(this,e);return l===s?null:l===r?o:o=t(r=l,n)}}function w4(e,t,n){var r,s,o;return function(){var l=Lo(this,e),u=n(this),d=u+"";return u==null&&(d=u=(this.style.removeProperty(e),Lo(this,e))),l===d?null:l===r&&d===s?o:(s=d,o=t(r=l,u))}}function v4(e,t){var n,r,s,o="style."+t,l="end."+o,u;return function(){var d=vr(this,e),f=d.on,h=d.value[o]==null?u||(u=Q2(t)):void 0;(f!==n||s!==h)&&(r=(n=f).copy()).on(l,s=h),d.on=r}}function x4(e,t,n){var r=(e+="")=="transform"?x3:J2;return t==null?this.styleTween(e,g4(e,r)).on("end.style."+e,Q2(e)):typeof t=="function"?this.styleTween(e,w4(e,r,Ax(this,"style."+e,t))).each(v4(this._id,e)):this.styleTween(e,y4(e,r,t),n).on("end.style."+e,null)}function b4(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function k4(e,t,n){var r,s;function o(){var l=t.apply(this,arguments);return l!==s&&(r=(s=l)&&b4(e,l,n)),r}return o._value=t,o}function N4(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,k4(e,t,n??""))}function S4(e){return function(){this.textContent=e}}function j4(e){return function(){var t=e(this);this.textContent=t??""}}function _4(e){return this.tween("text",typeof e=="function"?j4(Ax(this,"text",e)):S4(e==null?"":e+""))}function E4(e){return function(t){this.textContent=e.call(this,t)}}function C4(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&E4(s)),t}return r._value=e,r}function T4(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,C4(e))}function R4(){for(var e=this._name,t=this._id,n=eR(),r=this._groups,s=r.length,o=0;o<s;++o)for(var l=r[o],u=l.length,d,f=0;f<u;++f)if(d=l[f]){var h=Gn(d,t);ud(d,e,n,f,l,{time:h.time+h.delay+h.duration,delay:0,duration:h.duration,ease:h.ease})}return new zr(r,this._parents,e,n)}function A4(){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 f=vr(this,r),h=f.on;h!==e&&(t=(e=h).copy(),t._.cancel.push(u),t._.interrupt.push(u),t._.end.push(d)),f.on=t}),s===0&&o()})}var M4=0;function zr(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function eR(){return++M4}var Dr=Ol.prototype;zr.prototype={constructor:zr,select:h4,selectAll:f4,selectChild:Dr.selectChild,selectChildren:Dr.selectChildren,filter:a4,merge:o4,selection:m4,transition:R4,call:Dr.call,nodes:Dr.nodes,node:Dr.node,size:Dr.size,empty:Dr.empty,each:Dr.each,on:c4,attr:U3,attrTween:K3,style:x4,styleTween:N4,text:_4,textTween:T4,remove:d4,tween:L3,delay:Z3,duration:e4,ease:n4,easeVarying:s4,end:A4,[Symbol.iterator]:Dr[Symbol.iterator]};function $4(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var I4={time:null,delay:0,duration:250,ease:$4};function O4(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 L4(e){var t,n;e instanceof zr?(t=e._id,e=e._name):(t=eR(),(n=I4).time=Tx(),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,f=0;f<u;++f)(d=l[f])&&ud(d,e,t,f,l,n||O4(d,t));return new zr(r,this._parents,e,t)}Ol.prototype.interrupt=$3;Ol.prototype.transition=L4;const tu=e=>()=>e;function P4(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 Fr(e,t,n){this.k=e,this.x=t,this.y=n}Fr.prototype={constructor:Fr,scale:function(e){return e===1?this:new Fr(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Fr(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 qr=new Fr(1,0,0);Fr.prototype;function Of(e){e.stopImmediatePropagation()}function Gi(e){e.preventDefault(),e.stopImmediatePropagation()}function D4(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function F4(){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 O1(){return this.__zoom||qr}function q4(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function B4(){return navigator.maxTouchPoints||"ontouchstart"in this}function z4(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 tR(){var e=D4,t=F4,n=z4,r=q4,s=B4,o=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],u=250,d=j3,f=id("start","zoom","end"),h,m,g,w=500,k=150,v=0,b=10;function S($){$.property("__zoom",O1).on("wheel.zoom",O,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",A).filter(s).on("touchstart.zoom",L).on("touchmove.zoom",z).on("touchend.zoom touchcancel.zoom",V).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}S.transform=function($,P,F,Y){var K=$.selection?$.selection():$;K.property("__zoom",O1),$!==K?T($,P,F,Y):K.interrupt().each(function(){R(this,arguments).event(Y).start().zoom(null,typeof P=="function"?P.apply(this,arguments):P).end()})},S.scaleBy=function($,P,F,Y){S.scaleTo($,function(){var K=this.__zoom.k,D=typeof P=="function"?P.apply(this,arguments):P;return K*D},F,Y)},S.scaleTo=function($,P,F,Y){S.transform($,function(){var K=t.apply(this,arguments),D=this.__zoom,W=F==null?E(K):typeof F=="function"?F.apply(this,arguments):F,B=D.invert(W),X=typeof P=="function"?P.apply(this,arguments):P;return n(j(_(D,X),W,B),K,l)},F,Y)},S.translateBy=function($,P,F,Y){S.transform($,function(){return n(this.__zoom.translate(typeof P=="function"?P.apply(this,arguments):P,typeof F=="function"?F.apply(this,arguments):F),t.apply(this,arguments),l)},null,Y)},S.translateTo=function($,P,F,Y,K){S.transform($,function(){var D=t.apply(this,arguments),W=this.__zoom,B=Y==null?E(D):typeof Y=="function"?Y.apply(this,arguments):Y;return n(qr.translate(B[0],B[1]).scale(W.k).translate(typeof P=="function"?-P.apply(this,arguments):-P,typeof F=="function"?-F.apply(this,arguments):-F),D,l)},Y,K)};function _($,P){return P=Math.max(o[0],Math.min(o[1],P)),P===$.k?$:new Fr(P,$.x,$.y)}function j($,P,F){var Y=P[0]-F[0]*$.k,K=P[1]-F[1]*$.k;return Y===$.x&&K===$.y?$:new Fr($.k,Y,K)}function E($){return[(+$[0][0]+ +$[1][0])/2,(+$[0][1]+ +$[1][1])/2]}function T($,P,F,Y){$.on("start.zoom",function(){R(this,arguments).event(Y).start()}).on("interrupt.zoom end.zoom",function(){R(this,arguments).event(Y).end()}).tween("zoom",function(){var K=this,D=arguments,W=R(K,D).event(Y),B=t.apply(K,D),X=F==null?E(B):typeof F=="function"?F.apply(K,D):F,G=Math.max(B[1][0]-B[0][0],B[1][1]-B[0][1]),U=K.__zoom,Z=typeof P=="function"?P.apply(K,D):P,H=d(U.invert(X).concat(G/U.k),Z.invert(X).concat(G/Z.k));return function(J){if(J===1)J=Z;else{var ee=H(J),re=G/ee[2];J=new Fr(re,X[0]-ee[0]*re,X[1]-ee[1]*re)}W.zoom(null,J)}})}function R($,P,F){return!F&&$.__zooming||new M($,P)}function M($,P){this.that=$,this.args=P,this.active=0,this.sourceEvent=null,this.extent=t.apply($,P),this.taps=0}M.prototype={event:function($){return $&&(this.sourceEvent=$),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function($,P){return this.mouse&&$!=="mouse"&&(this.mouse[1]=P.invert(this.mouse[0])),this.touch0&&$!=="touch"&&(this.touch0[1]=P.invert(this.touch0[0])),this.touch1&&$!=="touch"&&(this.touch1[1]=P.invert(this.touch1[0])),this.that.__zoom=P,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function($){var P=jn(this.that).datum();f.call($,this.that,new P4($,{sourceEvent:this.sourceEvent,target:S,transform:this.that.__zoom,dispatch:f}),P)}};function O($,...P){if(!e.apply(this,arguments))return;var F=R(this,P).event($),Y=this.__zoom,K=Math.max(o[0],Math.min(o[1],Y.k*Math.pow(2,r.apply(this,arguments)))),D=Fn($);if(F.wheel)(F.mouse[0][0]!==D[0]||F.mouse[0][1]!==D[1])&&(F.mouse[1]=Y.invert(F.mouse[0]=D)),clearTimeout(F.wheel);else{if(Y.k===K)return;F.mouse=[D,Y.invert(D)],ku(this),F.start()}Gi($),F.wheel=setTimeout(W,k),F.zoom("mouse",n(j(_(Y,K),F.mouse[0],F.mouse[1]),F.extent,l));function W(){F.wheel=null,F.end()}}function I($,...P){if(g||!e.apply(this,arguments))return;var F=$.currentTarget,Y=R(this,P,!0).event($),K=jn($.view).on("mousemove.zoom",X,!0).on("mouseup.zoom",G,!0),D=Fn($,F),W=$.clientX,B=$.clientY;q2($.view),Of($),Y.mouse=[D,this.__zoom.invert(D)],ku(this),Y.start();function X(U){if(Gi(U),!Y.moved){var Z=U.clientX-W,H=U.clientY-B;Y.moved=Z*Z+H*H>v}Y.event(U).zoom("mouse",n(j(Y.that.__zoom,Y.mouse[0]=Fn(U,F),Y.mouse[1]),Y.extent,l))}function G(U){K.on("mousemove.zoom mouseup.zoom",null),B2(U.view,Y.moved),Gi(U),Y.event(U).end()}}function A($,...P){if(e.apply(this,arguments)){var F=this.__zoom,Y=Fn($.changedTouches?$.changedTouches[0]:$,this),K=F.invert(Y),D=F.k*($.shiftKey?.5:2),W=n(j(_(F,D),Y,K),t.apply(this,P),l);Gi($),u>0?jn(this).transition().duration(u).call(T,W,Y,$):jn(this).call(S.transform,W,Y,$)}}function L($,...P){if(e.apply(this,arguments)){var F=$.touches,Y=F.length,K=R(this,P,$.changedTouches.length===Y).event($),D,W,B,X;for(Of($),W=0;W<Y;++W)B=F[W],X=Fn(B,this),X=[X,this.__zoom.invert(X),B.identifier],K.touch0?!K.touch1&&K.touch0[2]!==X[2]&&(K.touch1=X,K.taps=0):(K.touch0=X,D=!0,K.taps=1+!!h);h&&(h=clearTimeout(h)),D&&(K.taps<2&&(m=X[0],h=setTimeout(function(){h=null},w)),ku(this),K.start())}}function z($,...P){if(this.__zooming){var F=R(this,P).event($),Y=$.changedTouches,K=Y.length,D,W,B,X;for(Gi($),D=0;D<K;++D)W=Y[D],B=Fn(W,this),F.touch0&&F.touch0[2]===W.identifier?F.touch0[0]=B:F.touch1&&F.touch1[2]===W.identifier&&(F.touch1[0]=B);if(W=F.that.__zoom,F.touch1){var G=F.touch0[0],U=F.touch0[1],Z=F.touch1[0],H=F.touch1[1],J=(J=Z[0]-G[0])*J+(J=Z[1]-G[1])*J,ee=(ee=H[0]-U[0])*ee+(ee=H[1]-U[1])*ee;W=_(W,Math.sqrt(J/ee)),B=[(G[0]+Z[0])/2,(G[1]+Z[1])/2],X=[(U[0]+H[0])/2,(U[1]+H[1])/2]}else if(F.touch0)B=F.touch0[0],X=F.touch0[1];else return;F.zoom("touch",n(j(W,B,X),F.extent,l))}}function V($,...P){if(this.__zooming){var F=R(this,P).event($),Y=$.changedTouches,K=Y.length,D,W;for(Of($),g&&clearTimeout(g),g=setTimeout(function(){g=null},w),D=0;D<K;++D)W=Y[D],F.touch0&&F.touch0[2]===W.identifier?delete F.touch0:F.touch1&&F.touch1[2]===W.identifier&&delete F.touch1;if(F.touch1&&!F.touch0&&(F.touch0=F.touch1,delete F.touch1),F.touch0)F.touch0[1]=this.__zoom.invert(F.touch0[0]);else if(F.end(),F.taps===2&&(W=Fn(W,this),Math.hypot(m[0]-W[0],m[1]-W[1])<b)){var B=jn(this).on("dblclick.zoom");B&&B.apply(this,arguments)}}}return S.wheelDelta=function($){return arguments.length?(r=typeof $=="function"?$:tu(+$),S):r},S.filter=function($){return arguments.length?(e=typeof $=="function"?$:tu(!!$),S):e},S.touchable=function($){return arguments.length?(s=typeof $=="function"?$:tu(!!$),S):s},S.extent=function($){return arguments.length?(t=typeof $=="function"?$:tu([[+$[0][0],+$[0][1]],[+$[1][0],+$[1][1]]]),S):t},S.scaleExtent=function($){return arguments.length?(o[0]=+$[0],o[1]=+$[1],S):[o[0],o[1]]},S.translateExtent=function($){return arguments.length?(l[0][0]=+$[0][0],l[1][0]=+$[1][0],l[0][1]=+$[0][1],l[1][1]=+$[1][1],S):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},S.constrain=function($){return arguments.length?(n=$,S):n},S.duration=function($){return arguments.length?(u=+$,S):u},S.interpolate=function($){return arguments.length?(d=$,S):d},S.on=function(){var $=f.on.apply(f,arguments);return $===f?S:$},S.clickDistance=function($){return arguments.length?(v=($=+$)*$,S):Math.sqrt(v)},S.tapDistance=function($){return arguments.length?(b=+$,S):b},S}var zt=_2();const dd=x.createContext(null),U4=dd.Provider,Ur={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.`},nR=Ur.error001();function We(e,t){const n=x.useContext(dd);if(n===null)throw new Error(nR);return E2(n,e,t)}const yt=()=>{const e=x.useContext(dd);if(e===null)throw new Error(nR);return x.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},H4=e=>e.userSelectionActive?"none":"all";function Mx({position:e,children:t,className:n,style:r,...s}){const o=We(H4),l=`${e}`.split("-");return ce.createElement("div",{className:Ot(["react-flow__panel",n,...l]),style:{...r,pointerEvents:o},...s},t)}function W4({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:ce.createElement(Mx,{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"},ce.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const V4=({x:e,y:t,label:n,labelStyle:r={},labelShowBg:s=!0,labelBgStyle:o={},labelBgPadding:l=[2,4],labelBgBorderRadius:u=2,children:d,className:f,...h})=>{const m=x.useRef(null),[g,w]=x.useState({x:0,y:0,width:0,height:0}),k=Ot(["react-flow__edge-textwrapper",f]);return x.useEffect(()=>{if(m.current){const v=m.current.getBBox();w({x:v.x,y:v.y,width:v.width,height:v.height})}},[n]),typeof n>"u"||!n?null:ce.createElement("g",{transform:`translate(${e-g.width/2} ${t-g.height/2})`,className:k,visibility:g.width?"visible":"hidden",...h},s&&ce.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}),ce.createElement("text",{className:"react-flow__edge-text",y:g.height/2,dy:"0.3em",ref:m,style:r},n),d)};var G4=x.memo(V4);const $x=e=>({width:e.offsetWidth,height:e.offsetHeight}),Do=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ix=(e={x:0,y:0},t)=>({x:Do(e.x,t[0][0],t[1][0]),y:Do(e.y,t[0][1],t[1][1])}),L1=(e,t,n)=>e<t?Do(Math.abs(e-t),1,50)/50:e>n?-Do(Math.abs(e-n),1,50)/50:0,rR=(e,t)=>{const n=L1(e.x,35,t.width-35)*20,r=L1(e.y,35,t.height-35)*20;return[n,r]},sR=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},aR=(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)}),gl=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),oR=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),P1=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),K4=(e,t)=>oR(aR(gl(e),gl(t))),$v=(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)},Y4=e=>_n(e.width)&&_n(e.height)&&_n(e.x)&&_n(e.y),_n=e=>!isNaN(e)&&isFinite(e),ht=Symbol.for("internals"),iR=["Enter"," ","Escape"],X4=(e,t)=>{},Z4=e=>"nativeEvent"in e;function Iv(e){var s,o;const t=Z4(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 lR=e=>"clientX"in e,Ns=(e,t)=>{var o,l;const n=lR(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)}},Du=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},Pl=({id:e,path:t,labelX:n,labelY:r,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:m,markerStart:g,interactionWidth:w=20})=>ce.createElement(ce.Fragment,null,ce.createElement("path",{id:e,style:h,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:m,markerStart:g}),w&&ce.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:w,className:"react-flow__edge-interaction"}),s&&_n(n)&&_n(r)?ce.createElement(G4,{x:n,y:r,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f}):null);Pl.displayName="BaseEdge";function Ki(e,t,n){return n===void 0?n:r=>{const s=t().edges.find(o=>o.id===e);s&&n(r,{...s})}}function cR({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 uR({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,f=t*.125+o*.375+u*.375+r*.125,h=Math.abs(d-e),m=Math.abs(f-t);return[d,f,h,m]}var va;(function(e){e.Strict="strict",e.Loose="loose"})(va||(va={}));var ha;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(ha||(ha={}));var yl;(function(e){e.Partial="partial",e.Full="full"})(yl||(yl={}));var vs;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(vs||(vs={}));var Fu;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Fu||(Fu={}));var Ce;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ce||(Ce={}));function D1({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===Ce.Left||e===Ce.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function dR({sourceX:e,sourceY:t,sourcePosition:n=Ce.Bottom,targetX:r,targetY:s,targetPosition:o=Ce.Top}){const[l,u]=D1({pos:n,x1:e,y1:t,x2:r,y2:s}),[d,f]=D1({pos:o,x1:r,y1:s,x2:e,y2:t}),[h,m,g,w]=uR({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:u,targetControlX:d,targetControlY:f});return[`M${e},${t} C${l},${u} ${d},${f} ${r},${s}`,h,m,g,w]}const Ox=x.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s=Ce.Bottom,targetPosition:o=Ce.Top,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:m,style:g,markerEnd:w,markerStart:k,interactionWidth:v})=>{const[b,S,_]=dR({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o});return ce.createElement(Pl,{path:b,labelX:S,labelY:_,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:m,style:g,markerEnd:w,markerStart:k,interactionWidth:v})});Ox.displayName="SimpleBezierEdge";const F1={[Ce.Left]:{x:-1,y:0},[Ce.Right]:{x:1,y:0},[Ce.Top]:{x:0,y:-1},[Ce.Bottom]:{x:0,y:1}},J4=({source:e,sourcePosition:t=Ce.Bottom,target:n})=>t===Ce.Left||t===Ce.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},q1=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Q4({source:e,sourcePosition:t=Ce.Bottom,target:n,targetPosition:r=Ce.Top,center:s,offset:o}){const l=F1[t],u=F1[r],d={x:e.x+l.x*o,y:e.y+l.y*o},f={x:n.x+u.x*o,y:n.y+u.y*o},h=J4({source:d,sourcePosition:t,target:f}),m=h.x!==0?"x":"y",g=h[m];let w=[],k,v;const b={x:0,y:0},S={x:0,y:0},[_,j,E,T]=cR({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[m]*u[m]===-1){k=s.x??_,v=s.y??j;const M=[{x:k,y:d.y},{x:k,y:f.y}],O=[{x:d.x,y:v},{x:f.x,y:v}];l[m]===g?w=m==="x"?M:O:w=m==="x"?O:M}else{const M=[{x:d.x,y:f.y}],O=[{x:f.x,y:d.y}];if(m==="x"?w=l.x===g?O:M:w=l.y===g?M:O,t===r){const V=Math.abs(e[m]-n[m]);if(V<=o){const $=Math.min(o-1,o-V);l[m]===g?b[m]=(d[m]>e[m]?-1:1)*$:S[m]=(f[m]>n[m]?-1:1)*$}}if(t!==r){const V=m==="x"?"y":"x",$=l[m]===u[V],P=d[V]>f[V],F=d[V]<f[V];(l[m]===1&&(!$&&P||$&&F)||l[m]!==1&&(!$&&F||$&&P))&&(w=m==="x"?M:O)}const I={x:d.x+b.x,y:d.y+b.y},A={x:f.x+S.x,y:f.y+S.y},L=Math.max(Math.abs(I.x-w[0].x),Math.abs(A.x-w[0].x)),z=Math.max(Math.abs(I.y-w[0].y),Math.abs(A.y-w[0].y));L>=z?(k=(I.x+A.x)/2,v=w[0].y):(k=w[0].x,v=(I.y+A.y)/2)}return[[e,{x:d.x+b.x,y:d.y+b.y},...w,{x:f.x+S.x,y:f.y+S.y},n],k,v,E,T]}function eD(e,t,n,r){const s=Math.min(q1(e,t)/2,q1(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 f=e.x<n.x?-1:1,h=e.y<n.y?1:-1;return`L ${o+s*f},${l}Q ${o},${l} ${o},${l+s*h}`}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 Ov({sourceX:e,sourceY:t,sourcePosition:n=Ce.Bottom,targetX:r,targetY:s,targetPosition:o=Ce.Top,borderRadius:l=5,centerX:u,centerY:d,offset:f=20}){const[h,m,g,w,k]=Q4({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:o,center:{x:u,y:d},offset:f});return[h.reduce((b,S,_)=>{let j="";return _>0&&_<h.length-1?j=eD(h[_-1],S,h[_+1],l):j=`${_===0?"M":"L"}${S.x} ${S.y}`,b+=j,b},""),m,g,w,k]}const hd=x.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,sourcePosition:m=Ce.Bottom,targetPosition:g=Ce.Top,markerEnd:w,markerStart:k,pathOptions:v,interactionWidth:b})=>{const[S,_,j]=Ov({sourceX:e,sourceY:t,sourcePosition:m,targetX:n,targetY:r,targetPosition:g,borderRadius:v==null?void 0:v.borderRadius,offset:v==null?void 0:v.offset});return ce.createElement(Pl,{path:S,labelX:_,labelY:j,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:w,markerStart:k,interactionWidth:b})});hd.displayName="SmoothStepEdge";const Lx=x.memo(e=>{var t;return ce.createElement(hd,{...e,pathOptions:x.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});Lx.displayName="StepEdge";function tD({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,o,l,u]=cR({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,o,l,u]}const Px=x.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:m,markerStart:g,interactionWidth:w})=>{const[k,v,b]=tD({sourceX:e,sourceY:t,targetX:n,targetY:r});return ce.createElement(Pl,{path:k,labelX:v,labelY:b,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:m,markerStart:g,interactionWidth:w})});Px.displayName="StraightEdge";function nu(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function B1({pos:e,x1:t,y1:n,x2:r,y2:s,c:o}){switch(e){case Ce.Left:return[t-nu(t-r,o),n];case Ce.Right:return[t+nu(r-t,o),n];case Ce.Top:return[t,n-nu(n-s,o)];case Ce.Bottom:return[t,n+nu(s-n,o)]}}function Dx({sourceX:e,sourceY:t,sourcePosition:n=Ce.Bottom,targetX:r,targetY:s,targetPosition:o=Ce.Top,curvature:l=.25}){const[u,d]=B1({pos:n,x1:e,y1:t,x2:r,y2:s,c:l}),[f,h]=B1({pos:o,x1:r,y1:s,x2:e,y2:t,c:l}),[m,g,w,k]=uR({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:u,sourceControlY:d,targetControlX:f,targetControlY:h});return[`M${e},${t} C${u},${d} ${f},${h} ${r},${s}`,m,g,w,k]}const qu=x.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s=Ce.Bottom,targetPosition:o=Ce.Top,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:m,style:g,markerEnd:w,markerStart:k,pathOptions:v,interactionWidth:b})=>{const[S,_,j]=Dx({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o,curvature:v==null?void 0:v.curvature});return ce.createElement(Pl,{path:S,labelX:_,labelY:j,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:m,style:g,markerEnd:w,markerStart:k,interactionWidth:b})});qu.displayName="BezierEdge";const Fx=x.createContext(null),nD=Fx.Provider;Fx.Consumer;const rD=()=>x.useContext(Fx),sD=e=>"id"in e&&"source"in e&&"target"in e,aD=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,Lv=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`,oD=(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)),iD=(e,t)=>{if(!e.source||!e.target)return t;let n;return sD(e)?n={...e}:n={...e,id:aD(e)},oD(n,t)?t:t.concat(n)},Pv=({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},hR=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r}),ma=(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}},fd=(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}=ma(s,t).positionAbsolute;return aR(r,gl({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 oR(n)},fR=(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},f=[];return e.forEach(h=>{const{width:m,height:g,selectable:w=!0,hidden:k=!1}=h;if(l&&!w||k)return!1;const{positionAbsolute:v}=ma(h,u),b={x:v.x,y:v.y,width:m||0,height:g||0},S=$v(d,b),_=typeof m>"u"||typeof g>"u"||m===null||g===null,j=o&&S>0,E=(m||0)*(g||0);(_||j||S>=E||h.dragging)&&f.push(h)}),f},pR=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},mR=(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),f=Do(d,r,s),h=e.x+e.width/2,m=e.y+e.height/2,g=t/2-h*f,w=n/2-m*f;return{x:g,y:w,zoom:f}},la=(e,t=0)=>e.transition().duration(t);function z1(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 lD(e,t,n,r,s,o){const{x:l,y:u}=Ns(e),f=t.elementsFromPoint(l,u).find(k=>k.classList.contains("react-flow__handle"));if(f){const k=f.getAttribute("data-nodeid");if(k){const v=qx(void 0,f),b=f.getAttribute("data-handleid"),S=o({nodeId:k,id:b,type:v});if(S){const _=s.find(j=>j.nodeId===k&&j.type===v&&j.id===b);return{handle:{id:b,type:v,nodeId:k,x:(_==null?void 0:_.x)||n.x,y:(_==null?void 0:_.y)||n.y},validHandleResult:S}}}}let h=[],m=1/0;if(s.forEach(k=>{const v=Math.sqrt((k.x-n.x)**2+(k.y-n.y)**2);if(v<=r){const b=o(k);v<=m&&(v<m?h=[{handle:k,validHandleResult:b}]:v===m&&h.push({handle:k,validHandleResult:b}),m=v)}}),!h.length)return{handle:null,validHandleResult:gR()};if(h.length===1)return h[0];const g=h.some(({validHandleResult:k})=>k.isValid),w=h.some(({handle:k})=>k.type==="target");return h.find(({handle:k,validHandleResult:v})=>w?k.type==="target":g?v.isValid:!0)||h[0]}const cD={source:null,target:null,sourceHandle:null,targetHandle:null},gR=()=>({handleDomNode:null,isValid:!1,connection:cD,endHandle:null});function yR(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}"]`),f={...gR(),handleDomNode:d};if(d){const h=qx(void 0,d),m=d.getAttribute("data-nodeid"),g=d.getAttribute("data-handleid"),w=d.classList.contains("connectable"),k=d.classList.contains("connectableend"),v={source:u?m:n,sourceHandle:u?g:r,target:u?n:m,targetHandle:u?r:g};f.connection=v,w&&k&&(t===va.Strict?u&&h==="source"||!u&&h==="target":m!==n||g!==r)&&(f.endHandle={nodeId:m,handleId:g,type:h},f.isValid=o(v))}return f}function uD({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((s,o)=>{if(o[ht]){const{handleBounds:l}=o[ht];let u=[],d=[];l&&(u=z1(o,l,"source",`${t}-${n}-${r}`),d=z1(o,l,"target",`${t}-${n}-${r}`)),s.push(...u,...d)}return s},[])}function qx(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Lf(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function dD(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function wR({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:s,getState:o,setState:l,isValidConnection:u,edgeUpdaterType:d,onReconnectEnd:f}){const h=sR(e.target),{connectionMode:m,domNode:g,autoPanOnConnect:w,connectionRadius:k,onConnectStart:v,panBy:b,getNodes:S,cancelConnection:_}=o();let j=0,E;const{x:T,y:R}=Ns(e),M=h==null?void 0:h.elementFromPoint(T,R),O=qx(d,M),I=g==null?void 0:g.getBoundingClientRect();if(!I||!O)return;let A,L=Ns(e,I),z=!1,V=null,$=!1,P=null;const F=uD({nodes:S(),nodeId:n,handleId:t,handleType:O}),Y=()=>{if(!w)return;const[W,B]=rR(L,I);b({x:W,y:B}),j=requestAnimationFrame(Y)};l({connectionPosition:L,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:O,connectionStartHandle:{nodeId:n,handleId:t,type:O},connectionEndHandle:null}),v==null||v(e,{nodeId:n,handleId:t,handleType:O});function K(W){const{transform:B}=o();L=Ns(W,I);const{handle:X,validHandleResult:G}=lD(W,h,Pv(L,B,!1,[1,1]),k,F,U=>yR(U,m,n,t,s?"target":"source",u,h));if(E=X,z||(Y(),z=!0),P=G.handleDomNode,V=G.connection,$=G.isValid,l({connectionPosition:E&&$?hR({x:E.x,y:E.y},B):L,connectionStatus:dD(!!E,$),connectionEndHandle:G.endHandle}),!E&&!$&&!P)return Lf(A);V.source!==V.target&&P&&(Lf(A),A=P,P.classList.add("connecting","react-flow__handle-connecting"),P.classList.toggle("valid",$),P.classList.toggle("react-flow__handle-valid",$))}function D(W){var B,X;(E||P)&&V&&$&&(r==null||r(V)),(X=(B=o()).onConnectEnd)==null||X.call(B,W),d&&(f==null||f(W)),Lf(A),_(),cancelAnimationFrame(j),z=!1,$=!1,V=null,P=null,h.removeEventListener("mousemove",K),h.removeEventListener("mouseup",D),h.removeEventListener("touchmove",K),h.removeEventListener("touchend",D)}h.addEventListener("mousemove",K),h.addEventListener("mouseup",D),h.addEventListener("touchmove",K),h.addEventListener("touchend",D)}const U1=()=>!0,hD=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),fD=(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}},vR=x.forwardRef(({type:e="source",position:t=Ce.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:o=!0,id:l,onConnect:u,children:d,className:f,onMouseDown:h,onTouchStart:m,...g},w)=>{var I,A;const k=l||null,v=e==="target",b=yt(),S=rD(),{connectOnClick:_,noPanClassName:j}=We(hD,_t),{connecting:E,clickConnecting:T}=We(fD(S,k,e),_t);S||(A=(I=b.getState()).onError)==null||A.call(I,"010",Ur.error010());const R=L=>{const{defaultEdgeOptions:z,onConnect:V,hasDefaultEdges:$}=b.getState(),P={...z,...L};if($){const{edges:F,setEdges:Y}=b.getState();Y(iD(P,F))}V==null||V(P),u==null||u(P)},M=L=>{if(!S)return;const z=lR(L);s&&(z&&L.button===0||!z)&&wR({event:L,handleId:k,nodeId:S,onConnect:R,isTarget:v,getState:b.getState,setState:b.setState,isValidConnection:n||b.getState().isValidConnection||U1}),z?h==null||h(L):m==null||m(L)},O=L=>{const{onClickConnectStart:z,onClickConnectEnd:V,connectionClickStartHandle:$,connectionMode:P,isValidConnection:F}=b.getState();if(!S||!$&&!s)return;if(!$){z==null||z(L,{nodeId:S,handleId:k,handleType:e}),b.setState({connectionClickStartHandle:{nodeId:S,type:e,handleId:k}});return}const Y=sR(L.target),K=n||F||U1,{connection:D,isValid:W}=yR({nodeId:S,id:k,type:e},P,$.nodeId,$.handleId||null,$.type,K,Y);W&&R(D),V==null||V(L),b.setState({connectionClickStartHandle:null})};return ce.createElement("div",{"data-handleid":k,"data-nodeid":S,"data-handlepos":t,"data-id":`${S}-${k}-${e}`,className:Ot(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",j,f,{source:!v,target:v,connectable:r,connectablestart:s,connectableend:o,connecting:T,connectionindicator:r&&(s&&!E||o&&E)}]),onMouseDown:M,onTouchStart:M,onClick:_?O:void 0,ref:w,...g},d)});vR.displayName="Handle";var xa=x.memo(vR);const xR=({data:e,isConnectable:t,targetPosition:n=Ce.Top,sourcePosition:r=Ce.Bottom})=>ce.createElement(ce.Fragment,null,ce.createElement(xa,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,ce.createElement(xa,{type:"source",position:r,isConnectable:t}));xR.displayName="DefaultNode";var Dv=x.memo(xR);const bR=({data:e,isConnectable:t,sourcePosition:n=Ce.Bottom})=>ce.createElement(ce.Fragment,null,e==null?void 0:e.label,ce.createElement(xa,{type:"source",position:n,isConnectable:t}));bR.displayName="InputNode";var kR=x.memo(bR);const NR=({data:e,isConnectable:t,targetPosition:n=Ce.Top})=>ce.createElement(ce.Fragment,null,ce.createElement(xa,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);NR.displayName="OutputNode";var SR=x.memo(NR);const Bx=()=>null;Bx.displayName="GroupNode";const pD=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),ru=e=>e.id;function mD(e,t){return _t(e.selectedNodes.map(ru),t.selectedNodes.map(ru))&&_t(e.selectedEdges.map(ru),t.selectedEdges.map(ru))}const jR=x.memo(({onSelectionChange:e})=>{const t=yt(),{selectedNodes:n,selectedEdges:r}=We(pD,mD);return x.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChange.forEach(o=>o(s))},[n,r,e]),null});jR.displayName="SelectionListener";const gD=e=>!!e.onSelectionChange;function yD({onSelectionChange:e}){const t=We(gD);return e||t?ce.createElement(jR,{onSelectionChange:e}):null}const wD=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 ho(e,t){x.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function De(e,t,n){x.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const vD=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:s,onConnectStart:o,onConnectEnd:l,onClickConnectStart:u,onClickConnectEnd:d,nodesDraggable:f,nodesConnectable:h,nodesFocusable:m,edgesFocusable:g,edgesUpdatable:w,elevateNodesOnSelect:k,minZoom:v,maxZoom:b,nodeExtent:S,onNodesChange:_,onEdgesChange:j,elementsSelectable:E,connectionMode:T,snapGrid:R,snapToGrid:M,translateExtent:O,connectOnClick:I,defaultEdgeOptions:A,fitView:L,fitViewOptions:z,onNodesDelete:V,onEdgesDelete:$,onNodeDrag:P,onNodeDragStart:F,onNodeDragStop:Y,onSelectionDrag:K,onSelectionDragStart:D,onSelectionDragStop:W,noPanClassName:B,nodeOrigin:X,rfId:G,autoPanOnConnect:U,autoPanOnNodeDrag:Z,onError:H,connectionRadius:J,isValidConnection:ee,nodeDragThreshold:re})=>{const{setNodes:oe,setEdges:fe,setDefaultNodesAndEdges:Ne,setMinZoom:ke,setMaxZoom:we,setTranslateExtent:ve,setNodeExtent:$e,reset:ye}=We(wD,_t),ue=yt();return x.useEffect(()=>{const se=r==null?void 0:r.map(xe=>({...xe,...A}));return Ne(n,se),()=>{ye()}},[]),De("defaultEdgeOptions",A,ue.setState),De("connectionMode",T,ue.setState),De("onConnect",s,ue.setState),De("onConnectStart",o,ue.setState),De("onConnectEnd",l,ue.setState),De("onClickConnectStart",u,ue.setState),De("onClickConnectEnd",d,ue.setState),De("nodesDraggable",f,ue.setState),De("nodesConnectable",h,ue.setState),De("nodesFocusable",m,ue.setState),De("edgesFocusable",g,ue.setState),De("edgesUpdatable",w,ue.setState),De("elementsSelectable",E,ue.setState),De("elevateNodesOnSelect",k,ue.setState),De("snapToGrid",M,ue.setState),De("snapGrid",R,ue.setState),De("onNodesChange",_,ue.setState),De("onEdgesChange",j,ue.setState),De("connectOnClick",I,ue.setState),De("fitViewOnInit",L,ue.setState),De("fitViewOnInitOptions",z,ue.setState),De("onNodesDelete",V,ue.setState),De("onEdgesDelete",$,ue.setState),De("onNodeDrag",P,ue.setState),De("onNodeDragStart",F,ue.setState),De("onNodeDragStop",Y,ue.setState),De("onSelectionDrag",K,ue.setState),De("onSelectionDragStart",D,ue.setState),De("onSelectionDragStop",W,ue.setState),De("noPanClassName",B,ue.setState),De("nodeOrigin",X,ue.setState),De("rfId",G,ue.setState),De("autoPanOnConnect",U,ue.setState),De("autoPanOnNodeDrag",Z,ue.setState),De("onError",H,ue.setState),De("connectionRadius",J,ue.setState),De("isValidConnection",ee,ue.setState),De("nodeDragThreshold",re,ue.setState),ho(e,oe),ho(t,fe),ho(v,ke),ho(b,we),ho(O,ve),ho(S,$e),null},H1={display:"none"},xD={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},_R="react-flow__node-desc",ER="react-flow__edge-desc",bD="react-flow__aria-live",kD=e=>e.ariaLiveMessage;function ND({rfId:e}){const t=We(kD);return ce.createElement("div",{id:`${bD}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:xD},t)}function SD({rfId:e,disableKeyboardA11y:t}){return ce.createElement(ce.Fragment,null,ce.createElement("div",{id:`${_R}-${e}`,style:H1},"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."," "),ce.createElement("div",{id:`${ER}-${e}`,style:H1},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&ce.createElement(ND,{rfId:e}))}var wl=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,r]=x.useState(!1),s=x.useRef(!1),o=x.useRef(new Set([])),[l,u]=x.useMemo(()=>{if(e!==null){const f=(Array.isArray(e)?e:[e]).filter(m=>typeof m=="string").map(m=>m.split("+")),h=f.reduce((m,g)=>m.concat(...g),[]);return[f,h]}return[[],[]]},[e]);return x.useEffect(()=>{const d=typeof document<"u"?document:null,f=(t==null?void 0:t.target)||d;if(e!==null){const h=w=>{if(s.current=w.ctrlKey||w.metaKey||w.shiftKey,(!s.current||s.current&&!t.actInsideInputWithModifier)&&Iv(w))return!1;const v=V1(w.code,u);o.current.add(w[v]),W1(l,o.current,!1)&&(w.preventDefault(),r(!0))},m=w=>{if((!s.current||s.current&&!t.actInsideInputWithModifier)&&Iv(w))return!1;const v=V1(w.code,u);W1(l,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(w[v]),w.key==="Meta"&&o.current.clear(),s.current=!1},g=()=>{o.current.clear(),r(!1)};return f==null||f.addEventListener("keydown",h),f==null||f.addEventListener("keyup",m),window.addEventListener("blur",g),()=>{f==null||f.removeEventListener("keydown",h),f==null||f.removeEventListener("keyup",m),window.removeEventListener("blur",g)}}},[e,r]),n};function W1(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function V1(e,t){return t.includes(e)?"code":"key"}function CR(e,t,n,r){var u,d;const s=e.parentNode||e.parentId;if(!s)return n;const o=t.get(s),l=ma(o,r);return CR(o,t,{x:(n.x??0)+l.x,y:(n.y??0)+l.y,z:(((u=o[ht])==null?void 0:u.z)??0)>(n.z??0)?((d=o[ht])==null?void 0:d.z)??0:n.z??0},r)}function TR(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}=CR(r,e,{...r.position,z:((o=r[ht])==null?void 0:o.z)??0},t);r.positionAbsolute={x:l,y:u},r[ht].z=d,n!=null&&n[r.id]&&(r[ht].isParent=!0)}})}function Pf(e,t,n,r){const s=new Map,o={},l=r?1e3:0;return e.forEach(u=>{var w;const d=(_n(u.zIndex)?u.zIndex:0)+(u.selected?l:0),f=t.get(u.id),h={...u,positionAbsolute:{x:u.position.x,y:u.position.y}},m=u.parentNode||u.parentId;m&&(o[m]=!0);const g=(f==null?void 0:f.type)&&(f==null?void 0:f.type)!==u.type;Object.defineProperty(h,ht,{enumerable:!1,value:{handleBounds:g||(w=f==null?void 0:f[ht])==null?void 0:w.handleBounds,z:d}}),s.set(u.id,h)}),TR(s,n,o),s}function RR(e,t={}){const{getNodes:n,width:r,height:s,minZoom:o,maxZoom:l,d3Zoom:u,d3Selection:d,fitViewOnInitDone:f,fitViewOnInit:h,nodeOrigin:m}=e(),g=t.initial&&!f&&h;if(u&&d&&(g||!t.initial)){const k=n().filter(b=>{var _;const S=t.includeHiddenNodes?b.width&&b.height:!b.hidden;return(_=t.nodes)!=null&&_.length?S&&t.nodes.some(j=>j.id===b.id):S}),v=k.every(b=>b.width&&b.height);if(k.length>0&&v){const b=fd(k,m),{x:S,y:_,zoom:j}=mR(b,r,s,t.minZoom??o,t.maxZoom??l,t.padding??.1),E=qr.translate(S,_).scale(j);return typeof t.duration=="number"&&t.duration>0?u.transform(la(d,t.duration),E):u.transform(d,E),!0}}return!1}function jD(e,t){return e.forEach(n=>{const r=t.get(n.id);r&&t.set(r.id,{...r,[ht]:r[ht],selected:n.selected})}),new Map(t)}function _D(e,t){return t.map(n=>{const r=e.find(s=>s.id===n.id);return r&&(n.selected=r.selected),n})}function su({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:s,edges:o,onNodesChange:l,onEdgesChange:u,hasDefaultNodes:d,hasDefaultEdges:f}=n();e!=null&&e.length&&(d&&r({nodeInternals:jD(e,s)}),l==null||l(e)),t!=null&&t.length&&(f&&r({edges:_D(t,o)}),u==null||u(t))}const fo=()=>{},ED={zoomIn:fo,zoomOut:fo,zoomTo:fo,getZoom:()=>1,setViewport:fo,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:fo,fitBounds:fo,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},CD=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),TD=()=>{const e=yt(),{d3Zoom:t,d3Selection:n}=We(CD,_t);return x.useMemo(()=>n&&t?{zoomIn:s=>t.scaleBy(la(n,s==null?void 0:s.duration),1.2),zoomOut:s=>t.scaleBy(la(n,s==null?void 0:s.duration),1/1.2),zoomTo:(s,o)=>t.scaleTo(la(n,o==null?void 0:o.duration),s),getZoom:()=>e.getState().transform[2],setViewport:(s,o)=>{const[l,u,d]=e.getState().transform,f=qr.translate(s.x??l,s.y??u).scale(s.zoom??d);t.transform(la(n,o==null?void 0:o.duration),f)},getViewport:()=>{const[s,o,l]=e.getState().transform;return{x:s,y:o,zoom:l}},fitView:s=>RR(e.getState,s),setCenter:(s,o,l)=>{const{width:u,height:d,maxZoom:f}=e.getState(),h=typeof(l==null?void 0:l.zoom)<"u"?l.zoom:f,m=u/2-s*h,g=d/2-o*h,w=qr.translate(m,g).scale(h);t.transform(la(n,l==null?void 0:l.duration),w)},fitBounds:(s,o)=>{const{width:l,height:u,minZoom:d,maxZoom:f}=e.getState(),{x:h,y:m,zoom:g}=mR(s,l,u,d,f,(o==null?void 0:o.padding)??.1),w=qr.translate(h,m).scale(g);t.transform(la(n,o==null?void 0:o.duration),w)},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"),Pv(s,o,l,u)},screenToFlowPosition:s=>{const{transform:o,snapToGrid:l,snapGrid:u,domNode:d}=e.getState();if(!d)return s;const{x:f,y:h}=d.getBoundingClientRect(),m={x:s.x-f,y:s.y-h};return Pv(m,o,l,u)},flowToScreenPosition:s=>{const{transform:o,domNode:l}=e.getState();if(!l)return s;const{x:u,y:d}=l.getBoundingClientRect(),f=hR(s,o);return{x:f.x+u,y:f.y+d}},viewportInitialized:!0}:ED,[t,n])};function Go(){const e=TD(),t=yt(),n=x.useCallback(()=>t.getState().getNodes().map(v=>({...v})),[]),r=x.useCallback(v=>t.getState().nodeInternals.get(v),[]),s=x.useCallback(()=>{const{edges:v=[]}=t.getState();return v.map(b=>({...b}))},[]),o=x.useCallback(v=>{const{edges:b=[]}=t.getState();return b.find(S=>S.id===v)},[]),l=x.useCallback(v=>{const{getNodes:b,setNodes:S,hasDefaultNodes:_,onNodesChange:j}=t.getState(),E=b(),T=typeof v=="function"?v(E):v;if(_)S(T);else if(j){const R=T.length===0?E.map(M=>({type:"remove",id:M.id})):T.map(M=>({item:M,type:"reset"}));j(R)}},[]),u=x.useCallback(v=>{const{edges:b=[],setEdges:S,hasDefaultEdges:_,onEdgesChange:j}=t.getState(),E=typeof v=="function"?v(b):v;if(_)S(E);else if(j){const T=E.length===0?b.map(R=>({type:"remove",id:R.id})):E.map(R=>({item:R,type:"reset"}));j(T)}},[]),d=x.useCallback(v=>{const b=Array.isArray(v)?v:[v],{getNodes:S,setNodes:_,hasDefaultNodes:j,onNodesChange:E}=t.getState();if(j){const R=[...S(),...b];_(R)}else if(E){const T=b.map(R=>({item:R,type:"add"}));E(T)}},[]),f=x.useCallback(v=>{const b=Array.isArray(v)?v:[v],{edges:S=[],setEdges:_,hasDefaultEdges:j,onEdgesChange:E}=t.getState();if(j)_([...S,...b]);else if(E){const T=b.map(R=>({item:R,type:"add"}));E(T)}},[]),h=x.useCallback(()=>{const{getNodes:v,edges:b=[],transform:S}=t.getState(),[_,j,E]=S;return{nodes:v().map(T=>({...T})),edges:b.map(T=>({...T})),viewport:{x:_,y:j,zoom:E}}},[]),m=x.useCallback(({nodes:v,edges:b})=>{const{nodeInternals:S,getNodes:_,edges:j,hasDefaultNodes:E,hasDefaultEdges:T,onNodesDelete:R,onEdgesDelete:M,onNodesChange:O,onEdgesChange:I}=t.getState(),A=(v||[]).map(P=>P.id),L=(b||[]).map(P=>P.id),z=_().reduce((P,F)=>{const Y=F.parentNode||F.parentId,K=!A.includes(F.id)&&Y&&P.find(W=>W.id===Y);return(typeof F.deletable=="boolean"?F.deletable:!0)&&(A.includes(F.id)||K)&&P.push(F),P},[]),V=j.filter(P=>typeof P.deletable=="boolean"?P.deletable:!0),$=V.filter(P=>L.includes(P.id));if(z||$){const P=pR(z,V),F=[...$,...P],Y=F.reduce((K,D)=>(K.includes(D.id)||K.push(D.id),K),[]);if((T||E)&&(T&&t.setState({edges:j.filter(K=>!Y.includes(K.id))}),E&&(z.forEach(K=>{S.delete(K.id)}),t.setState({nodeInternals:new Map(S)}))),Y.length>0&&(M==null||M(F),I&&I(Y.map(K=>({id:K,type:"remove"})))),z.length>0&&(R==null||R(z),O)){const K=z.map(D=>({id:D.id,type:"remove"}));O(K)}}},[]),g=x.useCallback(v=>{const b=Y4(v),S=b?null:t.getState().nodeInternals.get(v.id);return!b&&!S?[null,null,b]:[b?v:P1(S),S,b]},[]),w=x.useCallback((v,b=!0,S)=>{const[_,j,E]=g(v);return _?(S||t.getState().getNodes()).filter(T=>{if(!E&&(T.id===j.id||!T.positionAbsolute))return!1;const R=P1(T),M=$v(R,_);return b&&M>0||M>=_.width*_.height}):[]},[]),k=x.useCallback((v,b,S=!0)=>{const[_]=g(v);if(!_)return!1;const j=$v(_,b);return S&&j>0||j>=_.width*_.height},[]);return x.useMemo(()=>({...e,getNodes:n,getNode:r,getEdges:s,getEdge:o,setNodes:l,setEdges:u,addNodes:d,addEdges:f,toObject:h,deleteElements:m,getIntersectingNodes:w,isNodeIntersecting:k}),[e,n,r,s,o,l,u,d,f,h,m,w,k])}const RD={actInsideInputWithModifier:!1};var AD=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=yt(),{deleteElements:r}=Go(),s=wl(e,RD),o=wl(t);x.useEffect(()=>{if(s){const{edges:l,getNodes:u}=n.getState(),d=u().filter(h=>h.selected),f=l.filter(h=>h.selected);r({nodes:d,edges:f}),n.setState({nodesSelectionActive:!1})}},[s]),x.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])};function MD(e){const t=yt();x.useEffect(()=>{let n;const r=()=>{var o,l;if(!e.current)return;const s=$x(e.current);(s.height===0||s.width===0)&&((l=(o=t.getState()).onError)==null||l.call(o,"004",Ur.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 zx={position:"absolute",width:"100%",height:"100%",top:0,left:0},$D=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,au=e=>({x:e.x,y:e.y,zoom:e.k}),po=(e,t)=>e.target.closest(`.${t}`),G1=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),K1=e=>{const t=e.ctrlKey&&Du()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},ID=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),OD=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:s=!0,zoomOnPinch:o=!0,panOnScroll:l=!1,panOnScrollSpeed:u=.5,panOnScrollMode:d=ha.Free,zoomOnDoubleClick:f=!0,elementsSelectable:h,panOnDrag:m=!0,defaultViewport:g,translateExtent:w,minZoom:k,maxZoom:v,zoomActivationKeyCode:b,preventScrolling:S=!0,children:_,noWheelClassName:j,noPanClassName:E})=>{const T=x.useRef(),R=yt(),M=x.useRef(!1),O=x.useRef(!1),I=x.useRef(null),A=x.useRef({x:0,y:0,zoom:0}),{d3Zoom:L,d3Selection:z,d3ZoomHandler:V,userSelectionActive:$}=We(ID,_t),P=wl(b),F=x.useRef(0),Y=x.useRef(!1),K=x.useRef();return MD(I),x.useEffect(()=>{if(I.current){const D=I.current.getBoundingClientRect(),W=tR().scaleExtent([k,v]).translateExtent(w),B=jn(I.current).call(W),X=qr.translate(g.x,g.y).scale(Do(g.zoom,k,v)),G=[[0,0],[D.width,D.height]],U=W.constrain()(X,G,w);W.transform(B,U),W.wheelDelta(K1),R.setState({d3Zoom:W,d3Selection:B,d3ZoomHandler:B.on("wheel.zoom"),transform:[U.x,U.y,U.k],domNode:I.current.closest(".react-flow")})}},[]),x.useEffect(()=>{z&&L&&(l&&!P&&!$?z.on("wheel.zoom",D=>{if(po(D,j))return!1;D.preventDefault(),D.stopImmediatePropagation();const W=z.property("__zoom").k||1;if(D.ctrlKey&&o){const ee=Fn(D),re=K1(D),oe=W*Math.pow(2,re);L.scaleTo(z,oe,ee,D);return}const B=D.deltaMode===1?20:1;let X=d===ha.Vertical?0:D.deltaX*B,G=d===ha.Horizontal?0:D.deltaY*B;!Du()&&D.shiftKey&&d!==ha.Vertical&&(X=D.deltaY*B,G=0),L.translateBy(z,-(X/W)*u,-(G/W)*u,{internal:!0});const U=au(z.property("__zoom")),{onViewportChangeStart:Z,onViewportChange:H,onViewportChangeEnd:J}=R.getState();clearTimeout(K.current),Y.current||(Y.current=!0,t==null||t(D,U),Z==null||Z(U)),Y.current&&(e==null||e(D,U),H==null||H(U),K.current=setTimeout(()=>{n==null||n(D,U),J==null||J(U),Y.current=!1},150))},{passive:!1}):typeof V<"u"&&z.on("wheel.zoom",function(D,W){if(!S&&D.type==="wheel"&&!D.ctrlKey||po(D,j))return null;D.preventDefault(),V.call(this,D,W)},{passive:!1}))},[$,l,d,z,L,V,P,o,S,j,t,e,n]),x.useEffect(()=>{L&&L.on("start",D=>{var X,G;if(!D.sourceEvent||D.sourceEvent.internal)return null;F.current=(X=D.sourceEvent)==null?void 0:X.button;const{onViewportChangeStart:W}=R.getState(),B=au(D.transform);M.current=!0,A.current=B,((G=D.sourceEvent)==null?void 0:G.type)==="mousedown"&&R.setState({paneDragging:!0}),W==null||W(B),t==null||t(D.sourceEvent,B)})},[L,t]),x.useEffect(()=>{L&&($&&!M.current?L.on("zoom",null):$||L.on("zoom",D=>{var B;const{onViewportChange:W}=R.getState();if(R.setState({transform:[D.transform.x,D.transform.y,D.transform.k]}),O.current=!!(r&&G1(m,F.current??0)),(e||W)&&!((B=D.sourceEvent)!=null&&B.internal)){const X=au(D.transform);W==null||W(X),e==null||e(D.sourceEvent,X)}}))},[$,L,e,m,r]),x.useEffect(()=>{L&&L.on("end",D=>{if(!D.sourceEvent||D.sourceEvent.internal)return null;const{onViewportChangeEnd:W}=R.getState();if(M.current=!1,R.setState({paneDragging:!1}),r&&G1(m,F.current??0)&&!O.current&&r(D.sourceEvent),O.current=!1,(n||W)&&$D(A.current,D.transform)){const B=au(D.transform);A.current=B,clearTimeout(T.current),T.current=setTimeout(()=>{W==null||W(B),n==null||n(D.sourceEvent,B)},l?150:0)}})},[L,l,m,n,r]),x.useEffect(()=>{L&&L.filter(D=>{const W=P||s,B=o&&D.ctrlKey;if((m===!0||Array.isArray(m)&&m.includes(1))&&D.button===1&&D.type==="mousedown"&&(po(D,"react-flow__node")||po(D,"react-flow__edge")))return!0;if(!m&&!W&&!l&&!f&&!o||$||!f&&D.type==="dblclick"||po(D,j)&&D.type==="wheel"||po(D,E)&&(D.type!=="wheel"||l&&D.type==="wheel"&&!P)||!o&&D.ctrlKey&&D.type==="wheel"||!W&&!l&&!B&&D.type==="wheel"||!m&&(D.type==="mousedown"||D.type==="touchstart")||Array.isArray(m)&&!m.includes(D.button)&&D.type==="mousedown")return!1;const X=Array.isArray(m)&&m.includes(D.button)||!D.button||D.button<=1;return(!D.ctrlKey||D.type==="wheel")&&X})},[$,L,s,o,l,f,m,h,P]),ce.createElement("div",{className:"react-flow__renderer",ref:I,style:zx},_)},LD=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function PD(){const{userSelectionActive:e,userSelectionRect:t}=We(LD,_t);return e&&t?ce.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 Y1(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 DD(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&&Y1(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&&Y1(r,l);break}case"remove":return r}return r.push(l),r},n)}function FD(e,t){return DD(e,t)}const ws=(e,t)=>({id:e,type:"select",selected:t});function _o(e,t){return e.reduce((n,r)=>{const s=t.includes(r.id);return!r.selected&&s?(r.selected=!0,n.push(ws(r.id,!0))):r.selected&&!s&&(r.selected=!1,n.push(ws(r.id,!1))),n},[])}const Df=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},qD=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),AR=x.memo(({isSelecting:e,selectionMode:t=yl.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:s,onPaneClick:o,onPaneContextMenu:l,onPaneScroll:u,onPaneMouseEnter:d,onPaneMouseMove:f,onPaneMouseLeave:h,children:m})=>{const g=x.useRef(null),w=yt(),k=x.useRef(0),v=x.useRef(0),b=x.useRef(),{userSelectionActive:S,elementsSelectable:_,dragging:j}=We(qD,_t),E=()=>{w.setState({userSelectionActive:!1,userSelectionRect:null}),k.current=0,v.current=0},T=V=>{o==null||o(V),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},R=V=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){V.preventDefault();return}l==null||l(V)},M=u?V=>u(V):void 0,O=V=>{const{resetSelectedElements:$,domNode:P}=w.getState();if(b.current=P==null?void 0:P.getBoundingClientRect(),!_||!e||V.button!==0||V.target!==g.current||!b.current)return;const{x:F,y:Y}=Ns(V,b.current);$(),w.setState({userSelectionRect:{width:0,height:0,startX:F,startY:Y,x:F,y:Y}}),r==null||r(V)},I=V=>{const{userSelectionRect:$,nodeInternals:P,edges:F,transform:Y,onNodesChange:K,onEdgesChange:D,nodeOrigin:W,getNodes:B}=w.getState();if(!e||!b.current||!$)return;w.setState({userSelectionActive:!0,nodesSelectionActive:!1});const X=Ns(V,b.current),G=$.startX??0,U=$.startY??0,Z={...$,x:X.x<G?X.x:G,y:X.y<U?X.y:U,width:Math.abs(X.x-G),height:Math.abs(X.y-U)},H=B(),J=fR(P,Z,Y,t===yl.Partial,!0,W),ee=pR(J,F).map(oe=>oe.id),re=J.map(oe=>oe.id);if(k.current!==re.length){k.current=re.length;const oe=_o(H,re);oe.length&&(K==null||K(oe))}if(v.current!==ee.length){v.current=ee.length;const oe=_o(F,ee);oe.length&&(D==null||D(oe))}w.setState({userSelectionRect:Z})},A=V=>{if(V.button!==0)return;const{userSelectionRect:$}=w.getState();!S&&$&&V.target===g.current&&(T==null||T(V)),w.setState({nodesSelectionActive:k.current>0}),E(),s==null||s(V)},L=V=>{S&&(w.setState({nodesSelectionActive:k.current>0}),s==null||s(V)),E()},z=_&&(e||S);return ce.createElement("div",{className:Ot(["react-flow__pane",{dragging:j,selection:e}]),onClick:z?void 0:Df(T,g),onContextMenu:Df(R,g),onWheel:Df(M,g),onMouseEnter:z?void 0:d,onMouseDown:z?O:void 0,onMouseMove:z?I:f,onMouseUp:z?A:void 0,onMouseLeave:z?L:h,ref:g,style:zx},m,ce.createElement(PD,null))});AR.displayName="Pane";function MR(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return r?r.selected?!0:MR(r,t):!1}function X1(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 BD(e,t,n,r){return Array.from(e.values()).filter(s=>(s.selected||s.id===r)&&(!s.parentNode||s.parentId||!MR(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 zD(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function $R(e,t,n,r,s=[0,0],o){const l=zD(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 m=n.get(d),{x:g,y:w}=ma(m,s).positionAbsolute;u=m&&_n(g)&&_n(w)&&_n(m.width)&&_n(m.height)?[[g+e.width*s[0],w+e.height*s[1]],[g+m.width-e.width+e.width*s[0],w+m.height-e.height+e.height*s[1]]]:u}else o==null||o("005",Ur.error005()),u=l;else if(e.extent&&d&&e.extent!=="parent"){const m=n.get(d),{x:g,y:w}=ma(m,s).positionAbsolute;u=[[e.extent[0][0]+g,e.extent[0][1]+w],[e.extent[1][0]+g,e.extent[1][1]+w]]}let f={x:0,y:0};if(d){const m=n.get(d);f=ma(m,s).positionAbsolute}const h=u&&u!=="parent"?Ix(t,u):t;return{position:{x:h.x-f.x,y:h.y-f.y},positionAbsolute:h}}function Ff({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 Z1=(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 f=d.getBoundingClientRect();return{id:d.getAttribute("data-handleid"),position:d.getAttribute("data-handlepos"),x:(f.left-l.left-u.x)/n,y:(f.top-l.top-u.y)/n,...$x(d)}})};function Yi(e,t,n){return n===void 0?n:r=>{const s=t().nodeInternals.get(e);s&&n(r,{...s})}}function Fv({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:o,multiSelectionActive:l,nodeInternals:u,onError:d}=t.getState(),f=u.get(e);if(!f){d==null||d("012",Ur.error012(e));return}t.setState({nodesSelectionActive:!1}),f.selected?(n||f.selected&&l)&&(o({nodes:[f],edges:[]}),requestAnimationFrame(()=>{var h;return(h=r==null?void 0:r.current)==null?void 0:h.blur()})):s([e])}function UD(){const e=yt();return x.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 qf(e){return(t,n,r)=>e==null?void 0:e(t,r)}function IR({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:o,selectNodesOnDrag:l}){const u=yt(),[d,f]=x.useState(!1),h=x.useRef([]),m=x.useRef({x:null,y:null}),g=x.useRef(0),w=x.useRef(null),k=x.useRef({x:0,y:0}),v=x.useRef(null),b=x.useRef(!1),S=x.useRef(!1),_=x.useRef(!1),j=UD();return x.useEffect(()=>{if(e!=null&&e.current){const E=jn(e.current),T=({x:O,y:I})=>{const{nodeInternals:A,onNodeDrag:L,onSelectionDrag:z,updateNodePositions:V,nodeExtent:$,snapGrid:P,snapToGrid:F,nodeOrigin:Y,onError:K}=u.getState();m.current={x:O,y:I};let D=!1,W={x:0,y:0,x2:0,y2:0};if(h.current.length>1&&$){const X=fd(h.current,Y);W=gl(X)}if(h.current=h.current.map(X=>{const G={x:O-X.distance.x,y:I-X.distance.y};F&&(G.x=P[0]*Math.round(G.x/P[0]),G.y=P[1]*Math.round(G.y/P[1]));const U=[[$[0][0],$[0][1]],[$[1][0],$[1][1]]];h.current.length>1&&$&&!X.extent&&(U[0][0]=X.positionAbsolute.x-W.x+$[0][0],U[1][0]=X.positionAbsolute.x+(X.width??0)-W.x2+$[1][0],U[0][1]=X.positionAbsolute.y-W.y+$[0][1],U[1][1]=X.positionAbsolute.y+(X.height??0)-W.y2+$[1][1]);const Z=$R(X,G,A,U,Y,K);return D=D||X.position.x!==Z.position.x||X.position.y!==Z.position.y,X.position=Z.position,X.positionAbsolute=Z.positionAbsolute,X}),!D)return;V(h.current,!0,!0),f(!0);const B=s?L:qf(z);if(B&&v.current){const[X,G]=Ff({nodeId:s,dragItems:h.current,nodeInternals:A});B(v.current,X,G)}},R=()=>{if(!w.current)return;const[O,I]=rR(k.current,w.current);if(O!==0||I!==0){const{transform:A,panBy:L}=u.getState();m.current.x=(m.current.x??0)-O/A[2],m.current.y=(m.current.y??0)-I/A[2],L({x:O,y:I})&&T(m.current)}g.current=requestAnimationFrame(R)},M=O=>{var Y;const{nodeInternals:I,multiSelectionActive:A,nodesDraggable:L,unselectNodesAndEdges:z,onNodeDragStart:V,onSelectionDragStart:$}=u.getState();S.current=!0;const P=s?V:qf($);(!l||!o)&&!A&&s&&((Y=I.get(s))!=null&&Y.selected||z()),s&&o&&l&&Fv({id:s,store:u,nodeRef:e});const F=j(O);if(m.current=F,h.current=BD(I,L,F,s),P&&h.current){const[K,D]=Ff({nodeId:s,dragItems:h.current,nodeInternals:I});P(O.sourceEvent,K,D)}};if(t)E.on(".drag",null);else{const O=QP().on("start",I=>{const{domNode:A,nodeDragThreshold:L}=u.getState();L===0&&M(I),_.current=!1;const z=j(I);m.current=z,w.current=(A==null?void 0:A.getBoundingClientRect())||null,k.current=Ns(I.sourceEvent,w.current)}).on("drag",I=>{var V,$;const A=j(I),{autoPanOnNodeDrag:L,nodeDragThreshold:z}=u.getState();if(I.sourceEvent.type==="touchmove"&&I.sourceEvent.touches.length>1&&(_.current=!0),!_.current){if(!b.current&&S.current&&L&&(b.current=!0,R()),!S.current){const P=A.xSnapped-(((V=m==null?void 0:m.current)==null?void 0:V.x)??0),F=A.ySnapped-((($=m==null?void 0:m.current)==null?void 0:$.y)??0);Math.sqrt(P*P+F*F)>z&&M(I)}(m.current.x!==A.xSnapped||m.current.y!==A.ySnapped)&&h.current&&S.current&&(v.current=I.sourceEvent,k.current=Ns(I.sourceEvent,w.current),T(A))}}).on("end",I=>{if(!(!S.current||_.current)&&(f(!1),b.current=!1,S.current=!1,cancelAnimationFrame(g.current),h.current)){const{updateNodePositions:A,nodeInternals:L,onNodeDragStop:z,onSelectionDragStop:V}=u.getState(),$=s?z:qf(V);if(A(h.current,!1,!1),$){const[P,F]=Ff({nodeId:s,dragItems:h.current,nodeInternals:L});$(I.sourceEvent,P,F)}}}).filter(I=>{const A=I.target;return!I.button&&(!n||!X1(A,`.${n}`,e))&&(!r||X1(A,r,e))});return E.call(O),()=>{E.on(".drag",null)}}}},[e,t,n,r,o,u,s,l,j]),d}function OR(){const e=yt();return x.useCallback(n=>{const{nodeInternals:r,nodeExtent:s,updateNodePositions:o,getNodes:l,snapToGrid:u,snapGrid:d,onError:f,nodesDraggable:h}=e.getState(),m=l().filter(_=>_.selected&&(_.draggable||h&&typeof _.draggable>"u")),g=u?d[0]:5,w=u?d[1]:5,k=n.isShiftPressed?4:1,v=n.x*g*k,b=n.y*w*k,S=m.map(_=>{if(_.positionAbsolute){const j={x:_.positionAbsolute.x+v,y:_.positionAbsolute.y+b};u&&(j.x=d[0]*Math.round(j.x/d[0]),j.y=d[1]*Math.round(j.y/d[1]));const{positionAbsolute:E,position:T}=$R(_,j,r,s,void 0,f);_.position=T,_.positionAbsolute=E}return _});o(S,!0,!1)},[])}const Mo={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var Xi=e=>{const t=({id:n,type:r,data:s,xPos:o,yPos:l,xPosOrigin:u,yPosOrigin:d,selected:f,onClick:h,onMouseEnter:m,onMouseMove:g,onMouseLeave:w,onContextMenu:k,onDoubleClick:v,style:b,className:S,isDraggable:_,isSelectable:j,isConnectable:E,isFocusable:T,selectNodesOnDrag:R,sourcePosition:M,targetPosition:O,hidden:I,resizeObserver:A,dragHandle:L,zIndex:z,isParent:V,noDragClassName:$,noPanClassName:P,initialized:F,disableKeyboardA11y:Y,ariaLabel:K,rfId:D,hasHandleBounds:W})=>{const B=yt(),X=x.useRef(null),G=x.useRef(null),U=x.useRef(M),Z=x.useRef(O),H=x.useRef(r),J=j||_||h||m||g||w,ee=OR(),re=Yi(n,B.getState,m),oe=Yi(n,B.getState,g),fe=Yi(n,B.getState,w),Ne=Yi(n,B.getState,k),ke=Yi(n,B.getState,v),we=ye=>{const{nodeDragThreshold:ue}=B.getState();if(j&&(!R||!_||ue>0)&&Fv({id:n,store:B,nodeRef:X}),h){const se=B.getState().nodeInternals.get(n);se&&h(ye,{...se})}},ve=ye=>{if(!Iv(ye)&&!Y)if(iR.includes(ye.key)&&j){const ue=ye.key==="Escape";Fv({id:n,store:B,unselect:ue,nodeRef:X})}else _&&f&&Object.prototype.hasOwnProperty.call(Mo,ye.key)&&(B.setState({ariaLiveMessage:`Moved selected node ${ye.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~l}`}),ee({x:Mo[ye.key].x,y:Mo[ye.key].y,isShiftPressed:ye.shiftKey}))};x.useEffect(()=>()=>{G.current&&(A==null||A.unobserve(G.current),G.current=null)},[]),x.useEffect(()=>{if(X.current&&!I){const ye=X.current;(!F||!W||G.current!==ye)&&(G.current&&(A==null||A.unobserve(G.current)),A==null||A.observe(ye),G.current=ye)}},[I,F,W]),x.useEffect(()=>{const ye=H.current!==r,ue=U.current!==M,se=Z.current!==O;X.current&&(ye||ue||se)&&(ye&&(H.current=r),ue&&(U.current=M),se&&(Z.current=O),B.getState().updateNodeDimensions([{id:n,nodeElement:X.current,forceUpdate:!0}]))},[n,r,M,O]);const $e=IR({nodeRef:X,disabled:I||!_,noDragClassName:$,handleSelector:L,nodeId:n,isSelectable:j,selectNodesOnDrag:R});return I?null:ce.createElement("div",{className:Ot(["react-flow__node",`react-flow__node-${r}`,{[P]:_},S,{selected:f,selectable:j,parent:V,dragging:$e}]),ref:X,style:{zIndex:z,transform:`translate(${u}px,${d}px)`,pointerEvents:J?"all":"none",visibility:F?"visible":"hidden",...b},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:re,onMouseMove:oe,onMouseLeave:fe,onContextMenu:Ne,onClick:we,onDoubleClick:ke,onKeyDown:T?ve:void 0,tabIndex:T?0:void 0,role:T?"button":void 0,"aria-describedby":Y?void 0:`${_R}-${D}`,"aria-label":K},ce.createElement(nD,{value:n},ce.createElement(e,{id:n,data:s,type:r,xPos:o,yPos:l,selected:f,isConnectable:E,sourcePosition:M,targetPosition:O,dragging:$e,dragHandle:L,zIndex:z})))};return t.displayName="NodeWrapper",x.memo(t)};const HD=e=>{const t=e.getNodes().filter(n=>n.selected);return{...fd(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function WD({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=yt(),{width:s,height:o,x:l,y:u,transformString:d,userSelectionActive:f}=We(HD,_t),h=OR(),m=x.useRef(null);if(x.useEffect(()=>{var k;n||(k=m.current)==null||k.focus({preventScroll:!0})},[n]),IR({nodeRef:m}),f||!s||!o)return null;const g=e?k=>{const v=r.getState().getNodes().filter(b=>b.selected);e(k,v)}:void 0,w=k=>{Object.prototype.hasOwnProperty.call(Mo,k.key)&&h({x:Mo[k.key].x,y:Mo[k.key].y,isShiftPressed:k.shiftKey})};return ce.createElement("div",{className:Ot(["react-flow__nodesselection","react-flow__container",t]),style:{transform:d}},ce.createElement("div",{ref:m,className:"react-flow__nodesselection-rect",onContextMenu:g,tabIndex:n?void 0:-1,onKeyDown:n?void 0:w,style:{width:s,height:o,top:u,left:l}}))}var VD=x.memo(WD);const GD=e=>e.nodesSelectionActive,LR=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:l,deleteKeyCode:u,onMove:d,onMoveStart:f,onMoveEnd:h,selectionKeyCode:m,selectionOnDrag:g,selectionMode:w,onSelectionStart:k,onSelectionEnd:v,multiSelectionKeyCode:b,panActivationKeyCode:S,zoomActivationKeyCode:_,elementsSelectable:j,zoomOnScroll:E,zoomOnPinch:T,panOnScroll:R,panOnScrollSpeed:M,panOnScrollMode:O,zoomOnDoubleClick:I,panOnDrag:A,defaultViewport:L,translateExtent:z,minZoom:V,maxZoom:$,preventScrolling:P,onSelectionContextMenu:F,noWheelClassName:Y,noPanClassName:K,disableKeyboardA11y:D})=>{const W=We(GD),B=wl(m),X=wl(S),G=X||A,U=X||R,Z=B||g&&G!==!0;return AD({deleteKeyCode:u,multiSelectionKeyCode:b}),ce.createElement(OD,{onMove:d,onMoveStart:f,onMoveEnd:h,onPaneContextMenu:o,elementsSelectable:j,zoomOnScroll:E,zoomOnPinch:T,panOnScroll:U,panOnScrollSpeed:M,panOnScrollMode:O,zoomOnDoubleClick:I,panOnDrag:!B&&G,defaultViewport:L,translateExtent:z,minZoom:V,maxZoom:$,zoomActivationKeyCode:_,preventScrolling:P,noWheelClassName:Y,noPanClassName:K},ce.createElement(AR,{onSelectionStart:k,onSelectionEnd:v,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:l,panOnDrag:G,isSelecting:!!Z,selectionMode:w},e,W&&ce.createElement(VD,{onSelectionContextMenu:F,noPanClassName:K,disableKeyboardA11y:D})))};LR.displayName="FlowRenderer";var KD=x.memo(LR);function YD(e){return We(x.useCallback(n=>e?fR(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function XD(e){const t={input:Xi(e.input||kR),default:Xi(e.default||Dv),output:Xi(e.output||SR),group:Xi(e.group||Bx)},n={},r=Object.keys(e).filter(s=>!["input","default","output","group"].includes(s)).reduce((s,o)=>(s[o]=Xi(e[o]||Dv),s),n);return{...t,...r}}const ZD=({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]},JD=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),PR=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,updateNodeDimensions:o,onError:l}=We(JD,_t),u=YD(e.onlyRenderVisibleElements),d=x.useRef(),f=x.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const h=new ResizeObserver(m=>{const g=m.map(w=>({id:w.target.getAttribute("data-id"),nodeElement:w.target,forceUpdate:!0}));o(g)});return d.current=h,h},[]);return x.useEffect(()=>()=>{var h;(h=d==null?void 0:d.current)==null||h.disconnect()},[]),ce.createElement("div",{className:"react-flow__nodes",style:zx},u.map(h=>{var T,R,M;let m=h.type||"default";e.nodeTypes[m]||(l==null||l("003",Ur.error003(m)),m="default");const g=e.nodeTypes[m]||e.nodeTypes.default,w=!!(h.draggable||t&&typeof h.draggable>"u"),k=!!(h.selectable||s&&typeof h.selectable>"u"),v=!!(h.connectable||n&&typeof h.connectable>"u"),b=!!(h.focusable||r&&typeof h.focusable>"u"),S=e.nodeExtent?Ix(h.positionAbsolute,e.nodeExtent):h.positionAbsolute,_=(S==null?void 0:S.x)??0,j=(S==null?void 0:S.y)??0,E=ZD({x:_,y:j,width:h.width??0,height:h.height??0,origin:e.nodeOrigin});return ce.createElement(g,{key:h.id,id:h.id,className:h.className,style:h.style,type:m,data:h.data,sourcePosition:h.sourcePosition||Ce.Bottom,targetPosition:h.targetPosition||Ce.Top,hidden:h.hidden,xPos:_,yPos:j,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:!!h.selected,isDraggable:w,isSelectable:k,isConnectable:v,isFocusable:b,resizeObserver:f,dragHandle:h.dragHandle,zIndex:((T=h[ht])==null?void 0:T.z)??0,isParent:!!((R=h[ht])!=null&&R.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!h.width&&!!h.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:h.ariaLabel,hasHandleBounds:!!((M=h[ht])!=null&&M.handleBounds)})}))};PR.displayName="NodeRenderer";var QD=x.memo(PR);const e5=(e,t,n)=>n===Ce.Left?e-t:n===Ce.Right?e+t:e,t5=(e,t,n)=>n===Ce.Top?e-t:n===Ce.Bottom?e+t:e,J1="react-flow__edgeupdater",Q1=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:o,onMouseOut:l,type:u})=>ce.createElement("circle",{onMouseDown:s,onMouseEnter:o,onMouseOut:l,className:Ot([J1,`${J1}-${u}`]),cx:e5(t,r,e),cy:t5(n,r,e),r,stroke:"transparent",fill:"transparent"}),n5=()=>!0;var mo=e=>{const t=({id:n,className:r,type:s,data:o,onClick:l,onEdgeDoubleClick:u,selected:d,animated:f,label:h,labelStyle:m,labelShowBg:g,labelBgStyle:w,labelBgPadding:k,labelBgBorderRadius:v,style:b,source:S,target:_,sourceX:j,sourceY:E,targetX:T,targetY:R,sourcePosition:M,targetPosition:O,elementsSelectable:I,hidden:A,sourceHandleId:L,targetHandleId:z,onContextMenu:V,onMouseEnter:$,onMouseMove:P,onMouseLeave:F,reconnectRadius:Y,onReconnect:K,onReconnectStart:D,onReconnectEnd:W,markerEnd:B,markerStart:X,rfId:G,ariaLabel:U,isFocusable:Z,isReconnectable:H,pathOptions:J,interactionWidth:ee,disableKeyboardA11y:re})=>{const oe=x.useRef(null),[fe,Ne]=x.useState(!1),[ke,we]=x.useState(!1),ve=yt(),$e=x.useMemo(()=>`url('#${Lv(X,G)}')`,[X,G]),ye=x.useMemo(()=>`url('#${Lv(B,G)}')`,[B,G]);if(A)return null;const ue=Ve=>{var Oe;const{edges:ut,addSelectedEdges:Ze,unselectNodesAndEdges:ot,multiSelectionActive:Gt}=ve.getState(),ge=ut.find(Fe=>Fe.id===n);ge&&(I&&(ve.setState({nodesSelectionActive:!1}),ge.selected&&Gt?(ot({nodes:[],edges:[ge]}),(Oe=oe.current)==null||Oe.blur()):Ze([n])),l&&l(Ve,ge))},se=Ki(n,ve.getState,u),xe=Ki(n,ve.getState,V),Ae=Ki(n,ve.getState,$),Le=Ki(n,ve.getState,P),Ie=Ki(n,ve.getState,F),qe=(Ve,ut)=>{if(Ve.button!==0)return;const{edges:Ze,isValidConnection:ot}=ve.getState(),Gt=ut?_:S,ge=(ut?z:L)||null,Oe=ut?"target":"source",Fe=ot||n5,Lt=ut,Kt=Ze.find(Ut=>Ut.id===n);we(!0),D==null||D(Ve,Kt,Oe);const Mt=Ut=>{we(!1),W==null||W(Ut,Kt,Oe)};wR({event:Ve,handleId:ge,nodeId:Gt,onConnect:Ut=>K==null?void 0:K(Kt,Ut),isTarget:Lt,getState:ve.getState,setState:ve.setState,isValidConnection:Fe,edgeUpdaterType:Oe,onReconnectEnd:Mt})},nt=Ve=>qe(Ve,!0),rt=Ve=>qe(Ve,!1),Ye=()=>Ne(!0),ct=()=>Ne(!1),At=!I&&!l,vt=Ve=>{var ut;if(!re&&iR.includes(Ve.key)&&I){const{unselectNodesAndEdges:Ze,addSelectedEdges:ot,edges:Gt}=ve.getState();Ve.key==="Escape"?((ut=oe.current)==null||ut.blur(),Ze({edges:[Gt.find(Oe=>Oe.id===n)]})):ot([n])}};return ce.createElement("g",{className:Ot(["react-flow__edge",`react-flow__edge-${s}`,r,{selected:d,animated:f,inactive:At,updating:fe}]),onClick:ue,onDoubleClick:se,onContextMenu:xe,onMouseEnter:Ae,onMouseMove:Le,onMouseLeave:Ie,onKeyDown:Z?vt:void 0,tabIndex:Z?0:void 0,role:Z?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":U===null?void 0:U||`Edge from ${S} to ${_}`,"aria-describedby":Z?`${ER}-${G}`:void 0,ref:oe},!ke&&ce.createElement(e,{id:n,source:S,target:_,selected:d,animated:f,label:h,labelStyle:m,labelShowBg:g,labelBgStyle:w,labelBgPadding:k,labelBgBorderRadius:v,data:o,style:b,sourceX:j,sourceY:E,targetX:T,targetY:R,sourcePosition:M,targetPosition:O,sourceHandleId:L,targetHandleId:z,markerStart:$e,markerEnd:ye,pathOptions:J,interactionWidth:ee}),H&&ce.createElement(ce.Fragment,null,(H==="source"||H===!0)&&ce.createElement(Q1,{position:M,centerX:j,centerY:E,radius:Y,onMouseDown:nt,onMouseEnter:Ye,onMouseOut:ct,type:"source"}),(H==="target"||H===!0)&&ce.createElement(Q1,{position:O,centerX:T,centerY:R,radius:Y,onMouseDown:rt,onMouseEnter:Ye,onMouseOut:ct,type:"target"})))};return t.displayName="EdgeWrapper",x.memo(t)};function r5(e){const t={default:mo(e.default||qu),straight:mo(e.bezier||Px),step:mo(e.step||Lx),smoothstep:mo(e.step||hd),simplebezier:mo(e.simplebezier||Ox)},n={},r=Object.keys(e).filter(s=>!["default","bezier"].includes(s)).reduce((s,o)=>(s[o]=mo(e[o]||qu),s),n);return{...t,...r}}function eN(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 Ce.Top:return{x:r+o/2,y:s};case Ce.Right:return{x:r+o,y:s+l/2};case Ce.Bottom:return{x:r+o/2,y:s+l};case Ce.Left:return{x:r,y:s+l/2}}}function tN(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const s5=(e,t,n,r,s,o)=>{const l=eN(n,e,t),u=eN(o,r,s);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y}};function a5({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:s,targetHeight:o,width:l,height:u,transform:d}){const f={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)};f.x===f.x2&&(f.x2+=1),f.y===f.y2&&(f.y2+=1);const h=gl({x:(0-d[0])/d[2],y:(0-d[1])/d[2],width:l/d[2],height:u/d[2]}),m=Math.max(0,Math.min(h.x2,f.x2)-Math.max(h.x,f.x)),g=Math.max(0,Math.min(h.y2,f.y2)-Math.max(h.y,f.y));return Math.ceil(m*g)>0}function nN(e){var r,s,o,l,u;const t=((r=e==null?void 0:e[ht])==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 o5=[{level:0,isMaxLevel:!0,edges:[]}];function i5(e,t,n=!1){let r=-1;const s=e.reduce((l,u)=>{var h,m;const d=_n(u.zIndex);let f=d?u.zIndex:0;if(n){const g=t.get(u.target),w=t.get(u.source),k=u.selected||(g==null?void 0:g.selected)||(w==null?void 0:w.selected),v=Math.max(((h=w==null?void 0:w[ht])==null?void 0:h.z)||0,((m=g==null?void 0:g[ht])==null?void 0:m.z)||0,1e3);f=(d?u.zIndex:0)+(k?v:0)}return l[f]?l[f].push(u):l[f]=[u],r=f>r?f:r,l},{}),o=Object.entries(s).map(([l,u])=>{const d=+l;return{edges:u,level:d,isMaxLevel:d===r}});return o.length===0?o5:o}function l5(e,t,n){const r=We(x.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)&&a5({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 i5(r,t,n)}const c5=({color:e="none",strokeWidth:t=1})=>ce.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),u5=({color:e="none",strokeWidth:t=1})=>ce.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),rN={[Fu.Arrow]:c5,[Fu.ArrowClosed]:u5};function d5(e){const t=yt();return x.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(rN,e)?rN[e]:((o=(s=t.getState()).onError)==null||o.call(s,"009",Ur.error009(e)),null)},[e])}const h5=({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=d5(t);return d?ce.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"},ce.createElement(d,{color:n,strokeWidth:l})):null},f5=({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=Lv(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))},DR=({defaultColor:e,rfId:t})=>{const n=We(x.useCallback(f5({defaultColor:e,rfId:t}),[e,t]),(r,s)=>!(r.length!==s.length||r.some((o,l)=>o.id!==s[l].id)));return ce.createElement("defs",null,n.map(r=>ce.createElement(h5,{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})))};DR.displayName="MarkerDefinitions";var p5=x.memo(DR);const m5=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}),FR=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:s,noPanClassName:o,onEdgeContextMenu:l,onEdgeMouseEnter:u,onEdgeMouseMove:d,onEdgeMouseLeave:f,onEdgeClick:h,onEdgeDoubleClick:m,onReconnect:g,onReconnectStart:w,onReconnectEnd:k,reconnectRadius:v,children:b,disableKeyboardA11y:S})=>{const{edgesFocusable:_,edgesUpdatable:j,elementsSelectable:E,width:T,height:R,connectionMode:M,nodeInternals:O,onError:I}=We(m5,_t),A=l5(t,O,n);return T?ce.createElement(ce.Fragment,null,A.map(({level:L,edges:z,isMaxLevel:V})=>ce.createElement("svg",{key:L,style:{zIndex:L},width:T,height:R,className:"react-flow__edges react-flow__container"},V&&ce.createElement(p5,{defaultColor:e,rfId:r}),ce.createElement("g",null,z.map($=>{const[P,F,Y]=nN(O.get($.source)),[K,D,W]=nN(O.get($.target));if(!Y||!W)return null;let B=$.type||"default";s[B]||(I==null||I("011",Ur.error011(B)),B="default");const X=s[B]||s.default,G=M===va.Strict?D.target:(D.target??[]).concat(D.source??[]),U=tN(F.source,$.sourceHandle),Z=tN(G,$.targetHandle),H=(U==null?void 0:U.position)||Ce.Bottom,J=(Z==null?void 0:Z.position)||Ce.Top,ee=!!($.focusable||_&&typeof $.focusable>"u"),re=$.reconnectable||$.updatable,oe=typeof g<"u"&&(re||j&&typeof re>"u");if(!U||!Z)return I==null||I("008",Ur.error008(U,$)),null;const{sourceX:fe,sourceY:Ne,targetX:ke,targetY:we}=s5(P,U,H,K,Z,J);return ce.createElement(X,{key:$.id,id:$.id,className:Ot([$.className,o]),type:B,data:$.data,selected:!!$.selected,animated:!!$.animated,hidden:!!$.hidden,label:$.label,labelStyle:$.labelStyle,labelShowBg:$.labelShowBg,labelBgStyle:$.labelBgStyle,labelBgPadding:$.labelBgPadding,labelBgBorderRadius:$.labelBgBorderRadius,style:$.style,source:$.source,target:$.target,sourceHandleId:$.sourceHandle,targetHandleId:$.targetHandle,markerEnd:$.markerEnd,markerStart:$.markerStart,sourceX:fe,sourceY:Ne,targetX:ke,targetY:we,sourcePosition:H,targetPosition:J,elementsSelectable:E,onContextMenu:l,onMouseEnter:u,onMouseMove:d,onMouseLeave:f,onClick:h,onEdgeDoubleClick:m,onReconnect:g,onReconnectStart:w,onReconnectEnd:k,reconnectRadius:v,rfId:r,ariaLabel:$.ariaLabel,isFocusable:ee,isReconnectable:oe,pathOptions:"pathOptions"in $?$.pathOptions:void 0,interactionWidth:$.interactionWidth,disableKeyboardA11y:S})})))),b):null};FR.displayName="EdgeRenderer";var g5=x.memo(FR);const y5=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function w5({children:e}){const t=We(y5);return ce.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function v5(e){const t=Go(),n=x.useRef(!1);x.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const x5={[Ce.Left]:Ce.Right,[Ce.Right]:Ce.Left,[Ce.Top]:Ce.Bottom,[Ce.Bottom]:Ce.Top},qR=({nodeId:e,handleType:t,style:n,type:r=vs.Bezier,CustomComponent:s,connectionStatus:o})=>{var R,M,O;const{fromNode:l,handleId:u,toX:d,toY:f,connectionMode:h}=We(x.useCallback(I=>({fromNode:I.nodeInternals.get(e),handleId:I.connectionHandleId,toX:(I.connectionPosition.x-I.transform[0])/I.transform[2],toY:(I.connectionPosition.y-I.transform[1])/I.transform[2],connectionMode:I.connectionMode}),[e]),_t),m=(R=l==null?void 0:l[ht])==null?void 0:R.handleBounds;let g=m==null?void 0:m[t];if(h===va.Loose&&(g=g||(m==null?void 0:m[t==="source"?"target":"source"])),!l||!g)return null;const w=u?g.find(I=>I.id===u):g[0],k=w?w.x+w.width/2:(l.width??0)/2,v=w?w.y+w.height/2:l.height??0,b=(((M=l.positionAbsolute)==null?void 0:M.x)??0)+k,S=(((O=l.positionAbsolute)==null?void 0:O.y)??0)+v,_=w==null?void 0:w.position,j=_?x5[_]:null;if(!_||!j)return null;if(s)return ce.createElement(s,{connectionLineType:r,connectionLineStyle:n,fromNode:l,fromHandle:w,fromX:b,fromY:S,toX:d,toY:f,fromPosition:_,toPosition:j,connectionStatus:o});let E="";const T={sourceX:b,sourceY:S,sourcePosition:_,targetX:d,targetY:f,targetPosition:j};return r===vs.Bezier?[E]=Dx(T):r===vs.Step?[E]=Ov({...T,borderRadius:0}):r===vs.SmoothStep?[E]=Ov(T):r===vs.SimpleBezier?[E]=dR(T):E=`M${b},${S} ${d},${f}`,ce.createElement("path",{d:E,fill:"none",className:"react-flow__connection-path",style:n})};qR.displayName="ConnectionLine";const b5=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function k5({containerStyle:e,style:t,type:n,component:r}){const{nodeId:s,handleType:o,nodesConnectable:l,width:u,height:d,connectionStatus:f}=We(b5,_t);return!(s&&o&&u&&l)?null:ce.createElement("svg",{style:e,width:u,height:d,className:"react-flow__edges react-flow__connectionline react-flow__container"},ce.createElement("g",{className:Ot(["react-flow__connection",f])},ce.createElement(qR,{nodeId:s,handleType:o,style:t,type:n,CustomComponent:r,connectionStatus:f})))}function sN(e,t){return x.useRef(null),yt(),x.useMemo(()=>t(e),[e])}const BR=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:s,onInit:o,onNodeClick:l,onEdgeClick:u,onNodeDoubleClick:d,onEdgeDoubleClick:f,onNodeMouseEnter:h,onNodeMouseMove:m,onNodeMouseLeave:g,onNodeContextMenu:w,onSelectionContextMenu:k,onSelectionStart:v,onSelectionEnd:b,connectionLineType:S,connectionLineStyle:_,connectionLineComponent:j,connectionLineContainerStyle:E,selectionKeyCode:T,selectionOnDrag:R,selectionMode:M,multiSelectionKeyCode:O,panActivationKeyCode:I,zoomActivationKeyCode:A,deleteKeyCode:L,onlyRenderVisibleElements:z,elementsSelectable:V,selectNodesOnDrag:$,defaultViewport:P,translateExtent:F,minZoom:Y,maxZoom:K,preventScrolling:D,defaultMarkerColor:W,zoomOnScroll:B,zoomOnPinch:X,panOnScroll:G,panOnScrollSpeed:U,panOnScrollMode:Z,zoomOnDoubleClick:H,panOnDrag:J,onPaneClick:ee,onPaneMouseEnter:re,onPaneMouseMove:oe,onPaneMouseLeave:fe,onPaneScroll:Ne,onPaneContextMenu:ke,onEdgeContextMenu:we,onEdgeMouseEnter:ve,onEdgeMouseMove:$e,onEdgeMouseLeave:ye,onReconnect:ue,onReconnectStart:se,onReconnectEnd:xe,reconnectRadius:Ae,noDragClassName:Le,noWheelClassName:Ie,noPanClassName:qe,elevateEdgesOnSelect:nt,disableKeyboardA11y:rt,nodeOrigin:Ye,nodeExtent:ct,rfId:At})=>{const vt=sN(e,XD),Ve=sN(t,r5);return v5(o),ce.createElement(KD,{onPaneClick:ee,onPaneMouseEnter:re,onPaneMouseMove:oe,onPaneMouseLeave:fe,onPaneContextMenu:ke,onPaneScroll:Ne,deleteKeyCode:L,selectionKeyCode:T,selectionOnDrag:R,selectionMode:M,onSelectionStart:v,onSelectionEnd:b,multiSelectionKeyCode:O,panActivationKeyCode:I,zoomActivationKeyCode:A,elementsSelectable:V,onMove:n,onMoveStart:r,onMoveEnd:s,zoomOnScroll:B,zoomOnPinch:X,zoomOnDoubleClick:H,panOnScroll:G,panOnScrollSpeed:U,panOnScrollMode:Z,panOnDrag:J,defaultViewport:P,translateExtent:F,minZoom:Y,maxZoom:K,onSelectionContextMenu:k,preventScrolling:D,noDragClassName:Le,noWheelClassName:Ie,noPanClassName:qe,disableKeyboardA11y:rt},ce.createElement(w5,null,ce.createElement(g5,{edgeTypes:Ve,onEdgeClick:u,onEdgeDoubleClick:f,onlyRenderVisibleElements:z,onEdgeContextMenu:we,onEdgeMouseEnter:ve,onEdgeMouseMove:$e,onEdgeMouseLeave:ye,onReconnect:ue,onReconnectStart:se,onReconnectEnd:xe,reconnectRadius:Ae,defaultMarkerColor:W,noPanClassName:qe,elevateEdgesOnSelect:!!nt,disableKeyboardA11y:rt,rfId:At},ce.createElement(k5,{style:_,type:S,component:j,containerStyle:E})),ce.createElement("div",{className:"react-flow__edgelabel-renderer"}),ce.createElement(QD,{nodeTypes:vt,onNodeClick:l,onNodeDoubleClick:d,onNodeMouseEnter:h,onNodeMouseMove:m,onNodeMouseLeave:g,onNodeContextMenu:w,selectNodesOnDrag:$,onlyRenderVisibleElements:z,noPanClassName:qe,noDragClassName:Le,disableKeyboardA11y:rt,nodeOrigin:Ye,nodeExtent:ct,rfId:At})))};BR.displayName="GraphView";var N5=x.memo(BR);const qv=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ms={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:qv,nodeExtent:qv,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:va.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:X4,isValidConnection:void 0},S5=()=>dL((e,t)=>({...ms,setNodes:n=>{const{nodeInternals:r,nodeOrigin:s,elevateNodesOnSelect:o}=t();e({nodeInternals:Pf(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?Pf(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:f}=t(),h=d==null?void 0:d.querySelector(".react-flow__viewport");if(!h)return;const m=window.getComputedStyle(h),{m22:g}=new window.DOMMatrixReadOnly(m.transform),w=n.reduce((v,b)=>{const S=s.get(b.id);if(S!=null&&S.hidden)s.set(S.id,{...S,[ht]:{...S[ht],handleBounds:void 0}});else if(S){const _=$x(b.nodeElement);!!(_.width&&_.height&&(S.width!==_.width||S.height!==_.height||b.forceUpdate))&&(s.set(S.id,{...S,[ht]:{...S[ht],handleBounds:{source:Z1(".source",b.nodeElement,g,f),target:Z1(".target",b.nodeElement,g,f)}},..._}),v.push({id:S.id,type:"dimensions",dimensions:_}))}return v},[]);TR(s,f);const k=l||o&&!l&&RR(t,{initial:!0,...u});e({nodeInternals:new Map(s),fitViewOnInitDone:k}),(w==null?void 0:w.length)>0&&(r==null||r(w))},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 f=FD(n,u()),h=Pf(f,s,l,d);e({nodeInternals:h})}r==null||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:s,getNodes:o}=t();let l,u=null;r?l=n.map(d=>ws(d,!0)):(l=_o(o(),n),u=_o(s,[])),su({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=>ws(d,!0)):(l=_o(s,n),u=_o(o(),[])),su({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(h=>(h.selected=!1,ws(h.id,!1))),f=u.map(h=>ws(h.id,!1));su({changedNodes:d,changedEdges:f,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=>ws(u.id,!1)),l=n.filter(u=>u.selected).map(u=>ws(u.id,!1));su({changedNodes:o,changedEdges:l,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach(s=>{s.positionAbsolute=Ix(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 f=qr.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),h=[[0,0],[s,o]],m=l==null?void 0:l.constrain()(f,h,d);return l.transform(u,m),r[0]!==m.x||r[1]!==m.y||r[2]!==m.k},cancelConnection:()=>e({connectionNodeId:ms.connectionNodeId,connectionHandleId:ms.connectionHandleId,connectionHandleType:ms.connectionHandleType,connectionStatus:ms.connectionStatus,connectionStartHandle:ms.connectionStartHandle,connectionEndHandle:ms.connectionEndHandle}),reset:()=>e({...ms})}),Object.is),Ux=({children:e})=>{const t=x.useRef(null);return t.current||(t.current=S5()),ce.createElement(U4,{value:t.current},e)};Ux.displayName="ReactFlowProvider";const zR=({children:e})=>x.useContext(dd)?ce.createElement(ce.Fragment,null,e):ce.createElement(Ux,null,e);zR.displayName="ReactFlowWrapper";const j5={input:kR,default:Dv,output:SR,group:Bx},_5={default:qu,straight:Px,step:Lx,smoothstep:hd,simplebezier:Ox},E5=[0,0],C5=[15,15],T5={x:0,y:0,zoom:1},R5={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},UR=x.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:o=j5,edgeTypes:l=_5,onNodeClick:u,onEdgeClick:d,onInit:f,onMove:h,onMoveStart:m,onMoveEnd:g,onConnect:w,onConnectStart:k,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:S,onNodeMouseEnter:_,onNodeMouseMove:j,onNodeMouseLeave:E,onNodeContextMenu:T,onNodeDoubleClick:R,onNodeDragStart:M,onNodeDrag:O,onNodeDragStop:I,onNodesDelete:A,onEdgesDelete:L,onSelectionChange:z,onSelectionDragStart:V,onSelectionDrag:$,onSelectionDragStop:P,onSelectionContextMenu:F,onSelectionStart:Y,onSelectionEnd:K,connectionMode:D=va.Strict,connectionLineType:W=vs.Bezier,connectionLineStyle:B,connectionLineComponent:X,connectionLineContainerStyle:G,deleteKeyCode:U="Backspace",selectionKeyCode:Z="Shift",selectionOnDrag:H=!1,selectionMode:J=yl.Full,panActivationKeyCode:ee="Space",multiSelectionKeyCode:re=Du()?"Meta":"Control",zoomActivationKeyCode:oe=Du()?"Meta":"Control",snapToGrid:fe=!1,snapGrid:Ne=C5,onlyRenderVisibleElements:ke=!1,selectNodesOnDrag:we=!0,nodesDraggable:ve,nodesConnectable:$e,nodesFocusable:ye,nodeOrigin:ue=E5,edgesFocusable:se,edgesUpdatable:xe,elementsSelectable:Ae,defaultViewport:Le=T5,minZoom:Ie=.5,maxZoom:qe=2,translateExtent:nt=qv,preventScrolling:rt=!0,nodeExtent:Ye,defaultMarkerColor:ct="#b1b1b7",zoomOnScroll:At=!0,zoomOnPinch:vt=!0,panOnScroll:Ve=!1,panOnScrollSpeed:ut=.5,panOnScrollMode:Ze=ha.Free,zoomOnDoubleClick:ot=!0,panOnDrag:Gt=!0,onPaneClick:ge,onPaneMouseEnter:Oe,onPaneMouseMove:Fe,onPaneMouseLeave:Lt,onPaneScroll:Kt,onPaneContextMenu:Mt,children:on,onEdgeContextMenu:Ut,onEdgeDoubleClick:Xn,onEdgeMouseEnter:Ra,onEdgeMouseMove:Aa,onEdgeMouseLeave:Rs,onEdgeUpdate:br,onEdgeUpdateStart:Ma,onEdgeUpdateEnd:kr,onReconnect:As,onReconnectStart:Zn,onReconnectEnd:ri,reconnectRadius:Nr=10,edgeUpdaterRadius:Pt=10,onNodesChange:Jn,onEdgesChange:$a,noDragClassName:si="nodrag",noWheelClassName:Gr="nowheel",noPanClassName:Ia="nopan",fitView:Qn=!1,fitViewOptions:Ms,connectOnClick:$s=!0,attributionPosition:ai,proOptions:Oa,defaultEdgeOptions:er,elevateNodesOnSelect:La=!0,elevateEdgesOnSelect:Is=!1,disableKeyboardA11y:tr=!1,autoPanOnConnect:Kr=!0,autoPanOnNodeDrag:Ge=!0,connectionRadius:oi=20,isValidConnection:Os,onError:Ls,style:Sr,id:Pa,nodeDragThreshold:Ps,...jr},pt)=>{const Ds=Pa||"1";return ce.createElement("div",{...jr,style:{...Sr,...R5},ref:pt,className:Ot(["react-flow",s]),"data-testid":"rf__wrapper",id:Pa},ce.createElement(zR,null,ce.createElement(N5,{onInit:f,onMove:h,onMoveStart:m,onMoveEnd:g,onNodeClick:u,onEdgeClick:d,onNodeMouseEnter:_,onNodeMouseMove:j,onNodeMouseLeave:E,onNodeContextMenu:T,onNodeDoubleClick:R,nodeTypes:o,edgeTypes:l,connectionLineType:W,connectionLineStyle:B,connectionLineComponent:X,connectionLineContainerStyle:G,selectionKeyCode:Z,selectionOnDrag:H,selectionMode:J,deleteKeyCode:U,multiSelectionKeyCode:re,panActivationKeyCode:ee,zoomActivationKeyCode:oe,onlyRenderVisibleElements:ke,selectNodesOnDrag:we,defaultViewport:Le,translateExtent:nt,minZoom:Ie,maxZoom:qe,preventScrolling:rt,zoomOnScroll:At,zoomOnPinch:vt,zoomOnDoubleClick:ot,panOnScroll:Ve,panOnScrollSpeed:ut,panOnScrollMode:Ze,panOnDrag:Gt,onPaneClick:ge,onPaneMouseEnter:Oe,onPaneMouseMove:Fe,onPaneMouseLeave:Lt,onPaneScroll:Kt,onPaneContextMenu:Mt,onSelectionContextMenu:F,onSelectionStart:Y,onSelectionEnd:K,onEdgeContextMenu:Ut,onEdgeDoubleClick:Xn,onEdgeMouseEnter:Ra,onEdgeMouseMove:Aa,onEdgeMouseLeave:Rs,onReconnect:As??br,onReconnectStart:Zn??Ma,onReconnectEnd:ri??kr,reconnectRadius:Nr??Pt,defaultMarkerColor:ct,noDragClassName:si,noWheelClassName:Gr,noPanClassName:Ia,elevateEdgesOnSelect:Is,rfId:Ds,disableKeyboardA11y:tr,nodeOrigin:ue,nodeExtent:Ye}),ce.createElement(vD,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:w,onConnectStart:k,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:S,nodesDraggable:ve,nodesConnectable:$e,nodesFocusable:ye,edgesFocusable:se,edgesUpdatable:xe,elementsSelectable:Ae,elevateNodesOnSelect:La,minZoom:Ie,maxZoom:qe,nodeExtent:Ye,onNodesChange:Jn,onEdgesChange:$a,snapToGrid:fe,snapGrid:Ne,connectionMode:D,translateExtent:nt,connectOnClick:$s,defaultEdgeOptions:er,fitView:Qn,fitViewOptions:Ms,onNodesDelete:A,onEdgesDelete:L,onNodeDragStart:M,onNodeDrag:O,onNodeDragStop:I,onSelectionDrag:$,onSelectionDragStart:V,onSelectionDragStop:P,noPanClassName:Ia,nodeOrigin:ue,rfId:Ds,autoPanOnConnect:Kr,autoPanOnNodeDrag:Ge,onError:Ls,connectionRadius:oi,isValidConnection:Os,nodeDragThreshold:Ps}),ce.createElement(yD,{onSelectionChange:z}),on,ce.createElement(W4,{proOptions:Oa,position:ai}),ce.createElement(SD,{rfId:Ds,disableKeyboardA11y:tr})))});UR.displayName="ReactFlow";const A5=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function HR(){return We(A5,_t)}const WR=({id:e,x:t,y:n,width:r,height:s,style:o,color:l,strokeColor:u,strokeWidth:d,className:f,borderRadius:h,shapeRendering:m,onClick:g,selected:w})=>{const{background:k,backgroundColor:v}=o||{},b=l||k||v;return ce.createElement("rect",{className:Ot(["react-flow__minimap-node",{selected:w},f]),x:t,y:n,rx:h,ry:h,width:r,height:s,fill:b,stroke:u,strokeWidth:d,shapeRendering:m,onClick:g?S=>g(S,e):void 0})};WR.displayName="MiniMapNode";var M5=x.memo(WR);const $5=e=>e.nodeOrigin,I5=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),Bf=e=>e instanceof Function?e:()=>e;function O5({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s=2,nodeComponent:o=M5,onClick:l}){const u=We(I5,_t),d=We($5),f=Bf(t),h=Bf(e),m=Bf(n),g=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return ce.createElement(ce.Fragment,null,u.map(w=>{const{x:k,y:v}=ma(w,d).positionAbsolute;return ce.createElement(o,{key:w.id,x:k,y:v,width:w.width,height:w.height,style:w.style,selected:w.selected,className:m(w),color:f(w),borderRadius:r,strokeColor:h(w),strokeWidth:s,shapeRendering:g,onClick:l,id:w.id})}))}var L5=x.memo(O5);const P5=200,D5=150,F5=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?K4(fd(t,e.nodeOrigin),n):n,rfId:e.rfId}},q5="react-flow__minimap-desc";function VR({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:f="none",maskStrokeWidth:h=1,position:m="bottom-right",onClick:g,onNodeClick:w,pannable:k=!1,zoomable:v=!1,ariaLabel:b="React Flow mini map",inversePan:S=!1,zoomStep:_=10,offsetScale:j=5}){const E=yt(),T=x.useRef(null),{boundingRect:R,viewBB:M,rfId:O}=We(F5,_t),I=(e==null?void 0:e.width)??P5,A=(e==null?void 0:e.height)??D5,L=R.width/I,z=R.height/A,V=Math.max(L,z),$=V*I,P=V*A,F=j*V,Y=R.x-($-R.width)/2-F,K=R.y-(P-R.height)/2-F,D=$+F*2,W=P+F*2,B=`${q5}-${O}`,X=x.useRef(0);X.current=V,x.useEffect(()=>{if(T.current){const Z=jn(T.current),H=re=>{const{transform:oe,d3Selection:fe,d3Zoom:Ne}=E.getState();if(re.sourceEvent.type!=="wheel"||!fe||!Ne)return;const ke=-re.sourceEvent.deltaY*(re.sourceEvent.deltaMode===1?.05:re.sourceEvent.deltaMode?1:.002)*_,we=oe[2]*Math.pow(2,ke);Ne.scaleTo(fe,we)},J=re=>{const{transform:oe,d3Selection:fe,d3Zoom:Ne,translateExtent:ke,width:we,height:ve}=E.getState();if(re.sourceEvent.type!=="mousemove"||!fe||!Ne)return;const $e=X.current*Math.max(1,oe[2])*(S?-1:1),ye={x:oe[0]-re.sourceEvent.movementX*$e,y:oe[1]-re.sourceEvent.movementY*$e},ue=[[0,0],[we,ve]],se=qr.translate(ye.x,ye.y).scale(oe[2]),xe=Ne.constrain()(se,ue,ke);Ne.transform(fe,xe)},ee=tR().on("zoom",k?J:null).on("zoom.wheel",v?H:null);return Z.call(ee),()=>{Z.on("zoom",null)}}},[k,v,S,_]);const G=g?Z=>{const H=Fn(Z);g(Z,{x:H[0],y:H[1]})}:void 0,U=w?(Z,H)=>{const J=E.getState().nodeInternals.get(H);w(Z,J)}:void 0;return ce.createElement(Mx,{position:m,style:e,className:Ot(["react-flow__minimap",t]),"data-testid":"rf__minimap"},ce.createElement("svg",{width:I,height:A,viewBox:`${Y} ${K} ${D} ${W}`,role:"img","aria-labelledby":B,ref:T,onClick:G},b&&ce.createElement("title",{id:B},b),ce.createElement(L5,{onClick:U,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:s,nodeStrokeWidth:l,nodeComponent:u}),ce.createElement("path",{className:"react-flow__minimap-mask",d:`M${Y-F},${K-F}h${D+F*2}v${W+F*2}h${-D-F*2}z
57
- M${M.x},${M.y}h${M.width}v${M.height}h${-M.width}z`,fill:d,fillRule:"evenodd",stroke:f,strokeWidth:h,pointerEvents:"none"})))}VR.displayName="MiniMap";var B5=x.memo(VR);function z5(){return ce.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},ce.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function U5(){return ce.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},ce.createElement("path",{d:"M0 0h32v4.2H0z"}))}function H5(){return ce.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},ce.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 W5(){return ce.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ce.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 V5(){return ce.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ce.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 Sn=({children:e,className:t,...n})=>ce.createElement("button",{type:"button",className:Ot(["react-flow__controls-button",t]),...n},e);Sn.displayName="ControlButton";const G5=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),GR=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:o,onZoomOut:l,onFitView:u,onInteractiveChange:d,className:f,children:h,position:m="bottom-left"})=>{const g=yt(),[w,k]=x.useState(!1),{isInteractive:v,minZoomReached:b,maxZoomReached:S}=We(G5,_t),{zoomIn:_,zoomOut:j,fitView:E}=Go();if(x.useEffect(()=>{k(!0)},[]),!w)return null;const T=()=>{_(),o==null||o()},R=()=>{j(),l==null||l()},M=()=>{E(s),u==null||u()},O=()=>{g.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),d==null||d(!v)};return ce.createElement(Mx,{className:Ot(["react-flow__controls",f]),position:m,style:e,"data-testid":"rf__controls"},t&&ce.createElement(ce.Fragment,null,ce.createElement(Sn,{onClick:T,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:S},ce.createElement(z5,null)),ce.createElement(Sn,{onClick:R,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:b},ce.createElement(U5,null))),n&&ce.createElement(Sn,{className:"react-flow__controls-fitview",onClick:M,title:"fit view","aria-label":"fit view"},ce.createElement(H5,null)),r&&ce.createElement(Sn,{className:"react-flow__controls-interactive",onClick:O,title:"toggle interactivity","aria-label":"toggle interactivity"},v?ce.createElement(V5,null):ce.createElement(W5,null)),h)};GR.displayName="Controls";var K5=x.memo(GR),Un;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Un||(Un={}));function Y5({color:e,dimensions:t,lineWidth:n}){return ce.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function X5({color:e,radius:t}){return ce.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const Z5={[Un.Dots]:"#91919a",[Un.Lines]:"#eee",[Un.Cross]:"#e2e2e2"},J5={[Un.Dots]:1,[Un.Lines]:1,[Un.Cross]:6},Q5=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function KR({id:e,variant:t=Un.Dots,gap:n=20,size:r,lineWidth:s=1,offset:o=2,color:l,style:u,className:d}){const f=x.useRef(null),{transform:h,patternId:m}=We(Q5,_t),g=l||Z5[t],w=r||J5[t],k=t===Un.Dots,v=t===Un.Cross,b=Array.isArray(n)?n:[n,n],S=[b[0]*h[2]||1,b[1]*h[2]||1],_=w*h[2],j=v?[_,_]:S,E=k?[_/o,_/o]:[j[0]/o,j[1]/o];return ce.createElement("svg",{className:Ot(["react-flow__background",d]),style:{...u,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:f,"data-testid":"rf__background"},ce.createElement("pattern",{id:m+e,x:h[0]%S[0],y:h[1]%S[1],width:S[0],height:S[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${E[0]},-${E[1]})`},k?ce.createElement(X5,{color:g,radius:_/o}):ce.createElement(Y5,{dimensions:j,color:g,lineWidth:s})),ce.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${m+e})`}))}KR.displayName="Background";var eF=x.memo(KR);function tF(e,t){return e?t==="gone"?"entering":t==="leaving"?"here":t:t==="gone"?"gone":"leaving"}function Nu(e){return e!=="gone"}function Su(e,t){const[n,r]=x.useState(()=>e?"here":"gone"),s=x.useRef(null);return x.useEffect(()=>{r(o=>tF(e,o))},[e]),x.useEffect(()=>{if(n==="leaving")return s.current=window.setTimeout(()=>r("gone"),t),()=>{s.current!=null&&window.clearTimeout(s.current)}},[n,t]),x.useEffect(()=>{n==="entering"&&r("here")},[n]),n}const aN="agent-dag.fm-custom-stations",oN="agent-dag.fm-muted",Bv="custom:",nF=/^UC[A-Za-z0-9_-]{22}$/,rF=/^[A-Za-z0-9_-]{11}$/,Hx=/^[A-Za-z0-9_-]{1,80}$/,sF=/\.(mp3|aac|ogg)$/i,aF=/\.m3u8$/i,YR=2048,vl=80;function ba(e){return`${Bv}${e}`}function Fo(e){if(!e.startsWith(Bv))return null;const t=e.slice(Bv.length);return Hx.test(t)?t:null}function iN(e){return Fo(e)??e}function oF(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 Wx(e){var l,u;const t=e.trim();if(t.length>YR)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&&nF.test(d))return{kind:"youtube-channel",url:r,channel:d};const f=(u=/^\/@([^/]+)\/live\/?$/.exec(n.pathname))==null?void 0:u[1];if(f&&/^[A-Za-z0-9._-]{1,64}$/.test(f))return{kind:"youtube-handle",url:r,handle:f};if(n.pathname==="/watch"){const h=n.searchParams.get("v")??"";if(rF.test(h))return{kind:"youtube-video",url:r,video:h}}return null}return aF.test(n.pathname)?{kind:"direct-audio",url:r,format:"hls"}:sF.test(n.pathname)?{kind:"direct-audio",url:r,format:"audio"}:null}function iF(e){return e==="1"}function lF(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=Wx(u);!Hx.test(o)||n.has(o)||!l||l.length>vl||!d||(n.add(o),r.push({id:o,name:l,url:d.url}))}return r}function cF(e,t,n){const r=Fo(e??"");return r&&t.some(s=>s.id===r)?ba(r):n(e)}function uF(e,t){return e===ba(t)?"claude-fm":e}function dF(){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 hF(e,t,n=dF()){const r=e.trim(),s=Wx(t);return!r||r.length>vl||!Hx.test(n)||!s?null:{id:n,name:r,url:s.url}}const XR=.2,ZR=1.6;function fF(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<XR||s>ZR?null:{x:n,y:r,zoom:s}}function zv({durationMs:e,documentHidden:t,reducedMotion:n=pF()}){return t||n?!1:Number.isFinite(e)&&e>0}function pF(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}const mF=["us-gov","global","apac","us","eu","jp","au"],gF=new RegExp(`^(?:(?:${mF.join("|")})\\.)?anthropic\\.`,"i");function Ko(e){return e.replace(gF,"")}const yF=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i,wF=new Set(["tool_input","tool_response"]);function JR(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.model=="string"&&yF.test(Ko(n.model)))return n.model;for(const[r,s]of Object.entries(n)){if(wF.has(r))continue;const o=JR(s,t+1);if(o)return o}return null}function Vx(){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 Cs(e,t){return`${e}::${t}`}function Yo(e,t){return`${e}\0${t}`}const vF=/[0-9a-f]{16,}/i,xF=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function QR(e){return vF.test(e)||xF.test(e)}function bF(e){if(!e)return;const t=e.replace(/\\/g,"/").split("/").filter(Boolean);for(let n=t.length-1;n>=0;n--)if(!QR(t[n]))return t[n];return t[t.length-1]}function eA(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function tA(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 nA(e){const t=tA(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 kF(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t={};for(const[n,r]of Object.entries(e))!n||!r||typeof r!="object"||(t[n]=nA(r));return Object.keys(t).length?t:void 0}function rA(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),...tA(n)};for(const r of Object.values(n)){const s=rA(r,t+1);if(s)return s}return null}function Gx(e){return bF(e)}function Kx(e){const t=e.agent_type??e.subagent_type;return t&&!QR(t)?t:"subagent"}function Dl(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function xl(e,t){!e.cwd&&t.cwd&&(e.cwd=t.cwd,e.cwdBasename=Gx(t.cwd))}function sA(e,t){e.label==="session"&&t.cwd&&(e.label=Gx(t.cwd)??"session")}function aA(e,t){const n=Kx(t);n&&(e.label==="subagent"||!e.label)&&(e.label=n)}function Xo(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:eA()},e.agents.set(s,o),o)}function oA(e,t,n,r){const s=Cs(t,n),o=e.agents.get(s);return o?(xl(o,r),aA(o,r),o):null}function NF(e,t,n){const r=t.session_id??"unknown",s=Dl(t);if(s){const d=oA(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(Cs(r,l));if(d)return xl(d,t),d}const u=Xo(e,r,n,t.hook_event_name!=="SessionStart");return xl(u,t),sA(u,t),u}function SF(e,t,n,r,s){const o=Cs(t,n),l=Xo(e,t,s,!0);let u=e.agents.get(o);if(u)return xl(u,r),aA(u,r),u;u={id:o,sessionId:t,label:Kx(r),kind:"subagent",parentId:l.id,state:"active",startedAt:s,tools:[],prompts:[],cwd:r.cwd,cwdBasename:Gx(r.cwd),toolCount:0,childCount:0,usage:eA()},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 jF(e,t,n){const r=e.activeSubagentStack.get(t)??[];r.includes(n)||(r.push(n),e.activeSubagentStack.set(t,r))}function iA(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 sn(e,t){return Object.hasOwn(e,t)?e[t]:void 0}const _F=/^\s*<task-notification>([\s\S]*?)<\/task-notification>/;function lN(e,t){var n;return((n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`).exec(e))==null?void 0:n[1].trim())||void 0}const EF={completed:"background task finished",failed:"background task failed",killed:"background task stopped"};function Yx(e){const t=_F.exec(e);if(!t)return null;const n=lN(t[1],"status");return{label:(n?sn(EF,n):void 0)??"background task update",detail:lN(t[1],"summary")}}function lA(e){return e.filter(t=>!Yx(t.text))}const cN=2e3;function CF(e,t,n){for(let r=e.prompts.length-1;r>=0;r--){const s=e.prompts[r];if(s.at<t-cN)return!1;if(s.text===n&&s.at<=t+cN)return!0}return!1}const Bu=2e3;function TF(e){let t=e.startedAt;for(const n of e.prompts)n.at>t&&(t=n.at);return t}function zu(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 uN=200;function RF(e,t,n){var r;return((r=e.get(t))==null?void 0:r.tools.find(s=>s.id===n))??null}const AF=25;function MF(e,t){const n=t.tools;if(n.length>uN){const r=n.splice(0,n.length-uN);for(const s of r)uA(e,t,s)}for(let r=n.length-AF-1;r>=0;r--){const s=n[r];if(s.trimmed)break;s.input=void 0,s.response=void 0,s.trimmed=!0}}function $F(e,t,n){const r=e.toolIndex.get(Yo(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 cA(e,t){for(const n of t.tools)uA(e,t,n)}function uA(e,t,n){const r=Yo(t.sessionId,n.id);e.toolIndex.get(r)===n&&e.toolIndex.delete(r)}const IF="no result reached the deck — events were dropped while the deck was paused";function dA(e,t,n,r,s){n.endedAt=r,n.ok=!1,n.errorPreview=n.outcomeGap?IF:s,e.toolIndex.delete(Yo(t.sessionId,n.id))}function OF(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(Yo((n==null?void 0:n.session_id)??"unknown",s))}function LF(e,t,n,r,s){const o=t.tool_use_id?$F(e,r,t.tool_use_id):null;if(o){t.tool_name&&o.name==="?"&&(o.name=t.tool_name),o.endedAt==null&&!o.trimmed&&t.tool_input!==void 0&&(o.input=t.tool_input,o.inputPreview=zu(t.tool_input));return}const l=t.tool_use_id??`${r.id}:${r.toolCount}`,u=Dl(t),d={id:l,name:t.tool_name??"?",input:t.tool_input,inputPreview:zu(t.tool_input),agentId:r.id,explicitSubagentId:u?Cs(n,u):void 0,startedAt:s};r.tools.push(d),r.toolCount+=1,r.state="active",e.toolIndex.set(Yo(r.sessionId,l),d),MF(e,r)}function PF(e,t,n,r,s){const o=t.tool_use_id;if(!o)return;const l=Yo(r,o);let u=e.toolIndex.get(l),d=!1;if(!u)for(const h of e.agents.values()){if(h.sessionId!==r)continue;const m=h.tools.find(g=>g.id===o);if(m){u=m,d=!0;break}}if(!u||u.outcomeApplied)return;u.outcomeApplied=!0,u.outcomeGap=void 0,u.endedAt=s,u.ok=n==="PostToolUse",u.trimmed||(u.response=t.tool_response),n==="PostToolUseFailure"?u.errorPreview=zu(t.tool_response):d&&(u.errorPreview=void 0);const f=rA(t.tool_response);f&&(u.usage=f),e.toolIndex.delete(l)}function DF(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 FF(e,t,n,r){const s=Xo(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),xl(s,t),sA(s,t)}function qF(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=Xo(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&&!CF(s,r,o)&&(s.prompts.push({at:r,text:o}),!s.firstPrompt&&!Yx(o)&&(s.firstPrompt=zu(o,120)))}function BF(e,t,n,r){const s=Xo(e,n,r,!1),o=TF(s);if(r<o)return;const l=s.lastTurnEndAt;if(!(l!=null&&o>l&&r<=l+Bu)){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&&dA(e,u,d,r,"the turn ended before this call returned");t==="SessionEnd"&&(s.closedAt=r),e.activeSubagentStack.delete(n)}}function zF(e,t,n,r){const s=Dl(t);if(!s)return;const o=SF(e,n,s,t,r),l=Kx(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<=Bu,f=u!=null&&r-u<=Bu;if(d||f){const h=f?u:o.endedAt;o.state="done",o.endedAt=h,o.startedAt=Math.min(o.startedAt,h),iA(e,n,s);return}o.state="active",o.startedAt=o.startedAt||r,o.exitAt=void 0,o.endedAt=void 0,jF(e,n,s)}function UF(e,t,n,r){const s=Dl(t);if(!s)return;const o=oA(e,n,s,t);if(!o){for(const[l,u]of e.subagentTombstones)r-u>Bu&&e.subagentTombstones.delete(l);e.subagentTombstones.set(Cs(n,s),r);return}o.state="done",o.endedAt=Math.min(o.endedAt??r,r),iA(e,n,s)}function hA(){return{msgsUser:0,msgsAssistant:0,toolUses:0,toolResults:0,systemReminders:0,currentContextTokens:0,memoryFiles:[]}}function HF(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??hA(),currentContextTokens:t.context_tokens})}}const WF=6e4,dN=64;function VF(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=Cs(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 f=e.pendingSubagentModels.keys().next().value;f!==void 0&&e.pendingSubagentModels.delete(f)}}}function GF(e,t,n){const r=t.context??null;if(r){const s=e.agents.get(n);if(s){const o=s.context??hA(),l=(d,f)=>typeof r[d]=="number"?r[d]:f,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 KF(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 YF(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 XF(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<WF);u.push(o),l.outputs=u.length>dN?u.slice(-dN):u}e.revision+=1}}function ZF(e,t,n){const r=t.usage??null;if(r){const s=e.agents.get(n);s&&(Object.assign(s.usage,nA(r)),s.usageByModel=kF(t.usageByModel))}}const JF=["command","cmd","file_path","path","url","pattern","notebook_path"],hN=120,zf=e=>e.length>hN?`${e.slice(0,hN-1)}…`:e;function QF(e){if(typeof e=="string")return e.trim()?zf(e.trim()):null;if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;for(const n of JF){const r=t[n];if(typeof r=="string"&&r.trim())return zf(r.trim());if(Array.isArray(r)&&r.length>0&&r.every(s=>typeof s=="string")){const s=r.join(" ").trim();if(s)return zf(s)}}return null}function e6(e){return e==="permission_prompt"?"permission":e==="agent_needs_input"?"asked":e==="idle_prompt"?"idle":null}const t6=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved","SessionNamed","SessionRecapped","OutputObserved"]);function n6(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 r6=3e4;function s6(e,t){if(!(!e||!e.name)&&!(t-e.startedAt>r6)&&!(e.startedAt>t))return{name:e.name,preview:QF(e.input)??""}}function a6(e,t,n,r,s){if(n!=="permission")return{kind:n,message:r,since:s};const o=n6(e,t),l={kind:n,message:r,since:s};o!=null&&o.explicitSubagentId&&(l.subagentId=o.explicitSubagentId);const u=s6(o,s);return u&&(l.tool=u),l}function o6(e,t,n){if(e.kind==="idle")return!0;const r=Dl(t);return r==null?!0:e.subagentId!=null&&Cs(n,r)===e.subagentId}function i6(e,t,n,r){if(!t6.has(t)){const s=e.agents.get(r);s!=null&&s.waiting&&o6(s.waiting,n,r)&&(s.waiting=null)}}function l6(e,t,n,r){const s=e6(t.notification_type);if(!s)return;const o=Xo(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)}:a6(e,n,s,l,r)}function Fl(e,t){return t&&(e.revision+=1),t}function c6(e,t,n,r,s){if(e.agents.size<=n)return!1;const o=m=>m.state==="done"&&m.endedAt!=null&&t-m.endedAt>r,l=[],u=new Map;for(const[m,g]of e.agents){if(g.parentId!=null){const w=u.get(g.parentId);w?w.push(m):u.set(g.parentId,[m])}o(g)&&l.push({id:m,endedAt:g.endedAt})}if(l.length===0)return!1;l.sort((m,g)=>m.endedAt-g.endedAt);let d=0;const f=new Set,h=m=>{const g=e.agents.get(m);g&&(cA(e,g),e.agents.delete(m),f.add(g.sessionId),d++)};for(const m of l){if(e.agents.size<=n)break;if(!e.agents.has(m.id))continue;const g=(u.get(m.id)??[]).map(w=>e.agents.get(w)).filter(w=>w!=null);if(!g.some(w=>!o(w))){for(const w of g)h(w.id);h(m.id)}}if(s&&f.size>0){const m=new Set;for(const g of e.agents.values())m.add(g.sessionId);for(const g of f)m.has(g)||s(g)}return Fl(e,d>0)}function u6(e,t,n,r,s){const o=new Map;for(const[h,m]of e.agents){let g=o.get(m.sessionId);g||(g={ids:[],endedAt:0,live:!1,closed:!1},o.set(m.sessionId,g)),g.ids.push(h),m.kind==="root"&&m.closedAt!=null&&(g.closed=!0),m.state==="done"&&m.endedAt!=null?g.endedAt=Math.max(g.endedAt,m.endedAt):g.live=!0}const l=[...o].filter(([,h])=>!h.live&&h.endedAt>0&&t-h.endedAt>r).sort(([,h],[,m])=>h.closed===m.closed?h.endedAt-m.endedAt:h.closed?-1:1);let d=[...o.values()].filter(h=>!h.live).length-n;if(d<=0)return!1;let f=!1;for(const[h,m]of l){if(d<=0)break;for(const w of m.ids){const k=e.agents.get(w);k&&cA(e,k),e.agents.delete(w)}const g=Cs(h,"");for(const w of e.pendingSubagentModels.keys())w.startsWith(g)&&e.pendingSubagentModels.delete(w);s==null||s(h),d--,f=!0}return Fl(e,f)}function d6(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 Fl(e,t)}function h6(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&&(dA(e,s,u,d,"session ended before this call returned"),r=!0)}}return Fl(e,r)}const fN=90*6e4;function f6(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 Fl(e,r)}function Uu(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 fA(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{...Vx(),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(i6(e,o,r,l),DF(e,l,s),HF(e,r,l),o){case"ModelObserved":return VF(e,r,l),e;case"ContextObserved":return GF(e,r,l),e;case"SessionNamed":return KF(e,r,l),e;case"SessionRecapped":return YF(e,r,l),e;case"OutputObserved":return XF(e,r,l,s),e;case"UsageObserved":return ZF(e,r,l),e}const u=NF(e,r,s);u.provider||(u.provider=r.provider==="codex"?"codex":"claude");const d=JR(r);switch(d&&(u.model=d),o){case"SessionStart":FF(e,r,l,s);break;case"UserPromptSubmit":qF(e,r,l,s);break;case"PreToolUse":LF(e,r,l,u,s);break;case"PostToolUse":case"PostToolUseFailure":PF(e,r,o,l,s);break;case"SubagentStart":zF(e,r,l,s);break;case"SubagentStop":UF(e,r,l,s);break;case"Stop":case"SessionEnd":BF(e,o,l,s);break;case"Notification":l6(e,r,l,s);break}return e}const p6={input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4},m6=[{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:p6},{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}}];function g6(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function Sa(e,t=Date.now()){if(!e)return null;const n=Ko(e);for(const r of m6)if(r.match.test(n))return typeof r.rates=="function"?r.rates(t):r.rates;return null}function ol(e,t){return e*t/1e6}function pA(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:ol(o,t.cacheWrite),usd1h:ol(n,l)}}function mA(e,t,n=Date.now()){if(!g6(t))return e.inputTokens;const r=Sa(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 bl(e,t,n=Date.now()){const r=Sa(t,n);if(!r)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const s=ol(mA(e,t,n),r.input),o=ol(e.outputTokens,r.output),l=ol(e.cacheReadTokens,r.cacheRead),u=pA(e,r),d=u.usd5m+u.usd1h;return{input:s,output:o,cacheRead:l,cacheWrite:d,total:s+o+l+d}}const Hr="not priced";function Uf(e,t,n){const r=e.toFixed(t);return Number(r)<n?r:null}function Be(e){if(e<=0)return"—";if(e<.005)return"<1¢";if(e<1){const t=Uf(e*100,e<.1?1:0,100);if(t!==null)return`${t}¢`}if(e<100){const t=Uf(e,2,100);if(t!==null)return`$${t}`}if(e<1e4){const t=Uf(e,0,1e4);if(t!==null)return`$${t}`}return`$${(e/1e3).toFixed(1)}k`}function Xx(e,t){if(e<=0||t<10)return null;const n=e/t,r=n*60;return r>=.01?`${Be(r)}/min`:`${Be(n*3600)}/hr`}function y6(e,t){const n={inputTokens:e.inputTokens+t.inputTokens,outputTokens:e.outputTokens+t.outputTokens,cacheReadTokens:e.cacheReadTokens+t.cacheReadTokens,cacheCreateTokens:e.cacheCreateTokens+t.cacheCreateTokens};return(e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0||t.cacheCreate1hTokens!==void 0||t.cacheCreate5mTokens!==void 0)&&(n.cacheCreate1hTokens=(e.cacheCreate1hTokens??0)+(t.cacheCreate1hTokens??0),n.cacheCreate5mTokens=(e.cacheCreate5mTokens??0)+(t.cacheCreate5mTokens??0)),(e.reasoningOutputTokens!==void 0||t.reasoningOutputTokens!==void 0)&&(n.reasoningOutputTokens=(e.reasoningOutputTokens??0)+(t.reasoningOutputTokens??0)),n}function w6(e,t){let n=0,r=0,s=0,o=0,l=0,u=0;for(const m of t)n+=m.inputTokens,r+=m.outputTokens,s+=m.cacheReadTokens,o+=m.cacheCreateTokens,l+=m.cacheCreate1hTokens??0,u+=m.cacheCreate5mTokens??0;const d=(m,g)=>Math.max(0,m-g),f={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)&&(f.cacheCreate1hTokens=d(e.cacheCreate1hTokens??0,l),f.cacheCreate5mTokens=d(e.cacheCreate5mTokens??0,u)),f.inputTokens+f.outputTokens+f.cacheReadTokens+f.cacheCreateTokens>0?f:null}function ql(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=w6(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:y6(r[o].usage,s)}:r.push({model:e.model,usage:s})}return r}function an(e,t=Date.now()){const n={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const r of ql(e)){const s=bl(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 kl(e,t=Date.now()){let n=0;for(const r of ql(e))Sa(r.model,t)==null&&(n+=r.usage.inputTokens+r.usage.outputTokens);return n}function gA(e){const t=[];for(const n of ql(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 yA(e){return gA(e).filter(t=>t!==e.model)}function pN(e,t){const n=Sa(t);if(!n)return`model: ${t}
58
- no published rate in this build — the tokens are counted, the dollars are not`;const r=h=>h.toLocaleString(),s=h=>`$${h}/MTok`,o=bl(e,t),l=pA(e,n),u=l.tokens1h>0?[`cache w5m${r(l.tokens5m).padStart(14)} × ${s(n.cacheWrite).padEnd(11)} = ${Be(l.usd5m)}`,`cache w1h${r(l.tokens1h).padStart(14)} × ${s(n.cacheWrite1h??n.cacheWrite).padEnd(11)} = ${Be(l.usd1h)}`]:[`cache w ${r(l.tokens5m).padStart(14)} × ${s(n.cacheWrite).padEnd(11)} = ${Be(l.usd5m)}`],d=mA(e,t),f=d===e.inputTokens?"input":"uncached";return[`model: ${t}`,`${f.padEnd(9)}${r(d).padStart(14)} × ${s(n.input).padEnd(11)} = ${Be(o.input)}`,`output ${r(e.outputTokens).padStart(14)} × ${s(n.output).padEnd(11)} = ${Be(o.output)}`,`cache r ${r(e.cacheReadTokens).padStart(14)} × ${s(n.cacheRead).padEnd(11)} = ${Be(o.cacheRead)}`,...u,"─────────────────────────────────────────",`total = ${Be(o.total)}`].join(`
59
- `)}function mN(e){const t=ql(e);return t.length<=1?pN(e.usage,e.model):[...t.map(n=>pN(n.usage,n.model)),"═════════════════════════════════════════",`all models = ${Be(an(e).total)}`].join(`
60
- `)}function v6(e){if(!e.model)return null;const t=Sa(e.model),n=an(e),r=kl(e);if(!t&&n.total<=0)return e.usage.inputTokens+e.usage.outputTokens<=0?null:{kind:"unpriced",tt:mN(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?Xx(n.total,s):null,l=mN(e)+(o?`
61
- burn: ${o}`:"");return{kind:"spent",total:n.total,floor:r>0,tt:l}}const x6=new Set(["untrusted","on-request","on-failure"]);function b6(e){return typeof e!="string"||!e?null:x6.has(e)?!0:e==="never"?!1:null}function k6(e){if(e.provider!=="codex"||e.kind!=="root"||e.waiting||e.state!=="active")return null;const t=b6(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."}
62
-
63
- 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 gN(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function js(e){const t=Ko(e).replace(/[-_]\d{8}(?!\d)/,""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const s=gN(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(gN);return[`GPT-${s}`,...o].join(" ")}return e}function pd(e){const t=Ko(e??""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_]/i);return n?n[1].toLowerCase():/^gpt[-_]/i.test(t)?"gpt":""}function Kn(e){return(e==null?void 0:e.kind)==="permission"||(e==null?void 0:e.kind)==="asked"}function Uv(e){const t=[];for(const n of e)n.kind==="root"&&Kn(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 N6(e,t){if(e.length===0)return null;const n=e.findIndex(r=>r.id===t);return e[(n+1)%e.length]}function S6(e){const t=new Set;for(const n of e)n.state==="active"&&t.add(n.sessionId);return t.size}function md(e,t){return`${e}@${t.since}`}function wA(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 j6(e){const t=e.message||"Needs your permission",n=wA(e,t);return n?`${t}
64
- Likely on: ${n}`:t}function _6(e,t,n,r=!0){if(!r)return[];if(n)return[];const s=[];for(const o of e){if(!Kn(o.waiting))continue;const l=md(o.id,o.waiting);t.has(l)||s.push({key:l,title:o.label,body:j6(o.waiting),sessionId:o.id})}return s}function E6(e,t,n){const r=new Set;for(const o of e)r.add(md(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 Hf(e){return new Set(e.map(t=>md(t.id,t.waiting)))}function C6(e,t){return e!==t}function T6(e,t){return!e&&t!=null}function R6(e,t){return e!==null&&t!=null}function qo(e){return e==="active"?"live":e==="done"?"done":"err"}function Bo(e){return e.message?e.message:e.kind==="permission"?"Needs your permission":"Waiting for your input"}function A6(e,t=Date.now(),n=!1){const r=e.tools.filter(o=>o.ok===!1).length,s=an(e,t).total;return[e.label,e.kind==="root"?"session":"subagent",qo(e.state),Kn(e.waiting)?Bo(e.waiting):null,e.model?js(e.model):null,`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,r>0?`${r} failed`:null,s>0?`${Be(s)}${kl(e,t)>0?"+":""}`:null,n?"selected":null].filter(Boolean).join(", ")}function M6(e,t){const n=wA(e,t);return n?`Likely on: ${n}`:null}function Zx(e){return e.kind==="idle"?"Your turn":Bo(e)}function et(e){const t=Math.round(e);return t<1e3?`${t}`:t<1e6?`${(t/1e3).toFixed(1)}k`:t<1e9?`${(t/1e6).toFixed(2)}M`:`${(t/1e9).toFixed(2)}B`}function zo(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 vA(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 Jx(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 yN=["B","KB","MB","GB","TB"];function ca(e){if(e==null||!Number.isFinite(e)||e<0)return"—";if(e===0)return"0 B";let t=e,n=0;for(;n<yN.length-1&&Number(t.toFixed(1))>=1024;)t/=1024,n++;return`${t.toFixed(1)} ${yN[n]}`}const wN=2e5,$6=1e6,I6=[/\[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],O6=[{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 L6(e){if(!e)return wN;const t=Ko(e);for(const n of I6)if(n.test(t))return $6;for(const n of O6)if(n.match.test(t))return n.window;return wN}function xA(e,t){return typeof e=="number"&&e>0?e:L6(t)}const P6=1;function D6(){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 il=D6(),F6=e=>e==="Escape";function q6(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function vN(e){return String(e.tagName??"").toUpperCase()==="BODY"}function B6(e,t){return!e||!e.isConnected||vN(e)?!1:t==null||vN(t)}const xN="a[href], button, input, select, textarea, [tabindex]";function z6(e){return!e||e.disabled||e.rendered===!1?!1:(e.tabIndex??0)>=0}function U6(e){if(!e||!e.overflowing||e.hasFocusable)return!1;const t=String(e.overflow??"").toLowerCase();return t==="auto"||t==="scroll"}function H6({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 gd(e){return e.ctrlKey||e.metaKey||e.altKey}const W6=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),V6=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),G6=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function Qx(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function K6(e){return Qx(e)==="BUTTON"?!0:(typeof e.role=="string"?e.role.trim().toLowerCase():"").split(/\s+/).includes("button")}function yd(e){if(!e)return!1;if(e.isContentEditable)return!0;const t=Qx(e);return t==="TEXTAREA"?!0:t!=="INPUT"?!1:!W6.has(String(e.type??"text").toLowerCase())}function Y6(e,t){if(!e)return!1;if(yd(e))return!0;if(t!=null&&t.length===1&&t!==" "&&e.pointerFocused&&K6(e))return!1;if(V6.has(Qx(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(r=>G6.has(r))}function X6({key:e,modalOpen:t,sheetOpen:n}){return t?!(e==="?"&&n):!1}function Z6({appModal:e,dialogDepth:t}){return e||t>0}function bA(e){return e?Array.from(e.querySelectorAll("*")).filter(t=>{if(t.matches(xN))return z6({disabled:t.disabled,tabIndex:t.tabIndex,rendered:t.getClientRects().length>0});const n=t.scrollHeight>t.clientHeight;return n&&U6({overflowing:n,overflow:getComputedStyle(t).overflowY,hasFocusable:t.querySelector(xN)!=null})}):[]}function J6(e,t){const n=bA(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 Et(e,t={}){const{focusRef:n,layer:r,popover:s}=t,o=s?"popover":"dialog",l=x.useRef(null),u=x.useRef(e);u.current=e;const d=x.useRef(null);d.current===null&&(d.current=()=>u.current());const f=d.current;return x.useEffect(()=>il.push(f,r,o),[f,r,o]),x.useEffect(()=>{var m;const h=document.activeElement;return(m=(n==null?void 0:n.current)??bA(l.current)[0])==null||m.focus(),()=>{B6(h,document.activeElement)&&h.focus()}},[]),x.useEffect(()=>{const h=m=>{var S;if(m.key!=="Tab"||gd(m))return;const g=l.current;if(!g)return;const w=document.activeElement;if(!(w!=null&&g.contains(w))&&!il.isTop(f))return;const v=J6(g,w),b=H6({count:v.length,index:w?v.indexOf(w):-1,shiftKey:m.shiftKey});b.kind!=="allow"&&(m.preventDefault(),b.kind==="focus"&&((S=v[b.index])==null||S.focus()))};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[f]),l}function Q6(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 Nn(e){return e.toLocaleString()}const eq=60;function tq(e,t=eq){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 nq({agent:e,onClose:t}){var g;const n=x.useRef(null),r=Et(t,{focusRef:n}),s=e.context,o=e.usage,l=(s==null?void 0:s.currentContextTokens)??0,u=xA(e.contextWindow,e.model),d=Math.min(100,l/u*100),f=an(e),h=e.provider==="codex"?o.inputTokens+o.outputTokens:o.inputTokens+o.outputTokens+o.cacheReadTokens+o.cacheCreateTokens,m=Q6(e.provider);return i.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:i.jsxs("div",{ref:r,className:"modal ctx-modal",onClick:w=>w.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Context breakdown",children:[i.jsxs("header",{className:"ctx-modal-head",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"ctx-modal-title",children:["Context · ",e.label]}),i.jsx("div",{className:"ctx-modal-sub",children:m.subtitle})]}),i.jsx("button",{type:"button",ref:n,className:"glyph-btn ctx-modal-close",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),i.jsxs("section",{className:"ctx-window-row",children:[i.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:i.jsx("div",{className:"ctx-window-fill",style:{transform:`scaleX(${Math.min(100,Math.max(0,d))/100})`}})}),i.jsxs("div",{className:"ctx-window-meta",children:[i.jsxs("span",{className:"ctx-window-pct",children:[d.toFixed(1),"%"]}),i.jsxs("span",{children:[Nn(l)," / ",Nn(u)," tok (",m.windowScope,")"]})]})]}),i.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),i.jsxs("div",{className:"ctx-grid",children:[i.jsx(Dn,{label:"input tokens",val:Nn(o.inputTokens)}),i.jsx(Dn,{label:"output tokens",val:Nn(o.outputTokens)}),i.jsx(Dn,{label:"cache reads",val:Nn(o.cacheReadTokens)}),i.jsx(Dn,{label:"cache writes",val:Nn(o.cacheCreateTokens)}),i.jsx(Dn,{label:"cumulative total",val:Nn(h)}),i.jsx(Dn,{label:"estimated cost",val:Be(f.total),accent:!0})]}),i.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),m.compositionCounted?i.jsxs("div",{className:"ctx-grid",children:[i.jsx(Dn,{label:"user messages",val:Nn((s==null?void 0:s.msgsUser)??0)}),i.jsx(Dn,{label:"assistant messages",val:Nn((s==null?void 0:s.msgsAssistant)??0)}),i.jsx(Dn,{label:"tool uses",val:Nn((s==null?void 0:s.toolUses)??0)}),i.jsx(Dn,{label:"tool results",val:Nn((s==null?void 0:s.toolResults)??0)}),i.jsx(Dn,{label:"system-reminders",val:Nn((s==null?void 0:s.systemReminders)??0)})]}):i.jsx("div",{className:"ctx-empty",children:m.compositionUncounted}),i.jsx("h3",{className:"ctx-section-title",children:m.memoryHeading}),(((g=s==null?void 0:s.memoryFiles)==null?void 0:g.length)??0)===0?i.jsx("div",{className:"ctx-empty",children:m.memoryEmpty}):i.jsx("ul",{className:"ctx-md-list",children:s.memoryFiles.map(w=>i.jsxs("li",{children:[i.jsx("span",{className:"ctx-md-path",title:w.path,children:tq(w.path)}),i.jsx("span",{className:"ctx-md-size",children:ca(w.bytes)})]},w.path))})]})})}function Dn({label:e,val:t,accent:n}){return i.jsxs("div",{className:`ctx-row${n?" accent":""}`,children:[i.jsx("span",{className:"ctx-row-label",children:e}),i.jsx("span",{className:"ctx-row-val",children:t})]})}function rq({currentContextTokens:e,modelId:t,contextWindow:n,size:r=26,onClick:s}){const o=xA(n,t),l=Math.min(1,e/o),u=r/2-3,d=r/2,f=2*Math.PI*u,h=f*l,m=l>.9?"var(--err)":l>.7?"var(--warn)":"var(--accent)";return i.jsx("button",{type:"button",className:"ctx-donut",onClick: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:i.jsxs("svg",{width:r,height:r,viewBox:`0 0 ${r} ${r}`,"aria-hidden":"true",children:[i.jsx("circle",{cx:d,cy:d,r:u,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),i.jsx("circle",{cx:d,cy:d,r:u,stroke:m,strokeWidth:"2.5",fill:"none",strokeDasharray:`${h} ${f-h}`,strokeDashoffset:f/4,strokeLinecap:"round",style:{transition:"var(--ctx-arc-transition)"}}),i.jsx("text",{x:d,y:d+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(l*100)})]})})}const bN=new Map;function kA(e){let t=bN.get(e);return t||(t={now:Date.now(),listeners:new Set,timer:null},bN.set(e,t)),t}function sq(e,t){const n=kA(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 aq(e){return kA(e).now}const kN=new Map,NN=new Map;function Zo(e=1e3){let t=kN.get(e);t||(t=r=>sq(e,r),kN.set(e,t));let n=NN.get(e);return n||(n=()=>aq(e),NN.set(e,n)),x.useSyncExternalStore(t,n,n)}function wd(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 oq="1",SN="agent-dag.schema",iq=["agent-dag.layout","agent-dag.viewport"];function tt(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function Ke(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}function Br(e){if(!(typeof window>"u"))try{window.localStorage.removeItem(e)}catch{}}function ll(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function lq(e,t=oq){let n=null;try{n=e.getItem(SN)}catch{return[]}if(n===t)return[];const r=[];if(n!==null)for(const s of iq)try{e.getItem(s)!==null&&(e.removeItem(s),r.push(s))}catch{}try{e.setItem(SN,t)}catch{}return r}const NA="agent-dag.recapsDismissed",jN=200;function cq(){const e=tt(NA);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}let Uo=new Set(cq());const Hv=new Set;let SA=0;function jA(e){return Hv.add(e),()=>{Hv.delete(e)}}function _A(e){Uo=e,SA++;const t=Array.from(e);Ke(NA,JSON.stringify(t.length>jN?t.slice(-jN):t));for(const n of Hv)n()}function EA(e,t){return`${e}@${t}`}function uq(e){return Uo.has(e)}function dq(e){if(Uo.has(e))return;const t=new Set(Uo);t.add(e),_A(t)}function hq(e){const t=new Set(Uo);t.delete(e)||t.add(e),_A(t)}function fq(e){return x.useSyncExternalStore(jA,()=>e!=null&&Uo.has(e),()=>!1)}function e0(e){return`recap:${e}`}function pq(e){return e.startsWith("recap:")}function mq(){return x.useSyncExternalStore(jA,()=>SA,()=>0)}function gq(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 CA(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 TA(e){return e.live>0?`→ ${e.total} · ${e.live} live`:`→ ${e.total} · done`}function yq(e,t,n){const r=e.kind==="root"?e.waiting:null;if(r&&Kn(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:CA(t),short:TA(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 Wv(e){return e==="active"?"live":e==="done"?"done":"err"}const vd={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"}},wq=Object.fromEntries(Object.entries(vd).map(([e,t])=>[e,t.category])),vq=Object.fromEntries(Object.entries(vd).map(([e,t])=>[e,t.emoji])),xq=Object.fromEntries(Object.entries(vd).map(([e,t])=>[e,t.label])),bq=new Set(Object.entries(vd).filter(([,e])=>e.shell).map(([e])=>e)),kq={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",...wq};function RA(e){return e.startsWith("mcp__")?"mcp":sn(kq,e)??"other"}const Nq=/\btools\.exec_command\s*\(\s*\{[^{}]*?\bcmd\s*:\s*(["'`])((?:\\.|(?!\1)[^\\])*)\1/,Sq=/\btools\.([A-Za-z_$][\w$]*)\s*\(/;function jq(e){if(typeof e!="string"||!e)return null;const t=Nq.exec(e);if(t){const r=_q(t[2]);if(r.trim())return r}const n=Sq.exec(e);return n?n[1]:null}function _q(e){return e.replace(/\\(["'`\\nrt])/g,(t,n)=>n==="n"?`
65
- `:n==="r"?"\r":n==="t"?" ":n)}const Eq={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:"📡",...vq};function _N(e){return e.startsWith("mcp__")?"🔌":sn(Eq,e)??"✨"}const Cq={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 AA(e){if(!e)return null;let t=e.trim();if(!t)return null;const n=t.match(/^(?:bash|sh|zsh|fish|powershell|pwsh)(?:\.exe)?\s+(?:-c|-Command|-NoProfile|-NonInteractive|\s)+["']([^"']+)["']/i);if(n)return AA(n[1]);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 Tq(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const t=e;if(typeof t.script=="string"){const n=jq(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(s=>/^(-Command|-c)$/i.test(s));if(r>=0&&r+1<n.length)return n[r+1]}return n.join(" ")}return typeof t.script=="string"?t.script:null}const Rq=new Set(["Bash","PowerShell",...bq]);function Aq(e,t){if(!Rq.has(e))return null;const n=Tq(t);if(!n)return null;const r=AA(n);return r?{emoji:sn(Cq,r)??"⚙️",label:r,category:"shell",detail:n}:null}const Mq=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),$q={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:"🗄️"},Iq={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 Oq(e){const n=e.replace(/\\/g,"/").replace(/\/+$/,""),r=n.lastIndexOf("/");return r>=0?n.slice(r+1):n}function Lq(e){const t=e.toLowerCase(),n=sn(Iq,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=sn($q,t.slice(r+1));if(s!==void 0)return s}return"📄"}function Pq(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 Dq(e,t){if(!Mq.has(e))return null;const n=Pq(e,t);if(!n)return null;const r=Oq(n);return r?{emoji:e==="LS"?"📂":Lq(r),label:r,category:"file",detail:n}:null}const Fq={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 t0(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 qq(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 MA(e){return sn(Fq,e.toLowerCase())}function Bq(e,t){const n=t0(e);if(!n)return null;const{server:r,method:s}=n;if(!s)return null;const o=MA(r);return{emoji:(o==null?void 0:o.emoji)??"🔌",label:s,category:"mcp",detail:o?`${o.name} · ${s}`:`${r} · ${s}`}}function $A(e,t){return Aq(e,t)??Dq(e,t)??Bq(e)}function zq(e,t){var n;return((n=$A(e,t))==null?void 0:n.label)??null}const Uq=xq,EN=18;function ou(e){const t=[...e];return t.length<=EN?e:t.slice(0,EN-1).join("")+"…"}const Wf=13,Hq=6;function Wq(e,t){const n=[...e];if(n.length<=Wf)return e;const r=n.lastIndexOf("."),s=r>0?n.slice(r):[];return t==="file"&&s.length>1&&s.length<=Hq?n.slice(0,Wf-1-s.length).join("")+"…"+s.join(""):n.slice(0,Wf-1).join("")+"…"}function n0(e){const t=t0(e);if(t){const r=MA(t.server);return r?{emoji:r.emoji,label:ou(r.name)}:{emoji:"🔌",label:ou(t.server),hue:qq(t.server)}}const n=sn(Uq,e)??"";return n?{emoji:_N(e),label:ou(n)}:{emoji:_N(e),label:ou(e)}}function Vq(e){let t=null,n="";for(const r of e){const s=t0(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:n0(n)}const Vv=6e4,$o=24,CN=Vv/$o,Vf=132,ju=14;function Gq(e,t,n){const r=new Array($o).fill(0);let s=0;const o=g=>{const w=n-g;if(w<0||w>=Vv)return;const k=$o-1-Math.floor(w/CN);k>=0&&k<$o&&(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)/(CN/1e3),d=e.filter(g=>n-g.startedAt>=0&&n-g.startedAt<Vv).length,f=s-d,h=[d>0?`${d} tool ${d===1?"call":"calls"}`:"",f>0?`${f} ${f===1?"block":"blocks"} of thinking and writing`:""].filter(Boolean),m=s===0?"nothing in the last 60s":`${h.join(" · ")} in last 60s · peak ${u.toFixed(1)}/s`;return{counts:r,title:m}}const Kq=2;function Yq(e){return e===0?1.5:Math.max(1.5,Math.min(1,e/Kq)*ju)}function IA({kind:e}){return i.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"&&i.jsx("circle",{cx:"5",cy:"5",r:"3.2",fill:"currentColor"}),e==="done"&&i.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"&&i.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 r0(){return i.jsxs("svg",{className:"alert-mark",viewBox:"0 0 12 12",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[i.jsx("path",{d:"M6 1.4l4.7 8.3H1.3z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round",fill:"none"}),i.jsx("path",{d:"M6 4.6v2.4",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"}),i.jsx("circle",{cx:"6",cy:"8.35",r:"0.72",fill:"currentColor"})]})}function Nl(){return i.jsxs("svg",{className:"recap-glyph",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true",focusable:"false",children:[i.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"}),i.jsx("circle",{cx:"6",cy:"1.2",r:"1.05",fill:"currentColor"}),i.jsx("circle",{cx:"6",cy:"10.8",r:"1.05",fill:"currentColor"}),i.jsx("circle",{cx:"1.2",cy:"6",r:"1.05",fill:"currentColor"}),i.jsx("circle",{cx:"10.8",cy:"6",r:"1.05",fill:"currentColor"})]})}function Xq({data:e,selected:t}){var S,_;const n=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":"",t?"selected":""].filter(Boolean).join(" "),r=e.tools.filter(j=>!j.endedAt).length,s=e.tools.filter(j=>j.ok===!1).length,o=Uu(e.sessionId),l=((S=e.context)==null?void 0:S.currentContextTokens)??0,u=e.kind==="root"&&l>0,d=e.sessionTitle?e.cwd?`${e.cwd}
66
- ${e.sessionTitle}`:e.sessionTitle:e.cwd,f=yA(e),h=f.length>0?`${e.model}
67
- spend on this card also covers:
68
- ${f.join(`
69
- `)}`:e.model,m=Jx(e.sessionName,e.sessionTitle),g=wd(e),w=g?EA(e.sessionId,g.at):null,k=fq(w),v=g!=null&&!k,b=v6(e);return i.jsxs("div",{className:n,style:{"--session-hue":o},children:[i.jsx("span",{className:"accent-stripe"}),i.jsx(xa,{type:"target",position:Ce.Left,style:{background:"transparent",border:"none"}}),i.jsxs("div",{className:"head",children:[i.jsxs("div",{className:"title",children:[i.jsx(e8,{state:e.state}),i.jsx("span",{className:"label",title:d,children:e.label}),e.synthetic&&i.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"}),g&&w&&i.jsx("button",{type:"button",className:"glyph-btn recap-pin","aria-label":"Claude Code's recap","aria-expanded":v,title:v?"Hide the recap":"Show Claude Code's recap",onClick:j=>{j.stopPropagation(),hq(w)},children:i.jsx(Nl,{})})]}),i.jsxs("div",{className:"head-right",children:[u&&e.onOpenContext&&i.jsx(rq,{currentContextTokens:l,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)}),i.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?"≥ ":"",i.jsx(Qq,{start:e.startedAt,end:e.endedAt})]})]})]}),i.jsxs("div",{className:"sub",children:[e.kind==="root"?"session":"subagent",e.childCount>0&&i.jsxs("span",{className:"spawn-badge",title:`${e.childCount} subagents spawned`,children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model?i.jsxs("span",{className:"model-chip","data-family":pd(e.model),title:h,children:[js(e.model),f.length>0?` +${f.length}`:""]}):e.provider==="codex"?i.jsx("span",{className:"model-chip",title:"OpenAI Codex — no model reported yet",children:"Codex"}):null]}),e.kind==="root"&&m.face&&i.jsx("div",{className:"session-name",title:m.tooltip,children:m.face}),e.waiting&&i.jsx(t8,{waiting:e.waiting}),(()=>{const j=k6(e);return j?i.jsxs("div",{className:"approval-blind-row",title:j.detail,children:[i.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),i.jsx("span",{className:"approval-blind-said",children:j.label})]}):null})(),(e.tools.length>0||(((_=e.outputs)==null?void 0:_.length)??0)>0)&&i.jsx(n8,{tools:e.tools,outputs:e.outputs}),i.jsxs("div",{className:"meta",children:[i.jsxs("span",{children:[i.jsx("b",{children:e.toolCount})," tools"]}),s>0&&i.jsxs("span",{className:"failed-meta",title:`${s} tool ${s===1?"call":"calls"} returned an error`,children:[i.jsx("b",{children:s})," err"]}),r>0&&i.jsxs("span",{className:"inflight-meta",children:[i.jsx("b",{children:r})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&i.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:[i.jsx("b",{children:et(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),(b==null?void 0:b.kind)==="unpriced"&&i.jsx("span",{className:"cost-unpriced",title:b.tt,children:Hr}),(b==null?void 0:b.kind)==="spent"&&i.jsx("span",{className:"cost-meta",title:b.tt,children:i.jsxs("b",{children:[Be(b.total),b.floor?"+":""]})})]}),i.jsx(Jq,{data:e,title:e.kind==="root"?m.face:void 0}),i.jsx(xa,{type:"source",position:Ce.Right,style:{background:"transparent",border:"none"}})]})}const Zq=x.memo(Xq);function Jq({data:e,title:t}){const n=e.kind==="root"&&Kn(e.waiting),r=yq(e,e.branch,{sayWaiting:Zx,describeCall:s=>({name:n0(s.name).label,subject:zq(s.name,s.input)})});return i.jsxs("div",{className:"lod-face","data-kind":e.kind,"data-alarm":n?"":void 0,"data-signal":r?"":void 0,"aria-hidden":!0,children:[i.jsxs("div",{className:"lod-id",children:[i.jsx(IA,{kind:Wv(e.state)}),i.jsx("span",{className:"lod-name",children:e.label}),r&&i.jsx("span",{className:"lod-inline","data-tone":r.tone,children:r.short}),n&&i.jsx(r0,{})]}),t&&i.jsx("div",{className:"lod-title",children:t}),r&&i.jsxs("div",{className:"lod-signal","data-tone":r.tone,children:[i.jsx("span",{className:"lod-long",children:r.long}),i.jsx("span",{className:"lod-short",children:r.short})]})]})}function Qq({start:e,end:t}){const n=Zo(1e3);return i.jsx(i.Fragment,{children:zo(e,t,n)})}function e8({state:e}){return i.jsx("span",{className:`state-pill state-${e}`,children:qo(e)})}function t8({waiting:e}){const t=Zo(1e3),n=Kn(e),r=Bo(e);return i.jsxs("div",{className:n?"waiting-row permission":"waiting-row idle",title:`${r}
70
- Blocked for ${zo(e.since,void 0,t)} — the answer goes in the terminal, not here.`,children:[n?i.jsx("span",{className:"ap-pulse","aria-hidden":!0}):i.jsx("span",{className:"waiting-dot","aria-hidden":!0}),i.jsx("span",{className:"waiting-said",children:Zx(e)}),i.jsx("b",{children:zo(e.since,void 0,t)})]})}function n8({tools:e,outputs:t}){const n=Zo(1e3),{counts:r,title:s}=Gq(e,t,n),o=Vf/$o;return i.jsxs("div",{className:"tool-spark-row",title:s,children:[i.jsx("svg",{className:"tool-spark",width:Vf,height:ju,viewBox:`0 0 ${Vf} ${ju}`,"aria-hidden":!0,children:r.map((l,u)=>{const d=Yq(l),f=u===$o-1&&l>0,m=`tool-spark-bar${l>0?" active":""}${f?" latest":""}`;return i.jsx("rect",{x:u*o+.4,y:ju-d,width:Math.max(.5,o-1),height:d,rx:.8,className:m},f?`landed:${l}`:u)})}),i.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function r8({enableAutoFitAndRefit:e}){return i.jsxs("div",{className:"autofit-chip",children:[i.jsx("span",{className:"autofit-state",title:"New sessions are not brought into view while you are moving it yourself",children:"Auto-fit off"}),i.jsx("button",{type:"button",className:"autofit-resume",onClick:e,title:"Bring new sessions into view again","aria-label":"Resume auto-fit",children:"Resume"})]})}function Hu(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const TN=99;function s8(e){const t=Math.max(0,Math.floor(e));return t>TN?`${TN}+`:String(t)}const a8="Pause the canvas";function o8(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 — ${Hu(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)":`${Hu(e.held)} arrived while paused and will be applied in order when you resume (Space)`}function i8(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 OA="paused · full",l8=(e,t)=>t>0?OA:e>0?`paused · ${s8(e)}`:"paused";function c8(e){const t=Math.max(0,Math.floor(e.dropped??0));return e.connected?e.paused?{tone:"paused",resting:!1,label:l8(e.held,t),widest:OA,title:t>0?`Connected — the pause is full at ${Hu(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up (Space)`:e.held>0?`Connected — ${Hu(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 u8=e=>e.transform[2]>=e.maxZoom,d8=e=>e.transform[2]<=e.minZoom;function h8({autoFitDisabled:e,enableAutoFitAndRefit:t,paused:n,pauseGate:r,togglePause:s,handleRelayout:o,requestClear:l,setKeyHelpOpen:u}){const d=Go(),f=We(u8),h=We(d8);return i.jsxs(K5,{showInteractive:!1,showFitView:!1,showZoom:!1,children:[i.jsx(Sn,{onClick:()=>d.zoomIn(),title:"Zoom in","aria-label":"Zoom in",disabled:f,children:i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:i.jsx("path",{d:"M12 5v14M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),i.jsx(Sn,{onClick:()=>d.zoomOut(),title:"Zoom out","aria-label":"Zoom out",disabled:h,children:i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:i.jsx("path",{d:"M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),i.jsx(Sn,{onClick:t,title:e?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view","data-nudge":e?"":void 0,children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[i.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),i.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),i.jsx(Sn,{"data-group-start":"",onClick:s,title:o8({paused:n,held:r.size,dropped:r.dropped}),"aria-label":a8,"aria-pressed":n,children:i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:i.jsx("path",{d:"M9 5.5v13M15 5.5v13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),i.jsx(Sn,{onClick:o,title:"Auto-arrange — clear pins (R)","aria-label":"Re-arrange the canvas",children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[i.jsx("rect",{x:"8.5",y:"2",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),i.jsx("rect",{x:"1.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),i.jsx("rect",{x:"15.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),i.jsx("path",{d:"M12 7v6.5M5 17v-3.5h14V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),i.jsx(Sn,{"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:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[i.jsx("path",{d:"M4 6.2h16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),i.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"}),i.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"}),i.jsx("path",{d:"M10.3 10.6v6.8M13.7 10.6v6.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),i.jsx(Sn,{"data-group-start":"",onClick:()=>u(m=>!m),title:"Keyboard shortcuts (?)","aria-label":"Open the keyboard shortcuts","aria-haspopup":"dialog",children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[i.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"}),i.jsx("path",{d:"M12 18.4v.2",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",fill:"none"})]})})]})}const ga=148,RN=6e3,f8=16e3,LA=46,bs=34;function p8(e,t,n=ga){let r=-Math.round(t()*n);if(Math.abs(r-e)<bs){const s=e-bs>=-n?-bs:bs;r=Math.max(-n,Math.min(0,Math.round(e+s)))}return{to:r,ms:Math.round(Math.abs(r-e)*LA)}}function m8(e){return Math.round(RN+e()*(f8-RN))}const AN=[{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 g8(e){const t=AN.reduce((r,s)=>r+s.weight,0);let n=e()*t;for(const r of AN)if(n-=r.weight,n<0)return r.kind;return"stroll"}const y8=720,w8=260,v8=620,x8=220,MN=520,PA=1600,$N=7e3,b8=15e3,IN=6e3,k8=14e3;function go(e,t,n=ga){let r=-Math.round(t()*n);if(Math.abs(r-e)<bs){const s=e-bs>=-n?-bs:bs;r=Math.max(-n,Math.min(0,Math.round(e+s)))}return r}const jt=(e,t)=>Math.round(Math.abs(t-e)*LA),N8=120,iu=0;function S8(e,t){const n=r=>({kind:"litter",at:t,...r});return[{x:t,prop:n({}),act:"walk",ms:jt(e,t)},{x:t,prop:n({}),act:"stoop",ms:y8},{x:iu,prop:n({held:!0}),act:"carry",ms:jt(t,iu)},{x:iu,prop:n({held:!0}),act:"windup",ms:w8},{x:iu,prop:n({held:!0,leaving:!0}),act:"toss",ms:v8}]}function j8(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:jt(e,r)},{x:r,prop:s(),act:"windup",ms:x8,facing:n>0?"right":"left"},{x:r,prop:s({leaving:!0}),act:"kick",ms:MN,facing:n>0?"right":"left"},{x:r,prop:s({leaving:!0}),act:"stand",ms:PA-MN}]}const DA=640;function _8(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:jt(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:jt(r,0)}]}function E8(e,t,n){const r=Math.max(-110,Math.min(-30,t)),s={x:r,prop:null};return[{...s,act:"walk",ms:jt(e,r)},{...s,act:"skip-ready",ms:500},{...s,act:"skip",ms:DA*(6+Math.floor(n()*5))},{...s,act:"skip-rest",ms:600},{...s,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:jt(r,0)}]}function C8(e,t,n){return[{x:t,prop:null,act:"walk",ms:jt(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(IN+n()*(k8-IN))},{x:t,prop:null,act:"stand",ms:400}]}function T8(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:jt(e,t)},{x:t,prop:r(),act:"watch",ms:Math.round($N+n()*(b8-$N))},{x:t,prop:r(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function Gf(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 R8=1500,A8=e=>Math.round(1e3*Math.sqrt(2*e/R8)),M8=115,$8=e=>Math.round(e/M8*1e3),I8=620,O8=200,L8=760,P8=600,D8=240;function F8(e,t,n){const s=-(t.ledgeSpan??ga),o=A8(t.ledgeH),l=$8(t.ledgeH),u=n(),d=n(),f=-Math.round(u*t.floorSpan),h=-Math.round(d*t.floorSpan);return[{x:s,act:"walk",prop:null,ms:jt(e,s)},{x:s,act:"peer",prop:null,ms:I8},{x:s,act:"fall",prop:null,ms:o,place:"floor"},{x:s,act:"land",prop:null,ms:O8,place:"floor"},{x:f,act:"walk",prop:null,ms:jt(s,f),place:"floor",floorFrac:u},{x:h,act:"walk",prop:null,ms:jt(f,h),place:"floor",floorFrac:d},{x:s,act:"walk",prop:null,ms:jt(h,s),place:"floor"},{x:s,act:"lasso",prop:null,ms:L8,place:"floor"},{x:s,act:"rope-throw",prop:null,ms:P8,place:"floor"},{x:s,act:"rope-catch",prop:null,ms:D8,place:"floor"},{x:s,act:"climb",prop:null,ms:l},{x:s,act:"pull-up",prop:null,ms:480}]}function q8(e,t,n){const r=(n==null?void 0:n.ledgeSpan)??ga;switch(g8(t)){case"tidy":return S8(e,go(e,t,r));case"kick":return j8(e,go(e,t,r));case"sit":return C8(e,go(e,t,r),t);case"watch":return T8(e,go(e,t,r),t);case"fish":return _8(e,go(e,t,r),t);case"skip":return E8(e,go(e,t,r),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return F8(e,n,t)}}const o=p8(e,t,r);return[{x:o.to,prop:null,act:"walk",ms:o.ms}]}const B8=420;function z8(e,t,n){const r=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(B8,Math.max(0,r))}const U8=260,H8=200;function W8(e,t,n){const r=(h,m=jt(e,h))=>({x:h,prop:null,act:"walk",ms:m,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,f={place:"floor",riser:n.height,prop:null};return[r(u,jt(e,u)),{...f,x:u,act:"mount",ms:U8},{...f,x:d,act:"walk",ms:jt(u,d)},{x:d,prop:null,act:"dismount",ms:H8,place:"floor"},{x:t,prop:null,act:"walk",ms:jt(d,t),place:"floor"}]}const FA=["bob","sway","groove"],ON=9e3,V8=16e3,qA=1e3,G8=.08;function K8(e,t){const n=FA.filter(o=>o!==e),r=n[Math.min(n.length-1,Math.floor(t()*n.length))],s=(t()*2-1)*G8;return{dance:r,beatMs:Math.round(qA*(1+s))}}function Y8(e){return Math.round(ON+e()*(V8-ON))}const BA=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],LN=18,X8=BA.length,zA=new Set(["a","c","p"]);function xd(e=BA){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 Z8=[".xx.","xxxx",".xx."],J8=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],Q8=["...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."],Kf={litter:Z8,ball:J8,scope:Q8},eB=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],tB=3,nB=-1,Gv=11,PN=9,Kv="https://www.youtube-nocookie.com";function rB(e,t,n){const r=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${Kv}/embed/${n?encodeURIComponent(n):"live_stream"}?${r.toString()}`}function yo(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function sB(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const aB=[1,3],oB=[0,2],iB=[2,5,100,101,150];function lB(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:aB.includes(s)?{kind:"playing",playing:!0}:oB.includes(s)?{kind:"playing",playing:!1}:null}return null}const cB="modulepreload",uB=function(e){return"/"+e},DN={},s0=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){let l=function(f){return Promise.all(f.map(h=>Promise.resolve(h).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};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(f=>{if(f=uB(f),f in DN)return;DN[f]=!0;const h=f.endsWith(".css"),m=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${m}`))return;const g=document.createElement("link");if(g.rel=h?"stylesheet":cB,h||(g.as="script"),g.crossOrigin="",g.href=f,d&&g.setAttribute("nonce",d),document.head.appendChild(g),h)return new Promise((w,k)=>{g.addEventListener("load",w),g.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${f}`)))})}))}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)})},dB={"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 hB({fetchImpl:e,volume:t,muted:n,source:r,playRequest:s,customStation:o,onAvailabilityChange:l}){const[u,d]=x.useState(null),[f,h]=x.useState(!1),[m,g]=x.useState(!1),[w,k]=x.useState(!1),v=x.useRef(s),b=x.useRef(null),S=x.useRef(null),_=x.useRef(null),j=x.useCallback(()=>{var A;(A=S.current)==null||A.destroy(),S.current=null;const I=b.current;I&&(I.pause(),I.removeAttribute("src"),I.load(),b.current=null)},[]),E=x.useCallback(I=>{var A,L;(L=(A=_.current)==null?void 0:A.contentWindow)==null||L.postMessage(I,Kv)},[]),T=x.useRef(t);T.current=t;const R=x.useRef(n);R.current=n;const M=x.useCallback((I,A,L)=>{j();const z=new Audio;z.preload="none",z.volume=T.current/100,z.muted=R.current,b.current=z,g(!0),k(!0);const V=()=>b.current===z,$=()=>{j(),g(!1),k(!1)},P=()=>{V()&&($(),h(!0),l==null||l(L,!0))},F=Y=>{if(V()){if(Y instanceof DOMException&&Y.name==="NotAllowedError"){$();return}P()}};z.addEventListener("playing",()=>{V()&&(k(!0),l==null||l(L,!1))}),z.addEventListener("ended",()=>{V()&&$()}),z.addEventListener("error",P,{once:!0}),A&&!z.canPlayType("application/vnd.apple.mpegurl")?s0(async()=>{const{default:Y}=await import("./hls-BFpXDghs.js");return{default:Y}},[]).then(({default:Y})=>{if(!V())return;if(!Y.isSupported()){P();return}const K=new Y;S.current=K,K.on(Y.Events.ERROR,(D,W)=>{W.fatal&&P()}),K.on(Y.Events.MEDIA_ATTACHED,()=>K.loadSource(I)),K.on(Y.Events.MANIFEST_PARSED,()=>{z.play().catch(F)}),K.attachMedia(z)},P):(z.src=I,z.play().catch(F))},[l,j]);return x.useEffect(()=>{m&&(E(yo("setVolume",[t])),E(yo(n?"mute":"unMute")),b.current&&(b.current.volume=t/100,b.current.muted=n))},[t,n,m,E]),x.useEffect(()=>{let I=!0;const A=e??fetch,L=v.current!==s;v.current=s,d(null),h(!1),g(L),k(L),j();const z=o&&ba(o.id)===r?Wx(o.url):null;if(z)return z.kind==="direct-audio"?(d({live:!0,channel:"",audio:z.url,hls:z.format==="hls"}),l==null||l(r,!1),L&&M(z.url,z.format==="hls",r),()=>{I=!1}):(A(`/api/fm-station?url=${encodeURIComponent(z.url)}`).then(P=>P.ok?P.json():null).then(P=>{I&&(P!=null&&P.channel||P!=null&&P.video?(d({live:!0,channel:P.channel??"",video:P.video??void 0}),l==null||l(r,!1)):(h(!0),l==null||l(r,!0)))}).catch(()=>{I&&(h(!0),l==null||l(r,!0))}),()=>{I=!1});if(Fo(r))return h(!0),l==null||l(r,!0),()=>{I=!1};const V=r,$=dB[V];if($)A($).then(P=>P.ok?P.json():null).then(P=>{I&&(P!=null&&P.video&&d({live:!0,channel:"",video:P.video}),l==null||l(r,!(P!=null&&P.video)))}).catch(()=>{I&&(l==null||l(r,!0))});else if(V!=="claude-fm"){const P=V.replace("lofi-","");A(`/api/lofi-girl?station=${encodeURIComponent(P)}`).then(F=>F.ok?F.json():null).then(F=>{I&&(F!=null&&F.video&&d({live:!0,channel:"",video:F.video}),l==null||l(r,!(F!=null&&F.video)))}).catch(()=>{I&&(l==null||l(r,!0))})}else A("/api/claude-fm").then(P=>P.ok?P.json():null).then(P=>{if(!I)return;const F=!!(P!=null&&P.live&&(P!=null&&P.channel));F&&d({live:!0,channel:P.channel}),l==null||l(r,!F)}).catch(()=>{I&&(l==null||l(r,!0))});return()=>{I=!1}},[o==null?void 0:o.id,o==null?void 0:o.url,e,l,s,r,M,j]),x.useEffect(()=>()=>j(),[j]),x.useEffect(()=>{if(!m)return;const I=A=>{var z;if(A.origin!==Kv||A.source!==((z=_.current)==null?void 0:z.contentWindow))return;const L=lB(A.data);if(L){if(L.kind==="ready"){E(yo("setVolume",[T.current])),E(yo(n?"mute":"unMute")),E(yo("playVideo"));return}if(L.kind==="playing"){k(L.playing);return}iB.includes(L.code)&&(g(!1),k(!1),h(!0),l==null||l(r,!0))}};return window.addEventListener("message",I),()=>window.removeEventListener("message",I)},[m,n,l,E,r]),{probe:u,dead:f,armed:m,playing:w,frame:_,say:E,press:()=>{if(!u)return;if(u.audio){if(m){j(),g(!1),k(!1);return}M(u.audio,u.hls===!0,r);return}if(!m){g(!0),k(!0);return}const I=!w;k(I),E(yo(I?"playVideo":"pauseVideo")),I||g(!1)}}}function FN(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 f=n;n=null,f==null||f()},r))},d=()=>{e.hidden&&t!==null?(r=Math.max(0,r-(performance.now()-s)),l()):e.hidden||u()};return e.addEventListener("visibilitychange",d),{schedule(f,h){o||(l(),n=f,r=Math.max(0,h),u())},dispose(){o=!0,l(),n=null,e.removeEventListener("visibilitychange",d)}}}function fB(e,t,n){const[r,s]=x.useState(0),[o,l]=x.useState(0),[u,d]=x.useState(null),[f,h]=x.useState(null),[m,g]=x.useState({x:0,drop:0}),[w,k]=x.useState("ledge"),[v,b]=x.useState("left"),[S,_]=x.useState(0),j=x.useRef(null),[E,T]=x.useState(()=>document.hidden);x.useEffect(()=>{const z=new Set,V=()=>{var $;if(document.hidden){for(const P of(($=j.current)==null?void 0:$.getAnimations({subtree:!0}))??[])if(P.playState==="running"||P.pending){const F=P.currentTime;P.pause(),F!==null&&(P.currentTime=F),z.add(P)}}else{for(const P of z)P.playState==="paused"&&P.play();z.clear()}T(document.hidden)};return V(),document.addEventListener("visibilitychange",V),()=>document.removeEventListener("visibilitychange",V)},[e,t]);const[R,M]=x.useState(null),[O,I]=x.useState(qA),[A,L]=x.useState(()=>{var z;return((z=window.matchMedia)==null?void 0:z.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});return x.useEffect(()=>{var $;const z=($=window.matchMedia)==null?void 0:$.call(window,"(prefers-reduced-motion: reduce)");if(!z)return;const V=()=>L(z.matches);return V(),z.addEventListener("change",V),()=>z.removeEventListener("change",V)},[]),x.useEffect(()=>{var H;if(!e||t||A)return;const z=FN(document);let V=0;s(J=>V=J);let $=null,P=0,F=0;const Y=J=>{var Ne,ke;const[ee,...re]=J;if(!ee){$=null,d(null),h(null),G();return}d(ee.act),h(ee.prop),k(ee.place??"ledge"),_(ee.riser??0);const oe=V,fe=B(ee);if(ee.act==="kick"){const we=(ke=(Ne=j.current)==null?void 0:Ne.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:ke.getBoundingClientRect();we&&g({x:z8(we.x,Gf(ee,oe,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-we.y+24)})}F=ee.act==="walk"?Math.max(jt(oe,fe),N8):ee.ms,ee.act==="carry"&&(F=jt(oe,fe)),l(F),b(we=>Gf({...ee,x:fe},oe,we)),s(fe),V=fe,$=ee,P=Date.now(),z.schedule(()=>Y(re),F)},K=()=>{const J=j.current,ee=J==null?void 0:J.querySelector(".fm-sprite"),re=J==null?void 0:J.parentElement;if(!J||!ee||!re)return null;const oe=J.getBoundingClientRect(),fe=re.getBoundingClientRect(),Ne=fe.right-oe.right,ke=fe.width-Ne*2-ee.offsetWidth;return ke>0?ke:null},D=()=>{const J=j.current,ee=J==null?void 0:J.querySelector(".fm-walker"),re=K();if(!J||!ee||re==null)return;const oe=J.getBoundingClientRect().bottom-ee.getBoundingClientRect().bottom;if(oe>0)return{ledgeH:oe,floorSpan:re}},W=()=>{const J=j.current,ee=document.querySelector(".autofit-chip");if(!J||!ee)return null;const re=J.getBoundingClientRect(),oe=ee.getBoundingClientRect();return oe.width<=0||oe.height<=0?null:{left:oe.left-re.right,right:oe.right-re.right,height:oe.height}},B=J=>{const ee=(J.place??"ledge")==="floor",re=ee?K()??ga:ga,oe=ee&&J.floorFrac!=null?-Math.round(J.floorFrac*re):J.x;return Math.max(-re,Math.min(0,oe))},X=()=>{if(!$)return;const J=B($);J!==V&&(l(Math.max(0,P+F-Date.now())),b(ee=>Gf({...$,x:J},V,ee)),s(J),V=J)},G=()=>{z.schedule(()=>{const J=q8(V,Math.random,D()),ee=J.some(fe=>fe.place==="floor")?W():null;let re=V;const oe=J.flatMap(fe=>{const Ne=re;if(re=fe.x,!(fe.place==="floor"&&fe.act==="walk"))return[fe];const ke=W8(Ne,fe.x,ee),we=ke.length-1;return fe.floorFrac==null?ke:ke.map((ve,$e)=>$e===we?{...ve,floorFrac:fe.floorFrac}:ve)});Y(oe)},m8(Math.random))},U=(H=j.current)==null?void 0:H.parentElement,Z=typeof ResizeObserver>"u"?null:new ResizeObserver(X);return U&&Z&&Z.observe(U),G(),()=>{z.dispose(),Z==null||Z.disconnect(),k("ledge"),s(J=>Math.max(-ga,Math.min(0,J))),l(0),d(null),h(null),_(0)}},[e,t,A]),x.useEffect(()=>{if(!n||A){M(null);return}const z=FN(document),V=$=>{const P=K8($,Math.random);M(P.dance),I(P.beatMs),z.schedule(()=>V(P.dance),Y8(Math.random))};return V(null),()=>z.dispose()},[n,A]),{scene:j,suspended:E,x:r,walkMs:o,act:u,prop:f,ballFlight:m,place:w,facing:v,riser:S,dance:R,beatMs:O}}const Yf={e:"fm-eye",s:"fm-shade",p:"fm-pad"},Wu=xd().filter(e=>!zA.has(e.cell)),pB=xd().filter(e=>zA.has(e.cell)),qN=Wu.filter(e=>e.cell==="e"),mB=xd(eB),gB=Wu.filter(e=>e.y<Gv&&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),yB={left:Wu.filter(e=>e.y>=Gv&&e.x<PN),right:Wu.filter(e=>e.y>=Gv&&e.x>=PN)},wB=x.memo(function({act:t,facing:n}){return i.jsxs("svg",{viewBox:`0 0 ${LN} ${X8}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[i.jsx("g",{className:"fm-gear",children:i.jsx("g",{className:"fm-gear-motion",children:pB.map(r=>i.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:Yf[r.cell]},`g${r.y}-${r.x}`))})}),i.jsxs("g",{className:"fm-body",children:[qN.map(r=>i.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:"var(--accent)"},`eye-bed-${r.x}`)),gB.map(r=>i.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:Yf[r.cell]},`b${r.y}-${r.x}`)),i.jsxs("g",{className:"fm-arms",children:[i.jsx("rect",{x:4,y:8,width:2,height:2}),i.jsx("rect",{x:12,y:8,width:1,height:2}),i.jsx("rect",{x:13,y:8,width:1,height:2,className:"fm-shade"})]}),qN.map(r=>i.jsx("rect",{x:r.x-(r.x>=LN/2?1:0)+(n==="right"?1:0),y:r.y,width:r.w,height:1,className:"fm-eye"},`eye-${r.x}`))]}),i.jsx("g",{className:"fm-hat",children:mB.map(r=>i.jsx("rect",{x:tB+r.x,y:nB+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")&&i.jsxs("g",{className:"fm-grip",children:[i.jsx("path",{className:"fm-grip-left",d:"M5 9H4V4H7V3H9V5H6V9Z"}),i.jsx("path",{className:"fm-grip-right",d:"M12 9H14V6H11V5H9V7H12Z"})]}),(t==="land"||t==="dismount")&&i.jsxs("g",{className:"fm-crouch-legs",children:[i.jsx("path",{d:"M6 11H8V13H6Z"}),i.jsx("path",{d:"M10 11H12V13H10Z"})]}),["sit","cast","fish","reel","stow"].includes(t)&&i.jsxs("g",{className:"fm-seated-legs",children:[i.jsx("path",{className:"fm-seated-far",d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),i.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(r=>i.jsx("g",{className:"fm-leg","data-side":r,children:yB[r].map(s=>i.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:Yf[s.cell]},`${r}${s.y}-${s.x}`))},r))]})}),vB={"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 xB(e,t){return t&&ba(t.id)===e?t.name:Fo(e)?"Custom FM":vB[e]}function Xf(e,t){var r;const n=((r=e[0])==null?void 0:r.length)??0;return i.jsx("svg",{viewBox:`0 0 ${n} ${e.length}`,shapeRendering:"crispEdges","aria-hidden":!0,children:xd(e).map(s=>i.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 BN={litter:Xf(Kf.litter,"litter"),ball:Xf(Kf.ball,"ball"),scope:Xf(Kf.scope,"scope")};function bB(e){try{return new URL(e).host}catch{return"the station's server"}}const kB=x.memo(function({fetchImpl:t,volume:n,muted:r=!1,source:s="claude-fm",playRequest:o=0,customStation:l,onAvailabilityChange:u}){const{probe:d,dead:f,armed:h,playing:m,frame:g,say:w,press:k}=hB({fetchImpl:t,volume:n,muted:r,source:s,playRequest:o,customStation:l,onAvailabilityChange:u}),{scene:v,suspended:b,x:S,walkMs:_,act:j,prop:E,ballFlight:T,place:R,facing:M,riser:O,dance:I,beatMs:A}=fB(d,f,m);if(!d||f)return null;const L=xB(s,l),z=d.audio?bB(d.audio):"YouTube";return i.jsxs("div",{ref:v,className:"fm","data-suspended":b?"":void 0,"data-place":R,style:{"--fm-beat":`${A}ms`},children:[E&&!E.held&&i.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":`${PA}ms`,"--fm-ball-turn":M==="right"?"1080deg":"-1080deg"},children:BN[E.kind]}),(j==="lasso"||j==="rope-throw"||j==="rope-catch"||j==="climb"||j==="pull-up")&&i.jsxs("div",{className:"fm-rope","data-act":j,style:{"--fm-rope-x":`${S}px`,"--fm-rope-ms":`${_}ms`},children:[i.jsx("div",{className:"fm-rope-line"}),i.jsxs("svg",{className:"fm-rope-hook",viewBox:"0 0 9 9",shapeRendering:"crispEdges","aria-hidden":!0,children:[i.jsx("path",{d:"M4 8V3H3V1H1V3H0V5H2V4H3V6H5V4H6V5H8V3H7V1H5V3H4"}),i.jsx("rect",{className:"fm-rope-knot",x:"3",y:"6",width:"3",height:"2"})]})]}),i.jsxs("div",{className:"fm-walker","data-act":j??void 0,"data-place":R,"data-facing":M,style:{"--fm-x":`${S}px`,"--fm-walk-ms":`${_}ms`,"--fm-riser":`${O}px`,"--fm-skip-beat":`${DA}ms`},children:[(E==null?void 0:E.held)&&i.jsx("div",{className:"fm-held","data-prop":E.kind,"data-toss":E.leaving?"":void 0,children:BN[E.kind]}),["cast","fish","reel","stow"].includes(j)&&i.jsxs("svg",{className:"fm-fishing",viewBox:"0 0 24 32",shapeRendering:"crispEdges","aria-hidden":!0,children:[i.jsxs("g",{children:[i.jsx("path",{d:"M24 11H22V9H20V7H18V5H16V3H13V2H8"}),i.jsx("rect",{className:"fm-fishing-grip",x:"21",y:"9",width:"3",height:"3"})]}),i.jsxs("g",{className:"fm-fishing-line",children:[i.jsx("path",{d:"M8 2V26"}),i.jsxs("g",{className:"fm-float",children:[i.jsx("rect",{x:"7",y:"25",width:"3",height:"2"}),i.jsx("rect",{x:"8",y:"24",width:"1",height:"1"})]})]}),i.jsx("path",{className:"fm-ripple",d:"M3 28H6M10 28H14M5 30H12"})]}),["skip-ready","skip","skip-rest"].includes(j)&&i.jsxs("svg",{className:"fm-skipping-rope",viewBox:"0 0 26 26",shapeRendering:"crispEdges","aria-hidden":!0,children:[i.jsx("path",{className:"fm-skip-back",d:"M5 18H3V8H5V5H8V2H18V5H21V8H23V18H21"}),i.jsx("path",{className:"fm-skip-forward",d:"M5 18H3V14H5V11H8V9H18V11H21V14H23V18H21"}),i.jsx("path",{className:"fm-skip-front",d:"M5 18H3V21H5V23H8V25H18V23H21V21H23V18H21"}),i.jsx("path",{className:"fm-skip-return",d:"M5 18H3V19H8V20H18V19H23V18H21"}),i.jsx("path",{className:"fm-skip-handles",d:"M5 17V19M21 17V19"})]}),i.jsx("button",{type:"button",className:"fm-sprite","data-playing":m?"":void 0,"data-dance":m?I??FA[0]:void 0,onClick:k,title:m?`Stop ${L}`:`Play ${L} — streams from ${z}`,"aria-label":m?`Stop ${L}`:`Play ${L}`,children:i.jsx(wB,{act:j,facing:M})})]}),h&&!d.audio&&(d.channel||d.video)&&i.jsx("iframe",{ref:g,className:"fm-frame",title:L,src:rB(d.channel,window.location.origin,d.video),onLoad:()=>w(sB()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})]})});function UA(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 Vu(e){return UA(Math.floor(e/1e3))}function HA(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 NB(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Gu(e,t,n){const r=new Date(e),s=Vu(t-e);return{label:NB(r,new Date(t))?s:`${s} · ${r.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:r.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function SB({data:e}){const t=Zo(3e4),n=Gu(e.recap.at,t);return i.jsxs("div",{className:"recap-note",role:"note","aria-label":"Claude Code's recap",style:{"--session-hue":e.hue},children:[i.jsxs("div",{className:"recap-note-head",children:[i.jsxs("span",{className:"recap-note-mark",children:[i.jsx(Nl,{}),"recap"]}),i.jsx("span",{className:"recap-note-age",title:n.title,children:n.label}),i.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(),dq(e.noteKey)},children:"×"})]}),i.jsx("p",{className:"recap-note-text",children:e.recap.text}),i.jsxs("div",{className:"lod-face recap-face","aria-hidden":!0,children:[i.jsxs("div",{className:"lod-id",children:[i.jsxs("span",{className:"recap-note-mark",children:[i.jsx(Nl,{}),"recap"]}),i.jsx("span",{className:"recap-face-age",children:n.label})]}),i.jsx("p",{className:"recap-face-text",children:e.recap.text})]}),i.jsx(xa,{type:"source",position:Ce.Right,style:{background:"transparent",border:"none"}})]})}function jB({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s,targetPosition:o,style:l}){const[u]=Dx({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o,curvature:.35});return i.jsxs("g",{className:"recap-tie",style:l,children:[i.jsx("path",{className:"recap-tie-thread",d:u}),i.jsx("path",{className:"recap-tie-beads",d:u}),i.jsx("circle",{className:"recap-tie-end",cx:e,cy:t,r:3.5}),i.jsx("circle",{className:"recap-tie-end",cx:n,cy:r,r:3.5})]})}const _u=" · ",_B=32,EB=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function zN(e){return EB.test(e)?2:1}function UN(e,t=_B){const n=[...e];let r=0;for(const l of n)r+=zN(l);if(r<=t)return e;const s=[];let o=0;for(const l of n){const u=zN(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 CB(e,t,n,r){const s=(t==null?void 0:t.trim())??"",o=r?TB(n):void 0,l=[e,s||void 0,o].filter(Boolean);return{label:UN(e),name:s?UN(s):void 0,shortId:o,fullLabel:l.join(_u)}}function TB(e){const t=e.match(/[a-zA-Z0-9]{4}/);return t?t[0]:e.slice(0,4)}const fa=18,Yv=26,WA=12,RB=240;function AB(e,t){return(e+RB)*(t||1)}function MB(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 $B(e,t,n){return{position:"absolute",left:e.x+16,top:e.y-WA/(t||1),transform:`scale(${1/(t||1)})`,transformOrigin:"left top",maxWidth:AB(e.w,t),"--session-hue":n}}function IB(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,f=u+s.height,h=t.get(o.sessionId),m=OB(o);h?(h.minX=Math.min(h.minX,l),h.minY=Math.min(h.minY,u),h.maxX=Math.max(h.maxX,d),h.maxY=Math.max(h.maxY,f),m&&(h.label=m.label??h.label,h.name=m.name,h.alarm=m.alarm,h.branch=m.branch)):t.set(o.sessionId,{minX:l,minY:u,maxX:d,maxY:f,label:(m==null?void 0:m.label)??o.sessionId,name:m==null?void 0:m.name,alarm:(m==null?void 0:m.alarm)??!1,branch:m==null?void 0:m.branch})}const n=new Map;for(const s of t.values())n.set(s.label,(n.get(s.label)??0)+1);const r=[];for(const[s,o]of t){const l=(n.get(o.label)??0)>1;r.push({sessionId:s,...CB(o.label,o.name,s,l),x:o.minX-fa,y:o.minY-fa-Yv,w:o.maxX-o.minX+fa*2,h:o.maxY-o.minY+fa*2+Yv,...o.alarm?{alarm:!0}:null,...o.branch?{branch:o.branch}:null})}return r}function OB(e){if(e.kind!=="root")return null;const t=e.branch;return{label:e.label,name:Jx(e.sessionName,e.sessionTitle).face,alarm:Kn(e.waiting),branch:t&&t.total>0?TA(t):void 0}}function LB(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 PB(e){return IB(e.nodeInternals.values())}function DB({onFocusSession:e}){const{x:t,y:n,zoom:r}=HR(),s=We(PB,LB);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 i.jsx("div",{className:"session-clusters",style:l,children:s.map(u=>{const d=Uu(u.sessionId),f=MB(u,d),h=$B(u,r,d);return i.jsxs(ce.Fragment,{children:[i.jsx("div",{className:"cluster-card",style:f,"aria-hidden":!0}),i.jsxs("button",{type:"button",className:"cluster-label","data-alarm":u.alarm?"":void 0,style:h,title:`${u.alarm?`Waiting on you
71
- `:""}Zoom to ${u.fullLabel}
72
- drag the wrapper to move the whole session`,onClick:()=>o(u.sessionId),children:[u.alarm?i.jsxs(i.Fragment,{children:[i.jsx(r0,{}),i.jsx("span",{className:"cluster-label-said",children:"waiting on you: "})]}):null,u.label,u.branch?i.jsx("span",{className:"cluster-label-branch",children:_u+u.branch}):null,u.name?i.jsx("span",{className:"cluster-label-name",children:_u+u.name}):null,u.shortId?i.jsx("span",{className:"cluster-label-id",children:_u+u.shortId}):null]})]},u.sessionId)})})}function FB({data:e}){return i.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const VA=600,qB=4,BB=36,Xv=16,zB=60,UB=6,HN=220,HB=96,WB=28;function VB(e,t){return Math.max(HB,61+[...t].length*6.8)}function GB(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function KB(e,t){if(t==null)return 1;const n=e-t;return n<0?1:Math.max(0,1-n/VA)}function YB(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 XB(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>VA)continue;const d=r.get(u.id)??n.get(u.id);if(!d)continue;const f=YB(u.tools,qB);if(f.length===0)continue;const h=u.exitAt??null,m=s.get(u.id),g=Math.max((m==null?void 0:m.width)??HN,HN),w=(m==null?void 0:m.height)??130,k=d.x,v=d.y,b=k+g,S=v+w/2;f.forEach((_,j)=>{const E=j*BB,T=k+g+zB,R=v+UB+E,M=KB(o,h),O=_.inputPreview??"",I=GB(_),A=M<.999,L=n0(_.name);l.push({id:`${u.id}::${_.id}`,toolId:_.id,agentId:u.id,toolName:_.name,name:L.label,emoji:L.emoji,status:I,category:RA(_.name),mcpHue:L.hue,inputPreview:O,fade:M,fading:A,worldX:T,worldY:R,anchorX:b,anchorY:S,spawnDx:b-T,spawnDy:S-(R+Xv)});const z=$A(_.name,_.input);if(z){const V=VB(_.name,L.label),$=T+V+WB,P=R,F=T+V,Y=R+Xv;l.push({id:`sub:${u.id}::${_.id}`,toolId:_.id,agentId:u.id,toolName:_.name,name:Wq(z.label,z.category),fullName:z.label,emoji:z.emoji,isSub:!0,status:I,category:z.category,inputPreview:z.detail??O,fade:M,fading:A,worldX:$,worldY:P,anchorX:F,anchorY:Y,spawnDx:F-$,spawnDy:0})}})}return l}function ZB({agents:e,visibleAgentIds:t,positions:n,pinned:r,measured:s,spotlight:o,hiddenCategories:l,now:u,onOpenTool:d}){const f=XB(e,t,n,r,s,u),h=l&&l.size>0?f.filter(m=>!l.has(m.category)):f;return i.jsx(JB,{bursts:h,spotlight:o,onOpenTool:d})}function JB({bursts:e,spotlight:t,onOpenTool:n}){const{x:r,y:s,zoom:o}=HR();return i.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[i.jsx("svg",{className:"tool-bursts-svg",children:e.map(l=>{const u=l.anchorX*o+r,d=l.anchorY*o+s,f=(l.worldX+6)*o+r,h=(l.worldY+Xv)*o+s,m=Math.max(1,f-u),g=Math.min(1,Math.abs(h-d)/m),w=u+m*(.55-.22*g),k=t!=null&&!t.has(l.agentId),v=l.fade*(k?.14:1);return i.jsx("path",{d:`M ${u} ${d} Q ${w} ${d}, ${f} ${h}`,className:`tool-conn status-${l.status}${l.fading?" fading":""}`,opacity:v},`l:${l.id}`)})}),e.map(l=>i.jsx(ez,{b:l,x:r,y:s,zoom:o,dim:t!=null&&!t.has(l.agentId),onOpenTool:n},l.id))]})}function QB(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 ez=x.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,f={left:`${u}px`,top:`${d}px`,transform:`scale(${s})`,transformOrigin:"left top","--spawn-dx":`${t.spawnDx}px`,"--spawn-dy":`${t.spawnDy}px`},h=t.isSub?`${t.toolName} · ${t.fullName??t.name}`:t.toolName,m=t.inputPreview?`${h} · ${t.inputPreview}`:h,g=l!=null,w=t.mcpHue!=null?{"--mcp-hue":t.mcpHue}:{},k=o?" dim":"";return i.jsx("div",{className:"tool-burst-wrap",style:f,children:i.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:w,title:m,onClick:g?()=>l(t.agentId,t.toolId):void 0,children:[i.jsx("span",{className:"tb-emoji",children:t.emoji}),i.jsx("span",{className:"tb-name",children:t.name}),t.status==="inflight"&&i.jsx("span",{className:"tb-spin"}),t.status==="done"&&i.jsx("span",{className:"tb-mark done",children:"✓"}),t.status==="err"&&i.jsx("span",{className:"tb-mark err",children:"×"})]})})},QB),tz={agent:Zq,sessionGroup:FB,recapNote:SB},nz={recapTie:jB},WN=400;function rz({graph:e,layout:t,viewport:n,clicks:r,drag:s,appearance:o,fm:l,autoFit:u,pause:d,stateRef:f,measuredRef:h,hiddenCats:m,now:g,openTool:w,focusAgent:k,requestClear:v,setKeyHelpOpen:b}){const{allNodes:S,edges:_,visibleAgentIds:j,spotlightSet:E}=e,{positionsRef:T,pinnedRef:R,handleRelayout:M}=t,{restoredViewport:O,onMoveStart:I,onMove:A}=n,{onNodeClick:L,onPaneClick:z,onNodeDoubleClick:V,onNodeMouseEnter:$,onNodeMouseLeave:P}=r,{onNodeDragStart:F,onNodeDrag:Y,onNodeDragStop:K}=s,{palette:D,minimapNodeFill:W,characterEnabled:B}=o,{fmVolume:X,fmMuted:G,fmSource:U,fmPlayRequest:Z,customFmStations:H,markFmStationAvailability:J}=l,{autoFitDisabled:ee,enableAutoFitAndRefit:re}=u,{paused:oe,pauseGate:fe,togglePause:Ne}=d;return i.jsxs(UR,{nodes:S,edges:_,nodeTypes:tz,edgesFocusable:!1,edgeTypes:nz,fitView:!O,fitViewOptions:{padding:.25,duration:zv({durationMs:WN,documentHidden:document.hidden})?WN:0},minZoom:XR,maxZoom:ZR,panOnScroll:!0,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,disableKeyboardA11y:!0,deleteKeyCode:null,onNodeClick:L,onPaneClick:z,onNodeDoubleClick:V,onNodeMouseEnter:$,onNodeMouseLeave:P,onMoveStart:I,onMove:A,onNodeDragStart:F,onNodeDrag:Y,onNodeDragStop:K,children:[i.jsx(eF,{gap:28,size:1,color:D["--grid-line"]}),i.jsx(DB,{onFocusSession:k}),i.jsx(ZB,{agents:f.current.agents,visibleAgentIds:j,positions:T.current,pinned:R.current,measured:h.current,spotlight:E,hiddenCategories:m,now:g,onOpenTool:w}),ee&&i.jsx(r8,{enableAutoFitAndRefit:re}),i.jsx(h8,{autoFitDisabled:ee,enableAutoFitAndRefit:re,paused:oe,pauseGate:fe,togglePause:Ne,handleRelayout:M,requestClear:v,setKeyHelpOpen:b}),i.jsx(B5,{zoomable:!0,pannable:!0,nodeColor:W,nodeStrokeWidth:2,maskColor:D["--minimap-mask"],maskStrokeColor:D["--line"]}),B&&i.jsx(kB,{volume:X,muted:G,source:U,playRequest:Z,customStation:H.find(ke=>ba(ke.id)===U),onAvailabilityChange:J})]})}function sz(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=an(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 az="spend on this board",oz="on this board",VN=`Everything on the board right now, and only that.
73
- 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.
74
- Press H for the totals ccusage reads off the logs on disk, which do not forget.`,GA="session spend",Zv="__unknown__",iz=12;function lz(e,t=Date.now()){const n=new Map;for(const r of e)for(const s of ql(r)){const o=s.model??Zv,l=bl(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:Sa(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 cz(e,t=Date.now()){const n=[...e],r=[];for(const s of n){if(s.kind!=="root")continue;let o=an(s,t).total,l=s.usage.inputTokens,u=s.usage.outputTokens,d=kl(s,t);for(const f of n)f.sessionId!==s.sessionId||f.kind==="root"||(o+=an(f,t).total,l+=f.usage.inputTokens,u+=f.usage.outputTokens,d+=kl(f,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,iz)}function GN(e){return e.waiting?Kn(e.waiting)?0:1:e.state==="active"?2:3}function uz(e,t){const n=[];for(const r of e.agents.values()){if(r.kind!=="root")continue;let s=r.toolCount,o=an(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+=an(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:wd(r),modelId:r.model,toolCount:s,cost:o,startedAt:r.startedAt,lastActivity:l})}return n.sort((r,s)=>{const o=GN(r),l=GN(s);return o!==l?o-l:r.waiting&&s.waiting?r.waiting.since-s.waiting.since:s.lastActivity-r.lastActivity}),n}function KN(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 dz({state:e,now:t,selectedIds:n,onSelect:r,onClose:s,removedIds:o,onBringBackAll:l}){const u=x.useMemo(()=>uz(e),[e,e.revision,t]),d=u.filter(h=>h.state==="active").length,f=u.filter(h=>Kn(h.waiting)).length;return i.jsxs("aside",{className:"session-list",id:"session-list","aria-label":"Sessions",children:[i.jsxs("div",{className:"sl-header",children:[i.jsxs("h2",{children:["Sessions ",i.jsx("span",{className:"sl-count",children:u.length})]}),f>0&&i.jsxs("span",{className:"sl-waiting-count",children:[f," waiting"]}),d>0&&i.jsxs("span",{className:"sl-live-count",children:[d," live"]}),i.jsx("button",{className:"glyph-btn sl-close",onClick:s,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),i.jsxs("ul",{className:"sl-rows",children:[u.length===0&&i.jsx("li",{className:"sl-empty",children:"No sessions yet."}),u.map(h=>{const m=n.has(h.sessionId),g=(o==null?void 0:o.has(h.sessionId))??!1;return i.jsx("li",{className:"sl-row-item",children:i.jsxs("button",{type:"button",className:`sl-row state-${h.state}${m?" selected":""}${g?" removed":""}`,"aria-current":m?"true":void 0,onClick:()=>r(h.sessionId),title:g?`Bring ${h.label} back to the board`:`Focus ${h.label}`,children:[i.jsx("span",{className:`sl-dot state-${h.state}`,"aria-hidden":!0}),i.jsx("span",{className:"vis-hidden",children:qo(h.state)}),i.jsxs("div",{className:"sl-row-body",children:[i.jsxs("div",{className:"sl-row-head",children:[i.jsx("span",{className:"sl-label",children:h.label}),g&&i.jsx("span",{className:"sl-removed",children:"off the board"}),h.modelId&&i.jsx("span",{className:"model-chip","data-family":pd(h.modelId),title:h.modelId,children:js(h.modelId)})]}),i.jsxs("div",{className:"sl-row-meta",children:[i.jsxs("span",{title:"tool calls",children:[i.jsx("b",{children:h.toolCount})," tools"]}),h.cost>0&&i.jsx("span",{className:"sl-cost",title:GA,children:i.jsx("b",{children:Be(h.cost)})}),h.waiting?i.jsxs("span",{className:"sl-waiting",title:[Bo(h.waiting),M6(h.waiting,Bo(h.waiting)),`Blocked since ${new Date(h.waiting.since).toLocaleTimeString()} · started ${new Date(h.startedAt).toLocaleString()}`].filter(Boolean).join(`
75
- `),children:["waiting ",KN(h.waiting.since,void 0,t),h.waiting.tool&&i.jsxs("span",{className:"sl-waiting-tool",children:[" · ",h.waiting.tool.name]})]}):i.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(h.startedAt).toLocaleString()}`,children:KN(h.startedAt,h.state==="active"?void 0:h.lastActivity,t)})]}),h.recap&&i.jsxs("span",{className:"sl-recap",title:h.recap.text,children:[i.jsx(Nl,{}),h.recap.text]})]})]})},h.sessionId)})]}),(()=>{const h=(o==null?void 0:o.size)??0;return h===0||!l?null:i.jsx("div",{className:"sl-foot",children:i.jsxs("button",{type:"button",className:"btn sl-bring-back",onClick:m=>{const g=m.currentTarget.closest(".session-list");l(),requestAnimationFrame(()=>{var w;return(w=g==null?void 0:g.querySelector(".sl-row"))==null?void 0:w.focus()})},children:["Bring back ",h," removed ",h===1?"card":"cards"]})})})()]})}const Jv={cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,sessions:0};function hz(e){if(!e.synthetic)return!1;const t=e.usage;return t.inputTokens+t.outputTokens+t.cacheReadTokens+t.cacheCreateTokens<=0}function Qv(e,t){const n=new Map;for(const r of e){if(r.kind!=="root"||!r.sessionId||hz(r))continue;const s=an(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 fz(e,t){if(!e)return Jv;const n={...Jv};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 YN(e,t=new Date){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}const bd=[{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 pz(e,t,n=bd.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 KA(e,t=new Date){return e==="today"?YN(1,t):e==="month"?YN(t.getDate(),t):"20200101"}const tn=e=>typeof e=="number"&&Number.isFinite(e)?e:0,Eu=e=>typeof e=="string"?e:"";function YA(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=Eu(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+=tn(o==null?void 0:o.cost),u.inputTokens+=tn(o==null?void 0:o.inputTokens),u.outputTokens+=tn(o==null?void 0:o.outputTokens),u.cacheReadTokens+=tn(o==null?void 0:o.cacheReadTokens),u.cacheCreateTokens+=tn(o==null?void 0:o.cacheCreationTokens)}}return[...n.values()].sort((r,s)=>s.cost-r.cost||s.tokens-r.tokens)}const mz=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function gz(e){var t;return((t=mz.exec(e))==null?void 0:t[0])??e}function yz(e,t=new Map){const n=Array.isArray(e==null?void 0:e.sessions)?e.sessions:[],r=[];for(const s of n){const o=Eu(s==null?void 0:s.period);if(!o)continue;const l=gz(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:Eu(s==null?void 0:s.agent)||"claude",cost:tn(s==null?void 0:s.totalCost),tokens:tn(s==null?void 0:s.totalTokens),models:Array.isArray(s==null?void 0:s.modelsUsed)?s.modelsUsed.map(Eu).filter(Boolean):[],lastActivityMs:Number.isFinite(d)?d:null})}return r.sort((s,o)=>o.cost-s.cost||o.tokens-s.tokens)}function wz(e,t=kd(e).cost){const r=(Array.isArray(e==null?void 0:e.sessions)?e.sessions:[]).reduce((o,l)=>o+tn(l==null?void 0:l.totalCost),0),s=Math.max(.01,t*.01);return{sum:r,total:t,over:r>t+s}}function vz(e,t,n){const r=`Sessions with activity ${e}, and what ccusage puts against each one.`;return t.over?`${r}
76
- 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 kd(e){const t=e==null?void 0:e.totals;if(t&&typeof t=="object"){const d=tn(t.cacheReadTokens),f=tn(t.cacheCreationTokens),h=tn(t.inputTokens),m=tn(t.outputTokens);return{cost:tn(t.totalCost),inputTokens:h,outputTokens:m,cacheReadTokens:d,cacheCreateTokens:f,tokens:tn(t.totalTokens)||h+m+d+f}}const n=YA(e),r=d=>n.reduce((f,h)=>f+d(h),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 xz(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 XA(e,t){var n;return((n=bd.find(r=>r.key===(e??t)))==null?void 0:n.noun)??"today"}function bz(e,t,n){const r=e!=null,s=kd(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 ZA="agent-dag.usagePeriod";function kz(){const e=tt(ZA);return bd.some(t=>t.key===e)?e:"today"}function Nz(e){Ke(ZA,e)}const JA="agent-dag.usageSessionsOpen";function Sz(){return tt(JA)==="1"}function jz(e){Ke(JA,e?"1":"0")}function a0({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 i.jsx("span",{className:`cb-seg ${l}`,style:{width:`${d}%`},title:`${u}: ${Be(o)} (${d.toFixed(0)}%)`},l)},s=t==="lg";return i.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 gt="ccdeck";function QA(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 _z(e,t,n,r){const s=Math.max(0,t-r),o=Math.max(0,n-s);if(o<120)return null;const l=Math.min(100,o/n*100),u=e-l;if(Math.abs(u)<3)return{label:"on pace",color:"var(--ok)",expectedPct:l,isDeficit:!1};if(u>0){const d=100-e,f=o>0?e/o:0,h=f>0?d/f:1/0,m={label:`${Math.round(u)}% over pace`,color:"var(--warn)",expectedPct:l,isDeficit:!0};if(h<s&&h<86400){const g=Math.floor(h/3600),w=Math.floor(h%3600/60);m.runsOutIn=g>0?`${g}h ${w}m`:`${w}m`}return m}return{label:`${Math.round(-u)}% under pace`,color:"var(--ok)",expectedPct:l,isDeficit:!1}}function xs({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,h=o||d>=90?"var(--err)":d>=70?"var(--warn)":"var(--accent)",m=u?d===0?"< 1%":`${d}%`:"no reading",g=d===0?2:d,w=r?HA(r,l):null,k=u&&r&&s?_z(d,r,s,l):null,[v,b]=x.useState(!1),S=x.useId();return i.jsxs("div",{className:"qb-row",children:[i.jsxs("div",{className:"qb-meta",children:[i.jsxs("span",{className:"qb-label",children:[t,o&&i.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),i.jsx("span",{className:"qb-pct",style:{color:u?h:"var(--muted)"},children:m})]}),i.jsxs("div",{className:"qb-track",children:[u&&i.jsx("div",{className:"qb-fill",style:{transform:`scaleX(${g/100})`,background:h,opacity:d===0?.4:1}}),k&&i.jsx("div",{className:"qb-pace-rail",style:{transform:`translateX(${k.expectedPct}%)`},children:i.jsx("div",{"aria-hidden":!0,className:"qb-pace-marker",style:{background:k.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(k.expectedPct)}% by now`})})]}),i.jsxs("div",{className:"qb-reset-row",children:[w?i.jsxs("span",{className:"qb-reset",children:["resets in ",w]}):n?i.jsxs("span",{className:"qb-reset",children:["resets ",n]}):null,k&&i.jsxs("button",{type:"button",className:"qb-pace",style:{color:k.color},"aria-expanded":v,"aria-controls":v?S:void 0,onClick:()=>b(_=>!_),children:[i.jsx("i",{className:"qb-pace-key","aria-hidden":!0,style:{background:k.isDeficit?"var(--err)":"var(--ok)"}}),k.runsOutIn?`runs out in ${k.runsOutIn}`:k.label]})]}),v&&k&&i.jsxs("div",{id:S,className:"qb-why",children:["To last until reset, stay near ",Math.round(k.expectedPct),"% by now."]})]})}function eM(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 Ez(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 Cz(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 Tz(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 Rz({quota:e,quotaLoading:t,nowSec:n}){const r=eM(e==null?void 0:e.fetchedAt,n);return i.jsxs("section",{className:"up-section up-quota-section",children:[i.jsxs("h3",{className:"up-section-title",children:["Claude quota",r&&!t&&i.jsx("span",{className:"up-section-age",title:Ez(e==null?void 0:e.source),children:r})]}),e!=null&&e.ok?i.jsxs("div",{className:"up-quota-bars",children:[e.session5hPct!=null&&i.jsx(xs,{label:"5-hour window",pct:e.session5hPct,reset:e.session5hReset,resetAt:e.session5hResetAt,windowSec:e.session5hWindowSec,nowSec:n}),i.jsx(xs,{label:"7-day window",pct:e.week7dPct??null,reset:e.week7dReset,resetAt:e.week7dResetAt,windowSec:e.week7dWindowSec,nowSec:n}),e.weekSonnetPct!=null&&i.jsx(xs,{label:"Sonnet (7d)",pct:e.weekSonnetPct,nowSec:n}),e.weekOpusPct!=null&&i.jsx(xs,{label:"Opus (7d)",pct:e.weekOpusPct,nowSec:n}),e.extraEnabled&&e.extraUsedCredits!=null&&e.extraMonthlyLimit?i.jsx(xs,{label:`Extra credits (month${e.extraCurrency?`, ${e.extraCurrency}`:""})`,pct:Math.min(100,Math.round(e.extraUsedCredits/e.extraMonthlyLimit*100)),nowSec:n}):e.extraEnabled&&i.jsx("div",{className:"up-quota-sub up-credits",children:"extra usage credits: on"}),e.resetCredits&&e.resetCredits.availableCount>0&&i.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 — ${gt} only reports them`,children:QA("limit reset",e.resetCredits)})]}):(e==null?void 0:e.ok)===!1?i.jsxs("div",{className:"up-quota-na",children:[i.jsx("span",{children:e.reason==="no_subscription"?"No quota to show.":"Quota unavailable."}),i.jsx("span",{className:"up-quota-hint",children:Cz(e.reason)})]}):i.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]})}function Az({codexQuota:e,codexLoading:t,codexUsage:n,nowSec:r}){var o,l;const s=eM(e==null?void 0:e.fetchedAt,r);return i.jsxs("section",{className:"up-section up-quota-section",children:[i.jsxs("h3",{className:"up-section-title",children:["Codex quota",(e==null?void 0:e.ok)&&e.planLabel&&i.jsx("span",{className:"up-plan-badge",children:e.planLabel}),s&&!t&&i.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:s})]}),e!=null&&e.ok?i.jsxs("div",{className:"up-quota-bars",children:[(o=e.windows)==null?void 0:o.map(u=>i.jsx(xs,{label:u.label,pct:u.pct,reset:u.reset??void 0,resetAt:u.resetAt??void 0,windowSec:u.windowSec??void 0,limitReached:e.limitReached&&u.pct>=100,nowSec:r},u.id)),(l=e.extraWindows)==null?void 0:l.map(u=>i.jsx(xs,{label:u.label,pct:u.pct,reset:u.reset??void 0,resetAt:u.resetAt??void 0,windowSec:u.windowSec??void 0,nowSec:r},u.id)),e.creditLimit&&i.jsx(xs,{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&&i.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",e.creditsBalance,e.overageReached&&" · overage limit reached"]}),e.creditsUnlimited&&i.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),e.resetCredits&&e.resetCredits.availableCount>0&&i.jsx("div",{className:"up-quota-sub up-reset-credits",title:`Redeem in the Codex CLI or ChatGPT — ${gt} only reports them`,children:QA("rate-limit reset",e.resetCredits)}),e.promo&&i.jsx("div",{className:"up-quota-sub",children:e.promo}),e.partial&&i.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?i.jsxs("div",{className:"up-quota-na",children:[i.jsx("span",{children:"Quota unavailable."}),i.jsx("span",{className:"up-quota-hint",children:Tz(e.reason)})]}):i.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"}),(n==null?void 0:n.ok)&&n.window7d&&n.window7d.sessionCount>0&&i.jsxs("div",{className:"up-quota-sub",title:`Counted from the rollout files under CODEX_HOME — no network, no account${n.window5h?`
77
- last 5h: ${et(n.window5h.totalTokens)} tokens · ${n.window5h.sessionCount} session${n.window5h.sessionCount!==1?"s":""}`:""}`,children:[et(n.window7d.totalTokens)," tokens · ",n.window7d.sessionCount," session",n.window7d.sessionCount!==1?"s":""," (7d)"]})]})}function Mz({fromRange:e,rangeModelRows:t,boardModelRows:n}){return i.jsxs("section",{className:"up-section",children:[i.jsx("h3",{className:"up-section-title",children:"By model"}),i.jsxs("table",{className:"up-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Model"}),i.jsx("th",{children:"Tokens"}),i.jsx("th",{children:"Cost"})]})}),i.jsx("tbody",{children:e?t.map(r=>i.jsxs("tr",{children:[i.jsx("td",{className:"up-model-name",title:r.model,children:js(r.model)}),i.jsx("td",{className:"up-num",children:et(r.tokens)}),r.cost>0?i.jsx("td",{className:"up-num up-cost-val",children:Be(r.cost)}):i.jsx("td",{className:"up-num up-unpriced",children:Hr})]},r.model)):n.map(r=>i.jsxs("tr",{children:[i.jsx("td",{className:"up-model-name",title:r.model===Zv?"no model reported yet":r.model,children:r.model===Zv?"unknown":js(r.model)}),i.jsx("td",{className:"up-num",children:et(r.inputTokens+r.outputTokens)}),r.priced?i.jsx("td",{className:"up-num up-cost-val",children:Be(r.cost.total)}):i.jsx("td",{className:"up-num up-unpriced",children:Hr})]},r.model))})]})]})}function $z({period:e,rangePending:t,setPeriod:n}){const r=x.useRef([]);return i.jsxs(i.Fragment,{children:[i.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=pz(s.key,o);l!==null&&(s.preventDefault(),(u=r.current[l])==null||u.focus())},children:bd.map((s,o)=>i.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))}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:t?`Reading ${XA(e,e)}…`:""})]})}function Iz({fromRange:e,rangeSessionRows:t,boardSessionRows:n,boardStates:r,sessionsOpen:s,setSessionsOpen:o,periodNoun:l,sessionScale:u}){const d=e?t.length:n.length;return i.jsxs("section",{className:"up-section",children:[i.jsx("h3",{className:"up-section-title",children:i.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(f=>!f),children:["By session",e&&i.jsxs("span",{className:"up-section-age",title:vz(l,u,Be),children:["active ",l]}),i.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:i.jsx("path",{d:"M2.2 3.6 5 6.4 7.8 3.6"})})]})}),i.jsxs("div",{className:"up-sessions",id:"up-sessions",hidden:!s,children:[e&&t.map(f=>{const h=r.get(f.sessionId);return i.jsxs("div",{className:"up-session-row",children:[h?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:`sl-dot state-${h}`,"aria-hidden":!0}),i.jsx("span",{className:"vis-hidden",children:qo(h)})]}):i.jsx("span",{className:"sl-dot up-dot-past","aria-hidden":!0}),i.jsx("span",{className:`up-session-label${f.label?"":" up-session-id"}`,title:f.label?`${f.label}
78
- ${f.sessionId}`:f.sessionId,children:f.label??f.sessionId.slice(0,8)}),i.jsx("span",{className:"up-session-tokens",children:et(f.tokens)}),f.cost>0?i.jsx("span",{className:"up-session-cost",title:f.models.join(", ")||void 0,children:Be(f.cost)}):i.jsx("span",{className:"up-session-cost up-unpriced",children:Hr})]},f.sessionId)}),!e&&n.map(f=>i.jsxs("div",{className:"up-session-row",children:[i.jsx("span",{className:`sl-dot state-${f.state}`,"aria-hidden":!0}),i.jsx("span",{className:"vis-hidden",children:qo(f.state)}),i.jsx("span",{className:"up-session-label",children:f.label}),i.jsx("span",{className:"up-session-tokens",children:et(f.inputTokens+f.outputTokens)}),f.cost>0?i.jsxs("span",{className:"up-session-cost",title:f.unpricedTokens>0?`${et(f.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[Be(f.cost),f.unpricedTokens>0?"+":""]}):i.jsx("span",{className:"up-session-cost up-unpriced",children:Hr})]},f.sessionId))]})]})}function _s(e,t){return{disabled:e!=null&&e!==t,busy:e===t}}function Nd(e){return e==null}const ex="self";function Ss(e,t=!1){const n=_s(e?ex:null,ex);return{disabled:t||n.disabled,"aria-busy":n.busy}}function pr(e){return Nd(e?ex:null)}const Sl=400;function jl({armedFor:e,target:t,armedAt:n,now:r,gapMs:s}){return e!==t?"arm":r-n<s?"ignore":"fire"}function tM(e){return[...e==null?[]:[`#ap-more-${e}`],".accounts-panel .ap-refresh"]}function _l(e){return e==null||e==="BODY"||e==="HTML"}const Oz=6e4,Lz=2e4;function Pz(e){const[t,n]=x.useState(null),[r,s]=x.useState(!1),o=x.useRef(null),l=x.useRef(!1),u=async(f=!1)=>{if(!(f&&!pr(l.current))){f&&(l.current=!0,s(!0));try{const m=await fetch(f?"/api/quota?refresh=1":"/api/quota",{signal:AbortSignal.timeout(Lz)});m.ok&&n(await m.json())}catch{}finally{f&&(l.current=!1,s(!1))}}};return x.useEffect(()=>{if(e)return u(!0),o.current=window.setInterval(()=>u(!1),Oz),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{quota:t,loading:r,refresh:()=>{e&&u(!0)}}}const nM=6e4;function Dz(e){const[t,n]=x.useState(null),[r,s]=x.useState(!1),o=x.useRef(null),l=x.useRef(!1),u=async(f=!1)=>{if(!(f&&!pr(l.current))){f&&(l.current=!0,s(!0));try{const m=await fetch(f?"/api/codex-quota?refresh=1":"/api/codex-quota");m.ok&&n(await m.json())}catch{}finally{f&&(l.current=!1,s(!1))}}};return x.useEffect(()=>{if(e)return u(!0),o.current=window.setInterval(()=>u(!1),nM),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{data:t,loading:r,refresh:()=>{e&&u(!0)}}}function Fz(e){const[t,n]=x.useState(null),r=x.useRef(null),s=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return x.useEffect(()=>{if(e)return s(),r.current=window.setInterval(s,nM),()=>{r.current!=null&&window.clearInterval(r.current)}},[e]),{data:t}}const XN=6e4;function qz(e,t,n){const[r,s]=x.useState(null),[o,l]=x.useState(!1),[u,d]=x.useState(0),f=x.useRef(0);x.useEffect(()=>{const m=()=>document.visibilityState==="visible",g=()=>{m()&&d(v=>v+1)},w=window.setInterval(g,XN),k=()=>{m()&&Date.now()-f.current>=XN&&d(v=>v+1)};return document.addEventListener("visibilitychange",k),()=>{window.clearInterval(w),document.removeEventListener("visibilitychange",k)}},[]);const h=x.useRef(t);return x.useEffect(()=>{let m=!0;const g=t!==h.current;h.current=t;const w=e,k=KA(w);return l(!0),fetch(`/api/ccusage?since=${k}${g?"&refresh=1":""}`).then(v=>v.ok?v.json():null).then(v=>{!m||!(v!=null&&v.ok)||(f.current=Date.now(),s({period:w,data:v,baseline:n()}))}).catch(()=>{}).finally(()=>{m&&l(!1)}),()=>{m=!1}},[e,t,u]),{...xz(r,e),loading:o}}const Bz=e=>1-Math.pow(1-e,5),rM=420;function zz(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 Uz(e,t,n,r=rM){return n>=r?t:n<=0?e:e+(t-e)*Bz(n/r)}function Hz(e,t,n,r={}){const s=r.now??(()=>performance.now()),o=r.raf??(w=>requestAnimationFrame(w)),l=r.cancel??(w=>cancelAnimationFrame(w)),u=r.reducedMotion??(()=>typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches),d=r.hidden??(()=>typeof document=="object"&&document.hidden===!0);if(u()||d()||!zz(e,t))return n(t),()=>{};const f=s();let h=0,m=!0;const g=()=>{if(!m)return;const w=s()-f;n(Uz(e,t,w)),w<rM&&(h=o(g))};return h=o(g),()=>{m=!1,h&&l(h)}}function Zi(e){const[t,n]=x.useState(e),r=x.useRef(e),s=x.useRef(!0);return x.useEffect(()=>{r.current=t},[t]),x.useEffect(()=>{if(s.current){s.current=!1,r.current=e,n(e);return}return Hz(r.current,e,l=>{r.current=l,n(l)})},[e]),t}function sM(e,t,n){const r=Vz*Math.max(1,n/oM);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 ZN={samples:[],last:new Map,watched:0},aM=10*6e4,Wz=6e4,oM=5e3,Vz=20;function Gz(e,t,n){const r=e.samples[e.samples.length-1];if(r&&t-r.t<oM)return e;const s=e.watched+sM(e.last,n,r?t-r.t:0),o=e.samples.filter(l=>t-l.t<=aM);return o.push({t,watched:s}),{samples:o,last:n,watched:s}}function Kz(e,t,n){const r=e.samples[0];if(!r)return null;const s=t-r.t;if(s<Wz)return null;const o=e.samples[e.samples.length-1].t,l=e.watched+sM(e.last,n,t-o)-r.watched;return l>0?{spent:l,spanSec:s/1e3,spanMin:Math.min(aM/6e4,Math.ceil(s/6e4))}:null}function Yz(e,t,n){const r=x.useRef(ZN),s=x.useRef(null);return x.useMemo(()=>{const o=lz(e.agents.values()),l=sz(e.agents.values());s.current!==n&&(s.current=n,r.current=ZN);const u=Qv(e.agents.values(),t);n!=null&&(r.current=Gz(r.current,t,u));const d=n==null?null:Kz(r.current,t,u),f=d?{label:Xx(d.spent,d.spanSec),spanMin:d.spanMin}:null;return{byModel:o,totalCost:l.cost,totalTokens:l,burnRate:f}},[e,e.revision,t,n])}const Xz=3e4;function iM(){const[e,t]=x.useState(()=>Math.floor(Date.now()/1e3));return x.useEffect(()=>{const n=window.setInterval(()=>t(Math.floor(Date.now()/1e3)),Xz);return()=>window.clearInterval(n)},[]),e}function JN(e){return(typeof e.cost=="number"?e.cost:e.cost.total)>0||e.inputTokens+e.outputTokens>0}function Zz(e,t,n){return e?t.some(r=>r.cost<=0&&r.tokens>0):n.some(r=>!r.priced)}function Jz(e){return e.claude&&e.codex?"Refresh Claude + Codex quota":e.codex?"Refresh Codex quota":"Refresh Claude quota"}function Qz(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 eU(e){const t=new Map;for(const n of e)n.kind!=="root"||!n.sessionId||t.set(n.sessionId,n.state);return t}function tU(e){const t=new Map;for(const n of e)n.label&&t.set(n.label,(t.get(n.label)??0)+1);return e.map(n=>n.label&&(t.get(n.label)??0)>1?{...n,label:`${n.label} ${n.sessionId.slice(0,4)}`}:n)}function nU({state:e,now:t,providers:n,leaving:r,onClose:s,liveSince:o=null}){const{quota:l,loading:u,refresh:d}=Pz(n.claude),{data:f,loading:h,refresh:m}=Dz(n.codex),{data:g}=Fz(n.codex),w=iM(),{byModel:k,totalCost:v,totalTokens:b,burnRate:S}=Yz(e,t,o),_=x.useMemo(()=>cz(e.agents.values()),[e,e.revision]),[j,E]=x.useState(kz);x.useEffect(()=>{Nz(j)},[j]);const[T,R]=x.useState(Sz);x.useEffect(()=>{jz(T)},[T]);const[M,O]=x.useState(0),I=x.useRef(()=>new Map);I.current=()=>o==null?null:Qv(e.agents.values(),t);const A=x.useCallback(()=>I.current(),[]),{data:L,shown:z,stale:V,loading:$,baseline:P}=qz(j,M,A),F=L!=null,Y=$&&V,K=x.useMemo(()=>Qz(e.agents.values()),[e,e.revision]),D=x.useMemo(()=>eU(e.agents.values()),[e,e.revision]),W=x.useMemo(()=>F?YA(L):[],[L,F]),B=x.useMemo(()=>F?tU(yz(L,K).slice(0,12)):[],[L,F,K]),X=x.useMemo(()=>kd(L),[L]),G=x.useMemo(()=>wz(L,X.cost),[L,X.cost]),U=XA(z,j),Z=x.useMemo(()=>F?fz(P,Qv(e.agents.values(),t)):Jv,[e,e.revision,P,F,t]),H=bz(L,{...b,cost:v},Z),J=H.hasCost,ee=H.tokenSum,re=Zi(H.cost),oe=Zi(H.inputTokens),fe=Zi(H.outputTokens),Ne=Zi(H.cacheReadTokens),ke=Zi(H.cacheCreateTokens),we=k.filter(JN),ve=_.filter(JN),$e=Zz(F,W,we),ye=u||h,ue=()=>{d(),m(),O(xe=>xe+1)},se=Jz(n);return i.jsxs("aside",{className:`usage-panel${r?" leaving":""}`,id:"usage-panel","aria-label":"Usage",children:[i.jsxs("div",{className:"up-header",children:[i.jsx("h2",{children:"Usage"}),S&&i.jsxs("span",{className:"up-rate",title:`Spend on this board over the last ${S.spanMin} min`,children:[S.label,i.jsxs("span",{className:"up-rate-span",children:[" · ",S.spanMin," min"]})]}),i.jsxs("div",{className:"up-header-right",children:[(n.claude||n.codex)&&i.jsx("button",{type:"button",className:"glyph-btn up-refresh-btn",onClick:ue,...Ss(ye),"aria-label":se,title:se,children:ye?"…":"↻"}),i.jsx("button",{type:"button",className:"glyph-btn up-close",onClick:s,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),n.claude&&i.jsx(Rz,{quota:l,quotaLoading:u,nowSec:w}),n.codex&&i.jsx(Az,{codexQuota:f,codexLoading:h,codexUsage:g,nowSec:w}),F&&i.jsx($z,{period:j,rangePending:Y,setPeriod:E}),ee>0?i.jsxs(i.Fragment,{children:[J&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"up-total",title:F?void 0:VN,children:[i.jsx("span",{className:"up-total-value",children:Be(re)}),i.jsx("span",{className:"up-total-label",children:F?U:az})]}),H.showCostBar&&i.jsx(a0,{cost:v})]}),i.jsxs("div",{className:"up-tokens-row",title:F?void 0:VN,children:[i.jsxs("span",{className:"up-tok",children:[i.jsx("span",{className:"up-k",children:"in"}),et(oe)]}),i.jsxs("span",{className:"up-tok",children:[i.jsx("span",{className:"up-k",children:"out"}),et(fe)]}),H.cacheReadTokens>0&&i.jsxs("span",{className:"up-tok",children:[i.jsx("span",{className:"up-k",children:"cache r"}),et(Ne)]}),H.cacheCreateTokens>0&&i.jsxs("span",{className:"up-tok",children:[i.jsx("span",{className:"up-k",children:"cache c"}),et(ke)]}),!J&&i.jsx("span",{className:"up-tok up-scope",children:oz})]}),(F?W.length:we.length)>0&&i.jsx(Mz,{fromRange:F,rangeModelRows:W,boardModelRows:we}),F&&B.length===0&&X.tokens>0&&i.jsxs("section",{className:"up-section",children:[i.jsx("h3",{className:"up-section-title",children:"By session"}),i.jsxs("div",{className:"up-hint",children:["No session is dated ",U," yet — ccusage dates sessions in UTC, and the totals above are your local day."]})]}),(F?B.length:ve.length)>0&&i.jsx(Iz,{fromRange:F,rangeSessionRows:B,boardSessionRows:ve,boardStates:D,sessionsOpen:T,setSessionsOpen:R,periodNoun:U,sessionScale:G}),$e&&i.jsxs("div",{className:"up-hint",children:["“",Hr,"” means this build holds no published rate for that model — those tokens are counted above and their dollars are not."]})]}):i.jsx("div",{className:"up-empty",children:F?i.jsxs(i.Fragment,{children:["No usage ",U,".",i.jsx("br",{}),"Try a longer period."]}):i.jsxs(i.Fragment,{children:["No usage data yet.",i.jsx("br",{}),"Start a Claude Code or Codex session."]})})]})}function rU(e,t,n){return e>=n?"hot":e>=t?"warn":"calm"}function sU(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}% ${aU(t.lastMs,n)}`:"running at full speed, and never held back"}}function aU(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 oU(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 iU(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 lU(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 cU=3e3;function uU(){const[e,t]=x.useState(null),n=x.useRef(null);return x.useEffect(()=>{let r=!0;const s=async()=>{if(document.visibilityState!=="hidden")try{const d=await fetch("/api/system");if(!d.ok)return;const f=await d.json();r&&(f!=null&&f.ok)&&t(f)}catch{}},o=()=>{n.current==null&&(s(),n.current=window.setInterval(s,cU))},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 Zf(e){return e<9.95?e.toFixed(1):String(Math.round(e))}function o0(e){const t=Number.isFinite(e)?Math.max(0,e):0;return t<50?{value:"0",unit:"KB/s"}:t<999500?{value:Zf(t/1e3),unit:"KB/s"}:t<9995e5?{value:Zf(t/1e6),unit:"MB/s"}:{value:Zf(t/1e9),unit:"GB/s"}}function Sd(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 El(e){return e.unit?e.unit==="%"||e.unit==="°C"?`${e.value}${e.unit}`:`${e.value} ${e.unit}`:e.value}function Jf(e,t){return t==="B/s"?o0(e):t==="ms"?Sd(e):{value:String(e),unit:t==="C"?"°C":t}}const Nt={l:30,r:6,t:6,b:2},gs={l:0,r:0,t:2,b:1},jd=104,dU=64;function zn(e,t=100,n=jd,r=Nt){const s=n-r.t-r.b;return r.t+s*(1-Math.max(0,Math.min(t,e))/t)}function lM(e,t,n,r=100,s=jd,o=Nt){if(!e.length)return"";const l=e[e.length-1].t-e[0].t,u=h=>{const m=t-o.l-o.r;return o.l+(l>0?m*(h-e[0].t)/l:m/2)};let d="",f=null;for(const h of e){const m=f&&h.t-f.t<=n*2?"L":"M";d+=`${m}${u(h.t).toFixed(1)} ${zn(h.v,r,s,o).toFixed(1)}`,f=h}return d}function cM(e,t,n,r=100,s=jd,o=Nt){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,f=w=>o.l+(u>0?d*(w-e[0].t)/u:d/2);let h="",m=[];const g=()=>{if(m.length>=2){let w=`M${f(m[0].t).toFixed(1)} ${l}`;for(const k of m)w+=`L${f(k.t).toFixed(1)} ${zn(k.v,r,s,o).toFixed(1)}`;h+=`${w}L${f(m[m.length-1].t).toFixed(1)} ${l}Z`}m=[]};for(const w of e)m.length&&w.t-m[m.length-1].t>n*2&&g(),m.push(w);return g(),h}function hU(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 uM(e,t,n){return n!=null&&e>=n?"hot":t!=null&&e>=t?"warn":""}function fU(e,t,n=r=>ua(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 ua(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function i0(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 pU({group:e,title:t,onClose:n}){const r=Et(n),[s,o]=x.useState(null);x.useEffect(()=>{let f=!0;const h=async()=>{try{const g=await fetch(`/api/system/history?group=${e}`);if(!g.ok)return;const w=await g.json();f&&(w!=null&&w.ok)&&o(w)}catch{}};h();const m=window.setInterval(h,2e4);return()=>{f=!1,window.clearInterval(m)}},[e]);const l=(s==null?void 0:s.series)??[],[u,d]=x.useMemo(()=>{let f=1/0,h=0;for(const m of l)m.points.length&&(f=Math.min(f,m.points[0].t),h=Math.max(h,m.points[m.points.length-1].t));return[Number.isFinite(f)?Math.max(f,(s==null?void 0:s.sinceMs)??0):(s==null?void 0:s.sinceMs)??0,h]},[l,s==null?void 0:s.sinceMs]);return zt.createPortal(i.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:i.jsxs("div",{ref:r,className:"modal hist-modal",onClick:f=>f.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"hist-modal-title",children:[i.jsxs("div",{className:"modal-head",children:[i.jsx("span",{className:"modal-title",id:"hist-modal-title",children:t}),s&&u>0&&i.jsxs("span",{className:"hist-since",children:["since ",ua(u)," · ",i0(u,d||Date.now())]}),i.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),i.jsx("div",{className:"hist-body",children:s==null?i.jsx("p",{className:"hist-empty",children:"Reading…"}):l.length===0?i.jsx("p",{className:"hist-empty",children:"Nothing has been measured yet."}):l.map(f=>i.jsx(mU,{series:f,stepMs:s.stepMs},f.label))})]})}),document.body)}function mU({series:e,stepMs:t}){const n=x.useRef(null),[r,s]=x.useState(560),[o,l]=x.useState(null);x.useEffect(()=>{const I=n.current;if(!I||typeof ResizeObserver>"u")return;const A=new ResizeObserver(([L])=>s(Math.max(160,L.contentRect.width)));return A.observe(I),()=>A.disconnect()},[]);const{points:u,unit:d,warnAt:f,critAt:h,label:m,top:g,restsAtZero:w,changes:k}=e,v=w?dU:jd,{now:b,peak:S}=hU(u),_=b!=null?Jf(b,d):null,j=S!=null?Jf(S,d):null,E=m==="Throttling"?fU(u,t):null,T=o!=null?u[o]:null,R=u.length>1?u[u.length-1].t-u[0].t:0,M=I=>{const A=r-Nt.l-Nt.r;return Nt.l+(R>0?A*(I-u[0].t)/R:A/2)},O=I=>{if(u.length<2)return;const A=I.currentTarget.getBoundingClientRect(),L=(I.clientX-A.left-Nt.l)/Math.max(1,A.width-Nt.l-Nt.r),z=u[0].t+R*Math.max(0,Math.min(1,L));let V=0;for(let $=1;$<u.length;$++)Math.abs(u[$].t-z)<Math.abs(u[V].t-z)&&(V=$);l(V)};return i.jsxs("section",{className:"hist-series","aria-label":`${m} history`,children:[i.jsxs("div",{className:"hist-head",children:[i.jsx("span",{className:"hist-label",children:m}),i.jsxs("span",{className:"hist-stats",children:[_&&i.jsxs(i.Fragment,{children:[i.jsx("b",{children:_.value}),i.jsxs("span",{children:[_.unit," now"]})]}),S!=null&&j&&i.jsxs(i.Fragment,{children:[i.jsx("b",{className:uM(S,f,h),children:j.value}),i.jsxs("span",{children:[j.unit," peak"]})]})]})]}),i.jsx("div",{className:"hist-plot",ref:n,children:i.jsxs("svg",{className:"hist-chart",width:"100%",height:v,viewBox:`0 0 ${r} ${v}`,preserveAspectRatio:"none",role:"img","aria-label":_==null||j==null?`${m}: nothing measured yet`:`${m}: ${El(_)} now, peak ${El(j)}, over ${i0(u[0].t,u[u.length-1].t)}`,onPointerMove:O,onPointerLeave:()=>l(null),children:[[["warn",f],["hot",h]].map(([I,A])=>A==null||A>g?null:i.jsxs("g",{children:[i.jsx("line",{className:`hist-rule ${I}`,x1:Nt.l,x2:r-Nt.r,y1:zn(A,g,v),y2:zn(A,g,v)}),i.jsx("text",{className:`hist-rule-tag ${I}`,x:2,y:zn(A,g,v)+3,children:A})]},I)),i.jsx("line",{className:"hist-floor",x1:Nt.l,x2:r-Nt.r,y1:v-Nt.b,y2:v-Nt.b}),(k??[]).filter(I=>I.from!=null&&u.length>1&&I.t>=u[0].t&&I.t<=u[u.length-1].t).map(I=>i.jsx("line",{className:"hist-mark",x1:M(I.t),x2:M(I.t),y1:Nt.t,y2:v-Nt.b},I.t)),i.jsx("path",{className:"hist-area",d:cM(u,r,t,g,v)}),i.jsx("path",{className:"hist-line",d:lM(u,r,t,g,v)}),u.length===1&&i.jsx("circle",{className:"hist-dot",cx:M(u[0].t),cy:zn(u[0].v,g,v),r:3}),T&&i.jsxs("g",{children:[i.jsx("line",{className:"hist-cross",x1:M(T.t),x2:M(T.t),y1:Nt.t,y2:v-Nt.b}),i.jsx("circle",{className:"hist-dot",cx:M(T.t),cy:zn(T.v,g,v),r:3})]})]})}),i.jsx("div",{className:"hist-axis",children:T?i.jsxs("span",{className:"hist-at",children:[ua(T.t)," — ",(()=>{const I=Jf(T.v,d);return i.jsxs(i.Fragment,{children:[i.jsx("b",{children:I.value}),I.unit==="%"||I.unit==="°C"||!I.unit?I.unit:` ${I.unit}`]})})()]}):i.jsxs(i.Fragment,{children:[i.jsx("span",{children:u.length?ua(u[0].t):""}),i.jsx("span",{children:u.length?ua(u[u.length-1].t):""})]})}),E&&i.jsx("div",{className:"hist-note",children:E}),k==null?void 0:k.slice(-3).map(I=>i.jsx("div",{className:"hist-note hist-route",children:I.from==null?`Since ${ua(I.t)} — ${I.label}`:`${ua(I.t)} — ${I.label.charAt(0).toUpperCase()+I.label.slice(1)}`},I.t))]})}const gU="thermal:Throttling";function yU(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[gU]=Math.max(0,100-e.thermal.throttle.speedLimit)),t}function cl(e,t){return t==="B/s"?El(o0(e)):t==="ms"?El(Sd(e)):t==="C"?`${Math.round(e)}°`:t==="%"?`${Math.round(e)}%`:e.toFixed(2)}function lu(e,t){return t==="B/s"||t==="ms"||!Number.isInteger(e)?cl(e,t):t==="C"?`${e}°`:t==="%"?`${e}%`:`${e}`}const QN=["cores","memory","load","thermal"],ia=116,hr=24,wU=60,vU=6e4;function xU(e){return e.points.length?e.restsAtZero?e.points.some(t=>t.v>0):!0:!1}function bU(e){return e.unit==="C"?`${e.label} temp`:e.key==="mem:physical"?"Physical RAM":e.key==="mem:swap"?`${e.label} memory`:e.label}function kU(e,t=wU){return e.points.length<=t?e:{...e,points:e.points.slice(-t)}}function NU({sys:e}){const[t,n]=x.useState({});x.useEffect(()=>{let l=!0;const u=async()=>{const f=await Promise.all(QN.map(async h=>{try{const m=await fetch(`/api/system/history?group=${h}`);return m.ok?[h,await m.json()]:[h,null]}catch{return[h,null]}}));l&&n(h=>{const m={...h};for(const[g,w]of f)w!=null&&w.ok&&(m[g]=w);return m})};u();const d=setInterval(()=>void u(),vU);return()=>{l=!1,clearInterval(d)}},[]);const r=x.useMemo(()=>yU(e),[e]),s=x.useMemo(()=>QN.flatMap(l=>{const u=t[l];return u?u.series.filter(xU).map(d=>({series:kU(d),stepMs:u.stepMs})):[]}),[t]),o=x.useMemo(()=>{let l=1/0,u=-1/0;for(const{series:d}of s){const f=d.points;f.length&&(l=Math.min(l,f[0].t),u=Math.max(u,f[f.length-1].t))}return Number.isFinite(l)?i0(l,u):"less than a minute"},[s]);return Object.keys(r).length?i.jsx("div",{className:"pl-strip",role:"group","aria-label":`This machine, over the last ${o}`,children:s.map(({series:l,stepMs:u})=>i.jsx(SU,{series:l,stepMs:u,now:r[l.key],span:o},l.key))}):null}function SU({series:e,stepMs:t,now:n,span:r}){var w;const{points:s,top:o,unit:l,warnAt:u,critAt:d}=e,f=bU(e),h=n??((w=s[s.length-1])==null?void 0:w.v),m=h==null?"":uM(h,u,d),g=Math.max(...s.map(k=>k.v));return i.jsxs("div",{className:`pl-cell${m?` ${m}`:""}`,title:[`${f} · peak ${cl(g,l)} over the last ${r}`,u!=null?`over ${lu(u,l)} is uncomfortable`:"",d!=null?`over ${lu(d,l)} the machine acts`:""].filter(Boolean).join(" · "),children:[i.jsxs("div",{className:"pl-cell-head",children:[i.jsx("span",{className:"pl-cell-label",children:f}),i.jsx("span",{className:"pl-cell-now",children:h==null?"—":cl(h,l)})]}),i.jsxs("svg",{className:"pl-spark",width:ia,height:hr,viewBox:`0 0 ${ia} ${hr}`,preserveAspectRatio:"none","aria-hidden":!0,children:[i.jsx("line",{className:"pl-spark-floor",x1:0,x2:ia,y1:hr-gs.b,y2:hr-gs.b}),i.jsx("path",{className:"pl-spark-area",d:cM(s,ia,t,o,hr,gs)}),u!=null&&i.jsx("line",{className:"pl-rule warn",x1:0,x2:ia,y1:zn(u,o,hr,gs),y2:zn(u,o,hr,gs)}),d!=null&&i.jsx("line",{className:"pl-rule hot",x1:0,x2:ia,y1:zn(d,o,hr,gs),y2:zn(d,o,hr,gs)}),i.jsx("path",{className:"pl-spark-line",d:lM(s,ia,t,o,hr,gs)})]}),i.jsxs("span",{className:"vis-hidden",children:["peak ",cl(g,l)," over the last ",r,u!=null&&`, uncomfortable over ${lu(u,l)}`,d!=null&&`, the machine acts over ${lu(d,l)}`]})]})}const jU={key:"cpu",dir:"desc"};function _U(e,t){return e.key===t?{...e,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:t==="name"||t==="user"?"asc":"desc"}}function EU(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 f=o.user??"",h=l.user??"";return!f||!h?f===h?0:f?-1:1:n*f.localeCompare(h,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)}function CU(e,t){return e.key!==t?"none":e.dir==="asc"?"ascending":"descending"}const TU=4e3;function RU(){const[e,t]=x.useState(null);return x.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&&(l!=null&&l.ok)&&t({procs:l.procs??[],total:l.total??0})}catch{}};r();const s=window.setInterval(r,TU);return()=>{n=!1,window.clearInterval(s)}},[]),e}function AU(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 MU({sys:e,onClose:t}){const n=Et(t),[r,s]=x.useState(jU),o=RU(),l=o?EU(o.procs,r):null;return zt.createPortal(i.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:i.jsxs("div",{ref:n,className:"modal pl-modal",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"pl-modal-title",children:[i.jsxs("div",{className:"modal-head",children:[i.jsx("span",{className:"modal-title",id:"pl-modal-title",children:"Busiest processes"}),o&&i.jsxs("span",{className:"pl-count",children:[l.length," of ",o.total," running"]}),i.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),i.jsxs("div",{className:"pl-split",children:[i.jsx("div",{className:"pl-body",children:l==null?i.jsx("p",{className:"pl-empty",children:"Reading the process list…"}):l.length===0?i.jsx("p",{className:"pl-empty",children:"Could not read the process list on this platform."}):i.jsxs("table",{className:"sd-procs pl-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx(wo,{col:"cpu",label:"cpu",sort:r,onSort:s}),i.jsx(wo,{col:"rss",label:"memory",note:"Resident set size, which is what ps and Task Manager report; macOS Activity Monitor shows a different figure.",sort:r,onSort:s}),i.jsx(wo,{col:"threads",label:"threads",sort:r,onSort:s}),i.jsx(wo,{col:"uptime",label:"up",sort:r,onSort:s}),i.jsx(wo,{col:"user",label:"user",sort:r,onSort:s}),i.jsx("th",{scope:"col",className:"pl-pid-h",children:"pid"}),i.jsx(wo,{col:"name",label:"process",note:"Command lines have anything secret-shaped removed, which is a filter and not a guarantee.",sort:r,onSort:s})]})}),i.jsx("tbody",{children:l.map(u=>i.jsxs("tr",{children:[i.jsx("td",{className:"sd-num",children:u.cpu==null?"—":u.cpu.toFixed(0)}),i.jsx("td",{className:"sd-num sd-dim",title:`${u.mem.toFixed(1)}% of installed memory`,children:ca(u.rssBytes)}),i.jsx("td",{className:"sd-num sd-dim",children:u.threads??"—"}),i.jsx("td",{className:"sd-num sd-dim",children:AU(u.uptimeSec)}),i.jsx("td",{className:"sd-dim pl-user",children:u.user??"—"}),i.jsx("td",{className:"sd-num sd-dim pl-pid",children:u.pid}),i.jsxs("td",{className:"pl-name",children:[u.name,u.cmd&&i.jsxs("span",{className:"pl-cmd",title:u.cmd,children:[" ",u.cmd]})]})]},u.pid))})]})}),i.jsx(NU,{sys:e})]})]})}),document.body)}function wo({col:e,label:t,note:n,sort:r,onSort:s}){const o=CU(r,e);return i.jsx("th",{scope:"col","aria-sort":o,children:i.jsxs("button",{type:"button",className:"sd-sort",title:n?`Sort by ${t}
79
-
80
- ${n}`:`Sort by ${t}`,onClick:()=>s(_U(r,e)),children:[t,i.jsx("span",{className:"sd-sort-dir","aria-hidden":!0,children:o==="none"?"":o==="ascending"?"↑":"↓"})]})})}function tx({value:e,unit:t,cap:n}){return t?i.jsxs("span",{className:"sd-fig",children:[i.jsx("span",{className:"sd-fig-cap",children:n}),i.jsxs("span",{className:"sd-fig-read",children:[i.jsx("b",{children:e})," ",i.jsx("span",{className:"sd-fig-unit",children:t})]})]}):i.jsxs("span",{className:"sd-fig",children:[i.jsx("b",{children:e}),i.jsx("span",{className:"sd-fig-cap",children:n})]})}function Cl({group:e,title:t,action:n,label:r,value:s,hint:o,children:l}){const[u,d]=x.useState(!1);return i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:"sd-open",onClick:()=>d(!0),title:n,"aria-label":s==null?n:`${n}, now ${s}`,"aria-describedby":o?`sd-hint-${e}`:void 0,children:[i.jsxs("div",{className:"sd-h","aria-hidden":!0,children:[r," ",i.jsx("i",{className:"sd-row-more",children:"›"}),s!=null&&i.jsx("span",{className:"sd-h-val",children:s})]}),l]}),o&&i.jsx("span",{id:`sd-hint-${e}`,className:"vis-hidden",children:o}),u&&i.jsx(pU,{group:e,title:t,onClose:()=>d(!1)})]})}function Ku({label:e,value:t,pct:n,tone:r="calm",note:s,mark:o,title:l,trackLabel:u}){return i.jsxs("div",{className:"sd-row",title:l,children:[i.jsxs("div",{className:"sd-row-head",children:[i.jsx("span",{className:"sd-row-label",children:e}),i.jsx("span",{className:"sd-row-val",children:t})]}),i.jsxs("span",{className:"sd-track",role:u?"img":void 0,"aria-label":u,children:[i.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&&i.jsx("span",{className:"sd-mark",style:{left:`${o}%`},"aria-hidden":!0})]}),s&&i.jsx("div",{className:"sd-note",children:s})]})}function $U(e,t,n){if(n<=0||gd(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 ks=4,qn=8;function l0(e,t,n){const r=n.width-qn-(e.right+ks),s=e.left-ks-qn,o=t.width<=r||r>=s?"right":"left",l=o==="right"?e.right+ks:e.left-ks-t.width,u=n.height-qn*2,d=t.height<=u,f=d?t.height:Math.max(0,u);return{top:Math.max(qn,Math.min(e.top,n.height-qn-f)),left:Math.max(qn,l),side:o,maxHeight:d?null:f}}function IU(e,t,n){const r=n.height-qn-(e.bottom+ks),s=e.top-ks-qn,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),f=o==="below"?e.bottom+ks:e.top-ks-d,h=Math.max(qn,Math.min(e.right-t.width,n.width-qn-t.width));return{top:Math.max(qn,f),left:h,side:o,maxHeight:u?null:d}}function OU(e,t,n){return!(!e||t!=null&&t.contains(e)||n!=null&&n.contains(e))}function dM(e,t,n){const r=x.useRef(t);r.current=t;const s=x.useRef(n);s.current=n,x.useEffect(()=>{const o=l=>{OU(l.target,e.current,r.current())&&s.current()};return window.addEventListener("pointerdown",o,!0),()=>window.removeEventListener("pointerdown",o,!0)},[e])}const hM='[role="menuitem"]';function eS(e){return e?Array.from(e.querySelectorAll(hM)).filter(t=>!t.disabled):[]}function c0({anchorId:e,boundaryId:t,id:n,className:r,role:s,labelledBy:o,start:l="first",onClose:u,children:d}){const f=x.useRef(u);f.current=u;const h=Et(()=>{var v;(v=document.getElementById(e))==null||v.focus(),f.current()},{popover:!0}),m=x.useCallback(()=>{var E;const v=h.current;if(!v)return;const b=document.getElementById(e);if(!b){f.current();return}const S=b.getBoundingClientRect(),_=t?(E=document.getElementById(t))==null?void 0:E.getBoundingClientRect():null;if(_&&(S.bottom<=_.top||S.top>=_.bottom)){v.contains(document.activeElement)&&b.focus({preventScroll:!0}),f.current();return}v.style.maxHeight="";const j=IU(S,{width:v.offsetWidth,height:v.offsetHeight},{width:window.innerWidth,height:window.innerHeight});v.style.top=`${j.top}px`,v.style.left=`${j.left}px`,v.style.maxHeight=j.maxHeight==null?"":`${j.maxHeight}px`,v.dataset.side=j.side},[e,t,h]);x.useLayoutEffect(()=>{m()}),x.useEffect(()=>{const v=b=>{var S;(S=h.current)!=null&&S.contains(b.target)||m()};return window.addEventListener("scroll",v,!0),window.addEventListener("resize",m),()=>{window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",m)}},[m,h]),dM(h,()=>document.getElementById(e),u),x.useEffect(()=>{var b;if(s!=="menu")return;const v=eS(h.current);(b=l==="last"?v[v.length-1]:v[0])==null||b.focus()},[]);const g=v=>{var b;if(s==="menu"&&v.key==="Tab"){v.stopPropagation(),(b=document.getElementById(e))==null||b.focus(),v.shiftKey&&v.preventDefault(),f.current();return}if(s==="menu"){const S=eS(h.current),_=$U(v,S.indexOf(document.activeElement),S.length);_.kind==="focus"&&(v.preventDefault(),S[_.index].focus())}v.key.length===1&&v.stopPropagation()},w=v=>{v.target.closest("button, input, select, textarea, code")||v.preventDefault()},k=v=>{if(s!=="menu"||v.pointerType==="touch")return;const b=v.target.closest(hM);b&&!b.disabled&&document.activeElement!==b&&b.focus({preventScroll:!0})};return zt.createPortal(i.jsx("div",{ref:h,id:n,className:`anchored-popover${r?` ${r}`:""}`,role:s,"aria-labelledby":o,onKeyDown:g,onMouseDown:w,onPointerMove:k,children:d}),document.body)}function LU({network:e}){const{down:t,up:n,api:r,route:s}=e,[o,l]=x.useState(!1),u=r&&r.ms!=null?Sd(r.ms):null,d=t!=null&&n!=null;return i.jsxs("div",{className:"sd-section",role:"group","aria-label":"Network",children:[i.jsxs(Cl,{group:"network",title:"Network history",action:"Show network history",label:"Network",children:[(d||u)&&i.jsxs("div",{className:"sd-figs sd-figs-named",children:[d&&[["Download",t],["Upload",n]].map(([f,h])=>{const m=o0(h);return i.jsx(tx,{value:m.value,unit:m.unit,cap:f},f)}),u&&i.jsx(tx,{value:u.value,unit:u.unit,cap:"Claude API"})]}),!d&&i.jsx("div",{className:"sd-note",children:"measuring…"}),r&&r.ms==null&&i.jsx("div",{className:"sd-note sd-note-warn",children:"Can’t reach Claude"})]}),s&&i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:"sd-detail",id:"sd-conn","aria-expanded":o,"aria-haspopup":"dialog",onClick:()=>l(f=>!f),children:["Connection details",s.relay&&i.jsx("span",{className:"sd-route-relay",children:" · relayed"}),i.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),o&&i.jsx(PU,{route:s,api:r,onClose:()=>l(!1)})]})]})}function PU({route:e,api:t,onClose:n}){return i.jsxs(c0,{anchorId:"sd-conn",boundaryId:"system-panel",id:"sd-conn-pop",className:"sd-pop",role:"dialog",labelledBy:"sd-conn-title",onClose:n,children:[i.jsx("p",{className:"sd-pop-title",id:"sd-conn-title",children:"Connection"}),i.jsxs("dl",{className:"sd-pop-rows",children:[i.jsxs("div",{className:"sd-pop-row",children:[i.jsx("dt",{children:e.to==="claude"?"Traffic to Claude":"Internet traffic"}),i.jsxs("dd",{children:["through ",lU(e)]})]}),e.relay&&i.jsxs("div",{className:"sd-pop-row",children:[i.jsx("dt",{children:"Relay"}),i.jsxs("dd",{children:[i.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&&i.jsxs("div",{className:"sd-pop-row",children:[i.jsx("dt",{children:"Round trip"}),i.jsx("dd",{children:t.ms==null?`${t.host} did not answer`:`${El(Sd(t.ms))} to open a connection to ${t.host}`})]}),i.jsxs("div",{className:"sd-pop-row",children:[i.jsx("dt",{children:"Throughput"}),i.jsx("dd",{children:"every interface on this machine, not this path alone"})]})]})]})}function tS({usageOpen:e,leaving:t,sub:n,flag:r,onClose:s,children:o}){return i.jsxs("aside",{className:`sysdetail${e?" shifted":""}${t?" leaving":""}`,id:"system-panel","aria-labelledby":"sd-title",children:[i.jsxs("div",{className:"sd-top",children:[i.jsxs("div",{className:"sd-head",children:[i.jsx("h2",{className:"sd-title",id:"sd-title",children:"This machine"}),n&&i.jsx("span",{className:"sd-sub",children:n}),i.jsx("button",{type:"button",className:"glyph-btn sd-close",onClick:s,"aria-label":"Close",title:"Close",children:"×"})]}),r&&i.jsx("p",{className:"sd-flag",children:r})]}),o]})}function DU({usageOpen:e,leaving:t,onClose:n}){const r=uU();if(!r||r.cpu==null||!r.memory)return i.jsx(tS,{usageOpen:e,leaving:t,onClose:n,children:i.jsx("div",{className:"sd-note",children:"reading this machine…"})});const{memory:s,swap:o,perCore:l,loadavg:u,cores:d,uptimeSec:f,platform:h,thermal:m,network:g,cpu:w}=r;return i.jsxs(tS,{usageOpen:e,leaving:t,sub:`up ${oU(f)} · ${d} cores`,flag:iU(r),onClose:n,children:[i.jsx(FU,{cpu:w,perCore:l,loadavg:u,cores:d}),i.jsx(qU,{memory:s,swap:o,platform:h}),g&&i.jsx(LU,{network:g}),i.jsx(BU,{thermal:m}),i.jsx(zU,{sys:r})]})}function FU({cpu:e,perCore:t,loadavg:n,cores:r}){const s=!!t&&t.length>0;return!s&&!n?null:i.jsxs("div",{className:"sd-section sd-cpu",role:"group","aria-label":"CPU",children:[s&&i.jsx(Cl,{group:"cores",title:"Core history",action:"Show core history",label:"CPU",value:e==null?null:`${Math.round(e)}%`,children:i.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)=>i.jsx("span",{className:"sd-core",title:`logical core ${l+1} · ${o}% busy`,children:i.jsx("span",{className:"sd-core-fill",style:{transform:`scaleY(${Math.max(2,o)/100})`}})},l))})}),n&&i.jsxs(Cl,{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:[i.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)=>i.jsx(tx,{value:o.toFixed(2),cap:["1m","5m","15m"][l]},l))}),n[0]>r&&i.jsx("div",{className:"sd-note",children:`${(n[0]/r).toFixed(1)}× more work queued than cores to run it`})]})]})}function qU({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 i.jsx("div",{className:"sd-section",role:"group","aria-label":"Memory",children:i.jsxs(Cl,{group:"memory",title:"Memory history",action:"Show memory history",label:"Memory",children:[i.jsx(Ku,{label:"Physical",value:i.jsxs(i.Fragment,{children:[i.jsx("b",{children:ca(r)})," of ",ca(e.total)]}),pct:e.usedPct,tone:e.usedPct>=90?"warn":"calm",note:`${ca(e.available)} available`}),t&&t.total>0&&i.jsx(Ku,{label:s,value:i.jsxs(i.Fragment,{children:[i.jsx("b",{children:ca(t.used)})," of ",ca(t.total)]}),pct:o,tone:o>=90?"warn":"calm"})]})})}function BU({thermal:e}){if(!e)return null;const t=e.throttle?sU(e.throttle.speedLimit,e.heldBack):null;return i.jsx("div",{className:"sd-section",role:"group","aria-label":"Thermal",children:i.jsxs(Cl,{group:"thermal",title:"Thermal history",action:"Show thermal history",label:"Thermal",children:[e.celsius.map(n=>i.jsx(Ku,{label:n.label,value:i.jsxs(i.Fragment,{children:[i.jsx("b",{children:n.celsius})," °C"]}),pct:n.celsius/n.critAt*100,mark:n.warnAt/n.critAt*100,tone:rU(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&&i.jsx(Ku,{label:"Throttling",value:i.jsx("b",{children:t.value}),pct:t.pct,tone:t.tone,note:t.note})]})})}function zU({sys:e}){const[t,n]=x.useState(!1);return i.jsxs("div",{className:"sd-section sd-door-section",children:[i.jsx("button",{type:"button",className:"sd-open sd-door",onClick:()=>n(!0),"aria-label":"Show every process the deck is watching",children:i.jsxs("span",{className:"sd-door-plate",children:[i.jsxs("span",{className:"sd-door-name",children:["Busiest processes",i.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),i.jsx("span",{className:"sd-door-sub",children:"every process, with its command line"})]})}),t&&i.jsx(MU,{sys:e,onClose:()=>n(!1)})]})}function UU(e){return{inputTokens:e.i,outputTokens:e.o,cacheReadTokens:e.cr,cacheCreateTokens:e.cc,cacheCreate1hTokens:e.c1h,cacheCreate5mTokens:e.c5m}}function fM(e){return e.i+e.o+e.cr+e.cc}function nS(e){let t=0;for(const n of Object.values(e))t+=fM(n);return t}function HU(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 f=`${o}|${d}`,h=n.get(f),m=h?h.usage:{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,cacheCreate1hTokens:0,cacheCreate5mTokens:0};m.inputTokens+=t(u.inputTokens),m.outputTokens+=t(u.outputTokens),m.cacheReadTokens+=t(u.cacheReadTokens),m.cacheCreateTokens+=t(u.cacheCreationTokens),h?h.cost+=t(u.cost):n.set(f,{cost:t(u.cost),usage:m})}}return n}function WU(e,t,n,r=Date.now()){const s=new Map;let o=0,l=0;for(const[T,R]of n){const M=T.indexOf("|"),O=T.slice(0,M),I=T.slice(M+1),A=bl(R.usage,I,r).total;if(!(A>0&&R.cost>0))continue;o+=R.cost,l+=A;let L=s.get(O);L||(L=new Map,s.set(O,L)),L.set(I,R.cost/A)}const u=l>0,d=(T,R)=>{const M=s.get(T);return(M==null?void 0:M.get(R))??(M==null?void 0:M.get(Ko(R)))??1},f=new Set,h=(T,R)=>{let M=0,O=0;for(const[I,A]of Object.entries(T)){if(Sa(I,r)){M+=bl(UU(A),I,r).total*R(I);continue}const L=fM(A);L>0&&(O+=L,f.add(I))}return{cost:M,unpriced:O}},m=new Map,g=[];for(const T of e){const R=new Map,M=new Map;let O=0;for(const I of T.projects){const{cost:A,unpriced:L}=h(I.models,V=>d(T.day,V));R.set(I.path,(R.get(I.path)??0)+A),L>0&&M.set(I.path,(M.get(I.path)??0)+L),O+=A;let z=m.get(I.path);z||(z={path:I.path,cost:0,tokens:0,unpricedTokens:0},m.set(I.path,z)),z.cost+=A,z.tokens+=nS(I.models),z.unpricedTokens+=L}g.push({day:T.day,total:O,byPath:R,unpricedByPath:M})}const w=[...m.values()].sort((T,R)=>R.cost-T.cost||R.tokens-T.tokens),k=w.reduce((T,R)=>T+R.cost,0),v=w.reduce((T,R)=>T+R.tokens,0),b=w.reduce((T,R)=>T+R.unpricedTokens,0),S=u?o/l:1,_=t?nS(t):0,j=t?h(t,()=>S):{cost:0,unpriced:0},E=j.cost>0||_>0?{cost:j.cost,tokens:_,unpricedTokens:j.unpriced}:null;return{projects:w,totalCost:k,totalTokens:v,unpricedTokens:b,perDay:g,unattributed:E,unpricedModels:[...f].sort(),calibrated:u,reconciled:u&&b===0}}function fr(e,t,n=Be){return t>0?e>0?`${n(e)}+`:Hr:n(e)}function vo(e){return e>0?`${et(e)} of these tokens are on an unpriced model, so this is a floor`:void 0}function VU(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 ${Hr}: this build holds no published rate for it, so its tokens are counted and its dollars are not.`:`${n} are ${Hr}: this build holds no published rate for them, so their tokens are counted and their dollars are not.`}const GU={phase:"running"},KU={phase:"failed"},YU={gen:0,report:null,error:null,early:null};function XU(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:GU;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 ZU(e){var t;return((t=e.report)==null?void 0:t.gen)!==e.gen&&e.error===null}function JU(e){const t=e;return t&&t.ok!==!1?{phase:"ready",range:t}:KU}function rS(e){return`${e.getFullYear()}${String(e.getMonth()+1).padStart(2,"0")}${String(e.getDate()).padStart(2,"0")}`}function QU(e,t,n=Date.now()){const r=t===0?60:t,s=rS(new Date(n-(r-1)*864e5)),o=rS(new Date(n));return{report:`/api/account-projects?num=${e}&days=${t}`,ccusage:`/api/ccusage?since=${s}&until=${o}`}}function eH({num:e,days:t,gen:n,dispatch:r,get:s=(l,u)=>fetch(l,u),now:o=Date.now()}){const l=QU(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:JU(d)}))}async function ja(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 pM(e){return/^[A-Za-z]:[\\/]$/.test(e)?e:e.replace(/[\\/]+$/,"")}function Qf(e){const t=pM(e).replace(/\\/g,"/");return/^[A-Za-z]:\//.test(t)?t.toLowerCase():t}function sS(e){if(!e)return e;const t=pM(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 tH(e,t){const n=Qf(e);let r;for(const s of t){const o=Qf(s.path);!o||o===n||!n.startsWith(`${o}/`)||(!r||Qf(r.path).length<o.length)&&(r=s)}return r==null?void 0:r.label}function nx(e){return e===0?"all time":e===1?"today":`the last ${e} days`}function nH(e){return e===1?"No work attributed to this account yet today.":`No work attributed to this account in ${nx(e)}.`}function rH(e){return e===1?7:e===7?30:e===30?0:null}function sH(e,t){return e!==1&&t>0}const aH=[{days:1,label:"Today"},{days:7,label:"7d"},{days:30,label:"30d"},{days:0,label:"All"}],xo=["var(--usage-blue)","var(--usage-teal)","var(--usage-lime)","var(--usage-purple)","var(--usage-indigo)","var(--usage-pink)","var(--usage-orange)","var(--usage-zinc)"],oH="var(--usage-zinc)",ep=6,iH=1600;function lH(e){const t=Be(e),n=/^\$(\d{4,})$/.exec(t);return n?`$${Number(n[1]).toLocaleString("en-US")}`:t}function cu(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 cH(e){const t=/^\d{4}-(\d{2})-(\d{2})$/.exec(e);return t?`${Number(t[1])}/${Number(t[2])}`:e}function uH(e){const t=Math.max(1,Math.ceil(e/6));return n=>n===0||n===e-1||n%t===0}function tp(e){if(!e)return"";try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function dH({num:e,name:t,onClose:n}){var P,F,Y,K;const[r,s]=x.useState(1),[o,l]=x.useReducer(XU,YU),u=((P=o.report)==null?void 0:P.data)??null,d=((F=o.report)==null?void 0:F.days)??r,f=((Y=o.report)==null?void 0:Y.cost.phase)==="ready"?o.report.cost.range:null,h=((K=o.report)==null?void 0:K.cost.phase)==="running",[m,g]=x.useState(null),[w,k]=x.useState(()=>new Set),v=ZU(o),b=o.error,[S,_]=x.useState(null),j=x.useRef(void 0),E=x.useRef(!0);x.useEffect(()=>()=>{E.current=!1,window.clearTimeout(j.current)},[]);const T=x.useRef(null),R=Et(n,{focusRef:T}),M=x.useRef(0);x.useEffect(()=>{const D=++M.current;l({type:"start",gen:D}),g(null),k(new Set),eH({num:e,days:r,gen:D,dispatch:l})},[e,r]);const O=x.useMemo(()=>{const D=Date.now();if(!u)return null;const W=WU(u.daily??[],u.unattributed,HU(f),D),B=ue=>ue.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||ue||"(unknown)",X=new Map;for(const ue of W.projects)X.set(B(ue.path),(X.get(B(ue.path))??0)+1);const G=ue=>{const se=B(ue);if((X.get(se)??0)<=1)return se;const xe=ue.replace(/[\\/]+$/,"").split(/[\\/]/).slice(-2,-1)[0];return xe?`${xe}/${se}`:se},U=W.projects.map(ue=>({path:ue.path,label:G(ue.path)})),Z=ue=>({path:ue.path,label:G(ue.path),parentLabel:tH(ue.path,U),cost:ue.cost,tokens:ue.tokens,unpricedTokens:ue.unpricedTokens}),H=xo[ep%xo.length],J=new Map,ee=[],re=W.projects.slice(0,ep),oe=W.projects.slice(ep);re.forEach((ue,se)=>{J.set(ue.path,xo[se%xo.length]),ee.push({key:ue.path,...Z(ue),color:xo[se%xo.length]})}),oe.length&&ee.push({key:"__other__",label:`Other · ${oe.length} project${oe.length>1?"s":""}`,cost:oe.reduce((ue,se)=>ue+se.cost,0),tokens:oe.reduce((ue,se)=>ue+se.tokens,0),unpricedTokens:oe.reduce((ue,se)=>ue+se.unpricedTokens,0),color:H,muted:!0,members:oe.map(Z)});const fe=W.totalCost,Ne=W.totalTokens,ke=fe>0&&W.unpricedTokens===0?"cost":"tokens",we=ke==="cost"?fe:Ne,ve=ee.map(ue=>ue.color),$e=W.perDay.map(ue=>{const se=new Map;for(const[Le,Ie]of ue.byPath){const qe=J.get(Le)??H;se.set(qe,(se.get(qe)??0)+Ie)}const xe=new Map;let Ae=0;for(const[Le,Ie]of ue.unpricedByPath){const qe=J.get(Le)??H;xe.set(qe,(xe.get(qe)??0)+Ie),Ae+=Ie}return{day:ue.day,total:ue.total,costByColor:se,unpricedByColor:xe,unpriced:Ae}}),ye=$e.reduce((ue,se)=>Math.max(ue,se.total),0);return{rows:ee,totalCost:fe,totalTokens:Ne,basis:ke,denom:we,un:W.unattributed,chart:$e,maxDay:ye,colorOrder:ve,unpricedTokens:W.unpricedTokens,unpricedNote:VU(W.unpricedModels),calibrated:W.calibrated,reconciled:W.reconciled}},[u,f]),I=(D,W)=>{ja(D).then(B=>{E.current&&(window.clearTimeout(j.current),_({path:D,label:W,ok:B}),j.current=window.setTimeout(()=>{E.current&&_(null)},iH))})},A=D=>S!=null&&S.ok&&S.path===D?"Copied":"Copy",L=u!=null&&u.trackedSince?`Tracked since ${tp(u.trackedSince)}`:"Tracking starts with this version",z=nx(d),V=rH(d),$=v&&!!u;return zt.createPortal(i.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:i.jsxs("div",{ref:R,className:"modal ap-proj-modal",onClick:D=>D.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ap-proj-title ap-proj-sub",children:[i.jsxs("header",{className:"ap-proj-head",children:[i.jsxs("div",{className:"ap-proj-titlewrap",children:[i.jsx("div",{className:"ap-proj-title",id:"ap-proj-title",children:"Projects"}),i.jsx("div",{className:"ap-proj-sub",id:"ap-proj-sub",title:t,children:t})]}),i.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:aH.map(D=>i.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":r===D.days,onClick:()=>s(D.days),children:D.label},D.days))}),i.jsx("button",{ref:T,className:"glyph-btn ap-proj-close",onClick:n,"aria-label":"Close",children:"×"})]}),i.jsxs("div",{className:`ap-proj-body${$?" refreshing":""}`,"aria-busy":v,children:[v&&!u&&i.jsx("div",{className:"ap-proj-state",children:"Loading…"}),!v&&b&&i.jsxs("div",{className:"ap-proj-state ap-proj-error",children:["Couldn’t load this report: ",b]}),!b&&O&&i.jsx(i.Fragment,{children:O.rows.length===0?i.jsxs("div",{className:"ap-proj-state",children:[nH(d),V!=null&&i.jsx("div",{className:"ap-proj-widen-wrap",children:i.jsxs("button",{type:"button",className:"ap-proj-copy",onClick:()=>s(V),children:["Show ",nx(V)]})}),i.jsxs("div",{className:"ap-proj-note",children:[L,". Only work from this version onward can be tied to an account."]})]}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"ap-proj-bar",role:"img","aria-label":O.basis==="cost"?`Share of ${Be(O.totalCost)} across ${O.rows.length} projects`:`Share of ${et(O.totalTokens)} tokens across ${O.rows.length} projects`,children:O.rows.map(D=>{const W=O.basis==="cost"?D.cost:D.tokens,B=O.denom>0?W/O.denom*100:0;if(B<=0)return null;const X=O.basis==="cost"?cu(D.cost,O.totalCost):`${cu(D.tokens,O.totalTokens)} of tokens`;return i.jsx("span",{className:"ap-proj-seg",style:{width:`${B}%`,background:D.color},title:`${D.label} · ${fr(D.cost,D.unpricedTokens)} · ${X}${D.tokens?` · ${et(D.tokens)} tokens`:""}`},D.key)})}),i.jsxs("div",{className:"ap-proj-totals",children:[i.jsx("span",{className:"ap-proj-total-cost",title:vo(O.unpricedTokens),children:fr(O.totalCost,O.unpricedTokens)}),i.jsxs("span",{className:"ap-proj-total-tok",children:[et(O.totalTokens)," tokens"]}),i.jsxs("span",{className:"ap-proj-total-win",children:["· ",z]}),h&&i.jsx("span",{className:"ap-proj-total-pending",children:"Reconciling cost…"})]}),O.unpricedNote&&i.jsx("div",{className:"ap-proj-note",children:O.unpricedNote}),sH(d,O.chart.length)&&i.jsxs("div",{className:"ap-proj-days",children:[i.jsxs("div",{className:"ap-proj-days-cap",children:["By day",O.chart.length>1?" · click a bar":""]}),i.jsx("div",{className:"ap-proj-days-plot",role:"img","aria-label":`Spend across ${O.chart.length} day${O.chart.length>1?"s":""}`,children:O.chart.map(D=>{const W=O.maxDay>0?D.total/O.maxDay*100:0,B=m===D.day,X=O.rows.map(U=>({label:U.label,c:D.costByColor.get(U.color)??0,u:D.unpricedByColor.get(U.color)??0})).filter(U=>U.c>0||U.u>0),G=`${tp(Date.parse(`${D.day}T00:00:00`))}, ${fr(D.total,D.unpriced)}. ${X.map(U=>`${U.label} ${fr(U.c,U.u)}`).join(", ")}`;return i.jsx("button",{type:"button",className:`ap-proj-day${B?" selected":""}`,"aria-pressed":B,"aria-label":G,title:`${D.day} · ${fr(D.total,D.unpriced)}`,onClick:()=>g(U=>U===D.day?null:D.day),children:i.jsx("span",{className:"ap-proj-col",style:{height:`${W}%`},children:O.colorOrder.map((U,Z)=>{const H=D.costByColor.get(U)??0;return H<=0||D.total<=0?null:i.jsx("span",{className:"ap-proj-colseg",style:{height:`${H/D.total*100}%`,background:U}},Z)})})},D.day)})}),(()=>{const D=uH(O.chart.length);return i.jsx("div",{className:"ap-proj-days-axis","aria-hidden":"true",children:O.chart.map((W,B)=>i.jsx("div",{className:"ap-proj-axis-cell",children:D(B)?cH(W.day):""},W.day))})})(),(()=>{const D=m?O.chart.find(B=>B.day===m):null;if(!D)return null;const W=O.rows.map(B=>({r:B,c:D.costByColor.get(B.color)??0,u:D.unpricedByColor.get(B.color)??0})).filter(B=>B.c>0||B.u>0);return i.jsxs("div",{className:"ap-proj-day-detail",children:[i.jsxs("div",{className:"ap-proj-day-detail-head",children:[i.jsx("span",{children:tp(Date.parse(`${D.day}T00:00:00`))}),i.jsx("span",{className:"ap-proj-day-detail-total",title:vo(D.unpriced),children:fr(D.total,D.unpriced)})]}),W.map(({r:B,c:X,u:G})=>i.jsxs("div",{className:"ap-proj-day-detail-row",children:[i.jsx("span",{className:"ap-proj-dot",style:{background:B.color},"aria-hidden":"true"}),i.jsx("span",{className:"ap-proj-day-detail-name",children:B.label}),i.jsx("span",{className:"ap-proj-day-detail-cost",title:vo(G),children:fr(X,G)})]},B.key))]})})()]}),i.jsx("ul",{className:"ap-proj-list",children:O.rows.map((D,W)=>{const B=O.basis==="cost"?D.cost:D.tokens,X=O.denom>0?B/O.denom*100:0,G=w.has(D.key),U=`ap-proj-details-${W}`,Z=G&&(!!D.path||!!D.members),H=D.members?`${G?"Hide":"Show"} the ${D.members.length} project${D.members.length>1?"s":""} folded into Other`:`${G?"Hide":"Show"} location for ${D.label}`;return i.jsxs("li",{className:`ap-proj-row${D.muted?" muted":""}${G?" expanded":""}`,children:[i.jsx("span",{className:"ap-proj-dot",style:{background:D.color},"aria-hidden":"true"}),i.jsxs("span",{className:"ap-proj-name",children:[D.label,D.parentLabel&&i.jsxs("span",{className:"ap-proj-parent",children:[" · in ",D.parentLabel]})]}),i.jsx("span",{className:"ap-proj-track",title:O.basis==="cost"?`${cu(D.cost,O.totalCost)} of tracked cost`:`${cu(D.tokens,O.totalTokens)} of tracked tokens`,children:i.jsx("span",{className:"ap-proj-fill",style:{width:`${X}%`,background:D.color}})}),i.jsx("span",{className:"ap-proj-cost",title:vo(D.unpricedTokens),children:fr(D.cost,D.unpricedTokens)}),i.jsx("span",{className:"ap-proj-tok",children:et(D.tokens)}),i.jsx("button",{type:"button",className:"glyph-btn ap-proj-info","aria-expanded":G,"aria-controls":Z?U:void 0,"aria-label":H,onClick:()=>k(J=>{const ee=new Set(J);return ee.has(D.key)?ee.delete(D.key):ee.add(D.key),ee}),children:"ⓘ"}),G&&D.path&&i.jsxs("div",{className:"ap-proj-details",id:U,children:[i.jsx("code",{className:"ap-proj-path",children:sS(D.path)}),i.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${A(D.path)} location for ${D.label}`,onClick:()=>I(D.path,D.label),children:A(D.path)})]}),G&&D.members&&i.jsx("div",{className:"ap-proj-details ap-proj-other-members",id:U,children:D.members.map(J=>i.jsxs("div",{className:"ap-proj-other-member",children:[i.jsxs("div",{className:"ap-proj-other-name",children:[J.label,J.parentLabel&&i.jsxs("span",{className:"ap-proj-parent",children:[" · in ",J.parentLabel]})]}),i.jsx("code",{className:"ap-proj-path",children:sS(J.path)}),i.jsx("span",{className:"ap-proj-cost",title:vo(J.unpricedTokens),children:fr(J.cost,J.unpricedTokens)}),i.jsx("span",{className:"ap-proj-tok",children:et(J.tokens)}),i.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${A(J.path)} location for ${J.label}`,onClick:()=>I(J.path,J.label),children:A(J.path)})]},J.path))})]},D.key)})}),O.un&&i.jsxs("div",{className:"ap-proj-unattributed",children:[i.jsx("span",{className:"ap-proj-dot",style:{background:oH},"aria-hidden":"true"}),i.jsxs("div",{className:"ap-proj-un-labels",children:[i.jsx("span",{className:"ap-proj-un-title",children:"Unattributed usage"}),i.jsx("span",{className:"ap-proj-un-tag",children:"Excluded from the project totals"})]}),i.jsx("span",{className:"ap-proj-un-cost",title:vo(O.un.unpricedTokens),children:fr(O.un.cost,O.un.unpricedTokens,lH)}),i.jsx("span",{className:"ap-proj-un-tok",children:et(O.un.tokens)}),i.jsx("div",{className:"ap-proj-note",children:"Work no account could be tied to — from before tracking, or a gap."})]}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:S&&(S.ok?`Copied the location of ${S.label}`:`Could not copy the location of ${S.label} — select it and copy it by hand`)}),i.jsxs("div",{className:"ap-proj-foot",children:[h?"Dollars estimated · ccusage still running":O.reconciled?"Dollars from ccusage · split by activity":O.calibrated?"Dollars from ccusage for the priced models · split by activity":f?"Dollars estimated · ccusage could not price this window":"Dollars estimated · ccusage unavailable"," · ",L]})]})})]})]})}),document.body)}function rx(e,t){return UA(t-Math.floor(e/1e3))}function hH(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 u0(){return i.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:[i.jsx("path",{d:"M7 1.9 12.9 12H1.1Z"}),i.jsx("path",{d:"M7 5.6v2.9"}),i.jsx("path",{d:"M7 10.3v.05"})]})}function fH({anchorId:e,boundaryId:t,issue:n,who:r,fetchedAt:s,nowSec:o,onClose:l,onSignIn:u}){return i.jsx(c0,{anchorId:e,boundaryId:t,id:"ap-issue-pop",className:"ap-pop ap-issue-pop",role:"dialog",labelledBy:"ap-issue-title",onClose:()=>l(),children:i.jsxs("div",{className:"ap-pop-form",children:[i.jsxs("p",{className:"ap-pop-title ap-issue-title",id:"ap-issue-title","data-tone":n.tone,children:[n.tone==="warn"&&i.jsx(u0,{}),n.text]}),i.jsx("p",{className:"ap-pop-note ap-issue-hint",children:n.hint}),i.jsxs("p",{className:"ap-pop-note ap-issue-when",children:[i.jsx("span",{className:"ap-issue-who",children:r})," · ",s?`last collected ${rx(s,o)}`:"never collected"]}),i.jsxs("div",{className:"ap-pop-actions",children:[i.jsx("button",{type:"button",className:"btn",onClick:()=>l(!0),children:"Done"}),n.fix&&i.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 nl(e){return e.charAt(0).toUpperCase()+e.slice(1)}function pH(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 mH(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 gH(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.`}}}function Yu(e,t){if(e.staleCopy){const n=pH(e.repair??null,t);return{text:nl(n.text),hint:n.hint,fix:null,tone:"quiet",blocksSwitch:!1}}if(e.stopped){const n=gH(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:nl(n.text),hint:n.hint,fix:n.fix?nl(n.fix):null,tone:r||e.collector==="keychain_unavailable"?"warn":"quiet",blocksSwitch:r}}if(e.error){const n=mH(e.error);return{text:nl(n.text),hint:n.hint,fix:n.fixable?"Sign in again":null,tone:n.fixable?"warn":"quiet",blocksSwitch:n.fixable}}return null}function aS(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function yH(e){const t=e.filter(u=>!aS(u)),n=e.filter(u=>aS(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}}function wH(e){return e>=90?"hi":e>=70?"mid":void 0}function vH({lane:e,nowSec:t,frozen:n}){const r=Math.min(100,Math.max(0,e.pct)),s=n?"var(--muted)":r>=90?"var(--err)":r>=70?"var(--warn)":"var(--accent)",o=e.resetAt&&!n?HA(e.resetAt,t):null;return i.jsxs("div",{className:"ap-lane",children:[i.jsx("span",{className:"ap-lane-label",title:e.label,children:e.label}),i.jsx("div",{className:"ap-lane-track",children:i.jsx("div",{className:"ap-lane-fill",style:{width:`${r===0?1.5:r}%`,background:s,opacity:r===0||n?.4:1}})}),i.jsxs("span",{className:"ap-lane-pct",style:{color:s},children:[r,"%"]}),i.jsx("span",{className:"ap-lane-reset",title:o?`${e.label} resets in ${o}`:void 0,children:o&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"vis-hidden",children:"resets in "}),o]})})]})}function xH({a:e,nowSec:t,opened:n,onToggleLanes:r,busy:s,pressProps:o,onSwitch:l,menuOpen:u,onOpenMenu:d,onCloseMenu:f,refusal:h,onDismissRefusal:m,switchedHere:g,swapped:w,displaced:k,issueExpanded:v,onOpenIssue:b}){const{shown:S,fuller:_}=yH(e.lanes),j=Yu(e,t),E=e.active||n,T=e.alias??e.email??`account ${e.num}`,R=e.alias&&e.email?`${e.alias} · ${e.email}`:T,M=e.stale||(j==null?void 0:j.blocksSwitch)===!0,O=_?[...S,_]:S,I=e.fetchedAt?rx(e.fetchedAt,t):null;return i.jsxs("li",{className:`ap-account${e.active?" active":""}`,"aria-current":e.active?"true":void 0,"data-open":E?"":void 0,"data-frozen":M?"":void 0,children:[!e.active&&i.jsx("button",{type:"button",className:"ap-row-open",id:`ap-row-${e.num}`,title:R,"aria-expanded":E,"aria-controls":E?`ap-detail-${e.num}`:void 0,"aria-describedby":[e.alias&&e.email?`ap-email-${e.num}`:null,!E&&!(j!=null&&j.blocksSwitch)?`ap-quota-${e.num}`:null].filter(Boolean).join(" ")||void 0,onClick:()=>r(),children:i.jsxs("span",{className:"vis-hidden",children:[T,", ",E?"hide details":"details"]})}),i.jsxs("div",{className:"ap-account-head",children:[e.active?i.jsx("span",{className:"ap-live",title:`Active account · slot ${e.num}`,children:i.jsxs("span",{className:"vis-hidden",children:["Active account, slot ",e.num,":"]})}):i.jsx("span",{className:"ap-num",children:e.num}),e.alias&&i.jsx("span",{className:"ap-alias",title:e.alias,children:e.alias}),i.jsx("span",{className:"ap-email",id:`ap-email-${e.num}`,title:e.email??void 0,children:e.email}),e.disabled&&i.jsx("span",{className:"ap-held",children:"held out"}),!e.active&&!e.disabled&&!(j!=null&&j.blocksSwitch)&&i.jsx("button",{type:"button",className:"ap-switch",...o(`switch-${e.num}`),onClick:()=>l(e.num,T),"aria-label":`Switch to ${T}`,title:`Switch to ${e.alias??e.email}`,children:s===`switch-${e.num}`?"…":"Switch"}),i.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":u,"aria-controls":u?`ap-menu-${e.num}`:void 0,title:"More actions",onClick:()=>u?f():d(e.num),onKeyDown:A=>{A.key!=="ArrowDown"&&A.key!=="ArrowUp"||(A.preventDefault(),d(e.num,A.key==="ArrowUp"?"last":"first"))},children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"currentColor","aria-hidden":!0,children:[i.jsx("circle",{cx:"2.8",cy:"7",r:"1.15"}),i.jsx("circle",{cx:"7",cy:"7",r:"1.15"}),i.jsx("circle",{cx:"11.2",cy:"7",r:"1.15"})]})})]}),h&&i.jsxs("div",{className:"ap-failure ap-row-failure",role:"alert",children:[i.jsx("span",{className:"ap-failure-text",title:h.raw||void 0,children:h.text}),i.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>m(),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),e.active&&g&&i.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."}),w&&(()=>{const A=(k==null?void 0:k.alias)??(k==null?void 0:k.email)??"the account that was there";return i.jsxs("p",{className:"ap-note ap-swap-note",title:`Slot ${w.at} was taken, so the two accounts traded places: ${A} now holds slot ${w.displaced}.`,children:["swapped with slot ",w.displaced]})})(),j&&i.jsxs("div",{className:"ap-issue-line",children:[i.jsxs("button",{type:"button",id:`ap-issue-${e.num}`,className:"ap-issue","data-tone":j.tone,"aria-haspopup":"dialog","aria-expanded":v,"aria-controls":v?"ap-issue-pop":void 0,onClick:()=>b(e.num,`ap-issue-${e.num}`),children:[j.tone==="warn"&&i.jsx(u0,{}),i.jsx("span",{className:"ap-issue-text",children:j.text})]}),!E&&i.jsx("span",{className:"ap-issue-age",title:"When claude-swap last read this account's usage",children:I??"never collected"})]}),!E&&!(j!=null&&j.blocksSwitch)&&i.jsxs("p",{className:"ap-quota",id:`ap-quota-${e.num}`,children:[O.length?O.map(A=>i.jsxs("span",{className:"ap-q",children:[i.jsx("span",{className:"ap-q-label",children:A.label})," ",i.jsxs("span",{className:"ap-q-pct","data-level":M?void 0:wH(A.pct),children:[Math.round(A.pct),"%"]})]},A.id)):i.jsx("span",{className:"ap-q-label",children:"no usage recorded yet"}),e.stale&&!j&&i.jsx("span",{className:"ap-q-age","data-never":I?void 0:"",title:"When claude-swap last read this account's usage",children:I??"never collected"})]}),E&&i.jsxs("div",{className:"ap-detail",id:`ap-detail-${e.num}`,children:[i.jsx("div",{className:"ap-lanes",children:e.lanes.length?e.lanes.map(A=>i.jsx(vH,{lane:A,nowSec:t,frozen:M},A.id)):i.jsx("div",{className:"ap-hint",children:"No usage recorded yet."})}),i.jsx("div",{className:"ap-meta",children:e.fetchedAt?i.jsxs("span",{className:`ap-age${e.stale&&!j?" 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 ",rx(e.fetchedAt,t),j!=null&&j.blocksSwitch?"":hH(e.nextAt,t)]}):i.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})})]})]})}function bH({data:e}){return i.jsx("div",{className:"ap-empty",children:e.reason==="cswap_installing"?i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"Installing claude-swap…"}),i.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"?i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"claude-swap isn't installed."}),i.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&&i.jsx("code",{className:"ap-cmd",children:e.hint}),i.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",i.jsx("strong",{children:"+"})," button above."]})]}):e.reason==="no_accounts"?i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"No accounts added yet."}),i.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",i.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"Couldn't read the account store."}),i.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",e.reason?` (${e.reason})`:"","."]})]})})}function kH({canShare:e,onAdd:t,onShareSet:n,onReload:r,pressProps:s,reloading:o,closeButton:l}){return i.jsxs("div",{className:"ap-header",children:[i.jsx("h2",{children:"Claude accounts"}),i.jsxs("div",{className:"ap-header-right",children:[i.jsx("button",{type:"button",className:"glyph-btn ap-add",onClick:()=>t(),"aria-label":"Add an account",title:"Sign in to another Claude account, or paste one shared from another deck",children:i.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:i.jsx("path",{d:"M7 2.2v9.6M2.2 7h9.6"})})}),e&&i.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>n(),"aria-label":"Share accounts with another deck",title:`Copy several accounts to another ${gt} in one paste. The text carries a live login for each one — treat it as those passwords.`,children:i.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:[i.jsx("path",{d:"M3.3 10.7L10.7 3.3"}),i.jsx("path",{d:"M5.5 3.3h5.2v5.2"})]})}),i.jsx("button",{type:"button",className:"glyph-btn ap-refresh",onClick:()=>r(),...s("reload",o),"aria-label":"Reload accounts",title:"Reload from claude-swap",children:i.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:[i.jsx("path",{d:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),i.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]})}),l]})]})}const np=[70,80,85,90,95];function NH(e){const t=Number(e);return[...Number.isFinite(t)&&t>0&&!np.includes(t)?[...np,t]:np].sort((r,s)=>r-s)}function SH({auto:e,threshold:t,thresholdPick:n,thresholdCtl:r,thresholdSaved:s,thresholdRef:o,thresholdSaveRef:l,proposeThreshold:u,doThreshold:d,pressProps:f,post:h,load:m}){return i.jsxs("div",{className:"ap-policy-block",children:[i.jsxs("div",{className:"ap-policy",children:[i.jsx("h3",{className:"ap-auto-title",children:"Auto-switch"}),i.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:i.jsx("select",{ref:o,"aria-label":"Switch threshold",value:n,...f("threshold"),onChange:g=>u(g.target.value),children:NH(t).map(g=>i.jsxs("option",{value:g,children:[g,"%"]},g))})}),(r.sends||s)&&i.jsx("button",{ref:l,type:"button",className:"ap-manage-btn",...f("threshold"),title:r.title,onClick:()=>d(n,r),children:s&&!r.sends?r.done:r.label}),i.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":e.enabled,"aria-label":"Auto-switch",...f("enable"),onClick:()=>h({action:"enable",enabled:!e.enabled},"enable").then(()=>m(!0)),title:e.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:i.jsx("span",{className:"switch-knob"})})]}),e.external&&i.jsxs("p",{className:"ap-auto-note",children:[i.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",i.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 oS=18,jH=1100,bo=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},_H=Array.from({length:oS},(e,t)=>{const n=-72+144*t/(oS-1)+(bo(t,1)-.5)*9,r=(n-90)*(Math.PI/180),s=(54+32*Math.cos(n*Math.PI/180))*(.74+bo(t,2)*.52);return{dx:Math.cos(r)*s,dy:Math.sin(r)*s,rot:(t%2?1:-1)*(100+bo(t,3)*260),delay:Math.round(bo(t,4)*90),dur:760+Math.round(bo(t,5)*260),scale:.8+bo(t,6)*.45,hue:t%4,round:t%3===0}});function iS({anchor:e}){var s;const[t,n]=x.useState(null),r=typeof window<"u"&&((s=window.matchMedia)==null?void 0:s.call(window,"(prefers-reduced-motion: reduce)").matches);return x.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),jH);return()=>window.clearTimeout(u)},[e,r]),r||!t?null:zt.createPortal(i.jsx("div",{className:"confetti",style:{left:`${t.x}px`,top:`${t.y}px`},"aria-hidden":!0,children:_H.map((o,l)=>i.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 mM=new Set(["awaiting_url","awaiting_code","registering"]);function EH(e){return e!=null&&mM.has(e)}function gM(e){return e!=null&&e!=="done"&&!mM.has(e)}const CH="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",TH="the sign-in did not complete";function RH({state:e,serverError:t,localError:n}){const r=e==="idle";return{title:r?"Sign-in ended":"Sign-in failed",message:n||t||(r?CH:TH)}}function AH({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 MH({started:e,state:t}){return!e||t==="done"?null:{action:"login-cancel"}}const $H="done";function IH(){let e=!1;return{shouldAnnounce(t){return t!==$H?(e=!1,!1):e?!1:(e=!0,!0)}}}function d0(e,t){return t?sn(e,t):void 0}const OH={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 ${gt}`,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"},LH={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"},h0=`claude-swap could not read the login keychain — start ${gt} from a Terminal window rather than a background service`,PH={unreadable_here:{short:"Keychain locked on this Mac",long:`${h0}.`},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 Xu(e){return e?sn(PH,e)??null:null}const yM={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 sx(e,t,n){const r=n==null?null:yM[n];if(r)return r;if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(Tl(e)))return h0;const s=d0(LH,e==null?void 0:e.reason);return s||(e==null?void 0:e.reason)||t}function Tl(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const DH={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"},FH="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 qH(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const BH="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",zH="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",UH=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),HH=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,WH=/[\\/]_npx[\\/]/i,VH=`the copy of ccusage ${gt} installed for itself`;function GH(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function rte(e,t){const n=KH(e,t),r=GH(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 ${Ji(n)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${Ji(n)}`;case"managed":return`${VH} failed to run: ${Ji(n)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${Ji(n)}`:`the ccusage this deck found on your PATH failed to run: ${Ji(n)}`;default:return n}}const Ji=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function KH(e,t){const n=Tl(e);if(UH(n)){if(WH.test(n))return zH;if(HH.test(n))return BH}if(qH(n))return FH;const r=d0(DH,e==null?void 0:e.reason);return r||(e==null?void 0:e.reason)||t}function Eo(e,t,n){const r=n==null?null:yM[n];if(r)return r;if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&gM(e.state))return e.error;const s=d0(OH,e==null?void 0:e.reason);return s||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function YH(e,t,n){if(n<=0||gd(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 wM(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 XH(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 ZH(e,t){return e.filter(n=>!t.includes(n.num)).map(n=>n.num)}function JH(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function QH(e){return e.length?{action:"share",accounts:[...e]}:null}function eW(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 ax(e){return`${e.email}|${e.org??""}`}function tW(e,t,n){return e&&e.map(r=>ax(r)===t?n:r)}function nW(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 rW(e){const t=e.length;if(!t)return"Nothing to import.";const n=h=>e.filter(m=>m.state===h).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 f=[...new Set(e.map(h=>{var m;return(m=Xu(h.check))==null?void 0:m.short}).filter(h=>!!h))];return`${r.join(", ")}${f.length?`, ${f.join(", ")}`:""}.`}const sW=1500,uu=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],lS="aa-panel",cS=e=>`aa-tab-${e}`;async function Qi(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const ox=ce.forwardRef((e,t)=>i.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:t,children:[i.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),i.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));ox.displayName="SuccessMark";function aW({onClose:e,onChanged:t}){const[n,r]=x.useState("login"),[s,o]=x.useState(null),[l,u]=x.useState(""),[d,f]=x.useState(""),[h,m]=x.useState(!1),[g,w]=x.useState(null),[k,v]=x.useState(null),[b,S]=x.useState(null),[_,j]=x.useState(null),E=x.useRef(""),T=x.useRef(!1),R=x.useRef(!1),M=x.useRef(null),O=x.useRef(null),I=x.useRef(null),A=x.useRef(null),L=x.useRef([]),z=x.useRef(!1),V=x.useCallback(()=>{const H=MH({started:T.current,state:s==null?void 0:s.state});H&&Qi(H).catch(()=>{}),e()},[e,s==null?void 0:s.state]),$=Et(V,{focusRef:I}),P=x.useCallback(async()=>{if(!pr(R.current))return;R.current=!0,m(!0),w(null),T.current=!0;const H=await Qi({action:"login"}).catch(()=>null);if(R.current=!1,m(!1),!(H!=null&&H.ok)){w(Eo(H,"could not start the sign-in"));return}o(H)},[]);x.useEffect(()=>{if(!EH(s==null?void 0:s.state))return;const H=window.setInterval(async()=>{try{const J=await fetch("/api/claude-accounts/login");J.ok&&o(await J.json())}catch{}},sW);return()=>window.clearInterval(H)},[s]);const F=x.useRef(t);F.current=t;const Y=x.useState(IH)[0];x.useEffect(()=>{var H;(s==null?void 0:s.state)==="awaiting_code"&&((H=M.current)==null||H.focus()),Y.shouldAnnounce(s==null?void 0:s.state)&&F.current()},[s==null?void 0:s.state,Y]),x.useEffect(()=>{var H;n==="paste"&&!z.current&&((H=O.current)==null||H.focus()),z.current=!1},[n]);const K=x.useCallback(H=>{var ee;const J=YH(H,uu.findIndex(re=>re.id===n),uu.length);J.kind!=="pass"&&(H.preventDefault(),z.current=!0,r(uu[J.index].id),(ee=L.current[J.index])==null||ee.focus())},[n]),D=x.useCallback(async()=>{var J;if(!pr(R.current))return;R.current=!0,m(!0),w(null);const H=await Qi({action:"login-code",code:l}).catch(()=>null);if(R.current=!1,m(!1),!(H!=null&&H.ok)){w(Eo(H,"the code was not accepted")),H!=null&&H.state&&o(H),(J=M.current)==null||J.select();return}u(""),o(H)},[l,s]),W=x.useCallback(async()=>{if(!pr(R.current))return;R.current=!0,m(!0),w(null);const H=await Qi({action:"import",blob:d}).catch(()=>null);if(R.current=!1,m(!1),!(H!=null&&H.ok)){w(Eo(H,"the import failed"));return}E.current=d,f(""),j(null),v(H.results??[]),t()},[d,t]),B=x.useCallback(async H=>{const J=ax(H);if(!pr(R.current)||!E.current)return;R.current=!0,m(!0),S(J),j(null);const ee=await Qi({action:"import",blob:E.current,force:!0,only:{email:H.email,org:H.org??""}}).catch(()=>null);if(R.current=!1,m(!1),S(null),!(ee!=null&&ee.ok)){j({key:J,text:Eo(ee,"that account could not be updated")});return}const re=(ee.results??[])[0];re&&v(oe=>tW(oe,J,re)),t()},[t]),X=(s==null?void 0:s.state)==="done"?s.account:null,G=AH({restored:s==null?void 0:s.restored,activeAccount:s==null?void 0:s.activeAccount}),U=gM(s==null?void 0:s.state)||!!(g&&T.current&&!h),Z=RH({state:s==null?void 0:s.state,serverError:s==null?void 0:s.error,localError:g});return zt.createPortal(i.jsx("div",{className:"modal-backdrop",onClick:V,role:"presentation",children:i.jsxs("div",{ref:$,className:"modal aa-modal",onClick:H=>H.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{className:"aa-tabs",role:"tablist","aria-label":"How to add the account",onKeyDown:K,children:uu.map((H,J)=>i.jsx("button",{type:"button",role:"tab",id:cS(H.id),ref:ee=>{L.current[J]=ee},"aria-selected":n===H.id,"aria-controls":lS,tabIndex:n===H.id?0:-1,className:`aa-tab${n===H.id?" on":""}`,onClick:()=>{z.current=!1,r(H.id)},children:H.label},H.id))})}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:V,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsx("section",{className:"modal-body aa-body",id:lS,role:"tabpanel","aria-labelledby":cS(n),children:n==="login"?X?i.jsxs("div",{className:"aa-done",children:[i.jsx(ox,{ref:A}),i.jsx(iS,{anchor:A}),i.jsx("h4",{children:X.added?`Account ${X.num} added`:"Credentials refreshed"}),i.jsxs("p",{className:"aa-note",children:[i.jsx("strong",{children:X.email}),X.added?G?" 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."]}),G?i.jsx("p",{className:"aa-note aa-warn",role:"status",children:G}):null,i.jsx("button",{type:"button",className:"btn primary",onClick:V,children:"Done"})]}):(s==null?void 0:s.state)==="awaiting_code"||(s==null?void 0:s.state)==="registering"?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"aa-step",children:[i.jsx("h4",{children:"1 · Approve in the browser"}),i.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),i.jsx("a",{className:"aa-link",href:s.url??"#",target:"_blank",rel:"noreferrer noopener",children:s.url})]}),i.jsxs("div",{className:"aa-step",children:[i.jsx("h4",{children:"2 · Paste a code, if the page shows one"}),i.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."}),i.jsxs("div",{className:"aa-field",children:[i.jsx("input",{ref:M,type:"text",value:l,onChange:H=>u(H.target.value),onKeyDown:H=>{H.key==="Enter"&&l.trim()&&!h&&D()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:s.state==="registering"}),i.jsx("button",{type:"button",className:"btn primary",...Ss(h,!l.trim()||s.state==="registering"),onClick:D,children:s.state==="registering"?"registering…":"Continue"})]}),(g||s.error)&&i.jsx("p",{className:"aa-err",children:g??s.error}),i.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."})]})]}):U?i.jsxs("div",{className:"aa-step",children:[i.jsx("h4",{children:Z.title}),i.jsx("p",{className:"aa-err",children:Z.message}),i.jsx("button",{type:"button",className:"btn",onClick:()=>{T.current=!1,o(null),w(null),P()},children:"Try again"})]}):h||T.current?i.jsx("div",{className:"aa-step",children:i.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):i.jsxs("div",{className:"aa-step aa-primer",children:[i.jsx("h4",{children:"Sign in to Anthropic"}),i.jsx("p",{className:"aa-note",children:"Opens a browser tab where you approve the sign-in. It normally completes by itself; only if the page hands you a code does it need pasting back here. claude-swap records the account when it completes, and the account you are using now stays active."}),i.jsx("div",{className:"aa-actions",children:i.jsx("button",{type:"button",ref:I,className:"btn primary",onClick:P,children:"Open the sign-in page"})})]}):k?(()=>{const H=k.filter(ee=>ee.state==="imported").length,J=k.some(ee=>Xu(ee.check));return i.jsxs("div",{className:"aa-done",children:[!J&&i.jsx(ox,{ref:A}),H>0&&!J&&i.jsx(iS,{anchor:A}),i.jsx("h4",{children:rW(k)}),k.length>0&&i.jsx("ul",{className:"aa-results",children:k.map(ee=>{const re=ax(ee),oe=Xu(ee.check);return i.jsxs("li",{className:`aa-result ${ee.state}`,children:[i.jsx("span",{className:"aa-result-who",children:ee.email||(ee.num?`slot ${ee.num}`:"an account")}),i.jsx("span",{className:"aa-result-what",children:nW(ee.state)}),ee.state==="present"&&i.jsx("button",{type:"button",className:"aa-result-fix","aria-busy":b===re,title:`Overwrite the stored login for ${ee.email} with the one in this share. Do this when that account has stopped working here; if it works, leave it.`,onClick:()=>B(ee),children:b===re?"updating…":"update anyway"}),oe&&i.jsx("span",{className:"aa-result-err",children:oe.long}),(_==null?void 0:_.key)===re&&i.jsx("span",{className:"aa-result-err",children:_.text})]},re)})}),i.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",i.jsx("strong",{children:" update anyway"}),"."]}),i.jsxs("div",{className:"aa-actions",children:[i.jsx("button",{type:"button",className:"btn primary",onClick:V,children:"Done"}),i.jsx("button",{type:"button",className:"btn",onClick:()=>{E.current="",j(null),v(null)},children:"Import another"})]})]})})():i.jsxs("div",{className:"aa-step",children:[i.jsx("h4",{children:"Paste an account shared from another deck"}),i.jsxs("div",{className:"aa-field",children:[i.jsx("input",{ref:O,type:"text",value:d,onChange:H=>f(H.target.value),onKeyDown:H=>{H.key==="Enter"&&d.trim()&&!h&&W()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),i.jsx("button",{type:"button",className:"btn primary",...Ss(h,!d.trim()),onClick:W,children:h?"importing…":"Import"})]}),g&&i.jsx("p",{className:"aa-err",children:g}),i.jsxs("p",{className:"aa-note",children:["Use ",i.jsx("strong",{children:"share"})," on one account in the other deck, or ",i.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 oW(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 iW(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 lW=64;function cW(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}function uW(e,t,n){return t!=null&&e.some(r=>r.slot===t)?t:n}function dW(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 hW(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 fW({a:e,slots:t,nowSec:n,boundaryId:r,accountMenu:s,busy:o,pressProps:l,rotating:u,onProjects:d,onRotation:f}){const{menu:h,menuError:m,aliasDraft:g,confirmRemove:w,share:k,shareCopied:v,slotDraft:b,dropMenu:S,closeMenu:_,startRename:j,typeAlias:E,doAlias:T,startMove:R,pickSlot:M,doSlot:O,makeShare:I,copyShare:A,pressRemove:L}=s;if(!h)return null;const z=`ap-pop-title-${e.num}`,V=m&&i.jsx("p",{className:"ap-pop-error",role:"alert",title:m.raw||void 0,children:m.text});return i.jsxs(c0,{anchorId:`ap-more-${e.num}`,boundaryId:r,id:`ap-menu-${e.num}`,className:"ap-pop",role:h.view==="menu"?"menu":"dialog",labelledBy:h.view==="menu"?`ap-more-${e.num}`:z,start:h.start,onClose:S,children:[h.view==="menu"&&i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>j(e.num,e.alias),children:"Rename"}),i.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>R(e.num),children:"Move to slot…"}),i.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...l(`share-${e.num}`),title:`Copy this account to another ${gt}. 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:()=>I(e.num),children:o===`share-${e.num}`?"Sharing…":"Share"}),i.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)&&i.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:()=>f(),children:e.disabled?"Put back in rotation":"Hold out of rotation"}),i.jsx("div",{role:"separator",className:"ap-menu-sep"}),i.jsx("button",{type:"button",role:"menuitem",className:`ap-menu-item danger${w===e.num?" armed":""}`,...l(`rm-${e.num}`),"aria-label":w===e.num?"Confirm remove":void 0,title:w===e.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>L(e.num),children:o===`rm-${e.num}`?"Removing…":w===e.num?"Confirm":"Remove"}),V]}),h.view==="rename"&&i.jsxs("form",{className:"ap-pop-form",onSubmit:$=>{$.preventDefault(),T(e.num,e.alias)},children:[i.jsx("label",{className:"ap-pop-title",id:z,htmlFor:`ap-alias-${e.num}`,children:"Rename account"}),i.jsx("input",{id:`ap-alias-${e.num}`,className:"ap-manage-input",type:"text",value:g,onChange:$=>E($.target.value),maxLength:lW,placeholder:"e.g. work",spellCheck:!1,autoComplete:"off",autoFocus:!0,onFocus:$=>$.currentTarget.select()}),V,i.jsxs("div",{className:"ap-pop-actions",children:[i.jsx("button",{type:"button",className:"btn",onClick:()=>_(),children:"Cancel"}),i.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"})]})]}),h.view==="move"&&(()=>{const $=oW(t,e.num),P=uW($,b,e.num),F=dW($,P,e.num);return i.jsxs("div",{className:"ap-pop-form",children:[i.jsx("label",{className:"ap-pop-title",id:z,htmlFor:`ap-slot-${e.num}`,children:"Move to slot"}),i.jsx("span",{className:"ap-field",children:i.jsx("select",{id:`ap-slot-${e.num}`,value:String(P),...l(`move-${e.num}`),onChange:Y=>M(Number(Y.target.value)),autoFocus:!0,children:$.map(Y=>i.jsx("option",{value:Y.slot,children:Y.label},Y.slot))})}),V,i.jsxs("div",{className:"ap-pop-actions",children:[i.jsx("button",{type:"button",className:"btn",onClick:()=>_(),children:"Cancel"}),i.jsx("button",{type:"button",className:"btn primary",...l(`move-${e.num}`),title:F.title,onClick:()=>O(e.num,P,F),children:o===`move-${e.num}`?"…":nl(F.label)})]})]})})(),h.view==="share"&&(k==null?void 0:k.num)===e.num&&(()=>{const $=wM(k.expiresAt,n),P=$.tone==="gone";return i.jsxs("div",{className:"ap-pop-form",children:[i.jsx("p",{className:"ap-pop-title",id:z,children:"Share account"}),i.jsx("code",{className:"ap-share-blob",children:k.blob}),i.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:[i.jsx("span",{className:"ap-share-warn",children:"This is the password"})," · ",i.jsx("span",{className:`ap-share-expiry ${$.tone}`,children:$.text})]}),V,i.jsxs("div",{className:"ap-pop-actions",children:[i.jsx("button",{type:"button",className:"btn",onClick:()=>_(),children:"Done"}),i.jsx("button",{type:"button",className:"btn primary",...l(`share-${e.num}`),autoFocus:!0,onClick:async()=>{if(P){await I(e.num);return}await A(k.blob)},children:P?"Make a new share":v?"Copied":"Copy"})]})]})})()]})}const pW=6;function mW(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?gW(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 gW(e){const t=e.map(n=>n.headroom).filter(n=>typeof n=="number");return t.length?Math.max(...t):null}function yW(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,pW),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 gr(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 wW={keychain_unavailable:{short:"Keychain locked on the other Mac",long:`the other Mac could not export it. On that Mac: ${h0}. The next round brings it.`}};function ix(e){return e.why?sn(wW,e.why)??Xu(e.why):null}const f0={"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"}},vW={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 uS(e){var r;const t=xW[e];if(t)return t;const n=(r=/\b(E[A-Z]{3,})\b/.exec(e))==null?void 0:r[1];return n&&vW[n]||e}const xW={"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 _d(e,t){var h;if(!e)return null;if(e.error&&((h=e.done)!=null&&h.length)){const m=_d({...e,error:void 0},t),g=` · ${gr(e.at,t)}`;return{...m,text:`${m.text.slice(0,-g.length)}, then ${uS(e.error)}${g}`,tone:"bad"}}if(e.error)return f0[e.error]??{text:uS(e.error),tone:"bad"};const n=e.done??[];if(!n.length)return{text:`all logins fine · ${gr(e.at,t)}`,tone:"idle"};const r=n.filter(m=>m.ok),s=r.length===1?"login":"logins",o=n.map(m=>({d:m,why:ix(m)})).filter(m=>m.why),l=[...new Set(o.map(m=>m.why.short))],u=l.length?`, ${l.join(", ")}`:"",d=o.length?o.map(m=>`${m.d.email}: ${m.why.long}`).join(" "):void 0,f=gr(e.at,t);return r.length===n.length?{text:`${r.length} ${s} arrived${u} · ${f}`,tone:o.length?"warn":"ok",...d?{hint:d}:{}}:{text:`${r.length} of ${n.length} logins arrived${u} · ${f}`,tone:"bad",...d?{hint:d}:{}}}const bW=9e4;function kW({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(f=>f.addr===l&&f.port&&f.at>0&&s-f.at<bW);if(!u.length)return null;const d=[...new Set(u.map(f=>f.port))];if(n!=null&&!d.includes(n)){const f=d.length===1?`port ${d[0]}`:`ports ${d.join(" and ")}`;return`A deck at ${l} is announcing itself on ${f}, 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 vM(e,t){var n,r;return(n=e.last)!=null&&n.error&&!f0[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 NW(e,t){const n=[],r=[];for(const s of e??[])(vM(s,t)?n:r).push(s);return{online:n,offline:r}}function SW(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(w=>w.paired!==!1||w.met);if(!r.length)return{text:"no deck paired yet",tone:"idle"};const s=r.filter(w=>w.waiting),o=r.filter(w=>!w.waiting),l=s.filter(w=>xM(w.lastSeen,t)),{online:u,offline:d}=NW(o,t),f=[...d,...s.filter(w=>!l.includes(w))],h=u.length+l.length,m=u.filter(w=>{var k;return((k=w.last)==null?void 0:k.error)==="waiting for the other deck to accept this one"});if(h&&m.length===h)return{text:h===1?"1 deck found · waiting for them to accept":`${h} decks found · waiting for them to accept`,tone:"wait"};if(!h)return{text:f.length===1?"this deck cannot reach the one it is paired with":`this deck cannot reach any of its ${f.length} decks`,tone:"bad"};const g=h===1?"1 deck ready":`${h} decks ready`;return{text:f.length?`${g} · ${f.length} away`:g,tone:"ok"}}function jW(e,t,n){if(n)return"checking…";if(e==null)return"not checked yet";const r=gr(e,t);return r==="now"?"checked just now":`checked ${r}`}function p0(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 xM(e,t){return e!=null&&t-e<lx}function _W(e,t){if(e==null)return{text:"one-way · has not called yet",here:!1};const n=xM(e,t);return{text:n?"online · one-way, it calls in":`one-way · last online ${gr(e,t)}`,here:n}}function dS(e,t,n){return t?"online":e.lastSeen!=null?`last online ${gr(e.lastSeen,n)}`:e.waiting?"has not called yet":"never reached"}function EW(e,t){if(!e)return[];const n=[],r=new Set,s=(m,g)=>m.name.localeCompare(g.name,void 0,{numeric:!0}),o=e.aliases??{};for(const m of e.pending??[])!(m!=null&&m.fp)||r.has(m.fp)||(r.add(m.fp),n.push(CW(m,o,t)));const l=[],u=[];for(const m of e.peers??[]){const g=m.peerFp??m.fp;!g||r.has(g)||(r.add(g),!m.paired&&m.manual&&!m.met?u.push(TW(m,g,t)):l.push(RW(m,g,o,t)))}n.push(...$W(l).sort(s),...u.sort(s));const d=[];for(const m of e.strangers??[])!(m!=null&&m.fp)||r.has(m.fp)||(r.add(m.fp),d.push(AW(m,o,e.pairingMode)));n.push(...d.sort(s));const f=[];for(const m of e.declined??[])!(m!=null&&m.fp)||r.has(m.fp)||(r.add(m.fp),f.push(MW(m,o)));n.push(...f.sort(s));const h=new Map;for(const m of n)h.set(m.name,(h.get(m.name)??0)+1);for(const m of n)(h.get(m.name)??0)<2||!m.addr||(m.state=m.quiet||!m.state?m.addr:`${m.addr} · ${m.state}`,m.quiet=!1);return n}function CW(e,t,n){const r=Ed(t,e.fp,e.name||e.fp);return{fp:e.fp,...r,addr:e.addr??"",kind:"asks",state:`wants to pair · ${p0(e.at,n)}`,tone:"wait",here:!0,hint:`${r.name} at ${e.addr}${e.via==="tailscale"?", over Tailscale,":""} is waiting for an answer.`,...Cd(e.via)}}function TW(e,t,n){var o;const r=_d(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?cx(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.`,...Cd(e.via)}}function RW(e,t,n,r){var w,k,v,b;const s=_d(e.last,r),o=vM(e,r),l=e.addr?`${e.addr}:${e.port}`:"",u=e.waiting?_W(e.lastSeen,r):null,d=u?u.here:o,f=!u&&s?d?`online · ${cx(s)}`:`${cx(s)} · ${dS(e,d,r)}`:u?u.text:dS(e,d,r),h=(w=e.last)!=null&&w.error?f0[e.last.error]:null,m=!u&&d&&!((k=e.last)!=null&&k.error)&&!(((v=e.last)==null?void 0:v.done)??[]).length,g=e.manual&&!e.met?{name:l}:Ed(n,t,e.name||t);return{fp:t,...g,addr:e.addr??"",kind:"paired",state:f,quiet:m,tone:h?h.tone==="bad"?"bad":"wait":s?s.tone:d?"ok":"idle",here:u?u.here:o,...Cd(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 ${gr(e.lastSeen,r)}.`} Add its address with the + at the top of this section to reach it either way.`:`${g.name}${l?` at ${l}`:""}${(b=e.last)!=null&&b.error?` — ${e.last.error}`:""}${s!=null&&s.hint?` — ${s.hint}`:""}`}}function AW(e,t,n){const r=Ed(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.`,...Cd(e.via)}}function MW(e,t){const n=Ed(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 Ed(e,t,n){const r=t?e[t]:void 0;return r&&r!==n?{name:r,self:n}:{name:n}}function Cd(e){return e==="tailscale"?{via:"tailscale"}:{}}function cx(e){return e.text.replace(/ · .*$/,"")}function $W(e){const t=new Map;for(const r of e){const s=t.get(r.name);s?s.push(r):t.set(r.name,[r])}const n=[];for(const r of t.values()){const s=[...new Set(r.filter(o=>o.addr).map(o=>o.addr))];if(s.length>1){for(const o of s)n.push(hS(r.filter(l=>l.addr===o)));n.push(...r.filter(o=>!o.addr))}else n.push(hS(r))}return n}function hS(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 fS(e,t){return t?e.map(n=>t[n.fp]?{...n,name:t[n.fp]}:n):e}function pS(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 IW(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 OW(e,t){const n=e.filter(h=>h.kind==="asks"),r=e.filter(h=>h.kind!=="asks"),s=r.filter(h=>h.here),o=r.filter(h=>!h.here),l=o.filter(h=>h.tone==="bad").length,u=t||s.length===0,d=u?[...s,...o]:s,f=r.filter(h=>h.kind==="paired").length;return{asks:n,rest:r,live:s,folded:o,troubled:l,showFolded:u,shown:d,paired:f}}const bM=160,kM=140;function LW(){const[e,t]=x.useState(!1),n=x.useRef(0);return x.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),kM)},holdPeek:()=>window.clearTimeout(n.current),dropPeek:()=>{window.clearTimeout(n.current),t(!1)}}}const ux=5e3,NM=6e4;function St(e,t){if(t==null)return`Could not ${e} — the deck did not answer.`;const n=t.reason?FW(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 PW={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."},DW=new Set(["EACCES","EPERM"]);function FW(e,t){const n=PW[e];if(!n)return;const r=e==="prefs_unreadable"&&t?qW(t):void 0,s=t!=null&&t.code&&t.code!=="BADJSON"?` Error code: ${t.code}.`:"";return(r??n)+s}function qW({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&&!DW.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 ko(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}function BW(e,t){const[n,r]=x.useState(null),[s,o]=x.useState([]),[l,u]=x.useState(null),[d,f]=x.useState(null),h=x.useRef(null),m=x.useCallback(A=>Nd(h.current)?(h.current=A,u(A),!0):!1,[]),g=x.useCallback(()=>{h.current=null,b.current&&u(null)},[]),w=A=>{const L=_s(l,A);return{disabled:L.disabled,"aria-busy":L.busy}},[k,v]=x.useState(()=>Date.now()),b=x.useRef(!0),S=x.useRef(ux),_=x.useCallback(async()=>{var A,L;try{const[z,V]=await Promise.all([fetch("/api/lan").then($=>$.json()),fetch("/api/prefs").then($=>$.json())]);if(!b.current)return;z!=null&&z.ok&&r(z),V!=null&&V.ok&&o(Array.isArray((L=(A=V.prefs)==null?void 0:A.lan)==null?void 0:L.manual)?V.prefs.lan.manual:[]),S.current=(z==null?void 0:z.enabled)===!0?ux:NM}catch{}},[]);x.useEffect(()=>{b.current=!0;let A=0;const L=async()=>{v(Date.now()),await _(),b.current&&(A=window.setTimeout(L,S.current))};return L(),()=>{b.current=!1,window.clearTimeout(A)}},[_]);const j=x.useCallback(async()=>{const A=(n==null?void 0:n.enabled)===!0;if(m("switch"))try{const L=await ko("/api/prefs",{lan:{enabled:!A}});if(!b.current)return;L!=null&&L.ok?(f(null),A||t()):f(St(A?"turn this off":"turn this on",L)),await _()}catch{b.current&&f(St(A?"turn this off":"turn this on",null))}finally{g()}},[n==null?void 0:n.enabled,_,m,g,t]),E=x.useCallback(async(A,L,z)=>{if(!m(`${A}:${L}`))return null;let V=null;try{const $=await ko("/api/lan/peer",{action:A,fp:L});if(!b.current)return null;$!=null&&$.ok?(r($),f(null)):(V=St(z,$),f(V)),await _()}catch{V=St(z,null),b.current&&f(V)}finally{g()}return V},[_,m,g]),T=x.useCallback(async A=>{if(!m(`drop:${A}`))return null;let L=null;try{const z=await ko("/api/prefs",{lan:{manual:s.filter(V=>V!==A)}});if(!b.current)return null;z!=null&&z.ok?(f(null),e()):(L=St("stop dialling that address",z),f(L)),await _()}catch{L=St("stop dialling that address",null),b.current&&f(L)}finally{g()}return L},[s,_,e,m,g]),R=x.useCallback(async(A,L)=>{if(!m(`alias:${A}`))return"Something else is still being saved. Try again in a moment.";try{const z=await ko("/api/lan/peer",{action:"alias",fp:A,name:L});return b.current?z!=null&&z.ok?(r(z),null):St("rename that deck",z):null}catch{return St("rename that deck",null)}finally{g()}},[m,g]),M=x.useCallback(async A=>{if(!m(`check:${A}`))return null;try{const L=await ko("/api/lan/sync",{fp:A});return b.current?L!=null&&L.ok?(r(L),e(),null):(L==null?void 0:L.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.":St("check that deck",L):null}catch{return St("check that deck",null)}finally{g()}},[m,g,e]),O=x.useCallback(async()=>{if(m("check"))try{const A=await ko("/api/lan/sync",{});if(!b.current)return;A!=null&&A.ok?(r(A),f(null)):f(St("check the other decks",A)),e()}catch{b.current&&f(St("check the other decks",null))}finally{g()}},[m,g,e]);return{status:n,manual:s,now:k,busy:l,failure:d,dismissFailure:()=>f(null),pressProps:w,load:_,toggle:j,answer:E,dropAddress:T,rename:R,checkOne:M,checkNow:O}}function zW(e){const[t,n]=x.useState(null),r=x.useRef(0);return x.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=jl({armedFor:t,target:o.fp,armedAt:r.current,now:l,gapMs:Sl});if(u==="arm"){n(o.fp),r.current=l;return}u!=="ignore"&&(n(null),e("unpair",o.fp,"unpair that deck"))}}}function SM({title:e,steps:t,finish:n,aside:r,onClose:s}){const o=x.useRef(null),l=Et(s,{focusRef:o}),[u,d]=x.useState(0),f=u===t.length-1,h=t[u],m=k=>d(Math.max(0,Math.min(t.length-1,k))),g=k=>{k.key!=="ArrowRight"&&k.key!=="ArrowLeft"||(k.preventDefault(),k.stopPropagation(),m(k.key==="ArrowRight"?u+1:u-1))},w=()=>{if(!f){m(u+1);return}n?n.act():s()};return zt.createPortal(i.jsx("div",{className:"modal-backdrop",onClick:s,role:"presentation",children:i.jsxs("div",{ref:l,className:"modal guide",onClick:k=>k.stopPropagation(),onKeyDown:g,role:"dialog","aria-modal":"true","aria-labelledby":"guide-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{id:"guide-title",className:"modal-tool-name",children:e}),i.jsxs("span",{className:"modal-tool-id",children:[u+1," / ",t.length]})]}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[i.jsx("div",{className:"guide-stage",children:h.art},u),i.jsx("p",{className:"guide-line","aria-live":"polite",children:h.line}),i.jsx("p",{className:"guide-tip",children:h.tip??""}),i.jsxs("div",{className:"guide-foot",children:[i.jsx("div",{className:"guide-dots",children:t.map((k,v)=>i.jsx("button",{type:"button",className:"glyph-btn guide-dot","aria-label":`Step ${v+1} of ${t.length}`,"aria-current":v===u?"step":void 0,onClick:()=>m(v)},v))}),f&&r&&i.jsx("button",{type:"button",className:"ap-lan-word guide-aside",onClick:r.act,children:r.label}),u>0&&i.jsx("button",{type:"button",className:"btn",onClick:()=>m(u-1),children:"Back"}),i.jsx("button",{ref:o,type:"button",className:"btn primary",onClick:w,children:f?(n==null?void 0:n.label)??"Done":"Next"})]})]})]})}),document.body)}const dx={ok:"ga-ok",warn:"ga-warn",accent:"ga-accent",flight:"ga-flight"};function Tn({children:e}){return i.jsx("svg",{className:"guide-art",viewBox:"0 0 440 200","aria-hidden":!0,focusable:"false",children:e})}function Cn({x:e,y:t=34,w:n=176,h:r=132,label:s}){return i.jsxs(i.Fragment,{children:[s&&i.jsx("text",{x:e+2,y:t-9,className:"ga-cap",children:s}),i.jsx("rect",{x:e,y:t,width:n,height:r,rx:10,className:"ga-screen"})]})}function Hn({x:e,y:t,email:n,state:r,tone:s,bars:o}){return i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:e+3,cy:t-4,r:3,className:dx[s]}),i.jsx("text",{x:e+12,y:t,className:"ga-t ga-mono",children:n}),i.jsx("text",{x:e+12,y:t+16,className:`ga-s ${dx[s]}`,children:r}),o==null?void 0:o.map((l,u)=>i.jsxs("g",{children:[i.jsx("text",{x:e,y:t+40+u*18,className:"ga-s",children:u?"7d":"5h"}),i.jsx("rect",{x:e+22,y:t+35+u*18,width:96,height:4,rx:2,className:"ga-track"}),i.jsx("rect",{x:e+22,y:t+35+u*18,width:96*l/100,height:4,rx:2,className:"ga-accent"}),i.jsxs("text",{x:e+148,y:t+40+u*18,className:"ga-s ga-accent",textAnchor:"end",children:[l,"%"]})]},u))]})}function jM({x:e,y:t,on:n}){return i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:e,y:t,width:30,height:18,rx:9,className:n?"ga-switch-on":"ga-switch"}),i.jsx("circle",{cx:n?e+21:e+9,cy:t+9,r:6,className:n?"ga-knob-on":"ga-knob"})]})}function du({x:e,y:t,name:n,here:r=!0}){return i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:e+3,cy:t-4,r:3,className:r?"ga-ok":"ga-dim"}),i.jsx("text",{x:e+12,y:t,className:r?"ga-t":"ga-s",children:n})]})}function mS({x:e,y:t,on:n}){return n?i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:e,y:t,width:12,height:12,rx:3,className:"ga-accent"}),i.jsx("path",{d:`M${e+3} ${t+6.2}l2.3 2.3 4-4.6`,className:"ga-tick"})]}):i.jsx("rect",{x:e+.5,y:t+.5,width:11,height:11,rx:3,className:"ga-box"})}function gS({x:e,y:t,d:n}){return i.jsx("path",{d:n,transform:`translate(${e} ${t})`,className:"ga-glyph"})}function m0({x:e,y:t}){return i.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 g0(){return i.jsxs(i.Fragment,{children:[i.jsx("circle",{r:9,className:"ga-key-bed"}),i.jsxs("g",{transform:"translate(-6 -6) scale(0.857)",className:"ga-key",children:[i.jsx("circle",{cx:4.6,cy:7,r:2.6}),i.jsx("path",{d:"M7.2 7h5.2M10.6 7v2.2M12.4 7v1.6"})]})]})}function Co({x:e,y:t,w:n,title:r,sub:s,tone:o}){return i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:e,y:t,width:n,height:40,rx:8,className:"ga-screen"}),i.jsx("rect",{x:e+6,y:t+10,width:3,height:20,rx:1.5,className:dx[o]}),i.jsx("text",{x:e+16,y:t+17,className:"ga-t ga-strong",children:r}),i.jsx("text",{x:e+16,y:t+31,className:"ga-s",children:s})]})}function Io({x:e,y:t,label:n,live:r}){return i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:e,y:t,width:46,height:20,rx:10,className:r?"ga-chip-live":"ga-chip"}),i.jsx("text",{x:e+23,y:t+14,className:"ga-s ga-mono",textAnchor:"middle",children:n})]})}function Zu({x:e,y:t}){return i.jsxs(i.Fragment,{children:[i.jsx("text",{x:e,y:t,className:"ga-cap",children:"LOCAL NETWORK"}),i.jsx(jM,{x:e+118,y:t-13,on:!0})]})}function UW(){return i.jsxs(Tn,{children:[i.jsx("rect",{x:14,y:14,width:206,height:172,rx:10,className:"ga-screen"}),i.jsx("text",{x:28,y:38,className:"ga-t ga-strong",children:"Sessions"}),i.jsx("text",{x:206,y:38,className:"ga-s ga-warn",textAnchor:"end",children:"1 waiting"}),i.jsx("rect",{x:20,y:50,width:194,height:42,rx:6,className:"ga-bed-warn"}),i.jsx("circle",{cx:33,cy:64,r:7,className:"ga-ring-warn ga-ping"}),i.jsx("circle",{cx:33,cy:64,r:3.5,className:"ga-warn"}),i.jsx("text",{x:44,y:68,className:"ga-t",children:"api-server"}),i.jsx("text",{x:44,y:83,className:"ga-s ga-warn",children:"waiting 6m · Bash"}),i.jsx("circle",{cx:33,cy:108,r:3.5,className:"ga-flight"}),i.jsx("text",{x:44,y:112,className:"ga-t",children:"docs-site"}),i.jsx("text",{x:44,y:127,className:"ga-s",children:"running · 12 tools"}),i.jsx("circle",{cx:33,cy:150,r:3.5,className:"ga-ok"}),i.jsx("text",{x:44,y:154,className:"ga-t",children:"billing"}),i.jsx("text",{x:44,y:169,className:"ga-s",children:"done · $0.84"}),i.jsx("path",{d:"M216 71C234 71 230 100 244 100",className:"ga-arc"}),i.jsx("path",{d:"M239 96l5 4-5 4",className:"ga-arrow"}),i.jsx("rect",{x:248,y:44,width:178,height:112,rx:10,className:"ga-screen"}),i.jsx("text",{x:262,y:64,className:"ga-cap",children:"API-SERVER"}),i.jsx("line",{x1:248,y1:74,x2:426,y2:74,className:"ga-line"}),i.jsx("text",{x:262,y:96,className:"ga-s ga-mono",children:"Bash(npm test)"}),i.jsx("text",{x:262,y:116,className:"ga-t ga-mono ga-warn",children:"Allow this command?"}),i.jsx("text",{x:262,y:136,className:"ga-s ga-mono",children:"> 1. Yes 2. No"})]})}function HW(){return i.jsxs(Tn,{children:[i.jsx("path",{d:"M136 100C166 100 166 38 196 38",className:"ga-edge ga-flow"}),i.jsx("path",{d:"M136 100H196",className:"ga-edge ga-flow"}),i.jsx("path",{d:"M136 100C166 100 166 162 196 162",className:"ga-edge-done"}),i.jsx("path",{d:"M308 38H326M308 100H326",className:"ga-edge"}),i.jsx(Co,{x:20,y:80,w:116,title:"main",sub:"Opus 5 · 9 tools",tone:"accent"}),i.jsx(Co,{x:196,y:18,w:112,title:"explore",sub:"Haiku · 14 tools",tone:"flight"}),i.jsx(Co,{x:196,y:80,w:112,title:"tests",sub:"Sonnet · 6 tools",tone:"flight"}),i.jsx(Co,{x:196,y:142,w:112,title:"review",sub:"done · 38s",tone:"ok"}),i.jsx(Io,{x:326,y:28,label:"Read"}),i.jsx(Io,{x:380,y:28,label:"Grep",live:!0}),i.jsx(Io,{x:326,y:90,label:"Bash",live:!0})]})}function yS({x:e,y:t,label:n,pct:r,note:s}){return i.jsxs(i.Fragment,{children:[i.jsx("text",{x:e,y:t,className:"ga-s",children:n}),i.jsxs("text",{x:e+194,y:t,className:"ga-s ga-accent",textAnchor:"end",children:[r,"%"]}),i.jsx("rect",{x:e,y:t+7,width:194,height:5,rx:2.5,className:"ga-track"}),i.jsx("rect",{x:e,y:t+7,width:194*r/100,height:5,rx:2.5,className:"ga-accent"}),i.jsx("text",{x:e,y:t+26,className:"ga-s",children:s})]})}function WW(){return i.jsxs(Tn,{children:[i.jsx("rect",{x:14,y:30,width:172,height:140,rx:10,className:"ga-screen"}),i.jsx("text",{x:30,y:56,className:"ga-cap",children:"THIS SESSION"}),i.jsx("text",{x:30,y:98,className:"ga-big",children:"$3.66"}),i.jsx("text",{x:30,y:122,className:"ga-s",children:"Opus 5 · 1.2M tokens"}),i.jsx("text",{x:30,y:150,className:"ga-s",children:"$21.40 today"}),i.jsx("rect",{x:200,y:30,width:226,height:140,rx:10,className:"ga-screen"}),i.jsx("text",{x:216,y:56,className:"ga-cap",children:"CLAUDE QUOTA"}),i.jsx(yS,{x:216,y:80,label:"5-hour window",pct:24,note:"resets in 53m"}),i.jsx(yS,{x:216,y:124,label:"7-day window",pct:61,note:"resets in 4d"})]})}function VW(){return i.jsxs(Tn,{children:[i.jsx("rect",{x:14,y:40,width:172,height:120,rx:10,className:"ga-canvas"}),i.jsx(Co,{x:30,y:80,w:140,title:"tests",sub:"Sonnet 5 · 6 tools",tone:"flight"}),i.jsx(m0,{x:156,y:106}),i.jsx("path",{d:"M170 92C186 92 184 60 200 60",className:"ga-arc"}),i.jsx("path",{d:"M195 56l5 4-5 4",className:"ga-arrow"}),i.jsx(Cn,{x:200,y:22,w:226,h:160}),i.jsx("text",{x:214,y:46,className:"ga-t ga-strong",children:"tests"}),i.jsx("text",{x:412,y:46,className:"ga-s",textAnchor:"end",children:"Sonnet 5 · 38s"}),i.jsx("line",{x1:200,y1:56,x2:426,y2:56,className:"ga-line"}),i.jsx("text",{x:214,y:76,className:"ga-cap",children:"PROMPT"}),i.jsx("text",{x:214,y:92,className:"ga-t",children:"Run the suite and fix what fails"}),i.jsx("text",{x:214,y:116,className:"ga-cap",children:"TOOLS · 6"}),i.jsx(Io,{x:214,y:122,label:"Read"}),i.jsx(Io,{x:266,y:122,label:"Edit"}),i.jsx(Io,{x:318,y:122,label:"Bash",live:!0}),i.jsx("text",{x:214,y:164,className:"ga-cap",children:"TOKENS"}),i.jsx("text",{x:214,y:178,className:"ga-s ga-mono",children:"41k in · 2.1k out · $0.12"})]})}function GW(){const e=[18,24,28,14,22,26,30,16,24,28,20,26];return i.jsxs(Tn,{children:[i.jsx(Cn,{x:14,y:20,w:412,h:160}),i.jsx("text",{x:28,y:44,className:"ga-t ga-strong",children:"This machine"}),i.jsx("text",{x:412,y:44,className:"ga-s",textAnchor:"end",children:"12 cores · up 10d"}),i.jsx("line",{x1:14,y1:56,x2:426,y2:56,className:"ga-line"}),i.jsx("text",{x:28,y:76,className:"ga-cap",children:"CORES"}),e.map((t,n)=>i.jsxs("g",{children:[i.jsx("rect",{x:28+n*15,y:82,width:10,height:30,rx:2,className:"ga-track"}),i.jsx("rect",{x:28+n*15,y:112-t,width:10,height:t,rx:2,className:"ga-accent"})]},n)),i.jsx("text",{x:28,y:136,className:"ga-cap",children:"MEMORY"}),i.jsx("rect",{x:28,y:143,width:178,height:5,rx:2.5,className:"ga-track"}),i.jsx("rect",{x:28,y:143,width:105,height:5,rx:2.5,className:"ga-accent"}),i.jsx("text",{x:28,y:165,className:"ga-s",children:"18.9 GB of 32.0 GB"}),i.jsx("text",{x:240,y:76,className:"ga-cap",children:"THERMAL"}),i.jsx("text",{x:240,y:100,className:"ga-big",children:"66 °C"}),i.jsx("text",{x:240,y:118,className:"ga-s ga-ok",children:"running at full speed"}),i.jsx("text",{x:240,y:142,className:"ga-cap",children:"BUSIEST PROCESSES"}),i.jsx("text",{x:240,y:160,className:"ga-s ga-mono",children:"node · claude"}),i.jsx("text",{x:412,y:160,className:"ga-s ga-mono",textAnchor:"end",children:"38%"}),i.jsx("text",{x:240,y:176,className:"ga-s ga-mono",children:"esbuild"}),i.jsx("text",{x:412,y:176,className:"ga-s ga-mono",textAnchor:"end",children:"21%"})]})}function KW(){return i.jsxs(Tn,{children:[i.jsx("rect",{x:14,y:40,width:188,height:120,rx:10,className:"ga-screen"}),i.jsx("text",{x:28,y:60,className:"ga-cap",children:"~/MY-PROJECT"}),i.jsx("line",{x1:14,y1:70,x2:202,y2:70,className:"ga-line"}),i.jsxs("text",{x:28,y:100,className:"ga-t ga-mono",children:[i.jsx("tspan",{className:"ga-accent",children:"$"})," claude"]}),i.jsx("rect",{x:86,y:90,width:7,height:13,className:"ga-caret ga-blink"}),i.jsx("text",{x:28,y:130,className:"ga-s ga-mono",children:"or: codex"}),i.jsx("path",{d:"M210 100H238",className:"ga-arc"}),i.jsx("path",{d:"M233 95l6 5-6 5",className:"ga-arrow"}),i.jsx("rect",{x:250,y:40,width:176,height:120,rx:10,className:"ga-canvas"}),i.jsx("g",{className:"ga-pop",children:i.jsx(Co,{x:278,y:80,w:120,title:"my-project",sub:"Opus 5 · live",tone:"accent"})})]})}function YW(){return i.jsxs(Tn,{children:[i.jsx(Cn,{x:14,y:16,w:232,h:170}),i.jsx("text",{x:28,y:40,className:"ga-t ga-strong",children:"Claude accounts"}),i.jsx(gS,{x:196,y:33,d:"M7 2.2v9.6M2.2 7h9.6"}),i.jsx(gS,{x:220,y:33,d:"M3.3 10.7L10.7 3.3M5.2 3.3h5.5v5.5"}),i.jsx("line",{x1:14,y1:52,x2:246,y2:52,className:"ga-line"}),i.jsx(Hn,{x:28,y:74,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),i.jsx("rect",{x:190,y:62,width:44,height:18,rx:9,className:"ga-accent"}),i.jsx("text",{x:212,y:74,className:"ga-s ga-on-accent",textAnchor:"middle",children:"active"}),i.jsx("line",{x1:14,y1:140,x2:246,y2:140,className:"ga-line"}),i.jsx(Hn,{x:28,y:160,email:"personal@me.dev",state:"signed in",tone:"ok"}),i.jsx("rect",{x:188,y:148,width:46,height:18,rx:9,className:"ga-chip"}),i.jsx("text",{x:211,y:160,className:"ga-s",textAnchor:"middle",children:"switch"}),i.jsx(m0,{x:221,y:161}),i.jsx("path",{d:"M250 40C270 40 262 78 282 78",className:"ga-arc"}),i.jsx("path",{d:"M277 74l5 4-5 4",className:"ga-arrow"}),i.jsx(Cn,{x:282,y:62,w:144,h:64,label:"ANOTHER MACHINE"}),i.jsx("g",{className:"ga-pop",children:i.jsx(Hn,{x:296,y:92,email:"work@team.dev",state:"shared here",tone:"ok"})})]})}function XW(){return i.jsxs(Tn,{children:[i.jsx(Cn,{x:14,label:"THIS MACHINE"}),i.jsx(Zu,{x:28,y:60}),i.jsx("g",{className:"ga-swap-out",children:i.jsx(Hn,{x:28,y:98,email:"work@team.dev",state:"login expired",tone:"warn"})}),i.jsx("g",{className:"ga-swap-in",children:i.jsx(Hn,{x:28,y:98,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),i.jsx(Cn,{x:250,label:"ANOTHER MACHINE"}),i.jsx(Zu,{x:264,y:60}),i.jsx(Hn,{x:264,y:98,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),i.jsx("path",{d:"M246 120C234 80 206 80 194 120",className:"ga-arc"}),i.jsx("g",{className:"ga-travel ga-travel-low",transform:"translate(220 90)",children:i.jsx(g0,{})})]})}const ZW=[{art:i.jsx(UW,{}),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:i.jsx(HW,{}),line:"Every agent and subagent is a node. Tool calls light up as they run."},{art:i.jsx(VW,{}),line:"Double-click any node: its prompt, every tool call, tokens and timing."},{art:i.jsx(WW,{}),line:"What each session costs, and how much quota is left."},{art:i.jsx(GW,{}),line:"Cores, memory and heat while the agents run, and what is hogging them."},{art:i.jsx(YW,{}),line:"Several Claude accounts: switch, add one, share one to another machine."},{art:i.jsx(XW,{}),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:i.jsx(KW,{}),line:"Run claude or codex in any folder. It shows up here on its own."}];function JW(){return i.jsxs(Tn,{children:[i.jsx(Cn,{x:14,label:"THIS MACHINE"}),i.jsx(Hn,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"}),i.jsx("rect",{x:40,y:94,width:86,height:20,rx:10,className:"ga-pill-warn"}),i.jsx("text",{x:83,y:108,className:"ga-s ga-warn",textAnchor:"middle",children:"sign in again"}),i.jsx("line",{x1:198,y1:100,x2:242,y2:100,className:"ga-off"}),i.jsx(Cn,{x:250,label:"ANOTHER MACHINE"}),i.jsx(Hn,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]})]})}function QW(){return i.jsxs(Tn,{children:[i.jsx(Cn,{x:14,label:"THIS MACHINE"}),i.jsx(Zu,{x:28,y:60}),i.jsx(du,{x:28,y:92,name:"Ana's MacBook"}),i.jsx(du,{x:28,y:114,name:"Dorin's PC"}),i.jsx(Cn,{x:250,label:"ANOTHER MACHINE"}),i.jsx(Zu,{x:264,y:60}),i.jsx(du,{x:264,y:92,name:"Your MacBook"}),i.jsx(du,{x:264,y:114,name:"Dorin's PC"}),i.jsx("line",{x1:196,y1:100,x2:244,y2:100,className:"ga-arc"}),i.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping"}),i.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping ga-ping-2"}),i.jsx("circle",{cx:220,cy:100,r:3,className:"ga-accent"})]})}function e7(){return i.jsxs(Tn,{children:[i.jsx("rect",{x:90,y:18,width:260,height:164,rx:10,className:"ga-screen"}),i.jsx("text",{x:106,y:42,className:"ga-t ga-strong",children:"This deck on the network"}),i.jsx("line",{x1:90,y1:54,x2:350,y2:54,className:"ga-line"}),i.jsx("text",{x:106,y:76,className:"ga-cap",children:"SHARE THESE ACCOUNTS"}),i.jsx(mS,{x:106,y:88,on:!0}),i.jsx("text",{x:126,y:98,className:"ga-t ga-mono",children:"work@team.dev"}),i.jsx(mS,{x:106,y:112}),i.jsx("text",{x:126,y:122,className:"ga-s ga-mono",children:"personal@me.dev"}),i.jsx("text",{x:106,y:150,className:"ga-cap",children:"PAIRING"}),i.jsx("text",{x:106,y:168,className:"ga-s",children:"Say yes to every deck that asks"}),i.jsx(jM,{x:304,y:157,on:!0}),i.jsx(m0,{x:115,y:97})]})}function t7(){return i.jsxs(Tn,{children:[i.jsx(Cn,{x:14,label:"THIS MACHINE"}),i.jsx("g",{className:"ga-swap-out",children:i.jsx(Hn,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"})}),i.jsx("g",{className:"ga-swap-in",children:i.jsx(Hn,{x:28,y:64,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),i.jsx(Cn,{x:250,label:"ANOTHER MACHINE"}),i.jsx(Hn,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),i.jsx("path",{d:"M246 96C234 56 206 56 194 96",className:"ga-arc"}),i.jsx("g",{className:"ga-travel",transform:"translate(220 66)",children:i.jsx(g0,{})})]})}const n7=[{art:i.jsx(JW,{}),line:"A login can expire on one machine while it still works on another."},{art:i.jsx(QW,{}),line:"Both decks are on. They find each other and ask to pair.",tip:"Not showing up? The + in the section reaches a machine by address or invite."},{art:i.jsx(e7,{}),line:"Tick which logins this machine may hand out. Nothing is shared until you do."},{art:i.jsx(t7,{}),line:"An expired login is copied from a paired machine within a minute."}];function r7(){return i.jsxs("svg",{className:"guide-art",viewBox:"0 0 232 60","aria-hidden":!0,focusable:"false",children:[i.jsx("rect",{x:1,y:14,width:78,height:42,rx:7,className:"ga-screen"}),i.jsx("circle",{cx:13,cy:29,r:3,className:"ga-warn"}),i.jsx("rect",{x:21,y:27,width:46,height:4,rx:2,className:"ga-track"}),i.jsx("rect",{x:13,y:39,width:40,height:3,rx:1.5,className:"ga-track"}),i.jsx("rect",{x:153,y:14,width:78,height:42,rx:7,className:"ga-screen"}),i.jsx("circle",{cx:165,cy:29,r:3,className:"ga-ok"}),i.jsx("rect",{x:173,y:27,width:46,height:4,rx:2,className:"ga-track"}),i.jsx("rect",{x:165,y:39,width:40,height:3,rx:1.5,className:"ga-accent"}),i.jsx("path",{d:"M150 36C138 6 94 6 82 36",className:"ga-arc"}),i.jsx("g",{transform:"translate(116 13)",children:i.jsx(g0,{})})]})}const s7={panel:"Nothing here is stuck: whoever pastes an invite is the one dialling out. Ask them for one and paste it behind the + 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."},a7=1600;function _M({reach:e,where:t}){const[n,r]=x.useState(!1),s=x.useRef(!0);x.useEffect(()=>()=>{s.current=!1},[]);const o=(e==null?void 0:e.steps)??[],l=x.useCallback(async()=>{await ja(o.join(`
81
- `))&&s.current&&(r(!0),window.setTimeout(()=>{s.current&&r(!1)},a7))},[o]);if(!(e!=null&&e.blocked))return null;const u=e.shell==="sh";return i.jsxs("div",{className:"ap-lan-reach",children:[i.jsx("p",{className:"lan-warn",children:e.text}),i.jsx("p",{className:"lan-note",children:s7[t]}),o.length>0&&i.jsxs("details",{className:"ap-lan-reach-fix",children:[i.jsx("summary",{children:"or let them find this deck on their own"}),i.jsxs("p",{className:"lan-note",children:[u?i.jsx(i.Fragment,{children:"Run this in a terminal on this machine, then restart the deck."}):i.jsxs(i.Fragment,{children:["Run this in PowerShell ",i.jsx("strong",{children:"as Administrator"}),", then restart the deck."]}),e.category==="Public"&&i.jsx(i.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&&i.jsxs(i.Fragment,{children:[" ",e.unsure]})]}),i.jsx("pre",{className:"ap-lan-cmd",children:i.jsx("code",{children:o.join(`
82
- `)})}),i.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 o7(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 i7(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 rp(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}const l7={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."},c7={not_running:"This deck is not on the network yet. Turn Local network on, then make one."};function wS(e,t,n){return(t==null?void 0:t.reason)&&e[t.reason]||St(n,t)}function u7({status:e,manual:t,startWith:n,onClose:r,onChanged:s}){const o=x.useRef(null),l=x.useRef(null),u=x.useRef(null),d=e.pairingMode==="invite",f=Et(r,{focusRef:d?l:o}),[h,m]=x.useState(""),[g,w]=x.useState(""),[k,v]=x.useState(null),[b,S]=x.useState(null),[_,j]=x.useState(null),[E,T]=x.useState(null),[R,M]=x.useState(()=>Date.now());x.useEffect(()=>{const G=window.setInterval(()=>M(Date.now()),1e3);return()=>window.clearInterval(G)},[]);const O=x.useRef(!0);x.useEffect(()=>()=>{O.current=!1},[]);const I=x.useRef(null),A=x.useCallback(G=>Nd(I.current)?(I.current=G,j(G),!0):!1,[]),L=x.useCallback(()=>{I.current=null,O.current&&j(null)},[]),z=G=>{const U=_s(_,G);return{disabled:U.disabled,"aria-busy":U.busy}},V=G=>(k==null?void 0:k.field)===G?{"aria-invalid":!0,"aria-describedby":"lan-add-failure"}:{},$=G=>v(U=>U&&U.field===G?null:U),P=x.useCallback(async()=>{if(d)return;const G=o7(h);if(!G){v({text:d7(h),field:"addr"});return}const U=`${G.addr}:${G.port}`,Z=e.peers.find(H=>H.addr===G.addr&&H.port===G.port&&H.paired);if(Z){v({text:`Already paired with ${Z.name} at that address.`,field:"addr"});return}if(t.includes(U)){v({text:"This deck already calls that address.",field:"addr"});return}if(A("add"))try{const H=await rp("/api/prefs",{lan:{manual:[...t,U]}});if(!O.current)return;H!=null&&H.ok?(v(null),m(""),s(),r()):v({text:St("add that address",H),field:"addr"})}catch{O.current&&v({text:St("add that address",null),field:"addr"})}finally{L()}},[h,d,t,e.peers,s,r,A,L]),F=x.useCallback(async G=>{if(!A(`invite:${G}`))return;const U=G==="make"?"make an invite":"cancel that invite";try{const Z=await rp("/api/lan/invite",{action:G});if(!O.current)return;Z!=null&&Z.ok?(v(null),S(null),s()):v({text:wS(c7,Z,U)})}catch{O.current&&v({text:St(U,null)})}finally{L()}},[s,A,L]),Y=x.useCallback(async()=>{const G=g.trim();if(!(!G||!A("join"))){T(null);try{const U=await rp("/api/lan/invite",{action:"join",token:G});if(!O.current)return;U!=null&&U.ok?(w(""),v(null),s(),r()):(U==null?void 0:U.reason)==="unreachable"&&Array.isArray(U.tried)&&U.tried.length?(T(U.tried),v(null)):(T(null),v({text:wS(l7,U,"use that invite"),field:"join"}))}catch{O.current&&v({text:St("use that invite",null),field:"join"})}finally{L()}}},[g,s,r,A,L]),K=x.useCallback(async(G,U)=>{try{await navigator.clipboard.writeText(G),S(U),window.setTimeout(()=>{O.current&&S(Z=>Z===U?null:Z)},1600)}catch{v({text:"Could not copy it — select the text and copy it by hand."})}},[]),D=e.invite&&e.invite.expiresAt>R?e.invite:null,W=x.useRef(!1);x.useEffect(()=>{n!=="invite"||W.current||D||(W.current=!0,F("make"))},[n,D,F]);const B=x.useRef(!1);x.useEffect(()=>{var G;n!=="invite"||B.current||!D||(B.current=!0,(G=u.current)==null||G.focus())},[n,D]);const X=e.port!=null?(e.addrs??[]).map(G=>`${G}:${e.port}`):[];return zt.createPortal(i.jsx("div",{className:"modal-backdrop",onClick:r,role:"presentation",children:i.jsxs("div",{ref:f,className:"modal lan-add",onClick:G=>G.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-add-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"lan-add-title",className:"modal-tool-name",children:"Add a deck"})}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{className:"glyph-btn",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[k&&i.jsxs("div",{className:"ap-failure",role:"alert",children:[i.jsx("span",{id:"lan-add-failure",className:"ap-failure-text",children:k.text}),i.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>v(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),i.jsx(_M,{reach:e.reach,where:"dialog"}),d&&i.jsx("div",{className:"modal-section",children:i.jsx("p",{className:"lan-note",children:"Adding by address is off while this deck pairs only by invite."})}),!d&&i.jsxs("div",{className:"modal-section",children:[i.jsx("h3",{className:"lan-h",children:"By address"}),i.jsxs("div",{className:"ap-lan-row",children:[i.jsx("input",{ref:o,className:"ap-manage-input ap-lan-input","aria-label":"Another deck's address",value:h,placeholder:"192.168.1.5:54340",spellCheck:!1,...V("addr"),onChange:G=>{m(G.target.value),$("addr")},onKeyDown:G=>{G.key==="Enter"&&P()}}),h.trim()!==""&&i.jsx("button",{type:"button",className:"ap-manage-btn",...z("add"),onClick:()=>void P(),title:"Add it to the decks this one calls, starting now.",children:"add"})]}),i.jsx("p",{className:"lan-note",children:"This deck calls that address until somebody there accepts."}),e.port!=null&&X.length>0&&i.jsxs("p",{className:"lan-note",children:["They type this deck’s own address into the same field on theirs:"," ",X.map((G,U)=>i.jsxs("span",{children:[U>0&&" or ",i.jsx("code",{className:"ap-lan-code",children:G})]},G)),i.jsx("button",{type:"button",className:"ap-lan-word lan-copy",...z("copy:mine"),onClick:()=>void K(X.join(" "),"mine"),title:"Copy this deck's address, to send to whoever is adding it",children:b==="mine"?"copied":"copy"})]})]}),i.jsxs("div",{className:"modal-section",children:[i.jsxs("h3",{className:"lan-h",children:["With an invite",!D&&i.jsx("button",{type:"button",className:"ap-lan-word lan-h-act",...z("invite:make"),onClick:()=>void F("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"})]}),i.jsxs("div",{className:"ap-lan-row",children:[i.jsx("input",{ref:l,className:"ap-manage-input ap-lan-input","aria-label":"An invite you were sent",value:g,placeholder:"paste one you were sent",spellCheck:!1,...V("join"),onChange:G=>{w(G.target.value),T(null),$("join")},onKeyDown:G=>{G.key==="Enter"&&Y()}}),g.trim()!==""&&i.jsx("button",{type:"button",className:"ap-manage-btn",...z("join"),onClick:()=>void Y(),title:"Reach that deck and pair with it. Nobody has to press anything there.",children:_==="join"?"joining…":"join"})]}),i.jsx("p",{className:"lan-note",children:"Pasting one pairs both decks on the spot — nobody has to accept."}),E&&i.jsxs("div",{className:"ap-lan-tried",children:[i.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."}),E.map(G=>i.jsxs("span",{className:"ap-lan-tried-row",children:[i.jsx("code",{className:"ap-lan-code",children:G.addr}),i.jsx("span",{className:"ap-lan-bad",children:G.why})]},G.addr))]}),D&&i.jsxs("div",{className:"ap-lan-invite",children:[i.jsxs("div",{className:"ap-lan-invite-head",children:[i.jsx("span",{className:"ap-lan-invite-title",children:"Send this to them"}),i.jsxs("span",{className:"ap-lan-invite-left",id:"lan-invite-left",children:[i7(D.expiresAt,R)," left"]})]}),i.jsx("code",{className:"ap-lan-token",children:D.token}),i.jsxs("div",{className:"ap-lan-acts",children:[i.jsx("button",{type:"button",className:"ap-manage-btn",ref:u,...z("copy:invite"),"aria-label":b==="invite"?"Invite copied":"Copy invite","aria-describedby":"lan-invite-left",onClick:()=>void K(D.token,"invite"),title:"Copy it, and send it however you already talk to them",children:b==="invite"?"copied":"copy"}),i.jsx("button",{type:"button",className:"ap-manage-btn",...z("invite:withdraw"),onClick:()=>void F("withdraw"),title:"Cancel it. Anybody already holding the text can no longer use it.",children:"cancel"})]}),i.jsx("p",{className:"lan-warn",children:"Anyone who gets this text can pair with this deck until it runs out."})]})]})]})]})}),document.body)}function d7(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 h7({asks:e,pressProps:t,answer:n}){return i.jsx("div",{className:"ap-lan-asks",role:"alert",children:e.map(r=>i.jsxs("div",{className:"ap-lan-ask",children:[i.jsxs("span",{className:"ap-lan-ask-what",children:[i.jsx("strong",{className:"ap-lan-peer-name",children:r.name})," at ",i.jsx("code",{className:"ap-lan-code",children:r.addr})," wants to pair"]}),i.jsxs("span",{className:"ap-lan-ask-fp",children:["fingerprint ",i.jsx("code",{className:"ap-lan-code",children:r.fp})]}),i.jsxs("span",{className:"ap-lan-ask-acts",children:[i.jsx("button",{type:"button",className:"ap-manage-btn",...t(`accept:${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"}),i.jsx("button",{type:"button",className:"ap-manage-btn",...t(`dismiss:${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 f7({rows:e,pairingMode:t,armed:n,pressProps:r,answer:s,dropAddress:o,onUnpair:l,onOpenPeer:u,onInvite:d}){return i.jsx("ul",{className:"ap-lan-here",children:e.map((f,h)=>i.jsxs("li",{className:"ap-lan-who","data-tone":f.tone,children:[i.jsx("i",{className:f.here?"ap-pulse":"ap-dot","aria-hidden":!0}),i.jsxs("span",{className:"ap-lan-who-name","aria-hidden":!0,children:[f.name,f.via==="tailscale"&&i.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]}),i.jsx("button",{type:"button",className:"ap-lan-who-open","aria-haspopup":"dialog","aria-describedby":`lan-who-state-${h}`,onClick:()=>u(f.fp),children:i.jsxs("span",{className:"vis-hidden",children:[f.name,f.via==="tailscale"?", over Tailscale":"",", details"]})}),i.jsx("span",{id:`lan-who-state-${h}`,className:f.quiet?"vis-hidden":"ap-lan-who-when",children:f.state}),f.kind==="nearby"&&t!=="invite"&&i.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...r(`accept:${f.fp}`),onClick:()=>void s("accept",f.fp,"reach that deck"),"aria-label":`Ask ${f.name} to pair`,title:`Send ${f.name} a request. Somebody at that machine has to accept it before anything is shared. Its fingerprint is ${f.fp}.`,children:"ask"}),(f.kind==="nearby"||f.kind==="declined")&&t==="invite"&&i.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do","aria-haspopup":"dialog",onClick:d,"aria-label":`Invite ${f.name} to pair`,title:`This deck pairs only by invite. Make one and send it to whoever is at ${f.name}.`,children:"invite"}),f.kind==="paired"&&i.jsx("button",{type:"button",className:`ap-manage-btn ap-lan-do danger${n===f.fp?" armed":""}`,...r(`unpair:${f.fp}`),onClick:()=>l(f),"aria-label":n===f.fp?`Confirm unpairing ${f.name}`:`Unpair ${f.name}`,title:n===f.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===f.fp?"confirm":"unpair"}),f.kind==="dialling"&&i.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...r(`drop:${f.fp}`),onClick:()=>void o(f.fp),"aria-label":`Stop dialling ${f.name}`,title:"Stop trying this address. Nothing was ever paired here.",children:"stop"}),f.kind==="declined"&&t!=="invite"&&i.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...r(`allow:${f.fp}`),onClick:()=>void s("allow",f.fp,"let that deck ask again"),"aria-label":`Let ${f.name} ask again`,title:"Take the no back. That deck is still trying, so the request comes round again on its own.",children:"allow"})]},`${f.kind}:${f.fp}`))})}function p7(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 m7({on:e,status:t}){return i.jsxs(i.Fragment,{children:[e&&i.jsx(_M,{reach:t==null?void 0:t.reach,where:"panel"}),e&&(t==null?void 0:t.deaf)&&i.jsx("p",{className:"ap-lan-fine",children:t.deaf}),e&&(t==null?void 0:t.lanTunneled)&&i.jsx("p",{className:"ap-lan-fine",children:p7(t)})]})}const g7=6;function y7({anchorId:e,id:t,rows:n,onHold:r,onLet:s}){const o=x.useRef(null),l=n.filter(g=>g.kind==="paired"),u=l.filter(g=>g.here),d=u.slice(0,g7),f=l.length-u.length,h=u.length>d.length?`and ${u.length-d.length} more`:f>0?`${f} not on right now`:null,m=x.useCallback(()=>{const g=o.current,w=document.getElementById(e);if(!g||!w)return;const k=l0(w.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 x.useLayoutEffect(()=>{m()}),x.useEffect(()=>(window.addEventListener("scroll",m,!0),window.addEventListener("resize",m),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}),[m]),zt.createPortal(i.jsxs("div",{ref:o,id:t,className:"ap-peek",role:"tooltip",onPointerEnter:r,onPointerLeave:s,children:[i.jsx("p",{className:"ap-peek-title",children:u.length?"On the network now":"Nobody on the network"}),d.length>0&&i.jsx("div",{className:"ap-peek-list",children:d.map(g=>i.jsxs("span",{className:"ap-peek-who",children:[i.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),i.jsxs("span",{children:[g.name,g.via==="tailscale"&&i.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]})]},`${g.kind}:${g.fp}`))}),h&&i.jsx("p",{className:"ap-peek-rest",children:h})]}),document.body)}function w7({entry:e,rows:t,onOpen:n,peek:r,openPeek:s,shutPeek:o,holdPeek:l,dropPeek:u}){return i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",id:"ap-lan-entry",className:"ap-nav",onClick:()=>{u(),n()},"aria-describedby":r?"ap-lan-peek":void 0,onPointerEnter:d=>{d.pointerType==="mouse"&&s(bM)},onPointerLeave:o,onFocus:d=>{d.target.matches(":focus-visible")&&s(0)},onBlur:o,children:[i.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:[i.jsx("rect",{x:"1.8",y:"2.3",width:"10.4",height:"7.2",rx:"1.2"}),i.jsx("path",{d:"M5 11.9h4M7 9.5v2.4"})]}),i.jsxs("span",{className:"ap-nav-text",children:[i.jsx("span",{className:"ap-nav-name",children:"Local network"}),i.jsxs("span",{className:"ap-nav-state","data-tone":e.tone,children:[e.live&&i.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),e.text]})]}),i.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:i.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),r&&i.jsx(y7,{anchorId:"ap-lan-entry",id:"ap-lan-peek",rows:t,onHold:l,onLet:o})]})}function v7(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 x7(e,t,n){const r=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:r,note:null,tone:"idle"};if(!e.alive){const s=t&&!t.alive?"neither copy works — sign in again here":null;return{there:"broken there",here:r,note:s,tone:s?"bad":"idle"}}return t?t.alive?{there:"works there",here:r,note:null,tone:t.shareable===!1?"idle":"ok"}:n?{there:"works there",here:r,note:"repairs next round",tone:"wait"}:{there:"works there",here:r,note:"share it to repair",tone:"bad"}:{there:"works there",here:r,note:"arrives next round",tone:"wait"}}function b7(e,t,n,r=null){var d;const s=new Map;for(const f of t)(d=s.get(f.key))!=null&&d.alive||s.set(f.key,f);const o=new Set(n),l=[],u=new Set;for(const f of e??[]){if(u.has(f.key))continue;u.add(f.key);const h=s.get(f.key)??null,m=o.has(f.key),g=x7(f,h,m),w=h?h.alive?h.shareable===!1?"unavailable":"works":"expired":"missing",k=!f.alive&&h&&!h.alive?g.note:[w==="works"?null:g.here,f.alive&&f.shareable!==!1?null:g.there,g.note].filter(Boolean).join(" · ")||null;l.push({key:f.key,email:f.email,here:w,there:f.alive?f.shareable===!1?"unavailable":"works":"broken",in:!f.alive||f.shareable===!1?"cut":g.tone==="wait"?"wait":g.tone==="bad"?"blocked":"live",out:m&&h?h.alive&&h.shareable!==!1?"live":"cut":null,caption:k,tone:g.tone,usedThere:r===f.key})}for(const f of n){const h=s.get(f);!h||u.has(f)||(u.add(f),l.push({key:f,email:h.email,here:h.alive?h.shareable===!1?"unavailable":"works":"expired",there:"unknown",in:null,out:h.alive&&h.shareable!==!1?"live":"cut",caption:h.alive?h.shareable===!1?"cannot share here":null:"expired here",tone:h.alive?h.shareable===!1?"idle":"ok":"bad",usedThere:!1}))}return l}const k7=1e3;function N7(e,t){const n=new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),r=gr(e,t);return`${n} · ${r==="now"?"just now":r}`}function vS(e){return e&&[e.version,e.os,e.arch].filter(Boolean).join(" · ")||null}const S7={works:"works here",expired:"expired here",missing:"not on this deck",unavailable:"cannot share here"},j7={works:"works there",broken:"broken there",unavailable:"cannot share there",unknown:"not offered by that deck"};function _7(e){const t=e.in&&e.out?"offered both ways":e.in?"offered by that deck":"offered by this deck";return`${S7[e.here]}, ${j7[e.there]}, ${t}${e.usedThere?", in use there":""}.`}function E7({row:e,source:t,status:n,accounts:r,now:s}){var U,Z,H,J,ee;const{peer:o,stranger:l}=t,u=e.kind==="paired",d=e.self??e.name,f=e.kind!=="dialling",h=e.kind==="dialling"?null:e.fp,m=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,w=((U=n.about)==null?void 0:U.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",v=vS(n.about),b=vS(g),S=g!=null&&g.version&&w?v7(g.version,w):null,_=o?_d(o.last,s):null,j=o&&((Z=o.last)!=null&&Z.error)?kW({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=(H=o==null?void 0:o.last)!=null&&H.error&&_&&_.text!==o.last.error?o.last.error:null,T=((J=o==null?void 0:o.last)==null?void 0:J.done)??[],R=!!_&&!!E&&!e.quiet&&e.state.startsWith(_.text),M=u||e.kind==="dialling",O=((o==null?void 0:o.via)??e.via)==="tailscale",I=o?o.waiting?null:o.manual?O?"added by its Tailscale address":"added by address":O?"over Tailscale":"on this network":e.kind==="nearby"?O?"heard over Tailscale":"heard on this network":O?"asked this deck to pair, over Tailscale":"asked this deck to pair",A=e.tone==="bad"?"bad":u?e.here?"up":"down":"loose",L=(o==null?void 0:o.offers)??null,z=A==="up"?(L==null?void 0:L.current)??null:null,V=z&&"key"in z?z.key:null,$=!!z&&"hidden"in z,P=!!z&&"other"in z,F=u?b7((L==null?void 0:L.accounts)??null,r,n.shared??[],V):[],Y=F.filter(re=>re.in==null&&re.out==="cut"),K=F.some(re=>re.in!=null),D=F.some(re=>re.out!=null),W=new Map(T.map(re=>[re.email,re])),B=T.filter(re=>!F.some(oe=>oe.email===re.email)),X=u?L?L.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,G=L&&(o!=null&&o.last)&&o.last.at-L.at>k7?gr(L.at,s):null;return{peer:o,stranger:l,paired:u,own:d,canRename:f,fp:h,where:m,about:g,unsaid:k,hereRuns:v,thereRuns:b,order:S,line:_,silence:j,raw:E,echoed:R,showRound:M,how:I,link:A,hiddenThere:$,otherThere:P,lanes:F,spent:Y,taking:K,giving:D,told:W,unplaced:B,unknown:X,stale:G}}function C7({row:e,run:t,onVerb:n,onUnpair:r}){const[s,o]=x.useState(!1),l=x.useRef(0),[u,d]=x.useState(null);return x.useEffect(()=>{if(!s)return;const m=window.setTimeout(()=>o(!1),4e3);return()=>window.clearTimeout(m)},[s]),x.useEffect(()=>{if(!u)return;const m=window.setTimeout(()=>d(null),4e3);return()=>window.clearTimeout(m)},[u]),{armed:s,armedTwin:u,pressOwn:()=>{const m=Date.now(),g=jl({armedFor:s?e.fp:null,target:e.fp,armedAt:l.current,now:m,gapMs:Sl});if(g==="arm"){o(!0),d(null),l.current=m;return}g!=="ignore"&&(o(!1),t(n))},pressTwin:m=>{if(!r)return;const g=Date.now(),w=jl({armedFor:u,target:m,armedAt:l.current,now:g,gapMs:Sl});if(w==="arm"){d(m),o(!1),l.current=g;return}w!=="ignore"&&(d(null),t(()=>r(m)))}}}function T7({row:e,paired:t,peer:n,status:r,busy:s,press:o,checkNow:l,armed:u,pressOwn:d,run:f,onVerb:h,onInvite:m}){return i.jsxs("footer",{className:"lan-peer-foot",children:[e.kind==="asks"&&i.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)&&i.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"&&i.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"&&i.jsx("button",{type:"button",className:"btn primary lan-peer-verb",...o(`accept:${e.fp}`),onClick:()=>void f(h),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"&&i.jsx("button",{type:"button",className:"btn lan-peer-verb",...o(`drop:${e.fp}`),onClick:()=>void f(h),title:"Stop trying this address. Nothing was ever paired here.",children:s===`drop:${e.fp}`?"Stopping…":"Stop dialling"}),e.kind==="declined"&&r.pairingMode!=="invite"&&i.jsx("button",{type:"button",className:"btn lan-peer-verb",...o(`allow:${e.fp}`),onClick:()=>void f(h),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"&&m&&i.jsx("button",{type:"button",className:"btn primary lan-peer-verb",onClick:m,title:"This deck pairs only by invite. Make one and send it to whoever is at that machine.",children:"Invite to pair"})]})}function xS(){return i.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:[i.jsx("rect",{x:"2.5",y:"3",width:"11",height:"7.5",rx:"1.2"}),i.jsx("path",{d:"M1 13h14"})]})}function hu({dir:e,gate:t=!1}){const n=t?12:8;return i.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:i.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 R7({view:e,row:t,status:n,asking:r,drawn:s,onSettings:o}){const{peer:l,paired:u,where:d,about:f,unsaid:h,hereRuns:m,thereRuns:g,order:w,line:k,silence:v,raw:b,echoed:S,showRound:_,how:j,link:E,hiddenThere:T,otherThere:R,lanes:M,spent:O,taking:I,giving:A,told:L,unplaced:z,unknown:V,stale:$}=e;return i.jsxs("div",{className:"lan-map","data-link":E,"data-asking":r||void 0,"data-bus":M.length>0||void 0,children:[i.jsxs("div",{className:"lan-ends",children:[i.jsxs("p",{className:"lan-end",children:[i.jsx("span",{className:"lan-end-name",children:"This deck"}),m&&i.jsx("span",{className:"lan-end-runs",children:m}),u&&n.shareActive===!1&&i.jsx("span",{className:"lan-end-note",children:"current account hidden"})]}),i.jsxs("p",{className:"lan-end","data-side":"there",children:[i.jsx("span",{className:"lan-end-name",children:t.name}),t.kind!=="dialling"&&i.jsxs("span",{className:"lan-end-runs",children:[g??(f?"not said":h),w?` · ${w<0?"older":"newer"}`:null]}),T&&i.jsx("span",{className:"lan-end-note",children:"current account hidden"}),R&&i.jsx("span",{className:"lan-end-note",children:"on another account"})]})]}),i.jsxs("div",{className:"lan-link",children:[i.jsx(xS,{}),i.jsxs("span",{className:"lan-span",children:[i.jsxs("span",{className:"lan-wire","aria-hidden":!0,children:[i.jsx("i",{className:"lan-glint","data-dir":"out"}),i.jsx("i",{className:"lan-glint","data-dir":"in"})]}),i.jsx("span",{className:"lan-link-label",children:d?i.jsx("code",{className:"ap-lan-code",children:d}):"none here — it calls this deck"})]}),i.jsx(xS,{}),(d&&j||_)&&i.jsxs("p",{className:"lan-link-sub",children:[d&&j,d&&j&&_&&" · ",_&&(k?S?i.jsx("code",{className:"ap-lan-code",children:b}):i.jsx("span",{className:"lan-round","data-tone":k.tone,children:k.text.replace(/ · now$/," · just now")}):"not asked yet"),_&&b&&!S&&i.jsx("code",{className:"lan-fact-raw",children:b})]}),z.length>0&&i.jsx("ul",{className:"lan-done",children:z.map(P=>{const F=ix(P);return i.jsxs("li",{"data-ok":P.ok&&!F,children:[P.email," ",i.jsxs("span",{className:"lan-done-what",children:[P.ok?"arrived":"did not arrive",F&&` — ${F.long}`]})]},`${P.email}:${P.action}`)})}),v&&i.jsx("p",{className:"lan-note lan-link-note",children:v}),(l==null?void 0:l.waiting)&&i.jsx("p",{className:"lan-note lan-link-note",children:t.hint}),(k==null?void 0:k.hint)&&i.jsx("p",{className:"lan-note lan-link-note",children:k.hint})]}),M.length>0&&i.jsx("ul",{className:"lan-lanes",role:"list","aria-label":`Logins between this deck and ${t.name}`,children:M.map((P,F)=>{const Y=L.get(P.email),K=Y?ix(Y):null,D=P.out==="live"||P.in!=null&&P.in!=="cut";return i.jsxs("li",{role:"listitem",className:"lan-lane","data-tone":P.tone,"data-draw":P.in&&P.out?"both":P.in?"in":"out","data-used-there":P.usedThere||void 0,style:{"--i":F},children:[i.jsx("i",{className:"lan-pip","data-end":"here","data-state":P.here,"aria-hidden":!0}),i.jsxs("span",{className:"lan-track",children:[i.jsxs("span",{className:"lan-wire","data-flow":D?"live":"cut","aria-hidden":!0,children:[(P.in==="live"||P.in==="wait")&&i.jsx("i",{className:"lan-glint","data-dir":"in","data-tone":P.in}),P.out==="live"&&i.jsx("i",{className:"lan-glint","data-dir":"out"})]}),P.in&&P.in!=="cut"&&i.jsx(hu,{dir:"in",gate:P.in==="blocked"}),P.out==="live"&&i.jsx(hu,{dir:"out"}),i.jsx("span",{className:"lan-lane-email",children:P.email})]}),i.jsx("i",{className:"lan-pip","data-end":"there","data-state":P.there,"aria-hidden":!0}),i.jsx("span",{className:"vis-hidden",children:_7(P)}),(P.caption||Y)&&i.jsxs("span",{className:"lan-lane-note",children:[P.caption,P.caption&&Y&&" · ",Y&&i.jsxs("span",{className:"lan-lane-done","data-ok":Y.ok&&!K,children:[Y.ok?"arrived last round":"did not arrive last round",K&&` — ${K.long}`]})]})]},P.key)})},s),u&&i.jsxs(i.Fragment,{children:[O.length>0&&i.jsxs("p",{className:"lan-spent",children:["Paired decks get nothing from ",O.length===1?O[0].email:"the expired ones"," until you sign in again here."]}),V&&i.jsx("p",{className:"lan-empty",children:V}),$&&i.jsxs("p",{className:"lan-stale",children:["As of ",$==="now"?"just now":$,", when it last answered."]}),i.jsxs("div",{className:"lan-legend",children:[I&&i.jsxs("span",{className:"lan-key",children:[i.jsx("span",{className:"lan-key-wire","data-dir":"in","aria-hidden":!0,children:i.jsx(hu,{dir:"in"})}),"from ",t.name]}),A?i.jsxs("span",{className:"lan-key",children:[i.jsx("span",{className:"lan-key-wire","data-dir":"out","aria-hidden":!0,children:i.jsx(hu,{dir:"out"})}),"from this deck, to every paired deck"]}):i.jsx("span",{className:"lan-key",children:"This deck offers nothing yet."}),i.jsx("button",{type:"button",className:"ap-lan-word lan-legend-act",onClick:o,"aria-label":"Change what this deck offers",children:"change"})]})]})]})}function A7({instances:e,now:t,busy:n,press:r,armedTwin:s,pressTwin:o,onUnpair:l}){return i.jsxs("div",{className:"modal-section",children:[i.jsxs("h3",{className:"lan-h",children:[e.length," decks on this machine"]}),i.jsx("ul",{className:"lan-twins",role:"list",children:e.map((u,d)=>{var k,v,b,S;const f=(k=u.peer)!=null&&k.addr?`${u.peer.addr}:${u.peer.port}`:u.row.addr,h=f||u.row.fp,m=(v=u.peer)!=null&&v.pairedAt?gr(u.peer.pairedAt,t):null,g=[(S=(b=u.peer)==null?void 0:b.about)!=null&&S.version?`runs ${u.peer.about.version}`:null,m?`paired ${m==="now"?"just now":m}`:null,u.row.state].filter(Boolean).join(" · "),w=u.row.fp;return i.jsxs("li",{role:"listitem",className:"lan-twin","data-tone":u.row.tone,children:[i.jsx("i",{className:u.row.here?"ap-pulse":"ap-dot","aria-hidden":!0}),f?i.jsx("code",{className:"ap-lan-code lan-twin-at",children:f}):i.jsx("span",{className:"lan-twin-at lan-twin-none",children:"no address here"}),i.jsx("code",{className:"ap-lan-code lan-twin-fp",children:w}),d>0&&l&&i.jsx("button",{type:"button",className:`ap-manage-btn danger lan-twin-do${s===w?" armed":""}`,...r(`unpair:${w}`),onKeyDown:_=>{_.repeat&&_.preventDefault()},onClick:()=>o(w),"aria-label":s===w?`Confirm unpairing ${h}`:`Unpair ${h}`,title:s===w?"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:${w}`?"unpairing…":s===w?"confirm":"unpair"}),i.jsx("span",{className:"lan-twin-meta",children:d===0?`${g} · shown above`:g})]},w)})})]})}function M7(){return i.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:[i.jsx("path",{d:"M9.6 2.4l2 2L5 11l-2.6.6L3 9z"}),i.jsx("path",{d:"M8.4 3.6l2 2"})]})}function $7({row:e,source:t,status:n,accounts:r,now:s,busy:o,onClose:l,onRename:u,onCheck:d,onVerb:f,onSettings:h,onInvite:m,twins:g=[],onUnpair:w}){const k=x.useRef(null),v=Et(l,{focusRef:k}),[b,S]=x.useState(null),[_,j]=x.useState(null),[E,T]=x.useState(!1),[R,M]=x.useState(0),O=x.useRef(null),I=x.useRef(!0);x.useEffect(()=>()=>{I.current=!1},[]);const A=b!=null;x.useEffect(()=>{var oe;A&&((oe=O.current)==null||oe.select())},[A]);const L=oe=>{const fe=_s(o,oe);return{disabled:fe.disabled,"aria-busy":fe.busy}},z=async oe=>{const fe=await oe();return I.current&&j(fe),fe==null},{armed:V,armedTwin:$,pressOwn:P,pressTwin:F}=C7({row:e,run:z,onVerb:f,onUnpair:w}),Y=E7({row:e,source:t,status:n,accounts:r,now:s}),{peer:K,stranger:D,paired:W,own:B,canRename:X,fp:G}=Y,U=o===`check:${e.fp}`,Z=async oe=>{const fe=oe.trim()===B?"":oe;await z(()=>u(fe))&&S(null)},H=()=>void z(d).then(oe=>{oe&&I.current&&M(fe=>fe+1)}),J=async()=>{if(G)try{if(await navigator.clipboard.writeText(G),!I.current)return;T(!0),window.setTimeout(()=>{I.current&&T(!1)},1600)}catch{I.current&&j("Could not copy it — select the fingerprint and copy it by hand.")}},ee=[];W&&(K!=null&&K.pairedAt)?ee.push({label:"Paired",value:N7(K.pairedAt,s),tone:"meta"}):e.kind==="declined"&&D&&ee.push({label:"Paired",value:`no · you said no ${p0(D.at,s)}`,tone:"meta"}),ee.push({label:"Fingerprint",value:G?i.jsxs("span",{className:"lan-fp",children:[i.jsx("code",{className:"ap-lan-code",children:G}),i.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void J(),"aria-label":E?"Fingerprint copied":"Copy the fingerprint",children:E?"copied":"copy"})]}):"not known — nothing has answered there",tone:G?void 0:"quiet"});const re=g.length?[{row:e,peer:K??null},...g]:[];return zt.createPortal(i.jsx("div",{className:"modal-backdrop",onClick:l,role:"presentation",children:i.jsxs("div",{ref:v,className:"modal lan-peer","data-tone":e.tone,onClick:oe=>oe.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-peer-title","aria-describedby":"lan-peer-sub",children:[i.jsxs("header",{className:"modal-head lan-peer-head",children:[i.jsx("i",{className:e.here?"ap-pulse":"ap-dot","aria-hidden":!0}),i.jsxs("div",{className:"lan-peer-id",children:[A?i.jsxs("form",{className:"lan-peer-edit",onSubmit:oe=>{oe.preventDefault(),Z(b??"")},children:[i.jsx("span",{id:"lan-peer-title",className:"vis-hidden",children:e.name}),i.jsx("input",{ref:O,className:"ap-manage-input lan-peer-input",value:b??"",maxLength:48,placeholder:B,"aria-label":"Name for this deck, shown on this deck only",onChange:oe=>S(oe.target.value)}),i.jsx("button",{type:"submit",className:"ap-manage-btn",...L(`alias:${e.fp}`),children:"save"}),i.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>S(null),children:"cancel"})]}):i.jsxs("span",{className:"lan-peer-title",children:[i.jsx("span",{id:"lan-peer-title",className:"lan-peer-name",children:e.name}),X&&i.jsx("button",{type:"button",className:"glyph-btn lan-peer-rename",onClick:()=>{j(null),S(e.name)},"aria-label":`Rename ${e.name} on this deck`,title:"Give it a name of your own. Only this deck sees it.",children:i.jsx(M7,{})})]}),i.jsxs("p",{id:"lan-peer-sub",className:"lan-peer-sub",children:[e.self&&i.jsxs(i.Fragment,{children:["calls itself ",i.jsx("span",{className:"lan-peer-self",children:e.self}),A&&i.jsx("button",{type:"button",className:"ap-lan-word lan-peer-restore",...L(`alias:${e.fp}`),onClick:()=>void Z(""),children:"use this name"}),i.jsx("span",{className:"vis-hidden",children:". "}),!e.quiet&&i.jsx("span",{"aria-hidden":!0,children:" · "})]}),i.jsx("span",{className:e.quiet?"vis-hidden":"lan-peer-state",children:e.state})]})]}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{ref:k,type:"button",className:"glyph-btn",onClick:l,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body lan-peer-body",children:[_&&i.jsxs("div",{className:"ap-failure",role:"alert",children:[i.jsx("span",{className:"ap-failure-text",children:_}),i.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>j(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),i.jsx(R7,{view:Y,row:e,status:n,asking:U,drawn:R,onSettings:h}),i.jsx("dl",{className:"lan-facts",children:ee.map(oe=>i.jsxs("div",{className:"lan-fact","data-tone":oe.tone,children:[i.jsx("dt",{children:oe.label}),i.jsx("dd",{children:oe.value})]},oe.label))}),re.length>1&&i.jsx(A7,{instances:re,now:s,busy:o,press:L,armedTwin:$,pressTwin:F,onUnpair:w})]}),i.jsx(T7,{row:e,paired:W,peer:K,status:n,busy:o,press:L,checkNow:H,armed:V,pressOwn:P,run:z,onVerb:f,onInvite:m})]})}),document.body)}function I7(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(r=>n.has(r))}function O7(e,t,n,r){const s=new Set(e??t);return r?s.add(n):s.delete(n),[...s]}function bS(e,t,n){return e==null||n!=null&&!n.ok||I7(e,t)?null:e}function L7(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 fu="Paused while this deck pairs only by invite. Turn that off above to use it.";function P7({status:e,accounts:t,onClose:n,onChanged:r}){const s=Et(n),[o,l]=x.useState(null),[u,d]=x.useState(null),[f,h]=x.useState(!1),[m,g]=x.useState(null),w=x.useRef(null),k=$=>{const P=_s(m,$);return{disabled:P.disabled,"aria-busy":P.busy}},v=x.useRef(null),b=x.useRef(!0);x.useEffect(()=>()=>{b.current=!1},[]),x.useEffect(()=>{v.current=bS(v.current,e.shared??[],null)},[e.shared]);const S=x.useCallback(async($,P,F="write")=>{w.current=F,g(F);try{const K=await(await fetch("/api/prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:$})})).json().catch(()=>null);return b.current?(K!=null&&K.ok?d(null):d(St(P,K)),r(),(K==null?void 0:K.ok)===!0):!1}catch{return b.current&&d(St(P,null)),!1}finally{w.current=null,b.current&&g(null)}},[r]),_=x.useCallback(async()=>{if(o!=null&&o!==(e.name??"")){if(!await S({name:o},"save the name","name"))return;b.current&&l(null)}n()},[o,e.name,S,n]),j=async()=>{if(!e.fp)return;const $=await ja(e.fp);if(b.current){if(!$){d("Could not copy it — select the fingerprint and copy it by hand.");return}h(!0),window.setTimeout(()=>{b.current&&h(!1)},1600)}},E=new Set(v.current??e.shared??[]),T=e.autoAsk!==!1,R=e.autoAccept!==!1,M=e.pairingMode==="invite",O=$=>{const P=k($);return{...P,disabled:P.disabled||M}},I=e.shareActive!==!1,A=e.tailscale??null,L=!!(A!=null&&A.on),z=(A==null?void 0:A.ask)!==!1,V=(A==null?void 0:A.accept)!==!1;return zt.createPortal(i.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:i.jsxs("div",{ref:s,className:"modal lan-modal",onClick:$=>$.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-modal-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"lan-modal-title",className:"modal-tool-name",children:"This deck on the network"})}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[u&&i.jsxs("div",{className:"ap-failure",role:"alert",children:[i.jsx("span",{className:"ap-failure-text",children:u}),i.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>d(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),i.jsxs("div",{className:"modal-section",children:[i.jsx("h3",{className:"lan-h",children:"Name"}),i.jsxs("div",{className:"ap-lan-row",children:[i.jsx("span",{className:"ap-lan-label",children:"appear as"}),i.jsx("input",{className:"ap-manage-input ap-lan-input","aria-label":"This deck's name on the network",value:o??e.name??"",placeholder:"this machine",onChange:$=>l($.target.value),onKeyDown:$=>{$.key!=="Enter"||o==null||(S({name:o},"save the name","name"),l(null))}}),o!=null&&o!==(e.name??"")&&i.jsx("button",{type:"button",className:"ap-manage-btn",...k("name"),onClick:()=>{S({name:o},"save the name","name"),l(null)},title:"Save it. This is the name other decks show for this one.",children:"save"})]}),i.jsxs("div",{className:"ap-lan-row",children:[i.jsx("span",{className:"ap-lan-label",children:"fingerprint"}),e.fp?i.jsxs("span",{className:"lan-fp",children:[i.jsx("code",{className:"ap-lan-code",children:e.fp}),i.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void j(),"aria-label":f?"Fingerprint copied":"Copy this deck's fingerprint",children:f?"copied":"copy"})]}):i.jsx("span",{className:"ap-lan-label",children:"not known yet"})]})]}),i.jsxs("div",{className:"modal-section",children:[i.jsx("h3",{className:"lan-h",children:"Share these accounts"}),i.jsxs("div",{className:"ap-lan-picks",children:[t.length===0&&i.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($=>i.jsxs("label",{className:"ap-lan-pick",title:$.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:[i.jsx("input",{type:"checkbox",checked:E.has($.key),onChange:P=>{const F=O7(v.current,e.shared??[],$.key,P.target.checked);v.current=F,S({shared:F},P.target.checked?"share that account":"stop sharing that account").then(Y=>{v.current===F&&(v.current=bS(F,e.shared??[],{ok:Y}))})}}),i.jsx("span",{className:"ap-lan-pick-name",children:$.email}),!$.alive&&i.jsx("span",{className:"ap-lan-dead",children:"not working here"})]},$.key))]}),t.length>0&&i.jsxs("div",{className:"lan-switch",children:[i.jsx("span",{className:"lan-switch-what",children:"Show paired decks which of these this deck is using"}),i.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":I,"aria-label":"Show paired decks which of these this deck is using",...k("current"),onClick:()=>void S({shareActive:!I},I?"stop showing which account this deck is using":"show which account this deck is using","current"),title:I?"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:i.jsx("span",{className:"switch-knob"})})]})]}),i.jsxs("div",{className:"modal-section",children:[i.jsx("h3",{className:"lan-h",id:"lan-pairing-h",children:"Pairing"}),i.jsx("div",{className:"lan-switches lan-switches-lead",role:"group","aria-labelledby":"lan-pairing-h",children:i.jsxs("div",{className:"lan-switch",children:[i.jsxs("span",{className:"lan-switch-what",children:["Pair new decks only by invite",M&&i.jsx("span",{id:"lan-invite-only-detail",className:"lan-switch-detail",children:"A new deck needs an invite from + in the panel. Paired decks stay paired."})]}),i.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":M,"aria-label":"Pair new decks only by invite","aria-describedby":M?"lan-invite-only-detail":void 0,...k("mode"),onKeyDown:$=>{$.repeat&&$.preventDefault()},onClick:()=>void S({pairingMode:M?"automatic":"invite"},M?"let decks pair on their own again":"pair new decks only by invite","mode"),title:M?"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:i.jsx("span",{className:"switch-knob"})})]})}),i.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-auto-h",children:[i.jsxs("p",{className:"lan-sub",id:"lan-auto-h",children:["Automatic pairing",M&&i.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),i.jsxs("div",{className:"lan-switches","data-paused":M||void 0,children:[i.jsxs("div",{className:"lan-switch",children:[i.jsx("span",{className:"lan-switch-what",children:"Ask every deck this one finds"}),i.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":T,"aria-label":"Ask every deck this one finds",...O("ask"),onClick:()=>void S({autoAsk:!T},T?"stop asking automatically":"ask every deck this one finds","ask"),title:M?fu:T?"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:i.jsx("span",{className:"switch-knob"})})]}),i.jsxs("div",{className:"lan-switch",children:[i.jsx("span",{className:"lan-switch-what",children:"Say yes to every deck that asks"}),i.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":R,"aria-label":"Say yes to every deck that asks","data-tone":"warn",...O("accept"),onKeyDown:$=>{$.repeat&&$.preventDefault()},onClick:()=>void S({autoAccept:!R},R?"stop accepting automatically":"accept every deck that asks","accept"),title:M?fu:R?"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:i.jsx("span",{className:"switch-knob"})})]})]})]})]}),(A==null?void 0:A.found)&&i.jsxs("div",{className:"modal-section",children:[i.jsx("h3",{className:"lan-h",children:"Tailscale"}),i.jsxs("div",{className:"lan-switches",children:[i.jsxs("div",{className:"lan-switch",children:[i.jsxs("span",{className:"lan-switch-what",children:["Look for my devices",i.jsx("span",{id:"lan-ts-detail",className:"lan-switch-detail",children:L7(A)})]}),i.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":L,"aria-label":"Look for my devices over Tailscale","aria-describedby":"lan-ts-detail",...k("tailscale"),onClick:()=>void S({tailscale:!L},L?"stop looking over Tailscale":"look for your devices over Tailscale","tailscale"),title:L?"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:i.jsx("span",{className:"switch-knob"})})]}),L&&i.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-ts-auto-h",children:[i.jsxs("p",{className:"lan-sub",id:"lan-ts-auto-h",children:["Automatic pairing with my devices",M&&i.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),i.jsxs("div",{className:"lan-switches",children:[i.jsxs("div",{className:"lan-switch","data-paused":M||void 0,children:[i.jsx("span",{className:"lan-switch-what",children:"Ask each device it finds"}),i.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":z,"aria-label":"Ask each of my devices it finds over Tailscale",...O("tailscale-ask"),onClick:()=>void S({tailscaleAsk:!z},z?"stop asking your devices automatically":"ask your devices automatically","tailscale-ask"),title:M?fu:z?"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:i.jsx("span",{className:"switch-knob"})})]}),i.jsxs("div",{className:"lan-switch","data-paused":M||void 0,children:[i.jsx("span",{className:"lan-switch-what",children:"Say yes to each device that asks"}),i.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":V,"aria-label":"Say yes to my devices when they ask over Tailscale","data-tone":"warn",...O("tailscale-accept"),onKeyDown:$=>{$.repeat&&$.preventDefault()},onClick:()=>void S({tailscaleAccept:!V},V?"stop accepting your devices automatically":"accept your devices automatically","tailscale-accept"),title:M?fu:V?"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:i.jsx("span",{className:"switch-knob"})})]})]})]})]})]})]}),i.jsxs("footer",{className:"lan-setup-foot",children:[i.jsx("span",{className:"lan-foot-note",children:"Changes are saved as you make them."}),i.jsx("button",{type:"button",className:"btn primary",...k("name"),onClick:()=>void _(),children:"Done"})]})]})}),document.body)}function D7({on:e,status:t,paired:n,busy:r,pressProps:s,checkNow:o,setAddOpen:l,setSetupOpen:u,onBack:d,closeButton:f}){return i.jsxs("div",{className:"ap-header",children:[i.jsx("button",{type:"button",id:"ap-lan-back",className:"glyph-btn ap-back",onClick:d,"aria-label":"Back to Claude accounts",title:"Back to Claude accounts",children:i.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:i.jsx("path",{d:"M8.4 3.4 4.8 7l3.6 3.6"})})}),i.jsx("h2",{id:"ap-lan-title",children:"Local network"}),i.jsxs("div",{className:"ap-header-right",children:[e&&i.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:i.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:[i.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"}),i.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&&i.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:i.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:[i.jsx("circle",{cx:"7",cy:"7",r:"1.1",fill:"currentColor",stroke:"none"}),i.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"}),i.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&&i.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:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[i.jsx("path",{d:"M1.8 4.7h10.4M1.8 9.3h10.4"}),i.jsx("circle",{cx:"9.1",cy:"4.7",r:"1.6",fill:"var(--panel)"}),i.jsx("circle",{cx:"4.9",cy:"9.3",r:"1.6",fill:"var(--panel)"})]})}),f]})]})}function F7({accounts:e,onChanged:t,view:n,onOpen:r,onBack:s,closeButton:o}){const[l,u]=x.useState(!1),[d,f]=x.useState(!1),[h,m]=x.useState(!1),g=LW(),[w,k]=x.useState(!1),{status:v,manual:b,now:S,busy:_,failure:j,dismissFailure:E,pressProps:T,load:R,toggle:M,answer:O,dropAddress:I,rename:A,checkOne:L,checkNow:z}=BW(t,()=>u(!0)),{armed:V,pressUnpair:$}=zW(O),[P,F]=x.useState(null),Y=(v==null?void 0:v.enabled)===!0,K=EW((v==null?void 0:v.pairingMode)==="invite"&&v?{...v,pending:[]}:v,S),D=P?K.find(oe=>{var fe;return oe.fp===P||((fe=oe.twins)==null?void 0:fe.some(Ne=>Ne.fp===P))})??null:null;x.useEffect(()=>{P&&v&&!D&&F(null)},[P,v,D]);const{asks:W,rest:B,live:X,folded:G,troubled:U,shown:Z,paired:H}=OW(K,w),J=SW(v,S),ee=IW(v,K),re=i.jsxs(i.Fragment,{children:[d&&v&&i.jsx(u7,{status:v,manual:b,startWith:d==="invite"?"invite":void 0,onClose:()=>f(!1),onChanged:()=>{R(),t()}}),h&&i.jsx(SM,{title:"How Local network works",steps:n7,finish:Y?void 0:{label:"Turn it on",act:()=>{m(!1),M()}},onClose:()=>m(!1)}),l&&v&&i.jsx(P7,{status:{...v,manualRows:b},accounts:e,manual:b,onClose:()=>u(!1),onChanged:()=>{R(),t()}}),D&&v&&i.jsx($7,{row:D,source:pS(v,D),status:v,accounts:e,now:S,busy:_,onClose:()=>F(null),onRename:oe=>A(D.fp,oe),onCheck:()=>L(D.fp),onVerb:()=>{switch(D.kind){case"paired":return O("unpair",D.fp,"unpair that deck");case"nearby":return O("accept",D.fp,"reach that deck");case"declined":return O("allow",D.fp,"let that deck ask again");case"dialling":return I(D.fp);default:return Promise.resolve(null)}},onSettings:()=>{F(null),u(!0)},onInvite:()=>{F(null),f("invite")},twins:(D.twins??[]).map(oe=>({row:oe,peer:pS(v,oe).peer??null})),onUnpair:oe=>O("unpair",oe,"unpair that deck")})]});return n?i.jsxs("div",{className:"ap-lan-view",children:[i.jsx(D7,{on:Y,status:v,paired:H,busy:_,pressProps:T,checkNow:z,setAddOpen:f,setSetupOpen:u,onBack:s,closeButton:o}),i.jsx("div",{className:"ap-scroll",id:"ap-lan-scroll",children:i.jsxs("div",{className:"ap-lan",children:[i.jsxs("div",{className:"ap-policy",children:[i.jsx("h3",{className:"ap-auto-title",children:"Sync with paired decks"}),i.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":Y,"aria-label":"Sync with paired decks",...T("switch"),onClick:()=>void M(),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:i.jsx("span",{className:"switch-knob"})})]}),i.jsx(m7,{on:Y,status:v}),!Y&&i.jsxs("button",{type:"button",className:"ap-lan-intro",onClick:()=>m(!0),title:"Four pictures: what this does, and what to do on each machine",children:[i.jsx(r7,{}),i.jsx("span",{className:"ap-lan-intro-text",children:"Paired machines repair each other's expired logins."}),i.jsx("span",{className:"ap-lan-intro-go",children:"See how it works"})]}),i.jsx("p",{className:`ap-lan-status ${J.tone}`,role:"status",children:J.tone==="ok"?"":J.text}),j&&i.jsxs("div",{className:"ap-failure",role:"alert",children:[i.jsx("span",{className:"ap-failure-text",children:j}),i.jsx("button",{type:"button",className:"ap-failure-x",onClick:E,"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),Y&&i.jsxs(i.Fragment,{children:[W.length>0&&i.jsx(h7,{asks:W,pressProps:T,answer:O}),Z.length>0&&i.jsx(f7,{rows:Z,pairingMode:v==null?void 0:v.pairingMode,armed:V,pressProps:T,answer:O,dropAddress:I,onUnpair:$,onOpenPeer:F,onInvite:()=>f("invite")}),(X.length>0&&G.length>0||Y&&H>0)&&i.jsxs("div",{className:"ap-lan-tail",children:[X.length>0&&G.length>0&&i.jsxs("button",{type:"button",className:"ap-lan-word ap-lan-more","aria-expanded":w,onClick:()=>k(oe=>!oe),title:w?"Show only the decks that are on":`Show the ${G.length} deck${G.length===1?"":"s"} that are not responding right now`,children:[i.jsx("span",{className:`ap-lan-chev${w?" open":""}`,"aria-hidden":!0,children:"›"}),w?"fewer":`${G.length} more`,!w&&U>0&&i.jsxs("span",{className:"ap-lan-more-bad",children:[" · ",U," not responding"]})]}),Y&&H>0&&i.jsx("span",{className:"ap-lan-checked",children:jW(v==null?void 0:v.checkedAt,S,_==="check")})]}),B.length===0&&W.length===0&&!(v!=null&&v.stalled)&&!(v!=null&&v.deaf)&&!(v!=null&&v.lanTunneled)&&i.jsxs(i.Fragment,{children:[i.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."}),i.jsx("button",{type:"button",className:"ap-lan-word ap-lan-how",onClick:()=>m(!0),children:"How it works"})]})]})]})}),re]}):i.jsxs("div",{className:"ap-foot",children:[i.jsx(w7,{entry:ee,rows:K,onOpen:r,...g}),i.jsx("p",{className:"vis-hidden",role:"status",children:J.tone==="ok"?"":J.text}),re]})}function q7({anchorId:e,id:t,peers:n,onHold:r,onLet:s}){const o=x.useRef(null),{title:l,shown:u,rest:d}=yW(n),f=x.useCallback(()=>{const h=o.current,m=document.getElementById(e);if(!h||!m)return;const g=l0(m.getBoundingClientRect(),{width:h.offsetWidth,height:h.offsetHeight},{width:window.innerWidth,height:window.innerHeight});h.style.top=`${g.top}px`,h.style.left=`${g.left}px`,h.style.maxHeight=g.maxHeight==null?"":`${g.maxHeight}px`,h.dataset.side=g.side},[e]);return x.useLayoutEffect(()=>{f()}),x.useEffect(()=>(window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}),[f]),zt.createPortal(i.jsxs("div",{ref:o,id:t,className:"ap-peek ap-fold-peek",role:"tooltip",onPointerEnter:r,onPointerLeave:s,children:[i.jsx("p",{className:"ap-peek-title",children:l}),i.jsx("div",{className:"ap-peek-list",children:u.map(h=>i.jsxs("span",{className:"ap-peek-who ap-fold-who",children:[i.jsx("span",{className:"ap-fold-name",children:h.name}),i.jsx("span",{className:"ap-fold-state","data-tone":h.ready?"ok":h.warn?"warn":"idle",children:h.ready?h.headroom==null?"not read yet":`${h.headroom}% free`:h.why})]},h.key))}),d&&i.jsx("p",{className:"ap-peek-rest",children:d})]}),document.body)}function B7({peers:e,strained:t,armed:n,threshold:r,open:s,onToggle:o}){const[l,u]=x.useState(!1),d=x.useRef(0);x.useEffect(()=>()=>window.clearTimeout(d.current),[]),x.useEffect(()=>{s&&(window.clearTimeout(d.current),u(!1))},[s]);const f=k=>{s||(window.clearTimeout(d.current),d.current=window.setTimeout(()=>u(!0),k))},h=()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>u(!1),kM)},m=()=>window.clearTimeout(d.current),g=()=>{window.clearTimeout(d.current),u(!1)},w=mW(e,{strained:t&&!s,armed:n,threshold:r});return i.jsxs("div",{className:"ap-rest",children:[i.jsxs("button",{type:"button",id:"ap-rest-entry",className:"ap-nav","aria-expanded":s,"aria-controls":s?"ap-rest-panel":void 0,"aria-describedby":l?"ap-rest-peek":void 0,onClick:()=>{g(),o()},onPointerEnter:k=>{k.pointerType==="mouse"&&f(bM)},onPointerLeave:h,onFocus:k=>{k.target.matches(":focus-visible")&&f(0)},onBlur:h,children:[i.jsxs("span",{className:"ap-nav-text",children:[i.jsx("span",{className:"ap-nav-name",children:"Other accounts"}),i.jsx("span",{className:"ap-nav-state","data-tone":w.tone,children:w.text})]}),i.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:i.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),l&&i.jsx(q7,{anchorId:"ap-rest-entry",id:"ap-rest-peek",peers:e,onHold:m,onLet:h})]})}async function z7(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const U7=1800;function H7({accounts:e,onClose:t,copyText:n}){const[r,s]=x.useState([]),[o,l]=x.useState(null),[u,d]=x.useState(!1),[f,h]=x.useState(null),[m,g]=x.useState(!1),[w,k]=x.useState(()=>Math.floor(Date.now()/1e3)),v=x.useRef(null),b=x.useRef(!1),S=Et(t,{focusRef:v});x.useEffect(()=>{if(!o)return;k(Math.floor(Date.now()/1e3));const A=window.setInterval(()=>k(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval(A)},[o]);const _=XH(e),j=ZH(e,r),E=j.length===e.length,T=A=>s(L=>JH(L,A)),R=x.useCallback(async()=>{const A=QH(j);if(!pr(b.current)||!A)return;b.current=!0,d(!0),h(null),g(!1);const L=await z7(A).catch(()=>null);if(b.current=!1,d(!1),!(L!=null&&L.ok)){h(Eo(L,"the share could not be made"));return}l({blob:L.blob,expiresAt:L.expiresAt,shared:L.shared??[],failed:L.failed??[]})},[e,j]),M=o?wM(o.expiresAt,w):null,O=(M==null?void 0:M.tone)==="gone",I=(o==null?void 0:o.shared.length)??0;return zt.createPortal(i.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:i.jsxs("div",{ref:S,className:"modal sa-modal",onClick:A=>A.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Share accounts with another deck",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("h3",{children:"Share accounts"})}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsx("section",{className:"modal-body sa-body",children:o?i.jsxs("div",{className:"sa-step",children:[i.jsx("h4",{children:O?"This share has expired":I===1?"1 account, ready to paste":`${I} accounts, ready to paste`}),i.jsx("code",{className:"ap-share-blob",children:o.blob}),i.jsxs("div",{className:"ap-share-foot",children:[i.jsx("button",{type:"button",className:"ap-manage-btn",ref:v,onClick:async()=>{if(O){l(null),R();return}await n(o.blob)&&(g(!0),window.setTimeout(()=>g(!1),U7))},children:O?"make a new share":m?"copied":`copy ${I===1?"the share":"all "+I}`}),i.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:[i.jsx("span",{className:"ap-share-warn",children:I===1?"this is the password":`this is ${I} passwords`})," · ",i.jsx("span",{className:`ap-share-expiry ${M==null?void 0:M.tone}`,children:M==null?void 0:M.text})]})]}),o.failed.length>0&&i.jsxs("div",{className:"sa-failed",role:"alert",children:[i.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:`}),i.jsx("ul",{className:"sa-list",children:o.failed.map(A=>{var z;const L=!!(A.email&&((z=A.detail)!=null&&z.includes(A.email)));return i.jsxs("li",{children:[!L&&i.jsx("span",{className:"sa-who",children:A.email||`account ${A.num}`}),i.jsx("span",{className:"sa-why",children:A.detail||"could not be exported"})]},`${A.num}-${A.email}`)})})]}),i.jsx("p",{className:"sa-note",children:O?i.jsx(i.Fragment,{children:"Another deck will refuse this text now. Make a new one — the same accounts are still picked."}):i.jsxs(i.Fragment,{children:["Paste it into the other deck with ",i.jsx("strong",{children:"+"})," → ",i.jsx("strong",{children:"Paste a share"}),". Accounts it already holds are left exactly as they are."]})}),i.jsxs("div",{className:"sa-actions",children:[i.jsx("button",{type:"button",className:"btn",onClick:()=>{l(null),g(!1)},children:"Pick again"}),i.jsx("button",{type:"button",className:"btn primary",onClick:t,children:"Done"})]})]}):e.length===0?i.jsxs("div",{className:"sa-step",children:[i.jsx("h4",{children:"Nothing to share"}),i.jsxs("p",{className:"sa-note",children:["This deck is not holding any accounts right now. Sign one in with ",i.jsx("strong",{children:"+"}),", or wait — the panel is still reading the store."]}),i.jsx("div",{className:"sa-actions",children:i.jsx("button",{type:"button",className:"btn primary",ref:v,onClick:t,children:"Close"})})]}):i.jsxs("div",{className:"sa-step",children:[i.jsxs("h4",{children:["Which accounts go to the other ",gt,"?"]}),i.jsx("p",{className:`sa-count${j.length?"":" empty"}`,children:eW(j.length)}),i.jsx("ul",{className:"sa-list sa-pick",children:_.map(A=>i.jsx("li",{children:i.jsxs("label",{className:"sa-row",children:[i.jsx("input",{type:"checkbox",checked:j.includes(A.num),onChange:()=>T(A.num)}),i.jsx("span",{className:"sa-who",children:A.label}),A.sub&&i.jsx("span",{className:"sa-sub",children:A.sub})]})},A.num))}),f&&i.jsx("p",{className:"aa-err",children:f}),i.jsxs("div",{className:"sa-actions",children:[i.jsx("button",{type:"button",className:"btn",onClick:()=>s(E?e.map(A=>A.num):[]),children:E?"Clear all":"Select all"}),i.jsx("button",{type:"button",className:"btn primary",ref:v,...Ss(u,!j.length),onClick:R,children:u?"making the share…":j.length===0?"Share":j.length===1?"Share 1 account":`Share ${j.length} accounts`})]})]})})]})}),document.body)}const W7="\0";function Td(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}${W7}${n}`}function V7(e,t){const n=Td(t);return e.includes(n)?e.filter(r=>r!==n):[...e,n]}function G7(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map(Td)),r=e.filter(s=>n.has(s));return r.length===e.length?e:r}function K7(e,t){return e.map(n=>{const r=Yu(n,t);return{key:Td(n),name:n.alias??n.email??`account ${n.num}`,ready:!n.disabled&&!(r!=null&&r.blocksSwitch),why:n.disabled?"held out":r!=null&&r.blocksSwitch?r.text:null,warn:(r==null?void 0:r.tone)==="warn",headroom:n.headroom}})}function Y7(e,t){const n=Number(t);return(e==null?void 0:e.headroom)!=null&&Number.isFinite(n)&&100-e.headroom>=n}function X7(e){return(e==null?void 0:e.ok)===!0&&(e.enabled||e.external)}function Z7(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 J7(){const[e,t]=x.useState(null),n=x.useRef(null),r=x.useCallback(l=>Nd(n.current)?(n.current=l,t(l),!0):!1,[]),s=x.useCallback(()=>{n.current=null,t(null)},[]);return{busy:e,claim:r,release:s,pressProps:(l,u=!1)=>{const d=_s(e,l);return{disabled:d.disabled,"aria-busy":d.busy||u}}}}const Q7=8e3,e9=1800,t9=4e3;function n9({claim:e,release:t,load:n,clearFailure:r,rescueFocus:s}){const[o,l]=x.useState(null),u=(o==null?void 0:o.num)??null,d=x.useRef(o);d.current=o;const[f,h]=x.useState(null),[m,g]=x.useState(""),[w,k]=x.useState(null),v=x.useRef(0);x.useEffect(()=>{if(w==null)return;const G=window.setTimeout(()=>k(null),t9);return()=>window.clearTimeout(G)},[w]);const[b,S]=x.useState(null),[_,j]=x.useState(!1),[E,T]=x.useState(null),[R,M]=x.useState(null),O=x.useCallback(async(G,U)=>{if(!e(U))return null;r(),h(null);try{const Z=await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(G)}),H=await Z.json().catch(()=>null);return H!=null&&H.ok||h({text:Eo(H,"command failed",Z.status)}),H}catch{return h({text:"server unreachable"}),null}finally{t()}},[e,t,r]),I=x.useCallback(()=>{l(null),h(null),k(null),S(null),j(!1)},[]),A=(G,U="first")=>{I(),M(null),l({num:G,view:"menu",start:U})},L=x.useCallback(G=>{var H,J;const U=d.current;if(!U||G!=null&&U.num!==G)return;const Z=document.getElementById(`ap-menu-${U.num}`);(Z!=null&&Z.contains(document.activeElement)||_l(((H=document.activeElement)==null?void 0:H.tagName)??null))&&((J=document.getElementById(`ap-more-${U.num}`))==null||J.focus()),I()},[I]),z=x.useCallback(G=>h(G),[]),V=(G,U)=>{g(U??""),h(null),l({num:G,view:"rename"})},$=G=>g(G),P=G=>{M(null),h(null),l({num:G,view:"move"})},F=G=>M(G),Y=async G=>{var Z;j(!1);const U=await O({action:"share",account:G},`share-${G}`);!(U!=null&&U.ok)||((Z=d.current)==null?void 0:Z.num)!==G||(S({num:G,blob:U.blob,expiresAt:U.expiresAt}),l({num:G,view:"share"}))},K=async G=>{await ja(G)&&(j(!0),window.setTimeout(()=>j(!1),e9))},D=async(G,U)=>{const{commit:Z,alias:H}=cW(m,U);if(Z){const J=await O({action:"alias",account:G,alias:H},`alias-${G}`);if(await n(!0),!(J!=null&&J.ok))return}L(G)},W=async(G,U)=>{var J,ee,re;const Z=await O({action:"move",account:G,slot:U},`move-${G}`),H=iW({menuFor:((J=d.current)==null?void 0:J.num)??null,shareFor:(b==null?void 0:b.num)??null},G,Z);if(await n(!0),H){if(H.menuFor!=null){const fe=document.getElementById(`ap-menu-${G}`),Ne=document.getElementById(`ap-more-${H.menuFor}`);Ne&&(fe!=null&&fe.contains(document.activeElement)||_l(((ee=document.activeElement)==null?void 0:ee.tagName)??null))&&Ne.focus()}((re=d.current)==null?void 0:re.num)===G&&I(),k(H.confirmRemove),H.shareFor==null&&(S(null),j(!1)),T(H.swapNote);const oe=H.swapNote;oe&&window.setTimeout(()=>T(fe=>fe===oe?null:fe),Q7),M(null),s(H.menuFor)}return Z};return{menu:o,menuFor:u,menuError:f,aliasDraft:m,confirmRemove:w,share:b,shareCopied:_,slotDraft:R,swapNote:E,showMenu:A,dropMenu:I,closeMenu:L,sayInMenu:z,startRename:V,typeAlias:$,doAlias:D,startMove:P,pickSlot:F,doSlot:async(G,U,Z)=>{if(!Z.sends){L(G);return}await W(G,U)},makeShare:Y,copyShare:K,pressRemove:G=>{const U=Date.now(),Z=jl({armedFor:w,target:G,armedAt:v.current,now:U,gapMs:Sl});if(Z==="arm"){k(G),v.current=U;return}Z!=="ignore"&&(k(null),O({action:"remove",account:G},`rm-${G}`).then(H=>{var J;n(!0),H!=null&&H.ok&&(((J=d.current)==null?void 0:J.num)===G&&I(),s(null))}))}}}function r9(e,t){return!e||!t||t.some(n=>n.num===e.num&&n.active)?e:null}function s9({data:e,claim:t,release:n,load:r,sayFailure:s,clearFailure:o,sayInMenu:l,rescueFocus:u}){const[d,f]=x.useState(null),h=x.useCallback(async(g,w,k="panel")=>{if(!t(w))return null;const v=k==="menu"?l:s;v(null);try{const b=await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)}),S=await b.json().catch(()=>null);return S!=null&&S.ok||v({text:sx(S,"command failed",b.status),raw:Tl(S)}),S}catch{return v({text:"server unreachable"}),null}finally{n()}},[t,n,l,s]);return x.useEffect(()=>{!(e!=null&&e.ok)||!e.accounts||f(g=>r9(g,e.accounts))},[e]),{switched:d,post:h,doSwitch:async(g,w)=>{if(t(`switch-${g}`)){o(),f(null);try{const v=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:g})})).json().catch(()=>null);v!=null&&v.ok?f({num:g,name:w}):s({text:sx(v,"the switch failed"),raw:Tl(v),row:g}),await r(!0)}catch{s({text:"server unreachable",row:g})}finally{n(),u(g)}}}}}const a9=1800;function o9({auto:e,post:t,load:n}){var k;const[r,s]=x.useState(null),[o,l]=x.useState(!1),u=x.useRef(null),d=x.useRef(null),f=((k=e==null?void 0:e.settings["autoswitch.threshold"])==null?void 0:k.value)??"90",h=r??f,m=hW(h,f);return{threshold:f,thresholdPick:h,thresholdCtl:m,thresholdSaved:o,thresholdRef:u,thresholdSaveRef:d,proposeThreshold:v=>s(v),doThreshold:async(v,b)=>{if(b.sends){const S=await t({action:"setting",key:"autoswitch.threshold",value:v},"threshold");if(await n(!0),!(S!=null&&S.ok))return;s(null)}l(!0),window.setTimeout(()=>{var S;document.activeElement===d.current&&((S=u.current)==null||S.focus()),l(!1)},a9)}}}const i9=Object.freeze({text:"couldn't reach the deck server",reload:!0}),l9=Object.freeze({text:"still waiting on the deck server — claude-swap can be slow to answer",reload:!0});async function kS(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function c9(e){const t=e.find(r=>!r.ok);if(!t)return null;const n=Tl(t.body);return{text:sx(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function NS(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 EM=15e3,u9=3e4;function d9(e){const[t,n]=x.useState(null),[r,s]=x.useState(null),[o,l]=x.useState(!1),[u,d]=x.useState(null),f=x.useRef(null),h=x.useCallback(async(w=!1)=>{w&&l(!0);const k=new AbortController,v=window.setTimeout(()=>k.abort(),u9);try{const[b,S]=await Promise.all([fetch(`/api/claude-accounts${w?"?refresh=1":""}`,{signal:k.signal}),fetch("/api/cswap-auto",{signal:k.signal})]);if(b.ok){const j=await b.json();n(j),e(j)}S.ok&&s(await S.json());const _=c9([await kS(b),await kS(S)]);d(j=>NS(j,_))}catch{d(b=>NS(b,k.signal.aborted?l9:i9))}finally{window.clearTimeout(v),w&&l(!1)}},[e]);x.useEffect(()=>(h(!0),f.current=window.setInterval(()=>h(!1),EM),()=>{f.current!=null&&window.clearInterval(f.current)}),[h]);const m=x.useCallback(w=>d(w),[]),g=x.useCallback(()=>d(null),[]);return{data:t,auto:r,reloading:o,failure:u,load:h,sayFailure:m,clearFailure:g}}const h9="#ap-rest-entry";function f9(e){return[`#${e}`,h9,...tM(null)]}function p9(e){const t=x.useRef(null),n=s=>{t.current=s.target.id||null},r=s=>{s.target.isConnected&&(t.current=null)};return x.useLayoutEffect(()=>{var o;const s=t.current;if(!(!s||!_l(((o=document.activeElement)==null?void 0:o.tagName)??null)))for(const l of f9(s)){const u=document.querySelector(l);if(u){u.focus();return}}},[e]),{onFocus:n,onBlur:r}}function m9({onClose:e,leaving:t}){var ot,Gt;const{busy:n,claim:r,release:s,pressProps:o}=J7(),[l,u]=x.useState("accounts"),[d,f]=x.useState(!1),[h,m]=x.useState(null),g=x.useRef(h);g.current=h;const[w,k]=x.useState(!1),[v,b]=x.useState(!1),[S,_]=x.useState(null),[j,E]=x.useState([]),[T,R]=x.useState(!1),M=x.useCallback(ge=>E(Oe=>G7(Oe,ge.accounts)),[]),{data:O,auto:I,reloading:A,failure:L,load:z,sayFailure:V,clearFailure:$}=d9(M),P=p9(O),F=x.useCallback(ge=>{window.requestAnimationFrame(()=>{var Oe;if(_l(((Oe=document.activeElement)==null?void 0:Oe.tagName)??null))for(const Fe of tM(ge)){const Lt=document.querySelector(Fe);if(Lt){Lt.focus();return}}})},[]),Y=n9({claim:r,release:s,load:z,clearFailure:$,rescueFocus:F}),{menu:K,menuFor:D,swapNote:W,showMenu:B,dropMenu:X,closeMenu:G,sayInMenu:U}=Y,{switched:Z,post:H,doSwitch:J}=s9({data:O,claim:r,release:s,load:z,sayFailure:V,clearFailure:$,sayInMenu:U,rescueFocus:F}),{threshold:ee,thresholdPick:re,thresholdCtl:oe,thresholdSaved:fe,thresholdRef:Ne,thresholdSaveRef:ke,proposeThreshold:we,doThreshold:ve}=o9({auto:I,post:H,load:z}),$e=iM(),ye=(ot=O==null?void 0:O.accounts)==null?void 0:ot.find(ge=>ge.active),ue=ye?Yu(ye,$e):null,se=(O==null?void 0:O.accounts)??[],xe=ye?se.filter(ge=>!ge.active):[],Ae=xe.length?se.filter(ge=>ge.active):se,Le=K7(xe,$e),Ie=Y7(ye,ee),qe=X7(I),nt=ge=>T&&xe.some(Oe=>Oe.num===ge)?"ap-rest-list":"ap-scroll",rt=(ge,Oe="first")=>{B(ge,Oe),m(null)},Ye=(ge,Oe)=>{X(),m(Fe=>(Fe==null?void 0:Fe.anchor)===Oe?null:{num:ge,anchor:Oe})},ct=x.useCallback((ge=!1)=>{var Fe;const Oe=g.current;ge&&Oe&&((Fe=document.getElementById(Oe.anchor))==null||Fe.focus()),m(null)},[]),At=()=>{X(),m(null),u("lan")},vt=x.useRef(l);x.useEffect(()=>{vt.current!==l&&(vt.current=l,window.requestAnimationFrame(()=>{var ge;(ge=document.getElementById(l==="lan"?"ap-lan-back":"ap-lan-entry"))==null||ge.focus()}))},[l]),x.useEffect(()=>{O!=null&&O.ok&&f(!0)},[O==null?void 0:O.ok]),x.useEffect(()=>{t&&(X(),m(null))},[t,X]),x.useEffect(()=>{K&&(O!=null&&O.accounts)&&!O.accounts.some(ge=>ge.num===K.num)&&X(),h&&(O!=null&&O.accounts)&&!O.accounts.some(ge=>ge.num===h.num)&&m(null)},[O,K,h,X]),x.useEffect(()=>{S==null||!(O!=null&&O.accounts)||O.accounts.some(ge=>ge.num===S.num)||(_(null),F(null))},[O,S,F]);const Ve=i.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:i.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:i.jsx("path",{d:"M3.4 3.4l7.2 7.2M10.6 3.4l-7.2 7.2"})})}),ut=ge=>{const Oe=j.includes(Td(ge)),Fe=D===ge.num,Lt=(L==null?void 0:L.row)===ge.num?L:null,Kt=(Z==null?void 0:Z.num)===ge.num,Mt=(W==null?void 0:W.at)===ge.num?W:null,on=Mt?se.find(Xn=>Xn.num===Mt.displaced):void 0,Ut=(h==null?void 0:h.anchor)===`ap-issue-${ge.num}`;return i.jsx(xH,{a:ge,nowSec:$e,opened:Oe,onToggleLanes:()=>E(Xn=>V7(Xn,ge)),busy:n,pressProps:o,onSwitch:J,menuOpen:Fe,onOpenMenu:rt,onCloseMenu:G,refusal:Lt,onDismissRefusal:()=>$(),switchedHere:Kt,swapped:Mt,displaced:on,issueExpanded:Ut,onOpenIssue:Ye},ge.num)},Ze=O!=null&&O.ok&&(I!=null&&I.ok)?i.jsx(SH,{auto:I,threshold:ee,thresholdPick:re,thresholdCtl:oe,thresholdSaved:fe,thresholdRef:Ne,thresholdSaveRef:ke,proposeThreshold:we,doThreshold:ve,pressProps:o,post:H,load:z}):null;return i.jsxs("aside",{className:`accounts-panel${t?" leaving":""}`,id:"accounts-panel","aria-label":"Claude accounts",onFocus:P.onFocus,onBlur:P.onBlur,children:[l==="accounts"&&i.jsx(kH,{canShare:(((Gt=O==null?void 0:O.accounts)==null?void 0:Gt.length)??0)>0,onAdd:()=>k(!0),onShareSet:()=>b(!0),onReload:()=>z(!0),pressProps:o,reloading:A,closeButton:Ve}),l==="accounts"&&i.jsx("div",{className:"ap-scroll",id:"ap-scroll",children:O==null?L?i.jsxs("div",{className:"ap-empty",role:"alert",children:[i.jsx("span",{title:L.raw||void 0,children:L.text}),i.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",EM/1e3," seconds."]}),i.jsx("button",{type:"button",className:"ap-fix",...o("reload",A),onClick:()=>z(!0).then(()=>F(null)),children:A?"trying…":"try again"})]}):i.jsx("div",{className:"ap-empty",children:"Checking…"}):O.ok?i.jsxs(i.Fragment,{children:[ye&&(ue==null?void 0:ue.tone)==="warn"&&i.jsxs("div",{className:"ap-notice",children:[i.jsxs("button",{type:"button",id:"ap-notice",className:"ap-issue","data-tone":"warn","aria-haspopup":"dialog","aria-expanded":(h==null?void 0:h.anchor)==="ap-notice","aria-controls":(h==null?void 0:h.anchor)==="ap-notice"?"ap-issue-pop":void 0,onClick:()=>Ye(ye.num,"ap-notice"),children:[i.jsx(u0,{}),i.jsx("span",{className:"ap-issue-text",children:"Current account needs attention"})]}),ue.fix&&i.jsx("button",{type:"button",className:"ap-notice-fix",onClick:()=>k(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"Sign in"})]}),i.jsx("ul",{className:"ap-list",children:Ae.map(ut)}),xe.length>0&&i.jsx(B7,{peers:Le,strained:Ie,armed:qe,threshold:I!=null&&I.ok?ee:null,open:T,onToggle:()=>R(ge=>!ge)}),xe.length>0&&T&&i.jsxs("div",{className:"ap-rest-panel",id:"ap-rest-panel",children:[i.jsx("ul",{className:"ap-list ap-others",id:"ap-rest-list",children:xe.map(ut)}),Ze]}),xe.length===0&&Ze,L&&L.row==null&&i.jsxs("div",{className:"ap-failure",role:"alert",children:[i.jsx("span",{className:"ap-failure-text",title:L.raw||void 0,children:L.text}),i.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>$(),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),K&&(()=>{var Oe;const ge=(Oe=O.accounts)==null?void 0:Oe.find(Fe=>Fe.num===K.num);return ge?i.jsx(fW,{a:ge,accountMenu:Y,slots:(O.accounts??[]).map(Fe=>Fe.num),boundaryId:nt(ge.num),nowSec:$e,busy:n,pressProps:o,rotating:!!(I!=null&&I.enabled||I!=null&&I.external),onProjects:()=>{_({num:ge.num,name:ge.alias??ge.email??`account ${ge.num}`}),G(ge.num)},onRotation:()=>H({action:"account",account:ge.num,enabled:ge.disabled},`rot-${ge.num}`,"menu").then(Fe=>{z(!0),Fe!=null&&Fe.ok&&G(ge.num)})}):null})(),h&&(()=>{var Fe;const ge=(Fe=O.accounts)==null?void 0:Fe.find(Lt=>Lt.num===h.num),Oe=ge?Yu(ge,$e):null;return!ge||!Oe?null:i.jsx(fH,{anchorId:h.anchor,boundaryId:h.anchor==="ap-notice"?"ap-scroll":nt(ge.num),issue:Oe,who:ge.alias??ge.email??`account ${ge.num}`,fetchedAt:ge.fetchedAt,nowSec:$e,onClose:ct,onSignIn:()=>k(!0)})})()]}):i.jsx(bH,{data:O})}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Z?`Now active: ${Z.name}`:""}),d&&i.jsx(F7,{accounts:Z7((O==null?void 0:O.accounts)??[]),onChanged:()=>z(!0),view:l==="lan",onOpen:At,onBack:()=>u("accounts"),closeButton:Ve}),w&&i.jsx(aW,{onClose:()=>k(!1),onChanged:()=>z(!0)}),v&&i.jsx(H7,{accounts:((O==null?void 0:O.accounts)??[]).map(ge=>({num:ge.num,email:ge.email,alias:ge.alias,org:ge.org})),onClose:()=>b(!1),copyText:ja}),S!=null&&(()=>{var Oe;const ge=(Oe=O==null?void 0:O.accounts)==null?void 0:Oe.find(Fe=>Fe.num===S.num);return O!=null&&O.accounts&&!ge?null:i.jsx(dH,{num:S.num,name:ge?ge.alias??ge.email??`account ${ge.num}`:S.name,onClose:()=>_(null)})})()]})}const g9=16,y9=120;function w9(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 v9(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 x9(e,t){return w9(e,t,g9)?"over":v9(e,t)<=y9?"near":"far"}function b9(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 k9(){const[e,t]=x.useState(!1),[n,r]=x.useState(""),[s,o]=x.useState("far"),l=x.useRef(null),u=Su(e,140),d=x.useCallback(g=>{var v;const w=(v=l.current)==null?void 0:v.getBoundingClientRect(),k=b9(g);return w&&k?x9(k,w):"far"},[]),f=x.useCallback(g=>{g!==null&&(r(g),t(!0)),o("far")},[]),h=x.useCallback(g=>{o(d(g))},[d]),m=x.useCallback((g,w)=>{const k=w&&d(g)==="over";return t(!1),k},[d]);return{trashDragging:e,trashLabel:n,trashState:s,trashZoneRef:l,trashPhase:u,beginTrashDrag:f,trackTrashDrag:h,endTrashDrag:m}}const N9=420;function S9(){const[e,t]=x.useState(!1),n=x.useRef(null),r=x.useCallback(()=>{n.current&&(window.clearTimeout(n.current),n.current=null),t(!1)},[]),s=x.useCallback(o=>{o.length!==0&&queueMicrotask(()=>{t(!0),n.current&&window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!1),N9+80)})},[]);return x.useEffect(()=>()=>{n.current&&window.clearTimeout(n.current)},[]),{bubbling:e,endBubble:r,onBubble:s}}const y0=11,CM=7.2,TM=6.6,j9={width:104,height:48},SS={width:96,height:44},RM={width:220,height:103};function _9(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)?RM:{width:Math.max(160,t),height:Math.max(72,n)}}function sp(e,t,n){return e.width*t>=n.width&&e.height*t>=n.height}function E9(e,t,n=RM){if(!Number.isFinite(t)||t<=0)return e??"detail";const r=y0*t;return e==="detail"?r>=TM?"detail":sp(n,t,SS)?"compact":"overview":r>=CM?"detail":e==="compact"?sp(n,t,SS)?"compact":"overview":sp(n,t,j9)?"compact":"overview"}const C9=CM/y0,T9=TM/y0;function R9(e,t){return e>=C9?e:Math.max(e,Math.min(t,T9-.001))}const A9=.8,M9=1;function $9({stateRef:e,measuredRef:t,measuredVersionRef:n,canvasRef:r}){const[s,o]=x.useState("detail"),l=x.useRef(null),u=x.useRef(null),d=x.useCallback(()=>{var w;const h=n.current;if(((w=u.current)==null?void 0:w.version)===h)return u.current.card;const m=[];for(const k of e.current.agents.keys()){const v=t.current.get(k);v&&m.push(v)}const g=_9(m);return u.current={version:h,card:g},g},[]),f=x.useCallback(h=>{var g;const m=E9(l.current,h,d());return m===l.current?null:(l.current=m,(g=r.current)==null||g.setAttribute("data-lod",m),o(m),m)},[d,r]);return{lod:s,lodRef:l,applyZoom:f}}const I9=40,O9=120;function L9(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,f,h)=>{if(n!=null){if(r<=d)return;l()}const m=Math.min(h,Math.max(0,d-f));r=d,n=t.setTimeout(o,m)};return{live(d=I9){const f=t.now(),h=Math.max(s+d,f);if(h<=f){l(),o();return}u(h,f,d)},replay(d=O9){l(),r=t.now()+d,n=t.setTimeout(o,d)},flush(){l(),o()},cancel(){l()}}}const P9=1024*1024,jS=5,AM=.8,hx=24,D9="agent-dag.soundCustom.done",F9="agent-dag.soundCustom.needs-input",ul={done:D9,"needs-input":F9};function Rl(e){if(e.kind!=="audio")return e;const{bytes:t,...n}=e;return n}function _S(e){return!e||!/^[a-zA-Z0-9._-]{1,96}$/.test(e)?null:e}function q9(e){return{done:_S(e(ul.done)),"needs-input":_S(e(ul["needs-input"]))}}function B9(e,t){return{done:e.done===t?null:e.done,"needs-input":e["needs-input"]===t?null:e["needs-input"]}}function z9(e){return e.done&&e.done===e["needs-input"]?e.done:null}const U9={wav:"audio/wav",wave:"audio/wav",mp3:"audio/mpeg",ogg:"audio/ogg",oga:"audio/ogg",webm:"audio/webm",m4a:"audio/mp4",mp4:"audio/mp4"},MM=new Set(["audio/wav","audio/x-wav","audio/mpeg","audio/mp3","audio/ogg","audio/webm","audio/mp4"]);function $M(e,t){const n=t.toLowerCase().split(";")[0].trim();if(MM.has(n))return n;const r=e.toLowerCase().split(".").pop()??"";return U9[r]??n}function ES(e,t){const n=$M(e.name,e.type);if(!MM.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>P9)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>jS)return`Audio must be ${jS} seconds or shorter.`}return null}function fx(e){return e>=hx?`There are already ${hx} custom sounds. Delete one first.`:null}function H9(e,t){const n=e.indexOf(t);return n<0?null:e[n+1]??e[n-1]??null}function W9(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,AM/t)}function IM(){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 V9(e,t,n=IM()){var f;const r=((f=e.name)==null?void 0:f.trim())||"Custom sound",s=ES({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=ES({name:r,type:e.type,size:e.size},l.duration);if(u)throw new Error(u);const d=Array.from({length:l.numberOfChannels},(h,m)=>l.getChannelData(m));return{id:n,name:r.replace(/\.(wav|wave|mp3|ogg|oga|webm|m4a|mp4)$/i,"")||"Custom sound",kind:"audio",mime:$M(r,e.type),duration:l.duration,normalizationGain:W9(d),bytes:o}}function G9(e,t=IM()){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 K9="ccdeck-notification-audio",Y9=2,Wn="assets",wr="summaries";function Bl(){return typeof window<"u"?window.ccdeckNotificationAudio??null:null}function X9(){return new Promise((e,t)=>{const n=indexedDB.open(K9,Y9);n.onupgradeneeded=r=>{const s=n.result,o=s.objectStoreNames.contains(Wn)?n.transaction.objectStore(Wn):s.createObjectStore(Wn,{keyPath:"id"});if(s.objectStoreNames.contains(wr))return;const l=s.createObjectStore(wr,{keyPath:"id"});if(r.oldVersion<1)return;const u=o.openCursor();u.onsuccess=()=>{const d=u.result;d&&(l.put(Rl(d.value)),d.continue())}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??new Error("Could not open local audio storage."))})}async function zl(e,t,n){const r=await X9();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 Z9(){const e=Bl();return e?e.list():typeof indexedDB>"u"?[]:await zl([wr],"readonly",t=>t.objectStore(wr).getAll())??[]}async function J9(e){const t=Bl();return t?t.get(e):typeof indexedDB>"u"?null:await zl([Wn],"readonly",n=>n.objectStore(Wn).get(e))??null}async function CS(e){const t=Bl();if(t){await t.put(e);return}if(typeof indexedDB>"u")throw new Error("Local audio storage is unavailable in this browser.");await zl([Wn,wr],"readwrite",n=>{n.objectStore(Wn).put(e),n.objectStore(wr).put(Rl(e))})}async function Q9(e,t){const n=Bl();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 zl([Wn,wr],"readwrite",r=>{const s=r.objectStore(Wn),o=s.get(e);o.onsuccess=()=>{const l=o.result;if(!l)return;const u={...l,name:t};s.put(u),r.objectStore(wr).put(Rl(u))}})}async function eV(e){const t=Bl();if(t){await t.remove(e);return}typeof indexedDB>"u"||await zl([Wn,wr],"readwrite",n=>{n.objectStore(Wn).delete(e),n.objectStore(wr).delete(e)})}const Cu=["done","needs-input"],tV=[{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}]}],nV=[{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}]}],w0={done:tV,"needs-input":nV},pn="two";function px(e,t){const n=w0[e];return n.find(r=>r.id===t)??n.find(r=>r.id===pn)??n[0]}function OM(e,t){return w0[e].some(r=>r.id===t)?t:pn}px("done",pn).notes,px("needs-input",pn).notes;const TS=.04,LM=.24,Tu=0,Ju=100,mx=5,ka=50;function Ho(e){if(!Number.isFinite(e))return ka;const t=Math.round(e/mx)*mx;return Math.min(Ju,Math.max(Tu,t))}function PM(e){if(e==null)return ka;const t=e.trim();return/^-?\d+(\.\d+)?$/.test(t)?Ho(Number(t)):ka}function v0(e){const t=Ho(e),n=TS+(LM-TS)*(t/Ju);return Math.round(n*1e4)/1e4}function rV(e,t){const n=t.trim,r=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(v0(e)*r*1e4)/1e4}const sV=.012,RS=1e-4;function aV(e){return Math.min(1,v0(e)/LM)}function oV(e,t){const n=e*(v0(t)/AM);return Math.max(1e-4,n)}const iV=160,lV="agent-dag.soundLevel.done",cV="agent-dag.soundLevel.needs-input",uV="agent-dag.soundFigure.done",dV="agent-dag.soundFigure.needs-input",DM={done:lV,"needs-input":cV},Qu={done:uV,"needs-input":dV},gx={done:{level:ka,figure:pn},"needs-input":{level:ka,figure:pn}};function hV(e){const t=n=>({level:PM(e(DM[n])),figure:OM(n,e(Qu[n]))});return{done:t("done"),"needs-input":t("needs-input")}}function fV(e,t){return(e??gx)[t]??gx[t]}const pV={Stop:"done",Notification:"needs-input"};function mV(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:sn(pV,n)??null}const gV=6,yV="ccdeck-tabs";function wV(e){return e>=gV}function vV(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=f=>{const h=f.data;(h==null?void 0:h.kind)==="here"&&h.to===t&&h.streaming&&u.add(h.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 xV({stateRef:e,rerender:t,pauseGate:n,chimesRef:r,desktopUpdateRef:s}){const[o,l]=x.useState(!1),[u,d]=x.useState(!1),[f,h]=x.useState(!1),m=x.useRef(!0),[g,w]=x.useState(null);return x.useEffect(()=>{const k=new EventSource("/events"),v=L9(t,{now:()=>Date.now(),setTimeout:(j,E)=>window.setTimeout(j,E),clearTimeout:j=>window.clearTimeout(j)});let b=!1;const S=typeof BroadcastChannel=="function"?vV(new BroadcastChannel(yV),Math.random().toString(36).slice(2),()=>b):null,_=window.setInterval(()=>{b||!S||S.ask(600).then(j=>{b||d(wV(j))})},3e3);return k.addEventListener("open",()=>{l(!0),h(!0)}),k.addEventListener("error",()=>{l(!1),w(null)}),k.addEventListener("open",()=>{b=!0,d(!1)}),k.addEventListener("error",()=>{b=!1}),k.addEventListener("replay-end",()=>{m.current=!1,v.flush(),w(Date.now())}),k.addEventListener("desktop-update",j=>s.current(j.data)),k.addEventListener("hook",j=>{var E;try{const T=JSON.parse(j.data);if(!n.accept(T))return;e.current=fA(e.current,T);const R=T.replay===!0||m.current||Date.now()-T.receivedAt>3e4;R?v.replay():v.live();const M=mV(T,R);M&&((E=r.current)==null||E.play(M))}catch{}}),()=>{k.close(),v.cancel(),window.clearInterval(_),S==null||S.leave()}},[t]),{live:o,tabCapped:u,everConnected:f,liveSince:g}}const bV=200,kV=5*6e4,NV=6,SV=2*6e4;function pu(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function jV(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 _V(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`),n.kind==="root"&&t.add(e0(n.id));return t}function EV(e){const t=new Set;for(const n of e)t.add(n.id),n.kind==="root"&&t.add(e0(n.id));return t}function CV(e,t){let n=h6(e,t,fN);f6(e,t,fN)&&(n=!0);const r=[],s=o=>{r.push(o)};return c6(e,t,bV,kV,s)&&(n=!0),u6(e,t,NV,SV,s)&&(n=!0),{changed:n,forgotten:r}}function TV(e,t){const[n,r]=x.useState(()=>new Set),[s,o]=x.useState(null),l=x.useCallback((f,h,m=!h)=>{r(g=>{if(!h)return new Set([f]);const w=new Set(g);return w.has(f)?w.delete(f):w.add(f),w}),o(g=>h&&g===f?g:f),!h&&m&&t(!0)},[]),u=x.useCallback(()=>{r(new Set),o(null)},[]),d=x.useCallback(()=>{r(f=>jV(f,e.current.agents)),o(f=>f!=null&&!e.current.agents.has(f)?null:f)},[e]);return{selectedIds:n,primarySelectedId:s,selectAgent:l,clearSelection:u,pruneSelectionToBoard:d}}function RV({stateRef:e,rerender:t,pruneSelectionToBoard:n,setContextFor:r,setSummaryFor:s}){const[o,l]=x.useState(Date.now());return x.useEffect(()=>{const u=setInterval(()=>{const d=Date.now();l(d);const{changed:f,forgotten:h}=CV(e.current,d);h.length>0&&fetch("/api/forget",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ids:h})}).catch(()=>{}),n(),r(m=>m!=null&&!e.current.agents.has(m)?null:m),s(m=>m!=null&&!e.current.agents.has(m)?null:m),f&&t()},250);return()=>clearInterval(u)},[t]),o}function x0(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 ap,AS;function AV(){if(AS)return ap;AS=1;function e(){this.__data__=[],this.size=0}return ap=e,ap}var op,MS;function Jo(){if(MS)return op;MS=1;function e(t,n){return t===n||t!==t&&n!==n}return op=e,op}var ip,$S;function Rd(){if($S)return ip;$S=1;var e=Jo();function t(n,r){for(var s=n.length;s--;)if(e(n[s][0],r))return s;return-1}return ip=t,ip}var lp,IS;function MV(){if(IS)return lp;IS=1;var e=Rd(),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 lp=r,lp}var cp,OS;function $V(){if(OS)return cp;OS=1;var e=Rd();function t(n){var r=this.__data__,s=e(r,n);return s<0?void 0:r[s][1]}return cp=t,cp}var up,LS;function IV(){if(LS)return up;LS=1;var e=Rd();function t(n){return e(this.__data__,n)>-1}return up=t,up}var dp,PS;function OV(){if(PS)return dp;PS=1;var e=Rd();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 dp=t,dp}var hp,DS;function Ad(){if(DS)return hp;DS=1;var e=AV(),t=MV(),n=$V(),r=IV(),s=OV();function o(l){var u=-1,d=l==null?0:l.length;for(this.clear();++u<d;){var f=l[u];this.set(f[0],f[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=r,o.prototype.set=s,hp=o,hp}var fp,FS;function LV(){if(FS)return fp;FS=1;var e=Ad();function t(){this.__data__=new e,this.size=0}return fp=t,fp}var pp,qS;function PV(){if(qS)return pp;qS=1;function e(t){var n=this.__data__,r=n.delete(t);return this.size=n.size,r}return pp=e,pp}var mp,BS;function DV(){if(BS)return mp;BS=1;function e(t){return this.__data__.get(t)}return mp=e,mp}var gp,zS;function FV(){if(zS)return gp;zS=1;function e(t){return this.__data__.has(t)}return gp=e,gp}var yp,US;function FM(){if(US)return yp;US=1;var e=typeof Yc=="object"&&Yc&&Yc.Object===Object&&Yc;return yp=e,yp}var wp,HS;function Yn(){if(HS)return wp;HS=1;var e=FM(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return wp=n,wp}var vp,WS;function Qo(){if(WS)return vp;WS=1;var e=Yn(),t=e.Symbol;return vp=t,vp}var xp,VS;function qV(){if(VS)return xp;VS=1;var e=Qo(),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 f=!0}catch{}var h=r.call(l);return f&&(u?l[s]=d:delete l[s]),h}return xp=o,xp}var bp,GS;function BV(){if(GS)return bp;GS=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return bp=n,bp}var kp,KS;function _a(){if(KS)return kp;KS=1;var e=Qo(),t=qV(),n=BV(),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 kp=l,kp}var Np,YS;function Rn(){if(YS)return Np;YS=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return Np=e,Np}var Sp,XS;function Ul(){if(XS)return Sp;XS=1;var e=_a(),t=Rn(),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 Sp=l,Sp}var jp,ZS;function zV(){if(ZS)return jp;ZS=1;var e=Yn(),t=e["__core-js_shared__"];return jp=t,jp}var _p,JS;function UV(){if(JS)return _p;JS=1;var e=zV(),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 _p=n,_p}var Ep,QS;function qM(){if(QS)return Ep;QS=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 Ep=n,Ep}var Cp,ej;function HV(){if(ej)return Cp;ej=1;var e=Ul(),t=UV(),n=Rn(),r=qM(),s=/[\\^$.*+?()[\]{}|]/g,o=/^\[object .+?Constructor\]$/,l=Function.prototype,u=Object.prototype,d=l.toString,f=u.hasOwnProperty,h=RegExp("^"+d.call(f).replace(s,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(g){if(!n(g)||t(g))return!1;var w=e(g)?h:o;return w.test(r(g))}return Cp=m,Cp}var Tp,tj;function WV(){if(tj)return Tp;tj=1;function e(t,n){return t==null?void 0:t[n]}return Tp=e,Tp}var Rp,nj;function Ea(){if(nj)return Rp;nj=1;var e=HV(),t=WV();function n(r,s){var o=t(r,s);return e(o)?o:void 0}return Rp=n,Rp}var Ap,rj;function b0(){if(rj)return Ap;rj=1;var e=Ea(),t=Yn(),n=e(t,"Map");return Ap=n,Ap}var Mp,sj;function Md(){if(sj)return Mp;sj=1;var e=Ea(),t=e(Object,"create");return Mp=t,Mp}var $p,aj;function VV(){if(aj)return $p;aj=1;var e=Md();function t(){this.__data__=e?e(null):{},this.size=0}return $p=t,$p}var Ip,oj;function GV(){if(oj)return Ip;oj=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return Ip=e,Ip}var Op,ij;function KV(){if(ij)return Op;ij=1;var e=Md(),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 Op=s,Op}var Lp,lj;function YV(){if(lj)return Lp;lj=1;var e=Md(),t=Object.prototype,n=t.hasOwnProperty;function r(s){var o=this.__data__;return e?o[s]!==void 0:n.call(o,s)}return Lp=r,Lp}var Pp,cj;function XV(){if(cj)return Pp;cj=1;var e=Md(),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 Pp=n,Pp}var Dp,uj;function ZV(){if(uj)return Dp;uj=1;var e=VV(),t=GV(),n=KV(),r=YV(),s=XV();function o(l){var u=-1,d=l==null?0:l.length;for(this.clear();++u<d;){var f=l[u];this.set(f[0],f[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=r,o.prototype.set=s,Dp=o,Dp}var Fp,dj;function JV(){if(dj)return Fp;dj=1;var e=ZV(),t=Ad(),n=b0();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return Fp=r,Fp}var qp,hj;function QV(){if(hj)return qp;hj=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return qp=e,qp}var Bp,fj;function $d(){if(fj)return Bp;fj=1;var e=QV();function t(n,r){var s=n.__data__;return e(r)?s[typeof r=="string"?"string":"hash"]:s.map}return Bp=t,Bp}var zp,pj;function eG(){if(pj)return zp;pj=1;var e=$d();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return zp=t,zp}var Up,mj;function tG(){if(mj)return Up;mj=1;var e=$d();function t(n){return e(this,n).get(n)}return Up=t,Up}var Hp,gj;function nG(){if(gj)return Hp;gj=1;var e=$d();function t(n){return e(this,n).has(n)}return Hp=t,Hp}var Wp,yj;function rG(){if(yj)return Wp;yj=1;var e=$d();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 Wp=t,Wp}var Vp,wj;function k0(){if(wj)return Vp;wj=1;var e=JV(),t=eG(),n=tG(),r=nG(),s=rG();function o(l){var u=-1,d=l==null?0:l.length;for(this.clear();++u<d;){var f=l[u];this.set(f[0],f[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=r,o.prototype.set=s,Vp=o,Vp}var Gp,vj;function sG(){if(vj)return Gp;vj=1;var e=Ad(),t=b0(),n=k0(),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 Gp=s,Gp}var Kp,xj;function Id(){if(xj)return Kp;xj=1;var e=Ad(),t=LV(),n=PV(),r=DV(),s=FV(),o=sG();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,Kp=l,Kp}var Yp,bj;function N0(){if(bj)return Yp;bj=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 Yp=e,Yp}var Xp,kj;function BM(){if(kj)return Xp;kj=1;var e=Ea(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return Xp=t,Xp}var Zp,Nj;function Od(){if(Nj)return Zp;Nj=1;var e=BM();function t(n,r,s){r=="__proto__"&&e?e(n,r,{configurable:!0,enumerable:!0,value:s,writable:!0}):n[r]=s}return Zp=t,Zp}var Jp,Sj;function Ld(){if(Sj)return Jp;Sj=1;var e=Od(),t=Jo(),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 Jp=s,Jp}var Qp,jj;function Hl(){if(jj)return Qp;jj=1;var e=Ld(),t=Od();function n(r,s,o,l){var u=!o;o||(o={});for(var d=-1,f=s.length;++d<f;){var h=s[d],m=l?l(o[h],r[h],h,o,r):void 0;m===void 0&&(m=r[h]),u?t(o,h,m):e(o,h,m)}return o}return Qp=n,Qp}var em,_j;function aG(){if(_j)return em;_j=1;function e(t,n){for(var r=-1,s=Array(t);++r<t;)s[r]=n(r);return s}return em=e,em}var tm,Ej;function xr(){if(Ej)return tm;Ej=1;function e(t){return t!=null&&typeof t=="object"}return tm=e,tm}var nm,Cj;function oG(){if(Cj)return nm;Cj=1;var e=_a(),t=xr(),n="[object Arguments]";function r(s){return t(s)&&e(s)==n}return nm=r,nm}var rm,Tj;function Wl(){if(Tj)return rm;Tj=1;var e=oG(),t=xr(),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 rm=o,rm}var sm,Rj;function wt(){if(Rj)return sm;Rj=1;var e=Array.isArray;return sm=e,sm}var rl={exports:{}},am,Aj;function iG(){if(Aj)return am;Aj=1;function e(){return!1}return am=e,am}rl.exports;var Mj;function ei(){return Mj||(Mj=1,(function(e,t){var n=Yn(),r=iG(),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,f=d||r;e.exports=f})(rl,rl.exports)),rl.exports}var om,$j;function Pd(){if($j)return om;$j=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 om=n,om}var im,Ij;function S0(){if(Ij)return im;Ij=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return im=t,im}var lm,Oj;function lG(){if(Oj)return lm;Oj=1;var e=_a(),t=S0(),n=xr(),r="[object Arguments]",s="[object Array]",o="[object Boolean]",l="[object Date]",u="[object Error]",d="[object Function]",f="[object Map]",h="[object Number]",m="[object Object]",g="[object RegExp]",w="[object Set]",k="[object String]",v="[object WeakMap]",b="[object ArrayBuffer]",S="[object DataView]",_="[object Float32Array]",j="[object Float64Array]",E="[object Int8Array]",T="[object Int16Array]",R="[object Int32Array]",M="[object Uint8Array]",O="[object Uint8ClampedArray]",I="[object Uint16Array]",A="[object Uint32Array]",L={};L[_]=L[j]=L[E]=L[T]=L[R]=L[M]=L[O]=L[I]=L[A]=!0,L[r]=L[s]=L[b]=L[o]=L[S]=L[l]=L[u]=L[d]=L[f]=L[h]=L[m]=L[g]=L[w]=L[k]=L[v]=!1;function z(V){return n(V)&&t(V.length)&&!!L[e(V)]}return lm=z,lm}var cm,Lj;function Dd(){if(Lj)return cm;Lj=1;function e(t){return function(n){return t(n)}}return cm=e,cm}var sl={exports:{}};sl.exports;var Pj;function j0(){return Pj||(Pj=1,(function(e,t){var n=FM(),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})(sl,sl.exports)),sl.exports}var um,Dj;function Vl(){if(Dj)return um;Dj=1;var e=lG(),t=Dd(),n=j0(),r=n&&n.isTypedArray,s=r?t(r):e;return um=s,um}var dm,Fj;function zM(){if(Fj)return dm;Fj=1;var e=aG(),t=Wl(),n=wt(),r=ei(),s=Pd(),o=Vl(),l=Object.prototype,u=l.hasOwnProperty;function d(f,h){var m=n(f),g=!m&&t(f),w=!m&&!g&&r(f),k=!m&&!g&&!w&&o(f),v=m||g||w||k,b=v?e(f.length,String):[],S=b.length;for(var _ in f)(h||u.call(f,_))&&!(v&&(_=="length"||w&&(_=="offset"||_=="parent")||k&&(_=="buffer"||_=="byteLength"||_=="byteOffset")||s(_,S)))&&b.push(_);return b}return dm=d,dm}var hm,qj;function Fd(){if(qj)return hm;qj=1;var e=Object.prototype;function t(n){var r=n&&n.constructor,s=typeof r=="function"&&r.prototype||e;return n===s}return hm=t,hm}var fm,Bj;function UM(){if(Bj)return fm;Bj=1;function e(t,n){return function(r){return t(n(r))}}return fm=e,fm}var pm,zj;function cG(){if(zj)return pm;zj=1;var e=UM(),t=e(Object.keys,Object);return pm=t,pm}var mm,Uj;function _0(){if(Uj)return mm;Uj=1;var e=Fd(),t=cG(),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 mm=s,mm}var gm,Hj;function Wr(){if(Hj)return gm;Hj=1;var e=Ul(),t=S0();function n(r){return r!=null&&t(r.length)&&!e(r)}return gm=n,gm}var ym,Wj;function Ts(){if(Wj)return ym;Wj=1;var e=zM(),t=_0(),n=Wr();function r(s){return n(s)?e(s):t(s)}return ym=r,ym}var wm,Vj;function uG(){if(Vj)return wm;Vj=1;var e=Hl(),t=Ts();function n(r,s){return r&&e(s,t(s),r)}return wm=n,wm}var vm,Gj;function dG(){if(Gj)return vm;Gj=1;function e(t){var n=[];if(t!=null)for(var r in Object(t))n.push(r);return n}return vm=e,vm}var xm,Kj;function hG(){if(Kj)return xm;Kj=1;var e=Rn(),t=Fd(),n=dG(),r=Object.prototype,s=r.hasOwnProperty;function o(l){if(!e(l))return n(l);var u=t(l),d=[];for(var f in l)f=="constructor"&&(u||!s.call(l,f))||d.push(f);return d}return xm=o,xm}var bm,Yj;function Ca(){if(Yj)return bm;Yj=1;var e=zM(),t=hG(),n=Wr();function r(s){return n(s)?e(s,!0):t(s)}return bm=r,bm}var km,Xj;function fG(){if(Xj)return km;Xj=1;var e=Hl(),t=Ca();function n(r,s){return r&&e(s,t(s),r)}return km=n,km}var al={exports:{}};al.exports;var Zj;function HM(){return Zj||(Zj=1,(function(e,t){var n=Yn(),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(f,h){if(h)return f.slice();var m=f.length,g=u?u(m):new f.constructor(m);return f.copy(g),g}e.exports=d})(al,al.exports)),al.exports}var Nm,Jj;function WM(){if(Jj)return Nm;Jj=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 Nm=e,Nm}var Sm,Qj;function VM(){if(Qj)return Sm;Qj=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 Sm=e,Sm}var jm,e_;function GM(){if(e_)return jm;e_=1;function e(){return[]}return jm=e,jm}var _m,t_;function E0(){if(t_)return _m;t_=1;var e=VM(),t=GM(),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 _m=o,_m}var Em,n_;function pG(){if(n_)return Em;n_=1;var e=Hl(),t=E0();function n(r,s){return e(r,t(r),s)}return Em=n,Em}var Cm,r_;function C0(){if(r_)return Cm;r_=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 Cm=e,Cm}var Tm,s_;function qd(){if(s_)return Tm;s_=1;var e=UM(),t=e(Object.getPrototypeOf,Object);return Tm=t,Tm}var Rm,a_;function KM(){if(a_)return Rm;a_=1;var e=C0(),t=qd(),n=E0(),r=GM(),s=Object.getOwnPropertySymbols,o=s?function(l){for(var u=[];l;)e(u,n(l)),l=t(l);return u}:r;return Rm=o,Rm}var Am,o_;function mG(){if(o_)return Am;o_=1;var e=Hl(),t=KM();function n(r,s){return e(r,t(r),s)}return Am=n,Am}var Mm,i_;function YM(){if(i_)return Mm;i_=1;var e=C0(),t=wt();function n(r,s,o){var l=s(r);return t(r)?l:e(l,o(r))}return Mm=n,Mm}var $m,l_;function XM(){if(l_)return $m;l_=1;var e=YM(),t=E0(),n=Ts();function r(s){return e(s,n,t)}return $m=r,$m}var Im,c_;function gG(){if(c_)return Im;c_=1;var e=YM(),t=KM(),n=Ca();function r(s){return e(s,n,t)}return Im=r,Im}var Om,u_;function yG(){if(u_)return Om;u_=1;var e=Ea(),t=Yn(),n=e(t,"DataView");return Om=n,Om}var Lm,d_;function wG(){if(d_)return Lm;d_=1;var e=Ea(),t=Yn(),n=e(t,"Promise");return Lm=n,Lm}var Pm,h_;function ZM(){if(h_)return Pm;h_=1;var e=Ea(),t=Yn(),n=e(t,"Set");return Pm=n,Pm}var Dm,f_;function vG(){if(f_)return Dm;f_=1;var e=Ea(),t=Yn(),n=e(t,"WeakMap");return Dm=n,Dm}var Fm,p_;function ti(){if(p_)return Fm;p_=1;var e=yG(),t=b0(),n=wG(),r=ZM(),s=vG(),o=_a(),l=qM(),u="[object Map]",d="[object Object]",f="[object Promise]",h="[object Set]",m="[object WeakMap]",g="[object DataView]",w=l(e),k=l(t),v=l(n),b=l(r),S=l(s),_=o;return(e&&_(new e(new ArrayBuffer(1)))!=g||t&&_(new t)!=u||n&&_(n.resolve())!=f||r&&_(new r)!=h||s&&_(new s)!=m)&&(_=function(j){var E=o(j),T=E==d?j.constructor:void 0,R=T?l(T):"";if(R)switch(R){case w:return g;case k:return u;case v:return f;case b:return h;case S:return m}return E}),Fm=_,Fm}var qm,m_;function xG(){if(m_)return qm;m_=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 qm=n,qm}var Bm,g_;function JM(){if(g_)return Bm;g_=1;var e=Yn(),t=e.Uint8Array;return Bm=t,Bm}var zm,y_;function T0(){if(y_)return zm;y_=1;var e=JM();function t(n){var r=new n.constructor(n.byteLength);return new e(r).set(new e(n)),r}return zm=t,zm}var Um,w_;function bG(){if(w_)return Um;w_=1;var e=T0();function t(n,r){var s=r?e(n.buffer):n.buffer;return new n.constructor(s,n.byteOffset,n.byteLength)}return Um=t,Um}var Hm,v_;function kG(){if(v_)return Hm;v_=1;var e=/\w*$/;function t(n){var r=new n.constructor(n.source,e.exec(n));return r.lastIndex=n.lastIndex,r}return Hm=t,Hm}var Wm,x_;function NG(){if(x_)return Wm;x_=1;var e=Qo(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function r(s){return n?Object(n.call(s)):{}}return Wm=r,Wm}var Vm,b_;function QM(){if(b_)return Vm;b_=1;var e=T0();function t(n,r){var s=r?e(n.buffer):n.buffer;return new n.constructor(s,n.byteOffset,n.length)}return Vm=t,Vm}var Gm,k_;function SG(){if(k_)return Gm;k_=1;var e=T0(),t=bG(),n=kG(),r=NG(),s=QM(),o="[object Boolean]",l="[object Date]",u="[object Map]",d="[object Number]",f="[object RegExp]",h="[object Set]",m="[object String]",g="[object Symbol]",w="[object ArrayBuffer]",k="[object DataView]",v="[object Float32Array]",b="[object Float64Array]",S="[object Int8Array]",_="[object Int16Array]",j="[object Int32Array]",E="[object Uint8Array]",T="[object Uint8ClampedArray]",R="[object Uint16Array]",M="[object Uint32Array]";function O(I,A,L){var z=I.constructor;switch(A){case w:return e(I);case o:case l:return new z(+I);case k:return t(I,L);case v:case b:case S:case _:case j:case E:case T:case R:case M:return s(I,L);case u:return new z;case d:case m:return new z(I);case f:return n(I);case h:return new z;case g:return r(I)}}return Gm=O,Gm}var Km,N_;function e$(){if(N_)return Km;N_=1;var e=Rn(),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 Km=n,Km}var Ym,S_;function t$(){if(S_)return Ym;S_=1;var e=e$(),t=qd(),n=Fd();function r(s){return typeof s.constructor=="function"&&!n(s)?e(t(s)):{}}return Ym=r,Ym}var Xm,j_;function jG(){if(j_)return Xm;j_=1;var e=ti(),t=xr(),n="[object Map]";function r(s){return t(s)&&e(s)==n}return Xm=r,Xm}var Zm,__;function _G(){if(__)return Zm;__=1;var e=jG(),t=Dd(),n=j0(),r=n&&n.isMap,s=r?t(r):e;return Zm=s,Zm}var Jm,E_;function EG(){if(E_)return Jm;E_=1;var e=ti(),t=xr(),n="[object Set]";function r(s){return t(s)&&e(s)==n}return Jm=r,Jm}var Qm,C_;function CG(){if(C_)return Qm;C_=1;var e=EG(),t=Dd(),n=j0(),r=n&&n.isSet,s=r?t(r):e;return Qm=s,Qm}var eg,T_;function n$(){if(T_)return eg;T_=1;var e=Id(),t=N0(),n=Ld(),r=uG(),s=fG(),o=HM(),l=WM(),u=pG(),d=mG(),f=XM(),h=gG(),m=ti(),g=xG(),w=SG(),k=t$(),v=wt(),b=ei(),S=_G(),_=Rn(),j=CG(),E=Ts(),T=Ca(),R=1,M=2,O=4,I="[object Arguments]",A="[object Array]",L="[object Boolean]",z="[object Date]",V="[object Error]",$="[object Function]",P="[object GeneratorFunction]",F="[object Map]",Y="[object Number]",K="[object Object]",D="[object RegExp]",W="[object Set]",B="[object String]",X="[object Symbol]",G="[object WeakMap]",U="[object ArrayBuffer]",Z="[object DataView]",H="[object Float32Array]",J="[object Float64Array]",ee="[object Int8Array]",re="[object Int16Array]",oe="[object Int32Array]",fe="[object Uint8Array]",Ne="[object Uint8ClampedArray]",ke="[object Uint16Array]",we="[object Uint32Array]",ve={};ve[I]=ve[A]=ve[U]=ve[Z]=ve[L]=ve[z]=ve[H]=ve[J]=ve[ee]=ve[re]=ve[oe]=ve[F]=ve[Y]=ve[K]=ve[D]=ve[W]=ve[B]=ve[X]=ve[fe]=ve[Ne]=ve[ke]=ve[we]=!0,ve[V]=ve[$]=ve[G]=!1;function $e(ye,ue,se,xe,Ae,Le){var Ie,qe=ue&R,nt=ue&M,rt=ue&O;if(se&&(Ie=Ae?se(ye,xe,Ae,Le):se(ye)),Ie!==void 0)return Ie;if(!_(ye))return ye;var Ye=v(ye);if(Ye){if(Ie=g(ye),!qe)return l(ye,Ie)}else{var ct=m(ye),At=ct==$||ct==P;if(b(ye))return o(ye,qe);if(ct==K||ct==I||At&&!Ae){if(Ie=nt||At?{}:k(ye),!qe)return nt?d(ye,s(Ie,ye)):u(ye,r(Ie,ye))}else{if(!ve[ct])return Ae?ye:{};Ie=w(ye,ct,qe)}}Le||(Le=new e);var vt=Le.get(ye);if(vt)return vt;Le.set(ye,Ie),j(ye)?ye.forEach(function(Ze){Ie.add($e(Ze,ue,se,Ze,ye,Le))}):S(ye)&&ye.forEach(function(Ze,ot){Ie.set(ot,$e(Ze,ue,se,ot,ye,Le))});var Ve=rt?nt?h:f:nt?T:E,ut=Ye?void 0:Ve(ye);return t(ut||ye,function(Ze,ot){ut&&(ot=Ze,Ze=ye[ot]),n(Ie,ot,$e(Ze,ue,se,ot,ye,Le))}),Ie}return eg=$e,eg}var tg,R_;function TG(){if(R_)return tg;R_=1;var e=n$(),t=4;function n(r){return e(r,t)}return tg=n,tg}var ng,A_;function R0(){if(A_)return ng;A_=1;function e(t){return function(){return t}}return ng=e,ng}var rg,M_;function RG(){if(M_)return rg;M_=1;function e(t){return function(n,r,s){for(var o=-1,l=Object(n),u=s(n),d=u.length;d--;){var f=u[t?d:++o];if(r(l[f],f,l)===!1)break}return n}}return rg=e,rg}var sg,$_;function A0(){if($_)return sg;$_=1;var e=RG(),t=e();return sg=t,sg}var ag,I_;function M0(){if(I_)return ag;I_=1;var e=A0(),t=Ts();function n(r,s){return r&&e(r,s,t)}return ag=n,ag}var og,O_;function AG(){if(O_)return og;O_=1;var e=Wr();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 og=t,og}var ig,L_;function Bd(){if(L_)return ig;L_=1;var e=M0(),t=AG(),n=t(e);return ig=n,ig}var lg,P_;function Ta(){if(P_)return lg;P_=1;function e(t){return t}return lg=e,lg}var cg,D_;function r$(){if(D_)return cg;D_=1;var e=Ta();function t(n){return typeof n=="function"?n:e}return cg=t,cg}var ug,F_;function s$(){if(F_)return ug;F_=1;var e=N0(),t=Bd(),n=r$(),r=wt();function s(o,l){var u=r(o)?e:t;return u(o,n(l))}return ug=s,ug}var dg,q_;function a$(){return q_||(q_=1,dg=s$()),dg}var hg,B_;function MG(){if(B_)return hg;B_=1;var e=Bd();function t(n,r){var s=[];return e(n,function(o,l,u){r(o,l,u)&&s.push(o)}),s}return hg=t,hg}var fg,z_;function $G(){if(z_)return fg;z_=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return fg=t,fg}var pg,U_;function IG(){if(U_)return pg;U_=1;function e(t){return this.__data__.has(t)}return pg=e,pg}var mg,H_;function o$(){if(H_)return mg;H_=1;var e=k0(),t=$G(),n=IG();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,mg=r,mg}var gg,W_;function OG(){if(W_)return gg;W_=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 gg=e,gg}var yg,V_;function i$(){if(V_)return yg;V_=1;function e(t,n){return t.has(n)}return yg=e,yg}var wg,G_;function l$(){if(G_)return wg;G_=1;var e=o$(),t=OG(),n=i$(),r=1,s=2;function o(l,u,d,f,h,m){var g=d&r,w=l.length,k=u.length;if(w!=k&&!(g&&k>w))return!1;var v=m.get(l),b=m.get(u);if(v&&b)return v==u&&b==l;var S=-1,_=!0,j=d&s?new e:void 0;for(m.set(l,u),m.set(u,l);++S<w;){var E=l[S],T=u[S];if(f)var R=g?f(T,E,S,u,l,m):f(E,T,S,l,u,m);if(R!==void 0){if(R)continue;_=!1;break}if(j){if(!t(u,function(M,O){if(!n(j,O)&&(E===M||h(E,M,d,f,m)))return j.push(O)})){_=!1;break}}else if(!(E===T||h(E,T,d,f,m))){_=!1;break}}return m.delete(l),m.delete(u),_}return wg=o,wg}var vg,K_;function LG(){if(K_)return vg;K_=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(s,o){r[++n]=[o,s]}),r}return vg=e,vg}var xg,Y_;function $0(){if(Y_)return xg;Y_=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(s){r[++n]=s}),r}return xg=e,xg}var bg,X_;function PG(){if(X_)return bg;X_=1;var e=Qo(),t=JM(),n=Jo(),r=l$(),s=LG(),o=$0(),l=1,u=2,d="[object Boolean]",f="[object Date]",h="[object Error]",m="[object Map]",g="[object Number]",w="[object RegExp]",k="[object Set]",v="[object String]",b="[object Symbol]",S="[object ArrayBuffer]",_="[object DataView]",j=e?e.prototype:void 0,E=j?j.valueOf:void 0;function T(R,M,O,I,A,L,z){switch(O){case _:if(R.byteLength!=M.byteLength||R.byteOffset!=M.byteOffset)return!1;R=R.buffer,M=M.buffer;case S:return!(R.byteLength!=M.byteLength||!L(new t(R),new t(M)));case d:case f:case g:return n(+R,+M);case h:return R.name==M.name&&R.message==M.message;case w:case v:return R==M+"";case m:var V=s;case k:var $=I&l;if(V||(V=o),R.size!=M.size&&!$)return!1;var P=z.get(R);if(P)return P==M;I|=u,z.set(R,M);var F=r(V(R),V(M),I,A,L,z);return z.delete(R),F;case b:if(E)return E.call(R)==E.call(M)}return!1}return bg=T,bg}var kg,Z_;function DG(){if(Z_)return kg;Z_=1;var e=XM(),t=1,n=Object.prototype,r=n.hasOwnProperty;function s(o,l,u,d,f,h){var m=u&t,g=e(o),w=g.length,k=e(l),v=k.length;if(w!=v&&!m)return!1;for(var b=w;b--;){var S=g[b];if(!(m?S in l:r.call(l,S)))return!1}var _=h.get(o),j=h.get(l);if(_&&j)return _==l&&j==o;var E=!0;h.set(o,l),h.set(l,o);for(var T=m;++b<w;){S=g[b];var R=o[S],M=l[S];if(d)var O=m?d(M,R,S,l,o,h):d(R,M,S,o,l,h);if(!(O===void 0?R===M||f(R,M,u,d,h):O)){E=!1;break}T||(T=S=="constructor")}if(E&&!T){var I=o.constructor,A=l.constructor;I!=A&&"constructor"in o&&"constructor"in l&&!(typeof I=="function"&&I instanceof I&&typeof A=="function"&&A instanceof A)&&(E=!1)}return h.delete(o),h.delete(l),E}return kg=s,kg}var Ng,J_;function FG(){if(J_)return Ng;J_=1;var e=Id(),t=l$(),n=PG(),r=DG(),s=ti(),o=wt(),l=ei(),u=Vl(),d=1,f="[object Arguments]",h="[object Array]",m="[object Object]",g=Object.prototype,w=g.hasOwnProperty;function k(v,b,S,_,j,E){var T=o(v),R=o(b),M=T?h:s(v),O=R?h:s(b);M=M==f?m:M,O=O==f?m:O;var I=M==m,A=O==m,L=M==O;if(L&&l(v)){if(!l(b))return!1;T=!0,I=!1}if(L&&!I)return E||(E=new e),T||u(v)?t(v,b,S,_,j,E):n(v,b,M,S,_,j,E);if(!(S&d)){var z=I&&w.call(v,"__wrapped__"),V=A&&w.call(b,"__wrapped__");if(z||V){var $=z?v.value():v,P=V?b.value():b;return E||(E=new e),j($,P,S,_,E)}}return L?(E||(E=new e),r(v,b,S,_,j,E)):!1}return Ng=k,Ng}var Sg,Q_;function c$(){if(Q_)return Sg;Q_=1;var e=FG(),t=xr();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 Sg=n,Sg}var jg,eE;function qG(){if(eE)return jg;eE=1;var e=Id(),t=c$(),n=1,r=2;function s(o,l,u,d){var f=u.length,h=f,m=!d;if(o==null)return!h;for(o=Object(o);f--;){var g=u[f];if(m&&g[2]?g[1]!==o[g[0]]:!(g[0]in o))return!1}for(;++f<h;){g=u[f];var w=g[0],k=o[w],v=g[1];if(m&&g[2]){if(k===void 0&&!(w in o))return!1}else{var b=new e;if(d)var S=d(k,v,w,o,l,b);if(!(S===void 0?t(v,k,n|r,d,b):S))return!1}}return!0}return jg=s,jg}var _g,tE;function u$(){if(tE)return _g;tE=1;var e=Rn();function t(n){return n===n&&!e(n)}return _g=t,_g}var Eg,nE;function BG(){if(nE)return Eg;nE=1;var e=u$(),t=Ts();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 Eg=n,Eg}var Cg,rE;function d$(){if(rE)return Cg;rE=1;function e(t,n){return function(r){return r==null?!1:r[t]===n&&(n!==void 0||t in Object(r))}}return Cg=e,Cg}var Tg,sE;function zG(){if(sE)return Tg;sE=1;var e=qG(),t=BG(),n=d$();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 Tg=r,Tg}var Rg,aE;function ni(){if(aE)return Rg;aE=1;var e=_a(),t=xr(),n="[object Symbol]";function r(s){return typeof s=="symbol"||t(s)&&e(s)==n}return Rg=r,Rg}var Ag,oE;function I0(){if(oE)return Ag;oE=1;var e=wt(),t=ni(),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 Ag=s,Ag}var Mg,iE;function UG(){if(iE)return Mg;iE=1;var e=k0(),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 f=r.apply(this,l);return o.cache=d.set(u,f)||d,f};return o.cache=new(n.Cache||e),o}return n.Cache=e,Mg=n,Mg}var $g,lE;function HG(){if(lE)return $g;lE=1;var e=UG(),t=500;function n(r){var s=e(r,function(l){return o.size===t&&o.clear(),l}),o=s.cache;return s}return $g=n,$g}var Ig,cE;function WG(){if(cE)return Ig;cE=1;var e=HG(),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,f){o.push(d?f.replace(n,"$1"):u||l)}),o});return Ig=r,Ig}var Og,uE;function zd(){if(uE)return Og;uE=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 Og=e,Og}var Lg,dE;function VG(){if(dE)return Lg;dE=1;var e=Qo(),t=zd(),n=wt(),r=ni(),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 Lg=l,Lg}var Pg,hE;function h$(){if(hE)return Pg;hE=1;var e=VG();function t(n){return n==null?"":e(n)}return Pg=t,Pg}var Dg,fE;function Ud(){if(fE)return Dg;fE=1;var e=wt(),t=I0(),n=WG(),r=h$();function s(o,l){return e(o)?o:t(o,l)?[o]:n(r(o))}return Dg=s,Dg}var Fg,pE;function Gl(){if(pE)return Fg;pE=1;var e=ni();function t(n){if(typeof n=="string"||e(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}return Fg=t,Fg}var qg,mE;function Hd(){if(mE)return qg;mE=1;var e=Ud(),t=Gl();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 qg=n,qg}var Bg,gE;function GG(){if(gE)return Bg;gE=1;var e=Hd();function t(n,r,s){var o=n==null?void 0:e(n,r);return o===void 0?s:o}return Bg=t,Bg}var zg,yE;function KG(){if(yE)return zg;yE=1;function e(t,n){return t!=null&&n in Object(t)}return zg=e,zg}var Ug,wE;function f$(){if(wE)return Ug;wE=1;var e=Ud(),t=Wl(),n=wt(),r=Pd(),s=S0(),o=Gl();function l(u,d,f){d=e(d,u);for(var h=-1,m=d.length,g=!1;++h<m;){var w=o(d[h]);if(!(g=u!=null&&f(u,w)))break;u=u[w]}return g||++h!=m?g:(m=u==null?0:u.length,!!m&&s(m)&&r(w,m)&&(n(u)||t(u)))}return Ug=l,Ug}var Hg,vE;function p$(){if(vE)return Hg;vE=1;var e=KG(),t=f$();function n(r,s){return r!=null&&t(r,s,e)}return Hg=n,Hg}var Wg,xE;function YG(){if(xE)return Wg;xE=1;var e=c$(),t=GG(),n=p$(),r=I0(),s=u$(),o=d$(),l=Gl(),u=1,d=2;function f(h,m){return r(h)&&s(m)?o(l(h),m):function(g){var w=t(g,h);return w===void 0&&w===m?n(g,h):e(m,w,u|d)}}return Wg=f,Wg}var Vg,bE;function m$(){if(bE)return Vg;bE=1;function e(t){return function(n){return n==null?void 0:n[t]}}return Vg=e,Vg}var Gg,kE;function XG(){if(kE)return Gg;kE=1;var e=Hd();function t(n){return function(r){return e(r,n)}}return Gg=t,Gg}var Kg,NE;function ZG(){if(NE)return Kg;NE=1;var e=m$(),t=XG(),n=I0(),r=Gl();function s(o){return n(o)?e(r(o)):t(o)}return Kg=s,Kg}var Yg,SE;function Vr(){if(SE)return Yg;SE=1;var e=zG(),t=YG(),n=Ta(),r=wt(),s=ZG();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 Yg=o,Yg}var Xg,jE;function g$(){if(jE)return Xg;jE=1;var e=VM(),t=MG(),n=Vr(),r=wt();function s(o,l){var u=r(o)?e:t;return u(o,n(l,3))}return Xg=s,Xg}var Zg,_E;function JG(){if(_E)return Zg;_E=1;var e=Object.prototype,t=e.hasOwnProperty;function n(r,s){return r!=null&&t.call(r,s)}return Zg=n,Zg}var Jg,EE;function y$(){if(EE)return Jg;EE=1;var e=JG(),t=f$();function n(r,s){return r!=null&&t(r,s,e)}return Jg=n,Jg}var Qg,CE;function QG(){if(CE)return Qg;CE=1;var e=_0(),t=ti(),n=Wl(),r=wt(),s=Wr(),o=ei(),l=Fd(),u=Vl(),d="[object Map]",f="[object Set]",h=Object.prototype,m=h.hasOwnProperty;function g(w){if(w==null)return!0;if(s(w)&&(r(w)||typeof w=="string"||typeof w.splice=="function"||o(w)||u(w)||n(w)))return!w.length;var k=t(w);if(k==d||k==f)return!w.size;if(l(w))return!e(w).length;for(var v in w)if(m.call(w,v))return!1;return!0}return Qg=g,Qg}var ey,TE;function w$(){if(TE)return ey;TE=1;function e(t){return t===void 0}return ey=e,ey}var ty,RE;function v$(){if(RE)return ty;RE=1;var e=Bd(),t=Wr();function n(r,s){var o=-1,l=t(r)?Array(r.length):[];return e(r,function(u,d,f){l[++o]=s(u,d,f)}),l}return ty=n,ty}var ny,AE;function x$(){if(AE)return ny;AE=1;var e=zd(),t=Vr(),n=v$(),r=wt();function s(o,l){var u=r(o)?e:n;return u(o,t(l,3))}return ny=s,ny}var ry,ME;function eK(){if(ME)return ry;ME=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 ry=e,ry}var sy,$E;function tK(){if($E)return sy;$E=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 sy=e,sy}var ay,IE;function b$(){if(IE)return ay;IE=1;var e=eK(),t=Bd(),n=Vr(),r=tK(),s=wt();function o(l,u,d){var f=s(l)?e:r,h=arguments.length<3;return f(l,n(u,4),d,h,t)}return ay=o,ay}var oy,OE;function nK(){if(OE)return oy;OE=1;var e=_a(),t=wt(),n=xr(),r="[object String]";function s(o){return typeof o=="string"||!t(o)&&n(o)&&e(o)==r}return oy=s,oy}var iy,LE;function rK(){if(LE)return iy;LE=1;var e=m$(),t=e("length");return iy=t,iy}var ly,PE;function sK(){if(PE)return ly;PE=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(f){return u.test(f)}return ly=d,ly}var cy,DE;function aK(){if(DE)return cy;DE=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]",f="(?:"+u+"|"+d+")",h="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",g="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",k=f+"?",v="["+o+"]?",b="(?:"+w+"(?:"+[h,m,g].join("|")+")"+v+k+")*",S=v+k+b,_="(?:"+[h+u+"?",u,m,g,l].join("|")+")",j=RegExp(d+"(?="+d+")|"+_+S,"g");function E(T){for(var R=j.lastIndex=0;j.test(T);)++R;return R}return cy=E,cy}var uy,FE;function oK(){if(FE)return uy;FE=1;var e=rK(),t=sK(),n=aK();function r(s){return t(s)?n(s):e(s)}return uy=r,uy}var dy,qE;function iK(){if(qE)return dy;qE=1;var e=_0(),t=ti(),n=Wr(),r=nK(),s=oK(),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 f=t(d);return f==o||f==l?d.size:e(d).length}return dy=u,dy}var hy,BE;function lK(){if(BE)return hy;BE=1;var e=N0(),t=e$(),n=M0(),r=Vr(),s=qd(),o=wt(),l=ei(),u=Ul(),d=Rn(),f=Vl();function h(m,g,w){var k=o(m),v=k||l(m)||f(m);if(g=r(g,4),w==null){var b=m&&m.constructor;v?w=k?new b:[]:d(m)?w=u(b)?t(s(m)):{}:w={}}return(v?e:n)(m,function(S,_,j){return g(w,S,_,j)}),w}return hy=h,hy}var fy,zE;function cK(){if(zE)return fy;zE=1;var e=Qo(),t=Wl(),n=wt(),r=e?e.isConcatSpreadable:void 0;function s(o){return n(o)||t(o)||!!(r&&o&&o[r])}return fy=s,fy}var py,UE;function O0(){if(UE)return py;UE=1;var e=C0(),t=cK();function n(r,s,o,l,u){var d=-1,f=r.length;for(o||(o=t),u||(u=[]);++d<f;){var h=r[d];s>0&&o(h)?s>1?n(h,s-1,o,l,u):e(u,h):l||(u[u.length]=h)}return u}return py=n,py}var my,HE;function uK(){if(HE)return my;HE=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 my=e,my}var gy,WE;function k$(){if(WE)return gy;WE=1;var e=uK(),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),f=Array(d);++u<d;)f[u]=l[s+u];u=-1;for(var h=Array(s+1);++u<s;)h[u]=l[u];return h[s]=o(f),e(r,this,h)}}return gy=n,gy}var yy,VE;function dK(){if(VE)return yy;VE=1;var e=R0(),t=BM(),n=Ta(),r=t?function(s,o){return t(s,"toString",{configurable:!0,enumerable:!1,value:e(o),writable:!0})}:n;return yy=r,yy}var wy,GE;function hK(){if(GE)return wy;GE=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 wy=r,wy}var vy,KE;function N$(){if(KE)return vy;KE=1;var e=dK(),t=hK(),n=t(e);return vy=n,vy}var xy,YE;function Wd(){if(YE)return xy;YE=1;var e=Ta(),t=k$(),n=N$();function r(s,o){return n(t(s,o,e),s+"")}return xy=r,xy}var by,XE;function S$(){if(XE)return by;XE=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 by=e,by}var ky,ZE;function fK(){if(ZE)return ky;ZE=1;function e(t){return t!==t}return ky=e,ky}var Ny,JE;function pK(){if(JE)return Ny;JE=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 Ny=e,Ny}var Sy,QE;function mK(){if(QE)return Sy;QE=1;var e=S$(),t=fK(),n=pK();function r(s,o,l){return o===o?n(s,o,l):e(s,t,l)}return Sy=r,Sy}var jy,eC;function gK(){if(eC)return jy;eC=1;var e=mK();function t(n,r){var s=n==null?0:n.length;return!!s&&e(n,r,0)>-1}return jy=t,jy}var _y,tC;function yK(){if(tC)return _y;tC=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 _y=e,_y}var Ey,nC;function wK(){if(nC)return Ey;nC=1;function e(){}return Ey=e,Ey}var Cy,rC;function vK(){if(rC)return Cy;rC=1;var e=ZM(),t=wK(),n=$0(),r=1/0,s=e&&1/n(new e([,-0]))[1]==r?function(o){return new e(o)}:t;return Cy=s,Cy}var Ty,sC;function xK(){if(sC)return Ty;sC=1;var e=o$(),t=gK(),n=yK(),r=i$(),s=vK(),o=$0(),l=200;function u(d,f,h){var m=-1,g=t,w=d.length,k=!0,v=[],b=v;if(h)k=!1,g=n;else if(w>=l){var S=f?null:s(d);if(S)return o(S);k=!1,g=r,b=new e}else b=f?[]:v;e:for(;++m<w;){var _=d[m],j=f?f(_):_;if(_=h||_!==0?_:0,k&&j===j){for(var E=b.length;E--;)if(b[E]===j)continue e;f&&b.push(j),v.push(_)}else g(b,j,h)||(b!==v&&b.push(j),v.push(_))}return v}return Ty=u,Ty}var Ry,aC;function j$(){if(aC)return Ry;aC=1;var e=Wr(),t=xr();function n(r){return t(r)&&e(r)}return Ry=n,Ry}var Ay,oC;function bK(){if(oC)return Ay;oC=1;var e=O0(),t=Wd(),n=xK(),r=j$(),s=t(function(o){return n(e(o,1,r,!0))});return Ay=s,Ay}var My,iC;function kK(){if(iC)return My;iC=1;var e=zd();function t(n,r){return e(r,function(s){return n[s]})}return My=t,My}var $y,lC;function _$(){if(lC)return $y;lC=1;var e=kK(),t=Ts();function n(r){return r==null?[]:e(r,t(r))}return $y=n,$y}var Iy,cC;function An(){if(cC)return Iy;cC=1;var e;if(typeof x0=="function")try{e={clone:TG(),constant:R0(),each:a$(),filter:g$(),has:y$(),isArray:wt(),isEmpty:QG(),isFunction:Ul(),isUndefined:w$(),keys:Ts(),map:x$(),reduce:b$(),size:iK(),transform:lK(),union:bK(),values:_$()}}catch{}return e||(e=window._),Iy=e,Iy}var Oy,uC;function L0(){if(uC)return Oy;uC=1;var e=An();Oy=s;var t="\0",n="\0",r="";function s(h){this._isDirected=e.has(h,"directed")?h.directed:!0,this._isMultigraph=e.has(h,"multigraph")?h.multigraph:!1,this._isCompound=e.has(h,"compound")?h.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(h){return this._label=h,this},s.prototype.graph=function(){return this._label},s.prototype.setDefaultNodeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultNodeLabelFn=h,this},s.prototype.nodeCount=function(){return this._nodeCount},s.prototype.nodes=function(){return e.keys(this._nodes)},s.prototype.sources=function(){var h=this;return e.filter(this.nodes(),function(m){return e.isEmpty(h._in[m])})},s.prototype.sinks=function(){var h=this;return e.filter(this.nodes(),function(m){return e.isEmpty(h._out[m])})},s.prototype.setNodes=function(h,m){var g=arguments,w=this;return e.each(h,function(k){g.length>1?w.setNode(k,m):w.setNode(k)}),this},s.prototype.setNode=function(h,m){return e.has(this._nodes,h)?(arguments.length>1&&(this._nodes[h]=m),this):(this._nodes[h]=arguments.length>1?m:this._defaultNodeLabelFn(h),this._isCompound&&(this._parent[h]=n,this._children[h]={},this._children[n][h]=!0),this._in[h]={},this._preds[h]={},this._out[h]={},this._sucs[h]={},++this._nodeCount,this)},s.prototype.node=function(h){return this._nodes[h]},s.prototype.hasNode=function(h){return e.has(this._nodes,h)},s.prototype.removeNode=function(h){var m=this;if(e.has(this._nodes,h)){var g=function(w){m.removeEdge(m._edgeObjs[w])};delete this._nodes[h],this._isCompound&&(this._removeFromParentsChildList(h),delete this._parent[h],e.each(this.children(h),function(w){m.setParent(w)}),delete this._children[h]),e.each(e.keys(this._in[h]),g),delete this._in[h],delete this._preds[h],e.each(e.keys(this._out[h]),g),delete this._out[h],delete this._sucs[h],--this._nodeCount}return this},s.prototype.setParent=function(h,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(m))m=n;else{m+="";for(var g=m;!e.isUndefined(g);g=this.parent(g))if(g===h)throw new Error("Setting "+m+" as parent of "+h+" would create a cycle");this.setNode(m)}return this.setNode(h),this._removeFromParentsChildList(h),this._parent[h]=m,this._children[m][h]=!0,this},s.prototype._removeFromParentsChildList=function(h){delete this._children[this._parent[h]][h]},s.prototype.parent=function(h){if(this._isCompound){var m=this._parent[h];if(m!==n)return m}},s.prototype.children=function(h){if(e.isUndefined(h)&&(h=n),this._isCompound){var m=this._children[h];if(m)return e.keys(m)}else{if(h===n)return this.nodes();if(this.hasNode(h))return[]}},s.prototype.predecessors=function(h){var m=this._preds[h];if(m)return e.keys(m)},s.prototype.successors=function(h){var m=this._sucs[h];if(m)return e.keys(m)},s.prototype.neighbors=function(h){var m=this.predecessors(h);if(m)return e.union(m,this.successors(h))},s.prototype.isLeaf=function(h){var m;return this.isDirected()?m=this.successors(h):m=this.neighbors(h),m.length===0},s.prototype.filterNodes=function(h){var m=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});m.setGraph(this.graph());var g=this;e.each(this._nodes,function(v,b){h(b)&&m.setNode(b,v)}),e.each(this._edgeObjs,function(v){m.hasNode(v.v)&&m.hasNode(v.w)&&m.setEdge(v,g.edge(v))});var w={};function k(v){var b=g.parent(v);return b===void 0||m.hasNode(b)?(w[v]=b,b):b in w?w[b]:k(b)}return this._isCompound&&e.each(m.nodes(),function(v){m.setParent(v,k(v))}),m},s.prototype.setDefaultEdgeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultEdgeLabelFn=h,this},s.prototype.edgeCount=function(){return this._edgeCount},s.prototype.edges=function(){return e.values(this._edgeObjs)},s.prototype.setPath=function(h,m){var g=this,w=arguments;return e.reduce(h,function(k,v){return w.length>1?g.setEdge(k,v,m):g.setEdge(k,v),v}),this},s.prototype.setEdge=function(){var h,m,g,w,k=!1,v=arguments[0];typeof v=="object"&&v!==null&&"v"in v?(h=v.v,m=v.w,g=v.name,arguments.length===2&&(w=arguments[1],k=!0)):(h=v,m=arguments[1],g=arguments[3],arguments.length>2&&(w=arguments[2],k=!0)),h=""+h,m=""+m,e.isUndefined(g)||(g=""+g);var b=u(this._isDirected,h,m,g);if(e.has(this._edgeLabels,b))return k&&(this._edgeLabels[b]=w),this;if(!e.isUndefined(g)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(h),this.setNode(m),this._edgeLabels[b]=k?w:this._defaultEdgeLabelFn(h,m,g);var S=d(this._isDirected,h,m,g);return h=S.v,m=S.w,Object.freeze(S),this._edgeObjs[b]=S,o(this._preds[m],h),o(this._sucs[h],m),this._in[m][b]=S,this._out[h][b]=S,this._edgeCount++,this},s.prototype.edge=function(h,m,g){var w=arguments.length===1?f(this._isDirected,arguments[0]):u(this._isDirected,h,m,g);return this._edgeLabels[w]},s.prototype.hasEdge=function(h,m,g){var w=arguments.length===1?f(this._isDirected,arguments[0]):u(this._isDirected,h,m,g);return e.has(this._edgeLabels,w)},s.prototype.removeEdge=function(h,m,g){var w=arguments.length===1?f(this._isDirected,arguments[0]):u(this._isDirected,h,m,g),k=this._edgeObjs[w];return k&&(h=k.v,m=k.w,delete this._edgeLabels[w],delete this._edgeObjs[w],l(this._preds[m],h),l(this._sucs[h],m),delete this._in[m][w],delete this._out[h][w],this._edgeCount--),this},s.prototype.inEdges=function(h,m){var g=this._in[h];if(g){var w=e.values(g);return m?e.filter(w,function(k){return k.v===m}):w}},s.prototype.outEdges=function(h,m){var g=this._out[h];if(g){var w=e.values(g);return m?e.filter(w,function(k){return k.w===m}):w}},s.prototype.nodeEdges=function(h,m){var g=this.inEdges(h,m);if(g)return g.concat(this.outEdges(h,m))};function o(h,m){h[m]?h[m]++:h[m]=1}function l(h,m){--h[m]||delete h[m]}function u(h,m,g,w){var k=""+m,v=""+g;if(!h&&k>v){var b=k;k=v,v=b}return k+r+v+r+(e.isUndefined(w)?t:w)}function d(h,m,g,w){var k=""+m,v=""+g;if(!h&&k>v){var b=k;k=v,v=b}var S={v:k,w:v};return w&&(S.name=w),S}function f(h,m){return u(h,m.v,m.w,m.name)}return Oy}var Ly,dC;function NK(){return dC||(dC=1,Ly="2.1.8"),Ly}var Py,hC;function SK(){return hC||(hC=1,Py={Graph:L0(),version:NK()}),Py}var Dy,fC;function jK(){if(fC)return Dy;fC=1;var e=An(),t=L0();Dy={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),f=l.parent(u),h={v:u};return e.isUndefined(d)||(h.value=d),e.isUndefined(f)||(h.parent=f),h})}function s(l){return e.map(l.edges(),function(u){var d=l.edge(u),f={v:u.v,w:u.w};return e.isUndefined(u.name)||(f.name=u.name),e.isUndefined(d)||(f.value=d),f})}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 Dy}var Fy,pC;function _K(){if(pC)return Fy;pC=1;var e=An();Fy=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 Fy}var qy,mC;function E$(){if(mC)return qy;mC=1;var e=An();qy=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},qy}var By,gC;function C$(){if(gC)return By;gC=1;var e=An(),t=E$();By=r;var n=e.constant(1);function r(o,l,u,d){return s(o,String(l),u||n,d||function(f){return o.outEdges(f)})}function s(o,l,u,d){var f={},h=new t,m,g,w=function(k){var v=k.v!==m?k.v:k.w,b=f[v],S=u(k),_=g.distance+S;if(S<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+k+" Weight: "+S);_<b.distance&&(b.distance=_,b.predecessor=m,h.decrease(v,_))};for(o.nodes().forEach(function(k){var v=k===l?0:Number.POSITIVE_INFINITY;f[k]={distance:v},h.add(k,v)});h.size()>0&&(m=h.removeMin(),g=f[m],g.distance!==Number.POSITIVE_INFINITY);)d(m).forEach(w);return f}return By}var zy,yC;function EK(){if(yC)return zy;yC=1;var e=C$(),t=An();zy=n;function n(r,s,o){return t.transform(r.nodes(),function(l,u){l[u]=e(r,u,s,o)},{})}return zy}var Uy,wC;function T$(){if(wC)return Uy;wC=1;var e=An();Uy=t;function t(n){var r=0,s=[],o={},l=[];function u(d){var f=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&&(f.lowlink=Math.min(f.lowlink,o[g].index)):(u(g),f.lowlink=Math.min(f.lowlink,o[g].lowlink))}),f.lowlink===f.index){var h=[],m;do m=s.pop(),o[m].onStack=!1,h.push(m);while(d!==m);l.push(h)}}return n.nodes().forEach(function(d){e.has(o,d)||u(d)}),l}return Uy}var Hy,vC;function CK(){if(vC)return Hy;vC=1;var e=An(),t=T$();Hy=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 Hy}var Wy,xC;function TK(){if(xC)return Wy;xC=1;var e=An();Wy=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(f){u[f]={},u[f][f]={distance:0},d.forEach(function(h){f!==h&&(u[f][h]={distance:Number.POSITIVE_INFINITY})}),l(f).forEach(function(h){var m=h.v===f?h.w:h.v,g=o(h);u[f][m]={distance:g,predecessor:f}})}),d.forEach(function(f){var h=u[f];d.forEach(function(m){var g=u[m];d.forEach(function(w){var k=g[f],v=h[w],b=g[w],S=k.distance+v.distance;S<b.distance&&(b.distance=S,b.predecessor=v.predecessor)})})}),u}return Wy}var Vy,bC;function R$(){if(bC)return Vy;bC=1;var e=An();Vy=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,Vy}var Gy,kC;function RK(){if(kC)return Gy;kC=1;var e=R$();Gy=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return Gy}var Ky,NC;function A$(){if(NC)return Ky;NC=1;var e=An();Ky=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(f){if(!r.hasNode(f))throw new Error("Graph does not have node: "+f);n(r,f,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(f){n(r,f,o,l,u,d)}),o&&d.push(s))}return Ky}var Yy,SC;function AK(){if(SC)return Yy;SC=1;var e=A$();Yy=t;function t(n,r){return e(n,r,"post")}return Yy}var Xy,jC;function MK(){if(jC)return Xy;jC=1;var e=A$();Xy=t;function t(n,r){return e(n,r,"pre")}return Xy}var Zy,_C;function $K(){if(_C)return Zy;_C=1;var e=An(),t=L0(),n=E$();Zy=r;function r(s,o){var l=new t,u={},d=new n,f;function h(g){var w=g.v===f?g.w:g.v,k=d.priority(w);if(k!==void 0){var v=o(g);v<k&&(u[w]=f,d.decrease(w,v))}}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 m=!1;d.size()>0;){if(f=d.removeMin(),e.has(u,f))l.setEdge(f,u[f]);else{if(m)throw new Error("Input graph is not connected: "+s);m=!0}s.nodeEdges(f).forEach(h)}return l}return Zy}var Jy,EC;function IK(){return EC||(EC=1,Jy={components:_K(),dijkstra:C$(),dijkstraAll:EK(),findCycles:CK(),floydWarshall:TK(),isAcyclic:RK(),postorder:AK(),preorder:MK(),prim:$K(),tarjan:T$(),topsort:R$()}),Jy}var Qy,CC;function OK(){if(CC)return Qy;CC=1;var e=SK();return Qy={Graph:e.Graph,json:jK(),alg:IK(),version:e.version},Qy}var ew,TC;function Vn(){if(TC)return ew;TC=1;var e;if(typeof x0=="function")try{e=OK()}catch{}return e||(e=window.graphlib),ew=e,ew}var tw,RC;function LK(){if(RC)return tw;RC=1;var e=n$(),t=1,n=4;function r(s){return e(s,t|n)}return tw=r,tw}var nw,AC;function Vd(){if(AC)return nw;AC=1;var e=Jo(),t=Wr(),n=Pd(),r=Rn();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 nw=s,nw}var rw,MC;function PK(){if(MC)return rw;MC=1;var e=Wd(),t=Jo(),n=Vd(),r=Ca(),s=Object.prototype,o=s.hasOwnProperty,l=e(function(u,d){u=Object(u);var f=-1,h=d.length,m=h>2?d[2]:void 0;for(m&&n(d[0],d[1],m)&&(h=1);++f<h;)for(var g=d[f],w=r(g),k=-1,v=w.length;++k<v;){var b=w[k],S=u[b];(S===void 0||t(S,s[b])&&!o.call(u,b))&&(u[b]=g[b])}return u});return rw=l,rw}var sw,$C;function DK(){if($C)return sw;$C=1;var e=Vr(),t=Wr(),n=Ts();function r(s){return function(o,l,u){var d=Object(o);if(!t(o)){var f=e(l,3);o=n(o),l=function(m){return f(d[m],m,d)}}var h=s(o,l,u);return h>-1?d[f?o[h]:h]:void 0}}return sw=r,sw}var aw,IC;function FK(){if(IC)return aw;IC=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return aw=t,aw}var ow,OC;function qK(){if(OC)return ow;OC=1;var e=FK(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return ow=n,ow}var iw,LC;function BK(){if(LC)return iw;LC=1;var e=qK(),t=Rn(),n=ni(),r=NaN,s=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,l=/^0o[0-7]+$/i,u=parseInt;function d(f){if(typeof f=="number")return f;if(n(f))return r;if(t(f)){var h=typeof f.valueOf=="function"?f.valueOf():f;f=t(h)?h+"":h}if(typeof f!="string")return f===0?f:+f;f=e(f);var m=o.test(f);return m||l.test(f)?u(f.slice(2),m?2:8):s.test(f)?r:+f}return iw=d,iw}var lw,PC;function M$(){if(PC)return lw;PC=1;var e=BK(),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 lw=r,lw}var cw,DC;function zK(){if(DC)return cw;DC=1;var e=M$();function t(n){var r=e(n),s=r%1;return r===r?s?r-s:r:0}return cw=t,cw}var uw,FC;function UK(){if(FC)return uw;FC=1;var e=S$(),t=Vr(),n=zK(),r=Math.max;function s(o,l,u){var d=o==null?0:o.length;if(!d)return-1;var f=u==null?0:n(u);return f<0&&(f=r(d+f,0)),e(o,t(l,3),f)}return uw=s,uw}var dw,qC;function HK(){if(qC)return dw;qC=1;var e=DK(),t=UK(),n=e(t);return dw=n,dw}var hw,BC;function $$(){if(BC)return hw;BC=1;var e=O0();function t(n){var r=n==null?0:n.length;return r?e(n,1):[]}return hw=t,hw}var fw,zC;function WK(){if(zC)return fw;zC=1;var e=A0(),t=r$(),n=Ca();function r(s,o){return s==null?s:e(s,t(o),n)}return fw=r,fw}var pw,UC;function VK(){if(UC)return pw;UC=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return pw=e,pw}var mw,HC;function GK(){if(HC)return mw;HC=1;var e=Od(),t=M0(),n=Vr();function r(s,o){var l={};return o=n(o,3),t(s,function(u,d,f){e(l,d,o(u,d,f))}),l}return mw=r,mw}var gw,WC;function P0(){if(WC)return gw;WC=1;var e=ni();function t(n,r,s){for(var o=-1,l=n.length;++o<l;){var u=n[o],d=r(u);if(d!=null&&(f===void 0?d===d&&!e(d):s(d,f)))var f=d,h=u}return h}return gw=t,gw}var yw,VC;function KK(){if(VC)return yw;VC=1;function e(t,n){return t>n}return yw=e,yw}var ww,GC;function YK(){if(GC)return ww;GC=1;var e=P0(),t=KK(),n=Ta();function r(s){return s&&s.length?e(s,n,t):void 0}return ww=r,ww}var vw,KC;function I$(){if(KC)return vw;KC=1;var e=Od(),t=Jo();function n(r,s,o){(o!==void 0&&!t(r[s],o)||o===void 0&&!(s in r))&&e(r,s,o)}return vw=n,vw}var xw,YC;function XK(){if(YC)return xw;YC=1;var e=_a(),t=qd(),n=xr(),r="[object Object]",s=Function.prototype,o=Object.prototype,l=s.toString,u=o.hasOwnProperty,d=l.call(Object);function f(h){if(!n(h)||e(h)!=r)return!1;var m=t(h);if(m===null)return!0;var g=u.call(m,"constructor")&&m.constructor;return typeof g=="function"&&g instanceof g&&l.call(g)==d}return xw=f,xw}var bw,XC;function O$(){if(XC)return bw;XC=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return bw=e,bw}var kw,ZC;function ZK(){if(ZC)return kw;ZC=1;var e=Hl(),t=Ca();function n(r){return e(r,t(r))}return kw=n,kw}var Nw,JC;function JK(){if(JC)return Nw;JC=1;var e=I$(),t=HM(),n=QM(),r=WM(),s=t$(),o=Wl(),l=wt(),u=j$(),d=ei(),f=Ul(),h=Rn(),m=XK(),g=Vl(),w=O$(),k=ZK();function v(b,S,_,j,E,T,R){var M=w(b,_),O=w(S,_),I=R.get(O);if(I){e(b,_,I);return}var A=T?T(M,O,_+"",b,S,R):void 0,L=A===void 0;if(L){var z=l(O),V=!z&&d(O),$=!z&&!V&&g(O);A=O,z||V||$?l(M)?A=M:u(M)?A=r(M):V?(L=!1,A=t(O,!0)):$?(L=!1,A=n(O,!0)):A=[]:m(O)||o(O)?(A=M,o(M)?A=k(M):(!h(M)||f(M))&&(A=s(O))):L=!1}L&&(R.set(O,A),E(A,O,j,T,R),R.delete(O)),e(b,_,A)}return Nw=v,Nw}var Sw,QC;function QK(){if(QC)return Sw;QC=1;var e=Id(),t=I$(),n=A0(),r=JK(),s=Rn(),o=Ca(),l=O$();function u(d,f,h,m,g){d!==f&&n(f,function(w,k){if(g||(g=new e),s(w))r(d,f,k,h,u,m,g);else{var v=m?m(l(d,k),w,k+"",d,f,g):void 0;v===void 0&&(v=w),t(d,k,v)}},o)}return Sw=u,Sw}var jw,eT;function eY(){if(eT)return jw;eT=1;var e=Wd(),t=Vd();function n(r){return e(function(s,o){var l=-1,u=o.length,d=u>1?o[u-1]:void 0,f=u>2?o[2]:void 0;for(d=r.length>3&&typeof d=="function"?(u--,d):void 0,f&&t(o[0],o[1],f)&&(d=u<3?void 0:d,u=1),s=Object(s);++l<u;){var h=o[l];h&&r(s,h,l,d)}return s})}return jw=n,jw}var _w,tT;function tY(){if(tT)return _w;tT=1;var e=QK(),t=eY(),n=t(function(r,s,o){e(r,s,o)});return _w=n,_w}var Ew,nT;function L$(){if(nT)return Ew;nT=1;function e(t,n){return t<n}return Ew=e,Ew}var Cw,rT;function nY(){if(rT)return Cw;rT=1;var e=P0(),t=L$(),n=Ta();function r(s){return s&&s.length?e(s,n,t):void 0}return Cw=r,Cw}var Tw,sT;function rY(){if(sT)return Tw;sT=1;var e=P0(),t=Vr(),n=L$();function r(s,o){return s&&s.length?e(s,t(o,2),n):void 0}return Tw=r,Tw}var Rw,aT;function sY(){if(aT)return Rw;aT=1;var e=Yn(),t=function(){return e.Date.now()};return Rw=t,Rw}var Aw,oT;function aY(){if(oT)return Aw;oT=1;var e=Ld(),t=Ud(),n=Pd(),r=Rn(),s=Gl();function o(l,u,d,f){if(!r(l))return l;u=t(u,l);for(var h=-1,m=u.length,g=m-1,w=l;w!=null&&++h<m;){var k=s(u[h]),v=d;if(k==="__proto__"||k==="constructor"||k==="prototype")return l;if(h!=g){var b=w[k];v=f?f(b,k,w):void 0,v===void 0&&(v=r(b)?b:n(u[h+1])?[]:{})}e(w,k,v),w=w[k]}return l}return Aw=o,Aw}var Mw,iT;function oY(){if(iT)return Mw;iT=1;var e=Hd(),t=aY(),n=Ud();function r(s,o,l){for(var u=-1,d=o.length,f={};++u<d;){var h=o[u],m=e(s,h);l(m,h)&&t(f,n(h,s),m)}return f}return Mw=r,Mw}var $w,lT;function iY(){if(lT)return $w;lT=1;var e=oY(),t=p$();function n(r,s){return e(r,s,function(o,l){return t(r,l)})}return $w=n,$w}var Iw,cT;function lY(){if(cT)return Iw;cT=1;var e=$$(),t=k$(),n=N$();function r(s){return n(t(s,void 0,e),s+"")}return Iw=r,Iw}var Ow,uT;function cY(){if(uT)return Ow;uT=1;var e=iY(),t=lY(),n=t(function(r,s){return r==null?{}:e(r,s)});return Ow=n,Ow}var Lw,dT;function uY(){if(dT)return Lw;dT=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),f=Array(d);d--;)f[l?d:++u]=r,r+=o;return f}return Lw=n,Lw}var Pw,hT;function dY(){if(hT)return Pw;hT=1;var e=uY(),t=Vd(),n=M$();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 Pw=r,Pw}var Dw,fT;function hY(){if(fT)return Dw;fT=1;var e=dY(),t=e();return Dw=t,Dw}var Fw,pT;function fY(){if(pT)return Fw;pT=1;function e(t,n){var r=t.length;for(t.sort(n);r--;)t[r]=t[r].value;return t}return Fw=e,Fw}var qw,mT;function pY(){if(mT)return qw;mT=1;var e=ni();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,f=r===null,h=r===r,m=e(r);if(!f&&!m&&!u&&n>r||u&&d&&h&&!f&&!m||o&&d&&h||!s&&h||!l)return 1;if(!o&&!u&&!m&&n<r||m&&s&&l&&!o&&!u||f&&s&&l||!d&&l||!h)return-1}return 0}return qw=t,qw}var Bw,gT;function mY(){if(gT)return Bw;gT=1;var e=pY();function t(n,r,s){for(var o=-1,l=n.criteria,u=r.criteria,d=l.length,f=s.length;++o<d;){var h=e(l[o],u[o]);if(h){if(o>=f)return h;var m=s[o];return h*(m=="desc"?-1:1)}}return n.index-r.index}return Bw=t,Bw}var zw,yT;function gY(){if(yT)return zw;yT=1;var e=zd(),t=Hd(),n=Vr(),r=v$(),s=fY(),o=Dd(),l=mY(),u=Ta(),d=wt();function f(h,m,g){m.length?m=e(m,function(v){return d(v)?function(b){return t(b,v.length===1?v[0]:v)}:v}):m=[u];var w=-1;m=e(m,o(n));var k=r(h,function(v,b,S){var _=e(m,function(j){return j(v)});return{criteria:_,index:++w,value:v}});return s(k,function(v,b){return l(v,b,g)})}return zw=f,zw}var Uw,wT;function yY(){if(wT)return Uw;wT=1;var e=O0(),t=gY(),n=Wd(),r=Vd(),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 Uw=s,Uw}var Hw,vT;function wY(){if(vT)return Hw;vT=1;var e=h$(),t=0;function n(r){var s=++t;return e(r)+s}return Hw=n,Hw}var Ww,xT;function vY(){if(xT)return Ww;xT=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 Ww=e,Ww}var Vw,bT;function xY(){if(bT)return Vw;bT=1;var e=Ld(),t=vY();function n(r,s){return t(r||[],s||[],e)}return Vw=n,Vw}var Gw,kT;function at(){if(kT)return Gw;kT=1;var e;if(typeof x0=="function")try{e={cloneDeep:LK(),constant:R0(),defaults:PK(),each:a$(),filter:g$(),find:HK(),flatten:$$(),forEach:s$(),forIn:WK(),has:y$(),isUndefined:w$(),last:VK(),map:x$(),mapValues:GK(),max:YK(),merge:tY(),min:nY(),minBy:rY(),now:sY(),pick:cY(),range:hY(),reduce:b$(),sortBy:yY(),uniqueId:wY(),values:_$(),zipObject:xY()}}catch{}return e||(e=window._),Gw=e,Gw}var Kw,NT;function bY(){if(NT)return Kw;NT=1,Kw=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 Kw}var Yw,ST;function kY(){if(ST)return Yw;ST=1;var e=at(),t=Vn().Graph,n=bY();Yw=s;var r=e.constant(1);function s(f,h){if(f.nodeCount()<=1)return[];var m=u(f,h||r),g=o(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(g,function(w){return f.outEdges(w.v,w.w)}),!0)}function o(f,h,m){for(var g=[],w=h[h.length-1],k=h[0],v;f.nodeCount();){for(;v=k.dequeue();)l(f,h,m,v);for(;v=w.dequeue();)l(f,h,m,v);if(f.nodeCount()){for(var b=h.length-2;b>0;--b)if(v=h[b].dequeue(),v){g=g.concat(l(f,h,m,v,!0));break}}}return g}function l(f,h,m,g,w){var k=w?[]:void 0;return e.forEach(f.inEdges(g.v),function(v){var b=f.edge(v),S=f.node(v.v);w&&k.push({v:v.v,w:v.w}),S.out-=b,d(h,m,S)}),e.forEach(f.outEdges(g.v),function(v){var b=f.edge(v),S=v.w,_=f.node(S);_.in-=b,d(h,m,_)}),f.removeNode(g.v),k}function u(f,h){var m=new t,g=0,w=0;e.forEach(f.nodes(),function(b){m.setNode(b,{v:b,in:0,out:0})}),e.forEach(f.edges(),function(b){var S=m.edge(b.v,b.w)||0,_=h(b),j=S+_;m.setEdge(b.v,b.w,j),w=Math.max(w,m.node(b.v).out+=_),g=Math.max(g,m.node(b.w).in+=_)});var k=e.range(w+g+3).map(function(){return new n}),v=g+1;return e.forEach(m.nodes(),function(b){d(k,v,m.node(b))}),{graph:m,buckets:k,zeroIdx:v}}function d(f,h,m){m.out?m.in?f[m.out-m.in+h].enqueue(m):f[f.length-1].enqueue(m):f[0].enqueue(m)}return Yw}var Xw,jT;function NY(){if(jT)return Xw;jT=1;var e=at(),t=kY();Xw={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 f=o.edge(d);o.removeEdge(d),f.forwardName=d.name,f.reversed=!0,o.setEdge(d.w,d.v,f,e.uniqueId("rev"))});function u(d){return function(f){return d.edge(f).weight}}}function r(o){var l=[],u={},d={};function f(h){e.has(d,h)||(d[h]=!0,u[h]=!0,e.forEach(o.outEdges(h),function(m){e.has(u,m.w)?l.push(m):f(m.w)}),delete u[h])}return e.forEach(o.nodes(),f),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 Xw}var Zw,_T;function rn(){if(_T)return Zw;_T=1;var e=at(),t=Vn().Graph;Zw={addDummyNode:n,simplify:r,asNonCompoundGraph:s,successorWeights:o,predecessorWeights:l,intersectRect:u,buildLayerMatrix:d,normalizeRanks:f,removeEmptyRanks:h,addBorderNode:m,maxRank:g,partition:w,time:k,notime:v};function n(b,S,_,j){var E;do E=e.uniqueId(j);while(b.hasNode(E));return _.dummy=S,b.setNode(E,_),E}function r(b){var S=new t().setGraph(b.graph());return e.forEach(b.nodes(),function(_){S.setNode(_,b.node(_))}),e.forEach(b.edges(),function(_){var j=S.edge(_.v,_.w)||{weight:0,minlen:1},E=b.edge(_);S.setEdge(_.v,_.w,{weight:j.weight+E.weight,minlen:Math.max(j.minlen,E.minlen)})}),S}function s(b){var S=new t({multigraph:b.isMultigraph()}).setGraph(b.graph());return e.forEach(b.nodes(),function(_){b.children(_).length||S.setNode(_,b.node(_))}),e.forEach(b.edges(),function(_){S.setEdge(_,b.edge(_))}),S}function o(b){var S=e.map(b.nodes(),function(_){var j={};return e.forEach(b.outEdges(_),function(E){j[E.w]=(j[E.w]||0)+b.edge(E).weight}),j});return e.zipObject(b.nodes(),S)}function l(b){var S=e.map(b.nodes(),function(_){var j={};return e.forEach(b.inEdges(_),function(E){j[E.v]=(j[E.v]||0)+b.edge(E).weight}),j});return e.zipObject(b.nodes(),S)}function u(b,S){var _=b.x,j=b.y,E=S.x-_,T=S.y-j,R=b.width/2,M=b.height/2;if(!E&&!T)throw new Error("Not possible to find intersection inside of the rectangle");var O,I;return Math.abs(T)*R>Math.abs(E)*M?(T<0&&(M=-M),O=M*E/T,I=M):(E<0&&(R=-R),O=R,I=R*T/E),{x:_+O,y:j+I}}function d(b){var S=e.map(e.range(g(b)+1),function(){return[]});return e.forEach(b.nodes(),function(_){var j=b.node(_),E=j.rank;e.isUndefined(E)||(S[E][j.order]=_)}),S}function f(b){var S=e.min(e.map(b.nodes(),function(_){return b.node(_).rank}));e.forEach(b.nodes(),function(_){var j=b.node(_);e.has(j,"rank")&&(j.rank-=S)})}function h(b){var S=e.min(e.map(b.nodes(),function(T){return b.node(T).rank})),_=[];e.forEach(b.nodes(),function(T){var R=b.node(T).rank-S;_[R]||(_[R]=[]),_[R].push(T)});var j=0,E=b.graph().nodeRankFactor;e.forEach(_,function(T,R){e.isUndefined(T)&&R%E!==0?--j:j&&e.forEach(T,function(M){b.node(M).rank+=j})})}function m(b,S,_,j){var E={width:0,height:0};return arguments.length>=4&&(E.rank=_,E.order=j),n(b,"border",E,S)}function g(b){return e.max(e.map(b.nodes(),function(S){var _=b.node(S).rank;if(!e.isUndefined(_))return _}))}function w(b,S){var _={lhs:[],rhs:[]};return e.forEach(b,function(j){S(j)?_.lhs.push(j):_.rhs.push(j)}),_}function k(b,S){var _=e.now();try{return S()}finally{console.log(b+" time: "+(e.now()-_)+"ms")}}function v(b,S){return S()}return Zw}var Jw,ET;function SY(){if(ET)return Jw;ET=1;var e=at(),t=rn();Jw={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,f=l.w,h=o.node(f).rank,m=l.name,g=o.edge(l),w=g.labelRank;if(h!==d+1){o.removeEdge(l);var k,v,b;for(b=0,++d;d<h;++b,++d)g.points=[],v={width:0,height:0,edgeLabel:g,edgeObj:l,rank:d},k=t.addDummyNode(o,"edge",v,"_d"),d===w&&(v.width=g.width,v.height=g.height,v.dummy="edge-label",v.labelpos=g.labelpos),o.setEdge(u,k,{weight:g.weight},m),b===0&&o.graph().dummyChains.push(k),u=k;o.setEdge(u,f,{weight:g.weight},m)}}function s(o){e.forEach(o.graph().dummyChains,function(l){var u=o.node(l),d=u.edgeLabel,f;for(o.setEdge(u.edgeObj,d);u.dummy;)f=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=f,u=o.node(l)})}return Jw}var Qw,CT;function ed(){if(CT)return Qw;CT=1;var e=at();Qw={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(f){return o(f.w)-r.edge(f).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 Qw}var ev,TT;function P$(){if(TT)return ev;TT=1;var e=at(),t=Vn().Graph,n=ed().slack;ev=r;function r(u){var d=new t({directed:!1}),f=u.nodes()[0],h=u.nodeCount();d.setNode(f,{});for(var m,g;s(d,u)<h;)m=o(d,u),g=d.hasNode(m.v)?n(u,m):-n(u,m),l(d,u,g);return d}function s(u,d){function f(h){e.forEach(d.nodeEdges(h),function(m){var g=m.v,w=h===g?m.w:g;!u.hasNode(w)&&!n(d,m)&&(u.setNode(w,{}),u.setEdge(h,w,{}),f(w))})}return e.forEach(u.nodes(),f),u.nodeCount()}function o(u,d){return e.minBy(d.edges(),function(f){if(u.hasNode(f.v)!==u.hasNode(f.w))return n(d,f)})}function l(u,d,f){e.forEach(u.nodes(),function(h){d.node(h).rank+=f})}return ev}var tv,RT;function jY(){if(RT)return tv;RT=1;var e=at(),t=P$(),n=ed().slack,r=ed().longestPath,s=Vn().alg.preorder,o=Vn().alg.postorder,l=rn().simplify;tv=u,u.initLowLimValues=m,u.initCutValues=d,u.calcCutValue=h,u.leaveEdge=w,u.enterEdge=k,u.exchangeEdges=v;function u(j){j=l(j),r(j);var E=t(j);m(E),d(E,j);for(var T,R;T=w(E);)R=k(E,j,T),v(E,j,T,R)}function d(j,E){var T=o(j,j.nodes());T=T.slice(0,T.length-1),e.forEach(T,function(R){f(j,E,R)})}function f(j,E,T){var R=j.node(T),M=R.parent;j.edge(T,M).cutvalue=h(j,E,T)}function h(j,E,T){var R=j.node(T),M=R.parent,O=!0,I=E.edge(T,M),A=0;return I||(O=!1,I=E.edge(M,T)),A=I.weight,e.forEach(E.nodeEdges(T),function(L){var z=L.v===T,V=z?L.w:L.v;if(V!==M){var $=z===O,P=E.edge(L).weight;if(A+=$?P:-P,S(j,T,V)){var F=j.edge(T,V).cutvalue;A+=$?-F:F}}}),A}function m(j,E){arguments.length<2&&(E=j.nodes()[0]),g(j,{},1,E)}function g(j,E,T,R,M){var O=T,I=j.node(R);return E[R]=!0,e.forEach(j.neighbors(R),function(A){e.has(E,A)||(T=g(j,E,T,A,R))}),I.low=O,I.lim=T++,M?I.parent=M:delete I.parent,T}function w(j){return e.find(j.edges(),function(E){return j.edge(E).cutvalue<0})}function k(j,E,T){var R=T.v,M=T.w;E.hasEdge(R,M)||(R=T.w,M=T.v);var O=j.node(R),I=j.node(M),A=O,L=!1;O.lim>I.lim&&(A=I,L=!0);var z=e.filter(E.edges(),function(V){return L===_(j,j.node(V.v),A)&&L!==_(j,j.node(V.w),A)});return e.minBy(z,function(V){return n(E,V)})}function v(j,E,T,R){var M=T.v,O=T.w;j.removeEdge(M,O),j.setEdge(R.v,R.w,{}),m(j),d(j,E),b(j,E)}function b(j,E){var T=e.find(j.nodes(),function(M){return!E.node(M).parent}),R=s(j,T);R=R.slice(1),e.forEach(R,function(M){var O=j.node(M).parent,I=E.edge(M,O),A=!1;I||(I=E.edge(O,M),A=!0),E.node(M).rank=E.node(O).rank+(A?I.minlen:-I.minlen)})}function S(j,E,T){return j.hasEdge(E,T)}function _(j,E,T){return T.low<=E.lim&&E.lim<=T.lim}return tv}var nv,AT;function _Y(){if(AT)return nv;AT=1;var e=ed(),t=e.longestPath,n=P$(),r=jY();nv=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 nv}var rv,MT;function EY(){if(MT)return rv;MT=1;var e=at();rv=t;function t(s){var o=r(s);e.forEach(s.graph().dummyChains,function(l){for(var u=s.node(l),d=u.edgeObj,f=n(s,o,d.v,d.w),h=f.path,m=f.lca,g=0,w=h[g],k=!0;l!==d.w;){if(u=s.node(l),k){for(;(w=h[g])!==m&&s.node(w).maxRank<u.rank;)g++;w===m&&(k=!1)}if(!k){for(;g<h.length-1&&s.node(w=h[g+1]).minRank<=u.rank;)g++;w=h[g]}s.setParent(l,w),l=s.successors(l)[0]}})}function n(s,o,l,u){var d=[],f=[],h=Math.min(o[l].low,o[u].low),m=Math.max(o[l].lim,o[u].lim),g,w;g=l;do g=s.parent(g),d.push(g);while(g&&(o[g].low>h||m>o[g].lim));for(w=g,g=u;(g=s.parent(g))!==w;)f.push(g);return{path:d.concat(f.reverse()),lca:w}}function r(s){var o={},l=0;function u(d){var f=l;e.forEach(s.children(d),u),o[d]={low:f,lim:l++}}return e.forEach(s.children(),u),o}return rv}var sv,$T;function CY(){if($T)return sv;$T=1;var e=at(),t=rn();sv={run:n,cleanup:l};function n(u){var d=t.addDummyNode(u,"root",{},"_root"),f=s(u),h=e.max(e.values(f))-1,m=2*h+1;u.graph().nestingRoot=d,e.forEach(u.edges(),function(w){u.edge(w).minlen*=m});var g=o(u)+1;e.forEach(u.children(),function(w){r(u,d,m,g,h,f,w)}),u.graph().nodeRankFactor=m}function r(u,d,f,h,m,g,w){var k=u.children(w);if(!k.length){w!==d&&u.setEdge(d,w,{weight:0,minlen:f});return}var v=t.addBorderNode(u,"_bt"),b=t.addBorderNode(u,"_bb"),S=u.node(w);u.setParent(v,w),S.borderTop=v,u.setParent(b,w),S.borderBottom=b,e.forEach(k,function(_){r(u,d,f,h,m,g,_);var j=u.node(_),E=j.borderTop?j.borderTop:_,T=j.borderBottom?j.borderBottom:_,R=j.borderTop?h:2*h,M=E!==T?1:m-g[w]+1;u.setEdge(v,E,{weight:R,minlen:M,nestingEdge:!0}),u.setEdge(T,b,{weight:R,minlen:M,nestingEdge:!0})}),u.parent(w)||u.setEdge(d,v,{weight:0,minlen:m+g[w]})}function s(u){var d={};function f(h,m){var g=u.children(h);g&&g.length&&e.forEach(g,function(w){f(w,m+1)}),d[h]=m}return e.forEach(u.children(),function(h){f(h,1)}),d}function o(u){return e.reduce(u.edges(),function(d,f){return d+u.edge(f).weight},0)}function l(u){var d=u.graph();u.removeNode(d.nestingRoot),delete d.nestingRoot,e.forEach(u.edges(),function(f){var h=u.edge(f);h.nestingEdge&&u.removeEdge(f)})}return sv}var av,IT;function TY(){if(IT)return av;IT=1;var e=at(),t=rn();av=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 f=d.minRank,h=d.maxRank+1;f<h;++f)r(s,"borderLeft","_bl",l,d,f),r(s,"borderRight","_br",l,d,f)}}e.forEach(s.children(),o)}function r(s,o,l,u,d,f){var h={width:0,height:0,rank:f,borderType:o},m=d[o][f-1],g=t.addDummyNode(s,"border",h,l);d[o][f]=g,s.setParent(g,u),m&&s.setEdge(m,g,{weight:1})}return av}var ov,OT;function RY(){if(OT)return ov;OT=1;var e=at();ov={adjust:t,undo:n};function t(f){var h=f.graph().rankdir.toLowerCase();(h==="lr"||h==="rl")&&r(f)}function n(f){var h=f.graph().rankdir.toLowerCase();(h==="bt"||h==="rl")&&o(f),(h==="lr"||h==="rl")&&(u(f),r(f))}function r(f){e.forEach(f.nodes(),function(h){s(f.node(h))}),e.forEach(f.edges(),function(h){s(f.edge(h))})}function s(f){var h=f.width;f.width=f.height,f.height=h}function o(f){e.forEach(f.nodes(),function(h){l(f.node(h))}),e.forEach(f.edges(),function(h){var m=f.edge(h);e.forEach(m.points,l),e.has(m,"y")&&l(m)})}function l(f){f.y=-f.y}function u(f){e.forEach(f.nodes(),function(h){d(f.node(h))}),e.forEach(f.edges(),function(h){var m=f.edge(h);e.forEach(m.points,d),e.has(m,"x")&&d(m)})}function d(f){var h=f.x;f.x=f.y,f.y=h}return ov}var iv,LT;function AY(){if(LT)return iv;LT=1;var e=at();iv=t;function t(n){var r={},s=e.filter(n.nodes(),function(f){return!n.children(f).length}),o=e.max(e.map(s,function(f){return n.node(f).rank})),l=e.map(e.range(o+1),function(){return[]});function u(f){if(!e.has(r,f)){r[f]=!0;var h=n.node(f);l[h.rank].push(f),e.forEach(n.successors(f),u)}}var d=e.sortBy(s,function(f){return n.node(f).rank});return e.forEach(d,u),l}return iv}var lv,PT;function MY(){if(PT)return lv;PT=1;var e=at();lv=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,w){return w})),u=e.flatten(e.map(s,function(g){return e.sortBy(e.map(r.outEdges(g),function(w){return{pos:l[w.w],weight:r.edge(w).weight}}),"pos")}),!0),d=1;d<o.length;)d<<=1;var f=2*d-1;d-=1;var h=e.map(new Array(f),function(){return 0}),m=0;return e.forEach(u.forEach(function(g){var w=g.pos+d;h[w]+=g.weight;for(var k=0;w>0;)w%2&&(k+=h[w+1]),w=w-1>>1,h[w]+=g.weight;m+=g.weight*k})),m}return lv}var cv,DT;function $Y(){if(DT)return cv;DT=1;var e=at();cv=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 f=n.edge(d),h=n.node(d.v);return{sum:u.sum+f.weight*h.order,weight:u.weight+f.weight}},{sum:0,weight:0});return{v:s,barycenter:l.sum/l.weight,weight:l.weight}}else return{v:s}})}return cv}var uv,FT;function IY(){if(FT)return uv;FT=1;var e=at();uv=t;function t(s,o){var l={};e.forEach(s,function(d,f){var h=l[d.v]={indegree:0,in:[],out:[],vs:[d.v],i:f};e.isUndefined(d.barycenter)||(h.barycenter=d.barycenter,h.weight=d.weight)}),e.forEach(o.edges(),function(d){var f=l[d.v],h=l[d.w];!e.isUndefined(f)&&!e.isUndefined(h)&&(h.indegree++,f.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(f){return function(h){h.merged||(e.isUndefined(h.barycenter)||e.isUndefined(f.barycenter)||h.barycenter>=f.barycenter)&&r(f,h)}}function u(f){return function(h){h.in.push(f),--h.indegree===0&&s.push(h)}}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(f){return!f.merged}),function(f){return e.pick(f,["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 uv}var dv,qT;function OY(){if(qT)return dv;qT=1;var e=at(),t=rn();dv=n;function n(o,l){var u=t.partition(o,function(v){return e.has(v,"barycenter")}),d=u.lhs,f=e.sortBy(u.rhs,function(v){return-v.i}),h=[],m=0,g=0,w=0;d.sort(s(!!l)),w=r(h,f,w),e.forEach(d,function(v){w+=v.vs.length,h.push(v.vs),m+=v.barycenter*v.weight,g+=v.weight,w=r(h,f,w)});var k={vs:e.flatten(h,!0)};return g&&(k.barycenter=m/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 dv}var hv,BT;function LY(){if(BT)return hv;BT=1;var e=at(),t=$Y(),n=IY(),r=OY();hv=s;function s(u,d,f,h){var m=u.children(d),g=u.node(d),w=g?g.borderLeft:void 0,k=g?g.borderRight:void 0,v={};w&&(m=e.filter(m,function(T){return T!==w&&T!==k}));var b=t(u,m);e.forEach(b,function(T){if(u.children(T.v).length){var R=s(u,T.v,f,h);v[T.v]=R,e.has(R,"barycenter")&&l(T,R)}});var S=n(b,f);o(S,v);var _=r(S,h);if(w&&(_.vs=e.flatten([w,_.vs,k],!0),u.predecessors(w).length)){var j=u.node(u.predecessors(w)[0]),E=u.node(u.predecessors(k)[0]);e.has(_,"barycenter")||(_.barycenter=0,_.weight=0),_.barycenter=(_.barycenter*_.weight+j.order+E.order)/(_.weight+2),_.weight+=2}return _}function o(u,d){e.forEach(u,function(f){f.vs=e.flatten(f.vs.map(function(h){return d[h]?d[h].vs:h}),!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 hv}var fv,zT;function PY(){if(zT)return fv;zT=1;var e=at(),t=Vn().Graph;fv=n;function n(s,o,l){var u=r(s),d=new t({compound:!0}).setGraph({root:u}).setDefaultNodeLabel(function(f){return s.node(f)});return e.forEach(s.nodes(),function(f){var h=s.node(f),m=s.parent(f);(h.rank===o||h.minRank<=o&&o<=h.maxRank)&&(d.setNode(f),d.setParent(f,m||u),e.forEach(s[l](f),function(g){var w=g.v===f?g.w:g.v,k=d.edge(w,f),v=e.isUndefined(k)?0:k.weight;d.setEdge(w,f,{weight:s.edge(g).weight+v})}),e.has(h,"minRank")&&d.setNode(f,{borderLeft:h.borderLeft[o],borderRight:h.borderRight[o]}))}),d}function r(s){for(var o;s.hasNode(o=e.uniqueId("_root")););return o}return fv}var pv,UT;function DY(){if(UT)return pv;UT=1;var e=at();pv=t;function t(n,r,s){var o={},l;e.forEach(s,function(u){for(var d=n.parent(u),f,h;d;){if(f=n.parent(d),f?(h=o[f],o[f]=d):(h=l,l=d),h&&h!==d){r.setEdge(h,d);return}d=f}})}return pv}var mv,HT;function FY(){if(HT)return mv;HT=1;var e=at(),t=AY(),n=MY(),r=LY(),s=PY(),o=DY(),l=Vn().Graph,u=rn();mv=d;function d(g){var w=u.maxRank(g),k=f(g,e.range(1,w+1),"inEdges"),v=f(g,e.range(w-1,-1,-1),"outEdges"),b=t(g);m(g,b);for(var S=Number.POSITIVE_INFINITY,_,j=0,E=0;E<4;++j,++E){h(j%2?k:v,j%4>=2),b=u.buildLayerMatrix(g);var T=n(g,b);T<S&&(E=0,_=e.cloneDeep(b),S=T)}m(g,_)}function f(g,w,k){return e.map(w,function(v){return s(g,v,k)})}function h(g,w){var k=new l;e.forEach(g,function(v){var b=v.graph().root,S=r(v,b,k,w);e.forEach(S.vs,function(_,j){v.node(_).order=j}),o(v,k,S.vs)})}function m(g,w){e.forEach(w,function(k){e.forEach(k,function(v,b){g.node(v).order=b})})}return mv}var gv,WT;function qY(){if(WT)return gv;WT=1;var e=at(),t=Vn().Graph,n=rn();gv={positionX:k,findType1Conflicts:r,findType2Conflicts:s,addConflict:l,hasConflict:u,verticalAlignment:d,horizontalCompaction:f,alignCoordinates:g,findSmallestWidthAlignment:m,balance:w};function r(S,_){var j={};function E(T,R){var M=0,O=0,I=T.length,A=e.last(R);return e.forEach(R,function(L,z){var V=o(S,L),$=V?S.node(V).order:I;(V||L===A)&&(e.forEach(R.slice(O,z+1),function(P){e.forEach(S.predecessors(P),function(F){var Y=S.node(F),K=Y.order;(K<M||$<K)&&!(Y.dummy&&S.node(P).dummy)&&l(j,F,P)})}),O=z+1,M=$)}),R}return e.reduce(_,E),j}function s(S,_){var j={};function E(R,M,O,I,A){var L;e.forEach(e.range(M,O),function(z){L=R[z],S.node(L).dummy&&e.forEach(S.predecessors(L),function(V){var $=S.node(V);$.dummy&&($.order<I||$.order>A)&&l(j,V,L)})})}function T(R,M){var O=-1,I,A=0;return e.forEach(M,function(L,z){if(S.node(L).dummy==="border"){var V=S.predecessors(L);V.length&&(I=S.node(V[0]).order,E(M,A,z,O,I),A=z,O=I)}E(M,A,M.length,I,R.length)}),M}return e.reduce(_,T),j}function o(S,_){if(S.node(_).dummy)return e.find(S.predecessors(_),function(j){return S.node(j).dummy})}function l(S,_,j){if(_>j){var E=_;_=j,j=E}var T=S[_];T||(S[_]=T={}),T[j]=!0}function u(S,_,j){if(_>j){var E=_;_=j,j=E}return e.has(S[_],j)}function d(S,_,j,E){var T={},R={},M={};return e.forEach(_,function(O){e.forEach(O,function(I,A){T[I]=I,R[I]=I,M[I]=A})}),e.forEach(_,function(O){var I=-1;e.forEach(O,function(A){var L=E(A);if(L.length){L=e.sortBy(L,function(F){return M[F]});for(var z=(L.length-1)/2,V=Math.floor(z),$=Math.ceil(z);V<=$;++V){var P=L[V];R[A]===A&&I<M[P]&&!u(j,A,P)&&(R[P]=A,R[A]=T[A]=T[P],I=M[P])}}})}),{root:T,align:R}}function f(S,_,j,E,T){var R={},M=h(S,_,j,T),O=T?"borderLeft":"borderRight";function I(z,V){for(var $=M.nodes(),P=$.pop(),F={};P;)F[P]?z(P):(F[P]=!0,$.push(P),$=$.concat(V(P))),P=$.pop()}function A(z){R[z]=M.inEdges(z).reduce(function(V,$){return Math.max(V,R[$.v]+M.edge($))},0)}function L(z){var V=M.outEdges(z).reduce(function(P,F){return Math.min(P,R[F.w]-M.edge(F))},Number.POSITIVE_INFINITY),$=S.node(z);V!==Number.POSITIVE_INFINITY&&$.borderType!==O&&(R[z]=Math.max(R[z],V))}return I(A,M.predecessors.bind(M)),I(L,M.successors.bind(M)),e.forEach(E,function(z){R[z]=R[j[z]]}),R}function h(S,_,j,E){var T=new t,R=S.graph(),M=v(R.nodesep,R.edgesep,E);return e.forEach(_,function(O){var I;e.forEach(O,function(A){var L=j[A];if(T.setNode(L),I){var z=j[I],V=T.edge(z,L);T.setEdge(z,L,Math.max(M(S,A,I),V||0))}I=A})}),T}function m(S,_){return e.minBy(e.values(_),function(j){var E=Number.NEGATIVE_INFINITY,T=Number.POSITIVE_INFINITY;return e.forIn(j,function(R,M){var O=b(S,M)/2;E=Math.max(R+O,E),T=Math.min(R-O,T)}),E-T})}function g(S,_){var j=e.values(_),E=e.min(j),T=e.max(j);e.forEach(["u","d"],function(R){e.forEach(["l","r"],function(M){var O=R+M,I=S[O],A;if(I!==_){var L=e.values(I);A=M==="l"?E-e.min(L):T-e.max(L),A&&(S[O]=e.mapValues(I,function(z){return z+A}))}})})}function w(S,_){return e.mapValues(S.ul,function(j,E){if(_)return S[_.toLowerCase()][E];var T=e.sortBy(e.map(S,E));return(T[1]+T[2])/2})}function k(S){var _=n.buildLayerMatrix(S),j=e.merge(r(S,_),s(S,_)),E={},T;e.forEach(["u","d"],function(M){T=M==="u"?_:e.values(_).reverse(),e.forEach(["l","r"],function(O){O==="r"&&(T=e.map(T,function(z){return e.values(z).reverse()}));var I=(M==="u"?S.predecessors:S.successors).bind(S),A=d(S,T,j,I),L=f(S,T,A.root,A.align,O==="r");O==="r"&&(L=e.mapValues(L,function(z){return-z})),E[M+O]=L})});var R=m(S,E);return g(E,R),w(E,S.graph().align)}function v(S,_,j){return function(E,T,R){var M=E.node(T),O=E.node(R),I=0,A;if(I+=M.width/2,e.has(M,"labelpos"))switch(M.labelpos.toLowerCase()){case"l":A=-M.width/2;break;case"r":A=M.width/2;break}if(A&&(I+=j?A:-A),A=0,I+=(M.dummy?_:S)/2,I+=(O.dummy?_:S)/2,I+=O.width/2,e.has(O,"labelpos"))switch(O.labelpos.toLowerCase()){case"l":A=O.width/2;break;case"r":A=-O.width/2;break}return A&&(I+=j?A:-A),A=0,I}}function b(S,_){return S.node(_).width}return gv}var yv,VT;function BY(){if(VT)return yv;VT=1;var e=at(),t=rn(),n=qY().positionX;yv=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(f){var h=e.max(e.map(f,function(m){return o.node(m).height}));e.forEach(f,function(m){o.node(m).y=d+h/2}),d+=h+u})}return yv}var wv,GT;function zY(){if(GT)return wv;GT=1;var e=at(),t=NY(),n=SY(),r=_Y(),s=rn().normalizeRanks,o=EY(),l=rn().removeEmptyRanks,u=CY(),d=TY(),f=RY(),h=FY(),m=BY(),g=rn(),w=Vn().Graph;wv=k;function k(U,Z){var H=Z&&Z.debugTiming?g.time:g.notime;H("layout",function(){var J=H(" buildLayoutGraph",function(){return I(U)});H(" runLayout",function(){v(J,H)}),H(" updateInputGraph",function(){b(U,J)})})}function v(U,Z){Z(" makeSpaceForEdgeLabels",function(){A(U)}),Z(" removeSelfEdges",function(){D(U)}),Z(" acyclic",function(){t.run(U)}),Z(" nestingGraph.run",function(){u.run(U)}),Z(" rank",function(){r(g.asNonCompoundGraph(U))}),Z(" injectEdgeLabelProxies",function(){L(U)}),Z(" removeEmptyRanks",function(){l(U)}),Z(" nestingGraph.cleanup",function(){u.cleanup(U)}),Z(" normalizeRanks",function(){s(U)}),Z(" assignRankMinMax",function(){z(U)}),Z(" removeEdgeLabelProxies",function(){V(U)}),Z(" normalize.run",function(){n.run(U)}),Z(" parentDummyChains",function(){o(U)}),Z(" addBorderSegments",function(){d(U)}),Z(" order",function(){h(U)}),Z(" insertSelfEdges",function(){W(U)}),Z(" adjustCoordinateSystem",function(){f.adjust(U)}),Z(" position",function(){m(U)}),Z(" positionSelfEdges",function(){B(U)}),Z(" removeBorderNodes",function(){K(U)}),Z(" normalize.undo",function(){n.undo(U)}),Z(" fixupEdgeLabelCoords",function(){F(U)}),Z(" undoCoordinateSystem",function(){f.undo(U)}),Z(" translateGraph",function(){$(U)}),Z(" assignNodeIntersects",function(){P(U)}),Z(" reversePoints",function(){Y(U)}),Z(" acyclic.undo",function(){t.undo(U)})}function b(U,Z){e.forEach(U.nodes(),function(H){var J=U.node(H),ee=Z.node(H);J&&(J.x=ee.x,J.y=ee.y,Z.children(H).length&&(J.width=ee.width,J.height=ee.height))}),e.forEach(U.edges(),function(H){var J=U.edge(H),ee=Z.edge(H);J.points=ee.points,e.has(ee,"x")&&(J.x=ee.x,J.y=ee.y)}),U.graph().width=Z.graph().width,U.graph().height=Z.graph().height}var S=["nodesep","edgesep","ranksep","marginx","marginy"],_={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},j=["acyclicer","ranker","rankdir","align"],E=["width","height"],T={width:0,height:0},R=["minlen","weight","width","height","labeloffset"],M={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},O=["labelpos"];function I(U){var Z=new w({multigraph:!0,compound:!0}),H=G(U.graph());return Z.setGraph(e.merge({},_,X(H,S),e.pick(H,j))),e.forEach(U.nodes(),function(J){var ee=G(U.node(J));Z.setNode(J,e.defaults(X(ee,E),T)),Z.setParent(J,U.parent(J))}),e.forEach(U.edges(),function(J){var ee=G(U.edge(J));Z.setEdge(J,e.merge({},M,X(ee,R),e.pick(ee,O)))}),Z}function A(U){var Z=U.graph();Z.ranksep/=2,e.forEach(U.edges(),function(H){var J=U.edge(H);J.minlen*=2,J.labelpos.toLowerCase()!=="c"&&(Z.rankdir==="TB"||Z.rankdir==="BT"?J.width+=J.labeloffset:J.height+=J.labeloffset)})}function L(U){e.forEach(U.edges(),function(Z){var H=U.edge(Z);if(H.width&&H.height){var J=U.node(Z.v),ee=U.node(Z.w),re={rank:(ee.rank-J.rank)/2+J.rank,e:Z};g.addDummyNode(U,"edge-proxy",re,"_ep")}})}function z(U){var Z=0;e.forEach(U.nodes(),function(H){var J=U.node(H);J.borderTop&&(J.minRank=U.node(J.borderTop).rank,J.maxRank=U.node(J.borderBottom).rank,Z=e.max(Z,J.maxRank))}),U.graph().maxRank=Z}function V(U){e.forEach(U.nodes(),function(Z){var H=U.node(Z);H.dummy==="edge-proxy"&&(U.edge(H.e).labelRank=H.rank,U.removeNode(Z))})}function $(U){var Z=Number.POSITIVE_INFINITY,H=0,J=Number.POSITIVE_INFINITY,ee=0,re=U.graph(),oe=re.marginx||0,fe=re.marginy||0;function Ne(ke){var we=ke.x,ve=ke.y,$e=ke.width,ye=ke.height;Z=Math.min(Z,we-$e/2),H=Math.max(H,we+$e/2),J=Math.min(J,ve-ye/2),ee=Math.max(ee,ve+ye/2)}e.forEach(U.nodes(),function(ke){Ne(U.node(ke))}),e.forEach(U.edges(),function(ke){var we=U.edge(ke);e.has(we,"x")&&Ne(we)}),Z-=oe,J-=fe,e.forEach(U.nodes(),function(ke){var we=U.node(ke);we.x-=Z,we.y-=J}),e.forEach(U.edges(),function(ke){var we=U.edge(ke);e.forEach(we.points,function(ve){ve.x-=Z,ve.y-=J}),e.has(we,"x")&&(we.x-=Z),e.has(we,"y")&&(we.y-=J)}),re.width=H-Z+oe,re.height=ee-J+fe}function P(U){e.forEach(U.edges(),function(Z){var H=U.edge(Z),J=U.node(Z.v),ee=U.node(Z.w),re,oe;H.points?(re=H.points[0],oe=H.points[H.points.length-1]):(H.points=[],re=ee,oe=J),H.points.unshift(g.intersectRect(J,re)),H.points.push(g.intersectRect(ee,oe))})}function F(U){e.forEach(U.edges(),function(Z){var H=U.edge(Z);if(e.has(H,"x"))switch((H.labelpos==="l"||H.labelpos==="r")&&(H.width-=H.labeloffset),H.labelpos){case"l":H.x-=H.width/2+H.labeloffset;break;case"r":H.x+=H.width/2+H.labeloffset;break}})}function Y(U){e.forEach(U.edges(),function(Z){var H=U.edge(Z);H.reversed&&H.points.reverse()})}function K(U){e.forEach(U.nodes(),function(Z){if(U.children(Z).length){var H=U.node(Z),J=U.node(H.borderTop),ee=U.node(H.borderBottom),re=U.node(e.last(H.borderLeft)),oe=U.node(e.last(H.borderRight));H.width=Math.abs(oe.x-re.x),H.height=Math.abs(ee.y-J.y),H.x=re.x+H.width/2,H.y=J.y+H.height/2}}),e.forEach(U.nodes(),function(Z){U.node(Z).dummy==="border"&&U.removeNode(Z)})}function D(U){e.forEach(U.edges(),function(Z){if(Z.v===Z.w){var H=U.node(Z.v);H.selfEdges||(H.selfEdges=[]),H.selfEdges.push({e:Z,label:U.edge(Z)}),U.removeEdge(Z)}})}function W(U){var Z=g.buildLayerMatrix(U);e.forEach(Z,function(H){var J=0;e.forEach(H,function(ee,re){var oe=U.node(ee);oe.order=re+J,e.forEach(oe.selfEdges,function(fe){g.addDummyNode(U,"selfedge",{width:fe.label.width,height:fe.label.height,rank:oe.rank,order:re+ ++J,e:fe.e,label:fe.label},"_se")}),delete oe.selfEdges})})}function B(U){e.forEach(U.nodes(),function(Z){var H=U.node(Z);if(H.dummy==="selfedge"){var J=U.node(H.e.v),ee=J.x+J.width/2,re=J.y,oe=H.x-ee,fe=J.height/2;U.setEdge(H.e,H.label),U.removeNode(Z),H.label.points=[{x:ee+2*oe/3,y:re-fe},{x:ee+5*oe/6,y:re-fe},{x:ee+oe,y:re},{x:ee+5*oe/6,y:re+fe},{x:ee+2*oe/3,y:re+fe}],H.label.x=H.x,H.label.y=H.y}})}function X(U,Z){return e.mapValues(e.pick(U,Z),Number)}function G(U){var Z={};return e.forEach(U,function(H,J){Z[J.toLowerCase()]=H}),Z}return wv}var vv,KT;function UY(){if(KT)return vv;KT=1;var e=at(),t=rn(),n=Vn().Graph;vv={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 f="layer"+d;l.setNode(f,{rank:"same"}),e.reduce(u,function(h,m){return l.setEdge(h,m,{style:"invis"}),m})}),l}return vv}var xv,YT;function HY(){return YT||(YT=1,xv="0.8.5"),xv}var bv,XT;function WY(){return XT||(XT=1,bv={graphlib:Vn(),layout:zY(),debug:UY(),util:{time:rn().time,notime:rn().notime},version:HY()}),bv}var VY=WY();const ZT=jx(VY),td=240,D$=130,yx=fa*2+Yv+WA,GY=72,Oo=yx+GY,Ru=24,F$=fa*2+Ru,nd=Oo;function q$(e,t){var r;let n=td;for(const s of e)n=Math.max(n,((r=t.get(s.id))==null?void 0:r.width)??td);return n}const rd=420,B$=1;function KY(e,t,n,r){return Math.min(B$,n/Math.max(1,e),r/Math.max(1,t))}function Gd(e){var n;return((n=e.data)==null?void 0:n.sessionId)??"_default"}function Kd(e,t=()=>!0){const n=new Map;for(const r of e){if(!t(r))continue;const s=Gd(r),o=n.get(s);o?o.push(r):n.set(s,[r])}return n}function YY(e,t){return((t==null?void 0:t.get(e))??0)>0?rd:0}function XY(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function sd(e,t){const n=t.get(e);return{w:(n==null?void 0:n.width)??td,h:(n==null?void 0:n.height)??D$}}function Al(e,t,n){const r=sd(e,t);return{w:r.w+YY(e,n),h:Math.max(r.h,XY(e,n))}}function ZY(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function JY(e,t,n){const r=Kd(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 f;if(t.has(s.id)||n(s.id))return s;const o=r.get(Gd(s));if(!o)return s;const l=(f=s.data)==null?void 0:f.parentId,u=o.find(h=>h.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 QY(e,t,n,r,s,o,l){const u=j=>Al(j,r,o),d=j=>n.get(j)??t.get(j),f=j=>{const{w:E,h:T}=sd(j,r);return{cw:E,ch:T}},h=l!=null&&l.width>0&&l.height>0,m=Kd(e,j=>d(j.id)!=null),g=new Set;for(const[j,E]of m)E.every(T=>s.has(T.id)&&!n.has(T.id))&&g.add(j);const w=new Map,k=[];for(const j of e){const E=d(j.id);if(!E)continue;const{w:T,h:R}=u(j.id),M=Gd(j);g.has(M)?(w.get(M)??w.set(M,[]).get(M)).push(j):k.push({x:E.x,y:E.y,w:T,h:R,...f(j.id)})}if(w.size===0||h&&k.length===0)return[];const v=nd,b=(j,E,T,R)=>k.some(M=>j<M.x+M.w+yx&&M.x<j+T+yx&&E<M.y+M.h+v&&M.y<E+R+v),S=q$(e,r),_=[];for(const j of[...w.keys()].sort()){const E=w.get(j);let T=1/0,R=1/0,M=-1/0,O=-1/0,I=-1/0,A=-1/0;for(const Y of E){const K=d(Y.id),{w:D,h:W}=u(Y.id),{cw:B,ch:X}=f(Y.id);T=Math.min(T,K.x),R=Math.min(R,K.y),M=Math.max(M,K.x+D),O=Math.max(O,K.y+W),I=Math.max(I,K.x+B),A=Math.max(A,K.y+X)}const L=M-T,z=O-R,V=[...new Set(k.map(Y=>Math.round(Y.x)))].sort((Y,K)=>Y-K),$=V.length?V:[T],P=[0,...k.map(Y=>Y.y+Y.h+v)].sort((Y,K)=>Y-K);let F=null;if(h){let Y=1/0,K=1/0,D=-1/0,W=-1/0;for(const H of k)Y=Math.min(Y,H.x),K=Math.min(K,H.y),D=Math.max(D,H.x+H.cw),W=Math.max(W,H.y+H.ch);const B=(H,J)=>{const ee=l.width/(Math.max(D,H+I-T)-Math.min(Y,H)+rd),re=l.height/(Math.max(W,J+A-R)-Math.min(K,J));return[Math.min(B$,ee,re),Math.min(ee,re),Math.max(ee,re)]},X=(H,J)=>{for(let ee=0;ee<H.length;ee++){if(H[ee]>J[ee]+1e-9)return!0;if(H[ee]<J[ee]-1e-9)return!1}return!1},G=Math.round(D+rd+S),U=[...new Set([...P,K])].sort((H,J)=>H-J);let Z=null;for(const H of[...$,G])for(const J of U){if(b(H,J,L,z))continue;const ee=B(H,J);(Z===null||X(ee,Z))&&(Z=ee,F={x:H,y:J})}F&&F.x===T&&F.y===R&&(F=null)}else e:for(const Y of $)for(const K of P){if(K>=R)break;if(!b(Y,K,L,z)){F={x:Y,y:K};break e}}if(F){const Y=F.x-T,K=F.y-R;for(const D of E){const W=d(D.id);t.set(D.id,{x:W.x+Y,y:W.y+K})}_.push(j)}for(const Y of E){const K=d(Y.id),{w:D,h:W}=u(Y.id);k.push({x:K.x,y:K.y,w:D,h:W,...f(Y.id)})}}return _}function eX(e,t,n,r,s,o){const l=g=>Al(g,r,s),u=new Map(e.map(g=>[g.id,Gd(g)])),d=[],f=e.map(g=>({id:g.id,pos:n.get(g.id)??t.get(g.id)})).filter(g=>g.pos!=null).sort((g,w)=>g.pos.y-w.pos.y||g.pos.x-w.pos.x||g.id.localeCompare(w.id)),h=g=>(o==null?void 0:o.has(g))===!0&&!n.has(g);for(const{id:g,pos:w}of f){if(!h(g))continue;const{w:k,h:v}=l(g);d.push({x:w.x,y:w.y,w:k,h:v,sid:u.get(g)??"_default"})}const m=[];for(const{id:g,pos:w}of f){if(h(g))continue;const{w:k,h:v}=l(g),b=u.get(g)??"_default";if(n.has(g)){d.push({x:w.x,y:w.y,w:k,h:v,sid:b});continue}let S=w.y;for(let _=0;_<d.length+1;_++){const j=d.find(E=>{const T=E.sid===b?Ru:F$,R=E.sid===b?Ru:nd;return w.x<E.x+E.w+T&&E.x<w.x+k+T&&S<E.y+E.h+R&&E.y<S+v+R});if(!j)break;S=j.y+j.h+(j.sid===b?Ru:nd)}S!==w.y&&(t.set(g,{x:w.x,y:S}),m.push(g)),d.push({x:w.x,y:S,w:k,h:v,sid:b})}return m}function tX(e,t,n,r,s,o=!1,l){const d=F$+1,f=nd+1,h=8,m=1.75,g=200,w=.7,k=.01,v=A=>Al(A,r,l),b=A=>n.get(A)??t.get(A),S=Kd(e,A=>b(A.id)!=null),_=[],j=new Set,E=new Set,T=s.size===0;for(const A of[...S.keys()].sort()){const L=S.get(A);let z=1/0,V=1/0,$=-1/0,P=-1/0,F=!1;for(const W of L){const B=b(W.id),{w:X,h:G}=v(W.id);z=Math.min(z,B.x),V=Math.min(V,B.y),$=Math.max($,B.x+X),P=Math.max(P,B.y+G),n.has(W.id)&&(F=!0)}const Y=$-z,K=P-V;E.add(A);const D=s.get(A);D&&(Y>D.w+h||K>D.h+h)&&j.add(A),s.set(A,{w:Y,h:K}),_.push({sid:A,members:L.map(W=>W.id),x:z,y:V,w:Y,h:K,anchored:F,mass:1})}for(const A of[...s.keys()])E.has(A)||s.delete(A);if(o||T)return[];let R=!1;for(let A=0;A<_.length&&!R;A++)for(let L=A+1;L<_.length;L++){const z=_[A],V=_[L];if(!(z.anchored&&V.anchored)&&Math.abs(z.x+z.w/2-(V.x+V.w/2))<(z.w+V.w)/2+d&&Math.abs(z.y+z.h/2-(V.y+V.h/2))<(z.h+V.h)/2+f){R=!0;break}}if(j.size===0&&!R)return[];if(j.size>0)for(const A of _)j.has(A.sid)&&(A.mass=8);else for(const A of _)A.mass=Math.max(1,A.w*A.h/(td*D$));const M=new Map(_.map(A=>[A.sid,A.x])),O=new Map(_.map(A=>[A.sid,A.y]));for(let A=0;A<g;A++){const L=new Map,z=new Map;let V=0;for(let $=0;$<_.length;$++)for(let P=$+1;P<_.length;P++){const F=_[$],Y=_[P];if(F.anchored&&Y.anchored)continue;const K=F.x+F.w/2,D=F.y+F.h/2,W=Y.x+Y.w/2,B=Y.y+Y.h/2,X=(F.w+Y.w)/2+d-Math.abs(K-W),G=(F.h+Y.h)/2+f-Math.abs(D-B);if(X<=0||G<=0)continue;const U=(Ie,qe)=>!Ie.anchored&&!(qe<0&&Ie.x<=0),Z=(Ie,qe)=>!Ie.anchored&&!(qe<0&&Ie.y<=0),H=(Ie,qe,nt)=>{const rt=Ie===qe,Ye=rt?F.sid<Y.sid?-1:1:Math.sign(Ie-qe);return nt(F,Ye)||nt(Y,-Ye)?Ye:rt&&(nt(F,-Ye)||nt(Y,Ye))?-Ye:0},J=H(K,W,U),ee=H(D,B,Z),re=J!==0,oe=ee!==0;if(!re&&!oe)continue;const fe=re&&(!oe||X*m<G),[Ne,ke,we,ve]=fe?[J,X,L,U]:[ee,G,z,Z],$e=ve(F,Ne),ye=ve(Y,-Ne),ue=F.mass,se=Y.mass,xe=$e?ye?se/(ue+se):1:0,Ae=ye?$e?ue/(ue+se):1:0,Le=ke*w;we.set(F.sid,(we.get(F.sid)??0)+Ne*Le*xe),we.set(Y.sid,(we.get(Y.sid)??0)-Ne*Le*Ae),V+=Le}for(const $ of _)$.anchored||($.x=Math.max(0,$.x+(L.get($.sid)??0)),$.y=Math.max(0,$.y+(z.get($.sid)??0)));if(V<k)break}const I=[];for(const A of _){const L=A.x-M.get(A.sid),z=A.y-O.get(A.sid);if(!(Math.abs(L)<1&&Math.abs(z)<1)){for(const V of A.members){if(n.has(V))continue;const $=t.get(V);$&&t.set(V,{x:$.x+L,y:$.y+z})}I.push(A.sid)}}return I}function nX(e,t,n,r,s,o){const l=new ZT.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const u=e.filter(S=>!s.has(S)),d=new Set(u);for(const S of u){const{w:_,h:j}=Al(S,r,o);l.setNode(S,{width:_,height:j})}for(const S of t)d.has(S.source)&&d.has(S.target)&&l.setEdge(S.source,S.target);ZT.layout(l);const f=new Map;let h=1/0,m=1/0,g=-1/0,w=-1/0;for(const S of u){const _=l.node(S);if(!_)continue;const{w:j,h:E}=sd(S,r),T=Al(S,r,o),R=_.x-T.w/2,M=_.y-T.h/2;f.set(S,{x:R,y:M}),R<h&&(h=R),M<m&&(m=M),R+j>g&&(g=R+j),M+E>w&&(w=M+E)}if(Number.isFinite(h)&&Number.isFinite(m))for(const[S,_]of f)f.set(S,{x:_.x-h,y:_.y-m});const k=Number.isFinite(g)?g-h:0,v=Number.isFinite(w)?w-m:0;let b=null;for(const S of e){const _=s.get(S);if(!_)continue;const{w:j,h:E}=sd(S,r);b=b===null?{minX:_.x,minY:_.y,maxX:_.x+j,maxY:_.y+E}:{minX:Math.min(b.minX,_.x),minY:Math.min(b.minY,_.y),maxX:Math.max(b.maxX,_.x+j),maxY:Math.max(b.maxY,_.y+E)}}return{positions:f,width:k,height:v,pinnedBox:b}}function z$(e,t,n){const r=n.direction??"LR",s=n.pinned??new Map,o=n.measured??new Map,l=n.lanes,u=Kd(e);return{laid:Array.from(u.keys()).sort().map(h=>({sid:h,...nX(u.get(h).map(m=>m.id),t,r,o,s,l)})),gap:q$(e,o)}}const U$=e=>e.reduce((t,n)=>Math.max(t,n.width),0)+rd,rX=e=>e.reduce((t,n)=>t+n.height,0)+Oo*Math.max(0,e.length-1);function wx(e,t,n,r){const s=d=>{const f=[[]];let h=0;for(const m of e)h>0&&h+m.height>d&&(f.push([]),h=0),f[f.length-1].push(m),h+=m.height+Oo;return f},o=[];for(let d=0;d<e.length;d++){let f=-Oo;for(let h=d;h<e.length;h++)o.push(f+=e[h].height+Oo)}o.sort((d,f)=>d-f);const l=d=>{let f=0,h=o.length-1;for(;f<h;){const m=f+h>>1;s(o[m]).length<=d?h=m:f=m+1}return s(o[f])};let u=[e];if(n>0&&r>0){const d=h=>KY(h.reduce((m,g)=>m+U$(g),0)+t*(h.length-1),Math.max(...h.map(rX)),n,r);let f=d(u);for(let h=2;h<=e.length;h++){const m=l(h),g=d(m);g>f+1e-9&&(f=g,u=m)}}return u}function sX(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}=z$(e,t,n);return o.length<2?!1:wx(o,l,r.width,r.height).length!==wx(o,l,s.width,s.height).length}function aX(e,t,n={}){const r=n.pinned??new Map,{laid:s,gap:o}=z$(e,t,n),l=wx(s,o,n.availableWidth??0,n.availableHeight??0),u=new Map;let d=0;for(const f of l){const h=U$(f);let m=0;for(const{positions:g,height:w,pinnedBox:k}of f){for(const[b,S]of g)u.set(b,{x:S.x+d,y:S.y+m});let v=m+w;k&&k.maxY>v&&k.minX<d+h&&d<k.maxX&&(v=k.maxY),m=v+Oo}d+=h+o}return e.map(f=>{const h=r.get(f.id);if(h)return{...f,position:h};const m=u.get(f.id);return m?{...f,position:m}:f})}function Au(e,t,n){return!t.has(e)||n.has(e)}function oX(e,t,n,r){return!t.has(e)&&Au(e,n,r)}function iX(e,t,n){const r={x:0,y:0};return t.set(e,r),n.add(e),r}function JT(e,t,n,r){n.set(e,t),r.delete(e)}const lX=300,QT=130,cX=160,e2=new WeakMap;function uX(e,t){let n=e2.get(e);(!n||n.revision!==e.revision||n.open!==t)&&(n={revision:e.revision,open:t,byId:new Map,branches:gq(e.agents.values())},e2.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 D0(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 dX(e,t,n,r,s,o,l,u,d,f,h,m,g,w,k,v,b,S,_,j){var F,Y,K,D;const E=[],T=[],R=uX(e,S);for(const W of e.agents.values()){if(!b.has(W.id))continue;const B=W.exitAt!=null,X=v!=null&&!v.has(W.id),G=[B?"rf-exiting":"",X?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,U=o.get(W.id);if(E.push({id:W.id,type:"agent",position:{x:0,y:0},data:R(W),className:G,ariaLabel:A6(W,t,k.has(W.id)),...U?{width:U.width,height:U.height}:null}),W.parentId&&b.has(W.parentId)){const J=Uu(W.sessionId),ee=B,re=k.size>0&&(k.has(W.id)||k.has(W.parentId)),oe=v!=null&&!v.has(W.id)&&!v.has(W.parentId),fe=W.state==="active"?2:1.5,Ne=re?fe+1.5:fe,ke=ee?.2:oe?.12:1,we=["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":J,strokeWidth:`calc(${Ne}px * var(--edge-k, 1))`,opacity:ke,transition:"var(--edge-transition)"},className:we})}const Z=W.kind==="root"?wd(W):null,H=Z?EA(W.sessionId,Z.at):null;if(Z&&H&&!uq(H)){const J=e0(W.id),ee=Uu(W.sessionId),re=o.get(J);E.push({id:J,type:"recapNote",position:{x:0,y:0},data:{sessionId:W.sessionId,parentId:W.id,recap:Z,noteKey:H,hue:ee},className:X?"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:J,target:W.id,type:"recapTie",className:"recap-edge",focusable:!1,style:{"--session-hue":ee}})}}const M=D0(e),O=j.size>0&&!(d&&_);O||j.clear();const I=`${g}#lanes:${ZY(M)}${O?"#held":""}`,A=new Set(E.filter(W=>W.type==="recapNote").map(W=>W.id));for(const W of Array.from(h.keys()))_&&pq(W)&&!A.has(W)&&!s.has(W)&&(h.delete(W),m.delete(W));const L=E.filter(W=>oX(W.id,s,h,m));if(L.length>0||I!==w.current){if(L.length>0){for(const B of L)j.delete(B.id);const W=JY(aX(E,T,{direction:"LR",pinned:s,measured:o,availableWidth:n,availableHeight:r,lanes:M}),s,B=>Au(B,h,m)?void 0:h.get(B));for(const B of W)Au(B.id,h,m)&&JT(B.id,B.position,h,m);QY(E,h,s,o,new Set(L.filter(B=>B.type!=="recapNote").map(B=>B.id)),M,{width:n,height:r});for(const B of L){if(B.type!=="recapNote")continue;const X=(F=B.data)==null?void 0:F.parentId;if(!X)continue;const G=s.get(X)??(Au(X,h,m)?void 0:h.get(X));if(!G)continue;const U=((Y=o.get(B.id))==null?void 0:Y.width)??lX,Z=((K=o.get(B.id))==null?void 0:K.height)??QT,H=((D=o.get(X))==null?void 0:D.height)??QT;JT(B.id,{x:G.x-cX-U,y:G.y+(H-Z)/2},h,m)}}eX(E,h,s,o,M,O?j:void 0),w.current=I}const z=tX(E,h,s,o,l,!d||f,M);z.length>0&&u(z);const V=EV(e.agents.values());_&&pu(h,V),pu(m,V),_&&pu(s,V),pu(o,_V(e.agents.values()));const $=[];let P=!1;for(const W of E){let B=s.get(W.id)??h.get(W.id);B||(B=iX(W.id,h,m),P=!0),$.push({...W,position:B})}return P&&(w.current=""),{nodes:$,edges:T}}function hX(e){return e.slice().sort((t,n)=>t.y-n.y||t.x-n.x)}function fX(e,t,n){var l;if(e.length===0)return null;const r=hX(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 pX=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Backspace"]);function mX(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:pX.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const gX=new Set(["","BODY","HTML","#DOCUMENT"]);function yX(e){return!e||yd(e)?!1:!gX.has(String(e.tagName??"").toUpperCase())}const H$="react-flow__node";function F0(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,H$))===!0}function wX(e){try{const t=document.querySelector(`.${H$}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}let ya=null,To=null;const vx=new Set,xx=()=>{for(const e of vx)e()},vX=e=>(vx.add(e),()=>{vx.delete(e)}),t2=()=>ya,xX=90;function W$(e){!To||e!=null&&To.at.id!==e||(clearTimeout(To.timer),To=null)}function V$(e,t,n="pointer"){W$();const r={id:e,anchor:t,by:n};if(ya||n==="focus"){ya=r,xx();return}To={at:r,timer:setTimeout(()=>{To=null,ya=r,xx()},xX)}}function Es(e){W$(e),!(!ya||e!=null&&ya.id!==e)&&(ya=null,xx())}function bX({agentFor:e,recapFor:t,labelFor:n,bounds:r}){const s=x.useSyncExternalStore(vX,t2,t2),o=s?e(s.id):void 0,l=s&&!o?t(s.id):void 0,u=s!=null&&(!o&&!l||!s.anchor.isConnected);return x.useEffect(()=>{u&&s&&Es(s.id)},[u,s]),!s||u?null:o?i.jsx(NX,{a:o,anchor:s.anchor,parentLabel:o.parentId?n(o.parentId):void 0,bounds:r},s.id):l?i.jsx(kX,{r:l,anchor:s.anchor,bounds:r},s.id):null}function G$(e,t){const n=x.useRef(null),r=x.useCallback(()=>{const s=n.current;if(!s||!e.isConnected)return;const o=l0(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 x.useLayoutEffect(()=>{r()}),n}function kX({r:e,anchor:t,bounds:n}){const r=G$(t,n),s=Zo(3e4),o=Gu(e.recap.at,s);return zt.createPortal(i.jsxs("div",{ref:r,className:"ap-peek node-peek recap-peek",role:"tooltip",id:"node-peek",style:{"--session-hue":e.hue},children:[i.jsxs("div",{className:"node-peek-head",children:[i.jsxs("span",{className:"recap-peek-mark",children:[i.jsx(Nl,{}),"recap"]}),i.jsx("span",{className:"node-peek-time",title:o.title,children:o.label})]}),e.sessionLabel&&i.jsx("div",{className:"node-peek-kind",children:i.jsxs("span",{children:["Claude Code's recap of ",e.sessionLabel]})}),i.jsx("p",{className:"recap-peek-text",children:e.recap.text}),i.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for its details"})]}),document.body)}function NX({a:e,anchor:t,parentLabel:n,bounds:r}){const s=G$(t,r),o=Zo(1e3),l=Jx(e.sessionName,e.sessionTitle),u=e.tools.filter(k=>k.ok===!1).length,d=e.tools.filter(k=>!k.endedAt).length,f=an(e,o).total,h=e.usage.inputTokens+e.usage.outputTokens,m=e.kind==="root"&&Kn(e.waiting),g=e.kind==="root"?"session":n?`subagent of ${n}`:"subagent",w=[`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,d>0?`${d} in-flight`:null,h>0?`${et(h)} tok`:null,f>0?`${Be(f)}${kl(e,o)>0?"+":""}`:null].filter(Boolean).join(" · ");return zt.createPortal(i.jsxs("div",{ref:s,className:"ap-peek node-peek",role:"tooltip",id:"node-peek",children:[i.jsxs("div",{className:"node-peek-head",children:[i.jsx("span",{className:"node-peek-name",children:e.label}),i.jsxs("span",{className:"node-peek-time",children:[e.synthetic?"≥ ":"",zo(e.startedAt,e.endedAt,o)]})]}),i.jsxs("div",{className:"node-peek-kind",children:[i.jsxs("span",{className:"node-peek-state","data-kind":Wv(e.state),children:[i.jsx(IA,{kind:Wv(e.state)}),qo(e.state)]}),i.jsx("span",{children:g}),e.model?i.jsx("span",{children:js(e.model)}):null]}),e.kind==="root"&&l.face&&i.jsx("p",{className:"node-peek-title",children:l.face}),e.kind==="root"&&e.waiting&&i.jsxs("p",{className:`node-peek-wait${m?" warn":""}`,children:[m&&i.jsx(r0,{}),i.jsx("span",{children:Zx(e.waiting)}),i.jsx("b",{children:zo(e.waiting.since,void 0,o)})]}),i.jsxs("p",{className:"node-peek-facts",children:[w,u>0&&i.jsxs("span",{className:"node-peek-failed",children:[" · ",u," failed"]})]}),e.branch&&e.branch.total>0&&i.jsx("p",{className:"node-peek-branch",children:CA(e.branch)}),i.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for details"})]}),document.body)}function SX(e){const t=e.minZoom??A9,n=e.maxZoom??M9,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,f=e.anchor,h=Math.min(l/Math.max(1,d.width),u/Math.max(1,d.height))*r,m=Math.max(t,Math.min(n,h)),g=(w,k,v,b,S,_)=>{let j=w+(k-b*m)/2-v*m;const E=S*m+j,T=(S+_)*m+j;return _*m<=k?E<w?j+=w-E:T>w+k&&(j-=T-(w+k)):j+=w-E,j};return{x:g(s,l,d.x,d.width,f.x,f.width),y:g(o,u,d.y,d.height,f.y,f.height),zoom:m}}function jX(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 En(e){const t=x.useRef(e);return t.current=e,t}const bx=80,kx=.86;function K$(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 _X({canvasRef:e,canvasSize:t,machinePhase:n,usagePhase:r,usagePanelOpen:s,detailShown:o}){const[l,u]=x.useState(0);x.useEffect(()=>{const m=K$(e.current);u(g=>Math.abs(g-m)>40?m:g)},[n,r,s,o,t.w]);const d=En(l),f=t.w>0?Math.max(0,(t.w-l-bx*2)*kx):0,h=t.h>0?Math.max(0,(t.h-bx*2)*kx):0;return{railInsetRef:d,availableWidth:f,availableHeight:h}}const Y$=420;function EX(){const e=Go(),t=yt(),n=x.useCallback((d,f)=>{if(zv({durationMs:f,documentHidden:document.hidden})){e.setViewport(d,{duration:f});return}const{d3Zoom:h,d3Selection:m}=t.getState(),g=m==null?void 0:m.property("__zoom");if(h&&m&&g&&g.k>0&&d.zoom>0){h.transform(m,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=x.useRef(null),s=x.useRef(0),o=x.useRef(0),l=x.useCallback((d,f)=>{const h=++s.current;return n(d,f),o.current=Date.now(),r.current=zv({durationMs:f,documentHidden:document.hidden})?{target:d,until:Date.now()+f+60}:null,h},[n]),u=x.useCallback((d=500)=>{const f=bx,h=1,m=.2,g=kx;try{const w=document.querySelector(".canvas-wrap"),k=Array.from(document.querySelectorAll(".react-flow__node")).filter(P=>P.offsetWidth>0);if(!w||k.length===0)return;const v=w.getBoundingClientRect(),b=e.getViewport();if(!Number.isFinite(b.zoom)||b.zoom<=0)return;const S=P=>(P-v.left-b.x)/b.zoom,_=P=>(P-v.top-b.y)/b.zoom,j=k.map(P=>P.getBoundingClientRect()),E=Math.min(...j.map(P=>S(P.left))),T=Math.max(...j.map(P=>S(P.right))),R=Math.min(...j.map(P=>_(P.top))),M=Math.max(...j.map(P=>_(P.bottom))),O=T-E,I=M-R;if(!(O>0&&I>0))return;const A=K$(w),L=P=>Math.max(m,Math.min(h,(v.width-A-f*2)/(O+P)*g,(v.height-f*2)/I*g)),z=R9(L(Y$),L(0)),V={x:f-E*z,y:Math.max(f,(v.height-I*z)/2)-R*z,zoom:z},$=l(V,d);window.setTimeout(()=>{var P;try{if(((P=r.current)==null?void 0:P.target)===V&&(r.current=null),s.current!==$)return;const F=e.getViewport();(Math.abs(F.zoom-z)>.01||Math.abs(F.x-V.x)>2)&&n(V,0)}catch{}},d+60)}catch{}},[e,n,l]);return x.useEffect(()=>{const d=()=>{if(!document.hidden)return;const f=r.current;if(r.current=null,!(!f||Date.now()>f.until)){try{n(f.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 CX=450;function TX({canvasRef:e,stateRef:t,measuredRef:n,nodesRef:r,railInsetRef:s,moveCamera:o,disableAutoFit:l,lastFocusRef:u,focusAgentRef:d,selectAgent:f,primarySelectedIdRef:h}){const m=x.useCallback(k=>{var O;const v=e.current,b=t.current.agents.get(k);if(!v||!b)return;const S=D0(t.current),_=(I,A)=>{const L=n.current.get(I.id);if(!L)return null;const z=A&&S.has(I.id)?Y$:0;return{x:I.position.x,y:I.position.y,width:L.width+z,height:L.height}},j=r.current.find(I=>I.id===k),E=j?_(j,!1):null;if(!E)return;const T=[];for(const I of r.current){if(I.type!=="agent"&&I.type!=="recapNote"||((O=I.data)==null?void 0:O.sessionId)!==b.sessionId)continue;const A=_(I,I.type==="agent");A&&T.push(A)}const R=v.getBoundingClientRect(),M=SX({pane:{width:R.width,height:R.height},insets:{top:56,left:72,bottom:32,right:s.current+32},context:jX(T)??E,anchor:E});Es(),l(),u.current={id:k,at:Date.now()},o(M,CX)},[o,l]);d.current=m;const g=x.useCallback(k=>{const v=r.current.filter(j=>j.type==="agent"),b=fX(v.map(j=>({id:j.id,x:j.position.x,y:j.position.y})),h.current,k),S=b?v.find(j=>j.id===b):void 0;if(!S)return;const _=F0(document.activeElement);f(S.id,!1),window.setTimeout(()=>{try{m(S.id)}catch{}_&&wX(S.id)},30)},[f,m]),w=x.useCallback(k=>{f(k,!1),window.setTimeout(()=>{try{m(k)}catch{}},60)},[f,m]);return{focusAgent:m,stepAgent:g,focusSession:w}}function RX({nodesRef:e,stateRef:t,canvasRef:n,railInsetRef:r}){const s=x.useCallback(d=>{const f=e.current.find(h=>h.id===d&&h.type==="agent");return f?f.data:void 0},[]),o=x.useCallback(d=>{var f;return(f=t.current.agents.get(d))==null?void 0:f.label},[]),l=x.useCallback(d=>{var m;const f=e.current.find(g=>g.id===d&&g.type==="recapNote");if(!f)return;const h=f.data;return{recap:h.recap,hue:h.hue,sessionLabel:(m=t.current.agents.get(h.parentId))==null?void 0:m.label}},[]),u=x.useCallback(()=>{var h;const d=(h=n.current)==null?void 0:h.getBoundingClientRect(),f=document.documentElement;return d?{width:d.right-r.current,height:d.bottom}:{width:f.clientWidth,height:f.clientHeight}},[]);return{peekAgent:s,peekLabel:o,peekRecap:l,peekBounds:u}}function AX(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 n2(e){return Object.entries(e??{}).filter(([,t])=>t&&typeof t.x=="number"&&typeof t.y=="number")}function MX(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=n2(n);return{positions:s,pins:s.map(([o])=>o)}}const r=n;return{positions:n2(r.positions),pins:Array.isArray(r.pins)?r.pins:[]}}function $X(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 IX(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 q0="agent-dag.layout",B0="agent-dag.layoutFrame",z0="agent-dag.viewport";function OX(){return MX(tt(q0))}function Ml(e,t){Ke(q0,$X(e,t))}function LX(){return IX(tt(B0))}function X$(e){Ke(B0,JSON.stringify(e))}function PX(){return fF(tt(z0))}function DX(e){Ke(z0,JSON.stringify(e))}function Z$(){Br(q0),Br(z0),Br(B0)}function FX(e){const t=x.useState(()=>AX(OX()))[0],n=x.useRef(t.pinned),r=x.useRef(t.positions),s=x.useRef(new Set),o=x.useRef(""),[l,u]=x.useState(0),d=x.useState(LX)[0],f=x.useRef(d),h=x.useCallback(()=>{n.current.clear(),r.current.clear(),o.current="",Z$(),u(m=>m+1),window.setTimeout(()=>{Ml(r.current,n.current),f.current&&X$(f.current),e(500)},80)},[e]);return{restoredLayout:t,pinnedRef:n,positionsRef:r,provisionalRef:s,lastLayoutSigRef:o,layoutEpoch:l,setLayoutEpoch:u,lastLayoutFrameRef:f,handleRelayout:h}}function qX(e,t){const{positionsRef:n,pinnedRef:r}=t,s=x.useRef(null);x.useEffect(()=>(s.current!=null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{Ml(n.current,r.current)},1500),()=>{s.current!=null&&window.clearTimeout(s.current)}),[e])}function BX({nodes:e,edges:t,settled:n,dragging:r,availableWidth:s,availableHeight:o,layout:l,camera:u,rf:d,measuredRef:f,stateRef:h,lastFocusRef:m,primarySelectedIdRef:g,focusAgentRef:w,autoFitDisabledRef:k}){const{lastLayoutFrameRef:v,pinnedRef:b,positionsRef:S,provisionalRef:_,lastLayoutSigRef:j,setLayoutEpoch:E}=l,{applyViewport:T,fitLeft:R,cameraEpochRef:M,lastFitTimeRef:O}=u;x.useEffect(()=>{if(!n||r)return;const I={width:s,height:o};if(!(I.width>0&&I.height>0))return;const A=v.current;if(v.current=I,X$(I),!A||A.width===I.width&&A.height===I.height)return;const L={direction:"LR",pinned:b.current,measured:f.current,lanes:D0(h.current)};if(!sX(e,t,L,A,I))return;const z=m.current&&Date.now()-m.current.at<1500?m.current.id:null,V=z??g.current,$=V?b.current.get(V)??S.current.get(V):void 0;for(const P of Array.from(S.current.keys()))b.current.has(P)||S.current.delete(P);_.current.clear(),j.current="",E(P=>P+1),window.setTimeout(()=>{if(Ml(S.current,b.current),k.current){if(z){w.current(z);return}const P=V?b.current.get(V)??S.current.get(V):void 0;if($&&P&&(P.x!==$.x||P.y!==$.y)){const F=d.getViewport();M.current+=1,T({x:F.x-(P.x-$.x)*F.zoom,y:F.y-(P.y-$.y)*F.zoom,zoom:F.zoom},0),O.current=Date.now()}return}R(500)},80)},[s,o,n,r,R,d,T])}const zX=600;function U0(e,t){return!(e.exitAt!=null&&t-e.exitAt>zX||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function UX(e,t){const n=new Set;for(const r of e.agents.values())U0(r,t)&&n.add(r.id);return n}function HX(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 WX(e,t,n=0){if(!e)return!1;for(const r of t)if(HX(e,r,n))return!0;return!1}function VX(e,t,n,r,s){const o=[];for(const l of e)!U0(l,t)||n.has(l.id)||o.push(l.id+(l.parentId?`>${l.parentId}`:""));return o.sort(),`${o.join("|")}#sv${r}.${s}`}const H0="agent-dag.removedNodes";function GX(e){try{const t=JSON.parse((e==null?void 0:e.getItem(H0))??"[]");return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function r2(e,t){try{e==null||e.setItem(H0,JSON.stringify([...t]))}catch{}}function J$(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 KX(e,t){if(t.size===0)return new Set;const n=[...e],r=J$(n,t);return new Set(n.filter(r).map(s=>s.id))}function YX(e,t,n){const r=u=>({id:u.id,parentId:u.data.parentId,sessionId:u.data.sessionId}),s=J$(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 XX(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 ZX(e,t){return t.size===0?[]:[...e].filter(n=>t.has(n.id)).map(n=>n.id)}function JX(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 QX(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 eZ(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=JX(u);if(d<=s)continue;const f=[],h=new Set,m=w=>{var k;for(let v=w;v&&!h.has(v);v=(k=e.get(v))==null?void 0:k.parentId)h.add(v),n.has(v)&&f.push(v)};m(u.id),m(u.sessionId);let g=-1/0;for(const w of f)g=Math.max(g,r.get(w)??1/0);if(d>g)for(const w of f)o.add(w)}return[...o]}const Q$="sessionGroup";function tZ(e,t){var r,s;if(e.type===Q$)return"transparent";if(Kn((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 mu=fa;function nZ(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,f=u+o,h=d+l,m=t.get(s.sessionId);m?(m.minX=Math.min(m.minX,u),m.minY=Math.min(m.minY,d),m.maxX=Math.max(m.maxX,f),m.maxY=Math.max(m.maxY,h)):t.set(s.sessionId,{minX:u,minY:d,maxX:f,maxY:h})}const n=[];for(const[r,s]of t){const o=s.maxX-s.minX+mu*2,l=s.maxY-s.minY+mu*2;n.push({id:`group:${r}`,type:Q$,position:{x:s.minX-mu,y:s.minY-mu},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 rZ(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 sZ(e,t){const n=new Set;for(const r of t){const s=rZ(e,r);if(s)for(const o of s)n.add(o)}return n.size>0?n:null}function aZ({stateRef:e,now:t,removedAgentIds:n,sizeVersion:r,domSizeVersion:s}){return x.useMemo(()=>VX(e.current.agents.values(),t,n,r,s),[e.current,e.current.revision,t,r,s,n])}function oZ({stateRef:e,now:t,availableWidth:n,availableHeight:r,layout:s,measuredRef:o,onBubble:l,settled:u,dragging:d,layoutSig:f,selectedIds:h,openContext:m,historyReplayed:g,removedNodes:w,removedAgentIds:k,dragTick:v,dragPatchRef:b,dragMoveTick:S}){const{pinnedRef:_,positionsRef:j,provisionalRef:E,lastLayoutSigRef:T,restoredLayout:R,layoutEpoch:M}=s,O=x.useMemo(()=>sZ(e.current,h),[e.current,e.current.revision,h]),I=x.useMemo(()=>{const F=UX(e.current,t);for(const Y of k)F.delete(Y);return F},[e.current,e.current.revision,t,k]),A=x.useRef(new Map),L=mq(),{nodes:z,edges:V}=x.useMemo(()=>{const F=dX(e.current,t,n,r,_.current,o.current,A.current,l,u,d,j.current,E.current,f,T,h,O,I,m,g,R.restored);return YX(F.nodes,F.edges,w)},[e.current,e.current.revision,t,n,r,u,d,f,h,O,I,m,v,L,w,M,g]),$=x.useMemo(()=>nZ(z),[z]),P=x.useMemo(()=>{const F=[...$,...z],Y=b.current;return!Y||Y.size===0?F:F.map(K=>{const D=Y.get(K.id);return D?{...K,position:D}:K})},[$,z,S]);return{spotlightSet:O,visibleAgentIds:I,nodes:z,edges:V,allNodes:P}}function iZ(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 lZ({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,iZ(s,t,e))return!1;return r}function cZ({layoutSig:e,rf:t,stateRef:n,measuredRef:r,pinnedRef:s,positionsRef:o,paneSizeRef:l,lastInteractRef:u,autoFitDisabledRef:d,lastFitTimeRef:f,fitLeft:h}){const m=x.useRef(null),g=x.useRef("");x.useEffect(()=>{const w=setInterval(()=>{if(d.current||Date.now()-u.current<800)return;const k=n.current,v=Date.now(),b=[];for(const _ of k.agents.values())U0(_,v)&&b.push({id:_.id});if(b.length===0)return;const S=[];for(const{id:_}of b){const j=r.current.get(_),E=s.current.get(_)??o.current.get(_);!j||!E||S.push({x:E.x,y:E.y,width:j.width,height:j.height})}lZ({pane:l.current,viewport:t.getViewport(),boxes:S})&&h(600)},1500);return()=>clearInterval(w)},[t]),x.useEffect(()=>{if(g.current===e)return;const w=g.current;if(g.current=e,!w||d.current)return;Date.now()-f.current>1200&&h(400),m.current&&window.clearTimeout(m.current),m.current=window.setTimeout(()=>{d.current||h(500)},280)},[e,t,h])}function uZ({stateRef:e,pinnedRef:t,positionsRef:n,canvasRef:r,clearSelection:s,primarySelectedId:o}){const[l,u]=x.useState(()=>GX(ll())),[d,f]=x.useState(null),h=x.useMemo(()=>KX(e.current.agents.values(),l),[e.current,e.current.revision,l]),m=x.useCallback(S=>{const _=e.current.agents.get(S);_&&(u(j=>{const E=new Set(j);return E.add(S),r2(ll(),E),E}),f({id:S,label:_.label}),t.current.delete(S),n.current.delete(S),s())},[s]),g=x.useCallback(()=>{o&&m(o)},[o,m]),w=d&&l.has(d.id)?d:null;x.useEffect(()=>{var S;d&&((S=r.current)==null||S.focus())},[d]);const k=x.useCallback(S=>{const _=[...S];u(j=>{const E=XX(j,_);return E!==j&&r2(ll(),E),E})},[]),v=x.useCallback(()=>{k([...l]),f(null)},[k,l]),b=x.useCallback(()=>{u(new Set),f(null),Br(H0)},[]);return{removedNodes:l,lastRemoval:d,removedAgentIds:h,removeNode:m,removeSelectedNode:g,removalNotice:w,bringBack:k,bringBackAll:v,forgetRemovals:b}}function dZ({stateRef:e,waitingSessions:t,removedAgentIds:n,removedNodes:r,bringBack:s}){const o=x.useRef(new Map);x.useEffect(()=>{o.current=QX(o.current,r,Date.now());const l=[...ZX(t,n),...eZ(e.current.agents,n,r,o.current)];l.length>0&&s(l)},[t,n,r,s])}function hZ({waiting:e,running:t,connected:n=!0}){return{title:e>0?`(${e}) ${gt}`:gt,icon:n?e>0?"waiting":t>0?"running":"idle":"offline"}}const gu={offline:"#e05252",waiting:"#c97d12",running:"#2a90d4",idle:"#7e828c"};function yu(e,t){const s=l=>`<circle cx="16" cy="16" r="12" fill="none" stroke="${e}" stroke-width="5"${l}/>`;return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">${t==="waiting"?`<circle cx="16" cy="16" r="14.5" fill="${e}"/>`:t==="offline"?s(` stroke-dasharray="${56.5485.toFixed(2)} ${18.8495.toFixed(2)}" transform="rotate(-58 16 16)"`):s("")+(t==="running"?`<circle cx="16" cy="16" r="5" fill="${e}"/>`:"")}</svg>`}const fZ=Object.freeze({offline:`data:image/svg+xml,${encodeURIComponent(yu(gu.offline,"offline"))}`,waiting:`data:image/svg+xml,${encodeURIComponent(yu(gu.waiting,"waiting"))}`,running:`data:image/svg+xml,${encodeURIComponent(yu(gu.running,"running"))}`,idle:`data:image/svg+xml,${encodeURIComponent(yu(gu.idle,"idle"))}`});function pZ({stateRef:e,waitingSessions:t,live:n}){const r=x.useMemo(()=>S6(e.current.agents.values()),[e.current,e.current.revision]),s=x.useRef(null);x.useEffect(()=>{const o=hZ({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"]');u&&(u.href=fZ[o.icon])}},[t.length,r,n])}const mZ=1200,gZ=1e3;function kv(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<mZ?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<gZ}function yZ({applyViewport:e,lastFitTimeRef:t,cameraEpochRef:n,disableAutoFit:r,markInteract:s,canvasRef:o,applyZoom:l}){const u=x.useState(()=>PX())[0];x.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=x.useRef(null),f=x.useRef(0),h=x.useCallback(()=>{f.current=Date.now()},[]),m=x.useCallback(k=>({hasSourceEvent:!!k,at:Date.now(),lastDeckFitAt:t.current,lastCanvasInputAt:f.current}),[]);return{restoredViewport:u,markCanvasInput:h,onMoveStart:k=>{Es(),kv(m(k))&&(n.current+=1),kv(m(k))&&r()},onMove:(k,v)=>{var b;s(),kv(m(k))&&r(),(b=o.current)==null||b.style.setProperty("--zoom",String(v.zoom)),l(v.zoom)==="detail"&&Es(),d.current&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>DX(v),250)}}}function wZ({clearSelection:e,selectAgent:t,detailOpen:n,setDetailOpen:r,detailShown:s,focusAgent:o,draggingRef:l,lodRef:u}){return{onNodeClick:(w,k)=>{if(k.type==="sessionGroup"){e();return}const v=k.type==="recapNote"?k.data.parentId:k.id;t(v,w.shiftKey,!1),!w.shiftKey&&(n&&r(!1),s?window.setTimeout(()=>{try{o(v)}catch{}},80):o(v))},onPaneClick:()=>{Es(),e()},onNodeDoubleClick:(w,k)=>{if(k.type!=="agent"&&k.type!=="recapNote")return;const v=k.type==="recapNote"?k.data.parentId:k.id;t(v,!1),window.setTimeout(()=>{try{o(v)}catch{}},80)},onNodeMouseEnter:(w,k)=>{k.type!=="agent"&&k.type!=="recapNote"||l.current||u.current==null||u.current==="detail"||V$(k.id,w.currentTarget)},onNodeMouseLeave:(w,k)=>Es(k.id)}}function vZ(){const e=x.useRef(null),t=x.useRef(null),[n,r]=x.useState({w:0,h:0});return x.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(f=>Math.abs(f.w-u.width)>40||Math.abs(f.h-u.height)>40?{w:u.width,h:u.height}:f))});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 xZ(e){const t=x.useRef(new Map),n=x.useRef(0),r=x.useCallback(u=>{const d=t.current;let f=!1;for(const h of u.nodeInternals.values()){const m=h.width,g=h.height;if(m==null||g==null)continue;const w=d.get(h.id);w?(Math.abs(w.height-g)>4||Math.abs(w.width-m)>4)&&(d.set(h.id,{width:m,height:g}),f=!0):(d.set(h.id,{width:m,height:g}),f=!0)}return f&&(n.current+=1),n.current},[]),s=We(r),[o,l]=x.useState(0);return x.useEffect(()=>{let u=0;const d=()=>{const h=t.current;let m=!1;for(const g of document.querySelectorAll(".react-flow__node[data-id]")){const w=g.getAttribute("data-id");if(!w)continue;const k=g.offsetWidth,v=g.offsetHeight;if(!k||!v)continue;const b=h.get(w);(!b||Math.abs(b.width-k)>4||Math.abs(b.height-v)>4)&&(h.set(w,{width:k,height:v}),m=!0)}m&&l(g=>g+1)};if(e.current)return;let f=0;return document.visibilityState==="hidden"?f=window.setTimeout(d,32):u=requestAnimationFrame(d),()=>{cancelAnimationFrame(u),window.clearTimeout(f)}}),{measuredRef:t,measuredVersionRef:n,sizeVersion:s,domSizeVersion:o}}function bZ(){const[e,t]=x.useState(!1);return x.useEffect(()=>{const n=window.setTimeout(()=>t(!0),2500);return()=>window.clearTimeout(n)},[]),e}function kZ(){const e=x.useRef(null);return x.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 NZ({pointerFocusRef:e,nodesRef:t,stateRef:n,primarySelectedIdRef:r,providersRef:s,soundOnRef:o,keyHelpOpenRef:l,modalOpenRef:u,waitingCursorRef:d,removeSelectedRef:f,activateSoundRef:h,clearSelection:m,selectAgent:g,focusAgent:w,stepAgent:k,focusSession:v,requestClear:b,handleRelayout:S,handleFit:_,togglePause:j,toggleSessionList:E,toggleAccountsPanel:T,setDetailOpen:R,setUsageHistoryOpen:M,setUsagePanelOpen:O,setMachinePanelOpen:I,setBrowserWatchOpen:A,setSoundMenuOpen:L,setKeyHelpOpen:z,setTheme:V}){x.useEffect(()=>{const $=P=>{var B,X;const F=P.target,Y={tagName:F==null?void 0:F.tagName,isContentEditable:F==null?void 0:F.isContentEditable,role:(B=F==null?void 0:F.getAttribute)==null?void 0:B.call(F,"role"),type:F==null?void 0:F.type,pointerFocused:F!=null&&F===e.current};if(P.key==="Escape"){const G=q6({overlayOpen:il.depth()>0,typing:yd(Y)});G==="dismiss"?il.dismissTop():G==="blur"?F==null||F.blur():(yX(Y)&&(F==null||F.blur()),m());return}if(gd(P))return;const K=F0(F)?(X=F==null?void 0:F.getAttribute)==null?void 0:X.call(F,"data-id"):null,D=K&&t.current.some(G=>G.id===K)?K:null,W=mX(P,D);if(W.kind==="activate"){P.preventDefault(),g(W.nodeId,W.additive);return}if(W.kind!=="node"&&!(W.nodeId==null&&Y6(Y,P.key))&&!X6({key:P.key,modalOpen:Z6({appModal:u.current,dialogDepth:il.dialogDepth()}),sheetOpen:l.current})){if(P.key===" "&&(P.preventDefault(),j()),(P.key==="c"||P.key==="C")&&b("shortcut"),(P.key==="r"||P.key==="R")&&S(),(P.key==="f"||P.key==="F")&&_(),(P.key==="z"||P.key==="Z")&&r.current&&w(r.current),P.key==="Delete"&&f.current(),(P.key==="l"||P.key==="L")&&E(),P.key==="d"||P.key==="D")if(r.current)R(G=>!G);else{const G=Uv(n.current.agents.values());G.length>0?v(G[0].id):k(1)}if((P.key==="h"||P.key==="H")&&M(G=>!G),(P.key==="u"||P.key==="U")&&O(G=>!G),(P.key==="a"||P.key==="A")&&s.current.claude&&T(),(P.key==="j"||P.key==="J")&&k(1),(P.key==="k"||P.key==="K")&&k(-1),P.key==="w"||P.key==="W"){const G=N6(Uv(n.current.agents.values()),d.current);G&&(d.current=G.id,v(G.id))}(P.key==="t"||P.key==="T")&&V(G=>G==="dark"?"light":"dark"),(P.key==="m"||P.key==="M")&&s.current.claude&&o.current!==null&&h.current(P.shiftKey),(P.key==="s"||P.key==="S")&&I(G=>!G),(P.key==="b"||P.key==="B")&&A(G=>!G),(P.key==="v"||P.key==="V")&&s.current.claude&&o.current!==null&&L(G=>!G),P.key==="?"&&z(G=>!G)}};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[b,S,_,m,g,k,v,w,j])}function SZ({nodes:e,stateRef:t,pinnedRef:n,positionsRef:r,draggingRef:s,dragPatchRef:o,setDragging:l,setDragMoveTick:u,setDragTick:d,endBubble:f,markInteract:h,disableAutoFit:m,beginTrashDrag:g,trackTrashDrag:w,endTrashDrag:k,removeNode:v}){const b=x.useRef(null);return{onNodeDragStart:(E,T)=>{var R,M;if(Es(),f(),s.current=!0,o.current=new Map,l(!0),g(T.type==="agent"?((R=t.current.agents.get(T.id))==null?void 0:R.label)??"":null),h(),m(),T.type==="sessionGroup"){const O=(M=T.data)==null?void 0:M.sessionId,I=new Map;if(O)for(const A of e){const L=A.data;(L==null?void 0:L.sessionId)===O&&I.set(A.id,{x:A.position.x,y:A.position.y})}b.current={start:{x:T.position.x,y:T.position.y},members:I};return}n.current.set(T.id,{x:T.position.x,y:T.position.y})},onNodeDrag:(E,T)=>{var R;if(h(),T.type==="agent"&&w(E),T.type==="sessionGroup"){const M=b.current;if(!M)return;const O=T.position.x-M.start.x,I=T.position.y-M.start.y;for(const[L,z]of M.members){const V={x:z.x+O,y:z.y+I};n.current.set(L,V),r.current.set(L,V)}const A=o.current;if(A){for(const[L,z]of M.members)A.set(L,{x:z.x+O,y:z.y+I});A.set(T.id,{x:T.position.x,y:T.position.y})}u(L=>L+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}),(R=o.current)==null||R.set(T.id,{x:T.position.x,y:T.position.y}),u(M=>M+1)},onNodeDragStop:(E,T)=>{h();const R=k(E,T.type==="agent");if(s.current=!1,o.current=null,l(!1),d(M=>M+1),T.type==="sessionGroup"){const M=b.current;if(M){const O=T.position.x-M.start.x,I=T.position.y-M.start.y;for(const[A,L]of M.members){const z={x:L.x+O,y:L.y+I};n.current.set(A,z),r.current.set(A,z)}}b.current=null,Ml(r.current,n.current),d(O=>O+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}),R){v(T.id);return}Ml(r.current,n.current)}}}function jZ(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const _Z={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent",zcode:"ZCode"};function EZ(e){const t=e.toLowerCase(),n=sn(_Z,t);return n!==void 0?n:t?t[0].toUpperCase()+t.slice(1):""}function CZ(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function ste(e,t=[]){const n=t.length?CZ(t.map(EZ)):jZ(e);return n?`via ccusage · local ${n} logs`:"via ccusage · local agent logs"}function TZ(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 RZ(e,t){const n=t.prefs??gx,r=Ho(n.done.level),s=Ho(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?`
83
-
84
- 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?`
85
-
86
- 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+`
87
-
88
- Click to set the volume and the sound of each tone, and to hear either one.`}function AZ(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 MZ(){return i.jsxs("div",{className:"empty-hero",children:[i.jsxs("div",{className:"orbit-stack","aria-hidden":!0,children:[i.jsx("div",{className:"core"}),i.jsxs("div",{className:"orbit r1",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{className:"dot b"})]}),i.jsxs("div",{className:"orbit r2",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{className:"dot b"})]}),i.jsxs("div",{className:"orbit r3",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{className:"dot b"})]})]}),i.jsxs("h2",{children:["Too many ",gt," tabs are open"]}),i.jsxs("p",{children:["This browser keeps at most six live connections to one address, and other ",i.jsx("code",{children:gt})," tabs are holding them. Close one and this tab connects on its own."]})]})}function $Z({live:e,everConnected:t,providers:n,workspace:r,onTour:s}){const o=!e;return i.jsxs("div",{className:"empty-hero",children:[i.jsxs("div",{className:"orbit-stack","aria-hidden":!0,children:[i.jsx("div",{className:"core"}),i.jsxs("div",{className:"orbit r1",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{className:"dot b"})]}),i.jsxs("div",{className:"orbit r2",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{className:"dot b"})]}),i.jsxs("div",{className:"orbit r3",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{className:"dot b"})]})]}),o?i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:t?"Disconnected from server":"Server unreachable"}),i.jsxs("p",{children:[t?"This page lost its connection to ":"This page cannot reach ",i.jsx("code",{children:gt}),". Check that it is still running in your terminal — the page picks up again on its own."]})]}):IZ(n,r),!o&&i.jsx("button",{type:"button",className:"btn empty-tour",onClick:s,children:"Take the tour"})]})}function IZ(e,t){const n=AZ(t);return i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:"Waiting for Claude Code or Codex"}),n.kind==="scoped"?i.jsxs("p",{children:[n.lead," ",i.jsx("code",{children:n.workspace}),n.tail]}):i.jsxs("p",{children:["Run ",i.jsx("code",{children:"claude"})," or ",i.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."]}),TZ(e).map(r=>i.jsx("p",{className:"hint-row",children:r.spans.map((s,o)=>s.code?i.jsx("code",{children:s.text},o):i.jsx("span",{children:s.text},o))},r.provider))]})}const OZ=1;function LZ(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 PZ(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:OZ,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(LZ)}))}}function DZ(e,t){const n=(e||"session").replace(/[^a-z0-9._-]/gi,"_");return`${gt}-${n}-${t.slice(0,8)}.json`}const eI={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},FZ={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 qZ({cat:e}){return i.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:i.jsx("path",{d:FZ[e]})})}const ad={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},tI=RA;function BZ({agent:e,now:t,onOpenTool:n,onShowSummary:r,onExportSession:s,onRemove:o}){const l=`${e.synthetic?"≥ ":""}${zo(e.startedAt,e.endedAt,t)}`,u=an(e),d=u.total>0,f=e.usage.inputTokens+e.usage.outputTokens,h=new Map;for(const v of e.tools){const b=tI(v.name);h.set(b,(h.get(b)??0)+1)}const m=e.tools.filter(v=>v.ok===!1).length,g=e.tools.filter(v=>!v.endedAt).length,w=Array.from(h.entries()).sort((v,b)=>b[1]-v[1]),k=h.has("mcp")?Vq(e.tools.map(v=>v.name)):null;return i.jsxs(i.Fragment,{children:[i.jsxs("header",{className:"detail-hero",children:[i.jsxs("div",{className:"hero-line",children:[i.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),i.jsx("h2",{className:"hero-title",title:e.cwd??e.label,children:e.label})]}),i.jsxs("div",{className:"hero-meta",children:[i.jsx("span",{className:"hero-meta-item",children:e.kind==="root"?"session":"subagent"}),i.jsx("span",{className:"hero-sep",children:"·"}),i.jsx("span",{className:"hero-meta-item",title:`started ${new Date(e.startedAt).toLocaleString()}`,children:l}),e.model&&(()=>{const v=yA(e);return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"hero-sep",children:"·"}),i.jsxs("span",{className:"model-chip","data-family":pd(e.model),title:v.length>0?`${e.model}
89
- spend on this panel also covers:
90
- ${v.join(`
91
- `)}`:e.model,children:[js(e.model),v.length>0?` +${v.length}`:""]})]})})()]}),d&&i.jsxs("div",{className:"hero-cost",children:[i.jsxs("div",{className:"hero-cost-headline",children:[i.jsx("span",{className:"hero-cost-value",children:Be(u.total)}),i.jsx("span",{className:"hero-cost-label",children:"spend"})]}),i.jsx(a0,{cost:u})]}),i.jsxs("div",{className:"hero-actions",children:[e.kind==="root"&&e.state==="done"&&r&&i.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&&i.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>s(e.sessionId),title:"Download this session as JSON",children:"Export JSON"}),o&&i.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 v=wd(e);if(!v)return null;const b=Gu(v.at,t);return i.jsxs("section",{className:"detail-section",children:[i.jsxs("h3",{children:["Recap ",i.jsx("span",{className:"section-count",title:b.title,children:b.label})]}),i.jsx("p",{className:"detail-recap",children:v.text})]})})(),e.tools.length>0&&i.jsxs("section",{className:"detail-section",children:[i.jsx("h3",{children:"Activity"}),i.jsxs("div",{className:"activity-row",children:[i.jsxs("div",{className:"activity-counters",children:[i.jsxs("span",{className:"ac-item",children:[i.jsx("b",{children:e.toolCount})," calls"]}),g>0&&i.jsxs("span",{className:"ac-item ac-live",children:[i.jsx("b",{children:g})," live"]}),m>0&&i.jsxs("span",{className:"ac-item ac-err",children:[i.jsx("b",{children:m})," err"]})]}),i.jsx("div",{className:"cat-strip",children:w.map(([v,b])=>{const S=v==="mcp"?k:null,_=S==null?void 0:S.hue,j=`${b} ${ad[v]} call${b===1?"":"s"}`;return i.jsxs("span",{className:`cat-chip cat-${v}${_!=null?" mcp-hue":""}`,style:_!=null?{"--mcp-hue":_}:void 0,title:S?`${j}, all to ${S.label}`:j,children:[i.jsx("span",{className:"cat-emoji","aria-hidden":!0,children:eI[v]}),i.jsx("span",{className:"cat-name",children:ad[v]}),i.jsx("span",{className:"cat-count",children:b}),S&&i.jsx("span",{className:"cat-server",children:S.label})]},v)})})]})]}),f>0&&i.jsxs("section",{className:"detail-section",children:[i.jsx("h3",{children:"Tokens"}),i.jsxs("div",{className:"tokens-grid",children:[i.jsxs("div",{children:[i.jsx("span",{className:"k",children:"in"}),i.jsx("b",{title:e.usage.inputTokens.toLocaleString(),children:et(e.usage.inputTokens)})]}),i.jsxs("div",{children:[i.jsx("span",{className:"k",children:"out"}),i.jsx("b",{title:e.usage.outputTokens.toLocaleString(),children:et(e.usage.outputTokens)})]}),i.jsxs("div",{children:[i.jsx("span",{className:"k",children:"cache r"}),i.jsx("b",{title:e.usage.cacheReadTokens.toLocaleString(),children:et(e.usage.cacheReadTokens)})]}),i.jsxs("div",{children:[i.jsx("span",{className:"k",children:"cache c"}),i.jsx("b",{title:e.usage.cacheCreateTokens.toLocaleString(),children:et(e.usage.cacheCreateTokens)})]})]})]}),i.jsxs("section",{className:"detail-section",children:[i.jsx("h3",{children:"Identity"}),i.jsxs("div",{children:[e.cwd&&i.jsxs("div",{className:"row",children:[i.jsx("span",{className:"k",children:"cwd"}),i.jsx("span",{className:"v",title:e.cwd,children:e.cwd})]}),i.jsxs("div",{className:"row",children:[i.jsx("span",{className:"k",children:"session"}),i.jsxs("span",{className:"v",children:[e.sessionId.slice(0,12),"…"]})]}),e.parentId&&i.jsxs("div",{className:"row",children:[i.jsx("span",{className:"k",children:"parent"}),i.jsxs("span",{className:"v",children:[e.parentId.slice(0,12),"…"]})]})]})]}),e.prompts.length>0&&i.jsxs("section",{className:"detail-section",children:[i.jsxs("h3",{children:["Prompts ",i.jsx("span",{className:"section-count",children:lA(e.prompts).length})]}),i.jsx("div",{className:"prompts",children:e.prompts.slice().reverse().map((v,b)=>{const S=Gu(v.at,t),_=Yx(v.text);return _?i.jsxs("details",{className:"prompt-entry prompt-injected",children:[i.jsxs("summary",{children:[i.jsx("span",{className:"prompt-time",title:S.title,children:S.label}),i.jsx("span",{className:"prompt-injected-label",children:_.label})]}),_.detail&&i.jsx("div",{className:"prompt-injected-detail",children:_.detail})]},b):i.jsxs("div",{className:"prompt-entry",children:[i.jsx("div",{className:"prompt-time",title:S.title,children:S.label}),i.jsx("div",{className:"prompt-text",children:v.text})]},b)})})]}),i.jsxs("section",{className:"detail-section",children:[i.jsxs("h3",{children:["Tool calls ",i.jsx("span",{className:"section-count",children:e.tools.length})]}),e.tools.length===0&&i.jsx("div",{className:"empty",children:"No tool calls yet."}),i.jsx("div",{children:e.tools.slice().reverse().map(v=>i.jsx(UZ,{t:v,onClick:()=>n(e.id,v.id)},v.id))})]})]})}const zZ={inflight:"in-flight",done:"done",err:"error"};function UZ({t:e,onClick:t}){const n=e.endedAt==null?"inflight":e.ok===!1?"err":"done",r=vA(e,"…");return i.jsxs("button",{className:"tool clickable",title:e.inputPreview||e.name,onClick:t,children:[i.jsxs("span",{className:"name",children:[i.jsx("span",{className:`status-dot ${n}`,"aria-hidden":!0}),i.jsx("span",{className:"vis-hidden",children:zZ[n]}),e.name]}),i.jsx("span",{style:{color:"var(--muted)"},children:r})]})}function HZ(e,t){const n=PZ(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=DZ(n.label,t),document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(o),1e3)}function WZ({selected:e,now:t,openTool:n,setSummaryFor:r,setDetailOpen:s,stateRef:o,removeSelectedNode:l}){return i.jsxs("aside",{className:"detail","aria-label":"Detail",children:[i.jsx("button",{type:"button",className:"glyph-btn detail-close",title:"Close panel","aria-label":"Close detail panel",onClick:()=>s(!1),children:"×"}),i.jsx(BZ,{agent:e,now:t,onOpenTool:n,onShowSummary:r,onExportSession:u=>HZ(o.current,u),onRemove:l})]})}function nI({id:e,value:t,onLevel:n,"aria-describedby":r}){return i.jsxs("div",{className:"sm-row",children:[i.jsx("label",{htmlFor:e,children:"Volume"}),i.jsx("input",{id:e,type:"range",min:Tu,max:Ju,step:mx,value:t,"aria-describedby":r,onChange:s=>n(Number(s.target.value)),style:{"--sm-level":`${(t-Tu)/(Ju-Tu)*100}%`}}),i.jsxs("span",{className:"sm-read",children:[t,"%"]})]})}const rI="agent-dag.character-enabled",sI="agent-dag.fm-volume",s2="agent-dag.fm-source",VZ=[{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 GZ(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 KZ(e){return e!=="0"}function YZ(){return KZ(tt(rI))}function XZ(e){return PM(e)}function ZZ(){return XZ(tt(sI))}const No=["light","dark"],JZ={light:"Light",dark:"Dark"},a2=VZ,So="Give the station a name.",QZ="Use an https YouTube live or channel link, or a .mp3, .aac, .ogg or .m3u8 stream.";function eJ({theme:e}){return i.jsx("span",{className:"appearance-preview","data-swatch":e,children:i.jsxs("svg",{viewBox:"0 0 112 56","aria-hidden":!0,focusable:"false",children:[i.jsx("rect",{className:"tp-canvas",width:"112",height:"56"}),i.jsx("rect",{className:"tp-surface",width:"112",height:"7"}),i.jsx("rect",{className:"tp-rule",y:"7",width:"112",height:"1"}),i.jsx("rect",{className:"tp-surface",y:"8",width:"25",height:"48"}),i.jsx("rect",{className:"tp-rule",x:"25",y:"8",width:"1",height:"48"}),i.jsx("rect",{className:"tp-card",x:"36.5",y:"27.5",width:"28",height:"14",rx:"2.5"}),i.jsx("rect",{className:"tp-tag",x:"39.5",y:"25.5",width:"13",height:"4",rx:"2"}),i.jsx("rect",{className:"tp-card",x:"76.5",y:"14.5",width:"29",height:"20",rx:"2.5"}),i.jsx("rect",{className:"tp-rule",x:"81",y:"23",width:"20",height:"2",rx:"1"}),i.jsx("rect",{className:"tp-accent",x:"81",y:"23",width:"12",height:"2",rx:"1"})]})})}function tJ({theme:e,onTheme:t,characterEnabled:n,onToggleCharacter:r,fmVolume:s,onFmVolume:o,fmMuted:l,onFmMuted:u,fmSource:d,onFmSource:f,customFmStations:h,unavailableFmStations:m,onAddFmStation:g,onRenameFmStation:w,onRemoveFmStation:k,onClose:v}){var ue;const b=Et(v),S=[...a2.map(se=>({...se,label:m.has(se.value)?`${se.label} · not live`:se.label,unavailable:m.has(se.value)})),...h.map(se=>({group:"🎵 Your stations",value:ba(se.id),label:m.has(se.id)?`${se.name} · unavailable`:se.name,unavailable:m.has(se.id)}))],_=S.some(se=>se.value===d&&se.unavailable),j=[];S.forEach((se,xe)=>{const Ae=j[j.length-1];Ae&&Ae.group===se.group?Ae.indexes.push(xe):j.push({group:se.group,indexes:[xe]})});const[E,T]=x.useState(!1),[R,M]=x.useState(()=>Math.max(0,S.findIndex(se=>se.value===d))),[O,I]=x.useState(!1),[A,L]=x.useState(""),[z,V]=x.useState(""),[$,P]=x.useState(""),[F,Y]=x.useState(!1),[K,D]=x.useState(""),[W,B]=x.useState(""),X=x.useRef(null),G=x.useRef(null),U=x.useRef(null),Z=x.useRef(null),H=x.useRef(null),J=Fo(d),ee=J?h.find(se=>se.id===J):void 0;x.useEffect(()=>{const se=S.findIndex(xe=>xe.value===d);M(se<0?0:se)},[d,h,m]),x.useEffect(()=>{Y(!1),D((ee==null?void 0:ee.name)??"")},[ee==null?void 0:ee.id,ee==null?void 0:ee.name]),x.useEffect(()=>{var se;E&&((se=document.getElementById(`appearance-fm-option-${R}`))==null||se.scrollIntoView({block:"nearest"}))},[R,E]),x.useEffect(()=>{if(!E)return;const se=xe=>{var Le,Ie;const Ae=xe.target;!((Le=X.current)!=null&&Le.contains(Ae))&&!((Ie=H.current)!=null&&Ie.contains(Ae))&&T(!1)};return document.addEventListener("pointerdown",se),()=>document.removeEventListener("pointerdown",se)},[E]);const re=se=>{const xe=se.relatedTarget;xe&&!se.currentTarget.contains(xe)&&T(!1)},oe=se=>{var Ae;const xe=S[se];xe&&(M(se),f(xe.value),T(!1),(Ae=X.current)==null||Ae.focus())},fe=se=>{if(F6(se.key)){if(!E)return;se.preventDefault(),se.stopPropagation(),T(!1);return}if(se.key==="Tab"){T(!1);return}if(se.key==="Enter"||se.key===" "){se.preventDefault(),E?oe(R):T(!0);return}se.key!=="ArrowDown"&&se.key!=="ArrowUp"&&se.key!=="Home"&&se.key!=="End"||(se.preventDefault(),T(!0),M(xe=>se.key==="Home"?0:se.key==="End"?S.length-1:Math.min(S.length-1,Math.max(0,xe+(se.key==="ArrowDown"?1:-1)))))},Ne=()=>{var se;return(se=X.current)==null?void 0:se.focus()},ke=se=>{var Ae,Le;if(se.preventDefault(),!A.trim()){P(So),(Ae=G.current)==null||Ae.focus();return}const xe=hF(A,z);if(!xe){P(QZ),(Le=U.current)==null||Le.focus();return}g(xe),f(ba(xe.id)),L(""),V(""),P(""),I(!1),Ne()},we=se=>{var xe;if(se.preventDefault(),!!J){if(!K.trim()){B(So),(xe=Z.current)==null||xe.focus();return}w(J,K),Y(!1),Ne()}},ve=se=>{var Le;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(se.key))return;se.preventDefault();const Ae=(No.indexOf(e)+(se.key==="ArrowLeft"||se.key==="ArrowUp"?-1:1)+No.length)%No.length;t(No[Ae]),(Le=se.currentTarget.querySelectorAll('[role="radio"]')[Ae])==null||Le.focus()},$e=se=>{var Ae;if(se.key===" "){se.stopPropagation();return}if(yd(se.target)||se.key!=="t"&&se.key!=="T"||se.ctrlKey||se.metaKey||se.altKey)return;se.preventDefault(),se.stopPropagation();const xe=e==="dark"?"light":"dark";t(xe),se.target.getAttribute("role")==="radio"&&((Ae=se.currentTarget.querySelectorAll('[role="radio"]')[No.indexOf(xe)])==null||Ae.focus())},ye=se=>{const xe=S[se],Ae="unavailable"in xe&&xe.unavailable;return i.jsxs("div",{className:"appearance-source-option",role:"option",id:`appearance-fm-option-${se}`,"aria-selected":d===xe.value,"data-highlighted":R===se||void 0,"data-unavailable":Ae||void 0,onMouseEnter:()=>M(se),onClick:()=>oe(se),children:[i.jsx("span",{children:xe.label}),d===xe.value&&i.jsx("span",{"aria-hidden":!0,children:"✓"})]},xe.value)};return zt.createPortal(i.jsx("div",{className:"modal-backdrop appearance-backdrop",onClick:v,role:"presentation",children:i.jsxs("div",{ref:b,id:"appearance-menu",className:"modal appearance-menu appearance-modal",role:"dialog","aria-modal":"true","aria-labelledby":"appearance-title",onClick:se=>se.stopPropagation(),onKeyDown:$e,children:[i.jsxs("div",{className:"appearance-head",children:[i.jsxs("div",{className:"appearance-heading",children:[i.jsx("h2",{id:"appearance-title",className:"appearance-title",children:"Appearance"}),i.jsx("p",{className:"appearance-subtitle",children:"Tune the deck to your workspace."})]}),i.jsx("button",{type:"button",className:"glyph-btn appearance-close",onClick:v,"aria-label":"Close appearance settings",title:"Close (Esc)",children:"×"})]}),i.jsxs("section",{className:"appearance-section","aria-labelledby":"appearance-theme-caption",children:[i.jsxs("div",{className:"appearance-caption",children:[i.jsxs("div",{children:[i.jsx("h3",{id:"appearance-theme-caption",children:"Color theme"}),i.jsx("p",{className:"appearance-section-note",children:"Choose how the dashboard looks."})]}),i.jsx("kbd",{className:"appearance-key","aria-hidden":!0,title:"Press T anywhere to switch themes",children:"T"})]}),i.jsx("div",{className:"appearance-themes",role:"radiogroup","aria-labelledby":"appearance-theme-caption","aria-keyshortcuts":"T",onKeyDown:ve,children:No.map(se=>i.jsxs("button",{type:"button",className:"appearance-theme",role:"radio","aria-checked":e===se,tabIndex:e===se?0:-1,onClick:()=>t(se),children:[i.jsx(eJ,{theme:se}),i.jsxs("span",{className:"appearance-theme-name",children:[JZ[se],i.jsx("svg",{className:"appearance-check",viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:i.jsx("path",{d:"M2.5 6.4 4.9 8.7 9.5 3.6"})})]})]},se))})]}),i.jsxs("section",{className:"appearance-section","aria-labelledby":"appearance-fm-caption",children:[i.jsx("div",{className:"appearance-caption",children:i.jsx("h3",{id:"appearance-fm-caption",children:"Music source"})}),i.jsxs("div",{className:"appearance-controls",children:[i.jsxs("div",{className:"appearance-source-row",children:[i.jsx("label",{htmlFor:"appearance-fm-source",children:"Station"}),i.jsxs("div",{className:`appearance-source-picker${E?" is-open":""}`,onBlur:re,children:[i.jsxs("button",{ref:X,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-${R}`:void 0,"aria-describedby":"appearance-fm-source-note",onClick:()=>T(se=>!se),onKeyDown:fe,children:[i.jsx("span",{children:((ue=S.find(se=>se.value===d))==null?void 0:ue.label)??a2[0].label}),i.jsx("svg",{viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:i.jsx("path",{d:"m2.5 4.5 3.5 3 3.5-3"})})]}),E&&i.jsx("div",{ref:H,id:"appearance-fm-source-list",className:"appearance-source-list",role:"listbox","aria-label":"Music stations",children:j.map((se,xe)=>se.group?i.jsxs("div",{role:"group","aria-labelledby":`appearance-fm-group-${xe}`,children:[i.jsx("div",{id:`appearance-fm-group-${xe}`,className:"appearance-source-group",role:"presentation",children:se.group}),se.indexes.map(ye)]},`group-${xe}`):se.indexes.map(ye))})]})]}),i.jsx("span",{id:"appearance-fm-source-note",className:"vis-hidden",children:"Changing station starts live playback automatically."}),i.jsx("p",{className:"appearance-fm-status",role:"status",children:_?oF(Fo(d)!==null):""}),i.jsxs("div",{className:"appearance-station-manage",children:[i.jsx("button",{type:"button",className:"btn appearance-station-action","aria-expanded":O,onClick:()=>{I(se=>!se),P("")},children:O?"Cancel":"+ Add station"}),ee&&!F&&i.jsxs("span",{className:"appearance-station-edit",children:[i.jsx("button",{type:"button",className:"btn appearance-station-action",onClick:()=>{D(ee.name),B(""),Y(!0)},children:"Rename"}),i.jsx("button",{type:"button",className:"btn danger appearance-station-action",onClick:()=>{k(ee.id),Ne()},children:"Remove"})]})]}),O&&i.jsxs("form",{className:"appearance-station-form",onSubmit:ke,noValidate:!0,children:[i.jsxs("label",{className:"appearance-station-field",children:[i.jsx("span",{children:"Station name"}),i.jsx("input",{ref:G,className:"ap-manage-input",value:A,onChange:se=>L(se.target.value),"aria-invalid":$===So||void 0,"aria-describedby":$===So?"appearance-station-error":void 0,maxLength:vl,autoFocus:!0})]}),i.jsxs("label",{className:"appearance-station-field",children:[i.jsx("span",{children:"Link"}),i.jsx("input",{ref:U,className:"ap-manage-input",value:z,onChange:se=>V(se.target.value),placeholder:"https://…","aria-invalid":$!==""&&$!==So||void 0,"aria-describedby":$&&$!==So?"appearance-station-error":void 0,inputMode:"url",autoComplete:"off",spellCheck:!1,maxLength:YR})]}),i.jsx("button",{type:"submit",className:"btn primary",children:"Add"}),$&&i.jsx("p",{id:"appearance-station-error",className:"appearance-station-error",role:"alert",children:$})]}),ee&&F&&i.jsxs("form",{className:"appearance-station-form is-rename",onSubmit:we,noValidate:!0,children:[i.jsxs("label",{className:"appearance-station-field",children:[i.jsx("span",{children:"Station name"}),i.jsx("input",{ref:Z,className:"ap-manage-input",value:K,onChange:se=>D(se.target.value),"aria-invalid":W!==""||void 0,"aria-describedby":W?"appearance-rename-error":void 0,maxLength:vl,autoFocus:!0})]}),i.jsx("button",{type:"submit",className:"btn primary",children:"Save"}),i.jsx("button",{type:"button",className:"btn",onClick:()=>{Y(!1),Ne()},children:"Cancel"}),W&&i.jsx("p",{id:"appearance-rename-error",className:"appearance-station-error",role:"alert",children:W})]}),i.jsxs("label",{className:"appearance-row",children:[i.jsx("span",{className:"appearance-row-label",id:"appearance-character-label",children:"Show character on minimap"}),i.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":n,"aria-labelledby":"appearance-character-label","aria-describedby":"appearance-character-note",onClick:r,children:i.jsx("span",{className:"switch-knob"})}),i.jsx("span",{id:"appearance-character-note",className:"vis-hidden",children:"Shows the animated minimap character and enables music playback."})]}),i.jsx(nI,{id:"appearance-fm-volume",value:s,"aria-describedby":"appearance-fm-volume-note",onLevel:o}),i.jsxs("label",{className:"appearance-row",children:[i.jsx("span",{className:"appearance-row-label",id:"appearance-fm-mute-label",children:"Mute music"}),i.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":l,"aria-labelledby":"appearance-fm-mute-label",onClick:u,children:i.jsx("span",{className:"switch-knob"})})]})]}),i.jsx("span",{id:"appearance-fm-volume-note",className:"vis-hidden",children:"Controls live music volume."})]})]})}),document.body)}const nJ="With no deck tab open, get a notification wherever a sound would have played.",rJ="With the ccdeck window closed, get a notification wherever a sound would have played.";function sJ(e){return e?rJ:nJ}const aJ="Held off for this run — the deck was started with alerts disabled. Your choice is saved for the next start.",o2="Get notified when you're away from this tab.";function oJ(e){switch(e){case"granted":return{status:"Enabled",ask:!1,ok:!0,note:o2};case"default":return{status:null,ask:!0,ok:!1,note:o2};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 $l(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}const iJ=["audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4"];function lJ(e){return iJ.find(t=>e(t))}const cJ=4400;function uJ(e){const t=e.split(";")[0];return{name:`Recorded voice.${t==="audio/mp4"?"m4a":t==="audio/ogg"?"ogg":"webm"}`,type:t}}function dJ({full:e,setCustomError:t,runCustom:n,onImportCustom:r}){const[s,o]=x.useState(!1),l=x.useRef(null),u=x.useRef(null),d=()=>{var h;u.current!==null&&clearTimeout(u.current),u.current=null,((h=l.current)==null?void 0:h.state)==="recording"&&l.current.stop()},f=async()=>{var m;if(e)return;if(t(""),!((m=navigator.mediaDevices)!=null&&m.getUserMedia)||typeof MediaRecorder>"u"){t("Microphone recording is unavailable in this browser.");return}let h;try{h=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{t("Microphone access was denied or unavailable.");return}if(l.current){h.getTracks().forEach(g=>g.stop());return}try{const g=lJ(v=>MediaRecorder.isTypeSupported(v)),w=new MediaRecorder(h,g?{mimeType:g}:void 0),k=[];l.current=w,w.ondataavailable=v=>{v.data.size&&k.push(v.data)},w.onerror=()=>t("Recording failed. Please try again."),w.onstop=()=>{h.getTracks().forEach(_=>_.stop()),u.current!==null&&clearTimeout(u.current),u.current=null;const v=l.current===w;if(v&&(l.current=null),o(!1),!v||!k.length)return;const b=uJ(w.mimeType),S=new File(k,b.name,{type:b.type});n(()=>r(S))},w.start(200),o(!0),u.current=setTimeout(d,cJ)}catch{l.current=null,h.getTracks().forEach(g=>g.stop()),t("This browser cannot record a supported audio format.")}};return x.useEffect(()=>()=>{u.current!==null&&clearTimeout(u.current);const h=l.current;l.current=null,(h==null?void 0:h.state)==="recording"&&h.stop()},[]),{recording:s,startRecording:f,stopRecording:d}}function hJ({full:e,fullProps:t,runCustom:n,onCreateVoice:r}){const[s,o]=x.useState("Custom voice"),[l,u]=x.useState("Your turn"),[d,f]=x.useState(""),[h,m]=x.useState("1"),[g,w]=x.useState("1"),[k,v]=x.useState([]);return x.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const b=()=>{v(window.speechSynthesis.getVoices())};return b(),window.speechSynthesis.addEventListener("voiceschanged",b),()=>window.speechSynthesis.removeEventListener("voiceschanged",b)},[]),i.jsxs("details",{className:"sm-voice",children:[i.jsxs("summary",{...t,onClick:b=>{const S=b.currentTarget.parentElement;e&&S&&!S.open&&b.preventDefault()},children:[i.jsx("span",{children:"Spoken voice"}),i.jsx("span",{children:"Create from text"})]}),i.jsxs("div",{className:"sm-voice-fields",children:[i.jsxs("label",{children:[i.jsx("span",{children:"Name"}),i.jsx("input",{className:"ap-manage-input",value:s,maxLength:80,onChange:b=>o(b.target.value)})]}),i.jsxs("label",{children:[i.jsx("span",{children:"Text"}),i.jsx("input",{className:"ap-manage-input",value:l,maxLength:180,onChange:b=>u(b.target.value)})]}),i.jsxs("label",{children:[i.jsx("span",{children:"Voice"}),i.jsxs("select",{className:"sm-select",value:d,onChange:b=>f(b.target.value),children:[i.jsx("option",{value:"",children:"System default"}),k.map(b=>i.jsx("option",{value:b.voiceURI,children:b.name},b.voiceURI))]})]}),i.jsxs("div",{className:"sm-voice-pair",children:[i.jsxs("label",{children:[i.jsx("span",{children:"Rate"}),i.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:h,onChange:b=>m(b.target.value)})]}),i.jsxs("label",{children:[i.jsx("span",{children:"Pitch"}),i.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:g,onChange:b=>w(b.target.value)})]})]}),i.jsx("button",{type:"button",className:"btn sm-custom-action",...t,onClick:()=>{e||n(async()=>{await r({name:s,text:l,voiceURI:d,rate:parseFloat(h),pitch:parseFloat(g)}),u("Your turn")})},children:"Add spoken voice"})]})]})}function fJ({customAssets:e,onImportCustom:t,onCreateVoice:n,onRenameCustom:r,onPreviewCustom:s,onDeleteCustom:o}){const[l,u]=x.useState(""),d=e.length,f=fx(d),h=f!==null,m=h?{"aria-disabled":!0,"aria-describedby":"sm-custom-full"}:{},[g,w]=x.useState(null),k=x.useRef(0),v=x.useRef(new Map),b=x.useRef(null);x.useEffect(()=>{if(!g)return;const R=window.setTimeout(()=>w(null),4e3);return()=>window.clearTimeout(R)},[g]);const S=async R=>{u("");try{await R()}catch(M){u(M instanceof Error?M.message:"Custom audio could not be saved.")}},_=(R,M)=>{const O=Date.now(),I=jl({armedFor:g,target:R,armedAt:k.current,now:O,gapMs:Sl});if(I==="arm"){w(R),k.current=O;return}if(I==="ignore")return;w(null);const A=H9(e.map(L=>L.id),R);S(async()=>{var z;await o(R);const L=document.activeElement;L!==M&&!_l((L==null?void 0:L.tagName)??null)||(z=A?v.current.get(A):b.current)==null||z.focus()})},{recording:j,startRecording:E,stopRecording:T}=dJ({full:h,setCustomError:u,runCustom:S,onImportCustom:t});return i.jsxs("section",{className:"sm-custom","aria-labelledby":"sm-custom-title",children:[i.jsxs("div",{className:"sm-custom-head",children:[i.jsx("h3",{className:"sm-tone-name",id:"sm-custom-title",children:"Custom sounds"}),i.jsxs("span",{children:[d," of ",hx,", kept on this machine"]})]}),h&&i.jsx("p",{className:"sm-note",id:"sm-custom-full",children:f}),i.jsxs("div",{className:"sm-custom-actions",children:[i.jsxs("label",{className:"sm-custom-card sm-file",children:[i.jsxs("span",{className:"sm-custom-card-copy",children:[i.jsx("strong",{children:"Import audio"}),i.jsx("span",{children:"WAV, MP3 or OGG"})]}),i.jsx("span",{className:"btn sm-custom-action","aria-hidden":"true",children:"Choose file"}),i.jsx("input",{ref:b,type:"file",accept:"audio/wav,audio/x-wav,audio/mpeg,audio/mp3,audio/ogg,.wav,.mp3,.ogg",...m,onClick:R=>{h&&R.preventDefault()},onChange:R=>{var O;const M=(O=R.target.files)==null?void 0:O[0];R.currentTarget.value="",M&&!h&&S(()=>t(M))}})]}),i.jsxs("div",{className:"sm-custom-card",children:[i.jsxs("span",{className:"sm-custom-card-copy",children:[i.jsx("strong",{children:"Record a clip"}),i.jsx("span",{children:j?"Recording…":"Up to 5 seconds"})]}),j?i.jsx("button",{type:"button",className:"btn sm-custom-action",onClick:T,children:"Stop & save"}):i.jsx("button",{type:"button",className:"btn sm-custom-action",...m,onClick:()=>void E(),children:"Record"})]})]}),i.jsx(hJ,{full:h,fullProps:m,runCustom:S,onCreateVoice:n}),e.length>0&&i.jsx("div",{className:"sm-custom-list",children:e.map(R=>i.jsxs("div",{className:"sm-custom-item",children:[i.jsx("input",{className:"ap-manage-input","aria-label":`Rename ${R.name}`,defaultValue:R.name,maxLength:80,onBlur:M=>{if(!M.target.value.trim()){M.target.value=R.name;return}S(()=>r(R.id,M.target.value))},onKeyDown:M=>{M.key==="Enter"&&M.currentTarget.blur()}}),i.jsx("span",{children:R.kind==="audio"?`${R.duration.toFixed(1)}s`:"Voice"}),i.jsx("button",{type:"button",className:"btn sm-custom-icon","aria-label":`Play ${R.name}`,onClick:()=>s(R.id),children:"Play"}),i.jsx("button",{type:"button",ref:M=>{M?v.current.set(R.id,M):v.current.delete(R.id)},className:`btn sm-custom-icon${g===R.id?" armed":""}`,onKeyDown:M=>{M.repeat&&M.preventDefault()},onClick:M=>_(R.id,M.currentTarget),"aria-label":g===R.id?`Confirm deleting ${R.name}`:`Delete ${R.name}`,title:g===R.id?"Press again to delete this sound. It cannot be brought back.":"Delete this sound",children:g===R.id?"Confirm":"Delete"})]},R.id))}),l&&i.jsx("p",{className:"sm-custom-error",role:"alert",children:l})]})}const Nx="custom:";function i2(e){return`${Nx}${e}`}function pJ(e){return e.startsWith(Nx)?e.slice(Nx.length):null}const l2={done:"Turn finished","needs-input":"Claude is asking"},mJ={done:"Plays when Claude or Codex finishes a turn.","needs-input":"Available in Claude Code only."};function gJ({chime:e,tone:t,soundOn:n,customAssets:r,customSelections:s,onLevel:o,onFigure:l,onPreview:u,onBuiltInSelected:d,onCustomSelected:f}){const h=`sm-level-${e}`,m=`sm-figure-${e}`,g=s[e];return i.jsxs("section",{className:"sm-tone","aria-labelledby":`sm-name-${e}`,children:[i.jsxs("div",{className:"sm-tone-head",children:[i.jsx("h3",{className:"sm-tone-name",id:`sm-name-${e}`,children:l2[e]}),i.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>u(e),"aria-label":`Hear the ${l2[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:[i.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:i.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),"Hear it"]})]}),i.jsx(nI,{id:h,value:t.level,onLevel:w=>o(e,w)}),i.jsxs("div",{className:"sm-row",children:[i.jsx("label",{htmlFor:m,children:"Tone"}),i.jsxs("select",{id:m,className:"sm-select",value:g?i2(g):t.figure,onChange:w=>{const k=w.target.value,v=pJ(k);v!==null?f(e,v):(d(e),l(e,k))},children:[w0[e].map(w=>i.jsx("option",{value:w.id,children:w.label},w.id)),r.length>0&&i.jsx("optgroup",{label:"Custom",children:r.map(w=>i.jsx("option",{value:i2(w.id),children:w.name},w.id))})]})]}),i.jsx("p",{className:"sm-note",children:mJ[e]})]})}function yJ({onClose:e,soundOn:t,onToggleSound:n,prefs:r,onLevel:s,onFigure:o,onPreview:l,openerRef:u,customAssets:d,customSelections:f,onBuiltInSelected:h,onCustomSelected:m,onImportCustom:g,onCreateVoice:w,onRenameCustom:k,onPreviewCustom:v,onDeleteCustom:b,notifyOn:S,onToggleNotify:_,notifyVetoed:j,notifyPermission:E,onAskNotify:T}){var z;const R=oJ(E),M=$l(),O=S&&!j&&!M,I=z9(f),A=((z=d.find(V=>V.id===I))==null?void 0:z.name)??"the same custom sound",L=Et(e,{popover:!0});return dM(L,()=>u.current,e),i.jsxs("div",{ref:L,id:"sound-menu",className:"sound-menu",role:"dialog","aria-label":"Sound settings",children:[i.jsxs("div",{className:"sm-switches",children:[i.jsxs("label",{className:"sm-switch",children:[i.jsx("span",{className:"sm-switch-label",id:"sm-sound-label",children:"Sounds"}),i.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:i.jsx("span",{className:"switch-knob"})})]}),i.jsxs("div",{className:"sm-setting",children:[i.jsxs("label",{className:"sm-switch",children:[i.jsx("span",{className:"sm-switch-label",id:"sm-notify-label",children:"Notifications while closed"}),i.jsx("button",{type:"button",role:"switch","aria-checked":S,"aria-labelledby":"sm-notify-label",className:"switch",onClick:_,title:"With no deck tab open, a notification wherever a sound would play",children:i.jsx("span",{className:"switch-knob"})})]}),i.jsx("p",{className:"sm-note",children:j?aJ:sJ(M)})]})]}),O&&i.jsxs("section",{className:"sm-channel","aria-labelledby":"sm-channel-name",children:[i.jsxs("div",{className:"sm-channel-head",children:[i.jsx("h3",{className:"sm-channel-name",id:"sm-channel-name",children:"Browser notifications"}),R.ask?i.jsx("button",{type:"button",className:"btn sm-channel-action",onClick:T,children:"Enable"}):i.jsxs("span",{className:"sm-channel-state","data-ok":R.ok||void 0,children:[R.ok&&i.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:i.jsx("path",{d:"M1.5 5.2 3.9 7.6 8.5 2.4"})}),R.status]})]}),i.jsx("p",{className:"sm-note",children:R.note})]}),!t&&i.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."}),i.jsx("div",{className:"sm-tones",children:Cu.map(V=>i.jsx(gJ,{chime:V,tone:r[V],soundOn:t,customAssets:d,customSelections:f,onLevel:s,onFigure:o,onPreview:l,onBuiltInSelected:h,onCustomSelected:m},V))}),I&&i.jsxs("p",{className:"sm-note",role:"status",children:["Both tones use “",A,"”. They may be harder to tell apart."]}),i.jsx(fJ,{customAssets:d,onImportCustom:g,onCreateVoice:w,onRenameCustom:k,onPreviewCustom:v,onDeleteCustom:b}),i.jsxs("p",{className:"sm-foot",children:[i.jsx("kbd",{children:"M"}),"Mute or unmute sounds anywhere."]})]})}function wJ({sessionListOpen:e,toggleSessionList:t,usagePanelOpen:n,setUsagePanelOpen:r,setUsageHistoryOpen:s}){return i.jsxs("div",{className:"action-run",children:[i.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:[i.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:[i.jsx("path",{d:"M5.4 3.6h6.6M5.4 7h6.6M5.4 10.4h6.6"}),i.jsx("path",{d:"M2.2 3.6h.2M2.2 7h.2M2.2 10.4h.2"})]}),i.jsx("span",{className:"tb-word",children:"Session list"})]}),i.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:[i.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:[i.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"}),i.jsx("path",{d:"M7 1.6v1.5M7 10.9v1.5"})]}),i.jsx("span",{className:"tb-word",children:"Usage"})]}),i.jsxs("button",{className:"btn icon-btn",onClick:()=>s(o=>!o),title:"Usage history — ccusage (H)","aria-label":"Open usage history","aria-haspopup":"dialog",children:[i.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:[i.jsx("line",{x1:"3",y1:"11.5",x2:"3",y2:"7"}),i.jsx("line",{x1:"7",y1:"11.5",x2:"7",y2:"3"}),i.jsx("line",{x1:"11",y1:"11.5",x2:"11",y2:"8.5"})]}),i.jsx("span",{className:"tb-word",children:"History"})]})]})}function vJ({providers:e,accountsPanelOpen:t,toggleAccountsPanel:n,machinePanelOpen:r,setMachinePanelOpen:s,watchOn:o,watchUnseen:l,setBrowserWatchOpen:u}){return i.jsxs("div",{className:"action-run",children:[e.claude&&i.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:[i.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:[i.jsx("circle",{cx:"7",cy:"4.6",r:"2.4"}),i.jsx("path",{d:"M2.4 12c0-2.3 2.1-3.7 4.6-3.7s4.6 1.4 4.6 3.7"})]}),i.jsx("span",{className:"tb-word",children:"Accounts"})]}),i.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:[i.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:[i.jsx("rect",{x:"3.6",y:"3.6",width:"6.8",height:"6.8",rx:"1.2"}),i.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"})]}),i.jsx("span",{className:"tb-word",children:"Machine"})]}),i.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:[i.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:[i.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?i.jsx("circle",{cx:"7",cy:"7",r:"1.8",fill:"currentColor",stroke:"none"}):i.jsx("line",{x1:"2.4",y1:"11.6",x2:"11.6",y2:"2.4"})]}),i.jsx("span",{className:"tb-word",children:"Browser watch"}),l>0&&i.jsx("span",{className:"bw-badge","aria-hidden":!0,children:l})]})]})}function xJ({providers:e,sound:t,tones:n,customTones:r,notify:s,chimeState:o,menus:l,appearance:u,fm:d}){const{soundOn:f,toggleSound:h}=t,{tonePrefs:m,previewTone:g,changeTone:w}=n,{customSelections:k,customAssets:v,clearCustomOnly:b,selectCustomTone:S,importNotificationAudio:_,createNotificationVoice:j,renameCustomAsset:E,deleteCustomAsset:T,previewCustomAsset:R}=r,{notifyPermission:M,notifyOn:O,notifyVetoed:I,toggleNotify:A,notifySupported:L,askForNotifications:z}=s,{soundMenuOpen:V,setSoundMenuOpen:$,soundButtonRef:P,appearanceMenuOpen:F,setAppearanceMenuOpen:Y,appearanceButtonRef:K}=l,{theme:D,setTheme:W,characterEnabled:B,setCharacterEnabled:X}=u,{fmVolume:G,setFmVolume:U,fmMuted:Z,setFmMuted:H,fmSource:J,customFmStations:ee,unavailableFmStations:re,addFmStation:oe,renameFmStation:fe,removeFmStation:Ne,pickFmSource:ke}=d;return i.jsxs("div",{className:"action-run action-run-utility",children:[e.claude&&f!==null&&i.jsxs("div",{className:"sound-slot",children:[i.jsxs("button",{ref:P,className:"btn icon-btn",onClick:()=>$(we=>!we),...Ss(!1),title:RZ(e,{on:f===!0,locked:o==="locked",prefs:m}),"aria-label":`Sound settings, ${f?"on":"off"}`,"aria-haspopup":"dialog","aria-expanded":V,"aria-controls":V?"sound-menu":void 0,children:[i.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:[i.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),f?i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M9.8 5.4a2.4 2.4 0 0 1 0 3.2"}),i.jsx("path",{d:"M11.3 3.9a4.6 4.6 0 0 1 0 6.2"})]}):i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M10 5.6l2.6 2.8"}),i.jsx("path",{d:"M12.6 5.6L10 8.4"})]})]}),i.jsx("span",{className:"tb-word",children:"Sound"})]}),V&&i.jsx(yJ,{onClose:()=>$(!1),soundOn:f===!0,onToggleSound:h,prefs:m,onLevel:(we,ve)=>w(we,{level:ve}),onFigure:(we,ve)=>w(we,{figure:ve}),onPreview:we=>g(we),customAssets:v,customSelections:k,onBuiltInSelected:b,onCustomSelected:S,onImportCustom:_,onCreateVoice:j,onRenameCustom:E,onPreviewCustom:R,onDeleteCustom:T,notifyOn:O,onToggleNotify:A,notifyVetoed:I,notifyPermission:L?M:"unsupported",onAskNotify:z,openerRef:P})]}),i.jsxs("div",{className:"appearance-slot",children:[i.jsx("button",{ref:K,className:"btn icon-btn",onClick:()=>{$(!1),Y(we=>!we)},title:"Appearance settings","aria-label":`Appearance settings, ${D} theme, character ${B?"shown":"hidden"}`,"aria-haspopup":"dialog","aria-expanded":F,"aria-controls":F?"appearance-menu":void 0,children:D==="dark"?i.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:[i.jsx("circle",{cx:"7",cy:"7",r:"2.5"}),i.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"})]}):i.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:i.jsx("path",{d:"M11.8 8.4A5 5 0 1 1 5.6 2.2a4 4 0 0 0 6.2 6.2Z"})})}),F&&i.jsx(tJ,{theme:D,onTheme:W,characterEnabled:B,onToggleCharacter:()=>X(we=>!we),fmVolume:G,onFmVolume:U,fmMuted:Z,onFmMuted:()=>H(we=>!we),fmSource:J,onFmSource:ke,customFmStations:ee,unavailableFmStations:re,onAddFmStation:oe,onRenameFmStation:fe,onRemoveFmStation:Ne,onClose:()=>Y(!1)})]})]})}const bJ=5*6e4,kJ=6e4;function NJ({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>=bJ}function c2(e=new Date){return KA("month",e)}function SJ(e){const t=kd(e);return{cost:t.cost,tokens:t.tokens}}function u2(e){return e>0?Be(e):"$0.00"}const jJ=new Set(["idle","checking","current","downloading","ready","error"]);function d2(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.status!="string"||!jJ.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 _J(e){return(e==null?void 0:e.status)==="ready"&&e.version?{version:e.version}:null}function EJ(e=typeof navigator>"u"?"":navigator.userAgent){var t;return((t=/\bccdeck-desktop\/(\d[^\s]*)/.exec(e))==null?void 0:t[1])??null}const od="Restart to update",aI=3e4;function CJ(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 TJ(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 ${od} comes first`}}function RJ(e){const t=e==null?void 0:e.reason;return t==="app_disconnected"||t==="update_not_ready"?t:"refused"}function AJ(e,t,n=typeof navigator>"u"?"":navigator.userAgent){const r=CJ(n),s=`Use ${od} 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, ${od} is in ${r}.`;case"timeout":return`ccdeck has not restarted after ${aI/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 MJ="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",Nv="click for what's new";function $J(e){if(e.checkDisabled)return`${MJ} · ${Nv}`;if(e.checking)return`Asking npm for the newest release… · ${Nv}`;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 · ${Nv}, and to check npm now`}function IJ(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 OJ(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 oI(e){return e?`${e.kind}:${e.to}`:""}function LJ(e,t){return e!=null&&t!==oI(e)}function PJ({readyAppUpdate:e,notice:t,noticeOpen:n,version:r,chipVersion:s,versionChecking:o,now:l,openReleaseNotes:u,showNotice:d,loadVersion:f}){return i.jsx(i.Fragment,{children:e?(()=>{const h=TJ(EJ()??s,e.version);return i.jsxs("button",{type:"button",className:"v ready",onClick:u,"aria-haspopup":"dialog","aria-label":h.label,title:h.title,children:[h.text,i.jsx("span",{className:"v-dot","aria-hidden":!0})]})})():t?i.jsxs("button",{type:"button",className:"v stale",onClick:()=>{u(),d()},"aria-haspopup":"dialog","aria-label":OJ({...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,i.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const h={running:s,latest:r==null?void 0:r.latest,latestPending:r==null?void 0:r.latestPending,checkedAgo:r!=null&&r.checkedAt?Vu(l-r.checkedAt):null,checkFailedAgo:r!=null&&r.checkFailedAt&&r.checkFailedAt>(r.checkedAt??0)?Vu(l-r.checkFailedAt):null,checkDisabled:r==null?void 0:r.checkDisabled,checking:o};return i.jsxs("button",{type:"button",className:o?"v checking":"v",onClick:()=>{u(),f(!0)},"aria-busy":o||void 0,"aria-haspopup":"dialog","aria-label":IJ(h),title:$J(h),children:["v",h.running]})})()})}function DJ({live:e,paused:t,pauseGate:n,monthUsageRef:r,monthlyUsage:s,monthlyUsageUnavailable:o}){return i.jsxs("span",{className:"status",children:[(()=>{const l=c8({connected:e,paused:t,held:n.size,dropped:n.dropped});return l.resting?null:i.jsx("span",{className:`pill ${l.tone}`,title:l.title,children:i.jsxs("span",{className:"pill-box",children:[i.jsx("span",{className:"pill-widest","aria-hidden":!0,children:l.widest}),i.jsx("span",{className:"pill-label",children:l.label})]})})})(),i.jsxs("span",{ref:r,className:"month-usage",title:s?`${s.tokens.toLocaleString()} tokens · ${u2(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:[i.jsx("span",{className:"month-usage-label",children:"this month"}),s?i.jsxs(i.Fragment,{children:[i.jsx("b",{children:et(s.tokens)}),i.jsx("span",{className:"month-usage-unit",children:"tokens"}),i.jsx("span",{className:"month-usage-sep","aria-hidden":!0,children:"·"}),i.jsx("b",{children:u2(s.cost)})]}):i.jsx("span",{className:"month-usage-pending",children:o?"unavailable":"…"})]})]})}function FJ({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:r}){return i.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:
92
- ${e.map(s=>` ${s.label}: ${Bo(s.waiting)} (${Vu(r-s.waiting.since)})`).join(`
93
- `)}`,"aria-label":`${e.length} session${e.length===1?"":"s"} waiting for you`,children:[i.jsx("span",{className:"ap-pulse","aria-hidden":!0}),i.jsx("b",{children:e.length})," ",i.jsx("span",{className:"ws-word",children:"waiting"})]})}function qJ({notifySaid:e}){return i.jsx("span",{className:e==="on"?"notify-said":"notify-said notify-said-blocked",role:"status",title:e==="on"?"The deck will raise a system notification when a session blocks on you and this tab is in the background":"Notifications are blocked for this page. Only your browser can undo that — its site settings for this address",children:e==="on"?"notifications on":"notifications blocked"})}function BJ({versionCheck:e,welcome:t,desktopUpdate:n,pause:r,monthly:s,announcements:o,notify:l,waitingSessions:u,waitingCursorRef:d,focusSession:f,live:h,now:m}){const{version:g,notice:w,noticeOpen:k,showNotice:v,versionChecking:b,loadVersion:S}=e,{chipVersion:_,openReleaseNotes:j}=t,{readyAppUpdate:E}=n,{paused:T,pauseGate:R}=r,{monthlyUsage:M,monthlyUsageUnavailable:O,monthUsageRef:I}=s,{blockedSaid:A,watchSaid:L}=o,{notifySaid:z}=l;return i.jsxs("div",{className:"readout",children:[i.jsxs("div",{className:"brand",children:[i.jsx("span",{className:"logo"}),i.jsx("h1",{children:gt}),i.jsx(PJ,{readyAppUpdate:E,notice:w,noticeOpen:k,version:g,chipVersion:_,versionChecking:b,now:m,openReleaseNotes:j,showNotice:v,loadVersion:S})]}),i.jsx(DJ,{live:h,paused:T,pauseGate:R,monthUsageRef:I,monthlyUsage:M,monthlyUsageUnavailable:O}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:A}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:L}),u.length>0&&i.jsx(FJ,{waitingSessions:u,waitingCursorRef:d,focusSession:f,now:m}),z&&i.jsx(qJ,{notifySaid:z})]})}function zJ({selected:e,now:t,selectedIds:n,focusAgent:r,clearSelection:s}){const o=an(e),l=Math.max(0,((e.endedAt??t)-e.startedAt)/1e3),u=e.state==="active"?Xx(o.total,l):null,d=n.size-1;return i.jsxs("button",{type:"button",className:"selected-ribbon",title:`Zoom to ${e.label} and its session (Z)${o.total>0?`
94
- ${Be(o.total)} spent${u?` · ${u}`:""}`:""}`,onClick:()=>{try{r(e.id)}catch{}},children:[i.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),i.jsx("span",{className:"selected-label",children:e.label}),o.total>0&&i.jsxs("span",{className:"selected-cost",children:[Be(o.total),u?i.jsxs("span",{className:"selected-rate",children:[" · ",u]}):null]}),d>0&&i.jsxs("span",{className:"selected-extra",children:["+",d]}),i.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:f=>{f.stopPropagation(),s()},children:"×"})]})}function UJ({catBarRef:e,catBarOccluded:t,presentCats:n,hiddenCats:r,toggleCat:s}){return i.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 i.jsxs("button",{type:"button",className:`cat-filter${l?" off":""}`,onClick:()=>s(o),"aria-pressed":!l,title:`${l?"Show":"Hide"} ${ad[o]} tools`,children:[i.jsx(qZ,{cat:o}),i.jsx("span",{className:"cat-name",children:ad[o]})]},o)})})}const HJ=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(",");function WJ(e){var n,r;const t=e.target;!(t!=null&&t.closest)||t.closest(HJ)!==e.currentTarget||(e.preventDefault(),(r=(n=document.activeElement)==null?void 0:n.blur)==null||r.call(n))}function VJ({trashZoneRef:e,trashState:t,trashPhase:n,trashLabel:r}){return i.jsxs("div",{ref:e,className:`drag-trash-zone ${t}${n==="leaving"?" leaving":""}`,role:"status",children:[i.jsx("svg",{className:"drag-trash-icon",viewBox:"0 0 24 24","aria-hidden":"true",children:i.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"})}),i.jsxs("span",{className:"drag-trash-copy",children:[i.jsx("span",{className:"drag-trash-text",children:t==="over"?i.jsxs(i.Fragment,{children:["Release to remove ",i.jsx("strong",{className:"drag-trash-name",children:r||"this card"})]}):"Drop here to remove from the board"}),i.jsx("span",{className:"drag-trash-hint",children:t==="over"?"The session list (L) brings it back":"The session keeps running"})]})]})}function GJ({canvasRef:e,bubbling:t,dragging:n,trash:r,zoom:s,viewport:o,stateRef:l,peek:u,children:d}){const{trashDragging:f,trashState:h,trashPhase:m,trashZoneRef:g,trashLabel:w}=r,{lod:k,lodRef:v}=s,{markCanvasInput:b}=o,{peekAgent:S,peekLabel:_,peekRecap:j,peekBounds:E}=u;return i.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${t?" bubbling":""}${n?" dragging-any":""}${f&&h==="over"?" trash-hover":""}`,"data-lod":k,ref:e,onMouseDownCapture:WJ,onPointerDownCapture:b,onPointerUpCapture:b,onWheelCapture:b,onFocusCapture:T=>{const R=T.target;if(!F0(R)||v.current==null||v.current==="detail")return;const M=R.getAttribute("data-id");M&&l.current.agents.has(M)&&R.matches(":focus-visible")&&V$(M,R,"focus")},onBlurCapture:T=>{var M,O;const R=(O=(M=T.target).getAttribute)==null?void 0:O.call(M,"data-id");R&&Es(R)},children:[d,Nu(m)&&i.jsx(VJ,{trashZoneRef:g,trashState:h,trashPhase:m,trashLabel:w}),i.jsx(bX,{agentFor:S,recapFor:j,labelFor:_,bounds:E})]})}function KJ({restarting:e,restartMode:t,live:n,paused:r}){return i.jsxs("div",{className:"conn-banner",role:"alert",children:[i.jsx("span",{className:"conn-dot"}),e?t==="npx"?"Fetching the new version with npx — this can take a minute…":`Restarting ${gt}…`:(()=>{const s=i8({connected:n,paused:r});return i.jsxs(i.Fragment,{children:[`Lost connection to the ${gt} server. Reconnecting…`,s&&i.jsx("span",{className:"conn-sub",children:s})]})})()]})}function YJ({oldName:e,version:t,dismissOldName:n}){return i.jsxs("div",{className:"ver-banner",role:"status",children:[i.jsx("span",{className:"ver-dot"}),i.jsxs("strong",{children:[e," still works — the deck is called ",gt," now."]}),t!=null&&t.renameFix?i.jsx("span",{className:"ver-sub",children:t.renameFix}):null,i.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}const XJ=3e4;function ZJ({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function JJ({bundle:e,running:t,pending:n,lastTried:r}){return t?ZJ({bundle:e,running:t,lastTried:r})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function QJ(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function eQ({asked:e,reported:t}){return t?t!==e:!1}function iI(e){const t=e.thresholdMs??XJ;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 tQ(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 nQ(e,t){return e?t==null?"auto when idle":`auto in ${tQ(t)}`:"auto-restart off"}function h2(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function rQ(e){return 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 sQ(e){const t=iI(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 f2={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 aQ({notice:e,version:t,dismissNotice:n,upgradeState:r,startUpgrade:s,copyCommand:o,cmdCopied:l,autoRestart:u,toggleAutoRestart:d,askRestart:f,restartCopy:h,restartFuseMs:m,restarting:g}){var w,k,v;return i.jsxs("div",{className:`ver-banner ${e.kind}`,role:"status",children:[i.jsx("span",{className:`ver-dot${m==null?"":" armed"}`}),e.kind==="restart"?i.jsxs(i.Fragment,{children:[i.jsxs("strong",{children:["v",e.to," is installed — this deck still runs v",e.from,"."]}),t!=null&&t.canRestart?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"ver-act",onClick:()=>f(),...Ss(g),title:`Stop this process and bring it back on the same port. The canvas replays from the event log.
95
-
96
- 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…":h.label}),!g&&i.jsx("span",{className:"ver-sub",children:h.clause}),i.jsxs("label",{className:"ver-auto",children:[i.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:i.jsx("span",{className:"switch-knob"})}),i.jsx("span",{"aria-hidden":!0,children:nQ(u,m)})]})]}):i.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."})]}):i.jsxs(i.Fragment,{children:[i.jsxs("strong",{children:[gt," v",e.to," is out — you are on v",e.from,"."]}),(t==null?void 0:t.upgradeMode)==="install"&&r!=="failed"&&i.jsx("button",{type:"button",className:"ver-act",onClick:s,...Ss(r==="running",r==="done"),title:`Runs ${((w=t==null?void 0:t.upgrade)==null?void 0:w.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)&&i.jsx("button",{type:"button",className:"ver-act",onClick:()=>f({upgrade:!0}),...Ss(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"?i.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",": ",((v=t==null?void 0:t.upgrade)==null?void 0:v.error)??"unknown error"," — run it yourself:"]}):(t==null?void 0:t.upgradeMode)==="npx"?i.jsx("span",{className:"ver-sub",children:t!=null&&t.canRestart?"npx cannot upgrade in place, so the deck re-runs:":f2.npx}):t!=null&&t.upgradeBlocked?i.jsx("span",{className:"ver-sub",children:sn(f2,t.upgradeBlocked)??"cannot install from here"}):null,i.jsxs("button",{type:"button",className:"ver-cmd",onClick:o,title:"Copy to clipboard",children:[i.jsx("code",{children:t==null?void 0:t.command}),i.jsx("span",{className:"ver-cmd-hint",children:l?"copied":"copy"})]})]}),i.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}function oQ({restart:e,versionCheck:t,upgrade:n,oldNameNotice:r,everConnected:s,live:o,paused:l}){const{autoRestart:u,toggleAutoRestart:d,restarting:f,restartMode:h,restartedTo:m,askRestart:g,restartCopy:w,restartFuseMs:k}=e,{version:v,notice:b,noticeOpen:S,dismissNotice:_}=t,{upgradeState:j,startUpgrade:E,copyCommand:T,cmdCopied:R}=n,{oldName:M,oldNameOpen:O,dismissOldName:I}=r;return m?i.jsxs("div",{className:"ver-banner done",role:"status",children:[i.jsx("span",{className:"ver-dot"}),i.jsxs("strong",{children:["Restarted — now running v",m,"."]}),i.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):s&&!o?i.jsx(KJ,{restarting:f,restartMode:h,live:o,paused:l}):S&&b?i.jsx(aQ,{notice:b,version:v,dismissNotice:_,upgradeState:j,startUpgrade:E,copyCommand:T,cmdCopied:R,autoRestart:u,toggleAutoRestart:d,askRestart:g,restartCopy:w,restartFuseMs:k,restarting:f}):O&&M?i.jsx(YJ,{oldName:M,version:v,dismissOldName:I}):null}function iQ(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function lQ(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 cQ(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function uQ(e,t){const n=cQ(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 dQ({agentCount:e,onConfirm:t,onCancel:n}){const r=x.useRef(null),s=Et(n,{focusRef:r,layer:P6}),[o,l]=x.useState(null);x.useEffect(()=>{let m=!1;return fetch("/api/clear").then(g=>g.ok?g.json():null).then(g=>{m||l(lQ(g))}).catch(()=>{}),()=>{m=!0}},[]);const{goes:u,stays:d,final:f,confirm:h}=uQ(e,o);return i.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:i.jsxs("div",{ref:s,className:"modal clear-confirm",onClick:m=>m.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{className:"status-dot err","aria-hidden":!0}),i.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[i.jsxs("dl",{className:"cc-plan",children:[i.jsx("dt",{children:"Goes"}),i.jsx("dd",{children:u.map(m=>i.jsx("span",{children:m},m))}),i.jsx("dt",{children:"Stays"}),i.jsx("dd",{children:d.length>0?d.map(m=>i.jsx("span",{children:m},m)):i.jsx("span",{children:"nothing"})})]}),f&&i.jsx("p",{className:"cc-final",children:f}),i.jsxs("div",{className:"cc-actions",children:[i.jsx("button",{type:"button",ref:r,className:"btn",onClick:n,children:"Cancel"}),i.jsx("button",{type:"button",className:"btn danger",onClick:t,children:h})]})]})]})})}const hQ="Press Esc first if a key does nothing.",fQ=[{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 pQ({onClose:e,onTour:t}){const n=Et(e);return i.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:i.jsxs("div",{ref:n,className:"modal key-help",onClick:r=>r.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[t&&i.jsxs("div",{className:"guide-door",children:[i.jsx("span",{children:"Eight pictures of what the deck shows."}),i.jsx("button",{type:"button",className:"btn",onClick:t,children:"Take the tour"})]}),i.jsx("div",{className:"shortcuts",children:fQ.map(r=>i.jsxs(x.Fragment,{children:[i.jsx("h3",{className:"kh-group",children:r.title}),r.rows.map(s=>i.jsxs("div",{className:"sc",children:[i.jsx("kbd",{children:s.cap}),i.jsx("span",{children:s.action})]},`${r.title}:${s.cap}:${s.action}`))]},r.title))}),i.jsx("p",{className:"kh-foot",children:hQ})]})]})})}function mQ(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 gQ({request:e,waiting:t,busy:n,now:r,onAccept:s,onDecline:o,onLater:l}){const u=x.useRef(null),d=Et(l,{focusRef:u}),f=_s(n,"accept"),h=_s(n,"dismiss");return i.jsx("div",{className:"modal-backdrop",onClick:l,role:"presentation",children:i.jsxs("div",{ref:d,className:"modal lan-ask",onClick:m=>m.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-ask-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("i",{className:"ap-pulse","aria-hidden":!0}),i.jsx("span",{id:"lan-ask-title",className:"modal-tool-name",children:"A deck wants to pair"})]}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:l,"aria-label":"Answer later (Esc)",title:"Answer later (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[i.jsxs("p",{className:"lan-ask-who",children:[i.jsx("strong",{className:"lan-ask-name",children:e.name})," at ",i.jsx("code",{className:"ap-lan-code",children:e.addr})," · asked ",p0(e.at,r)]}),i.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."}),i.jsxs("p",{className:"lan-ask-fp",children:["Its fingerprint is ",i.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&&i.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.`}),i.jsxs("div",{className:"lan-ask-acts",children:[i.jsx("button",{type:"button",ref:u,className:"btn",disabled:h.disabled,"aria-busy":h.busy,onClick:o,title:"Nothing is shared. If that deck asks again, this comes back.",children:n==="dismiss"?"declining…":"Decline"}),i.jsx("button",{type:"button",className:"btn primary",disabled:f.disabled,"aria-busy":f.busy,onClick:s,title:"Talk to this deck from now on, and repair its expired logins with this deck's own.",children:n==="accept"?"accepting…":"Accept"})]})]})]})})}function yQ({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:r,deferLanPair:s}){const{request:o,waiting:l}=mQ(e,t.current);return o?i.jsx(gQ,{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)}):null}const wQ={"//":["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.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.
97
-
98
- 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.
99
-
100
- 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.
101
-
102
- 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.
103
-
104
- 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.
105
-
106
- 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".
107
-
108
- **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.
109
-
110
- \`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.
111
-
112
- **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.
113
-
114
- 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.
115
-
116
- 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.
117
-
118
- 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.
119
-
120
- 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.
121
-
122
- 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.
123
-
124
- 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.
125
-
126
- What you are reading is the first version that does not.
127
-
128
- 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.
129
-
130
- 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.
131
-
132
- 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.
133
-
134
- 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.
135
-
136
- 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.
137
-
138
- The count of what is behind it is on the heading's tooltip, so collapsing it does not hide how much there is.
139
-
140
- **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.
141
-
142
- 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.
143
-
144
- \`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.
145
-
146
- 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.
147
-
148
- **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.
149
-
150
- **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.
151
-
152
- **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.
153
-
154
- **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.
155
-
156
- **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.
157
-
158
- **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.
159
-
160
- 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.
161
-
162
- 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.
163
-
164
- 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.
165
-
166
- 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.
167
-
168
- 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.
169
-
170
- 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.
171
-
172
- 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.
173
-
174
- 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.
175
-
176
- 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.
177
-
178
- 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.
179
-
180
- 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.
181
-
182
- 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.
183
-
184
- 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.
185
-
186
- 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.
187
-
188
- 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.
189
-
190
- 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.
191
-
192
- 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.
193
-
194
- 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.
195
-
196
- 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.
197
-
198
- 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.
199
-
200
- 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.
201
-
202
- 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.
203
-
204
- 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.
205
-
206
- 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.
207
-
208
- 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.
209
-
210
- 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.
211
-
212
- 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.
213
-
214
- 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.
215
-
216
- 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.
217
-
218
- 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.
219
-
220
- 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.
221
-
222
- 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.
223
-
224
- 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.
225
-
226
- 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.
227
-
228
- 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.
229
-
230
- 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.
231
-
232
- 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.
233
-
234
- 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.
235
-
236
- 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.
237
-
238
- 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".
239
-
240
- 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.
241
-
242
- 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.
243
-
244
- 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.
245
-
246
- 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.
247
-
248
- 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.
249
-
250
- 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.
251
-
252
- 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.
253
-
254
- 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.
255
-
256
- 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.
257
-
258
- 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.
259
-
260
- 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.
261
-
262
- 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.
263
-
264
- 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.
265
-
266
- 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.
267
-
268
- 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.
269
-
270
- 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.
271
-
272
- 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.
273
-
274
- 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.
275
-
276
- 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.
277
-
278
- 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.
279
-
280
- 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.
281
-
282
- 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.
283
-
284
- 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.
285
-
286
- 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.
287
-
288
- 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.`}]},W0="agent-dag.releaseNotesSeen";function p2(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function Wo(e,t){const n=p2(e),r=p2(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 Vo(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function vQ(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 xQ(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,r]of Object.entries(e)){if(!Vo(n)||!Array.isArray(r))continue;const s=r.filter(vQ);s.length&&t.push({version:n,notes:s})}return t.sort((n,r)=>Wo(r.version,n.version))}const m2=xQ(wQ);function lI(e,t,n){return e.filter(r=>Wo(r.version,n)<=0&&(t===null||Wo(r.version,t)>0))}function bQ(e,t){return e.filter(n=>Wo(n.version,t)===0)}function kQ(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 NQ({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&&Vo(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(!Vo(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=Wo(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 SQ=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function jQ(e){const t=SQ.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function _Q(e){if(!e)return null;let t=null;try{t=e.getItem(W0)}catch{return null}return Vo(t)?t:null}function EQ(e){if(!e)return!1;try{return e.getItem(W0),!0}catch{return!1}}function CQ(e,t){if(!e)return!1;try{return e.setItem(W0,t),!0}catch{return!1}}const cI="agent-dag.tourSeen";function TQ(e){if(!e)return!1;try{return e.getItem(cI)==="1"}catch{return!1}}function RQ(e){if(!e)return!1;try{return e.setItem(cI,"1"),!0}catch{return!1}}function AQ({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 MQ({stored:e,running:t,notes:n,remembers:r=!0}){if(!Vo(t))return{show:[],record:null,reason:"no-version"};if(!Vo(e)){if(!r)return{show:[],record:t,reason:"cannot-remember"};const l=bQ(n,t);return l.length?{show:l,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const s=Wo(e,t);if(s===0)return{show:[],record:null,reason:"seen"};if(s>0)return{show:[],record:null,reason:"ahead"};const o=lI(n,e,t);return o.length?{show:o,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function $Q(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 uI(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=$Q(e,o);if(l>0){s(),n.push({kind:"bold",kids:uI(e.slice(o+2,l),!1)}),o=l+2;continue}}r+=e[o],o+=1}return s(),n}function IQ({entries:e,since:t,running:n,firstRun:r,onClose:s,onTour:o,updateVersion:l,updateBusy:u,onUpdateRestart:d,updateFailure:f,onRestart:h}){const m=Et(s),g=kQ(e);return i.jsx("div",{className:"modal-backdrop",onClick:s,role:"presentation",children:i.jsxs("div",{ref:m,className:"modal release-notes",onClick:w=>w.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"release-notes-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{id:"release-notes-title",className:"modal-tool-name",children:"What's new"}),g&&i.jsx("span",{className:"modal-tool-id",children:g})]}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[(l||f)&&i.jsxs("div",{className:"rn-update",children:[l&&d&&i.jsxs("div",{className:"guide-door",children:[i.jsxs("span",{children:["ccdeck v",l," is downloaded and verified."]}),i.jsx("button",{type:"button",className:"btn",onClick:d,"aria-busy":u||void 0,children:u?"Restarting…":od})]}),i.jsx("p",{className:"rn-update-said",role:"status",children:f})]}),i.jsx("p",{className:"modal-note",children:NQ({since:t,running:n,firstRun:r,entries:e})}),o&&!l&&i.jsxs("div",{className:"guide-door",children:[i.jsx("span",{children:"Eight pictures of what the deck shows."}),i.jsx("button",{type:"button",className:"btn",onClick:o,children:"Take the tour"})]}),h&&i.jsxs("div",{className:"guide-door",children:[i.jsx("span",{children:"Restart the deck. Sessions, settings and pairings come back as they were."}),i.jsx("button",{type:"button",className:"btn",onClick:h,children:"Restart"})]}),e.map(w=>i.jsxs("section",{className:"modal-section",children:[i.jsxs("h3",{className:"rn-version",children:["v",w.version]}),i.jsx("ul",{className:"rn-notes",children:w.notes.map((k,v)=>{const{icon:b,rest:S}=jQ(k.title);return i.jsxs("li",{className:"rn-note",children:[i.jsxs("p",{className:"rn-note-title",children:[b&&i.jsx("span",{className:"rn-note-icon",children:b}),S]}),i.jsx("p",{className:"rn-note-body",children:dI(uI(k.body))})]},v)})})]},w.version))]})]})})}function dI(e){return e.map((t,n)=>t.kind==="text"?t.text:t.kind==="code"?i.jsx("code",{className:"rn-code",children:t.text},n):i.jsx("strong",{className:"rn-strong",children:dI(t.kids)},n))}function OQ({state:e,sessionId:t,onClose:n}){const r=x.useMemo(()=>LQ(e,t),[e,t]),s=x.useRef(null),o=Et(n,{focusRef:s});return r?i.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:i.jsxs("div",{ref:o,className:"modal session-summary",onClick:l=>l.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[i.jsxs("div",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),i.jsx("span",{id:"ss-title",className:"modal-tool-name",title:r.cwd??r.sessionId,children:r.label}),i.jsxs("span",{className:"modal-tool-id",children:["· ",r.sessionId.slice(0,8)]})]}),i.jsxs("div",{className:"modal-actions",children:[i.jsx("span",{className:"modal-dur",title:"Total wall time",children:r.durationLabel}),i.jsx("button",{type:"button",ref:s,className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),i.jsxs("div",{className:"modal-body",children:[i.jsxs("section",{className:"ss-hero",children:[i.jsxs("div",{className:"ss-hero-left",children:[i.jsx("div",{className:"ss-cost-label",children:GA}),i.jsx("div",{className:"ss-cost",children:Be(r.cost.total)}),r.modelChips.length>0&&i.jsx("div",{className:"ss-models",children:r.modelChips.map(l=>i.jsx("span",{className:"model-chip","data-family":pd(l),title:l,children:js(l)},l))})]}),i.jsx("div",{className:"ss-hero-right",children:r.cost.total>0&&i.jsxs(i.Fragment,{children:[i.jsx(a0,{cost:r.cost,size:"lg"}),i.jsxs("div",{className:"ss-cost-legend",children:[i.jsxs("span",{className:"ssl ssl-in",children:["input ",i.jsx("b",{children:Be(r.cost.input)})]}),i.jsxs("span",{className:"ssl ssl-out",children:["output ",i.jsx("b",{children:Be(r.cost.output)})]}),i.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",i.jsx("b",{children:Be(r.cost.cacheRead)})]}),i.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",i.jsx("b",{children:Be(r.cost.cacheWrite)})]})]})]})})]}),i.jsxs("section",{className:"ss-stats",children:[i.jsx(jo,{label:"agents",value:r.agentCount}),i.jsx(jo,{label:"subagents",value:r.subagentCount}),i.jsx(jo,{label:"tool calls",value:r.toolCount}),i.jsx(jo,{label:"prompts",value:r.promptCount}),i.jsx(jo,{label:"tokens",value:r.tokensSum.toLocaleString()}),r.errCount>0&&i.jsx(jo,{label:"errors",value:r.errCount,tone:"err"})]}),r.topTools.length>0&&i.jsxs("section",{className:"modal-section",children:[i.jsx("h4",{children:"Most-used tools"}),i.jsx("div",{className:"ss-top-tools",children:r.topTools.map(([l,u])=>i.jsxs("div",{className:"ss-tt",children:[i.jsx("span",{className:"ss-tt-name",children:l}),i.jsx("span",{className:"ss-tt-bar",children:i.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${u/r.topTools[0][1]*100}%`}})}),i.jsx("span",{className:"ss-tt-count",children:u})]},l))})]}),r.firstPrompt&&i.jsxs("section",{className:"modal-section",children:[i.jsx("h4",{children:"Opening prompt"}),i.jsx("div",{className:"ss-prompt",children:r.firstPrompt})]})]})]})}):null}function jo({label:e,value:t,tone:n}){return i.jsxs("div",{className:`ss-stat${n?` tone-${n}`:""}`,children:[i.jsx("div",{className:"ss-stat-value",children:t}),i.jsx("div",{className:"ss-stat-label",children:e})]})}function LQ(e,t){const n=e.agents.get(t);if(!n)return null;const r=[];for(const j of e.agents.values())j.sessionId===t&&r.push(j);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,f=0,h=0,m=0,g,w=1/0,k=0;for(const j of r){const E=an(j);s.input+=E.input,s.output+=E.output,s.cacheRead+=E.cacheRead,s.cacheWrite+=E.cacheWrite,s.total+=E.total;for(const R of gA(j))o.add(R);j.model&&o.add(j.model),j.kind==="subagent"&&m++;const T=lA(j.prompts);d+=T.length,!g&&T.length>0&&(g=T[0].text),f+=j.usage.inputTokens+j.usage.outputTokens,u+=j.toolCount,w=Math.min(w,j.startedAt),k=Math.max(k,j.endedAt??Date.now());for(const R of j.tools)l.set(R.name,(l.get(R.name)??0)+1),R.ok===!1&&h++}const v=Math.max(0,k-w),b=Math.floor(v/1e3),S=b<60?`${b}s`:b<3600?`${Math.floor(b/60)}m ${String(b%60).padStart(2,"0")}s`:`${Math.floor(b/3600)}h ${Math.floor(b%3600/60)}m`,_=Array.from(l.entries()).sort((j,E)=>E[1]-j[1]).slice(0,5);return{sessionId:t,label:n.label||n.cwdBasename||"session",cwd:n.cwd,durationLabel:S,cost:s,modelChips:Array.from(o),agentCount:r.length,subagentCount:m,toolCount:u,promptCount:d,tokensSum:f,errCount:h,topTools:_,firstPrompt:g}}const PQ=60,DQ=6e3,yr=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),hn=e=>typeof e=="string"?e:null;function Na(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(`
289
- `)){s.push(u);for(const d of l.split(`
290
- `))s.push(`${t} ${d}`)}else if(l!==null&&typeof l=="object"){const d=Na(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(`
291
- `)}function FQ(e){return e.lines??e.text.split(`
292
- `).map(t=>({text:t}))}function qQ(e,t){if(t)return{shown:e,cut:!1};const n=[];let r=0;for(const s of e){if(n.length===PQ)return{shown:n,cut:!0};const o=DQ-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}}const Vt=(e,t,n=!1)=>({...e?{label:e}:{},text:t,...n?{err:!0}:{}}),fn=(e,t)=>({label:e,text:t,inline:!0}),hI=(e,t)=>({label:e,text:t.map(n=>n.text).join(`
293
- `),lines:t});function BQ(e,t){return[...e.split(`
294
- `).map(n=>({text:`- ${n}`,tone:"del"})),...t.split(`
295
- `).map(n=>({text:`+ ${n}`,tone:"add"}))]}function zQ(e){if(!Array.isArray(e)||e.length===0)return null;const t=[];for(const n of e){if(!yr(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 g2(e){if(typeof e=="string")return[Vt(void 0,e)];if(!yr(e))return[Vt(void 0,Na(e))];const t=[],n=hn(e.type);n==="create"&&t.push(fn("result","created the file"));const r=zQ(e.structuredPatch);return r&&t.push(hI("applied",r)),e.userModified===!0&&t.push(fn("note","the user changed it before it was applied")),t.length?t:[fn("result",n==="update"?"updated the file":"done")]}function UQ(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 HQ(e){if(typeof e=="string")return[Vt(void 0,e)];const t=yr(e)&&yr(e.file)?e.file:null,n=hn(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(fn("lines",o>=l?`all ${l}`:Number.isFinite(u)?`${u}–${u+o-1} of ${l}`:`${o} of ${l}`)),s.push(Vt("content",n)),s}const r=yr(e)?hn(e.type):null;return r&&r!=="text"?[fn("result",`${/^[aeiou]/i.test(r)?"an":"a"} ${r} file`)]:[Vt(void 0,Na(e))]}function WQ(e){if(typeof e=="string")return[Vt("output",e)];if(!yr(e))return[Vt(void 0,Na(e))];const t=hn(e.stdout),n=hn(e.stderr);if(t==null&&n==null)return[Vt(void 0,Na(e))];const r=[];return t&&r.push(Vt("output",t.replace(/\n$/,""))),n&&r.push(Vt("errors",n.replace(/\n$/,""),!0)),e.interrupted===!0&&r.push(fn("note","interrupted before it finished")),r.length?r:[fn("output","none")]}function VQ(e,t,n){const r=yr(t)?t:null;if(r&&(e==="Edit"||e==="MultiEdit")){const s=hn(r.file_path),o=(e==="MultiEdit"?Array.isArray(r.edits)?r.edits:[]:[r]).filter(yr).filter(l=>hn(l.old_string)!=null&&hn(l.new_string)!=null);if(s&&o.length){const l=[fn("file",s)];return o.forEach((u,d)=>{const f=u.replace_all===!0?", every occurrence":"";l.push(hI(o.length>1?`change ${d+1}${f}`:`change${f}`,BQ(u.old_string,u.new_string)))}),{input:l,response:g2(n)}}}if(r&&e==="Write"){const s=hn(r.file_path),o=hn(r.content);if(s&&o!=null)return{input:[fn("file",s),Vt("content",o)],response:g2(n)}}if(r&&e==="Read"){const s=hn(r.file_path);if(s){const o=UQ(r);return{input:o?[fn("file",s),fn("lines",o)]:[fn("file",s)],response:HQ(n)}}}if(r&&e==="Bash"){const s=hn(r.command);if(s!=null){const o=hn(r.description);return{input:o?[Vt("command",s),fn("why",o)]:[Vt("command",s)],response:WQ(n)}}}return{input:[Vt(void 0,Na(t))],response:[Vt(void 0,Na(n))]}}function y2(e,t,n){if(n==null)return"";if(typeof n=="string")return n;if(yr(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(`
296
- `);if(e==="Read"&&t==="response"&&yr(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 GQ({tool:e,onClose:t}){const n=Et(t),r=e.endedAt==null?"inflight":e.ok===!1?"err":"done",s=e.input??e.inputPreview,o=e.response??e.errorPreview,l=VQ(e.name,s,o);return i.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:i.jsxs("div",{ref:n,className:"modal",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{className:`status-dot ${r}`,"aria-hidden":!0}),i.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),i.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),i.jsxs("div",{className:"modal-actions",children:[i.jsx("span",{className:"modal-dur",children:vA(e,"in-flight…")}),i.jsx("button",{className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),i.jsxs("section",{className:"modal-body",children:[e.trimmed&&i.jsx("div",{className:"modal-section",children:i.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),i.jsxs("div",{className:"modal-section",children:[i.jsxs("div",{className:"tm-head",children:[i.jsx("h4",{children:"Input"}),i.jsx(v2,{text:y2(e.name,"input",s),what:"input"})]}),l.input.map((u,d)=>i.jsx(w2,{block:u},d))]}),i.jsxs("div",{className:"modal-section",children:[i.jsxs("div",{className:"tm-head",children:[i.jsxs("h4",{children:["Response ",r==="err"&&i.jsx("span",{className:"err-tag",children:"error"})]}),e.endedAt!=null&&i.jsx(v2,{text:y2(e.name,"response",o),what:"response"})]}),e.endedAt==null?i.jsx("pre",{children:"(waiting…)"}):l.response.map((u,d)=>i.jsx(w2,{block:u},d))]})]})]})})}const KQ={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function w2({block:e}){const[t,n]=x.useState(!1);if(e.inline)return i.jsxs("p",{className:"tm-inline",children:[e.label&&i.jsx("span",{className:"tm-label",children:e.label}),i.jsx("code",{children:e.text})]});const{shown:r,cut:s}=qQ(FQ(e),t);return i.jsxs("div",{className:"tm-block",children:[e.label&&i.jsx("span",{className:"tm-label",children:e.label}),i.jsx("pre",{className:e.err?"tm-err":void 0,children:e.lines?r.map((o,l)=>i.jsxs("span",{className:o.tone?KQ[o.tone]:void 0,children:[o.text,l<r.length-1?`
297
- `:""]},l)):r.map(o=>o.text).join(`
298
- `)}),s&&i.jsx("button",{type:"button",className:"btn tm-more",onClick:()=>n(!0),children:"show all"})]})}function v2({text:e,what:t}){const[n,r]=x.useState(!1),s=x.useRef(!0);return x.useEffect(()=>()=>{s.current=!1},[]),i.jsx("button",{type:"button",className:"btn tm-copy",disabled:!e,"aria-label":n?`The ${t} was copied`:`Copy the ${t}`,onClick:()=>void ja(e).then(o=>{!o||!s.current||(r(!0),window.setTimeout(()=>{s.current&&r(!1)},1600))}),children:n?"copied":"copy"})}const YQ=x.lazy(()=>s0(()=>import("./UsageHistoryModal-CcdPVXAw.js"),[])),XQ=x.lazy(()=>s0(()=>import("./BrowserWatchModal-DP3YMtEi.js"),[]));function ZQ({dialogs:e,welcome:t,desktopUpdate:n,versionCheck:r,restart:s,lanPairs:o,clearFlow:l,watchBadge:u,announcements:d,appearance:f,providers:h,stateRef:m,agentCount:g}){const{openedTool:w,setOpenedToolKey:k,usageHistoryOpen:v,setUsageHistoryOpen:b,browserWatchOpen:S,setBrowserWatchOpen:_,contextAgent:j,setContextFor:E,summaryFor:T,setSummaryFor:R,keyHelpOpen:M,setKeyHelpOpen:O}=e,{tourOpen:I,openTour:A,closeTour:L,releaseNotes:z,closeReleaseNotes:V,chipVersion:$}=t,{desktopUpdateRestarting:P,desktopUpdateFailure:F,readyAppUpdate:Y,askDesktopUpdateRestart:K}=n,{version:D}=r,{askRestart:W}=s,{clearConfirmOpen:B,setClearConfirmOpen:X,requestClear:G}=l,{setWatchOn:U,markWatchSeen:Z}=u,{setWatchSaid:H}=d,{palette:J}=f;return i.jsxs(i.Fragment,{children:[w&&i.jsx(GQ,{tool:w,onClose:()=>k(null)}),v&&i.jsx(x.Suspense,{fallback:null,children:i.jsx(YQ,{providers:h,onClose:()=>b(!1)})}),S&&i.jsx(x.Suspense,{fallback:null,children:i.jsx(XQ,{onClose:()=>_(!1),onSeen:ee=>{H(""),Z(ee)},onWatching:U,palette:J})}),j&&i.jsx(nq,{agent:j,onClose:()=>E(null)}),T&&i.jsx(OQ,{state:m.current,sessionId:T,onClose:()=>R(null)}),z&&i.jsx(IQ,{entries:z.entries,since:z.since,firstRun:z.firstRun,running:$,onClose:V,onTour:()=>{V(),A()},updateVersion:Y==null?void 0:Y.version,updateBusy:P,updateFailure:F&&(!Y||Y.version===F.version)?AJ(F.failure,F.version):void 0,onUpdateRestart:Y?()=>{K(Y.version)}:void 0,onRestart:!Y&&(D!=null&&D.canRestart)?()=>{V(),W()}:void 0}),i.jsx(yQ,{...o}),M&&i.jsx(pQ,{onClose:()=>O(!1),onTour:()=>{O(!1),A()}}),I&&i.jsx(SM,{title:"What the deck shows you",steps:ZW,onClose:L}),B&&i.jsx(dQ,{agentCount:g,onConfirm:()=>G("confirmation"),onCancel:()=>X(!1)})]})}const JQ=1e3;function QQ(e={}){const t=Math.max(1,Math.floor(e.limit??JQ)),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(f){const h=typeof(f==null?void 0:f.seq)=="number"?f.seq:null,m=(f==null?void 0:f.epoch)??null,g=m!==null&&m!==d;g&&(d=m,u=0);const w=h!==null&&!g&&h<=u;if(h!==null&&h>u&&(u=h),!r)return!0;if(w)return!1;if(s.push(f),n!=null&&n(f)&&o.add(f),s.length>t){let k=0;if(o.size<s.length)for(;o.has(s[k]);)k++;const[v]=s.splice(k,1);o.delete(v),l++}return!1},setPaused(f){if(r=f,f)return[];const h=s;return s=[],o=new Set,l=0,h}}}function eee(e){const t=x.useState(()=>QQ({protect:o=>OF(e.current,o)}))[0],[n,r]=x.useState(!1),s=x.useCallback(()=>{const o=t.paused&&t.dropped>0,l=t.setPaused(!t.paused);o&&d6(e.current);for(const u of l)e.current=fA(e.current,u);r(t.paused)},[t,e]);return{pauseGate:t,paused:n,togglePause:s}}const Sx={kind:"assumed",claude:!0,codex:!0};function tee(e){if(!e||typeof e!="object")return Sx;const t=e.providers;if(!t||typeof t!="object")return Sx;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function nee(e){const[t,n]=x.useState(null),[r,s]=x.useState(Sx);x.useEffect(()=>{let l=!1;return fetch("/api/health").then(u=>u.ok?u.json():null).then(u=>{l||(s(tee(u)),!(!u||typeof u.workspace!="string")&&n(u.workspace))}).catch(()=>{}),()=>{l=!0}},[e]);const o=En(r);return{workspace:t,providers:r,providersRef:o}}function ree({version:e,loadVersion:t}){var f;const[n,r]=x.useState(!1),s=((f=e==null?void 0:e.upgrade)==null?void 0:f.state)??"idle",o=QJ(e==null?void 0:e.upgrade),l=x.useRef(!1),u=x.useCallback(async()=>{if(pr(l.current||s==="running")){l.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await t(),l.current=!1}},[s,t]);x.useEffect(()=>{if(s!=="running")return;const h=window.setInterval(t,3e3);return()=>window.clearInterval(h)},[s,t]);const d=x.useCallback(async()=>{const h=e==null?void 0:e.command;!h||!await ja(h)||(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 x2="agent-dag.browserWatch.seenMs";function see(e,t){return e.filter(n=>n.startMs>t)}function aee(){const[e,t]=x.useState(()=>Number(tt(x2))||0),[n,r]=x.useState([]),[s,o]=x.useState(!1);x.useEffect(()=>{let d=!0;const f=()=>{fetch("/api/browser-watch?live=0").then(m=>m.ok?m.json():null).then(m=>{var g;!d||!(m!=null&&m.ok)||(r(m.episodes??[]),o(((g=m.settings)==null?void 0:g.enabled)===!0))}).catch(()=>{})};f();const h=setInterval(f,5*6e4);return()=>{d=!1,clearInterval(h)}},[]);const l=x.useMemo(()=>see(n,e).length,[n,e]),u=x.useCallback(d=>{t(d),Ke(x2,String(d))},[]);return{watchOn:s,setWatchOn:o,watchUnseen:l,markWatchSeen:u}}const fI=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function b2(e){const t={};for(const n of fI)t[n]=e(n);return t}function oee(e){return t=>e[t]??""}function iee(e,t){return fI.every(n=>e[n]===t[n])}const pI="agent-dag.theme";function lee(e,t=!1){return e==="light"||e==="dark"?e:t?"light":"dark"}function cee(){try{return window.matchMedia("(prefers-color-scheme: light)").matches}catch{return!1}}function uee(){return lee(tt(pI),cee())}function k2(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function dee(){const[e,t]=x.useState(uee),[n,r]=x.useState(YZ),[s,o]=x.useState(()=>b2(k2)),l=x.useMemo(()=>oee(s),[s]),u=x.useCallback(d=>tZ(d,l),[l]);return x.useEffect(()=>{document.documentElement.dataset.theme=e,Ke(pI,e),o(d=>{const f=b2(k2);return iee(d,f)?d:f})},[e]),x.useEffect(()=>{Ke(rI,n?"1":"0")},[n]),x.useEffect(()=>{const d=document.querySelector('meta[name="theme-color"]'),f=s["--panel"];d&&f&&d.setAttribute("content",f)},[s]),{theme:e,setTheme:t,characterEnabled:n,setCharacterEnabled:r,palette:s,minimapNodeFill:u}}function hee(e){const t=x.useRef(null),[n,r]=x.useState(!1),[s,o]=x.useState(()=>new Set),l=x.useMemo(()=>{const d=new Set;for(const f of e.current.agents.values())for(const h of f.tools)d.add(tI(h.name));return Object.keys(eI).filter(f=>d.has(f))},[e.current,e.current.revision]);x.useEffect(()=>{if(l.length<=1){r(!1);return}let d=0;const f=()=>{const h=t.current;if(h&&!document.hidden){const m=h.getBoundingClientRect(),g=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(k=>k.getBoundingClientRect()),w=WX(m,g,8);r(k=>k===w?k:w)}d=window.setTimeout(f,300)};return f(),()=>window.clearTimeout(d)},[l.length]);const u=x.useCallback(d=>{o(f=>{const h=new Set(f);return h.has(d)?h.delete(d):h.add(d),h})},[]);return{presentCats:l,hiddenCats:s,toggleCat:u,catBarRef:t,catBarOccluded:n}}function fee(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null,r=!1;const s=()=>e.enabled()?r&&(n==null?void 0:n.state)==="running"?"ready":"locked":"off",o=()=>{var m;return(m=e.onState)==null?void 0:m.call(e,s())};function l(){var m;if(!(!t||r))try{n=n??new t,(m=n.resume)==null||m.call(n).then(o,()=>{}),r=!0,o()}catch{}}function u(m,g,w=g.figure){if(!n||n.state!=="running")return!1;const k=px(m,w),v=rV(g.level,k),b=n.currentTime;for(const S of k.notes){const _=n.createOscillator(),j=n.createGain();_.type=k.type??"sine",_.frequency.value=S.hz;const E=b+S.at,T=E+S.ms/1e3;j.gain.setValueAtTime(RS,E),j.gain.exponentialRampToValueAtTime(v,E+sV),j.gain.exponentialRampToValueAtTime(RS,T),_.connect(j).connect(n.destination),_.start(E),_.stop(T+.02)}return!0}async function d(m,g){if(!e.loadCustom)return"unavailable";let w;try{w=await e.loadCustom(m)}catch{return"unavailable"}if(!w)return"missing";if(w.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const v=new SpeechSynthesisUtterance(w.text),b=window.speechSynthesis.getVoices();v.voice=b.find(S=>S.voiceURI===w.voiceURI)??null,v.rate=w.rate,v.pitch=w.pitch,v.volume=aV(g.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(v),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let k;try{k=await n.decodeAudioData(w.bytes.slice(0))}catch{return"broken"}try{const v=n.createBufferSource(),b=n.createGain();return v.buffer=k,b.gain.setValueAtTime(oV(w.normalizationGain,g.level),n.currentTime),v.connect(b).connect(n.destination),v.start(n.currentTime),"played"}catch{return"unavailable"}}function f(m,g=!1){var v,b;if(!g&&!e.enabled())return!1;const w=fV((v=e.prefs)==null?void 0:v.call(e),m),k=((b=e.customSelection)==null?void 0:b.call(e)[m])??null;return k&&e.loadCustom?(d(k,w).then(S=>{var _;S==="played"||S==="locked"||((S==="missing"||S==="broken")&&((_=e.onCustomFailure)==null||_.call(e,m,k)),u(m,{...w,figure:pn},pn))}),!0):!n||n.state!=="running"?!1:u(m,w)}function h(m,g=ka){return d(m,{level:Ho(g),figure:pn}),!0}return{unlock:l,play:f,previewCustom:h,state:s,get context(){return n}}}function pee({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:r,fallbackCustomRef:s}){const[o,l]=x.useState("locked");return x.useEffect(()=>{const u=fee({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>r.current,loadCustom:J9,onCustomFailure:(f,h)=>s.current(f,h),onState:l});e.current=u,l(u.state());const d=()=>u.unlock();return window.addEventListener("pointerdown",d,{once:!0,capture:!0}),window.addEventListener("keydown",d,{once:!0,capture:!0}),()=>{window.removeEventListener("pointerdown",d,{capture:!0}),window.removeEventListener("keydown",d,{capture:!0})}},[]),{chimeState:o}}function mee(){const[e,t]=x.useState(ZZ),[n,r]=x.useState(()=>lF(tt(aN))),[s,o]=x.useState(()=>iF(tt(oN))),[l,u]=x.useState(()=>cF(tt(s2),n,GZ)),[d,f]=x.useState(()=>new Set),[h,m]=x.useState(0);x.useEffect(()=>{Ke(sI,String(e))},[e]),x.useEffect(()=>{Ke(oN,s?"1":"0")},[s]),x.useEffect(()=>{Ke(aN,JSON.stringify(n))},[n]),x.useEffect(()=>{Ke(s2,l)},[l]);const g=x.useCallback(S=>{r(_=>_.some(j=>j.id===S.id)?_:[..._,S]),f(_=>{if(!_.has(S.id))return _;const j=new Set(_);return j.delete(S.id),j})},[]),w=x.useCallback((S,_)=>{const j=_.trim();!j||j.length>vl||r(E=>E.map(T=>T.id===S?{...T,name:j}:T))},[]),k=x.useCallback(S=>{r(_=>_.filter(j=>j.id!==S)),u(_=>uF(_,S)),f(_=>{if(!_.has(S))return _;const j=new Set(_);return j.delete(S),j})},[]),v=x.useCallback(S=>{const _=iN(S),j=d.has(_);S===l&&!j||(j&&f(E=>{const T=new Set(E);return T.delete(_),T}),u(S),m(E=>E+1))},[l,d]),b=x.useCallback((S,_)=>{const j=iN(S);f(E=>{if(E.has(j)===_)return E;const R=new Set(E);return _?R.add(j):R.delete(j),R})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:s,setFmMuted:o,fmSource:l,customFmStations:n,unavailableFmStations:d,fmPlayRequest:h,addFmStation:g,renameFmStation:w,removeFmStation:k,pickFmSource:v,markFmStationAvailability:b}}function gee(e){const[t,n]=x.useState(null),[r,s]=x.useState(!1),[o,l]=x.useState(null),u=x.useRef(0);x.useEffect(()=>{if(!e||!$l())return;let k=!1;const v=u.current;return fetch("/api/desktop-update").then(b=>b.ok?b.json():null).then(b=>{if(k||u.current!==v)return;const S=d2(b);S&&n(S)}).catch(()=>{}),()=>{k=!0}},[e]);const d=_J(t),f=x.useRef(!1),h=x.useRef(0),m=x.useRef(0);x.useEffect(()=>()=>window.clearTimeout(h.current),[]);const g=x.useCallback(async k=>{if(!pr(f.current))return;const v=++m.current;window.clearTimeout(h.current),f.current=!0,s(!0),l(null);const b=S=>{v===m.current&&(window.clearTimeout(h.current),f.current=!1,s(!1),l({failure:S,version:k}))};try{const S=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:k})});if(!S.ok)return b(RJ(await S.json().catch(()=>null)))}catch{return b("unreachable")}v===m.current&&(h.current=window.setTimeout(()=>b("timeout"),aI))},[]),w=x.useCallback(k=>{if($l())try{const v=d2(JSON.parse(k));v&&(u.current++,n(v),v.status!=="ready"&&(m.current++,window.clearTimeout(h.current),f.current=!1,s(!1)))}catch{}},[]);return{desktopUpdateRestarting:r,desktopUpdateFailure:o,readyAppUpdate:d,askDesktopUpdateRestart:g,onDesktopUpdateEvent:w}}const wu="agent-dag.autoRestart",N2="agent-dag.bundleReloadedFor";function yee({now:e,stateRef:t,version:n,notice:r,noticeOpen:s,upgradeFailure:o}){const[l,u]=x.useState(()=>tt(wu)!=="0"),d=x.useRef(!1),f=x.useCallback(()=>{const I=!l;d.current=!0,Br(wu),u(I),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:I})}).then(A=>A.ok?A.json():null).then(A=>{var L;A!=null&&A.ok&&u(((L=A.prefs)==null?void 0:L.autoUpdate)!==!1)}).catch(()=>{})},[l]),[h,m]=x.useState(!1),[g,w]=x.useState("restart"),[k,v]=x.useState(null),b=x.useRef(!1),S=x.useRef(null),_=x.useRef(0),j=x.useCallback(async I=>{if(!pr(b.current))return;const A=(I==null?void 0:I.upgrade)===!0;b.current=!0,S.current=o;const L=++_.current;w(A?"npx":"restart"),m(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(r==null?void 0:r.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:A})})}catch{}window.setTimeout(()=>{if(_.current===L&&b.current){b.current=!1,m(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},A?18e4:3e4)},[r==null?void 0:r.to,o]),E=x.useRef(null);x.useEffect(()=>{const I=h2(t.current.agents.values())>0,A=sQ({enabled:l,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:I,idleSince:E.current,now:e});E.current=A.idleSince,A.restart&&j()},[l,r==null?void 0:r.kind,n==null?void 0:n.canRestart,s,e,j]);const T=h2(t.current.agents.values()),R=rQ(T),M=iI({enabled:l,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:T>0,idleSince:E.current,now:e});x.useEffect(()=>{const I=n==null?void 0:n.running;let A=null,L=null;try{A=window.sessionStorage.getItem("agent-dag.restartPending"),L=window.sessionStorage.getItem(N2)}catch{return}const z=JJ({bundle:"3.30.0",running:I,pending:A,lastTried:L});if(z==="reload"){try{window.sessionStorage.setItem(N2,I??"")}catch{return}window.location.reload();return}if(z!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}b.current=!1,m(!1),v(I??null);const V=window.setTimeout(()=>v(null),6e3);return()=>window.clearTimeout(V)},[n==null?void 0:n.running]),x.useEffect(()=>{if(h&&eQ({asked:S.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}b.current=!1,m(!1)}},[h,o]);const O=x.useCallback(I=>{var A,L;if(!d.current){const z=tt(wu)==="0";Br(wu),z&&((A=I.prefs)==null?void 0:A.autoUpdate)!==!1?(u(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):u(((L=I.prefs)==null?void 0:L.autoUpdate)!==!1)}},[]);return{autoRestart:l,toggleAutoRestart:f,restarting:h,restartMode:g,restartedTo:k,askRestart:j,restartCopy:R,restartFuseMs:M,loadAutoRestartPrefs:O}}function wee(){const[e,t]=x.useState([]),n=x.useRef(new Set),[r,s]=x.useState(null);x.useEffect(()=>{let u=!0,d=0;const f=()=>{fetch("/api/lan").then(h=>h.ok?h.json():null).then(h=>u?(h!=null&&h.ok&&t(fS(Array.isArray(h.pending)?h.pending:[],h.aliases)),h):null).catch(()=>null).then(h=>{u&&(d=window.setTimeout(f,(h==null?void 0:h.enabled)===!0?ux:NM))})};return f(),()=>{u=!1,window.clearTimeout(d)}},[]);const o=x.useCallback(async(u,d)=>{if(!r){s(u);try{const h=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:u,fp:d})})).json().catch(()=>null);h&&Array.isArray(h.pending)?t(fS(h.pending,h.aliases)):t(m=>m.filter(g=>g.fp!==d))}catch{}finally{s(null)}}},[r]),l=x.useCallback(u=>{r||(n.current.add(u),t(d=>[...d]))},[r]);return{lanPending:e,lanDeferred:n,lanBusy:r,answerLanPair:o,deferLanPair:l}}const mI="agent-dag.sessionListOpen",gI="agent-dag.accountsPanelOpen";function vee(){return tt(mI)==="1"}function xee(e){Ke(mI,e?"1":"0")}function bee(){const e=tt(gI);return e===null?!0:e==="1"}function kee(){const[e,t]=x.useState(vee);x.useEffect(()=>{xee(e)},[e]);const n=x.useRef(!1),[r,s]=x.useState(()=>{const f=bee();return f&&e?(n.current=!0,!1):f});x.useEffect(()=>{!r&&n.current||Ke(gI,r?"1":"0")},[r]),x.useEffect(()=>{!e&&n.current&&(n.current=!1,s(!0))},[e]);const o=x.useCallback(()=>{t(f=>(f||s(h=>(h&&(n.current=!0),!1)),!f))},[]),l=x.useCallback(()=>{n.current=!1,s(f=>(f||t(!1),!f))},[]),u=x.useCallback(()=>t(!1),[]),d=x.useCallback(()=>s(!1),[]);return{sessionListOpen:e,accountsPanelOpen:r,toggleSessionList:o,toggleAccountsPanel:l,closeSessionList:u,closeAccountsPanel:d}}const yI="agent-dag.detailOpen",wI="agent-dag.usagePanelOpen",vI="agent-dag.systemPanelOpen";function Nee(){return tt(yI)==="1"}function See(e){Ke(yI,e?"1":"0")}function jee(){const e=tt(wI);return e===null?!0:e==="1"}function _ee(e){Ke(wI,e?"1":"0")}function Eee(){const e=tt(vI);return e===null?!0:e==="1"}function Cee(e){Ke(vI,e?"1":"0")}function Tee(){const[e,t]=x.useState(Nee);x.useEffect(()=>{See(e)},[e]);const[n,r]=x.useState(jee);x.useEffect(()=>{_ee(n)},[n]);const[s,o]=x.useState(Eee);return x.useEffect(()=>{Cee(s)},[s]),{detailOpen:e,setDetailOpen:t,usagePanelOpen:n,setUsagePanelOpen:r,machinePanelOpen:s,setMachinePanelOpen:o}}const Ree="No sessions are waiting for you.";function Aee(e){if(e.length===0)return"";const[t,...n]=e;if(n.length===0)return`${t.label} is waiting for your permission.`;const r=`${n.length} more session${n.length===1?"":"s"}`;return`${t.label} and ${r} are waiting for your permission.`}function S2(e,t,n=Ree){return t!==""?t:e===""?"":n}function Mee({waitingSessions:e,watchUnseen:t}){const[n,r]=x.useState(""),s=Aee(e);x.useEffect(()=>{r(d=>S2(d,s))},[s]);const[o,l]=x.useState(""),u=t>0?`Browser watch has ${t} unread ${t===1?"finding":"findings"}.`:"";return x.useEffect(()=>{l(d=>S2(d,u,"Browser watch has no unread findings."))},[u]),{blockedSaid:n,watchSaid:o,setWatchSaid:l}}function $ee({waitingSessions:e,liveSince:t,focusSession:n}){const[r,s]=x.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[o,l]=x.useState(null),[u,d]=x.useState(!1),[f,h]=x.useState(!1),m=x.useRef(()=>{}),g=x.useCallback(()=>{const E=!u;d(E),E&&typeof Notification<"u"&&Notification.permission==="default"&&m.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:E})}).then(T=>T.ok?T.json():null).then(T=>{var R;T!=null&&T.ok&&(d(((R=T.prefs)==null?void 0:R.notifications)===!0),h(T.notificationsVetoed===!0))}).catch(()=>{})},[u]),w=typeof Notification<"u";x.useEffect(()=>{if(!o)return;const T=setTimeout(()=>l(null),o==="blocked"?8e3:4e3);return()=>clearTimeout(T)},[o]);const k=x.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(E=>{const T=E;s(T),T==="granted"?l("on"):T==="denied"&&l("blocked")})},[]);m.current=k;const v=x.useRef(new Set),b=x.useRef(null),S=e.map(E=>md(E.id,E.waiting)).join("|");x.useEffect(()=>{C6(b.current,r)&&(b.current=r,v.current=Hf(e))},[r]);const _=x.useRef(!1);x.useEffect(()=>{T6(_.current,t)&&(_.current=!0,v.current=Hf(e))},[t]),x.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!R6(b.current,t))return;const E=typeof document>"u"||!document.hidden,T=_6(e,v.current,E,u);for(const R of T)try{const M=new Notification(R.title,{body:R.body,tag:R.key});M.onclick=()=>{window.focus(),n(R.sessionId),M.close()}}catch{}v.current=E?Hf(e):E6(e,T,v.current)},[S,t]);const j=x.useCallback(E=>{var T;d(((T=E.prefs)==null?void 0:T.notifications)===!0),h(E.notificationsVetoed===!0)},[]);return{notifyPermission:r,notifySaid:o,notifyOn:u,notifyVetoed:f,toggleNotify:g,notifySupported:w,askForNotifications:k,loadNotifyPrefs:j}}function Iee({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:r,summaryFor:s,browserWatchOpen:o,keyHelpOpen:l,releaseNotes:u}){const d=En(l),f=x.useRef(!1);return f.current=e!=null||t||n!=null||r||s!=null||o||l||u!=null,{keyHelpOpenRef:d,modalOpenRef:f}}function Oee({stateRef:e,tourOpen:t,releaseNotes:n}){const[r,s]=x.useState(null),o=x.useCallback((T,R)=>s({agentId:T,toolId:R}),[]),[l,u]=x.useState(null),[d,f]=x.useState(null),h=x.useCallback(T=>f(T),[]),[m,g]=x.useState(!1),[w,k]=x.useState(!1),[v,b]=x.useState(!1),S=r?RF(e.current.agents,r.agentId,r.toolId):null,_=d?e.current.agents.get(d):void 0,{keyHelpOpenRef:j,modalOpenRef:E}=Iee({openedTool:S,usageHistoryOpen:w,contextFor:d,tourOpen:t,summaryFor:l,browserWatchOpen:v,keyHelpOpen:m,releaseNotes:n});return{setOpenedToolKey:s,openTool:o,openedTool:S,summaryFor:l,setSummaryFor:u,contextFor:d,setContextFor:f,openContext:h,contextAgent:_,keyHelpOpen:m,setKeyHelpOpen:g,usageHistoryOpen:w,setUsageHistoryOpen:k,browserWatchOpen:v,setBrowserWatchOpen:b,keyHelpOpenRef:j,modalOpenRef:E}}function Lee({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:r,lastLayoutSigRef:s,forgetRemovals:o,clearSelection:l,rerender:u,modalOpenRef:d}){const[f,h]=x.useState(!1),m=x.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}e.current=Vx(),t.current.clear(),n.current.clear(),r.current.clear(),s.current="",Z$(),o(),l(),u()},[u,l,o]),g=En(f),w=x.useCallback(k=>{const v=iQ(k,{confirmOpen:g.current,modalOpen:d.current});v==="confirm"?h(!0):v==="clear"&&(h(!1),m())},[m]);return{clearConfirmOpen:f,setClearConfirmOpen:h,requestClear:w}}const j2="agent-dag.oldNameNoticeDismissed";function Pee(e){const[t,n]=x.useState(()=>tt(j2)??""),r=e!=null&&e.invokedAs&&e.invokedAs!==gt?e.invokedAs:null,s=r!=null&&t!==r,o=x.useCallback(()=>{r&&(n(r),Ke(j2,r))},[r]);return{oldName:r,oldNameOpen:s,dismissOldName:o}}function Dee({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:r}){const[s,o]=x.useState(()=>q9(tt)),l=En(s),[u,d]=x.useState([]),f=x.useCallback(_=>{o(j=>{const E={...j,[_]:null};return l.current=E,E}),Br(ul[_])},[]),h=x.useCallback((_,j)=>{const E=l.current[_];j&&E!==j||(f(_),t(T=>{const R={...T,[_]:{...T[_],figure:pn}};return n.current=R,R}),Ke(Qu[_],pn))},[f]),m=En(h);x.useEffect(()=>{let _=!0;return Z9().then(j=>{if(!_)return;d(j);const E=new Set(j.map(T=>T.id));for(const T of Cu){const R=l.current[T];R&&!E.has(R)&&m.current(T,R)}},()=>{}),()=>{_=!1}},[]);const g=x.useCallback((_,j)=>{if(!u.some(T=>T.id===j))return;const E={...l.current,[_]:j};l.current=E,o(E),Ke(ul[_],j),r(_,!0)},[u,r]),w=x.useCallback(async _=>{var R;const j=fx(u.length);if(j)throw new Error(j);const E=window.AudioContext??window.webkitAudioContext;if(!E)throw new Error("This browser cannot decode audio files.");const T=new E;try{const M=await V9(_,I=>T.decodeAudioData(I));await CS(M);const O=Rl(M);d(I=>[...I.filter(A=>A.id!==O.id),O])}finally{(R=T.close)==null||R.call(T)}},[u.length]),k=x.useCallback(async _=>{const j=fx(u.length);if(j)throw new Error(j);const E=G9(_);await CS(E);const T=Rl(E);d(R=>[...R.filter(M=>M.id!==T.id),T])},[u.length]),v=x.useCallback(async(_,j)=>{const E=u.find(R=>R.id===_),T=j.trim().slice(0,80);!E||!T||T===E.name||(await Q9(_,T),d(R=>R.map(M=>M.id===_?{...M,name:T}:M)))},[u]),b=x.useCallback(async _=>{await eV(_),d(R=>R.filter(M=>M.id!==_));const j=l.current,E=B9(j,_);l.current=E,o(E);const T=Cu.filter(R=>j[R]===_);for(const R of T)Br(ul[R]),Ke(Qu[R],pn);T.length>0&&t(R=>{const M={...R};for(const O of T)M[O]={...M[O],figure:pn};return n.current=M,M})},[]),S=x.useCallback(_=>{var T,R;const j=Cu.find(M=>l.current[M]===_),E=j?n.current[j].level:ka;(T=e.current)==null||T.unlock(),(R=e.current)==null||R.previewCustom(_,E)},[]);return{customSelections:s,customSelectionsRef:l,customAssets:u,clearCustomOnly:f,fallbackCustomRef:m,selectCustomTone:g,importNotificationAudio:w,createNotificationVoice:k,renameCustomAsset:v,deleteCustomAsset:b,previewCustomAsset:S}}function Fee(e){const[t,n]=x.useState(()=>hV(tt)),r=En(t),s=x.useRef(null),o=x.useCallback((u,d=!1)=>{var f,h;if((f=e.current)==null||f.unlock(),s.current!==null&&clearTimeout(s.current),s.current=null,!d){(h=e.current)==null||h.play(u,!0);return}s.current=setTimeout(()=>{var m;s.current=null,(m=e.current)==null||m.play(u,!0)},iV)},[]),l=x.useCallback((u,d)=>{n(f=>{const h={level:Ho(d.level??f[u].level),figure:OM(u,d.figure??f[u].figure)};return Ke(DM[u],String(h.level)),Ke(Qu[u],h.figure),{...f,[u]:h}}),o(u,!0)},[o]);return x.useEffect(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]),{tonePrefs:t,setTonePrefs:n,tonePrefsRef:r,previewTone:o,changeTone:l}}const qee=15e3;function Bee(e){return e.visibilityState==="visible"&&e.hasFocus()}function zee(e,t){return t||e===!0}function Uee(){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 Hee(){x.useEffect(()=>{const e=Uee();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=Bee(document);zee(t,l)&&n(l),t=l},s=()=>{t&&n(!1),t=!1};r();const o=window.setInterval(r,qee);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 Wee({loadAutoRestartPrefs:e,loadNotifyPrefs:t}){x.useEffect(()=>{let n=!0;return fetch("/api/prefs").then(r=>r.ok?r.json():null).then(r=>{!n||!(r!=null&&r.ok)||(e(r),t(r))}).catch(()=>{}),()=>{n=!1}},[])}const Sv="agent-dag.versionNoticeDismissed",Vee=15*6e4;function Gee(e){const[t,n]=x.useState(null),[r,s]=x.useState(()=>tt(Sv)??""),o=x.useRef(0),[l,u]=x.useState(!1),d=x.useCallback((v=!1)=>(v&&(o.current=Date.now(),u(!0)),fetch(v?"/api/version?refresh=1":"/api/version").then(b=>b.ok?b.json():null).then(b=>{b&&n(b)}).catch(()=>{}).finally(()=>{v&&u(!1)})),[]),f=x.useCallback(()=>{d(Date.now()-o.current>=Vee)},[d]);x.useEffect(()=>{d();const v=window.setInterval(f,5*6e4),b=()=>{document.visibilityState==="visible"&&f()};return document.addEventListener("visibilitychange",b),()=>{window.clearInterval(v),document.removeEventListener("visibilitychange",b)}},[d,f]),x.useEffect(()=>{e&&d()},[e,d]);const h=(t==null?void 0:t.notice)??null,m=oI(h),g=LJ(h,r),w=x.useCallback(()=>{s(""),Ke(Sv,"")},[]),k=x.useCallback(()=>{h&&(s(m),Ke(Sv,m))},[h,m]);return{version:t,notice:h,noticeOpen:g,showNotice:w,dismissNotice:k,versionChecking:l,loadVersion:d}}function Kee({version:e,readyAppUpdate:t}){const[n,r]=x.useState(!1),s=x.useRef(null),[o,l]=x.useState(null),u=o&&t?t.version:null,d=x.useRef(null);x.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 f=x.useRef(!1);x.useEffect(()=>{if(f.current)return;const b=ll(),S=_Q(b),_=MQ({stored:S,running:(e==null?void 0:e.running)??null,notes:m2,remembers:EQ(b)});if(_.reason==="no-version")return;f.current=!0,_.record&&CQ(b,_.record);let j=!0;return(async()=>{var O;let T=TQ(b);if($l())try{const I=await fetch("/api/prefs");if(!I.ok)throw new Error("desktop tour preferences unavailable");const A=await I.json();if(!(A!=null&&A.ok))throw new Error("desktop tour preferences unavailable");const L=((O=A.prefs)==null?void 0:O.tourSeen)===!0;T&&!L&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{}),T=T||L}catch{T=!0}if(!j)return;const R=AQ({tourSeen:T,decision:_}),M=_.show.length?{entries:_.show,since:S,firstRun:!1}:null;R.tour&&r(!0),R.notes==="now"?l(M):R.notes==="after"&&(s.current=M)})(),()=>{j=!1}},[e==null?void 0:e.running]);const h=(e==null?void 0:e.running)??"3.30.0",m=x.useMemo(()=>lI(m2,null,h),[h]),g=x.useCallback(()=>{l({entries:m,since:null,firstRun:!1})},[m]),w=x.useCallback(()=>r(!0),[]),k=x.useCallback(()=>l(null),[]),v=x.useCallback(()=>{r(!1),RQ(ll()),$l()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const b=s.current;s.current=null,b&&l(b)},[]);return{tourOpen:n,openTour:w,closeTour:v,releaseNotes:o,closeReleaseNotes:k,chipVersion:h,openReleaseNotes:g}}function Yee(){const[e,t]=x.useState(null),[n,r]=x.useState(!1),s=x.useRef(null);return x.useEffect(()=>{let o=!0,l=!1,u=null,d=null,f="";const h=v=>{o&&(r(!0),v!==f&&t(null))},m=()=>{if(l)return;l=!0,u=Date.now();const v=c2();d=v,fetch(`/api/ccusage?since=${v}`).then(b=>b.ok?b.json():null).then(b=>{if(o){if(!(b!=null&&b.ok)){h(v);return}f=v,t(SJ(b)),r(!1)}}).catch(()=>h(v)).finally(()=>{l=!1})},g=()=>{const v=s.current;NJ({shown:!!v&&v.getClientRects().length>0,tabVisible:document.visibilityState==="visible",lastSince:d,since:c2(),lastReadAt:u,now:Date.now()})&&m()};g();const w=window.setInterval(g,kJ);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(w),document.removeEventListener("visibilitychange",g),k==null||k.disconnect()}},[]),{monthlyUsage:e,monthlyUsageUnavailable:n,monthUsageRef:s}}function Xee(e){const[t,n]=x.useState(null);x.useEffect(()=>{const u=tt("agent-dag.sound");n(u===null?!0:u==="on")},[]);const r=x.useCallback(()=>{n(u=>{var f;const d=u!==!0;return Ke("agent-dag.sound",d?"on":"off"),d&&((f=e.current)==null||f.unlock()),d})},[]),s=x.useCallback(u=>{r()},[r]),o=En(s),l=En(t);return{soundOn:t,toggleSound:r,activateSoundRef:o,soundOnRef:l}}function Zee(){const[e,t]=x.useState(!1),n=x.useRef(null),[r,s]=x.useState(!1),o=x.useRef(null);return x.useEffect(()=>{e&&s(!1)},[e]),{soundMenuOpen:e,setSoundMenuOpen:t,soundButtonRef:n,appearanceMenuOpen:r,setAppearanceMenuOpen:s,appearanceButtonRef:o}}const Jee="agent-dag.autoFitDisabled";function Qee(e){const t=x.useRef(!1),[n,r]=x.useState(!1);x.useEffect(()=>{Br(Jee)},[]);const s=x.useCallback(()=>{t.current||(t.current=!0,r(!0))},[]),o=x.useCallback(()=>{t.current=!1,r(!1),e(400)},[e]);return{autoFitDisabled:n,autoFitDisabledRef:t,disableAutoFit:s,enableAutoFitAndRefit:o}}function ete(){return i.jsx(Ux,{children:i.jsx(tte,{})})}function tte(){const e=Go(),t=x.useState(Vx)[0],n=x.useRef(t),[,r]=x.useState(0),s=x.useCallback(()=>r(Ks=>Ks+1),[]),{detailOpen:o,setDetailOpen:l,usagePanelOpen:u,setUsagePanelOpen:d,machinePanelOpen:f,setMachinePanelOpen:h}=Tee(),{selectedIds:m,primarySelectedId:g,selectAgent:w,clearSelection:k,pruneSelectionToBoard:v}=TV(n,l),{sessionListOpen:b,accountsPanelOpen:S,toggleSessionList:_,toggleAccountsPanel:j,closeSessionList:E,closeAccountsPanel:T}=kee(),R=Yee(),M=Su(S,200),O=Su(u,130),I=Su(f,130),A=x.useRef(null),L=Xee(A),{activateSoundRef:z,soundOnRef:V}=L,$=Fee(A),{setTonePrefs:P,tonePrefsRef:F,previewTone:Y}=$,K=Dee({chimesRef:A,setTonePrefs:P,tonePrefsRef:F,previewTone:Y}),{customSelectionsRef:D,fallbackCustomRef:W}=K,B=Zee(),{setSoundMenuOpen:X}=B,{chimeState:G}=pee({chimesRef:A,soundOnRef:V,tonePrefsRef:F,customSelectionsRef:D,fallbackCustomRef:W}),U=eee(n),{pauseGate:Z,paused:H,togglePause:J}=U,ee=x.useRef(()=>{}),{live:re,tabCapped:oe,everConnected:fe,liveSince:Ne}=xV({stateRef:n,rerender:s,pauseGate:Z,chimesRef:A,desktopUpdateRef:ee}),ke=Gee(re),{version:we,notice:ve,noticeOpen:$e,loadVersion:ye}=ke,ue=gee(re),{readyAppUpdate:se,onDesktopUpdateEvent:xe}=ue;ee.current=xe,Hee();const Ae=Kee({version:we,readyAppUpdate:se}),{tourOpen:Le,openTour:Ie,releaseNotes:qe}=Ae,{workspace:nt,providers:rt,providersRef:Ye}=nee(re),ct=Pee(we),At=ree({version:we,loadVersion:ye}),{upgradeFailure:vt}=At,Ve=Oee({stateRef:n,tourOpen:Le,releaseNotes:qe}),{openTool:ut,setSummaryFor:Ze,setContextFor:ot,openContext:Gt,setKeyHelpOpen:ge,setUsageHistoryOpen:Oe,setBrowserWatchOpen:Fe,keyHelpOpenRef:Lt,modalOpenRef:Kt}=Ve,Mt=aee(),{watchOn:on,watchUnseen:Ut}=Mt,Xn=wee(),[Ra,Aa]=x.useState(0),{presentCats:Rs,hiddenCats:br,toggleCat:Ma,catBarRef:kr,catBarOccluded:As}=hee(n),Zn=x.useRef(null),[ri,Nr]=x.useState(0),Pt=RV({stateRef:n,rerender:s,pruneSelectionToBoard:v,setContextFor:ot,setSummaryFor:Ze}),Jn=yee({now:Pt,stateRef:n,version:we,notice:ve,noticeOpen:$e,upgradeFailure:vt}),{askRestart:$a,loadAutoRestartPrefs:si}=Jn,Gr=dee(),{setTheme:Ia,palette:Qn}=Gr,Ms=mee(),$s=EX(),{applyViewport:ai,moveCamera:Oa,fitLeft:er,cameraEpochRef:La,lastFitTimeRef:Is}=$s,tr=FX(er),{pinnedRef:Kr,positionsRef:Ge,lastLayoutSigRef:oi,handleRelayout:Os}=tr,Ls=x.useRef(null),Sr=x.useRef(()=>{}),Pa=Ne!==null,Ps=x.useRef(0),jr=x.useCallback(()=>{Ps.current=Date.now()},[]),{canvasRef:pt,canvasSize:Ds,paneSizeRef:ln}=vZ(),Kl=Qee(er),{autoFitDisabledRef:Yl,disableAutoFit:ii}=Kl,Yr=x.useRef(!1),{measuredRef:gn,measuredVersionRef:Fs,sizeVersion:Da,domSizeVersion:Yd}=xZ(Yr),{removedNodes:Xl,removedAgentIds:nr,removeNode:Zl,removeSelectedNode:Fa,removalNotice:Xr,bringBack:li,bringBackAll:ci,forgetRemovals:He}=uZ({stateRef:n,pinnedRef:Kr,positionsRef:Ge,canvasRef:pt,clearSelection:k,primarySelectedId:g}),qa=aZ({stateRef:n,now:Pt,removedAgentIds:nr,sizeVersion:Da,domSizeVersion:Yd});qX(qa,tr),cZ({layoutSig:qa,rf:e,stateRef:n,measuredRef:gn,pinnedRef:Kr,positionsRef:Ge,paneSizeRef:ln,lastInteractRef:Ps,autoFitDisabledRef:Yl,lastFitTimeRef:Is,fitLeft:er});const ui=bZ(),{bubbling:di,endBubble:Jl,onBubble:Ql}=S9(),[Ba,hi]=x.useState(!1),qs=k9(),{beginTrashDrag:rr,trackTrashDrag:sr,endTrashDrag:ar}=qs,Zr=$9({stateRef:n,measuredRef:gn,measuredVersionRef:Fs,canvasRef:pt}),{lodRef:Bs,applyZoom:or}=Zr,ec=yZ({applyViewport:ai,lastFitTimeRef:Is,cameraEpochRef:La,disableAutoFit:ii,markInteract:jr,canvasRef:pt,applyZoom:or}),Jr=g?n.current.agents.get(g):null,Qr=o&&Jr!=null,{railInsetRef:tc,availableWidth:fi,availableHeight:zs}=_X({canvasRef:pt,canvasSize:Ds,machinePhase:I,usagePhase:O,usagePanelOpen:u,detailShown:Qr}),pi=oZ({stateRef:n,now:Pt,availableWidth:fi,availableHeight:zs,layout:tr,measuredRef:gn,onBubble:Ql,settled:ui,dragging:Ba,layoutSig:qa,selectedIds:m,openContext:Gt,historyReplayed:Pa,removedNodes:Xl,removedAgentIds:nr,dragTick:Ra,dragPatchRef:Zn,dragMoveTick:ri}),{nodes:mi,edges:Us}=pi,_r=En(g);BX({nodes:mi,edges:Us,settled:ui,dragging:Ba,availableWidth:fi,availableHeight:zs,layout:tr,camera:$s,rf:e,measuredRef:gn,stateRef:n,lastFocusRef:Ls,primarySelectedIdRef:_r,focusAgentRef:Sr,autoFitDisabledRef:Yl});const Er=Lee({stateRef:n,pinnedRef:Kr,measuredRef:gn,positionsRef:Ge,lastLayoutSigRef:oi,forgetRemovals:He,clearSelection:k,rerender:s,modalOpenRef:Kt}),{requestClear:Hs}=Er,Xd=SZ({nodes:mi,stateRef:n,pinnedRef:Kr,positionsRef:Ge,draggingRef:Yr,dragPatchRef:Zn,setDragging:hi,setDragMoveTick:Nr,setDragTick:Aa,endBubble:Jl,markInteract:jr,disableAutoFit:ii,beginTrashDrag:rr,trackTrashDrag:sr,endTrashDrag:ar,removeNode:Zl}),Zd=x.useCallback(()=>er(500),[er]),Ws=En(mi),{focusAgent:Cr,stepAgent:gi,focusSession:es}=TX({canvasRef:pt,stateRef:n,measuredRef:gn,nodesRef:Ws,railInsetRef:tc,moveCamera:Oa,disableAutoFit:ii,lastFocusRef:Ls,focusAgentRef:Sr,selectAgent:w,primarySelectedIdRef:_r}),ir=wZ({clearSelection:k,selectAgent:w,detailOpen:o,setDetailOpen:l,detailShown:Qr,focusAgent:Cr,draggingRef:Yr,lodRef:Bs}),yi=RX({nodesRef:Ws,stateRef:n,canvasRef:pt,railInsetRef:tc}),za=En(Fa),wi=x.useRef(null),Ua=x.useCallback(Ks=>{nr.has(Ks)&&li([Ks]),es(Ks)},[nr,li,es]),Ha=kZ();NZ({pointerFocusRef:Ha,nodesRef:Ws,stateRef:n,primarySelectedIdRef:_r,providersRef:Ye,soundOnRef:V,keyHelpOpenRef:Lt,modalOpenRef:Kt,waitingCursorRef:wi,removeSelectedRef:za,activateSoundRef:z,clearSelection:k,selectAgent:w,focusAgent:Cr,stepAgent:gi,focusSession:es,requestClear:Hs,handleRelayout:Os,handleFit:Zd,togglePause:J,toggleSessionList:_,toggleAccountsPanel:j,setDetailOpen:l,setUsageHistoryOpen:Oe,setUsagePanelOpen:d,setMachinePanelOpen:h,setBrowserWatchOpen:Fe,setSoundMenuOpen:X,setKeyHelpOpen:ge,setTheme:Ia});const vi=n.current.agents.size,xt=x.useMemo(()=>Uv(n.current.agents.values()),[n.current,n.current.revision]);dZ({stateRef:n,waitingSessions:xt,removedAgentIds:nr,removedNodes:Xl,bringBack:li}),pZ({stateRef:n,waitingSessions:xt,live:re});const Tr=Mee({waitingSessions:xt,watchUnseen:Ut}),Vs=$ee({waitingSessions:xt,liveSince:Ne,focusSession:es}),{loadNotifyPrefs:Gs}=Vs;return Wee({loadAutoRestartPrefs:si,loadNotifyPrefs:Gs}),i.jsxs("div",{className:"app",children:[i.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),i.jsxs("header",{className:"topbar",children:[i.jsx(BJ,{versionCheck:ke,welcome:Ae,desktopUpdate:ue,pause:U,monthly:R,announcements:Tr,notify:Vs,waitingSessions:xt,waitingCursorRef:wi,focusSession:es,live:re,now:Pt}),Jr&&i.jsx(zJ,{selected:Jr,now:Pt,selectedIds:m,focusAgent:Cr,clearSelection:k}),i.jsxs("div",{className:"actions",children:[i.jsx(wJ,{sessionListOpen:b,toggleSessionList:_,usagePanelOpen:u,setUsagePanelOpen:d,setUsageHistoryOpen:Oe}),i.jsx(vJ,{providers:rt,accountsPanelOpen:S,toggleAccountsPanel:j,machinePanelOpen:f,setMachinePanelOpen:h,watchOn:on,watchUnseen:Ut,setBrowserWatchOpen:Fe}),i.jsx(xJ,{providers:rt,sound:L,tones:$,customTones:K,notify:Vs,chimeState:G,menus:B,appearance:Gr,fm:Ms})]})]}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Xr?`${Xr.label} removed from the board.`:""}),i.jsx(oQ,{restart:Jn,versionCheck:ke,upgrade:At,oldNameNotice:ct,everConnected:fe,live:re,paused:H}),Nu(M)&&rt.claude&&i.jsx(m9,{leaving:M==="leaving",onClose:T}),b&&i.jsx(dz,{state:n.current,now:Pt,selectedIds:m,onSelect:Ua,onClose:E,removedIds:nr,onBringBackAll:ci}),i.jsxs(GJ,{canvasRef:pt,bubbling:di,dragging:Ba,trash:qs,zoom:Zr,viewport:ec,stateRef:n,peek:yi,children:[vi===0&&(!re&&oe?i.jsx(MZ,{}):i.jsx($Z,{live:re,everConnected:fe,providers:rt,workspace:nt,onTour:Ie})),(Rs.length>1||br.size>0)&&i.jsx(UJ,{catBarRef:kr,catBarOccluded:As,presentCats:Rs,hiddenCats:br,toggleCat:Ma}),i.jsx(rz,{graph:pi,layout:tr,viewport:ec,clicks:ir,drag:Xd,appearance:Gr,fm:Ms,autoFit:Kl,pause:U,stateRef:n,measuredRef:gn,hiddenCats:br,now:Pt,openTool:ut,focusAgent:Cr,requestClear:Hs,setKeyHelpOpen:ge})]}),Nu(O)&&i.jsx(nU,{state:n.current,now:Pt,providers:rt,liveSince:Ne,leaving:O==="leaving",onClose:()=>d(!1)}),Nu(I)&&i.jsx(DU,{usageOpen:u,leaving:I==="leaving",onClose:()=>h(!1)}),o&&Jr?i.jsx(WZ,{selected:Jr,now:Pt,openTool:ut,setSummaryFor:Ze,setDetailOpen:l,stateRef:n,removeSelectedNode:Fa}):null,i.jsx(ZQ,{dialogs:Ve,welcome:Ae,desktopUpdate:ue,versionCheck:ke,restart:Jn,lanPairs:Xn,clearFlow:Er,watchBadge:Mt,announcements:Tr,appearance:Gr,providers:rt,stateRef:n,agentCount:vi})]})}try{lq(window.localStorage)}catch{}const nte=QO.createRoot(document.getElementById("root"));nte.render(i.jsx(ete,{}));export{EZ as a,et as b,js as c,ste as d,Ss as e,Be as f,rte as g,Tl as h,ca as i,i as j,ja as k,YN as p,x as r,pr as s,Et as u};