ccdeck 3.36.0 → 3.36.3

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.
Files changed (40) hide show
  1. package/LICENSING.md +17 -3
  2. package/README.md +6 -1
  3. package/dist/web/apple-touch-icon.png +0 -0
  4. package/dist/web/assets/{BrowserWatchModal-BnNwmF9s.js → BrowserWatchModal-BJKk2x-P.js} +1 -1
  5. package/dist/web/assets/{UsageHistoryModal-CAsrCgeA.js → UsageHistoryModal-ClT1-0hN.js} +1 -1
  6. package/dist/web/assets/index-1U-Iz_x2.css +1 -0
  7. package/dist/web/assets/index-Dj4JHRcG.js +306 -0
  8. package/dist/web/brand/ccdeck-mark-gradient-small-optical.svg +1 -0
  9. package/dist/web/brand/ccdeck-mark-mono-dark-small-optical.svg +1 -0
  10. package/dist/web/favicon.ico +0 -0
  11. package/dist/web/favicon.svg +1 -0
  12. package/dist/web/icon-192.png +0 -0
  13. package/dist/web/icon-512.png +0 -0
  14. package/dist/web/icon-maskable-512.png +0 -0
  15. package/dist/web/index.html +13 -11
  16. package/dist/web/manifest.webmanifest +1 -2
  17. package/dist/web/state/favicon-error-32.png +0 -0
  18. package/dist/web/state/favicon-error.svg +1 -0
  19. package/dist/web/state/favicon-syncing-32.png +0 -0
  20. package/dist/web/state/favicon-syncing.svg +1 -0
  21. package/dist/web/state/favicon-waiting-32.png +0 -0
  22. package/dist/web/state/favicon-waiting.svg +1 -0
  23. package/hook/hook.js +23 -6
  24. package/package.json +1 -1
  25. package/release-notes.json +8 -1
  26. package/src/server/account-origins.mjs +201 -0
  27. package/src/server/account-routes.mjs +106 -5
  28. package/src/server/claude-accounts.mjs +78 -2
  29. package/src/server/cswap-admin.mjs +62 -1
  30. package/src/server/deck-prefs.mjs +9 -1
  31. package/src/server/feedback-form.mjs +125 -0
  32. package/src/server/http-io.mjs +40 -4
  33. package/src/server/index.mjs +9 -3
  34. package/src/server/prefs-routes.mjs +4 -1
  35. package/src/server/reports-routes.mjs +69 -11
  36. package/src/server/static-serve.mjs +1 -0
  37. package/dist/web/assets/index-CuVOi3gc.css +0 -1
  38. package/dist/web/assets/index-MjcQ231B.js +0 -305
  39. package/dist/web/icon-maskable.svg +0 -21
  40. package/dist/web/icon.svg +0 -24
@@ -0,0 +1,306 @@
1
+ var YP=Object.defineProperty;var XP=(e,t,n)=>t in e?YP(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var U1=(e,t,n)=>XP(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();var lu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function sb(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var zf={exports:{}},cl={},Wf={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 z1;function ZP(){if(z1)return Pe;z1=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.iterator;function g(F){return F===null||typeof F!="object"?null:(F=p&&F[p]||F["@@iterator"],typeof F=="function"?F:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,b={};function x(F,Y,J){this.props=F,this.context=Y,this.refs=b,this.updater=J||v}x.prototype.isReactComponent={},x.prototype.setState=function(F,Y){if(typeof F!="object"&&typeof F!="function"&&F!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,F,Y,"setState")},x.prototype.forceUpdate=function(F){this.updater.enqueueForceUpdate(this,F,"forceUpdate")};function N(){}N.prototype=x.prototype;function S(F,Y,J){this.props=F,this.context=Y,this.refs=b,this.updater=J||v}var _=S.prototype=new N;_.constructor=S,k(_,x.prototype),_.isPureReactComponent=!0;var E=Array.isArray,T=Object.prototype.hasOwnProperty,A={current:null},R={key:!0,ref:!0,__self:!0,__source:!0};function B(F,Y,J){var V,G={},K=null,Z=null;if(Y!=null)for(V in Y.ref!==void 0&&(Z=Y.ref),Y.key!==void 0&&(K=""+Y.key),Y)T.call(Y,V)&&!R.hasOwnProperty(V)&&(G[V]=Y[V]);var ee=arguments.length-2;if(ee===1)G.children=J;else if(1<ee){for(var re=Array(ee),ue=0;ue<ee;ue++)re[ue]=arguments[ue+2];G.children=re}if(F&&F.defaultProps)for(V in ee=F.defaultProps,ee)G[V]===void 0&&(G[V]=ee[V]);return{$$typeof:e,type:F,key:K,ref:Z,props:G,_owner:A.current}}function P(F,Y){return{$$typeof:e,type:F.type,key:Y,ref:F.ref,props:F.props,_owner:F._owner}}function D(F){return typeof F=="object"&&F!==null&&F.$$typeof===e}function O(F){var Y={"=":"=0",":":"=2"};return"$"+F.replace(/[=:]/g,function(J){return Y[J]})}var L=/\/+/g;function z(F,Y){return typeof F=="object"&&F!==null&&F.key!=null?O(""+F.key):Y.toString(36)}function M(F,Y,J,V,G){var K=typeof F;(K==="undefined"||K==="boolean")&&(F=null);var Z=!1;if(F===null)Z=!0;else switch(K){case"string":case"number":Z=!0;break;case"object":switch(F.$$typeof){case e:case t:Z=!0}}if(Z)return Z=F,G=G(Z),F=V===""?"."+z(Z,0):V,E(G)?(J="",F!=null&&(J=F.replace(L,"$&/")+"/"),M(G,Y,J,"",function(ue){return ue})):G!=null&&(D(G)&&(G=P(G,J+(!G.key||Z&&Z.key===G.key?"":(""+G.key).replace(L,"$&/")+"/")+F)),Y.push(G)),1;if(Z=0,V=V===""?".":V+":",E(F))for(var ee=0;ee<F.length;ee++){K=F[ee];var re=V+z(K,ee);Z+=M(K,Y,J,re,G)}else if(re=g(F),typeof re=="function")for(F=re.call(F),ee=0;!(K=F.next()).done;)K=K.value,re=V+z(K,ee++),Z+=M(K,Y,J,re,G);else if(K==="object")throw Y=String(F),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(F).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.");return Z}function $(F,Y,J){if(F==null)return F;var V=[],G=0;return M(F,V,"","",function(K){return Y.call(J,K,G++)}),V}function q(F){if(F._status===-1){var Y=F._result;Y=Y(),Y.then(function(J){(F._status===0||F._status===-1)&&(F._status=1,F._result=J)},function(J){(F._status===0||F._status===-1)&&(F._status=2,F._result=J)}),F._status===-1&&(F._status=0,F._result=Y)}if(F._status===1)return F._result.default;throw F._result}var X={current:null},H={transition:null},I={ReactCurrentDispatcher:X,ReactCurrentBatchConfig:H,ReactCurrentOwner:A};function W(){throw Error("act(...) is not supported in production builds of React.")}return Pe.Children={map:$,forEach:function(F,Y,J){$(F,function(){Y.apply(this,arguments)},J)},count:function(F){var Y=0;return $(F,function(){Y++}),Y},toArray:function(F){return $(F,function(Y){return Y})||[]},only:function(F){if(!D(F))throw Error("React.Children.only expected to receive a single React element child.");return F}},Pe.Component=x,Pe.Fragment=n,Pe.Profiler=s,Pe.PureComponent=S,Pe.StrictMode=r,Pe.Suspense=d,Pe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=I,Pe.act=W,Pe.cloneElement=function(F,Y,J){if(F==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+F+".");var V=k({},F.props),G=F.key,K=F.ref,Z=F._owner;if(Y!=null){if(Y.ref!==void 0&&(K=Y.ref,Z=A.current),Y.key!==void 0&&(G=""+Y.key),F.type&&F.type.defaultProps)var ee=F.type.defaultProps;for(re in Y)T.call(Y,re)&&!R.hasOwnProperty(re)&&(V[re]=Y[re]===void 0&&ee!==void 0?ee[re]:Y[re])}var re=arguments.length-2;if(re===1)V.children=J;else if(1<re){ee=Array(re);for(var ue=0;ue<re;ue++)ee[ue]=arguments[ue+2];V.children=ee}return{$$typeof:e,type:F.type,key:G,ref:K,props:V,_owner:Z}},Pe.createContext=function(F){return F={$$typeof:l,_currentValue:F,_currentValue2:F,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},F.Provider={$$typeof:o,_context:F},F.Consumer=F},Pe.createElement=B,Pe.createFactory=function(F){var Y=B.bind(null,F);return Y.type=F,Y},Pe.createRef=function(){return{current:null}},Pe.forwardRef=function(F){return{$$typeof:u,render:F}},Pe.isValidElement=D,Pe.lazy=function(F){return{$$typeof:f,_payload:{_status:-1,_result:F},_init:q}},Pe.memo=function(F,Y){return{$$typeof:h,type:F,compare:Y===void 0?null:Y}},Pe.startTransition=function(F){var Y=H.transition;H.transition={};try{F()}finally{H.transition=Y}},Pe.unstable_act=W,Pe.useCallback=function(F,Y){return X.current.useCallback(F,Y)},Pe.useContext=function(F){return X.current.useContext(F)},Pe.useDebugValue=function(){},Pe.useDeferredValue=function(F){return X.current.useDeferredValue(F)},Pe.useEffect=function(F,Y){return X.current.useEffect(F,Y)},Pe.useId=function(){return X.current.useId()},Pe.useImperativeHandle=function(F,Y,J){return X.current.useImperativeHandle(F,Y,J)},Pe.useInsertionEffect=function(F,Y){return X.current.useInsertionEffect(F,Y)},Pe.useLayoutEffect=function(F,Y){return X.current.useLayoutEffect(F,Y)},Pe.useMemo=function(F,Y){return X.current.useMemo(F,Y)},Pe.useReducer=function(F,Y,J){return X.current.useReducer(F,Y,J)},Pe.useRef=function(F){return X.current.useRef(F)},Pe.useState=function(F){return X.current.useState(F)},Pe.useSyncExternalStore=function(F,Y,J){return X.current.useSyncExternalStore(F,Y,J)},Pe.useTransition=function(){return X.current.useTransition()},Pe.version="18.3.1",Pe}var W1;function Xl(){return W1||(W1=1,Wf.exports=ZP()),Wf.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 H1;function JP(){if(H1)return cl;H1=1;var e=Xl(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,s=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function l(u,d,h){var f,p={},g=null,v=null;h!==void 0&&(g=""+h),d.key!==void 0&&(g=""+d.key),d.ref!==void 0&&(v=d.ref);for(f in d)r.call(d,f)&&!o.hasOwnProperty(f)&&(p[f]=d[f]);if(u&&u.defaultProps)for(f in d=u.defaultProps,d)p[f]===void 0&&(p[f]=d[f]);return{$$typeof:t,type:u,key:g,ref:v,props:p,_owner:s.current}}return cl.Fragment=n,cl.jsx=l,cl.jsxs=l,cl}var V1;function QP(){return V1||(V1=1,zf.exports=JP()),zf.exports}var a=QP(),cu={},Hf={exports:{}},ln={},Vf={exports:{}},Gf={};/**
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 G1;function e3(){return G1||(G1=1,(function(e){function t(H,I){var W=H.length;H.push(I);e:for(;0<W;){var F=W-1>>>1,Y=H[F];if(0<s(Y,I))H[F]=I,H[W]=Y,W=F;else break e}}function n(H){return H.length===0?null:H[0]}function r(H){if(H.length===0)return null;var I=H[0],W=H.pop();if(W!==I){H[0]=W;e:for(var F=0,Y=H.length,J=Y>>>1;F<J;){var V=2*(F+1)-1,G=H[V],K=V+1,Z=H[K];if(0>s(G,W))K<Y&&0>s(Z,G)?(H[F]=Z,H[K]=W,F=K):(H[F]=G,H[V]=W,F=V);else if(K<Y&&0>s(Z,W))H[F]=Z,H[K]=W,F=K;else break e}}return I}function s(H,I){var W=H.sortIndex-I.sortIndex;return W!==0?W:H.id-I.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var l=Date,u=l.now();e.unstable_now=function(){return l.now()-u}}var d=[],h=[],f=1,p=null,g=3,v=!1,k=!1,b=!1,x=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function _(H){for(var I=n(h);I!==null;){if(I.callback===null)r(h);else if(I.startTime<=H)r(h),I.sortIndex=I.expirationTime,t(d,I);else break;I=n(h)}}function E(H){if(b=!1,_(H),!k)if(n(d)!==null)k=!0,q(T);else{var I=n(h);I!==null&&X(E,I.startTime-H)}}function T(H,I){k=!1,b&&(b=!1,N(B),B=-1),v=!0;var W=g;try{for(_(I),p=n(d);p!==null&&(!(p.expirationTime>I)||H&&!O());){var F=p.callback;if(typeof F=="function"){p.callback=null,g=p.priorityLevel;var Y=F(p.expirationTime<=I);I=e.unstable_now(),typeof Y=="function"?p.callback=Y:p===n(d)&&r(d),_(I)}else r(d);p=n(d)}if(p!==null)var J=!0;else{var V=n(h);V!==null&&X(E,V.startTime-I),J=!1}return J}finally{p=null,g=W,v=!1}}var A=!1,R=null,B=-1,P=5,D=-1;function O(){return!(e.unstable_now()-D<P)}function L(){if(R!==null){var H=e.unstable_now();D=H;var I=!0;try{I=R(!0,H)}finally{I?z():(A=!1,R=null)}}else A=!1}var z;if(typeof S=="function")z=function(){S(L)};else if(typeof MessageChannel<"u"){var M=new MessageChannel,$=M.port2;M.port1.onmessage=L,z=function(){$.postMessage(null)}}else z=function(){x(L,0)};function q(H){R=H,A||(A=!0,z())}function X(H,I){B=x(function(){H(e.unstable_now())},I)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(H){H.callback=null},e.unstable_continueExecution=function(){k||v||(k=!0,q(T))},e.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):P=0<H?Math.floor(1e3/H):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(H){switch(g){case 1:case 2:case 3:var I=3;break;default:I=g}var W=g;g=I;try{return H()}finally{g=W}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(H,I){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var W=g;g=H;try{return I()}finally{g=W}},e.unstable_scheduleCallback=function(H,I,W){var F=e.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?F+W:F):W=F,H){case 1:var Y=-1;break;case 2:Y=250;break;case 5:Y=1073741823;break;case 4:Y=1e4;break;default:Y=5e3}return Y=W+Y,H={id:f++,callback:I,priorityLevel:H,startTime:W,expirationTime:Y,sortIndex:-1},W>F?(H.sortIndex=W,t(h,H),n(d)===null&&H===n(h)&&(b?(N(B),B=-1):b=!0,X(E,W-F))):(H.sortIndex=Y,t(d,H),k||v||(k=!0,q(T))),H},e.unstable_shouldYield=O,e.unstable_wrapCallback=function(H){var I=g;return function(){var W=g;g=I;try{return H.apply(this,arguments)}finally{g=W}}}})(Gf)),Gf}var K1;function t3(){return K1||(K1=1,Vf.exports=e3()),Vf.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 Y1;function n3(){if(Y1)return ln;Y1=1;var e=Xl(),t=t3();function n(i){for(var c="https://reactjs.org/docs/error-decoder.html?invariant="+i,m=1;m<arguments.length;m++)c+="&args[]="+encodeURIComponent(arguments[m]);return"Minified React error #"+i+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,s={};function o(i,c){l(i,c),l(i+"Capture",c)}function l(i,c){for(s[i]=c,i=0;i<c.length;i++)r.add(c[i])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),d=Object.prototype.hasOwnProperty,h=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},p={};function g(i){return d.call(p,i)?!0:d.call(f,i)?!1:h.test(i)?p[i]=!0:(f[i]=!0,!1)}function v(i,c,m,y){if(m!==null&&m.type===0)return!1;switch(typeof c){case"function":case"symbol":return!0;case"boolean":return y?!1:m!==null?!m.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function k(i,c,m,y){if(c===null||typeof c>"u"||v(i,c,m,y))return!0;if(y)return!1;if(m!==null)switch(m.type){case 3:return!c;case 4:return c===!1;case 5:return isNaN(c);case 6:return isNaN(c)||1>c}return!1}function b(i,c,m,y,j,C,U){this.acceptsBooleans=c===2||c===3||c===4,this.attributeName=y,this.attributeNamespace=j,this.mustUseProperty=m,this.propertyName=i,this.type=c,this.sanitizeURL=C,this.removeEmptyString=U}var x={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){x[i]=new b(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var c=i[0];x[c]=new b(c,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){x[i]=new b(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){x[i]=new b(i,2,!1,i,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(i){x[i]=new b(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){x[i]=new b(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){x[i]=new b(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){x[i]=new b(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){x[i]=new b(i,5,!1,i.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function S(i){return i[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(i){var c=i.replace(N,S);x[c]=new b(c,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var c=i.replace(N,S);x[c]=new b(c,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var c=i.replace(N,S);x[c]=new b(c,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){x[i]=new b(i,1,!1,i.toLowerCase(),null,!1,!1)}),x.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){x[i]=new b(i,1,!1,i.toLowerCase(),null,!0,!0)});function _(i,c,m,y){var j=x.hasOwnProperty(c)?x[c]:null;(j!==null?j.type!==0:y||!(2<c.length)||c[0]!=="o"&&c[0]!=="O"||c[1]!=="n"&&c[1]!=="N")&&(k(c,m,j,y)&&(m=null),y||j===null?g(c)&&(m===null?i.removeAttribute(c):i.setAttribute(c,""+m)):j.mustUseProperty?i[j.propertyName]=m===null?j.type===3?!1:"":m:(c=j.attributeName,y=j.attributeNamespace,m===null?i.removeAttribute(c):(j=j.type,m=j===3||j===4&&m===!0?"":""+m,y?i.setAttributeNS(y,c,m):i.setAttribute(c,m))))}var E=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,T=Symbol.for("react.element"),A=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),B=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),D=Symbol.for("react.provider"),O=Symbol.for("react.context"),L=Symbol.for("react.forward_ref"),z=Symbol.for("react.suspense"),M=Symbol.for("react.suspense_list"),$=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),X=Symbol.for("react.offscreen"),H=Symbol.iterator;function I(i){return i===null||typeof i!="object"?null:(i=H&&i[H]||i["@@iterator"],typeof i=="function"?i:null)}var W=Object.assign,F;function Y(i){if(F===void 0)try{throw Error()}catch(m){var c=m.stack.trim().match(/\n( *(at )?)/);F=c&&c[1]||""}return`
34
+ `+F+i}var J=!1;function V(i,c){if(!i||J)return"";J=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(c)if(c=function(){throw Error()},Object.defineProperty(c.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(c,[])}catch(ce){var y=ce}Reflect.construct(i,[],c)}else{try{c.call()}catch(ce){y=ce}i.call(c.prototype)}else{try{throw Error()}catch(ce){y=ce}i()}}catch(ce){if(ce&&y&&typeof ce.stack=="string"){for(var j=ce.stack.split(`
35
+ `),C=y.stack.split(`
36
+ `),U=j.length-1,Q=C.length-1;1<=U&&0<=Q&&j[U]!==C[Q];)Q--;for(;1<=U&&0<=Q;U--,Q--)if(j[U]!==C[Q]){if(U!==1||Q!==1)do if(U--,Q--,0>Q||j[U]!==C[Q]){var te=`
37
+ `+j[U].replace(" at new "," at ");return i.displayName&&te.includes("<anonymous>")&&(te=te.replace("<anonymous>",i.displayName)),te}while(1<=U&&0<=Q);break}}}finally{J=!1,Error.prepareStackTrace=m}return(i=i?i.displayName||i.name:"")?Y(i):""}function G(i){switch(i.tag){case 5:return Y(i.type);case 16:return Y("Lazy");case 13:return Y("Suspense");case 19:return Y("SuspenseList");case 0:case 2:case 15:return i=V(i.type,!1),i;case 11:return i=V(i.type.render,!1),i;case 1:return i=V(i.type,!0),i;default:return""}}function K(i){if(i==null)return null;if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case R:return"Fragment";case A:return"Portal";case P:return"Profiler";case B:return"StrictMode";case z:return"Suspense";case M:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case O:return(i.displayName||"Context")+".Consumer";case D:return(i._context.displayName||"Context")+".Provider";case L:var c=i.render;return i=i.displayName,i||(i=c.displayName||c.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case $:return c=i.displayName||null,c!==null?c:K(i.type)||"Memo";case q:c=i._payload,i=i._init;try{return K(i(c))}catch{}}return null}function Z(i){var c=i.type;switch(i.tag){case 24:return"Cache";case 9:return(c.displayName||"Context")+".Consumer";case 10:return(c._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return i=c.render,i=i.displayName||i.name||"",c.displayName||(i!==""?"ForwardRef("+i+")":"ForwardRef");case 7:return"Fragment";case 5:return c;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return K(c);case 8:return c===B?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof c=="function")return c.displayName||c.name||null;if(typeof c=="string")return c}return null}function ee(i){switch(typeof i){case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function re(i){var c=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(c==="checkbox"||c==="radio")}function ue(i){var c=re(i)?"checked":"value",m=Object.getOwnPropertyDescriptor(i.constructor.prototype,c),y=""+i[c];if(!i.hasOwnProperty(c)&&typeof m<"u"&&typeof m.get=="function"&&typeof m.set=="function"){var j=m.get,C=m.set;return Object.defineProperty(i,c,{configurable:!0,get:function(){return j.call(this)},set:function(U){y=""+U,C.call(this,U)}}),Object.defineProperty(i,c,{enumerable:m.enumerable}),{getValue:function(){return y},setValue:function(U){y=""+U},stopTracking:function(){i._valueTracker=null,delete i[c]}}}}function me(i){i._valueTracker||(i._valueTracker=ue(i))}function ae(i){if(!i)return!1;var c=i._valueTracker;if(!c)return!0;var m=c.getValue(),y="";return i&&(y=re(i)?i.checked?"true":"false":i.value),i=y,i!==m?(c.setValue(i),!0):!1}function pe(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}function xe(i,c){var m=c.checked;return W({},c,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:m??i._wrapperState.initialChecked})}function se(i,c){var m=c.defaultValue==null?"":c.defaultValue,y=c.checked!=null?c.checked:c.defaultChecked;m=ee(c.value!=null?c.value:m),i._wrapperState={initialChecked:y,initialValue:m,controlled:c.type==="checkbox"||c.type==="radio"?c.checked!=null:c.value!=null}}function ve(i,c){c=c.checked,c!=null&&_(i,"checked",c,!1)}function fe(i,c){ve(i,c);var m=ee(c.value),y=c.type;if(m!=null)y==="number"?(m===0&&i.value===""||i.value!=m)&&(i.value=""+m):i.value!==""+m&&(i.value=""+m);else if(y==="submit"||y==="reset"){i.removeAttribute("value");return}c.hasOwnProperty("value")?_e(i,c.type,m):c.hasOwnProperty("defaultValue")&&_e(i,c.type,ee(c.defaultValue)),c.checked==null&&c.defaultChecked!=null&&(i.defaultChecked=!!c.defaultChecked)}function he(i,c,m){if(c.hasOwnProperty("value")||c.hasOwnProperty("defaultValue")){var y=c.type;if(!(y!=="submit"&&y!=="reset"||c.value!==void 0&&c.value!==null))return;c=""+i._wrapperState.initialValue,m||c===i.value||(i.value=c),i.defaultValue=c}m=i.name,m!==""&&(i.name=""),i.defaultChecked=!!i._wrapperState.initialChecked,m!==""&&(i.name=m)}function _e(i,c,m){(c!=="number"||pe(i.ownerDocument)!==i)&&(m==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+m&&(i.defaultValue=""+m))}var Fe=Array.isArray;function Le(i,c,m,y){if(i=i.options,c){c={};for(var j=0;j<m.length;j++)c["$"+m[j]]=!0;for(m=0;m<i.length;m++)j=c.hasOwnProperty("$"+i[m].value),i[m].selected!==j&&(i[m].selected=j),j&&y&&(i[m].defaultSelected=!0)}else{for(m=""+ee(m),c=null,j=0;j<i.length;j++){if(i[j].value===m){i[j].selected=!0,y&&(i[j].defaultSelected=!0);return}c!==null||i[j].disabled||(c=i[j])}c!==null&&(c.selected=!0)}}function Ve(i,c){if(c.dangerouslySetInnerHTML!=null)throw Error(n(91));return W({},c,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function le(i,c){var m=c.value;if(m==null){if(m=c.children,c=c.defaultValue,m!=null){if(c!=null)throw Error(n(92));if(Fe(m)){if(1<m.length)throw Error(n(93));m=m[0]}c=m}c==null&&(c=""),m=c}i._wrapperState={initialValue:ee(m)}}function je(i,c){var m=ee(c.value),y=ee(c.defaultValue);m!=null&&(m=""+m,m!==i.value&&(i.value=m),c.defaultValue==null&&i.defaultValue!==m&&(i.defaultValue=m)),y!=null&&(i.defaultValue=""+y)}function $e(i){var c=i.textContent;c===i._wrapperState.initialValue&&c!==""&&c!==null&&(i.value=c)}function Oe(i){switch(i){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function ze(i,c){return i==null||i==="http://www.w3.org/1999/xhtml"?Oe(c):i==="http://www.w3.org/2000/svg"&&c==="foreignObject"?"http://www.w3.org/1999/xhtml":i}var nt,it=(function(i){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(c,m,y,j){MSApp.execUnsafeLocalFunction(function(){return i(c,m,y,j)})}:i})(function(i,c){if(i.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in i)i.innerHTML=c;else{for(nt=nt||document.createElement("div"),nt.innerHTML="<svg>"+c.valueOf().toString()+"</svg>",c=nt.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;c.firstChild;)i.appendChild(c.firstChild)}});function At(i,c){if(c){var m=i.firstChild;if(m&&m===i.lastChild&&m.nodeType===3){m.nodeValue=c;return}}i.textContent=c}var Ue={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Ze=["Webkit","ms","Moz","O"];Object.keys(Ue).forEach(function(i){Ze.forEach(function(c){c=c+i.charAt(0).toUpperCase()+i.substring(1),Ue[c]=Ue[i]})});function Je(i,c,m){return c==null||typeof c=="boolean"||c===""?"":m||typeof c!="number"||c===0||Ue.hasOwnProperty(i)&&Ue[i]?(""+c).trim():c+"px"}function rt(i,c){i=i.style;for(var m in c)if(c.hasOwnProperty(m)){var y=m.indexOf("--")===0,j=Je(m,c[m],y);m==="float"&&(m="cssFloat"),y?i.setProperty(m,j):i[m]=j}}var gt=W({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Rt(i,c){if(c){if(gt[i]&&(c.children!=null||c.dangerouslySetInnerHTML!=null))throw Error(n(137,i));if(c.dangerouslySetInnerHTML!=null){if(c.children!=null)throw Error(n(60));if(typeof c.dangerouslySetInnerHTML!="object"||!("__html"in c.dangerouslySetInnerHTML))throw Error(n(61))}if(c.style!=null&&typeof c.style!="object")throw Error(n(62))}}function yt(i,c){if(i.indexOf("-")===-1)return typeof c.is=="string";switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var lt=null;function Qt(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Pt=null,Dt=null,Ft=null;function Kt(i){if(i=Ki(i)){if(typeof Pt!="function")throw Error(n(280));var c=i.stateNode;c&&(c=Nc(c),Pt(i.stateNode,i.type,c))}}function qr(i){Dt?Ft?Ft.push(i):Ft=[i]:Dt=i}function Un(){if(Dt){var i=Dt,c=Ft;if(Ft=Dt=null,Kt(i),c)for(i=0;i<c.length;i++)Kt(c[i])}}function Ur(i,c){return i(c)}function zr(){}var zn=!1;function mr(i,c,m){if(zn)return i(c,m);zn=!0;try{return Ur(i,c,m)}finally{zn=!1,(Dt!==null||Ft!==null)&&(zr(),Un())}}function Wn(i,c){var m=i.stateNode;if(m===null)return null;var y=Nc(m);if(y===null)return null;m=y[c];e:switch(c){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(y=!y.disabled)||(i=i.type,y=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!y;break e;default:i=!1}if(i)return null;if(m&&typeof m!="function")throw Error(n(231,c,typeof m));return m}var Wr=!1;if(u)try{var kn={};Object.defineProperty(kn,"passive",{get:function(){Wr=!0}}),window.addEventListener("test",kn,kn),window.removeEventListener("test",kn,kn)}catch{Wr=!1}function ms(i,c,m,y,j,C,U,Q,te){var ce=Array.prototype.slice.call(arguments,3);try{c.apply(m,ce)}catch(ye){this.onError(ye)}}var Nn=!1,gr=null,vt=!1,yr=null,wr={onError:function(i){Nn=!0,gr=i}};function Hr(i,c,m,y,j,C,U,Q,te){Nn=!1,gr=null,ms.apply(wr,arguments)}function Hn(i,c,m,y,j,C,U,Q,te){if(Hr.apply(this,arguments),Nn){if(Nn){var ce=gr;Nn=!1,gr=null}else throw Error(n(198));vt||(vt=!0,yr=ce)}}function fn(i){var c=i,m=i;if(i.alternate)for(;c.return;)c=c.return;else{i=c;do c=i,(c.flags&4098)!==0&&(m=c.return),i=c.return;while(i)}return c.tag===3?m:null}function Vr(i){if(i.tag===13){var c=i.memoizedState;if(c===null&&(i=i.alternate,i!==null&&(c=i.memoizedState)),c!==null)return c.dehydrated}return null}function jn(i){if(fn(i)!==i)throw Error(n(188))}function we(i){var c=i.alternate;if(!c){if(c=fn(i),c===null)throw Error(n(188));return c!==i?null:i}for(var m=i,y=c;;){var j=m.return;if(j===null)break;var C=j.alternate;if(C===null){if(y=j.return,y!==null){m=y;continue}break}if(j.child===C.child){for(C=j.child;C;){if(C===m)return jn(j),i;if(C===y)return jn(j),c;C=C.sibling}throw Error(n(188))}if(m.return!==y.return)m=j,y=C;else{for(var U=!1,Q=j.child;Q;){if(Q===m){U=!0,m=j,y=C;break}if(Q===y){U=!0,y=j,m=C;break}Q=Q.sibling}if(!U){for(Q=C.child;Q;){if(Q===m){U=!0,m=C,y=j;break}if(Q===y){U=!0,y=C,m=j;break}Q=Q.sibling}if(!U)throw Error(n(189))}}if(m.alternate!==y)throw Error(n(190))}if(m.tag!==3)throw Error(n(188));return m.stateNode.current===m?i:c}function Be(i){return i=we(i),i!==null?We(i):null}function We(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var c=We(i);if(c!==null)return c;i=i.sibling}return null}var en=t.unstable_scheduleCallback,gs=t.unstable_cancelCallback,vr=t.unstable_shouldYield,Vn=t.unstable_requestPaint,Qe=t.unstable_now,xr=t.unstable_getCurrentPriorityLevel,Gn=t.unstable_ImmediatePriority,Gr=t.unstable_UserBlockingPriority,Kn=t.unstable_NormalPriority,Ya=t.unstable_LowPriority,Xa=t.unstable_IdlePriority,Kr=null,Yt=null;function ra(i){if(Yt&&typeof Yt.onCommitFiberRoot=="function")try{Yt.onCommitFiberRoot(Kr,i,void 0,(i.current.flags&128)===128)}catch{}}var tn=Math.clz32?Math.clz32:gh,uc=Math.log,Yr=Math.LN2;function gh(i){return i>>>=0,i===0?32:31-(uc(i)/Yr|0)|0}var Za=64,sa=4194304;function ys(i){switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return i&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return i}}function ws(i,c){var m=i.pendingLanes;if(m===0)return 0;var y=0,j=i.suspendedLanes,C=i.pingedLanes,U=m&268435455;if(U!==0){var Q=U&~j;Q!==0?y=ys(Q):(C&=U,C!==0&&(y=ys(C)))}else U=m&~j,U!==0?y=ys(U):C!==0&&(y=ys(C));if(y===0)return 0;if(c!==0&&c!==y&&(c&j)===0&&(j=y&-y,C=c&-c,j>=C||j===16&&(C&4194240)!==0))return c;if((y&4)!==0&&(y|=m&16),c=i.entangledLanes,c!==0)for(i=i.entanglements,c&=y;0<c;)m=31-tn(c),j=1<<m,y|=i[m],c&=~j;return y}function Si(i,c){switch(i){case 1:case 2:case 4:return c+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return c+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Xr(i,c){for(var m=i.suspendedLanes,y=i.pingedLanes,j=i.expirationTimes,C=i.pendingLanes;0<C;){var U=31-tn(C),Q=1<<U,te=j[U];te===-1?((Q&m)===0||(Q&y)!==0)&&(j[U]=Si(Q,c)):te<=c&&(i.expiredLanes|=Q),C&=~Q}}function _i(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function dc(){var i=Za;return Za<<=1,(Za&4194240)===0&&(Za=64),i}function Ei(i){for(var c=[],m=0;31>m;m++)c.push(i);return c}function vs(i,c,m){i.pendingLanes|=c,c!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,c=31-tn(c),i[c]=m}function xs(i,c){var m=i.pendingLanes&~c;i.pendingLanes=c,i.suspendedLanes=0,i.pingedLanes=0,i.expiredLanes&=c,i.mutableReadLanes&=c,i.entangledLanes&=c,c=i.entanglements;var y=i.eventTimes;for(i=i.expirationTimes;0<m;){var j=31-tn(m),C=1<<j;c[j]=0,y[j]=-1,i[j]=-1,m&=~C}}function Ci(i,c){var m=i.entangledLanes|=c;for(i=i.entanglements;m;){var y=31-tn(m),j=1<<y;j&c|i[y]&c&&(i[y]|=c),m&=~j}}var Ge=0;function Ti(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var Ja,Ai,hc,Qa,Ri,Mi=!1,eo=[],br=null,Sn=null,kr=null,bs=new Map,aa=new Map,Nr=[],yh="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 $i(i,c){switch(i){case"focusin":case"focusout":br=null;break;case"dragenter":case"dragleave":Sn=null;break;case"mouseover":case"mouseout":kr=null;break;case"pointerover":case"pointerout":bs.delete(c.pointerId);break;case"gotpointercapture":case"lostpointercapture":aa.delete(c.pointerId)}}function oa(i,c,m,y,j,C){return i===null||i.nativeEvent!==C?(i={blockedOn:c,domEventName:m,eventSystemFlags:y,nativeEvent:C,targetContainers:[j]},c!==null&&(c=Ki(c),c!==null&&Ai(c)),i):(i.eventSystemFlags|=y,c=i.targetContainers,j!==null&&c.indexOf(j)===-1&&c.push(j),i)}function wh(i,c,m,y,j){switch(c){case"focusin":return br=oa(br,i,c,m,y,j),!0;case"dragenter":return Sn=oa(Sn,i,c,m,y,j),!0;case"mouseover":return kr=oa(kr,i,c,m,y,j),!0;case"pointerover":var C=j.pointerId;return bs.set(C,oa(bs.get(C)||null,i,c,m,y,j)),!0;case"gotpointercapture":return C=j.pointerId,aa.set(C,oa(aa.get(C)||null,i,c,m,y,j)),!0}return!1}function Ii(i){var c=da(i.target);if(c!==null){var m=fn(c);if(m!==null){if(c=m.tag,c===13){if(c=Vr(m),c!==null){i.blockedOn=c,Ri(i.priority,function(){hc(m)});return}}else if(c===3&&m.stateNode.current.memoizedState.isDehydrated){i.blockedOn=m.tag===3?m.stateNode.containerInfo:null;return}}}i.blockedOn=null}function jr(i){if(i.blockedOn!==null)return!1;for(var c=i.targetContainers;0<c.length;){var m=Pi(i.domEventName,i.eventSystemFlags,c[0],i.nativeEvent);if(m===null){m=i.nativeEvent;var y=new m.constructor(m.type,m);lt=y,m.target.dispatchEvent(y),lt=null}else return c=Ki(m),c!==null&&Ai(c),i.blockedOn=m,!1;c.shift()}return!0}function Oi(i,c,m){jr(i)&&m.delete(c)}function fc(){Mi=!1,br!==null&&jr(br)&&(br=null),Sn!==null&&jr(Sn)&&(Sn=null),kr!==null&&jr(kr)&&(kr=null),bs.forEach(Oi),aa.forEach(Oi)}function ks(i,c){i.blockedOn===c&&(i.blockedOn=null,Mi||(Mi=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,fc)))}function Ns(i){function c(j){return ks(j,i)}if(0<eo.length){ks(eo[0],i);for(var m=1;m<eo.length;m++){var y=eo[m];y.blockedOn===i&&(y.blockedOn=null)}}for(br!==null&&ks(br,i),Sn!==null&&ks(Sn,i),kr!==null&&ks(kr,i),bs.forEach(c),aa.forEach(c),m=0;m<Nr.length;m++)y=Nr[m],y.blockedOn===i&&(y.blockedOn=null);for(;0<Nr.length&&(m=Nr[0],m.blockedOn===null);)Ii(m),m.blockedOn===null&&Nr.shift()}var Zr=E.ReactCurrentBatchConfig,js=!0;function vh(i,c,m,y){var j=Ge,C=Zr.transition;Zr.transition=null;try{Ge=1,to(i,c,m,y)}finally{Ge=j,Zr.transition=C}}function Li(i,c,m,y){var j=Ge,C=Zr.transition;Zr.transition=null;try{Ge=4,to(i,c,m,y)}finally{Ge=j,Zr.transition=C}}function to(i,c,m,y){if(js){var j=Pi(i,c,m,y);if(j===null)Mh(i,c,y,ia,m),$i(i,y);else if(wh(j,i,c,m,y))y.stopPropagation();else if($i(i,y),c&4&&-1<yh.indexOf(i)){for(;j!==null;){var C=Ki(j);if(C!==null&&Ja(C),C=Pi(i,c,m,y),C===null&&Mh(i,c,y,ia,m),C===j)break;j=C}j!==null&&y.stopPropagation()}else Mh(i,c,y,null,m)}}var ia=null;function Pi(i,c,m,y){if(ia=null,i=Qt(y),i=da(i),i!==null)if(c=fn(i),c===null)i=null;else if(m=c.tag,m===13){if(i=Vr(c),i!==null)return i;i=null}else if(m===3){if(c.stateNode.current.memoizedState.isDehydrated)return c.tag===3?c.stateNode.containerInfo:null;i=null}else c!==i&&(i=null);return ia=i,null}function pc(i){switch(i){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(xr()){case Gn:return 1;case Gr:return 4;case Kn:case Ya:return 16;case Xa:return 536870912;default:return 16}default:return 16}}var _n=null,Ss=null,no=null;function _s(){if(no)return no;var i,c=Ss,m=c.length,y,j="value"in _n?_n.value:_n.textContent,C=j.length;for(i=0;i<m&&c[i]===j[i];i++);var U=m-i;for(y=1;y<=U&&c[m-y]===j[C-y];y++);return no=j.slice(i,1<y?1-y:void 0)}function ro(i){var c=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&c===13&&(i=13)):i=c,i===10&&(i=13),32<=i||i===13?i:0}function so(){return!0}function mc(){return!1}function zt(i){function c(m,y,j,C,U){this._reactName=m,this._targetInst=j,this.type=y,this.nativeEvent=C,this.target=U,this.currentTarget=null;for(var Q in i)i.hasOwnProperty(Q)&&(m=i[Q],this[Q]=m?m(C):C[Q]);return this.isDefaultPrevented=(C.defaultPrevented!=null?C.defaultPrevented:C.returnValue===!1)?so:mc,this.isPropagationStopped=mc,this}return W(c.prototype,{preventDefault:function(){this.defaultPrevented=!0;var m=this.nativeEvent;m&&(m.preventDefault?m.preventDefault():typeof m.returnValue!="unknown"&&(m.returnValue=!1),this.isDefaultPrevented=so)},stopPropagation:function(){var m=this.nativeEvent;m&&(m.stopPropagation?m.stopPropagation():typeof m.cancelBubble!="unknown"&&(m.cancelBubble=!0),this.isPropagationStopped=so)},persist:function(){},isPersistent:so}),c}var Es={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Di=zt(Es),Cs=W({},Es,{view:0,detail:0}),la=zt(Cs),ao,ca,ua,Sr=W({},Cs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:bh,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==ua&&(ua&&i.type==="mousemove"?(ao=i.screenX-ua.screenX,ca=i.screenY-ua.screenY):ca=ao=0,ua=i),ao)},movementY:function(i){return"movementY"in i?i.movementY:ca}}),R0=zt(Sr),NL=W({},Sr,{dataTransfer:0}),jL=zt(NL),SL=W({},Cs,{relatedTarget:0}),xh=zt(SL),_L=W({},Es,{animationName:0,elapsedTime:0,pseudoElement:0}),EL=zt(_L),CL=W({},Es,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),TL=zt(CL),AL=W({},Es,{data:0}),M0=zt(AL),RL={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ML={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"},$L={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function IL(i){var c=this.nativeEvent;return c.getModifierState?c.getModifierState(i):(i=$L[i])?!!c[i]:!1}function bh(){return IL}var OL=W({},Cs,{key:function(i){if(i.key){var c=RL[i.key]||i.key;if(c!=="Unidentified")return c}return i.type==="keypress"?(i=ro(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?ML[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:bh,charCode:function(i){return i.type==="keypress"?ro(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?ro(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),LL=zt(OL),PL=W({},Sr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),$0=zt(PL),DL=W({},Cs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:bh}),FL=zt(DL),BL=W({},Es,{propertyName:0,elapsedTime:0,pseudoElement:0}),qL=zt(BL),UL=W({},Sr,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),zL=zt(UL),WL=[9,13,27,32],kh=u&&"CompositionEvent"in window,Fi=null;u&&"documentMode"in document&&(Fi=document.documentMode);var HL=u&&"TextEvent"in window&&!Fi,I0=u&&(!kh||Fi&&8<Fi&&11>=Fi),O0=" ",L0=!1;function P0(i,c){switch(i){case"keyup":return WL.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function D0(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var oo=!1;function VL(i,c){switch(i){case"compositionend":return D0(c);case"keypress":return c.which!==32?null:(L0=!0,O0);case"textInput":return i=c.data,i===O0&&L0?null:i;default:return null}}function GL(i,c){if(oo)return i==="compositionend"||!kh&&P0(i,c)?(i=_s(),no=Ss=_n=null,oo=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(c.ctrlKey||c.altKey||c.metaKey)||c.ctrlKey&&c.altKey){if(c.char&&1<c.char.length)return c.char;if(c.which)return String.fromCharCode(c.which)}return null;case"compositionend":return I0&&c.locale!=="ko"?null:c.data;default:return null}}var KL={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 F0(i){var c=i&&i.nodeName&&i.nodeName.toLowerCase();return c==="input"?!!KL[i.type]:c==="textarea"}function B0(i,c,m,y){qr(y),c=xc(c,"onChange"),0<c.length&&(m=new Di("onChange","change",null,m,y),i.push({event:m,listeners:c}))}var Bi=null,qi=null;function YL(i){sk(i,0)}function gc(i){var c=ho(i);if(ae(c))return i}function XL(i,c){if(i==="change")return c}var q0=!1;if(u){var Nh;if(u){var jh="oninput"in document;if(!jh){var U0=document.createElement("div");U0.setAttribute("oninput","return;"),jh=typeof U0.oninput=="function"}Nh=jh}else Nh=!1;q0=Nh&&(!document.documentMode||9<document.documentMode)}function z0(){Bi&&(Bi.detachEvent("onpropertychange",W0),qi=Bi=null)}function W0(i){if(i.propertyName==="value"&&gc(qi)){var c=[];B0(c,qi,i,Qt(i)),mr(YL,c)}}function ZL(i,c,m){i==="focusin"?(z0(),Bi=c,qi=m,Bi.attachEvent("onpropertychange",W0)):i==="focusout"&&z0()}function JL(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return gc(qi)}function QL(i,c){if(i==="click")return gc(c)}function eP(i,c){if(i==="input"||i==="change")return gc(c)}function tP(i,c){return i===c&&(i!==0||1/i===1/c)||i!==i&&c!==c}var Yn=typeof Object.is=="function"?Object.is:tP;function Ui(i,c){if(Yn(i,c))return!0;if(typeof i!="object"||i===null||typeof c!="object"||c===null)return!1;var m=Object.keys(i),y=Object.keys(c);if(m.length!==y.length)return!1;for(y=0;y<m.length;y++){var j=m[y];if(!d.call(c,j)||!Yn(i[j],c[j]))return!1}return!0}function H0(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function V0(i,c){var m=H0(i);i=0;for(var y;m;){if(m.nodeType===3){if(y=i+m.textContent.length,i<=c&&y>=c)return{node:m,offset:c-i};i=y}e:{for(;m;){if(m.nextSibling){m=m.nextSibling;break e}m=m.parentNode}m=void 0}m=H0(m)}}function G0(i,c){return i&&c?i===c?!0:i&&i.nodeType===3?!1:c&&c.nodeType===3?G0(i,c.parentNode):"contains"in i?i.contains(c):i.compareDocumentPosition?!!(i.compareDocumentPosition(c)&16):!1:!1}function K0(){for(var i=window,c=pe();c instanceof i.HTMLIFrameElement;){try{var m=typeof c.contentWindow.location.href=="string"}catch{m=!1}if(m)i=c.contentWindow;else break;c=pe(i.document)}return c}function Sh(i){var c=i&&i.nodeName&&i.nodeName.toLowerCase();return c&&(c==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||c==="textarea"||i.contentEditable==="true")}function nP(i){var c=K0(),m=i.focusedElem,y=i.selectionRange;if(c!==m&&m&&m.ownerDocument&&G0(m.ownerDocument.documentElement,m)){if(y!==null&&Sh(m)){if(c=y.start,i=y.end,i===void 0&&(i=c),"selectionStart"in m)m.selectionStart=c,m.selectionEnd=Math.min(i,m.value.length);else if(i=(c=m.ownerDocument||document)&&c.defaultView||window,i.getSelection){i=i.getSelection();var j=m.textContent.length,C=Math.min(y.start,j);y=y.end===void 0?C:Math.min(y.end,j),!i.extend&&C>y&&(j=y,y=C,C=j),j=V0(m,C);var U=V0(m,y);j&&U&&(i.rangeCount!==1||i.anchorNode!==j.node||i.anchorOffset!==j.offset||i.focusNode!==U.node||i.focusOffset!==U.offset)&&(c=c.createRange(),c.setStart(j.node,j.offset),i.removeAllRanges(),C>y?(i.addRange(c),i.extend(U.node,U.offset)):(c.setEnd(U.node,U.offset),i.addRange(c)))}}for(c=[],i=m;i=i.parentNode;)i.nodeType===1&&c.push({element:i,left:i.scrollLeft,top:i.scrollTop});for(typeof m.focus=="function"&&m.focus(),m=0;m<c.length;m++)i=c[m],i.element.scrollLeft=i.left,i.element.scrollTop=i.top}}var rP=u&&"documentMode"in document&&11>=document.documentMode,io=null,_h=null,zi=null,Eh=!1;function Y0(i,c,m){var y=m.window===m?m.document:m.nodeType===9?m:m.ownerDocument;Eh||io==null||io!==pe(y)||(y=io,"selectionStart"in y&&Sh(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}),zi&&Ui(zi,y)||(zi=y,y=xc(_h,"onSelect"),0<y.length&&(c=new Di("onSelect","select",null,c,m),i.push({event:c,listeners:y}),c.target=io)))}function yc(i,c){var m={};return m[i.toLowerCase()]=c.toLowerCase(),m["Webkit"+i]="webkit"+c,m["Moz"+i]="moz"+c,m}var lo={animationend:yc("Animation","AnimationEnd"),animationiteration:yc("Animation","AnimationIteration"),animationstart:yc("Animation","AnimationStart"),transitionend:yc("Transition","TransitionEnd")},Ch={},X0={};u&&(X0=document.createElement("div").style,"AnimationEvent"in window||(delete lo.animationend.animation,delete lo.animationiteration.animation,delete lo.animationstart.animation),"TransitionEvent"in window||delete lo.transitionend.transition);function wc(i){if(Ch[i])return Ch[i];if(!lo[i])return i;var c=lo[i],m;for(m in c)if(c.hasOwnProperty(m)&&m in X0)return Ch[i]=c[m];return i}var Z0=wc("animationend"),J0=wc("animationiteration"),Q0=wc("animationstart"),ek=wc("transitionend"),tk=new Map,nk="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(i,c){tk.set(i,c),o(c,[i])}for(var Th=0;Th<nk.length;Th++){var Ah=nk[Th],sP=Ah.toLowerCase(),aP=Ah[0].toUpperCase()+Ah.slice(1);Ts(sP,"on"+aP)}Ts(Z0,"onAnimationEnd"),Ts(J0,"onAnimationIteration"),Ts(Q0,"onAnimationStart"),Ts("dblclick","onDoubleClick"),Ts("focusin","onFocus"),Ts("focusout","onBlur"),Ts(ek,"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 Wi="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(" "),oP=new Set("cancel close invalid load scroll toggle".split(" ").concat(Wi));function rk(i,c,m){var y=i.type||"unknown-event";i.currentTarget=m,Hn(y,c,void 0,i),i.currentTarget=null}function sk(i,c){c=(c&4)!==0;for(var m=0;m<i.length;m++){var y=i[m],j=y.event;y=y.listeners;e:{var C=void 0;if(c)for(var U=y.length-1;0<=U;U--){var Q=y[U],te=Q.instance,ce=Q.currentTarget;if(Q=Q.listener,te!==C&&j.isPropagationStopped())break e;rk(j,Q,ce),C=te}else for(U=0;U<y.length;U++){if(Q=y[U],te=Q.instance,ce=Q.currentTarget,Q=Q.listener,te!==C&&j.isPropagationStopped())break e;rk(j,Q,ce),C=te}}}if(vt)throw i=yr,vt=!1,yr=null,i}function st(i,c){var m=c[Dh];m===void 0&&(m=c[Dh]=new Set);var y=i+"__bubble";m.has(y)||(ak(c,i,2,!1),m.add(y))}function Rh(i,c,m){var y=0;c&&(y|=4),ak(m,i,y,c)}var vc="_reactListening"+Math.random().toString(36).slice(2);function Hi(i){if(!i[vc]){i[vc]=!0,r.forEach(function(m){m!=="selectionchange"&&(oP.has(m)||Rh(m,!1,i),Rh(m,!0,i))});var c=i.nodeType===9?i:i.ownerDocument;c===null||c[vc]||(c[vc]=!0,Rh("selectionchange",!1,c))}}function ak(i,c,m,y){switch(pc(c)){case 1:var j=vh;break;case 4:j=Li;break;default:j=to}m=j.bind(null,c,m,i),j=void 0,!Wr||c!=="touchstart"&&c!=="touchmove"&&c!=="wheel"||(j=!0),y?j!==void 0?i.addEventListener(c,m,{capture:!0,passive:j}):i.addEventListener(c,m,!0):j!==void 0?i.addEventListener(c,m,{passive:j}):i.addEventListener(c,m,!1)}function Mh(i,c,m,y,j){var C=y;if((c&1)===0&&(c&2)===0&&y!==null)e:for(;;){if(y===null)return;var U=y.tag;if(U===3||U===4){var Q=y.stateNode.containerInfo;if(Q===j||Q.nodeType===8&&Q.parentNode===j)break;if(U===4)for(U=y.return;U!==null;){var te=U.tag;if((te===3||te===4)&&(te=U.stateNode.containerInfo,te===j||te.nodeType===8&&te.parentNode===j))return;U=U.return}for(;Q!==null;){if(U=da(Q),U===null)return;if(te=U.tag,te===5||te===6){y=C=U;continue e}Q=Q.parentNode}}y=y.return}mr(function(){var ce=C,ye=Qt(m),be=[];e:{var ge=tk.get(i);if(ge!==void 0){var Ne=Di,Ee=i;switch(i){case"keypress":if(ro(m)===0)break e;case"keydown":case"keyup":Ne=LL;break;case"focusin":Ee="focus",Ne=xh;break;case"focusout":Ee="blur",Ne=xh;break;case"beforeblur":case"afterblur":Ne=xh;break;case"click":if(m.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ne=R0;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ne=jL;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ne=FL;break;case Z0:case J0:case Q0:Ne=EL;break;case ek:Ne=qL;break;case"scroll":Ne=la;break;case"wheel":Ne=zL;break;case"copy":case"cut":case"paste":Ne=TL;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ne=$0}var Ce=(c&4)!==0,wt=!Ce&&i==="scroll",oe=Ce?ge!==null?ge+"Capture":null:ge;Ce=[];for(var ne=ce,ie;ne!==null;){ie=ne;var ke=ie.stateNode;if(ie.tag===5&&ke!==null&&(ie=ke,oe!==null&&(ke=Wn(ne,oe),ke!=null&&Ce.push(Vi(ne,ke,ie)))),wt)break;ne=ne.return}0<Ce.length&&(ge=new Ne(ge,Ee,null,m,ye),be.push({event:ge,listeners:Ce}))}}if((c&7)===0){e:{if(ge=i==="mouseover"||i==="pointerover",Ne=i==="mouseout"||i==="pointerout",ge&&m!==lt&&(Ee=m.relatedTarget||m.fromElement)&&(da(Ee)||Ee[Jr]))break e;if((Ne||ge)&&(ge=ye.window===ye?ye:(ge=ye.ownerDocument)?ge.defaultView||ge.parentWindow:window,Ne?(Ee=m.relatedTarget||m.toElement,Ne=ce,Ee=Ee?da(Ee):null,Ee!==null&&(wt=fn(Ee),Ee!==wt||Ee.tag!==5&&Ee.tag!==6)&&(Ee=null)):(Ne=null,Ee=ce),Ne!==Ee)){if(Ce=R0,ke="onMouseLeave",oe="onMouseEnter",ne="mouse",(i==="pointerout"||i==="pointerover")&&(Ce=$0,ke="onPointerLeave",oe="onPointerEnter",ne="pointer"),wt=Ne==null?ge:ho(Ne),ie=Ee==null?ge:ho(Ee),ge=new Ce(ke,ne+"leave",Ne,m,ye),ge.target=wt,ge.relatedTarget=ie,ke=null,da(ye)===ce&&(Ce=new Ce(oe,ne+"enter",Ee,m,ye),Ce.target=ie,Ce.relatedTarget=wt,ke=Ce),wt=ke,Ne&&Ee)t:{for(Ce=Ne,oe=Ee,ne=0,ie=Ce;ie;ie=co(ie))ne++;for(ie=0,ke=oe;ke;ke=co(ke))ie++;for(;0<ne-ie;)Ce=co(Ce),ne--;for(;0<ie-ne;)oe=co(oe),ie--;for(;ne--;){if(Ce===oe||oe!==null&&Ce===oe.alternate)break t;Ce=co(Ce),oe=co(oe)}Ce=null}else Ce=null;Ne!==null&&ok(be,ge,Ne,Ce,!1),Ee!==null&&wt!==null&&ok(be,wt,Ee,Ce,!0)}}e:{if(ge=ce?ho(ce):window,Ne=ge.nodeName&&ge.nodeName.toLowerCase(),Ne==="select"||Ne==="input"&&ge.type==="file")var Te=XL;else if(F0(ge))if(q0)Te=eP;else{Te=JL;var Re=ZL}else(Ne=ge.nodeName)&&Ne.toLowerCase()==="input"&&(ge.type==="checkbox"||ge.type==="radio")&&(Te=QL);if(Te&&(Te=Te(i,ce))){B0(be,Te,m,ye);break e}Re&&Re(i,ge,ce),i==="focusout"&&(Re=ge._wrapperState)&&Re.controlled&&ge.type==="number"&&_e(ge,"number",ge.value)}switch(Re=ce?ho(ce):window,i){case"focusin":(F0(Re)||Re.contentEditable==="true")&&(io=Re,_h=ce,zi=null);break;case"focusout":zi=_h=io=null;break;case"mousedown":Eh=!0;break;case"contextmenu":case"mouseup":case"dragend":Eh=!1,Y0(be,m,ye);break;case"selectionchange":if(rP)break;case"keydown":case"keyup":Y0(be,m,ye)}var Me;if(kh)e:{switch(i){case"compositionstart":var Ie="onCompositionStart";break e;case"compositionend":Ie="onCompositionEnd";break e;case"compositionupdate":Ie="onCompositionUpdate";break e}Ie=void 0}else oo?P0(i,m)&&(Ie="onCompositionEnd"):i==="keydown"&&m.keyCode===229&&(Ie="onCompositionStart");Ie&&(I0&&m.locale!=="ko"&&(oo||Ie!=="onCompositionStart"?Ie==="onCompositionEnd"&&oo&&(Me=_s()):(_n=ye,Ss="value"in _n?_n.value:_n.textContent,oo=!0)),Re=xc(ce,Ie),0<Re.length&&(Ie=new M0(Ie,i,null,m,ye),be.push({event:Ie,listeners:Re}),Me?Ie.data=Me:(Me=D0(m),Me!==null&&(Ie.data=Me)))),(Me=HL?VL(i,m):GL(i,m))&&(ce=xc(ce,"onBeforeInput"),0<ce.length&&(ye=new M0("onBeforeInput","beforeinput",null,m,ye),be.push({event:ye,listeners:ce}),ye.data=Me))}sk(be,c)})}function Vi(i,c,m){return{instance:i,listener:c,currentTarget:m}}function xc(i,c){for(var m=c+"Capture",y=[];i!==null;){var j=i,C=j.stateNode;j.tag===5&&C!==null&&(j=C,C=Wn(i,m),C!=null&&y.unshift(Vi(i,C,j)),C=Wn(i,c),C!=null&&y.push(Vi(i,C,j))),i=i.return}return y}function co(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function ok(i,c,m,y,j){for(var C=c._reactName,U=[];m!==null&&m!==y;){var Q=m,te=Q.alternate,ce=Q.stateNode;if(te!==null&&te===y)break;Q.tag===5&&ce!==null&&(Q=ce,j?(te=Wn(m,C),te!=null&&U.unshift(Vi(m,te,Q))):j||(te=Wn(m,C),te!=null&&U.push(Vi(m,te,Q)))),m=m.return}U.length!==0&&i.push({event:c,listeners:U})}var iP=/\r\n?/g,lP=/\u0000|\uFFFD/g;function ik(i){return(typeof i=="string"?i:""+i).replace(iP,`
38
+ `).replace(lP,"")}function bc(i,c,m){if(c=ik(c),ik(i)!==c&&m)throw Error(n(425))}function kc(){}var $h=null,Ih=null;function Oh(i,c){return i==="textarea"||i==="noscript"||typeof c.children=="string"||typeof c.children=="number"||typeof c.dangerouslySetInnerHTML=="object"&&c.dangerouslySetInnerHTML!==null&&c.dangerouslySetInnerHTML.__html!=null}var Lh=typeof setTimeout=="function"?setTimeout:void 0,cP=typeof clearTimeout=="function"?clearTimeout:void 0,lk=typeof Promise=="function"?Promise:void 0,uP=typeof queueMicrotask=="function"?queueMicrotask:typeof lk<"u"?function(i){return lk.resolve(null).then(i).catch(dP)}:Lh;function dP(i){setTimeout(function(){throw i})}function Ph(i,c){var m=c,y=0;do{var j=m.nextSibling;if(i.removeChild(m),j&&j.nodeType===8)if(m=j.data,m==="/$"){if(y===0){i.removeChild(j),Ns(c);return}y--}else m!=="$"&&m!=="$?"&&m!=="$!"||y++;m=j}while(m);Ns(c)}function As(i){for(;i!=null;i=i.nextSibling){var c=i.nodeType;if(c===1||c===3)break;if(c===8){if(c=i.data,c==="$"||c==="$!"||c==="$?")break;if(c==="/$")return null}}return i}function ck(i){i=i.previousSibling;for(var c=0;i;){if(i.nodeType===8){var m=i.data;if(m==="$"||m==="$!"||m==="$?"){if(c===0)return i;c--}else m==="/$"&&c++}i=i.previousSibling}return null}var uo=Math.random().toString(36).slice(2),_r="__reactFiber$"+uo,Gi="__reactProps$"+uo,Jr="__reactContainer$"+uo,Dh="__reactEvents$"+uo,hP="__reactListeners$"+uo,fP="__reactHandles$"+uo;function da(i){var c=i[_r];if(c)return c;for(var m=i.parentNode;m;){if(c=m[Jr]||m[_r]){if(m=c.alternate,c.child!==null||m!==null&&m.child!==null)for(i=ck(i);i!==null;){if(m=i[_r])return m;i=ck(i)}return c}i=m,m=i.parentNode}return null}function Ki(i){return i=i[_r]||i[Jr],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function ho(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(n(33))}function Nc(i){return i[Gi]||null}var Fh=[],fo=-1;function Rs(i){return{current:i}}function at(i){0>fo||(i.current=Fh[fo],Fh[fo]=null,fo--)}function tt(i,c){fo++,Fh[fo]=i.current,i.current=c}var Ms={},Wt=Rs(Ms),nn=Rs(!1),ha=Ms;function po(i,c){var m=i.type.contextTypes;if(!m)return Ms;var y=i.stateNode;if(y&&y.__reactInternalMemoizedUnmaskedChildContext===c)return y.__reactInternalMemoizedMaskedChildContext;var j={},C;for(C in m)j[C]=c[C];return y&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=c,i.__reactInternalMemoizedMaskedChildContext=j),j}function rn(i){return i=i.childContextTypes,i!=null}function jc(){at(nn),at(Wt)}function uk(i,c,m){if(Wt.current!==Ms)throw Error(n(168));tt(Wt,c),tt(nn,m)}function dk(i,c,m){var y=i.stateNode;if(c=c.childContextTypes,typeof y.getChildContext!="function")return m;y=y.getChildContext();for(var j in y)if(!(j in c))throw Error(n(108,Z(i)||"Unknown",j));return W({},m,y)}function Sc(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||Ms,ha=Wt.current,tt(Wt,i),tt(nn,nn.current),!0}function hk(i,c,m){var y=i.stateNode;if(!y)throw Error(n(169));m?(i=dk(i,c,ha),y.__reactInternalMemoizedMergedChildContext=i,at(nn),at(Wt),tt(Wt,i)):at(nn),tt(nn,m)}var Qr=null,_c=!1,Bh=!1;function fk(i){Qr===null?Qr=[i]:Qr.push(i)}function pP(i){_c=!0,fk(i)}function $s(){if(!Bh&&Qr!==null){Bh=!0;var i=0,c=Ge;try{var m=Qr;for(Ge=1;i<m.length;i++){var y=m[i];do y=y(!0);while(y!==null)}Qr=null,_c=!1}catch(j){throw Qr!==null&&(Qr=Qr.slice(i+1)),en(Gn,$s),j}finally{Ge=c,Bh=!1}}return null}var mo=[],go=0,Ec=null,Cc=0,En=[],Cn=0,fa=null,es=1,ts="";function pa(i,c){mo[go++]=Cc,mo[go++]=Ec,Ec=i,Cc=c}function pk(i,c,m){En[Cn++]=es,En[Cn++]=ts,En[Cn++]=fa,fa=i;var y=es;i=ts;var j=32-tn(y)-1;y&=~(1<<j),m+=1;var C=32-tn(c)+j;if(30<C){var U=j-j%5;C=(y&(1<<U)-1).toString(32),y>>=U,j-=U,es=1<<32-tn(c)+j|m<<j|y,ts=C+i}else es=1<<C|m<<j|y,ts=i}function qh(i){i.return!==null&&(pa(i,1),pk(i,1,0))}function Uh(i){for(;i===Ec;)Ec=mo[--go],mo[go]=null,Cc=mo[--go],mo[go]=null;for(;i===fa;)fa=En[--Cn],En[Cn]=null,ts=En[--Cn],En[Cn]=null,es=En[--Cn],En[Cn]=null}var pn=null,mn=null,ct=!1,Xn=null;function mk(i,c){var m=Mn(5,null,null,0);m.elementType="DELETED",m.stateNode=c,m.return=i,c=i.deletions,c===null?(i.deletions=[m],i.flags|=16):c.push(m)}function gk(i,c){switch(i.tag){case 5:var m=i.type;return c=c.nodeType!==1||m.toLowerCase()!==c.nodeName.toLowerCase()?null:c,c!==null?(i.stateNode=c,pn=i,mn=As(c.firstChild),!0):!1;case 6:return c=i.pendingProps===""||c.nodeType!==3?null:c,c!==null?(i.stateNode=c,pn=i,mn=null,!0):!1;case 13:return c=c.nodeType!==8?null:c,c!==null?(m=fa!==null?{id:es,overflow:ts}:null,i.memoizedState={dehydrated:c,treeContext:m,retryLane:1073741824},m=Mn(18,null,null,0),m.stateNode=c,m.return=i,i.child=m,pn=i,mn=null,!0):!1;default:return!1}}function zh(i){return(i.mode&1)!==0&&(i.flags&128)===0}function Wh(i){if(ct){var c=mn;if(c){var m=c;if(!gk(i,c)){if(zh(i))throw Error(n(418));c=As(m.nextSibling);var y=pn;c&&gk(i,c)?mk(y,m):(i.flags=i.flags&-4097|2,ct=!1,pn=i)}}else{if(zh(i))throw Error(n(418));i.flags=i.flags&-4097|2,ct=!1,pn=i}}}function yk(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;pn=i}function Tc(i){if(i!==pn)return!1;if(!ct)return yk(i),ct=!0,!1;var c;if((c=i.tag!==3)&&!(c=i.tag!==5)&&(c=i.type,c=c!=="head"&&c!=="body"&&!Oh(i.type,i.memoizedProps)),c&&(c=mn)){if(zh(i))throw wk(),Error(n(418));for(;c;)mk(i,c),c=As(c.nextSibling)}if(yk(i),i.tag===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(317));e:{for(i=i.nextSibling,c=0;i;){if(i.nodeType===8){var m=i.data;if(m==="/$"){if(c===0){mn=As(i.nextSibling);break e}c--}else m!=="$"&&m!=="$!"&&m!=="$?"||c++}i=i.nextSibling}mn=null}}else mn=pn?As(i.stateNode.nextSibling):null;return!0}function wk(){for(var i=mn;i;)i=As(i.nextSibling)}function yo(){mn=pn=null,ct=!1}function Hh(i){Xn===null?Xn=[i]:Xn.push(i)}var mP=E.ReactCurrentBatchConfig;function Yi(i,c,m){if(i=m.ref,i!==null&&typeof i!="function"&&typeof i!="object"){if(m._owner){if(m=m._owner,m){if(m.tag!==1)throw Error(n(309));var y=m.stateNode}if(!y)throw Error(n(147,i));var j=y,C=""+i;return c!==null&&c.ref!==null&&typeof c.ref=="function"&&c.ref._stringRef===C?c.ref:(c=function(U){var Q=j.refs;U===null?delete Q[C]:Q[C]=U},c._stringRef=C,c)}if(typeof i!="string")throw Error(n(284));if(!m._owner)throw Error(n(290,i))}return i}function Ac(i,c){throw i=Object.prototype.toString.call(c),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(c).join(", ")+"}":i))}function vk(i){var c=i._init;return c(i._payload)}function xk(i){function c(oe,ne){if(i){var ie=oe.deletions;ie===null?(oe.deletions=[ne],oe.flags|=16):ie.push(ne)}}function m(oe,ne){if(!i)return null;for(;ne!==null;)c(oe,ne),ne=ne.sibling;return null}function y(oe,ne){for(oe=new Map;ne!==null;)ne.key!==null?oe.set(ne.key,ne):oe.set(ne.index,ne),ne=ne.sibling;return oe}function j(oe,ne){return oe=qs(oe,ne),oe.index=0,oe.sibling=null,oe}function C(oe,ne,ie){return oe.index=ie,i?(ie=oe.alternate,ie!==null?(ie=ie.index,ie<ne?(oe.flags|=2,ne):ie):(oe.flags|=2,ne)):(oe.flags|=1048576,ne)}function U(oe){return i&&oe.alternate===null&&(oe.flags|=2),oe}function Q(oe,ne,ie,ke){return ne===null||ne.tag!==6?(ne=Pf(ie,oe.mode,ke),ne.return=oe,ne):(ne=j(ne,ie),ne.return=oe,ne)}function te(oe,ne,ie,ke){var Te=ie.type;return Te===R?ye(oe,ne,ie.props.children,ke,ie.key):ne!==null&&(ne.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===q&&vk(Te)===ne.type)?(ke=j(ne,ie.props),ke.ref=Yi(oe,ne,ie),ke.return=oe,ke):(ke=eu(ie.type,ie.key,ie.props,null,oe.mode,ke),ke.ref=Yi(oe,ne,ie),ke.return=oe,ke)}function ce(oe,ne,ie,ke){return ne===null||ne.tag!==4||ne.stateNode.containerInfo!==ie.containerInfo||ne.stateNode.implementation!==ie.implementation?(ne=Df(ie,oe.mode,ke),ne.return=oe,ne):(ne=j(ne,ie.children||[]),ne.return=oe,ne)}function ye(oe,ne,ie,ke,Te){return ne===null||ne.tag!==7?(ne=ka(ie,oe.mode,ke,Te),ne.return=oe,ne):(ne=j(ne,ie),ne.return=oe,ne)}function be(oe,ne,ie){if(typeof ne=="string"&&ne!==""||typeof ne=="number")return ne=Pf(""+ne,oe.mode,ie),ne.return=oe,ne;if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case T:return ie=eu(ne.type,ne.key,ne.props,null,oe.mode,ie),ie.ref=Yi(oe,null,ne),ie.return=oe,ie;case A:return ne=Df(ne,oe.mode,ie),ne.return=oe,ne;case q:var ke=ne._init;return be(oe,ke(ne._payload),ie)}if(Fe(ne)||I(ne))return ne=ka(ne,oe.mode,ie,null),ne.return=oe,ne;Ac(oe,ne)}return null}function ge(oe,ne,ie,ke){var Te=ne!==null?ne.key:null;if(typeof ie=="string"&&ie!==""||typeof ie=="number")return Te!==null?null:Q(oe,ne,""+ie,ke);if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case T:return ie.key===Te?te(oe,ne,ie,ke):null;case A:return ie.key===Te?ce(oe,ne,ie,ke):null;case q:return Te=ie._init,ge(oe,ne,Te(ie._payload),ke)}if(Fe(ie)||I(ie))return Te!==null?null:ye(oe,ne,ie,ke,null);Ac(oe,ie)}return null}function Ne(oe,ne,ie,ke,Te){if(typeof ke=="string"&&ke!==""||typeof ke=="number")return oe=oe.get(ie)||null,Q(ne,oe,""+ke,Te);if(typeof ke=="object"&&ke!==null){switch(ke.$$typeof){case T:return oe=oe.get(ke.key===null?ie:ke.key)||null,te(ne,oe,ke,Te);case A:return oe=oe.get(ke.key===null?ie:ke.key)||null,ce(ne,oe,ke,Te);case q:var Re=ke._init;return Ne(oe,ne,ie,Re(ke._payload),Te)}if(Fe(ke)||I(ke))return oe=oe.get(ie)||null,ye(ne,oe,ke,Te,null);Ac(ne,ke)}return null}function Ee(oe,ne,ie,ke){for(var Te=null,Re=null,Me=ne,Ie=ne=0,It=null;Me!==null&&Ie<ie.length;Ie++){Me.index>Ie?(It=Me,Me=null):It=Me.sibling;var Ke=ge(oe,Me,ie[Ie],ke);if(Ke===null){Me===null&&(Me=It);break}i&&Me&&Ke.alternate===null&&c(oe,Me),ne=C(Ke,ne,Ie),Re===null?Te=Ke:Re.sibling=Ke,Re=Ke,Me=It}if(Ie===ie.length)return m(oe,Me),ct&&pa(oe,Ie),Te;if(Me===null){for(;Ie<ie.length;Ie++)Me=be(oe,ie[Ie],ke),Me!==null&&(ne=C(Me,ne,Ie),Re===null?Te=Me:Re.sibling=Me,Re=Me);return ct&&pa(oe,Ie),Te}for(Me=y(oe,Me);Ie<ie.length;Ie++)It=Ne(Me,oe,Ie,ie[Ie],ke),It!==null&&(i&&It.alternate!==null&&Me.delete(It.key===null?Ie:It.key),ne=C(It,ne,Ie),Re===null?Te=It:Re.sibling=It,Re=It);return i&&Me.forEach(function(Us){return c(oe,Us)}),ct&&pa(oe,Ie),Te}function Ce(oe,ne,ie,ke){var Te=I(ie);if(typeof Te!="function")throw Error(n(150));if(ie=Te.call(ie),ie==null)throw Error(n(151));for(var Re=Te=null,Me=ne,Ie=ne=0,It=null,Ke=ie.next();Me!==null&&!Ke.done;Ie++,Ke=ie.next()){Me.index>Ie?(It=Me,Me=null):It=Me.sibling;var Us=ge(oe,Me,Ke.value,ke);if(Us===null){Me===null&&(Me=It);break}i&&Me&&Us.alternate===null&&c(oe,Me),ne=C(Us,ne,Ie),Re===null?Te=Us:Re.sibling=Us,Re=Us,Me=It}if(Ke.done)return m(oe,Me),ct&&pa(oe,Ie),Te;if(Me===null){for(;!Ke.done;Ie++,Ke=ie.next())Ke=be(oe,Ke.value,ke),Ke!==null&&(ne=C(Ke,ne,Ie),Re===null?Te=Ke:Re.sibling=Ke,Re=Ke);return ct&&pa(oe,Ie),Te}for(Me=y(oe,Me);!Ke.done;Ie++,Ke=ie.next())Ke=Ne(Me,oe,Ie,Ke.value,ke),Ke!==null&&(i&&Ke.alternate!==null&&Me.delete(Ke.key===null?Ie:Ke.key),ne=C(Ke,ne,Ie),Re===null?Te=Ke:Re.sibling=Ke,Re=Ke);return i&&Me.forEach(function(KP){return c(oe,KP)}),ct&&pa(oe,Ie),Te}function wt(oe,ne,ie,ke){if(typeof ie=="object"&&ie!==null&&ie.type===R&&ie.key===null&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case T:e:{for(var Te=ie.key,Re=ne;Re!==null;){if(Re.key===Te){if(Te=ie.type,Te===R){if(Re.tag===7){m(oe,Re.sibling),ne=j(Re,ie.props.children),ne.return=oe,oe=ne;break e}}else if(Re.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===q&&vk(Te)===Re.type){m(oe,Re.sibling),ne=j(Re,ie.props),ne.ref=Yi(oe,Re,ie),ne.return=oe,oe=ne;break e}m(oe,Re);break}else c(oe,Re);Re=Re.sibling}ie.type===R?(ne=ka(ie.props.children,oe.mode,ke,ie.key),ne.return=oe,oe=ne):(ke=eu(ie.type,ie.key,ie.props,null,oe.mode,ke),ke.ref=Yi(oe,ne,ie),ke.return=oe,oe=ke)}return U(oe);case A:e:{for(Re=ie.key;ne!==null;){if(ne.key===Re)if(ne.tag===4&&ne.stateNode.containerInfo===ie.containerInfo&&ne.stateNode.implementation===ie.implementation){m(oe,ne.sibling),ne=j(ne,ie.children||[]),ne.return=oe,oe=ne;break e}else{m(oe,ne);break}else c(oe,ne);ne=ne.sibling}ne=Df(ie,oe.mode,ke),ne.return=oe,oe=ne}return U(oe);case q:return Re=ie._init,wt(oe,ne,Re(ie._payload),ke)}if(Fe(ie))return Ee(oe,ne,ie,ke);if(I(ie))return Ce(oe,ne,ie,ke);Ac(oe,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"?(ie=""+ie,ne!==null&&ne.tag===6?(m(oe,ne.sibling),ne=j(ne,ie),ne.return=oe,oe=ne):(m(oe,ne),ne=Pf(ie,oe.mode,ke),ne.return=oe,oe=ne),U(oe)):m(oe,ne)}return wt}var wo=xk(!0),bk=xk(!1),Rc=Rs(null),Mc=null,vo=null,Vh=null;function Gh(){Vh=vo=Mc=null}function Kh(i){var c=Rc.current;at(Rc),i._currentValue=c}function Yh(i,c,m){for(;i!==null;){var y=i.alternate;if((i.childLanes&c)!==c?(i.childLanes|=c,y!==null&&(y.childLanes|=c)):y!==null&&(y.childLanes&c)!==c&&(y.childLanes|=c),i===m)break;i=i.return}}function xo(i,c){Mc=i,Vh=vo=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&c)!==0&&(sn=!0),i.firstContext=null)}function Tn(i){var c=i._currentValue;if(Vh!==i)if(i={context:i,memoizedValue:c,next:null},vo===null){if(Mc===null)throw Error(n(308));vo=i,Mc.dependencies={lanes:0,firstContext:i}}else vo=vo.next=i;return c}var ma=null;function Xh(i){ma===null?ma=[i]:ma.push(i)}function kk(i,c,m,y){var j=c.interleaved;return j===null?(m.next=m,Xh(c)):(m.next=j.next,j.next=m),c.interleaved=m,ns(i,y)}function ns(i,c){i.lanes|=c;var m=i.alternate;for(m!==null&&(m.lanes|=c),m=i,i=i.return;i!==null;)i.childLanes|=c,m=i.alternate,m!==null&&(m.childLanes|=c),m=i,i=i.return;return m.tag===3?m.stateNode:null}var Is=!1;function Zh(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Nk(i,c){i=i.updateQueue,c.updateQueue===i&&(c.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,effects:i.effects})}function rs(i,c){return{eventTime:i,lane:c,tag:0,payload:null,callback:null,next:null}}function Os(i,c,m){var y=i.updateQueue;if(y===null)return null;if(y=y.shared,(He&2)!==0){var j=y.pending;return j===null?c.next=c:(c.next=j.next,j.next=c),y.pending=c,ns(i,m)}return j=y.interleaved,j===null?(c.next=c,Xh(y)):(c.next=j.next,j.next=c),y.interleaved=c,ns(i,m)}function $c(i,c,m){if(c=c.updateQueue,c!==null&&(c=c.shared,(m&4194240)!==0)){var y=c.lanes;y&=i.pendingLanes,m|=y,c.lanes=m,Ci(i,m)}}function jk(i,c){var m=i.updateQueue,y=i.alternate;if(y!==null&&(y=y.updateQueue,m===y)){var j=null,C=null;if(m=m.firstBaseUpdate,m!==null){do{var U={eventTime:m.eventTime,lane:m.lane,tag:m.tag,payload:m.payload,callback:m.callback,next:null};C===null?j=C=U:C=C.next=U,m=m.next}while(m!==null);C===null?j=C=c:C=C.next=c}else j=C=c;m={baseState:y.baseState,firstBaseUpdate:j,lastBaseUpdate:C,shared:y.shared,effects:y.effects},i.updateQueue=m;return}i=m.lastBaseUpdate,i===null?m.firstBaseUpdate=c:i.next=c,m.lastBaseUpdate=c}function Ic(i,c,m,y){var j=i.updateQueue;Is=!1;var C=j.firstBaseUpdate,U=j.lastBaseUpdate,Q=j.shared.pending;if(Q!==null){j.shared.pending=null;var te=Q,ce=te.next;te.next=null,U===null?C=ce:U.next=ce,U=te;var ye=i.alternate;ye!==null&&(ye=ye.updateQueue,Q=ye.lastBaseUpdate,Q!==U&&(Q===null?ye.firstBaseUpdate=ce:Q.next=ce,ye.lastBaseUpdate=te))}if(C!==null){var be=j.baseState;U=0,ye=ce=te=null,Q=C;do{var ge=Q.lane,Ne=Q.eventTime;if((y&ge)===ge){ye!==null&&(ye=ye.next={eventTime:Ne,lane:0,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null});e:{var Ee=i,Ce=Q;switch(ge=c,Ne=m,Ce.tag){case 1:if(Ee=Ce.payload,typeof Ee=="function"){be=Ee.call(Ne,be,ge);break e}be=Ee;break e;case 3:Ee.flags=Ee.flags&-65537|128;case 0:if(Ee=Ce.payload,ge=typeof Ee=="function"?Ee.call(Ne,be,ge):Ee,ge==null)break e;be=W({},be,ge);break e;case 2:Is=!0}}Q.callback!==null&&Q.lane!==0&&(i.flags|=64,ge=j.effects,ge===null?j.effects=[Q]:ge.push(Q))}else Ne={eventTime:Ne,lane:ge,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null},ye===null?(ce=ye=Ne,te=be):ye=ye.next=Ne,U|=ge;if(Q=Q.next,Q===null){if(Q=j.shared.pending,Q===null)break;ge=Q,Q=ge.next,ge.next=null,j.lastBaseUpdate=ge,j.shared.pending=null}}while(!0);if(ye===null&&(te=be),j.baseState=te,j.firstBaseUpdate=ce,j.lastBaseUpdate=ye,c=j.shared.interleaved,c!==null){j=c;do U|=j.lane,j=j.next;while(j!==c)}else C===null&&(j.shared.lanes=0);wa|=U,i.lanes=U,i.memoizedState=be}}function Sk(i,c,m){if(i=c.effects,c.effects=null,i!==null)for(c=0;c<i.length;c++){var y=i[c],j=y.callback;if(j!==null){if(y.callback=null,y=m,typeof j!="function")throw Error(n(191,j));j.call(y)}}}var Xi={},Er=Rs(Xi),Zi=Rs(Xi),Ji=Rs(Xi);function ga(i){if(i===Xi)throw Error(n(174));return i}function Jh(i,c){switch(tt(Ji,c),tt(Zi,i),tt(Er,Xi),i=c.nodeType,i){case 9:case 11:c=(c=c.documentElement)?c.namespaceURI:ze(null,"");break;default:i=i===8?c.parentNode:c,c=i.namespaceURI||null,i=i.tagName,c=ze(c,i)}at(Er),tt(Er,c)}function bo(){at(Er),at(Zi),at(Ji)}function _k(i){ga(Ji.current);var c=ga(Er.current),m=ze(c,i.type);c!==m&&(tt(Zi,i),tt(Er,m))}function Qh(i){Zi.current===i&&(at(Er),at(Zi))}var dt=Rs(0);function Oc(i){for(var c=i;c!==null;){if(c.tag===13){var m=c.memoizedState;if(m!==null&&(m=m.dehydrated,m===null||m.data==="$?"||m.data==="$!"))return c}else if(c.tag===19&&c.memoizedProps.revealOrder!==void 0){if((c.flags&128)!==0)return c}else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===i)break;for(;c.sibling===null;){if(c.return===null||c.return===i)return null;c=c.return}c.sibling.return=c.return,c=c.sibling}return null}var ef=[];function tf(){for(var i=0;i<ef.length;i++)ef[i]._workInProgressVersionPrimary=null;ef.length=0}var Lc=E.ReactCurrentDispatcher,nf=E.ReactCurrentBatchConfig,ya=0,ht=null,jt=null,Mt=null,Pc=!1,Qi=!1,el=0,gP=0;function Ht(){throw Error(n(321))}function rf(i,c){if(c===null)return!1;for(var m=0;m<c.length&&m<i.length;m++)if(!Yn(i[m],c[m]))return!1;return!0}function sf(i,c,m,y,j,C){if(ya=C,ht=c,c.memoizedState=null,c.updateQueue=null,c.lanes=0,Lc.current=i===null||i.memoizedState===null?xP:bP,i=m(y,j),Qi){C=0;do{if(Qi=!1,el=0,25<=C)throw Error(n(301));C+=1,Mt=jt=null,c.updateQueue=null,Lc.current=kP,i=m(y,j)}while(Qi)}if(Lc.current=Bc,c=jt!==null&&jt.next!==null,ya=0,Mt=jt=ht=null,Pc=!1,c)throw Error(n(300));return i}function af(){var i=el!==0;return el=0,i}function Cr(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Mt===null?ht.memoizedState=Mt=i:Mt=Mt.next=i,Mt}function An(){if(jt===null){var i=ht.alternate;i=i!==null?i.memoizedState:null}else i=jt.next;var c=Mt===null?ht.memoizedState:Mt.next;if(c!==null)Mt=c,jt=i;else{if(i===null)throw Error(n(310));jt=i,i={memoizedState:jt.memoizedState,baseState:jt.baseState,baseQueue:jt.baseQueue,queue:jt.queue,next:null},Mt===null?ht.memoizedState=Mt=i:Mt=Mt.next=i}return Mt}function tl(i,c){return typeof c=="function"?c(i):c}function of(i){var c=An(),m=c.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=i;var y=jt,j=y.baseQueue,C=m.pending;if(C!==null){if(j!==null){var U=j.next;j.next=C.next,C.next=U}y.baseQueue=j=C,m.pending=null}if(j!==null){C=j.next,y=y.baseState;var Q=U=null,te=null,ce=C;do{var ye=ce.lane;if((ya&ye)===ye)te!==null&&(te=te.next={lane:0,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null}),y=ce.hasEagerState?ce.eagerState:i(y,ce.action);else{var be={lane:ye,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null};te===null?(Q=te=be,U=y):te=te.next=be,ht.lanes|=ye,wa|=ye}ce=ce.next}while(ce!==null&&ce!==C);te===null?U=y:te.next=Q,Yn(y,c.memoizedState)||(sn=!0),c.memoizedState=y,c.baseState=U,c.baseQueue=te,m.lastRenderedState=y}if(i=m.interleaved,i!==null){j=i;do C=j.lane,ht.lanes|=C,wa|=C,j=j.next;while(j!==i)}else j===null&&(m.lanes=0);return[c.memoizedState,m.dispatch]}function lf(i){var c=An(),m=c.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=i;var y=m.dispatch,j=m.pending,C=c.memoizedState;if(j!==null){m.pending=null;var U=j=j.next;do C=i(C,U.action),U=U.next;while(U!==j);Yn(C,c.memoizedState)||(sn=!0),c.memoizedState=C,c.baseQueue===null&&(c.baseState=C),m.lastRenderedState=C}return[C,y]}function Ek(){}function Ck(i,c){var m=ht,y=An(),j=c(),C=!Yn(y.memoizedState,j);if(C&&(y.memoizedState=j,sn=!0),y=y.queue,cf(Rk.bind(null,m,y,i),[i]),y.getSnapshot!==c||C||Mt!==null&&Mt.memoizedState.tag&1){if(m.flags|=2048,nl(9,Ak.bind(null,m,y,j,c),void 0,null),$t===null)throw Error(n(349));(ya&30)!==0||Tk(m,c,j)}return j}function Tk(i,c,m){i.flags|=16384,i={getSnapshot:c,value:m},c=ht.updateQueue,c===null?(c={lastEffect:null,stores:null},ht.updateQueue=c,c.stores=[i]):(m=c.stores,m===null?c.stores=[i]:m.push(i))}function Ak(i,c,m,y){c.value=m,c.getSnapshot=y,Mk(c)&&$k(i)}function Rk(i,c,m){return m(function(){Mk(c)&&$k(i)})}function Mk(i){var c=i.getSnapshot;i=i.value;try{var m=c();return!Yn(i,m)}catch{return!0}}function $k(i){var c=ns(i,1);c!==null&&er(c,i,1,-1)}function Ik(i){var c=Cr();return typeof i=="function"&&(i=i()),c.memoizedState=c.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:tl,lastRenderedState:i},c.queue=i,i=i.dispatch=vP.bind(null,ht,i),[c.memoizedState,i]}function nl(i,c,m,y){return i={tag:i,create:c,destroy:m,deps:y,next:null},c=ht.updateQueue,c===null?(c={lastEffect:null,stores:null},ht.updateQueue=c,c.lastEffect=i.next=i):(m=c.lastEffect,m===null?c.lastEffect=i.next=i:(y=m.next,m.next=i,i.next=y,c.lastEffect=i)),i}function Ok(){return An().memoizedState}function Dc(i,c,m,y){var j=Cr();ht.flags|=i,j.memoizedState=nl(1|c,m,void 0,y===void 0?null:y)}function Fc(i,c,m,y){var j=An();y=y===void 0?null:y;var C=void 0;if(jt!==null){var U=jt.memoizedState;if(C=U.destroy,y!==null&&rf(y,U.deps)){j.memoizedState=nl(c,m,C,y);return}}ht.flags|=i,j.memoizedState=nl(1|c,m,C,y)}function Lk(i,c){return Dc(8390656,8,i,c)}function cf(i,c){return Fc(2048,8,i,c)}function Pk(i,c){return Fc(4,2,i,c)}function Dk(i,c){return Fc(4,4,i,c)}function Fk(i,c){if(typeof c=="function")return i=i(),c(i),function(){c(null)};if(c!=null)return i=i(),c.current=i,function(){c.current=null}}function Bk(i,c,m){return m=m!=null?m.concat([i]):null,Fc(4,4,Fk.bind(null,c,i),m)}function uf(){}function qk(i,c){var m=An();c=c===void 0?null:c;var y=m.memoizedState;return y!==null&&c!==null&&rf(c,y[1])?y[0]:(m.memoizedState=[i,c],i)}function Uk(i,c){var m=An();c=c===void 0?null:c;var y=m.memoizedState;return y!==null&&c!==null&&rf(c,y[1])?y[0]:(i=i(),m.memoizedState=[i,c],i)}function zk(i,c,m){return(ya&21)===0?(i.baseState&&(i.baseState=!1,sn=!0),i.memoizedState=m):(Yn(m,c)||(m=dc(),ht.lanes|=m,wa|=m,i.baseState=!0),c)}function yP(i,c){var m=Ge;Ge=m!==0&&4>m?m:4,i(!0);var y=nf.transition;nf.transition={};try{i(!1),c()}finally{Ge=m,nf.transition=y}}function Wk(){return An().memoizedState}function wP(i,c,m){var y=Fs(i);if(m={lane:y,action:m,hasEagerState:!1,eagerState:null,next:null},Hk(i))Vk(c,m);else if(m=kk(i,c,m,y),m!==null){var j=Zt();er(m,i,y,j),Gk(m,c,y)}}function vP(i,c,m){var y=Fs(i),j={lane:y,action:m,hasEagerState:!1,eagerState:null,next:null};if(Hk(i))Vk(c,j);else{var C=i.alternate;if(i.lanes===0&&(C===null||C.lanes===0)&&(C=c.lastRenderedReducer,C!==null))try{var U=c.lastRenderedState,Q=C(U,m);if(j.hasEagerState=!0,j.eagerState=Q,Yn(Q,U)){var te=c.interleaved;te===null?(j.next=j,Xh(c)):(j.next=te.next,te.next=j),c.interleaved=j;return}}catch{}finally{}m=kk(i,c,j,y),m!==null&&(j=Zt(),er(m,i,y,j),Gk(m,c,y))}}function Hk(i){var c=i.alternate;return i===ht||c!==null&&c===ht}function Vk(i,c){Qi=Pc=!0;var m=i.pending;m===null?c.next=c:(c.next=m.next,m.next=c),i.pending=c}function Gk(i,c,m){if((m&4194240)!==0){var y=c.lanes;y&=i.pendingLanes,m|=y,c.lanes=m,Ci(i,m)}}var Bc={readContext:Tn,useCallback:Ht,useContext:Ht,useEffect:Ht,useImperativeHandle:Ht,useInsertionEffect:Ht,useLayoutEffect:Ht,useMemo:Ht,useReducer:Ht,useRef:Ht,useState:Ht,useDebugValue:Ht,useDeferredValue:Ht,useTransition:Ht,useMutableSource:Ht,useSyncExternalStore:Ht,useId:Ht,unstable_isNewReconciler:!1},xP={readContext:Tn,useCallback:function(i,c){return Cr().memoizedState=[i,c===void 0?null:c],i},useContext:Tn,useEffect:Lk,useImperativeHandle:function(i,c,m){return m=m!=null?m.concat([i]):null,Dc(4194308,4,Fk.bind(null,c,i),m)},useLayoutEffect:function(i,c){return Dc(4194308,4,i,c)},useInsertionEffect:function(i,c){return Dc(4,2,i,c)},useMemo:function(i,c){var m=Cr();return c=c===void 0?null:c,i=i(),m.memoizedState=[i,c],i},useReducer:function(i,c,m){var y=Cr();return c=m!==void 0?m(c):c,y.memoizedState=y.baseState=c,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:c},y.queue=i,i=i.dispatch=wP.bind(null,ht,i),[y.memoizedState,i]},useRef:function(i){var c=Cr();return i={current:i},c.memoizedState=i},useState:Ik,useDebugValue:uf,useDeferredValue:function(i){return Cr().memoizedState=i},useTransition:function(){var i=Ik(!1),c=i[0];return i=yP.bind(null,i[1]),Cr().memoizedState=i,[c,i]},useMutableSource:function(){},useSyncExternalStore:function(i,c,m){var y=ht,j=Cr();if(ct){if(m===void 0)throw Error(n(407));m=m()}else{if(m=c(),$t===null)throw Error(n(349));(ya&30)!==0||Tk(y,c,m)}j.memoizedState=m;var C={value:m,getSnapshot:c};return j.queue=C,Lk(Rk.bind(null,y,C,i),[i]),y.flags|=2048,nl(9,Ak.bind(null,y,C,m,c),void 0,null),m},useId:function(){var i=Cr(),c=$t.identifierPrefix;if(ct){var m=ts,y=es;m=(y&~(1<<32-tn(y)-1)).toString(32)+m,c=":"+c+"R"+m,m=el++,0<m&&(c+="H"+m.toString(32)),c+=":"}else m=gP++,c=":"+c+"r"+m.toString(32)+":";return i.memoizedState=c},unstable_isNewReconciler:!1},bP={readContext:Tn,useCallback:qk,useContext:Tn,useEffect:cf,useImperativeHandle:Bk,useInsertionEffect:Pk,useLayoutEffect:Dk,useMemo:Uk,useReducer:of,useRef:Ok,useState:function(){return of(tl)},useDebugValue:uf,useDeferredValue:function(i){var c=An();return zk(c,jt.memoizedState,i)},useTransition:function(){var i=of(tl)[0],c=An().memoizedState;return[i,c]},useMutableSource:Ek,useSyncExternalStore:Ck,useId:Wk,unstable_isNewReconciler:!1},kP={readContext:Tn,useCallback:qk,useContext:Tn,useEffect:cf,useImperativeHandle:Bk,useInsertionEffect:Pk,useLayoutEffect:Dk,useMemo:Uk,useReducer:lf,useRef:Ok,useState:function(){return lf(tl)},useDebugValue:uf,useDeferredValue:function(i){var c=An();return jt===null?c.memoizedState=i:zk(c,jt.memoizedState,i)},useTransition:function(){var i=lf(tl)[0],c=An().memoizedState;return[i,c]},useMutableSource:Ek,useSyncExternalStore:Ck,useId:Wk,unstable_isNewReconciler:!1};function Zn(i,c){if(i&&i.defaultProps){c=W({},c),i=i.defaultProps;for(var m in i)c[m]===void 0&&(c[m]=i[m]);return c}return c}function df(i,c,m,y){c=i.memoizedState,m=m(y,c),m=m==null?c:W({},c,m),i.memoizedState=m,i.lanes===0&&(i.updateQueue.baseState=m)}var qc={isMounted:function(i){return(i=i._reactInternals)?fn(i)===i:!1},enqueueSetState:function(i,c,m){i=i._reactInternals;var y=Zt(),j=Fs(i),C=rs(y,j);C.payload=c,m!=null&&(C.callback=m),c=Os(i,C,j),c!==null&&(er(c,i,j,y),$c(c,i,j))},enqueueReplaceState:function(i,c,m){i=i._reactInternals;var y=Zt(),j=Fs(i),C=rs(y,j);C.tag=1,C.payload=c,m!=null&&(C.callback=m),c=Os(i,C,j),c!==null&&(er(c,i,j,y),$c(c,i,j))},enqueueForceUpdate:function(i,c){i=i._reactInternals;var m=Zt(),y=Fs(i),j=rs(m,y);j.tag=2,c!=null&&(j.callback=c),c=Os(i,j,y),c!==null&&(er(c,i,y,m),$c(c,i,y))}};function Kk(i,c,m,y,j,C,U){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(y,C,U):c.prototype&&c.prototype.isPureReactComponent?!Ui(m,y)||!Ui(j,C):!0}function Yk(i,c,m){var y=!1,j=Ms,C=c.contextType;return typeof C=="object"&&C!==null?C=Tn(C):(j=rn(c)?ha:Wt.current,y=c.contextTypes,C=(y=y!=null)?po(i,j):Ms),c=new c(m,C),i.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,c.updater=qc,i.stateNode=c,c._reactInternals=i,y&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=j,i.__reactInternalMemoizedMaskedChildContext=C),c}function Xk(i,c,m,y){i=c.state,typeof c.componentWillReceiveProps=="function"&&c.componentWillReceiveProps(m,y),typeof c.UNSAFE_componentWillReceiveProps=="function"&&c.UNSAFE_componentWillReceiveProps(m,y),c.state!==i&&qc.enqueueReplaceState(c,c.state,null)}function hf(i,c,m,y){var j=i.stateNode;j.props=m,j.state=i.memoizedState,j.refs={},Zh(i);var C=c.contextType;typeof C=="object"&&C!==null?j.context=Tn(C):(C=rn(c)?ha:Wt.current,j.context=po(i,C)),j.state=i.memoizedState,C=c.getDerivedStateFromProps,typeof C=="function"&&(df(i,c,C,m),j.state=i.memoizedState),typeof c.getDerivedStateFromProps=="function"||typeof j.getSnapshotBeforeUpdate=="function"||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(c=j.state,typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount(),c!==j.state&&qc.enqueueReplaceState(j,j.state,null),Ic(i,m,j,y),j.state=i.memoizedState),typeof j.componentDidMount=="function"&&(i.flags|=4194308)}function ko(i,c){try{var m="",y=c;do m+=G(y),y=y.return;while(y);var j=m}catch(C){j=`
39
+ Error generating stack: `+C.message+`
40
+ `+C.stack}return{value:i,source:c,stack:j,digest:null}}function ff(i,c,m){return{value:i,source:null,stack:m??null,digest:c??null}}function pf(i,c){try{console.error(c.value)}catch(m){setTimeout(function(){throw m})}}var NP=typeof WeakMap=="function"?WeakMap:Map;function Zk(i,c,m){m=rs(-1,m),m.tag=3,m.payload={element:null};var y=c.value;return m.callback=function(){Kc||(Kc=!0,Tf=y),pf(i,c)},m}function Jk(i,c,m){m=rs(-1,m),m.tag=3;var y=i.type.getDerivedStateFromError;if(typeof y=="function"){var j=c.value;m.payload=function(){return y(j)},m.callback=function(){pf(i,c)}}var C=i.stateNode;return C!==null&&typeof C.componentDidCatch=="function"&&(m.callback=function(){pf(i,c),typeof y!="function"&&(Ps===null?Ps=new Set([this]):Ps.add(this));var U=c.stack;this.componentDidCatch(c.value,{componentStack:U!==null?U:""})}),m}function Qk(i,c,m){var y=i.pingCache;if(y===null){y=i.pingCache=new NP;var j=new Set;y.set(c,j)}else j=y.get(c),j===void 0&&(j=new Set,y.set(c,j));j.has(m)||(j.add(m),i=PP.bind(null,i,c,m),c.then(i,i))}function e1(i){do{var c;if((c=i.tag===13)&&(c=i.memoizedState,c=c!==null?c.dehydrated!==null:!0),c)return i;i=i.return}while(i!==null);return null}function t1(i,c,m,y,j){return(i.mode&1)===0?(i===c?i.flags|=65536:(i.flags|=128,m.flags|=131072,m.flags&=-52805,m.tag===1&&(m.alternate===null?m.tag=17:(c=rs(-1,1),c.tag=2,Os(m,c,1))),m.lanes|=1),i):(i.flags|=65536,i.lanes=j,i)}var jP=E.ReactCurrentOwner,sn=!1;function Xt(i,c,m,y){c.child=i===null?bk(c,null,m,y):wo(c,i.child,m,y)}function n1(i,c,m,y,j){m=m.render;var C=c.ref;return xo(c,j),y=sf(i,c,m,y,C,j),m=af(),i!==null&&!sn?(c.updateQueue=i.updateQueue,c.flags&=-2053,i.lanes&=~j,ss(i,c,j)):(ct&&m&&qh(c),c.flags|=1,Xt(i,c,y,j),c.child)}function r1(i,c,m,y,j){if(i===null){var C=m.type;return typeof C=="function"&&!Lf(C)&&C.defaultProps===void 0&&m.compare===null&&m.defaultProps===void 0?(c.tag=15,c.type=C,s1(i,c,C,y,j)):(i=eu(m.type,null,y,c,c.mode,j),i.ref=c.ref,i.return=c,c.child=i)}if(C=i.child,(i.lanes&j)===0){var U=C.memoizedProps;if(m=m.compare,m=m!==null?m:Ui,m(U,y)&&i.ref===c.ref)return ss(i,c,j)}return c.flags|=1,i=qs(C,y),i.ref=c.ref,i.return=c,c.child=i}function s1(i,c,m,y,j){if(i!==null){var C=i.memoizedProps;if(Ui(C,y)&&i.ref===c.ref)if(sn=!1,c.pendingProps=y=C,(i.lanes&j)!==0)(i.flags&131072)!==0&&(sn=!0);else return c.lanes=i.lanes,ss(i,c,j)}return mf(i,c,m,y,j)}function a1(i,c,m){var y=c.pendingProps,j=y.children,C=i!==null?i.memoizedState:null;if(y.mode==="hidden")if((c.mode&1)===0)c.memoizedState={baseLanes:0,cachePool:null,transitions:null},tt(jo,gn),gn|=m;else{if((m&1073741824)===0)return i=C!==null?C.baseLanes|m:m,c.lanes=c.childLanes=1073741824,c.memoizedState={baseLanes:i,cachePool:null,transitions:null},c.updateQueue=null,tt(jo,gn),gn|=i,null;c.memoizedState={baseLanes:0,cachePool:null,transitions:null},y=C!==null?C.baseLanes:m,tt(jo,gn),gn|=y}else C!==null?(y=C.baseLanes|m,c.memoizedState=null):y=m,tt(jo,gn),gn|=y;return Xt(i,c,j,m),c.child}function o1(i,c){var m=c.ref;(i===null&&m!==null||i!==null&&i.ref!==m)&&(c.flags|=512,c.flags|=2097152)}function mf(i,c,m,y,j){var C=rn(m)?ha:Wt.current;return C=po(c,C),xo(c,j),m=sf(i,c,m,y,C,j),y=af(),i!==null&&!sn?(c.updateQueue=i.updateQueue,c.flags&=-2053,i.lanes&=~j,ss(i,c,j)):(ct&&y&&qh(c),c.flags|=1,Xt(i,c,m,j),c.child)}function i1(i,c,m,y,j){if(rn(m)){var C=!0;Sc(c)}else C=!1;if(xo(c,j),c.stateNode===null)zc(i,c),Yk(c,m,y),hf(c,m,y,j),y=!0;else if(i===null){var U=c.stateNode,Q=c.memoizedProps;U.props=Q;var te=U.context,ce=m.contextType;typeof ce=="object"&&ce!==null?ce=Tn(ce):(ce=rn(m)?ha:Wt.current,ce=po(c,ce));var ye=m.getDerivedStateFromProps,be=typeof ye=="function"||typeof U.getSnapshotBeforeUpdate=="function";be||typeof U.UNSAFE_componentWillReceiveProps!="function"&&typeof U.componentWillReceiveProps!="function"||(Q!==y||te!==ce)&&Xk(c,U,y,ce),Is=!1;var ge=c.memoizedState;U.state=ge,Ic(c,y,U,j),te=c.memoizedState,Q!==y||ge!==te||nn.current||Is?(typeof ye=="function"&&(df(c,m,ye,y),te=c.memoizedState),(Q=Is||Kk(c,m,Q,y,ge,te,ce))?(be||typeof U.UNSAFE_componentWillMount!="function"&&typeof U.componentWillMount!="function"||(typeof U.componentWillMount=="function"&&U.componentWillMount(),typeof U.UNSAFE_componentWillMount=="function"&&U.UNSAFE_componentWillMount()),typeof U.componentDidMount=="function"&&(c.flags|=4194308)):(typeof U.componentDidMount=="function"&&(c.flags|=4194308),c.memoizedProps=y,c.memoizedState=te),U.props=y,U.state=te,U.context=ce,y=Q):(typeof U.componentDidMount=="function"&&(c.flags|=4194308),y=!1)}else{U=c.stateNode,Nk(i,c),Q=c.memoizedProps,ce=c.type===c.elementType?Q:Zn(c.type,Q),U.props=ce,be=c.pendingProps,ge=U.context,te=m.contextType,typeof te=="object"&&te!==null?te=Tn(te):(te=rn(m)?ha:Wt.current,te=po(c,te));var Ne=m.getDerivedStateFromProps;(ye=typeof Ne=="function"||typeof U.getSnapshotBeforeUpdate=="function")||typeof U.UNSAFE_componentWillReceiveProps!="function"&&typeof U.componentWillReceiveProps!="function"||(Q!==be||ge!==te)&&Xk(c,U,y,te),Is=!1,ge=c.memoizedState,U.state=ge,Ic(c,y,U,j);var Ee=c.memoizedState;Q!==be||ge!==Ee||nn.current||Is?(typeof Ne=="function"&&(df(c,m,Ne,y),Ee=c.memoizedState),(ce=Is||Kk(c,m,ce,y,ge,Ee,te)||!1)?(ye||typeof U.UNSAFE_componentWillUpdate!="function"&&typeof U.componentWillUpdate!="function"||(typeof U.componentWillUpdate=="function"&&U.componentWillUpdate(y,Ee,te),typeof U.UNSAFE_componentWillUpdate=="function"&&U.UNSAFE_componentWillUpdate(y,Ee,te)),typeof U.componentDidUpdate=="function"&&(c.flags|=4),typeof U.getSnapshotBeforeUpdate=="function"&&(c.flags|=1024)):(typeof U.componentDidUpdate!="function"||Q===i.memoizedProps&&ge===i.memoizedState||(c.flags|=4),typeof U.getSnapshotBeforeUpdate!="function"||Q===i.memoizedProps&&ge===i.memoizedState||(c.flags|=1024),c.memoizedProps=y,c.memoizedState=Ee),U.props=y,U.state=Ee,U.context=te,y=ce):(typeof U.componentDidUpdate!="function"||Q===i.memoizedProps&&ge===i.memoizedState||(c.flags|=4),typeof U.getSnapshotBeforeUpdate!="function"||Q===i.memoizedProps&&ge===i.memoizedState||(c.flags|=1024),y=!1)}return gf(i,c,m,y,C,j)}function gf(i,c,m,y,j,C){o1(i,c);var U=(c.flags&128)!==0;if(!y&&!U)return j&&hk(c,m,!1),ss(i,c,C);y=c.stateNode,jP.current=c;var Q=U&&typeof m.getDerivedStateFromError!="function"?null:y.render();return c.flags|=1,i!==null&&U?(c.child=wo(c,i.child,null,C),c.child=wo(c,null,Q,C)):Xt(i,c,Q,C),c.memoizedState=y.state,j&&hk(c,m,!0),c.child}function l1(i){var c=i.stateNode;c.pendingContext?uk(i,c.pendingContext,c.pendingContext!==c.context):c.context&&uk(i,c.context,!1),Jh(i,c.containerInfo)}function c1(i,c,m,y,j){return yo(),Hh(j),c.flags|=256,Xt(i,c,m,y),c.child}var yf={dehydrated:null,treeContext:null,retryLane:0};function wf(i){return{baseLanes:i,cachePool:null,transitions:null}}function u1(i,c,m){var y=c.pendingProps,j=dt.current,C=!1,U=(c.flags&128)!==0,Q;if((Q=U)||(Q=i!==null&&i.memoizedState===null?!1:(j&2)!==0),Q?(C=!0,c.flags&=-129):(i===null||i.memoizedState!==null)&&(j|=1),tt(dt,j&1),i===null)return Wh(c),i=c.memoizedState,i!==null&&(i=i.dehydrated,i!==null)?((c.mode&1)===0?c.lanes=1:i.data==="$!"?c.lanes=8:c.lanes=1073741824,null):(U=y.children,i=y.fallback,C?(y=c.mode,C=c.child,U={mode:"hidden",children:U},(y&1)===0&&C!==null?(C.childLanes=0,C.pendingProps=U):C=tu(U,y,0,null),i=ka(i,y,m,null),C.return=c,i.return=c,C.sibling=i,c.child=C,c.child.memoizedState=wf(m),c.memoizedState=yf,i):vf(c,U));if(j=i.memoizedState,j!==null&&(Q=j.dehydrated,Q!==null))return SP(i,c,U,y,Q,j,m);if(C){C=y.fallback,U=c.mode,j=i.child,Q=j.sibling;var te={mode:"hidden",children:y.children};return(U&1)===0&&c.child!==j?(y=c.child,y.childLanes=0,y.pendingProps=te,c.deletions=null):(y=qs(j,te),y.subtreeFlags=j.subtreeFlags&14680064),Q!==null?C=qs(Q,C):(C=ka(C,U,m,null),C.flags|=2),C.return=c,y.return=c,y.sibling=C,c.child=y,y=C,C=c.child,U=i.child.memoizedState,U=U===null?wf(m):{baseLanes:U.baseLanes|m,cachePool:null,transitions:U.transitions},C.memoizedState=U,C.childLanes=i.childLanes&~m,c.memoizedState=yf,y}return C=i.child,i=C.sibling,y=qs(C,{mode:"visible",children:y.children}),(c.mode&1)===0&&(y.lanes=m),y.return=c,y.sibling=null,i!==null&&(m=c.deletions,m===null?(c.deletions=[i],c.flags|=16):m.push(i)),c.child=y,c.memoizedState=null,y}function vf(i,c){return c=tu({mode:"visible",children:c},i.mode,0,null),c.return=i,i.child=c}function Uc(i,c,m,y){return y!==null&&Hh(y),wo(c,i.child,null,m),i=vf(c,c.pendingProps.children),i.flags|=2,c.memoizedState=null,i}function SP(i,c,m,y,j,C,U){if(m)return c.flags&256?(c.flags&=-257,y=ff(Error(n(422))),Uc(i,c,U,y)):c.memoizedState!==null?(c.child=i.child,c.flags|=128,null):(C=y.fallback,j=c.mode,y=tu({mode:"visible",children:y.children},j,0,null),C=ka(C,j,U,null),C.flags|=2,y.return=c,C.return=c,y.sibling=C,c.child=y,(c.mode&1)!==0&&wo(c,i.child,null,U),c.child.memoizedState=wf(U),c.memoizedState=yf,C);if((c.mode&1)===0)return Uc(i,c,U,null);if(j.data==="$!"){if(y=j.nextSibling&&j.nextSibling.dataset,y)var Q=y.dgst;return y=Q,C=Error(n(419)),y=ff(C,y,void 0),Uc(i,c,U,y)}if(Q=(U&i.childLanes)!==0,sn||Q){if(y=$t,y!==null){switch(U&-U){case 4:j=2;break;case 16:j=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:j=32;break;case 536870912:j=268435456;break;default:j=0}j=(j&(y.suspendedLanes|U))!==0?0:j,j!==0&&j!==C.retryLane&&(C.retryLane=j,ns(i,j),er(y,i,j,-1))}return Of(),y=ff(Error(n(421))),Uc(i,c,U,y)}return j.data==="$?"?(c.flags|=128,c.child=i.child,c=DP.bind(null,i),j._reactRetry=c,null):(i=C.treeContext,mn=As(j.nextSibling),pn=c,ct=!0,Xn=null,i!==null&&(En[Cn++]=es,En[Cn++]=ts,En[Cn++]=fa,es=i.id,ts=i.overflow,fa=c),c=vf(c,y.children),c.flags|=4096,c)}function d1(i,c,m){i.lanes|=c;var y=i.alternate;y!==null&&(y.lanes|=c),Yh(i.return,c,m)}function xf(i,c,m,y,j){var C=i.memoizedState;C===null?i.memoizedState={isBackwards:c,rendering:null,renderingStartTime:0,last:y,tail:m,tailMode:j}:(C.isBackwards=c,C.rendering=null,C.renderingStartTime=0,C.last=y,C.tail=m,C.tailMode=j)}function h1(i,c,m){var y=c.pendingProps,j=y.revealOrder,C=y.tail;if(Xt(i,c,y.children,m),y=dt.current,(y&2)!==0)y=y&1|2,c.flags|=128;else{if(i!==null&&(i.flags&128)!==0)e:for(i=c.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&d1(i,m,c);else if(i.tag===19)d1(i,m,c);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===c)break e;for(;i.sibling===null;){if(i.return===null||i.return===c)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}y&=1}if(tt(dt,y),(c.mode&1)===0)c.memoizedState=null;else switch(j){case"forwards":for(m=c.child,j=null;m!==null;)i=m.alternate,i!==null&&Oc(i)===null&&(j=m),m=m.sibling;m=j,m===null?(j=c.child,c.child=null):(j=m.sibling,m.sibling=null),xf(c,!1,j,m,C);break;case"backwards":for(m=null,j=c.child,c.child=null;j!==null;){if(i=j.alternate,i!==null&&Oc(i)===null){c.child=j;break}i=j.sibling,j.sibling=m,m=j,j=i}xf(c,!0,m,null,C);break;case"together":xf(c,!1,null,null,void 0);break;default:c.memoizedState=null}return c.child}function zc(i,c){(c.mode&1)===0&&i!==null&&(i.alternate=null,c.alternate=null,c.flags|=2)}function ss(i,c,m){if(i!==null&&(c.dependencies=i.dependencies),wa|=c.lanes,(m&c.childLanes)===0)return null;if(i!==null&&c.child!==i.child)throw Error(n(153));if(c.child!==null){for(i=c.child,m=qs(i,i.pendingProps),c.child=m,m.return=c;i.sibling!==null;)i=i.sibling,m=m.sibling=qs(i,i.pendingProps),m.return=c;m.sibling=null}return c.child}function _P(i,c,m){switch(c.tag){case 3:l1(c),yo();break;case 5:_k(c);break;case 1:rn(c.type)&&Sc(c);break;case 4:Jh(c,c.stateNode.containerInfo);break;case 10:var y=c.type._context,j=c.memoizedProps.value;tt(Rc,y._currentValue),y._currentValue=j;break;case 13:if(y=c.memoizedState,y!==null)return y.dehydrated!==null?(tt(dt,dt.current&1),c.flags|=128,null):(m&c.child.childLanes)!==0?u1(i,c,m):(tt(dt,dt.current&1),i=ss(i,c,m),i!==null?i.sibling:null);tt(dt,dt.current&1);break;case 19:if(y=(m&c.childLanes)!==0,(i.flags&128)!==0){if(y)return h1(i,c,m);c.flags|=128}if(j=c.memoizedState,j!==null&&(j.rendering=null,j.tail=null,j.lastEffect=null),tt(dt,dt.current),y)break;return null;case 22:case 23:return c.lanes=0,a1(i,c,m)}return ss(i,c,m)}var f1,bf,p1,m1;f1=function(i,c){for(var m=c.child;m!==null;){if(m.tag===5||m.tag===6)i.appendChild(m.stateNode);else if(m.tag!==4&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===c)break;for(;m.sibling===null;){if(m.return===null||m.return===c)return;m=m.return}m.sibling.return=m.return,m=m.sibling}},bf=function(){},p1=function(i,c,m,y){var j=i.memoizedProps;if(j!==y){i=c.stateNode,ga(Er.current);var C=null;switch(m){case"input":j=xe(i,j),y=xe(i,y),C=[];break;case"select":j=W({},j,{value:void 0}),y=W({},y,{value:void 0}),C=[];break;case"textarea":j=Ve(i,j),y=Ve(i,y),C=[];break;default:typeof j.onClick!="function"&&typeof y.onClick=="function"&&(i.onclick=kc)}Rt(m,y);var U;m=null;for(ce in j)if(!y.hasOwnProperty(ce)&&j.hasOwnProperty(ce)&&j[ce]!=null)if(ce==="style"){var Q=j[ce];for(U in Q)Q.hasOwnProperty(U)&&(m||(m={}),m[U]="")}else ce!=="dangerouslySetInnerHTML"&&ce!=="children"&&ce!=="suppressContentEditableWarning"&&ce!=="suppressHydrationWarning"&&ce!=="autoFocus"&&(s.hasOwnProperty(ce)?C||(C=[]):(C=C||[]).push(ce,null));for(ce in y){var te=y[ce];if(Q=j!=null?j[ce]:void 0,y.hasOwnProperty(ce)&&te!==Q&&(te!=null||Q!=null))if(ce==="style")if(Q){for(U in Q)!Q.hasOwnProperty(U)||te&&te.hasOwnProperty(U)||(m||(m={}),m[U]="");for(U in te)te.hasOwnProperty(U)&&Q[U]!==te[U]&&(m||(m={}),m[U]=te[U])}else m||(C||(C=[]),C.push(ce,m)),m=te;else ce==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,Q=Q?Q.__html:void 0,te!=null&&Q!==te&&(C=C||[]).push(ce,te)):ce==="children"?typeof te!="string"&&typeof te!="number"||(C=C||[]).push(ce,""+te):ce!=="suppressContentEditableWarning"&&ce!=="suppressHydrationWarning"&&(s.hasOwnProperty(ce)?(te!=null&&ce==="onScroll"&&st("scroll",i),C||Q===te||(C=[])):(C=C||[]).push(ce,te))}m&&(C=C||[]).push("style",m);var ce=C;(c.updateQueue=ce)&&(c.flags|=4)}},m1=function(i,c,m,y){m!==y&&(c.flags|=4)};function rl(i,c){if(!ct)switch(i.tailMode){case"hidden":c=i.tail;for(var m=null;c!==null;)c.alternate!==null&&(m=c),c=c.sibling;m===null?i.tail=null:m.sibling=null;break;case"collapsed":m=i.tail;for(var y=null;m!==null;)m.alternate!==null&&(y=m),m=m.sibling;y===null?c||i.tail===null?i.tail=null:i.tail.sibling=null:y.sibling=null}}function Vt(i){var c=i.alternate!==null&&i.alternate.child===i.child,m=0,y=0;if(c)for(var j=i.child;j!==null;)m|=j.lanes|j.childLanes,y|=j.subtreeFlags&14680064,y|=j.flags&14680064,j.return=i,j=j.sibling;else for(j=i.child;j!==null;)m|=j.lanes|j.childLanes,y|=j.subtreeFlags,y|=j.flags,j.return=i,j=j.sibling;return i.subtreeFlags|=y,i.childLanes=m,c}function EP(i,c,m){var y=c.pendingProps;switch(Uh(c),c.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Vt(c),null;case 1:return rn(c.type)&&jc(),Vt(c),null;case 3:return y=c.stateNode,bo(),at(nn),at(Wt),tf(),y.pendingContext&&(y.context=y.pendingContext,y.pendingContext=null),(i===null||i.child===null)&&(Tc(c)?c.flags|=4:i===null||i.memoizedState.isDehydrated&&(c.flags&256)===0||(c.flags|=1024,Xn!==null&&(Mf(Xn),Xn=null))),bf(i,c),Vt(c),null;case 5:Qh(c);var j=ga(Ji.current);if(m=c.type,i!==null&&c.stateNode!=null)p1(i,c,m,y,j),i.ref!==c.ref&&(c.flags|=512,c.flags|=2097152);else{if(!y){if(c.stateNode===null)throw Error(n(166));return Vt(c),null}if(i=ga(Er.current),Tc(c)){y=c.stateNode,m=c.type;var C=c.memoizedProps;switch(y[_r]=c,y[Gi]=C,i=(c.mode&1)!==0,m){case"dialog":st("cancel",y),st("close",y);break;case"iframe":case"object":case"embed":st("load",y);break;case"video":case"audio":for(j=0;j<Wi.length;j++)st(Wi[j],y);break;case"source":st("error",y);break;case"img":case"image":case"link":st("error",y),st("load",y);break;case"details":st("toggle",y);break;case"input":se(y,C),st("invalid",y);break;case"select":y._wrapperState={wasMultiple:!!C.multiple},st("invalid",y);break;case"textarea":le(y,C),st("invalid",y)}Rt(m,C),j=null;for(var U in C)if(C.hasOwnProperty(U)){var Q=C[U];U==="children"?typeof Q=="string"?y.textContent!==Q&&(C.suppressHydrationWarning!==!0&&bc(y.textContent,Q,i),j=["children",Q]):typeof Q=="number"&&y.textContent!==""+Q&&(C.suppressHydrationWarning!==!0&&bc(y.textContent,Q,i),j=["children",""+Q]):s.hasOwnProperty(U)&&Q!=null&&U==="onScroll"&&st("scroll",y)}switch(m){case"input":me(y),he(y,C,!0);break;case"textarea":me(y),$e(y);break;case"select":case"option":break;default:typeof C.onClick=="function"&&(y.onclick=kc)}y=j,c.updateQueue=y,y!==null&&(c.flags|=4)}else{U=j.nodeType===9?j:j.ownerDocument,i==="http://www.w3.org/1999/xhtml"&&(i=Oe(m)),i==="http://www.w3.org/1999/xhtml"?m==="script"?(i=U.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof y.is=="string"?i=U.createElement(m,{is:y.is}):(i=U.createElement(m),m==="select"&&(U=i,y.multiple?U.multiple=!0:y.size&&(U.size=y.size))):i=U.createElementNS(i,m),i[_r]=c,i[Gi]=y,f1(i,c,!1,!1),c.stateNode=i;e:{switch(U=yt(m,y),m){case"dialog":st("cancel",i),st("close",i),j=y;break;case"iframe":case"object":case"embed":st("load",i),j=y;break;case"video":case"audio":for(j=0;j<Wi.length;j++)st(Wi[j],i);j=y;break;case"source":st("error",i),j=y;break;case"img":case"image":case"link":st("error",i),st("load",i),j=y;break;case"details":st("toggle",i),j=y;break;case"input":se(i,y),j=xe(i,y),st("invalid",i);break;case"option":j=y;break;case"select":i._wrapperState={wasMultiple:!!y.multiple},j=W({},y,{value:void 0}),st("invalid",i);break;case"textarea":le(i,y),j=Ve(i,y),st("invalid",i);break;default:j=y}Rt(m,j),Q=j;for(C in Q)if(Q.hasOwnProperty(C)){var te=Q[C];C==="style"?rt(i,te):C==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,te!=null&&it(i,te)):C==="children"?typeof te=="string"?(m!=="textarea"||te!=="")&&At(i,te):typeof te=="number"&&At(i,""+te):C!=="suppressContentEditableWarning"&&C!=="suppressHydrationWarning"&&C!=="autoFocus"&&(s.hasOwnProperty(C)?te!=null&&C==="onScroll"&&st("scroll",i):te!=null&&_(i,C,te,U))}switch(m){case"input":me(i),he(i,y,!1);break;case"textarea":me(i),$e(i);break;case"option":y.value!=null&&i.setAttribute("value",""+ee(y.value));break;case"select":i.multiple=!!y.multiple,C=y.value,C!=null?Le(i,!!y.multiple,C,!1):y.defaultValue!=null&&Le(i,!!y.multiple,y.defaultValue,!0);break;default:typeof j.onClick=="function"&&(i.onclick=kc)}switch(m){case"button":case"input":case"select":case"textarea":y=!!y.autoFocus;break e;case"img":y=!0;break e;default:y=!1}}y&&(c.flags|=4)}c.ref!==null&&(c.flags|=512,c.flags|=2097152)}return Vt(c),null;case 6:if(i&&c.stateNode!=null)m1(i,c,i.memoizedProps,y);else{if(typeof y!="string"&&c.stateNode===null)throw Error(n(166));if(m=ga(Ji.current),ga(Er.current),Tc(c)){if(y=c.stateNode,m=c.memoizedProps,y[_r]=c,(C=y.nodeValue!==m)&&(i=pn,i!==null))switch(i.tag){case 3:bc(y.nodeValue,m,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&bc(y.nodeValue,m,(i.mode&1)!==0)}C&&(c.flags|=4)}else y=(m.nodeType===9?m:m.ownerDocument).createTextNode(y),y[_r]=c,c.stateNode=y}return Vt(c),null;case 13:if(at(dt),y=c.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(ct&&mn!==null&&(c.mode&1)!==0&&(c.flags&128)===0)wk(),yo(),c.flags|=98560,C=!1;else if(C=Tc(c),y!==null&&y.dehydrated!==null){if(i===null){if(!C)throw Error(n(318));if(C=c.memoizedState,C=C!==null?C.dehydrated:null,!C)throw Error(n(317));C[_r]=c}else yo(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;Vt(c),C=!1}else Xn!==null&&(Mf(Xn),Xn=null),C=!0;if(!C)return c.flags&65536?c:null}return(c.flags&128)!==0?(c.lanes=m,c):(y=y!==null,y!==(i!==null&&i.memoizedState!==null)&&y&&(c.child.flags|=8192,(c.mode&1)!==0&&(i===null||(dt.current&1)!==0?St===0&&(St=3):Of())),c.updateQueue!==null&&(c.flags|=4),Vt(c),null);case 4:return bo(),bf(i,c),i===null&&Hi(c.stateNode.containerInfo),Vt(c),null;case 10:return Kh(c.type._context),Vt(c),null;case 17:return rn(c.type)&&jc(),Vt(c),null;case 19:if(at(dt),C=c.memoizedState,C===null)return Vt(c),null;if(y=(c.flags&128)!==0,U=C.rendering,U===null)if(y)rl(C,!1);else{if(St!==0||i!==null&&(i.flags&128)!==0)for(i=c.child;i!==null;){if(U=Oc(i),U!==null){for(c.flags|=128,rl(C,!1),y=U.updateQueue,y!==null&&(c.updateQueue=y,c.flags|=4),c.subtreeFlags=0,y=m,m=c.child;m!==null;)C=m,i=y,C.flags&=14680066,U=C.alternate,U===null?(C.childLanes=0,C.lanes=i,C.child=null,C.subtreeFlags=0,C.memoizedProps=null,C.memoizedState=null,C.updateQueue=null,C.dependencies=null,C.stateNode=null):(C.childLanes=U.childLanes,C.lanes=U.lanes,C.child=U.child,C.subtreeFlags=0,C.deletions=null,C.memoizedProps=U.memoizedProps,C.memoizedState=U.memoizedState,C.updateQueue=U.updateQueue,C.type=U.type,i=U.dependencies,C.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),m=m.sibling;return tt(dt,dt.current&1|2),c.child}i=i.sibling}C.tail!==null&&Qe()>So&&(c.flags|=128,y=!0,rl(C,!1),c.lanes=4194304)}else{if(!y)if(i=Oc(U),i!==null){if(c.flags|=128,y=!0,m=i.updateQueue,m!==null&&(c.updateQueue=m,c.flags|=4),rl(C,!0),C.tail===null&&C.tailMode==="hidden"&&!U.alternate&&!ct)return Vt(c),null}else 2*Qe()-C.renderingStartTime>So&&m!==1073741824&&(c.flags|=128,y=!0,rl(C,!1),c.lanes=4194304);C.isBackwards?(U.sibling=c.child,c.child=U):(m=C.last,m!==null?m.sibling=U:c.child=U,C.last=U)}return C.tail!==null?(c=C.tail,C.rendering=c,C.tail=c.sibling,C.renderingStartTime=Qe(),c.sibling=null,m=dt.current,tt(dt,y?m&1|2:m&1),c):(Vt(c),null);case 22:case 23:return If(),y=c.memoizedState!==null,i!==null&&i.memoizedState!==null!==y&&(c.flags|=8192),y&&(c.mode&1)!==0?(gn&1073741824)!==0&&(Vt(c),c.subtreeFlags&6&&(c.flags|=8192)):Vt(c),null;case 24:return null;case 25:return null}throw Error(n(156,c.tag))}function CP(i,c){switch(Uh(c),c.tag){case 1:return rn(c.type)&&jc(),i=c.flags,i&65536?(c.flags=i&-65537|128,c):null;case 3:return bo(),at(nn),at(Wt),tf(),i=c.flags,(i&65536)!==0&&(i&128)===0?(c.flags=i&-65537|128,c):null;case 5:return Qh(c),null;case 13:if(at(dt),i=c.memoizedState,i!==null&&i.dehydrated!==null){if(c.alternate===null)throw Error(n(340));yo()}return i=c.flags,i&65536?(c.flags=i&-65537|128,c):null;case 19:return at(dt),null;case 4:return bo(),null;case 10:return Kh(c.type._context),null;case 22:case 23:return If(),null;case 24:return null;default:return null}}var Wc=!1,Gt=!1,TP=typeof WeakSet=="function"?WeakSet:Set,Se=null;function No(i,c){var m=i.ref;if(m!==null)if(typeof m=="function")try{m(null)}catch(y){pt(i,c,y)}else m.current=null}function kf(i,c,m){try{m()}catch(y){pt(i,c,y)}}var g1=!1;function AP(i,c){if($h=js,i=K0(),Sh(i)){if("selectionStart"in i)var m={start:i.selectionStart,end:i.selectionEnd};else e:{m=(m=i.ownerDocument)&&m.defaultView||window;var y=m.getSelection&&m.getSelection();if(y&&y.rangeCount!==0){m=y.anchorNode;var j=y.anchorOffset,C=y.focusNode;y=y.focusOffset;try{m.nodeType,C.nodeType}catch{m=null;break e}var U=0,Q=-1,te=-1,ce=0,ye=0,be=i,ge=null;t:for(;;){for(var Ne;be!==m||j!==0&&be.nodeType!==3||(Q=U+j),be!==C||y!==0&&be.nodeType!==3||(te=U+y),be.nodeType===3&&(U+=be.nodeValue.length),(Ne=be.firstChild)!==null;)ge=be,be=Ne;for(;;){if(be===i)break t;if(ge===m&&++ce===j&&(Q=U),ge===C&&++ye===y&&(te=U),(Ne=be.nextSibling)!==null)break;be=ge,ge=be.parentNode}be=Ne}m=Q===-1||te===-1?null:{start:Q,end:te}}else m=null}m=m||{start:0,end:0}}else m=null;for(Ih={focusedElem:i,selectionRange:m},js=!1,Se=c;Se!==null;)if(c=Se,i=c.child,(c.subtreeFlags&1028)!==0&&i!==null)i.return=c,Se=i;else for(;Se!==null;){c=Se;try{var Ee=c.alternate;if((c.flags&1024)!==0)switch(c.tag){case 0:case 11:case 15:break;case 1:if(Ee!==null){var Ce=Ee.memoizedProps,wt=Ee.memoizedState,oe=c.stateNode,ne=oe.getSnapshotBeforeUpdate(c.elementType===c.type?Ce:Zn(c.type,Ce),wt);oe.__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(ke){pt(c,c.return,ke)}if(i=c.sibling,i!==null){i.return=c.return,Se=i;break}Se=c.return}return Ee=g1,g1=!1,Ee}function sl(i,c,m){var y=c.updateQueue;if(y=y!==null?y.lastEffect:null,y!==null){var j=y=y.next;do{if((j.tag&i)===i){var C=j.destroy;j.destroy=void 0,C!==void 0&&kf(c,m,C)}j=j.next}while(j!==y)}}function Hc(i,c){if(c=c.updateQueue,c=c!==null?c.lastEffect:null,c!==null){var m=c=c.next;do{if((m.tag&i)===i){var y=m.create;m.destroy=y()}m=m.next}while(m!==c)}}function Nf(i){var c=i.ref;if(c!==null){var m=i.stateNode;switch(i.tag){case 5:i=m;break;default:i=m}typeof c=="function"?c(i):c.current=i}}function y1(i){var c=i.alternate;c!==null&&(i.alternate=null,y1(c)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(c=i.stateNode,c!==null&&(delete c[_r],delete c[Gi],delete c[Dh],delete c[hP],delete c[fP])),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}function w1(i){return i.tag===5||i.tag===3||i.tag===4}function v1(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||w1(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function jf(i,c,m){var y=i.tag;if(y===5||y===6)i=i.stateNode,c?m.nodeType===8?m.parentNode.insertBefore(i,c):m.insertBefore(i,c):(m.nodeType===8?(c=m.parentNode,c.insertBefore(i,m)):(c=m,c.appendChild(i)),m=m._reactRootContainer,m!=null||c.onclick!==null||(c.onclick=kc));else if(y!==4&&(i=i.child,i!==null))for(jf(i,c,m),i=i.sibling;i!==null;)jf(i,c,m),i=i.sibling}function Sf(i,c,m){var y=i.tag;if(y===5||y===6)i=i.stateNode,c?m.insertBefore(i,c):m.appendChild(i);else if(y!==4&&(i=i.child,i!==null))for(Sf(i,c,m),i=i.sibling;i!==null;)Sf(i,c,m),i=i.sibling}var Bt=null,Jn=!1;function Ls(i,c,m){for(m=m.child;m!==null;)x1(i,c,m),m=m.sibling}function x1(i,c,m){if(Yt&&typeof Yt.onCommitFiberUnmount=="function")try{Yt.onCommitFiberUnmount(Kr,m)}catch{}switch(m.tag){case 5:Gt||No(m,c);case 6:var y=Bt,j=Jn;Bt=null,Ls(i,c,m),Bt=y,Jn=j,Bt!==null&&(Jn?(i=Bt,m=m.stateNode,i.nodeType===8?i.parentNode.removeChild(m):i.removeChild(m)):Bt.removeChild(m.stateNode));break;case 18:Bt!==null&&(Jn?(i=Bt,m=m.stateNode,i.nodeType===8?Ph(i.parentNode,m):i.nodeType===1&&Ph(i,m),Ns(i)):Ph(Bt,m.stateNode));break;case 4:y=Bt,j=Jn,Bt=m.stateNode.containerInfo,Jn=!0,Ls(i,c,m),Bt=y,Jn=j;break;case 0:case 11:case 14:case 15:if(!Gt&&(y=m.updateQueue,y!==null&&(y=y.lastEffect,y!==null))){j=y=y.next;do{var C=j,U=C.destroy;C=C.tag,U!==void 0&&((C&2)!==0||(C&4)!==0)&&kf(m,c,U),j=j.next}while(j!==y)}Ls(i,c,m);break;case 1:if(!Gt&&(No(m,c),y=m.stateNode,typeof y.componentWillUnmount=="function"))try{y.props=m.memoizedProps,y.state=m.memoizedState,y.componentWillUnmount()}catch(Q){pt(m,c,Q)}Ls(i,c,m);break;case 21:Ls(i,c,m);break;case 22:m.mode&1?(Gt=(y=Gt)||m.memoizedState!==null,Ls(i,c,m),Gt=y):Ls(i,c,m);break;default:Ls(i,c,m)}}function b1(i){var c=i.updateQueue;if(c!==null){i.updateQueue=null;var m=i.stateNode;m===null&&(m=i.stateNode=new TP),c.forEach(function(y){var j=FP.bind(null,i,y);m.has(y)||(m.add(y),y.then(j,j))})}}function Qn(i,c){var m=c.deletions;if(m!==null)for(var y=0;y<m.length;y++){var j=m[y];try{var C=i,U=c,Q=U;e:for(;Q!==null;){switch(Q.tag){case 5:Bt=Q.stateNode,Jn=!1;break e;case 3:Bt=Q.stateNode.containerInfo,Jn=!0;break e;case 4:Bt=Q.stateNode.containerInfo,Jn=!0;break e}Q=Q.return}if(Bt===null)throw Error(n(160));x1(C,U,j),Bt=null,Jn=!1;var te=j.alternate;te!==null&&(te.return=null),j.return=null}catch(ce){pt(j,c,ce)}}if(c.subtreeFlags&12854)for(c=c.child;c!==null;)k1(c,i),c=c.sibling}function k1(i,c){var m=i.alternate,y=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(Qn(c,i),Tr(i),y&4){try{sl(3,i,i.return),Hc(3,i)}catch(Ce){pt(i,i.return,Ce)}try{sl(5,i,i.return)}catch(Ce){pt(i,i.return,Ce)}}break;case 1:Qn(c,i),Tr(i),y&512&&m!==null&&No(m,m.return);break;case 5:if(Qn(c,i),Tr(i),y&512&&m!==null&&No(m,m.return),i.flags&32){var j=i.stateNode;try{At(j,"")}catch(Ce){pt(i,i.return,Ce)}}if(y&4&&(j=i.stateNode,j!=null)){var C=i.memoizedProps,U=m!==null?m.memoizedProps:C,Q=i.type,te=i.updateQueue;if(i.updateQueue=null,te!==null)try{Q==="input"&&C.type==="radio"&&C.name!=null&&ve(j,C),yt(Q,U);var ce=yt(Q,C);for(U=0;U<te.length;U+=2){var ye=te[U],be=te[U+1];ye==="style"?rt(j,be):ye==="dangerouslySetInnerHTML"?it(j,be):ye==="children"?At(j,be):_(j,ye,be,ce)}switch(Q){case"input":fe(j,C);break;case"textarea":je(j,C);break;case"select":var ge=j._wrapperState.wasMultiple;j._wrapperState.wasMultiple=!!C.multiple;var Ne=C.value;Ne!=null?Le(j,!!C.multiple,Ne,!1):ge!==!!C.multiple&&(C.defaultValue!=null?Le(j,!!C.multiple,C.defaultValue,!0):Le(j,!!C.multiple,C.multiple?[]:"",!1))}j[Gi]=C}catch(Ce){pt(i,i.return,Ce)}}break;case 6:if(Qn(c,i),Tr(i),y&4){if(i.stateNode===null)throw Error(n(162));j=i.stateNode,C=i.memoizedProps;try{j.nodeValue=C}catch(Ce){pt(i,i.return,Ce)}}break;case 3:if(Qn(c,i),Tr(i),y&4&&m!==null&&m.memoizedState.isDehydrated)try{Ns(c.containerInfo)}catch(Ce){pt(i,i.return,Ce)}break;case 4:Qn(c,i),Tr(i);break;case 13:Qn(c,i),Tr(i),j=i.child,j.flags&8192&&(C=j.memoizedState!==null,j.stateNode.isHidden=C,!C||j.alternate!==null&&j.alternate.memoizedState!==null||(Cf=Qe())),y&4&&b1(i);break;case 22:if(ye=m!==null&&m.memoizedState!==null,i.mode&1?(Gt=(ce=Gt)||ye,Qn(c,i),Gt=ce):Qn(c,i),Tr(i),y&8192){if(ce=i.memoizedState!==null,(i.stateNode.isHidden=ce)&&!ye&&(i.mode&1)!==0)for(Se=i,ye=i.child;ye!==null;){for(be=Se=ye;Se!==null;){switch(ge=Se,Ne=ge.child,ge.tag){case 0:case 11:case 14:case 15:sl(4,ge,ge.return);break;case 1:No(ge,ge.return);var Ee=ge.stateNode;if(typeof Ee.componentWillUnmount=="function"){y=ge,m=ge.return;try{c=y,Ee.props=c.memoizedProps,Ee.state=c.memoizedState,Ee.componentWillUnmount()}catch(Ce){pt(y,m,Ce)}}break;case 5:No(ge,ge.return);break;case 22:if(ge.memoizedState!==null){S1(be);continue}}Ne!==null?(Ne.return=ge,Se=Ne):S1(be)}ye=ye.sibling}e:for(ye=null,be=i;;){if(be.tag===5){if(ye===null){ye=be;try{j=be.stateNode,ce?(C=j.style,typeof C.setProperty=="function"?C.setProperty("display","none","important"):C.display="none"):(Q=be.stateNode,te=be.memoizedProps.style,U=te!=null&&te.hasOwnProperty("display")?te.display:null,Q.style.display=Je("display",U))}catch(Ce){pt(i,i.return,Ce)}}}else if(be.tag===6){if(ye===null)try{be.stateNode.nodeValue=ce?"":be.memoizedProps}catch(Ce){pt(i,i.return,Ce)}}else if((be.tag!==22&&be.tag!==23||be.memoizedState===null||be===i)&&be.child!==null){be.child.return=be,be=be.child;continue}if(be===i)break e;for(;be.sibling===null;){if(be.return===null||be.return===i)break e;ye===be&&(ye=null),be=be.return}ye===be&&(ye=null),be.sibling.return=be.return,be=be.sibling}}break;case 19:Qn(c,i),Tr(i),y&4&&b1(i);break;case 21:break;default:Qn(c,i),Tr(i)}}function Tr(i){var c=i.flags;if(c&2){try{e:{for(var m=i.return;m!==null;){if(w1(m)){var y=m;break e}m=m.return}throw Error(n(160))}switch(y.tag){case 5:var j=y.stateNode;y.flags&32&&(At(j,""),y.flags&=-33);var C=v1(i);Sf(i,C,j);break;case 3:case 4:var U=y.stateNode.containerInfo,Q=v1(i);jf(i,Q,U);break;default:throw Error(n(161))}}catch(te){pt(i,i.return,te)}i.flags&=-3}c&4096&&(i.flags&=-4097)}function RP(i,c,m){Se=i,N1(i)}function N1(i,c,m){for(var y=(i.mode&1)!==0;Se!==null;){var j=Se,C=j.child;if(j.tag===22&&y){var U=j.memoizedState!==null||Wc;if(!U){var Q=j.alternate,te=Q!==null&&Q.memoizedState!==null||Gt;Q=Wc;var ce=Gt;if(Wc=U,(Gt=te)&&!ce)for(Se=j;Se!==null;)U=Se,te=U.child,U.tag===22&&U.memoizedState!==null?_1(j):te!==null?(te.return=U,Se=te):_1(j);for(;C!==null;)Se=C,N1(C),C=C.sibling;Se=j,Wc=Q,Gt=ce}j1(i)}else(j.subtreeFlags&8772)!==0&&C!==null?(C.return=j,Se=C):j1(i)}}function j1(i){for(;Se!==null;){var c=Se;if((c.flags&8772)!==0){var m=c.alternate;try{if((c.flags&8772)!==0)switch(c.tag){case 0:case 11:case 15:Gt||Hc(5,c);break;case 1:var y=c.stateNode;if(c.flags&4&&!Gt)if(m===null)y.componentDidMount();else{var j=c.elementType===c.type?m.memoizedProps:Zn(c.type,m.memoizedProps);y.componentDidUpdate(j,m.memoizedState,y.__reactInternalSnapshotBeforeUpdate)}var C=c.updateQueue;C!==null&&Sk(c,C,y);break;case 3:var U=c.updateQueue;if(U!==null){if(m=null,c.child!==null)switch(c.child.tag){case 5:m=c.child.stateNode;break;case 1:m=c.child.stateNode}Sk(c,U,m)}break;case 5:var Q=c.stateNode;if(m===null&&c.flags&4){m=Q;var te=c.memoizedProps;switch(c.type){case"button":case"input":case"select":case"textarea":te.autoFocus&&m.focus();break;case"img":te.src&&(m.src=te.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(c.memoizedState===null){var ce=c.alternate;if(ce!==null){var ye=ce.memoizedState;if(ye!==null){var be=ye.dehydrated;be!==null&&Ns(be)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Gt||c.flags&512&&Nf(c)}catch(ge){pt(c,c.return,ge)}}if(c===i){Se=null;break}if(m=c.sibling,m!==null){m.return=c.return,Se=m;break}Se=c.return}}function S1(i){for(;Se!==null;){var c=Se;if(c===i){Se=null;break}var m=c.sibling;if(m!==null){m.return=c.return,Se=m;break}Se=c.return}}function _1(i){for(;Se!==null;){var c=Se;try{switch(c.tag){case 0:case 11:case 15:var m=c.return;try{Hc(4,c)}catch(te){pt(c,m,te)}break;case 1:var y=c.stateNode;if(typeof y.componentDidMount=="function"){var j=c.return;try{y.componentDidMount()}catch(te){pt(c,j,te)}}var C=c.return;try{Nf(c)}catch(te){pt(c,C,te)}break;case 5:var U=c.return;try{Nf(c)}catch(te){pt(c,U,te)}}}catch(te){pt(c,c.return,te)}if(c===i){Se=null;break}var Q=c.sibling;if(Q!==null){Q.return=c.return,Se=Q;break}Se=c.return}}var MP=Math.ceil,Vc=E.ReactCurrentDispatcher,_f=E.ReactCurrentOwner,Rn=E.ReactCurrentBatchConfig,He=0,$t=null,xt=null,qt=0,gn=0,jo=Rs(0),St=0,al=null,wa=0,Gc=0,Ef=0,ol=null,an=null,Cf=0,So=1/0,as=null,Kc=!1,Tf=null,Ps=null,Yc=!1,Ds=null,Xc=0,il=0,Af=null,Zc=-1,Jc=0;function Zt(){return(He&6)!==0?Qe():Zc!==-1?Zc:Zc=Qe()}function Fs(i){return(i.mode&1)===0?1:(He&2)!==0&&qt!==0?qt&-qt:mP.transition!==null?(Jc===0&&(Jc=dc()),Jc):(i=Ge,i!==0||(i=window.event,i=i===void 0?16:pc(i.type)),i)}function er(i,c,m,y){if(50<il)throw il=0,Af=null,Error(n(185));vs(i,m,y),((He&2)===0||i!==$t)&&(i===$t&&((He&2)===0&&(Gc|=m),St===4&&Bs(i,qt)),on(i,y),m===1&&He===0&&(c.mode&1)===0&&(So=Qe()+500,_c&&$s()))}function on(i,c){var m=i.callbackNode;Xr(i,c);var y=ws(i,i===$t?qt:0);if(y===0)m!==null&&gs(m),i.callbackNode=null,i.callbackPriority=0;else if(c=y&-y,i.callbackPriority!==c){if(m!=null&&gs(m),c===1)i.tag===0?pP(C1.bind(null,i)):fk(C1.bind(null,i)),uP(function(){(He&6)===0&&$s()}),m=null;else{switch(Ti(y)){case 1:m=Gn;break;case 4:m=Gr;break;case 16:m=Kn;break;case 536870912:m=Xa;break;default:m=Kn}m=L1(m,E1.bind(null,i))}i.callbackPriority=c,i.callbackNode=m}}function E1(i,c){if(Zc=-1,Jc=0,(He&6)!==0)throw Error(n(327));var m=i.callbackNode;if(_o()&&i.callbackNode!==m)return null;var y=ws(i,i===$t?qt:0);if(y===0)return null;if((y&30)!==0||(y&i.expiredLanes)!==0||c)c=Qc(i,y);else{c=y;var j=He;He|=2;var C=A1();($t!==i||qt!==c)&&(as=null,So=Qe()+500,xa(i,c));do try{OP();break}catch(Q){T1(i,Q)}while(!0);Gh(),Vc.current=C,He=j,xt!==null?c=0:($t=null,qt=0,c=St)}if(c!==0){if(c===2&&(j=_i(i),j!==0&&(y=j,c=Rf(i,j))),c===1)throw m=al,xa(i,0),Bs(i,y),on(i,Qe()),m;if(c===6)Bs(i,y);else{if(j=i.current.alternate,(y&30)===0&&!$P(j)&&(c=Qc(i,y),c===2&&(C=_i(i),C!==0&&(y=C,c=Rf(i,C))),c===1))throw m=al,xa(i,0),Bs(i,y),on(i,Qe()),m;switch(i.finishedWork=j,i.finishedLanes=y,c){case 0:case 1:throw Error(n(345));case 2:ba(i,an,as);break;case 3:if(Bs(i,y),(y&130023424)===y&&(c=Cf+500-Qe(),10<c)){if(ws(i,0)!==0)break;if(j=i.suspendedLanes,(j&y)!==y){Zt(),i.pingedLanes|=i.suspendedLanes&j;break}i.timeoutHandle=Lh(ba.bind(null,i,an,as),c);break}ba(i,an,as);break;case 4:if(Bs(i,y),(y&4194240)===y)break;for(c=i.eventTimes,j=-1;0<y;){var U=31-tn(y);C=1<<U,U=c[U],U>j&&(j=U),y&=~C}if(y=j,y=Qe()-y,y=(120>y?120:480>y?480:1080>y?1080:1920>y?1920:3e3>y?3e3:4320>y?4320:1960*MP(y/1960))-y,10<y){i.timeoutHandle=Lh(ba.bind(null,i,an,as),y);break}ba(i,an,as);break;case 5:ba(i,an,as);break;default:throw Error(n(329))}}}return on(i,Qe()),i.callbackNode===m?E1.bind(null,i):null}function Rf(i,c){var m=ol;return i.current.memoizedState.isDehydrated&&(xa(i,c).flags|=256),i=Qc(i,c),i!==2&&(c=an,an=m,c!==null&&Mf(c)),i}function Mf(i){an===null?an=i:an.push.apply(an,i)}function $P(i){for(var c=i;;){if(c.flags&16384){var m=c.updateQueue;if(m!==null&&(m=m.stores,m!==null))for(var y=0;y<m.length;y++){var j=m[y],C=j.getSnapshot;j=j.value;try{if(!Yn(C(),j))return!1}catch{return!1}}}if(m=c.child,c.subtreeFlags&16384&&m!==null)m.return=c,c=m;else{if(c===i)break;for(;c.sibling===null;){if(c.return===null||c.return===i)return!0;c=c.return}c.sibling.return=c.return,c=c.sibling}}return!0}function Bs(i,c){for(c&=~Ef,c&=~Gc,i.suspendedLanes|=c,i.pingedLanes&=~c,i=i.expirationTimes;0<c;){var m=31-tn(c),y=1<<m;i[m]=-1,c&=~y}}function C1(i){if((He&6)!==0)throw Error(n(327));_o();var c=ws(i,0);if((c&1)===0)return on(i,Qe()),null;var m=Qc(i,c);if(i.tag!==0&&m===2){var y=_i(i);y!==0&&(c=y,m=Rf(i,y))}if(m===1)throw m=al,xa(i,0),Bs(i,c),on(i,Qe()),m;if(m===6)throw Error(n(345));return i.finishedWork=i.current.alternate,i.finishedLanes=c,ba(i,an,as),on(i,Qe()),null}function $f(i,c){var m=He;He|=1;try{return i(c)}finally{He=m,He===0&&(So=Qe()+500,_c&&$s())}}function va(i){Ds!==null&&Ds.tag===0&&(He&6)===0&&_o();var c=He;He|=1;var m=Rn.transition,y=Ge;try{if(Rn.transition=null,Ge=1,i)return i()}finally{Ge=y,Rn.transition=m,He=c,(He&6)===0&&$s()}}function If(){gn=jo.current,at(jo)}function xa(i,c){i.finishedWork=null,i.finishedLanes=0;var m=i.timeoutHandle;if(m!==-1&&(i.timeoutHandle=-1,cP(m)),xt!==null)for(m=xt.return;m!==null;){var y=m;switch(Uh(y),y.tag){case 1:y=y.type.childContextTypes,y!=null&&jc();break;case 3:bo(),at(nn),at(Wt),tf();break;case 5:Qh(y);break;case 4:bo();break;case 13:at(dt);break;case 19:at(dt);break;case 10:Kh(y.type._context);break;case 22:case 23:If()}m=m.return}if($t=i,xt=i=qs(i.current,null),qt=gn=c,St=0,al=null,Ef=Gc=wa=0,an=ol=null,ma!==null){for(c=0;c<ma.length;c++)if(m=ma[c],y=m.interleaved,y!==null){m.interleaved=null;var j=y.next,C=m.pending;if(C!==null){var U=C.next;C.next=j,y.next=U}m.pending=y}ma=null}return i}function T1(i,c){do{var m=xt;try{if(Gh(),Lc.current=Bc,Pc){for(var y=ht.memoizedState;y!==null;){var j=y.queue;j!==null&&(j.pending=null),y=y.next}Pc=!1}if(ya=0,Mt=jt=ht=null,Qi=!1,el=0,_f.current=null,m===null||m.return===null){St=1,al=c,xt=null;break}e:{var C=i,U=m.return,Q=m,te=c;if(c=qt,Q.flags|=32768,te!==null&&typeof te=="object"&&typeof te.then=="function"){var ce=te,ye=Q,be=ye.tag;if((ye.mode&1)===0&&(be===0||be===11||be===15)){var ge=ye.alternate;ge?(ye.updateQueue=ge.updateQueue,ye.memoizedState=ge.memoizedState,ye.lanes=ge.lanes):(ye.updateQueue=null,ye.memoizedState=null)}var Ne=e1(U);if(Ne!==null){Ne.flags&=-257,t1(Ne,U,Q,C,c),Ne.mode&1&&Qk(C,ce,c),c=Ne,te=ce;var Ee=c.updateQueue;if(Ee===null){var Ce=new Set;Ce.add(te),c.updateQueue=Ce}else Ee.add(te);break e}else{if((c&1)===0){Qk(C,ce,c),Of();break e}te=Error(n(426))}}else if(ct&&Q.mode&1){var wt=e1(U);if(wt!==null){(wt.flags&65536)===0&&(wt.flags|=256),t1(wt,U,Q,C,c),Hh(ko(te,Q));break e}}C=te=ko(te,Q),St!==4&&(St=2),ol===null?ol=[C]:ol.push(C),C=U;do{switch(C.tag){case 3:C.flags|=65536,c&=-c,C.lanes|=c;var oe=Zk(C,te,c);jk(C,oe);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"&&(Ps===null||!Ps.has(ie)))){C.flags|=65536,c&=-c,C.lanes|=c;var ke=Jk(C,Q,c);jk(C,ke);break e}}C=C.return}while(C!==null)}M1(m)}catch(Te){c=Te,xt===m&&m!==null&&(xt=m=m.return);continue}break}while(!0)}function A1(){var i=Vc.current;return Vc.current=Bc,i===null?Bc:i}function Of(){(St===0||St===3||St===2)&&(St=4),$t===null||(wa&268435455)===0&&(Gc&268435455)===0||Bs($t,qt)}function Qc(i,c){var m=He;He|=2;var y=A1();($t!==i||qt!==c)&&(as=null,xa(i,c));do try{IP();break}catch(j){T1(i,j)}while(!0);if(Gh(),He=m,Vc.current=y,xt!==null)throw Error(n(261));return $t=null,qt=0,St}function IP(){for(;xt!==null;)R1(xt)}function OP(){for(;xt!==null&&!vr();)R1(xt)}function R1(i){var c=O1(i.alternate,i,gn);i.memoizedProps=i.pendingProps,c===null?M1(i):xt=c,_f.current=null}function M1(i){var c=i;do{var m=c.alternate;if(i=c.return,(c.flags&32768)===0){if(m=EP(m,c,gn),m!==null){xt=m;return}}else{if(m=CP(m,c),m!==null){m.flags&=32767,xt=m;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{St=6,xt=null;return}}if(c=c.sibling,c!==null){xt=c;return}xt=c=i}while(c!==null);St===0&&(St=5)}function ba(i,c,m){var y=Ge,j=Rn.transition;try{Rn.transition=null,Ge=1,LP(i,c,m,y)}finally{Rn.transition=j,Ge=y}return null}function LP(i,c,m,y){do _o();while(Ds!==null);if((He&6)!==0)throw Error(n(327));m=i.finishedWork;var j=i.finishedLanes;if(m===null)return null;if(i.finishedWork=null,i.finishedLanes=0,m===i.current)throw Error(n(177));i.callbackNode=null,i.callbackPriority=0;var C=m.lanes|m.childLanes;if(xs(i,C),i===$t&&(xt=$t=null,qt=0),(m.subtreeFlags&2064)===0&&(m.flags&2064)===0||Yc||(Yc=!0,L1(Kn,function(){return _o(),null})),C=(m.flags&15990)!==0,(m.subtreeFlags&15990)!==0||C){C=Rn.transition,Rn.transition=null;var U=Ge;Ge=1;var Q=He;He|=4,_f.current=null,AP(i,m),k1(m,i),nP(Ih),js=!!$h,Ih=$h=null,i.current=m,RP(m),Vn(),He=Q,Ge=U,Rn.transition=C}else i.current=m;if(Yc&&(Yc=!1,Ds=i,Xc=j),C=i.pendingLanes,C===0&&(Ps=null),ra(m.stateNode),on(i,Qe()),c!==null)for(y=i.onRecoverableError,m=0;m<c.length;m++)j=c[m],y(j.value,{componentStack:j.stack,digest:j.digest});if(Kc)throw Kc=!1,i=Tf,Tf=null,i;return(Xc&1)!==0&&i.tag!==0&&_o(),C=i.pendingLanes,(C&1)!==0?i===Af?il++:(il=0,Af=i):il=0,$s(),null}function _o(){if(Ds!==null){var i=Ti(Xc),c=Rn.transition,m=Ge;try{if(Rn.transition=null,Ge=16>i?16:i,Ds===null)var y=!1;else{if(i=Ds,Ds=null,Xc=0,(He&6)!==0)throw Error(n(331));var j=He;for(He|=4,Se=i.current;Se!==null;){var C=Se,U=C.child;if((Se.flags&16)!==0){var Q=C.deletions;if(Q!==null){for(var te=0;te<Q.length;te++){var ce=Q[te];for(Se=ce;Se!==null;){var ye=Se;switch(ye.tag){case 0:case 11:case 15:sl(8,ye,C)}var be=ye.child;if(be!==null)be.return=ye,Se=be;else for(;Se!==null;){ye=Se;var ge=ye.sibling,Ne=ye.return;if(y1(ye),ye===ce){Se=null;break}if(ge!==null){ge.return=Ne,Se=ge;break}Se=Ne}}}var Ee=C.alternate;if(Ee!==null){var Ce=Ee.child;if(Ce!==null){Ee.child=null;do{var wt=Ce.sibling;Ce.sibling=null,Ce=wt}while(Ce!==null)}}Se=C}}if((C.subtreeFlags&2064)!==0&&U!==null)U.return=C,Se=U;else e:for(;Se!==null;){if(C=Se,(C.flags&2048)!==0)switch(C.tag){case 0:case 11:case 15:sl(9,C,C.return)}var oe=C.sibling;if(oe!==null){oe.return=C.return,Se=oe;break e}Se=C.return}}var ne=i.current;for(Se=ne;Se!==null;){U=Se;var ie=U.child;if((U.subtreeFlags&2064)!==0&&ie!==null)ie.return=U,Se=ie;else e:for(U=ne;Se!==null;){if(Q=Se,(Q.flags&2048)!==0)try{switch(Q.tag){case 0:case 11:case 15:Hc(9,Q)}}catch(Te){pt(Q,Q.return,Te)}if(Q===U){Se=null;break e}var ke=Q.sibling;if(ke!==null){ke.return=Q.return,Se=ke;break e}Se=Q.return}}if(He=j,$s(),Yt&&typeof Yt.onPostCommitFiberRoot=="function")try{Yt.onPostCommitFiberRoot(Kr,i)}catch{}y=!0}return y}finally{Ge=m,Rn.transition=c}}return!1}function $1(i,c,m){c=ko(m,c),c=Zk(i,c,1),i=Os(i,c,1),c=Zt(),i!==null&&(vs(i,1,c),on(i,c))}function pt(i,c,m){if(i.tag===3)$1(i,i,m);else for(;c!==null;){if(c.tag===3){$1(c,i,m);break}else if(c.tag===1){var y=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof y.componentDidCatch=="function"&&(Ps===null||!Ps.has(y))){i=ko(m,i),i=Jk(c,i,1),c=Os(c,i,1),i=Zt(),c!==null&&(vs(c,1,i),on(c,i));break}}c=c.return}}function PP(i,c,m){var y=i.pingCache;y!==null&&y.delete(c),c=Zt(),i.pingedLanes|=i.suspendedLanes&m,$t===i&&(qt&m)===m&&(St===4||St===3&&(qt&130023424)===qt&&500>Qe()-Cf?xa(i,0):Ef|=m),on(i,c)}function I1(i,c){c===0&&((i.mode&1)===0?c=1:(c=sa,sa<<=1,(sa&130023424)===0&&(sa=4194304)));var m=Zt();i=ns(i,c),i!==null&&(vs(i,c,m),on(i,m))}function DP(i){var c=i.memoizedState,m=0;c!==null&&(m=c.retryLane),I1(i,m)}function FP(i,c){var m=0;switch(i.tag){case 13:var y=i.stateNode,j=i.memoizedState;j!==null&&(m=j.retryLane);break;case 19:y=i.stateNode;break;default:throw Error(n(314))}y!==null&&y.delete(c),I1(i,m)}var O1;O1=function(i,c,m){if(i!==null)if(i.memoizedProps!==c.pendingProps||nn.current)sn=!0;else{if((i.lanes&m)===0&&(c.flags&128)===0)return sn=!1,_P(i,c,m);sn=(i.flags&131072)!==0}else sn=!1,ct&&(c.flags&1048576)!==0&&pk(c,Cc,c.index);switch(c.lanes=0,c.tag){case 2:var y=c.type;zc(i,c),i=c.pendingProps;var j=po(c,Wt.current);xo(c,m),j=sf(null,c,y,i,j,m);var C=af();return c.flags|=1,typeof j=="object"&&j!==null&&typeof j.render=="function"&&j.$$typeof===void 0?(c.tag=1,c.memoizedState=null,c.updateQueue=null,rn(y)?(C=!0,Sc(c)):C=!1,c.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,Zh(c),j.updater=qc,c.stateNode=j,j._reactInternals=c,hf(c,y,i,m),c=gf(null,c,y,!0,C,m)):(c.tag=0,ct&&C&&qh(c),Xt(null,c,j,m),c=c.child),c;case 16:y=c.elementType;e:{switch(zc(i,c),i=c.pendingProps,j=y._init,y=j(y._payload),c.type=y,j=c.tag=qP(y),i=Zn(y,i),j){case 0:c=mf(null,c,y,i,m);break e;case 1:c=i1(null,c,y,i,m);break e;case 11:c=n1(null,c,y,i,m);break e;case 14:c=r1(null,c,y,Zn(y.type,i),m);break e}throw Error(n(306,y,""))}return c;case 0:return y=c.type,j=c.pendingProps,j=c.elementType===y?j:Zn(y,j),mf(i,c,y,j,m);case 1:return y=c.type,j=c.pendingProps,j=c.elementType===y?j:Zn(y,j),i1(i,c,y,j,m);case 3:e:{if(l1(c),i===null)throw Error(n(387));y=c.pendingProps,C=c.memoizedState,j=C.element,Nk(i,c),Ic(c,y,null,m);var U=c.memoizedState;if(y=U.element,C.isDehydrated)if(C={element:y,isDehydrated:!1,cache:U.cache,pendingSuspenseBoundaries:U.pendingSuspenseBoundaries,transitions:U.transitions},c.updateQueue.baseState=C,c.memoizedState=C,c.flags&256){j=ko(Error(n(423)),c),c=c1(i,c,y,m,j);break e}else if(y!==j){j=ko(Error(n(424)),c),c=c1(i,c,y,m,j);break e}else for(mn=As(c.stateNode.containerInfo.firstChild),pn=c,ct=!0,Xn=null,m=bk(c,null,y,m),c.child=m;m;)m.flags=m.flags&-3|4096,m=m.sibling;else{if(yo(),y===j){c=ss(i,c,m);break e}Xt(i,c,y,m)}c=c.child}return c;case 5:return _k(c),i===null&&Wh(c),y=c.type,j=c.pendingProps,C=i!==null?i.memoizedProps:null,U=j.children,Oh(y,j)?U=null:C!==null&&Oh(y,C)&&(c.flags|=32),o1(i,c),Xt(i,c,U,m),c.child;case 6:return i===null&&Wh(c),null;case 13:return u1(i,c,m);case 4:return Jh(c,c.stateNode.containerInfo),y=c.pendingProps,i===null?c.child=wo(c,null,y,m):Xt(i,c,y,m),c.child;case 11:return y=c.type,j=c.pendingProps,j=c.elementType===y?j:Zn(y,j),n1(i,c,y,j,m);case 7:return Xt(i,c,c.pendingProps,m),c.child;case 8:return Xt(i,c,c.pendingProps.children,m),c.child;case 12:return Xt(i,c,c.pendingProps.children,m),c.child;case 10:e:{if(y=c.type._context,j=c.pendingProps,C=c.memoizedProps,U=j.value,tt(Rc,y._currentValue),y._currentValue=U,C!==null)if(Yn(C.value,U)){if(C.children===j.children&&!nn.current){c=ss(i,c,m);break e}}else for(C=c.child,C!==null&&(C.return=c);C!==null;){var Q=C.dependencies;if(Q!==null){U=C.child;for(var te=Q.firstContext;te!==null;){if(te.context===y){if(C.tag===1){te=rs(-1,m&-m),te.tag=2;var ce=C.updateQueue;if(ce!==null){ce=ce.shared;var ye=ce.pending;ye===null?te.next=te:(te.next=ye.next,ye.next=te),ce.pending=te}}C.lanes|=m,te=C.alternate,te!==null&&(te.lanes|=m),Yh(C.return,m,c),Q.lanes|=m;break}te=te.next}}else if(C.tag===10)U=C.type===c.type?null:C.child;else if(C.tag===18){if(U=C.return,U===null)throw Error(n(341));U.lanes|=m,Q=U.alternate,Q!==null&&(Q.lanes|=m),Yh(U,m,c),U=C.sibling}else U=C.child;if(U!==null)U.return=C;else for(U=C;U!==null;){if(U===c){U=null;break}if(C=U.sibling,C!==null){C.return=U.return,U=C;break}U=U.return}C=U}Xt(i,c,j.children,m),c=c.child}return c;case 9:return j=c.type,y=c.pendingProps.children,xo(c,m),j=Tn(j),y=y(j),c.flags|=1,Xt(i,c,y,m),c.child;case 14:return y=c.type,j=Zn(y,c.pendingProps),j=Zn(y.type,j),r1(i,c,y,j,m);case 15:return s1(i,c,c.type,c.pendingProps,m);case 17:return y=c.type,j=c.pendingProps,j=c.elementType===y?j:Zn(y,j),zc(i,c),c.tag=1,rn(y)?(i=!0,Sc(c)):i=!1,xo(c,m),Yk(c,y,j),hf(c,y,j,m),gf(null,c,y,!0,i,m);case 19:return h1(i,c,m);case 22:return a1(i,c,m)}throw Error(n(156,c.tag))};function L1(i,c){return en(i,c)}function BP(i,c,m,y){this.tag=i,this.key=m,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=c,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=y,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Mn(i,c,m,y){return new BP(i,c,m,y)}function Lf(i){return i=i.prototype,!(!i||!i.isReactComponent)}function qP(i){if(typeof i=="function")return Lf(i)?1:0;if(i!=null){if(i=i.$$typeof,i===L)return 11;if(i===$)return 14}return 2}function qs(i,c){var m=i.alternate;return m===null?(m=Mn(i.tag,c,i.key,i.mode),m.elementType=i.elementType,m.type=i.type,m.stateNode=i.stateNode,m.alternate=i,i.alternate=m):(m.pendingProps=c,m.type=i.type,m.flags=0,m.subtreeFlags=0,m.deletions=null),m.flags=i.flags&14680064,m.childLanes=i.childLanes,m.lanes=i.lanes,m.child=i.child,m.memoizedProps=i.memoizedProps,m.memoizedState=i.memoizedState,m.updateQueue=i.updateQueue,c=i.dependencies,m.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext},m.sibling=i.sibling,m.index=i.index,m.ref=i.ref,m}function eu(i,c,m,y,j,C){var U=2;if(y=i,typeof i=="function")Lf(i)&&(U=1);else if(typeof i=="string")U=5;else e:switch(i){case R:return ka(m.children,j,C,c);case B:U=8,j|=8;break;case P:return i=Mn(12,m,c,j|2),i.elementType=P,i.lanes=C,i;case z:return i=Mn(13,m,c,j),i.elementType=z,i.lanes=C,i;case M:return i=Mn(19,m,c,j),i.elementType=M,i.lanes=C,i;case X:return tu(m,j,C,c);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case D:U=10;break e;case O:U=9;break e;case L:U=11;break e;case $:U=14;break e;case q:U=16,y=null;break e}throw Error(n(130,i==null?i:typeof i,""))}return c=Mn(U,m,c,j),c.elementType=i,c.type=y,c.lanes=C,c}function ka(i,c,m,y){return i=Mn(7,i,y,c),i.lanes=m,i}function tu(i,c,m,y){return i=Mn(22,i,y,c),i.elementType=X,i.lanes=m,i.stateNode={isHidden:!1},i}function Pf(i,c,m){return i=Mn(6,i,null,c),i.lanes=m,i}function Df(i,c,m){return c=Mn(4,i.children!==null?i.children:[],i.key,c),c.lanes=m,c.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},c}function UP(i,c,m,y,j){this.tag=c,this.containerInfo=i,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ei(0),this.expirationTimes=Ei(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ei(0),this.identifierPrefix=y,this.onRecoverableError=j,this.mutableSourceEagerHydrationData=null}function Ff(i,c,m,y,j,C,U,Q,te){return i=new UP(i,c,m,Q,te),c===1?(c=1,C===!0&&(c|=8)):c=0,C=Mn(3,null,null,c),i.current=C,C.stateNode=i,C.memoizedState={element:y,isDehydrated:m,cache:null,transitions:null,pendingSuspenseBoundaries:null},Zh(C),i}function zP(i,c,m){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:A,key:y==null?null:""+y,children:i,containerInfo:c,implementation:m}}function P1(i){if(!i)return Ms;i=i._reactInternals;e:{if(fn(i)!==i||i.tag!==1)throw Error(n(170));var c=i;do{switch(c.tag){case 3:c=c.stateNode.context;break e;case 1:if(rn(c.type)){c=c.stateNode.__reactInternalMemoizedMergedChildContext;break e}}c=c.return}while(c!==null);throw Error(n(171))}if(i.tag===1){var m=i.type;if(rn(m))return dk(i,m,c)}return c}function D1(i,c,m,y,j,C,U,Q,te){return i=Ff(m,y,!0,i,j,C,U,Q,te),i.context=P1(null),m=i.current,y=Zt(),j=Fs(m),C=rs(y,j),C.callback=c??null,Os(m,C,j),i.current.lanes=j,vs(i,j,y),on(i,y),i}function nu(i,c,m,y){var j=c.current,C=Zt(),U=Fs(j);return m=P1(m),c.context===null?c.context=m:c.pendingContext=m,c=rs(C,U),c.payload={element:i},y=y===void 0?null:y,y!==null&&(c.callback=y),i=Os(j,c,U),i!==null&&(er(i,j,U,C),$c(i,j,U)),U}function ru(i){if(i=i.current,!i.child)return null;switch(i.child.tag){case 5:return i.child.stateNode;default:return i.child.stateNode}}function F1(i,c){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var m=i.retryLane;i.retryLane=m!==0&&m<c?m:c}}function Bf(i,c){F1(i,c),(i=i.alternate)&&F1(i,c)}function WP(){return null}var B1=typeof reportError=="function"?reportError:function(i){console.error(i)};function qf(i){this._internalRoot=i}su.prototype.render=qf.prototype.render=function(i){var c=this._internalRoot;if(c===null)throw Error(n(409));nu(i,c,null,null)},su.prototype.unmount=qf.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var c=i.containerInfo;va(function(){nu(null,i,null,null)}),c[Jr]=null}};function su(i){this._internalRoot=i}su.prototype.unstable_scheduleHydration=function(i){if(i){var c=Qa();i={blockedOn:null,target:i,priority:c};for(var m=0;m<Nr.length&&c!==0&&c<Nr[m].priority;m++);Nr.splice(m,0,i),m===0&&Ii(i)}};function Uf(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function au(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function q1(){}function HP(i,c,m,y,j){if(j){if(typeof y=="function"){var C=y;y=function(){var ce=ru(U);C.call(ce)}}var U=D1(c,y,i,0,null,!1,!1,"",q1);return i._reactRootContainer=U,i[Jr]=U.current,Hi(i.nodeType===8?i.parentNode:i),va(),U}for(;j=i.lastChild;)i.removeChild(j);if(typeof y=="function"){var Q=y;y=function(){var ce=ru(te);Q.call(ce)}}var te=Ff(i,0,!1,null,null,!1,!1,"",q1);return i._reactRootContainer=te,i[Jr]=te.current,Hi(i.nodeType===8?i.parentNode:i),va(function(){nu(c,te,m,y)}),te}function ou(i,c,m,y,j){var C=m._reactRootContainer;if(C){var U=C;if(typeof j=="function"){var Q=j;j=function(){var te=ru(U);Q.call(te)}}nu(c,U,i,j)}else U=HP(m,c,i,j,y);return ru(U)}Ja=function(i){switch(i.tag){case 3:var c=i.stateNode;if(c.current.memoizedState.isDehydrated){var m=ys(c.pendingLanes);m!==0&&(Ci(c,m|1),on(c,Qe()),(He&6)===0&&(So=Qe()+500,$s()))}break;case 13:va(function(){var y=ns(i,1);if(y!==null){var j=Zt();er(y,i,1,j)}}),Bf(i,1)}},Ai=function(i){if(i.tag===13){var c=ns(i,134217728);if(c!==null){var m=Zt();er(c,i,134217728,m)}Bf(i,134217728)}},hc=function(i){if(i.tag===13){var c=Fs(i),m=ns(i,c);if(m!==null){var y=Zt();er(m,i,c,y)}Bf(i,c)}},Qa=function(){return Ge},Ri=function(i,c){var m=Ge;try{return Ge=i,c()}finally{Ge=m}},Pt=function(i,c,m){switch(c){case"input":if(fe(i,m),c=m.name,m.type==="radio"&&c!=null){for(m=i;m.parentNode;)m=m.parentNode;for(m=m.querySelectorAll("input[name="+JSON.stringify(""+c)+'][type="radio"]'),c=0;c<m.length;c++){var y=m[c];if(y!==i&&y.form===i.form){var j=Nc(y);if(!j)throw Error(n(90));ae(y),fe(y,j)}}}break;case"textarea":je(i,m);break;case"select":c=m.value,c!=null&&Le(i,!!m.multiple,c,!1)}},Ur=$f,zr=va;var VP={usingClientEntryPoint:!1,Events:[Ki,ho,Nc,qr,Un,$f]},ll={findFiberByHostInstance:da,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},GP={bundleType:ll.bundleType,version:ll.version,rendererPackageName:ll.rendererPackageName,rendererConfig:ll.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:E.ReactCurrentDispatcher,findHostInstanceByFiber:function(i){return i=Be(i),i===null?null:i.stateNode},findFiberByHostInstance:ll.findFiberByHostInstance||WP,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 iu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!iu.isDisabled&&iu.supportsFiber)try{Kr=iu.inject(GP),Yt=iu}catch{}}return ln.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=VP,ln.createPortal=function(i,c){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Uf(c))throw Error(n(200));return zP(i,c,null,m)},ln.createRoot=function(i,c){if(!Uf(i))throw Error(n(299));var m=!1,y="",j=B1;return c!=null&&(c.unstable_strictMode===!0&&(m=!0),c.identifierPrefix!==void 0&&(y=c.identifierPrefix),c.onRecoverableError!==void 0&&(j=c.onRecoverableError)),c=Ff(i,1,!1,null,null,m,!1,y,j),i[Jr]=c.current,Hi(i.nodeType===8?i.parentNode:i),new qf(c)},ln.findDOMNode=function(i){if(i==null)return null;if(i.nodeType===1)return i;var c=i._reactInternals;if(c===void 0)throw typeof i.render=="function"?Error(n(188)):(i=Object.keys(i).join(","),Error(n(268,i)));return i=Be(c),i=i===null?null:i.stateNode,i},ln.flushSync=function(i){return va(i)},ln.hydrate=function(i,c,m){if(!au(c))throw Error(n(200));return ou(null,i,c,!0,m)},ln.hydrateRoot=function(i,c,m){if(!Uf(i))throw Error(n(405));var y=m!=null&&m.hydratedSources||null,j=!1,C="",U=B1;if(m!=null&&(m.unstable_strictMode===!0&&(j=!0),m.identifierPrefix!==void 0&&(C=m.identifierPrefix),m.onRecoverableError!==void 0&&(U=m.onRecoverableError)),c=D1(c,null,i,1,m??null,j,!1,C,U),i[Jr]=c.current,Hi(i),y)for(i=0;i<y.length;i++)m=y[i],j=m._getVersion,j=j(m._source),c.mutableSourceEagerHydrationData==null?c.mutableSourceEagerHydrationData=[m,j]:c.mutableSourceEagerHydrationData.push(m,j);return new su(c)},ln.render=function(i,c,m){if(!au(c))throw Error(n(200));return ou(null,i,c,!1,m)},ln.unmountComponentAtNode=function(i){if(!au(i))throw Error(n(40));return i._reactRootContainer?(va(function(){ou(null,null,i,!1,function(){i._reactRootContainer=null,i[Jr]=null})}),!0):!1},ln.unstable_batchedUpdates=$f,ln.unstable_renderSubtreeIntoContainer=function(i,c,m,y){if(!au(m))throw Error(n(200));if(i==null||i._reactInternals===void 0)throw Error(n(38));return ou(i,c,m,!1,y)},ln.version="18.3.1-next-f1338f8080-20240426",ln}var X1;function OR(){if(X1)return Hf.exports;X1=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(),Hf.exports=n3(),Hf.exports}var Z1;function r3(){if(Z1)return cu;Z1=1;var e=OR();return cu.createRoot=e.createRoot,cu.hydrateRoot=e.hydrateRoot,cu}var s3=r3(),w=Xl();const de=sb(w);function Ut(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=Ut(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Kf={exports:{}},Yf={},Xf={exports:{}},Zf={};/**
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 J1;function a3(){if(J1)return Zf;J1=1;var e=Xl();function t(p,g){return p===g&&(p!==0||1/p===1/g)||p!==p&&g!==g}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,s=e.useEffect,o=e.useLayoutEffect,l=e.useDebugValue;function u(p,g){var v=g(),k=r({inst:{value:v,getSnapshot:g}}),b=k[0].inst,x=k[1];return o(function(){b.value=v,b.getSnapshot=g,d(b)&&x({inst:b})},[p,v,g]),s(function(){return d(b)&&x({inst:b}),p(function(){d(b)&&x({inst:b})})},[p]),l(v),v}function d(p){var g=p.getSnapshot;p=p.value;try{var v=g();return!n(p,v)}catch{return!0}}function h(p,g){return g()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:u;return Zf.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,Zf}var Q1;function o3(){return Q1||(Q1=1,Xf.exports=a3()),Xf.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 eN;function i3(){if(eN)return Yf;eN=1;var e=Xl(),t=o3();function n(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var r=typeof Object.is=="function"?Object.is:n,s=t.useSyncExternalStore,o=e.useRef,l=e.useEffect,u=e.useMemo,d=e.useDebugValue;return Yf.useSyncExternalStoreWithSelector=function(h,f,p,g,v){var k=o(null);if(k.current===null){var b={hasValue:!1,value:null};k.current=b}else b=k.current;k=u(function(){function N(A){if(!S){if(S=!0,_=A,A=g(A),v!==void 0&&b.hasValue){var R=b.value;if(v(R,A))return E=R}return E=A}if(R=E,r(_,A))return R;var B=g(A);return v!==void 0&&v(R,B)?(_=A,R):(_=A,E=B)}var S=!1,_,E,T=p===void 0?null:p;return[function(){return N(f())},T===null?void 0:function(){return N(T())}]},[f,p,g,v]);var x=s(h,k[0],k[1]);return l(function(){b.hasValue=!0,b.value=x},[x]),d(x),x},Yf}var tN;function l3(){return tN||(tN=1,Kf.exports=i3()),Kf.exports}var c3=l3();const u3=sb(c3),d3={},nN=e=>{let t;const n=new Set,r=(f,p)=>{const g=typeof f=="function"?f(t):f;if(!Object.is(g,t)){const v=t;t=p??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(k=>k(t,v))}},s=()=>t,d={setState:r,getState:s,getInitialState:()=>h,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(d3?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},h=t=e(r,s,d);return d},h3=e=>e?nN(e):nN,{useDebugValue:f3}=de,{useSyncExternalStoreWithSelector:p3}=u3,m3=e=>e;function LR(e,t=m3,n){const r=p3(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return f3(r),r}const rN=(e,t)=>{const n=h3(e),r=(s,o=t)=>LR(n,s,o);return Object.assign(r,n),r},g3=(e,t)=>e?rN(e,t):rN;function Tt(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,s]of e)if(!Object.is(s,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var y3={value:()=>{}};function _d(){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 Iu(n)}function Iu(e){this._=e}function w3(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}})}Iu.prototype=_d.prototype={constructor:Iu,on:function(e,t){var n=this._,r=w3(e+"",n),s,o=-1,l=r.length;if(arguments.length<2){for(;++o<l;)if((s=(e=r[o]).type)&&(s=v3(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]=sN(n[s],e.name,t);else if(t==null)for(s in n)n[s]=sN(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 Iu(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 v3(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function sN(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=y3,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Yv="http://www.w3.org/1999/xhtml";const aN={svg:"http://www.w3.org/2000/svg",xhtml:Yv,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ed(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),aN.hasOwnProperty(t)?{space:aN[t],local:e}:e}function x3(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Yv&&t.documentElement.namespaceURI===Yv?t.createElement(e):t.createElementNS(n,e)}}function b3(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function PR(e){var t=Ed(e);return(t.local?b3:x3)(t)}function k3(){}function ab(e){return e==null?k3:function(){return this.querySelector(e)}}function N3(e){typeof e!="function"&&(e=ab(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],l=o.length,u=r[s]=new Array(l),d,h,f=0;f<l;++f)(d=o[f])&&(h=e.call(d,d.__data__,f,o))&&("__data__"in d&&(h.__data__=d.__data__),u[f]=h);return new bn(r,this._parents)}function j3(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function S3(){return[]}function DR(e){return e==null?S3:function(){return this.querySelectorAll(e)}}function _3(e){return function(){return j3(e.apply(this,arguments))}}function E3(e){typeof e=="function"?e=_3(e):e=DR(e);for(var t=this._groups,n=t.length,r=[],s=[],o=0;o<n;++o)for(var l=t[o],u=l.length,d,h=0;h<u;++h)(d=l[h])&&(r.push(e.call(d,d.__data__,h,l)),s.push(d));return new bn(r,s)}function FR(e){return function(){return this.matches(e)}}function BR(e){return function(t){return t.matches(e)}}var C3=Array.prototype.find;function T3(e){return function(){return C3.call(this.children,e)}}function A3(){return this.firstElementChild}function R3(e){return this.select(e==null?A3:T3(typeof e=="function"?e:BR(e)))}var M3=Array.prototype.filter;function $3(){return Array.from(this.children)}function I3(e){return function(){return M3.call(this.children,e)}}function O3(e){return this.selectAll(e==null?$3:I3(typeof e=="function"?e:BR(e)))}function L3(e){typeof e!="function"&&(e=FR(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],l=o.length,u=r[s]=[],d,h=0;h<l;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&u.push(d);return new bn(r,this._parents)}function qR(e){return new Array(e.length)}function P3(){return new bn(this._enter||this._groups.map(qR),this._parents)}function Gu(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Gu.prototype={constructor:Gu,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 D3(e){return function(){return e}}function F3(e,t,n,r,s,o){for(var l=0,u,d=t.length,h=o.length;l<h;++l)(u=t[l])?(u.__data__=o[l],r[l]=u):n[l]=new Gu(e,o[l]);for(;l<d;++l)(u=t[l])&&(s[l]=u)}function B3(e,t,n,r,s,o,l){var u,d,h=new Map,f=t.length,p=o.length,g=new Array(f),v;for(u=0;u<f;++u)(d=t[u])&&(g[u]=v=l.call(d,d.__data__,u,t)+"",h.has(v)?s[u]=d:h.set(v,d));for(u=0;u<p;++u)v=l.call(e,o[u],u,o)+"",(d=h.get(v))?(r[u]=d,d.__data__=o[u],h.delete(v)):n[u]=new Gu(e,o[u]);for(u=0;u<f;++u)(d=t[u])&&h.get(g[u])===d&&(s[u]=d)}function q3(e){return e.__data__}function U3(e,t){if(!arguments.length)return Array.from(this,q3);var n=t?B3:F3,r=this._parents,s=this._groups;typeof e!="function"&&(e=D3(e));for(var o=s.length,l=new Array(o),u=new Array(o),d=new Array(o),h=0;h<o;++h){var f=r[h],p=s[h],g=p.length,v=z3(e.call(f,f&&f.__data__,h,r)),k=v.length,b=u[h]=new Array(k),x=l[h]=new Array(k),N=d[h]=new Array(g);n(f,p,b,x,N,v,t);for(var S=0,_=0,E,T;S<k;++S)if(E=b[S]){for(S>=_&&(_=S+1);!(T=x[_])&&++_<k;);E._next=T||null}}return l=new bn(l,r),l._enter=u,l._exit=d,l}function z3(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function W3(){return new bn(this._exit||this._groups.map(qR),this._parents)}function H3(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 V3(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,o=r.length,l=Math.min(s,o),u=new Array(s),d=0;d<l;++d)for(var h=n[d],f=r[d],p=h.length,g=u[d]=new Array(p),v,k=0;k<p;++k)(v=h[k]||f[k])&&(g[k]=v);for(;d<s;++d)u[d]=n[d];return new bn(u,this._parents)}function G3(){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 K3(e){e||(e=Y3);function t(p,g){return p&&g?e(p.__data__,g.__data__):!p-!g}for(var n=this._groups,r=n.length,s=new Array(r),o=0;o<r;++o){for(var l=n[o],u=l.length,d=s[o]=new Array(u),h,f=0;f<u;++f)(h=l[f])&&(d[f]=h);d.sort(t)}return new bn(s,this._parents).order()}function Y3(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function X3(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Z3(){return Array.from(this)}function J3(){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 Q3(){let e=0;for(const t of this)++e;return e}function e4(){return!this.node()}function t4(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 n4(e){return function(){this.removeAttribute(e)}}function r4(e){return function(){this.removeAttributeNS(e.space,e.local)}}function s4(e,t){return function(){this.setAttribute(e,t)}}function a4(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function o4(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function i4(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 l4(e,t){var n=Ed(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?r4:n4:typeof t=="function"?n.local?i4:o4:n.local?a4:s4)(n,t))}function UR(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function c4(e){return function(){this.style.removeProperty(e)}}function u4(e,t,n){return function(){this.style.setProperty(e,t,n)}}function d4(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function h4(e,t,n){return arguments.length>1?this.each((t==null?c4:typeof t=="function"?d4:u4)(e,t,n??"")):ni(this.node(),e)}function ni(e,t){return e.style.getPropertyValue(t)||UR(e).getComputedStyle(e,null).getPropertyValue(t)}function f4(e){return function(){delete this[e]}}function p4(e,t){return function(){this[e]=t}}function m4(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function g4(e,t){return arguments.length>1?this.each((t==null?f4:typeof t=="function"?m4:p4)(e,t)):this.node()[e]}function zR(e){return e.trim().split(/^|\s+/)}function ob(e){return e.classList||new WR(e)}function WR(e){this._node=e,this._names=zR(e.getAttribute("class")||"")}WR.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 HR(e,t){for(var n=ob(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function VR(e,t){for(var n=ob(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function y4(e){return function(){HR(this,e)}}function w4(e){return function(){VR(this,e)}}function v4(e,t){return function(){(t.apply(this,arguments)?HR:VR)(this,e)}}function x4(e,t){var n=zR(e+"");if(arguments.length<2){for(var r=ob(this.node()),s=-1,o=n.length;++s<o;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?v4:t?y4:w4)(n,t))}function b4(){this.textContent=""}function k4(e){return function(){this.textContent=e}}function N4(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function j4(e){return arguments.length?this.each(e==null?b4:(typeof e=="function"?N4:k4)(e)):this.node().textContent}function S4(){this.innerHTML=""}function _4(e){return function(){this.innerHTML=e}}function E4(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function C4(e){return arguments.length?this.each(e==null?S4:(typeof e=="function"?E4:_4)(e)):this.node().innerHTML}function T4(){this.nextSibling&&this.parentNode.appendChild(this)}function A4(){return this.each(T4)}function R4(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function M4(){return this.each(R4)}function $4(e){var t=typeof e=="function"?e:PR(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function I4(){return null}function O4(e,t){var n=typeof e=="function"?e:PR(e),r=t==null?I4:typeof t=="function"?t:ab(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function L4(){var e=this.parentNode;e&&e.removeChild(this)}function P4(){return this.each(L4)}function D4(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function F4(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function B4(e){return this.select(e?F4:D4)}function q4(e){return arguments.length?this.property("__data__",e):this.node().__data__}function U4(e){return function(t){e.call(this,t,this.__data__)}}function z4(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 W4(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 H4(e,t,n){return function(){var r=this.__on,s,o=U4(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 V4(e,t,n){var r=z4(e+""),s,o=r.length,l;if(arguments.length<2){var u=this.node().__on;if(u){for(var d=0,h=u.length,f;d<h;++d)for(s=0,f=u[d];s<o;++s)if((l=r[s]).type===f.type&&l.name===f.name)return f.value}return}for(u=t?H4:W4,s=0;s<o;++s)this.each(u(r[s],t,n));return this}function GR(e,t,n){var r=UR(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 G4(e,t){return function(){return GR(this,e,t)}}function K4(e,t){return function(){return GR(this,e,t.apply(this,arguments))}}function Y4(e,t){return this.each((typeof t=="function"?K4:G4)(e,t))}function*X4(){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 KR=[null];function bn(e,t){this._groups=e,this._parents=t}function Zl(){return new bn([[document.documentElement]],KR)}function Z4(){return this}bn.prototype=Zl.prototype={constructor:bn,select:N3,selectAll:E3,selectChild:R3,selectChildren:O3,filter:L3,data:U3,enter:P3,exit:W3,join:H3,merge:V3,selection:Z4,order:G3,sort:K3,call:X3,nodes:Z3,node:J3,size:Q3,empty:e4,each:t4,attr:l4,style:h4,property:g4,classed:x4,text:j4,html:C4,raise:A4,lower:M4,append:$4,insert:O4,remove:P4,clone:B4,datum:q4,on:V4,dispatch:Y4,[Symbol.iterator]:X4};function Ln(e){return typeof e=="string"?new bn([[document.querySelector(e)]],[document.documentElement]):new bn([[e]],KR)}function J4(e){let t;for(;t=e.sourceEvent;)e=t;return e}function sr(e,t){if(e=J4(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 Q4={passive:!1},Cl={capture:!0,passive:!1};function Jf(e){e.stopImmediatePropagation()}function Ko(e){e.preventDefault(),e.stopImmediatePropagation()}function YR(e){var t=e.document.documentElement,n=Ln(e).on("dragstart.drag",Ko,Cl);"onselectstart"in t?n.on("selectstart.drag",Ko,Cl):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function XR(e,t){var n=e.document.documentElement,r=Ln(e).on("dragstart.drag",null);t&&(r.on("click.drag",Ko,Cl),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 uu=e=>()=>e;function Xv(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:o,x:l,y:u,dx:d,dy:h,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:l,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:d,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:f}})}Xv.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function eD(e){return!e.ctrlKey&&!e.button}function tD(){return this.parentNode}function nD(e,t){return t??{x:e.x,y:e.y}}function rD(){return navigator.maxTouchPoints||"ontouchstart"in this}function sD(){var e=eD,t=tD,n=nD,r=rD,s={},o=_d("start","drag","end"),l=0,u,d,h,f,p=0;function g(E){E.on("mousedown.drag",v).filter(r).on("touchstart.drag",x).on("touchmove.drag",N,Q4).on("touchend.drag touchcancel.drag",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(E,T){if(!(f||!e.call(this,E,T))){var A=_(this,t.call(this,E,T),E,T,"mouse");A&&(Ln(E.view).on("mousemove.drag",k,Cl).on("mouseup.drag",b,Cl),YR(E.view),Jf(E),h=!1,u=E.clientX,d=E.clientY,A("start",E))}}function k(E){if(Ko(E),!h){var T=E.clientX-u,A=E.clientY-d;h=T*T+A*A>p}s.mouse("drag",E)}function b(E){Ln(E.view).on("mousemove.drag mouseup.drag",null),XR(E.view,h),Ko(E),s.mouse("end",E)}function x(E,T){if(e.call(this,E,T)){var A=E.changedTouches,R=t.call(this,E,T),B=A.length,P,D;for(P=0;P<B;++P)(D=_(this,R,E,T,A[P].identifier,A[P]))&&(Jf(E),D("start",E,A[P]))}}function N(E){var T=E.changedTouches,A=T.length,R,B;for(R=0;R<A;++R)(B=s[T[R].identifier])&&(Ko(E),B("drag",E,T[R]))}function S(E){var T=E.changedTouches,A=T.length,R,B;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),R=0;R<A;++R)(B=s[T[R].identifier])&&(Jf(E),B("end",E,T[R]))}function _(E,T,A,R,B,P){var D=o.copy(),O=sr(P||A,T),L,z,M;if((M=n.call(E,new Xv("beforestart",{sourceEvent:A,target:g,identifier:B,active:l,x:O[0],y:O[1],dx:0,dy:0,dispatch:D}),R))!=null)return L=M.x-O[0]||0,z=M.y-O[1]||0,function $(q,X,H){var I=O,W;switch(q){case"start":s[B]=$,W=l++;break;case"end":delete s[B],--l;case"drag":O=sr(H||X,T),W=l;break}D.call(q,E,new Xv(q,{sourceEvent:X,subject:M,target:g,identifier:B,active:W,x:O[0]+L,y:O[1]+z,dx:O[0]-I[0],dy:O[1]-I[1],dispatch:D}),R)}}return g.filter=function(E){return arguments.length?(e=typeof E=="function"?E:uu(!!E),g):e},g.container=function(E){return arguments.length?(t=typeof E=="function"?E:uu(E),g):t},g.subject=function(E){return arguments.length?(n=typeof E=="function"?E:uu(E),g):n},g.touchable=function(E){return arguments.length?(r=typeof E=="function"?E:uu(!!E),g):r},g.on=function(){var E=o.on.apply(o,arguments);return E===o?g:E},g.clickDistance=function(E){return arguments.length?(p=(E=+E)*E,g):Math.sqrt(p)},g}function ib(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function ZR(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Jl(){}var Tl=.7,Ku=1/Tl,Yo="\\s*([+-]?\\d+)\\s*",Al="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",$r="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",aD=/^#([0-9a-f]{3,8})$/,oD=new RegExp(`^rgb\\(${Yo},${Yo},${Yo}\\)$`),iD=new RegExp(`^rgb\\(${$r},${$r},${$r}\\)$`),lD=new RegExp(`^rgba\\(${Yo},${Yo},${Yo},${Al}\\)$`),cD=new RegExp(`^rgba\\(${$r},${$r},${$r},${Al}\\)$`),uD=new RegExp(`^hsl\\(${Al},${$r},${$r}\\)$`),dD=new RegExp(`^hsla\\(${Al},${$r},${$r},${Al}\\)$`),oN={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};ib(Jl,Rl,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:iN,formatHex:iN,formatHex8:hD,formatHsl:fD,formatRgb:lN,toString:lN});function iN(){return this.rgb().formatHex()}function hD(){return this.rgb().formatHex8()}function fD(){return JR(this).formatHsl()}function lN(){return this.rgb().formatRgb()}function Rl(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=aD.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?cN(t):n===3?new un(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?du(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?du(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=oD.exec(e))?new un(t[1],t[2],t[3],1):(t=iD.exec(e))?new un(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=lD.exec(e))?du(t[1],t[2],t[3],t[4]):(t=cD.exec(e))?du(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=uD.exec(e))?hN(t[1],t[2]/100,t[3]/100,1):(t=dD.exec(e))?hN(t[1],t[2]/100,t[3]/100,t[4]):oN.hasOwnProperty(e)?cN(oN[e]):e==="transparent"?new un(NaN,NaN,NaN,0):null}function cN(e){return new un(e>>16&255,e>>8&255,e&255,1)}function du(e,t,n,r){return r<=0&&(e=t=n=NaN),new un(e,t,n,r)}function pD(e){return e instanceof Jl||(e=Rl(e)),e?(e=e.rgb(),new un(e.r,e.g,e.b,e.opacity)):new un}function Zv(e,t,n,r){return arguments.length===1?pD(e):new un(e,t,n,r??1)}function un(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}ib(un,Zv,ZR(Jl,{brighter(e){return e=e==null?Ku:Math.pow(Ku,e),new un(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Tl:Math.pow(Tl,e),new un(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new un(Ra(this.r),Ra(this.g),Ra(this.b),Yu(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:uN,formatHex:uN,formatHex8:mD,formatRgb:dN,toString:dN}));function uN(){return`#${Ca(this.r)}${Ca(this.g)}${Ca(this.b)}`}function mD(){return`#${Ca(this.r)}${Ca(this.g)}${Ca(this.b)}${Ca((isNaN(this.opacity)?1:this.opacity)*255)}`}function dN(){const e=Yu(this.opacity);return`${e===1?"rgb(":"rgba("}${Ra(this.r)}, ${Ra(this.g)}, ${Ra(this.b)}${e===1?")":`, ${e})`}`}function Yu(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ra(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ca(e){return e=Ra(e),(e<16?"0":"")+e.toString(16)}function hN(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ar(e,t,n,r)}function JR(e){if(e instanceof ar)return new ar(e.h,e.s,e.l,e.opacity);if(e instanceof Jl||(e=Rl(e)),!e)return new ar;if(e instanceof ar)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 ar(l,u,d,e.opacity)}function gD(e,t,n,r){return arguments.length===1?JR(e):new ar(e,t,n,r??1)}function ar(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}ib(ar,gD,ZR(Jl,{brighter(e){return e=e==null?Ku:Math.pow(Ku,e),new ar(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Tl:Math.pow(Tl,e),new ar(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 un(Qf(e>=240?e-240:e+120,s,r),Qf(e,s,r),Qf(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new ar(fN(this.h),hu(this.s),hu(this.l),Yu(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=Yu(this.opacity);return`${e===1?"hsl(":"hsla("}${fN(this.h)}, ${hu(this.s)*100}%, ${hu(this.l)*100}%${e===1?")":`, ${e})`}`}}));function fN(e){return e=(e||0)%360,e<0?e+360:e}function hu(e){return Math.max(0,Math.min(1,e||0))}function Qf(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 QR=e=>()=>e;function yD(e,t){return function(n){return e+n*t}}function wD(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 vD(e){return(e=+e)==1?e2:function(t,n){return n-t?wD(t,n,e):QR(isNaN(t)?n:t)}}function e2(e,t){var n=t-e;return n?yD(e,n):QR(isNaN(e)?t:e)}const pN=(function e(t){var n=vD(t);function r(s,o){var l=n((s=Zv(s)).r,(o=Zv(o)).r),u=n(s.g,o.g),d=n(s.b,o.b),h=e2(s.opacity,o.opacity);return function(f){return s.r=l(f),s.g=u(f),s.b=d(f),s.opacity=h(f),s+""}}return r.gamma=e,r})(1);function Hs(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Jv=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ep=new RegExp(Jv.source,"g");function xD(e){return function(){return e}}function bD(e){return function(t){return e(t)+""}}function kD(e,t){var n=Jv.lastIndex=ep.lastIndex=0,r,s,o,l=-1,u=[],d=[];for(e=e+"",t=t+"";(r=Jv.exec(e))&&(s=ep.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:Hs(r,s)})),n=ep.lastIndex;return n<t.length&&(o=t.slice(n),u[l]?u[l]+=o:u[++l]=o),u.length<2?d[0]?bD(d[0].x):xD(t):(t=d.length,function(h){for(var f=0,p;f<t;++f)u[(p=d[f]).i]=p.x(h);return u.join("")})}var mN=180/Math.PI,Qv={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function t2(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)*mN,skewX:Math.atan(d)*mN,scaleX:l,scaleY:u}}var fu;function ND(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Qv:t2(t.a,t.b,t.c,t.d,t.e,t.f)}function jD(e){return e==null||(fu||(fu=document.createElementNS("http://www.w3.org/2000/svg","g")),fu.setAttribute("transform",e),!(e=fu.transform.baseVal.consolidate()))?Qv:(e=e.matrix,t2(e.a,e.b,e.c,e.d,e.e,e.f))}function n2(e,t,n,r){function s(h){return h.length?h.pop()+" ":""}function o(h,f,p,g,v,k){if(h!==p||f!==g){var b=v.push("translate(",null,t,null,n);k.push({i:b-4,x:Hs(h,p)},{i:b-2,x:Hs(f,g)})}else(p||g)&&v.push("translate("+p+t+g+n)}function l(h,f,p,g){h!==f?(h-f>180?f+=360:f-h>180&&(h+=360),g.push({i:p.push(s(p)+"rotate(",null,r)-2,x:Hs(h,f)})):f&&p.push(s(p)+"rotate("+f+r)}function u(h,f,p,g){h!==f?g.push({i:p.push(s(p)+"skewX(",null,r)-2,x:Hs(h,f)}):f&&p.push(s(p)+"skewX("+f+r)}function d(h,f,p,g,v,k){if(h!==p||f!==g){var b=v.push(s(v)+"scale(",null,",",null,")");k.push({i:b-4,x:Hs(h,p)},{i:b-2,x:Hs(f,g)})}else(p!==1||g!==1)&&v.push(s(v)+"scale("+p+","+g+")")}return function(h,f){var p=[],g=[];return h=e(h),f=e(f),o(h.translateX,h.translateY,f.translateX,f.translateY,p,g),l(h.rotate,f.rotate,p,g),u(h.skewX,f.skewX,p,g),d(h.scaleX,h.scaleY,f.scaleX,f.scaleY,p,g),h=f=null,function(v){for(var k=-1,b=g.length,x;++k<b;)p[(x=g[k]).i]=x.x(v);return p.join("")}}}var SD=n2(ND,"px, ","px)","deg)"),_D=n2(jD,", ",")",")"),ED=1e-12;function gN(e){return((e=Math.exp(e))+1/e)/2}function CD(e){return((e=Math.exp(e))-1/e)/2}function TD(e){return((e=Math.exp(2*e))-1)/(e+1)}const AD=(function e(t,n,r){function s(o,l){var u=o[0],d=o[1],h=o[2],f=l[0],p=l[1],g=l[2],v=f-u,k=p-d,b=v*v+k*k,x,N;if(b<ED)N=Math.log(g/h)/t,x=function(R){return[u+R*v,d+R*k,h*Math.exp(t*R*N)]};else{var S=Math.sqrt(b),_=(g*g-h*h+r*b)/(2*h*n*S),E=(g*g-h*h-r*b)/(2*g*n*S),T=Math.log(Math.sqrt(_*_+1)-_),A=Math.log(Math.sqrt(E*E+1)-E);N=(A-T)/t,x=function(R){var B=R*N,P=gN(T),D=h/(n*S)*(P*TD(t*B+T)-CD(T));return[u+D*v,d+D*k,h*P/gN(t*B+T)]}}return x.duration=N*1e3*t/Math.SQRT2,x}return s.rho=function(o){var l=Math.max(.001,+o),u=l*l,d=u*u;return e(l,u,d)},s})(Math.SQRT2,2,4);var ri=0,gl=0,ul=0,r2=1e3,Xu,yl,Zu=0,La=0,Cd=0,Ml=typeof performance=="object"&&performance.now?performance:Date,s2=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function lb(){return La||(s2(RD),La=Ml.now()+Cd)}function RD(){La=0}function Ju(){this._call=this._time=this._next=null}Ju.prototype=a2.prototype={constructor:Ju,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?lb():+n)+(t==null?0:+t),!this._next&&yl!==this&&(yl?yl._next=this:Xu=this,yl=this),this._call=e,this._time=n,ex()},stop:function(){this._call&&(this._call=null,this._time=1/0,ex())}};function a2(e,t,n){var r=new Ju;return r.restart(e,t,n),r}function MD(){lb(),++ri;for(var e=Xu,t;e;)(t=La-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ri}function yN(){La=(Zu=Ml.now())+Cd,ri=gl=0;try{MD()}finally{ri=0,ID(),La=0}}function $D(){var e=Ml.now(),t=e-Zu;t>r2&&(Cd-=t,Zu=e)}function ID(){for(var e,t=Xu,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:Xu=n);yl=e,ex(r)}function ex(e){if(!ri){gl&&(gl=clearTimeout(gl));var t=e-La;t>24?(e<1/0&&(gl=setTimeout(yN,e-Ml.now()-Cd)),ul&&(ul=clearInterval(ul))):(ul||(Zu=Ml.now(),ul=setInterval($D,r2)),ri=1,s2(yN))}}function wN(e,t,n){var r=new Ju;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var OD=_d("start","end","cancel","interrupt"),LD=[],o2=0,vN=1,tx=2,Ou=3,xN=4,nx=5,Lu=6;function Td(e,t,n,r,s,o){var l=e.__transition;if(!l)e.__transition={};else if(n in l)return;PD(e,n,{name:t,index:r,group:s,on:OD,tween:LD,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:o2})}function cb(e,t){var n=hr(e,t);if(n.state>o2)throw new Error("too late; already scheduled");return n}function Fr(e,t){var n=hr(e,t);if(n.state>Ou)throw new Error("too late; already running");return n}function hr(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function PD(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=a2(o,0,n.time);function o(h){n.state=vN,n.timer.restart(l,n.delay,n.time),n.delay<=h&&l(h-n.delay)}function l(h){var f,p,g,v;if(n.state!==vN)return d();for(f in r)if(v=r[f],v.name===n.name){if(v.state===Ou)return wN(l);v.state===xN?(v.state=Lu,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete r[f]):+f<t&&(v.state=Lu,v.timer.stop(),v.on.call("cancel",e,e.__data__,v.index,v.group),delete r[f])}if(wN(function(){n.state===Ou&&(n.state=xN,n.timer.restart(u,n.delay,n.time),u(h))}),n.state=tx,n.on.call("start",e,e.__data__,n.index,n.group),n.state===tx){for(n.state=Ou,s=new Array(g=n.tween.length),f=0,p=-1;f<g;++f)(v=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(s[++p]=v);s.length=p+1}}function u(h){for(var f=h<n.duration?n.ease.call(null,h/n.duration):(n.timer.restart(d),n.state=nx,1),p=-1,g=s.length;++p<g;)s[p].call(e,f);n.state===nx&&(n.on.call("end",e,e.__data__,n.index,n.group),d())}function d(){n.state=Lu,n.timer.stop(),delete r[t];for(var h in r)return;delete e.__transition}}function Pu(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>tx&&r.state<nx,r.state=Lu,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[l]}o&&delete e.__transition}}function DD(e){return this.each(function(){Pu(this,e)})}function FD(e,t){var n,r;return function(){var s=Fr(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 BD(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var o=Fr(this,e),l=o.tween;if(l!==r){s=(r=l).slice();for(var u={name:t,value:n},d=0,h=s.length;d<h;++d)if(s[d].name===t){s[d]=u;break}d===h&&s.push(u)}o.tween=s}}function qD(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=hr(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?FD:BD)(n,e,t))}function ub(e,t,n){var r=e._id;return e.each(function(){var s=Fr(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return hr(s,r).value[t]}}function i2(e,t){var n;return(typeof t=="number"?Hs:t instanceof Rl?pN:(n=Rl(t))?(t=n,pN):kD)(e,t)}function UD(e){return function(){this.removeAttribute(e)}}function zD(e){return function(){this.removeAttributeNS(e.space,e.local)}}function WD(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 HD(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 VD(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 GD(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 KD(e,t){var n=Ed(e),r=n==="transform"?_D:i2;return this.attrTween(e,typeof t=="function"?(n.local?GD:VD)(n,r,ub(this,"attr."+e,t)):t==null?(n.local?zD:UD)(n):(n.local?HD:WD)(n,r,t))}function YD(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function XD(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function ZD(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&XD(e,o)),n}return s._value=t,s}function JD(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&YD(e,o)),n}return s._value=t,s}function QD(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=Ed(e);return this.tween(n,(r.local?ZD:JD)(r,t))}function e5(e,t){return function(){cb(this,e).delay=+t.apply(this,arguments)}}function t5(e,t){return t=+t,function(){cb(this,e).delay=t}}function n5(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?e5:t5)(t,e)):hr(this.node(),t).delay}function r5(e,t){return function(){Fr(this,e).duration=+t.apply(this,arguments)}}function s5(e,t){return t=+t,function(){Fr(this,e).duration=t}}function a5(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?r5:s5)(t,e)):hr(this.node(),t).duration}function o5(e,t){if(typeof t!="function")throw new Error;return function(){Fr(this,e).ease=t}}function i5(e){var t=this._id;return arguments.length?this.each(o5(t,e)):hr(this.node(),t).ease}function l5(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Fr(this,e).ease=n}}function c5(e){if(typeof e!="function")throw new Error;return this.each(l5(this._id,e))}function u5(e){typeof e!="function"&&(e=FR(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],l=o.length,u=r[s]=[],d,h=0;h<l;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&u.push(d);return new us(r,this._parents,this._name,this._id)}function d5(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,s=n.length,o=Math.min(r,s),l=new Array(r),u=0;u<o;++u)for(var d=t[u],h=n[u],f=d.length,p=l[u]=new Array(f),g,v=0;v<f;++v)(g=d[v]||h[v])&&(p[v]=g);for(;u<r;++u)l[u]=t[u];return new us(l,this._parents,this._name,this._id)}function h5(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 f5(e,t,n){var r,s,o=h5(t)?cb:Fr;return function(){var l=o(this,e),u=l.on;u!==r&&(s=(r=u).copy()).on(t,n),l.on=s}}function p5(e,t){var n=this._id;return arguments.length<2?hr(this.node(),n).on.on(e):this.each(f5(n,e,t))}function m5(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function g5(){return this.on("end.remove",m5(this._id))}function y5(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ab(e));for(var r=this._groups,s=r.length,o=new Array(s),l=0;l<s;++l)for(var u=r[l],d=u.length,h=o[l]=new Array(d),f,p,g=0;g<d;++g)(f=u[g])&&(p=e.call(f,f.__data__,g,u))&&("__data__"in f&&(p.__data__=f.__data__),h[g]=p,Td(h[g],t,n,g,h,hr(f,n)));return new us(o,this._parents,t,n)}function w5(e){var t=this._name,n=this._id;typeof e!="function"&&(e=DR(e));for(var r=this._groups,s=r.length,o=[],l=[],u=0;u<s;++u)for(var d=r[u],h=d.length,f,p=0;p<h;++p)if(f=d[p]){for(var g=e.call(f,f.__data__,p,d),v,k=hr(f,n),b=0,x=g.length;b<x;++b)(v=g[b])&&Td(v,t,n,b,g,k);o.push(g),l.push(f)}return new us(o,l,t,n)}var v5=Zl.prototype.constructor;function x5(){return new v5(this._groups,this._parents)}function b5(e,t){var n,r,s;return function(){var o=ni(this,e),l=(this.style.removeProperty(e),ni(this,e));return o===l?null:o===n&&l===r?s:s=t(n=o,r=l)}}function l2(e){return function(){this.style.removeProperty(e)}}function k5(e,t,n){var r,s=n+"",o;return function(){var l=ni(this,e);return l===s?null:l===r?o:o=t(r=l,n)}}function N5(e,t,n){var r,s,o;return function(){var l=ni(this,e),u=n(this),d=u+"";return u==null&&(d=u=(this.style.removeProperty(e),ni(this,e))),l===d?null:l===r&&d===s?o:(s=d,o=t(r=l,u))}}function j5(e,t){var n,r,s,o="style."+t,l="end."+o,u;return function(){var d=Fr(this,e),h=d.on,f=d.value[o]==null?u||(u=l2(t)):void 0;(h!==n||s!==f)&&(r=(n=h).copy()).on(l,s=f),d.on=r}}function S5(e,t,n){var r=(e+="")=="transform"?SD:i2;return t==null?this.styleTween(e,b5(e,r)).on("end.style."+e,l2(e)):typeof t=="function"?this.styleTween(e,N5(e,r,ub(this,"style."+e,t))).each(j5(this._id,e)):this.styleTween(e,k5(e,r,t),n).on("end.style."+e,null)}function _5(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function E5(e,t,n){var r,s;function o(){var l=t.apply(this,arguments);return l!==s&&(r=(s=l)&&_5(e,l,n)),r}return o._value=t,o}function C5(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,E5(e,t,n??""))}function T5(e){return function(){this.textContent=e}}function A5(e){return function(){var t=e(this);this.textContent=t??""}}function R5(e){return this.tween("text",typeof e=="function"?A5(ub(this,"text",e)):T5(e==null?"":e+""))}function M5(e){return function(t){this.textContent=e.call(this,t)}}function $5(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&M5(s)),t}return r._value=e,r}function I5(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,$5(e))}function O5(){for(var e=this._name,t=this._id,n=c2(),r=this._groups,s=r.length,o=0;o<s;++o)for(var l=r[o],u=l.length,d,h=0;h<u;++h)if(d=l[h]){var f=hr(d,t);Td(d,e,n,h,l,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new us(r,this._parents,e,n)}function L5(){var e,t,n=this,r=n._id,s=n.size();return new Promise(function(o,l){var u={value:l},d={value:function(){--s===0&&o()}};n.each(function(){var h=Fr(this,r),f=h.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(u),t._.interrupt.push(u),t._.end.push(d)),h.on=t}),s===0&&o()})}var P5=0;function us(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function c2(){return++P5}var os=Zl.prototype;us.prototype={constructor:us,select:y5,selectAll:w5,selectChild:os.selectChild,selectChildren:os.selectChildren,filter:u5,merge:d5,selection:x5,transition:O5,call:os.call,nodes:os.nodes,node:os.node,size:os.size,empty:os.empty,each:os.each,on:p5,attr:KD,attrTween:QD,style:S5,styleTween:C5,text:R5,textTween:I5,remove:g5,tween:qD,delay:n5,duration:a5,ease:i5,easeVarying:c5,end:L5,[Symbol.iterator]:os[Symbol.iterator]};function D5(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var F5={time:null,delay:0,duration:250,ease:D5};function B5(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 q5(e){var t,n;e instanceof us?(t=e._id,e=e._name):(t=c2(),(n=F5).time=lb(),e=e==null?null:e+"");for(var r=this._groups,s=r.length,o=0;o<s;++o)for(var l=r[o],u=l.length,d,h=0;h<u;++h)(d=l[h])&&Td(d,e,t,h,l,n||B5(d,t));return new us(r,this._parents,e,t)}Zl.prototype.interrupt=DD;Zl.prototype.transition=q5;const pu=e=>()=>e;function U5(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 is(e,t,n){this.k=e,this.x=t,this.y=n}is.prototype={constructor:is,scale:function(e){return e===1?this:new is(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new is(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 ls=new is(1,0,0);is.prototype;function tp(e){e.stopImmediatePropagation()}function dl(e){e.preventDefault(),e.stopImmediatePropagation()}function z5(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function W5(){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 bN(){return this.__zoom||ls}function H5(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function V5(){return navigator.maxTouchPoints||"ontouchstart"in this}function G5(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 u2(){var e=z5,t=W5,n=G5,r=H5,s=V5,o=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],u=250,d=AD,h=_d("start","zoom","end"),f,p,g,v=500,k=150,b=0,x=10;function N(M){M.property("__zoom",bN).on("wheel.zoom",B,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",D).filter(s).on("touchstart.zoom",O).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}N.transform=function(M,$,q,X){var H=M.selection?M.selection():M;H.property("__zoom",bN),M!==H?T(M,$,q,X):H.interrupt().each(function(){A(this,arguments).event(X).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},N.scaleBy=function(M,$,q,X){N.scaleTo(M,function(){var H=this.__zoom.k,I=typeof $=="function"?$.apply(this,arguments):$;return H*I},q,X)},N.scaleTo=function(M,$,q,X){N.transform(M,function(){var H=t.apply(this,arguments),I=this.__zoom,W=q==null?E(H):typeof q=="function"?q.apply(this,arguments):q,F=I.invert(W),Y=typeof $=="function"?$.apply(this,arguments):$;return n(_(S(I,Y),W,F),H,l)},q,X)},N.translateBy=function(M,$,q,X){N.transform(M,function(){return n(this.__zoom.translate(typeof $=="function"?$.apply(this,arguments):$,typeof q=="function"?q.apply(this,arguments):q),t.apply(this,arguments),l)},null,X)},N.translateTo=function(M,$,q,X,H){N.transform(M,function(){var I=t.apply(this,arguments),W=this.__zoom,F=X==null?E(I):typeof X=="function"?X.apply(this,arguments):X;return n(ls.translate(F[0],F[1]).scale(W.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof q=="function"?-q.apply(this,arguments):-q),I,l)},X,H)};function S(M,$){return $=Math.max(o[0],Math.min(o[1],$)),$===M.k?M:new is($,M.x,M.y)}function _(M,$,q){var X=$[0]-q[0]*M.k,H=$[1]-q[1]*M.k;return X===M.x&&H===M.y?M:new is(M.k,X,H)}function E(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function T(M,$,q,X){M.on("start.zoom",function(){A(this,arguments).event(X).start()}).on("interrupt.zoom end.zoom",function(){A(this,arguments).event(X).end()}).tween("zoom",function(){var H=this,I=arguments,W=A(H,I).event(X),F=t.apply(H,I),Y=q==null?E(F):typeof q=="function"?q.apply(H,I):q,J=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),V=H.__zoom,G=typeof $=="function"?$.apply(H,I):$,K=d(V.invert(Y).concat(J/V.k),G.invert(Y).concat(J/G.k));return function(Z){if(Z===1)Z=G;else{var ee=K(Z),re=J/ee[2];Z=new is(re,Y[0]-ee[0]*re,Y[1]-ee[1]*re)}W.zoom(null,Z)}})}function A(M,$,q){return!q&&M.__zooming||new R(M,$)}function R(M,$){this.that=M,this.args=$,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,$),this.taps=0}R.prototype={event:function(M){return M&&(this.sourceEvent=M),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(M,$){return this.mouse&&M!=="mouse"&&(this.mouse[1]=$.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=$.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=$.invert(this.touch1[0])),this.that.__zoom=$,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var $=Ln(this.that).datum();h.call(M,this.that,new U5(M,{sourceEvent:this.sourceEvent,target:N,transform:this.that.__zoom,dispatch:h}),$)}};function B(M,...$){if(!e.apply(this,arguments))return;var q=A(this,$).event(M),X=this.__zoom,H=Math.max(o[0],Math.min(o[1],X.k*Math.pow(2,r.apply(this,arguments)))),I=sr(M);if(q.wheel)(q.mouse[0][0]!==I[0]||q.mouse[0][1]!==I[1])&&(q.mouse[1]=X.invert(q.mouse[0]=I)),clearTimeout(q.wheel);else{if(X.k===H)return;q.mouse=[I,X.invert(I)],Pu(this),q.start()}dl(M),q.wheel=setTimeout(W,k),q.zoom("mouse",n(_(S(X,H),q.mouse[0],q.mouse[1]),q.extent,l));function W(){q.wheel=null,q.end()}}function P(M,...$){if(g||!e.apply(this,arguments))return;var q=M.currentTarget,X=A(this,$,!0).event(M),H=Ln(M.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",J,!0),I=sr(M,q),W=M.clientX,F=M.clientY;YR(M.view),tp(M),X.mouse=[I,this.__zoom.invert(I)],Pu(this),X.start();function Y(V){if(dl(V),!X.moved){var G=V.clientX-W,K=V.clientY-F;X.moved=G*G+K*K>b}X.event(V).zoom("mouse",n(_(X.that.__zoom,X.mouse[0]=sr(V,q),X.mouse[1]),X.extent,l))}function J(V){H.on("mousemove.zoom mouseup.zoom",null),XR(V.view,X.moved),dl(V),X.event(V).end()}}function D(M,...$){if(e.apply(this,arguments)){var q=this.__zoom,X=sr(M.changedTouches?M.changedTouches[0]:M,this),H=q.invert(X),I=q.k*(M.shiftKey?.5:2),W=n(_(S(q,I),X,H),t.apply(this,$),l);dl(M),u>0?Ln(this).transition().duration(u).call(T,W,X,M):Ln(this).call(N.transform,W,X,M)}}function O(M,...$){if(e.apply(this,arguments)){var q=M.touches,X=q.length,H=A(this,$,M.changedTouches.length===X).event(M),I,W,F,Y;for(tp(M),W=0;W<X;++W)F=q[W],Y=sr(F,this),Y=[Y,this.__zoom.invert(Y),F.identifier],H.touch0?!H.touch1&&H.touch0[2]!==Y[2]&&(H.touch1=Y,H.taps=0):(H.touch0=Y,I=!0,H.taps=1+!!f);f&&(f=clearTimeout(f)),I&&(H.taps<2&&(p=Y[0],f=setTimeout(function(){f=null},v)),Pu(this),H.start())}}function L(M,...$){if(this.__zooming){var q=A(this,$).event(M),X=M.changedTouches,H=X.length,I,W,F,Y;for(dl(M),I=0;I<H;++I)W=X[I],F=sr(W,this),q.touch0&&q.touch0[2]===W.identifier?q.touch0[0]=F:q.touch1&&q.touch1[2]===W.identifier&&(q.touch1[0]=F);if(W=q.that.__zoom,q.touch1){var J=q.touch0[0],V=q.touch0[1],G=q.touch1[0],K=q.touch1[1],Z=(Z=G[0]-J[0])*Z+(Z=G[1]-J[1])*Z,ee=(ee=K[0]-V[0])*ee+(ee=K[1]-V[1])*ee;W=S(W,Math.sqrt(Z/ee)),F=[(J[0]+G[0])/2,(J[1]+G[1])/2],Y=[(V[0]+K[0])/2,(V[1]+K[1])/2]}else if(q.touch0)F=q.touch0[0],Y=q.touch0[1];else return;q.zoom("touch",n(_(W,F,Y),q.extent,l))}}function z(M,...$){if(this.__zooming){var q=A(this,$).event(M),X=M.changedTouches,H=X.length,I,W;for(tp(M),g&&clearTimeout(g),g=setTimeout(function(){g=null},v),I=0;I<H;++I)W=X[I],q.touch0&&q.touch0[2]===W.identifier?delete q.touch0:q.touch1&&q.touch1[2]===W.identifier&&delete q.touch1;if(q.touch1&&!q.touch0&&(q.touch0=q.touch1,delete q.touch1),q.touch0)q.touch0[1]=this.__zoom.invert(q.touch0[0]);else if(q.end(),q.taps===2&&(W=sr(W,this),Math.hypot(p[0]-W[0],p[1]-W[1])<x)){var F=Ln(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return N.wheelDelta=function(M){return arguments.length?(r=typeof M=="function"?M:pu(+M),N):r},N.filter=function(M){return arguments.length?(e=typeof M=="function"?M:pu(!!M),N):e},N.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:pu(!!M),N):s},N.extent=function(M){return arguments.length?(t=typeof M=="function"?M:pu([[+M[0][0],+M[0][1]],[+M[1][0],+M[1][1]]]),N):t},N.scaleExtent=function(M){return arguments.length?(o[0]=+M[0],o[1]=+M[1],N):[o[0],o[1]]},N.translateExtent=function(M){return arguments.length?(l[0][0]=+M[0][0],l[1][0]=+M[1][0],l[0][1]=+M[0][1],l[1][1]=+M[1][1],N):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},N.constrain=function(M){return arguments.length?(n=M,N):n},N.duration=function(M){return arguments.length?(u=+M,N):u},N.interpolate=function(M){return arguments.length?(d=M,N):d},N.on=function(){var M=h.on.apply(h,arguments);return M===h?N:M},N.clickDistance=function(M){return arguments.length?(b=(M=+M)*M,N):Math.sqrt(b)},N.tapDistance=function(M){return arguments.length?(x=+M,N):x},N}var Lt=OR();const Ad=w.createContext(null),K5=Ad.Provider,ds={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.`},d2=ds.error001();function Ye(e,t){const n=w.useContext(Ad);if(n===null)throw new Error(d2);return LR(n,e,t)}const kt=()=>{const e=w.useContext(Ad);if(e===null)throw new Error(d2);return w.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},Y5=e=>e.userSelectionActive?"none":"all";function db({position:e,children:t,className:n,style:r,...s}){const o=Ye(Y5),l=`${e}`.split("-");return de.createElement("div",{className:Ut(["react-flow__panel",n,...l]),style:{...r,pointerEvents:o},...s},t)}function X5({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:de.createElement(db,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},de.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const Z5=({x:e,y:t,label:n,labelStyle:r={},labelShowBg:s=!0,labelBgStyle:o={},labelBgPadding:l=[2,4],labelBgBorderRadius:u=2,children:d,className:h,...f})=>{const p=w.useRef(null),[g,v]=w.useState({x:0,y:0,width:0,height:0}),k=Ut(["react-flow__edge-textwrapper",h]);return w.useEffect(()=>{if(p.current){const b=p.current.getBBox();v({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),typeof n>"u"||!n?null:de.createElement("g",{transform:`translate(${e-g.width/2} ${t-g.height/2})`,className:k,visibility:g.width?"visible":"hidden",...f},s&&de.createElement("rect",{width:g.width+2*l[0],x:-l[0],y:-l[1],height:g.height+2*l[1],className:"react-flow__edge-textbg",style:o,rx:u,ry:u}),de.createElement("text",{className:"react-flow__edge-text",y:g.height/2,dy:"0.3em",ref:p,style:r},n),d)};var J5=w.memo(Z5);const hb=e=>({width:e.offsetWidth,height:e.offsetHeight}),si=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),fb=(e={x:0,y:0},t)=>({x:si(e.x,t[0][0],t[1][0]),y:si(e.y,t[0][1],t[1][1])}),kN=(e,t,n)=>e<t?si(Math.abs(e-t),1,50)/50:e>n?-si(Math.abs(e-n),1,50)/50:0,h2=(e,t)=>{const n=kN(e.x,35,t.width-35)*20,r=kN(e.y,35,t.height-35)*20;return[n,r]},f2=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},p2=(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)}),$l=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),m2=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),NN=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),Q5=(e,t)=>m2(p2($l(e),$l(t))),rx=(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)},eF=e=>Pn(e.width)&&Pn(e.height)&&Pn(e.x)&&Pn(e.y),Pn=e=>!isNaN(e)&&isFinite(e),mt=Symbol.for("internals"),g2=["Enter"," ","Escape"],tF=(e,t)=>{},nF=e=>"nativeEvent"in e;function sx(e){var s,o;const t=nF(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 y2=e=>"clientX"in e,Zs=(e,t)=>{var o,l;const n=y2(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)}},Qu=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},Ql=({id:e,path:t,labelX:n,labelY:r,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:g,interactionWidth:v=20})=>de.createElement(de.Fragment,null,de.createElement("path",{id:e,style:f,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:p,markerStart:g}),v&&de.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:v,className:"react-flow__edge-interaction"}),s&&Pn(n)&&Pn(r)?de.createElement(J5,{x:n,y:r,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h}):null);Ql.displayName="BaseEdge";function hl(e,t,n){return n===void 0?n:r=>{const s=t().edges.find(o=>o.id===e);s&&n(r,{...s})}}function w2({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 v2({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:o,targetControlX:l,targetControlY:u}){const d=e*.125+s*.375+l*.375+n*.125,h=t*.125+o*.375+u*.375+r*.125,f=Math.abs(d-e),p=Math.abs(h-t);return[d,h,f,p]}var Pa;(function(e){e.Strict="strict",e.Loose="loose"})(Pa||(Pa={}));var Ta;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ta||(Ta={}));var Il;(function(e){e.Partial="partial",e.Full="full"})(Il||(Il={}));var Gs;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Gs||(Gs={}));var ed;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(ed||(ed={}));var Ae;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ae||(Ae={}));function jN({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===Ae.Left||e===Ae.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function x2({sourceX:e,sourceY:t,sourcePosition:n=Ae.Bottom,targetX:r,targetY:s,targetPosition:o=Ae.Top}){const[l,u]=jN({pos:n,x1:e,y1:t,x2:r,y2:s}),[d,h]=jN({pos:o,x1:r,y1:s,x2:e,y2:t}),[f,p,g,v]=v2({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:u,targetControlX:d,targetControlY:h});return[`M${e},${t} C${l},${u} ${d},${h} ${r},${s}`,f,p,g,v]}const pb=w.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s=Ae.Bottom,targetPosition:o=Ae.Top,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:k,interactionWidth:b})=>{const[x,N,S]=x2({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o});return de.createElement(Ql,{path:x,labelX:N,labelY:S,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:k,interactionWidth:b})});pb.displayName="SimpleBezierEdge";const SN={[Ae.Left]:{x:-1,y:0},[Ae.Right]:{x:1,y:0},[Ae.Top]:{x:0,y:-1},[Ae.Bottom]:{x:0,y:1}},rF=({source:e,sourcePosition:t=Ae.Bottom,target:n})=>t===Ae.Left||t===Ae.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},_N=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function sF({source:e,sourcePosition:t=Ae.Bottom,target:n,targetPosition:r=Ae.Top,center:s,offset:o}){const l=SN[t],u=SN[r],d={x:e.x+l.x*o,y:e.y+l.y*o},h={x:n.x+u.x*o,y:n.y+u.y*o},f=rF({source:d,sourcePosition:t,target:h}),p=f.x!==0?"x":"y",g=f[p];let v=[],k,b;const x={x:0,y:0},N={x:0,y:0},[S,_,E,T]=w2({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*u[p]===-1){k=s.x??S,b=s.y??_;const R=[{x:k,y:d.y},{x:k,y:h.y}],B=[{x:d.x,y:b},{x:h.x,y:b}];l[p]===g?v=p==="x"?R:B:v=p==="x"?B:R}else{const R=[{x:d.x,y:h.y}],B=[{x:h.x,y:d.y}];if(p==="x"?v=l.x===g?B:R:v=l.y===g?R:B,t===r){const z=Math.abs(e[p]-n[p]);if(z<=o){const M=Math.min(o-1,o-z);l[p]===g?x[p]=(d[p]>e[p]?-1:1)*M:N[p]=(h[p]>n[p]?-1:1)*M}}if(t!==r){const z=p==="x"?"y":"x",M=l[p]===u[z],$=d[z]>h[z],q=d[z]<h[z];(l[p]===1&&(!M&&$||M&&q)||l[p]!==1&&(!M&&q||M&&$))&&(v=p==="x"?R:B)}const P={x:d.x+x.x,y:d.y+x.y},D={x:h.x+N.x,y:h.y+N.y},O=Math.max(Math.abs(P.x-v[0].x),Math.abs(D.x-v[0].x)),L=Math.max(Math.abs(P.y-v[0].y),Math.abs(D.y-v[0].y));O>=L?(k=(P.x+D.x)/2,b=v[0].y):(k=v[0].x,b=(P.y+D.y)/2)}return[[e,{x:d.x+x.x,y:d.y+x.y},...v,{x:h.x+N.x,y:h.y+N.y},n],k,b,E,T]}function aF(e,t,n,r){const s=Math.min(_N(e,t)/2,_N(t,n)/2,r),{x:o,y:l}=t;if(e.x===o&&o===n.x||e.y===l&&l===n.y)return`L${o} ${l}`;if(e.y===l){const h=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${o+s*h},${l}Q ${o},${l} ${o},${l+s*f}`}const u=e.x<n.x?1:-1,d=e.y<n.y?-1:1;return`L ${o},${l+s*d}Q ${o},${l} ${o+s*u},${l}`}function ax({sourceX:e,sourceY:t,sourcePosition:n=Ae.Bottom,targetX:r,targetY:s,targetPosition:o=Ae.Top,borderRadius:l=5,centerX:u,centerY:d,offset:h=20}){const[f,p,g,v,k]=sF({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:o,center:{x:u,y:d},offset:h});return[f.reduce((x,N,S)=>{let _="";return S>0&&S<f.length-1?_=aF(f[S-1],N,f[S+1],l):_=`${S===0?"M":"L"}${N.x} ${N.y}`,x+=_,x},""),p,g,v,k]}const Rd=w.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:f,sourcePosition:p=Ae.Bottom,targetPosition:g=Ae.Top,markerEnd:v,markerStart:k,pathOptions:b,interactionWidth:x})=>{const[N,S,_]=ax({sourceX:e,sourceY:t,sourcePosition:p,targetX:n,targetY:r,targetPosition:g,borderRadius:b==null?void 0:b.borderRadius,offset:b==null?void 0:b.offset});return de.createElement(Ql,{path:N,labelX:S,labelY:_,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:v,markerStart:k,interactionWidth:x})});Rd.displayName="SmoothStepEdge";const mb=w.memo(e=>{var t;return de.createElement(Rd,{...e,pathOptions:w.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});mb.displayName="StepEdge";function oF({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,o,l,u]=w2({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,o,l,u]}const gb=w.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:g,interactionWidth:v})=>{const[k,b,x]=oF({sourceX:e,sourceY:t,targetX:n,targetY:r});return de.createElement(Ql,{path:k,labelX:b,labelY:x,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:g,interactionWidth:v})});gb.displayName="StraightEdge";function mu(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function EN({pos:e,x1:t,y1:n,x2:r,y2:s,c:o}){switch(e){case Ae.Left:return[t-mu(t-r,o),n];case Ae.Right:return[t+mu(r-t,o),n];case Ae.Top:return[t,n-mu(n-s,o)];case Ae.Bottom:return[t,n+mu(s-n,o)]}}function yb({sourceX:e,sourceY:t,sourcePosition:n=Ae.Bottom,targetX:r,targetY:s,targetPosition:o=Ae.Top,curvature:l=.25}){const[u,d]=EN({pos:n,x1:e,y1:t,x2:r,y2:s,c:l}),[h,f]=EN({pos:o,x1:r,y1:s,x2:e,y2:t,c:l}),[p,g,v,k]=v2({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:u,sourceControlY:d,targetControlX:h,targetControlY:f});return[`M${e},${t} C${u},${d} ${h},${f} ${r},${s}`,p,g,v,k]}const td=w.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s=Ae.Bottom,targetPosition:o=Ae.Top,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:k,pathOptions:b,interactionWidth:x})=>{const[N,S,_]=yb({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o,curvature:b==null?void 0:b.curvature});return de.createElement(Ql,{path:N,labelX:S,labelY:_,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:k,interactionWidth:x})});td.displayName="BezierEdge";const wb=w.createContext(null),iF=wb.Provider;wb.Consumer;const lF=()=>w.useContext(wb),cF=e=>"id"in e&&"source"in e&&"target"in e,uF=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,ox=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`,dF=(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)),hF=(e,t)=>{if(!e.source||!e.target)return t;let n;return cF(e)?n={...e}:n={...e,id:uF(e)},dF(n,t)?t:t.concat(n)},ix=({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},b2=({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}},Md=(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 p2(r,$l({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 m2(n)},k2=(e,t,[n,r,s]=[0,0,1],o=!1,l=!1,u=[0,0])=>{const d={x:(t.x-n)/s,y:(t.y-r)/s,width:t.width/s,height:t.height/s},h=[];return e.forEach(f=>{const{width:p,height:g,selectable:v=!0,hidden:k=!1}=f;if(l&&!v||k)return!1;const{positionAbsolute:b}=Ma(f,u),x={x:b.x,y:b.y,width:p||0,height:g||0},N=rx(d,x),S=typeof p>"u"||typeof g>"u"||p===null||g===null,_=o&&N>0,E=(p||0)*(g||0);(S||_||N>=E||f.dragging)&&h.push(f)}),h},N2=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},j2=(e,t,n,r,s,o=.1)=>{const l=t/(e.width*(1+o)),u=n/(e.height*(1+o)),d=Math.min(l,u),h=si(d,r,s),f=e.x+e.width/2,p=e.y+e.height/2,g=t/2-f*h,v=n/2-p*h;return{x:g,y:v,zoom:h}},ja=(e,t=0)=>e.transition().duration(t);function CN(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 fF(e,t,n,r,s,o){const{x:l,y:u}=Zs(e),h=t.elementsFromPoint(l,u).find(k=>k.classList.contains("react-flow__handle"));if(h){const k=h.getAttribute("data-nodeid");if(k){const b=vb(void 0,h),x=h.getAttribute("data-handleid"),N=o({nodeId:k,id:x,type:b});if(N){const S=s.find(_=>_.nodeId===k&&_.type===b&&_.id===x);return{handle:{id:x,type:b,nodeId:k,x:(S==null?void 0:S.x)||n.x,y:(S==null?void 0:S.y)||n.y},validHandleResult:N}}}}let f=[],p=1/0;if(s.forEach(k=>{const b=Math.sqrt((k.x-n.x)**2+(k.y-n.y)**2);if(b<=r){const x=o(k);b<=p&&(b<p?f=[{handle:k,validHandleResult:x}]:b===p&&f.push({handle:k,validHandleResult:x}),p=b)}}),!f.length)return{handle:null,validHandleResult:S2()};if(f.length===1)return f[0];const g=f.some(({validHandleResult:k})=>k.isValid),v=f.some(({handle:k})=>k.type==="target");return f.find(({handle:k,validHandleResult:b})=>v?k.type==="target":g?b.isValid:!0)||f[0]}const pF={source:null,target:null,sourceHandle:null,targetHandle:null},S2=()=>({handleDomNode:null,isValid:!1,connection:pF,endHandle:null});function _2(e,t,n,r,s,o,l){const u=s==="target",d=l.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),h={...S2(),handleDomNode:d};if(d){const f=vb(void 0,d),p=d.getAttribute("data-nodeid"),g=d.getAttribute("data-handleid"),v=d.classList.contains("connectable"),k=d.classList.contains("connectableend"),b={source:u?p:n,sourceHandle:u?g:r,target:u?n:p,targetHandle:u?r:g};h.connection=b,v&&k&&(t===Pa.Strict?u&&f==="source"||!u&&f==="target":p!==n||g!==r)&&(h.endHandle={nodeId:p,handleId:g,type:f},h.isValid=o(b))}return h}function mF({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((s,o)=>{if(o[mt]){const{handleBounds:l}=o[mt];let u=[],d=[];l&&(u=CN(o,l,"source",`${t}-${n}-${r}`),d=CN(o,l,"target",`${t}-${n}-${r}`)),s.push(...u,...d)}return s},[])}function vb(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function np(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function gF(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function E2({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:s,getState:o,setState:l,isValidConnection:u,edgeUpdaterType:d,onReconnectEnd:h}){const f=f2(e.target),{connectionMode:p,domNode:g,autoPanOnConnect:v,connectionRadius:k,onConnectStart:b,panBy:x,getNodes:N,cancelConnection:S}=o();let _=0,E;const{x:T,y:A}=Zs(e),R=f==null?void 0:f.elementFromPoint(T,A),B=vb(d,R),P=g==null?void 0:g.getBoundingClientRect();if(!P||!B)return;let D,O=Zs(e,P),L=!1,z=null,M=!1,$=null;const q=mF({nodes:N(),nodeId:n,handleId:t,handleType:B}),X=()=>{if(!v)return;const[W,F]=h2(O,P);x({x:W,y:F}),_=requestAnimationFrame(X)};l({connectionPosition:O,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:B,connectionStartHandle:{nodeId:n,handleId:t,type:B},connectionEndHandle:null}),b==null||b(e,{nodeId:n,handleId:t,handleType:B});function H(W){const{transform:F}=o();O=Zs(W,P);const{handle:Y,validHandleResult:J}=fF(W,f,ix(O,F,!1,[1,1]),k,q,V=>_2(V,p,n,t,s?"target":"source",u,f));if(E=Y,L||(X(),L=!0),$=J.handleDomNode,z=J.connection,M=J.isValid,l({connectionPosition:E&&M?b2({x:E.x,y:E.y},F):O,connectionStatus:gF(!!E,M),connectionEndHandle:J.endHandle}),!E&&!M&&!$)return np(D);z.source!==z.target&&$&&(np(D),D=$,$.classList.add("connecting","react-flow__handle-connecting"),$.classList.toggle("valid",M),$.classList.toggle("react-flow__handle-valid",M))}function I(W){var F,Y;(E||$)&&z&&M&&(r==null||r(z)),(Y=(F=o()).onConnectEnd)==null||Y.call(F,W),d&&(h==null||h(W)),np(D),S(),cancelAnimationFrame(_),L=!1,M=!1,z=null,$=null,f.removeEventListener("mousemove",H),f.removeEventListener("mouseup",I),f.removeEventListener("touchmove",H),f.removeEventListener("touchend",I)}f.addEventListener("mousemove",H),f.addEventListener("mouseup",I),f.addEventListener("touchmove",H),f.addEventListener("touchend",I)}const TN=()=>!0,yF=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),wF=(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}},C2=w.forwardRef(({type:e="source",position:t=Ae.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:o=!0,id:l,onConnect:u,children:d,className:h,onMouseDown:f,onTouchStart:p,...g},v)=>{var P,D;const k=l||null,b=e==="target",x=kt(),N=lF(),{connectOnClick:S,noPanClassName:_}=Ye(yF,Tt),{connecting:E,clickConnecting:T}=Ye(wF(N,k,e),Tt);N||(D=(P=x.getState()).onError)==null||D.call(P,"010",ds.error010());const A=O=>{const{defaultEdgeOptions:L,onConnect:z,hasDefaultEdges:M}=x.getState(),$={...L,...O};if(M){const{edges:q,setEdges:X}=x.getState();X(hF($,q))}z==null||z($),u==null||u($)},R=O=>{if(!N)return;const L=y2(O);s&&(L&&O.button===0||!L)&&E2({event:O,handleId:k,nodeId:N,onConnect:A,isTarget:b,getState:x.getState,setState:x.setState,isValidConnection:n||x.getState().isValidConnection||TN}),L?f==null||f(O):p==null||p(O)},B=O=>{const{onClickConnectStart:L,onClickConnectEnd:z,connectionClickStartHandle:M,connectionMode:$,isValidConnection:q}=x.getState();if(!N||!M&&!s)return;if(!M){L==null||L(O,{nodeId:N,handleId:k,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:N,type:e,handleId:k}});return}const X=f2(O.target),H=n||q||TN,{connection:I,isValid:W}=_2({nodeId:N,id:k,type:e},$,M.nodeId,M.handleId||null,M.type,H,X);W&&A(I),z==null||z(O),x.setState({connectionClickStartHandle:null})};return de.createElement("div",{"data-handleid":k,"data-nodeid":N,"data-handlepos":t,"data-id":`${N}-${k}-${e}`,className:Ut(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",_,h,{source:!b,target:b,connectable:r,connectablestart:s,connectableend:o,connecting:T,connectionindicator:r&&(s&&!E||o&&E)}]),onMouseDown:R,onTouchStart:R,onClick:S?B:void 0,ref:v,...g},d)});C2.displayName="Handle";var Da=w.memo(C2);const T2=({data:e,isConnectable:t,targetPosition:n=Ae.Top,sourcePosition:r=Ae.Bottom})=>de.createElement(de.Fragment,null,de.createElement(Da,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,de.createElement(Da,{type:"source",position:r,isConnectable:t}));T2.displayName="DefaultNode";var lx=w.memo(T2);const A2=({data:e,isConnectable:t,sourcePosition:n=Ae.Bottom})=>de.createElement(de.Fragment,null,e==null?void 0:e.label,de.createElement(Da,{type:"source",position:n,isConnectable:t}));A2.displayName="InputNode";var R2=w.memo(A2);const M2=({data:e,isConnectable:t,targetPosition:n=Ae.Top})=>de.createElement(de.Fragment,null,de.createElement(Da,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);M2.displayName="OutputNode";var $2=w.memo(M2);const xb=()=>null;xb.displayName="GroupNode";const vF=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),gu=e=>e.id;function xF(e,t){return Tt(e.selectedNodes.map(gu),t.selectedNodes.map(gu))&&Tt(e.selectedEdges.map(gu),t.selectedEdges.map(gu))}const I2=w.memo(({onSelectionChange:e})=>{const t=kt(),{selectedNodes:n,selectedEdges:r}=Ye(vF,xF);return w.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChange.forEach(o=>o(s))},[n,r,e]),null});I2.displayName="SelectionListener";const bF=e=>!!e.onSelectionChange;function kF({onSelectionChange:e}){const t=Ye(bF);return e||t?de.createElement(I2,{onSelectionChange:e}):null}const NF=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 Eo(e,t){w.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function De(e,t,n){w.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const jF=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:s,onConnectStart:o,onConnectEnd:l,onClickConnectStart:u,onClickConnectEnd:d,nodesDraggable:h,nodesConnectable:f,nodesFocusable:p,edgesFocusable:g,edgesUpdatable:v,elevateNodesOnSelect:k,minZoom:b,maxZoom:x,nodeExtent:N,onNodesChange:S,onEdgesChange:_,elementsSelectable:E,connectionMode:T,snapGrid:A,snapToGrid:R,translateExtent:B,connectOnClick:P,defaultEdgeOptions:D,fitView:O,fitViewOptions:L,onNodesDelete:z,onEdgesDelete:M,onNodeDrag:$,onNodeDragStart:q,onNodeDragStop:X,onSelectionDrag:H,onSelectionDragStart:I,onSelectionDragStop:W,noPanClassName:F,nodeOrigin:Y,rfId:J,autoPanOnConnect:V,autoPanOnNodeDrag:G,onError:K,connectionRadius:Z,isValidConnection:ee,nodeDragThreshold:re})=>{const{setNodes:ue,setEdges:me,setDefaultNodesAndEdges:ae,setMinZoom:pe,setMaxZoom:xe,setTranslateExtent:se,setNodeExtent:ve,reset:fe}=Ye(NF,Tt),he=kt();return w.useEffect(()=>{const _e=r==null?void 0:r.map(Fe=>({...Fe,...D}));return ae(n,_e),()=>{fe()}},[]),De("defaultEdgeOptions",D,he.setState),De("connectionMode",T,he.setState),De("onConnect",s,he.setState),De("onConnectStart",o,he.setState),De("onConnectEnd",l,he.setState),De("onClickConnectStart",u,he.setState),De("onClickConnectEnd",d,he.setState),De("nodesDraggable",h,he.setState),De("nodesConnectable",f,he.setState),De("nodesFocusable",p,he.setState),De("edgesFocusable",g,he.setState),De("edgesUpdatable",v,he.setState),De("elementsSelectable",E,he.setState),De("elevateNodesOnSelect",k,he.setState),De("snapToGrid",R,he.setState),De("snapGrid",A,he.setState),De("onNodesChange",S,he.setState),De("onEdgesChange",_,he.setState),De("connectOnClick",P,he.setState),De("fitViewOnInit",O,he.setState),De("fitViewOnInitOptions",L,he.setState),De("onNodesDelete",z,he.setState),De("onEdgesDelete",M,he.setState),De("onNodeDrag",$,he.setState),De("onNodeDragStart",q,he.setState),De("onNodeDragStop",X,he.setState),De("onSelectionDrag",H,he.setState),De("onSelectionDragStart",I,he.setState),De("onSelectionDragStop",W,he.setState),De("noPanClassName",F,he.setState),De("nodeOrigin",Y,he.setState),De("rfId",J,he.setState),De("autoPanOnConnect",V,he.setState),De("autoPanOnNodeDrag",G,he.setState),De("onError",K,he.setState),De("connectionRadius",Z,he.setState),De("isValidConnection",ee,he.setState),De("nodeDragThreshold",re,he.setState),Eo(e,ue),Eo(t,me),Eo(b,pe),Eo(x,xe),Eo(B,se),Eo(N,ve),null},AN={display:"none"},SF={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},O2="react-flow__node-desc",L2="react-flow__edge-desc",_F="react-flow__aria-live",EF=e=>e.ariaLiveMessage;function CF({rfId:e}){const t=Ye(EF);return de.createElement("div",{id:`${_F}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:SF},t)}function TF({rfId:e,disableKeyboardA11y:t}){return de.createElement(de.Fragment,null,de.createElement("div",{id:`${O2}-${e}`,style:AN},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),de.createElement("div",{id:`${L2}-${e}`,style:AN},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&de.createElement(CF,{rfId:e}))}var Ol=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,r]=w.useState(!1),s=w.useRef(!1),o=w.useRef(new Set([])),[l,u]=w.useMemo(()=>{if(e!==null){const h=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.split("+")),f=h.reduce((p,g)=>p.concat(...g),[]);return[h,f]}return[[],[]]},[e]);return w.useEffect(()=>{const d=typeof document<"u"?document:null,h=(t==null?void 0:t.target)||d;if(e!==null){const f=v=>{if(s.current=v.ctrlKey||v.metaKey||v.shiftKey,(!s.current||s.current&&!t.actInsideInputWithModifier)&&sx(v))return!1;const b=MN(v.code,u);o.current.add(v[b]),RN(l,o.current,!1)&&(v.preventDefault(),r(!0))},p=v=>{if((!s.current||s.current&&!t.actInsideInputWithModifier)&&sx(v))return!1;const b=MN(v.code,u);RN(l,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(v[b]),v.key==="Meta"&&o.current.clear(),s.current=!1},g=()=>{o.current.clear(),r(!1)};return h==null||h.addEventListener("keydown",f),h==null||h.addEventListener("keyup",p),window.addEventListener("blur",g),()=>{h==null||h.removeEventListener("keydown",f),h==null||h.removeEventListener("keyup",p),window.removeEventListener("blur",g)}}},[e,r]),n};function RN(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function MN(e,t){return t.includes(e)?"code":"key"}function P2(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 P2(o,t,{x:(n.x??0)+l.x,y:(n.y??0)+l.y,z:(((u=o[mt])==null?void 0:u.z)??0)>(n.z??0)?((d=o[mt])==null?void 0:d.z)??0:n.z??0},r)}function D2(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}=P2(r,e,{...r.position,z:((o=r[mt])==null?void 0:o.z)??0},t);r.positionAbsolute={x:l,y:u},r[mt].z=d,n!=null&&n[r.id]&&(r[mt].isParent=!0)}})}function rp(e,t,n,r){const s=new Map,o={},l=r?1e3:0;return e.forEach(u=>{var v;const d=(Pn(u.zIndex)?u.zIndex:0)+(u.selected?l:0),h=t.get(u.id),f={...u,positionAbsolute:{x:u.position.x,y:u.position.y}},p=u.parentNode||u.parentId;p&&(o[p]=!0);const g=(h==null?void 0:h.type)&&(h==null?void 0:h.type)!==u.type;Object.defineProperty(f,mt,{enumerable:!1,value:{handleBounds:g||(v=h==null?void 0:h[mt])==null?void 0:v.handleBounds,z:d}}),s.set(u.id,f)}),D2(s,n,o),s}function F2(e,t={}){const{getNodes:n,width:r,height:s,minZoom:o,maxZoom:l,d3Zoom:u,d3Selection:d,fitViewOnInitDone:h,fitViewOnInit:f,nodeOrigin:p}=e(),g=t.initial&&!h&&f;if(u&&d&&(g||!t.initial)){const k=n().filter(x=>{var S;const N=t.includeHiddenNodes?x.width&&x.height:!x.hidden;return(S=t.nodes)!=null&&S.length?N&&t.nodes.some(_=>_.id===x.id):N}),b=k.every(x=>x.width&&x.height);if(k.length>0&&b){const x=Md(k,p),{x:N,y:S,zoom:_}=j2(x,r,s,t.minZoom??o,t.maxZoom??l,t.padding??.1),E=ls.translate(N,S).scale(_);return typeof t.duration=="number"&&t.duration>0?u.transform(ja(d,t.duration),E):u.transform(d,E),!0}}return!1}function AF(e,t){return e.forEach(n=>{const r=t.get(n.id);r&&t.set(r.id,{...r,[mt]:r[mt],selected:n.selected})}),new Map(t)}function RF(e,t){return t.map(n=>{const r=e.find(s=>s.id===n.id);return r&&(n.selected=r.selected),n})}function yu({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:s,edges:o,onNodesChange:l,onEdgesChange:u,hasDefaultNodes:d,hasDefaultEdges:h}=n();e!=null&&e.length&&(d&&r({nodeInternals:AF(e,s)}),l==null||l(e)),t!=null&&t.length&&(h&&r({edges:RF(t,o)}),u==null||u(t))}const Co=()=>{},MF={zoomIn:Co,zoomOut:Co,zoomTo:Co,getZoom:()=>1,setViewport:Co,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Co,fitBounds:Co,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},$F=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),IF=()=>{const e=kt(),{d3Zoom:t,d3Selection:n}=Ye($F,Tt);return w.useMemo(()=>n&&t?{zoomIn:s=>t.scaleBy(ja(n,s==null?void 0:s.duration),1.2),zoomOut:s=>t.scaleBy(ja(n,s==null?void 0:s.duration),1/1.2),zoomTo:(s,o)=>t.scaleTo(ja(n,o==null?void 0:o.duration),s),getZoom:()=>e.getState().transform[2],setViewport:(s,o)=>{const[l,u,d]=e.getState().transform,h=ls.translate(s.x??l,s.y??u).scale(s.zoom??d);t.transform(ja(n,o==null?void 0:o.duration),h)},getViewport:()=>{const[s,o,l]=e.getState().transform;return{x:s,y:o,zoom:l}},fitView:s=>F2(e.getState,s),setCenter:(s,o,l)=>{const{width:u,height:d,maxZoom:h}=e.getState(),f=typeof(l==null?void 0:l.zoom)<"u"?l.zoom:h,p=u/2-s*f,g=d/2-o*f,v=ls.translate(p,g).scale(f);t.transform(ja(n,l==null?void 0:l.duration),v)},fitBounds:(s,o)=>{const{width:l,height:u,minZoom:d,maxZoom:h}=e.getState(),{x:f,y:p,zoom:g}=j2(s,l,u,d,h,(o==null?void 0:o.padding)??.1),v=ls.translate(f,p).scale(g);t.transform(ja(n,o==null?void 0:o.duration),v)},project:s=>{const{transform:o,snapToGrid:l,snapGrid:u}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),ix(s,o,l,u)},screenToFlowPosition:s=>{const{transform:o,snapToGrid:l,snapGrid:u,domNode:d}=e.getState();if(!d)return s;const{x:h,y:f}=d.getBoundingClientRect(),p={x:s.x-h,y:s.y-f};return ix(p,o,l,u)},flowToScreenPosition:s=>{const{transform:o,domNode:l}=e.getState();if(!l)return s;const{x:u,y:d}=l.getBoundingClientRect(),h=b2(s,o);return{x:h.x+u,y:h.y+d}},viewportInitialized:!0}:MF,[t,n])};function mi(){const e=IF(),t=kt(),n=w.useCallback(()=>t.getState().getNodes().map(b=>({...b})),[]),r=w.useCallback(b=>t.getState().nodeInternals.get(b),[]),s=w.useCallback(()=>{const{edges:b=[]}=t.getState();return b.map(x=>({...x}))},[]),o=w.useCallback(b=>{const{edges:x=[]}=t.getState();return x.find(N=>N.id===b)},[]),l=w.useCallback(b=>{const{getNodes:x,setNodes:N,hasDefaultNodes:S,onNodesChange:_}=t.getState(),E=x(),T=typeof b=="function"?b(E):b;if(S)N(T);else if(_){const A=T.length===0?E.map(R=>({type:"remove",id:R.id})):T.map(R=>({item:R,type:"reset"}));_(A)}},[]),u=w.useCallback(b=>{const{edges:x=[],setEdges:N,hasDefaultEdges:S,onEdgesChange:_}=t.getState(),E=typeof b=="function"?b(x):b;if(S)N(E);else if(_){const T=E.length===0?x.map(A=>({type:"remove",id:A.id})):E.map(A=>({item:A,type:"reset"}));_(T)}},[]),d=w.useCallback(b=>{const x=Array.isArray(b)?b:[b],{getNodes:N,setNodes:S,hasDefaultNodes:_,onNodesChange:E}=t.getState();if(_){const A=[...N(),...x];S(A)}else if(E){const T=x.map(A=>({item:A,type:"add"}));E(T)}},[]),h=w.useCallback(b=>{const x=Array.isArray(b)?b:[b],{edges:N=[],setEdges:S,hasDefaultEdges:_,onEdgesChange:E}=t.getState();if(_)S([...N,...x]);else if(E){const T=x.map(A=>({item:A,type:"add"}));E(T)}},[]),f=w.useCallback(()=>{const{getNodes:b,edges:x=[],transform:N}=t.getState(),[S,_,E]=N;return{nodes:b().map(T=>({...T})),edges:x.map(T=>({...T})),viewport:{x:S,y:_,zoom:E}}},[]),p=w.useCallback(({nodes:b,edges:x})=>{const{nodeInternals:N,getNodes:S,edges:_,hasDefaultNodes:E,hasDefaultEdges:T,onNodesDelete:A,onEdgesDelete:R,onNodesChange:B,onEdgesChange:P}=t.getState(),D=(b||[]).map($=>$.id),O=(x||[]).map($=>$.id),L=S().reduce(($,q)=>{const X=q.parentNode||q.parentId,H=!D.includes(q.id)&&X&&$.find(W=>W.id===X);return(typeof q.deletable=="boolean"?q.deletable:!0)&&(D.includes(q.id)||H)&&$.push(q),$},[]),z=_.filter($=>typeof $.deletable=="boolean"?$.deletable:!0),M=z.filter($=>O.includes($.id));if(L||M){const $=N2(L,z),q=[...M,...$],X=q.reduce((H,I)=>(H.includes(I.id)||H.push(I.id),H),[]);if((T||E)&&(T&&t.setState({edges:_.filter(H=>!X.includes(H.id))}),E&&(L.forEach(H=>{N.delete(H.id)}),t.setState({nodeInternals:new Map(N)}))),X.length>0&&(R==null||R(q),P&&P(X.map(H=>({id:H,type:"remove"})))),L.length>0&&(A==null||A(L),B)){const H=L.map(I=>({id:I.id,type:"remove"}));B(H)}}},[]),g=w.useCallback(b=>{const x=eF(b),N=x?null:t.getState().nodeInternals.get(b.id);return!x&&!N?[null,null,x]:[x?b:NN(N),N,x]},[]),v=w.useCallback((b,x=!0,N)=>{const[S,_,E]=g(b);return S?(N||t.getState().getNodes()).filter(T=>{if(!E&&(T.id===_.id||!T.positionAbsolute))return!1;const A=NN(T),R=rx(A,S);return x&&R>0||R>=S.width*S.height}):[]},[]),k=w.useCallback((b,x,N=!0)=>{const[S]=g(b);if(!S)return!1;const _=rx(S,x);return N&&_>0||_>=S.width*S.height},[]);return w.useMemo(()=>({...e,getNodes:n,getNode:r,getEdges:s,getEdge:o,setNodes:l,setEdges:u,addNodes:d,addEdges:h,toObject:f,deleteElements:p,getIntersectingNodes:v,isNodeIntersecting:k}),[e,n,r,s,o,l,u,d,h,f,p,v,k])}const OF={actInsideInputWithModifier:!1};var LF=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=kt(),{deleteElements:r}=mi(),s=Ol(e,OF),o=Ol(t);w.useEffect(()=>{if(s){const{edges:l,getNodes:u}=n.getState(),d=u().filter(f=>f.selected),h=l.filter(f=>f.selected);r({nodes:d,edges:h}),n.setState({nodesSelectionActive:!1})}},[s]),w.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])};function PF(e){const t=kt();w.useEffect(()=>{let n;const r=()=>{var o,l;if(!e.current)return;const s=hb(e.current);(s.height===0||s.width===0)&&((l=(o=t.getState()).onError)==null||l.call(o,"004",ds.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 bb={position:"absolute",width:"100%",height:"100%",top:0,left:0},DF=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,wu=e=>({x:e.x,y:e.y,zoom:e.k}),To=(e,t)=>e.target.closest(`.${t}`),$N=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),IN=e=>{const t=e.ctrlKey&&Qu()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},FF=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),BF=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:s=!0,zoomOnPinch:o=!0,panOnScroll:l=!1,panOnScrollSpeed:u=.5,panOnScrollMode:d=Ta.Free,zoomOnDoubleClick:h=!0,elementsSelectable:f,panOnDrag:p=!0,defaultViewport:g,translateExtent:v,minZoom:k,maxZoom:b,zoomActivationKeyCode:x,preventScrolling:N=!0,children:S,noWheelClassName:_,noPanClassName:E})=>{const T=w.useRef(),A=kt(),R=w.useRef(!1),B=w.useRef(!1),P=w.useRef(null),D=w.useRef({x:0,y:0,zoom:0}),{d3Zoom:O,d3Selection:L,d3ZoomHandler:z,userSelectionActive:M}=Ye(FF,Tt),$=Ol(x),q=w.useRef(0),X=w.useRef(!1),H=w.useRef();return PF(P),w.useEffect(()=>{if(P.current){const I=P.current.getBoundingClientRect(),W=u2().scaleExtent([k,b]).translateExtent(v),F=Ln(P.current).call(W),Y=ls.translate(g.x,g.y).scale(si(g.zoom,k,b)),J=[[0,0],[I.width,I.height]],V=W.constrain()(Y,J,v);W.transform(F,V),W.wheelDelta(IN),A.setState({d3Zoom:W,d3Selection:F,d3ZoomHandler:F.on("wheel.zoom"),transform:[V.x,V.y,V.k],domNode:P.current.closest(".react-flow")})}},[]),w.useEffect(()=>{L&&O&&(l&&!$&&!M?L.on("wheel.zoom",I=>{if(To(I,_))return!1;I.preventDefault(),I.stopImmediatePropagation();const W=L.property("__zoom").k||1;if(I.ctrlKey&&o){const ee=sr(I),re=IN(I),ue=W*Math.pow(2,re);O.scaleTo(L,ue,ee,I);return}const F=I.deltaMode===1?20:1;let Y=d===Ta.Vertical?0:I.deltaX*F,J=d===Ta.Horizontal?0:I.deltaY*F;!Qu()&&I.shiftKey&&d!==Ta.Vertical&&(Y=I.deltaY*F,J=0),O.translateBy(L,-(Y/W)*u,-(J/W)*u,{internal:!0});const V=wu(L.property("__zoom")),{onViewportChangeStart:G,onViewportChange:K,onViewportChangeEnd:Z}=A.getState();clearTimeout(H.current),X.current||(X.current=!0,t==null||t(I,V),G==null||G(V)),X.current&&(e==null||e(I,V),K==null||K(V),H.current=setTimeout(()=>{n==null||n(I,V),Z==null||Z(V),X.current=!1},150))},{passive:!1}):typeof z<"u"&&L.on("wheel.zoom",function(I,W){if(!N&&I.type==="wheel"&&!I.ctrlKey||To(I,_))return null;I.preventDefault(),z.call(this,I,W)},{passive:!1}))},[M,l,d,L,O,z,$,o,N,_,t,e,n]),w.useEffect(()=>{O&&O.on("start",I=>{var Y,J;if(!I.sourceEvent||I.sourceEvent.internal)return null;q.current=(Y=I.sourceEvent)==null?void 0:Y.button;const{onViewportChangeStart:W}=A.getState(),F=wu(I.transform);R.current=!0,D.current=F,((J=I.sourceEvent)==null?void 0:J.type)==="mousedown"&&A.setState({paneDragging:!0}),W==null||W(F),t==null||t(I.sourceEvent,F)})},[O,t]),w.useEffect(()=>{O&&(M&&!R.current?O.on("zoom",null):M||O.on("zoom",I=>{var F;const{onViewportChange:W}=A.getState();if(A.setState({transform:[I.transform.x,I.transform.y,I.transform.k]}),B.current=!!(r&&$N(p,q.current??0)),(e||W)&&!((F=I.sourceEvent)!=null&&F.internal)){const Y=wu(I.transform);W==null||W(Y),e==null||e(I.sourceEvent,Y)}}))},[M,O,e,p,r]),w.useEffect(()=>{O&&O.on("end",I=>{if(!I.sourceEvent||I.sourceEvent.internal)return null;const{onViewportChangeEnd:W}=A.getState();if(R.current=!1,A.setState({paneDragging:!1}),r&&$N(p,q.current??0)&&!B.current&&r(I.sourceEvent),B.current=!1,(n||W)&&DF(D.current,I.transform)){const F=wu(I.transform);D.current=F,clearTimeout(T.current),T.current=setTimeout(()=>{W==null||W(F),n==null||n(I.sourceEvent,F)},l?150:0)}})},[O,l,p,n,r]),w.useEffect(()=>{O&&O.filter(I=>{const W=$||s,F=o&&I.ctrlKey;if((p===!0||Array.isArray(p)&&p.includes(1))&&I.button===1&&I.type==="mousedown"&&(To(I,"react-flow__node")||To(I,"react-flow__edge")))return!0;if(!p&&!W&&!l&&!h&&!o||M||!h&&I.type==="dblclick"||To(I,_)&&I.type==="wheel"||To(I,E)&&(I.type!=="wheel"||l&&I.type==="wheel"&&!$)||!o&&I.ctrlKey&&I.type==="wheel"||!W&&!l&&!F&&I.type==="wheel"||!p&&(I.type==="mousedown"||I.type==="touchstart")||Array.isArray(p)&&!p.includes(I.button)&&I.type==="mousedown")return!1;const Y=Array.isArray(p)&&p.includes(I.button)||!I.button||I.button<=1;return(!I.ctrlKey||I.type==="wheel")&&Y})},[M,O,s,o,l,h,p,f,$]),de.createElement("div",{className:"react-flow__renderer",ref:P,style:bb},S)},qF=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function UF(){const{userSelectionActive:e,userSelectionRect:t}=Ye(qF,Tt);return e&&t?de.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function ON(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 zF(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&&ON(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&&ON(r,l);break}case"remove":return r}return r.push(l),r},n)}function WF(e,t){return zF(e,t)}const Vs=(e,t)=>({id:e,type:"select",selected:t});function zo(e,t){return e.reduce((n,r)=>{const s=t.includes(r.id);return!r.selected&&s?(r.selected=!0,n.push(Vs(r.id,!0))):r.selected&&!s&&(r.selected=!1,n.push(Vs(r.id,!1))),n},[])}const sp=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},HF=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),B2=w.memo(({isSelecting:e,selectionMode:t=Il.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:s,onPaneClick:o,onPaneContextMenu:l,onPaneScroll:u,onPaneMouseEnter:d,onPaneMouseMove:h,onPaneMouseLeave:f,children:p})=>{const g=w.useRef(null),v=kt(),k=w.useRef(0),b=w.useRef(0),x=w.useRef(),{userSelectionActive:N,elementsSelectable:S,dragging:_}=Ye(HF,Tt),E=()=>{v.setState({userSelectionActive:!1,userSelectionRect:null}),k.current=0,b.current=0},T=z=>{o==null||o(z),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},A=z=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){z.preventDefault();return}l==null||l(z)},R=u?z=>u(z):void 0,B=z=>{const{resetSelectedElements:M,domNode:$}=v.getState();if(x.current=$==null?void 0:$.getBoundingClientRect(),!S||!e||z.button!==0||z.target!==g.current||!x.current)return;const{x:q,y:X}=Zs(z,x.current);M(),v.setState({userSelectionRect:{width:0,height:0,startX:q,startY:X,x:q,y:X}}),r==null||r(z)},P=z=>{const{userSelectionRect:M,nodeInternals:$,edges:q,transform:X,onNodesChange:H,onEdgesChange:I,nodeOrigin:W,getNodes:F}=v.getState();if(!e||!x.current||!M)return;v.setState({userSelectionActive:!0,nodesSelectionActive:!1});const Y=Zs(z,x.current),J=M.startX??0,V=M.startY??0,G={...M,x:Y.x<J?Y.x:J,y:Y.y<V?Y.y:V,width:Math.abs(Y.x-J),height:Math.abs(Y.y-V)},K=F(),Z=k2($,G,X,t===Il.Partial,!0,W),ee=N2(Z,q).map(ue=>ue.id),re=Z.map(ue=>ue.id);if(k.current!==re.length){k.current=re.length;const ue=zo(K,re);ue.length&&(H==null||H(ue))}if(b.current!==ee.length){b.current=ee.length;const ue=zo(q,ee);ue.length&&(I==null||I(ue))}v.setState({userSelectionRect:G})},D=z=>{if(z.button!==0)return;const{userSelectionRect:M}=v.getState();!N&&M&&z.target===g.current&&(T==null||T(z)),v.setState({nodesSelectionActive:k.current>0}),E(),s==null||s(z)},O=z=>{N&&(v.setState({nodesSelectionActive:k.current>0}),s==null||s(z)),E()},L=S&&(e||N);return de.createElement("div",{className:Ut(["react-flow__pane",{dragging:_,selection:e}]),onClick:L?void 0:sp(T,g),onContextMenu:sp(A,g),onWheel:sp(R,g),onMouseEnter:L?void 0:d,onMouseDown:L?B:void 0,onMouseMove:L?P:h,onMouseUp:L?D:void 0,onMouseLeave:L?O:f,ref:g,style:bb},p,de.createElement(UF,null))});B2.displayName="Pane";function q2(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return r?r.selected?!0:q2(r,t):!1}function LN(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 VF(e,t,n,r){return Array.from(e.values()).filter(s=>(s.selected||s.id===r)&&(!s.parentNode||s.parentId||!q2(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 GF(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function U2(e,t,n,r,s=[0,0],o){const l=GF(e,e.extent||r);let u=l;const d=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(d&&e.width&&e.height){const p=n.get(d),{x:g,y:v}=Ma(p,s).positionAbsolute;u=p&&Pn(g)&&Pn(v)&&Pn(p.width)&&Pn(p.height)?[[g+e.width*s[0],v+e.height*s[1]],[g+p.width-e.width+e.width*s[0],v+p.height-e.height+e.height*s[1]]]:u}else o==null||o("005",ds.error005()),u=l;else if(e.extent&&d&&e.extent!=="parent"){const p=n.get(d),{x:g,y:v}=Ma(p,s).positionAbsolute;u=[[e.extent[0][0]+g,e.extent[0][1]+v],[e.extent[1][0]+g,e.extent[1][1]+v]]}let h={x:0,y:0};if(d){const p=n.get(d);h=Ma(p,s).positionAbsolute}const f=u&&u!=="parent"?fb(t,u):t;return{position:{x:f.x-h.x,y:f.y-h.y},positionAbsolute:f}}function ap({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 PN=(e,t,n,r)=>{const s=t.querySelectorAll(e);if(!s||!s.length)return null;const o=Array.from(s),l=t.getBoundingClientRect(),u={x:l.width*r[0],y:l.height*r[1]};return o.map(d=>{const h=d.getBoundingClientRect();return{id:d.getAttribute("data-handleid"),position:d.getAttribute("data-handlepos"),x:(h.left-l.left-u.x)/n,y:(h.top-l.top-u.y)/n,...hb(d)}})};function fl(e,t,n){return n===void 0?n:r=>{const s=t().nodeInternals.get(e);s&&n(r,{...s})}}function cx({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:o,multiSelectionActive:l,nodeInternals:u,onError:d}=t.getState(),h=u.get(e);if(!h){d==null||d("012",ds.error012(e));return}t.setState({nodesSelectionActive:!1}),h.selected?(n||h.selected&&l)&&(o({nodes:[h],edges:[]}),requestAnimationFrame(()=>{var f;return(f=r==null?void 0:r.current)==null?void 0:f.blur()})):s([e])}function KF(){const e=kt();return w.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:s,snapToGrid:o}=e.getState(),l=n.touches?n.touches[0].clientX:n.clientX,u=n.touches?n.touches[0].clientY:n.clientY,d={x:(l-r[0])/r[2],y:(u-r[1])/r[2]};return{xSnapped:o?s[0]*Math.round(d.x/s[0]):d.x,ySnapped:o?s[1]*Math.round(d.y/s[1]):d.y,...d}},[])}function op(e){return(t,n,r)=>e==null?void 0:e(t,r)}function z2({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:o,selectNodesOnDrag:l}){const u=kt(),[d,h]=w.useState(!1),f=w.useRef([]),p=w.useRef({x:null,y:null}),g=w.useRef(0),v=w.useRef(null),k=w.useRef({x:0,y:0}),b=w.useRef(null),x=w.useRef(!1),N=w.useRef(!1),S=w.useRef(!1),_=KF();return w.useEffect(()=>{if(e!=null&&e.current){const E=Ln(e.current),T=({x:B,y:P})=>{const{nodeInternals:D,onNodeDrag:O,onSelectionDrag:L,updateNodePositions:z,nodeExtent:M,snapGrid:$,snapToGrid:q,nodeOrigin:X,onError:H}=u.getState();p.current={x:B,y:P};let I=!1,W={x:0,y:0,x2:0,y2:0};if(f.current.length>1&&M){const Y=Md(f.current,X);W=$l(Y)}if(f.current=f.current.map(Y=>{const J={x:B-Y.distance.x,y:P-Y.distance.y};q&&(J.x=$[0]*Math.round(J.x/$[0]),J.y=$[1]*Math.round(J.y/$[1]));const V=[[M[0][0],M[0][1]],[M[1][0],M[1][1]]];f.current.length>1&&M&&!Y.extent&&(V[0][0]=Y.positionAbsolute.x-W.x+M[0][0],V[1][0]=Y.positionAbsolute.x+(Y.width??0)-W.x2+M[1][0],V[0][1]=Y.positionAbsolute.y-W.y+M[0][1],V[1][1]=Y.positionAbsolute.y+(Y.height??0)-W.y2+M[1][1]);const G=U2(Y,J,D,V,X,H);return I=I||Y.position.x!==G.position.x||Y.position.y!==G.position.y,Y.position=G.position,Y.positionAbsolute=G.positionAbsolute,Y}),!I)return;z(f.current,!0,!0),h(!0);const F=s?O:op(L);if(F&&b.current){const[Y,J]=ap({nodeId:s,dragItems:f.current,nodeInternals:D});F(b.current,Y,J)}},A=()=>{if(!v.current)return;const[B,P]=h2(k.current,v.current);if(B!==0||P!==0){const{transform:D,panBy:O}=u.getState();p.current.x=(p.current.x??0)-B/D[2],p.current.y=(p.current.y??0)-P/D[2],O({x:B,y:P})&&T(p.current)}g.current=requestAnimationFrame(A)},R=B=>{var X;const{nodeInternals:P,multiSelectionActive:D,nodesDraggable:O,unselectNodesAndEdges:L,onNodeDragStart:z,onSelectionDragStart:M}=u.getState();N.current=!0;const $=s?z:op(M);(!l||!o)&&!D&&s&&((X=P.get(s))!=null&&X.selected||L()),s&&o&&l&&cx({id:s,store:u,nodeRef:e});const q=_(B);if(p.current=q,f.current=VF(P,O,q,s),$&&f.current){const[H,I]=ap({nodeId:s,dragItems:f.current,nodeInternals:P});$(B.sourceEvent,H,I)}};if(t)E.on(".drag",null);else{const B=sD().on("start",P=>{const{domNode:D,nodeDragThreshold:O}=u.getState();O===0&&R(P),S.current=!1;const L=_(P);p.current=L,v.current=(D==null?void 0:D.getBoundingClientRect())||null,k.current=Zs(P.sourceEvent,v.current)}).on("drag",P=>{var z,M;const D=_(P),{autoPanOnNodeDrag:O,nodeDragThreshold:L}=u.getState();if(P.sourceEvent.type==="touchmove"&&P.sourceEvent.touches.length>1&&(S.current=!0),!S.current){if(!x.current&&N.current&&O&&(x.current=!0,A()),!N.current){const $=D.xSnapped-(((z=p==null?void 0:p.current)==null?void 0:z.x)??0),q=D.ySnapped-(((M=p==null?void 0:p.current)==null?void 0:M.y)??0);Math.sqrt($*$+q*q)>L&&R(P)}(p.current.x!==D.xSnapped||p.current.y!==D.ySnapped)&&f.current&&N.current&&(b.current=P.sourceEvent,k.current=Zs(P.sourceEvent,v.current),T(D))}}).on("end",P=>{if(!(!N.current||S.current)&&(h(!1),x.current=!1,N.current=!1,cancelAnimationFrame(g.current),f.current)){const{updateNodePositions:D,nodeInternals:O,onNodeDragStop:L,onSelectionDragStop:z}=u.getState(),M=s?L:op(z);if(D(f.current,!1,!1),M){const[$,q]=ap({nodeId:s,dragItems:f.current,nodeInternals:O});M(P.sourceEvent,$,q)}}}).filter(P=>{const D=P.target;return!P.button&&(!n||!LN(D,`.${n}`,e))&&(!r||LN(D,r,e))});return E.call(B),()=>{E.on(".drag",null)}}}},[e,t,n,r,o,u,s,l,_]),d}function W2(){const e=kt();return w.useCallback(n=>{const{nodeInternals:r,nodeExtent:s,updateNodePositions:o,getNodes:l,snapToGrid:u,snapGrid:d,onError:h,nodesDraggable:f}=e.getState(),p=l().filter(S=>S.selected&&(S.draggable||f&&typeof S.draggable>"u")),g=u?d[0]:5,v=u?d[1]:5,k=n.isShiftPressed?4:1,b=n.x*g*k,x=n.y*v*k,N=p.map(S=>{if(S.positionAbsolute){const _={x:S.positionAbsolute.x+b,y:S.positionAbsolute.y+x};u&&(_.x=d[0]*Math.round(_.x/d[0]),_.y=d[1]*Math.round(_.y/d[1]));const{positionAbsolute:E,position:T}=U2(S,_,r,s,void 0,h);S.position=T,S.positionAbsolute=E}return S});o(N,!0,!1)},[])}const Xo={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var pl=e=>{const t=({id:n,type:r,data:s,xPos:o,yPos:l,xPosOrigin:u,yPosOrigin:d,selected:h,onClick:f,onMouseEnter:p,onMouseMove:g,onMouseLeave:v,onContextMenu:k,onDoubleClick:b,style:x,className:N,isDraggable:S,isSelectable:_,isConnectable:E,isFocusable:T,selectNodesOnDrag:A,sourcePosition:R,targetPosition:B,hidden:P,resizeObserver:D,dragHandle:O,zIndex:L,isParent:z,noDragClassName:M,noPanClassName:$,initialized:q,disableKeyboardA11y:X,ariaLabel:H,rfId:I,hasHandleBounds:W})=>{const F=kt(),Y=w.useRef(null),J=w.useRef(null),V=w.useRef(R),G=w.useRef(B),K=w.useRef(r),Z=_||S||f||p||g||v,ee=W2(),re=fl(n,F.getState,p),ue=fl(n,F.getState,g),me=fl(n,F.getState,v),ae=fl(n,F.getState,k),pe=fl(n,F.getState,b),xe=fe=>{const{nodeDragThreshold:he}=F.getState();if(_&&(!A||!S||he>0)&&cx({id:n,store:F,nodeRef:Y}),f){const _e=F.getState().nodeInternals.get(n);_e&&f(fe,{..._e})}},se=fe=>{if(!sx(fe)&&!X)if(g2.includes(fe.key)&&_){const he=fe.key==="Escape";cx({id:n,store:F,unselect:he,nodeRef:Y})}else S&&h&&Object.prototype.hasOwnProperty.call(Xo,fe.key)&&(F.setState({ariaLiveMessage:`Moved selected node ${fe.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~l}`}),ee({x:Xo[fe.key].x,y:Xo[fe.key].y,isShiftPressed:fe.shiftKey}))};w.useEffect(()=>()=>{J.current&&(D==null||D.unobserve(J.current),J.current=null)},[]),w.useEffect(()=>{if(Y.current&&!P){const fe=Y.current;(!q||!W||J.current!==fe)&&(J.current&&(D==null||D.unobserve(J.current)),D==null||D.observe(fe),J.current=fe)}},[P,q,W]),w.useEffect(()=>{const fe=K.current!==r,he=V.current!==R,_e=G.current!==B;Y.current&&(fe||he||_e)&&(fe&&(K.current=r),he&&(V.current=R),_e&&(G.current=B),F.getState().updateNodeDimensions([{id:n,nodeElement:Y.current,forceUpdate:!0}]))},[n,r,R,B]);const ve=z2({nodeRef:Y,disabled:P||!S,noDragClassName:M,handleSelector:O,nodeId:n,isSelectable:_,selectNodesOnDrag:A});return P?null:de.createElement("div",{className:Ut(["react-flow__node",`react-flow__node-${r}`,{[$]:S},N,{selected:h,selectable:_,parent:z,dragging:ve}]),ref:Y,style:{zIndex:L,transform:`translate(${u}px,${d}px)`,pointerEvents:Z?"all":"none",visibility:q?"visible":"hidden",...x},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:re,onMouseMove:ue,onMouseLeave:me,onContextMenu:ae,onClick:xe,onDoubleClick:pe,onKeyDown:T?se:void 0,tabIndex:T?0:void 0,role:T?"button":void 0,"aria-describedby":X?void 0:`${O2}-${I}`,"aria-label":H},de.createElement(iF,{value:n},de.createElement(e,{id:n,data:s,type:r,xPos:o,yPos:l,selected:h,isConnectable:E,sourcePosition:R,targetPosition:B,dragging:ve,dragHandle:O,zIndex:L})))};return t.displayName="NodeWrapper",w.memo(t)};const YF=e=>{const t=e.getNodes().filter(n=>n.selected);return{...Md(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function XF({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=kt(),{width:s,height:o,x:l,y:u,transformString:d,userSelectionActive:h}=Ye(YF,Tt),f=W2(),p=w.useRef(null);if(w.useEffect(()=>{var k;n||(k=p.current)==null||k.focus({preventScroll:!0})},[n]),z2({nodeRef:p}),h||!s||!o)return null;const g=e?k=>{const b=r.getState().getNodes().filter(x=>x.selected);e(k,b)}:void 0,v=k=>{Object.prototype.hasOwnProperty.call(Xo,k.key)&&f({x:Xo[k.key].x,y:Xo[k.key].y,isShiftPressed:k.shiftKey})};return de.createElement("div",{className:Ut(["react-flow__nodesselection","react-flow__container",t]),style:{transform:d}},de.createElement("div",{ref:p,className:"react-flow__nodesselection-rect",onContextMenu:g,tabIndex:n?void 0:-1,onKeyDown:n?void 0:v,style:{width:s,height:o,top:u,left:l}}))}var ZF=w.memo(XF);const JF=e=>e.nodesSelectionActive,H2=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:l,deleteKeyCode:u,onMove:d,onMoveStart:h,onMoveEnd:f,selectionKeyCode:p,selectionOnDrag:g,selectionMode:v,onSelectionStart:k,onSelectionEnd:b,multiSelectionKeyCode:x,panActivationKeyCode:N,zoomActivationKeyCode:S,elementsSelectable:_,zoomOnScroll:E,zoomOnPinch:T,panOnScroll:A,panOnScrollSpeed:R,panOnScrollMode:B,zoomOnDoubleClick:P,panOnDrag:D,defaultViewport:O,translateExtent:L,minZoom:z,maxZoom:M,preventScrolling:$,onSelectionContextMenu:q,noWheelClassName:X,noPanClassName:H,disableKeyboardA11y:I})=>{const W=Ye(JF),F=Ol(p),Y=Ol(N),J=Y||D,V=Y||A,G=F||g&&J!==!0;return LF({deleteKeyCode:u,multiSelectionKeyCode:x}),de.createElement(BF,{onMove:d,onMoveStart:h,onMoveEnd:f,onPaneContextMenu:o,elementsSelectable:_,zoomOnScroll:E,zoomOnPinch:T,panOnScroll:V,panOnScrollSpeed:R,panOnScrollMode:B,zoomOnDoubleClick:P,panOnDrag:!F&&J,defaultViewport:O,translateExtent:L,minZoom:z,maxZoom:M,zoomActivationKeyCode:S,preventScrolling:$,noWheelClassName:X,noPanClassName:H},de.createElement(B2,{onSelectionStart:k,onSelectionEnd:b,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:l,panOnDrag:J,isSelecting:!!G,selectionMode:v},e,W&&de.createElement(ZF,{onSelectionContextMenu:q,noPanClassName:H,disableKeyboardA11y:I})))};H2.displayName="FlowRenderer";var QF=w.memo(H2);function e6(e){return Ye(w.useCallback(n=>e?k2(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function t6(e){const t={input:pl(e.input||R2),default:pl(e.default||lx),output:pl(e.output||$2),group:pl(e.group||xb)},n={},r=Object.keys(e).filter(s=>!["input","default","output","group"].includes(s)).reduce((s,o)=>(s[o]=pl(e[o]||lx),s),n);return{...t,...r}}const n6=({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]},r6=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),V2=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,updateNodeDimensions:o,onError:l}=Ye(r6,Tt),u=e6(e.onlyRenderVisibleElements),d=w.useRef(),h=w.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const f=new ResizeObserver(p=>{const g=p.map(v=>({id:v.target.getAttribute("data-id"),nodeElement:v.target,forceUpdate:!0}));o(g)});return d.current=f,f},[]);return w.useEffect(()=>()=>{var f;(f=d==null?void 0:d.current)==null||f.disconnect()},[]),de.createElement("div",{className:"react-flow__nodes",style:bb},u.map(f=>{var T,A,R;let p=f.type||"default";e.nodeTypes[p]||(l==null||l("003",ds.error003(p)),p="default");const g=e.nodeTypes[p]||e.nodeTypes.default,v=!!(f.draggable||t&&typeof f.draggable>"u"),k=!!(f.selectable||s&&typeof f.selectable>"u"),b=!!(f.connectable||n&&typeof f.connectable>"u"),x=!!(f.focusable||r&&typeof f.focusable>"u"),N=e.nodeExtent?fb(f.positionAbsolute,e.nodeExtent):f.positionAbsolute,S=(N==null?void 0:N.x)??0,_=(N==null?void 0:N.y)??0,E=n6({x:S,y:_,width:f.width??0,height:f.height??0,origin:e.nodeOrigin});return de.createElement(g,{key:f.id,id:f.id,className:f.className,style:f.style,type:p,data:f.data,sourcePosition:f.sourcePosition||Ae.Bottom,targetPosition:f.targetPosition||Ae.Top,hidden:f.hidden,xPos:S,yPos:_,xPosOrigin:E.x,yPosOrigin:E.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!f.selected,isDraggable:v,isSelectable:k,isConnectable:b,isFocusable:x,resizeObserver:h,dragHandle:f.dragHandle,zIndex:((T=f[mt])==null?void 0:T.z)??0,isParent:!!((A=f[mt])!=null&&A.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!f.width&&!!f.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:f.ariaLabel,hasHandleBounds:!!((R=f[mt])!=null&&R.handleBounds)})}))};V2.displayName="NodeRenderer";var s6=w.memo(V2);const a6=(e,t,n)=>n===Ae.Left?e-t:n===Ae.Right?e+t:e,o6=(e,t,n)=>n===Ae.Top?e-t:n===Ae.Bottom?e+t:e,DN="react-flow__edgeupdater",FN=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:o,onMouseOut:l,type:u})=>de.createElement("circle",{onMouseDown:s,onMouseEnter:o,onMouseOut:l,className:Ut([DN,`${DN}-${u}`]),cx:a6(t,r,e),cy:o6(n,r,e),r,stroke:"transparent",fill:"transparent"}),i6=()=>!0;var Ao=e=>{const t=({id:n,className:r,type:s,data:o,onClick:l,onEdgeDoubleClick:u,selected:d,animated:h,label:f,labelStyle:p,labelShowBg:g,labelBgStyle:v,labelBgPadding:k,labelBgBorderRadius:b,style:x,source:N,target:S,sourceX:_,sourceY:E,targetX:T,targetY:A,sourcePosition:R,targetPosition:B,elementsSelectable:P,hidden:D,sourceHandleId:O,targetHandleId:L,onContextMenu:z,onMouseEnter:M,onMouseMove:$,onMouseLeave:q,reconnectRadius:X,onReconnect:H,onReconnectStart:I,onReconnectEnd:W,markerEnd:F,markerStart:Y,rfId:J,ariaLabel:V,isFocusable:G,isReconnectable:K,pathOptions:Z,interactionWidth:ee,disableKeyboardA11y:re})=>{const ue=w.useRef(null),[me,ae]=w.useState(!1),[pe,xe]=w.useState(!1),se=kt(),ve=w.useMemo(()=>`url('#${ox(Y,J)}')`,[Y,J]),fe=w.useMemo(()=>`url('#${ox(F,J)}')`,[F,J]);if(D)return null;const he=Ue=>{var yt;const{edges:Ze,addSelectedEdges:Je,unselectNodesAndEdges:rt,multiSelectionActive:gt}=se.getState(),Rt=Ze.find(lt=>lt.id===n);Rt&&(P&&(se.setState({nodesSelectionActive:!1}),Rt.selected&&gt?(rt({nodes:[],edges:[Rt]}),(yt=ue.current)==null||yt.blur()):Je([n])),l&&l(Ue,Rt))},_e=hl(n,se.getState,u),Fe=hl(n,se.getState,z),Le=hl(n,se.getState,M),Ve=hl(n,se.getState,$),le=hl(n,se.getState,q),je=(Ue,Ze)=>{if(Ue.button!==0)return;const{edges:Je,isValidConnection:rt}=se.getState(),gt=Ze?S:N,Rt=(Ze?L:O)||null,yt=Ze?"target":"source",lt=rt||i6,Qt=Ze,Pt=Je.find(Kt=>Kt.id===n);xe(!0),I==null||I(Ue,Pt,yt);const Dt=Kt=>{xe(!1),W==null||W(Kt,Pt,yt)};E2({event:Ue,handleId:Rt,nodeId:gt,onConnect:Kt=>H==null?void 0:H(Pt,Kt),isTarget:Qt,getState:se.getState,setState:se.setState,isValidConnection:lt,edgeUpdaterType:yt,onReconnectEnd:Dt})},$e=Ue=>je(Ue,!0),Oe=Ue=>je(Ue,!1),ze=()=>ae(!0),nt=()=>ae(!1),it=!P&&!l,At=Ue=>{var Ze;if(!re&&g2.includes(Ue.key)&&P){const{unselectNodesAndEdges:Je,addSelectedEdges:rt,edges:gt}=se.getState();Ue.key==="Escape"?((Ze=ue.current)==null||Ze.blur(),Je({edges:[gt.find(yt=>yt.id===n)]})):rt([n])}};return de.createElement("g",{className:Ut(["react-flow__edge",`react-flow__edge-${s}`,r,{selected:d,animated:h,inactive:it,updating:me}]),onClick:he,onDoubleClick:_e,onContextMenu:Fe,onMouseEnter:Le,onMouseMove:Ve,onMouseLeave:le,onKeyDown:G?At:void 0,tabIndex:G?0:void 0,role:G?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":V===null?void 0:V||`Edge from ${N} to ${S}`,"aria-describedby":G?`${L2}-${J}`:void 0,ref:ue},!pe&&de.createElement(e,{id:n,source:N,target:S,selected:d,animated:h,label:f,labelStyle:p,labelShowBg:g,labelBgStyle:v,labelBgPadding:k,labelBgBorderRadius:b,data:o,style:x,sourceX:_,sourceY:E,targetX:T,targetY:A,sourcePosition:R,targetPosition:B,sourceHandleId:O,targetHandleId:L,markerStart:ve,markerEnd:fe,pathOptions:Z,interactionWidth:ee}),K&&de.createElement(de.Fragment,null,(K==="source"||K===!0)&&de.createElement(FN,{position:R,centerX:_,centerY:E,radius:X,onMouseDown:$e,onMouseEnter:ze,onMouseOut:nt,type:"source"}),(K==="target"||K===!0)&&de.createElement(FN,{position:B,centerX:T,centerY:A,radius:X,onMouseDown:Oe,onMouseEnter:ze,onMouseOut:nt,type:"target"})))};return t.displayName="EdgeWrapper",w.memo(t)};function l6(e){const t={default:Ao(e.default||td),straight:Ao(e.bezier||gb),step:Ao(e.step||mb),smoothstep:Ao(e.step||Rd),simplebezier:Ao(e.simplebezier||pb)},n={},r=Object.keys(e).filter(s=>!["default","bezier"].includes(s)).reduce((s,o)=>(s[o]=Ao(e[o]||td),s),n);return{...t,...r}}function BN(e,t,n=null){const r=((n==null?void 0:n.x)||0)+t.x,s=((n==null?void 0:n.y)||0)+t.y,o=(n==null?void 0:n.width)||t.width,l=(n==null?void 0:n.height)||t.height;switch(e){case Ae.Top:return{x:r+o/2,y:s};case Ae.Right:return{x:r+o,y:s+l/2};case Ae.Bottom:return{x:r+o/2,y:s+l};case Ae.Left:return{x:r,y:s+l/2}}}function qN(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const c6=(e,t,n,r,s,o)=>{const l=BN(n,e,t),u=BN(o,r,s);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y}};function u6({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:s,targetHeight:o,width:l,height:u,transform:d}){const h={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+s),y2:Math.max(e.y+r,t.y+o)};h.x===h.x2&&(h.x2+=1),h.y===h.y2&&(h.y2+=1);const f=$l({x:(0-d[0])/d[2],y:(0-d[1])/d[2],width:l/d[2],height:u/d[2]}),p=Math.max(0,Math.min(f.x2,h.x2)-Math.max(f.x,h.x)),g=Math.max(0,Math.min(f.y2,h.y2)-Math.max(f.y,h.y));return Math.ceil(p*g)>0}function UN(e){var r,s,o,l,u;const t=((r=e==null?void 0:e[mt])==null?void 0:r.handleBounds)||null,n=t&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((s=e==null?void 0:e.positionAbsolute)==null?void 0:s.x)<"u"&&typeof((o=e==null?void 0:e.positionAbsolute)==null?void 0:o.y)<"u";return[{x:((l=e==null?void 0:e.positionAbsolute)==null?void 0:l.x)||0,y:((u=e==null?void 0:e.positionAbsolute)==null?void 0:u.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}const d6=[{level:0,isMaxLevel:!0,edges:[]}];function h6(e,t,n=!1){let r=-1;const s=e.reduce((l,u)=>{var f,p;const d=Pn(u.zIndex);let h=d?u.zIndex:0;if(n){const g=t.get(u.target),v=t.get(u.source),k=u.selected||(g==null?void 0:g.selected)||(v==null?void 0:v.selected),b=Math.max(((f=v==null?void 0:v[mt])==null?void 0:f.z)||0,((p=g==null?void 0:g[mt])==null?void 0:p.z)||0,1e3);h=(d?u.zIndex:0)+(k?b:0)}return l[h]?l[h].push(u):l[h]=[u],r=h>r?h:r,l},{}),o=Object.entries(s).map(([l,u])=>{const d=+l;return{edges:u,level:d,isMaxLevel:d===r}});return o.length===0?d6:o}function f6(e,t,n){const r=Ye(w.useCallback(s=>e?s.edges.filter(o=>{const l=t.get(o.source),u=t.get(o.target);return(l==null?void 0:l.width)&&(l==null?void 0:l.height)&&(u==null?void 0:u.width)&&(u==null?void 0:u.height)&&u6({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 h6(r,t,n)}const p6=({color:e="none",strokeWidth:t=1})=>de.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),m6=({color:e="none",strokeWidth:t=1})=>de.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),zN={[ed.Arrow]:p6,[ed.ArrowClosed]:m6};function g6(e){const t=kt();return w.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(zN,e)?zN[e]:((o=(s=t.getState()).onError)==null||o.call(s,"009",ds.error009(e)),null)},[e])}const y6=({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=g6(t);return d?de.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:u,refX:"0",refY:"0"},de.createElement(d,{color:n,strokeWidth:l})):null},w6=({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=ox(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))},G2=({defaultColor:e,rfId:t})=>{const n=Ye(w.useCallback(w6({defaultColor:e,rfId:t}),[e,t]),(r,s)=>!(r.length!==s.length||r.some((o,l)=>o.id!==s[l].id)));return de.createElement("defs",null,n.map(r=>de.createElement(y6,{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})))};G2.displayName="MarkerDefinitions";var v6=w.memo(G2);const x6=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}),K2=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:s,noPanClassName:o,onEdgeContextMenu:l,onEdgeMouseEnter:u,onEdgeMouseMove:d,onEdgeMouseLeave:h,onEdgeClick:f,onEdgeDoubleClick:p,onReconnect:g,onReconnectStart:v,onReconnectEnd:k,reconnectRadius:b,children:x,disableKeyboardA11y:N})=>{const{edgesFocusable:S,edgesUpdatable:_,elementsSelectable:E,width:T,height:A,connectionMode:R,nodeInternals:B,onError:P}=Ye(x6,Tt),D=f6(t,B,n);return T?de.createElement(de.Fragment,null,D.map(({level:O,edges:L,isMaxLevel:z})=>de.createElement("svg",{key:O,style:{zIndex:O},width:T,height:A,className:"react-flow__edges react-flow__container"},z&&de.createElement(v6,{defaultColor:e,rfId:r}),de.createElement("g",null,L.map(M=>{const[$,q,X]=UN(B.get(M.source)),[H,I,W]=UN(B.get(M.target));if(!X||!W)return null;let F=M.type||"default";s[F]||(P==null||P("011",ds.error011(F)),F="default");const Y=s[F]||s.default,J=R===Pa.Strict?I.target:(I.target??[]).concat(I.source??[]),V=qN(q.source,M.sourceHandle),G=qN(J,M.targetHandle),K=(V==null?void 0:V.position)||Ae.Bottom,Z=(G==null?void 0:G.position)||Ae.Top,ee=!!(M.focusable||S&&typeof M.focusable>"u"),re=M.reconnectable||M.updatable,ue=typeof g<"u"&&(re||_&&typeof re>"u");if(!V||!G)return P==null||P("008",ds.error008(V,M)),null;const{sourceX:me,sourceY:ae,targetX:pe,targetY:xe}=c6($,V,K,H,G,Z);return de.createElement(Y,{key:M.id,id:M.id,className:Ut([M.className,o]),type:F,data:M.data,selected:!!M.selected,animated:!!M.animated,hidden:!!M.hidden,label:M.label,labelStyle:M.labelStyle,labelShowBg:M.labelShowBg,labelBgStyle:M.labelBgStyle,labelBgPadding:M.labelBgPadding,labelBgBorderRadius:M.labelBgBorderRadius,style:M.style,source:M.source,target:M.target,sourceHandleId:M.sourceHandle,targetHandleId:M.targetHandle,markerEnd:M.markerEnd,markerStart:M.markerStart,sourceX:me,sourceY:ae,targetX:pe,targetY:xe,sourcePosition:K,targetPosition:Z,elementsSelectable:E,onContextMenu:l,onMouseEnter:u,onMouseMove:d,onMouseLeave:h,onClick:f,onEdgeDoubleClick:p,onReconnect:g,onReconnectStart:v,onReconnectEnd:k,reconnectRadius:b,rfId:r,ariaLabel:M.ariaLabel,isFocusable:ee,isReconnectable:ue,pathOptions:"pathOptions"in M?M.pathOptions:void 0,interactionWidth:M.interactionWidth,disableKeyboardA11y:N})})))),x):null};K2.displayName="EdgeRenderer";var b6=w.memo(K2);const k6=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function N6({children:e}){const t=Ye(k6);return de.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function j6(e){const t=mi(),n=w.useRef(!1);w.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const S6={[Ae.Left]:Ae.Right,[Ae.Right]:Ae.Left,[Ae.Top]:Ae.Bottom,[Ae.Bottom]:Ae.Top},Y2=({nodeId:e,handleType:t,style:n,type:r=Gs.Bezier,CustomComponent:s,connectionStatus:o})=>{var A,R,B;const{fromNode:l,handleId:u,toX:d,toY:h,connectionMode:f}=Ye(w.useCallback(P=>({fromNode:P.nodeInternals.get(e),handleId:P.connectionHandleId,toX:(P.connectionPosition.x-P.transform[0])/P.transform[2],toY:(P.connectionPosition.y-P.transform[1])/P.transform[2],connectionMode:P.connectionMode}),[e]),Tt),p=(A=l==null?void 0:l[mt])==null?void 0:A.handleBounds;let g=p==null?void 0:p[t];if(f===Pa.Loose&&(g=g||(p==null?void 0:p[t==="source"?"target":"source"])),!l||!g)return null;const v=u?g.find(P=>P.id===u):g[0],k=v?v.x+v.width/2:(l.width??0)/2,b=v?v.y+v.height/2:l.height??0,x=(((R=l.positionAbsolute)==null?void 0:R.x)??0)+k,N=(((B=l.positionAbsolute)==null?void 0:B.y)??0)+b,S=v==null?void 0:v.position,_=S?S6[S]:null;if(!S||!_)return null;if(s)return de.createElement(s,{connectionLineType:r,connectionLineStyle:n,fromNode:l,fromHandle:v,fromX:x,fromY:N,toX:d,toY:h,fromPosition:S,toPosition:_,connectionStatus:o});let E="";const T={sourceX:x,sourceY:N,sourcePosition:S,targetX:d,targetY:h,targetPosition:_};return r===Gs.Bezier?[E]=yb(T):r===Gs.Step?[E]=ax({...T,borderRadius:0}):r===Gs.SmoothStep?[E]=ax(T):r===Gs.SimpleBezier?[E]=x2(T):E=`M${x},${N} ${d},${h}`,de.createElement("path",{d:E,fill:"none",className:"react-flow__connection-path",style:n})};Y2.displayName="ConnectionLine";const _6=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function E6({containerStyle:e,style:t,type:n,component:r}){const{nodeId:s,handleType:o,nodesConnectable:l,width:u,height:d,connectionStatus:h}=Ye(_6,Tt);return!(s&&o&&u&&l)?null:de.createElement("svg",{style:e,width:u,height:d,className:"react-flow__edges react-flow__connectionline react-flow__container"},de.createElement("g",{className:Ut(["react-flow__connection",h])},de.createElement(Y2,{nodeId:s,handleType:o,style:t,type:n,CustomComponent:r,connectionStatus:h})))}function WN(e,t){return w.useRef(null),kt(),w.useMemo(()=>t(e),[e])}const X2=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:s,onInit:o,onNodeClick:l,onEdgeClick:u,onNodeDoubleClick:d,onEdgeDoubleClick:h,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:g,onNodeContextMenu:v,onSelectionContextMenu:k,onSelectionStart:b,onSelectionEnd:x,connectionLineType:N,connectionLineStyle:S,connectionLineComponent:_,connectionLineContainerStyle:E,selectionKeyCode:T,selectionOnDrag:A,selectionMode:R,multiSelectionKeyCode:B,panActivationKeyCode:P,zoomActivationKeyCode:D,deleteKeyCode:O,onlyRenderVisibleElements:L,elementsSelectable:z,selectNodesOnDrag:M,defaultViewport:$,translateExtent:q,minZoom:X,maxZoom:H,preventScrolling:I,defaultMarkerColor:W,zoomOnScroll:F,zoomOnPinch:Y,panOnScroll:J,panOnScrollSpeed:V,panOnScrollMode:G,zoomOnDoubleClick:K,panOnDrag:Z,onPaneClick:ee,onPaneMouseEnter:re,onPaneMouseMove:ue,onPaneMouseLeave:me,onPaneScroll:ae,onPaneContextMenu:pe,onEdgeContextMenu:xe,onEdgeMouseEnter:se,onEdgeMouseMove:ve,onEdgeMouseLeave:fe,onReconnect:he,onReconnectStart:_e,onReconnectEnd:Fe,reconnectRadius:Le,noDragClassName:Ve,noWheelClassName:le,noPanClassName:je,elevateEdgesOnSelect:$e,disableKeyboardA11y:Oe,nodeOrigin:ze,nodeExtent:nt,rfId:it})=>{const At=WN(e,t6),Ue=WN(t,l6);return j6(o),de.createElement(QF,{onPaneClick:ee,onPaneMouseEnter:re,onPaneMouseMove:ue,onPaneMouseLeave:me,onPaneContextMenu:pe,onPaneScroll:ae,deleteKeyCode:O,selectionKeyCode:T,selectionOnDrag:A,selectionMode:R,onSelectionStart:b,onSelectionEnd:x,multiSelectionKeyCode:B,panActivationKeyCode:P,zoomActivationKeyCode:D,elementsSelectable:z,onMove:n,onMoveStart:r,onMoveEnd:s,zoomOnScroll:F,zoomOnPinch:Y,zoomOnDoubleClick:K,panOnScroll:J,panOnScrollSpeed:V,panOnScrollMode:G,panOnDrag:Z,defaultViewport:$,translateExtent:q,minZoom:X,maxZoom:H,onSelectionContextMenu:k,preventScrolling:I,noDragClassName:Ve,noWheelClassName:le,noPanClassName:je,disableKeyboardA11y:Oe},de.createElement(N6,null,de.createElement(b6,{edgeTypes:Ue,onEdgeClick:u,onEdgeDoubleClick:h,onlyRenderVisibleElements:L,onEdgeContextMenu:xe,onEdgeMouseEnter:se,onEdgeMouseMove:ve,onEdgeMouseLeave:fe,onReconnect:he,onReconnectStart:_e,onReconnectEnd:Fe,reconnectRadius:Le,defaultMarkerColor:W,noPanClassName:je,elevateEdgesOnSelect:!!$e,disableKeyboardA11y:Oe,rfId:it},de.createElement(E6,{style:S,type:N,component:_,containerStyle:E})),de.createElement("div",{className:"react-flow__edgelabel-renderer"}),de.createElement(s6,{nodeTypes:At,onNodeClick:l,onNodeDoubleClick:d,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:g,onNodeContextMenu:v,selectNodesOnDrag:M,onlyRenderVisibleElements:L,noPanClassName:je,noDragClassName:Ve,disableKeyboardA11y:Oe,nodeOrigin:ze,nodeExtent:nt,rfId:it})))};X2.displayName="GraphView";var C6=w.memo(X2);const ux=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],zs={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:ux,nodeExtent:ux,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Pa.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:tF,isValidConnection:void 0},T6=()=>g3((e,t)=>({...zs,setNodes:n=>{const{nodeInternals:r,nodeOrigin:s,elevateNodesOnSelect:o}=t();e({nodeInternals:rp(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?rp(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:l,edges:o?r:[],hasDefaultNodes:s,hasDefaultEdges:o})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:s,fitViewOnInit:o,fitViewOnInitDone:l,fitViewOnInitOptions:u,domNode:d,nodeOrigin:h}=t(),f=d==null?void 0:d.querySelector(".react-flow__viewport");if(!f)return;const p=window.getComputedStyle(f),{m22:g}=new window.DOMMatrixReadOnly(p.transform),v=n.reduce((b,x)=>{const N=s.get(x.id);if(N!=null&&N.hidden)s.set(N.id,{...N,[mt]:{...N[mt],handleBounds:void 0}});else if(N){const S=hb(x.nodeElement);!!(S.width&&S.height&&(N.width!==S.width||N.height!==S.height||x.forceUpdate))&&(s.set(N.id,{...N,[mt]:{...N[mt],handleBounds:{source:PN(".source",x.nodeElement,g,h),target:PN(".target",x.nodeElement,g,h)}},...S}),b.push({id:N.id,type:"dimensions",dimensions:S}))}return b},[]);D2(s,h);const k=l||o&&!l&&F2(t,{initial:!0,...u});e({nodeInternals:new Map(s),fitViewOnInitDone:k}),(v==null?void 0:v.length)>0&&(r==null||r(v))},updateNodePositions:(n,r=!0,s=!1)=>{const{triggerNodeChanges:o}=t(),l=n.map(u=>{const d={id:u.id,type:"position",dragging:s};return r&&(d.positionAbsolute=u.positionAbsolute,d.position=u.position),d});o(l)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:s,hasDefaultNodes:o,nodeOrigin:l,getNodes:u,elevateNodesOnSelect:d}=t();if(n!=null&&n.length){if(o){const h=WF(n,u()),f=rp(h,s,l,d);e({nodeInternals:f})}r==null||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:s,getNodes:o}=t();let l,u=null;r?l=n.map(d=>Vs(d,!0)):(l=zo(o(),n),u=zo(s,[])),yu({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=>Vs(d,!0)):(l=zo(s,n),u=zo(o(),[])),yu({changedNodes:u,changedEdges:l,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:s,getNodes:o}=t(),l=n||o(),u=r||s,d=l.map(f=>(f.selected=!1,Vs(f.id,!1))),h=u.map(f=>Vs(f.id,!1));yu({changedNodes:d,changedEdges:h,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:s}=t();r==null||r.scaleExtent([n,s]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:s}=t();r==null||r.scaleExtent([s,n]),e({maxZoom:n})},setTranslateExtent:n=>{var r;(r=t().d3Zoom)==null||r.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=t(),o=r().filter(u=>u.selected).map(u=>Vs(u.id,!1)),l=n.filter(u=>u.selected).map(u=>Vs(u.id,!1));yu({changedNodes:o,changedEdges:l,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach(s=>{s.positionAbsolute=fb(s.position,n)}),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:s,height:o,d3Zoom:l,d3Selection:u,translateExtent:d}=t();if(!l||!u||!n.x&&!n.y)return!1;const h=ls.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),f=[[0,0],[s,o]],p=l==null?void 0:l.constrain()(h,f,d);return l.transform(u,p),r[0]!==p.x||r[1]!==p.y||r[2]!==p.k},cancelConnection:()=>e({connectionNodeId:zs.connectionNodeId,connectionHandleId:zs.connectionHandleId,connectionHandleType:zs.connectionHandleType,connectionStatus:zs.connectionStatus,connectionStartHandle:zs.connectionStartHandle,connectionEndHandle:zs.connectionEndHandle}),reset:()=>e({...zs})}),Object.is),kb=({children:e})=>{const t=w.useRef(null);return t.current||(t.current=T6()),de.createElement(K5,{value:t.current},e)};kb.displayName="ReactFlowProvider";const Z2=({children:e})=>w.useContext(Ad)?de.createElement(de.Fragment,null,e):de.createElement(kb,null,e);Z2.displayName="ReactFlowWrapper";const A6={input:R2,default:lx,output:$2,group:xb},R6={default:td,straight:gb,step:mb,smoothstep:Rd,simplebezier:pb},M6=[0,0],$6=[15,15],I6={x:0,y:0,zoom:1},O6={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},J2=w.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:o=A6,edgeTypes:l=R6,onNodeClick:u,onEdgeClick:d,onInit:h,onMove:f,onMoveStart:p,onMoveEnd:g,onConnect:v,onConnectStart:k,onConnectEnd:b,onClickConnectStart:x,onClickConnectEnd:N,onNodeMouseEnter:S,onNodeMouseMove:_,onNodeMouseLeave:E,onNodeContextMenu:T,onNodeDoubleClick:A,onNodeDragStart:R,onNodeDrag:B,onNodeDragStop:P,onNodesDelete:D,onEdgesDelete:O,onSelectionChange:L,onSelectionDragStart:z,onSelectionDrag:M,onSelectionDragStop:$,onSelectionContextMenu:q,onSelectionStart:X,onSelectionEnd:H,connectionMode:I=Pa.Strict,connectionLineType:W=Gs.Bezier,connectionLineStyle:F,connectionLineComponent:Y,connectionLineContainerStyle:J,deleteKeyCode:V="Backspace",selectionKeyCode:G="Shift",selectionOnDrag:K=!1,selectionMode:Z=Il.Full,panActivationKeyCode:ee="Space",multiSelectionKeyCode:re=Qu()?"Meta":"Control",zoomActivationKeyCode:ue=Qu()?"Meta":"Control",snapToGrid:me=!1,snapGrid:ae=$6,onlyRenderVisibleElements:pe=!1,selectNodesOnDrag:xe=!0,nodesDraggable:se,nodesConnectable:ve,nodesFocusable:fe,nodeOrigin:he=M6,edgesFocusable:_e,edgesUpdatable:Fe,elementsSelectable:Le,defaultViewport:Ve=I6,minZoom:le=.5,maxZoom:je=2,translateExtent:$e=ux,preventScrolling:Oe=!0,nodeExtent:ze,defaultMarkerColor:nt="#b1b1b7",zoomOnScroll:it=!0,zoomOnPinch:At=!0,panOnScroll:Ue=!1,panOnScrollSpeed:Ze=.5,panOnScrollMode:Je=Ta.Free,zoomOnDoubleClick:rt=!0,panOnDrag:gt=!0,onPaneClick:Rt,onPaneMouseEnter:yt,onPaneMouseMove:lt,onPaneMouseLeave:Qt,onPaneScroll:Pt,onPaneContextMenu:Dt,children:Ft,onEdgeContextMenu:Kt,onEdgeDoubleClick:qr,onEdgeMouseEnter:Un,onEdgeMouseMove:Ur,onEdgeMouseLeave:zr,onEdgeUpdate:zn,onEdgeUpdateStart:mr,onEdgeUpdateEnd:Wn,onReconnect:Wr,onReconnectStart:kn,onReconnectEnd:ms,reconnectRadius:Nn=10,edgeUpdaterRadius:gr=10,onNodesChange:vt,onEdgesChange:yr,noDragClassName:wr="nodrag",noWheelClassName:Hr="nowheel",noPanClassName:Hn="nopan",fitView:fn=!1,fitViewOptions:Vr,connectOnClick:jn=!0,attributionPosition:we,proOptions:Be,defaultEdgeOptions:We,elevateNodesOnSelect:en=!0,elevateEdgesOnSelect:gs=!1,disableKeyboardA11y:vr=!1,autoPanOnConnect:Vn=!0,autoPanOnNodeDrag:Qe=!0,connectionRadius:xr=20,isValidConnection:Gn,onError:Gr,style:Kn,id:Ya,nodeDragThreshold:Xa,...Kr},Yt)=>{const ra=Ya||"1";return de.createElement("div",{...Kr,style:{...Kn,...O6},ref:Yt,className:Ut(["react-flow",s]),"data-testid":"rf__wrapper",id:Ya},de.createElement(Z2,null,de.createElement(C6,{onInit:h,onMove:f,onMoveStart:p,onMoveEnd:g,onNodeClick:u,onEdgeClick:d,onNodeMouseEnter:S,onNodeMouseMove:_,onNodeMouseLeave:E,onNodeContextMenu:T,onNodeDoubleClick:A,nodeTypes:o,edgeTypes:l,connectionLineType:W,connectionLineStyle:F,connectionLineComponent:Y,connectionLineContainerStyle:J,selectionKeyCode:G,selectionOnDrag:K,selectionMode:Z,deleteKeyCode:V,multiSelectionKeyCode:re,panActivationKeyCode:ee,zoomActivationKeyCode:ue,onlyRenderVisibleElements:pe,selectNodesOnDrag:xe,defaultViewport:Ve,translateExtent:$e,minZoom:le,maxZoom:je,preventScrolling:Oe,zoomOnScroll:it,zoomOnPinch:At,zoomOnDoubleClick:rt,panOnScroll:Ue,panOnScrollSpeed:Ze,panOnScrollMode:Je,panOnDrag:gt,onPaneClick:Rt,onPaneMouseEnter:yt,onPaneMouseMove:lt,onPaneMouseLeave:Qt,onPaneScroll:Pt,onPaneContextMenu:Dt,onSelectionContextMenu:q,onSelectionStart:X,onSelectionEnd:H,onEdgeContextMenu:Kt,onEdgeDoubleClick:qr,onEdgeMouseEnter:Un,onEdgeMouseMove:Ur,onEdgeMouseLeave:zr,onReconnect:Wr??zn,onReconnectStart:kn??mr,onReconnectEnd:ms??Wn,reconnectRadius:Nn??gr,defaultMarkerColor:nt,noDragClassName:wr,noWheelClassName:Hr,noPanClassName:Hn,elevateEdgesOnSelect:gs,rfId:ra,disableKeyboardA11y:vr,nodeOrigin:he,nodeExtent:ze}),de.createElement(jF,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:v,onConnectStart:k,onConnectEnd:b,onClickConnectStart:x,onClickConnectEnd:N,nodesDraggable:se,nodesConnectable:ve,nodesFocusable:fe,edgesFocusable:_e,edgesUpdatable:Fe,elementsSelectable:Le,elevateNodesOnSelect:en,minZoom:le,maxZoom:je,nodeExtent:ze,onNodesChange:vt,onEdgesChange:yr,snapToGrid:me,snapGrid:ae,connectionMode:I,translateExtent:$e,connectOnClick:jn,defaultEdgeOptions:We,fitView:fn,fitViewOptions:Vr,onNodesDelete:D,onEdgesDelete:O,onNodeDragStart:R,onNodeDrag:B,onNodeDragStop:P,onSelectionDrag:M,onSelectionDragStart:z,onSelectionDragStop:$,noPanClassName:Hn,nodeOrigin:he,rfId:ra,autoPanOnConnect:Vn,autoPanOnNodeDrag:Qe,onError:Gr,connectionRadius:xr,isValidConnection:Gn,nodeDragThreshold:Xa}),de.createElement(kF,{onSelectionChange:L}),Ft,de.createElement(X5,{proOptions:Be,position:we}),de.createElement(TF,{rfId:ra,disableKeyboardA11y:vr})))});J2.displayName="ReactFlow";const L6=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function Q2(){return Ye(L6,Tt)}const eM=({id:e,x:t,y:n,width:r,height:s,style:o,color:l,strokeColor:u,strokeWidth:d,className:h,borderRadius:f,shapeRendering:p,onClick:g,selected:v})=>{const{background:k,backgroundColor:b}=o||{},x=l||k||b;return de.createElement("rect",{className:Ut(["react-flow__minimap-node",{selected:v},h]),x:t,y:n,rx:f,ry:f,width:r,height:s,fill:x,stroke:u,strokeWidth:d,shapeRendering:p,onClick:g?N=>g(N,e):void 0})};eM.displayName="MiniMapNode";var P6=w.memo(eM);const D6=e=>e.nodeOrigin,F6=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),ip=e=>e instanceof Function?e:()=>e;function B6({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s=2,nodeComponent:o=P6,onClick:l}){const u=Ye(F6,Tt),d=Ye(D6),h=ip(t),f=ip(e),p=ip(n),g=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return de.createElement(de.Fragment,null,u.map(v=>{const{x:k,y:b}=Ma(v,d).positionAbsolute;return de.createElement(o,{key:v.id,x:k,y:b,width:v.width,height:v.height,style:v.style,selected:v.selected,className:p(v),color:h(v),borderRadius:r,strokeColor:f(v),strokeWidth:s,shapeRendering:g,onClick:l,id:v.id})}))}var q6=w.memo(B6);const U6=200,z6=150,W6=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?Q5(Md(t,e.nodeOrigin),n):n,rfId:e.rfId}},H6="react-flow__minimap-desc";function tM({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:r="#e2e2e2",nodeClassName:s="",nodeBorderRadius:o=5,nodeStrokeWidth:l=2,nodeComponent:u,maskColor:d="rgb(240, 240, 240, 0.6)",maskStrokeColor:h="none",maskStrokeWidth:f=1,position:p="bottom-right",onClick:g,onNodeClick:v,pannable:k=!1,zoomable:b=!1,ariaLabel:x="React Flow mini map",inversePan:N=!1,zoomStep:S=10,offsetScale:_=5}){const E=kt(),T=w.useRef(null),{boundingRect:A,viewBB:R,rfId:B}=Ye(W6,Tt),P=(e==null?void 0:e.width)??U6,D=(e==null?void 0:e.height)??z6,O=A.width/P,L=A.height/D,z=Math.max(O,L),M=z*P,$=z*D,q=_*z,X=A.x-(M-A.width)/2-q,H=A.y-($-A.height)/2-q,I=M+q*2,W=$+q*2,F=`${H6}-${B}`,Y=w.useRef(0);Y.current=z,w.useEffect(()=>{if(T.current){const G=Ln(T.current),K=re=>{const{transform:ue,d3Selection:me,d3Zoom:ae}=E.getState();if(re.sourceEvent.type!=="wheel"||!me||!ae)return;const pe=-re.sourceEvent.deltaY*(re.sourceEvent.deltaMode===1?.05:re.sourceEvent.deltaMode?1:.002)*S,xe=ue[2]*Math.pow(2,pe);ae.scaleTo(me,xe)},Z=re=>{const{transform:ue,d3Selection:me,d3Zoom:ae,translateExtent:pe,width:xe,height:se}=E.getState();if(re.sourceEvent.type!=="mousemove"||!me||!ae)return;const ve=Y.current*Math.max(1,ue[2])*(N?-1:1),fe={x:ue[0]-re.sourceEvent.movementX*ve,y:ue[1]-re.sourceEvent.movementY*ve},he=[[0,0],[xe,se]],_e=ls.translate(fe.x,fe.y).scale(ue[2]),Fe=ae.constrain()(_e,he,pe);ae.transform(me,Fe)},ee=u2().on("zoom",k?Z:null).on("zoom.wheel",b?K:null);return G.call(ee),()=>{G.on("zoom",null)}}},[k,b,N,S]);const J=g?G=>{const K=sr(G);g(G,{x:K[0],y:K[1]})}:void 0,V=v?(G,K)=>{const Z=E.getState().nodeInternals.get(K);v(G,Z)}:void 0;return de.createElement(db,{position:p,style:e,className:Ut(["react-flow__minimap",t]),"data-testid":"rf__minimap"},de.createElement("svg",{width:P,height:D,viewBox:`${X} ${H} ${I} ${W}`,role:"img","aria-labelledby":F,ref:T,onClick:J},x&&de.createElement("title",{id:F},x),de.createElement(q6,{onClick:V,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:s,nodeStrokeWidth:l,nodeComponent:u}),de.createElement("path",{className:"react-flow__minimap-mask",d:`M${X-q},${H-q}h${I+q*2}v${W+q*2}h${-I-q*2}z
57
+ M${R.x},${R.y}h${R.width}v${R.height}h${-R.width}z`,fill:d,fillRule:"evenodd",stroke:h,strokeWidth:f,pointerEvents:"none"})))}tM.displayName="MiniMap";var V6=w.memo(tM);function G6(){return de.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},de.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function K6(){return de.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},de.createElement("path",{d:"M0 0h32v4.2H0z"}))}function Y6(){return de.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},de.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function X6(){return de.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},de.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function Z6(){return de.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},de.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const In=({children:e,className:t,...n})=>de.createElement("button",{type:"button",className:Ut(["react-flow__controls-button",t]),...n},e);In.displayName="ControlButton";const J6=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),nM=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:o,onZoomOut:l,onFitView:u,onInteractiveChange:d,className:h,children:f,position:p="bottom-left"})=>{const g=kt(),[v,k]=w.useState(!1),{isInteractive:b,minZoomReached:x,maxZoomReached:N}=Ye(J6,Tt),{zoomIn:S,zoomOut:_,fitView:E}=mi();if(w.useEffect(()=>{k(!0)},[]),!v)return null;const T=()=>{S(),o==null||o()},A=()=>{_(),l==null||l()},R=()=>{E(s),u==null||u()},B=()=>{g.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),d==null||d(!b)};return de.createElement(db,{className:Ut(["react-flow__controls",h]),position:p,style:e,"data-testid":"rf__controls"},t&&de.createElement(de.Fragment,null,de.createElement(In,{onClick:T,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:N},de.createElement(G6,null)),de.createElement(In,{onClick:A,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:x},de.createElement(K6,null))),n&&de.createElement(In,{className:"react-flow__controls-fitview",onClick:R,title:"fit view","aria-label":"fit view"},de.createElement(Y6,null)),r&&de.createElement(In,{className:"react-flow__controls-interactive",onClick:B,title:"toggle interactivity","aria-label":"toggle interactivity"},b?de.createElement(Z6,null):de.createElement(X6,null)),f)};nM.displayName="Controls";var Q6=w.memo(nM),lr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(lr||(lr={}));function eB({color:e,dimensions:t,lineWidth:n}){return de.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function tB({color:e,radius:t}){return de.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const nB={[lr.Dots]:"#91919a",[lr.Lines]:"#eee",[lr.Cross]:"#e2e2e2"},rB={[lr.Dots]:1,[lr.Lines]:1,[lr.Cross]:6},sB=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function rM({id:e,variant:t=lr.Dots,gap:n=20,size:r,lineWidth:s=1,offset:o=2,color:l,style:u,className:d}){const h=w.useRef(null),{transform:f,patternId:p}=Ye(sB,Tt),g=l||nB[t],v=r||rB[t],k=t===lr.Dots,b=t===lr.Cross,x=Array.isArray(n)?n:[n,n],N=[x[0]*f[2]||1,x[1]*f[2]||1],S=v*f[2],_=b?[S,S]:N,E=k?[S/o,S/o]:[_[0]/o,_[1]/o];return de.createElement("svg",{className:Ut(["react-flow__background",d]),style:{...u,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:h,"data-testid":"rf__background"},de.createElement("pattern",{id:p+e,x:f[0]%N[0],y:f[1]%N[1],width:N[0],height:N[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${E[0]},-${E[1]})`},k?de.createElement(tB,{color:g,radius:S/o}):de.createElement(eB,{dimensions:_,color:g,lineWidth:s})),de.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${p+e})`}))}rM.displayName="Background";var aB=w.memo(rM);function oB(e,t){return e?t==="gone"?"entering":t==="leaving"?"here":t:t==="gone"?"gone":"leaving"}function Du(e){return e!=="gone"}function Fu(e,t){const[n,r]=w.useState(()=>e?"here":"gone"),s=w.useRef(null);return w.useEffect(()=>{r(o=>oB(e,o))},[e]),w.useEffect(()=>{if(n==="leaving")return s.current=window.setTimeout(()=>r("gone"),t),()=>{s.current!=null&&window.clearTimeout(s.current)}},[n,t]),w.useEffect(()=>{n==="entering"&&r("here")},[n]),n}const HN="agent-dag.fm-custom-stations",VN="agent-dag.fm-muted",dx="custom:",iB=/^UC[A-Za-z0-9_-]{22}$/,lB=/^[A-Za-z0-9_-]{11}$/,Nb=/^[A-Za-z0-9_-]{1,80}$/,cB=/\.(mp3|aac|ogg)$/i,uB=/\.m3u8$/i,sM=2048,Ll=80;function Fa(e){return`${dx}${e}`}function ai(e){if(!e.startsWith(dx))return null;const t=e.slice(dx.length);return Nb.test(t)?t:null}function GN(e){return ai(e)??e}function dB(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 jb(e){var l,u;const t=e.trim();if(t.length>sM)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&&iB.test(d))return{kind:"youtube-channel",url:r,channel:d};const h=(u=/^\/@([^/]+)\/live\/?$/.exec(n.pathname))==null?void 0:u[1];if(h&&/^[A-Za-z0-9._-]{1,64}$/.test(h))return{kind:"youtube-handle",url:r,handle:h};if(n.pathname==="/watch"){const f=n.searchParams.get("v")??"";if(lB.test(f))return{kind:"youtube-video",url:r,video:f}}return null}return uB.test(n.pathname)?{kind:"direct-audio",url:r,format:"hls"}:cB.test(n.pathname)?{kind:"direct-audio",url:r,format:"audio"}:null}function hB(e){return e==="1"}function fB(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=jb(u);!Nb.test(o)||n.has(o)||!l||l.length>Ll||!d||(n.add(o),r.push({id:o,name:l,url:d.url}))}return r}function pB(e,t,n){const r=ai(e??"");return r&&t.some(s=>s.id===r)?Fa(r):n(e)}function mB(e,t){return e===Fa(t)?"claude-fm":e}function gB(){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 yB(e,t,n=gB()){const r=e.trim(),s=jb(t);return!r||r.length>Ll||!Nb.test(n)||!s?null:{id:n,name:r,url:s.url}}const aM=.2,oM=1.6;function wB(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<aM||s>oM?null:{x:n,y:r,zoom:s}}function hx({durationMs:e,documentHidden:t,reducedMotion:n=vB()}){return t||n?!1:Number.isFinite(e)&&e>0}function vB(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}const xB=["us-gov","global","apac","us","eu","jp","au"],bB=new RegExp(`^(?:(?:${xB.join("|")})\\.)?anthropic\\.`,"i");function gi(e){return e.replace(bB,"")}const kB=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i,NB=new Set(["tool_input","tool_response"]);function iM(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.model=="string"&&kB.test(gi(n.model)))return n.model;for(const[r,s]of Object.entries(n)){if(NB.has(r))continue;const o=iM(s,t+1);if(o)return o}return null}function Sb(){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 ta(e,t){return`${e}::${t}`}function yi(e,t){return`${e}\0${t}`}const jB=/[0-9a-f]{16,}/i,SB=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function lM(e){return jB.test(e)||SB.test(e)}function _B(e){if(!e)return;const t=e.replace(/\\/g,"/").split("/").filter(Boolean);for(let n=t.length-1;n>=0;n--)if(!lM(t[n]))return t[n];return t[t.length-1]}function cM(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function uM(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 _b(e){const t=uM(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 EB(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t={};for(const[n,r]of Object.entries(e)){if(!n||!r||typeof r!="object")continue;const s=r;t[n]=_b(s);const o=CB(s.speeds);o&&(t[n].bySpeed=o)}return Object.keys(t).length?t:void 0}function CB(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=Object.entries(e).filter(([n,r])=>n&&r&&typeof r=="object").map(([n,r])=>[n,_b(r)]);return t.length?Object.fromEntries(t):void 0}function dM(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),...uM(n)};for(const r of Object.values(n)){const s=dM(r,t+1);if(s)return s}return null}function Eb(e){return _B(e)}function Cb(e){const t=e.agent_type??e.subagent_type;return t&&!lM(t)?t:"subagent"}function ec(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function Pl(e,t){!e.cwd&&t.cwd&&(e.cwd=t.cwd,e.cwdBasename=Eb(t.cwd))}function hM(e,t){e.label==="session"&&t.cwd&&(e.label=Eb(t.cwd)??"session")}function fM(e,t){const n=Cb(t);n&&(e.label==="subagent"||!e.label)&&(e.label=n)}function wi(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:cM()},e.agents.set(s,o),o)}function pM(e,t,n,r){const s=ta(t,n),o=e.agents.get(s);return o?(Pl(o,r),fM(o,r),o):null}function TB(e,t,n){const r=t.session_id??"unknown",s=ec(t);if(s){const d=pM(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(ta(r,l));if(d)return Pl(d,t),d}const u=wi(e,r,n,t.hook_event_name!=="SessionStart");return Pl(u,t),hM(u,t),u}function AB(e,t,n,r,s){const o=ta(t,n),l=wi(e,t,s,!0);let u=e.agents.get(o);if(u)return Pl(u,r),fM(u,r),u;u={id:o,sessionId:t,label:Cb(r),kind:"subagent",parentId:l.id,state:"active",startedAt:s,tools:[],prompts:[],cwd:r.cwd,cwdBasename:Eb(r.cwd),toolCount:0,childCount:0,usage:cM()},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 RB(e,t,n){const r=e.activeSubagentStack.get(t)??[];r.includes(n)||(r.push(n),e.activeSubagentStack.set(t,r))}function mM(e,t,n){const r=e.activeSubagentStack.get(t);if(r){for(let s=r.length-1;s>=0;s--)if(r[s]===n){r.splice(s,1);break}r.length===0&&e.activeSubagentStack.delete(t)}}function Ot(e,t){return Object.hasOwn(e,t)?e[t]:void 0}const MB=/^\s*<task-notification>([\s\S]*?)<\/task-notification>/;function KN(e,t){var n;return((n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`).exec(e))==null?void 0:n[1].trim())||void 0}const $B={completed:"background task finished",failed:"background task failed",killed:"background task stopped"};function Tb(e){const t=MB.exec(e);if(!t)return null;const n=KN(t[1],"status");return{label:(n?Ot($B,n):void 0)??"background task update",detail:KN(t[1],"summary")}}function gM(e){return e.filter(t=>!Tb(t.text))}const YN=2e3;function IB(e,t,n){for(let r=e.length-1;r>=0;r--){const s=e[r];if(s.at<t-YN)return!1;if(s.text===n&&s.at<=t+YN)return!0}return!1}function OB(e,t,n){if(IB(e,t,n))return!1;let r=e.length;for(;r>0&&e[r-1].at>t;)r--;return e.splice(r,0,{at:t,text:n}),!0}const nd=2e3;function LB(e){const t=e.prompts[e.prompts.length-1];return t&&t.at>e.startedAt?t.at:e.startedAt}function rd(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 XN=200;function yM(e,t,n){const r=t.ok===!1;t.ok=n,e&&r===n&&(e.toolErrorCount=(e.toolErrorCount??0)+(n?-1:1))}function wM(e,t){return t.agentId==null?void 0:e.agents.get(t.agentId)}function lp(e,t,n){const r=e.toolCountByName??(e.toolCountByName=new Map),s=(r.get(t)??0)+n;s>0?r.set(t,s):r.delete(t)}function PB(e,t,n){var r;return((r=e.get(t))==null?void 0:r.tools.find(s=>s.id===n))??null}const DB=25;function FB(e,t){const n=t.tools;if(n.length>XN){const r=n.splice(0,n.length-XN);for(const s of r)xM(e,t,s)}for(let r=n.length-DB-1;r>=0;r--){const s=n[r];if(s.trimmed)break;s.input=void 0,s.response=void 0,s.trimmed=!0}}function BB(e,t,n){const r=e.toolIndex.get(yi(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 vM(e,t){for(const n of t.tools)xM(e,t,n)}function xM(e,t,n){const r=yi(t.sessionId,n.id);e.toolIndex.get(r)===n&&e.toolIndex.delete(r)}const qB="no result reached the deck — events were dropped while the deck was paused";function bM(e,t,n,r,s){n.endedAt=r,yM(t,n,!1),n.errorPreview=n.outcomeGap?qB:s,e.toolIndex.delete(yi(t.sessionId,n.id))}function UB(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(yi((n==null?void 0:n.session_id)??"unknown",s))}function zB(e,t,n,r,s){const o=t.tool_use_id?BB(e,r,t.tool_use_id):null;if(o){if(t.tool_name&&o.name==="?"){o.name=t.tool_name;const h=wM(e,o);h&&(lp(h,"?",-1),lp(h,o.name,1))}o.endedAt==null&&!o.trimmed&&t.tool_input!==void 0&&(o.input=t.tool_input,o.inputPreview=rd(t.tool_input));return}const l=t.tool_use_id??`${r.id}:${r.toolCount}`,u=ec(t),d={id:l,name:t.tool_name??"?",input:t.tool_input,inputPreview:rd(t.tool_input),agentId:r.id,explicitSubagentId:u?ta(n,u):void 0,startedAt:s};r.tools.push(d),r.toolCount+=1,lp(r,d.name,1),r.state="active",e.toolIndex.set(yi(r.sessionId,l),d),FB(e,r)}function WB(e,t,n,r,s){const o=t.tool_use_id;if(!o)return;const l=yi(r,o);let u=e.toolIndex.get(l),d=!1;if(!u)for(const f of e.agents.values()){if(f.sessionId!==r)continue;const p=f.tools.find(g=>g.id===o);if(p){u=p,d=!0;break}}if(!u||u.outcomeApplied)return;u.outcomeApplied=!0,u.outcomeGap=void 0,u.endedAt=s,yM(wM(e,u),u,n==="PostToolUse"),u.trimmed||(u.response=t.tool_response),n==="PostToolUseFailure"?u.errorPreview=rd(t.tool_response):d&&(u.errorPreview=void 0);const h=dM(t.tool_response);h&&(u.usage=h),e.toolIndex.delete(l)}function HB(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 VB(e,t,n,r){const s=wi(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),Pl(s,t),hM(s,t)}function GB(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=wi(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&&OB(s.prompts,r,o)&&!s.firstPrompt&&!Tb(o)&&(s.firstPrompt=rd(o,120))}function KB(e,t,n,r){const s=wi(e,n,r,!1),o=LB(s);if(r<o)return;const l=s.lastTurnEndAt;if(!(l!=null&&o>l&&r<=l+nd)){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&&bM(e,u,d,r,"the turn ended before this call returned");t==="SessionEnd"&&(s.closedAt=r),e.activeSubagentStack.delete(n)}}function YB(e,t,n,r){const s=ec(t);if(!s)return;const o=AB(e,n,s,t,r),l=Cb(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<=nd,h=u!=null&&r-u<=nd;if(d||h){const f=h?u:o.endedAt;o.state="done",o.endedAt=f,o.startedAt=Math.min(o.startedAt,f),mM(e,n,s);return}o.state="active",o.startedAt=o.startedAt||r,o.exitAt=void 0,o.endedAt=void 0,RB(e,n,s)}function XB(e,t,n,r){const s=ec(t);if(!s)return;const o=pM(e,n,s,t);if(!o){for(const[l,u]of e.subagentTombstones)r-u>nd&&e.subagentTombstones.delete(l);e.subagentTombstones.set(ta(n,s),r);return}o.state="done",o.endedAt=Math.min(o.endedAt??r,r),mM(e,n,s)}function kM(){return{msgsUser:0,msgsAssistant:0,toolUses:0,toolResults:0,systemReminders:0,currentContextTokens:0,memoryFiles:[]}}function ZB(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??kM(),currentContextTokens:t.context_tokens})}}const JB=6e4,ZN=64;function QB(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=ta(n,o),d=e.agents.get(u);if(d)d.model=l,e.pendingSubagentModels.delete(u);else if(e.pendingSubagentModels.delete(u),e.pendingSubagentModels.set(u,l),e.pendingSubagentModels.size>256){const h=e.pendingSubagentModels.keys().next().value;h!==void 0&&e.pendingSubagentModels.delete(h)}}}function eq(e,t,n){const r=t.context??null;if(r){const s=e.agents.get(n);if(s){const o=s.context??kM(),l=(d,h)=>typeof r[d]=="number"?r[d]:h,u=Array.isArray(r.memoryFiles)?r.memoryFiles:Array.isArray(r.claudeMdFiles)?r.claudeMdFiles:null;s.context={msgsUser:l("msgsUser",o.msgsUser),msgsAssistant:l("msgsAssistant",o.msgsAssistant),toolUses:l("toolUses",o.toolUses),toolResults:l("toolResults",o.toolResults),systemReminders:l("systemReminders",o.systemReminders),currentContextTokens:l("currentContextTokens",o.currentContextTokens),memoryFiles:u??o.memoryFiles}}}}function tq(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 nq(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 rq(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<JB);u.push(o),l.outputs=u.length>ZN?u.slice(-ZN):u}e.revision+=1}}function sq(e,t,n){const r=t.usage??null;if(r){const s=e.agents.get(n);s&&(Object.assign(s.usage,_b(r)),s.usageByModel=EB(t.usageByModel))}}const aq=["command","cmd","file_path","path","url","pattern","notebook_path"],JN=120,cp=e=>e.length>JN?`${e.slice(0,JN-1)}…`:e;function oq(e){if(typeof e=="string")return e.trim()?cp(e.trim()):null;if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;for(const n of aq){const r=t[n];if(typeof r=="string"&&r.trim())return cp(r.trim());if(Array.isArray(r)&&r.length>0&&r.every(s=>typeof s=="string")){const s=r.join(" ").trim();if(s)return cp(s)}}return null}function iq(e){return e==="permission_prompt"?"permission":e==="agent_needs_input"?"asked":e==="idle_prompt"?"idle":null}const lq=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved","SessionNamed","SessionRecapped","OutputObserved"]);function cq(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 uq=3e4;function dq(e,t){if(!(!e||!e.name)&&!(t-e.startedAt>uq)&&!(e.startedAt>t))return{name:e.name,preview:oq(e.input)??""}}function hq(e,t,n,r,s){if(n!=="permission")return{kind:n,message:r,since:s};const o=cq(e,t),l={kind:n,message:r,since:s};o!=null&&o.explicitSubagentId&&(l.subagentId=o.explicitSubagentId);const u=dq(o,s);return u&&(l.tool=u),l}function fq(e,t,n){if(e.kind==="idle")return!0;const r=ec(t);return r==null?!0:e.subagentId!=null&&ta(n,r)===e.subagentId}function pq(e,t,n,r){if(!lq.has(t)){const s=e.agents.get(r);s!=null&&s.waiting&&fq(s.waiting,n,r)&&(s.waiting=null)}}function mq(e,t,n,r){const s=iq(t.notification_type);if(!s)return;const o=wi(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)}:hq(e,n,s,l,r)}function tc(e,t){return t&&(e.revision+=1),t}function gq(e,t,n,r,s){if(e.agents.size<=n)return!1;const o=p=>p.state==="done"&&p.endedAt!=null&&t-p.endedAt>r,l=[],u=new Map;for(const[p,g]of e.agents){if(g.parentId!=null){const v=u.get(g.parentId);v?v.push(p):u.set(g.parentId,[p])}o(g)&&l.push({id:p,endedAt:g.endedAt})}if(l.length===0)return!1;l.sort((p,g)=>p.endedAt-g.endedAt);let d=0;const h=new Set,f=p=>{const g=e.agents.get(p);g&&(vM(e,g),e.agents.delete(p),h.add(g.sessionId),d++)};for(const p of l){if(e.agents.size<=n)break;if(!e.agents.has(p.id))continue;const g=(u.get(p.id)??[]).map(v=>e.agents.get(v)).filter(v=>v!=null);if(!g.some(v=>!o(v))){for(const v of g)f(v.id);f(p.id)}}if(s&&h.size>0){const p=new Set;for(const g of e.agents.values())p.add(g.sessionId);for(const g of h)p.has(g)||s(g)}return tc(e,d>0)}function yq(e,t,n,r,s){const o=new Map;for(const[f,p]of e.agents){let g=o.get(p.sessionId);g||(g={ids:[],endedAt:0,live:!1,closed:!1},o.set(p.sessionId,g)),g.ids.push(f),p.kind==="root"&&p.closedAt!=null&&(g.closed=!0),p.state==="done"&&p.endedAt!=null?g.endedAt=Math.max(g.endedAt,p.endedAt):g.live=!0}const l=[...o].filter(([,f])=>!f.live&&f.endedAt>0&&t-f.endedAt>r).sort(([,f],[,p])=>f.closed===p.closed?f.endedAt-p.endedAt:f.closed?-1:1);let d=[...o.values()].filter(f=>!f.live).length-n;if(d<=0)return!1;let h=!1;for(const[f,p]of l){if(d<=0)break;for(const v of p.ids){const k=e.agents.get(v);k&&vM(e,k),e.agents.delete(v)}const g=ta(f,"");for(const v of e.pendingSubagentModels.keys())v.startsWith(g)&&e.pendingSubagentModels.delete(v);s==null||s(f),d--,h=!0}return tc(e,h)}function wq(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 tc(e,t)}function vq(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&&(bM(e,s,u,d,"session ended before this call returned"),r=!0)}}return tc(e,r)}const QN=90*6e4;function xq(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 tc(e,r)}function sd(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 NM(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{...Sb(),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(pq(e,o,r,l),HB(e,l,s),ZB(e,r,l),o){case"ModelObserved":return QB(e,r,l),e;case"ContextObserved":return eq(e,r,l),e;case"SessionNamed":return tq(e,r,l),e;case"SessionRecapped":return nq(e,r,l),e;case"OutputObserved":return rq(e,r,l,s),e;case"UsageObserved":return sq(e,r,l),e}const u=TB(e,r,s);u.provider||(u.provider=r.provider==="codex"?"codex":"claude");const d=iM(r);switch(d&&(u.model=d),o){case"SessionStart":VB(e,r,l,s);break;case"UserPromptSubmit":GB(e,r,l,s);break;case"PreToolUse":zB(e,r,l,u,s);break;case"PostToolUse":case"PostToolUseFailure":WB(e,r,o,l,s);break;case"SubagentStart":YB(e,r,l,s);break;case"SubagentStop":XB(e,r,l,s);break;case"Stop":case"SessionEnd":KB(e,o,l,s);break;case"Notification":mq(e,r,l,s);break}return e}const bq={input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4},kq=[{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:bq},{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}}],Nq=[{match:/^claude[-_]opus[-_]5[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:8,output:40,cacheRead:.4,cacheWrite:10,cacheWrite1h:16}},{match:/^claude[-_]opus[-_]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:10,output:50,cacheRead:1,cacheWrite:12.5,cacheWrite1h:20}},{match:/^claude[-_]opus[-_]4[-_.]8\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:10,output:50,cacheRead:1,cacheWrite:12.5,cacheWrite1h:20}}];function jq(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function za(e,t=Date.now(),n=Ba){if(!e)return null;const r=Sq.get(n);if(!r)return null;const s=gi(e);for(const o of r)if(o.match.test(s))return typeof o.rates=="function"?o.rates(t):o.rates;return null}const Ba="standard",Sq=new Map([[Ba,kq],["fast",Nq]]);function Nl(e,t){return e*t/1e6}function jM(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:Nl(o,t.cacheWrite),usd1h:Nl(n,l)}}function SM(e,t,n=Date.now()){if(!jq(t))return e.inputTokens;const r=za(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 Zo(e,t,n=Date.now()){const r={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const s of Ab(e)){const o=_M(s.usage,t,s.speed,n);r.input+=o.input,r.output+=o.output,r.cacheRead+=o.cacheRead,r.cacheWrite+=o.cacheWrite,r.total+=o.total}return r}function _M(e,t,n,r=Date.now()){const s=za(t,r,n);if(!s)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const o=Nl(SM(e,t,r),s.input),l=Nl(e.outputTokens,s.output),u=Nl(e.cacheReadTokens,s.cacheRead),d=jM(e,s),h=d.usd5m+d.usd1h;return{input:o,output:l,cacheRead:u,cacheWrite:h,total:o+l+u+h}}function Ab(e){const t=e.bySpeed?Object.entries(e.bySpeed):[];return t.length===0?[{speed:Ba,usage:e}]:[{speed:Ba,usage:_q(e,t.map(([,n])=>n))},...t.map(([n,r])=>({speed:n,usage:r}))]}function _q(e,t){const n=o=>t.reduce((l,u)=>l+(o(u)??0),0),r=o=>Math.max(0,(o(e)??0)-n(o)),s={inputTokens:r(o=>o.inputTokens),outputTokens:r(o=>o.outputTokens),cacheReadTokens:r(o=>o.cacheReadTokens),cacheCreateTokens:r(o=>o.cacheCreateTokens)};return(e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0)&&(s.cacheCreate1hTokens=r(o=>o.cacheCreate1hTokens),s.cacheCreate5mTokens=r(o=>o.cacheCreate5mTokens)),e.reasoningOutputTokens!==void 0&&(s.reasoningOutputTokens=e.reasoningOutputTokens),s}const hs="not priced";function jl(e,t,n){const r=e.toFixed(t);return Number(r)<n?r:null}function qe(e){if(e<=0)return"—";if(e<.005)return"<1¢";if(e<1){const t=jl(e*100,e<.1?1:0,100);if(t!==null)return`${t}¢`}if(e<100){const t=jl(e,2,100);if(t!==null)return`$${t}`}if(e<1e4){const t=jl(e,0,1e4);if(t!==null)return`$${t}`}return`$${(e/1e3).toFixed(1)}k`}function Rb(e,t){if(e<=0||t<10)return null;const n=e/t,r=n*60;return r>=.01?`${qe(r)}/min`:`${qe(n*3600)}/hr`}function EM(e,t){const n={inputTokens:e.inputTokens+t.inputTokens,outputTokens:e.outputTokens+t.outputTokens,cacheReadTokens:e.cacheReadTokens+t.cacheReadTokens,cacheCreateTokens:e.cacheCreateTokens+t.cacheCreateTokens};if((e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0||t.cacheCreate1hTokens!==void 0||t.cacheCreate5mTokens!==void 0)&&(n.cacheCreate1hTokens=(e.cacheCreate1hTokens??0)+(t.cacheCreate1hTokens??0),n.cacheCreate5mTokens=(e.cacheCreate5mTokens??0)+(t.cacheCreate5mTokens??0)),(e.reasoningOutputTokens!==void 0||t.reasoningOutputTokens!==void 0)&&(n.reasoningOutputTokens=(e.reasoningOutputTokens??0)+(t.reasoningOutputTokens??0)),e.bySpeed||t.bySpeed){const r=new Map(Object.entries(e.bySpeed??{}));for(const[s,o]of Object.entries(t.bySpeed??{})){const l=r.get(s);r.set(s,l?EM(l,o):o)}n.bySpeed=Object.fromEntries(r)}return n}function Eq(e,t){let n=0,r=0,s=0,o=0,l=0,u=0;for(const p of t)n+=p.inputTokens,r+=p.outputTokens,s+=p.cacheReadTokens,o+=p.cacheCreateTokens,l+=p.cacheCreate1hTokens??0,u+=p.cacheCreate5mTokens??0;const d=(p,g)=>Math.max(0,p-g),h={inputTokens:d(e.inputTokens,n),outputTokens:d(e.outputTokens,r),cacheReadTokens:d(e.cacheReadTokens,s),cacheCreateTokens:d(e.cacheCreateTokens,o)};return(e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0)&&(h.cacheCreate1hTokens=d(e.cacheCreate1hTokens??0,l),h.cacheCreate5mTokens=d(e.cacheCreate5mTokens??0,u)),h.inputTokens+h.outputTokens+h.cacheReadTokens+h.cacheCreateTokens>0?h:null}function nc(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=Eq(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:EM(r[o].usage,s)}:r.push({model:e.model,usage:s})}return r}function hn(e,t=Date.now()){const n={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const r of nc(e)){const s=Zo(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 Dl(e,t=Date.now()){let n=0;for(const r of nc(e))for(const s of Ab(r.usage))za(r.model,t,s.speed)==null&&(n+=s.usage.inputTokens+s.usage.outputTokens);return n}function CM(e){const t=[];for(const n of nc(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 TM(e){return CM(e).filter(t=>t!==e.model)}function ej(e,t){if(!e.bySpeed)return up(e,t,Ba);const n=Ab(e).filter(r=>r.speed!==Ba||Cq(r.usage));return n.length===1?up(n[0].usage,t,n[0].speed):[...n.map(r=>up(r.usage,t,r.speed)),"═════════════════════════════════════════",`all speeds = ${qe(Zo(e,t).total)}`].join(`
58
+ `)}function Cq(e){return e.inputTokens+e.outputTokens+e.cacheReadTokens+e.cacheCreateTokens>0}function up(e,t,n){const r=za(t,Date.now(),n),s=n===Ba?`model: ${t}`:`model: ${t} · ${n}`;if(!r)return`${s}
59
+ no published rate in this build — the tokens are counted, the dollars are not`;const o=g=>g.toLocaleString(),l=g=>`$${g}/MTok`,u=_M(e,t,n),d=jM(e,r),h=d.tokens1h>0?[`cache w5m${o(d.tokens5m).padStart(14)} × ${l(r.cacheWrite).padEnd(11)} = ${qe(d.usd5m)}`,`cache w1h${o(d.tokens1h).padStart(14)} × ${l(r.cacheWrite1h??r.cacheWrite).padEnd(11)} = ${qe(d.usd1h)}`]:[`cache w ${o(d.tokens5m).padStart(14)} × ${l(r.cacheWrite).padEnd(11)} = ${qe(d.usd5m)}`],f=SM(e,t),p=f===e.inputTokens?"input":"uncached";return[s,`${p.padEnd(9)}${o(f).padStart(14)} × ${l(r.input).padEnd(11)} = ${qe(u.input)}`,`output ${o(e.outputTokens).padStart(14)} × ${l(r.output).padEnd(11)} = ${qe(u.output)}`,`cache r ${o(e.cacheReadTokens).padStart(14)} × ${l(r.cacheRead).padEnd(11)} = ${qe(u.cacheRead)}`,...h,"─────────────────────────────────────────",`total = ${qe(u.total)}`].join(`
60
+ `)}function tj(e){const t=nc(e),[n]=t;return t.length<=1?ej(n.usage,n.model):[...t.map(r=>ej(r.usage,r.model)),"═════════════════════════════════════════",`all models = ${qe(hn(e).total)}`].join(`
61
+ `)}function Tq(e){if(!e.model)return null;const t=za(e.model),n=hn(e),r=Dl(e);if(!t&&n.total<=0)return e.usage.inputTokens+e.usage.outputTokens<=0?null:{kind:"unpriced",tt:tj(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?Rb(n.total,s):null,l=tj(e)+(o?`
62
+ burn: ${o}`:"");return{kind:"spent",total:n.total,floor:r>0,tt:l}}const Aq=new Set(["untrusted","on-request","on-failure"]);function Rq(e){return typeof e!="string"||!e?null:Aq.has(e)?!0:e==="never"?!1:null}function Mq(e){if(e.provider!=="codex"||e.kind!=="root"||e.waiting||e.state!=="active")return null;const t=Rq(e.approvalPolicy);return t===!1?null:{label:"approvals not visible",detail:`${t===!0?`This session's approval policy is "${e.approvalPolicy}", so Codex can stop and ask you to approve a command.`:"This session's approval policy has not been read yet, so it may be able to stop and ask you to approve a command."}
63
+
64
+ Codex writes no approval request to its rollout files, which are the only thing this deck can read — so when it does ask, this card, the sidebar, the topbar count, the tab title and the favicon will all stay silent. Check the terminal.`}}function nj(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function Js(e){const t=gi(e).replace(/[-_]\d{8}(?!\d)/,""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const s=nj(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(nj);return[`GPT-${s}`,...o].join(" ")}return e}function $d(e){const t=gi(e??""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_]/i);return n?n[1].toLowerCase():/^gpt[-_]/i.test(t)?"gpt":""}function fr(e){return(e==null?void 0:e.kind)==="permission"||(e==null?void 0:e.kind)==="asked"}function fx(e){const t=[];for(const n of e)n.kind==="root"&&fr(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 $q(e,t){if(e.length===0)return null;const n=e.findIndex(r=>r.id===t);return e[(n+1)%e.length]}function Iq(e){const t=new Set;for(const n of e)n.state==="active"&&t.add(n.sessionId);return t.size}function Id(e,t){return`${e}@${t.since}`}function AM(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 Oq(e){const t=e.message||"Needs your permission",n=AM(e,t);return n?`${t}
65
+ Likely on: ${n}`:t}function Lq(e,t,n,r=!0){if(!r)return[];if(n)return[];const s=[];for(const o of e){if(!fr(o.waiting))continue;const l=Id(o.id,o.waiting);t.has(l)||s.push({key:l,title:o.label,body:Oq(o.waiting),sessionId:o.id})}return s}function Pq(e,t,n){const r=new Set;for(const o of e)r.add(Id(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 vu(e){return new Set(e.map(t=>Id(t.id,t.waiting)))}function Dq(e,t){return e!==t}function Fq(e,t){return!e&&t!=null}function Bq(e,t){return e!==null&&t!=null}function oi(e){return e==="active"?"live":e==="done"?"done":"err"}function ii(e){return e.message?e.message:e.kind==="permission"?"Needs your permission":"Waiting for your input"}function qq(e){return`${e} subagent${e===1?"":"s"} spawned`}function Uq(e,t=Date.now(),n=!1){const r=e.tools.filter(o=>o.ok===!1).length,s=hn(e,t).total;return[e.label,e.kind==="root"?"session":"subagent",oi(e.state),fr(e.waiting)?ii(e.waiting):null,e.model?Js(e.model):null,`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,r>0?`${r} failed`:null,s>0?`${qe(s)}${Dl(e,t)>0?"+":""}`:null,n?"selected":null].filter(Boolean).join(", ")}function zq(e,t){const n=AM(e,t);return n?`Likely on: ${n}`:null}function Mb(e){return e.kind==="idle"?"Your turn":ii(e)}function ot(e){const t=Math.round(e);if(t<1e3)return`${t}`;if(t<1e6){const n=jl(t/1e3,1,1e3);if(n!==null)return`${n}k`}if(t<1e9){const n=jl(t/1e6,2,1e3);if(n!==null)return`${n}M`}return`${(t/1e9).toFixed(2)}B`}function li(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 RM(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 $b(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 rj=["B","KB","MB","GB","TB"];function Sa(e){if(e==null||!Number.isFinite(e)||e<0)return"—";if(e===0)return"0 B";let t=e,n=0;for(;n<rj.length-1&&Number(t.toFixed(1))>=1024;)t/=1024,n++;return`${t.toFixed(1)} ${rj[n]}`}const sj=2e5,Wq=1e6,Hq=[/\[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],Vq=[{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 Gq(e){if(!e)return sj;const t=gi(e);for(const n of Hq)if(n.test(t))return Wq;for(const n of Vq)if(n.match.test(t))return n.window;return sj}function MM(e,t){return typeof e=="number"&&e>0?e:Gq(t)}const Kq=1;function Yq(){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 Jo=Yq(),Xq=e=>e==="Escape";function Zq(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function aj(e){return String(e.tagName??"").toUpperCase()==="BODY"}function Jq(e,t){return!e||!e.isConnected||aj(e)?!1:t==null||aj(t)}const oj="a[href], button, input, select, textarea, [tabindex]";function Qq(e){return!e||e.disabled||e.rendered===!1?!1:(e.tabIndex??0)>=0}function e8(e){if(!e||!e.overflowing||e.hasFocusable)return!1;const t=String(e.overflow??"").toLowerCase();return t==="auto"||t==="scroll"}function t8({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 Od(e){return e.ctrlKey||e.metaKey||e.altKey}const n8=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),r8=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),s8=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function Ib(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function a8(e){return Ib(e)==="BUTTON"?!0:(typeof e.role=="string"?e.role.trim().toLowerCase():"").split(/\s+/).includes("button")}function Ld(e){if(!e)return!1;if(e.isContentEditable)return!0;const t=Ib(e);return t==="TEXTAREA"?!0:t!=="INPUT"?!1:!n8.has(String(e.type??"text").toLowerCase())}function o8(e,t){if(!e)return!1;if(Ld(e))return!0;if(t!=null&&t.length===1&&t!==" "&&e.pointerFocused&&a8(e))return!1;if(r8.has(Ib(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(r=>s8.has(r))}function i8({key:e,modalOpen:t,sheetOpen:n}){return t?!(e==="?"&&n):!1}function l8({appModal:e,dialogDepth:t}){return e||t>0}function $M(e){return e?Array.from(e.querySelectorAll("*")).filter(t=>{if(t.matches(oj))return Qq({disabled:t.disabled,tabIndex:t.tabIndex,rendered:t.getClientRects().length>0});const n=t.scrollHeight>t.clientHeight;return n&&e8({overflowing:n,overflow:getComputedStyle(t).overflowY,hasFocusable:t.querySelector(oj)!=null})}):[]}function c8(e,t){const n=$M(e);if(!t||!e.contains(t)||n.includes(t))return n;const r=n.findIndex(s=>(t.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_FOLLOWING)!==0);return r===-1?[...n,t]:[...n.slice(0,r),t,...n.slice(r)]}function ft(e,t={}){const{focusRef:n,layer:r,popover:s}=t,o=s?"popover":"dialog",l=w.useRef(null),u=w.useRef(e);u.current=e;const d=w.useRef(null);d.current===null&&(d.current=()=>u.current());const h=d.current;return w.useEffect(()=>Jo.push(h,r,o),[h,r,o]),w.useEffect(()=>{var p;const f=document.activeElement;return(p=(n==null?void 0:n.current)??$M(l.current)[0])==null||p.focus(),()=>{Jq(f,document.activeElement)&&f.focus()}},[]),w.useEffect(()=>{const f=p=>{var N;if(p.key!=="Tab"||Od(p))return;const g=l.current;if(!g)return;const v=document.activeElement;if(!(v!=null&&g.contains(v))&&!Jo.isTop(h))return;const b=c8(g,v),x=t8({count:b.length,index:v?b.indexOf(v):-1,shiftKey:p.shiftKey});x.kind!=="allow"&&(p.preventDefault(),x.kind==="focus"&&((N=b[x.index])==null||N.focus()))};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[h]),l}function u8(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 $n(e){return e.toLocaleString()}const d8=60;function h8(e,t=d8){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 f8({agent:e,onClose:t}){var g;const n=w.useRef(null),r=ft(t,{focusRef:n}),s=e.context,o=e.usage,l=(s==null?void 0:s.currentContextTokens)??0,u=MM(e.contextWindow,e.model),d=Math.min(100,l/u*100),h=hn(e),f=e.provider==="codex"?o.inputTokens+o.outputTokens:o.inputTokens+o.outputTokens+o.cacheReadTokens+o.cacheCreateTokens,p=u8(e.provider);return a.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal ctx-modal",onClick:v=>v.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Context breakdown",children:[a.jsxs("header",{className:"ctx-modal-head",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"ctx-modal-title",children:["Context · ",e.label]}),a.jsx("div",{className:"ctx-modal-sub",children:p.subtitle})]}),a.jsx("button",{type:"button",ref:n,className:"glyph-btn ctx-modal-close",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),a.jsxs("section",{className:"ctx-window-row",children:[a.jsx("div",{className:"ctx-window-bar",role:"progressbar","aria-label":"Context window used","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(d),children:a.jsx("div",{className:"ctx-window-fill",style:{transform:`scaleX(${Math.min(100,Math.max(0,d))/100})`}})}),a.jsxs("div",{className:"ctx-window-meta",children:[a.jsxs("span",{className:"ctx-window-pct",children:[d.toFixed(1),"%"]}),a.jsxs("span",{children:[$n(l)," / ",$n(u)," tok (",p.windowScope,")"]})]})]}),a.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),a.jsxs("div",{className:"ctx-grid",children:[a.jsx(tr,{label:"input tokens",val:$n(o.inputTokens)}),a.jsx(tr,{label:"output tokens",val:$n(o.outputTokens)}),a.jsx(tr,{label:"cache reads",val:$n(o.cacheReadTokens)}),a.jsx(tr,{label:"cache writes",val:$n(o.cacheCreateTokens)}),a.jsx(tr,{label:"cumulative total",val:$n(f)}),a.jsx(tr,{label:"estimated cost",val:qe(h.total),accent:!0})]}),a.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),p.compositionCounted?a.jsxs("div",{className:"ctx-grid",children:[a.jsx(tr,{label:"user messages",val:$n((s==null?void 0:s.msgsUser)??0)}),a.jsx(tr,{label:"assistant messages",val:$n((s==null?void 0:s.msgsAssistant)??0)}),a.jsx(tr,{label:"tool uses",val:$n((s==null?void 0:s.toolUses)??0)}),a.jsx(tr,{label:"tool results",val:$n((s==null?void 0:s.toolResults)??0)}),a.jsx(tr,{label:"system-reminders",val:$n((s==null?void 0:s.systemReminders)??0)})]}):a.jsx("div",{className:"ctx-empty",children:p.compositionUncounted}),a.jsx("h3",{className:"ctx-section-title",children:p.memoryHeading}),(((g=s==null?void 0:s.memoryFiles)==null?void 0:g.length)??0)===0?a.jsx("div",{className:"ctx-empty",children:p.memoryEmpty}):a.jsx("ul",{className:"ctx-md-list",children:s.memoryFiles.map(v=>a.jsxs("li",{children:[a.jsx("span",{className:"ctx-md-path",title:v.path,children:h8(v.path)}),a.jsx("span",{className:"ctx-md-size",children:Sa(v.bytes)})]},v.path))})]})})}function tr({label:e,val:t,accent:n}){return a.jsxs("div",{className:`ctx-row${n?" accent":""}`,children:[a.jsx("span",{className:"ctx-row-label",children:e}),a.jsx("span",{className:"ctx-row-val",children:t})]})}function p8({currentContextTokens:e,modelId:t,contextWindow:n,size:r=26,onClick:s}){const o=MM(n,t),l=Math.min(1,e/o),u=r/2-3,d=r/2,h=2*Math.PI*u,f=h*l,p=l>.9?"var(--err)":l>.7?"var(--warn)":"var(--accent)";return a.jsx("button",{type:"button",className:"ctx-donut",onClick:g=>{g.stopPropagation(),s==null||s()},title:`context: ${e.toLocaleString()} / ${o.toLocaleString()} (${(l*100).toFixed(1)}%)`,"aria-label":`Context ${Math.round(l*100)}% of ${o.toLocaleString()} tokens — show breakdown`,children:a.jsxs("svg",{width:r,height:r,viewBox:`0 0 ${r} ${r}`,"aria-hidden":"true",children:[a.jsx("circle",{cx:d,cy:d,r:u,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),a.jsx("circle",{cx:d,cy:d,r:u,stroke:p,strokeWidth:"2.5",fill:"none",strokeDasharray:`${f} ${h-f}`,strokeDashoffset:h/4,strokeLinecap:"round",style:{transition:"var(--ctx-arc-transition)"}}),a.jsx("text",{x:d,y:d+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(l*100)})]})})}const ij=new Map;function IM(e){let t=ij.get(e);return t||(t={now:Date.now(),listeners:new Set,timer:null},ij.set(e,t)),t}function m8(e,t){const n=IM(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 g8(e){return IM(e).now}const lj=new Map,cj=new Map;function vi(e=1e3){let t=lj.get(e);t||(t=r=>m8(e,r),lj.set(e,t));let n=cj.get(e);return n||(n=()=>g8(e),cj.set(e,n)),w.useSyncExternalStore(t,n,n)}function Pd(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 y8="1",uj="agent-dag.schema",w8=["agent-dag.layout","agent-dag.viewport"];function et(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function Xe(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}function cs(e){if(!(typeof window>"u"))try{window.localStorage.removeItem(e)}catch{}}function Sl(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function v8(e,t=y8){let n=null;try{n=e.getItem(uj)}catch{return[]}if(n===t)return[];const r=[];if(n!==null)for(const s of w8)try{e.getItem(s)!==null&&(e.removeItem(s),r.push(s))}catch{}try{e.setItem(uj,t)}catch{}return r}const OM="agent-dag.recapsDismissed",dj=200;function x8(){const e=et(OM);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}let ci=new Set(x8());const px=new Set;let LM=0;function PM(e){return px.add(e),()=>{px.delete(e)}}function DM(e){ci=e,LM++;const t=Array.from(e);Xe(OM,JSON.stringify(t.length>dj?t.slice(-dj):t));for(const n of px)n()}function FM(e,t){return`${e}@${t}`}function b8(e){return ci.has(e)}function k8(e){if(ci.has(e))return;const t=new Set(ci);t.add(e),DM(t)}function N8(e){const t=new Set(ci);t.delete(e)||t.add(e),DM(t)}function j8(e){return w.useSyncExternalStore(PM,()=>e!=null&&ci.has(e),()=>!1)}function Ob(e){return`recap:${e}`}function S8(e){return e.startsWith("recap:")}function _8(){return w.useSyncExternalStore(PM,()=>LM,()=>0)}function E8(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 BM(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 qM(e){return e.live>0?`→ ${e.total} · ${e.live} live`:`→ ${e.total} · done`}function C8(e,t,n){const r=e.kind==="root"?e.waiting:null;if(r&&fr(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:BM(t),short:qM(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 mx(e){return e==="active"?"live":e==="done"?"done":"err"}const Dd={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"}},T8=Object.fromEntries(Object.entries(Dd).map(([e,t])=>[e,t.category])),A8=Object.fromEntries(Object.entries(Dd).map(([e,t])=>[e,t.emoji])),R8=Object.fromEntries(Object.entries(Dd).map(([e,t])=>[e,t.label])),M8=new Set(Object.entries(Dd).filter(([,e])=>e.shell).map(([e])=>e)),$8={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",...T8};function UM(e){return e.startsWith("mcp__")?"mcp":Ot($8,e)??"other"}const I8=/\btools\.exec_command\s*\(\s*\{[^{}]*?\bcmd\s*:\s*(["'`])((?:\\.|(?!\1)[^\\])*)\1/,O8=/\btools\.([A-Za-z_$][\w$]*)\s*\(/;function L8(e){if(typeof e!="string"||!e)return null;const t=I8.exec(e);if(t){const r=P8(t[2]);if(r.trim())return r}const n=O8.exec(e);return n?n[1]:null}function P8(e){return e.replace(/\\(["'`\\nrt])/g,(t,n)=>n==="n"?`
66
+ `:n==="r"?"\r":n==="t"?" ":n)}const D8={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:"📡",...A8};function hj(e){return e.startsWith("mcp__")?"🔌":Ot(D8,e)??"✨"}const F8={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 zM(e){return/^-(?:Command|c)$/i.test(e)||/^-[a-z]+c$/.test(e)}function WM(e){if(!e)return null;let t=e.trim();if(!t)return null;const n=t.match(/^(?:bash|sh|zsh|fish|powershell|pwsh)(?:\.exe)?((?:\s+-[A-Za-z]+)+)\s*["']([^"']+)["']/i);if(n&&n[1].trim().split(/\s+/).every(o=>zM(o)||/^-(?:NoProfile|NonInteractive)$/i.test(o)))return WM(n[2]);for(;;){const o=t.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!o)break;t=t.slice(o[0].length)}t=t.replace(/^sudo(?:\s+-\S+)*\s+/,""),t=t.replace(/^(?:time|nohup|xargs)\s+/,"");const r=t.match(/^([^\s|;&<>(]+)/);if(!r)return null;let s=r[1];return/^[A-Za-z0-9_][\w.+-]*$/.test(s.replace(/^.*[/\\]/,""))?(s=s.replace(/^.*[/\\]/,""),s=s.replace(/\.(exe|cmd|bat|ps1)$/i,""),s||null):null}function B8(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const t=e;if(typeof t.script=="string"){const n=L8(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(zM);if(r>=0&&r+1<n.length)return n[r+1]}return n.join(" ")}return typeof t.script=="string"?t.script:null}const q8=new Set(["Bash","PowerShell",...M8]);function U8(e,t){if(!q8.has(e))return null;const n=B8(t);if(!n)return null;const r=WM(n);return r?{emoji:Ot(F8,r)??"⚙️",label:r,category:"shell",detail:n}:null}const z8=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),W8={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:"🗄️"},H8={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 V8(e){const n=e.replace(/\\/g,"/").replace(/\/+$/,""),r=n.lastIndexOf("/");return r>=0?n.slice(r+1):n}function G8(e){const t=e.toLowerCase(),n=Ot(H8,t);if(n!==void 0)return n;if(t.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(t))return"🧪";const r=t.lastIndexOf(".");if(r>0&&r<t.length-1){const s=Ot(W8,t.slice(r+1));if(s!==void 0)return s}return"📄"}function K8(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 Y8(e,t){if(!z8.has(e))return null;const n=K8(e,t);if(!n)return null;const r=V8(n);return r?{emoji:e==="LS"?"📂":G8(r),label:r,category:"file",detail:n}:null}const X8={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 Lb(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 Z8(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 HM(e){return Ot(X8,e.toLowerCase())}function J8(e,t){const n=Lb(e);if(!n)return null;const{server:r,method:s}=n;if(!s)return null;const o=HM(r);return{emoji:(o==null?void 0:o.emoji)??"🔌",label:s,category:"mcp",detail:o?`${o.name} · ${s}`:`${r} · ${s}`}}function VM(e,t){return U8(e,t)??Y8(e,t)??J8(e)}function Q8(e,t){var n;return((n=VM(e,t))==null?void 0:n.label)??null}const eU=R8,fj=18;function xu(e){const t=[...e];return t.length<=fj?e:t.slice(0,fj-1).join("")+"…"}const dp=13,tU=6;function nU(e,t){const n=[...e];if(n.length<=dp)return e;const r=n.lastIndexOf("."),s=r>0?n.slice(r):[];return t==="file"&&s.length>1&&s.length<=tU?n.slice(0,dp-1-s.length).join("")+"…"+s.join(""):n.slice(0,dp-1).join("")+"…"}function Pb(e){const t=Lb(e);if(t){const r=HM(t.server);return r?{emoji:r.emoji,label:xu(r.name)}:{emoji:"🔌",label:xu(t.server),hue:Z8(t.server)}}const n=Ot(eU,e)??"";return n?{emoji:hj(e),label:xu(n)}:{emoji:hj(e),label:xu(e)}}function rU(e){let t=null,n="";for(const r of e){const s=Lb(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:Pb(n)}const gx=6e4,Qo=24,pj=gx/Qo,hp=132,Bu=14;function sU(e,t,n){const r=new Array(Qo).fill(0);let s=0;const o=g=>{const v=n-g;if(v<0||v>=gx)return;const k=Qo-1-Math.floor(v/pj);k>=0&&k<Qo&&(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)/(pj/1e3),d=e.filter(g=>n-g.startedAt>=0&&n-g.startedAt<gx).length,h=s-d,f=[d>0?`${d} tool ${d===1?"call":"calls"}`:"",h>0?`${h} ${h===1?"block":"blocks"} of thinking and writing`:""].filter(Boolean),p=s===0?"nothing in the last 60s":`${f.join(" · ")} in last 60s · peak ${u.toFixed(1)}/s`;return{counts:r,title:p}}const aU=2;function oU(e){return e===0?1.5:Math.max(1.5,Math.min(1,e/aU)*Bu)}function GM({kind:e}){return a.jsxs("svg",{className:"state-mark","data-kind":e,viewBox:"0 0 10 10",width:"10",height:"10","aria-hidden":"true",focusable:"false",children:[e==="live"&&a.jsx("circle",{cx:"5",cy:"5",r:"3.2",fill:"currentColor"}),e==="done"&&a.jsx("path",{d:"M2.2 5.3l1.9 1.9 3.8-4.4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),e==="err"&&a.jsx("path",{d:"M2.8 2.8l4.4 4.4M7.2 2.8l-4.4 4.4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",fill:"none"})]})}function Db(){return a.jsxs("svg",{className:"alert-mark",viewBox:"0 0 12 12",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[a.jsx("path",{d:"M6 1.4l4.7 8.3H1.3z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M6 4.6v2.4",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"}),a.jsx("circle",{cx:"6",cy:"8.35",r:"0.72",fill:"currentColor"})]})}function Fl(){return a.jsxs("svg",{className:"recap-glyph",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true",focusable:"false",children:[a.jsx("path",{d:"M3.3 3.3l5.4 5.4M8.7 3.3l-5.4 5.4",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",fill:"none"}),a.jsx("circle",{cx:"6",cy:"1.2",r:"1.05",fill:"currentColor"}),a.jsx("circle",{cx:"6",cy:"10.8",r:"1.05",fill:"currentColor"}),a.jsx("circle",{cx:"1.2",cy:"6",r:"1.05",fill:"currentColor"}),a.jsx("circle",{cx:"10.8",cy:"6",r:"1.05",fill:"currentColor"})]})}function iU({data:e,selected:t}){var N,S;const n=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":"",t?"selected":""].filter(Boolean).join(" "),r=e.tools.filter(_=>!_.endedAt).length,s=e.tools.filter(_=>_.ok===!1).length,o=sd(e.sessionId),l=((N=e.context)==null?void 0:N.currentContextTokens)??0,u=e.kind==="root"&&l>0,d=e.sessionTitle?e.cwd?`${e.cwd}
67
+ ${e.sessionTitle}`:e.sessionTitle:e.cwd,h=TM(e),f=h.length>0?`${e.model}
68
+ spend on this card also covers:
69
+ ${h.join(`
70
+ `)}`:e.model,p=$b(e.sessionName,e.sessionTitle),g=Pd(e),v=g?FM(e.sessionId,g.at):null,k=j8(v),b=g!=null&&!k,x=Tq(e);return a.jsxs("div",{className:n,style:{"--session-hue":o},children:[a.jsx("span",{className:"accent-stripe"}),a.jsx(Da,{type:"target",position:Ae.Left,style:{background:"transparent",border:"none"}}),a.jsxs("div",{className:"head",children:[a.jsxs("div",{className:"title",children:[a.jsx(dU,{state:e.state}),a.jsx("span",{className:"label",title:d,children:e.label}),e.synthetic&&a.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"}),g&&v&&a.jsx("button",{type:"button",className:"glyph-btn recap-pin","aria-label":"Claude Code's recap","aria-expanded":b,title:b?"Hide the recap":"Show Claude Code's recap",onClick:_=>{_.stopPropagation(),N8(v)},children:a.jsx(Fl,{})})]}),a.jsxs("div",{className:"head-right",children:[u&&e.onOpenContext&&a.jsx(p8,{currentContextTokens:l,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)}),a.jsxs("div",{className:"time",title:e.synthetic?`The deck joined this session after it began, so it has run at least this long — first seen ${new Date(e.startedAt).toLocaleTimeString()}`:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:[e.synthetic?"≥ ":"",a.jsx(uU,{start:e.startedAt,end:e.endedAt})]})]})]}),a.jsxs("div",{className:"sub",children:[e.kind==="root"?"session":"subagent",e.childCount>0&&a.jsxs("span",{className:"spawn-badge",title:qq(e.childCount),children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model?a.jsxs("span",{className:"model-chip","data-family":$d(e.model),title:f,children:[Js(e.model),h.length>0?` +${h.length}`:""]}):e.provider==="codex"?a.jsx("span",{className:"model-chip",title:"OpenAI Codex — no model reported yet",children:"Codex"}):null]}),e.kind==="root"&&p.face&&a.jsx("div",{className:"session-name",title:p.tooltip,children:p.face}),e.waiting&&a.jsx(hU,{waiting:e.waiting}),(()=>{const _=Mq(e);return _?a.jsxs("div",{className:"approval-blind-row",title:_.detail,children:[a.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),a.jsx("span",{className:"approval-blind-said",children:_.label})]}):null})(),(e.tools.length>0||(((S=e.outputs)==null?void 0:S.length)??0)>0)&&a.jsx(fU,{tools:e.tools,outputs:e.outputs}),a.jsxs("div",{className:"meta",children:[a.jsxs("span",{children:[a.jsx("b",{children:e.toolCount})," ",e.toolCount===1?"tool":"tools"]}),s>0&&a.jsxs("span",{className:"failed-meta",title:`${s} tool ${s===1?"call":"calls"} returned an error`,children:[a.jsx("b",{children:s})," err"]}),r>0&&a.jsxs("span",{className:"inflight-meta",children:[a.jsx("b",{children:r})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&a.jsxs("span",{className:"tokens-meta",title:`in:${e.usage.inputTokens} out:${e.usage.outputTokens} cache-r:${e.usage.cacheReadTokens} cache-c:${e.usage.cacheCreateTokens}${(e.usage.reasoningOutputTokens??0)>0?` reasoning:${e.usage.reasoningOutputTokens}`:""}`,children:[a.jsx("b",{children:ot(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),(x==null?void 0:x.kind)==="unpriced"&&a.jsx("span",{className:"cost-unpriced",title:x.tt,children:hs}),(x==null?void 0:x.kind)==="spent"&&a.jsx("span",{className:"cost-meta",title:x.tt,children:a.jsxs("b",{children:[qe(x.total),x.floor?"+":""]})})]}),a.jsx(cU,{data:e,title:e.kind==="root"?p.face:void 0}),a.jsx(Da,{type:"source",position:Ae.Right,style:{background:"transparent",border:"none"}})]})}const lU=w.memo(iU);function cU({data:e,title:t}){const n=e.kind==="root"&&fr(e.waiting),r=C8(e,e.branch,{sayWaiting:Mb,describeCall:s=>({name:Pb(s.name).label,subject:Q8(s.name,s.input)})});return a.jsxs("div",{className:"lod-face","data-kind":e.kind,"data-alarm":n?"":void 0,"data-signal":r?"":void 0,"aria-hidden":!0,children:[a.jsxs("div",{className:"lod-id",children:[a.jsx(GM,{kind:mx(e.state)}),a.jsx("span",{className:"lod-name",children:e.label}),r&&a.jsx("span",{className:"lod-inline","data-tone":r.tone,children:r.short}),n&&a.jsx(Db,{})]}),t&&a.jsx("div",{className:"lod-title",children:t}),r&&a.jsxs("div",{className:"lod-signal","data-tone":r.tone,children:[a.jsx("span",{className:"lod-long",children:r.long}),a.jsx("span",{className:"lod-short",children:r.short})]})]})}function uU({start:e,end:t}){const n=vi(1e3);return a.jsx(a.Fragment,{children:li(e,t,n)})}function dU({state:e}){return a.jsx("span",{className:`state-pill state-${e}`,children:oi(e)})}function hU({waiting:e}){const t=vi(1e3),n=fr(e),r=ii(e);return a.jsxs("div",{className:n?"waiting-row permission":"waiting-row idle",title:`${r}
71
+ Blocked for ${li(e.since,void 0,t)} — the answer goes in the terminal, not here.`,children:[n?a.jsx("span",{className:"ap-pulse","aria-hidden":!0}):a.jsx("span",{className:"waiting-dot","aria-hidden":!0}),a.jsx("span",{className:"waiting-said",children:Mb(e)}),a.jsx("b",{children:li(e.since,void 0,t)})]})}function fU({tools:e,outputs:t}){const n=vi(1e3),{counts:r,title:s}=sU(e,t,n),o=hp/Qo;return a.jsxs("div",{className:"tool-spark-row",title:s,children:[a.jsx("svg",{className:"tool-spark",width:hp,height:Bu,viewBox:`0 0 ${hp} ${Bu}`,"aria-hidden":!0,children:r.map((l,u)=>{const d=oU(l),h=u===Qo-1&&l>0,p=`tool-spark-bar${l>0?" active":""}${h?" latest":""}`;return a.jsx("rect",{x:u*o+.4,y:Bu-d,width:Math.max(.5,o-1),height:d,rx:.8,className:p},h?`landed:${l}`:u)})}),a.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function pU({enableAutoFitAndRefit:e}){return a.jsxs("div",{className:"autofit-chip",children:[a.jsx("span",{className:"autofit-state",title:"New sessions are not brought into view while you are moving it yourself",children:"Auto-fit off"}),a.jsx("button",{type:"button",className:"autofit-resume",onClick:e,title:"Bring new sessions into view again","aria-label":"Resume auto-fit",children:"Resume"})]})}function ad(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const mj=99;function mU(e){const t=Math.max(0,Math.floor(e));return t>mj?`${mj}+`:String(t)}const gU="Pause the canvas";function yU(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 — ${ad(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)":`${ad(e.held)} arrived while paused and will be applied in order when you resume (Space)`}function wU(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 KM="paused · full",vU=(e,t)=>t>0?KM:e>0?`paused · ${mU(e)}`:"paused";function xU(e){const t=Math.max(0,Math.floor(e.dropped??0));return e.connected?e.paused?{tone:"paused",resting:!1,label:vU(e.held,t),widest:KM,title:t>0?`Connected — the pause is full at ${ad(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up (Space)`:e.held>0?`Connected — ${ad(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 bU=e=>e.transform[2]>=e.maxZoom,kU=e=>e.transform[2]<=e.minZoom;function NU({autoFitDisabled:e,enableAutoFitAndRefit:t,paused:n,pauseGate:r,togglePause:s,handleRelayout:o,requestClear:l,setKeyHelpOpen:u}){const d=mi(),h=Ye(bU),f=Ye(kU);return a.jsxs(Q6,{showInteractive:!1,showFitView:!1,showZoom:!1,children:[a.jsx(In,{onClick:()=>{h||d.zoomIn()},title:"Zoom in","aria-label":"Zoom in","aria-disabled":h||void 0,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M12 5v14M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(In,{onClick:()=>{f||d.zoomOut()},title:"Zoom out","aria-label":"Zoom out","aria-disabled":f||void 0,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(In,{onClick:t,title:e?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view","data-nudge":e?"":void 0,children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),a.jsx(In,{"data-group-start":"",onClick:s,title:yU({paused:n,held:r.size,dropped:r.dropped}),"aria-label":gU,"aria-pressed":n,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M9 5.5v13M15 5.5v13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(In,{onClick:o,title:"Auto-arrange — clear pins (R)","aria-label":"Re-arrange the canvas",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("rect",{x:"8.5",y:"2",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("rect",{x:"1.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("rect",{x:"15.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("path",{d:"M12 7v6.5M5 17v-3.5h14V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),a.jsx(In,{"data-group-start":"","data-danger":"",onClick:()=>l("button"),title:"Clear the canvas and the server's event log — asks first (C)","aria-label":"Clear the canvas",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("path",{d:"M4 6.2h16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),a.jsx("path",{d:"M9 6.2V4.4a1.6 1.6 0 0 1 1.6-1.6h2.8a1.6 1.6 0 0 1 1.6 1.6v1.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M17.4 6.4 16.7 20a2 2 0 0 1-2 1.9H9.3a2 2 0 0 1-2-1.9L6.6 6.4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M10.3 10.6v6.8M13.7 10.6v6.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),a.jsx(In,{"data-group-start":"",onClick:()=>u(p=>!p),title:"Keyboard shortcuts (?)","aria-label":"Open the keyboard shortcuts","aria-haspopup":"dialog",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("path",{d:"M8.6 8.4a3.5 3.5 0 1 1 4.6 3.35c-.85.3-1.2 1-1.2 1.85v1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M12 18.4v.2",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",fill:"none"})]})})]})}const $a=148,gj=6e3,jU=16e3,YM=46,Ys=34;function SU(e,t,n=$a){let r=-Math.round(t()*n);if(Math.abs(r-e)<Ys){const s=e-Ys>=-n?-Ys:Ys;r=Math.max(-n,Math.min(0,Math.round(e+s)))}return{to:r,ms:Math.round(Math.abs(r-e)*YM)}}function _U(e){return Math.round(gj+e()*(jU-gj))}const yj=[{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 EU(e){const t=yj.reduce((r,s)=>r+s.weight,0);let n=e()*t;for(const r of yj)if(n-=r.weight,n<0)return r.kind;return"stroll"}const CU=720,TU=260,AU=620,RU=220,wj=520,XM=1600,vj=7e3,MU=15e3,xj=6e3,$U=14e3;function Ro(e,t,n=$a){let r=-Math.round(t()*n);if(Math.abs(r-e)<Ys){const s=e-Ys>=-n?-Ys:Ys;r=Math.max(-n,Math.min(0,Math.round(e+s)))}return r}const Ct=(e,t)=>Math.round(Math.abs(t-e)*YM),IU=120,bu=0;function OU(e,t){const n=r=>({kind:"litter",at:t,...r});return[{x:t,prop:n({}),act:"walk",ms:Ct(e,t)},{x:t,prop:n({}),act:"stoop",ms:CU},{x:bu,prop:n({held:!0}),act:"carry",ms:Ct(t,bu)},{x:bu,prop:n({held:!0}),act:"windup",ms:TU},{x:bu,prop:n({held:!0,leaving:!0}),act:"toss",ms:AU}]}function LU(e,t){const n=t>e?1:-1,r=t-n*Math.min(15,Math.abs(t-e)),s=(o={})=>({kind:"ball",at:t,...o});return[{x:r,prop:s(),act:"walk",ms:Ct(e,r)},{x:r,prop:s(),act:"windup",ms:RU,facing:n>0?"right":"left"},{x:r,prop:s({leaving:!0}),act:"kick",ms:wj,facing:n>0?"right":"left"},{x:r,prop:s({leaving:!0}),act:"stand",ms:XM-wj}]}const ZM=640;function PU(e,t,n){const r=Math.max(-70,Math.min(-20,t)),s={x:r,prop:null,facing:"left"};return[{x:r,prop:null,act:"walk",ms:Ct(e,r)},{...s,act:"sit",ms:600},{...s,act:"cast",ms:900},{...s,act:"fish",ms:6e3+Math.round(n()*4e3)},{...s,act:"reel",ms:1200},{...s,act:"stow",ms:500},{...s,act:"stand",ms:400},{x:0,prop:null,act:"walk",ms:Ct(r,0)}]}function DU(e,t,n){const r=Math.max(-110,Math.min(-30,t)),s={x:r,prop:null};return[{...s,act:"walk",ms:Ct(e,r)},{...s,act:"skip-ready",ms:500},{...s,act:"skip",ms:ZM*(6+Math.floor(n()*5))},{...s,act:"skip-rest",ms:600},{...s,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:Ct(r,0)}]}function FU(e,t,n){return[{x:t,prop:null,act:"walk",ms:Ct(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(xj+n()*($U-xj))},{x:t,prop:null,act:"stand",ms:400}]}function BU(e,t,n){t=Math.max(-110,Math.min(0,t));const r=()=>({kind:"scope",at:t,held:!0});return[{x:t,prop:null,act:"walk",ms:Ct(e,t)},{x:t,prop:r(),act:"watch",ms:Math.round(vj+n()*(MU-vj))},{x:t,prop:r(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function fp(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 qU=1500,UU=e=>Math.round(1e3*Math.sqrt(2*e/qU)),zU=115,WU=e=>Math.round(e/zU*1e3),HU=620,VU=200,GU=760,KU=600,YU=240;function XU(e,t,n){const s=-(t.ledgeSpan??$a),o=UU(t.ledgeH),l=WU(t.ledgeH),u=n(),d=n(),h=-Math.round(u*t.floorSpan),f=-Math.round(d*t.floorSpan);return[{x:s,act:"walk",prop:null,ms:Ct(e,s)},{x:s,act:"peer",prop:null,ms:HU},{x:s,act:"fall",prop:null,ms:o,place:"floor"},{x:s,act:"land",prop:null,ms:VU,place:"floor"},{x:h,act:"walk",prop:null,ms:Ct(s,h),place:"floor",floorFrac:u},{x:f,act:"walk",prop:null,ms:Ct(h,f),place:"floor",floorFrac:d},{x:s,act:"walk",prop:null,ms:Ct(f,s),place:"floor"},{x:s,act:"lasso",prop:null,ms:GU,place:"floor"},{x:s,act:"rope-throw",prop:null,ms:KU,place:"floor"},{x:s,act:"rope-catch",prop:null,ms:YU,place:"floor"},{x:s,act:"climb",prop:null,ms:l},{x:s,act:"pull-up",prop:null,ms:480}]}function ZU(e,t,n){const r=(n==null?void 0:n.ledgeSpan)??$a;switch(EU(t)){case"tidy":return OU(e,Ro(e,t,r));case"kick":return LU(e,Ro(e,t,r));case"sit":return FU(e,Ro(e,t,r),t);case"watch":return BU(e,Ro(e,t,r),t);case"fish":return PU(e,Ro(e,t,r),t);case"skip":return DU(e,Ro(e,t,r),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return XU(e,n,t)}}const o=SU(e,t,r);return[{x:o.to,prop:null,act:"walk",ms:o.ms}]}const JU=420;function QU(e,t,n){const r=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(JU,Math.max(0,r))}const ez=260,tz=200;function nz(e,t,n){const r=(f,p=Ct(e,f))=>({x:f,prop:null,act:"walk",ms:p,place:"floor"});if(!n||n.height<=0)return[r(t)];const s=Math.min(e,t);if(Math.max(e,t)<=n.left||s>=n.right)return[r(t)];const l=t>e,u=l?n.left:n.right,d=l?n.right:n.left,h={place:"floor",riser:n.height,prop:null};return[r(u,Ct(e,u)),{...h,x:u,act:"mount",ms:ez},{...h,x:d,act:"walk",ms:Ct(u,d)},{x:d,prop:null,act:"dismount",ms:tz,place:"floor"},{x:t,prop:null,act:"walk",ms:Ct(d,t),place:"floor"}]}const JM=["bob","sway","groove"],bj=9e3,rz=16e3,QM=1e3,sz=.08;function az(e,t){const n=JM.filter(o=>o!==e),r=n[Math.min(n.length-1,Math.floor(t()*n.length))],s=(t()*2-1)*sz;return{dance:r,beatMs:Math.round(QM*(1+s))}}function oz(e){return Math.round(bj+e()*(rz-bj))}const e$=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],kj=18,iz=e$.length,t$=new Set(["a","c","p"]);function Fd(e=e$){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 lz=[".xx.","xxxx",".xx."],cz=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],uz=["...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."],pp={litter:lz,ball:cz,scope:uz},dz=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],hz=3,fz=-1,yx=11,Nj=9,wx="https://www.youtube-nocookie.com";function pz(e,t,n){const r=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${wx}/embed/${n?encodeURIComponent(n):"live_stream"}?${r.toString()}`}function Mo(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function mz(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const gz=[1,3],yz=[0,2],wz=[2,5,100,101,150];function vz(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:gz.includes(s)?{kind:"playing",playing:!0}:yz.includes(s)?{kind:"playing",playing:!1}:null}return null}const xz="modulepreload",bz=function(e){return"/"+e},jj={},Fb=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.map(f=>Promise.resolve(f).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),d=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));s=l(n.map(h=>{if(h=bz(h),h in jj)return;jj[h]=!0;const f=h.endsWith(".css"),p=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${p}`))return;const g=document.createElement("link");if(g.rel=f?"stylesheet":xz,f||(g.as="script"),g.crossOrigin="",g.href=h,d&&g.setAttribute("nonce",d),document.head.appendChild(g),f)return new Promise((v,k)=>{g.addEventListener("load",v),g.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(l){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=l,window.dispatchEvent(u),!u.defaultPrevented)throw l}return s.then(l=>{for(const u of l||[])u.status==="rejected"&&o(u.reason);return t().catch(o)})},kz={"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 Nz({fetchImpl:e,volume:t,muted:n,source:r,playRequest:s,customStation:o,onAvailabilityChange:l}){const[u,d]=w.useState(null),[h,f]=w.useState(!1),[p,g]=w.useState(!1),[v,k]=w.useState(!1),b=w.useRef(s),x=w.useRef(null),N=w.useRef(null),S=w.useRef(null),_=w.useCallback(()=>{var D;(D=N.current)==null||D.destroy(),N.current=null;const P=x.current;P&&(P.pause(),P.removeAttribute("src"),P.load(),x.current=null)},[]),E=w.useCallback(P=>{var D,O;(O=(D=S.current)==null?void 0:D.contentWindow)==null||O.postMessage(P,wx)},[]),T=w.useRef(t);T.current=t;const A=w.useRef(n);A.current=n;const R=w.useCallback((P,D,O)=>{_();const L=new Audio;L.preload="none",L.volume=T.current/100,L.muted=A.current,x.current=L,g(!0),k(!0);const z=()=>x.current===L,M=()=>{_(),g(!1),k(!1)},$=()=>{z()&&(M(),f(!0),l==null||l(O,!0))},q=X=>{if(z()){if(X instanceof DOMException&&X.name==="NotAllowedError"){M();return}$()}};L.addEventListener("playing",()=>{z()&&(k(!0),l==null||l(O,!1))}),L.addEventListener("ended",()=>{z()&&M()}),L.addEventListener("error",$,{once:!0}),D&&!L.canPlayType("application/vnd.apple.mpegurl")?Fb(async()=>{const{default:X}=await import("./hls-BFpXDghs.js");return{default:X}},[]).then(({default:X})=>{if(!z())return;if(!X.isSupported()){$();return}const H=new X;N.current=H,H.on(X.Events.ERROR,(I,W)=>{W.fatal&&$()}),H.on(X.Events.MEDIA_ATTACHED,()=>H.loadSource(P)),H.on(X.Events.MANIFEST_PARSED,()=>{L.play().catch(q)}),H.attachMedia(L)},$):(L.src=P,L.play().catch(q))},[l,_]);return w.useEffect(()=>{p&&(E(Mo("setVolume",[t])),E(Mo(n?"mute":"unMute")),x.current&&(x.current.volume=t/100,x.current.muted=n))},[t,n,p,E]),w.useEffect(()=>{let P=!0;const D=e??fetch,O=b.current!==s;b.current=s,d(null),f(!1),g(O),k(O),_();const L=o&&Fa(o.id)===r?jb(o.url):null;if(L)return L.kind==="direct-audio"?(d({live:!0,channel:"",audio:L.url,hls:L.format==="hls"}),l==null||l(r,!1),O&&R(L.url,L.format==="hls",r),()=>{P=!1}):(D(`/api/fm-station?url=${encodeURIComponent(L.url)}`).then($=>$.ok?$.json():null).then($=>{P&&($!=null&&$.channel||$!=null&&$.video?(d({live:!0,channel:$.channel??"",video:$.video??void 0}),l==null||l(r,!1)):(f(!0),l==null||l(r,!0)))}).catch(()=>{P&&(f(!0),l==null||l(r,!0))}),()=>{P=!1});if(ai(r))return f(!0),l==null||l(r,!0),()=>{P=!1};const z=r,M=kz[z];if(M)D(M).then($=>$.ok?$.json():null).then($=>{P&&($!=null&&$.video&&d({live:!0,channel:"",video:$.video}),l==null||l(r,!($!=null&&$.video)))}).catch(()=>{P&&(l==null||l(r,!0))});else if(z!=="claude-fm"){const $=z.replace("lofi-","");D(`/api/lofi-girl?station=${encodeURIComponent($)}`).then(q=>q.ok?q.json():null).then(q=>{P&&(q!=null&&q.video&&d({live:!0,channel:"",video:q.video}),l==null||l(r,!(q!=null&&q.video)))}).catch(()=>{P&&(l==null||l(r,!0))})}else D("/api/claude-fm").then($=>$.ok?$.json():null).then($=>{if(!P)return;const q=!!($!=null&&$.live&&($!=null&&$.channel));q&&d({live:!0,channel:$.channel}),l==null||l(r,!q)}).catch(()=>{P&&(l==null||l(r,!0))});return()=>{P=!1}},[o==null?void 0:o.id,o==null?void 0:o.url,e,l,s,r,R,_]),w.useEffect(()=>()=>_(),[_]),w.useEffect(()=>{if(!p)return;const P=D=>{var L;if(D.origin!==wx||D.source!==((L=S.current)==null?void 0:L.contentWindow))return;const O=vz(D.data);if(O){if(O.kind==="ready"){E(Mo("setVolume",[T.current])),E(Mo(n?"mute":"unMute")),E(Mo("playVideo"));return}if(O.kind==="playing"){k(O.playing);return}wz.includes(O.code)&&(g(!1),k(!1),f(!0),l==null||l(r,!0))}};return window.addEventListener("message",P),()=>window.removeEventListener("message",P)},[p,n,l,E,r]),{probe:u,dead:h,armed:p,playing:v,frame:S,say:E,press:()=>{if(!u)return;if(u.audio){if(p){_(),g(!1),k(!1);return}R(u.audio,u.hls===!0,r);return}if(!p){g(!0),k(!0);return}const P=!v;k(P),E(Mo(P?"playVideo":"pauseVideo")),P||g(!1)}}}function Sj(e){let t=null,n=null,r=0,s=0,o=!1;const l=()=>{t!==null&&clearTimeout(t),t=null},u=()=>{o||e.hidden||!n||t!==null||(s=performance.now(),t=setTimeout(()=>{t=null;const h=n;n=null,h==null||h()},r))},d=()=>{e.hidden&&t!==null?(r=Math.max(0,r-(performance.now()-s)),l()):e.hidden||u()};return e.addEventListener("visibilitychange",d),{schedule(h,f){o||(l(),n=h,r=Math.max(0,f),u())},dispose(){o=!0,l(),n=null,e.removeEventListener("visibilitychange",d)}}}function jz(e,t,n){const[r,s]=w.useState(0),[o,l]=w.useState(0),[u,d]=w.useState(null),[h,f]=w.useState(null),[p,g]=w.useState({x:0,drop:0}),[v,k]=w.useState("ledge"),[b,x]=w.useState("left"),[N,S]=w.useState(0),_=w.useRef(null),[E,T]=w.useState(()=>document.hidden);w.useEffect(()=>{const L=new Set,z=()=>{var M;if(document.hidden){for(const $ of((M=_.current)==null?void 0:M.getAnimations({subtree:!0}))??[])if($.playState==="running"||$.pending){const q=$.currentTime;$.pause(),q!==null&&($.currentTime=q),L.add($)}}else{for(const $ of L)$.playState==="paused"&&$.play();L.clear()}T(document.hidden)};return z(),document.addEventListener("visibilitychange",z),()=>document.removeEventListener("visibilitychange",z)},[e,t]);const[A,R]=w.useState(null),[B,P]=w.useState(QM),[D,O]=w.useState(()=>{var L;return((L=window.matchMedia)==null?void 0:L.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});return w.useEffect(()=>{var M;const L=(M=window.matchMedia)==null?void 0:M.call(window,"(prefers-reduced-motion: reduce)");if(!L)return;const z=()=>O(L.matches);return z(),L.addEventListener("change",z),()=>L.removeEventListener("change",z)},[]),w.useEffect(()=>{var K;if(!e||t||D)return;const L=Sj(document);let z=0;s(Z=>z=Z);let M=null,$=0,q=0;const X=Z=>{var ae,pe;const[ee,...re]=Z;if(!ee){M=null,d(null),f(null),J();return}d(ee.act),f(ee.prop),k(ee.place??"ledge"),S(ee.riser??0);const ue=z,me=F(ee);if(ee.act==="kick"){const xe=(pe=(ae=_.current)==null?void 0:ae.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:pe.getBoundingClientRect();xe&&g({x:QU(xe.x,fp(ee,ue,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-xe.y+24)})}q=ee.act==="walk"?Math.max(Ct(ue,me),IU):ee.ms,ee.act==="carry"&&(q=Ct(ue,me)),l(q),x(xe=>fp({...ee,x:me},ue,xe)),s(me),z=me,M=ee,$=Date.now(),L.schedule(()=>X(re),q)},H=()=>{const Z=_.current,ee=Z==null?void 0:Z.querySelector(".fm-sprite"),re=Z==null?void 0:Z.parentElement;if(!Z||!ee||!re)return null;const ue=Z.getBoundingClientRect(),me=re.getBoundingClientRect(),ae=me.right-ue.right,pe=me.width-ae*2-ee.offsetWidth;return pe>0?pe:null},I=()=>{const Z=_.current,ee=Z==null?void 0:Z.querySelector(".fm-walker"),re=H();if(!Z||!ee||re==null)return;const ue=Z.getBoundingClientRect().bottom-ee.getBoundingClientRect().bottom;if(ue>0)return{ledgeH:ue,floorSpan:re}},W=()=>{const Z=_.current,ee=document.querySelector(".autofit-chip");if(!Z||!ee)return null;const re=Z.getBoundingClientRect(),ue=ee.getBoundingClientRect();return ue.width<=0||ue.height<=0?null:{left:ue.left-re.right,right:ue.right-re.right,height:ue.height}},F=Z=>{const ee=(Z.place??"ledge")==="floor",re=ee?H()??$a:$a,ue=ee&&Z.floorFrac!=null?-Math.round(Z.floorFrac*re):Z.x;return Math.max(-re,Math.min(0,ue))},Y=()=>{if(!M)return;const Z=F(M);Z!==z&&(l(Math.max(0,$+q-Date.now())),x(ee=>fp({...M,x:Z},z,ee)),s(Z),z=Z)},J=()=>{L.schedule(()=>{const Z=ZU(z,Math.random,I()),ee=Z.some(me=>me.place==="floor")?W():null;let re=z;const ue=Z.flatMap(me=>{const ae=re;if(re=me.x,!(me.place==="floor"&&me.act==="walk"))return[me];const pe=nz(ae,me.x,ee),xe=pe.length-1;return me.floorFrac==null?pe:pe.map((se,ve)=>ve===xe?{...se,floorFrac:me.floorFrac}:se)});X(ue)},_U(Math.random))},V=(K=_.current)==null?void 0:K.parentElement,G=typeof ResizeObserver>"u"?null:new ResizeObserver(Y);return V&&G&&G.observe(V),J(),()=>{L.dispose(),G==null||G.disconnect(),k("ledge"),s(Z=>Math.max(-$a,Math.min(0,Z))),l(0),d(null),f(null),S(0)}},[e,t,D]),w.useEffect(()=>{if(!n||D){R(null);return}const L=Sj(document),z=M=>{const $=az(M,Math.random);R($.dance),P($.beatMs),L.schedule(()=>z($.dance),oz(Math.random))};return z(null),()=>L.dispose()},[n,D]),{scene:_,suspended:E,x:r,walkMs:o,act:u,prop:h,ballFlight:p,place:v,facing:b,riser:N,dance:A,beatMs:B}}const mp={e:"fm-eye",s:"fm-shade",p:"fm-pad"},od=Fd().filter(e=>!t$.has(e.cell)),Sz=Fd().filter(e=>t$.has(e.cell)),_j=od.filter(e=>e.cell==="e"),_z=Fd(dz),Ez=od.filter(e=>e.y<yx&&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),Cz={left:od.filter(e=>e.y>=yx&&e.x<Nj),right:od.filter(e=>e.y>=yx&&e.x>=Nj)},Tz=w.memo(function({act:t,facing:n}){return a.jsxs("svg",{viewBox:`0 0 ${kj} ${iz}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:Sz.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:mp[r.cell]},`g${r.y}-${r.x}`))})}),a.jsxs("g",{className:"fm-body",children:[_j.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:"var(--accent)"},`eye-bed-${r.x}`)),Ez.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:mp[r.cell]},`b${r.y}-${r.x}`)),a.jsxs("g",{className:"fm-arms",children:[a.jsx("rect",{x:4,y:8,width:2,height:2}),a.jsx("rect",{x:12,y:8,width:1,height:2}),a.jsx("rect",{x:13,y:8,width:1,height:2,className:"fm-shade"})]}),_j.map(r=>a.jsx("rect",{x:r.x-(r.x>=kj/2?1:0)+(n==="right"?1:0),y:r.y,width:r.w,height:1,className:"fm-eye"},`eye-${r.x}`))]}),a.jsx("g",{className:"fm-hat",children:_z.map(r=>a.jsx("rect",{x:hz+r.x,y:fz+r.y,width:r.w,height:1,className:r.cell==="k"?"fm-hatband":void 0},`h${r.y}-${r.x}`))}),(t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up")&&a.jsxs("g",{className:"fm-grip",children:[a.jsx("path",{className:"fm-grip-left",d:"M5 9H4V4H7V3H9V5H6V9Z"}),a.jsx("path",{className:"fm-grip-right",d:"M12 9H14V6H11V5H9V7H12Z"})]}),(t==="land"||t==="dismount")&&a.jsxs("g",{className:"fm-crouch-legs",children:[a.jsx("path",{d:"M6 11H8V13H6Z"}),a.jsx("path",{d:"M10 11H12V13H10Z"})]}),["sit","cast","fish","reel","stow"].includes(t)&&a.jsxs("g",{className:"fm-seated-legs",children:[a.jsx("path",{className:"fm-seated-far",d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),a.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(r=>a.jsx("g",{className:"fm-leg","data-side":r,children:Cz[r].map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:mp[s.cell]},`${r}${s.y}-${s.x}`))},r))]})}),Az={"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 Rz(e,t){return t&&Fa(t.id)===e?t.name:ai(e)?"Custom FM":Az[e]}function gp(e,t){var r;const n=((r=e[0])==null?void 0:r.length)??0;return a.jsx("svg",{viewBox:`0 0 ${n} ${e.length}`,shapeRendering:"crispEdges","aria-hidden":!0,children:Fd(e).map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,fill:s.cell==="s"?"var(--fm-prop-shadow, var(--bg))":s.cell==="l"?"var(--fm-prop-light, var(--text))":s.cell==="a"?"var(--accent)":void 0},`${t}${s.y}-${s.x}`))})}const Ej={litter:gp(pp.litter,"litter"),ball:gp(pp.ball,"ball"),scope:gp(pp.scope,"scope")};function Mz(e){try{return new URL(e).host}catch{return"the station's server"}}const $z=w.memo(function({fetchImpl:t,volume:n,muted:r=!1,source:s="claude-fm",playRequest:o=0,customStation:l,onAvailabilityChange:u}){const{probe:d,dead:h,armed:f,playing:p,frame:g,say:v,press:k}=Nz({fetchImpl:t,volume:n,muted:r,source:s,playRequest:o,customStation:l,onAvailabilityChange:u}),{scene:b,suspended:x,x:N,walkMs:S,act:_,prop:E,ballFlight:T,place:A,facing:R,riser:B,dance:P,beatMs:D}=jz(d,h,p);if(!d||h)return null;const O=Rz(s,l),L=d.audio?Mz(d.audio):"YouTube";return a.jsxs("div",{ref:b,className:"fm","data-suspended":x?"":void 0,"data-place":A,style:{"--fm-beat":`${D}ms`},children:[E&&!E.held&&a.jsx("div",{className:"fm-prop","data-prop":E.kind,"data-leaving":E.leaving?"":void 0,style:{"--fm-prop-x":`${E.at}px`,"--fm-roll-to":`${T.x}px`,"--fm-ball-drop":`${T.drop}px`,"--fm-ball-flight-ms":`${XM}ms`,"--fm-ball-turn":R==="right"?"1080deg":"-1080deg"},children:Ej[E.kind]}),(_==="lasso"||_==="rope-throw"||_==="rope-catch"||_==="climb"||_==="pull-up")&&a.jsxs("div",{className:"fm-rope","data-act":_,style:{"--fm-rope-x":`${N}px`,"--fm-rope-ms":`${S}ms`},children:[a.jsx("div",{className:"fm-rope-line"}),a.jsxs("svg",{className:"fm-rope-hook",viewBox:"0 0 9 9",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("path",{d:"M4 8V3H3V1H1V3H0V5H2V4H3V6H5V4H6V5H8V3H7V1H5V3H4"}),a.jsx("rect",{className:"fm-rope-knot",x:"3",y:"6",width:"3",height:"2"})]})]}),a.jsxs("div",{className:"fm-walker","data-act":_??void 0,"data-place":A,"data-facing":R,style:{"--fm-x":`${N}px`,"--fm-walk-ms":`${S}ms`,"--fm-riser":`${B}px`,"--fm-skip-beat":`${ZM}ms`},children:[(E==null?void 0:E.held)&&a.jsx("div",{className:"fm-held","data-prop":E.kind,"data-toss":E.leaving?"":void 0,children:Ej[E.kind]}),["cast","fish","reel","stow"].includes(_)&&a.jsxs("svg",{className:"fm-fishing",viewBox:"0 0 24 32",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsxs("g",{children:[a.jsx("path",{d:"M24 11H22V9H20V7H18V5H16V3H13V2H8"}),a.jsx("rect",{className:"fm-fishing-grip",x:"21",y:"9",width:"3",height:"3"})]}),a.jsxs("g",{className:"fm-fishing-line",children:[a.jsx("path",{d:"M8 2V26"}),a.jsxs("g",{className:"fm-float",children:[a.jsx("rect",{x:"7",y:"25",width:"3",height:"2"}),a.jsx("rect",{x:"8",y:"24",width:"1",height:"1"})]})]}),a.jsx("path",{className:"fm-ripple",d:"M3 28H6M10 28H14M5 30H12"})]}),["skip-ready","skip","skip-rest"].includes(_)&&a.jsxs("svg",{className:"fm-skipping-rope",viewBox:"0 0 26 26",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("path",{className:"fm-skip-back",d:"M5 18H3V8H5V5H8V2H18V5H21V8H23V18H21"}),a.jsx("path",{className:"fm-skip-forward",d:"M5 18H3V14H5V11H8V9H18V11H21V14H23V18H21"}),a.jsx("path",{className:"fm-skip-front",d:"M5 18H3V21H5V23H8V25H18V23H21V21H23V18H21"}),a.jsx("path",{className:"fm-skip-return",d:"M5 18H3V19H8V20H18V19H23V18H21"}),a.jsx("path",{className:"fm-skip-handles",d:"M5 17V19M21 17V19"})]}),a.jsx("button",{type:"button",className:"fm-sprite","data-playing":p?"":void 0,"data-dance":p?P??JM[0]:void 0,onClick:k,title:p?`Stop ${O}`:`Play ${O} — streams from ${L}`,"aria-label":p?`Stop ${O}`:`Play ${O}`,children:a.jsx(Tz,{act:_,facing:R})})]}),f&&!d.audio&&(d.channel||d.video)&&a.jsx("iframe",{ref:g,className:"fm-frame",title:O,src:pz(d.channel,window.location.origin,d.video),onLoad:()=>v(mz()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})]})});function n$(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 id(e){return n$(Math.floor(e/1e3))}function Bd(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 Iz(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function ld(e,t,n){const r=new Date(e),s=id(t-e);return{label:Iz(r,new Date(t))?s:`${s} · ${r.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:r.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function Oz({data:e}){const t=vi(3e4),n=ld(e.recap.at,t);return a.jsxs("div",{className:"recap-note",role:"note","aria-label":"Claude Code's recap",style:{"--session-hue":e.hue},children:[a.jsxs("div",{className:"recap-note-head",children:[a.jsxs("span",{className:"recap-note-mark",children:[a.jsx(Fl,{}),"recap"]}),a.jsx("span",{className:"recap-note-age",title:n.title,children:n.label}),a.jsx("button",{type:"button",className:"glyph-btn recap-note-close","aria-label":"Hide the recap",title:"Hide — the ※ on the card brings it back",onClick:r=>{r.stopPropagation(),k8(e.noteKey)},children:"×"})]}),a.jsx("p",{className:"recap-note-text",children:e.recap.text}),a.jsxs("div",{className:"lod-face recap-face","aria-hidden":!0,children:[a.jsxs("div",{className:"lod-id",children:[a.jsxs("span",{className:"recap-note-mark",children:[a.jsx(Fl,{}),"recap"]}),a.jsx("span",{className:"recap-face-age",children:n.label})]}),a.jsx("p",{className:"recap-face-text",children:e.recap.text})]}),a.jsx(Da,{type:"source",position:Ae.Right,style:{background:"transparent",border:"none"}})]})}function Lz({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s,targetPosition:o,style:l}){const[u]=yb({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o,curvature:.35});return a.jsxs("g",{className:"recap-tie",style:l,children:[a.jsx("path",{className:"recap-tie-thread",d:u}),a.jsx("path",{className:"recap-tie-beads",d:u}),a.jsx("circle",{className:"recap-tie-end",cx:e,cy:t,r:3.5}),a.jsx("circle",{className:"recap-tie-end",cx:n,cy:r,r:3.5})]})}function vx(e){return e.replace(/[^a-zA-Z0-9]/g,"")}function Bb(e,t){const n=vx(e);return n?n.slice(-t):e.slice(-t)}function r$(e,t,n=4){const r=vx(e);if(!r)return Bb(e,n);let s=n;for(const o of t){if(o===e)continue;const l=vx(o);let u=0;for(;u<r.length&&u<l.length&&r[r.length-1-u]===l[l.length-1-u];)u++;s=Math.max(s,u+1)}return r.slice(-s)}const qu=" · ",Pz=32,Dz=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function Cj(e){return Dz.test(e)?2:1}function Tj(e,t=Pz){const n=[...e];let r=0;for(const l of n)r+=Cj(l);if(r<=t)return e;const s=[];let o=0;for(const l of n){const u=Cj(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 Fz(e,t,n,r,s=[]){const o=(t==null?void 0:t.trim())??"",l=r?r$(n,s):void 0,u=[e,o||void 0,l].filter(Boolean);return{label:Tj(e),name:o?Tj(o):void 0,shortId:l,fullLabel:u.join(qu)}}const Aa=18,xx=26,s$=12,Bz=240;function qz(e,t){return(e+Bz)*(t||1)}function Uz(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 zz(e,t,n){return{position:"absolute",left:e.x+16,top:e.y-s$/(t||1),transform:`scale(${1/(t||1)})`,transformOrigin:"left top",maxWidth:qz(e.w,t),"--session-hue":n}}function Wz(e){const t=new Map;for(const s of e){if(s.type!=="agent"&&s.type!=="recapNote")continue;const o=s.data;if(!(o!=null&&o.sessionId)||o.exitAt!=null||s.width==null||s.height==null)continue;const l=s.position.x,u=s.position.y,d=l+s.width,h=u+s.height,f=t.get(o.sessionId),p=Hz(o);f?(f.minX=Math.min(f.minX,l),f.minY=Math.min(f.minY,u),f.maxX=Math.max(f.maxX,d),f.maxY=Math.max(f.maxY,h),p&&(f.label=p.label??f.label,f.name=p.name,f.alarm=p.alarm,f.branch=p.branch)):t.set(o.sessionId,{minX:l,minY:u,maxX:d,maxY:h,label:(p==null?void 0:p.label)??o.sessionId,name:p==null?void 0:p.name,alarm:(p==null?void 0:p.alarm)??!1,branch:p==null?void 0:p.branch})}const n=new Map;for(const[s,o]of t){const l=n.get(o.label);l?l.push(s):n.set(o.label,[s])}const r=[];for(const[s,o]of t){const l=n.get(o.label)??[],u=l.length>1;r.push({sessionId:s,...Fz(o.label,o.name,s,u,l),x:o.minX-Aa,y:o.minY-Aa-xx,w:o.maxX-o.minX+Aa*2,h:o.maxY-o.minY+Aa*2+xx,...o.alarm?{alarm:!0}:null,...o.branch?{branch:o.branch}:null})}return r}function Hz(e){if(e.kind!=="root")return null;const t=e.branch;return{label:e.label,name:$b(e.sessionName,e.sessionTitle).face,alarm:fr(e.waiting),branch:t&&t.total>0?qM(t):void 0}}function Vz(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 Gz(e){return Wz(e.nodeInternals.values())}function Kz({onFocusSession:e}){const{x:t,y:n,zoom:r}=Q2(),s=Ye(Gz,Vz);if(s.length<=1)return null;const o=u=>{try{e==null||e(u)}catch{}},l={transform:`translate(${t}px, ${n}px) scale(${r})`};return a.jsx("div",{className:"session-clusters",style:l,children:s.map(u=>{const d=sd(u.sessionId),h=Uz(u,d),f=zz(u,r,d);return a.jsxs(de.Fragment,{children:[a.jsx("div",{className:"cluster-card",style:h,"aria-hidden":!0}),a.jsxs("button",{type:"button",className:"cluster-label","data-alarm":u.alarm?"":void 0,style:f,title:`${u.alarm?`Waiting on you
72
+ `:""}Zoom to ${u.fullLabel}
73
+ drag the wrapper to move the whole session`,onClick:()=>o(u.sessionId),children:[u.alarm?a.jsxs(a.Fragment,{children:[a.jsx(Db,{}),a.jsx("span",{className:"cluster-label-said",children:"waiting on you: "})]}):null,u.label,u.branch?a.jsx("span",{className:"cluster-label-branch",children:qu+u.branch}):null,u.name?a.jsx("span",{className:"cluster-label-name",children:qu+u.name}):null,u.shortId?a.jsx("span",{className:"cluster-label-id",children:qu+u.shortId}):null]})]},u.sessionId)})})}function Yz({data:e}){return a.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const a$=600,Xz=4,Zz=36,bx=16,Jz=60,Qz=6,Aj=220,eW=96,tW=28;function nW(e,t){return Math.max(eW,61+[...t].length*6.8)}function rW(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function sW(e,t){if(t==null)return 1;const n=e-t;return n<0?1:Math.max(0,1-n/a$)}function aW(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 oW(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>a$)continue;const d=r.get(u.id)??n.get(u.id);if(!d)continue;const h=aW(u.tools,Xz);if(h.length===0)continue;const f=u.exitAt??null,p=s.get(u.id),g=Math.max((p==null?void 0:p.width)??Aj,Aj),v=(p==null?void 0:p.height)??130,k=d.x,b=d.y,x=k+g,N=b+v/2;h.forEach((S,_)=>{const E=_*Zz,T=k+g+Jz,A=b+Qz+E,R=sW(o,f),B=S.inputPreview??"",P=rW(S),D=R<.999,O=Pb(S.name);l.push({id:`${u.id}::${S.id}`,toolId:S.id,agentId:u.id,toolName:S.name,name:O.label,emoji:O.emoji,status:P,category:UM(S.name),mcpHue:O.hue,inputPreview:B,fade:R,fading:D,worldX:T,worldY:A,anchorX:x,anchorY:N,spawnDx:x-T,spawnDy:N-(A+bx)});const L=VM(S.name,S.input);if(L){const z=nW(S.name,O.label),M=T+z+tW,$=A,q=T+z,X=A+bx;l.push({id:`sub:${u.id}::${S.id}`,toolId:S.id,agentId:u.id,toolName:S.name,name:nU(L.label,L.category),fullName:L.label,emoji:L.emoji,isSub:!0,status:P,category:L.category,inputPreview:L.detail??B,fade:R,fading:D,worldX:M,worldY:$,anchorX:q,anchorY:X,spawnDx:q-M,spawnDy:0})}})}return l}function iW({agents:e,visibleAgentIds:t,positions:n,pinned:r,measured:s,spotlight:o,hiddenCategories:l,now:u,onOpenTool:d}){const h=oW(e,t,n,r,s,u),f=l&&l.size>0?h.filter(p=>!l.has(p.category)):h;return a.jsx(lW,{bursts:f,spotlight:o,onOpenTool:d})}function lW({bursts:e,spotlight:t,onOpenTool:n}){const{x:r,y:s,zoom:o}=Q2();return a.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[a.jsx("svg",{className:"tool-bursts-svg",children:e.map(l=>{const u=l.anchorX*o+r,d=l.anchorY*o+s,h=(l.worldX+6)*o+r,f=(l.worldY+bx)*o+s,p=Math.max(1,h-u),g=Math.min(1,Math.abs(f-d)/p),v=u+p*(.55-.22*g),k=t!=null&&!t.has(l.agentId),b=l.fade*(k?.14:1);return a.jsx("path",{d:`M ${u} ${d} Q ${v} ${d}, ${h} ${f}`,className:`tool-conn status-${l.status}${l.fading?" fading":""}`,opacity:b},`l:${l.id}`)})}),e.map(l=>a.jsx(uW,{b:l,x:r,y:s,zoom:o,dim:t!=null&&!t.has(l.agentId),onOpenTool:n},l.id))]})}function cW(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 uW=w.memo(function({b:t,x:n,y:r,zoom:s,dim:o,onOpenTool:l}){const u=t.worldX*s+n,d=t.worldY*s+r,h={left:`${u}px`,top:`${d}px`,transform:`scale(${s})`,transformOrigin:"left top","--spawn-dx":`${t.spawnDx}px`,"--spawn-dy":`${t.spawnDy}px`},f=t.isSub?`${t.toolName} · ${t.fullName??t.name}`:t.toolName,p=t.inputPreview?`${f} · ${t.inputPreview}`:f,g=l!=null,v=t.mcpHue!=null?{"--mcp-hue":t.mcpHue}:{},k=o?" dim":"";return a.jsx("div",{className:"tool-burst-wrap",style:h,children:a.jsxs("div",{className:`tool-burst cat-${t.category}${t.mcpHue!=null?" mcp-hue":""} status-${t.status}${t.fading?" fading":""}${g?" clickable":""}${t.isSub?" sub":""}${k}`,style:v,title:p,onClick:g?()=>l(t.agentId,t.toolId):void 0,children:[a.jsx("span",{className:"tb-emoji",children:t.emoji}),a.jsx("span",{className:"tb-name",children:t.name}),t.status==="inflight"&&a.jsx("span",{className:"tb-spin"}),t.status==="done"&&a.jsx("span",{className:"tb-mark done",children:"✓"}),t.status==="err"&&a.jsx("span",{className:"tb-mark err",children:"×"})]})})},cW),dW={agent:lU,sessionGroup:Yz,recapNote:Oz},hW={recapTie:Lz},Rj=400;function fW({graph:e,layout:t,viewport:n,clicks:r,drag:s,appearance:o,fm:l,autoFit:u,pause:d,stateRef:h,measuredRef:f,hiddenCats:p,now:g,openTool:v,focusAgent:k,requestClear:b,setKeyHelpOpen:x}){const{allNodes:N,edges:S,visibleAgentIds:_,spotlightSet:E}=e,{positionsRef:T,pinnedRef:A,handleRelayout:R}=t,{restoredViewport:B,onMoveStart:P,onMove:D}=n,{onNodeClick:O,onPaneClick:L,onNodeDoubleClick:z,onNodeMouseEnter:M,onNodeMouseLeave:$}=r,{onNodeDragStart:q,onNodeDrag:X,onNodeDragStop:H}=s,{palette:I,minimapNodeFill:W,characterEnabled:F}=o,{fmVolume:Y,fmMuted:J,fmSource:V,fmPlayRequest:G,customFmStations:K,markFmStationAvailability:Z}=l,{autoFitDisabled:ee,enableAutoFitAndRefit:re}=u,{paused:ue,pauseGate:me,togglePause:ae}=d;return a.jsxs(J2,{nodes:N,edges:S,nodeTypes:dW,edgesFocusable:!1,edgeTypes:hW,fitView:!B,fitViewOptions:{padding:.25,duration:hx({durationMs:Rj,documentHidden:document.hidden})?Rj:0},minZoom:aM,maxZoom:oM,panOnScroll:!0,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,disableKeyboardA11y:!0,deleteKeyCode:null,onNodeClick:O,onPaneClick:L,onNodeDoubleClick:z,onNodeMouseEnter:M,onNodeMouseLeave:$,onMoveStart:P,onMove:D,onNodeDragStart:q,onNodeDrag:X,onNodeDragStop:H,children:[a.jsx(aB,{gap:28,size:1,color:I["--grid-line"]}),a.jsx(Kz,{onFocusSession:k}),a.jsx(iW,{agents:h.current.agents,visibleAgentIds:_,positions:T.current,pinned:A.current,measured:f.current,spotlight:E,hiddenCategories:p,now:g,onOpenTool:v}),ee&&a.jsx(pU,{enableAutoFitAndRefit:re}),a.jsx(NU,{autoFitDisabled:ee,enableAutoFitAndRefit:re,paused:ue,pauseGate:me,togglePause:ae,handleRelayout:R,requestClear:b,setKeyHelpOpen:x}),a.jsx(V6,{zoomable:!0,pannable:!0,nodeColor:W,nodeStrokeWidth:2,maskColor:I["--minimap-mask"],maskStrokeColor:I["--line"]}),F&&a.jsx($z,{volume:Y,muted:J,source:V,playRequest:G,customStation:K.find(pe=>Fa(pe.id)===V),onAvailabilityChange:Z})]})}function pW(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=hn(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 mW="spend on this board",gW="on this board",Mj=`Everything on the board right now, and only that.
74
+ Finished sessions are evicted from the canvas a couple of minutes after they end, and their tokens and dollars leave with them — so this figure falls on its own.
75
+ Press H for the totals ccusage reads off the logs on disk, which do not forget.`,o$="session spend",kx="__unknown__",yW=12;function wW(e,t=Date.now()){const n=new Map;for(const r of e)for(const s of nc(r)){const o=s.model??kx,l=Zo(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:za(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 vW(e,t=Date.now()){const n=[...e],r=[];for(const s of n){if(s.kind!=="root")continue;let o=hn(s,t).total,l=s.usage.inputTokens,u=s.usage.outputTokens,d=Dl(s,t);for(const h of n)h.sessionId!==s.sessionId||h.kind==="root"||(o+=hn(h,t).total,l+=h.usage.inputTokens,u+=h.usage.outputTokens,d+=Dl(h,t));r.push({sessionId:s.sessionId,label:s.label||s.cwdBasename||"session",state:s.state,cost:o,inputTokens:l,outputTokens:u,unpricedTokens:d})}return r.sort((s,o)=>o.cost-s.cost||o.inputTokens+o.outputTokens-(s.inputTokens+s.outputTokens)).slice(0,yW)}function $j(e){return e.waiting?fr(e.waiting)?0:1:e.state==="active"?2:3}function xW(e,t){const n=[];for(const r of e.agents.values()){if(r.kind!=="root")continue;let s=r.toolCount,o=hn(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+=hn(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:Pd(r),modelId:r.model,toolCount:s,cost:o,startedAt:r.startedAt,lastActivity:l})}return n.sort((r,s)=>{const o=$j(r),l=$j(s);return o!==l?o-l:r.waiting&&s.waiting?r.waiting.since-s.waiting.since:s.lastActivity-r.lastActivity}),n}function Ij(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 bW({state:e,now:t,selectedIds:n,onSelect:r,onClose:s,removedIds:o,onBringBackAll:l}){const u=w.useMemo(()=>xW(e),[e,e.revision,t]),d=u.filter(f=>f.state==="active").length,h=u.filter(f=>fr(f.waiting)).length;return a.jsxs("aside",{className:"session-list",id:"session-list","aria-label":"Sessions",children:[a.jsxs("div",{className:"sl-header",children:[a.jsxs("h2",{children:["Sessions ",a.jsx("span",{className:"sl-count",children:u.length})]}),h>0&&a.jsxs("span",{className:"sl-waiting-count",children:[h," waiting"]}),d>0&&a.jsxs("span",{className:"sl-live-count",children:[d," live"]}),a.jsx("button",{className:"glyph-btn sl-close",onClick:s,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),a.jsxs("ul",{className:"sl-rows",children:[u.length===0&&a.jsx("li",{className:"sl-empty",children:"No sessions yet."}),u.map(f=>{const p=n.has(f.sessionId),g=(o==null?void 0:o.has(f.sessionId))??!1;return a.jsx("li",{className:"sl-row-item",children:a.jsxs("button",{type:"button",className:`sl-row state-${f.state}${p?" selected":""}${g?" removed":""}`,"aria-current":p?"true":void 0,onClick:()=>r(f.sessionId),title:g?`Bring ${f.label} back to the board`:`Focus ${f.label}`,children:[a.jsx("span",{className:`sl-dot state-${f.state}`,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:oi(f.state)}),a.jsxs("div",{className:"sl-row-body",children:[a.jsxs("div",{className:"sl-row-head",children:[a.jsx("span",{className:"sl-label",children:f.label}),g&&a.jsx("span",{className:"sl-removed",children:"off the board"}),f.modelId&&a.jsx("span",{className:"model-chip","data-family":$d(f.modelId),title:f.modelId,children:Js(f.modelId)})]}),a.jsxs("div",{className:"sl-row-meta",children:[a.jsxs("span",{title:"tool calls",children:[a.jsx("b",{children:f.toolCount})," ",f.toolCount===1?"tool":"tools"]}),f.cost>0&&a.jsx("span",{className:"sl-cost",title:o$,children:a.jsx("b",{children:qe(f.cost)})}),f.waiting?a.jsxs("span",{className:"sl-waiting",title:[ii(f.waiting),zq(f.waiting,ii(f.waiting)),`Blocked since ${new Date(f.waiting.since).toLocaleTimeString()} · started ${new Date(f.startedAt).toLocaleString()}`].filter(Boolean).join(`
76
+ `),children:["waiting ",Ij(f.waiting.since,void 0,t),f.waiting.tool&&a.jsxs("span",{className:"sl-waiting-tool",children:[" · ",f.waiting.tool.name]})]}):a.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(f.startedAt).toLocaleString()}`,children:Ij(f.startedAt,f.state==="active"?void 0:f.lastActivity,t)})]}),f.recap&&a.jsxs("span",{className:"sl-recap",title:f.recap.text,children:[a.jsx(Fl,{}),f.recap.text]})]})]})},f.sessionId)})]}),(()=>{const f=(o==null?void 0:o.size)??0;return f===0||!l?null:a.jsx("div",{className:"sl-foot",children:a.jsxs("button",{type:"button",className:"btn sl-bring-back",onClick:p=>{const g=p.currentTarget.closest(".session-list");l(),requestAnimationFrame(()=>{var v;return(v=g==null?void 0:g.querySelector(".sl-row"))==null?void 0:v.focus()})},children:["Bring back ",f," removed ",f===1?"card":"cards"]})})})()]})}const Nx={cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,sessions:0};function kW(e){if(!e.synthetic)return!1;const t=e.usage;return t.inputTokens+t.outputTokens+t.cacheReadTokens+t.cacheCreateTokens<=0}function jx(e,t){const n=new Map;for(const r of e){if(r.kind!=="root"||!r.sessionId||kW(r))continue;const s=hn(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 NW(e,t){if(!e)return Nx;const n={...Nx};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 Sx(e,t=new Date){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}const qd=[{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 jW(e,t,n=qd.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 i$(e,t=new Date){return e==="today"?Sx(1,t):e==="month"?Sx(t.getDate(),t):"20200101"}const cn=e=>typeof e=="number"&&Number.isFinite(e)?e:0,Uu=e=>typeof e=="string"?e:"";function l$(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=Uu(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+=cn(o==null?void 0:o.cost),u.inputTokens+=cn(o==null?void 0:o.inputTokens),u.outputTokens+=cn(o==null?void 0:o.outputTokens),u.cacheReadTokens+=cn(o==null?void 0:o.cacheReadTokens),u.cacheCreateTokens+=cn(o==null?void 0:o.cacheCreationTokens)}}return[...n.values()].sort((r,s)=>s.cost-r.cost||s.tokens-r.tokens)}const SW=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function _W(e){var t;return((t=SW.exec(e))==null?void 0:t[0])??e}function EW(e,t=new Map){const n=Array.isArray(e==null?void 0:e.sessions)?e.sessions:[],r=[];for(const s of n){const o=Uu(s==null?void 0:s.period);if(!o)continue;const l=_W(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:Uu(s==null?void 0:s.agent)||"claude",cost:cn(s==null?void 0:s.totalCost),tokens:cn(s==null?void 0:s.totalTokens),models:Array.isArray(s==null?void 0:s.modelsUsed)?s.modelsUsed.map(Uu).filter(Boolean):[],lastActivityMs:Number.isFinite(d)?d:null})}return r.sort((s,o)=>o.cost-s.cost||o.tokens-s.tokens)}function CW(e,t=Ud(e).cost){const r=(Array.isArray(e==null?void 0:e.sessions)?e.sessions:[]).reduce((o,l)=>o+cn(l==null?void 0:l.totalCost),0),s=Math.max(.01,t*.01);return{sum:r,total:t,over:r>t+s}}function TW(e,t,n){const r=`Sessions with activity ${e}, and what ccusage puts against each one.`;return t.over?`${r}
77
+ They add up to ${n(t.sum)}, more than the ${n(t.total)} above: what a session cost and what a day cost are two different measurements, and they need not agree.`:r}function Ud(e){const t=e==null?void 0:e.totals;if(t&&typeof t=="object"){const d=cn(t.cacheReadTokens),h=cn(t.cacheCreationTokens),f=cn(t.inputTokens),p=cn(t.outputTokens);return{cost:cn(t.totalCost),inputTokens:f,outputTokens:p,cacheReadTokens:d,cacheCreateTokens:h,tokens:cn(t.totalTokens)||f+p+d+h}}const n=l$(e),r=d=>n.reduce((h,f)=>h+d(f),0),s=r(d=>d.inputTokens),o=r(d=>d.outputTokens),l=r(d=>d.cacheReadTokens),u=r(d=>d.cacheCreateTokens);return{cost:r(d=>d.cost),inputTokens:s,outputTokens:o,cacheReadTokens:l,cacheCreateTokens:u,tokens:s+o+l+u}}function AW(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 c$(e,t){var n;return((n=qd.find(r=>r.key===(e??t)))==null?void 0:n.noun)??"today"}function RW(e,t,n){const r=e!=null,s=Ud(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 u$="agent-dag.usagePeriod";function MW(){const e=et(u$);return qd.some(t=>t.key===e)?e:"today"}function $W(e){Xe(u$,e)}const d$="agent-dag.usageSessionsOpen";function IW(){return et(d$)==="1"}function OW(e){Xe(d$,e?"1":"0")}function qb({cost:e,size:t="md"}){const n=e.total;if(n<=0)return null;const r=(o,l,u)=>{if(o<=0)return null;const d=o/n*100;return a.jsx("span",{className:`cb-seg ${l}`,style:{width:`${d}%`},title:`${u}: ${qe(o)} (${d.toFixed(0)}%)`},l)},s=t==="lg";return a.jsxs("div",{className:s?"cost-bar cost-bar-lg":"cost-bar",role:"img","aria-label":"Cost breakdown",children:[r(e.input,"cb-input","input"),r(e.output,"cb-output","output"),r(e.cacheRead,"cb-cache-r","cache read"),r(e.cacheWrite,"cb-cache-w","cache write")]})}const bt="ccdeck",LW="/brand/ccdeck-mark-gradient-small-optical.svg",PW="/brand/ccdeck-mark-mono-dark-small-optical.svg";function h$(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 DW({incidents:e}){return a.jsx(a.Fragment,{children:e.map(t=>a.jsxs("a",{className:t.stale?"provider-incident provider-incident-stale":"provider-incident","data-state":t.state,href:t.href,target:"_blank",rel:"noopener noreferrer",title:t.detail,children:[a.jsx("span",{className:"pi-dot","aria-hidden":!0}),a.jsx("span",{className:"pi-name",children:t.name}),a.jsxs("span",{className:"pi-words",children:["· ",t.chipWords]}),a.jsxs("span",{className:"pi-short",children:["· ",t.shortWords]}),t.asOf&&a.jsxs("span",{className:"pi-asof",children:["· as of ",t.asOf]}),a.jsx("span",{className:"pi-go","aria-hidden":!0,children:"↗"}),a.jsxs("span",{className:"vis-hidden",children:[", on ",t.host,", opens in a new tab"]})]},t.provider))})}function f$({incident:e}){return e?a.jsxs("a",{className:e.stale?"up-incident up-incident-stale":"up-incident","data-state":e.state,href:e.href,target:"_blank",rel:"noopener noreferrer",title:e.detail,children:[a.jsx("span",{className:"pi-dot","aria-hidden":!0}),a.jsxs("span",{className:"up-incident-words",children:[a.jsxs("span",{className:"vis-hidden",children:[e.name,": "]}),e.words[0].toUpperCase()+e.words.slice(1),e.asOf?` · as of ${e.asOf}`:""]}),a.jsx("span",{className:"up-incident-go","aria-hidden":!0,children:"↗"}),e.what&&a.jsx("span",{className:"up-incident-what",children:e.what}),a.jsxs("span",{className:"vis-hidden",children:[", on ",e.host,", opens in a new tab"]})]}):null}function FW(e,t,n,r,s=!1){const o=Math.max(0,t-r),l=Math.max(0,n-o);if(l<120)return null;const u=Math.min(100,l/n*100),d=e-u;if(s||e>=100)return{label:"used up",color:"var(--warn)",expectedPct:u,isDeficit:!0};if(Math.abs(d)<3)return{label:"on pace",color:"var(--ok)",expectedPct:u,isDeficit:!1};if(d>0){const h=100-e,f=l>0?e/l:0,p=f>0?h/f:1/0,g={label:`${Math.round(d)}% over pace`,color:"var(--warn)",expectedPct:u,isDeficit:!0};if(p<o&&p<86400){const v=Math.floor(p/3600),k=Math.floor(p%3600/60);g.runsOutIn=v>0?`${v}h ${k}m`:`${k}m`}return g}return{label:`${Math.round(-d)}% under pace`,color:"var(--ok)",expectedPct:u,isDeficit:!1}}function Ks({pct:e,label:t,reset:n,resetAt:r,windowSec:s,limitReached:o,nowSec:l}){const u=e!=null,d=u?Math.min(100,Math.max(0,e)):0,f=o||d>=90?"var(--err)":d>=70?"var(--warn)":"var(--accent)",p=d<1,g=u?p?"< 1%":`${Math.round(d)}%`:"no reading",v=p?2:d,k=r?Bd(r,l):null,b=u&&r&&s?FW(d,r,s,l,o):null,[x,N]=w.useState(!1),S=w.useId();return a.jsxs("div",{className:"qb-row",children:[a.jsxs("div",{className:"qb-meta",children:[a.jsxs("span",{className:"qb-label",children:[t,o&&a.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),a.jsx("span",{className:"qb-pct",style:{color:u?f:"var(--muted)"},children:g})]}),a.jsxs("div",{className:"qb-track",children:[u&&a.jsx("div",{className:"qb-fill",style:{transform:`scaleX(${v/100})`,background:f,opacity:p?.4:1}}),b&&a.jsx("div",{className:"qb-pace-rail",style:{transform:`translateX(${b.expectedPct}%)`},children:a.jsx("div",{"aria-hidden":!0,className:"qb-pace-marker",style:{background:b.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(b.expectedPct)}% by now`})})]}),a.jsxs("div",{className:"qb-reset-row",children:[k?a.jsxs("span",{className:"qb-reset",children:["resets in ",k]}):n?a.jsxs("span",{className:"qb-reset",children:["resets ",n]}):null,b&&a.jsxs("button",{type:"button",className:"qb-pace",style:{color:b.color},"aria-expanded":x,"aria-controls":x?S:void 0,onClick:()=>N(_=>!_),children:[a.jsx("i",{className:"qb-pace-key","aria-hidden":!0,style:{background:b.isDeficit?"var(--err)":"var(--ok)"}}),b.runsOutIn?`runs out in ${b.runsOutIn}`:b.label]})]}),x&&b&&a.jsxs("div",{id:S,className:"qb-why",children:["To last until reset, stay near ",Math.round(b.expectedPct),"% by now."]})]})}function p$(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 BW(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 qW(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 UW(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 zW({quota:e,quotaLoading:t,nowSec:n,incident:r}){const s=p$(e==null?void 0:e.fetchedAt,n);return a.jsxs("section",{className:"up-section up-quota-section",children:[a.jsxs("h3",{className:"up-section-title",children:["Claude quota",s&&!t&&a.jsx("span",{className:"up-section-age",title:BW(e==null?void 0:e.source),children:s})]}),a.jsx(f$,{incident:r}),e!=null&&e.ok?a.jsxs("div",{className:"up-quota-bars",children:[e.session5hPct!=null&&a.jsx(Ks,{label:"5-hour window",pct:e.session5hPct,reset:e.session5hReset,resetAt:e.session5hResetAt,windowSec:e.session5hWindowSec,nowSec:n}),a.jsx(Ks,{label:"7-day window",pct:e.week7dPct??null,reset:e.week7dReset,resetAt:e.week7dResetAt,windowSec:e.week7dWindowSec,nowSec:n}),e.weekSonnetPct!=null&&a.jsx(Ks,{label:"Sonnet (7d)",pct:e.weekSonnetPct,nowSec:n}),e.weekOpusPct!=null&&a.jsx(Ks,{label:"Opus (7d)",pct:e.weekOpusPct,nowSec:n}),e.extraEnabled&&e.extraUsedCredits!=null&&e.extraMonthlyLimit?a.jsx(Ks,{label:`Extra credits (month${e.extraCurrency?`, ${e.extraCurrency}`:""})`,pct:Math.min(100,Math.round(e.extraUsedCredits/e.extraMonthlyLimit*100)),nowSec:n}):e.extraEnabled&&a.jsx("div",{className:"up-quota-sub up-credits",children:"extra usage credits: on"}),e.resetCredits&&e.resetCredits.availableCount>0&&a.jsx("div",{className:"up-quota-sub up-reset-credits",title:`Saved in Claude as "Reset for free". Redeem one in Claude on the web or desktop — ${bt} only reports them`,children:h$("limit reset",e.resetCredits)})]}):(e==null?void 0:e.ok)===!1?a.jsxs("div",{className:"up-quota-na",children:[a.jsx("span",{children:e.reason==="no_subscription"?"No quota to show.":"Quota unavailable."}),a.jsx("span",{className:"up-quota-hint",children:qW(e.reason)})]}):a.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]})}function WW({codexQuota:e,codexLoading:t,codexUsage:n,nowSec:r,incident:s}){var l,u;const o=p$(e==null?void 0:e.fetchedAt,r);return a.jsxs("section",{className:"up-section up-quota-section",children:[a.jsxs("h3",{className:"up-section-title",children:["Codex quota",(e==null?void 0:e.ok)&&e.planLabel&&a.jsx("span",{className:"up-plan-badge",children:e.planLabel}),o&&!t&&a.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:o})]}),a.jsx(f$,{incident:s}),e!=null&&e.ok?a.jsxs("div",{className:"up-quota-bars",children:[(l=e.windows)==null?void 0:l.map(d=>a.jsx(Ks,{label:d.label,pct:d.pct,reset:d.reset??void 0,resetAt:d.resetAt??void 0,windowSec:d.windowSec??void 0,limitReached:e.limitReached&&d.pct>=100,nowSec:r},d.id)),(u=e.extraWindows)==null?void 0:u.map(d=>a.jsx(Ks,{label:d.label,pct:d.pct,reset:d.reset??void 0,resetAt:d.resetAt??void 0,windowSec:d.windowSec??void 0,nowSec:r},d.id)),e.creditLimit&&a.jsx(Ks,{label:`spend cap · $${Math.round(e.creditLimit.used)} of $${Math.round(e.creditLimit.limit)}`,pct:e.creditLimit.usedPct,reset:e.creditLimit.reset??void 0,resetAt:e.creditLimit.resetAt??void 0,limitReached:e.spendControlReached,nowSec:r}),e.creditsBalance&&!e.creditsUnlimited&&a.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",e.creditsBalance,e.overageReached&&" · overage limit reached"]}),e.creditsUnlimited&&a.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),e.resetCredits&&e.resetCredits.availableCount>0&&a.jsx("div",{className:"up-quota-sub up-reset-credits",title:`Redeem in the Codex CLI or ChatGPT — ${bt} only reports them`,children:h$("rate-limit reset",e.resetCredits)}),e.promo&&a.jsx("div",{className:"up-quota-sub",children:e.promo}),e.partial&&a.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(e==null?void 0:e.ok)===!1?a.jsxs("div",{className:"up-quota-na",children:[a.jsx("span",{children:"Quota unavailable."}),a.jsx("span",{className:"up-quota-hint",children:UW(e.reason)})]}):a.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"}),(n==null?void 0:n.ok)&&n.window7d&&n.window7d.sessionCount>0&&a.jsxs("div",{className:"up-quota-sub",title:`Counted from the rollout files under CODEX_HOME — no network, no account${n.window5h?`
78
+ last 5h: ${ot(n.window5h.totalTokens)} tokens · ${n.window5h.sessionCount} session${n.window5h.sessionCount!==1?"s":""}`:""}`,children:[ot(n.window7d.totalTokens)," tokens · ",n.window7d.sessionCount," session",n.window7d.sessionCount!==1?"s":""," (7d)"]})]})}function HW({fromRange:e,rangeModelRows:t,boardModelRows:n}){return a.jsxs("section",{className:"up-section",children:[a.jsx("h3",{className:"up-section-title",children:"By model"}),a.jsxs("table",{className:"up-table",children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Model"}),a.jsx("th",{children:"Tokens"}),a.jsx("th",{children:"Cost"})]})}),a.jsx("tbody",{children:e?t.map(r=>a.jsxs("tr",{children:[a.jsx("td",{className:"up-model-name",title:r.model,children:Js(r.model)}),a.jsx("td",{className:"up-num",children:ot(r.tokens)}),r.cost>0?a.jsx("td",{className:"up-num up-cost-val",children:qe(r.cost)}):a.jsx("td",{className:"up-num up-unpriced",children:hs})]},r.model)):n.map(r=>a.jsxs("tr",{children:[a.jsx("td",{className:"up-model-name",title:r.model===kx?"no model reported yet":r.model,children:r.model===kx?"unknown":Js(r.model)}),a.jsx("td",{className:"up-num",children:ot(r.inputTokens+r.outputTokens)}),r.priced?a.jsx("td",{className:"up-num up-cost-val",children:qe(r.cost.total)}):a.jsx("td",{className:"up-num up-unpriced",children:hs})]},r.model))})]})]})}function VW({period:e,rangePending:t,setPeriod:n}){const r=w.useRef([]);return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"uh-range up-period",role:"toolbar","aria-orientation":"horizontal","aria-label":"Period","aria-busy":t||void 0,onKeyDown:s=>{var u;const o=r.current.indexOf(s.target);if(o<0)return;const l=jW(s.key,o);l!==null&&(s.preventDefault(),(u=r.current[l])==null||u.focus())},children:qd.map((s,o)=>a.jsx("button",{type:"button",ref:l=>{r.current[o]=l},tabIndex:e===s.key?0:-1,"aria-pressed":e===s.key,"data-pending":e===s.key&&t?"":void 0,title:e===s.key&&t?`Reading ${s.noun} from the transcripts on this machine…`:s.hint,className:"uh-range-btn",onClick:()=>n(s.key),children:s.label},s.key))}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:t?`Reading ${c$(e,e)}…`:""})]})}function GW({fromRange:e,rangeSessionRows:t,boardSessionRows:n,boardStates:r,sessionsOpen:s,setSessionsOpen:o,periodNoun:l,sessionScale:u}){const d=e?t.length:n.length;return a.jsxs("section",{className:"up-section",children:[a.jsx("h3",{className:"up-section-title",children:a.jsxs("button",{type:"button",className:"up-disclose","aria-expanded":s,"aria-controls":"up-sessions",title:s?"Hide the per-session breakdown":`Show the per-session breakdown — ${d} session${d===1?"":"s"}`,onClick:()=>o(h=>!h),children:["By session",e&&a.jsxs("span",{className:"up-section-age",title:TW(l,u,qe),children:["active ",l]}),a.jsx("svg",{className:"up-chev",width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M2.2 3.6 5 6.4 7.8 3.6"})})]})}),a.jsxs("div",{className:"up-sessions",id:"up-sessions",hidden:!s,children:[e&&t.map(h=>{const f=r.get(h.sessionId);return a.jsxs("div",{className:"up-session-row",children:[f?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:`sl-dot state-${f}`,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:oi(f)})]}):a.jsx("span",{className:"sl-dot up-dot-past","aria-hidden":!0}),a.jsx("span",{className:`up-session-label${h.label?"":" up-session-id"}`,title:h.label?`${h.label}
79
+ ${h.sessionId}`:h.sessionId,children:h.label??Bb(h.sessionId,8)}),a.jsx("span",{className:"up-session-tokens",children:ot(h.tokens)}),h.cost>0?a.jsx("span",{className:"up-session-cost",title:h.models.join(", ")||void 0,children:qe(h.cost)}):a.jsx("span",{className:"up-session-cost up-unpriced",children:hs})]},h.sessionId)}),!e&&n.map(h=>a.jsxs("div",{className:"up-session-row",children:[a.jsx("span",{className:`sl-dot state-${h.state}`,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:oi(h.state)}),a.jsx("span",{className:"up-session-label",children:h.label}),a.jsx("span",{className:"up-session-tokens",children:ot(h.inputTokens+h.outputTokens)}),h.cost>0?a.jsxs("span",{className:"up-session-cost",title:h.unpricedTokens>0?`${ot(h.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[qe(h.cost),h.unpricedTokens>0?"+":""]}):a.jsx("span",{className:"up-session-cost up-unpriced",children:hs})]},h.sessionId))]})]})}function Qs(e,t){return{disabled:e!=null&&e!==t,busy:e===t}}function zd(e){return e==null}const _x="self";function Ir(e,t=!1){const n=Qs(e?_x:null,_x);return{disabled:t||n.disabled,"aria-busy":n.busy}}function ir(e){return zd(e?_x:null)}const Bl=400;function ql({armedFor:e,target:t,armedAt:n,now:r,gapMs:s}){return e!==t?"arm":r-n<s?"ignore":"fire"}function m$(e){return[...e==null?[]:[`#ap-more-${e}`],".accounts-panel .ap-refresh"]}function Pr(e){return e==null||e==="BODY"||e==="HTML"}const KW=6e4,YW=2e4;function XW(e){const[t,n]=w.useState(null),[r,s]=w.useState(!1),o=w.useRef(null),l=w.useRef(!1),u=async(h=!1)=>{if(!(h&&!ir(l.current))){h&&(l.current=!0,s(!0));try{const p=await fetch(h?"/api/quota?refresh=1":"/api/quota",{signal:AbortSignal.timeout(YW)});p.ok&&n(await p.json())}catch{}finally{h&&(l.current=!1,s(!1))}}};return w.useEffect(()=>{if(e)return u(!0),o.current=window.setInterval(()=>u(!1),KW),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{quota:t,loading:r,refresh:()=>{e&&u(!0)}}}const g$=6e4;function ZW(e){const[t,n]=w.useState(null),[r,s]=w.useState(!1),o=w.useRef(null),l=w.useRef(!1),u=async(h=!1)=>{if(!(h&&!ir(l.current))){h&&(l.current=!0,s(!0));try{const p=await fetch(h?"/api/codex-quota?refresh=1":"/api/codex-quota");p.ok&&n(await p.json())}catch{}finally{h&&(l.current=!1,s(!1))}}};return w.useEffect(()=>{if(e)return u(!0),o.current=window.setInterval(()=>u(!1),g$),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{data:t,loading:r,refresh:()=>{e&&u(!0)}}}function JW(e){const[t,n]=w.useState(null),r=w.useRef(null),s=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return w.useEffect(()=>{if(e)return s(),r.current=window.setInterval(s,g$),()=>{r.current!=null&&window.clearInterval(r.current)}},[e]),{data:t}}const Oj=6e4;function QW(e,t,n){const[r,s]=w.useState(null),[o,l]=w.useState(!1),[u,d]=w.useState(0),h=w.useRef(0);w.useEffect(()=>{const p=()=>document.visibilityState==="visible",g=()=>{p()&&d(b=>b+1)},v=window.setInterval(g,Oj),k=()=>{p()&&Date.now()-h.current>=Oj&&d(b=>b+1)};return document.addEventListener("visibilitychange",k),()=>{window.clearInterval(v),document.removeEventListener("visibilitychange",k)}},[]);const f=w.useRef(t);return w.useEffect(()=>{let p=!0;const g=t!==f.current;f.current=t;const v=e,k=i$(v);return l(!0),fetch(`/api/ccusage?since=${k}${g?"&refresh=1":""}`).then(b=>b.ok?b.json():null).then(b=>{!p||!(b!=null&&b.ok)||(h.current=Date.now(),s({period:v,data:b,baseline:n()}))}).catch(()=>{}).finally(()=>{p&&l(!1)}),()=>{p=!1}},[e,t,u]),{...AW(r,e),loading:o}}const eH=e=>1-Math.pow(1-e,5),y$=420;function tH(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 nH(e,t,n,r=y$){return n>=r?t:n<=0?e:e+(t-e)*eH(n/r)}function w$(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function Lj(e,t,n,r={}){const s=r.now??(()=>performance.now()),o=r.raf??(v=>requestAnimationFrame(v)),l=r.cancel??(v=>cancelAnimationFrame(v)),u=r.reducedMotion??w$,d=r.hidden??(()=>typeof document=="object"&&document.hidden===!0);if(u()||d()||!tH(e,t))return n(t),()=>{};const h=s();let f=0,p=!0;const g=()=>{if(!p)return;const v=s()-h;n(nH(e,t,v)),v<y$&&(f=o(g))};return f=o(g),()=>{p=!1,f&&l(f)}}const rH=typeof window>"u"?w.useEffect:w.useLayoutEffect;function _a(e,{countIn:t=!1}={}){const[n,r]=w.useState(e),s=w.useRef(e),o=w.useRef(!0);return w.useEffect(()=>{s.current=n},[n]),rH(()=>{!t||w$()||(s.current=0,r(0))},[]),w.useEffect(()=>{if(o.current){if(o.current=!1,t)return Lj(0,e,u=>{s.current=u,r(u)});s.current=e,r(e);return}return Lj(s.current,e,u=>{s.current=u,r(u)})},[e]),n}function v$(e,t,n){const r=aH*Math.max(1,n/b$);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 Pj={samples:[],last:new Map,watched:0},x$=10*6e4,sH=6e4,b$=5e3,aH=20;function oH(e,t,n){const r=e.samples[e.samples.length-1];if(r&&t-r.t<b$)return e;const s=e.watched+v$(e.last,n,r?t-r.t:0),o=e.samples.filter(l=>t-l.t<=x$);return o.push({t,watched:s}),{samples:o,last:n,watched:s}}function iH(e,t,n){const r=e.samples[0];if(!r)return null;const s=t-r.t;if(s<sH)return null;const o=e.samples[e.samples.length-1].t,l=e.watched+v$(e.last,n,t-o)-r.watched;return l>0?{spent:l,spanSec:s/1e3,spanMin:Math.min(x$/6e4,Math.ceil(s/6e4))}:null}function lH(e,t,n){const r=w.useRef(Pj),s=w.useRef(null);return w.useMemo(()=>{const o=wW(e.agents.values()),l=pW(e.agents.values());s.current!==n&&(s.current=n,r.current=Pj);const u=jx(e.agents.values(),t);n!=null&&(r.current=oH(r.current,t,u));const d=n==null?null:iH(r.current,t,u),h=d?{label:Rb(d.spent,d.spanSec),spanMin:d.spanMin}:null;return{byModel:o,totalCost:l.cost,totalTokens:l,burnRate:h}},[e,e.revision,t,n])}const cH=3e4;function k$(){const[e,t]=w.useState(()=>Math.floor(Date.now()/1e3));return w.useEffect(()=>{const n=window.setInterval(()=>t(Math.floor(Date.now()/1e3)),cH);return()=>window.clearInterval(n)},[]),e}function Dj(e){return(typeof e.cost=="number"?e.cost:e.cost.total)>0||e.inputTokens+e.outputTokens>0}function uH(e,t,n){return e?t.some(r=>r.cost<=0&&r.tokens>0):n.some(r=>!r.priced)}function dH(e){return e.claude&&e.codex?"Refresh Claude + Codex quota":e.codex?"Refresh Codex quota":"Refresh Claude quota"}function hH(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 fH(e){const t=new Map;for(const n of e)n.kind!=="root"||!n.sessionId||t.set(n.sessionId,n.state);return t}function pH(e){const t=new Map;for(const n of e){if(!n.label)continue;const r=t.get(n.label);r?r.push(n.sessionId):t.set(n.label,[n.sessionId])}return e.map(n=>{const r=n.label?t.get(n.label)??[]:[];return r.length>1?{...n,label:`${n.label} ${r$(n.sessionId,r)}`}:n})}function mH({state:e,now:t,providers:n,incidents:r=[],leaving:s,onClose:o,liveSince:l=null}){const{quota:u,loading:d,refresh:h}=XW(n.claude),{data:f,loading:p,refresh:g}=ZW(n.codex),{data:v}=JW(n.codex),k=k$(),{byModel:b,totalCost:x,totalTokens:N,burnRate:S}=lH(e,t,l),_=w.useMemo(()=>vW(e.agents.values()),[e,e.revision]),[E,T]=w.useState(MW);w.useEffect(()=>{$W(E)},[E]);const[A,R]=w.useState(IW);w.useEffect(()=>{OW(A)},[A]);const[B,P]=w.useState(0),D=w.useRef(()=>new Map);D.current=()=>l==null?null:jx(e.agents.values(),t);const O=w.useCallback(()=>D.current(),[]),{data:L,shown:z,stale:M,loading:$,baseline:q}=QW(E,B,O),X=L!=null,H=$&&M,I=w.useMemo(()=>hH(e.agents.values()),[e,e.revision]),W=w.useMemo(()=>fH(e.agents.values()),[e,e.revision]),F=w.useMemo(()=>X?l$(L):[],[L,X]),Y=w.useMemo(()=>X?pH(EW(L,I).slice(0,12)):[],[L,X,I]),J=w.useMemo(()=>Ud(L),[L]),V=w.useMemo(()=>CW(L,J.cost),[L,J.cost]),G=c$(z,E),K=w.useMemo(()=>X?NW(q,jx(e.agents.values(),t)):Nx,[e,e.revision,q,X,t]),Z=RW(L,{...N,cost:x},K),ee=Z.hasCost,re=Z.tokenSum,ue=_a(Z.cost),me=_a(Z.inputTokens),ae=_a(Z.outputTokens),pe=_a(Z.cacheReadTokens),xe=_a(Z.cacheCreateTokens),se=b.filter(Dj),ve=_.filter(Dj),fe=uH(X,F,se),he=d||p,_e=()=>{h(),g(),P(Le=>Le+1)},Fe=dH(n);return a.jsxs("aside",{className:`usage-panel${s?" leaving":""}`,id:"usage-panel","aria-label":"Usage",children:[a.jsxs("div",{className:"up-header",children:[a.jsx("h2",{children:"Usage"}),S&&a.jsxs("span",{className:"up-rate",title:`Spend on this board over the last ${S.spanMin} min`,children:[S.label,a.jsxs("span",{className:"up-rate-span",children:[" · ",S.spanMin," min"]})]}),a.jsxs("div",{className:"up-header-right",children:[(n.claude||n.codex)&&a.jsx("button",{type:"button",className:"glyph-btn up-refresh-btn",onClick:_e,...Ir(he),"aria-label":Fe,title:Fe,children:he?"…":"↻"}),a.jsx("button",{type:"button",className:"glyph-btn up-close",onClick:o,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),n.claude&&a.jsx(zW,{quota:u,quotaLoading:d,nowSec:k,incident:r.find(Le=>Le.provider==="claude")}),n.codex&&a.jsx(WW,{codexQuota:f,codexLoading:p,codexUsage:v,nowSec:k,incident:r.find(Le=>Le.provider==="codex")}),X&&a.jsx(VW,{period:E,rangePending:H,setPeriod:T}),re>0?a.jsxs(a.Fragment,{children:[ee&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"up-total",title:X?void 0:Mj,children:[a.jsx("span",{className:"up-total-value",children:qe(ue)}),a.jsx("span",{className:"up-total-label",children:X?G:mW})]}),Z.showCostBar&&a.jsx(qb,{cost:x})]}),a.jsxs("div",{className:"up-tokens-row",title:X?void 0:Mj,children:[a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"in"}),ot(me)]}),a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"out"}),ot(ae)]}),Z.cacheReadTokens>0&&a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"cache r"}),ot(pe)]}),Z.cacheCreateTokens>0&&a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"cache c"}),ot(xe)]}),!ee&&a.jsx("span",{className:"up-tok up-scope",children:gW})]}),(X?F.length:se.length)>0&&a.jsx(HW,{fromRange:X,rangeModelRows:F,boardModelRows:se}),X&&Y.length===0&&J.tokens>0&&a.jsxs("section",{className:"up-section",children:[a.jsx("h3",{className:"up-section-title",children:"By session"}),a.jsxs("div",{className:"up-hint",children:["No session is dated ",G," yet — ccusage dates sessions in UTC, and the totals above are your local day."]})]}),(X?Y.length:ve.length)>0&&a.jsx(GW,{fromRange:X,rangeSessionRows:Y,boardSessionRows:ve,boardStates:W,sessionsOpen:A,setSessionsOpen:R,periodNoun:G,sessionScale:V}),fe&&a.jsxs("div",{className:"up-hint",children:["“",hs,"” means this build holds no published rate for that model — those tokens are counted above and their dollars are not."]})]}):a.jsx("div",{className:"up-empty",children:X?(z??E)==="all"?a.jsx(a.Fragment,{children:"No usage in any transcript on this machine."}):a.jsxs(a.Fragment,{children:["No usage ",G,".",a.jsx("br",{}),"Try a longer period."]}):a.jsxs(a.Fragment,{children:["No usage data yet.",a.jsx("br",{}),"Start a Claude Code or Codex session."]})})]})}function gH(e,t,n){return e>=n?"hot":e>=t?"warn":"calm"}function yH(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}% ${wH(t.lastMs,n)}`:"running at full speed, and never held back"}}function wH(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 vH(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 xH(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 bH(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 kH=3e3;function NH(){const[e,t]=w.useState(null),n=w.useRef(null);return w.useEffect(()=>{let r=!0;const s=async()=>{if(document.visibilityState!=="hidden")try{const d=await fetch("/api/system");if(!d.ok)return;const h=await d.json();r&&(h!=null&&h.ok)&&t(h)}catch{}},o=()=>{n.current==null&&(s(),n.current=window.setInterval(s,kH))},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 jH(e,t){return!e||e.key!==t?"none":e.dir==="asc"?"ascending":"descending"}function wl({col:e,label:t,note:n,sort:r,next:s,onSort:o,className:l}){const u=jH(r,e);return a.jsx("th",{scope:"col","aria-sort":u,className:l,children:a.jsxs("button",{type:"button",className:"sd-sort",title:n?`Sort by ${t}
80
+
81
+ ${n}`:`Sort by ${t}`,onClick:()=>o(s(r,e)),children:[t,a.jsx("span",{className:"sd-sort-dir","aria-hidden":!0,children:u==="none"?"":u==="ascending"?"↑":"↓"})]})})}function yp(e){return e<9.95?e.toFixed(1):String(Math.round(e))}function Ub(e){const t=Number.isFinite(e)?Math.max(0,e):0;return t<50?{value:"0",unit:"KB/s"}:t<999500?{value:yp(t/1e3),unit:"KB/s"}:t<9995e5?{value:yp(t/1e6),unit:"MB/s"}:{value:yp(t/1e9),unit:"GB/s"}}function Wd(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 Ul(e){return e.unit?e.unit==="%"||e.unit==="°C"?`${e.value}${e.unit}`:`${e.value} ${e.unit}`:e.value}function wp(e,t){return t==="B/s"?Ub(e):t==="ms"?Wd(e):{value:String(e),unit:t==="C"?"°C":t}}const _t={l:30,r:6,t:6,b:2},Ws={l:0,r:0,t:2,b:1},Hd=104,SH=64;function or(e,t=100,n=Hd,r=_t){const s=n-r.t-r.b;return r.t+s*(1-Math.max(0,Math.min(t,e))/t)}function N$(e,t,n,r=100,s=Hd,o=_t){if(!e.length)return"";const l=e[e.length-1].t-e[0].t,u=f=>{const p=t-o.l-o.r;return o.l+(l>0?p*(f-e[0].t)/l:p/2)};let d="",h=null;for(const f of e){const p=h&&f.t-h.t<=n*2?"L":"M";d+=`${p}${u(f.t).toFixed(1)} ${or(f.v,r,s,o).toFixed(1)}`,h=f}return d}function j$(e,t,n,r=100,s=Hd,o=_t){if(e.length<2)return"";const l=s-o.b,u=e[e.length-1].t-e[0].t,d=t-o.l-o.r,h=v=>o.l+(u>0?d*(v-e[0].t)/u:d/2);let f="",p=[];const g=()=>{if(p.length>=2){let v=`M${h(p[0].t).toFixed(1)} ${l}`;for(const k of p)v+=`L${h(k.t).toFixed(1)} ${or(k.v,r,s,o).toFixed(1)}`;f+=`${v}L${h(p[p.length-1].t).toFixed(1)} ${l}Z`}p=[]};for(const v of e)p.length&&v.t-p[p.length-1].t>n*2&&g(),p.push(v);return g(),f}function _H(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 S$(e,t,n){return n!=null&&e>=n?"hot":t!=null&&e>=t?"warn":""}function EH(e,t,n=r=>Ea(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 Ea(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function zb(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 CH({group:e,title:t,onClose:n}){const r=ft(n),[s,o]=w.useState(null);w.useEffect(()=>{let h=!0;const f=async()=>{try{const g=await fetch(`/api/system/history?group=${e}`);if(!g.ok)return;const v=await g.json();h&&(v!=null&&v.ok)&&o(v)}catch{}};f();const p=window.setInterval(f,2e4);return()=>{h=!1,window.clearInterval(p)}},[e]);const l=(s==null?void 0:s.series)??[],[u,d]=w.useMemo(()=>{let h=1/0,f=0;for(const p of l)p.points.length&&(h=Math.min(h,p.points[0].t),f=Math.max(f,p.points[p.points.length-1].t));return[Number.isFinite(h)?Math.max(h,(s==null?void 0:s.sinceMs)??0):(s==null?void 0:s.sinceMs)??0,f]},[l,s==null?void 0:s.sinceMs]);return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal hist-modal",onClick:h=>h.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"hist-modal-title",children:[a.jsxs("div",{className:"modal-head",children:[a.jsx("span",{className:"modal-title",id:"hist-modal-title",children:t}),s&&u>0&&a.jsxs("span",{className:"hist-since",children:["since ",Ea(u)," · ",zb(u,d||Date.now())]}),a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),a.jsx("div",{className:"hist-body",children:s==null?a.jsx("p",{className:"hist-empty",children:"Reading…"}):l.length===0?a.jsx("p",{className:"hist-empty",children:"Nothing has been measured yet."}):l.map(h=>a.jsx(TH,{series:h,stepMs:s.stepMs},h.label))})]})}),document.body)}function TH({series:e,stepMs:t}){const n=w.useRef(null),[r,s]=w.useState(560),[o,l]=w.useState(null);w.useEffect(()=>{const P=n.current;if(!P||typeof ResizeObserver>"u")return;const D=new ResizeObserver(([O])=>s(Math.max(160,O.contentRect.width)));return D.observe(P),()=>D.disconnect()},[]);const{points:u,unit:d,warnAt:h,critAt:f,label:p,top:g,restsAtZero:v,changes:k}=e,b=v?SH:Hd,{now:x,peak:N}=_H(u),S=x!=null?wp(x,d):null,_=N!=null?wp(N,d):null,E=p==="Throttling"?EH(u,t):null,T=o!=null?u[o]:null,A=u.length>1?u[u.length-1].t-u[0].t:0,R=P=>{const D=r-_t.l-_t.r;return _t.l+(A>0?D*(P-u[0].t)/A:D/2)},B=P=>{if(u.length<2)return;const D=P.currentTarget.getBoundingClientRect(),O=(P.clientX-D.left-_t.l)/Math.max(1,D.width-_t.l-_t.r),L=u[0].t+A*Math.max(0,Math.min(1,O));let z=0;for(let M=1;M<u.length;M++)Math.abs(u[M].t-L)<Math.abs(u[z].t-L)&&(z=M);l(z)};return a.jsxs("section",{className:"hist-series","aria-label":`${p} history`,children:[a.jsxs("div",{className:"hist-head",children:[a.jsx("span",{className:"hist-label",children:p}),a.jsxs("span",{className:"hist-stats",children:[S&&a.jsxs(a.Fragment,{children:[a.jsx("b",{children:S.value}),a.jsxs("span",{children:[S.unit," now"]})]}),N!=null&&_&&a.jsxs(a.Fragment,{children:[a.jsx("b",{className:S$(N,h,f),children:_.value}),a.jsxs("span",{children:[_.unit," peak"]})]})]})]}),a.jsx("div",{className:"hist-plot",ref:n,children:a.jsxs("svg",{className:"hist-chart",width:"100%",height:b,viewBox:`0 0 ${r} ${b}`,preserveAspectRatio:"none",role:"img","aria-label":S==null||_==null?`${p}: nothing measured yet`:`${p}: ${Ul(S)} now, peak ${Ul(_)}, over ${zb(u[0].t,u[u.length-1].t)}`,onPointerMove:B,onPointerLeave:()=>l(null),children:[[["warn",h],["hot",f]].map(([P,D])=>D==null||D>g?null:a.jsxs("g",{children:[a.jsx("line",{className:`hist-rule ${P}`,x1:_t.l,x2:r-_t.r,y1:or(D,g,b),y2:or(D,g,b)}),a.jsx("text",{className:`hist-rule-tag ${P}`,x:2,y:or(D,g,b)+3,children:D})]},P)),a.jsx("line",{className:"hist-floor",x1:_t.l,x2:r-_t.r,y1:b-_t.b,y2:b-_t.b}),(k??[]).filter(P=>P.from!=null&&u.length>1&&P.t>=u[0].t&&P.t<=u[u.length-1].t).map(P=>a.jsx("line",{className:"hist-mark",x1:R(P.t),x2:R(P.t),y1:_t.t,y2:b-_t.b},P.t)),a.jsx("path",{className:"hist-area",d:j$(u,r,t,g,b)}),a.jsx("path",{className:"hist-line",d:N$(u,r,t,g,b)}),u.length===1&&a.jsx("circle",{className:"hist-dot",cx:R(u[0].t),cy:or(u[0].v,g,b),r:3}),T&&a.jsxs("g",{children:[a.jsx("line",{className:"hist-cross",x1:R(T.t),x2:R(T.t),y1:_t.t,y2:b-_t.b}),a.jsx("circle",{className:"hist-dot",cx:R(T.t),cy:or(T.v,g,b),r:3})]})]})}),a.jsx("div",{className:"hist-axis",children:T?a.jsxs("span",{className:"hist-at",children:[Ea(T.t)," — ",(()=>{const P=wp(T.v,d);return a.jsxs(a.Fragment,{children:[a.jsx("b",{children:P.value}),P.unit==="%"||P.unit==="°C"||!P.unit?P.unit:` ${P.unit}`]})})()]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{children:u.length?Ea(u[0].t):""}),a.jsx("span",{children:u.length?Ea(u[u.length-1].t):""})]})}),E&&a.jsx("div",{className:"hist-note",children:E}),k==null?void 0:k.slice(-3).map(P=>a.jsx("div",{className:"hist-note hist-route",children:P.from==null?`Since ${Ea(P.t)} — ${P.label}`:`${Ea(P.t)} — ${P.label.charAt(0).toUpperCase()+P.label.slice(1)}`},P.t))]})}const AH="thermal:Throttling";function RH(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[AH]=Math.max(0,100-e.thermal.throttle.speedLimit)),t}function _l(e,t){return t==="B/s"?Ul(Ub(e)):t==="ms"?Ul(Wd(e)):t==="C"?`${Math.round(e)}°`:t==="%"?`${Math.round(e)}%`:e.toFixed(2)}function ku(e,t){return t==="B/s"||t==="ms"||!Number.isInteger(e)?_l(e,t):t==="C"?`${e}°`:t==="%"?`${e}%`:`${e}`}const Fj=["cores","memory","load","thermal"],Na=116,Ar=24,MH=60,$H=6e4;function IH(e){return e.points.length?e.restsAtZero?e.points.some(t=>t.v>0):!0:!1}function OH(e){return e.unit==="C"?`${e.label} temp`:e.key==="mem:physical"?"Physical RAM":e.key==="mem:swap"?`${e.label} memory`:e.label}function LH(e,t=MH){return e.points.length<=t?e:{...e,points:e.points.slice(-t)}}function PH({sys:e}){const[t,n]=w.useState({});w.useEffect(()=>{let l=!0;const u=async()=>{const h=await Promise.all(Fj.map(async f=>{try{const p=await fetch(`/api/system/history?group=${f}`);return p.ok?[f,await p.json()]:[f,null]}catch{return[f,null]}}));l&&n(f=>{const p={...f};for(const[g,v]of h)v!=null&&v.ok&&(p[g]=v);return p})};u();const d=setInterval(()=>void u(),$H);return()=>{l=!1,clearInterval(d)}},[]);const r=w.useMemo(()=>RH(e),[e]),s=w.useMemo(()=>Fj.flatMap(l=>{const u=t[l];return u?u.series.filter(IH).map(d=>({series:LH(d),stepMs:u.stepMs})):[]}),[t]),o=w.useMemo(()=>{let l=1/0,u=-1/0;for(const{series:d}of s){const h=d.points;h.length&&(l=Math.min(l,h[0].t),u=Math.max(u,h[h.length-1].t))}return Number.isFinite(l)?zb(l,u):"less than a minute"},[s]);return Object.keys(r).length?a.jsx("div",{className:"pl-strip",role:"group","aria-label":`This machine, over the last ${o}`,children:s.map(({series:l,stepMs:u})=>a.jsx(DH,{series:l,stepMs:u,now:r[l.key],span:o},l.key))}):null}function DH({series:e,stepMs:t,now:n,span:r}){var v;const{points:s,top:o,unit:l,warnAt:u,critAt:d}=e,h=OH(e),f=n??((v=s[s.length-1])==null?void 0:v.v),p=f==null?"":S$(f,u,d),g=Math.max(...s.map(k=>k.v));return a.jsxs("div",{className:`pl-cell${p?` ${p}`:""}`,title:[`${h} · peak ${_l(g,l)} over the last ${r}`,u!=null?`over ${ku(u,l)} is uncomfortable`:"",d!=null?`over ${ku(d,l)} the machine acts`:""].filter(Boolean).join(" · "),children:[a.jsxs("div",{className:"pl-cell-head",children:[a.jsx("span",{className:"pl-cell-label",children:h}),a.jsx("span",{className:"pl-cell-now",children:f==null?"—":_l(f,l)})]}),a.jsxs("svg",{className:"pl-spark",width:Na,height:Ar,viewBox:`0 0 ${Na} ${Ar}`,preserveAspectRatio:"none","aria-hidden":!0,children:[a.jsx("line",{className:"pl-spark-floor",x1:0,x2:Na,y1:Ar-Ws.b,y2:Ar-Ws.b}),a.jsx("path",{className:"pl-spark-area",d:j$(s,Na,t,o,Ar,Ws)}),u!=null&&a.jsx("line",{className:"pl-rule warn",x1:0,x2:Na,y1:or(u,o,Ar,Ws),y2:or(u,o,Ar,Ws)}),d!=null&&a.jsx("line",{className:"pl-rule hot",x1:0,x2:Na,y1:or(d,o,Ar,Ws),y2:or(d,o,Ar,Ws)}),a.jsx("path",{className:"pl-spark-line",d:N$(s,Na,t,o,Ar,Ws)})]}),a.jsxs("span",{className:"vis-hidden",children:["peak ",_l(g,l)," over the last ",r,u!=null&&`, uncomfortable over ${ku(u,l)}`,d!=null&&`, the machine acts over ${ku(d,l)}`]})]})}const _$={key:"cpu",dir:"desc"};function FH(e,t){return e.key===t?{...e,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:t==="name"||t==="user"?"asc":"desc"}}function BH(e,t){const n=t.dir==="asc"?1:-1,r=o=>t.key==="cpu"?o.cpu:t.key==="mem"?o.mem:t.key==="rss"?o.rssBytes:t.key==="threads"?o.threads:o.uptimeSec,s=(o,l)=>{if(t.key==="name")return n*o.name.localeCompare(l.name,void 0,{sensitivity:"base"});if(t.key==="user"){const h=o.user??"",f=l.user??"";return!h||!f?h===f?0:h?-1:1:n*h.localeCompare(f,void 0,{sensitivity:"base"})}const u=r(o),d=r(l);return u==null||d==null?u==null?d==null?0:1:-1:n*(u-d)};return[...e].sort((o,l)=>s(o,l)||(l.cpu??-1)-(o.cpu??-1)||l.mem-o.mem||o.pid-l.pid)}const qH=4e3;function UH(e,t){const n=t!=null&&t.ok&&Array.isArray(t.procs)?t.procs:[];return n.length?{procs:n,total:t.total??0}:e??{procs:[],total:0}}function zH(){const[e,t]=w.useState(null);return w.useEffect(()=>{let n=!0;const r=async()=>{if(document.visibilityState!=="hidden")try{const o=await fetch("/api/system/processes?detail=1");if(!o.ok)return;const l=await o.json();n&&t(u=>UH(u,l))}catch{}};r();const s=window.setInterval(r,qH);return()=>{n=!1,window.clearInterval(s)}},[]),e}function WH(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 HH({sys:e,onClose:t}){const n=ft(t),[r,s]=w.useState(_$),o=zH();return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:a.jsx("div",{ref:n,className:"modal pl-modal",onClick:l=>l.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"pl-modal-title",children:a.jsx(VH,{read:o,sort:r,onSort:s,sys:e,onClose:t})})}),document.body)}function VH({read:e,sort:t,onSort:n,sys:r,onClose:s}){const o=e?BH(e.procs,t):null;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"modal-head",children:[a.jsx("span",{className:"modal-title",id:"pl-modal-title",children:"Busiest processes"}),o!=null&&o.length>0&&a.jsxs("span",{className:"pl-count",children:[o.length," of ",e.total," running"]}),a.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),a.jsxs("div",{className:"pl-split",children:[a.jsx("div",{className:"pl-body",children:o==null?a.jsx("p",{className:"pl-empty",children:"Reading the process list…"}):o.length===0?a.jsx("p",{className:"pl-empty",children:"Could not read the process list — retrying."}):a.jsxs("table",{className:"sd-procs pl-table",children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx($o,{col:"cpu",label:"cpu",sort:t,onSort:n}),a.jsx($o,{col:"rss",label:"memory",note:"Resident set size, which is what ps and Task Manager report; macOS Activity Monitor shows a different figure.",sort:t,onSort:n}),a.jsx($o,{col:"threads",label:"threads",sort:t,onSort:n}),a.jsx($o,{col:"uptime",label:"up",sort:t,onSort:n}),a.jsx($o,{col:"user",label:"user",sort:t,onSort:n}),a.jsx("th",{scope:"col",className:"pl-pid-h",children:"pid"}),a.jsx($o,{col:"name",label:"process",note:"Command lines have anything secret-shaped removed, which is a filter and not a guarantee.",sort:t,onSort:n})]})}),a.jsx("tbody",{children:o.map(l=>a.jsxs("tr",{children:[a.jsx("td",{className:"sd-num",children:l.cpu==null?"—":l.cpu.toFixed(0)}),a.jsx("td",{className:"sd-num sd-dim",title:`${l.mem.toFixed(1)}% of installed memory`,children:Sa(l.rssBytes)}),a.jsx("td",{className:"sd-num sd-dim",children:l.threads??"—"}),a.jsx("td",{className:"sd-num sd-dim",children:WH(l.uptimeSec)}),a.jsx("td",{className:"sd-dim pl-user",children:l.user??"—"}),a.jsx("td",{className:"sd-num sd-dim pl-pid",children:l.pid}),a.jsxs("td",{className:"pl-name",children:[l.name,l.cmd&&a.jsxs("span",{className:"pl-cmd",title:l.cmd,children:[" ",l.cmd]})]})]},l.pid))})]})}),a.jsx(PH,{sys:r})]})]})}function $o(e){return a.jsx(wl,{...e,next:(t,n)=>FH(t??_$,n)})}function Ex({value:e,unit:t,cap:n}){return t?a.jsxs("span",{className:"sd-fig",children:[a.jsx("span",{className:"sd-fig-cap",children:n}),a.jsxs("span",{className:"sd-fig-read",children:[a.jsx("b",{children:e})," ",a.jsx("span",{className:"sd-fig-unit",children:t})]})]}):a.jsxs("span",{className:"sd-fig",children:[a.jsx("b",{children:e}),a.jsx("span",{className:"sd-fig-cap",children:n})]})}function zl({group:e,title:t,action:n,label:r,value:s,hint:o,children:l}){const[u,d]=w.useState(!1),h=w.useRef(null),f=()=>{var p,g;((p=window.getSelection())==null?void 0:p.isCollapsed)!==!1&&((g=h.current)==null||g.focus({preventScroll:!0}),d(!0))};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"sd-reading",onClick:f,children:[a.jsx("button",{ref:h,type:"button",className:"sd-open",onClick:()=>d(!0),title:n,"aria-label":s==null?`${r}: show history`:`${r}: show history, now ${s}`,"aria-describedby":o?`sd-hint-${e}`:void 0,children:a.jsxs("span",{className:"sd-h","aria-hidden":!0,children:[r," ",a.jsx("i",{className:"sd-row-more",children:"›"}),s!=null&&a.jsx("span",{className:"sd-h-val",children:s})]})}),l]}),o&&a.jsx("span",{id:`sd-hint-${e}`,className:"vis-hidden",children:o}),u&&a.jsx(CH,{group:e,title:t,onClose:()=>d(!1)})]})}function cd({label:e,value:t,pct:n,tone:r="calm",note:s,mark:o,title:l,trackLabel:u}){return a.jsxs("div",{className:"sd-row",title:l,children:[a.jsxs("div",{className:"sd-row-head",children:[a.jsx("span",{className:"sd-row-label",children:e}),a.jsx("span",{className:"sd-row-val",children:t})]}),a.jsxs("span",{className:"sd-track",role:u?"img":void 0,"aria-label":u,children:[a.jsx("span",{className:`sd-fill${r==="calm"?"":` ${r}`}`,style:{transform:`scaleX(${n<=0?0:Math.max(1,Math.min(100,n))/100})`}}),o!=null&&o>0&&o<100&&a.jsx("span",{className:"sd-mark",style:{left:`${o}%`},"aria-hidden":!0})]}),s&&a.jsx("div",{className:"sd-note",children:s})]})}function GH(e,t,n){if(n<=0||Od(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 Xs=4,On=8;function Wb(e,t,n){const r=n.width-On-(e.right+Xs),s=e.left-Xs-On,o=t.width<=r||r>=s?"right":"left",l=o==="right"?e.right+Xs:e.left-Xs-t.width,u=n.height-On*2,d=t.height<=u,h=d?t.height:Math.max(0,u),f=Math.max(On,Math.min(e.top,n.height-On-h)),p=Math.max(On,Math.min(l,n.width-On-t.width));return{top:f,left:p,side:o,maxHeight:d?null:h}}function KH(e,t,n){const r=n.height-On-(e.bottom+Xs),s=e.top-Xs-On,o=t.height<=r||r>=s?"below":"above",l=o==="below"?r:s,u=t.height<=l,d=u?t.height:Math.max(0,l),h=o==="below"?e.bottom+Xs:e.top-Xs-d,f=Math.max(On,Math.min(e.right-t.width,n.width-On-t.width));return{top:Math.max(On,h),left:f,side:o,maxHeight:u?null:d}}function YH(e,t,n){return!(!e||t!=null&&t.contains(e)||n!=null&&n.contains(e))}function E$(e,t,n){const r=w.useRef(t);r.current=t;const s=w.useRef(n);s.current=n,w.useEffect(()=>{const o=l=>{YH(l.target,e.current,r.current())&&s.current()};return window.addEventListener("pointerdown",o,!0),()=>window.removeEventListener("pointerdown",o,!0)},[e])}const C$='[role="menuitem"]';function Bj(e){return e?Array.from(e.querySelectorAll(C$)).filter(t=>!t.disabled):[]}function Hb({anchorId:e,boundaryId:t,id:n,className:r,role:s,labelledBy:o,start:l="first",onClose:u,children:d}){const h=w.useRef(u);h.current=u;const f=ft(()=>{var b;(b=document.getElementById(e))==null||b.focus(),h.current()},{popover:!0}),p=w.useCallback(()=>{var E;const b=f.current;if(!b)return;const x=document.getElementById(e);if(!x){h.current();return}const N=x.getBoundingClientRect(),S=t?(E=document.getElementById(t))==null?void 0:E.getBoundingClientRect():null;if(S&&(N.bottom<=S.top||N.top>=S.bottom)){b.contains(document.activeElement)&&x.focus({preventScroll:!0}),h.current();return}b.style.maxHeight="";const _=KH(N,{width:b.offsetWidth,height:b.offsetHeight},{width:window.innerWidth,height:window.innerHeight});b.style.top=`${_.top}px`,b.style.left=`${_.left}px`,b.style.maxHeight=_.maxHeight==null?"":`${_.maxHeight}px`,b.dataset.side=_.side},[e,t,f]);w.useLayoutEffect(()=>{p()}),w.useEffect(()=>{const b=x=>{var N;(N=f.current)!=null&&N.contains(x.target)||p()};return window.addEventListener("scroll",b,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",p)}},[p,f]),E$(f,()=>document.getElementById(e),u),w.useEffect(()=>{var x;if(s!=="menu")return;const b=Bj(f.current);(x=l==="last"?b[b.length-1]:b[0])==null||x.focus()},[]);const g=b=>{var x;if(s==="menu"&&b.key==="Tab"){b.stopPropagation(),(x=document.getElementById(e))==null||x.focus(),b.shiftKey&&b.preventDefault(),h.current();return}if(s==="menu"){const N=Bj(f.current),S=GH(b,N.indexOf(document.activeElement),N.length);S.kind==="focus"&&(b.preventDefault(),N[S.index].focus())}b.key.length===1&&b.stopPropagation()},v=b=>{b.target.closest("button, input, select, textarea, code")||b.preventDefault()},k=b=>{if(s!=="menu"||b.pointerType==="touch")return;const x=b.target.closest(C$);x&&!x.disabled&&document.activeElement!==x&&x.focus({preventScroll:!0})};return Lt.createPortal(a.jsx("div",{ref:f,id:n,className:`anchored-popover${r?` ${r}`:""}`,role:s,"aria-labelledby":o,onKeyDown:g,onMouseDown:v,onPointerMove:k,children:d}),document.body)}function XH({network:e}){const{down:t,up:n,api:r,route:s}=e,[o,l]=w.useState(!1),u=r&&r.ms!=null?Wd(r.ms):null,d=t!=null&&n!=null;return a.jsxs("div",{className:"sd-section",role:"group","aria-label":"Network",children:[a.jsxs(zl,{group:"network",title:"Network history",action:"Show network history",label:"Network",children:[(d||u)&&a.jsxs("div",{className:"sd-figs sd-figs-named",children:[d&&[["Download",t],["Upload",n]].map(([h,f])=>{const p=Ub(f);return a.jsx(Ex,{value:p.value,unit:p.unit,cap:h},h)}),u&&a.jsx(Ex,{value:u.value,unit:u.unit,cap:"Claude API"})]}),!d&&a.jsx("div",{className:"sd-note",children:"measuring…"}),r&&r.ms==null&&a.jsx("div",{className:"sd-note sd-note-warn",children:"Can’t reach Claude"})]}),s&&a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:"sd-detail",id:"sd-conn","aria-expanded":o,"aria-haspopup":"dialog",onClick:()=>l(h=>!h),children:["Connection details",s.relay&&a.jsx("span",{className:"sd-route-relay",children:" · relayed"}),a.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),o&&a.jsx(ZH,{route:s,api:r,onClose:()=>l(!1)})]})]})}function ZH({route:e,api:t,onClose:n}){return a.jsxs(Hb,{anchorId:"sd-conn",boundaryId:"system-panel",id:"sd-conn-pop",className:"sd-pop",role:"dialog",labelledBy:"sd-conn-title",onClose:n,children:[a.jsx("p",{className:"sd-pop-title",id:"sd-conn-title",children:"Connection"}),a.jsxs("dl",{className:"sd-pop-rows",children:[a.jsxs("div",{className:"sd-pop-row",children:[a.jsx("dt",{children:e.to==="claude"?"Traffic to Claude":"Internet traffic"}),a.jsxs("dd",{children:["through ",bH(e)]})]}),e.relay&&a.jsxs("div",{className:"sd-pop-row",children:[a.jsx("dt",{children:"Relay"}),a.jsxs("dd",{children:[a.jsx("span",{className:"sd-route-relay",children:e.relay})," — not a direct path, so every packet carries one more round trip than it has to"]})]}),t&&a.jsxs("div",{className:"sd-pop-row",children:[a.jsx("dt",{children:"Round trip"}),a.jsx("dd",{children:t.ms==null?`${t.host} did not answer`:`${Ul(Wd(t.ms))} to open a connection to ${t.host}`})]}),a.jsxs("div",{className:"sd-pop-row",children:[a.jsx("dt",{children:"Throughput"}),a.jsx("dd",{children:"every interface on this machine, not this path alone"})]})]})]})}function qj({usageOpen:e,leaving:t,sub:n,flag:r,onClose:s,children:o}){return a.jsxs("aside",{className:`sysdetail${e?" shifted":""}${t?" leaving":""}`,id:"system-panel","aria-labelledby":"sd-title",children:[a.jsxs("div",{className:"sd-top",children:[a.jsxs("div",{className:"sd-head",children:[a.jsx("h2",{className:"sd-title",id:"sd-title",children:"This machine"}),n&&a.jsx("span",{className:"sd-sub",children:n}),a.jsx("button",{type:"button",className:"glyph-btn sd-close",onClick:s,"aria-label":"Close",title:"Close",children:"×"})]}),r&&a.jsx("p",{className:"sd-flag",children:r})]}),o]})}function JH({usageOpen:e,leaving:t,onClose:n}){const r=NH();if(!r||r.cpu==null||!r.memory)return a.jsx(qj,{usageOpen:e,leaving:t,onClose:n,children:a.jsx("div",{className:"sd-note",children:"reading this machine…"})});const{memory:s,swap:o,perCore:l,loadavg:u,cores:d,uptimeSec:h,platform:f,thermal:p,network:g,cpu:v}=r;return a.jsxs(qj,{usageOpen:e,leaving:t,sub:`up ${vH(h)} · ${d} cores`,flag:xH(r),onClose:n,children:[a.jsx(QH,{cpu:v,perCore:l,loadavg:u,cores:d}),a.jsx(e7,{memory:s,swap:o,platform:f}),g&&a.jsx(XH,{network:g}),a.jsx(t7,{thermal:p}),a.jsx(n7,{sys:r})]})}function QH({cpu:e,perCore:t,loadavg:n,cores:r}){const s=!!t&&t.length>0;return!s&&!n?null:a.jsxs("div",{className:"sd-section sd-cpu",role:"group","aria-label":"CPU",children:[s&&a.jsx(zl,{group:"cores",title:"Core history",action:"Show core history",label:"CPU",value:e==null?null:`${Math.round(e)}%`,children:a.jsx("div",{className:"sd-cores",role:"img","aria-label":`${t.length} logical cores, busiest at ${Math.round(Math.max(...t))}%`,children:t.map((o,l)=>a.jsx("span",{className:"sd-core",title:`logical core ${l+1} · ${o}% busy`,children:a.jsx("span",{className:"sd-core-fill",style:{transform:`scaleY(${Math.max(2,o)/100})`}})},l))})}),n&&a.jsxs(zl,{group:"load",title:"Load history",action:"Show load history",label:"Load average",hint:"the queue for the cores, counted in tasks rather than as a share of them",children:[a.jsx("div",{className:"sd-figs",title:"The queue for this machine's cores, averaged over one, five and fifteen minutes. A count of tasks, not a share of the CPU.",children:n.map((o,l)=>a.jsx(Ex,{value:o.toFixed(2),cap:["1m","5m","15m"][l]},l))}),n[0]>r&&a.jsx("div",{className:"sd-note",children:`${(n[0]/r).toFixed(1)}× more work queued than cores to run it`})]})]})}function e7({memory:e,swap:t,platform:n}){const r=e.total-e.available,s=n==="win32"?"Commit":"Swap",o=t&&t.total>0?t.used/t.total*100:0;return a.jsx("div",{className:"sd-section",role:"group","aria-label":"Memory",children:a.jsxs(zl,{group:"memory",title:"Memory history",action:"Show memory history",label:"Memory",children:[a.jsx(cd,{label:"Physical",value:a.jsxs(a.Fragment,{children:[a.jsx("b",{children:Sa(r)})," of ",Sa(e.total)]}),pct:e.usedPct,tone:e.usedPct>=90?"warn":"calm",note:`${Sa(e.available)} available`}),t&&t.total>0&&a.jsx(cd,{label:s,value:a.jsxs(a.Fragment,{children:[a.jsx("b",{children:Sa(t.used)})," of ",Sa(t.total)]}),pct:o,tone:o>=90?"warn":"calm"})]})})}function t7({thermal:e}){if(!e)return null;const t=e.throttle?yH(e.throttle.speedLimit,e.heldBack):null;return a.jsx("div",{className:"sd-section",role:"group","aria-label":"Thermal",children:a.jsxs(zl,{group:"thermal",title:"Thermal history",action:"Show thermal history",label:"Thermal",children:[e.celsius.map(n=>a.jsx(cd,{label:n.label,value:a.jsxs(a.Fragment,{children:[a.jsx("b",{children:n.celsius})," °C"]}),pct:n.celsius/n.critAt*100,mark:n.warnAt/n.critAt*100,tone:gH(n.celsius,n.warnAt,n.critAt),title:`bar runs 0–${n.critAt} °C · amber from ${n.warnAt} °C, red at ${n.critAt} °C`,trackLabel:`${n.celsius} °C on a bar that runs to ${n.critAt} °C, amber from ${n.warnAt} °C`},n.label)),t&&a.jsx(cd,{label:"Throttling",value:a.jsx("b",{children:t.value}),pct:t.pct,tone:t.tone,note:t.note})]})})}function n7({sys:e}){const[t,n]=w.useState(!1);return a.jsxs("div",{className:"sd-section sd-door-section",children:[a.jsx("button",{type:"button",className:"sd-open sd-door",onClick:()=>n(!0),"aria-label":"Busiest processes: show every process the deck is watching",children:a.jsxs("span",{className:"sd-door-plate",children:[a.jsxs("span",{className:"sd-door-name",children:["Busiest processes",a.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),a.jsx("span",{className:"sd-door-sub",children:"every process, with its command line"})]})}),t&&a.jsx(HH,{sys:e,onClose:()=>n(!1)})]})}function T$(e){return{inputTokens:e.i,outputTokens:e.o,cacheReadTokens:e.cr,cacheCreateTokens:e.cc,cacheCreate1hTokens:e.c1h,cacheCreate5mTokens:e.c5m}}function r7(e){return{...T$(e),cacheCreate1hTokens:0,cacheCreate5mTokens:0}}function A$(e){return e.i+e.o+e.cr+e.cc}function Uj(e){let t=0;for(const n of Object.values(e))t+=A$(n);return t}function s7(e){const t=s=>typeof s=="number"&&Number.isFinite(s)?s:0,n=new Map,r=e&&Array.isArray(e.days)?e.days:[];for(const s of r){const o=typeof s.period=="string"?s.period:"",l=Array.isArray(s.modelBreakdowns)?s.modelBreakdowns:[];for(const u of l){const d=typeof u.modelName=="string"?u.modelName:"";if(!o||!/claude/i.test(d)||u.missingPricing===!0)continue;const h=`${o}|${d}`,f=n.get(h),p=f?f.usage:{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,cacheCreate1hTokens:0,cacheCreate5mTokens:0};p.inputTokens+=t(u.inputTokens),p.outputTokens+=t(u.outputTokens),p.cacheReadTokens+=t(u.cacheReadTokens),p.cacheCreateTokens+=t(u.cacheCreationTokens),f?f.cost+=t(u.cost):n.set(h,{cost:t(u.cost),usage:p})}}return n}function a7(e,t,n,r=Date.now()){const s=new Map;let o=0,l=0;for(const[T,A]of n){const R=T.indexOf("|"),B=T.slice(0,R),P=T.slice(R+1),D=Zo(A.usage,P,r).total;if(!(D>0&&A.cost>0))continue;o+=A.cost,l+=D;let O=s.get(B);O||(O=new Map,s.set(B,O)),O.set(P,A.cost/D)}const u=l>0,d=(T,A)=>{const R=s.get(T);return(R==null?void 0:R.get(A))??(R==null?void 0:R.get(gi(A)))??null},h=new Set,f=(T,A)=>{let R=0,B=0;for(const[P,D]of Object.entries(T)){if(za(P,r)){const L=A(P);R+=L===null?Zo(T$(D),P,r).total:Zo(r7(D),P,r).total*L;continue}const O=A$(D);O>0&&(B+=O,h.add(P))}return{cost:R,unpriced:B}},p=new Map,g=[];for(const T of e){const A=new Map,R=new Map;let B=0;for(const P of T.projects){const{cost:D,unpriced:O}=f(P.models,z=>d(T.day,z));A.set(P.path,(A.get(P.path)??0)+D),O>0&&R.set(P.path,(R.get(P.path)??0)+O),B+=D;let L=p.get(P.path);L||(L={path:P.path,cost:0,tokens:0,unpricedTokens:0},p.set(P.path,L)),L.cost+=D,L.tokens+=Uj(P.models),L.unpricedTokens+=O}g.push({day:T.day,total:B,byPath:A,unpricedByPath:R})}const v=[...p.values()].sort((T,A)=>A.cost-T.cost||A.tokens-T.tokens),k=v.reduce((T,A)=>T+A.cost,0),b=v.reduce((T,A)=>T+A.tokens,0),x=v.reduce((T,A)=>T+A.unpricedTokens,0),N=u?o/l:null,S=t?Uj(t):0,_=t?f(t,()=>N):{cost:0,unpriced:0},E=_.cost>0||S>0?{cost:_.cost,tokens:S,unpricedTokens:_.unpriced}:null;return{projects:v,totalCost:k,totalTokens:b,unpricedTokens:x,perDay:g,unattributed:E,unpricedModels:[...h].sort(),calibrated:u,reconciled:u&&x===0}}function Rr(e,t,n=qe){return t>0?e>0?`${n(e)}+`:hs:n(e)}function Io(e){return e>0?`${ot(e)} of these tokens are on an unpriced model, so this is a floor`:void 0}function o7(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 ${hs}: this build holds no published rate for it, so its tokens are counted and its dollars are not.`:`${n} are ${hs}: this build holds no published rate for them, so their tokens are counted and their dollars are not.`}const i7={phase:"running"},l7={phase:"failed"},c7={gen:0,report:null,error:null,early:null};function u7(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:i7;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 d7(e){var t;return((t=e.report)==null?void 0:t.gen)!==e.gen&&e.error===null}function h7(e){const t=e;return t&&t.ok!==!1?{phase:"ready",range:t}:l7}function f7(e){return`${e.getFullYear()}${String(e.getMonth()+1).padStart(2,"0")}${String(e.getDate()).padStart(2,"0")}`}function p7(e,t,n=Date.now()){const r=t===0?60:t,s=new Date(n),o=Sx(r,s),l=f7(s);return{report:`/api/account-projects?num=${e}&days=${t}`,ccusage:`/api/ccusage?since=${o}&until=${l}`}}function m7({num:e,days:t,gen:n,dispatch:r,get:s=(l,u)=>fetch(l,u),now:o=Date.now()}){const l=p7(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:h7(d)}))}async function Wa(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 R$(e){return/^[A-Za-z]:[\\/]$/.test(e)?e:e.replace(/[\\/]+$/,"")}function vp(e){const t=R$(e).replace(/\\/g,"/");return/^[A-Za-z]:\//.test(t)?t.toLowerCase():t}function zj(e){if(!e)return e;const t=R$(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 g7(e,t){const n=vp(e);let r;for(const s of t){const o=vp(s.path);!o||o===n||!n.startsWith(`${o}/`)||(!r||vp(r.path).length<o.length)&&(r=s)}return r==null?void 0:r.label}function Cx(e){return e===0?"all time":e===1?"today":`the last ${e} days`}function y7(e){return e===1?"No work attributed to this account yet today.":`No work attributed to this account in ${Cx(e)}.`}function w7(e){return e===1?7:e===7?30:e===30?0:null}function v7(e,t){return e!==1&&t>0}const x7=[{days:1,label:"Today"},{days:7,label:"7d"},{days:30,label:"30d"},{days:0,label:"All"}],Oo=["var(--usage-blue)","var(--usage-teal)","var(--usage-lime)","var(--usage-purple)","var(--usage-indigo)","var(--usage-pink)","var(--usage-orange)","var(--usage-zinc)"],b7="var(--usage-zinc)",xp=6,k7=1600;function N7(e){const t=qe(e),n=/^\$(\d{4,})$/.exec(t);return n?`$${Number(n[1]).toLocaleString("en-US")}`:t}function Nu(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 j7(e){const t=/^\d{4}-(\d{2})-(\d{2})$/.exec(e);return t?`${Number(t[1])}/${Number(t[2])}`:e}function S7(e){const t=Math.max(1,Math.ceil(e/6));return n=>n===0||n===e-1||n%t===0}function bp(e){if(!e)return"";try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function _7({num:e,name:t,onClose:n}){var $,q,X,H;const[r,s]=w.useState(1),[o,l]=w.useReducer(u7,c7),u=(($=o.report)==null?void 0:$.data)??null,d=((q=o.report)==null?void 0:q.days)??r,h=((X=o.report)==null?void 0:X.cost.phase)==="ready"?o.report.cost.range:null,f=((H=o.report)==null?void 0:H.cost.phase)==="running",[p,g]=w.useState(null),[v,k]=w.useState(()=>new Set),b=d7(o),x=o.error,[N,S]=w.useState(null),_=w.useRef(void 0),E=w.useRef(!0);w.useEffect(()=>()=>{E.current=!1,window.clearTimeout(_.current)},[]);const T=w.useRef(null),A=ft(n,{focusRef:T}),R=w.useRef(0);w.useEffect(()=>{const I=++R.current;l({type:"start",gen:I}),g(null),k(new Set),m7({num:e,days:r,gen:I,dispatch:l})},[e,r]);const B=w.useMemo(()=>{const I=Date.now();if(!u)return null;const W=a7(u.daily??[],u.unattributed,s7(h),I),F=he=>he.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||he||"(unknown)",Y=new Map;for(const he of W.projects)Y.set(F(he.path),(Y.get(F(he.path))??0)+1);const J=he=>{const _e=F(he);if((Y.get(_e)??0)<=1)return _e;const Fe=he.replace(/[\\/]+$/,"").split(/[\\/]/).slice(-2,-1)[0];return Fe?`${Fe}/${_e}`:_e},V=W.projects.map(he=>({path:he.path,label:J(he.path)})),G=he=>({path:he.path,label:J(he.path),parentLabel:g7(he.path,V),cost:he.cost,tokens:he.tokens,unpricedTokens:he.unpricedTokens}),K=Oo[xp%Oo.length],Z=new Map,ee=[],re=W.projects.slice(0,xp),ue=W.projects.slice(xp);re.forEach((he,_e)=>{Z.set(he.path,Oo[_e%Oo.length]),ee.push({key:he.path,...G(he),color:Oo[_e%Oo.length]})}),ue.length&&ee.push({key:"__other__",label:`Other · ${ue.length} project${ue.length>1?"s":""}`,cost:ue.reduce((he,_e)=>he+_e.cost,0),tokens:ue.reduce((he,_e)=>he+_e.tokens,0),unpricedTokens:ue.reduce((he,_e)=>he+_e.unpricedTokens,0),color:K,muted:!0,members:ue.map(G)});const me=W.totalCost,ae=W.totalTokens,pe=me>0&&W.unpricedTokens===0?"cost":"tokens",xe=pe==="cost"?me:ae,se=ee.map(he=>he.color),ve=W.perDay.map(he=>{const _e=new Map;for(const[Ve,le]of he.byPath){const je=Z.get(Ve)??K;_e.set(je,(_e.get(je)??0)+le)}const Fe=new Map;let Le=0;for(const[Ve,le]of he.unpricedByPath){const je=Z.get(Ve)??K;Fe.set(je,(Fe.get(je)??0)+le),Le+=le}return{day:he.day,total:he.total,costByColor:_e,unpricedByColor:Fe,unpriced:Le}}),fe=ve.reduce((he,_e)=>Math.max(he,_e.total),0);return{projectCount:W.projects.length,rows:ee,totalCost:me,totalTokens:ae,basis:pe,denom:xe,un:W.unattributed,chart:ve,maxDay:fe,colorOrder:se,unpricedTokens:W.unpricedTokens,unpricedNote:o7(W.unpricedModels),calibrated:W.calibrated,reconciled:W.reconciled}},[u,h]),P=(I,W)=>{Wa(I).then(F=>{E.current&&(window.clearTimeout(_.current),S({path:I,label:W,ok:F}),_.current=window.setTimeout(()=>{E.current&&S(null)},k7))})},D=I=>N!=null&&N.ok&&N.path===I?"Copied":"Copy",O=u!=null&&u.trackedSince?`Tracked since ${bp(u.trackedSince)}`:"Tracking starts with this version",L=Cx(d),z=w7(d),M=b&&!!u;return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:a.jsxs("div",{ref:A,className:"modal ap-proj-modal",onClick:I=>I.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ap-proj-title ap-proj-sub",children:[a.jsxs("header",{className:"ap-proj-head",children:[a.jsxs("div",{className:"ap-proj-titlewrap",children:[a.jsx("div",{className:"ap-proj-title",id:"ap-proj-title",children:"Projects"}),a.jsx("div",{className:"ap-proj-sub",id:"ap-proj-sub",title:t,children:t})]}),a.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:x7.map(I=>a.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":r===I.days,onClick:()=>s(I.days),children:I.label},I.days))}),a.jsx("button",{ref:T,className:"glyph-btn ap-proj-close",onClick:n,"aria-label":"Close",children:"×"})]}),a.jsxs("div",{className:`ap-proj-body${M?" refreshing":""}`,"aria-busy":b,children:[b&&!u&&a.jsx("div",{className:"ap-proj-state",children:"Loading…"}),!b&&x&&a.jsxs("div",{className:"ap-proj-state ap-proj-error",children:["Couldn’t load this report: ",x]}),!x&&B&&a.jsx(a.Fragment,{children:B.rows.length===0?a.jsxs("div",{className:"ap-proj-state",children:[M?"Updating…":y7(d),z!=null&&a.jsx("div",{className:"ap-proj-widen-wrap",children:a.jsxs("button",{type:"button",className:"ap-proj-copy",onClick:()=>s(z),children:["Show ",Cx(z)]})}),a.jsxs("div",{className:"ap-proj-note",children:[O,". Only work from this version onward can be tied to an account."]})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"ap-proj-bar",role:"img","aria-label":`Share of ${B.basis==="cost"?qe(B.totalCost):`${ot(B.totalTokens)} tokens`} across ${B.projectCount} project${B.projectCount>1?"s":""}`,children:B.rows.map(I=>{const W=B.basis==="cost"?I.cost:I.tokens,F=B.denom>0?W/B.denom*100:0;if(F<=0)return null;const Y=B.basis==="cost"?Nu(I.cost,B.totalCost):`${Nu(I.tokens,B.totalTokens)} of tokens`;return a.jsx("span",{className:"ap-proj-seg",style:{width:`${F}%`,background:I.color},title:`${I.label} · ${Rr(I.cost,I.unpricedTokens)} · ${Y}${I.tokens?` · ${ot(I.tokens)} tokens`:""}`},I.key)})}),a.jsxs("div",{className:"ap-proj-totals",children:[a.jsx("span",{className:"ap-proj-total-cost",title:Io(B.unpricedTokens),children:Rr(B.totalCost,B.unpricedTokens)}),a.jsxs("span",{className:"ap-proj-total-tok",children:[ot(B.totalTokens)," tokens"]}),a.jsxs("span",{className:"ap-proj-total-win",children:["· ",M?"updating…":L]}),f&&a.jsx("span",{className:"ap-proj-total-pending",children:"Reconciling cost…"})]}),B.unpricedNote&&a.jsx("div",{className:"ap-proj-note",children:B.unpricedNote}),v7(d,B.chart.length)&&a.jsxs("div",{className:"ap-proj-days",children:[a.jsxs("div",{className:"ap-proj-days-cap",children:["By day",B.chart.length>1?" · click a bar":""]}),a.jsx("div",{className:"ap-proj-days-plot",role:"group","aria-label":`Spend across ${B.chart.length} day${B.chart.length>1?"s":""}`,children:B.chart.map(I=>{const W=B.maxDay>0?I.total/B.maxDay*100:0,F=p===I.day,Y=B.rows.map(V=>({label:V.label,c:I.costByColor.get(V.color)??0,u:I.unpricedByColor.get(V.color)??0})).filter(V=>V.c>0||V.u>0),J=`${bp(Date.parse(`${I.day}T00:00:00`))}, ${Rr(I.total,I.unpriced)}. ${Y.map(V=>`${V.label} ${Rr(V.c,V.u)}`).join(", ")}`;return a.jsx("button",{type:"button",className:`ap-proj-day${F?" selected":""}`,"aria-pressed":F,"aria-label":J,title:`${I.day} · ${Rr(I.total,I.unpriced)}`,onClick:()=>g(V=>V===I.day?null:I.day),children:a.jsx("span",{className:"ap-proj-col",style:{height:`${W}%`},children:B.colorOrder.map((V,G)=>{const K=I.costByColor.get(V)??0;return K<=0||I.total<=0?null:a.jsx("span",{className:"ap-proj-colseg",style:{height:`${K/I.total*100}%`,background:V}},G)})})},I.day)})}),(()=>{const I=S7(B.chart.length);return a.jsx("div",{className:"ap-proj-days-axis","aria-hidden":"true",children:B.chart.map((W,F)=>a.jsx("div",{className:"ap-proj-axis-cell",children:I(F)?j7(W.day):""},W.day))})})(),(()=>{const I=p?B.chart.find(F=>F.day===p):null;if(!I)return null;const W=B.rows.map(F=>({r:F,c:I.costByColor.get(F.color)??0,u:I.unpricedByColor.get(F.color)??0})).filter(F=>F.c>0||F.u>0);return a.jsxs("div",{className:"ap-proj-day-detail",children:[a.jsxs("div",{className:"ap-proj-day-detail-head",children:[a.jsx("span",{children:bp(Date.parse(`${I.day}T00:00:00`))}),a.jsx("span",{className:"ap-proj-day-detail-total",title:Io(I.unpriced),children:Rr(I.total,I.unpriced)})]}),W.map(({r:F,c:Y,u:J})=>a.jsxs("div",{className:"ap-proj-day-detail-row",children:[a.jsx("span",{className:"ap-proj-dot",style:{background:F.color},"aria-hidden":"true"}),a.jsx("span",{className:"ap-proj-day-detail-name",children:F.label}),a.jsx("span",{className:"ap-proj-day-detail-cost",title:Io(J),children:Rr(Y,J)})]},F.key))]})})()]}),a.jsx("ul",{className:"ap-proj-list",children:B.rows.map((I,W)=>{const F=B.basis==="cost"?I.cost:I.tokens,Y=B.denom>0?F/B.denom*100:0,J=v.has(I.key),V=`ap-proj-details-${W}`,G=J&&(!!I.path||!!I.members),K=I.members?`${J?"Hide":"Show"} the ${I.members.length} project${I.members.length>1?"s":""} folded into Other`:`${J?"Hide":"Show"} location for ${I.label}`;return a.jsxs("li",{className:`ap-proj-row${I.muted?" muted":""}${J?" expanded":""}`,children:[a.jsx("span",{className:"ap-proj-dot",style:{background:I.color},"aria-hidden":"true"}),a.jsxs("span",{className:"ap-proj-name",children:[I.label,I.parentLabel&&a.jsxs("span",{className:"ap-proj-parent",children:[" · in ",I.parentLabel]})]}),a.jsx("span",{className:"ap-proj-track",title:B.basis==="cost"?`${Nu(I.cost,B.totalCost)} of tracked cost`:`${Nu(I.tokens,B.totalTokens)} of tracked tokens`,children:a.jsx("span",{className:"ap-proj-fill",style:{width:`${Y}%`,background:I.color}})}),a.jsx("span",{className:"ap-proj-cost",title:Io(I.unpricedTokens),children:Rr(I.cost,I.unpricedTokens)}),a.jsx("span",{className:"ap-proj-tok",children:ot(I.tokens)}),a.jsx("button",{type:"button",className:"glyph-btn ap-proj-info","aria-expanded":J,"aria-controls":G?V:void 0,"aria-label":K,onClick:()=>k(Z=>{const ee=new Set(Z);return ee.has(I.key)?ee.delete(I.key):ee.add(I.key),ee}),children:"ⓘ"}),J&&I.path&&a.jsxs("div",{className:"ap-proj-details",id:V,children:[a.jsx("code",{className:"ap-proj-path",children:zj(I.path)}),a.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${D(I.path)} location for ${I.label}`,onClick:()=>P(I.path,I.label),children:D(I.path)})]}),J&&I.members&&a.jsx("div",{className:"ap-proj-details ap-proj-other-members",id:V,children:I.members.map(Z=>a.jsxs("div",{className:"ap-proj-other-member",children:[a.jsxs("div",{className:"ap-proj-other-name",children:[Z.label,Z.parentLabel&&a.jsxs("span",{className:"ap-proj-parent",children:[" · in ",Z.parentLabel]})]}),a.jsx("code",{className:"ap-proj-path",children:zj(Z.path)}),a.jsx("span",{className:"ap-proj-cost",title:Io(Z.unpricedTokens),children:Rr(Z.cost,Z.unpricedTokens)}),a.jsx("span",{className:"ap-proj-tok",children:ot(Z.tokens)}),a.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${D(Z.path)} location for ${Z.label}`,onClick:()=>P(Z.path,Z.label),children:D(Z.path)})]},Z.path))})]},I.key)})}),B.un&&a.jsxs("div",{className:"ap-proj-unattributed",children:[a.jsx("span",{className:"ap-proj-dot",style:{background:b7},"aria-hidden":"true"}),a.jsxs("div",{className:"ap-proj-un-labels",children:[a.jsx("span",{className:"ap-proj-un-title",children:"Unattributed usage"}),a.jsx("span",{className:"ap-proj-un-tag",children:"Excluded from the project totals"})]}),a.jsx("span",{className:"ap-proj-un-cost",title:Io(B.un.unpricedTokens),children:Rr(B.un.cost,B.un.unpricedTokens,N7)}),a.jsx("span",{className:"ap-proj-un-tok",children:ot(B.un.tokens)}),a.jsx("div",{className:"ap-proj-note",children:"Work no account could be tied to — from before tracking, or a gap."})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:N&&(N.ok?`Copied the location of ${N.label}`:`Could not copy the location of ${N.label} — select it and copy it by hand`)}),a.jsxs("div",{className:"ap-proj-foot",children:[f?"Dollars estimated · ccusage still running":B.reconciled?"Dollars from ccusage · split by activity":B.calibrated?"Dollars from ccusage for the priced models · split by activity":h?"Dollars estimated · ccusage could not price this window":"Dollars estimated · ccusage unavailable"," · ",O]})]})})]})]})}),document.body)}function ui(e,t){return n$(t-Math.floor(e/1e3))}function E7(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 Vb(){return a.jsxs("svg",{className:"ap-warn-glyph",width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M7 1.9 12.9 12H1.1Z"}),a.jsx("path",{d:"M7 5.6v2.9"}),a.jsx("path",{d:"M7 10.3v.05"})]})}function C7({anchorId:e,boundaryId:t,issue:n,who:r,fetchedAt:s,nowSec:o,onClose:l,onSignIn:u,onReport:d}){return a.jsx(Hb,{anchorId:e,boundaryId:t,id:"ap-issue-pop",className:"ap-pop ap-issue-pop",role:"dialog",labelledBy:"ap-issue-title",onClose:()=>l(),children:a.jsxs("div",{className:"ap-pop-form",children:[a.jsxs("p",{className:"ap-pop-title ap-issue-title",id:"ap-issue-title","data-tone":n.tone,children:[n.tone==="warn"&&a.jsx(Vb,{}),n.text]}),a.jsx("p",{className:"ap-pop-note ap-issue-hint",children:n.hint}),a.jsxs("p",{className:"ap-pop-note ap-issue-when",children:[a.jsx("span",{className:"ap-issue-who",children:r})," · ",s?`last collected ${ui(s,o)}`:"never collected"]}),a.jsxs("div",{className:"ap-pop-actions",children:[d&&a.jsx("button",{type:"button",className:"ap-issue-report",onClick:()=>{l(),d()},children:"Report this"}),a.jsx("button",{type:"button",className:"btn",onClick:()=>l(!0),children:"Done"}),n.fix&&a.jsx("button",{type:"button",className:"btn primary",onClick:()=>{l(!0),u()},title:"Open the sign-in dialog. Signing in as this account puts its login back in this slot — it keeps its slot, its alias and its history.",children:n.fix})]})]})})}function vl(e){return e.charAt(0).toUpperCase()+e.slice(1)}function T7(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 A7(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 R7(e){switch(e){case"no_credentials":return{text:"no stored login",hint:"claude-swap holds no credentials for this account, so there is nothing to read its usage with and nothing to switch to. A paired deck that has them sends them on its own; signing in as this account puts them there by hand.",fix:"sign in"};case"relogin_required":return{text:"login expired",hint:"claude-swap's stored login for this account was rejected and cannot be refreshed. Signing in again replaces it — the account keeps its slot, its alias and its history.",fix:"sign in again"};case"keychain_unavailable":return{text:"keychain unreadable",hint:"This is about the deck, not the account: claude-swap could not open your keychain, so it cannot read any account's stored login. A deck started from a background session cannot reach the keychain at all — start it from a terminal, or let it start at login, and this clears."};case"token_expired":return{text:"token expired",hint:"The access token ran out and the refresh was deferred. The next collection retries."};case"foreign_credential":return{text:"wrong credential",hint:"The live credential belongs to a different account. Switching to this one repairs it."};case null:case void 0:return null;default:return{text:e,hint:`claude-swap reported "${e}" for this account.`}}}const Wj={text:"Login expired on all online decks",hint:"Every paired deck online right now that shares this account holds a copy that has expired too, so none of them can repair this one. Claude retires a login's other copies each time one machine refreshes it, which is how shared copies expire together. Sign in again on any one machine; the others repair from it on their next round."};function di(e,t,n){const r=$7(e,t);return!r||!(n!=null&&n.noCopyWorksNearby)||!M7(e)?r:{...r,text:Wj.text,hint:Wj.hint}}function M7(e){return e.staleCopy?!1:e.stopped?e.collector==="relogin_required":e.error==="invalid_grant"||e.error==="no_refresh_token"}function $7(e,t){if(e.staleCopy){const n=T7(e.repair??null,t);return{text:vl(n.text),hint:n.hint,fix:null,tone:"quiet",blocksSwitch:!1}}if(e.stopped){const n=R7(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:vl(n.text),hint:n.hint,fix:n.fix?vl(n.fix):null,tone:r||e.collector==="keychain_unavailable"?"warn":"quiet",blocksSwitch:r}}if(e.error){const n=A7(e.error);return{text:vl(n.text),hint:n.hint,fix:n.fixable?"Sign in again":null,tone:n.fixable?"warn":"quiet",blocksSwitch:n.fixable}}return null}function Hj(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function I7(e){const t=e.filter(u=>!Hj(u)),n=e.filter(u=>Hj(u)),r=t.length?t:n,s=t.length?n:[],o=r.reduce((u,d)=>u&&u.pct>=d.pct?u:d,null);let l=null;for(const u of s)o&&u.pct<=o.pct||(!l||u.pct>l.pct)&&(l=u);return{shown:r,rest:s,fuller:l,peak:l??o}}const O7="\0";function Mr(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}${O7}${n}`}function L7(e,t,n=Mr){const r=n(t);return e.includes(r)?e.filter(s=>s!==r):[...e,r]}const Vd="slot",Gb=[{lane:"five_hour",name:"5h"},{lane:"seven_day",name:"7d"}],M$=e=>e.id.startsWith("scoped-");function P7(e){var t;return((t=Gb.find(n=>n.lane===e.id))==null?void 0:t.name)??e.label}function D7(e){if(e==="room")return"room";const t=/^(.+):(full|empty)$/.exec(e);return t?t[1]:null}function $$(e){const t=[...new Set(e.flatMap(r=>(r.lanes??[]).filter(M$).map(s=>s.label)))].sort((r,s)=>r.localeCompare(s)),n=[...Gb.map(r=>r.name),...t];return[{id:Vd,label:"Slot"},...n.flatMap(r=>[{id:`${r}:full`,label:`${r} · fullest`},{id:`${r}:empty`,label:`${r} · emptiest`}]),{id:"room",label:"Most room"}]}function Vj(e,t){const n=Gb.find(s=>s.name===t),r=(e.lanes??[]).find(s=>n?s.id===n.lane:M$(s)&&s.label===t);return r&&Number.isFinite(r.pct)?r.pct:null}function F7(e,t,n=()=>!0){const r=[...e],s=h=>[...h.filter(n),...h.filter(f=>!n(f))];if(t==="room")return s(Gj(r,h=>Number.isFinite(h.headroom)?h.headroom:null,"desc"));const o=/^(.+):(full|empty)$/.exec(t);if(!o)return r;const[,l,u]=o;if(!r.some(h=>Vj(h,l)!=null))return r;const d=Gj(r,h=>Vj(h,l),u==="full"?"desc":"asc");return u==="empty"?s(d):d}function Gj(e,t,n){const r=e.filter(o=>t(o)!=null),s=e.filter(o=>t(o)==null);return r.sort((o,l)=>n==="desc"?t(l)-t(o):t(o)-t(l)),[...r,...s]}function B7(e,t){return $$(t).some(n=>n.id===e)?e:Vd}function Tx(e,t){if(!t)return[...e];const n=new Map(t.map((o,l)=>[o,l])),r=e.filter(o=>n.has(Mr(o))).sort((o,l)=>n.get(Mr(o))-n.get(Mr(l))),s=e.filter(o=>!n.has(Mr(o)));return[...r,...s]}function Kb(e){const t=Mr(e);return t.startsWith("slot:")?t:`h:${q7(t)}`}function q7(e){let t=3735928559,n=1103547991;for(let r=0;r<e.length;r++){const s=e.charCodeAt(r);t=Math.imul(t^s,2654435761),n=Math.imul(n^s,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),(4294967296*(2097151&n)+(t>>>0)).toString(36)}const Ax={mode:"some",keys:[]};function I$(e,t){const n=e.keys.includes(Kb(t));return e.mode==="all"?!n:n}function U7(e,t){return{mode:e.mode,keys:L7(e.keys,t,Kb)}}function O$(e,t){return t.length>0&&t.every(n=>I$(e,n))}function z7(e,t){return O$(e,t)?Ax:{mode:"all",keys:[]}}function W7(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map(Kb)),r=e.keys.filter(s=>n.has(s));return r.length===e.keys.length?e:{mode:e.mode,keys:r}}function H7(e){return e>=90?"hi":e>=70?"mid":void 0}function V7({lane:e,nowSec:t,frozen:n,sortedBy:r}){const s=Math.min(100,Math.max(0,e.pct)),o=n?"var(--muted)":s>=90?"var(--err)":s>=70?"var(--warn)":"var(--accent)",l=e.resetAt&&!n?Bd(e.resetAt,t):null;return a.jsxs("div",{className:"ap-lane","data-sort-key":r?"":void 0,children:[a.jsx("span",{className:"ap-lane-label",title:e.label,children:e.label}),a.jsx("div",{className:"ap-lane-track",children:a.jsx("div",{className:"ap-lane-fill",style:{width:`${s===0?1.5:s}%`,background:o,opacity:s===0||n?.4:1}})}),a.jsxs("span",{className:"ap-lane-pct",style:{color:o},children:[s,"%"]}),a.jsx("span",{className:"ap-lane-reset",title:l?`${e.label} resets in ${l}`:void 0,children:l&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"vis-hidden",children:"resets in "}),l]})})]})}function G7({a:e,nowSec:t,lan:n,opened:r,onToggleLanes:s,busy:o,pressProps:l,onSwitch:u,menuOpen:d,onOpenMenu:h,onCloseMenu:f,refusal:p,onDismissRefusal:g,switchedHere:v,swapped:k,displaced:b,issueExpanded:x,onOpenIssue:N,sortKey:S=null}){const{shown:_,fuller:E}=I7(e.lanes),T=S==="room"?e.lanes.reduce((z,M)=>z&&z.pct>=M.pct?z:M,null):S?e.lanes.find(z=>P7(z)===S)??null:null,A=di(e,t,n),R=e.active||r,B=e.alias??e.email??`account ${e.num}`,P=e.alias&&e.email?`${e.alias} · ${e.email}`:B,D=e.stale||(A==null?void 0:A.blocksSwitch)===!0,O=E?[..._,E]:_,L=e.fetchedAt?ui(e.fetchedAt,t):null;return a.jsxs("li",{className:`ap-account${e.active?" active":""}`,"aria-current":e.active?"true":void 0,"data-open":R?"":void 0,"data-frozen":D?"":void 0,children:[!e.active&&a.jsx("button",{type:"button",className:"ap-row-open",id:`ap-row-${e.num}`,title:P,"aria-expanded":R,"aria-controls":R?`ap-detail-${e.num}`:void 0,"aria-describedby":[e.alias&&e.email?`ap-email-${e.num}`:null,!R&&!(A!=null&&A.blocksSwitch)?`ap-quota-${e.num}`:null].filter(Boolean).join(" ")||void 0,onClick:()=>s(),children:a.jsxs("span",{className:"vis-hidden",children:[B,", ",R?"hide details":"details"]})}),a.jsxs("div",{className:"ap-account-head",children:[e.active?a.jsx("span",{className:"ap-live",title:`Active account · slot ${e.num}`,children:a.jsxs("span",{className:"vis-hidden",children:["Active account, slot ",e.num,":"]})}):a.jsx("span",{className:"ap-num",children:e.num}),e.alias&&a.jsx("span",{className:"ap-alias",title:e.alias,children:e.alias}),a.jsx("span",{className:"ap-email",id:`ap-email-${e.num}`,title:e.email??void 0,children:e.email}),e.disabled&&a.jsx("span",{className:"ap-held",children:"held out"}),!e.active&&!e.disabled&&!(A!=null&&A.blocksSwitch)&&a.jsx("button",{type:"button",className:"ap-switch",...l(`switch-${e.num}`),onClick:()=>u(e.num,B),"aria-label":`Switch to ${B}`,title:`Switch to ${e.alias??e.email}`,children:o===`switch-${e.num}`?"…":"Switch"}),a.jsx("button",{type:"button",id:`ap-more-${e.num}`,className:"ap-more","aria-label":`More actions for ${e.email??e.alias??`account ${e.num}`}`,"aria-haspopup":"menu","aria-expanded":d,"aria-controls":d?`ap-menu-${e.num}`:void 0,title:"More actions",onClick:()=>d?f():h(e.num),onKeyDown:z=>{z.key!=="ArrowDown"&&z.key!=="ArrowUp"||(z.preventDefault(),h(e.num,z.key==="ArrowUp"?"last":"first"))},children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"currentColor","aria-hidden":!0,children:[a.jsx("circle",{cx:"2.8",cy:"7",r:"1.15"}),a.jsx("circle",{cx:"7",cy:"7",r:"1.15"}),a.jsx("circle",{cx:"11.2",cy:"7",r:"1.15"})]})})]}),p&&a.jsxs("div",{className:"ap-failure ap-row-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",title:p.raw||void 0,children:p.text}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>g(),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),e.active&&v&&a.jsx("p",{className:"ap-switched",children:"Now active. New sessions start on it; ones already running pick it up on their next message, up to about 30 seconds later on macOS."}),k&&(()=>{const z=(b==null?void 0:b.alias)??(b==null?void 0:b.email)??"the account that was there";return a.jsxs("p",{className:"ap-note ap-swap-note",title:`Slot ${k.at} was taken, so the two accounts traded places: ${z} now holds slot ${k.displaced}.`,children:["swapped with slot ",k.displaced]})})(),A&&a.jsxs("div",{className:"ap-issue-line",children:[a.jsxs("button",{type:"button",id:`ap-issue-${e.num}`,className:"ap-issue","data-tone":A.tone,"aria-haspopup":"dialog","aria-expanded":x,"aria-controls":x?"ap-issue-pop":void 0,onClick:()=>N(e.num,`ap-issue-${e.num}`),children:[A.tone==="warn"&&a.jsx(Vb,{}),a.jsx("span",{className:"ap-issue-text",children:A.text})]}),!R&&a.jsx("span",{className:"ap-issue-age",title:"When claude-swap last read this account's usage",children:L??"never collected"})]}),!R&&!(A!=null&&A.blocksSwitch)&&a.jsxs("p",{className:"ap-quota",id:`ap-quota-${e.num}`,children:[O.length?O.map(z=>a.jsxs("span",{className:"ap-q","data-sort-key":z.id===(T==null?void 0:T.id)?"":void 0,children:[a.jsx("span",{className:"ap-q-label",children:z.label})," ",a.jsxs("span",{className:"ap-q-pct","data-level":D?void 0:H7(z.pct),children:[Math.round(z.pct),"%"]})]},z.id)):a.jsx("span",{className:"ap-q-label",children:"no usage recorded yet"}),e.stale&&!A&&a.jsx("span",{className:"ap-q-age","data-never":L?void 0:"",title:"When claude-swap last read this account's usage",children:L??"never collected"})]}),R&&a.jsxs("div",{className:"ap-detail",id:`ap-detail-${e.num}`,children:[a.jsx("div",{className:"ap-lanes",children:e.lanes.length?e.lanes.map(z=>a.jsx(V7,{lane:z,nowSec:t,frozen:D,sortedBy:z.id===(T==null?void 0:T.id)},z.id)):a.jsx("div",{className:"ap-hint",children:"No usage recorded yet."})}),a.jsx("div",{className:"ap-meta",children:e.fetchedAt?a.jsxs("span",{className:`ap-age${e.stale&&!A?" ap-stale":""}`,title:"When claude-swap last read this account's usage, and when it plans to read it again. It sets that interval itself — 3 minutes at the fastest, wider while an account is recovering from a rate limit — and every surface, including `cswap watch`, follows the same plan.",children:["collected ",ui(e.fetchedAt,t),A!=null&&A.blocksSwitch?"":E7(e.nextAt,t)]}):a.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})})]})]})}function K7({data:e}){return a.jsx("div",{className:"ap-empty",children:e.reason==="cswap_installing"?a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"Installing claude-swap…"}),a.jsx("span",{className:"ap-hint",children:"The deck is setting it up in the background, so there is nothing to do here. On a new machine this can take a few minutes; the panel fills in by itself when it is done."})]}):e.reason==="no_cswap"?a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"claude-swap isn't installed."}),a.jsx("span",{className:"ap-hint",children:"This panel reads the account store claude-swap keeps — without it there is nothing to show. It is a separate tool, published on PyPI, so it does not come with this package."}),e.hint&&a.jsx("code",{className:"ap-cmd",children:e.hint}),a.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",a.jsx("strong",{children:"+"})," button above."]})]}):e.reason==="cswap_refused"?a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"claude-swap was installed, but not the version the deck asked for."}),a.jsxs("span",{className:"ap-hint",children:[e.version?`v${e.version} answered`:"A different version answered",e.want?` where ${e.want} was asked for`:"",", so the deck is not driving it. Install the version it asked for, or set AGENTS_DECK_CSWAP to a claude-swap you trust."]})]}):e.reason==="no_accounts"?a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"No accounts added yet."}),a.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",a.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"Couldn't read the account store."}),a.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",e.reason?` (${e.reason})`:"","."]})]})})}function Y7({canShare:e,canReport:t,onAdd:n,onReport:r,onShareSet:s,onReload:o,pressProps:l,reloading:u,closeButton:d}){return a.jsxs("div",{className:"ap-header",children:[a.jsx("h2",{children:"Claude accounts"}),a.jsxs("div",{className:"ap-header-right",children:[a.jsx("button",{type:"button",className:"glyph-btn ap-add",onClick:()=>n(),"aria-label":"Add an account",title:"Sign in to another Claude account, or paste one shared from another deck",children:a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:a.jsx("path",{d:"M7 2.2v9.6M2.2 7h9.6"})})}),t&&a.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>r(),"aria-label":"Account capacity","aria-haspopup":"dialog",title:"Account capacity — how many accounts are ready, and what the 5h and 7d windows have left",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M2.5 10.9A5.2 5.2 0 1 1 11.5 10.9"}),a.jsx("path",{d:"M7 8.3l2.1-2.1"})]})}),e&&a.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>s(),"aria-label":"Share accounts with another deck",title:`Copy several accounts to another ${bt} in one paste. The text carries a live login for each one — treat it as those passwords.`,children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M3.3 10.7L10.7 3.3"}),a.jsx("path",{d:"M5.5 3.3h5.2v5.2"})]})}),a.jsx("button",{type:"button",className:"glyph-btn ap-refresh",onClick:()=>o(),...l("reload",u),"aria-label":"Reload accounts",title:"Reload from claude-swap",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),a.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]})}),d]})]})}const Ia=[{id:"five_hour",label:"5h",long:"5-hour"},{id:"seven_day",label:"7d",long:"7-day"}];function Kj(e){return e.counted?e.pct:e.why==="login"?null:e.estimate}function X7(e){const t=Kj(e.five_hour),n=Kj(e.seven_day);if(t==null||n==null)return"stale";const r=+(t>=100)+ +(n>=100);return r===0?"ready":r===1?"limited":"exhausted"}function Z7(e,t){const n=Ia.map(r=>e.cells[r.id]);for(const r of n)if(!r.counted&&(r.why==="login"||r.why==="none"))return{text:r.say,old:!0};return e.updatedAt==null?{text:"never read",old:!0}:n.every(r=>r.counted)?{text:"now",old:!1}:{text:ui(e.updatedAt,t),old:!0}}const J7=15*6e4,Q7=e=>e.alias??e.email??`account ${e.num}`;function Yj(e,t,n){const r=Ia.find(f=>f.id===t).label,s=(e.lanes??[]).find(f=>f.id===t),o=s&&Number.isFinite(s.pct)?e9(s.pct):null,l=di(e,n),u=(s==null?void 0:s.resetAt)!=null&&s.resetAt<=n,d=(f,p)=>({counted:!1,why:f,say:p,last:o,estimate:o==null?null:u?0:o,resetAt:u?null:(s==null?void 0:s.resetAt)??null});return l!=null&&l.blocksSwitch?d("login",l.text):o==null?d("none",`No ${r} reading`):e.stale||e.fetchedAt==null||n*1e3-e.fetchedAt>J7?d("stale",e.fetchedAt?`Updated ${ui(e.fetchedAt,n)}`:"Never read"):u?d("reset",`Reset ${ui(s.resetAt*1e3,n)}, not updated`):{counted:!0,pct:o,resetAt:s.resetAt}}const e9=e=>Math.min(100,Math.max(0,e));function t9(e,t){const n=Ia.find(h=>h.id===t);let r=0,s=0,o=0;const l=[];for(const h of e){const f=h.cells[t],p=f.counted?f.pct:f.estimate;p!=null&&(r+=p,o++,f.counted&&s++,f.resetAt!=null&&l.push({at:f.resetAt,name:h.name,pct:p}))}const u=l.reduce((h,f)=>!h||f.at<h.at?f:h,null),d=u&&{...u,more:l.filter(h=>h!==u&&h.at-u.at<60).length};return{id:t,label:n.label,long:n.long,reporting:s,included:o,total:e.length,used:o?r/o:null,nextReset:d}}function L$(e,t){const n=e.map(s=>{const o={five_hour:Yj(s,"five_hour",t),seven_day:Yj(s,"seven_day",t)};return{num:s.num,key:Mr(s),name:Q7(s),active:s.active,heldOut:s.disabled===!0,cells:o,status:X7(o),updatedAt:s.fetchedAt??null}}),r=n.filter(s=>s.status==="ready").length;return{rows:n,windows:Ia.map(s=>t9(n,s.id)),roomInBoth:r}}function ju(e,t){return(e==null?void 0:e.key)===t?{key:t,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:"asc"}}const n9={ready:0,limited:1,exhausted:2,stale:3};function r9(e){return e.counted?e.pct:e.last}function Xj(e,t){return t==="status"?n9[e.status]:t==="updated"?e.updatedAt==null?null:-e.updatedAt:r9(e.cells[t])}function s9(e,t){if(!t)return[...e];const n=t.dir==="asc"?1:-1,r=new Map(e.map((o,l)=>[o.num,l])),s=(o,l)=>{if(t.key==="account")return n*o.name.localeCompare(l.name,void 0,{sensitivity:"base"});const u=Xj(o,t.key),d=Xj(l,t.key);return u==null||d==null?u==null?d==null?0:1:-1:n*(u-d)};return[...e].sort((o,l)=>s(o,l)||r.get(o.num)-r.get(l.num))}function ud(e){return e>=100?100:Math.min(99,Math.round(e))}function a9(e){const t=ud(e);return{used:t,available:100-t}}function o9(e,t,n){return e?`${e} These are the last readings.`:t&&n?"The account store could not be read just now. These are the last readings.":null}function P$(e){return e>=90?"hi":e>=70?"mid":void 0}const D$=(e,t,n)=>`${e} ${e===1?t:n}`;function Zj(e){const t=e.more>0?`, and ${D$(e.more,"more account","more accounts")} in the same minute`:"";return`First: ${e.name} (${ud(e.pct)}% used)${t}`}function i9({w:e,nowSec:t}){const n=`ap-report-${e.id}`,r=e.total-e.included,s=r>0&&a.jsxs("p",{className:"ap-report-basis",children:[r," never read"]}),{used:o,available:l}=a9(e.used??0),u=Math.round(_a(l,{countIn:!0}));if(e.used==null)return a.jsxs("section",{className:"ap-report-sum","aria-labelledby":n,children:[a.jsxs("h3",{className:"ap-report-win",id:n,children:[e.long," window"]}),a.jsxs("p",{className:"ap-report-none",children:["No account has a ",e.long," reading yet."]}),s]});const d=e.nextReset?Bd(e.nextReset.at,t):null;return a.jsxs("section",{className:"ap-report-sum","aria-labelledby":n,children:[a.jsxs("h3",{className:"ap-report-win",id:n,children:[e.long," window"]}),a.jsxs("p",{className:"ap-report-left",children:[a.jsxs("b",{children:[u,"%"]})," remaining"]}),a.jsx("div",{className:"ap-report-meter","data-level":P$(o),"aria-hidden":!0,children:a.jsx("i",{style:{"--left":l/100}})}),d&&e.nextReset&&a.jsxs("p",{className:"ap-report-reset",title:Zj(e.nextReset),children:[a.jsxs("span",{children:["Next reset in ",a.jsx("span",{className:"ap-report-num",children:d})]}),a.jsx("span",{"aria-hidden":!0,children:"·"}),a.jsx("span",{className:"ap-report-who",children:e.nextReset.name}),e.nextReset.more>0&&a.jsxs("span",{className:"ap-report-more",children:["+",e.nextReset.more]}),a.jsxs("span",{className:"vis-hidden",children:[". ",Zj(e.nextReset)]})]}),s]})}function l9({cell:e,nowSec:t}){if(!e.counted)return a.jsxs("td",{className:"ap-report-cell","data-uncounted":"",children:[a.jsx("span",{className:"ap-report-pct",children:e.last==null?a.jsxs(a.Fragment,{children:[a.jsx("span",{"aria-hidden":!0,children:"—"}),a.jsx("span",{className:"vis-hidden",children:"no reading"})]}):`${ud(e.last)}%`}),a.jsx("span",{className:"vis-hidden",children:", not counted"})]});const n=e.resetAt!=null?Bd(e.resetAt,t):null;return a.jsxs("td",{className:"ap-report-cell",children:[a.jsxs("span",{className:"ap-report-pct","data-level":P$(e.pct),children:[ud(e.pct),"%"]}),n&&a.jsxs("span",{className:"ap-report-in",children:[a.jsx("span",{className:"vis-hidden",children:"resets in "}),n]})]})}const c9={ready:"Ready",limited:"Limited",exhausted:"Exhausted",stale:"Stale"};function u9({row:e}){return a.jsx("td",{className:"ap-report-state","data-status":e.status,children:a.jsxs("span",{className:"ap-report-state-word",children:[a.jsx("i",{"aria-hidden":!0}),c9[e.status]]})})}function d9({row:e,nowSec:t}){const n=Z7(e,t);return a.jsx("td",{className:"ap-report-upd","data-old":n.old?"":void 0,children:n.text})}function h9(){return a.jsxs("svg",{className:"ap-report-how-mark",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":!0,focusable:"false",children:[a.jsx("circle",{cx:"8",cy:"8",r:"6.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),a.jsx("path",{d:"M8 7.2v4.1M8 4.8v.1",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}function f9({accounts:e,nowSec:t,held:n,sort:r=null,onSort:s=()=>{}}){const o=L$(e,t),l=o.rows.length,u=Math.round(_a(o.roomInBoth,{countIn:!0}));return a.jsxs("div",{className:"ap-proj-body ap-report-body",role:"region","aria-label":"Report",children:[n&&a.jsx("p",{className:"ap-report-held",children:n}),a.jsxs("p",{className:"ap-report-lead",children:[a.jsx("b",{children:u})," of ",D$(l,"Claude account","Claude accounts")," ready"]}),a.jsx("div",{className:"ap-report-sums",children:o.windows.map(d=>a.jsx(i9,{w:d,nowSec:t},d.id))}),a.jsxs("table",{className:"ap-report-table",children:[a.jsx("caption",{className:"vis-hidden",children:"Each account's use of each window, and what it can do now"}),a.jsxs("colgroup",{children:[a.jsx("col",{}),Ia.map(d=>a.jsx("col",{className:"ap-report-col-win"},d.id)),a.jsx("col",{className:"ap-report-col-state"}),a.jsx("col",{className:"ap-report-col-upd"})]}),a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx(wl,{col:"account",label:"Account",sort:r,next:ju,onSort:s}),Ia.map(d=>a.jsx(wl,{col:d.id,label:`${d.label} used`,sort:r,next:ju,onSort:s},d.id)),a.jsx(wl,{col:"status",label:"Status",sort:r,next:ju,onSort:s}),a.jsx(wl,{col:"updated",label:"Updated",className:"ap-report-upd-h",sort:r,next:ju,onSort:s})]})}),a.jsx("tbody",{children:o.rows.map((d,h)=>a.jsxs("tr",{"data-active":d.active?"":void 0,style:{"--row":h},children:[a.jsx("th",{scope:"row",className:"ap-report-acct",children:a.jsxs("span",{className:"ap-report-acct-in",children:[a.jsx("span",{className:"ap-report-name",title:d.name,children:d.name}),d.active&&a.jsx("span",{className:"ap-report-current",children:"Current"}),d.heldOut&&a.jsx("span",{className:"ap-report-tag",children:"held out"})]})}),Ia.map(f=>a.jsx(l9,{cell:d.cells[f.id],nowSec:t},f.id)),a.jsx(u9,{row:d}),a.jsx(d9,{row:d,nowSec:t})]},d.num))})]}),a.jsxs("details",{className:"ap-report-how",children:[a.jsxs("summary",{children:[a.jsx(h9,{}),"How usage is calculated"]}),a.jsxs("div",{className:"ap-report-how-body",children:[a.jsxs("p",{children:["Every account here, at its last reading: ",a.jsx("b",{children:"used"})," is their average, and ",a.jsx("b",{children:"remaining"})," is the rest."]}),a.jsxs("p",{children:[a.jsx("b",{children:"Ready"})," has room in both windows. ",a.jsx("b",{children:"Limited"})," is at the limit of one, and ",a.jsx("b",{children:"Exhausted"})," of both. ",a.jsx("b",{children:"Stale"})," was never read, or is signed out."]})]})]})]})}function p9({accounts:e,order:t,failed:n,nowSec:r,onClose:s}){const o=w.useRef(null),l=ft(s,{focusRef:o}),[u,d]=w.useState(e??[]);w.useEffect(()=>{e&&e.length>0&&d(e)},[e]);const h=o9(n,!e||e.length===0,u.length>0),[f,p]=w.useState(null),g=Tx(u,(f==null?void 0:f.order)??t),v=k=>{const b=L$(Tx(u,t),r).rows;p({sort:k,order:s9(b,k).map(x=>x.key)})};return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",onClick:s,role:"presentation",children:a.jsxs("div",{ref:l,className:"modal ap-report-modal",onClick:k=>k.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ap-report-title",children:[a.jsxs("header",{className:"ap-proj-head",children:[a.jsx("div",{className:"ap-proj-titlewrap",children:a.jsx("h2",{className:"ap-proj-title",id:"ap-report-title",children:"Account capacity"})}),a.jsx("button",{ref:o,type:"button",className:"glyph-btn ap-proj-close",onClick:s,"aria-label":"Close",children:"×"})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:h??""}),a.jsx(f9,{accounts:g,nowSec:r,held:h,sort:(f==null?void 0:f.sort)??null,onSort:v})]})}),document.body)}const kp=[70,80,85,90,95];function m9(e){const t=Number(e);return[...Number.isFinite(t)&&t>0&&!kp.includes(t)?[...kp,t]:kp].sort((r,s)=>r-s)}function g9({auto:e,threshold:t,thresholdPick:n,thresholdCtl:r,thresholdSaved:s,thresholdRef:o,thresholdSaveRef:l,proposeThreshold:u,doThreshold:d,pressProps:h,post:f,load:p}){return a.jsxs("div",{className:"ap-policy-block",children:[a.jsxs("div",{className:"ap-policy",children:[a.jsx("h3",{className:"ap-auto-title",children:"Auto-switch"}),a.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:a.jsx("select",{ref:o,"aria-label":"Switch threshold",value:n,...h("threshold"),onChange:g=>u(g.target.value),children:m9(t).map(g=>a.jsxs("option",{value:g,children:[g,"%"]},g))})}),(r.sends||s)&&a.jsx("button",{ref:l,type:"button",className:"ap-manage-btn",...h("threshold"),title:r.title,onClick:()=>d(n,r),children:s&&!r.sends?r.done:r.label}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":e.enabled,"aria-label":"Auto-switch",...h("enable"),onClick:()=>f({action:"enable",enabled:!e.enabled},"enable").then(()=>p(!0)),title:e.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:a.jsx("span",{className:"switch-knob"})})]}),e.external&&a.jsxs("p",{className:"ap-auto-note",children:[a.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",a.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",e.enabled?" — this toggle takes over when you stop it.":"."]})]})}const Jj=18,y9=1100,Lo=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},w9=Array.from({length:Jj},(e,t)=>{const n=-72+144*t/(Jj-1)+(Lo(t,1)-.5)*9,r=(n-90)*(Math.PI/180),s=(54+32*Math.cos(n*Math.PI/180))*(.74+Lo(t,2)*.52);return{dx:Math.cos(r)*s,dy:Math.sin(r)*s,rot:(t%2?1:-1)*(100+Lo(t,3)*260),delay:Math.round(Lo(t,4)*90),dur:760+Math.round(Lo(t,5)*260),scale:.8+Lo(t,6)*.45,hue:t%4,round:t%3===0}});function Qj({anchor:e}){var s;const[t,n]=w.useState(null),r=typeof window<"u"&&((s=window.matchMedia)==null?void 0:s.call(window,"(prefers-reduced-motion: reduce)").matches);return w.useEffect(()=>{if(r)return;const o=e.current;if(!o)return;const l=o.getBoundingClientRect();n({x:l.left+l.width/2,y:l.top+l.height/2});const u=window.setTimeout(()=>n(null),y9);return()=>window.clearTimeout(u)},[e,r]),r||!t?null:Lt.createPortal(a.jsx("div",{className:"confetti",style:{left:`${t.x}px`,top:`${t.y}px`},"aria-hidden":!0,children:w9.map((o,l)=>a.jsx("span",{className:`confetti-bit${o.round?" round":""}`,"data-hue":o.hue,style:{"--dx":`${o.dx.toFixed(1)}px`,"--dy":`${o.dy.toFixed(1)}px`,"--rot":`${o.rot}deg`,"--s":o.scale.toFixed(2),animationDelay:`${o.delay}ms`,animationDuration:`${o.dur}ms, ${o.dur}ms`}},l))}),document.body)}const dd=w.forwardRef((e,t)=>a.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:t,children:[a.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),a.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));dd.displayName="SuccessMark";const F$=new Set(["awaiting_url","awaiting_code","registering"]);function B$(e){return e!=null&&F$.has(e)}function q$(e){return e!=null&&e!=="done"&&!F$.has(e)}const v9="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",x9="the sign-in did not complete";function b9({state:e,serverError:t,localError:n}){const r=e==="idle";return{title:r?"Sign-in ended":"Sign-in failed",message:n||t||(r?v9:x9)}}function k9({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 N9({started:e,state:t}){return!e||t==="done"?null:{action:"login-cancel"}}function j9({login:e,started:t,loginError:n,loginBusy:r}){return(e==null?void 0:e.state)==="done"&&e.account?"done":(e==null?void 0:e.state)==="awaiting_code"||(e==null?void 0:e.state)==="registering"?"code":q$(e==null?void 0:e.state)||n&&t&&!r?"ended":r||B$(e==null?void 0:e.state)?"asking":"primer"}const S9="done";function _9(){let e=!1;return{shouldAnnounce(t){return t!==S9?(e=!1,!1):e?!1:(e=!0,!0)}}}function Yb(e,t){return t?Ot(e,t):void 0}const E9={already_running:"a sign-in is already in progress",no_url:"the claude CLI did not offer a sign-in link — is it installed?",not_waiting:"that sign-in is no longer waiting for a code",not_prompted:"the CLI has not asked for a code yet",code_rejected:"that code was not accepted — copy it again from the browser",no_verdict:"the claude CLI has not answered — try the code again",empty_code:"paste the code from the browser first",login_failed:"the code was not accepted",no_identity:"signed in, but the CLI still reports nobody logged in",add_failed:"signed in, but claude-swap could not record the account",not_a_share:"that does not look like a shared account — it should start with ccdeck2:",corrupt:"that share is incomplete — copy the whole thing",wrong_version:`that share was made by a newer ${bt}`,expired:"that share has expired — make a new one",import_failed:"claude-swap refused the import",unreadable_export:"claude-swap wrote something this deck could not read — try again, and upgrade it if this repeats",mixed_versions:"claude-swap changed format part-way through — try again",nothing_to_share:"none of those accounts could be exported",too_many:"that is more accounts than one share can carry",not_in_bundle:"that account is not in this share",bad_value:"an alias can only use letters, numbers, spaces, dots, dashes and underscores, up to 64 characters, and cannot start with a dash",bad_email:"that does not look like an email address — it cannot contain spaces or start with a dash"},C9={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"},Xb=`claude-swap could not read the login keychain — start ${bt} from a Terminal window rather than a background service`,T9={unreadable_here:{short:"Keychain locked on this Mac",long:`${Xb}.`},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 hd(e){return e?Ot(T9,e)??null:null}const U$={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 Rx(e,t,n){const r=n==null?null:U$[n];if(r)return r;if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(Wl(e)))return Xb;const s=Yb(C9,e==null?void 0:e.reason);return s||(e==null?void 0:e.reason)||t}function Wl(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const A9={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"},R9="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 M9(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const $9="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",I9="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",O9=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),L9=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,P9=/[\\/]_npx[\\/]/i,D9=`the copy of ccusage ${bt} installed for itself`;function F9(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function lie(e,t){const n=B9(e,t),r=F9(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 ${ml(n)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${ml(n)}`;case"managed":return`${D9} failed to run: ${ml(n)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${ml(n)}`:`the ccusage this deck found on your PATH failed to run: ${ml(n)}`;default:return n}}const ml=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function B9(e,t){const n=Wl(e);if(O9(n)){if(P9.test(n))return I9;if(L9.test(n))return $9}if(M9(n))return R9;const r=Yb(A9,e==null?void 0:e.reason);return r||(e==null?void 0:e.reason)||t}function Wo(e,t,n){const r=n==null?null:U$[n];if(r)return r;if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&q$(e.state))return e.error;const s=Yb(E9,e==null?void 0:e.reason);return s||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function q9(e,t,n){if(n<=0||Od(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 z$(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 U9(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 z9(e,t){return e.filter(n=>!t.includes(n.num)).map(n=>n.num)}function W9(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function H9(e){return e.length?{action:"share",accounts:[...e]}:null}function V9(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 Mx(e){return`${e.email}|${e.org??""}`}function G9(e,t,n){return e&&e.map(r=>Mx(r)===t?n:r)}function K9(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 Y9(e){const t=e.length;if(!t)return"Nothing to import.";const n=f=>e.filter(p=>p.state===f).length,r=[],s=n("imported");s&&r.push(`${s} of ${t} imported`);const o=n("healed");o&&r.push(`${o} had a dead token replaced`);const l=n("updated");l&&r.push(`${l} updated`);const u=n("present");u&&r.push(`${u} already here`);const d=n("failed");d&&r.push(`${d} did not arrive`);const h=[...new Set(e.map(f=>{var p;return(p=hd(f.check))==null?void 0:p.short}).filter(f=>!!f))];return`${r.join(", ")}${h.length?`, ${h.join(", ")}`:""}.`}const X9=1500,Su=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],eS="aa-panel",tS=e=>`aa-tab-${e}`;async function Po(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}function W$({onClose:e,onChanged:t,email:n=null,onSignedIn:r}){const[s,o]=w.useState("login"),[l,u]=w.useState(null),[d,h]=w.useState(""),[f,p]=w.useState(""),[g,v]=w.useState(!1),[k,b]=w.useState(!1),[x,N]=w.useState(null),[S,_]=w.useState(null),E=g||k,[T,A]=w.useState(null),[R,B]=w.useState(null),[P,D]=w.useState(null),O=w.useRef(""),L=w.useRef(!1),z=w.useRef(!1),M=w.useRef(null),$=w.useRef(null),q=w.useRef(null),X=w.useRef(null),H=w.useRef([]),I=w.useRef(!1),W=w.useCallback(()=>{const se=N9({started:L.current,state:l==null?void 0:l.state});se&&Po(se).catch(()=>{}),e()},[e,l==null?void 0:l.state]),F=ft(W,{focusRef:q}),Y=w.useCallback(async()=>{if(!ir(z.current))return;z.current=!0,v(!0),N(null),L.current=!0;let se=await Po(n?{action:"login",email:n}:{action:"login"}).catch(()=>null);if(n&&(se==null?void 0:se.reason)==="bad_email"&&(se=await Po({action:"login"}).catch(()=>null)),z.current=!1,v(!1),!(se!=null&&se.ok)){N(Wo(se,"could not start the sign-in"));return}u(se)},[n]);w.useEffect(()=>{if(!B$(l==null?void 0:l.state))return;const se=window.setInterval(async()=>{try{const ve=await fetch("/api/claude-accounts/login");ve.ok&&u(await ve.json())}catch{}},X9);return()=>window.clearInterval(se)},[l]);const J=w.useRef(t);J.current=t;const V=w.useState(_9)[0];w.useEffect(()=>{var se;(l==null?void 0:l.state)==="awaiting_code"&&((se=M.current)==null||se.focus()),V.shouldAnnounce(l==null?void 0:l.state)&&J.current()},[l==null?void 0:l.state,V]);const G=w.useRef(r);G.current=r;const K=w.useRef(null);w.useEffect(()=>{var fe;const se=(l==null?void 0:l.state)==="done"?l.account:null,ve=se?`${se.num??""}|${se.email}`:null;!se||K.current===ve||(K.current=ve,(fe=G.current)==null||fe.call(G,se))},[l]),w.useEffect(()=>{var se;s==="paste"&&!I.current&&((se=$.current)==null||se.focus()),I.current=!1},[s]);const Z=w.useCallback(se=>{var fe;const ve=q9(se,Su.findIndex(he=>he.id===s),Su.length);ve.kind!=="pass"&&(se.preventDefault(),I.current=!0,o(Su[ve.index].id),(fe=H.current[ve.index])==null||fe.focus())},[s]),ee=w.useCallback(async()=>{var ve;if(!ir(z.current))return;z.current=!0,v(!0),N(null);const se=await Po({action:"login-code",code:d}).catch(()=>null);if(z.current=!1,v(!1),!(se!=null&&se.ok)){N(Wo(se,"the code was not accepted")),se!=null&&se.state&&u(se),(ve=M.current)==null||ve.select();return}h(""),u(se)},[d,l]),re=w.useCallback(async()=>{if(!ir(z.current))return;z.current=!0,b(!0),_(null);const se=await Po({action:"import",blob:f}).catch(()=>null);if(z.current=!1,b(!1),!(se!=null&&se.ok)){_(Wo(se,"the import failed"));return}O.current=f,p(""),D(null),A(se.results??[]),t()},[f,t]),ue=w.useCallback(async se=>{const ve=Mx(se);if(!ir(z.current)||!O.current)return;z.current=!0,b(!0),B(ve),D(null);const fe=await Po({action:"import",blob:O.current,force:!0,only:{email:se.email,org:se.org??""}}).catch(()=>null);if(z.current=!1,b(!1),B(null),!(fe!=null&&fe.ok)){D({key:ve,text:Wo(fe,"that account could not be updated")});return}const he=(fe.results??[])[0];he&&A(_e=>G9(_e,ve,he)),t()},[t]),me=(l==null?void 0:l.state)==="done"?l.account:null,ae=k9({restored:l==null?void 0:l.restored,activeAccount:l==null?void 0:l.activeAccount}),pe=j9({login:l,started:L.current,loginError:x,loginBusy:g}),xe=b9({state:l==null?void 0:l.state,serverError:l==null?void 0:l.error,localError:x});return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",onClick:W,role:"presentation",children:a.jsxs("div",{ref:F,className:"modal aa-modal",onClick:se=>se.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{className:"aa-tabs",role:"tablist","aria-label":"How to add the account",onKeyDown:Z,children:Su.map((se,ve)=>a.jsx("button",{type:"button",role:"tab",id:tS(se.id),ref:fe=>{H.current[ve]=fe},"aria-selected":s===se.id,"aria-controls":eS,tabIndex:s===se.id?0:-1,className:`aa-tab${s===se.id?" on":""}`,onClick:()=>{I.current=!1,o(se.id)},children:se.label},se.id))})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:W,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsx("section",{className:"modal-body aa-body",id:eS,role:"tabpanel","aria-labelledby":tS(s),children:s==="login"?pe==="done"&&me?a.jsxs("div",{className:"aa-done",children:[a.jsx(dd,{ref:X}),a.jsx(Qj,{anchor:X}),a.jsx("h4",{children:me.added?`Account ${me.num} added`:"Credentials refreshed"}),a.jsxs("p",{className:"aa-note",children:[a.jsx("strong",{children:me.email}),me.added?ae?" is in the rotation.":" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),ae?a.jsx("p",{className:"aa-note aa-warn",role:"status",children:ae}):null,a.jsx("button",{type:"button",className:"btn primary",onClick:W,children:"Done"})]}):pe==="code"&&l?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"aa-step",children:[a.jsx("h4",{children:"1 · Approve in the browser"}),a.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),a.jsx("a",{className:"aa-link",href:l.url??"#",target:"_blank",rel:"noreferrer noopener",children:l.url})]}),a.jsxs("div",{className:"aa-step",children:[a.jsx("h4",{children:"2 · Paste a code, if the page shows one"}),a.jsx("p",{className:"aa-note",children:"It usually finishes on its own — if the page says you are all set, there is nothing to do here."}),a.jsxs("div",{className:"aa-field",children:[a.jsx("input",{ref:M,type:"text",value:d,onChange:se=>h(se.target.value),onKeyDown:se=>{se.key==="Enter"&&d.trim()&&!E&&ee()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:l.state==="registering"}),a.jsx("button",{type:"button",className:"btn primary",...Ir(E,!d.trim()||l.state==="registering"),onClick:ee,children:l.state==="registering"?"registering…":"Continue"})]}),(x||l.error)&&a.jsx("p",{className:"aa-err",children:x??l.error}),a.jsx("p",{className:"aa-note",children:"The code goes straight to the claude CLI on this machine. It is never stored or sent anywhere else."})]})]}):pe==="ended"?a.jsxs("div",{className:"aa-step",children:[a.jsx("h4",{children:xe.title}),a.jsx("p",{className:"aa-err",children:xe.message}),a.jsx("button",{type:"button",className:"btn",onClick:()=>{L.current=!1,u(null),N(null),Y()},children:"Try again"})]}):pe==="asking"?a.jsx("div",{className:"aa-step",children:a.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):a.jsxs("div",{className:"aa-step aa-primer",children:[a.jsx("h4",{children:n?a.jsxs(a.Fragment,{children:["Sign in again as ",a.jsx("strong",{children:n})]}):"Sign in to Anthropic"}),a.jsxs("p",{className:"aa-note",children:["Opens a browser tab where you approve the sign-in",n?", with this address already filled in":"",". It normally completes by itself; only if the page hands you a code does it need pasting back here.",n?" claude-swap replaces the expired login in place — the account keeps its slot, its alias and its history — and the account you are using now stays active.":" claude-swap records the account when it completes, and the account you are using now stays active."]}),a.jsx("div",{className:"aa-actions",children:a.jsx("button",{type:"button",ref:q,className:"btn primary",...Ir(E),onClick:Y,children:"Open the sign-in page"})})]}):T?(()=>{const se=T.filter(fe=>fe.state==="imported").length,ve=T.some(fe=>hd(fe.check));return a.jsxs("div",{className:"aa-done",children:[!ve&&a.jsx(dd,{ref:X}),se>0&&!ve&&a.jsx(Qj,{anchor:X}),a.jsx("h4",{children:Y9(T)}),T.length>0&&a.jsx("ul",{className:"aa-results",children:T.map(fe=>{const he=Mx(fe),_e=hd(fe.check);return a.jsxs("li",{className:`aa-result ${fe.state}`,children:[a.jsx("span",{className:"aa-result-who",children:fe.email||(fe.num?`slot ${fe.num}`:"an account")}),a.jsx("span",{className:"aa-result-what",children:K9(fe.state)}),fe.state==="present"&&a.jsx("button",{type:"button",className:"aa-result-fix","aria-busy":R===he,title:`Overwrite the stored login for ${fe.email} with the one in this share. Do this when that account has stopped working here; if it works, leave it.`,onClick:()=>ue(fe),children:R===he?"updating…":"update anyway"}),_e&&a.jsx("span",{className:"aa-result-err",children:_e.long}),(P==null?void 0:P.key)===he&&a.jsx("span",{className:"aa-result-err",children:P.text})]},he)})}),a.jsxs("p",{className:"aa-note",children:["Nothing changed on the deck you copied this from. An account already here is left as it is, unless its stored login was dead or you pressed",a.jsx("strong",{children:" update anyway"}),"."]}),a.jsxs("div",{className:"aa-actions",children:[a.jsx("button",{type:"button",className:"btn primary",onClick:W,children:"Done"}),a.jsx("button",{type:"button",className:"btn",onClick:()=>{O.current="",D(null),A(null)},children:"Import another"})]})]})})():a.jsxs("div",{className:"aa-step",children:[a.jsx("h4",{children:"Paste an account shared from another deck"}),a.jsxs("div",{className:"aa-field",children:[a.jsx("input",{ref:$,type:"text",value:f,onChange:se=>p(se.target.value),onKeyDown:se=>{se.key==="Enter"&&f.trim()&&!E&&re()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),a.jsx("button",{type:"button",className:"btn primary",...Ir(E,!f.trim()),onClick:re,children:k?"importing…":"Import"})]}),S&&a.jsx("p",{className:"aa-err",children:S}),a.jsxs("p",{className:"aa-note",children:["Use ",a.jsx("strong",{children:"share"})," on one account in the other deck, or ",a.jsx("strong",{children:"↗"})," above its list to send several at once. A share carries a live login for every account in it and expires ten minutes after it is made."]})]})})]})}),document.body)}function Z9(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 J9(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 Q9=64;function eV(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}function tV(e,t,n){return t!=null&&e.some(r=>r.slot===t)?t:n}function nV(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 rV(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 sV({a:e,slots:t,nowSec:n,boundaryId:r,accountMenu:s,busy:o,pressProps:l,rotating:u,onProjects:d,onRotation:h}){const{menu:f,menuError:p,aliasDraft:g,confirmRemove:v,share:k,shareCopied:b,slotDraft:x,dropMenu:N,closeMenu:S,startRename:_,typeAlias:E,doAlias:T,startMove:A,pickSlot:R,doSlot:B,makeShare:P,copyShare:D,pressRemove:O}=s;if(!f)return null;const L=`ap-pop-title-${e.num}`,z=p&&a.jsx("p",{className:"ap-pop-error",role:"alert",title:p.raw||void 0,children:p.text});return a.jsxs(Hb,{anchorId:`ap-more-${e.num}`,boundaryId:r,id:`ap-menu-${e.num}`,className:"ap-pop",role:f.view==="menu"?"menu":"dialog",labelledBy:f.view==="menu"?`ap-more-${e.num}`:L,start:f.start,onClose:N,children:[f.view==="menu"&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>_(e.num,e.alias),children:"Rename"}),a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>A(e.num),children:"Move to slot…"}),a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...l(`share-${e.num}`),title:`Copy this account to another ${bt}. Anyone who has the text can use the account — treat it as the password. The other deck stops accepting it after 10 minutes; that does not make an escaped copy safe.`,onClick:()=>P(e.num),children:o===`share-${e.num}`?"Sharing…":"Share"}),a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",title:"See how much this account worked in each project",onClick:()=>d(),children:"Projects"}),(u&&!e.active||e.disabled)&&a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...l(`rot-${e.num}`),title:e.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",onClick:()=>h(),children:e.disabled?"Put back in rotation":"Hold out of rotation"}),a.jsx("div",{role:"separator",className:"ap-menu-sep"}),a.jsx("button",{type:"button",role:"menuitem",className:`ap-menu-item danger${v===e.num?" armed":""}`,...l(`rm-${e.num}`),"aria-label":v===e.num?"Confirm remove":void 0,title:v===e.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>O(e.num),children:o===`rm-${e.num}`?"Removing…":v===e.num?"Confirm":"Remove"}),z]}),f.view==="rename"&&a.jsxs("form",{className:"ap-pop-form",onSubmit:M=>{M.preventDefault(),T(e.num,e.alias)},children:[a.jsx("label",{className:"ap-pop-title",id:L,htmlFor:`ap-alias-${e.num}`,children:"Rename account"}),a.jsx("input",{id:`ap-alias-${e.num}`,className:"ap-manage-input",type:"text",value:g,onChange:M=>E(M.target.value),maxLength:Q9,placeholder:"e.g. work",spellCheck:!1,autoComplete:"off",autoFocus:!0,onFocus:M=>M.currentTarget.select()}),z,a.jsxs("div",{className:"ap-pop-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>S(),children:"Cancel"}),a.jsx("button",{type:"submit",className:"btn primary",...l(`alias-${e.num}`),title:"A short name to show instead of the email",children:o===`alias-${e.num}`?"…":"Save"})]})]}),f.view==="move"&&(()=>{const M=Z9(t,e.num),$=tV(M,x,e.num),q=nV(M,$,e.num);return a.jsxs("div",{className:"ap-pop-form",children:[a.jsx("label",{className:"ap-pop-title",id:L,htmlFor:`ap-slot-${e.num}`,children:"Move to slot"}),a.jsx("span",{className:"ap-field",children:a.jsx("select",{id:`ap-slot-${e.num}`,value:String($),...l(`move-${e.num}`),onChange:X=>R(Number(X.target.value)),autoFocus:!0,children:M.map(X=>a.jsx("option",{value:X.slot,children:X.label},X.slot))})}),z,a.jsxs("div",{className:"ap-pop-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>S(),children:"Cancel"}),a.jsx("button",{type:"button",className:"btn primary",...l(`move-${e.num}`),title:q.title,onClick:()=>B(e.num,$,q),children:o===`move-${e.num}`?"…":vl(q.label)})]})]})})(),f.view==="share"&&(k==null?void 0:k.num)===e.num&&(()=>{const M=z$(k.expiresAt,n),$=M.tone==="gone";return a.jsxs("div",{className:"ap-pop-form",children:[a.jsx("p",{className:"ap-pop-title",id:L,children:"Share account"}),a.jsx("code",{className:"ap-share-blob",children:k.blob}),a.jsxs("p",{className:"ap-pop-note",title:"This text is the account's password. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the login itself is in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign the account out and back in.",children:[a.jsx("span",{className:"ap-share-warn",children:"This is the password"})," · ",a.jsx("span",{className:`ap-share-expiry ${M.tone}`,children:M.text})]}),z,a.jsxs("div",{className:"ap-pop-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>S(),children:"Done"}),a.jsx("button",{type:"button",className:"btn primary",...l(`share-${e.num}`),autoFocus:!0,onClick:async()=>{if($){await P(e.num);return}await D(k.blob)},children:$?"Make a new share":b?"Copied":"Copy"})]})]})})()]})}const aV=6;function oV(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?iV(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 iV(e){const t=e.map(n=>n.headroom).filter(n=>typeof n=="number");return t.length?Math.max(...t):null}function lV(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,aV),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 Or(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 cV={keychain_unavailable:{short:"Keychain locked on the other Mac",long:`the other Mac could not export it. On that Mac: ${Xb}. The next round brings it.`}};function $x(e){return e.why?Ot(cV,e.why)??hd(e.why):null}const Zb={"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"}},uV={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 nS(e){var r;const t=dV[e];if(t)return t;const n=(r=/\b(E[A-Z]{3,})\b/.exec(e))==null?void 0:r[1];return n&&uV[n]||e}const dV={"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 Gd(e,t){var f;if(!e)return null;if(e.error&&((f=e.done)!=null&&f.length)){const p=Gd({...e,error:void 0},t),g=` · ${Or(e.at,t)}`;return{...p,text:`${p.text.slice(0,-g.length)}, then ${nS(e.error)}${g}`,tone:"bad"}}if(e.error)return Zb[e.error]??{text:nS(e.error),tone:"bad"};const n=e.done??[];if(!n.length)return{text:`all logins fine · ${Or(e.at,t)}`,tone:"idle"};const r=n.filter(p=>p.ok),s=r.length===1?"login":"logins",o=n.map(p=>({d:p,why:$x(p)})).filter(p=>p.why),l=[...new Set(o.map(p=>p.why.short))],u=l.length?`, ${l.join(", ")}`:"",d=o.length?o.map(p=>`${p.d.email}: ${p.why.long}`).join(" "):void 0,h=Or(e.at,t);return r.length===n.length?{text:`${r.length} ${s} arrived${u} · ${h}`,tone:o.length?"warn":"ok",...d?{hint:d}:{}}:{text:`${r.length} of ${n.length} logins arrived${u} · ${h}`,tone:"bad",...d?{hint:d}:{}}}const hV=9e4;function fV({error:e,host:t,port:n},r,s,o=45317){if(e!=="handshake timed out")return null;const l=(t??"").trim();if(!l)return null;const u=r.filter(h=>h.addr===l&&h.port&&h.at>0&&s-h.at<hV);if(!u.length)return null;const d=[...new Set(u.map(h=>h.port))];if(n!=null&&!d.includes(n)){const h=d.length===1?`port ${d[0]}`:`ports ${d.join(" and ")}`;return`A deck at ${l} is announcing itself on ${h}, not on ${n}. This deck already hears it and dials it there, so this typed row has nothing to reach.`}return`That machine is running the deck — its beacon arrives here every half minute — and what this deck sends back never gets there. That is a firewall on ${l}, not a network fault. Whoever uses it can allow two ports: UDP ${o} and TCP ${n??d[0]}.`}function Kd(e,t){var n,r;return(n=e.last)!=null&&n.error&&!Zb[e.last.error]?!1:!!((r=e.last)!=null&&r.at&&t-e.last.at<Ix||e.lastSeen!=null&&t-e.lastSeen<Ix)}const Ix=95e3;function pV(e,t){if(!e)return{text:"checking…",tone:"idle"};if(!e.enabled)return{text:"",tone:"idle"};if(e.stalled)return{text:`could not start — ${e.stalled}`,tone:"bad"};if(!e.running)return{text:"starting…",tone:"wait"};const n=(e.pending??[]).length;if(n)return{text:n===1?"1 deck is waiting for your answer":`${n} decks are waiting for your answer`,tone:"wait"};const r=(e.peers??[]).filter(p=>p.paired!==!1||p.met);if(!r.length)return{text:"no deck paired yet",tone:"idle"};const s=p=>p.waiting?H$(p.lastSeen,t):Kd(p,t),o=p=>{var g;return!p.waiting&&((g=p.last)==null?void 0:g.error)==="waiting for the other deck to accept this one"},l=e.aliases??{};let u=0,d=0,h=0;for(const p of G$(r,g=>V$(g,g.peerFp??g.fp,l).name,g=>g.addr??"")){const g=p.filter(s);if(!g.length){h++;continue}u++,g.every(o)&&d++}if(u&&d===u)return{text:u===1?"1 deck found · waiting for them to accept":`${u} decks found · waiting for them to accept`,tone:"wait"};if(!u)return{text:h===1?"this deck cannot reach the one it is paired with":`this deck cannot reach any of its ${h} decks`,tone:"bad"};const f=u===1?"1 deck ready":`${u} decks ready`;return{text:h?`${f} · ${h} away`:f,tone:"ok"}}function mV(e,t,n){if(n)return"checking…";if(e==null)return"not checked yet";const r=Or(e,t);return r==="now"?"checked just now":`checked ${r}`}function Jb(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 H$(e,t){return e!=null&&t-e<Ix}function gV(e,t){if(e==null)return{text:"one-way · has not called yet",here:!1};const n=H$(e,t);return{text:n?"online · one-way, it calls in":`one-way · last online ${Or(e,t)}`,here:n}}function rS(e,t,n){return t?"online":e.lastSeen!=null?`last online ${Or(e.lastSeen,n)}`:e.waiting?"has not called yet":"never reached"}function yV(e,t){if(!e)return[];const n=[],r=new Set,s=(p,g)=>p.name.localeCompare(g.name,void 0,{numeric:!0}),o=e.aliases??{};for(const p of e.pending??[])!(p!=null&&p.fp)||r.has(p.fp)||(r.add(p.fp),n.push(wV(p,o,t)));const l=[],u=[];for(const p of e.peers??[]){const g=p.peerFp??p.fp;!g||r.has(g)||(r.add(g),!p.paired&&p.manual&&!p.met?u.push(vV(p,g,t)):l.push(xV(p,g,o,t)))}n.push(...NV(l).sort(s),...u.sort(s));const d=[];for(const p of e.strangers??[])!(p!=null&&p.fp)||r.has(p.fp)||(r.add(p.fp),d.push(bV(p,o,e.pairingMode)));n.push(...d.sort(s));const h=[];for(const p of e.declined??[])!(p!=null&&p.fp)||r.has(p.fp)||(r.add(p.fp),h.push(kV(p,o)));n.push(...h.sort(s));const f=new Map;for(const p of n)f.set(p.name,(f.get(p.name)??0)+1);for(const p of n)(f.get(p.name)??0)<2||!p.addr||(p.state=p.quiet||!p.state?p.addr:`${p.addr} · ${p.state}`,p.quiet=!1);return n}function wV(e,t,n){const r=Yd(t,e.fp,e.name||e.fp);return{fp:e.fp,...r,addr:e.addr??"",kind:"asks",state:`wants to pair · ${Jb(e.at,n)}`,tone:"wait",here:!0,hint:`${r.name} at ${e.addr}${e.via==="tailscale"?", over Tailscale,":""} is waiting for an answer.`,...Xd(e.via)}}function vV(e,t,n){var o;const r=Gd(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?Ox(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.`,...Xd(e.via)}}function xV(e,t,n,r){var v,k,b,x;const s=Gd(e.last,r),o=Kd(e,r),l=e.addr?`${e.addr}:${e.port}`:"",u=e.waiting?gV(e.lastSeen,r):null,d=u?u.here:o,h=!u&&s?d?`online · ${Ox(s)}`:`${Ox(s)} · ${rS(e,d,r)}`:u?u.text:rS(e,d,r),f=(v=e.last)!=null&&v.error?Zb[e.last.error]:null,p=!u&&d&&!((k=e.last)!=null&&k.error)&&!(((b=e.last)==null?void 0:b.done)??[]).length,g=V$(e,t,n);return{fp:t,...g,addr:e.addr??"",kind:"paired",state:h,quiet:p,tone:f?f.tone==="bad"?"bad":"wait":s?s.tone:d?"ok":"idle",here:u?u.here:o,...Xd(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 ${Or(e.lastSeen,r)}.`} Add its address through Add a deck, the link at the top of this view, to reach it either way.`:`${g.name}${l?` at ${l}`:""}${(x=e.last)!=null&&x.error?` — ${e.last.error}`:""}${s!=null&&s.hint?` — ${s.hint}`:""}`}}function V$(e,t,n){return e.manual&&!e.met?{name:e.addr?`${e.addr}:${e.port}`:""}:Yd(n,t,e.name||t)}function bV(e,t,n){const r=Yd(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.`,...Xd(e.via)}}function kV(e,t){const n=Yd(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 Yd(e,t,n){const r=t?e[t]:void 0;return r&&r!==n?{name:r,self:n}:{name:n}}function Xd(e){return e==="tailscale"?{via:"tailscale"}:{}}function Ox(e){return e.text.replace(/ · .*$/,"")}function NV(e){return G$(e,t=>t.name,t=>t.addr).map(jV)}function G$(e,t,n){const r=new Map;for(const o of e){const l=r.get(t(o));l?l.push(o):r.set(t(o),[o])}const s=[];for(const o of r.values()){const l=[...new Set(o.map(n).filter(Boolean))];if(l.length>1){for(const u of l)s.push(o.filter(d=>n(d)===u));for(const u of o)n(u)||s.push([u])}else s.push(o)}return s}function jV(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 sS(e,t){return t?e.map(n=>t[n.fp]?{...n,name:t[n.fp]}:n):e}function Hl(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 SV(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 _V(e,t){const n=e.filter(f=>f.kind==="asks"),r=e.filter(f=>f.kind!=="asks"),s=r.filter(f=>f.here),o=r.filter(f=>!f.here),l=o.filter(f=>f.tone==="bad").length,u=t||s.length===0,d=u?[...s,...o]:s,h=r.filter(f=>f.kind==="paired").length;return{asks:n,rest:r,live:s,folded:o,troubled:l,showFolded:u,shown:d,paired:h}}function aS(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 EV(e,t,n){if(!(t!=null&&t.enabled)||!(t.shared??[]).includes(e))return!1;const r=(t.peers??[]).filter(s=>s.paired&&Kd(s,n)).map(s=>{var o,l;return(l=(o=s.offers)==null?void 0:o.accounts)==null?void 0:l.find(u=>u.key===e)}).filter(s=>s!=null);return r.length>0&&r.every(s=>!s.alive)}function CV(e,t,n,r){if(!(n!=null&&n.enabled)||n.running===!1||!(n.shared??[]).includes(e))return!1;const s=String(t??"").trim().toLowerCase();return(n.peers??[]).some(o=>{var u,d,h,f;if(!o.paired||!Kd(o,r))return!1;const l=(d=(u=o.offers)==null?void 0:u.accounts)==null?void 0:d.find(p=>p.key===e);return!(l!=null&&l.alive)||l.shareable===!1?!1:!((f=(h=o.last)==null?void 0:h.done)!=null&&f.some(p=>p.action==="heal"&&String(p.email??"").trim().toLowerCase()===s))})}const K$=160,Y$=140;function TV(){const[e,t]=w.useState(!1),n=w.useRef(0);return w.useEffect(()=>()=>window.clearTimeout(n.current),[]),{peek:e,openPeek:u=>{window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!0),u)},shutPeek:()=>{window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!1),Y$)},holdPeek:()=>window.clearTimeout(n.current),dropPeek:()=>{window.clearTimeout(n.current),t(!1)}}}function AV(e){var t;return((t=e==null?void 0:e.detail)==null?void 0:t.fix)==="give_back"}function rr(e,t){return{text:e,giveBack:AV(t),done:!1}}async function RV(){try{return await(await fetch("/api/prefs/give-back",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json().catch(()=>null)}catch{return null}}const MV={cancelled:"Nothing changed — the password dialog was closed. The folder still belongs to another user.",timed_out:"Nothing changed — the password dialog was not answered in time.",busy:"The password dialog is already open. It may be behind this window."};function $V(e){if(e!=null&&e.ok)return{text:e.changed===!1?"The settings folder is already yours, and the deck has read it again. Try that once more.":"Done — the settings folder is yours again, and the deck has read it again. Try that once more.",giveBack:!1,done:!0};if(e==null)return{text:"Could not give it back — the deck did not answer.",giveBack:!0,done:!1};const t=e.reason?MV[e.reason]:void 0;return t?{text:t,giveBack:!0,done:!1}:{text:"macOS did not give the folder back. The deck's log has the command that does it by hand.",giveBack:!1,done:!1}}const Lx=5e3,X$=6e4;function Et(e,t){if(t==null)return`Could not ${e} — the deck did not answer.`;const n=t.reason?LV(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 IV={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."},OV=new Set(["EACCES","EPERM"]);function LV(e,t){const n=IV[e];if(!n)return;const r=e==="prefs_unreadable"&&t?PV(t):void 0,s=t!=null&&t.code&&t.code!=="BADJSON"?` Error code: ${t.code}.`:"";return(r??n)+s}function PV({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&&!OV.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 Do(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}function DV(e,t){const[n,r]=w.useState(null),[s,o]=w.useState([]),[l,u]=w.useState(null),[d,h]=w.useState(null),f=w.useRef(null),p=w.useCallback(O=>zd(f.current)?(f.current=O,u(O),!0):!1,[]),g=w.useCallback(()=>{f.current=null,x.current&&u(null)},[]),v=O=>{const L=Qs(l,O);return{disabled:L.disabled,"aria-busy":L.busy}},[k,b]=w.useState(()=>Date.now()),x=w.useRef(!0),N=w.useRef(Lx),S=w.useCallback(async()=>{var O,L;try{const[z,M]=await Promise.all([fetch("/api/lan").then($=>$.json()),fetch("/api/prefs").then($=>$.json())]);if(!x.current)return;z!=null&&z.ok&&r(z),M!=null&&M.ok&&o(Array.isArray((L=(O=M.prefs)==null?void 0:O.lan)==null?void 0:L.manual)?M.prefs.lan.manual:[]),N.current=(z==null?void 0:z.enabled)===!0?Lx:X$}catch{}},[]);w.useEffect(()=>{x.current=!0;let O=0;const L=async()=>{b(Date.now()),await S(),x.current&&(O=window.setTimeout(L,N.current))};return L(),()=>{x.current=!1,window.clearTimeout(O)}},[S]);const _=w.useCallback(async()=>{const O=(n==null?void 0:n.enabled)===!0;if(p("switch"))try{const L=await Do("/api/prefs",{lan:{enabled:!O}});if(!x.current)return;L!=null&&L.ok?(h(null),O||t()):h(rr(Et(O?"turn this off":"turn this on",L),L)),await S()}catch{x.current&&h(rr(Et(O?"turn this off":"turn this on",null)))}finally{g()}},[n==null?void 0:n.enabled,S,p,g,t]),E=w.useCallback(async(O,L,z)=>{if(!p(`${O}:${L}`))return null;let M=null;try{const $=await Do("/api/lan/peer",{action:O,fp:L});if(!x.current)return null;$!=null&&$.ok?(r($),h(null)):(M=Et(z,$),h(rr(M,$))),await S()}catch{M=Et(z,null),x.current&&h(rr(M))}finally{g()}return M},[S,p,g]),T=w.useCallback(async O=>{if(!p(`drop:${O}`))return null;let L=null;try{const z=await Do("/api/prefs",{lan:{manual:s.filter(M=>M!==O)}});if(!x.current)return null;z!=null&&z.ok?(h(null),e()):(L=Et("stop dialling that address",z),h(rr(L,z))),await S()}catch{L=Et("stop dialling that address",null),x.current&&h(rr(L))}finally{g()}return L},[s,S,e,p,g]),A=w.useCallback(async(O,L)=>{if(!p(`alias:${O}`))return"Something else is still being saved. Try again in a moment.";try{const z=await Do("/api/lan/peer",{action:"alias",fp:O,name:L});return x.current?z!=null&&z.ok?(r(z),null):Et("rename that deck",z):null}catch{return Et("rename that deck",null)}finally{g()}},[p,g]),R=w.useCallback(async O=>{if(!p(`check:${O}`))return null;try{const L=await Do("/api/lan/sync",{fp:O});return x.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.":Et("check that deck",L):null}catch{return Et("check that deck",null)}finally{g()}},[p,g,e]),B=w.useCallback(async()=>{if(p("check"))try{const O=await Do("/api/lan/sync",{});if(!x.current)return;O!=null&&O.ok?(r(O),h(null)):h(rr(Et("check the other decks",O),O)),e()}catch{x.current&&h(rr(Et("check the other decks",null)))}finally{g()}},[p,g,e]);return{status:n,manual:s,now:k,busy:l,failure:d,dismissFailure:()=>h(null),answerGiveBack:O=>{h(O),O.done&&(S(),e())},pressProps:v,load:S,toggle:_,answer:E,dropAddress:T,rename:A,checkOne:R,checkNow:B}}function FV(e){const[t,n]=w.useState(null),r=w.useRef(0);return w.useEffect(()=>{if(t==null)return;const o=window.setTimeout(()=>n(null),4e3);return()=>window.clearTimeout(o)},[t]),{armed:t,pressUnpair:o=>{const l=Date.now(),u=ql({armedFor:t,target:o.fp,armedAt:r.current,now:l,gapMs:Bl});if(u==="arm"){n(o.fp),r.current=l;return}u!=="ignore"&&(n(null),e("unpair",o.fp,"unpair that deck"))}}}function Z$({title:e,steps:t,finish:n,aside:r,onClose:s}){const o=w.useRef(null),l=ft(s,{focusRef:o}),[u,d]=w.useState(0),h=u===t.length-1,f=t[u],p=k=>d(Math.max(0,Math.min(t.length-1,k)));w.useEffect(()=>{var k,b;Pr(((k=document.activeElement)==null?void 0:k.tagName)??null)&&((b=o.current)==null||b.focus())},[u]);const g=k=>{k.key!=="ArrowRight"&&k.key!=="ArrowLeft"||(k.preventDefault(),k.stopPropagation(),p(k.key==="ArrowRight"?u+1:u-1))},v=()=>{if(!h){p(u+1);return}n?n.act():s()};return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",onClick:s,role:"presentation",children:a.jsxs("div",{ref:l,className:"modal guide",onClick:k=>k.stopPropagation(),onKeyDown:g,role:"dialog","aria-modal":"true","aria-labelledby":"guide-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{id:"guide-title",className:"modal-tool-name",children:e}),a.jsxs("span",{className:"modal-tool-id",children:[u+1," / ",t.length]})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsx("div",{className:"guide-stage",children:f.art},u),a.jsx("p",{className:"guide-line","aria-live":"polite",children:f.line}),a.jsx("p",{className:"guide-tip",children:f.tip??""}),a.jsxs("div",{className:"guide-foot",children:[a.jsx("div",{className:"guide-dots",children:t.map((k,b)=>a.jsx("button",{type:"button",className:"glyph-btn guide-dot","aria-label":`Step ${b+1} of ${t.length}`,"aria-current":b===u?"step":void 0,onClick:()=>p(b)},b))}),h&&r&&a.jsx("button",{type:"button",className:"ap-lan-word guide-aside",onClick:r.act,children:r.label}),u>0&&a.jsx("button",{type:"button",className:"btn",onClick:()=>p(u-1),children:"Back"}),a.jsx("button",{ref:o,type:"button",className:"btn primary",onClick:v,children:h?(n==null?void 0:n.label)??"Done":"Next"})]})]})]})}),document.body)}const Px={ok:"ga-ok",warn:"ga-warn",accent:"ga-accent",flight:"ga-flight"};function Fn({children:e}){return a.jsx("svg",{className:"guide-art",viewBox:"0 0 440 200","aria-hidden":!0,focusable:"false",children:e})}function Dn({x:e,y:t=34,w:n=176,h:r=132,label:s}){return a.jsxs(a.Fragment,{children:[s&&a.jsx("text",{x:e+2,y:t-9,className:"ga-cap",children:s}),a.jsx("rect",{x:e,y:t,width:n,height:r,rx:10,className:"ga-screen"})]})}function cr({x:e,y:t,email:n,state:r,tone:s,bars:o}){return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:e+3,cy:t-4,r:3,className:Px[s]}),a.jsx("text",{x:e+12,y:t,className:"ga-t ga-mono",children:n}),a.jsx("text",{x:e+12,y:t+16,className:`ga-s ${Px[s]}`,children:r}),o==null?void 0:o.map((l,u)=>a.jsxs("g",{children:[a.jsx("text",{x:e,y:t+40+u*18,className:"ga-s",children:u?"7d":"5h"}),a.jsx("rect",{x:e+22,y:t+35+u*18,width:96,height:4,rx:2,className:"ga-track"}),a.jsx("rect",{x:e+22,y:t+35+u*18,width:96*l/100,height:4,rx:2,className:"ga-accent"}),a.jsxs("text",{x:e+148,y:t+40+u*18,className:"ga-s ga-accent",textAnchor:"end",children:[l,"%"]})]},u))]})}function J$({x:e,y:t,on:n}){return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:e,y:t,width:30,height:18,rx:9,className:n?"ga-switch-on":"ga-switch"}),a.jsx("circle",{cx:n?e+21:e+9,cy:t+9,r:6,className:n?"ga-knob-on":"ga-knob"})]})}function _u({x:e,y:t,name:n,here:r=!0}){return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:e+3,cy:t-4,r:3,className:r?"ga-ok":"ga-dim"}),a.jsx("text",{x:e+12,y:t,className:r?"ga-t":"ga-s",children:n})]})}function oS({x:e,y:t,on:n}){return n?a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:e,y:t,width:12,height:12,rx:3,className:"ga-accent"}),a.jsx("path",{d:`M${e+3} ${t+6.2}l2.3 2.3 4-4.6`,className:"ga-tick"})]}):a.jsx("rect",{x:e+.5,y:t+.5,width:11,height:11,rx:3,className:"ga-box"})}function iS({x:e,y:t,d:n}){return a.jsx("path",{d:n,transform:`translate(${e} ${t})`,className:"ga-glyph"})}function Qb({x:e,y:t}){return a.jsx("path",{d:`M${e} ${t}l0 13 3.4-3 2.4 5.2 2-.9-2.4-5.1 4.6-.2z`,className:"ga-pointer"})}function e0(){return a.jsxs(a.Fragment,{children:[a.jsx("circle",{r:9,className:"ga-key-bed"}),a.jsxs("g",{transform:"translate(-6 -6) scale(0.857)",className:"ga-key",children:[a.jsx("circle",{cx:4.6,cy:7,r:2.6}),a.jsx("path",{d:"M7.2 7h5.2M10.6 7v2.2M12.4 7v1.6"})]})]})}function Ho({x:e,y:t,w:n,title:r,sub:s,tone:o}){return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:e,y:t,width:n,height:40,rx:8,className:"ga-screen"}),a.jsx("rect",{x:e+6,y:t+10,width:3,height:20,rx:1.5,className:Px[o]}),a.jsx("text",{x:e+16,y:t+17,className:"ga-t ga-strong",children:r}),a.jsx("text",{x:e+16,y:t+31,className:"ga-s",children:s})]})}function ei({x:e,y:t,label:n,live:r}){return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:e,y:t,width:46,height:20,rx:10,className:r?"ga-chip-live":"ga-chip"}),a.jsx("text",{x:e+23,y:t+14,className:"ga-s ga-mono",textAnchor:"middle",children:n})]})}function fd({x:e,y:t}){return a.jsxs(a.Fragment,{children:[a.jsx("text",{x:e,y:t,className:"ga-cap",children:"LOCAL NETWORK"}),a.jsx(J$,{x:e+118,y:t-13,on:!0})]})}function BV(){return a.jsxs(Fn,{children:[a.jsx("rect",{x:14,y:14,width:206,height:172,rx:10,className:"ga-screen"}),a.jsx("text",{x:28,y:38,className:"ga-t ga-strong",children:"Sessions"}),a.jsx("text",{x:206,y:38,className:"ga-s ga-warn",textAnchor:"end",children:"1 waiting"}),a.jsx("rect",{x:20,y:50,width:194,height:42,rx:6,className:"ga-bed-warn"}),a.jsx("circle",{cx:33,cy:64,r:7,className:"ga-ring-warn ga-ping"}),a.jsx("circle",{cx:33,cy:64,r:3.5,className:"ga-warn"}),a.jsx("text",{x:44,y:68,className:"ga-t",children:"api-server"}),a.jsx("text",{x:44,y:83,className:"ga-s ga-warn",children:"waiting 6m · Bash"}),a.jsx("circle",{cx:33,cy:108,r:3.5,className:"ga-flight"}),a.jsx("text",{x:44,y:112,className:"ga-t",children:"docs-site"}),a.jsx("text",{x:44,y:127,className:"ga-s",children:"running · 12 tools"}),a.jsx("circle",{cx:33,cy:150,r:3.5,className:"ga-ok"}),a.jsx("text",{x:44,y:154,className:"ga-t",children:"billing"}),a.jsx("text",{x:44,y:169,className:"ga-s",children:"done · $0.84"}),a.jsx("path",{d:"M216 71C234 71 230 100 244 100",className:"ga-arc"}),a.jsx("path",{d:"M239 96l5 4-5 4",className:"ga-arrow"}),a.jsx("rect",{x:248,y:44,width:178,height:112,rx:10,className:"ga-screen"}),a.jsx("text",{x:262,y:64,className:"ga-cap",children:"API-SERVER"}),a.jsx("line",{x1:248,y1:74,x2:426,y2:74,className:"ga-line"}),a.jsx("text",{x:262,y:96,className:"ga-s ga-mono",children:"Bash(npm test)"}),a.jsx("text",{x:262,y:116,className:"ga-t ga-mono ga-warn",children:"Allow this command?"}),a.jsx("text",{x:262,y:136,className:"ga-s ga-mono",children:"> 1. Yes 2. No"})]})}function qV(){return a.jsxs(Fn,{children:[a.jsx("path",{d:"M136 100C166 100 166 38 196 38",className:"ga-edge ga-flow"}),a.jsx("path",{d:"M136 100H196",className:"ga-edge ga-flow"}),a.jsx("path",{d:"M136 100C166 100 166 162 196 162",className:"ga-edge-done"}),a.jsx("path",{d:"M308 38H326M308 100H326",className:"ga-edge"}),a.jsx(Ho,{x:20,y:80,w:116,title:"main",sub:"Opus 5 · 9 tools",tone:"accent"}),a.jsx(Ho,{x:196,y:18,w:112,title:"explore",sub:"Haiku · 14 tools",tone:"flight"}),a.jsx(Ho,{x:196,y:80,w:112,title:"tests",sub:"Sonnet · 6 tools",tone:"flight"}),a.jsx(Ho,{x:196,y:142,w:112,title:"review",sub:"done · 38s",tone:"ok"}),a.jsx(ei,{x:326,y:28,label:"Read"}),a.jsx(ei,{x:380,y:28,label:"Grep",live:!0}),a.jsx(ei,{x:326,y:90,label:"Bash",live:!0})]})}function lS({x:e,y:t,label:n,pct:r,note:s}){return a.jsxs(a.Fragment,{children:[a.jsx("text",{x:e,y:t,className:"ga-s",children:n}),a.jsxs("text",{x:e+194,y:t,className:"ga-s ga-accent",textAnchor:"end",children:[r,"%"]}),a.jsx("rect",{x:e,y:t+7,width:194,height:5,rx:2.5,className:"ga-track"}),a.jsx("rect",{x:e,y:t+7,width:194*r/100,height:5,rx:2.5,className:"ga-accent"}),a.jsx("text",{x:e,y:t+26,className:"ga-s",children:s})]})}function UV(){return a.jsxs(Fn,{children:[a.jsx("rect",{x:14,y:30,width:172,height:140,rx:10,className:"ga-screen"}),a.jsx("text",{x:30,y:56,className:"ga-cap",children:"THIS SESSION"}),a.jsx("text",{x:30,y:98,className:"ga-big",children:"$3.66"}),a.jsx("text",{x:30,y:122,className:"ga-s",children:"Opus 5 · 1.2M tokens"}),a.jsx("text",{x:30,y:150,className:"ga-s",children:"$21.40 today"}),a.jsx("rect",{x:200,y:30,width:226,height:140,rx:10,className:"ga-screen"}),a.jsx("text",{x:216,y:56,className:"ga-cap",children:"CLAUDE QUOTA"}),a.jsx(lS,{x:216,y:80,label:"5-hour window",pct:24,note:"resets in 53m"}),a.jsx(lS,{x:216,y:124,label:"7-day window",pct:61,note:"resets in 4d"})]})}function zV(){return a.jsxs(Fn,{children:[a.jsx("rect",{x:14,y:40,width:172,height:120,rx:10,className:"ga-canvas"}),a.jsx(Ho,{x:30,y:80,w:140,title:"tests",sub:"Sonnet 5 · 6 tools",tone:"flight"}),a.jsx(Qb,{x:156,y:106}),a.jsx("path",{d:"M170 92C186 92 184 60 200 60",className:"ga-arc"}),a.jsx("path",{d:"M195 56l5 4-5 4",className:"ga-arrow"}),a.jsx(Dn,{x:200,y:22,w:226,h:160}),a.jsx("text",{x:214,y:46,className:"ga-t ga-strong",children:"tests"}),a.jsx("text",{x:412,y:46,className:"ga-s",textAnchor:"end",children:"Sonnet 5 · 38s"}),a.jsx("line",{x1:200,y1:56,x2:426,y2:56,className:"ga-line"}),a.jsx("text",{x:214,y:76,className:"ga-cap",children:"PROMPT"}),a.jsx("text",{x:214,y:92,className:"ga-t",children:"Run the suite and fix what fails"}),a.jsx("text",{x:214,y:116,className:"ga-cap",children:"TOOLS · 6"}),a.jsx(ei,{x:214,y:122,label:"Read"}),a.jsx(ei,{x:266,y:122,label:"Edit"}),a.jsx(ei,{x:318,y:122,label:"Bash",live:!0}),a.jsx("text",{x:214,y:164,className:"ga-cap",children:"TOKENS"}),a.jsx("text",{x:214,y:178,className:"ga-s ga-mono",children:"41k in · 2.1k out · $0.12"})]})}function WV(){const e=[18,24,28,14,22,26,30,16,24,28,20,26];return a.jsxs(Fn,{children:[a.jsx(Dn,{x:14,y:20,w:412,h:160}),a.jsx("text",{x:28,y:44,className:"ga-t ga-strong",children:"This machine"}),a.jsx("text",{x:412,y:44,className:"ga-s",textAnchor:"end",children:"12 cores · up 10d"}),a.jsx("line",{x1:14,y1:56,x2:426,y2:56,className:"ga-line"}),a.jsx("text",{x:28,y:76,className:"ga-cap",children:"CORES"}),e.map((t,n)=>a.jsxs("g",{children:[a.jsx("rect",{x:28+n*15,y:82,width:10,height:30,rx:2,className:"ga-track"}),a.jsx("rect",{x:28+n*15,y:112-t,width:10,height:t,rx:2,className:"ga-accent"})]},n)),a.jsx("text",{x:28,y:136,className:"ga-cap",children:"MEMORY"}),a.jsx("rect",{x:28,y:143,width:178,height:5,rx:2.5,className:"ga-track"}),a.jsx("rect",{x:28,y:143,width:105,height:5,rx:2.5,className:"ga-accent"}),a.jsx("text",{x:28,y:165,className:"ga-s",children:"18.9 GB of 32.0 GB"}),a.jsx("text",{x:240,y:76,className:"ga-cap",children:"THERMAL"}),a.jsx("text",{x:240,y:100,className:"ga-big",children:"66 °C"}),a.jsx("text",{x:240,y:118,className:"ga-s ga-ok",children:"running at full speed"}),a.jsx("text",{x:240,y:142,className:"ga-cap",children:"BUSIEST PROCESSES"}),a.jsx("text",{x:240,y:160,className:"ga-s ga-mono",children:"node · claude"}),a.jsx("text",{x:412,y:160,className:"ga-s ga-mono",textAnchor:"end",children:"38%"}),a.jsx("text",{x:240,y:176,className:"ga-s ga-mono",children:"esbuild"}),a.jsx("text",{x:412,y:176,className:"ga-s ga-mono",textAnchor:"end",children:"21%"})]})}function HV(){return a.jsxs(Fn,{children:[a.jsx("rect",{x:14,y:40,width:188,height:120,rx:10,className:"ga-screen"}),a.jsx("text",{x:28,y:60,className:"ga-cap",children:"~/MY-PROJECT"}),a.jsx("line",{x1:14,y1:70,x2:202,y2:70,className:"ga-line"}),a.jsxs("text",{x:28,y:100,className:"ga-t ga-mono",children:[a.jsx("tspan",{className:"ga-accent",children:"$"})," claude"]}),a.jsx("rect",{x:86,y:90,width:7,height:13,className:"ga-caret ga-blink"}),a.jsx("text",{x:28,y:130,className:"ga-s ga-mono",children:"or: codex"}),a.jsx("path",{d:"M210 100H238",className:"ga-arc"}),a.jsx("path",{d:"M233 95l6 5-6 5",className:"ga-arrow"}),a.jsx("rect",{x:250,y:40,width:176,height:120,rx:10,className:"ga-canvas"}),a.jsx("g",{className:"ga-pop",children:a.jsx(Ho,{x:278,y:80,w:120,title:"my-project",sub:"Opus 5 · live",tone:"accent"})})]})}function VV(){return a.jsxs(Fn,{children:[a.jsx(Dn,{x:14,y:16,w:232,h:170}),a.jsx("text",{x:28,y:40,className:"ga-t ga-strong",children:"Claude accounts"}),a.jsx(iS,{x:196,y:33,d:"M7 2.2v9.6M2.2 7h9.6"}),a.jsx(iS,{x:220,y:33,d:"M3.3 10.7L10.7 3.3M5.2 3.3h5.5v5.5"}),a.jsx("line",{x1:14,y1:52,x2:246,y2:52,className:"ga-line"}),a.jsx(cr,{x:28,y:74,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),a.jsx("rect",{x:190,y:62,width:44,height:18,rx:9,className:"ga-accent"}),a.jsx("text",{x:212,y:74,className:"ga-s ga-on-accent",textAnchor:"middle",children:"active"}),a.jsx("line",{x1:14,y1:140,x2:246,y2:140,className:"ga-line"}),a.jsx(cr,{x:28,y:160,email:"personal@me.dev",state:"signed in",tone:"ok"}),a.jsx("rect",{x:188,y:148,width:46,height:18,rx:9,className:"ga-chip"}),a.jsx("text",{x:211,y:160,className:"ga-s",textAnchor:"middle",children:"switch"}),a.jsx(Qb,{x:221,y:161}),a.jsx("path",{d:"M250 40C270 40 262 78 282 78",className:"ga-arc"}),a.jsx("path",{d:"M277 74l5 4-5 4",className:"ga-arrow"}),a.jsx(Dn,{x:282,y:62,w:144,h:64,label:"ANOTHER MACHINE"}),a.jsx("g",{className:"ga-pop",children:a.jsx(cr,{x:296,y:92,email:"work@team.dev",state:"shared here",tone:"ok"})})]})}function GV(){return a.jsxs(Fn,{children:[a.jsx(Dn,{x:14,label:"THIS MACHINE"}),a.jsx(fd,{x:28,y:60}),a.jsx("g",{className:"ga-swap-out",children:a.jsx(cr,{x:28,y:98,email:"work@team.dev",state:"login expired",tone:"warn"})}),a.jsx("g",{className:"ga-swap-in",children:a.jsx(cr,{x:28,y:98,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),a.jsx(Dn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(fd,{x:264,y:60}),a.jsx(cr,{x:264,y:98,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),a.jsx("path",{d:"M246 120C234 80 206 80 194 120",className:"ga-arc"}),a.jsx("g",{className:"ga-travel ga-travel-low",transform:"translate(220 90)",children:a.jsx(e0,{})})]})}const KV=[{art:a.jsx(BV,{}),line:"Sessions waiting on you top the session list, longest wait first.",tip:"A tone and a system notification when one stops to ask. The speaker in the topbar."},{art:a.jsx(qV,{}),line:"Every agent and subagent is a node. Tool calls light up as they run."},{art:a.jsx(zV,{}),line:"Double-click any node: its prompt, every tool call, tokens and timing."},{art:a.jsx(UV,{}),line:"What each session costs, and how much quota is left."},{art:a.jsx(WV,{}),line:"Cores, memory and heat while the agents run, and what is hogging them."},{art:a.jsx(VV,{}),line:"Several Claude accounts: switch, add one, share one to another machine."},{art:a.jsx(GV,{}),line:"Your machines repair each other's expired logins over the local network.",tip:"Open it from the row at the foot of the Claude accounts panel."},{art:a.jsx(HV,{}),line:"Run claude or codex in any folder. It shows up here on its own."}];function YV(){return a.jsxs(Fn,{children:[a.jsx(Dn,{x:14,label:"THIS MACHINE"}),a.jsx(cr,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"}),a.jsx("rect",{x:40,y:94,width:86,height:20,rx:10,className:"ga-pill-warn"}),a.jsx("text",{x:83,y:108,className:"ga-s ga-warn",textAnchor:"middle",children:"sign in again"}),a.jsx("line",{x1:198,y1:100,x2:242,y2:100,className:"ga-off"}),a.jsx(Dn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(cr,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]})]})}function XV(){return a.jsxs(Fn,{children:[a.jsx(Dn,{x:14,label:"THIS MACHINE"}),a.jsx(fd,{x:28,y:60}),a.jsx(_u,{x:28,y:92,name:"Ana's MacBook"}),a.jsx(_u,{x:28,y:114,name:"Dorin's PC"}),a.jsx(Dn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(fd,{x:264,y:60}),a.jsx(_u,{x:264,y:92,name:"Your MacBook"}),a.jsx(_u,{x:264,y:114,name:"Dorin's PC"}),a.jsx("line",{x1:196,y1:100,x2:244,y2:100,className:"ga-arc"}),a.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping"}),a.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping ga-ping-2"}),a.jsx("circle",{cx:220,cy:100,r:3,className:"ga-accent"})]})}function ZV(){return a.jsxs(Fn,{children:[a.jsx("rect",{x:90,y:18,width:260,height:164,rx:10,className:"ga-screen"}),a.jsx("text",{x:106,y:42,className:"ga-t ga-strong",children:"This deck on the network"}),a.jsx("line",{x1:90,y1:54,x2:350,y2:54,className:"ga-line"}),a.jsx("text",{x:106,y:76,className:"ga-cap",children:"SHARE THESE ACCOUNTS"}),a.jsx(oS,{x:106,y:88,on:!0}),a.jsx("text",{x:126,y:98,className:"ga-t ga-mono",children:"work@team.dev"}),a.jsx(oS,{x:106,y:112}),a.jsx("text",{x:126,y:122,className:"ga-s ga-mono",children:"personal@me.dev"}),a.jsx("text",{x:106,y:150,className:"ga-cap",children:"PAIRING"}),a.jsx("text",{x:106,y:168,className:"ga-s",children:"Say yes to every deck that asks"}),a.jsx(J$,{x:304,y:157,on:!0}),a.jsx(Qb,{x:115,y:97})]})}function JV(){return a.jsxs(Fn,{children:[a.jsx(Dn,{x:14,label:"THIS MACHINE"}),a.jsx("g",{className:"ga-swap-out",children:a.jsx(cr,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"})}),a.jsx("g",{className:"ga-swap-in",children:a.jsx(cr,{x:28,y:64,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),a.jsx(Dn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(cr,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),a.jsx("path",{d:"M246 96C234 56 206 56 194 96",className:"ga-arc"}),a.jsx("g",{className:"ga-travel",transform:"translate(220 66)",children:a.jsx(e0,{})})]})}const QV=[{art:a.jsx(YV,{}),line:"A login can expire on one machine while it still works on another."},{art:a.jsx(XV,{}),line:"Both decks are on. They find each other and ask to pair.",tip:"Not showing up? Add a deck, the link at the top, takes an address or invite."},{art:a.jsx(ZV,{}),line:"Tick which logins this machine may hand out. Nothing is shared until you do."},{art:a.jsx(JV,{}),line:"An expired login is copied from a paired machine within a minute."}];function eG(){return a.jsxs("svg",{className:"guide-art",viewBox:"0 0 232 60","aria-hidden":!0,focusable:"false",children:[a.jsx("rect",{x:1,y:14,width:78,height:42,rx:7,className:"ga-screen"}),a.jsx("circle",{cx:13,cy:29,r:3,className:"ga-warn"}),a.jsx("rect",{x:21,y:27,width:46,height:4,rx:2,className:"ga-track"}),a.jsx("rect",{x:13,y:39,width:40,height:3,rx:1.5,className:"ga-track"}),a.jsx("rect",{x:153,y:14,width:78,height:42,rx:7,className:"ga-screen"}),a.jsx("circle",{cx:165,cy:29,r:3,className:"ga-ok"}),a.jsx("rect",{x:173,y:27,width:46,height:4,rx:2,className:"ga-track"}),a.jsx("rect",{x:165,y:39,width:40,height:3,rx:1.5,className:"ga-accent"}),a.jsx("path",{d:"M150 36C138 6 94 6 82 36",className:"ga-arc"}),a.jsx("g",{transform:"translate(116 13)",children:a.jsx(e0,{})})]})}const tG={panel:"Nothing here is stuck: whoever pastes an invite is the one dialling out. Ask them for one and paste it behind Add a deck, the link above, where an address can be typed too.",dialog:"Nothing here is stuck: whoever pastes an invite is the one dialling out. Ask them for one and paste it below, or type their address."},nG=1600;function Q$({reach:e,where:t}){const[n,r]=w.useState(!1),s=w.useRef(!0);w.useEffect(()=>()=>{s.current=!1},[]);const o=(e==null?void 0:e.steps)??[],l=w.useCallback(async()=>{await Wa(o.join(`
82
+ `))&&s.current&&(r(!0),window.setTimeout(()=>{s.current&&r(!1)},nG))},[o]);if(!(e!=null&&e.blocked))return null;const u=e.shell==="sh";return a.jsxs("div",{className:"ap-lan-reach",children:[a.jsx("p",{className:"lan-warn",children:e.text}),a.jsx("p",{className:"lan-note",children:tG[t]}),o.length>0&&a.jsxs("details",{className:"ap-lan-reach-fix",children:[a.jsx("summary",{children:"or let them find this deck on their own"}),a.jsxs("p",{className:"lan-note",children:[u?a.jsx(a.Fragment,{children:"Run this in a terminal on this machine, then restart the deck."}):a.jsxs(a.Fragment,{children:["Run this in PowerShell ",a.jsx("strong",{children:"as Administrator"}),", then restart the deck."]}),e.category==="Public"&&a.jsx(a.Fragment,{children:" The first line marks this network as a home or office one — leave it out on a network you do not trust."}),e.unsure&&a.jsxs(a.Fragment,{children:[" ",e.unsure]})]}),a.jsx("pre",{className:"ap-lan-cmd",children:a.jsx("code",{children:o.join(`
83
+ `)})}),a.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>void l(),title:u?"Copy these lines, then paste them into a terminal":"Copy these lines, then paste them into an elevated PowerShell",children:n?"copied":"copy command"})]})]})}function rG(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 sG(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 Np(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}const aG={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."},oG={not_running:"This deck is not on the network yet. Turn Local network on, then make one."};function cS(e,t,n){return(t==null?void 0:t.reason)&&e[t.reason]||Et(n,t)}function iG({status:e,manual:t,startWith:n,onClose:r,onChanged:s}){const o=w.useRef(null),l=w.useRef(null),u=w.useRef(null),d=w.useRef(null),h=e.pairingMode==="invite",f=ft(r,{focusRef:h?l:o}),[p,g]=w.useState(""),[v,k]=w.useState(""),[b,x]=w.useState(null),[N,S]=w.useState(null),[_,E]=w.useState(null),[T,A]=w.useState(null),[R,B]=w.useState(()=>Date.now());w.useEffect(()=>{const G=window.setInterval(()=>B(Date.now()),1e3);return()=>window.clearInterval(G)},[]);const P=w.useRef(!0);w.useEffect(()=>()=>{P.current=!1},[]);const D=w.useRef(null),O=w.useRef(null),L=w.useCallback(G=>zd(D.current)?(D.current=G,E(G),!0):!1,[]),z=w.useCallback(()=>{D.current=null,P.current&&E(null)},[]),M=G=>{const K=Qs(_,G);return{disabled:K.disabled,"aria-busy":K.busy}},$=G=>(b==null?void 0:b.field)===G?{"aria-invalid":!0,"aria-describedby":"lan-add-failure"}:{},q=G=>x(K=>K&&K.field===G?null:K),X=w.useCallback(async()=>{if(h)return;const G=rG(p);if(!G){x({text:lG(p),field:"addr"});return}const K=`${G.addr}:${G.port}`,Z=e.peers.find(ee=>ee.addr===G.addr&&ee.port===G.port&&ee.paired);if(Z){x({text:`Already paired with ${Z.name} at that address.`,field:"addr"});return}if(t.includes(K)){x({text:"This deck already calls that address.",field:"addr"});return}if(L("add"))try{const ee=await Np("/api/prefs",{lan:{manual:[...t,K]}});if(!P.current)return;ee!=null&&ee.ok?(x(null),g(""),s(),r()):x({text:Et("add that address",ee),field:"addr"})}catch{P.current&&x({text:Et("add that address",null),field:"addr"})}finally{z()}},[p,h,t,e.peers,s,r,L,z]),H=w.useCallback(async G=>{if(!L(`invite:${G}`))return;const K=G==="make"?"make an invite":"cancel that invite";try{const Z=await Np("/api/lan/invite",{action:G});if(!P.current)return;Z!=null&&Z.ok?(O.current=G,x(null),S(null),s()):x({text:cS(oG,Z,K)})}catch{P.current&&x({text:Et(K,null)})}finally{z()}},[s,L,z]),I=w.useCallback(async()=>{const G=v.trim();if(!(!G||!L("join"))){A(null);try{const K=await Np("/api/lan/invite",{action:"join",token:G});if(!P.current)return;K!=null&&K.ok?(k(""),x(null),s(),r()):(K==null?void 0:K.reason)==="unreachable"&&Array.isArray(K.tried)&&K.tried.length?(A(K.tried),x(null)):(A(null),x({text:cS(aG,K,"use that invite"),field:"join"}))}catch{P.current&&x({text:Et("use that invite",null),field:"join"})}finally{z()}}},[v,s,r,L,z]),W=w.useCallback(async(G,K)=>{try{await navigator.clipboard.writeText(G),S(K),window.setTimeout(()=>{P.current&&S(Z=>Z===K?null:Z)},1600)}catch{x({text:"Could not copy it — select the text and copy it by hand."})}},[]),F=e.invite&&e.invite.expiresAt>R?e.invite:null,Y=w.useRef(!1);w.useEffect(()=>{n!=="invite"||Y.current||F||(Y.current=!0,H("make"))},[n,F,H]);const J=w.useRef(!1);w.useEffect(()=>{var G;n!=="invite"||J.current||!F||(J.current=!0,(G=u.current)==null||G.focus())},[n,F]),w.useEffect(()=>{var K,Z;const G=O.current;!G||G==="make"!=!!F||(O.current=null,Pr(((K=document.activeElement)==null?void 0:K.tagName)??null)&&((Z=(G==="make"?u:d).current)==null||Z.focus()))},[F]);const V=e.port!=null?(e.addrs??[]).map(G=>`${G}:${e.port}`):[];return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",onClick:r,role:"presentation",children:a.jsxs("div",{ref:f,className:"modal lan-add",onClick:G=>G.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-add-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"lan-add-title",className:"modal-tool-name",children:"Add a deck"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{className:"glyph-btn",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[b&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{id:"lan-add-failure",className:"ap-failure-text",children:b.text}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>x(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),a.jsx(Q$,{reach:e.reach,where:"dialog"}),h&&a.jsx("div",{className:"modal-section",children:a.jsx("p",{className:"lan-note",children:"Adding by address is off while this deck pairs only by invite."})}),!h&&a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"By address"}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("input",{ref:o,className:"ap-manage-input ap-lan-input","aria-label":"Another deck's address",value:p,placeholder:"192.168.1.5:54340",spellCheck:!1,...$("addr"),onChange:G=>{g(G.target.value),q("addr")},onKeyDown:G=>{G.key==="Enter"&&X()}}),p.trim()!==""&&a.jsx("button",{type:"button",className:"ap-manage-btn",...M("add"),onClick:()=>void X(),title:"Add it to the decks this one calls, starting now.",children:"add"})]}),a.jsx("p",{className:"lan-note",children:"This deck calls that address until somebody there accepts."}),e.port!=null&&V.length>0&&a.jsxs("p",{className:"lan-note",children:["They type this deck’s own address into the same field on theirs:"," ",V.map((G,K)=>a.jsxs("span",{children:[K>0&&" or ",a.jsx("code",{className:"ap-lan-code",children:G})]},G)),a.jsx("button",{type:"button",className:"ap-lan-word lan-copy",...M("copy:mine"),onClick:()=>void W(V.join(" "),"mine"),title:"Copy this deck's address, to send to whoever is adding it",children:N==="mine"?"copied":"copy"})]})]}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("h3",{className:"lan-h",children:["With an invite",!F&&a.jsx("button",{type:"button",className:"ap-lan-word lan-h-act",ref:d,...M("invite:make"),onClick:()=>void H("make"),title:"One piece of text you send them. They paste it, and the two decks pair — nobody has to press anything here.",children:_==="invite:make"?"making…":"make one to send"})]}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("input",{ref:l,className:"ap-manage-input ap-lan-input","aria-label":"An invite you were sent",value:v,placeholder:"paste one you were sent",spellCheck:!1,...$("join"),onChange:G=>{k(G.target.value),A(null),q("join")},onKeyDown:G=>{G.key==="Enter"&&I()}}),v.trim()!==""&&a.jsx("button",{type:"button",className:"ap-manage-btn",...M("join"),onClick:()=>void I(),title:"Reach that deck and pair with it. Nobody has to press anything there.",children:_==="join"?"joining…":"join"})]}),a.jsx("p",{className:"lan-note",children:"Pasting one pairs both decks on the spot — nobody has to accept."}),T&&a.jsxs("div",{className:"ap-lan-tried",children:[a.jsx("span",{className:"lan-note",children:"Nothing answered at any address in that invite. Check that deck is running with its Local network switch on."}),T.map(G=>a.jsxs("span",{className:"ap-lan-tried-row",children:[a.jsx("code",{className:"ap-lan-code",children:G.addr}),a.jsx("span",{className:"ap-lan-bad",children:G.why})]},G.addr))]}),F&&a.jsxs("div",{className:"ap-lan-invite",children:[a.jsxs("div",{className:"ap-lan-invite-head",children:[a.jsx("span",{className:"ap-lan-invite-title",children:"Send this to them"}),a.jsxs("span",{className:"ap-lan-invite-left",id:"lan-invite-left",children:[sG(F.expiresAt,R)," left"]})]}),a.jsx("code",{className:"ap-lan-token",children:F.token}),a.jsxs("div",{className:"ap-lan-acts",children:[a.jsx("button",{type:"button",className:"ap-manage-btn",ref:u,...M("copy:invite"),"aria-label":N==="invite"?"Invite copied":"Copy invite","aria-describedby":"lan-invite-left",onClick:()=>void W(F.token,"invite"),title:"Copy it, and send it however you already talk to them",children:N==="invite"?"copied":"copy"}),a.jsx("button",{type:"button",className:"ap-manage-btn",...M("invite:withdraw"),onClick:()=>void H("withdraw"),title:"Cancel it. Anybody already holding the text can no longer use it.",children:"cancel"})]}),a.jsx("p",{className:"lan-warn",children:"Anyone who gets this text can pair with this deck until it runs out."})]})]})]})]})}),document.body)}function lG(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 cG({asks:e,pressProps:t,answer:n}){return a.jsx("div",{className:"ap-lan-asks",role:"alert",children:e.map(r=>a.jsxs("div",{className:"ap-lan-ask",children:[a.jsxs("span",{className:"ap-lan-ask-what",children:[a.jsx("strong",{className:"ap-lan-peer-name",children:r.name})," at ",a.jsx("code",{className:"ap-lan-code",children:r.addr})," wants to pair"]}),a.jsxs("span",{className:"ap-lan-ask-fp",id:`lan-ask-fp-${r.fp}`,children:["fingerprint ",a.jsx("code",{className:"ap-lan-code",children:r.fp})]}),a.jsxs("span",{className:"ap-lan-ask-acts",children:[a.jsx("button",{type:"button",className:"ap-manage-btn",...t(`accept:${r.fp}`),"aria-label":`Accept ${r.name}`,"aria-describedby":`lan-ask-fp-${r.fp}`,onClick:()=>void n("accept",r.fp,"accept that deck"),title:`Talk to this deck from now on. Its fingerprint is ${r.fp} — check it matches the one on their screen before you accept.`,children:"accept"}),a.jsx("button",{type:"button",className:"ap-manage-btn",...t(`dismiss:${r.fp}`),"aria-label":`Decline ${r.name}`,"aria-describedby":`lan-ask-fp-${r.fp}`,onClick:()=>void n("dismiss",r.fp,"decline that request"),title:"Say no. Nothing is shared, and that deck is told rather than left waiting.",children:"decline"})]})]},r.fp))})}function uG({rows:e,pairingMode:t,armed:n,pressProps:r,answer:s,dropAddress:o,onUnpair:l,onOpenPeer:u,onInvite:d}){return a.jsx("ul",{className:"ap-lan-here",children:e.map((h,f)=>a.jsxs("li",{className:"ap-lan-who","data-tone":h.tone,children:[a.jsx("i",{className:h.here?"ap-pulse":"ap-dot","aria-hidden":!0}),a.jsxs("span",{className:"ap-lan-who-name","aria-hidden":!0,children:[h.name,h.via==="tailscale"&&a.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]}),a.jsx("button",{type:"button",className:"ap-lan-who-open","aria-haspopup":"dialog","aria-describedby":`lan-who-state-${f}`,onClick:()=>u(h.fp),children:a.jsxs("span",{className:"vis-hidden",children:[h.name,h.via==="tailscale"?", over Tailscale":"",", details"]})}),a.jsx("span",{id:`lan-who-state-${f}`,className:h.quiet?"vis-hidden":"ap-lan-who-when",children:h.state}),h.kind==="nearby"&&t!=="invite"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...r(`accept:${h.fp}`),onClick:()=>void s("accept",h.fp,"reach that deck"),"aria-label":`Ask ${h.name} to pair`,title:`Send ${h.name} a request. Somebody at that machine has to accept it before anything is shared. Its fingerprint is ${h.fp}.`,children:"ask"}),(h.kind==="nearby"||h.kind==="declined")&&t==="invite"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do","aria-haspopup":"dialog",onClick:d,"aria-label":`Invite ${h.name} to pair`,title:`This deck pairs only by invite. Make one and send it to whoever is at ${h.name}.`,children:"invite"}),h.kind==="paired"&&a.jsx("button",{type:"button",className:`ap-manage-btn ap-lan-do danger${n===h.fp?" armed":""}`,...r(`unpair:${h.fp}`),onClick:()=>l(h),"aria-label":n===h.fp?`Confirm unpairing ${h.name}`:`Unpair ${h.name}`,title:n===h.fp?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this deck from now on",children:n===h.fp?"confirm":"unpair"}),h.kind==="dialling"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...r(`drop:${h.fp}`),onClick:()=>void o(h.fp),"aria-label":`Stop dialling ${h.name}`,title:"Stop trying this address. Nothing was ever paired here.",children:"stop"}),h.kind==="declined"&&t!=="invite"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...r(`allow:${h.fp}`),onClick:()=>void s("allow",h.fp,"let that deck ask again"),"aria-label":`Let ${h.name} ask again`,title:"Take the no back. That deck is still trying, so the request comes round again on its own.",children:"allow"})]},`${h.kind}:${h.fp}`))})}function dG(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 hG({on:e,status:t}){return a.jsxs(a.Fragment,{children:[e&&a.jsx(Q$,{reach:t==null?void 0:t.reach,where:"panel"}),e&&(t==null?void 0:t.deaf)&&a.jsx("p",{className:"ap-lan-fine",children:t.deaf}),e&&(t==null?void 0:t.lanTunneled)&&a.jsx("p",{className:"ap-lan-fine",children:dG(t)})]})}const uS=["online","offline","loose"],fG={online:0,offline:1,loose:2};function pG(e){return e.kind==="declined"?null:e.kind==="paired"?e.here?"online":"offline":"loose"}const mG=76,gG=62,pd=96,yG={1:[.62],2:[.58,1],3:[.42,.72,1]},wG=.2,vG=.16,xG=.05,bG=20,kG=17,Eu=7,NG=30,jG=116,SG=6.6,_G=6,EG=e=>t0(e,null),CG=1.5,TG=80,AG=.45,dS=40,RG=64,MG=150,hS=.3,fS=84,$G=1.3,pS=.16;function Dx(e,t){return Math.PI*(3*(e+t)-Math.sqrt((3*e+t)*(e+3*t)))}function eI(e,t){return t<-Math.abs(e)*.6?"top":"bottom"}function IG(e,t){if(e<=2)return t%2===0?0:90;const n=360/e;return-90+(t%2===0?0:n/2)}function OG(e){return e.map((t,n)=>({...t,i:n})).sort((t,n)=>uS.indexOf(t.tier)-uS.indexOf(n.tier)||+(t.row.via==="tailscale")-+(n.row.via==="tailscale")||t.i-n.i).map(({row:t,tier:n})=>({row:t,tier:n}))}function mS(e,t){let n=2166136261^t;for(let r=0;r<e.length;r++)n^=e.charCodeAt(r),n=Math.imul(n,16777619);return(n>>>0)%2e4/1e4-1}function LG(e,t,n){const r=[...yG[e.length]??[]];for(let s=0;s<r.length;s++){const o=e[s];if(o<2)continue;const l=Dx(t*r[s],n*r[s])/o;if(!(l>0)||l>=pd)continue;const u=s+1<r.length?r[s+1]-wG:1;r[s]=Math.max(r[s],Math.min(u,r[s]*(pd/l)*1.02))}return r}const Fo=(e,t)=>e.x0<t.x1&&t.x0<e.x1&&e.y0<t.y1&&t.y0<e.y1,jp={h:16,ch:6.1,maxW:100};function PG(e){const t=e?Math.max(80,e.length*7.2+16):128;return{x0:-t/2,y0:32,x1:t/2,y1:66}}function DG(e,t,n,r,s,o){const l=t==="loose"?kG:bG,u=!s||e.kind==="asks",d=u?NG:jp.h,h=s?jp.ch:SG,f=u?o.length:0,p=Math.min(s?jp.maxW:jG,Math.max(2*l,nI(e).length*h,f*_G)),g={x0:n-l,y0:r-l,x1:n+l,y1:r+l},v=eI(n,r)==="top"?{x0:n-p/2,y0:r-l-Eu-d,x1:n+p/2,y1:r-l-Eu}:{x0:n-p/2,y0:r+l+Eu,x1:n+p/2,y1:r+l+Eu+d};return[g,v]}const tI=e=>{const t=e.theta*Math.PI/180;return[Math.cos(t)*e.ring.rx*e.reach,Math.sin(t)*e.ring.ry*e.reach]},Cu=(e,t)=>((e-t)%360+540)%360-180;function gS(e,t,n){const r=new Map;for(const h of e)r.has(h.ring)||r.set(h.ring,[]),r.get(h.ring).push(h);const s=()=>e.map(h=>{const[f,p]=tI(h);return DG(h.row,h.tier,f,p,t,h.caption)}),o=(h,f)=>{if(h.count<=2)return!1;const p=h.theta+f*CG,g=r.get(h.ring),v=360/h.count*AG,k=g[(h.index+1)%h.count],b=g[(h.index-1+h.count)%h.count];return!(f>0?Cu(k.theta,p)>=v:Cu(p,b.theta)>=v)||p<h.lo||p>h.hi?!1:(h.theta=p,!0)},l=([h,f],[p,g])=>Fo(f,p)||Fo(g,h)||Fo(f,g)||Fo(h,p),u=([h,f])=>Fo(h,n)||Fo(f,n);for(let h=0;h<TG;h++){const f=s();let p=!1;for(let g=0;g<e.length;g++){u(f[g])&&(p=o(e[g],Cu(e[g].theta,90)>=0?1:-1)||p);for(let v=g+1;v<e.length;v++){if(!l(f[g],f[v]))continue;const k=e[g],b=e[v],x=b.ring.ring>k.ring.ring||b.ring===k.ring&&v>g?b:k,N=x===b?k:b,S=Cu(x.theta,N.theta)>=0?1:-1;p=o(x,S)||o(N,-S)||p}}if(!p)break}const d=s();for(let h=0;h<d.length;h++){if(u(d[h]))return!1;for(let f=h+1;f<d.length;f++)if(l(d[h],d[f]))return!1}return!0}const FG={online:0,offline:1,loose:1};function BG(e,t,n,r="",s=EG){const o=yS(e,t,n,r,fG,s);if(o.clear||o.layout.rings.length<3)return o.layout;const l=yS(e,t,n,r,FG,s);return l.clear?{...l.layout,folded:!0}:o.layout}function yS(e,t,n,r,s,o){const l=new Map;for(const D of e){const O=pG(D);if(!O)continue;const L=s[O];l.has(L)||l.set(L,[]),l.get(L).push({row:D,tier:O})}const u=[...l.keys()].sort((D,O)=>D-O),d=Math.max(0,t/2-mG),h=Math.max(0,n/2-gG),f=LG(u.map(D=>l.get(D).length),d,h),p=u.map((D,O)=>({ring:D,rx:d*f[O],ry:h*f[O],count:l.get(D).length})),g=p.reduce((D,O)=>D+O.count,0),v=D=>D.row.via==="tailscale",k=[...l.values()].flat().filter(v).length,b=Math.max(0,...p.map(D=>{const O=l.get(D.ring).filter(v).length,L=Dx(D.rx,D.ry);return O>0&&L>0?O*pd*$G/L*360:0})),x=k>0&&k<g?Math.min(MG,Math.max(RG,k/g*360,b)):0,N=dS-x/2,S=dS+x/2,_=[];let E=!1;p.forEach((D,O)=>{const L=OG(l.get(D.ring)),z=L.length,M=z>1&&Dx(D.rx,D.ry)/z<pd;M&&(E=!0);const $=O===p.length-1,q=$?-pS*(f[O]-(f[O-1]??0)):pS*(f[O+1]-f[O]),X=x>0?[{members:L.filter(I=>I.row.via!=="tailscale"),from:S,width:360-x},{members:L.filter(I=>I.row.via==="tailscale"),from:N+360,width:x}]:[{members:L,from:null,width:360}];let H=0;for(const I of X){const W=I.members.length;if(W===0)continue;const F=I.width/W,Y=W>2;I.members.forEach(({row:J,tier:V},G)=>{const K=nr(J),Z=I.from==null?IG(W,O)+F*G:I.from+F*(G+.5),ee=Y?mS(K,1)*vG*F:0,re=M&&H%2===1?1+q/f[O]:1,ue=Y?mS(K,2)*xG:0,me=F*.3;_.push({row:J,tier:V,ring:D,index:H,count:z,theta:Z+ee,reach:re*(1+($?-Math.abs(ue):ue)),lo:I.from==null?-1/0:I.from+me,hi:I.from==null?1/0:I.from+I.width-me,caption:o(J)}),H++})}});const T=PG(r);let A=gS(_,E,T);!A&&!E&&(E=!0,A=gS(_,!0,T));const R=_.map((D,O)=>{const[L,z]=tI(D);return{row:D.row,tier:D.tier,ring:D.ring.ring,x:L,y:z,angle:qG(Math.atan2(z,L)*180/Math.PI),dist:Math.hypot(L,z),side:eI(L,z),order:O}}),B=p.reduce((D,O,L)=>l.get(O.ring).some(v)?Math.max(D,f[L]):D,0),P=x>0?{from:N,to:S,inner:{rx:d*hS,ry:h*hS},outer:{rx:Math.min(t/2-8,d*B+fS),ry:Math.min(n/2-8,h*B+fS)},count:k}:null;return{layout:{nodes:R,rings:p,zone:P,dense:E},clear:A}}function qG(e){return(e%360+360)%360}function UG(e){const t=n=>e.filter(n).length;return{paired:t(n=>n.kind==="paired"),online:t(n=>n.kind==="paired"&&n.here),offline:t(n=>n.kind==="paired"&&!n.here),nearby:t(n=>n.kind==="nearby"),asks:t(n=>n.kind==="asks"),dialling:t(n=>n.kind==="dialling"),declined:t(n=>n.kind==="declined"),tailnet:t(n=>n.kind!=="declined"&&n.via==="tailscale"),oneWay:t(n=>n.kind==="paired"&&!n.here&&n.state.startsWith("one-way"))}}function zG(e){const t=[];return e.asks&&t.push(e.asks===1?"1 deck wants to pair":`${e.asks} decks want to pair`),e.paired===0?t.push("no paired decks yet"):e.paired===1?t.push(e.online?"1 paired deck, online":"1 paired deck, away"):e.online===e.paired?t.push(`${e.paired} paired decks, all online`):t.push(`${e.online} of ${e.paired} paired decks online`),e.nearby&&t.push(`${e.nearby} nearby, not paired`),e.dialling&&t.push(`${e.dialling} still dialling`),t.join(" · ")}function t0(e,t){switch(e.kind){case"asks":return"wants to pair";case"nearby":return e.state;case"dialling":return rI(e)?`${e.name.slice(e.addr.length)} · dialling`:"dialling";case"declined":return"declined";case"paired":{if(e.here)return t?WG(t):"online";const n=aI(e);return n?n==="now"?"away · just now":`away · ${n}`:e.state.startsWith("one-way")?"has not called yet":"away"}}}function nI(e){return rI(e)?e.addr:e.name}function rI(e){return e.kind==="dialling"&&!!e.addr&&e.name.startsWith(`${e.addr}:`)}function sI(e){if(e.kind!=="paired")return e.via==="tailscale"?`${e.state}, over Tailscale`:e.state;if(e.here)return e.via==="tailscale"?"online, over Tailscale":"online";const t=aI(e),n=t?t==="now"?"away · last online just now":`away · last online ${t}`:e.state.startsWith("one-way")?e.state:"away";return e.via==="tailscale"?`${n}, over Tailscale`:n}function aI(e){var t;return((t=/last online (.+)$/.exec(e.state))==null?void 0:t[1])??null}function WG(e){return e.trim().split(/\s+/).slice(0,2).join(" ")}function HG(e){var r;if(!e)return[];const t=(e.addrs??[]).map(s=>`${s}:${e.port}`),n=(r=e.tailscale)==null?void 0:r.addr;return n&&!(e.addrs??[]).includes(n)&&t.push(`${n}:${e.port}`),t}function nr(e){let t=e.fp;for(const n of e.twins??[])n.fp<t&&(t=n.fp);return t}function VG(e,t){if(e==null)return t;const n=((t-e)%360+540)%360-180;return e+n}function GG(e){return e.asks?e.asks===1?"1 deck wants to pair. Answer it in the Local network list, behind this map.":`${e.asks} decks want to pair. Answer them in the Local network list, behind this map.`:e.oneWay?`${e.oneWay} away deck${e.oneWay===1?" only calls":"s only call"} in, and this deck has no address to call ${e.oneWay===1?"it":"them"} on. Add ${e.oneWay===1?"its address":"their addresses"} through Add a deck to reach ${e.oneWay===1?"it":"them"} both ways.`:e.dialling?e.dialling===1?"1 address has never answered. Open it to stop dialling it.":`${e.dialling} addresses have never answered. Open one to stop dialling it.`:e.nearby?e.nearby===1?"1 deck nearby is not paired. Open it to ask to pair.":`${e.nearby} decks nearby are not paired. Open one to ask to pair.`:null}function KG(e,t){switch(e.kind){case"asks":return"Waiting for your answer, in the Local network list behind this map.";case"dialling":return"Nothing has answered here yet. Its dialog can stop dialling it.";case"nearby":return t==="invite"?"This deck pairs by invite only. Send one from Add a deck.":"Not paired yet. Its dialog can ask to pair.";case"paired":return!e.here&&e.state.startsWith("one-way")?"It can reach this deck, not the other way. Add its address through Add a deck.":null;default:return null}}function YG(e){const t={bad:0,wait:1,idle:2,ok:3};return e.map((n,r)=>({l:n,i:r})).sort((n,r)=>t[n.l.tone]-t[r.l.tone]||n.i-r.i).map(({l:n})=>n)}function XG(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 ZG(e,t,n,r=!0){const s=t?t.alive?t.shareable===!1?"cannot share here":"works here":"expired here":"not on this deck";if(e.alive&&e.shareable===!1)return{there:"cannot share there",here:s,note:null,tone:"idle"};if(!e.alive){const o=t&&!t.alive?"neither copy works — sign in again here":null;return{there:"broken there",here:s,note:o,tone:o?"bad":"idle"}}return t?t.alive?{there:"works there",here:s,note:null,tone:t.shareable===!1?"idle":"ok"}:n?{there:"works there",here:s,note:"repairs next round",tone:"wait"}:{there:"works there",here:s,note:"share it to repair",tone:"bad"}:r||n?{there:"works there",here:s,note:"arrives next round",tone:"wait"}:{there:"works there",here:s,note:"paired automatically — pair by invite to take it",tone:"bad"}}function JG(e,t,n,r=null,s=!0){var h;const o=new Map;for(const f of t)(h=o.get(f.key))!=null&&h.alive||o.set(f.key,f);const l=new Set(n),u=[],d=new Set;for(const f of e??[]){if(d.has(f.key))continue;d.add(f.key);const p=o.get(f.key)??null,g=l.has(f.key),v=ZG(f,p,g,s),k=p?p.alive?p.shareable===!1?"unavailable":"works":"expired":"missing",b=!f.alive&&p&&!p.alive?v.note:[k==="works"?null:v.here,f.alive&&f.shareable!==!1?null:v.there,v.note].filter(Boolean).join(" · ")||null;u.push({key:f.key,email:f.email,here:k,there:f.alive?f.shareable===!1?"unavailable":"works":"broken",in:!f.alive||f.shareable===!1?"cut":v.tone==="wait"?"wait":v.tone==="bad"?"blocked":"live",out:g&&p?p.alive&&p.shareable!==!1?"live":"cut":null,caption:b,tone:v.tone,usedThere:r===f.key})}for(const f of n){const p=o.get(f);!p||d.has(f)||(d.add(f),u.push({key:f,email:p.email,here:p.alive?p.shareable===!1?"unavailable":"works":"expired",there:"unknown",in:null,out:p.alive&&p.shareable!==!1?"live":"cut",caption:p.alive?p.shareable===!1?"cannot share here":null:"expired here",tone:p.alive?p.shareable===!1?"idle":"ok":"bad",usedThere:!1}))}return u}const QG=1e3;function eK(e,t){const n=new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),r=Or(e,t);return`${n} · ${r==="now"?"just now":r}`}function Fx(e){return e&&[e.version,e.os,e.arch].filter(Boolean).join(" · ")||null}const oI={works:"works here",expired:"expired here",missing:"not on this deck",unavailable:"cannot share here"},iI={works:"works there",broken:"broken there",unavailable:"cannot share there",unknown:"not offered by that deck"};function lI(e){const t=e.in&&e.out?"offered both ways":e.in?"offered by that deck":"offered by this deck";return`${oI[e.here]}, ${iI[e.there]}, ${t}${e.usedThere?", in use there":""}.`}function cI({row:e,source:t,status:n,accounts:r,now:s}){var V,G,K,Z,ee;const{peer:o,stranger:l}=t,u=e.kind==="paired",d=e.self??e.name,h=e.kind!=="dialling",f=e.kind==="dialling"?null:e.fp,p=o?o.addr?`${o.addr}:${o.port}`:"":l?l.port?`${l.addr}:${l.port}`:l.addr:e.addr,g=(o==null?void 0:o.about)??null,v=((V=n.about)==null?void 0:V.version)??null,k=u?o!=null&&o.waiting?o.lastSeen!=null?"not said — it runs an older version":"not said yet — it says when it next calls":o!=null&&o.offers?"not said — it runs an older version":"not reached yet":"shown once paired",b=Fx(n.about),x=Fx(g),N=g!=null&&g.version&&v?XG(g.version,v):null,S=o?Gd(o.last,s):null,_=o&&((G=o.last)!=null&&G.error)?fV({error:o.last.error,host:o.addr,port:o.port},[...n.strangers??[],...n.pending??[],...(n.peers??[]).filter(re=>!re.manual&&re.addr).map(re=>({fp:re.fp,name:re.name,addr:re.addr,port:re.port,at:re.lastSeen??0}))],s):null,E=(K=o==null?void 0:o.last)!=null&&K.error&&S&&S.text!==o.last.error?o.last.error:null,T=((Z=o==null?void 0:o.last)==null?void 0:Z.done)??[],A=!!S&&!!E&&!e.quiet&&e.state.startsWith(S.text),R=u||e.kind==="dialling",B=((o==null?void 0:o.via)??e.via)==="tailscale",P=o?o.waiting?null:o.manual?B?"added by its Tailscale address":"added by address":B?"over Tailscale":"on this network":e.kind==="nearby"?B?"heard over Tailscale":"heard on this network":B?"asked this deck to pair, over Tailscale":"asked this deck to pair",D=e.tone==="bad"?"bad":u?e.here?"up":"down":"loose",O=(o==null?void 0:o.offers)??null,L=D==="up"?(O==null?void 0:O.current)??null:null,z=L&&"key"in L?L.key:null,M=!!L&&"hidden"in L,$=!!L&&"other"in L,q=u?JG((O==null?void 0:O.accounts)??null,r,n.shared??[],z,(o==null?void 0:o.autoPaired)!==!0):[],X=q.filter(re=>re.in==null&&re.out==="cut"),H=q.some(re=>re.in!=null),I=q.some(re=>re.out!=null),W=new Map(T.map(re=>[re.email,re])),F=T.filter(re=>!q.some(ue=>ue.email===re.email)),Y=u?O?O.accounts.length===0?"That deck offers nothing. Nobody there has chosen a login to share.":null:o!=null&&o.waiting?"What that deck offers is not known yet. A deck that calls in says so each time it calls — one on an older version never does.":(ee=o==null?void 0:o.last)!=null&&ee.error?"What that deck offers is not known — the last attempt to ask it did not get through.":"Nobody has asked that deck what it offers yet. The next round asks it.":null,J=O&&(o!=null&&o.last)&&o.last.at-O.at>QG?Or(O.at,s):null;return{peer:o,stranger:l,paired:u,own:d,canRename:h,fp:f,where:p,about:g,unsaid:k,hereRuns:b,thereRuns:x,order:N,line:S,silence:_,raw:E,echoed:A,showRound:R,how:P,link:D,hiddenThere:M,otherThere:$,lanes:q,spent:X,taking:H,giving:I,told:W,unplaced:F,unknown:Y,stale:J}}function Bx(){return a.jsxs("svg",{className:"lan-machine",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("rect",{x:"2.5",y:"3",width:"11",height:"7.5",rx:"1.2"}),a.jsx("path",{d:"M1 13h14"})]})}function Tu({dir:e,gate:t=!1}){const n=t?12:8;return a.jsx("svg",{className:"lan-chev","data-dir":e,"data-gate":t||void 0,width:n,height:"8",viewBox:`0 0 ${n} 8`,fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:e==="out"?"M2.8 1L6 4 2.8 7":t?"M1 1v6M9.6 1L6.4 4l3.2 3":"M5.2 1L2 4l3.2 3"})})}function tK({view:e,row:t,status:n,asking:r,drawn:s,onSettings:o}){const{peer:l,paired:u,where:d,about:h,unsaid:f,hereRuns:p,thereRuns:g,order:v,line:k,silence:b,raw:x,echoed:N,showRound:S,how:_,link:E,hiddenThere:T,otherThere:A,lanes:R,spent:B,taking:P,giving:D,told:O,unplaced:L,unknown:z,stale:M}=e;return a.jsxs("div",{className:"lan-map","data-link":E,"data-asking":r||void 0,"data-bus":R.length>0||void 0,children:[a.jsxs("div",{className:"lan-ends",children:[a.jsxs("p",{className:"lan-end",children:[a.jsx("span",{className:"lan-end-name",children:"This deck"}),p&&a.jsx("span",{className:"lan-end-runs",children:p}),u&&n.shareActive===!1&&a.jsx("span",{className:"lan-end-note",children:"current account hidden"})]}),a.jsxs("p",{className:"lan-end","data-side":"there",children:[a.jsx("span",{className:"lan-end-name",children:t.name}),t.kind!=="dialling"&&a.jsxs("span",{className:"lan-end-runs",children:[g??(h?"not said":f),v?` · ${v<0?"older":"newer"}`:null]}),T&&a.jsx("span",{className:"lan-end-note",children:"current account hidden"}),A&&a.jsx("span",{className:"lan-end-note",children:"on another account"})]})]}),a.jsxs("div",{className:"lan-link",children:[a.jsx(Bx,{}),a.jsxs("span",{className:"lan-span",children:[a.jsxs("span",{className:"lan-wire","aria-hidden":!0,children:[a.jsx("i",{className:"lan-glint","data-dir":"out"}),a.jsx("i",{className:"lan-glint","data-dir":"in"})]}),a.jsx("span",{className:"lan-link-label",children:d?a.jsx("code",{className:"ap-lan-code",children:d}):"none here — it calls this deck"})]}),a.jsx(Bx,{}),(d&&_||S)&&a.jsxs("p",{className:"lan-link-sub",children:[d&&_,d&&_&&S&&" · ",S&&(k?N?a.jsx("code",{className:"ap-lan-code",children:x}):a.jsx("span",{className:"lan-round","data-tone":k.tone,children:k.text.replace(/ · now$/," · just now")}):"not asked yet"),S&&x&&!N&&a.jsx("code",{className:"lan-fact-raw",children:x})]}),L.length>0&&a.jsx("ul",{className:"lan-done",children:L.map($=>{const q=$x($);return a.jsxs("li",{"data-ok":$.ok&&!q,children:[$.email," ",a.jsxs("span",{className:"lan-done-what",children:[$.ok?"arrived":"did not arrive",q&&` — ${q.long}`]})]},`${$.email}:${$.action}`)})}),b&&a.jsx("p",{className:"lan-note lan-link-note",children:b}),(l==null?void 0:l.waiting)&&a.jsx("p",{className:"lan-note lan-link-note",children:t.hint}),(k==null?void 0:k.hint)&&a.jsx("p",{className:"lan-note lan-link-note",children:k.hint})]}),R.length>0&&a.jsx("ul",{className:"lan-lanes",role:"list","aria-label":`Logins between this deck and ${t.name}`,children:R.map(($,q)=>{const X=O.get($.email),H=X?$x(X):null,I=$.out==="live"||$.in!=null&&$.in!=="cut";return a.jsxs("li",{role:"listitem",className:"lan-lane","data-tone":$.tone,"data-draw":$.in&&$.out?"both":$.in?"in":"out","data-used-there":$.usedThere||void 0,style:{"--i":q},children:[a.jsx("i",{className:"lan-pip","data-end":"here","data-state":$.here,"aria-hidden":!0}),a.jsxs("span",{className:"lan-track",children:[a.jsxs("span",{className:"lan-wire","data-flow":I?"live":"cut","aria-hidden":!0,children:[($.in==="live"||$.in==="wait")&&a.jsx("i",{className:"lan-glint","data-dir":"in","data-tone":$.in}),$.out==="live"&&a.jsx("i",{className:"lan-glint","data-dir":"out"})]}),$.in&&$.in!=="cut"&&a.jsx(Tu,{dir:"in",gate:$.in==="blocked"}),$.out==="live"&&a.jsx(Tu,{dir:"out"}),a.jsx("span",{className:"lan-lane-email",children:$.email})]}),a.jsx("i",{className:"lan-pip","data-end":"there","data-state":$.there,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:lI($)}),($.caption||X)&&a.jsxs("span",{className:"lan-lane-note",children:[$.caption,$.caption&&X&&" · ",X&&a.jsxs("span",{className:"lan-lane-done","data-ok":X.ok&&!H,children:[X.ok?"arrived last round":"did not arrive last round",H&&` — ${H.long}`]})]})]},$.key)})},s),u&&a.jsxs(a.Fragment,{children:[B.length>0&&a.jsxs("p",{className:"lan-spent",children:["Paired decks get nothing from ",B.length===1?B[0].email:"the expired ones"," until you sign in again here."]}),z&&a.jsx("p",{className:"lan-empty",children:z}),M&&a.jsxs("p",{className:"lan-stale",children:["As of ",M==="now"?"just now":M,", when it last answered."]}),a.jsxs("div",{className:"lan-legend",children:[P&&a.jsxs("span",{className:"lan-key",children:[a.jsx("span",{className:"lan-key-wire","data-dir":"in","aria-hidden":!0,children:a.jsx(Tu,{dir:"in"})}),"from ",t.name]}),D?a.jsxs("span",{className:"lan-key",children:[a.jsx("span",{className:"lan-key-wire","data-dir":"out","aria-hidden":!0,children:a.jsx(Tu,{dir:"out"})}),"from this deck, to every paired deck"]}):a.jsx("span",{className:"lan-key",children:"This deck offers nothing yet."}),a.jsx("button",{type:"button",className:"ap-lan-word lan-legend-act",onClick:o,"aria-label":"Change what this deck offers",children:"change"})]})]})]})}const nK=20,rK=17,wS=34,sK=160,aK=80,oK=200,iK=8,vS=6,lK=14,cK=10,uK=.61803398875;function dK({status:e,rows:t,accounts:n,now:r,covered:s,onOpenDeck:o,onClose:l}){const u=w.useRef(null),d=ft(l,{focusRef:u}),h=w.useRef(null),[f,p]=w.useState(null),[g,v]=w.useState(!1),k=w.useRef(null);w.useLayoutEffect(()=>{const ae=h.current;if(!ae)return;let pe=null;const xe=()=>{const ve=Math.round(ae.clientWidth),fe=Math.round(ae.clientHeight);pe&&pe.w===ve&&pe.h===fe||(pe&&(v(!0),k.current!=null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>v(!1),oK)),pe={w:ve,h:fe},p(pe))};if(xe(),typeof ResizeObserver>"u")return;const se=new ResizeObserver(xe);return se.observe(ae),()=>{se.disconnect(),k.current!=null&&window.clearTimeout(k.current)}},[]);const b=w.useMemo(()=>f?BG(t,f.w,f.h,(e==null?void 0:e.name)??"",ae=>{var pe,xe;return t0(ae,(xe=(pe=Hl(e,ae).peer)==null?void 0:pe.about)==null?void 0:xe.os)}):null,[t,f,e]),x=w.useMemo(()=>UG(t),[t]),N=(b==null?void 0:b.nodes)??[],S=w.useRef(new Map),_=w.useMemo(()=>{const ae=new Map;for(const pe of N){const xe=nr(pe.row);ae.set(xe,VG(S.current.get(xe),pe.angle))}return S.current=ae,ae},[N]),[E,T]=w.useState(null),[A,R]=w.useState(null),[B,P]=w.useState("none"),D=w.useRef(null),O=w.useCallback((ae,pe)=>{D.current!==ae&&(D.current=ae,P(pe),R(ae))},[]),L=w.useRef(null),z=w.useRef(null),M=w.useCallback(()=>{z.current!=null&&window.clearTimeout(z.current),z.current=null},[]),$=w.useCallback((ae,pe)=>{if(L.current!=null&&window.clearTimeout(L.current),L.current=null,M(),T(ae),pe==="keyboard"){O(ae,"none");return}z.current=window.setTimeout(()=>O(ae,D.current?"swap":"full"),aK)},[O,M]),q=w.useCallback(()=>{L.current!=null&&window.clearTimeout(L.current),M(),L.current=window.setTimeout(()=>T(null),sK)},[M]);w.useEffect(()=>()=>{L.current!=null&&window.clearTimeout(L.current),M()},[M]);const X=E&&N.some(ae=>nr(ae.row)===E)?E:null,H=A?t.find(ae=>nr(ae)===A)??null:null;w.useEffect(()=>{A&&!H&&O(null,"swap")},[A,H,O]);const[I,W]=w.useState(null),F=w.useRef(new Map),Y=N.findIndex(ae=>nr(ae.row)===I),J=Y<0?0:Y,V=ae=>{var ve;if(N.length===0)return;const pe=ae.key==="ArrowRight"||ae.key==="ArrowDown"?1:ae.key==="ArrowLeft"||ae.key==="ArrowUp"?-1:0,xe=ae.key==="Home"?0:ae.key==="End"?N.length-1:pe?(J+pe+N.length)%N.length:null;if(xe==null)return;ae.preventDefault();const se=nr(N[xe].row);W(se),(ve=F.current.get(se))==null||ve.focus()},[G,K]=w.useState(()=>typeof document<"u"&&document.hidden);w.useEffect(()=>{const ae=()=>K(document.hidden);return document.addEventListener("visibilitychange",ae),()=>document.removeEventListener("visibilitychange",ae)},[]);const Z=(e==null?void 0:e.enabled)===!0,ee=e?Z?zG(x):"Local network is off":"checking…",re=()=>{M(),O(null,"swap"),T(null)},ue=X?N.find(ae=>nr(ae.row)===X)??null:null,me=()=>{var ae;A&&((ae=F.current.get(A))==null||ae.focus()),re()};return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",onClick:l,role:"presentation",children:a.jsxs("div",{ref:d,className:"modal nm-modal",onClick:ae=>ae.stopPropagation(),"data-paused":s||G||void 0,role:"dialog","aria-modal":"true","aria-labelledby":"nm-title","aria-describedby":"nm-sub",children:[a.jsxs("header",{className:"modal-head nm-head",children:[a.jsxs("div",{className:"nm-heading",children:[a.jsx("h2",{id:"nm-title",className:"modal-title nm-title",children:"Network map"}),a.jsx("p",{id:"nm-sub",className:"nm-sub",children:ee})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:u,type:"button",className:"glyph-btn",onClick:l,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("div",{className:"nm-body",children:[a.jsxs("div",{className:"nm-view",children:[a.jsx("div",{ref:h,className:"nm-stage","data-focus":X?"":void 0,"data-focus-via":ue==null?void 0:ue.row.via,"data-dense":(b==null?void 0:b.dense)||void 0,"data-still":g||void 0,onClick:ae=>{ae.target===ae.currentTarget&&re()},children:f&&b&&a.jsxs(a.Fragment,{children:[a.jsx(hK,{layout:b,w:f.w,h:f.h}),N.map(ae=>{const pe=nr(ae.row);return a.jsx(mK,{node:ae,angle:_.get(pe)??ae.angle,lit:X===pe},pe)}),a.jsx(gK,{status:e}),a.jsx("span",{id:"nm-ring-hint",className:"vis-hidden",children:"Arrow keys move between decks. Enter opens the deck's own dialog."}),a.jsx("div",{className:"nm-ring",role:"group","aria-label":`Decks around this deck, ${N.length}`,"aria-describedby":"nm-ring-hint",onKeyDown:V,children:N.map((ae,pe)=>{var se,ve;const xe=nr(ae.row);return a.jsx(yK,{node:ae,angle:_.get(xe)??ae.angle,os:(ve=(se=Hl(e,ae.row).peer)==null?void 0:se.about)==null?void 0:ve.os,lit:X===xe,shown:A===xe,tabbable:pe===J,register:fe=>{fe?F.current.set(xe,fe):F.current.delete(xe)},onHold:fe=>{W(xe),$(xe,fe)},onRelease:q,onOpen:()=>o(ae.row.fp)},xe)})}),N.length===0&&a.jsx(wK,{status:e})]})}),a.jsx(vK,{})]}),a.jsx("aside",{className:"nm-side","aria-label":"Details",children:H&&e?a.jsx(bK,{row:H,status:e,accounts:n,now:r,entrance:B,onOpen:()=>o(H.fp),onBack:me},nr(H)):a.jsx(xK,{status:e,summary:x,entrance:B})})]})]})}),document.body)}function uI(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("circle",{cx:"7",cy:"7.4",r:"1.8"}),a.jsx("circle",{cx:"2.4",cy:"2.9",r:"1.2"}),a.jsx("circle",{cx:"11.6",cy:"2.9",r:"1.2"}),a.jsx("circle",{cx:"7",cy:"12.4",r:"1.1"}),a.jsx("path",{d:"M5.7 6.1 3.3 3.8M8.3 6.1l2.4-2.3M7 9.2v2.1"})]})}function hK({layout:e,w:t,h:n}){const{zone:r}=e;return a.jsxs("svg",{className:"nm-orbits",width:t,height:n,viewBox:`0 0 ${t} ${n}`,"aria-hidden":!0,children:[r&&a.jsxs(a.Fragment,{children:[a.jsxs("defs",{children:[a.jsx("path",{id:"nm-zone-arc",d:pK(r,t/2,n/2)}),a.jsxs("radialGradient",{id:"nm-zone-fill",gradientUnits:"userSpaceOnUse",cx:t/2,cy:n/2,r:Math.max(r.outer.rx,r.outer.ry),children:[a.jsx("stop",{className:"nm-zone-stop",offset:"0.2","data-at":"in"}),a.jsx("stop",{className:"nm-zone-stop",offset:"0.5","data-at":"mid"}),a.jsx("stop",{className:"nm-zone-stop",offset:"1","data-at":"out"})]})]}),a.jsx("path",{className:"nm-zone",d:fK(r,t/2,n/2),fill:"url(#nm-zone-fill)"}),a.jsx("text",{className:"nm-zone-label",children:a.jsx("textPath",{href:"#nm-zone-arc",startOffset:"50%",textAnchor:"middle",children:`Tailscale · ${r.count} deck${r.count===1?"":"s"}`})})]}),e.rings.map((s,o)=>a.jsx("ellipse",{className:"nm-orbit","data-ring":s.ring,"data-folded":e.folded&&s.ring===1||void 0,cx:t/2,cy:n/2,rx:s.rx,ry:s.ry,style:{"--ring":o}},s.ring))]})}function xS(e,t,n,r){const s=r*Math.PI/180;return`${(t+Math.cos(s)*e.rx).toFixed(1)},${(n+Math.sin(s)*e.ry).toFixed(1)}`}function fK(e,t,n){const r=e.to-e.from>180?1:0,s=(N,S)=>{const _=S*Math.PI/180;return[t+Math.cos(_)*N.rx,n+Math.sin(_)*N.ry]},o=(N,S)=>S/((N.rx+N.ry)/2)*(180/Math.PI),l=(N,S,_)=>{const E=Math.hypot(S[0]-N[0],S[1]-N[1])||1,T=Math.min(.5,_/E);return[N[0]+(S[0]-N[0])*T,N[1]+(S[1]-N[1])*T]},u=([N,S])=>`${N.toFixed(1)},${S.toFixed(1)}`,d=cK,h=lK,f=o(e.inner,d),p=o(e.outer,h),g=s(e.inner,e.from),v=s(e.outer,e.from),k=s(e.outer,e.to),b=s(e.inner,e.to),x=N=>`${N.rx.toFixed(1)},${N.ry.toFixed(1)}`;return[`M${u(s(e.inner,e.from+f))}`,`Q${u(g)} ${u(l(g,v,d))}`,`L${u(l(v,g,h))}`,`Q${u(v)} ${u(s(e.outer,e.from+p))}`,`A${x(e.outer)} 0 ${r} 1 ${u(s(e.outer,e.to-p))}`,`Q${u(k)} ${u(l(k,b,h))}`,`L${u(l(b,k,d))}`,`Q${u(b)} ${u(s(e.inner,e.to-f))}`,`A${x(e.inner)} 0 ${r} 0 ${u(s(e.inner,e.from+f))}`,"Z"].join(" ")}function pK(e,t,n){const r={rx:e.outer.rx-vS,ry:e.outer.ry-vS},s=e.to-e.from>180?1:0;return`M${xS(r,t,n,e.to)} A${r.rx.toFixed(1)},${r.ry.toFixed(1)} 0 ${s} 0 ${xS(r,t,n,e.from)}`}function mK({node:e,angle:t,lit:n}){const r=e.row.kind==="paired"&&e.row.here,s=e.order*uK%1*iK;return a.jsx("span",{className:"nm-wire","aria-hidden":!0,"data-tier":e.tier,"data-via":e.row.via,"data-on":n||void 0,style:{"--nm-a":`${t.toFixed(2)}deg`,"--nm-d":`${e.dist.toFixed(1)}px`,"--from":`${wS}px`,"--gap":`${wS+(e.tier==="loose"?rK:nK)}px`,"--i":e.order,"--phase":`${s.toFixed(2)}s`},children:r&&a.jsx("i",{className:"nm-glint"})})}function gK({status:e}){const t=(e==null?void 0:e.enabled)===!0&&e.running;return a.jsxs("div",{className:"nm-core","data-listening":t||void 0,children:[a.jsx("span",{className:"nm-core-orb","aria-hidden":!0}),a.jsxs("span",{className:"nm-core-label",children:[a.jsx("span",{className:"nm-core-name",children:(e==null?void 0:e.name)??"…"}),a.jsx("span",{className:"nm-core-what",children:"this deck"})]})]})}function yK({node:e,angle:t,os:n,lit:r,shown:s,tabbable:o,register:l,onHold:u,onRelease:d,onOpen:h}){const{row:f}=e,p=`nm-d-${kK(nr(f))}`,g=e.angle*Math.PI/180,v=t0(f,n);return a.jsxs("button",{ref:l,type:"button",className:"nm-node",tabIndex:o?0:-1,"data-tier":e.tier,"data-kind":f.kind,"data-side":e.side,"data-via":f.via,"data-on":r||void 0,"data-shown":s||void 0,"aria-label":`${f.name}: ${sI(f)}`,"aria-describedby":e.tier==="online"?p:void 0,style:{"--nm-a":`${t.toFixed(2)}deg`,"--nm-d":`${e.dist.toFixed(1)}px`,"--i":e.order,"--in-x":`${(-Math.cos(g)*14).toFixed(1)}px`,"--in-y":`${(-Math.sin(g)*14).toFixed(1)}px`},onPointerEnter:k=>{k.pointerType==="mouse"&&u("pointer")},onPointerLeave:d,onFocus:k=>u(k.currentTarget.matches(":focus-visible")?"keyboard":"pointer"),onBlur:d,onClick:h,children:[a.jsx("i",{className:"nm-halo","data-tier":e.tier,"aria-hidden":!0}),f.kind==="dialling"?a.jsx("i",{className:"nm-addr-dot","aria-hidden":!0}):a.jsx(Bx,{}),e.tier!=="online"&&a.jsx("i",{className:"nm-mark","data-tier":e.tier,"data-kind":f.kind,"aria-hidden":!0}),a.jsxs("span",{className:"nm-label","aria-hidden":!0,children:[a.jsx("span",{className:"nm-name",children:nI(f)}),a.jsx("span",{className:"nm-cap",children:v})]}),e.tier==="online"&&a.jsx("span",{id:p,className:"vis-hidden",children:v})]})}function wK({status:e}){const t=(e==null?void 0:e.enabled)===!0;return a.jsx("p",{className:"nm-empty",children:e?t?"No other deck yet. Decks on one network usually find each other within a minute; one on another network needs its address, through Add a deck in Local network.":"Local network is off, so this deck is not looking for any other.":"Asking this deck about the network…"})}function vK(){return a.jsxs("ul",{className:"nm-legend",children:[a.jsxs("li",{children:[a.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[a.jsx("i",{className:"nm-key-wire","data-tier":"online"}),a.jsx("i",{className:"nm-key-mark","data-tier":"online"})]}),"online"]}),a.jsxs("li",{children:[a.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[a.jsx("i",{className:"nm-key-wire","data-tier":"offline"}),a.jsx("i",{className:"nm-key-mark","data-tier":"offline"})]}),"away"]}),a.jsxs("li",{children:[a.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[a.jsx("i",{className:"nm-key-wire","data-tier":"loose"}),a.jsx("i",{className:"nm-key-mark","data-tier":"loose"})]}),"not paired"]}),a.jsxs("li",{children:[a.jsx("i",{className:"nm-key-zone","aria-hidden":!0}),"over Tailscale"]})]})}function dI({facts:e}){return a.jsx("dl",{className:"lan-facts nm-facts",children:e.map(t=>a.jsxs("div",{className:"lan-fact","data-tone":t.quiet?"quiet":void 0,children:[a.jsx("dt",{children:t.label}),a.jsx("dd",{children:t.value})]},t.label))})}function xK({status:e,summary:t,entrance:n}){const r=HG(e),s=Fx(e==null?void 0:e.about),o=[];s&&o.push({label:"Runs",value:s}),o.push({label:r.length>1?"Addresses":"Address",value:r.length?a.jsx("span",{className:"nm-addrs",children:r.map(d=>a.jsx("code",{className:"ap-lan-code",children:d},d))}):"none yet",quiet:r.length===0}),e!=null&&e.pairingMode&&o.push({label:"Pairing",value:e.pairingMode==="invite"?"by invite only":"asks and answers"});const l=[{key:"online",n:t.online,words:"online",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"online","aria-hidden":!0})},{key:"away",n:t.offline,words:"away",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"offline","aria-hidden":!0})},{key:"asks",n:t.asks,words:"asking to pair",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"loose","data-kind":"asks","aria-hidden":!0})},{key:"nearby",n:t.nearby,words:"nearby, not paired",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"loose","aria-hidden":!0})},{key:"dialling",n:t.dialling,words:"still dialling",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"loose","aria-hidden":!0})},{key:"declined",n:t.declined,words:"declined, not drawn",mark:a.jsx("i",{"aria-hidden":!0})}],u=GG(t);return a.jsxs("div",{className:"nm-panel","data-view":"network","data-entrance":n,children:[a.jsx("h3",{className:"nm-panel-name",children:(e==null?void 0:e.name)??"…"}),a.jsx("p",{className:"nm-panel-self",children:"this deck, at the centre of the map"}),a.jsx("ul",{className:"nm-counts",children:l.filter(d=>d.n>0).map(d=>a.jsxs("li",{"data-count":d.key,children:[d.mark,a.jsx("span",{className:"nm-count-n",children:d.n}),a.jsx("span",{className:"nm-count-words",children:d.words})]},d.key))}),t.tailnet>0&&a.jsxs("p",{className:"nm-counts-note",children:[t.tailnet," reached over Tailscale — the shaded slice, lower right"]}),u&&a.jsx("p",{className:"nm-next",children:u}),a.jsx(dI,{facts:o}),a.jsx("p",{className:"nm-panel-hint",children:"Point at a deck, or reach one with the arrow keys, to see it here. Press it to open its own dialog."})]})}function bK({row:e,status:t,accounts:n,now:r,entrance:s,onOpen:o,onBack:l}){var x;const u=cI({row:e,source:Hl(t,e),status:t,accounts:n,now:r}),d=[];u.where&&d.push({label:"Address",value:a.jsx("code",{className:"ap-lan-code",children:u.where})}),u.thereRuns&&d.push({label:"Runs",value:`${u.thereRuns}${u.order?` · ${u.order<0?"older than this deck":"newer than this deck"}`:""}`}),u.hiddenThere&&d.push({label:"Signed in to",value:"not said — its owner hides it",quiet:!0}),u.otherThere&&d.push({label:"Signed in to",value:"an account it does not share",quiet:!0});const h=e.kind==="paired"&&e.here||e.kind==="asks",f=KG(e,t.pairingMode),p=YG(u.lanes),g=p.length,v=p.filter(N=>N.tone==="ok").length,k=g===0?"No shared logins":v===g?`${g} shared login${g===1?", fine":"s, all fine"}`:`${g} shared login${g===1?"":"s"} · ${v} fine`,b=u.unknown&&((x=u.peer)!=null&&x.waiting)&&!u.peer.offers?"Its side is not known until it next calls.":u.unknown;return a.jsxs("div",{className:"nm-panel","data-view":"deck","data-entrance":s,"data-tier":e.kind==="paired"?e.here?"online":"offline":"loose",children:[a.jsxs("button",{type:"button",className:"ap-lan-word nm-back",onClick:l,children:[a.jsx("span",{"aria-hidden":!0,children:"‹ "}),"the whole network"]}),a.jsxs("div",{className:"nm-panel-head",children:[a.jsxs("h3",{className:"nm-panel-name",children:[a.jsx("i",{className:h?"ap-pulse":"ap-dot","data-kind":e.kind,"aria-hidden":!0}),a.jsx("span",{className:"nm-panel-title",children:e.name})]}),a.jsx("button",{type:"button",className:"btn nm-open",onClick:o,"aria-label":`Open ${e.name}`,children:"Open"})]}),e.self&&a.jsxs("p",{className:"nm-panel-self",children:["calls itself ",e.self]}),a.jsx("p",{className:"nm-panel-state","data-kind":e.kind,children:sI(e)}),f&&a.jsx("p",{className:"nm-next",children:f}),d.length>0&&a.jsx(dI,{facts:d}),u.paired&&a.jsxs("section",{className:"nm-logins","aria-label":"Logins the two decks share",children:[a.jsx("p",{className:"nm-logins-title",children:k}),g>0&&a.jsx("ul",{className:"nm-lanes",children:p.map((N,S)=>a.jsxs("li",{className:"nm-lane","data-tone":N.tone,style:{"--k":S},children:[a.jsx("i",{className:"nm-lane-dot","aria-hidden":!0}),a.jsx("span",{className:"nm-lane-email","aria-hidden":!0,children:N.email}),bS(N)&&a.jsx("span",{className:"nm-lane-said","aria-hidden":!0,children:bS(N)}),N.usedThere&&a.jsx("span",{className:"nm-lane-used","aria-hidden":!0,children:"in use there"}),a.jsxs("span",{className:"vis-hidden",children:[N.email,": ",lI(N)]})]},N.key))}),b&&a.jsx("p",{className:"nm-panel-hint",children:b})]})]})}function bS(e){return e.caption?e.caption:e.tone==="ok"?null:`${oI[e.here]} · ${iI[e.there]}`}function kK(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}const NK=6;function jK({anchorId:e,id:t,rows:n,onHold:r,onLet:s}){const o=w.useRef(null),l=n.filter(g=>g.kind==="paired"),u=l.filter(g=>g.here),d=u.slice(0,NK),h=l.length-u.length,f=u.length>d.length?`and ${u.length-d.length} more`:h>0?`${h} not on right now`:null,p=w.useCallback(()=>{const g=o.current,v=document.getElementById(e);if(!g||!v)return;const k=Wb(v.getBoundingClientRect(),{width:g.offsetWidth,height:g.offsetHeight},{width:window.innerWidth,height:window.innerHeight});g.style.top=`${k.top}px`,g.style.left=`${k.left}px`,g.style.maxHeight=k.maxHeight==null?"":`${k.maxHeight}px`,g.dataset.side=k.side},[e]);return w.useLayoutEffect(()=>{p()}),w.useEffect(()=>(window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}),[p]),Lt.createPortal(a.jsxs("div",{ref:o,id:t,className:"ap-peek",role:"tooltip",onPointerEnter:r,onPointerLeave:s,children:[a.jsx("p",{className:"ap-peek-title",children:u.length?"On the network now":"Nobody on the network"}),d.length>0&&a.jsx("div",{className:"ap-peek-list",children:d.map(g=>a.jsxs("span",{className:"ap-peek-who",children:[a.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),a.jsxs("span",{children:[g.name,g.via==="tailscale"&&a.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]})]},`${g.kind}:${g.fp}`))}),f&&a.jsx("p",{className:"ap-peek-rest",children:f})]}),document.body)}function SK({entry:e,rows:t,onOpen:n,onMap:r,peek:s,openPeek:o,shutPeek:l,holdPeek:u,dropPeek:d}){return a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",id:"ap-lan-entry",className:"ap-nav",onClick:()=>{d(),n()},"aria-describedby":s?"ap-lan-peek":void 0,onPointerEnter:h=>{h.pointerType==="mouse"&&o(K$)},onPointerLeave:l,onFocus:h=>{h.target.matches(":focus-visible")&&o(0)},onBlur:l,children:[a.jsxs("svg",{className:"ap-nav-glyph",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("rect",{x:"1.8",y:"2.3",width:"10.4",height:"7.2",rx:"1.2"}),a.jsx("path",{d:"M5 11.9h4M7 9.5v2.4"})]}),a.jsxs("span",{className:"ap-nav-text",children:[a.jsx("span",{className:"ap-nav-name",children:"Local network"}),a.jsxs("span",{className:"ap-nav-state","data-tone":e.tone,children:[e.live&&a.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),e.text]})]}),a.jsx("svg",{className:"ap-nav-chev",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),r&&a.jsx("button",{type:"button",className:"ap-lan-map",onClick:()=>{d(),r()},"aria-label":"Show the network map",title:"Network map — every deck this one knows, drawn around it",children:a.jsx(uI,{})}),s&&a.jsx(jK,{anchorId:"ap-lan-entry",id:"ap-lan-peek",rows:t,onHold:u,onLet:l})]})}function _K({row:e,run:t,onVerb:n,onUnpair:r}){const[s,o]=w.useState(!1),l=w.useRef(0),[u,d]=w.useState(null);return w.useEffect(()=>{if(!s)return;const p=window.setTimeout(()=>o(!1),4e3);return()=>window.clearTimeout(p)},[s]),w.useEffect(()=>{if(!u)return;const p=window.setTimeout(()=>d(null),4e3);return()=>window.clearTimeout(p)},[u]),{armed:s,armedTwin:u,pressOwn:()=>{const p=Date.now(),g=ql({armedFor:s?e.fp:null,target:e.fp,armedAt:l.current,now:p,gapMs:Bl});if(g==="arm"){o(!0),d(null),l.current=p;return}g!=="ignore"&&(o(!1),t(n))},pressTwin:p=>{if(!r)return;const g=Date.now(),v=ql({armedFor:u,target:p,armedAt:l.current,now:g,gapMs:Bl});if(v==="arm"){d(p),o(!1),l.current=g;return}v!=="ignore"&&(d(null),t(()=>r(p)))}}}function EK({row:e,paired:t,peer:n,status:r,busy:s,press:o,checkNow:l,armed:u,pressOwn:d,run:h,onVerb:f,onInvite:p}){return a.jsxs("footer",{className:"lan-peer-foot",children:[e.kind==="asks"&&a.jsx("p",{className:"lan-foot-note",children:"This deck is now asking to pair. Answer it from the panel behind this."}),t&&!(n!=null&&n.waiting)&&a.jsx("button",{type:"button",className:"btn",...o(`check:${e.fp}`),onClick:l,title:"Ask this deck now instead of waiting for the next round",children:s===`check:${e.fp}`?"Checking…":"Check now"}),e.kind==="paired"&&a.jsx("button",{type:"button",className:`btn danger lan-peer-verb${u?" armed":""}`,...o(`unpair:${e.fp}`),onKeyDown:g=>{g.repeat&&g.preventDefault()},onClick:()=>d(),"aria-label":u?`Confirm unpairing ${e.name}`:`Unpair ${e.name}`,title:u?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this deck from now on",children:s===`unpair:${e.fp}`?"Unpairing…":u?"Confirm unpair":"Unpair"}),e.kind==="nearby"&&r.pairingMode!=="invite"&&a.jsx("button",{type:"button",className:"btn primary lan-peer-verb",...o(`accept:${e.fp}`),onClick:()=>void h(f),title:"Send it a request. Somebody at that machine has to accept it before anything is shared.",children:s===`accept:${e.fp}`?"Asking…":"Ask to pair"}),e.kind==="dialling"&&a.jsx("button",{type:"button",className:"btn lan-peer-verb",...o(`drop:${e.fp}`),onClick:()=>void h(f),title:"Stop trying this address. Nothing was ever paired here.",children:s===`drop:${e.fp}`?"Stopping…":"Stop dialling"}),e.kind==="declined"&&r.pairingMode!=="invite"&&a.jsx("button",{type:"button",className:"btn lan-peer-verb",...o(`allow:${e.fp}`),onClick:()=>void h(f),title:"Take the no back. That deck is still trying, so its request comes round again on its own.",children:s===`allow:${e.fp}`?"Allowing…":"Let it ask again"}),(e.kind==="nearby"||e.kind==="declined")&&r.pairingMode==="invite"&&p&&a.jsx("button",{type:"button",className:"btn primary lan-peer-verb",onClick:p,title:"This deck pairs only by invite. Make one and send it to whoever is at that machine.",children:"Invite to pair"})]})}function CK({instances:e,now:t,busy:n,press:r,armedTwin:s,pressTwin:o,onUnpair:l}){return a.jsxs("div",{className:"modal-section",children:[a.jsxs("h3",{className:"lan-h",children:[e.length," decks on this machine"]}),a.jsx("ul",{className:"lan-twins",role:"list",children:e.map((u,d)=>{var k,b,x,N;const h=(k=u.peer)!=null&&k.addr?`${u.peer.addr}:${u.peer.port}`:u.row.addr,f=h||u.row.fp,p=(b=u.peer)!=null&&b.pairedAt?Or(u.peer.pairedAt,t):null,g=[(N=(x=u.peer)==null?void 0:x.about)!=null&&N.version?`runs ${u.peer.about.version}`:null,p?`paired ${p==="now"?"just now":p}`:null,u.row.state].filter(Boolean).join(" · "),v=u.row.fp;return a.jsxs("li",{role:"listitem",className:"lan-twin","data-tone":u.row.tone,children:[a.jsx("i",{className:u.row.here?"ap-pulse":"ap-dot","aria-hidden":!0}),h?a.jsx("code",{className:"ap-lan-code lan-twin-at",children:h}):a.jsx("span",{className:"lan-twin-at lan-twin-none",children:"no address here"}),a.jsx("code",{className:"ap-lan-code lan-twin-fp",children:v}),d>0&&l&&a.jsx("button",{type:"button",className:`ap-manage-btn danger lan-twin-do${s===v?" armed":""}`,...r(`unpair:${v}`),onKeyDown:S=>{S.repeat&&S.preventDefault()},onClick:()=>o(v),"aria-label":s===v?`Confirm unpairing ${f}`:`Unpair ${f}`,title:s===v?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this one of the machine's decks",children:n===`unpair:${v}`?"unpairing…":s===v?"confirm":"unpair"}),a.jsx("span",{className:"lan-twin-meta",children:d===0?`${g} · shown above`:g})]},v)})})]})}function TK(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M9.6 2.4l2 2L5 11l-2.6.6L3 9z"}),a.jsx("path",{d:"M8.4 3.6l2 2"})]})}function AK({row:e,source:t,status:n,accounts:r,now:s,busy:o,onClose:l,onRename:u,onCheck:d,onVerb:h,onSettings:f,onInvite:p,twins:g=[],onUnpair:v}){const k=w.useRef(null),b=ft(l,{focusRef:k}),[x,N]=w.useState(null),[S,_]=w.useState(null),[E,T]=w.useState(!1),[A,R]=w.useState(0),B=w.useRef(null),P=w.useRef(null),D=w.useRef(!0);w.useEffect(()=>()=>{D.current=!1},[]);const O=x!=null;w.useEffect(()=>{var ae;O&&((ae=B.current)==null||ae.select())},[O]);const L=w.useRef(!1);w.useEffect(()=>{var ae,pe;L.current&&!O&&Pr(((ae=document.activeElement)==null?void 0:ae.tagName)??null)&&((pe=P.current)==null||pe.focus()),L.current=O},[O]);const z=ae=>{const pe=Qs(o,ae);return{disabled:pe.disabled,"aria-busy":pe.busy}},M=async ae=>{const pe=await ae();return D.current&&_(pe),pe==null},{armed:$,armedTwin:q,pressOwn:X,pressTwin:H}=_K({row:e,run:M,onVerb:h,onUnpair:v}),I=cI({row:e,source:t,status:n,accounts:r,now:s}),{peer:W,stranger:F,paired:Y,own:J,canRename:V,fp:G}=I,K=o===`check:${e.fp}`,Z=async ae=>{const pe=ae.trim()===J?"":ae;await M(()=>u(pe))&&N(null)},ee=()=>void M(d).then(ae=>{ae&&D.current&&R(pe=>pe+1)}),re=async()=>{if(G)try{if(await navigator.clipboard.writeText(G),!D.current)return;T(!0),window.setTimeout(()=>{D.current&&T(!1)},1600)}catch{D.current&&_("Could not copy it — select the fingerprint and copy it by hand.")}},ue=[];Y&&(W!=null&&W.pairedAt)?ue.push({label:"Paired",value:eK(W.pairedAt,s),tone:"meta"}):e.kind==="declined"&&F&&ue.push({label:"Paired",value:`no · you said no ${Jb(F.at,s)}`,tone:"meta"}),ue.push({label:"Fingerprint",value:G?a.jsxs("span",{className:"lan-fp",children:[a.jsx("code",{className:"ap-lan-code",children:G}),a.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void re(),"aria-label":E?"Fingerprint copied":"Copy the fingerprint",children:E?"copied":"copy"})]}):"not known — nothing has answered there",tone:G?void 0:"quiet"});const me=g.length?[{row:e,peer:W??null},...g]:[];return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",onClick:l,role:"presentation",children:a.jsxs("div",{ref:b,className:"modal lan-peer","data-tone":e.tone,onClick:ae=>ae.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-peer-title","aria-describedby":"lan-peer-sub",children:[a.jsxs("header",{className:"modal-head lan-peer-head",children:[a.jsx("i",{className:e.here?"ap-pulse":"ap-dot","aria-hidden":!0}),a.jsxs("div",{className:"lan-peer-id",children:[O?a.jsxs("form",{className:"lan-peer-edit",onSubmit:ae=>{ae.preventDefault(),Z(x??"")},children:[a.jsx("span",{id:"lan-peer-title",className:"vis-hidden",children:e.name}),a.jsx("input",{ref:B,className:"ap-manage-input lan-peer-input",value:x??"",maxLength:48,placeholder:J,"aria-label":"Name for this deck, shown on this deck only",onChange:ae=>N(ae.target.value)}),a.jsx("button",{type:"submit",className:"ap-manage-btn",...z(`alias:${e.fp}`),children:"save"}),a.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>N(null),children:"cancel"})]}):a.jsxs("span",{className:"lan-peer-title",children:[a.jsx("span",{id:"lan-peer-title",className:"lan-peer-name",children:e.name}),V&&a.jsx("button",{type:"button",className:"glyph-btn lan-peer-rename",ref:P,onClick:()=>{_(null),N(e.name)},"aria-label":`Rename ${e.name} on this deck`,title:"Give it a name of your own. Only this deck sees it.",children:a.jsx(TK,{})})]}),a.jsxs("p",{id:"lan-peer-sub",className:"lan-peer-sub",children:[e.self&&a.jsxs(a.Fragment,{children:["calls itself ",a.jsx("span",{className:"lan-peer-self",children:e.self}),O&&a.jsx("button",{type:"button",className:"ap-lan-word lan-peer-restore",...z(`alias:${e.fp}`),onClick:()=>void Z(""),children:"use this name"}),a.jsx("span",{className:"vis-hidden",children:". "}),!e.quiet&&a.jsx("span",{"aria-hidden":!0,children:" · "})]}),a.jsx("span",{className:e.quiet?"vis-hidden":"lan-peer-state",children:e.state})]})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:k,type:"button",className:"glyph-btn",onClick:l,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body lan-peer-body",children:[S&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",children:S}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>_(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),a.jsx(tK,{view:I,row:e,status:n,asking:K,drawn:A,onSettings:f}),a.jsx("dl",{className:"lan-facts",children:ue.map(ae=>a.jsxs("div",{className:"lan-fact","data-tone":ae.tone,children:[a.jsx("dt",{children:ae.label}),a.jsx("dd",{children:ae.value})]},ae.label))}),me.length>1&&a.jsx(CK,{instances:me,now:s,busy:o,press:z,armedTwin:q,pressTwin:H,onUnpair:v})]}),a.jsx(EK,{row:e,paired:Y,peer:W,status:n,busy:o,press:z,checkNow:ee,armed:$,pressOwn:X,run:M,onVerb:h,onInvite:p})]})}),document.body)}function md(e,t){const n=w.useRef(!1);return w.useEffect(()=>{var r,s;!e||!n.current||(n.current=!1,Pr(((r=document.activeElement)==null?void 0:r.tagName)??null)&&((s=t.current)==null||s.focus()))},[e]),()=>{n.current=!0}}function RK(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(r=>n.has(r))}function MK(e,t,n,r){const s=new Set(e??t);return r?s.add(n):s.delete(n),[...s]}function kS(e,t,n){return e==null||n!=null&&!n.ok||RK(e,t)?null:e}function hI({line:e,onDismiss:t,onAnswer:n}){const[r,s]=w.useState(!1),o=w.useRef(!1),l=w.useRef(!0);w.useEffect(()=>(l.current=!0,()=>{l.current=!1}),[]);const u=w.useRef(null),d=w.useRef(null),h=w.useRef(!1);if(w.useEffect(()=>{var p;h.current&&(h.current=!1,e!=null&&e.giveBack||(p=d.current)==null||p.focus())},[e]),!e)return null;const f=async()=>{if(o.current)return;o.current=!0,s(!0);const p=await RV();o.current=!1,l.current&&(s(!1),h.current=document.activeElement===u.current,n($V(p)))};return a.jsxs("div",{className:e.done?"ap-failure ap-failure-done":"ap-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",children:e.text}),e.giveBack&&a.jsx("button",{ref:u,type:"button",className:"ap-fix ap-give-back","aria-busy":r,onClick:f,title:"Opens macOS's password dialog to make the settings folder yours again",children:r?"waiting for macOS…":"give it back"}),a.jsx("button",{ref:d,type:"button",className:"ap-failure-x",onClick:t,"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]})}function $K(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 Au="Paused while this deck pairs only by invite. Turn that off above to use it.";function IK({status:e,accounts:t,onClose:n,onChanged:r}){const s=ft(n),[o,l]=w.useState(null),[u,d]=w.useState(null),[h,f]=w.useState(!1),[p,g]=w.useState(null),v=w.useRef(null),k=H=>{const I=Qs(p,H);return{disabled:I.disabled,"aria-busy":I.busy}},b=w.useRef(null),x=w.useRef(!0);w.useEffect(()=>()=>{x.current=!1},[]),w.useEffect(()=>{b.current=kS(b.current,e.shared??[],null)},[e.shared]);const N=w.useCallback(async(H,I,W="write")=>{v.current=W,g(W);try{const Y=await(await fetch("/api/prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:H})})).json().catch(()=>null);return x.current?(Y!=null&&Y.ok?d(null):d(rr(Et(I,Y),Y)),r(),(Y==null?void 0:Y.ok)===!0):!1}catch{return x.current&&d(rr(Et(I,null))),!1}finally{v.current=null,x.current&&g(null)}},[r]),S=w.useCallback(async H=>{const I=await N({name:H},"save the name","name");return I&&x.current&&l(W=>W===H?null:W),I},[N]),_=w.useRef(null),E=o!=null&&o!==(e.name??""),T=md(!E,_),A=w.useCallback(async()=>{E&&!await S(o)||n()},[E,o,S,n]),R=async()=>{if(!e.fp)return;const H=await Wa(e.fp);if(x.current){if(!H){d(rr("Could not copy it — select the fingerprint and copy it by hand."));return}f(!0),window.setTimeout(()=>{x.current&&f(!1)},1600)}},B=new Set(b.current??e.shared??[]),P=e.autoAsk!==!1,D=e.autoAccept!==!1,O=e.pairingMode==="invite",L=H=>{const I=k(H);return{...I,disabled:I.disabled||O}},z=e.shareActive!==!1,M=e.tailscale??null,$=!!(M!=null&&M.on),q=(M==null?void 0:M.ask)!==!1,X=(M==null?void 0:M.accept)!==!1;return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal lan-modal",onClick:H=>H.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-modal-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"lan-modal-title",className:"modal-tool-name",children:"This deck on the network"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsx(hI,{line:u,onDismiss:()=>d(null),onAnswer:H=>{d(H),H.done&&r()}}),a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"Name"}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("span",{className:"ap-lan-label",children:"appear as"}),a.jsx("input",{ref:_,className:"ap-manage-input ap-lan-input","aria-label":"This deck's name on the network",value:o??e.name??"",placeholder:"this machine",onChange:H=>l(H.target.value),onKeyDown:H=>{H.key!=="Enter"||o==null||S(o)}}),E&&a.jsx("button",{type:"button",className:"ap-manage-btn",...k("name"),onClick:()=>{T(),S(o)},title:"Save it. This is the name other decks show for this one.",children:"save"})]}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("span",{className:"ap-lan-label",children:"fingerprint"}),e.fp?a.jsxs("span",{className:"lan-fp",children:[a.jsx("code",{className:"ap-lan-code",children:e.fp}),a.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void R(),"aria-label":h?"Fingerprint copied":"Copy this deck's fingerprint",children:h?"copied":"copy"})]}):a.jsx("span",{className:"ap-lan-label",children:"not known yet"})]})]}),a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"Share these accounts"}),a.jsxs("div",{className:"ap-lan-picks",children:[t.length===0&&a.jsx("span",{className:"ap-lan-empty",children:"No Claude accounts on this deck yet — add one with + at the top of this panel."}),t.map(H=>a.jsxs("label",{className:"ap-lan-pick",title:H.alive?"Offer this account to the decks you have paired with, so one whose copy has died can heal from yours. Unticking stops it being offered from now on; it does not take back a copy somebody already has.":"This deck cannot use this login, so it has nothing to offer — a deck that can will heal it",children:[a.jsx("input",{type:"checkbox",checked:B.has(H.key),onChange:I=>{const W=MK(b.current,e.shared??[],H.key,I.target.checked);b.current=W,N({shared:W},I.target.checked?"share that account":"stop sharing that account").then(F=>{b.current===W&&(b.current=kS(W,e.shared??[],{ok:F}))})}}),a.jsx("span",{className:"ap-lan-pick-name",children:H.email}),!H.alive&&a.jsx("span",{className:"ap-lan-dead",children:"not working here"})]},H.key))]}),t.length>0&&a.jsxs("div",{className:"lan-switch",children:[a.jsx("span",{className:"lan-switch-what",children:"Show paired decks which of these this deck is using"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":z,"aria-label":"Show paired decks which of these this deck is using",...k("current"),onClick:()=>void N({shareActive:!z},z?"stop showing which account this deck is using":"show which account this deck is using","current"),title:z?"Stop telling paired decks which account this one is on. They read “current account hidden” instead.":"Tell paired decks which of the ticked accounts this one is on. An unticked account is never named.",children:a.jsx("span",{className:"switch-knob"})})]})]}),a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",id:"lan-pairing-h",children:"Pairing"}),a.jsx("div",{className:"lan-switches lan-switches-lead",role:"group","aria-labelledby":"lan-pairing-h",children:a.jsxs("div",{className:"lan-switch",children:[a.jsxs("span",{className:"lan-switch-what",children:["Pair new decks only by invite",O&&a.jsx("span",{id:"lan-invite-only-detail",className:"lan-switch-detail",children:"A new deck needs an invite from Add a deck, the link at the top of Local network. Paired decks stay paired."})]}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":O,"aria-label":"Pair new decks only by invite","aria-describedby":O?"lan-invite-only-detail":void 0,...k("mode"),onKeyDown:H=>{H.repeat&&H.preventDefault()},onClick:()=>void N({pairingMode:O?"automatic":"invite"},O?"let decks pair on their own again":"pair new decks only by invite","mode"),title:O?"Let decks on this network pair as the two switches below say again.":"Only a deck you send an invite to can pair with this one. Nearby decks can't ask, and requests waiting now are turned away.",children:a.jsx("span",{className:"switch-knob"})})]})}),a.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-auto-h",children:[a.jsxs("p",{className:"lan-sub",id:"lan-auto-h",children:["Automatic pairing",O&&a.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),a.jsxs("div",{className:"lan-switches","data-paused":O||void 0,children:[a.jsxs("div",{className:"lan-switch",children:[a.jsx("span",{className:"lan-switch-what",children:"Ask every deck this one finds"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":P,"aria-label":"Ask every deck this one finds",...L("ask"),onClick:()=>void N({autoAsk:!P},P?"stop asking automatically":"ask every deck this one finds","ask"),title:O?Au:P?"Stop sending requests on their own. You press ask on the row instead.":"Send a pairing request to every deck heard on this network. Somebody over there still has to say yes.",children:a.jsx("span",{className:"switch-knob"})})]}),a.jsxs("div",{className:"lan-switch",children:[a.jsx("span",{className:"lan-switch-what",children:"Say yes to every deck that asks"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":D,"aria-label":"Say yes to every deck that asks","data-tone":"warn",...L("accept"),onKeyDown:H=>{H.repeat&&H.preventDefault()},onClick:()=>void N({autoAccept:!D},D?"stop accepting automatically":"accept every deck that asks","accept"),title:O?Au:D?"Stop saying yes for you. A deck that asks waits in the panel again.":"Say yes for you. Every deck on this network that asks is paired without anybody being asked here.",children:a.jsx("span",{className:"switch-knob"})})]})]})]})]}),(M==null?void 0:M.found)&&a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"Tailscale"}),a.jsxs("div",{className:"lan-switches",children:[a.jsxs("div",{className:"lan-switch",children:[a.jsxs("span",{className:"lan-switch-what",children:["Look for my devices",a.jsx("span",{id:"lan-ts-detail",className:"lan-switch-detail",children:$K(M)})]}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":$,"aria-label":"Look for my devices over Tailscale","aria-describedby":"lan-ts-detail",...k("tailscale"),onClick:()=>void N({tailscale:!$},$?"stop looking over Tailscale":"look for your devices over Tailscale","tailscale"),title:$?"Stop. Nothing is looked for or answered over the tailnet; decks already paired stay paired.":"Find the decks on your other machines on Tailscale, wherever they are. Only machines signed in to your Tailscale account are asked.",children:a.jsx("span",{className:"switch-knob"})})]}),$&&a.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-ts-auto-h",children:[a.jsxs("p",{className:"lan-sub",id:"lan-ts-auto-h",children:["Automatic pairing with my devices",O&&a.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),a.jsxs("div",{className:"lan-switches",children:[a.jsxs("div",{className:"lan-switch","data-paused":O||void 0,children:[a.jsx("span",{className:"lan-switch-what",children:"Ask each device it finds"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":q,"aria-label":"Ask each of my devices it finds over Tailscale",...L("tailscale-ask"),onClick:()=>void N({tailscaleAsk:!q},q?"stop asking your devices automatically":"ask your devices automatically","tailscale-ask"),title:O?Au:q?"Stop sending requests on their own. You press ask on the row instead.":"Send a pairing request to every deck found on your devices over Tailscale.",children:a.jsx("span",{className:"switch-knob"})})]}),a.jsxs("div",{className:"lan-switch","data-paused":O||void 0,children:[a.jsx("span",{className:"lan-switch-what",children:"Say yes to each device that asks"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":X,"aria-label":"Say yes to my devices when they ask over Tailscale","data-tone":"warn",...L("tailscale-accept"),onKeyDown:H=>{H.repeat&&H.preventDefault()},onClick:()=>void N({tailscaleAccept:!X},X?"stop accepting your devices automatically":"accept your devices automatically","tailscale-accept"),title:O?Au:X?"Stop saying yes for you. A device that asks waits in the panel again.":"Say yes for you when a deck on one of your own devices asks. Anybody else on the tailnet still waits for a press.",children:a.jsx("span",{className:"switch-knob"})})]})]})]})]})]})]}),a.jsxs("footer",{className:"lan-setup-foot",children:[a.jsx("span",{className:"lan-foot-note",children:"Changes are saved as you make them."}),a.jsx("button",{type:"button",className:"btn primary",...k("name"),onClick:()=>void A(),children:"Done"})]})]})}),document.body)}function OK({on:e,status:t,paired:n,busy:r,pressProps:s,checkNow:o,setAddOpen:l,setSetupOpen:u,setMapOpen:d,onBack:h,closeButton:f}){return a.jsxs("div",{className:"ap-header",children:[a.jsx("button",{type:"button",id:"ap-lan-back",className:"glyph-btn ap-back",onClick:h,"aria-label":"Back to Claude accounts",title:"Back to Claude accounts",children:a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M8.4 3.4 4.8 7l3.6 3.6"})})}),a.jsx("h2",{id:"ap-lan-title",children:"Local network"}),a.jsxs("div",{className:"ap-header-right",children:[e&&a.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>d(!0),"aria-label":"Show the network map",title:"Network map — every deck this one knows, drawn around it",children:a.jsx(uI,{})}),e&&a.jsx("button",{type:"button",className:"glyph-btn ap-lan-plus",onClick:()=>l("add"),"aria-label":"Add a deck",title:(t==null?void 0:t.pairingMode)==="invite"?"Send an invite, or use one you were sent. This deck pairs only by invite.":"Reach a deck that has not turned up on its own — by address, or with an invite",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M6.1 7.9a2.6 2.6 0 0 0 3.7 0l1.9-1.9a2.6 2.6 0 0 0-3.7-3.7l-.9.9"}),a.jsx("path",{d:"M7.9 6.1a2.6 2.6 0 0 0-3.7 0L2.3 8a2.6 2.6 0 0 0 3.7 3.7l.9-.9"})]})}),e&&n>0&&a.jsx("button",{type:"button",className:"glyph-btn ap-lan-check",...s("check"),onClick:()=>void o(),"aria-label":r==="check"?"Checking every paired deck":"Check every paired deck now",title:"Ask every paired deck now for anything this deck's expired logins need, instead of waiting for the next round",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("circle",{cx:"7",cy:"7",r:"1.1",fill:"currentColor",stroke:"none"}),a.jsx("path",{d:"M4.6 4.6a3.4 3.4 0 0 0 0 4.8M9.4 4.6a3.4 3.4 0 0 1 0 4.8"}),a.jsx("path",{d:"M2.6 2.6a6.2 6.2 0 0 0 0 8.8M11.4 2.6a6.2 6.2 0 0 1 0 8.8"})]})}),e&&a.jsx("button",{type:"button",className:"glyph-btn ap-lan-set",...s("setup"),onClick:()=>u(!0),"aria-label":"This deck's name and shared logins",title:"This deck's name on the network, and which of its logins it offers",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M1.8 4.7h10.4M1.8 9.3h10.4"}),a.jsx("circle",{cx:"9.1",cy:"4.7",r:"1.6",fill:"var(--panel)"}),a.jsx("circle",{cx:"4.9",cy:"9.3",r:"1.6",fill:"var(--panel)"})]})}),f]})]})}function LK({accounts:e,onChanged:t,onNoCopy:n,view:r,onOpen:s,onBack:o,closeButton:l}){const[u,d]=w.useState(!1),[h,f]=w.useState(!1),[p,g]=w.useState(!1),v=TV(),[k,b]=w.useState(!1),{status:x,manual:N,now:S,busy:_,failure:E,dismissFailure:T,answerGiveBack:A,pressProps:R,load:B,toggle:P,answer:D,dropAddress:O,rename:L,checkOne:z,checkNow:M}=DV(t,()=>d(!0)),{armed:$,pressUnpair:q}=FV(D),[X,H]=w.useState(null),[I,W]=w.useState(!1),F=w.useMemo(()=>e.filter(se=>EV(se.key,x??null,S)).map(se=>se.key).sort().join(`
84
+ `),[e,x,S]);w.useEffect(()=>{n==null||n(F?F.split(`
85
+ `):[])},[F,n]);const Y=(x==null?void 0:x.enabled)===!0,J=w.useMemo(()=>yV((x==null?void 0:x.pairingMode)==="invite"&&x?{...x,pending:[]}:x,S),[x,S]),V=X?J.find(se=>{var ve;return se.fp===X||((ve=se.twins)==null?void 0:ve.some(fe=>fe.fp===X))})??null:null;w.useEffect(()=>{X&&x&&!V&&H(null)},[X,x,V]);const{asks:G,rest:K,live:Z,folded:ee,troubled:re,shown:ue,paired:me}=_V(J,k),ae=pV(x,S),pe=SV(x,J),xe=a.jsxs(a.Fragment,{children:[h&&x&&a.jsx(iG,{status:x,manual:N,startWith:h==="invite"?"invite":void 0,onClose:()=>f(!1),onChanged:()=>{B(),t()}}),p&&a.jsx(Z$,{title:"How Local network works",steps:QV,finish:Y?void 0:{label:"Turn it on",act:()=>{g(!1),P()}},onClose:()=>g(!1)}),u&&x&&a.jsx(IK,{status:{...x,manualRows:N},accounts:e,manual:N,onClose:()=>d(!1),onChanged:()=>{B(),t()}}),I&&a.jsx(dK,{status:x,rows:J,accounts:e,now:S,covered:!!V||u||!!h||p,onOpenDeck:H,onClose:()=>W(!1)}),V&&x&&a.jsx(AK,{row:V,source:Hl(x,V),status:x,accounts:e,now:S,busy:_,onClose:()=>H(null),onRename:se=>L(V.fp,se),onCheck:()=>z(V.fp),onVerb:()=>{switch(V.kind){case"paired":return D("unpair",V.fp,"unpair that deck");case"nearby":return D("accept",V.fp,"reach that deck");case"declined":return D("allow",V.fp,"let that deck ask again");case"dialling":return O(V.fp);default:return Promise.resolve(null)}},onSettings:()=>{H(null),d(!0)},onInvite:()=>{H(null),f("invite")},twins:(V.twins??[]).map(se=>({row:se,peer:Hl(x,se).peer??null})),onUnpair:se=>D("unpair",se,"unpair that deck")})]});return r?a.jsxs("div",{className:"ap-lan-view",children:[a.jsx(OK,{on:Y,status:x,paired:me,busy:_,pressProps:R,checkNow:M,setAddOpen:f,setSetupOpen:d,setMapOpen:W,onBack:o,closeButton:l}),a.jsx("div",{className:"ap-scroll",id:"ap-lan-scroll",children:a.jsxs("div",{className:"ap-lan",children:[a.jsxs("div",{className:"ap-policy",children:[a.jsx("h3",{className:"ap-auto-title",children:"Sync with paired decks"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":Y,"aria-label":"Sync with paired decks",...R("switch"),onClick:()=>void P(),title:Y?"Stop talking to other decks. Nothing is shared while this is off.":"Let the decks you pair with repair this one's expired logins",children:a.jsx("span",{className:"switch-knob"})})]}),a.jsx(hG,{on:Y,status:x}),!Y&&a.jsxs("button",{type:"button",className:"ap-lan-intro",onClick:()=>g(!0),title:"Four pictures: what this does, and what to do on each machine",children:[a.jsx(eG,{}),a.jsx("span",{className:"ap-lan-intro-text",children:"Paired machines repair each other's expired logins."}),a.jsx("span",{className:"ap-lan-intro-go",children:"See how it works"})]}),a.jsx("p",{className:`ap-lan-status ${ae.tone}`,role:"status",children:ae.tone==="ok"?"":ae.text}),a.jsx(hI,{line:E,onDismiss:T,onAnswer:A}),Y&&a.jsxs(a.Fragment,{children:[G.length>0&&a.jsx(cG,{asks:G,pressProps:R,answer:D}),ue.length>0&&a.jsx(uG,{rows:ue,pairingMode:x==null?void 0:x.pairingMode,armed:$,pressProps:R,answer:D,dropAddress:O,onUnpair:q,onOpenPeer:H,onInvite:()=>f("invite")}),(Z.length>0&&ee.length>0||Y&&me>0)&&a.jsxs("div",{className:"ap-lan-tail",children:[Z.length>0&&ee.length>0&&a.jsxs("button",{type:"button",className:"ap-lan-word ap-lan-more","aria-expanded":k,onClick:()=>b(se=>!se),title:k?"Show only the decks that are on":`Show the ${ee.length} deck${ee.length===1?"":"s"} that are not responding right now`,children:[a.jsx("span",{className:`ap-lan-chev${k?" open":""}`,"aria-hidden":!0,children:"›"}),k?"fewer":`${ee.length} more`,!k&&re>0&&a.jsxs("span",{className:"ap-lan-more-bad",children:[" · ",re," not responding"]})]}),Y&&me>0&&a.jsx("span",{className:"ap-lan-checked",children:mV(x==null?void 0:x.checkedAt,S,_==="check")})]}),K.length===0&&G.length===0&&!(x!=null&&x.stalled)&&!(x!=null&&x.deaf)&&!(x!=null&&x.lanTunneled)&&a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"ap-lan-fine",children:"No other deck yet. Decks on one network usually find each other on their own; when that has not happened, the link at the top of this view reaches one by address or by invite."}),a.jsx("button",{type:"button",className:"ap-lan-word ap-lan-how",onClick:()=>g(!0),children:"How it works"})]})]})]})}),xe]}):a.jsxs("div",{className:"ap-foot",children:[a.jsx(SK,{entry:pe,rows:J,onOpen:s,onMap:Y?()=>W(!0):void 0,...v}),a.jsx("p",{className:"vis-hidden",role:"status",children:ae.tone==="ok"?"":ae.text}),xe]})}function PK({anchorId:e,id:t,peers:n,onHold:r,onLet:s}){const o=w.useRef(null),{title:l,shown:u,rest:d}=lV(n),h=w.useCallback(()=>{const f=o.current,p=document.getElementById(e);if(!f||!p)return;const g=Wb(p.getBoundingClientRect(),{width:f.offsetWidth,height:f.offsetHeight},{width:window.innerWidth,height:window.innerHeight});f.style.top=`${g.top}px`,f.style.left=`${g.left}px`,f.style.maxHeight=g.maxHeight==null?"":`${g.maxHeight}px`,f.dataset.side=g.side},[e]);return w.useLayoutEffect(()=>{h()}),w.useEffect(()=>(window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}),[h]),Lt.createPortal(a.jsxs("div",{ref:o,id:t,className:"ap-peek ap-fold-peek",role:"tooltip",onPointerEnter:r,onPointerLeave:s,children:[a.jsx("p",{className:"ap-peek-title",children:l}),a.jsx("div",{className:"ap-peek-list",children:u.map(f=>a.jsxs("span",{className:"ap-peek-who ap-fold-who",children:[a.jsx("span",{className:"ap-fold-name",children:f.name}),a.jsx("span",{className:"ap-fold-state","data-tone":f.ready?"ok":f.warn?"warn":"idle",children:f.ready?f.headroom==null?"not read yet":`${f.headroom}% free`:f.why})]},f.key))}),d&&a.jsx("p",{className:"ap-peek-rest",children:d})]}),document.body)}function DK({peers:e,strained:t,armed:n,threshold:r,open:s,onToggle:o,order:l,choices:u,onOrder:d,allOpen:h,onToggleAll:f,held:p=!1}){const[g,v]=w.useState(!1),k=w.useRef(0);w.useEffect(()=>()=>window.clearTimeout(k.current),[]),w.useEffect(()=>{s&&(window.clearTimeout(k.current),v(!1))},[s]);const b=E=>{s||(window.clearTimeout(k.current),k.current=window.setTimeout(()=>v(!0),E))},x=()=>{window.clearTimeout(k.current),k.current=window.setTimeout(()=>v(!1),Y$)},N=()=>window.clearTimeout(k.current),S=()=>{window.clearTimeout(k.current),v(!1)},_=oV(e,{strained:t&&!s,armed:n,threshold:r});return a.jsxs("div",{className:"ap-rest",children:[a.jsxs("button",{type:"button",id:"ap-rest-entry",className:"ap-nav","aria-expanded":s,"aria-controls":s?"ap-rest-panel":void 0,"aria-describedby":g?"ap-rest-peek":void 0,onClick:()=>{S(),o()},onPointerEnter:E=>{E.pointerType==="mouse"&&b(K$)},onPointerLeave:x,onFocus:E=>{E.target.matches(":focus-visible")&&b(0)},onBlur:x,children:[a.jsxs("span",{className:"ap-nav-text",children:[a.jsx("span",{className:"ap-nav-name",children:"Other accounts"}),a.jsx("span",{className:"ap-nav-state","data-tone":_.tone,children:_.text})]}),a.jsx("svg",{className:"ap-nav-chev",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),g&&a.jsx(PK,{anchorId:"ap-rest-entry",id:"ap-rest-peek",peers:e,onHold:N,onLet:x}),s&&a.jsx(FK,{order:l,choices:u,onOrder:d,allOpen:h,onToggleAll:f,held:p})]})}function FK({order:e,choices:t,onOrder:n,allOpen:r,onToggleAll:s,held:o}){var d;const l=w.useRef(null);w.useLayoutEffect(()=>{const h=l.current,f=h==null?void 0:h.parentElement;if(!h||!f)return;const p=()=>f.style.setProperty("--rest-tools-w",`${Math.ceil(h.offsetWidth)}px`);if(p(),typeof ResizeObserver>"u")return;const g=new ResizeObserver(p);return g.observe(h),()=>{g.disconnect(),f.style.removeProperty("--rest-tools-w")}},[]);const u=((d=t.find(h=>h.id===e))==null?void 0:d.label)??"Slot";return a.jsxs("div",{className:"ap-rest-tools",ref:l,children:[a.jsxs("span",{className:"ap-rest-sort",children:[a.jsx("select",{value:e,onChange:h=>n(h.target.value),"aria-label":"Order of the other accounts",title:o?`${u} — held where it was while you are in the list`:u,"data-sorted":e===Vd?void 0:"","data-held":o?"":void 0,children:t.map(h=>a.jsx("option",{value:h.id,children:h.label},h.id))}),a.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M2.5 3.8 5 6.3l2.5-2.5"})})]}),a.jsx("button",{type:"button",className:"ap-rest-all","aria-label":"Expand every account","aria-pressed":r,"aria-controls":"ap-rest-list",title:r?"Collapse every account":"Expand every account",onClick:s,children:a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:r?"M2 7h10M7 1.5V5M5.2 3.2 7 5l1.8-1.8M7 12.5V9M5.2 10.8 7 9l1.8 1.8":"M2 7h10M7 1.5V5M5.2 3.3 7 1.5l1.8 1.8M7 12.5V9M5.2 10.7 7 12.5l1.8-1.8"})})})]})}async function BK(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const qK=1800;function UK({accounts:e,onClose:t,copyText:n}){const[r,s]=w.useState([]),[o,l]=w.useState(null),[u,d]=w.useState(!1),[h,f]=w.useState(null),[p,g]=w.useState(!1),[v,k]=w.useState(()=>Math.floor(Date.now()/1e3)),b=w.useRef(null),x=w.useRef(!1),N=ft(t,{focusRef:b}),S=md(o!=null,b),_=md(o==null,b);w.useEffect(()=>{if(!o)return;k(Math.floor(Date.now()/1e3));const $=window.setInterval(()=>k(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval($)},[o]);const E=U9(e),T=z9(e,r),A=T.length===e.length,R=$=>s(q=>W9(q,$)),B=w.useCallback(async()=>{const $=H9(T);if(!ir(x.current)||!$)return;x.current=!0,d(!0),f(null),g(!1);const q=await BK($).catch(()=>null);if(x.current=!1,d(!1),!(q!=null&&q.ok)){f(Wo(q,"the share could not be made"));return}l({blob:q.blob,expiresAt:q.expiresAt,shared:q.shared??[],failed:q.failed??[]})},[e,T]),P=o?z$(o.expiresAt,v):null,D=(P==null?void 0:P.tone)==="gone",O=(o==null?void 0:o.shared.length)??0,L=D?"This share has expired":O===1?"1 account, ready to paste":`${O} accounts, ready to paste`,z=O===1?"this is the password":`this is ${O} passwords`,M=o?D?L:`${L} — ${z}`:"";return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:a.jsxs("div",{ref:N,className:"modal sa-modal",onClick:$=>$.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Share accounts with another deck",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("h3",{children:"Share accounts"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body sa-body",children:[a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:M}),o?a.jsxs("div",{className:"sa-step",children:[a.jsx("h4",{children:L}),a.jsx("code",{className:"ap-share-blob",children:o.blob}),a.jsxs("div",{className:"ap-share-foot",children:[a.jsx("button",{type:"button",className:"ap-manage-btn",ref:b,onClick:async()=>{if(D){_(),S(),l(null),B();return}await n(o.blob)&&(g(!0),window.setTimeout(()=>g(!1),qK))},children:D?"make a new share":p?"copied":`copy ${O===1?"the share":"all "+O}`}),a.jsxs("span",{className:"ap-manage-hint",title:"This text is the sign-in for every account in it. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the logins themselves are in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign those accounts out and back in.",children:[a.jsx("span",{className:"ap-share-warn",children:z})," · ",a.jsx("span",{className:`ap-share-expiry ${P==null?void 0:P.tone}`,children:P==null?void 0:P.text})]})]}),o.failed.length>0&&a.jsxs("div",{className:"sa-failed",role:"alert",children:[a.jsx("p",{className:"sa-failed-head",children:o.failed.length===1?"One account is not in this bundle:":`${o.failed.length} accounts are not in this bundle:`}),a.jsx("ul",{className:"sa-list",children:o.failed.map($=>{var X;const q=!!($.email&&((X=$.detail)!=null&&X.includes($.email)));return a.jsxs("li",{children:[!q&&a.jsx("span",{className:"sa-who",children:$.email||`account ${$.num}`}),a.jsx("span",{className:"sa-why",children:$.detail||"could not be exported"})]},`${$.num}-${$.email}`)})})]}),a.jsx("p",{className:"sa-note",children:D?a.jsx(a.Fragment,{children:"Another deck will refuse this text now. Make a new one — the same accounts are still picked."}):a.jsxs(a.Fragment,{children:["Paste it into the other deck with ",a.jsx("strong",{children:"+"})," → ",a.jsx("strong",{children:"Paste a share"}),". Accounts it already holds are left exactly as they are."]})}),a.jsxs("div",{className:"sa-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>{_(),l(null),g(!1)},children:"Pick again"}),a.jsx("button",{type:"button",className:"btn primary",onClick:t,children:"Done"})]})]}):e.length===0?a.jsxs("div",{className:"sa-step",children:[a.jsx("h4",{children:"Nothing to share"}),a.jsxs("p",{className:"sa-note",children:["This deck is not holding any accounts right now. Sign one in with ",a.jsx("strong",{children:"+"}),", or wait — the panel is still reading the store."]}),a.jsx("div",{className:"sa-actions",children:a.jsx("button",{type:"button",className:"btn primary",ref:b,onClick:t,children:"Close"})})]}):a.jsxs("div",{className:"sa-step",children:[a.jsxs("h4",{children:["Which accounts go to the other ",bt,"?"]}),a.jsx("p",{className:`sa-count${T.length?"":" empty"}`,children:V9(T.length)}),a.jsx("ul",{className:"sa-list sa-pick",children:E.map($=>a.jsx("li",{children:a.jsxs("label",{className:"sa-row",children:[a.jsx("input",{type:"checkbox",checked:T.includes($.num),onChange:()=>R($.num)}),a.jsx("span",{className:"sa-who",children:$.label}),$.sub&&a.jsx("span",{className:"sa-sub",children:$.sub})]})},$.num))}),h&&a.jsx("p",{className:"aa-err",role:"alert",children:h}),a.jsxs("div",{className:"sa-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>s(A?e.map($=>$.num):[]),children:A?"Clear all":"Select all"}),a.jsx("button",{type:"button",className:"btn primary",ref:b,...Ir(u,!T.length),onClick:()=>{S(),B()},children:u?"making the share…":T.length===0?"Share":T.length===1?"Share 1 account":`Share ${T.length} accounts`})]})]})]})]})}),document.body)}function fI(e,t){var n;return!e.disabled&&!((n=di(e,t))!=null&&n.blocksSwitch)}function zK(e,t,n){return e.map(r=>{const s=di(r,t,n==null?void 0:n(r));return{key:Mr(r),name:r.alias??r.email??`account ${r.num}`,ready:fI(r,t),why:r.disabled?"held out":s!=null&&s.blocksSwitch?s.text:null,warn:(s==null?void 0:s.tone)==="warn",headroom:r.headroom}})}function WK(e,t){const n=Number(t);return(e==null?void 0:e.headroom)!=null&&Number.isFinite(n)&&100-e.headroom>=n}function HK(e){return(e==null?void 0:e.ok)===!0&&(e.enabled||e.external)}const pI="agent-dag.otherAccountsOrder",mI="agent-dag.otherAccountsOpen";function VK(){const e=et(pI);return typeof e=="string"&&e.length>0&&e.length<=64?e:Vd}function GK(e){Xe(pI,e)}function KK(){const e=et(mI);if(!e)return Ax;try{const t=JSON.parse(e);if(((t==null?void 0:t.mode)==="some"||(t==null?void 0:t.mode)==="all")&&Array.isArray(t.keys)&&t.keys.every(n=>typeof n=="string"))return{mode:t.mode,keys:t.keys.slice(0,200)}}catch{}return Ax}function YK(e){Xe(mI,JSON.stringify({mode:e.mode,keys:e.keys.filter(t=>!t.startsWith("slot:"))}))}function XK(){const[e,t]=w.useState(null),n=w.useRef(null),r=w.useCallback(l=>zd(n.current)?(n.current=l,t(l),!0):!1,[]),s=w.useCallback(()=>{n.current=null,t(null)},[]);return{busy:e,claim:r,release:s,pressProps:(l,u=!1)=>{const d=Qs(e,l);return{disabled:d.disabled,"aria-busy":d.busy||u}}}}const ZK=8e3,JK=1800,QK=4e3;function eY({claim:e,release:t,load:n,clearFailure:r,rescueFocus:s}){const[o,l]=w.useState(null),u=(o==null?void 0:o.num)??null,d=w.useRef(o);d.current=o;const[h,f]=w.useState(null),[p,g]=w.useState(""),[v,k]=w.useState(null),b=w.useRef(0);w.useEffect(()=>{if(v==null)return;const J=window.setTimeout(()=>k(null),QK);return()=>window.clearTimeout(J)},[v]);const[x,N]=w.useState(null),[S,_]=w.useState(!1),[E,T]=w.useState(null),[A,R]=w.useState(null),B=w.useCallback(async(J,V)=>{if(!e(V))return null;r(),f(null);try{const G=await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(J)}),K=await G.json().catch(()=>null);return K!=null&&K.ok||f({text:Wo(K,"command failed",G.status)}),K}catch{return f({text:"server unreachable"}),null}finally{t()}},[e,t,r]),P=w.useCallback(()=>{l(null),f(null),k(null),N(null),_(!1)},[]),D=(J,V="first")=>{P(),R(null),l({num:J,view:"menu",start:V})},O=w.useCallback(J=>{var K,Z;const V=d.current;if(!V||J!=null&&V.num!==J)return;const G=document.getElementById(`ap-menu-${V.num}`);(G!=null&&G.contains(document.activeElement)||Pr(((K=document.activeElement)==null?void 0:K.tagName)??null))&&((Z=document.getElementById(`ap-more-${V.num}`))==null||Z.focus()),P()},[P]),L=w.useCallback(J=>f(J),[]),z=(J,V)=>{g(V??""),f(null),l({num:J,view:"rename"})},M=J=>g(J),$=J=>{R(null),f(null),l({num:J,view:"move"})},q=J=>R(J),X=async J=>{var G;_(!1);const V=await B({action:"share",account:J},`share-${J}`);!(V!=null&&V.ok)||((G=d.current)==null?void 0:G.num)!==J||(N({num:J,blob:V.blob,expiresAt:V.expiresAt}),l({num:J,view:"share"}))},H=async J=>{await Wa(J)&&(_(!0),window.setTimeout(()=>_(!1),JK))},I=async(J,V)=>{const{commit:G,alias:K}=eV(p,V);if(G){const Z=await B({action:"alias",account:J,alias:K},`alias-${J}`);if(await n(!0),!(Z!=null&&Z.ok))return}O(J)},W=async(J,V)=>{var Z,ee,re;const G=await B({action:"move",account:J,slot:V},`move-${J}`),K=J9({menuFor:((Z=d.current)==null?void 0:Z.num)??null,shareFor:(x==null?void 0:x.num)??null},J,G);if(await n(!0),K){if(K.menuFor!=null){const me=document.getElementById(`ap-menu-${J}`),ae=document.getElementById(`ap-more-${K.menuFor}`);ae&&(me!=null&&me.contains(document.activeElement)||Pr(((ee=document.activeElement)==null?void 0:ee.tagName)??null))&&ae.focus()}((re=d.current)==null?void 0:re.num)===J&&P(),k(K.confirmRemove),K.shareFor==null&&(N(null),_(!1)),T(K.swapNote);const ue=K.swapNote;ue&&window.setTimeout(()=>T(me=>me===ue?null:me),ZK),R(null),s(K.menuFor)}return G};return{menu:o,menuFor:u,menuError:h,aliasDraft:p,confirmRemove:v,share:x,shareCopied:S,slotDraft:A,swapNote:E,showMenu:D,dropMenu:P,closeMenu:O,sayInMenu:L,startRename:z,typeAlias:M,doAlias:I,startMove:$,pickSlot:q,doSlot:async(J,V,G)=>{if(!G.sends){O(J);return}await W(J,V)},makeShare:X,copyShare:H,pressRemove:J=>{const V=Date.now(),G=ql({armedFor:v,target:J,armedAt:b.current,now:V,gapMs:Bl});if(G==="arm"){k(J),b.current=V;return}G!=="ignore"&&(k(null),B({action:"remove",account:J},`rm-${J}`).then(K=>{var Z;n(!0),K!=null&&K.ok&&(((Z=d.current)==null?void 0:Z.num)===J&&P(),s(null))}))}}}function tY(e,t){return!e||!t||t.some(n=>n.num===e.num&&n.active)?e:null}function nY({data:e,claim:t,release:n,load:r,sayFailure:s,clearFailure:o,sayInMenu:l,rescueFocus:u}){const[d,h]=w.useState(null),f=w.useCallback(async(g,v,k="panel")=>{if(!t(v))return null;const b=k==="menu"?l:s;b(null);try{const x=await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)}),N=await x.json().catch(()=>null);return N!=null&&N.ok||b({text:Rx(N,"command failed",x.status),raw:Wl(N)}),N}catch{return b({text:"server unreachable"}),null}finally{n()}},[t,n,l,s]);return w.useEffect(()=>{!(e!=null&&e.ok)||!e.accounts||h(g=>tY(g,e.accounts))},[e]),{switched:d,post:f,doSwitch:async(g,v)=>{if(t(`switch-${g}`)){o(),h(null);try{const b=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:g})})).json().catch(()=>null);b!=null&&b.ok?h({num:g,name:v}):s({text:Rx(b,"the switch failed"),raw:Wl(b),row:g}),await r(!0)}catch{s({text:"server unreachable",row:g})}finally{n(),u(g)}}}}}const rY=1800;function sY({auto:e,post:t,load:n}){var k;const[r,s]=w.useState(null),[o,l]=w.useState(!1),u=w.useRef(null),d=w.useRef(null),h=((k=e==null?void 0:e.settings["autoswitch.threshold"])==null?void 0:k.value)??"90",f=r??h,p=rV(f,h);return{threshold:h,thresholdPick:f,thresholdCtl:p,thresholdSaved:o,thresholdRef:u,thresholdSaveRef:d,proposeThreshold:b=>s(b),doThreshold:async(b,x)=>{if(x.sends){const N=await t({action:"setting",key:"autoswitch.threshold",value:b},"threshold");if(await n(!0),!(N!=null&&N.ok))return;s(null)}l(!0),window.setTimeout(()=>{var N;document.activeElement===d.current&&((N=u.current)==null||N.focus()),l(!1)},rY)}}}const aY=Object.freeze({text:"couldn't reach the deck server",reload:!0}),oY=Object.freeze({text:"still waiting on the deck server — claude-swap can be slow to answer",reload:!0});async function NS(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function iY(e){const t=e.find(r=>!r.ok);if(!t)return null;const n=Wl(t.body);return{text:Rx(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function jS(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 gI=15e3,lY=3e4;function cY(e){const[t,n]=w.useState(null),[r,s]=w.useState(null),[o,l]=w.useState(!1),[u,d]=w.useState(null),h=w.useRef(null),f=w.useCallback(async(v=!1)=>{v&&l(!0);const k=new AbortController,b=window.setTimeout(()=>k.abort(),lY);try{const[x,N]=await Promise.all([fetch(`/api/claude-accounts${v?"?refresh=1":""}`,{signal:k.signal}),fetch("/api/cswap-auto",{signal:k.signal})]);if(x.ok){const _=await x.json();n(_),e(_)}N.ok&&s(await N.json());const S=iY([await NS(x),await NS(N)]);d(_=>jS(_,S))}catch{d(x=>jS(x,k.signal.aborted?oY:aY))}finally{window.clearTimeout(b),v&&l(!1)}},[e]);w.useEffect(()=>(f(!0),h.current=window.setInterval(()=>f(!1),gI),()=>{h.current!=null&&window.clearInterval(h.current)}),[f]);const p=w.useCallback(v=>d(v),[]),g=w.useCallback(()=>d(null),[]);return{data:t,auto:r,reloading:o,failure:u,load:f,sayFailure:p,clearFailure:g}}const uY="#ap-rest-entry";function dY(e){return[`#${e}`,uY,...m$(null)]}function hY(e){const t=w.useRef(null),n=s=>{t.current=s.target.id||null},r=s=>{s.target.isConnected&&(t.current=null)};return w.useLayoutEffect(()=>{var o;const s=t.current;if(!(!s||!Pr(((o=document.activeElement)==null?void 0:o.tagName)??null)))for(const l of dY(s)){const u=document.querySelector(l);if(u){u.focus();return}}},[e]),{onFocus:n,onBlur:r}}function fY({onClose:e,leaving:t,onReport:n,onRoster:r}){var fn,Vr,jn;const{busy:s,claim:o,release:l,pressProps:u}=XK(),[d,h]=w.useState("accounts"),[f,p]=w.useState(!1),[g,v]=w.useState(null),k=w.useRef(g);k.current=g;const[b,x]=w.useState(!1),[N,S]=w.useState(!1),[_,E]=w.useState([]),[T,A]=w.useState(!1),[R,B]=w.useState(null),[P,D]=w.useState(KK),[O,L]=w.useState(VK),[z,M]=w.useState(null),[$,q]=w.useState(!1),X=w.useRef(r);X.current=r;const H=w.useCallback(we=>{var Be;D(We=>W7(We,we.accounts)),(Be=X.current)==null||Be.call(X,we)},[]),{data:I,auto:W,reloading:F,failure:Y,load:J,sayFailure:V,clearFailure:G}=cY(H),K=hY(I),Z=w.useCallback(we=>{window.requestAnimationFrame(()=>{var Be;if(Pr(((Be=document.activeElement)==null?void 0:Be.tagName)??null))for(const We of m$(we)){const en=document.querySelector(We);if(en){en.focus();return}}})},[]),ee=eY({claim:o,release:l,load:J,clearFailure:G,rescueFocus:Z}),{menu:re,menuFor:ue,swapNote:me,showMenu:ae,dropMenu:pe,closeMenu:xe,sayInMenu:se}=ee,{switched:ve,post:fe,doSwitch:he}=nY({data:I,claim:o,release:l,load:J,sayFailure:V,clearFailure:G,sayInMenu:se,rescueFocus:Z}),{threshold:_e,thresholdPick:Fe,thresholdCtl:Le,thresholdSaved:Ve,thresholdRef:le,thresholdSaveRef:je,proposeThreshold:$e,doThreshold:Oe}=sY({auto:W,post:fe,load:J}),ze=k$();w.useEffect(()=>{YK(P)},[P]),w.useEffect(()=>{GK(O)},[O]);const[nt,it]=w.useState(()=>new Set),At=w.useCallback(we=>it(new Set(we)),[]),Ue=we=>({noCopyWorksNearby:nt.has(aS([we])[0].key)}),Ze=(fn=I==null?void 0:I.accounts)==null?void 0:fn.find(we=>we.active),Je=Ze?di(Ze,ze,Ue(Ze)):null,rt=(I==null?void 0:I.accounts)??[],gt=Ze?rt.filter(we=>!we.active):[],Rt=$$(gt),yt=B7(O,gt),lt=Tx(F7(gt,yt,we=>fI(we,ze)),z),Qt=w.useRef(!1),Pt=w.useRef(!1),Dt=w.useRef(!1),Ft=w.useCallback(()=>{!Qt.current&&!Pt.current&&!Dt.current&&M(null)},[]),Kt=()=>M(we=>we??lt.map(Mr)),qr={onPointerEnter:()=>{Qt.current=!0,Kt()},onPointerLeave:()=>{Qt.current=!1,Ft()},onFocus:we=>{we.target.matches(":focus-visible")&&(Pt.current=!0,Kt())},onBlur:we=>{we.currentTarget.contains(we.relatedTarget)||(Pt.current=!1,Ft())}},Un=ue!=null&&gt.some(we=>we.num===ue)||g!=null&&gt.some(we=>we.num===g.num);w.useEffect(()=>{Dt.current=Un,Un||Ft()},[Un,Ft]);const Ur=$&&gt.length>0;w.useEffect(()=>{Ur||(Qt.current=Pt.current=Dt.current=!1,M(null))},[Ur]);const zr=w.useRef(!1);w.useEffect(()=>{zr.current&&gt.length===0&&Z(null),zr.current=gt.length>0},[gt.length,Z]);const zn=lt.length?rt.filter(we=>we.active):rt,mr=zK(lt,ze,Ue),Wn=WK(Ze,_e),Wr=HK(W),kn=we=>$&&lt.some(Be=>Be.num===we)?"ap-rest-list":"ap-scroll",ms=(we,Be="first")=>{ae(we,Be),v(null)},Nn=(we,Be)=>{pe(),v(We=>(We==null?void 0:We.anchor)===Be?null:{num:we,anchor:Be})},gr=w.useCallback((we=!1)=>{var We;const Be=k.current;we&&Be&&((We=document.getElementById(Be.anchor))==null||We.focus()),v(null)},[]),vt=()=>{pe(),v(null),h("lan")},yr=w.useRef(d);w.useEffect(()=>{yr.current!==d&&(yr.current=d,window.requestAnimationFrame(()=>{var we;(we=document.getElementById(d==="lan"?"ap-lan-back":"ap-lan-entry"))==null||we.focus()}))},[d]),w.useEffect(()=>{I!=null&&I.ok&&p(!0)},[I==null?void 0:I.ok]),w.useEffect(()=>{t&&(pe(),v(null))},[t,pe]),w.useEffect(()=>{re&&(I!=null&&I.accounts)&&!I.accounts.some(we=>we.num===re.num)&&pe(),g&&(I!=null&&I.accounts)&&!I.accounts.some(we=>we.num===g.num)&&v(null)},[I,re,g,pe]),w.useEffect(()=>{R==null||!(I!=null&&I.accounts)||I.accounts.some(we=>we.num===R.num)||(B(null),Z(null))},[I,R,Z]);const wr=a.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:a.jsx("path",{d:"M3.4 3.4l7.2 7.2M10.6 3.4l-7.2 7.2"})})}),Hr=we=>{const Be=I$(P,we),We=ue===we.num,en=(Y==null?void 0:Y.row)===we.num?Y:null,gs=(ve==null?void 0:ve.num)===we.num,vr=(me==null?void 0:me.at)===we.num?me:null,Vn=vr?rt.find(xr=>xr.num===vr.displaced):void 0,Qe=(g==null?void 0:g.anchor)===`ap-issue-${we.num}`;return a.jsx(G7,{a:we,nowSec:ze,lan:Ue(we),opened:Be,onToggleLanes:()=>D(xr=>U7(xr,we)),busy:s,pressProps:u,onSwitch:he,menuOpen:We,onOpenMenu:ms,onCloseMenu:xe,refusal:en,onDismissRefusal:()=>G(),switchedHere:gs,swapped:vr,displaced:Vn,issueExpanded:Qe,onOpenIssue:Nn,sortKey:we.active?null:D7(yt)},we.num)},Hn=I!=null&&I.ok&&(W!=null&&W.ok)?a.jsx(g9,{auto:W,threshold:_e,thresholdPick:Fe,thresholdCtl:Le,thresholdSaved:Ve,thresholdRef:le,thresholdSaveRef:je,proposeThreshold:$e,doThreshold:Oe,pressProps:u,post:fe,load:J}):null;return a.jsxs("aside",{className:`accounts-panel${t?" leaving":""}`,id:"accounts-panel","aria-label":"Claude accounts",onFocus:K.onFocus,onBlur:K.onBlur,children:[d==="accounts"&&a.jsx(Y7,{canShare:(((Vr=I==null?void 0:I.accounts)==null?void 0:Vr.length)??0)>0,canReport:(((jn=I==null?void 0:I.accounts)==null?void 0:jn.length)??0)>1||N,onAdd:()=>x(!0),onReport:()=>{E([...zn,...lt].map(Mr)),S(!0)},onShareSet:()=>A(!0),onReload:()=>J(!0),pressProps:u,reloading:F,closeButton:wr}),d==="accounts"&&a.jsx("div",{className:"ap-scroll",id:"ap-scroll",children:I==null?Y?a.jsxs("div",{className:"ap-empty",role:"alert",children:[a.jsx("span",{title:Y.raw||void 0,children:Y.text}),a.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",gI/1e3," seconds."]}),a.jsx("button",{type:"button",className:"ap-fix",...u("reload",F),onClick:()=>J(!0).then(()=>Z(null)),children:F?"trying…":"try again"})]}):a.jsx("div",{className:"ap-empty",children:"Checking…"}):I.ok?a.jsxs(a.Fragment,{children:[Ze&&(Je==null?void 0:Je.tone)==="warn"&&a.jsxs("div",{className:"ap-notice",children:[a.jsxs("button",{type:"button",id:"ap-notice",className:"ap-issue","data-tone":"warn","aria-haspopup":"dialog","aria-expanded":(g==null?void 0:g.anchor)==="ap-notice","aria-controls":(g==null?void 0:g.anchor)==="ap-notice"?"ap-issue-pop":void 0,onClick:()=>Nn(Ze.num,"ap-notice"),children:[a.jsx(Vb,{}),a.jsx("span",{className:"ap-issue-text",children:"Current account needs attention"})]}),Je.fix&&a.jsx("button",{type:"button",className:"ap-notice-fix",onClick:()=>x(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"Sign in"})]}),a.jsx("ul",{className:"ap-list",children:zn.map(Hr)}),lt.length>0&&a.jsx(DK,{peers:mr,strained:Wn,armed:Wr,threshold:W!=null&&W.ok?_e:null,open:$,onToggle:()=>q(we=>!we),order:yt,choices:Rt,onOrder:L,allOpen:O$(P,lt),onToggleAll:()=>D(we=>z7(we,lt)),held:z!=null}),lt.length>0&&$&&a.jsxs("div",{className:"ap-rest-panel",id:"ap-rest-panel",children:[a.jsx("ul",{className:"ap-list ap-others",id:"ap-rest-list",...qr,children:lt.map(Hr)}),Hn]}),lt.length===0&&Hn,Y&&Y.row==null&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",title:Y.raw||void 0,children:Y.text}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>G(),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),re&&(()=>{var Be;const we=(Be=I.accounts)==null?void 0:Be.find(We=>We.num===re.num);return we?a.jsx(sV,{a:we,accountMenu:ee,slots:(I.accounts??[]).map(We=>We.num),boundaryId:kn(we.num),nowSec:ze,busy:s,pressProps:u,rotating:!!(W!=null&&W.enabled||W!=null&&W.external),onProjects:()=>{B({num:we.num,name:we.alias??we.email??`account ${we.num}`}),xe(we.num)},onRotation:()=>fe({action:"account",account:we.num,enabled:we.disabled},`rot-${we.num}`,"menu").then(We=>{J(!0),We!=null&&We.ok&&xe(we.num)})}):null})(),g&&(()=>{var We;const we=(We=I.accounts)==null?void 0:We.find(en=>en.num===g.num),Be=we?di(we,ze,Ue(we)):null;return!we||!Be?null:a.jsx(C7,{anchorId:g.anchor,boundaryId:g.anchor==="ap-notice"?"ap-scroll":kn(we.num),issue:Be,who:we.alias??we.email??`account ${we.num}`,fetchedAt:we.fetchedAt,nowSec:ze,onClose:gr,onSignIn:()=>x(!0),onReport:n&&(()=>n({initialKind:Be.tone==="warn"?"bug":"other",initialBody:`Account issue: ${Be.text}. ${Be.hint}`}))})})()]}):a.jsx(K7,{data:I})}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:ve?`Now active: ${ve.name}`:""}),f&&a.jsx(LK,{accounts:aS((I==null?void 0:I.accounts)??[]),onChanged:()=>J(!0),onNoCopy:At,view:d==="lan",onOpen:vt,onBack:()=>h("accounts"),closeButton:wr}),b&&a.jsx(W$,{onClose:()=>x(!1),onChanged:()=>J(!0)}),T&&a.jsx(UK,{accounts:((I==null?void 0:I.accounts)??[]).map(we=>({num:we.num,email:we.email,alias:we.alias,org:we.org})),onClose:()=>A(!1),copyText:Wa}),R!=null&&(()=>{var Be;const we=(Be=I==null?void 0:I.accounts)==null?void 0:Be.find(We=>We.num===R.num);return I!=null&&I.accounts&&!we?null:a.jsx(_7,{num:R.num,name:we?we.alias??we.email??`account ${we.num}`:R.name,onClose:()=>B(null)})})(),N&&a.jsx(p9,{accounts:(I==null?void 0:I.accounts)??null,order:_,failed:Y!=null&&Y.reload?Y.text:null,nowSec:ze,onClose:()=>S(!1)})]})}const pY=16,mY=120;function gY(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 yY(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 wY(e,t){return gY(e,t,pY)?"over":yY(e,t)<=mY?"near":"far"}function vY(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 xY(){const[e,t]=w.useState(!1),[n,r]=w.useState(""),[s,o]=w.useState("far"),l=w.useRef(null),u=Fu(e,140),d=w.useCallback(g=>{var b;const v=(b=l.current)==null?void 0:b.getBoundingClientRect(),k=vY(g);return v&&k?wY(k,v):"far"},[]),h=w.useCallback(g=>{g!==null&&(r(g),t(!0)),o("far")},[]),f=w.useCallback(g=>{o(d(g))},[d]),p=w.useCallback((g,v)=>{const k=v&&d(g)==="over";return t(!1),k},[d]);return{trashDragging:e,trashLabel:n,trashState:s,trashZoneRef:l,trashPhase:u,beginTrashDrag:h,trackTrashDrag:f,endTrashDrag:p}}const bY=420;function kY(){const[e,t]=w.useState(!1),n=w.useRef(null),r=w.useCallback(()=>{n.current&&(window.clearTimeout(n.current),n.current=null),t(!1)},[]),s=w.useCallback(o=>{o.length!==0&&queueMicrotask(()=>{t(!0),n.current&&window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!1),bY+80)})},[]);return w.useEffect(()=>()=>{n.current&&window.clearTimeout(n.current)},[]),{bubbling:e,endBubble:r,onBubble:s}}const n0=11,yI=7.2,wI=6.6,NY={width:104,height:48},SS={width:96,height:44},vI={width:220,height:103};function jY(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)?vI:{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 SY(e,t,n=vI){if(!Number.isFinite(t)||t<=0)return e??"detail";const r=n0*t;return e==="detail"?r>=wI?"detail":Sp(n,t,SS)?"compact":"overview":r>=yI?"detail":e==="compact"?Sp(n,t,SS)?"compact":"overview":Sp(n,t,NY)?"compact":"overview"}const _Y=yI/n0,EY=wI/n0;function CY(e,t){return e>=_Y?e:Math.max(e,Math.min(t,EY-.001))}const TY=.8,AY=1;function RY({stateRef:e,measuredRef:t,measuredVersionRef:n,canvasRef:r}){const[s,o]=w.useState("detail"),l=w.useRef(null),u=w.useRef(null),d=w.useCallback(()=>{var v;const f=n.current;if(((v=u.current)==null?void 0:v.version)===f)return u.current.card;const p=[];for(const k of e.current.agents.keys()){const b=t.current.get(k);b&&p.push(b)}const g=jY(p);return u.current={version:f,card:g},g},[]),h=w.useCallback(f=>{var g;const p=SY(l.current,f,d());return p===l.current?null:(l.current=p,(g=r.current)==null||g.setAttribute("data-lod",p),o(p),p)},[d,r]);return{lod:s,lodRef:l,applyZoom:h}}const MY=40,$Y=120;function IY(e,t){let n=null,r=0,s=Number.NEGATIVE_INFINITY;const o=()=>{n=null,s=t.now(),e()},l=()=>{n!=null&&(t.clearTimeout(n),n=null)},u=(d,h,f)=>{if(n!=null){if(r<=d)return;l()}const p=Math.min(f,Math.max(0,d-h));r=d,n=t.setTimeout(o,p)};return{live(d=MY){const h=t.now(),f=Math.max(s+d,h);if(f<=h){l(),o();return}u(f,h,d)},replay(d=$Y){l(),r=t.now()+d,n=t.setTimeout(o,d)},flush(){l(),o()},cancel(){l()}}}const OY=1024*1024,_S=5,xI=.8,qx=24,LY="agent-dag.soundCustom.done",PY="agent-dag.soundCustom.needs-input",El={done:LY,"needs-input":PY};function Vl(e){if(e.kind!=="audio")return e;const{bytes:t,...n}=e;return n}function ES(e){return!e||!/^[a-zA-Z0-9._-]{1,96}$/.test(e)?null:e}function DY(e){return{done:ES(e(El.done)),"needs-input":ES(e(El["needs-input"]))}}function FY(e,t){return{done:e.done===t?null:e.done,"needs-input":e["needs-input"]===t?null:e["needs-input"]}}function BY(e){return e.done&&e.done===e["needs-input"]?e.done:null}const qY={wav:"audio/wav",wave:"audio/wav",mp3:"audio/mpeg",ogg:"audio/ogg",oga:"audio/ogg",webm:"audio/webm",m4a:"audio/mp4",mp4:"audio/mp4"},bI=new Set(["audio/wav","audio/x-wav","audio/mpeg","audio/mp3","audio/ogg","audio/webm","audio/mp4"]);function kI(e,t){const n=t.toLowerCase().split(";")[0].trim();if(bI.has(n))return n;const r=e.toLowerCase().split(".").pop()??"";return qY[r]??n}function CS(e,t){const n=kI(e.name,e.type);if(!bI.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>OY)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>_S)return`Audio must be ${_S} seconds or shorter.`}return null}function Ux(e){return e>=qx?`There are already ${qx} custom sounds. Delete one first.`:null}function UY(e,t){const n=e.indexOf(t);return n<0?null:e[n+1]??e[n-1]??null}function zY(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,xI/t)}function NI(){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 WY(e,t,n=NI()){var h;const r=((h=e.name)==null?void 0:h.trim())||"Custom sound",s=CS({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=CS({name:r,type:e.type,size:e.size},l.duration);if(u)throw new Error(u);const d=Array.from({length:l.numberOfChannels},(f,p)=>l.getChannelData(p));return{id:n,name:r.replace(/\.(wav|wave|mp3|ogg|oga|webm|m4a|mp4)$/i,"")||"Custom sound",kind:"audio",mime:kI(r,e.type),duration:l.duration,normalizationGain:zY(d),bytes:o}}function HY(e,t=NI()){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 VY="ccdeck-notification-audio",GY=2,ur="assets",Dr="summaries";function rc(){return typeof window<"u"?window.ccdeckNotificationAudio??null:null}function KY(){return new Promise((e,t)=>{const n=indexedDB.open(VY,GY);n.onupgradeneeded=r=>{const s=n.result,o=s.objectStoreNames.contains(ur)?n.transaction.objectStore(ur):s.createObjectStore(ur,{keyPath:"id"});if(s.objectStoreNames.contains(Dr))return;const l=s.createObjectStore(Dr,{keyPath:"id"});if(r.oldVersion<1)return;const u=o.openCursor();u.onsuccess=()=>{const d=u.result;d&&(l.put(Vl(d.value)),d.continue())}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??new Error("Could not open local audio storage."))})}async function sc(e,t,n){const r=await KY();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 YY(){const e=rc();return e?e.list():typeof indexedDB>"u"?[]:await sc([Dr],"readonly",t=>t.objectStore(Dr).getAll())??[]}async function XY(e){const t=rc();return t?t.get(e):typeof indexedDB>"u"?null:await sc([ur],"readonly",n=>n.objectStore(ur).get(e))??null}async function TS(e){const t=rc();if(t){await t.put(e);return}if(typeof indexedDB>"u")throw new Error("Local audio storage is unavailable in this browser.");await sc([ur,Dr],"readwrite",n=>{n.objectStore(ur).put(e),n.objectStore(Dr).put(Vl(e))})}async function ZY(e,t){const n=rc();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 sc([ur,Dr],"readwrite",r=>{const s=r.objectStore(ur),o=s.get(e);o.onsuccess=()=>{const l=o.result;if(!l)return;const u={...l,name:t};s.put(u),r.objectStore(Dr).put(Vl(u))}})}async function JY(e){const t=rc();if(t){await t.remove(e);return}typeof indexedDB>"u"||await sc([ur,Dr],"readwrite",n=>{n.objectStore(ur).delete(e),n.objectStore(Dr).delete(e)})}const zu=["done","needs-input"],QY=[{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}]}],eX=[{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}]}],r0={done:QY,"needs-input":eX},vn="two";function zx(e,t){const n=r0[e];return n.find(r=>r.id===t)??n.find(r=>r.id===vn)??n[0]}function jI(e,t){return r0[e].some(r=>r.id===t)?t:vn}zx("done",vn).notes,zx("needs-input",vn).notes;const AS=.04,SI=.24,Wu=0,gd=100,Wx=5,qa=50;function hi(e){if(!Number.isFinite(e))return qa;const t=Math.round(e/Wx)*Wx;return Math.min(gd,Math.max(Wu,t))}function _I(e){if(e==null)return qa;const t=e.trim();return/^-?\d+(\.\d+)?$/.test(t)?hi(Number(t)):qa}function s0(e){const t=hi(e),n=AS+(SI-AS)*(t/gd);return Math.round(n*1e4)/1e4}function tX(e,t){const n=t.trim,r=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(s0(e)*r*1e4)/1e4}const nX=.012,RS=1e-4;function rX(e){return Math.min(1,s0(e)/SI)}function sX(e,t){const n=e*(s0(t)/xI);return Math.max(1e-4,n)}const aX=160,oX="agent-dag.soundLevel.done",iX="agent-dag.soundLevel.needs-input",lX="agent-dag.soundFigure.done",cX="agent-dag.soundFigure.needs-input",EI={done:oX,"needs-input":iX},yd={done:lX,"needs-input":cX},Hx={done:{level:qa,figure:vn},"needs-input":{level:qa,figure:vn}};function uX(e){const t=n=>({level:_I(e(EI[n])),figure:jI(n,e(yd[n]))});return{done:t("done"),"needs-input":t("needs-input")}}function dX(e,t){return(e??Hx)[t]??Hx[t]}const hX={Stop:"done",Notification:"needs-input"};function fX(e,t){var r;if(t)return null;const n=(r=e==null?void 0:e.payload)==null?void 0:r.hook_event_name;return typeof n!="string"?null:Ot(hX,n)??null}const pX=6,mX="ccdeck-tabs";function gX(e){return e>=pX}function yX(e,t,n){const r=s=>{const o=s.data;(o==null?void 0:o.kind)==="who"&&o.from!==t&&e.postMessage({kind:"here",from:t,to:o.from,streaming:n()})};return e.addEventListener("message",r),{ask(s,o=(l,u)=>setTimeout(l,u)){return new Promise(l=>{const u=new Set,d=h=>{const f=h.data;(f==null?void 0:f.kind)==="here"&&f.to===t&&f.streaming&&u.add(f.from)};e.addEventListener("message",d),e.postMessage({kind:"who",from:t}),o(()=>{e.removeEventListener("message",d),l(u.size)},s)})},leave(){var s;e.removeEventListener("message",r),(s=e.close)==null||s.call(e)}}}function wX({stateRef:e,rerender:t,pauseGate:n,chimesRef:r,desktopUpdateRef:s}){const[o,l]=w.useState(!1),[u,d]=w.useState(!1),[h,f]=w.useState(!1),p=w.useRef(!0),[g,v]=w.useState(null);return w.useEffect(()=>{const k=new EventSource("/events"),b=IY(t,{now:()=>Date.now(),setTimeout:(_,E)=>window.setTimeout(_,E),clearTimeout:_=>window.clearTimeout(_)});let x=!1;const N=typeof BroadcastChannel=="function"?yX(new BroadcastChannel(mX),Math.random().toString(36).slice(2),()=>x):null,S=window.setInterval(()=>{x||!N||N.ask(600).then(_=>{x||d(gX(_))})},3e3);return k.addEventListener("open",()=>{l(!0),f(!0)}),k.addEventListener("error",()=>{l(!1),v(null)}),k.addEventListener("open",()=>{x=!0,d(!1)}),k.addEventListener("error",()=>{x=!1}),k.addEventListener("replay-end",()=>{p.current=!1,b.flush(),v(Date.now())}),k.addEventListener("desktop-update",_=>s.current(_.data)),k.addEventListener("hook",_=>{var E;try{const T=JSON.parse(_.data);if(!n.accept(T))return;e.current=NM(e.current,T);const A=T.replay===!0||p.current||Date.now()-T.receivedAt>3e4;A?b.replay():b.live();const R=fX(T,A);R&&((E=r.current)==null||E.play(R))}catch{}}),()=>{k.close(),b.cancel(),window.clearInterval(S),N==null||N.leave()}},[t]),{live:o,tabCapped:u,everConnected:h,liveSince:g}}const vX=200,xX=5*6e4,bX=6,kX=2*6e4;function Ru(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function NX(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 jX(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`),n.kind==="root"&&t.add(Ob(n.id));return t}function SX(e){const t=new Set;for(const n of e)t.add(n.id),n.kind==="root"&&t.add(Ob(n.id));return t}function _X(e,t){let n=vq(e,t,QN);xq(e,t,QN)&&(n=!0);const r=[],s=o=>{r.push(o)};return gq(e,t,vX,xX,s)&&(n=!0),yq(e,t,bX,kX,s)&&(n=!0),{changed:n,forgotten:r}}function EX(e,t,n){if(!n)return{ids:new Set([t]),primary:t};const r=new Set(e.ids);if(!r.has(t))return r.add(t),{ids:r,primary:t};if(r.delete(t),e.primary!==t)return{ids:r,primary:e.primary};let s=null;for(const o of r)s=o;return{ids:r,primary:s}}function CX(e,t){const[n,r]=w.useState(()=>({ids:new Set,primary:null})),{ids:s,primary:o}=n,l=w.useCallback((h,f,p=!f)=>{r(g=>EX(g,h,f)),!f&&p&&t(!0)},[]),u=w.useCallback(()=>{r({ids:new Set,primary:null})},[]),d=w.useCallback(()=>{r(h=>{const f=NX(h.ids,e.current.agents),p=h.primary!=null&&!e.current.agents.has(h.primary)?null:h.primary;return f===h.ids&&p===h.primary?h:{ids:f,primary:p}})},[e]);return{selectedIds:s,primarySelectedId:o,selectAgent:l,clearSelection:u,pruneSelectionToBoard:d}}function TX({stateRef:e,rerender:t,pruneSelectionToBoard:n,setContextFor:r,setSummaryFor:s}){const[o,l]=w.useState(Date.now());return w.useEffect(()=>{const u=setInterval(()=>{const d=Date.now();l(d);const{changed:h,forgotten:f}=_X(e.current,d);f.length>0&&fetch("/api/forget",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ids:f})}).catch(()=>{}),n(),r(p=>p!=null&&!e.current.agents.has(p)?null:p),s(p=>p!=null&&!e.current.agents.has(p)?null:p),h&&t()},250);return()=>clearInterval(u)},[t]),o}function a0(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 _p,MS;function AX(){if(MS)return _p;MS=1;function e(){this.__data__=[],this.size=0}return _p=e,_p}var Ep,$S;function xi(){if($S)return Ep;$S=1;function e(t,n){return t===n||t!==t&&n!==n}return Ep=e,Ep}var Cp,IS;function Zd(){if(IS)return Cp;IS=1;var e=xi();function t(n,r){for(var s=n.length;s--;)if(e(n[s][0],r))return s;return-1}return Cp=t,Cp}var Tp,OS;function RX(){if(OS)return Tp;OS=1;var e=Zd(),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 Tp=r,Tp}var Ap,LS;function MX(){if(LS)return Ap;LS=1;var e=Zd();function t(n){var r=this.__data__,s=e(r,n);return s<0?void 0:r[s][1]}return Ap=t,Ap}var Rp,PS;function $X(){if(PS)return Rp;PS=1;var e=Zd();function t(n){return e(this.__data__,n)>-1}return Rp=t,Rp}var Mp,DS;function IX(){if(DS)return Mp;DS=1;var e=Zd();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 Mp=t,Mp}var $p,FS;function Jd(){if(FS)return $p;FS=1;var e=AX(),t=RX(),n=MX(),r=$X(),s=IX();function o(l){var u=-1,d=l==null?0:l.length;for(this.clear();++u<d;){var h=l[u];this.set(h[0],h[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=r,o.prototype.set=s,$p=o,$p}var Ip,BS;function OX(){if(BS)return Ip;BS=1;var e=Jd();function t(){this.__data__=new e,this.size=0}return Ip=t,Ip}var Op,qS;function LX(){if(qS)return Op;qS=1;function e(t){var n=this.__data__,r=n.delete(t);return this.size=n.size,r}return Op=e,Op}var Lp,US;function PX(){if(US)return Lp;US=1;function e(t){return this.__data__.get(t)}return Lp=e,Lp}var Pp,zS;function DX(){if(zS)return Pp;zS=1;function e(t){return this.__data__.has(t)}return Pp=e,Pp}var Dp,WS;function CI(){if(WS)return Dp;WS=1;var e=typeof lu=="object"&&lu&&lu.Object===Object&&lu;return Dp=e,Dp}var Fp,HS;function pr(){if(HS)return Fp;HS=1;var e=CI(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Fp=n,Fp}var Bp,VS;function bi(){if(VS)return Bp;VS=1;var e=pr(),t=e.Symbol;return Bp=t,Bp}var qp,GS;function FX(){if(GS)return qp;GS=1;var e=bi(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,s=e?e.toStringTag:void 0;function o(l){var u=n.call(l,s),d=l[s];try{l[s]=void 0;var h=!0}catch{}var f=r.call(l);return h&&(u?l[s]=d:delete l[s]),f}return qp=o,qp}var Up,KS;function BX(){if(KS)return Up;KS=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return Up=n,Up}var zp,YS;function Ha(){if(YS)return zp;YS=1;var e=bi(),t=FX(),n=BX(),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 zp=l,zp}var Wp,XS;function Bn(){if(XS)return Wp;XS=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return Wp=e,Wp}var Hp,ZS;function ac(){if(ZS)return Hp;ZS=1;var e=Ha(),t=Bn(),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 Hp=l,Hp}var Vp,JS;function qX(){if(JS)return Vp;JS=1;var e=pr(),t=e["__core-js_shared__"];return Vp=t,Vp}var Gp,QS;function UX(){if(QS)return Gp;QS=1;var e=qX(),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 Gp=n,Gp}var Kp,e_;function TI(){if(e_)return Kp;e_=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 Kp=n,Kp}var Yp,t_;function zX(){if(t_)return Yp;t_=1;var e=ac(),t=UX(),n=Bn(),r=TI(),s=/[\\^$.*+?()[\]{}|]/g,o=/^\[object .+?Constructor\]$/,l=Function.prototype,u=Object.prototype,d=l.toString,h=u.hasOwnProperty,f=RegExp("^"+d.call(h).replace(s,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function p(g){if(!n(g)||t(g))return!1;var v=e(g)?f:o;return v.test(r(g))}return Yp=p,Yp}var Xp,n_;function WX(){if(n_)return Xp;n_=1;function e(t,n){return t==null?void 0:t[n]}return Xp=e,Xp}var Zp,r_;function Va(){if(r_)return Zp;r_=1;var e=zX(),t=WX();function n(r,s){var o=t(r,s);return e(o)?o:void 0}return Zp=n,Zp}var Jp,s_;function o0(){if(s_)return Jp;s_=1;var e=Va(),t=pr(),n=e(t,"Map");return Jp=n,Jp}var Qp,a_;function Qd(){if(a_)return Qp;a_=1;var e=Va(),t=e(Object,"create");return Qp=t,Qp}var em,o_;function HX(){if(o_)return em;o_=1;var e=Qd();function t(){this.__data__=e?e(null):{},this.size=0}return em=t,em}var tm,i_;function VX(){if(i_)return tm;i_=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return tm=e,tm}var nm,l_;function GX(){if(l_)return nm;l_=1;var e=Qd(),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 nm=s,nm}var rm,c_;function KX(){if(c_)return rm;c_=1;var e=Qd(),t=Object.prototype,n=t.hasOwnProperty;function r(s){var o=this.__data__;return e?o[s]!==void 0:n.call(o,s)}return rm=r,rm}var sm,u_;function YX(){if(u_)return sm;u_=1;var e=Qd(),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 sm=n,sm}var am,d_;function XX(){if(d_)return am;d_=1;var e=HX(),t=VX(),n=GX(),r=KX(),s=YX();function o(l){var u=-1,d=l==null?0:l.length;for(this.clear();++u<d;){var h=l[u];this.set(h[0],h[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=r,o.prototype.set=s,am=o,am}var om,h_;function ZX(){if(h_)return om;h_=1;var e=XX(),t=Jd(),n=o0();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return om=r,om}var im,f_;function JX(){if(f_)return im;f_=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return im=e,im}var lm,p_;function eh(){if(p_)return lm;p_=1;var e=JX();function t(n,r){var s=n.__data__;return e(r)?s[typeof r=="string"?"string":"hash"]:s.map}return lm=t,lm}var cm,m_;function QX(){if(m_)return cm;m_=1;var e=eh();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return cm=t,cm}var um,g_;function eZ(){if(g_)return um;g_=1;var e=eh();function t(n){return e(this,n).get(n)}return um=t,um}var dm,y_;function tZ(){if(y_)return dm;y_=1;var e=eh();function t(n){return e(this,n).has(n)}return dm=t,dm}var hm,w_;function nZ(){if(w_)return hm;w_=1;var e=eh();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 hm=t,hm}var fm,v_;function i0(){if(v_)return fm;v_=1;var e=ZX(),t=QX(),n=eZ(),r=tZ(),s=nZ();function o(l){var u=-1,d=l==null?0:l.length;for(this.clear();++u<d;){var h=l[u];this.set(h[0],h[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=r,o.prototype.set=s,fm=o,fm}var pm,x_;function rZ(){if(x_)return pm;x_=1;var e=Jd(),t=o0(),n=i0(),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 pm=s,pm}var mm,b_;function th(){if(b_)return mm;b_=1;var e=Jd(),t=OX(),n=LX(),r=PX(),s=DX(),o=rZ();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,mm=l,mm}var gm,k_;function l0(){if(k_)return gm;k_=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 gm=e,gm}var ym,N_;function AI(){if(N_)return ym;N_=1;var e=Va(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return ym=t,ym}var wm,j_;function nh(){if(j_)return wm;j_=1;var e=AI();function t(n,r,s){r=="__proto__"&&e?e(n,r,{configurable:!0,enumerable:!0,value:s,writable:!0}):n[r]=s}return wm=t,wm}var vm,S_;function rh(){if(S_)return vm;S_=1;var e=nh(),t=xi(),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 vm=s,vm}var xm,__;function oc(){if(__)return xm;__=1;var e=rh(),t=nh();function n(r,s,o,l){var u=!o;o||(o={});for(var d=-1,h=s.length;++d<h;){var f=s[d],p=l?l(o[f],r[f],f,o,r):void 0;p===void 0&&(p=r[f]),u?t(o,f,p):e(o,f,p)}return o}return xm=n,xm}var bm,E_;function sZ(){if(E_)return bm;E_=1;function e(t,n){for(var r=-1,s=Array(t);++r<t;)s[r]=n(r);return s}return bm=e,bm}var km,C_;function Br(){if(C_)return km;C_=1;function e(t){return t!=null&&typeof t=="object"}return km=e,km}var Nm,T_;function aZ(){if(T_)return Nm;T_=1;var e=Ha(),t=Br(),n="[object Arguments]";function r(s){return t(s)&&e(s)==n}return Nm=r,Nm}var jm,A_;function ic(){if(A_)return jm;A_=1;var e=aZ(),t=Br(),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 jm=o,jm}var Sm,R_;function Nt(){if(R_)return Sm;R_=1;var e=Array.isArray;return Sm=e,Sm}var xl={exports:{}},_m,M_;function oZ(){if(M_)return _m;M_=1;function e(){return!1}return _m=e,_m}xl.exports;var $_;function ki(){return $_||($_=1,(function(e,t){var n=pr(),r=oZ(),s=t&&!t.nodeType&&t,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,u=l?n.Buffer:void 0,d=u?u.isBuffer:void 0,h=d||r;e.exports=h})(xl,xl.exports)),xl.exports}var Em,I_;function sh(){if(I_)return Em;I_=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 Em=n,Em}var Cm,O_;function c0(){if(O_)return Cm;O_=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return Cm=t,Cm}var Tm,L_;function iZ(){if(L_)return Tm;L_=1;var e=Ha(),t=c0(),n=Br(),r="[object Arguments]",s="[object Array]",o="[object Boolean]",l="[object Date]",u="[object Error]",d="[object Function]",h="[object Map]",f="[object Number]",p="[object Object]",g="[object RegExp]",v="[object Set]",k="[object String]",b="[object WeakMap]",x="[object ArrayBuffer]",N="[object DataView]",S="[object Float32Array]",_="[object Float64Array]",E="[object Int8Array]",T="[object Int16Array]",A="[object Int32Array]",R="[object Uint8Array]",B="[object Uint8ClampedArray]",P="[object Uint16Array]",D="[object Uint32Array]",O={};O[S]=O[_]=O[E]=O[T]=O[A]=O[R]=O[B]=O[P]=O[D]=!0,O[r]=O[s]=O[x]=O[o]=O[N]=O[l]=O[u]=O[d]=O[h]=O[f]=O[p]=O[g]=O[v]=O[k]=O[b]=!1;function L(z){return n(z)&&t(z.length)&&!!O[e(z)]}return Tm=L,Tm}var Am,P_;function ah(){if(P_)return Am;P_=1;function e(t){return function(n){return t(n)}}return Am=e,Am}var bl={exports:{}};bl.exports;var D_;function u0(){return D_||(D_=1,(function(e,t){var n=CI(),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})(bl,bl.exports)),bl.exports}var Rm,F_;function lc(){if(F_)return Rm;F_=1;var e=iZ(),t=ah(),n=u0(),r=n&&n.isTypedArray,s=r?t(r):e;return Rm=s,Rm}var Mm,B_;function RI(){if(B_)return Mm;B_=1;var e=sZ(),t=ic(),n=Nt(),r=ki(),s=sh(),o=lc(),l=Object.prototype,u=l.hasOwnProperty;function d(h,f){var p=n(h),g=!p&&t(h),v=!p&&!g&&r(h),k=!p&&!g&&!v&&o(h),b=p||g||v||k,x=b?e(h.length,String):[],N=x.length;for(var S in h)(f||u.call(h,S))&&!(b&&(S=="length"||v&&(S=="offset"||S=="parent")||k&&(S=="buffer"||S=="byteLength"||S=="byteOffset")||s(S,N)))&&x.push(S);return x}return Mm=d,Mm}var $m,q_;function oh(){if(q_)return $m;q_=1;var e=Object.prototype;function t(n){var r=n&&n.constructor,s=typeof r=="function"&&r.prototype||e;return n===s}return $m=t,$m}var Im,U_;function MI(){if(U_)return Im;U_=1;function e(t,n){return function(r){return t(n(r))}}return Im=e,Im}var Om,z_;function lZ(){if(z_)return Om;z_=1;var e=MI(),t=e(Object.keys,Object);return Om=t,Om}var Lm,W_;function d0(){if(W_)return Lm;W_=1;var e=oh(),t=lZ(),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 Lm=s,Lm}var Pm,H_;function fs(){if(H_)return Pm;H_=1;var e=ac(),t=c0();function n(r){return r!=null&&t(r.length)&&!e(r)}return Pm=n,Pm}var Dm,V_;function na(){if(V_)return Dm;V_=1;var e=RI(),t=d0(),n=fs();function r(s){return n(s)?e(s):t(s)}return Dm=r,Dm}var Fm,G_;function cZ(){if(G_)return Fm;G_=1;var e=oc(),t=na();function n(r,s){return r&&e(s,t(s),r)}return Fm=n,Fm}var Bm,K_;function uZ(){if(K_)return Bm;K_=1;function e(t){var n=[];if(t!=null)for(var r in Object(t))n.push(r);return n}return Bm=e,Bm}var qm,Y_;function dZ(){if(Y_)return qm;Y_=1;var e=Bn(),t=oh(),n=uZ(),r=Object.prototype,s=r.hasOwnProperty;function o(l){if(!e(l))return n(l);var u=t(l),d=[];for(var h in l)h=="constructor"&&(u||!s.call(l,h))||d.push(h);return d}return qm=o,qm}var Um,X_;function Ga(){if(X_)return Um;X_=1;var e=RI(),t=dZ(),n=fs();function r(s){return n(s)?e(s,!0):t(s)}return Um=r,Um}var zm,Z_;function hZ(){if(Z_)return zm;Z_=1;var e=oc(),t=Ga();function n(r,s){return r&&e(s,t(s),r)}return zm=n,zm}var kl={exports:{}};kl.exports;var J_;function $I(){return J_||(J_=1,(function(e,t){var n=pr(),r=t&&!t.nodeType&&t,s=r&&!0&&e&&!e.nodeType&&e,o=s&&s.exports===r,l=o?n.Buffer:void 0,u=l?l.allocUnsafe:void 0;function d(h,f){if(f)return h.slice();var p=h.length,g=u?u(p):new h.constructor(p);return h.copy(g),g}e.exports=d})(kl,kl.exports)),kl.exports}var Wm,Q_;function II(){if(Q_)return Wm;Q_=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 Wm=e,Wm}var Hm,eE;function OI(){if(eE)return Hm;eE=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 Hm=e,Hm}var Vm,tE;function LI(){if(tE)return Vm;tE=1;function e(){return[]}return Vm=e,Vm}var Gm,nE;function h0(){if(nE)return Gm;nE=1;var e=OI(),t=LI(),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 Gm=o,Gm}var Km,rE;function fZ(){if(rE)return Km;rE=1;var e=oc(),t=h0();function n(r,s){return e(r,t(r),s)}return Km=n,Km}var Ym,sE;function f0(){if(sE)return Ym;sE=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 Ym=e,Ym}var Xm,aE;function ih(){if(aE)return Xm;aE=1;var e=MI(),t=e(Object.getPrototypeOf,Object);return Xm=t,Xm}var Zm,oE;function PI(){if(oE)return Zm;oE=1;var e=f0(),t=ih(),n=h0(),r=LI(),s=Object.getOwnPropertySymbols,o=s?function(l){for(var u=[];l;)e(u,n(l)),l=t(l);return u}:r;return Zm=o,Zm}var Jm,iE;function pZ(){if(iE)return Jm;iE=1;var e=oc(),t=PI();function n(r,s){return e(r,t(r),s)}return Jm=n,Jm}var Qm,lE;function DI(){if(lE)return Qm;lE=1;var e=f0(),t=Nt();function n(r,s,o){var l=s(r);return t(r)?l:e(l,o(r))}return Qm=n,Qm}var eg,cE;function FI(){if(cE)return eg;cE=1;var e=DI(),t=h0(),n=na();function r(s){return e(s,n,t)}return eg=r,eg}var tg,uE;function mZ(){if(uE)return tg;uE=1;var e=DI(),t=PI(),n=Ga();function r(s){return e(s,n,t)}return tg=r,tg}var ng,dE;function gZ(){if(dE)return ng;dE=1;var e=Va(),t=pr(),n=e(t,"DataView");return ng=n,ng}var rg,hE;function yZ(){if(hE)return rg;hE=1;var e=Va(),t=pr(),n=e(t,"Promise");return rg=n,rg}var sg,fE;function BI(){if(fE)return sg;fE=1;var e=Va(),t=pr(),n=e(t,"Set");return sg=n,sg}var ag,pE;function wZ(){if(pE)return ag;pE=1;var e=Va(),t=pr(),n=e(t,"WeakMap");return ag=n,ag}var og,mE;function Ni(){if(mE)return og;mE=1;var e=gZ(),t=o0(),n=yZ(),r=BI(),s=wZ(),o=Ha(),l=TI(),u="[object Map]",d="[object Object]",h="[object Promise]",f="[object Set]",p="[object WeakMap]",g="[object DataView]",v=l(e),k=l(t),b=l(n),x=l(r),N=l(s),S=o;return(e&&S(new e(new ArrayBuffer(1)))!=g||t&&S(new t)!=u||n&&S(n.resolve())!=h||r&&S(new r)!=f||s&&S(new s)!=p)&&(S=function(_){var E=o(_),T=E==d?_.constructor:void 0,A=T?l(T):"";if(A)switch(A){case v:return g;case k:return u;case b:return h;case x:return f;case N:return p}return E}),og=S,og}var ig,gE;function vZ(){if(gE)return ig;gE=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 ig=n,ig}var lg,yE;function qI(){if(yE)return lg;yE=1;var e=pr(),t=e.Uint8Array;return lg=t,lg}var cg,wE;function p0(){if(wE)return cg;wE=1;var e=qI();function t(n){var r=new n.constructor(n.byteLength);return new e(r).set(new e(n)),r}return cg=t,cg}var ug,vE;function xZ(){if(vE)return ug;vE=1;var e=p0();function t(n,r){var s=r?e(n.buffer):n.buffer;return new n.constructor(s,n.byteOffset,n.byteLength)}return ug=t,ug}var dg,xE;function bZ(){if(xE)return dg;xE=1;var e=/\w*$/;function t(n){var r=new n.constructor(n.source,e.exec(n));return r.lastIndex=n.lastIndex,r}return dg=t,dg}var hg,bE;function kZ(){if(bE)return hg;bE=1;var e=bi(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function r(s){return n?Object(n.call(s)):{}}return hg=r,hg}var fg,kE;function UI(){if(kE)return fg;kE=1;var e=p0();function t(n,r){var s=r?e(n.buffer):n.buffer;return new n.constructor(s,n.byteOffset,n.length)}return fg=t,fg}var pg,NE;function NZ(){if(NE)return pg;NE=1;var e=p0(),t=xZ(),n=bZ(),r=kZ(),s=UI(),o="[object Boolean]",l="[object Date]",u="[object Map]",d="[object Number]",h="[object RegExp]",f="[object Set]",p="[object String]",g="[object Symbol]",v="[object ArrayBuffer]",k="[object DataView]",b="[object Float32Array]",x="[object Float64Array]",N="[object Int8Array]",S="[object Int16Array]",_="[object Int32Array]",E="[object Uint8Array]",T="[object Uint8ClampedArray]",A="[object Uint16Array]",R="[object Uint32Array]";function B(P,D,O){var L=P.constructor;switch(D){case v:return e(P);case o:case l:return new L(+P);case k:return t(P,O);case b:case x:case N:case S:case _:case E:case T:case A:case R:return s(P,O);case u:return new L;case d:case p:return new L(P);case h:return n(P);case f:return new L;case g:return r(P)}}return pg=B,pg}var mg,jE;function zI(){if(jE)return mg;jE=1;var e=Bn(),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 mg=n,mg}var gg,SE;function WI(){if(SE)return gg;SE=1;var e=zI(),t=ih(),n=oh();function r(s){return typeof s.constructor=="function"&&!n(s)?e(t(s)):{}}return gg=r,gg}var yg,_E;function jZ(){if(_E)return yg;_E=1;var e=Ni(),t=Br(),n="[object Map]";function r(s){return t(s)&&e(s)==n}return yg=r,yg}var wg,EE;function SZ(){if(EE)return wg;EE=1;var e=jZ(),t=ah(),n=u0(),r=n&&n.isMap,s=r?t(r):e;return wg=s,wg}var vg,CE;function _Z(){if(CE)return vg;CE=1;var e=Ni(),t=Br(),n="[object Set]";function r(s){return t(s)&&e(s)==n}return vg=r,vg}var xg,TE;function EZ(){if(TE)return xg;TE=1;var e=_Z(),t=ah(),n=u0(),r=n&&n.isSet,s=r?t(r):e;return xg=s,xg}var bg,AE;function HI(){if(AE)return bg;AE=1;var e=th(),t=l0(),n=rh(),r=cZ(),s=hZ(),o=$I(),l=II(),u=fZ(),d=pZ(),h=FI(),f=mZ(),p=Ni(),g=vZ(),v=NZ(),k=WI(),b=Nt(),x=ki(),N=SZ(),S=Bn(),_=EZ(),E=na(),T=Ga(),A=1,R=2,B=4,P="[object Arguments]",D="[object Array]",O="[object Boolean]",L="[object Date]",z="[object Error]",M="[object Function]",$="[object GeneratorFunction]",q="[object Map]",X="[object Number]",H="[object Object]",I="[object RegExp]",W="[object Set]",F="[object String]",Y="[object Symbol]",J="[object WeakMap]",V="[object ArrayBuffer]",G="[object DataView]",K="[object Float32Array]",Z="[object Float64Array]",ee="[object Int8Array]",re="[object Int16Array]",ue="[object Int32Array]",me="[object Uint8Array]",ae="[object Uint8ClampedArray]",pe="[object Uint16Array]",xe="[object Uint32Array]",se={};se[P]=se[D]=se[V]=se[G]=se[O]=se[L]=se[K]=se[Z]=se[ee]=se[re]=se[ue]=se[q]=se[X]=se[H]=se[I]=se[W]=se[F]=se[Y]=se[me]=se[ae]=se[pe]=se[xe]=!0,se[z]=se[M]=se[J]=!1;function ve(fe,he,_e,Fe,Le,Ve){var le,je=he&A,$e=he&R,Oe=he&B;if(_e&&(le=Le?_e(fe,Fe,Le,Ve):_e(fe)),le!==void 0)return le;if(!S(fe))return fe;var ze=b(fe);if(ze){if(le=g(fe),!je)return l(fe,le)}else{var nt=p(fe),it=nt==M||nt==$;if(x(fe))return o(fe,je);if(nt==H||nt==P||it&&!Le){if(le=$e||it?{}:k(fe),!je)return $e?d(fe,s(le,fe)):u(fe,r(le,fe))}else{if(!se[nt])return Le?fe:{};le=v(fe,nt,je)}}Ve||(Ve=new e);var At=Ve.get(fe);if(At)return At;Ve.set(fe,le),_(fe)?fe.forEach(function(Je){le.add(ve(Je,he,_e,Je,fe,Ve))}):N(fe)&&fe.forEach(function(Je,rt){le.set(rt,ve(Je,he,_e,rt,fe,Ve))});var Ue=Oe?$e?f:h:$e?T:E,Ze=ze?void 0:Ue(fe);return t(Ze||fe,function(Je,rt){Ze&&(rt=Je,Je=fe[rt]),n(le,rt,ve(Je,he,_e,rt,fe,Ve))}),le}return bg=ve,bg}var kg,RE;function CZ(){if(RE)return kg;RE=1;var e=HI(),t=4;function n(r){return e(r,t)}return kg=n,kg}var Ng,ME;function m0(){if(ME)return Ng;ME=1;function e(t){return function(){return t}}return Ng=e,Ng}var jg,$E;function TZ(){if($E)return jg;$E=1;function e(t){return function(n,r,s){for(var o=-1,l=Object(n),u=s(n),d=u.length;d--;){var h=u[t?d:++o];if(r(l[h],h,l)===!1)break}return n}}return jg=e,jg}var Sg,IE;function g0(){if(IE)return Sg;IE=1;var e=TZ(),t=e();return Sg=t,Sg}var _g,OE;function y0(){if(OE)return _g;OE=1;var e=g0(),t=na();function n(r,s){return r&&e(r,s,t)}return _g=n,_g}var Eg,LE;function AZ(){if(LE)return Eg;LE=1;var e=fs();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 Eg=t,Eg}var Cg,PE;function lh(){if(PE)return Cg;PE=1;var e=y0(),t=AZ(),n=t(e);return Cg=n,Cg}var Tg,DE;function Ka(){if(DE)return Tg;DE=1;function e(t){return t}return Tg=e,Tg}var Ag,FE;function VI(){if(FE)return Ag;FE=1;var e=Ka();function t(n){return typeof n=="function"?n:e}return Ag=t,Ag}var Rg,BE;function GI(){if(BE)return Rg;BE=1;var e=l0(),t=lh(),n=VI(),r=Nt();function s(o,l){var u=r(o)?e:t;return u(o,n(l))}return Rg=s,Rg}var Mg,qE;function KI(){return qE||(qE=1,Mg=GI()),Mg}var $g,UE;function RZ(){if(UE)return $g;UE=1;var e=lh();function t(n,r){var s=[];return e(n,function(o,l,u){r(o,l,u)&&s.push(o)}),s}return $g=t,$g}var Ig,zE;function MZ(){if(zE)return Ig;zE=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return Ig=t,Ig}var Og,WE;function $Z(){if(WE)return Og;WE=1;function e(t){return this.__data__.has(t)}return Og=e,Og}var Lg,HE;function YI(){if(HE)return Lg;HE=1;var e=i0(),t=MZ(),n=$Z();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,Lg=r,Lg}var Pg,VE;function IZ(){if(VE)return Pg;VE=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 Pg=e,Pg}var Dg,GE;function XI(){if(GE)return Dg;GE=1;function e(t,n){return t.has(n)}return Dg=e,Dg}var Fg,KE;function ZI(){if(KE)return Fg;KE=1;var e=YI(),t=IZ(),n=XI(),r=1,s=2;function o(l,u,d,h,f,p){var g=d&r,v=l.length,k=u.length;if(v!=k&&!(g&&k>v))return!1;var b=p.get(l),x=p.get(u);if(b&&x)return b==u&&x==l;var N=-1,S=!0,_=d&s?new e:void 0;for(p.set(l,u),p.set(u,l);++N<v;){var E=l[N],T=u[N];if(h)var A=g?h(T,E,N,u,l,p):h(E,T,N,l,u,p);if(A!==void 0){if(A)continue;S=!1;break}if(_){if(!t(u,function(R,B){if(!n(_,B)&&(E===R||f(E,R,d,h,p)))return _.push(B)})){S=!1;break}}else if(!(E===T||f(E,T,d,h,p))){S=!1;break}}return p.delete(l),p.delete(u),S}return Fg=o,Fg}var Bg,YE;function OZ(){if(YE)return Bg;YE=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(s,o){r[++n]=[o,s]}),r}return Bg=e,Bg}var qg,XE;function w0(){if(XE)return qg;XE=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(s){r[++n]=s}),r}return qg=e,qg}var Ug,ZE;function LZ(){if(ZE)return Ug;ZE=1;var e=bi(),t=qI(),n=xi(),r=ZI(),s=OZ(),o=w0(),l=1,u=2,d="[object Boolean]",h="[object Date]",f="[object Error]",p="[object Map]",g="[object Number]",v="[object RegExp]",k="[object Set]",b="[object String]",x="[object Symbol]",N="[object ArrayBuffer]",S="[object DataView]",_=e?e.prototype:void 0,E=_?_.valueOf:void 0;function T(A,R,B,P,D,O,L){switch(B){case S:if(A.byteLength!=R.byteLength||A.byteOffset!=R.byteOffset)return!1;A=A.buffer,R=R.buffer;case N:return!(A.byteLength!=R.byteLength||!O(new t(A),new t(R)));case d:case h:case g:return n(+A,+R);case f:return A.name==R.name&&A.message==R.message;case v:case b:return A==R+"";case p:var z=s;case k:var M=P&l;if(z||(z=o),A.size!=R.size&&!M)return!1;var $=L.get(A);if($)return $==R;P|=u,L.set(A,R);var q=r(z(A),z(R),P,D,O,L);return L.delete(A),q;case x:if(E)return E.call(A)==E.call(R)}return!1}return Ug=T,Ug}var zg,JE;function PZ(){if(JE)return zg;JE=1;var e=FI(),t=1,n=Object.prototype,r=n.hasOwnProperty;function s(o,l,u,d,h,f){var p=u&t,g=e(o),v=g.length,k=e(l),b=k.length;if(v!=b&&!p)return!1;for(var x=v;x--;){var N=g[x];if(!(p?N in l:r.call(l,N)))return!1}var S=f.get(o),_=f.get(l);if(S&&_)return S==l&&_==o;var E=!0;f.set(o,l),f.set(l,o);for(var T=p;++x<v;){N=g[x];var A=o[N],R=l[N];if(d)var B=p?d(R,A,N,l,o,f):d(A,R,N,o,l,f);if(!(B===void 0?A===R||h(A,R,u,d,f):B)){E=!1;break}T||(T=N=="constructor")}if(E&&!T){var P=o.constructor,D=l.constructor;P!=D&&"constructor"in o&&"constructor"in l&&!(typeof P=="function"&&P instanceof P&&typeof D=="function"&&D instanceof D)&&(E=!1)}return f.delete(o),f.delete(l),E}return zg=s,zg}var Wg,QE;function DZ(){if(QE)return Wg;QE=1;var e=th(),t=ZI(),n=LZ(),r=PZ(),s=Ni(),o=Nt(),l=ki(),u=lc(),d=1,h="[object Arguments]",f="[object Array]",p="[object Object]",g=Object.prototype,v=g.hasOwnProperty;function k(b,x,N,S,_,E){var T=o(b),A=o(x),R=T?f:s(b),B=A?f:s(x);R=R==h?p:R,B=B==h?p:B;var P=R==p,D=B==p,O=R==B;if(O&&l(b)){if(!l(x))return!1;T=!0,P=!1}if(O&&!P)return E||(E=new e),T||u(b)?t(b,x,N,S,_,E):n(b,x,R,N,S,_,E);if(!(N&d)){var L=P&&v.call(b,"__wrapped__"),z=D&&v.call(x,"__wrapped__");if(L||z){var M=L?b.value():b,$=z?x.value():x;return E||(E=new e),_(M,$,N,S,E)}}return O?(E||(E=new e),r(b,x,N,S,_,E)):!1}return Wg=k,Wg}var Hg,eC;function JI(){if(eC)return Hg;eC=1;var e=DZ(),t=Br();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 Hg=n,Hg}var Vg,tC;function FZ(){if(tC)return Vg;tC=1;var e=th(),t=JI(),n=1,r=2;function s(o,l,u,d){var h=u.length,f=h,p=!d;if(o==null)return!f;for(o=Object(o);h--;){var g=u[h];if(p&&g[2]?g[1]!==o[g[0]]:!(g[0]in o))return!1}for(;++h<f;){g=u[h];var v=g[0],k=o[v],b=g[1];if(p&&g[2]){if(k===void 0&&!(v in o))return!1}else{var x=new e;if(d)var N=d(k,b,v,o,l,x);if(!(N===void 0?t(b,k,n|r,d,x):N))return!1}}return!0}return Vg=s,Vg}var Gg,nC;function QI(){if(nC)return Gg;nC=1;var e=Bn();function t(n){return n===n&&!e(n)}return Gg=t,Gg}var Kg,rC;function BZ(){if(rC)return Kg;rC=1;var e=QI(),t=na();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 Kg=n,Kg}var Yg,sC;function eO(){if(sC)return Yg;sC=1;function e(t,n){return function(r){return r==null?!1:r[t]===n&&(n!==void 0||t in Object(r))}}return Yg=e,Yg}var Xg,aC;function qZ(){if(aC)return Xg;aC=1;var e=FZ(),t=BZ(),n=eO();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 Xg=r,Xg}var Zg,oC;function ji(){if(oC)return Zg;oC=1;var e=Ha(),t=Br(),n="[object Symbol]";function r(s){return typeof s=="symbol"||t(s)&&e(s)==n}return Zg=r,Zg}var Jg,iC;function v0(){if(iC)return Jg;iC=1;var e=Nt(),t=ji(),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 Jg=s,Jg}var Qg,lC;function UZ(){if(lC)return Qg;lC=1;var e=i0(),t="Expected a function";function n(r,s){if(typeof r!="function"||s!=null&&typeof s!="function")throw new TypeError(t);var o=function(){var l=arguments,u=s?s.apply(this,l):l[0],d=o.cache;if(d.has(u))return d.get(u);var h=r.apply(this,l);return o.cache=d.set(u,h)||d,h};return o.cache=new(n.Cache||e),o}return n.Cache=e,Qg=n,Qg}var ey,cC;function zZ(){if(cC)return ey;cC=1;var e=UZ(),t=500;function n(r){var s=e(r,function(l){return o.size===t&&o.clear(),l}),o=s.cache;return s}return ey=n,ey}var ty,uC;function WZ(){if(uC)return ty;uC=1;var e=zZ(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=e(function(s){var o=[];return s.charCodeAt(0)===46&&o.push(""),s.replace(t,function(l,u,d,h){o.push(d?h.replace(n,"$1"):u||l)}),o});return ty=r,ty}var ny,dC;function ch(){if(dC)return ny;dC=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 ny=e,ny}var ry,hC;function HZ(){if(hC)return ry;hC=1;var e=bi(),t=ch(),n=Nt(),r=ji(),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 ry=l,ry}var sy,fC;function tO(){if(fC)return sy;fC=1;var e=HZ();function t(n){return n==null?"":e(n)}return sy=t,sy}var ay,pC;function uh(){if(pC)return ay;pC=1;var e=Nt(),t=v0(),n=WZ(),r=tO();function s(o,l){return e(o)?o:t(o,l)?[o]:n(r(o))}return ay=s,ay}var oy,mC;function cc(){if(mC)return oy;mC=1;var e=ji();function t(n){if(typeof n=="string"||e(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}return oy=t,oy}var iy,gC;function dh(){if(gC)return iy;gC=1;var e=uh(),t=cc();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 iy=n,iy}var ly,yC;function VZ(){if(yC)return ly;yC=1;var e=dh();function t(n,r,s){var o=n==null?void 0:e(n,r);return o===void 0?s:o}return ly=t,ly}var cy,wC;function GZ(){if(wC)return cy;wC=1;function e(t,n){return t!=null&&n in Object(t)}return cy=e,cy}var uy,vC;function nO(){if(vC)return uy;vC=1;var e=uh(),t=ic(),n=Nt(),r=sh(),s=c0(),o=cc();function l(u,d,h){d=e(d,u);for(var f=-1,p=d.length,g=!1;++f<p;){var v=o(d[f]);if(!(g=u!=null&&h(u,v)))break;u=u[v]}return g||++f!=p?g:(p=u==null?0:u.length,!!p&&s(p)&&r(v,p)&&(n(u)||t(u)))}return uy=l,uy}var dy,xC;function rO(){if(xC)return dy;xC=1;var e=GZ(),t=nO();function n(r,s){return r!=null&&t(r,s,e)}return dy=n,dy}var hy,bC;function KZ(){if(bC)return hy;bC=1;var e=JI(),t=VZ(),n=rO(),r=v0(),s=QI(),o=eO(),l=cc(),u=1,d=2;function h(f,p){return r(f)&&s(p)?o(l(f),p):function(g){var v=t(g,f);return v===void 0&&v===p?n(g,f):e(p,v,u|d)}}return hy=h,hy}var fy,kC;function sO(){if(kC)return fy;kC=1;function e(t){return function(n){return n==null?void 0:n[t]}}return fy=e,fy}var py,NC;function YZ(){if(NC)return py;NC=1;var e=dh();function t(n){return function(r){return e(r,n)}}return py=t,py}var my,jC;function XZ(){if(jC)return my;jC=1;var e=sO(),t=YZ(),n=v0(),r=cc();function s(o){return n(o)?e(r(o)):t(o)}return my=s,my}var gy,SC;function ps(){if(SC)return gy;SC=1;var e=qZ(),t=KZ(),n=Ka(),r=Nt(),s=XZ();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 gy=o,gy}var yy,_C;function aO(){if(_C)return yy;_C=1;var e=OI(),t=RZ(),n=ps(),r=Nt();function s(o,l){var u=r(o)?e:t;return u(o,n(l,3))}return yy=s,yy}var wy,EC;function ZZ(){if(EC)return wy;EC=1;var e=Object.prototype,t=e.hasOwnProperty;function n(r,s){return r!=null&&t.call(r,s)}return wy=n,wy}var vy,CC;function oO(){if(CC)return vy;CC=1;var e=ZZ(),t=nO();function n(r,s){return r!=null&&t(r,s,e)}return vy=n,vy}var xy,TC;function JZ(){if(TC)return xy;TC=1;var e=d0(),t=Ni(),n=ic(),r=Nt(),s=fs(),o=ki(),l=oh(),u=lc(),d="[object Map]",h="[object Set]",f=Object.prototype,p=f.hasOwnProperty;function g(v){if(v==null)return!0;if(s(v)&&(r(v)||typeof v=="string"||typeof v.splice=="function"||o(v)||u(v)||n(v)))return!v.length;var k=t(v);if(k==d||k==h)return!v.size;if(l(v))return!e(v).length;for(var b in v)if(p.call(v,b))return!1;return!0}return xy=g,xy}var by,AC;function iO(){if(AC)return by;AC=1;function e(t){return t===void 0}return by=e,by}var ky,RC;function lO(){if(RC)return ky;RC=1;var e=lh(),t=fs();function n(r,s){var o=-1,l=t(r)?Array(r.length):[];return e(r,function(u,d,h){l[++o]=s(u,d,h)}),l}return ky=n,ky}var Ny,MC;function cO(){if(MC)return Ny;MC=1;var e=ch(),t=ps(),n=lO(),r=Nt();function s(o,l){var u=r(o)?e:n;return u(o,t(l,3))}return Ny=s,Ny}var jy,$C;function QZ(){if($C)return jy;$C=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 jy=e,jy}var Sy,IC;function eJ(){if(IC)return Sy;IC=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 _y,OC;function uO(){if(OC)return _y;OC=1;var e=QZ(),t=lh(),n=ps(),r=eJ(),s=Nt();function o(l,u,d){var h=s(l)?e:r,f=arguments.length<3;return h(l,n(u,4),d,f,t)}return _y=o,_y}var Ey,LC;function tJ(){if(LC)return Ey;LC=1;var e=Ha(),t=Nt(),n=Br(),r="[object String]";function s(o){return typeof o=="string"||!t(o)&&n(o)&&e(o)==r}return Ey=s,Ey}var Cy,PC;function nJ(){if(PC)return Cy;PC=1;var e=sO(),t=e("length");return Cy=t,Cy}var Ty,DC;function rJ(){if(DC)return Ty;DC=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",s=t+n+r,o="\\ufe0e\\ufe0f",l="\\u200d",u=RegExp("["+l+e+s+o+"]");function d(h){return u.test(h)}return Ty=d,Ty}var Ay,FC;function sJ(){if(FC)return Ay;FC=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",s=t+n+r,o="\\ufe0e\\ufe0f",l="["+e+"]",u="["+s+"]",d="\\ud83c[\\udffb-\\udfff]",h="(?:"+u+"|"+d+")",f="[^"+e+"]",p="(?:\\ud83c[\\udde6-\\uddff]){2}",g="[\\ud800-\\udbff][\\udc00-\\udfff]",v="\\u200d",k=h+"?",b="["+o+"]?",x="(?:"+v+"(?:"+[f,p,g].join("|")+")"+b+k+")*",N=b+k+x,S="(?:"+[f+u+"?",u,p,g,l].join("|")+")",_=RegExp(d+"(?="+d+")|"+S+N,"g");function E(T){for(var A=_.lastIndex=0;_.test(T);)++A;return A}return Ay=E,Ay}var Ry,BC;function aJ(){if(BC)return Ry;BC=1;var e=nJ(),t=rJ(),n=sJ();function r(s){return t(s)?n(s):e(s)}return Ry=r,Ry}var My,qC;function oJ(){if(qC)return My;qC=1;var e=d0(),t=Ni(),n=fs(),r=tJ(),s=aJ(),o="[object Map]",l="[object Set]";function u(d){if(d==null)return 0;if(n(d))return r(d)?s(d):d.length;var h=t(d);return h==o||h==l?d.size:e(d).length}return My=u,My}var $y,UC;function iJ(){if(UC)return $y;UC=1;var e=l0(),t=zI(),n=y0(),r=ps(),s=ih(),o=Nt(),l=ki(),u=ac(),d=Bn(),h=lc();function f(p,g,v){var k=o(p),b=k||l(p)||h(p);if(g=r(g,4),v==null){var x=p&&p.constructor;b?v=k?new x:[]:d(p)?v=u(x)?t(s(p)):{}:v={}}return(b?e:n)(p,function(N,S,_){return g(v,N,S,_)}),v}return $y=f,$y}var Iy,zC;function lJ(){if(zC)return Iy;zC=1;var e=bi(),t=ic(),n=Nt(),r=e?e.isConcatSpreadable:void 0;function s(o){return n(o)||t(o)||!!(r&&o&&o[r])}return Iy=s,Iy}var Oy,WC;function x0(){if(WC)return Oy;WC=1;var e=f0(),t=lJ();function n(r,s,o,l,u){var d=-1,h=r.length;for(o||(o=t),u||(u=[]);++d<h;){var f=r[d];s>0&&o(f)?s>1?n(f,s-1,o,l,u):e(u,f):l||(u[u.length]=f)}return u}return Oy=n,Oy}var Ly,HC;function cJ(){if(HC)return Ly;HC=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 Ly=e,Ly}var Py,VC;function dO(){if(VC)return Py;VC=1;var e=cJ(),t=Math.max;function n(r,s,o){return s=t(s===void 0?r.length-1:s,0),function(){for(var l=arguments,u=-1,d=t(l.length-s,0),h=Array(d);++u<d;)h[u]=l[s+u];u=-1;for(var f=Array(s+1);++u<s;)f[u]=l[u];return f[s]=o(h),e(r,this,f)}}return Py=n,Py}var Dy,GC;function uJ(){if(GC)return Dy;GC=1;var e=m0(),t=AI(),n=Ka(),r=t?function(s,o){return t(s,"toString",{configurable:!0,enumerable:!1,value:e(o),writable:!0})}:n;return Dy=r,Dy}var Fy,KC;function dJ(){if(KC)return Fy;KC=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 Fy=r,Fy}var By,YC;function hO(){if(YC)return By;YC=1;var e=uJ(),t=dJ(),n=t(e);return By=n,By}var qy,XC;function hh(){if(XC)return qy;XC=1;var e=Ka(),t=dO(),n=hO();function r(s,o){return n(t(s,o,e),s+"")}return qy=r,qy}var Uy,ZC;function fO(){if(ZC)return Uy;ZC=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 Uy=e,Uy}var zy,JC;function hJ(){if(JC)return zy;JC=1;function e(t){return t!==t}return zy=e,zy}var Wy,QC;function fJ(){if(QC)return Wy;QC=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 Wy=e,Wy}var Hy,eT;function pJ(){if(eT)return Hy;eT=1;var e=fO(),t=hJ(),n=fJ();function r(s,o,l){return o===o?n(s,o,l):e(s,t,l)}return Hy=r,Hy}var Vy,tT;function mJ(){if(tT)return Vy;tT=1;var e=pJ();function t(n,r){var s=n==null?0:n.length;return!!s&&e(n,r,0)>-1}return Vy=t,Vy}var Gy,nT;function gJ(){if(nT)return Gy;nT=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 Gy=e,Gy}var Ky,rT;function yJ(){if(rT)return Ky;rT=1;function e(){}return Ky=e,Ky}var Yy,sT;function wJ(){if(sT)return Yy;sT=1;var e=BI(),t=yJ(),n=w0(),r=1/0,s=e&&1/n(new e([,-0]))[1]==r?function(o){return new e(o)}:t;return Yy=s,Yy}var Xy,aT;function vJ(){if(aT)return Xy;aT=1;var e=YI(),t=mJ(),n=gJ(),r=XI(),s=wJ(),o=w0(),l=200;function u(d,h,f){var p=-1,g=t,v=d.length,k=!0,b=[],x=b;if(f)k=!1,g=n;else if(v>=l){var N=h?null:s(d);if(N)return o(N);k=!1,g=r,x=new e}else x=h?[]:b;e:for(;++p<v;){var S=d[p],_=h?h(S):S;if(S=f||S!==0?S:0,k&&_===_){for(var E=x.length;E--;)if(x[E]===_)continue e;h&&x.push(_),b.push(S)}else g(x,_,f)||(x!==b&&x.push(_),b.push(S))}return b}return Xy=u,Xy}var Zy,oT;function pO(){if(oT)return Zy;oT=1;var e=fs(),t=Br();function n(r){return t(r)&&e(r)}return Zy=n,Zy}var Jy,iT;function xJ(){if(iT)return Jy;iT=1;var e=x0(),t=hh(),n=vJ(),r=pO(),s=t(function(o){return n(e(o,1,r,!0))});return Jy=s,Jy}var Qy,lT;function bJ(){if(lT)return Qy;lT=1;var e=ch();function t(n,r){return e(r,function(s){return n[s]})}return Qy=t,Qy}var ew,cT;function mO(){if(cT)return ew;cT=1;var e=bJ(),t=na();function n(r){return r==null?[]:e(r,t(r))}return ew=n,ew}var tw,uT;function qn(){if(uT)return tw;uT=1;var e;if(typeof a0=="function")try{e={clone:CZ(),constant:m0(),each:KI(),filter:aO(),has:oO(),isArray:Nt(),isEmpty:JZ(),isFunction:ac(),isUndefined:iO(),keys:na(),map:cO(),reduce:uO(),size:oJ(),transform:iJ(),union:xJ(),values:mO()}}catch{}return e||(e=window._),tw=e,tw}var nw,dT;function b0(){if(dT)return nw;dT=1;var e=qn();nw=s;var t="\0",n="\0",r="";function s(f){this._isDirected=e.has(f,"directed")?f.directed:!0,this._isMultigraph=e.has(f,"multigraph")?f.multigraph:!1,this._isCompound=e.has(f,"compound")?f.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[n]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}s.prototype._nodeCount=0,s.prototype._edgeCount=0,s.prototype.isDirected=function(){return this._isDirected},s.prototype.isMultigraph=function(){return this._isMultigraph},s.prototype.isCompound=function(){return this._isCompound},s.prototype.setGraph=function(f){return this._label=f,this},s.prototype.graph=function(){return this._label},s.prototype.setDefaultNodeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultNodeLabelFn=f,this},s.prototype.nodeCount=function(){return this._nodeCount},s.prototype.nodes=function(){return e.keys(this._nodes)},s.prototype.sources=function(){var f=this;return e.filter(this.nodes(),function(p){return e.isEmpty(f._in[p])})},s.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(p){return e.isEmpty(f._out[p])})},s.prototype.setNodes=function(f,p){var g=arguments,v=this;return e.each(f,function(k){g.length>1?v.setNode(k,p):v.setNode(k)}),this},s.prototype.setNode=function(f,p){return e.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=p),this):(this._nodes[f]=arguments.length>1?p:this._defaultNodeLabelFn(f),this._isCompound&&(this._parent[f]=n,this._children[f]={},this._children[n][f]=!0),this._in[f]={},this._preds[f]={},this._out[f]={},this._sucs[f]={},++this._nodeCount,this)},s.prototype.node=function(f){return this._nodes[f]},s.prototype.hasNode=function(f){return e.has(this._nodes,f)},s.prototype.removeNode=function(f){var p=this;if(e.has(this._nodes,f)){var g=function(v){p.removeEdge(p._edgeObjs[v])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(v){p.setParent(v)}),delete this._children[f]),e.each(e.keys(this._in[f]),g),delete this._in[f],delete this._preds[f],e.each(e.keys(this._out[f]),g),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},s.prototype.setParent=function(f,p){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(p))p=n;else{p+="";for(var g=p;!e.isUndefined(g);g=this.parent(g))if(g===f)throw new Error("Setting "+p+" as parent of "+f+" would create a cycle");this.setNode(p)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=p,this._children[p][f]=!0,this},s.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},s.prototype.parent=function(f){if(this._isCompound){var p=this._parent[f];if(p!==n)return p}},s.prototype.children=function(f){if(e.isUndefined(f)&&(f=n),this._isCompound){var p=this._children[f];if(p)return e.keys(p)}else{if(f===n)return this.nodes();if(this.hasNode(f))return[]}},s.prototype.predecessors=function(f){var p=this._preds[f];if(p)return e.keys(p)},s.prototype.successors=function(f){var p=this._sucs[f];if(p)return e.keys(p)},s.prototype.neighbors=function(f){var p=this.predecessors(f);if(p)return e.union(p,this.successors(f))},s.prototype.isLeaf=function(f){var p;return this.isDirected()?p=this.successors(f):p=this.neighbors(f),p.length===0},s.prototype.filterNodes=function(f){var p=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});p.setGraph(this.graph());var g=this;e.each(this._nodes,function(b,x){f(x)&&p.setNode(x,b)}),e.each(this._edgeObjs,function(b){p.hasNode(b.v)&&p.hasNode(b.w)&&p.setEdge(b,g.edge(b))});var v={};function k(b){var x=g.parent(b);return x===void 0||p.hasNode(x)?(v[b]=x,x):x in v?v[x]:k(x)}return this._isCompound&&e.each(p.nodes(),function(b){p.setParent(b,k(b))}),p},s.prototype.setDefaultEdgeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultEdgeLabelFn=f,this},s.prototype.edgeCount=function(){return this._edgeCount},s.prototype.edges=function(){return e.values(this._edgeObjs)},s.prototype.setPath=function(f,p){var g=this,v=arguments;return e.reduce(f,function(k,b){return v.length>1?g.setEdge(k,b,p):g.setEdge(k,b),b}),this},s.prototype.setEdge=function(){var f,p,g,v,k=!1,b=arguments[0];typeof b=="object"&&b!==null&&"v"in b?(f=b.v,p=b.w,g=b.name,arguments.length===2&&(v=arguments[1],k=!0)):(f=b,p=arguments[1],g=arguments[3],arguments.length>2&&(v=arguments[2],k=!0)),f=""+f,p=""+p,e.isUndefined(g)||(g=""+g);var x=u(this._isDirected,f,p,g);if(e.has(this._edgeLabels,x))return k&&(this._edgeLabels[x]=v),this;if(!e.isUndefined(g)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(p),this._edgeLabels[x]=k?v:this._defaultEdgeLabelFn(f,p,g);var N=d(this._isDirected,f,p,g);return f=N.v,p=N.w,Object.freeze(N),this._edgeObjs[x]=N,o(this._preds[p],f),o(this._sucs[f],p),this._in[p][x]=N,this._out[f][x]=N,this._edgeCount++,this},s.prototype.edge=function(f,p,g){var v=arguments.length===1?h(this._isDirected,arguments[0]):u(this._isDirected,f,p,g);return this._edgeLabels[v]},s.prototype.hasEdge=function(f,p,g){var v=arguments.length===1?h(this._isDirected,arguments[0]):u(this._isDirected,f,p,g);return e.has(this._edgeLabels,v)},s.prototype.removeEdge=function(f,p,g){var v=arguments.length===1?h(this._isDirected,arguments[0]):u(this._isDirected,f,p,g),k=this._edgeObjs[v];return k&&(f=k.v,p=k.w,delete this._edgeLabels[v],delete this._edgeObjs[v],l(this._preds[p],f),l(this._sucs[f],p),delete this._in[p][v],delete this._out[f][v],this._edgeCount--),this},s.prototype.inEdges=function(f,p){var g=this._in[f];if(g){var v=e.values(g);return p?e.filter(v,function(k){return k.v===p}):v}},s.prototype.outEdges=function(f,p){var g=this._out[f];if(g){var v=e.values(g);return p?e.filter(v,function(k){return k.w===p}):v}},s.prototype.nodeEdges=function(f,p){var g=this.inEdges(f,p);if(g)return g.concat(this.outEdges(f,p))};function o(f,p){f[p]?f[p]++:f[p]=1}function l(f,p){--f[p]||delete f[p]}function u(f,p,g,v){var k=""+p,b=""+g;if(!f&&k>b){var x=k;k=b,b=x}return k+r+b+r+(e.isUndefined(v)?t:v)}function d(f,p,g,v){var k=""+p,b=""+g;if(!f&&k>b){var x=k;k=b,b=x}var N={v:k,w:b};return v&&(N.name=v),N}function h(f,p){return u(f,p.v,p.w,p.name)}return nw}var rw,hT;function kJ(){return hT||(hT=1,rw="2.1.8"),rw}var sw,fT;function NJ(){return fT||(fT=1,sw={Graph:b0(),version:kJ()}),sw}var aw,pT;function jJ(){if(pT)return aw;pT=1;var e=qn(),t=b0();aw={write:n,read:o};function n(l){var u={options:{directed:l.isDirected(),multigraph:l.isMultigraph(),compound:l.isCompound()},nodes:r(l),edges:s(l)};return e.isUndefined(l.graph())||(u.value=e.clone(l.graph())),u}function r(l){return e.map(l.nodes(),function(u){var d=l.node(u),h=l.parent(u),f={v:u};return e.isUndefined(d)||(f.value=d),e.isUndefined(h)||(f.parent=h),f})}function s(l){return e.map(l.edges(),function(u){var d=l.edge(u),h={v:u.v,w:u.w};return e.isUndefined(u.name)||(h.name=u.name),e.isUndefined(d)||(h.value=d),h})}function o(l){var u=new t(l.options).setGraph(l.value);return e.each(l.nodes,function(d){u.setNode(d.v,d.value),d.parent&&u.setParent(d.v,d.parent)}),e.each(l.edges,function(d){u.setEdge({v:d.v,w:d.w,name:d.name},d.value)}),u}return aw}var ow,mT;function SJ(){if(mT)return ow;mT=1;var e=qn();ow=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 ow}var iw,gT;function gO(){if(gT)return iw;gT=1;var e=qn();iw=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},iw}var lw,yT;function yO(){if(yT)return lw;yT=1;var e=qn(),t=gO();lw=r;var n=e.constant(1);function r(o,l,u,d){return s(o,String(l),u||n,d||function(h){return o.outEdges(h)})}function s(o,l,u,d){var h={},f=new t,p,g,v=function(k){var b=k.v!==p?k.v:k.w,x=h[b],N=u(k),S=g.distance+N;if(N<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+k+" Weight: "+N);S<x.distance&&(x.distance=S,x.predecessor=p,f.decrease(b,S))};for(o.nodes().forEach(function(k){var b=k===l?0:Number.POSITIVE_INFINITY;h[k]={distance:b},f.add(k,b)});f.size()>0&&(p=f.removeMin(),g=h[p],g.distance!==Number.POSITIVE_INFINITY);)d(p).forEach(v);return h}return lw}var cw,wT;function _J(){if(wT)return cw;wT=1;var e=yO(),t=qn();cw=n;function n(r,s,o){return t.transform(r.nodes(),function(l,u){l[u]=e(r,u,s,o)},{})}return cw}var uw,vT;function wO(){if(vT)return uw;vT=1;var e=qn();uw=t;function t(n){var r=0,s=[],o={},l=[];function u(d){var h=o[d]={onStack:!0,lowlink:r,index:r++};if(s.push(d),n.successors(d).forEach(function(g){e.has(o,g)?o[g].onStack&&(h.lowlink=Math.min(h.lowlink,o[g].index)):(u(g),h.lowlink=Math.min(h.lowlink,o[g].lowlink))}),h.lowlink===h.index){var f=[],p;do p=s.pop(),o[p].onStack=!1,f.push(p);while(d!==p);l.push(f)}}return n.nodes().forEach(function(d){e.has(o,d)||u(d)}),l}return uw}var dw,xT;function EJ(){if(xT)return dw;xT=1;var e=qn(),t=wO();dw=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 dw}var hw,bT;function CJ(){if(bT)return hw;bT=1;var e=qn();hw=n;var t=e.constant(1);function n(s,o,l){return r(s,o||t,l||function(u){return s.outEdges(u)})}function r(s,o,l){var u={},d=s.nodes();return d.forEach(function(h){u[h]={},u[h][h]={distance:0},d.forEach(function(f){h!==f&&(u[h][f]={distance:Number.POSITIVE_INFINITY})}),l(h).forEach(function(f){var p=f.v===h?f.w:f.v,g=o(f);u[h][p]={distance:g,predecessor:h}})}),d.forEach(function(h){var f=u[h];d.forEach(function(p){var g=u[p];d.forEach(function(v){var k=g[h],b=f[v],x=g[v],N=k.distance+b.distance;N<x.distance&&(x.distance=N,x.predecessor=b.predecessor)})})}),u}return hw}var fw,kT;function vO(){if(kT)return fw;kT=1;var e=qn();fw=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,fw}var pw,NT;function TJ(){if(NT)return pw;NT=1;var e=vO();pw=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return pw}var mw,jT;function xO(){if(jT)return mw;jT=1;var e=qn();mw=t;function t(r,s,o){e.isArray(s)||(s=[s]);var l=(r.isDirected()?r.successors:r.neighbors).bind(r),u=[],d={};return e.each(s,function(h){if(!r.hasNode(h))throw new Error("Graph does not have node: "+h);n(r,h,o==="post",d,l,u)}),u}function n(r,s,o,l,u,d){e.has(l,s)||(l[s]=!0,o||d.push(s),e.each(u(s),function(h){n(r,h,o,l,u,d)}),o&&d.push(s))}return mw}var gw,ST;function AJ(){if(ST)return gw;ST=1;var e=xO();gw=t;function t(n,r){return e(n,r,"post")}return gw}var yw,_T;function RJ(){if(_T)return yw;_T=1;var e=xO();yw=t;function t(n,r){return e(n,r,"pre")}return yw}var ww,ET;function MJ(){if(ET)return ww;ET=1;var e=qn(),t=b0(),n=gO();ww=r;function r(s,o){var l=new t,u={},d=new n,h;function f(g){var v=g.v===h?g.w:g.v,k=d.priority(v);if(k!==void 0){var b=o(g);b<k&&(u[v]=h,d.decrease(v,b))}}if(s.nodeCount()===0)return l;e.each(s.nodes(),function(g){d.add(g,Number.POSITIVE_INFINITY),l.setNode(g)}),d.decrease(s.nodes()[0],0);for(var p=!1;d.size()>0;){if(h=d.removeMin(),e.has(u,h))l.setEdge(h,u[h]);else{if(p)throw new Error("Input graph is not connected: "+s);p=!0}s.nodeEdges(h).forEach(f)}return l}return ww}var vw,CT;function $J(){return CT||(CT=1,vw={components:SJ(),dijkstra:yO(),dijkstraAll:_J(),findCycles:EJ(),floydWarshall:CJ(),isAcyclic:TJ(),postorder:AJ(),preorder:RJ(),prim:MJ(),tarjan:wO(),topsort:vO()}),vw}var xw,TT;function IJ(){if(TT)return xw;TT=1;var e=NJ();return xw={Graph:e.Graph,json:jJ(),alg:$J(),version:e.version},xw}var bw,AT;function dr(){if(AT)return bw;AT=1;var e;if(typeof a0=="function")try{e=IJ()}catch{}return e||(e=window.graphlib),bw=e,bw}var kw,RT;function OJ(){if(RT)return kw;RT=1;var e=HI(),t=1,n=4;function r(s){return e(s,t|n)}return kw=r,kw}var Nw,MT;function fh(){if(MT)return Nw;MT=1;var e=xi(),t=fs(),n=sh(),r=Bn();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 jw,$T;function LJ(){if($T)return jw;$T=1;var e=hh(),t=xi(),n=fh(),r=Ga(),s=Object.prototype,o=s.hasOwnProperty,l=e(function(u,d){u=Object(u);var h=-1,f=d.length,p=f>2?d[2]:void 0;for(p&&n(d[0],d[1],p)&&(f=1);++h<f;)for(var g=d[h],v=r(g),k=-1,b=v.length;++k<b;){var x=v[k],N=u[x];(N===void 0||t(N,s[x])&&!o.call(u,x))&&(u[x]=g[x])}return u});return jw=l,jw}var Sw,IT;function PJ(){if(IT)return Sw;IT=1;var e=ps(),t=fs(),n=na();function r(s){return function(o,l,u){var d=Object(o);if(!t(o)){var h=e(l,3);o=n(o),l=function(p){return h(d[p],p,d)}}var f=s(o,l,u);return f>-1?d[h?o[f]:f]:void 0}}return Sw=r,Sw}var _w,OT;function DJ(){if(OT)return _w;OT=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return _w=t,_w}var Ew,LT;function FJ(){if(LT)return Ew;LT=1;var e=DJ(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return Ew=n,Ew}var Cw,PT;function BJ(){if(PT)return Cw;PT=1;var e=FJ(),t=Bn(),n=ji(),r=NaN,s=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,l=/^0o[0-7]+$/i,u=parseInt;function d(h){if(typeof h=="number")return h;if(n(h))return r;if(t(h)){var f=typeof h.valueOf=="function"?h.valueOf():h;h=t(f)?f+"":f}if(typeof h!="string")return h===0?h:+h;h=e(h);var p=o.test(h);return p||l.test(h)?u(h.slice(2),p?2:8):s.test(h)?r:+h}return Cw=d,Cw}var Tw,DT;function bO(){if(DT)return Tw;DT=1;var e=BJ(),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 Tw=r,Tw}var Aw,FT;function qJ(){if(FT)return Aw;FT=1;var e=bO();function t(n){var r=e(n),s=r%1;return r===r?s?r-s:r:0}return Aw=t,Aw}var Rw,BT;function UJ(){if(BT)return Rw;BT=1;var e=fO(),t=ps(),n=qJ(),r=Math.max;function s(o,l,u){var d=o==null?0:o.length;if(!d)return-1;var h=u==null?0:n(u);return h<0&&(h=r(d+h,0)),e(o,t(l,3),h)}return Rw=s,Rw}var Mw,qT;function zJ(){if(qT)return Mw;qT=1;var e=PJ(),t=UJ(),n=e(t);return Mw=n,Mw}var $w,UT;function kO(){if(UT)return $w;UT=1;var e=x0();function t(n){var r=n==null?0:n.length;return r?e(n,1):[]}return $w=t,$w}var Iw,zT;function WJ(){if(zT)return Iw;zT=1;var e=g0(),t=VI(),n=Ga();function r(s,o){return s==null?s:e(s,t(o),n)}return Iw=r,Iw}var Ow,WT;function HJ(){if(WT)return Ow;WT=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return Ow=e,Ow}var Lw,HT;function VJ(){if(HT)return Lw;HT=1;var e=nh(),t=y0(),n=ps();function r(s,o){var l={};return o=n(o,3),t(s,function(u,d,h){e(l,d,o(u,d,h))}),l}return Lw=r,Lw}var Pw,VT;function k0(){if(VT)return Pw;VT=1;var e=ji();function t(n,r,s){for(var o=-1,l=n.length;++o<l;){var u=n[o],d=r(u);if(d!=null&&(h===void 0?d===d&&!e(d):s(d,h)))var h=d,f=u}return f}return Pw=t,Pw}var Dw,GT;function GJ(){if(GT)return Dw;GT=1;function e(t,n){return t>n}return Dw=e,Dw}var Fw,KT;function KJ(){if(KT)return Fw;KT=1;var e=k0(),t=GJ(),n=Ka();function r(s){return s&&s.length?e(s,n,t):void 0}return Fw=r,Fw}var Bw,YT;function NO(){if(YT)return Bw;YT=1;var e=nh(),t=xi();function n(r,s,o){(o!==void 0&&!t(r[s],o)||o===void 0&&!(s in r))&&e(r,s,o)}return Bw=n,Bw}var qw,XT;function YJ(){if(XT)return qw;XT=1;var e=Ha(),t=ih(),n=Br(),r="[object Object]",s=Function.prototype,o=Object.prototype,l=s.toString,u=o.hasOwnProperty,d=l.call(Object);function h(f){if(!n(f)||e(f)!=r)return!1;var p=t(f);if(p===null)return!0;var g=u.call(p,"constructor")&&p.constructor;return typeof g=="function"&&g instanceof g&&l.call(g)==d}return qw=h,qw}var Uw,ZT;function jO(){if(ZT)return Uw;ZT=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return Uw=e,Uw}var zw,JT;function XJ(){if(JT)return zw;JT=1;var e=oc(),t=Ga();function n(r){return e(r,t(r))}return zw=n,zw}var Ww,QT;function ZJ(){if(QT)return Ww;QT=1;var e=NO(),t=$I(),n=UI(),r=II(),s=WI(),o=ic(),l=Nt(),u=pO(),d=ki(),h=ac(),f=Bn(),p=YJ(),g=lc(),v=jO(),k=XJ();function b(x,N,S,_,E,T,A){var R=v(x,S),B=v(N,S),P=A.get(B);if(P){e(x,S,P);return}var D=T?T(R,B,S+"",x,N,A):void 0,O=D===void 0;if(O){var L=l(B),z=!L&&d(B),M=!L&&!z&&g(B);D=B,L||z||M?l(R)?D=R:u(R)?D=r(R):z?(O=!1,D=t(B,!0)):M?(O=!1,D=n(B,!0)):D=[]:p(B)||o(B)?(D=R,o(R)?D=k(R):(!f(R)||h(R))&&(D=s(B))):O=!1}O&&(A.set(B,D),E(D,B,_,T,A),A.delete(B)),e(x,S,D)}return Ww=b,Ww}var Hw,eA;function JJ(){if(eA)return Hw;eA=1;var e=th(),t=NO(),n=g0(),r=ZJ(),s=Bn(),o=Ga(),l=jO();function u(d,h,f,p,g){d!==h&&n(h,function(v,k){if(g||(g=new e),s(v))r(d,h,k,f,u,p,g);else{var b=p?p(l(d,k),v,k+"",d,h,g):void 0;b===void 0&&(b=v),t(d,k,b)}},o)}return Hw=u,Hw}var Vw,tA;function QJ(){if(tA)return Vw;tA=1;var e=hh(),t=fh();function n(r){return e(function(s,o){var l=-1,u=o.length,d=u>1?o[u-1]:void 0,h=u>2?o[2]:void 0;for(d=r.length>3&&typeof d=="function"?(u--,d):void 0,h&&t(o[0],o[1],h)&&(d=u<3?void 0:d,u=1),s=Object(s);++l<u;){var f=o[l];f&&r(s,f,l,d)}return s})}return Vw=n,Vw}var Gw,nA;function eQ(){if(nA)return Gw;nA=1;var e=JJ(),t=QJ(),n=t(function(r,s,o){e(r,s,o)});return Gw=n,Gw}var Kw,rA;function SO(){if(rA)return Kw;rA=1;function e(t,n){return t<n}return Kw=e,Kw}var Yw,sA;function tQ(){if(sA)return Yw;sA=1;var e=k0(),t=SO(),n=Ka();function r(s){return s&&s.length?e(s,n,t):void 0}return Yw=r,Yw}var Xw,aA;function nQ(){if(aA)return Xw;aA=1;var e=k0(),t=ps(),n=SO();function r(s,o){return s&&s.length?e(s,t(o,2),n):void 0}return Xw=r,Xw}var Zw,oA;function rQ(){if(oA)return Zw;oA=1;var e=pr(),t=function(){return e.Date.now()};return Zw=t,Zw}var Jw,iA;function sQ(){if(iA)return Jw;iA=1;var e=rh(),t=uh(),n=sh(),r=Bn(),s=cc();function o(l,u,d,h){if(!r(l))return l;u=t(u,l);for(var f=-1,p=u.length,g=p-1,v=l;v!=null&&++f<p;){var k=s(u[f]),b=d;if(k==="__proto__"||k==="constructor"||k==="prototype")return l;if(f!=g){var x=v[k];b=h?h(x,k,v):void 0,b===void 0&&(b=r(x)?x:n(u[f+1])?[]:{})}e(v,k,b),v=v[k]}return l}return Jw=o,Jw}var Qw,lA;function aQ(){if(lA)return Qw;lA=1;var e=dh(),t=sQ(),n=uh();function r(s,o,l){for(var u=-1,d=o.length,h={};++u<d;){var f=o[u],p=e(s,f);l(p,f)&&t(h,n(f,s),p)}return h}return Qw=r,Qw}var ev,cA;function oQ(){if(cA)return ev;cA=1;var e=aQ(),t=rO();function n(r,s){return e(r,s,function(o,l){return t(r,l)})}return ev=n,ev}var tv,uA;function iQ(){if(uA)return tv;uA=1;var e=kO(),t=dO(),n=hO();function r(s){return n(t(s,void 0,e),s+"")}return tv=r,tv}var nv,dA;function lQ(){if(dA)return nv;dA=1;var e=oQ(),t=iQ(),n=t(function(r,s){return r==null?{}:e(r,s)});return nv=n,nv}var rv,hA;function cQ(){if(hA)return rv;hA=1;var e=Math.ceil,t=Math.max;function n(r,s,o,l){for(var u=-1,d=t(e((s-r)/(o||1)),0),h=Array(d);d--;)h[l?d:++u]=r,r+=o;return h}return rv=n,rv}var sv,fA;function uQ(){if(fA)return sv;fA=1;var e=cQ(),t=fh(),n=bO();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 sv=r,sv}var av,pA;function dQ(){if(pA)return av;pA=1;var e=uQ(),t=e();return av=t,av}var ov,mA;function hQ(){if(mA)return ov;mA=1;function e(t,n){var r=t.length;for(t.sort(n);r--;)t[r]=t[r].value;return t}return ov=e,ov}var iv,gA;function fQ(){if(gA)return iv;gA=1;var e=ji();function t(n,r){if(n!==r){var s=n!==void 0,o=n===null,l=n===n,u=e(n),d=r!==void 0,h=r===null,f=r===r,p=e(r);if(!h&&!p&&!u&&n>r||u&&d&&f&&!h&&!p||o&&d&&f||!s&&f||!l)return 1;if(!o&&!u&&!p&&n<r||p&&s&&l&&!o&&!u||h&&s&&l||!d&&l||!f)return-1}return 0}return iv=t,iv}var lv,yA;function pQ(){if(yA)return lv;yA=1;var e=fQ();function t(n,r,s){for(var o=-1,l=n.criteria,u=r.criteria,d=l.length,h=s.length;++o<d;){var f=e(l[o],u[o]);if(f){if(o>=h)return f;var p=s[o];return f*(p=="desc"?-1:1)}}return n.index-r.index}return lv=t,lv}var cv,wA;function mQ(){if(wA)return cv;wA=1;var e=ch(),t=dh(),n=ps(),r=lO(),s=hQ(),o=ah(),l=pQ(),u=Ka(),d=Nt();function h(f,p,g){p.length?p=e(p,function(b){return d(b)?function(x){return t(x,b.length===1?b[0]:b)}:b}):p=[u];var v=-1;p=e(p,o(n));var k=r(f,function(b,x,N){var S=e(p,function(_){return _(b)});return{criteria:S,index:++v,value:b}});return s(k,function(b,x){return l(b,x,g)})}return cv=h,cv}var uv,vA;function gQ(){if(vA)return uv;vA=1;var e=x0(),t=mQ(),n=hh(),r=fh(),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 uv=s,uv}var dv,xA;function yQ(){if(xA)return dv;xA=1;var e=tO(),t=0;function n(r){var s=++t;return e(r)+s}return dv=n,dv}var hv,bA;function wQ(){if(bA)return hv;bA=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 hv=e,hv}var fv,kA;function vQ(){if(kA)return fv;kA=1;var e=rh(),t=wQ();function n(r,s){return t(r||[],s||[],e)}return fv=n,fv}var pv,NA;function ut(){if(NA)return pv;NA=1;var e;if(typeof a0=="function")try{e={cloneDeep:OJ(),constant:m0(),defaults:LJ(),each:KI(),filter:aO(),find:zJ(),flatten:kO(),forEach:GI(),forIn:WJ(),has:oO(),isUndefined:iO(),last:HJ(),map:cO(),mapValues:VJ(),max:KJ(),merge:eQ(),min:tQ(),minBy:nQ(),now:rQ(),pick:lQ(),range:dQ(),reduce:uO(),sortBy:gQ(),uniqueId:yQ(),values:mO(),zipObject:vQ()}}catch{}return e||(e=window._),pv=e,pv}var mv,jA;function xQ(){if(jA)return mv;jA=1,mv=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 mv}var gv,SA;function bQ(){if(SA)return gv;SA=1;var e=ut(),t=dr().Graph,n=xQ();gv=s;var r=e.constant(1);function s(h,f){if(h.nodeCount()<=1)return[];var p=u(h,f||r),g=o(p.graph,p.buckets,p.zeroIdx);return e.flatten(e.map(g,function(v){return h.outEdges(v.v,v.w)}),!0)}function o(h,f,p){for(var g=[],v=f[f.length-1],k=f[0],b;h.nodeCount();){for(;b=k.dequeue();)l(h,f,p,b);for(;b=v.dequeue();)l(h,f,p,b);if(h.nodeCount()){for(var x=f.length-2;x>0;--x)if(b=f[x].dequeue(),b){g=g.concat(l(h,f,p,b,!0));break}}}return g}function l(h,f,p,g,v){var k=v?[]:void 0;return e.forEach(h.inEdges(g.v),function(b){var x=h.edge(b),N=h.node(b.v);v&&k.push({v:b.v,w:b.w}),N.out-=x,d(f,p,N)}),e.forEach(h.outEdges(g.v),function(b){var x=h.edge(b),N=b.w,S=h.node(N);S.in-=x,d(f,p,S)}),h.removeNode(g.v),k}function u(h,f){var p=new t,g=0,v=0;e.forEach(h.nodes(),function(x){p.setNode(x,{v:x,in:0,out:0})}),e.forEach(h.edges(),function(x){var N=p.edge(x.v,x.w)||0,S=f(x),_=N+S;p.setEdge(x.v,x.w,_),v=Math.max(v,p.node(x.v).out+=S),g=Math.max(g,p.node(x.w).in+=S)});var k=e.range(v+g+3).map(function(){return new n}),b=g+1;return e.forEach(p.nodes(),function(x){d(k,b,p.node(x))}),{graph:p,buckets:k,zeroIdx:b}}function d(h,f,p){p.out?p.in?h[p.out-p.in+f].enqueue(p):h[h.length-1].enqueue(p):h[0].enqueue(p)}return gv}var yv,_A;function kQ(){if(_A)return yv;_A=1;var e=ut(),t=bQ();yv={run:n,undo:s};function n(o){var l=o.graph().acyclicer==="greedy"?t(o,u(o)):r(o);e.forEach(l,function(d){var h=o.edge(d);o.removeEdge(d),h.forwardName=d.name,h.reversed=!0,o.setEdge(d.w,d.v,h,e.uniqueId("rev"))});function u(d){return function(h){return d.edge(h).weight}}}function r(o){var l=[],u={},d={};function h(f){e.has(d,f)||(d[f]=!0,u[f]=!0,e.forEach(o.outEdges(f),function(p){e.has(u,p.w)?l.push(p):h(p.w)}),delete u[f])}return e.forEach(o.nodes(),h),l}function s(o){e.forEach(o.edges(),function(l){var u=o.edge(l);if(u.reversed){o.removeEdge(l);var d=u.forwardName;delete u.reversed,delete u.forwardName,o.setEdge(l.w,l.v,u,d)}})}return yv}var wv,EA;function dn(){if(EA)return wv;EA=1;var e=ut(),t=dr().Graph;wv={addDummyNode:n,simplify:r,asNonCompoundGraph:s,successorWeights:o,predecessorWeights:l,intersectRect:u,buildLayerMatrix:d,normalizeRanks:h,removeEmptyRanks:f,addBorderNode:p,maxRank:g,partition:v,time:k,notime:b};function n(x,N,S,_){var E;do E=e.uniqueId(_);while(x.hasNode(E));return S.dummy=N,x.setNode(E,S),E}function r(x){var N=new t().setGraph(x.graph());return e.forEach(x.nodes(),function(S){N.setNode(S,x.node(S))}),e.forEach(x.edges(),function(S){var _=N.edge(S.v,S.w)||{weight:0,minlen:1},E=x.edge(S);N.setEdge(S.v,S.w,{weight:_.weight+E.weight,minlen:Math.max(_.minlen,E.minlen)})}),N}function s(x){var N=new t({multigraph:x.isMultigraph()}).setGraph(x.graph());return e.forEach(x.nodes(),function(S){x.children(S).length||N.setNode(S,x.node(S))}),e.forEach(x.edges(),function(S){N.setEdge(S,x.edge(S))}),N}function o(x){var N=e.map(x.nodes(),function(S){var _={};return e.forEach(x.outEdges(S),function(E){_[E.w]=(_[E.w]||0)+x.edge(E).weight}),_});return e.zipObject(x.nodes(),N)}function l(x){var N=e.map(x.nodes(),function(S){var _={};return e.forEach(x.inEdges(S),function(E){_[E.v]=(_[E.v]||0)+x.edge(E).weight}),_});return e.zipObject(x.nodes(),N)}function u(x,N){var S=x.x,_=x.y,E=N.x-S,T=N.y-_,A=x.width/2,R=x.height/2;if(!E&&!T)throw new Error("Not possible to find intersection inside of the rectangle");var B,P;return Math.abs(T)*A>Math.abs(E)*R?(T<0&&(R=-R),B=R*E/T,P=R):(E<0&&(A=-A),B=A,P=A*T/E),{x:S+B,y:_+P}}function d(x){var N=e.map(e.range(g(x)+1),function(){return[]});return e.forEach(x.nodes(),function(S){var _=x.node(S),E=_.rank;e.isUndefined(E)||(N[E][_.order]=S)}),N}function h(x){var N=e.min(e.map(x.nodes(),function(S){return x.node(S).rank}));e.forEach(x.nodes(),function(S){var _=x.node(S);e.has(_,"rank")&&(_.rank-=N)})}function f(x){var N=e.min(e.map(x.nodes(),function(T){return x.node(T).rank})),S=[];e.forEach(x.nodes(),function(T){var A=x.node(T).rank-N;S[A]||(S[A]=[]),S[A].push(T)});var _=0,E=x.graph().nodeRankFactor;e.forEach(S,function(T,A){e.isUndefined(T)&&A%E!==0?--_:_&&e.forEach(T,function(R){x.node(R).rank+=_})})}function p(x,N,S,_){var E={width:0,height:0};return arguments.length>=4&&(E.rank=S,E.order=_),n(x,"border",E,N)}function g(x){return e.max(e.map(x.nodes(),function(N){var S=x.node(N).rank;if(!e.isUndefined(S))return S}))}function v(x,N){var S={lhs:[],rhs:[]};return e.forEach(x,function(_){N(_)?S.lhs.push(_):S.rhs.push(_)}),S}function k(x,N){var S=e.now();try{return N()}finally{console.log(x+" time: "+(e.now()-S)+"ms")}}function b(x,N){return N()}return wv}var vv,CA;function NQ(){if(CA)return vv;CA=1;var e=ut(),t=dn();vv={run:n,undo:s};function n(o){o.graph().dummyChains=[],e.forEach(o.edges(),function(l){r(o,l)})}function r(o,l){var u=l.v,d=o.node(u).rank,h=l.w,f=o.node(h).rank,p=l.name,g=o.edge(l),v=g.labelRank;if(f!==d+1){o.removeEdge(l);var k,b,x;for(x=0,++d;d<f;++x,++d)g.points=[],b={width:0,height:0,edgeLabel:g,edgeObj:l,rank:d},k=t.addDummyNode(o,"edge",b,"_d"),d===v&&(b.width=g.width,b.height=g.height,b.dummy="edge-label",b.labelpos=g.labelpos),o.setEdge(u,k,{weight:g.weight},p),x===0&&o.graph().dummyChains.push(k),u=k;o.setEdge(u,h,{weight:g.weight},p)}}function s(o){e.forEach(o.graph().dummyChains,function(l){var u=o.node(l),d=u.edgeLabel,h;for(o.setEdge(u.edgeObj,d);u.dummy;)h=o.successors(l)[0],o.removeNode(l),d.points.push({x:u.x,y:u.y}),u.dummy==="edge-label"&&(d.x=u.x,d.y=u.y,d.width=u.width,d.height=u.height),l=h,u=o.node(l)})}return vv}var xv,TA;function wd(){if(TA)return xv;TA=1;var e=ut();xv={longestPath:t,slack:n};function t(r){var s={};function o(l){var u=r.node(l);if(e.has(s,l))return u.rank;s[l]=!0;var d=e.min(e.map(r.outEdges(l),function(h){return o(h.w)-r.edge(h).minlen}));return(d===Number.POSITIVE_INFINITY||d===void 0||d===null)&&(d=0),u.rank=d}e.forEach(r.sources(),o)}function n(r,s){return r.node(s.w).rank-r.node(s.v).rank-r.edge(s).minlen}return xv}var bv,AA;function _O(){if(AA)return bv;AA=1;var e=ut(),t=dr().Graph,n=wd().slack;bv=r;function r(u){var d=new t({directed:!1}),h=u.nodes()[0],f=u.nodeCount();d.setNode(h,{});for(var p,g;s(d,u)<f;)p=o(d,u),g=d.hasNode(p.v)?n(u,p):-n(u,p),l(d,u,g);return d}function s(u,d){function h(f){e.forEach(d.nodeEdges(f),function(p){var g=p.v,v=f===g?p.w:g;!u.hasNode(v)&&!n(d,p)&&(u.setNode(v,{}),u.setEdge(f,v,{}),h(v))})}return e.forEach(u.nodes(),h),u.nodeCount()}function o(u,d){return e.minBy(d.edges(),function(h){if(u.hasNode(h.v)!==u.hasNode(h.w))return n(d,h)})}function l(u,d,h){e.forEach(u.nodes(),function(f){d.node(f).rank+=h})}return bv}var kv,RA;function jQ(){if(RA)return kv;RA=1;var e=ut(),t=_O(),n=wd().slack,r=wd().longestPath,s=dr().alg.preorder,o=dr().alg.postorder,l=dn().simplify;kv=u,u.initLowLimValues=p,u.initCutValues=d,u.calcCutValue=f,u.leaveEdge=v,u.enterEdge=k,u.exchangeEdges=b;function u(_){_=l(_),r(_);var E=t(_);p(E),d(E,_);for(var T,A;T=v(E);)A=k(E,_,T),b(E,_,T,A)}function d(_,E){var T=o(_,_.nodes());T=T.slice(0,T.length-1),e.forEach(T,function(A){h(_,E,A)})}function h(_,E,T){var A=_.node(T),R=A.parent;_.edge(T,R).cutvalue=f(_,E,T)}function f(_,E,T){var A=_.node(T),R=A.parent,B=!0,P=E.edge(T,R),D=0;return P||(B=!1,P=E.edge(R,T)),D=P.weight,e.forEach(E.nodeEdges(T),function(O){var L=O.v===T,z=L?O.w:O.v;if(z!==R){var M=L===B,$=E.edge(O).weight;if(D+=M?$:-$,N(_,T,z)){var q=_.edge(T,z).cutvalue;D+=M?-q:q}}}),D}function p(_,E){arguments.length<2&&(E=_.nodes()[0]),g(_,{},1,E)}function g(_,E,T,A,R){var B=T,P=_.node(A);return E[A]=!0,e.forEach(_.neighbors(A),function(D){e.has(E,D)||(T=g(_,E,T,D,A))}),P.low=B,P.lim=T++,R?P.parent=R:delete P.parent,T}function v(_){return e.find(_.edges(),function(E){return _.edge(E).cutvalue<0})}function k(_,E,T){var A=T.v,R=T.w;E.hasEdge(A,R)||(A=T.w,R=T.v);var B=_.node(A),P=_.node(R),D=B,O=!1;B.lim>P.lim&&(D=P,O=!0);var L=e.filter(E.edges(),function(z){return O===S(_,_.node(z.v),D)&&O!==S(_,_.node(z.w),D)});return e.minBy(L,function(z){return n(E,z)})}function b(_,E,T,A){var R=T.v,B=T.w;_.removeEdge(R,B),_.setEdge(A.v,A.w,{}),p(_),d(_,E),x(_,E)}function x(_,E){var T=e.find(_.nodes(),function(R){return!E.node(R).parent}),A=s(_,T);A=A.slice(1),e.forEach(A,function(R){var B=_.node(R).parent,P=E.edge(R,B),D=!1;P||(P=E.edge(B,R),D=!0),E.node(R).rank=E.node(B).rank+(D?P.minlen:-P.minlen)})}function N(_,E,T){return _.hasEdge(E,T)}function S(_,E,T){return T.low<=E.lim&&E.lim<=T.lim}return kv}var Nv,MA;function SQ(){if(MA)return Nv;MA=1;var e=wd(),t=e.longestPath,n=_O(),r=jQ();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 jv,$A;function _Q(){if($A)return jv;$A=1;var e=ut();jv=t;function t(s){var o=r(s);e.forEach(s.graph().dummyChains,function(l){for(var u=s.node(l),d=u.edgeObj,h=n(s,o,d.v,d.w),f=h.path,p=h.lca,g=0,v=f[g],k=!0;l!==d.w;){if(u=s.node(l),k){for(;(v=f[g])!==p&&s.node(v).maxRank<u.rank;)g++;v===p&&(k=!1)}if(!k){for(;g<f.length-1&&s.node(v=f[g+1]).minRank<=u.rank;)g++;v=f[g]}s.setParent(l,v),l=s.successors(l)[0]}})}function n(s,o,l,u){var d=[],h=[],f=Math.min(o[l].low,o[u].low),p=Math.max(o[l].lim,o[u].lim),g,v;g=l;do g=s.parent(g),d.push(g);while(g&&(o[g].low>f||p>o[g].lim));for(v=g,g=u;(g=s.parent(g))!==v;)h.push(g);return{path:d.concat(h.reverse()),lca:v}}function r(s){var o={},l=0;function u(d){var h=l;e.forEach(s.children(d),u),o[d]={low:h,lim:l++}}return e.forEach(s.children(),u),o}return jv}var Sv,IA;function EQ(){if(IA)return Sv;IA=1;var e=ut(),t=dn();Sv={run:n,cleanup:l};function n(u){var d=t.addDummyNode(u,"root",{},"_root"),h=s(u),f=e.max(e.values(h))-1,p=2*f+1;u.graph().nestingRoot=d,e.forEach(u.edges(),function(v){u.edge(v).minlen*=p});var g=o(u)+1;e.forEach(u.children(),function(v){r(u,d,p,g,f,h,v)}),u.graph().nodeRankFactor=p}function r(u,d,h,f,p,g,v){var k=u.children(v);if(!k.length){v!==d&&u.setEdge(d,v,{weight:0,minlen:h});return}var b=t.addBorderNode(u,"_bt"),x=t.addBorderNode(u,"_bb"),N=u.node(v);u.setParent(b,v),N.borderTop=b,u.setParent(x,v),N.borderBottom=x,e.forEach(k,function(S){r(u,d,h,f,p,g,S);var _=u.node(S),E=_.borderTop?_.borderTop:S,T=_.borderBottom?_.borderBottom:S,A=_.borderTop?f:2*f,R=E!==T?1:p-g[v]+1;u.setEdge(b,E,{weight:A,minlen:R,nestingEdge:!0}),u.setEdge(T,x,{weight:A,minlen:R,nestingEdge:!0})}),u.parent(v)||u.setEdge(d,b,{weight:0,minlen:p+g[v]})}function s(u){var d={};function h(f,p){var g=u.children(f);g&&g.length&&e.forEach(g,function(v){h(v,p+1)}),d[f]=p}return e.forEach(u.children(),function(f){h(f,1)}),d}function o(u){return e.reduce(u.edges(),function(d,h){return d+u.edge(h).weight},0)}function l(u){var d=u.graph();u.removeNode(d.nestingRoot),delete d.nestingRoot,e.forEach(u.edges(),function(h){var f=u.edge(h);f.nestingEdge&&u.removeEdge(h)})}return Sv}var _v,OA;function CQ(){if(OA)return _v;OA=1;var e=ut(),t=dn();_v=n;function n(s){function o(l){var u=s.children(l),d=s.node(l);if(u.length&&e.forEach(u,o),e.has(d,"minRank")){d.borderLeft=[],d.borderRight=[];for(var h=d.minRank,f=d.maxRank+1;h<f;++h)r(s,"borderLeft","_bl",l,d,h),r(s,"borderRight","_br",l,d,h)}}e.forEach(s.children(),o)}function r(s,o,l,u,d,h){var f={width:0,height:0,rank:h,borderType:o},p=d[o][h-1],g=t.addDummyNode(s,"border",f,l);d[o][h]=g,s.setParent(g,u),p&&s.setEdge(p,g,{weight:1})}return _v}var Ev,LA;function TQ(){if(LA)return Ev;LA=1;var e=ut();Ev={adjust:t,undo:n};function t(h){var f=h.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&r(h)}function n(h){var f=h.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&o(h),(f==="lr"||f==="rl")&&(u(h),r(h))}function r(h){e.forEach(h.nodes(),function(f){s(h.node(f))}),e.forEach(h.edges(),function(f){s(h.edge(f))})}function s(h){var f=h.width;h.width=h.height,h.height=f}function o(h){e.forEach(h.nodes(),function(f){l(h.node(f))}),e.forEach(h.edges(),function(f){var p=h.edge(f);e.forEach(p.points,l),e.has(p,"y")&&l(p)})}function l(h){h.y=-h.y}function u(h){e.forEach(h.nodes(),function(f){d(h.node(f))}),e.forEach(h.edges(),function(f){var p=h.edge(f);e.forEach(p.points,d),e.has(p,"x")&&d(p)})}function d(h){var f=h.x;h.x=h.y,h.y=f}return Ev}var Cv,PA;function AQ(){if(PA)return Cv;PA=1;var e=ut();Cv=t;function t(n){var r={},s=e.filter(n.nodes(),function(h){return!n.children(h).length}),o=e.max(e.map(s,function(h){return n.node(h).rank})),l=e.map(e.range(o+1),function(){return[]});function u(h){if(!e.has(r,h)){r[h]=!0;var f=n.node(h);l[f.rank].push(h),e.forEach(n.successors(h),u)}}var d=e.sortBy(s,function(h){return n.node(h).rank});return e.forEach(d,u),l}return Cv}var Tv,DA;function RQ(){if(DA)return Tv;DA=1;var e=ut();Tv=t;function t(r,s){for(var o=0,l=1;l<s.length;++l)o+=n(r,s[l-1],s[l]);return o}function n(r,s,o){for(var l=e.zipObject(o,e.map(o,function(g,v){return v})),u=e.flatten(e.map(s,function(g){return e.sortBy(e.map(r.outEdges(g),function(v){return{pos:l[v.w],weight:r.edge(v).weight}}),"pos")}),!0),d=1;d<o.length;)d<<=1;var h=2*d-1;d-=1;var f=e.map(new Array(h),function(){return 0}),p=0;return e.forEach(u.forEach(function(g){var v=g.pos+d;f[v]+=g.weight;for(var k=0;v>0;)v%2&&(k+=f[v+1]),v=v-1>>1,f[v]+=g.weight;p+=g.weight*k})),p}return Tv}var Av,FA;function MQ(){if(FA)return Av;FA=1;var e=ut();Av=t;function t(n,r){return e.map(r,function(s){var o=n.inEdges(s);if(o.length){var l=e.reduce(o,function(u,d){var h=n.edge(d),f=n.node(d.v);return{sum:u.sum+h.weight*f.order,weight:u.weight+h.weight}},{sum:0,weight:0});return{v:s,barycenter:l.sum/l.weight,weight:l.weight}}else return{v:s}})}return Av}var Rv,BA;function $Q(){if(BA)return Rv;BA=1;var e=ut();Rv=t;function t(s,o){var l={};e.forEach(s,function(d,h){var f=l[d.v]={indegree:0,in:[],out:[],vs:[d.v],i:h};e.isUndefined(d.barycenter)||(f.barycenter=d.barycenter,f.weight=d.weight)}),e.forEach(o.edges(),function(d){var h=l[d.v],f=l[d.w];!e.isUndefined(h)&&!e.isUndefined(f)&&(f.indegree++,h.out.push(l[d.w]))});var u=e.filter(l,function(d){return!d.indegree});return n(u)}function n(s){var o=[];function l(h){return function(f){f.merged||(e.isUndefined(f.barycenter)||e.isUndefined(h.barycenter)||f.barycenter>=h.barycenter)&&r(h,f)}}function u(h){return function(f){f.in.push(h),--f.indegree===0&&s.push(f)}}for(;s.length;){var d=s.pop();o.push(d),e.forEach(d.in.reverse(),l(d)),e.forEach(d.out,u(d))}return e.map(e.filter(o,function(h){return!h.merged}),function(h){return e.pick(h,["vs","i","barycenter","weight"])})}function r(s,o){var l=0,u=0;s.weight&&(l+=s.barycenter*s.weight,u+=s.weight),o.weight&&(l+=o.barycenter*o.weight,u+=o.weight),s.vs=o.vs.concat(s.vs),s.barycenter=l/u,s.weight=u,s.i=Math.min(o.i,s.i),o.merged=!0}return Rv}var Mv,qA;function IQ(){if(qA)return Mv;qA=1;var e=ut(),t=dn();Mv=n;function n(o,l){var u=t.partition(o,function(b){return e.has(b,"barycenter")}),d=u.lhs,h=e.sortBy(u.rhs,function(b){return-b.i}),f=[],p=0,g=0,v=0;d.sort(s(!!l)),v=r(f,h,v),e.forEach(d,function(b){v+=b.vs.length,f.push(b.vs),p+=b.barycenter*b.weight,g+=b.weight,v=r(f,h,v)});var k={vs:e.flatten(f,!0)};return g&&(k.barycenter=p/g,k.weight=g),k}function r(o,l,u){for(var d;l.length&&(d=e.last(l)).i<=u;)l.pop(),o.push(d.vs),u++;return u}function s(o){return function(l,u){return l.barycenter<u.barycenter?-1:l.barycenter>u.barycenter?1:o?u.i-l.i:l.i-u.i}}return Mv}var $v,UA;function OQ(){if(UA)return $v;UA=1;var e=ut(),t=MQ(),n=$Q(),r=IQ();$v=s;function s(u,d,h,f){var p=u.children(d),g=u.node(d),v=g?g.borderLeft:void 0,k=g?g.borderRight:void 0,b={};v&&(p=e.filter(p,function(T){return T!==v&&T!==k}));var x=t(u,p);e.forEach(x,function(T){if(u.children(T.v).length){var A=s(u,T.v,h,f);b[T.v]=A,e.has(A,"barycenter")&&l(T,A)}});var N=n(x,h);o(N,b);var S=r(N,f);if(v&&(S.vs=e.flatten([v,S.vs,k],!0),u.predecessors(v).length)){var _=u.node(u.predecessors(v)[0]),E=u.node(u.predecessors(k)[0]);e.has(S,"barycenter")||(S.barycenter=0,S.weight=0),S.barycenter=(S.barycenter*S.weight+_.order+E.order)/(S.weight+2),S.weight+=2}return S}function o(u,d){e.forEach(u,function(h){h.vs=e.flatten(h.vs.map(function(f){return d[f]?d[f].vs:f}),!0)})}function l(u,d){e.isUndefined(u.barycenter)?(u.barycenter=d.barycenter,u.weight=d.weight):(u.barycenter=(u.barycenter*u.weight+d.barycenter*d.weight)/(u.weight+d.weight),u.weight+=d.weight)}return $v}var Iv,zA;function LQ(){if(zA)return Iv;zA=1;var e=ut(),t=dr().Graph;Iv=n;function n(s,o,l){var u=r(s),d=new t({compound:!0}).setGraph({root:u}).setDefaultNodeLabel(function(h){return s.node(h)});return e.forEach(s.nodes(),function(h){var f=s.node(h),p=s.parent(h);(f.rank===o||f.minRank<=o&&o<=f.maxRank)&&(d.setNode(h),d.setParent(h,p||u),e.forEach(s[l](h),function(g){var v=g.v===h?g.w:g.v,k=d.edge(v,h),b=e.isUndefined(k)?0:k.weight;d.setEdge(v,h,{weight:s.edge(g).weight+b})}),e.has(f,"minRank")&&d.setNode(h,{borderLeft:f.borderLeft[o],borderRight:f.borderRight[o]}))}),d}function r(s){for(var o;s.hasNode(o=e.uniqueId("_root")););return o}return Iv}var Ov,WA;function PQ(){if(WA)return Ov;WA=1;var e=ut();Ov=t;function t(n,r,s){var o={},l;e.forEach(s,function(u){for(var d=n.parent(u),h,f;d;){if(h=n.parent(d),h?(f=o[h],o[h]=d):(f=l,l=d),f&&f!==d){r.setEdge(f,d);return}d=h}})}return Ov}var Lv,HA;function DQ(){if(HA)return Lv;HA=1;var e=ut(),t=AQ(),n=RQ(),r=OQ(),s=LQ(),o=PQ(),l=dr().Graph,u=dn();Lv=d;function d(g){var v=u.maxRank(g),k=h(g,e.range(1,v+1),"inEdges"),b=h(g,e.range(v-1,-1,-1),"outEdges"),x=t(g);p(g,x);for(var N=Number.POSITIVE_INFINITY,S,_=0,E=0;E<4;++_,++E){f(_%2?k:b,_%4>=2),x=u.buildLayerMatrix(g);var T=n(g,x);T<N&&(E=0,S=e.cloneDeep(x),N=T)}p(g,S)}function h(g,v,k){return e.map(v,function(b){return s(g,b,k)})}function f(g,v){var k=new l;e.forEach(g,function(b){var x=b.graph().root,N=r(b,x,k,v);e.forEach(N.vs,function(S,_){b.node(S).order=_}),o(b,k,N.vs)})}function p(g,v){e.forEach(v,function(k){e.forEach(k,function(b,x){g.node(b).order=x})})}return Lv}var Pv,VA;function FQ(){if(VA)return Pv;VA=1;var e=ut(),t=dr().Graph,n=dn();Pv={positionX:k,findType1Conflicts:r,findType2Conflicts:s,addConflict:l,hasConflict:u,verticalAlignment:d,horizontalCompaction:h,alignCoordinates:g,findSmallestWidthAlignment:p,balance:v};function r(N,S){var _={};function E(T,A){var R=0,B=0,P=T.length,D=e.last(A);return e.forEach(A,function(O,L){var z=o(N,O),M=z?N.node(z).order:P;(z||O===D)&&(e.forEach(A.slice(B,L+1),function($){e.forEach(N.predecessors($),function(q){var X=N.node(q),H=X.order;(H<R||M<H)&&!(X.dummy&&N.node($).dummy)&&l(_,q,$)})}),B=L+1,R=M)}),A}return e.reduce(S,E),_}function s(N,S){var _={};function E(A,R,B,P,D){var O;e.forEach(e.range(R,B),function(L){O=A[L],N.node(O).dummy&&e.forEach(N.predecessors(O),function(z){var M=N.node(z);M.dummy&&(M.order<P||M.order>D)&&l(_,z,O)})})}function T(A,R){var B=-1,P,D=0;return e.forEach(R,function(O,L){if(N.node(O).dummy==="border"){var z=N.predecessors(O);z.length&&(P=N.node(z[0]).order,E(R,D,L,B,P),D=L,B=P)}E(R,D,R.length,P,A.length)}),R}return e.reduce(S,T),_}function o(N,S){if(N.node(S).dummy)return e.find(N.predecessors(S),function(_){return N.node(_).dummy})}function l(N,S,_){if(S>_){var E=S;S=_,_=E}var T=N[S];T||(N[S]=T={}),T[_]=!0}function u(N,S,_){if(S>_){var E=S;S=_,_=E}return e.has(N[S],_)}function d(N,S,_,E){var T={},A={},R={};return e.forEach(S,function(B){e.forEach(B,function(P,D){T[P]=P,A[P]=P,R[P]=D})}),e.forEach(S,function(B){var P=-1;e.forEach(B,function(D){var O=E(D);if(O.length){O=e.sortBy(O,function(q){return R[q]});for(var L=(O.length-1)/2,z=Math.floor(L),M=Math.ceil(L);z<=M;++z){var $=O[z];A[D]===D&&P<R[$]&&!u(_,D,$)&&(A[$]=D,A[D]=T[D]=T[$],P=R[$])}}})}),{root:T,align:A}}function h(N,S,_,E,T){var A={},R=f(N,S,_,T),B=T?"borderLeft":"borderRight";function P(L,z){for(var M=R.nodes(),$=M.pop(),q={};$;)q[$]?L($):(q[$]=!0,M.push($),M=M.concat(z($))),$=M.pop()}function D(L){A[L]=R.inEdges(L).reduce(function(z,M){return Math.max(z,A[M.v]+R.edge(M))},0)}function O(L){var z=R.outEdges(L).reduce(function($,q){return Math.min($,A[q.w]-R.edge(q))},Number.POSITIVE_INFINITY),M=N.node(L);z!==Number.POSITIVE_INFINITY&&M.borderType!==B&&(A[L]=Math.max(A[L],z))}return P(D,R.predecessors.bind(R)),P(O,R.successors.bind(R)),e.forEach(E,function(L){A[L]=A[_[L]]}),A}function f(N,S,_,E){var T=new t,A=N.graph(),R=b(A.nodesep,A.edgesep,E);return e.forEach(S,function(B){var P;e.forEach(B,function(D){var O=_[D];if(T.setNode(O),P){var L=_[P],z=T.edge(L,O);T.setEdge(L,O,Math.max(R(N,D,P),z||0))}P=D})}),T}function p(N,S){return e.minBy(e.values(S),function(_){var E=Number.NEGATIVE_INFINITY,T=Number.POSITIVE_INFINITY;return e.forIn(_,function(A,R){var B=x(N,R)/2;E=Math.max(A+B,E),T=Math.min(A-B,T)}),E-T})}function g(N,S){var _=e.values(S),E=e.min(_),T=e.max(_);e.forEach(["u","d"],function(A){e.forEach(["l","r"],function(R){var B=A+R,P=N[B],D;if(P!==S){var O=e.values(P);D=R==="l"?E-e.min(O):T-e.max(O),D&&(N[B]=e.mapValues(P,function(L){return L+D}))}})})}function v(N,S){return e.mapValues(N.ul,function(_,E){if(S)return N[S.toLowerCase()][E];var T=e.sortBy(e.map(N,E));return(T[1]+T[2])/2})}function k(N){var S=n.buildLayerMatrix(N),_=e.merge(r(N,S),s(N,S)),E={},T;e.forEach(["u","d"],function(R){T=R==="u"?S:e.values(S).reverse(),e.forEach(["l","r"],function(B){B==="r"&&(T=e.map(T,function(L){return e.values(L).reverse()}));var P=(R==="u"?N.predecessors:N.successors).bind(N),D=d(N,T,_,P),O=h(N,T,D.root,D.align,B==="r");B==="r"&&(O=e.mapValues(O,function(L){return-L})),E[R+B]=O})});var A=p(N,E);return g(E,A),v(E,N.graph().align)}function b(N,S,_){return function(E,T,A){var R=E.node(T),B=E.node(A),P=0,D;if(P+=R.width/2,e.has(R,"labelpos"))switch(R.labelpos.toLowerCase()){case"l":D=-R.width/2;break;case"r":D=R.width/2;break}if(D&&(P+=_?D:-D),D=0,P+=(R.dummy?S:N)/2,P+=(B.dummy?S:N)/2,P+=B.width/2,e.has(B,"labelpos"))switch(B.labelpos.toLowerCase()){case"l":D=B.width/2;break;case"r":D=-B.width/2;break}return D&&(P+=_?D:-D),D=0,P}}function x(N,S){return N.node(S).width}return Pv}var Dv,GA;function BQ(){if(GA)return Dv;GA=1;var e=ut(),t=dn(),n=FQ().positionX;Dv=r;function r(o){o=t.asNonCompoundGraph(o),s(o),e.forEach(n(o),function(l,u){o.node(u).x=l})}function s(o){var l=t.buildLayerMatrix(o),u=o.graph().ranksep,d=0;e.forEach(l,function(h){var f=e.max(e.map(h,function(p){return o.node(p).height}));e.forEach(h,function(p){o.node(p).y=d+f/2}),d+=f+u})}return Dv}var Fv,KA;function qQ(){if(KA)return Fv;KA=1;var e=ut(),t=kQ(),n=NQ(),r=SQ(),s=dn().normalizeRanks,o=_Q(),l=dn().removeEmptyRanks,u=EQ(),d=CQ(),h=TQ(),f=DQ(),p=BQ(),g=dn(),v=dr().Graph;Fv=k;function k(V,G){var K=G&&G.debugTiming?g.time:g.notime;K("layout",function(){var Z=K(" buildLayoutGraph",function(){return P(V)});K(" runLayout",function(){b(Z,K)}),K(" updateInputGraph",function(){x(V,Z)})})}function b(V,G){G(" makeSpaceForEdgeLabels",function(){D(V)}),G(" removeSelfEdges",function(){I(V)}),G(" acyclic",function(){t.run(V)}),G(" nestingGraph.run",function(){u.run(V)}),G(" rank",function(){r(g.asNonCompoundGraph(V))}),G(" injectEdgeLabelProxies",function(){O(V)}),G(" removeEmptyRanks",function(){l(V)}),G(" nestingGraph.cleanup",function(){u.cleanup(V)}),G(" normalizeRanks",function(){s(V)}),G(" assignRankMinMax",function(){L(V)}),G(" removeEdgeLabelProxies",function(){z(V)}),G(" normalize.run",function(){n.run(V)}),G(" parentDummyChains",function(){o(V)}),G(" addBorderSegments",function(){d(V)}),G(" order",function(){f(V)}),G(" insertSelfEdges",function(){W(V)}),G(" adjustCoordinateSystem",function(){h.adjust(V)}),G(" position",function(){p(V)}),G(" positionSelfEdges",function(){F(V)}),G(" removeBorderNodes",function(){H(V)}),G(" normalize.undo",function(){n.undo(V)}),G(" fixupEdgeLabelCoords",function(){q(V)}),G(" undoCoordinateSystem",function(){h.undo(V)}),G(" translateGraph",function(){M(V)}),G(" assignNodeIntersects",function(){$(V)}),G(" reversePoints",function(){X(V)}),G(" acyclic.undo",function(){t.undo(V)})}function x(V,G){e.forEach(V.nodes(),function(K){var Z=V.node(K),ee=G.node(K);Z&&(Z.x=ee.x,Z.y=ee.y,G.children(K).length&&(Z.width=ee.width,Z.height=ee.height))}),e.forEach(V.edges(),function(K){var Z=V.edge(K),ee=G.edge(K);Z.points=ee.points,e.has(ee,"x")&&(Z.x=ee.x,Z.y=ee.y)}),V.graph().width=G.graph().width,V.graph().height=G.graph().height}var N=["nodesep","edgesep","ranksep","marginx","marginy"],S={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},_=["acyclicer","ranker","rankdir","align"],E=["width","height"],T={width:0,height:0},A=["minlen","weight","width","height","labeloffset"],R={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},B=["labelpos"];function P(V){var G=new v({multigraph:!0,compound:!0}),K=J(V.graph());return G.setGraph(e.merge({},S,Y(K,N),e.pick(K,_))),e.forEach(V.nodes(),function(Z){var ee=J(V.node(Z));G.setNode(Z,e.defaults(Y(ee,E),T)),G.setParent(Z,V.parent(Z))}),e.forEach(V.edges(),function(Z){var ee=J(V.edge(Z));G.setEdge(Z,e.merge({},R,Y(ee,A),e.pick(ee,B)))}),G}function D(V){var G=V.graph();G.ranksep/=2,e.forEach(V.edges(),function(K){var Z=V.edge(K);Z.minlen*=2,Z.labelpos.toLowerCase()!=="c"&&(G.rankdir==="TB"||G.rankdir==="BT"?Z.width+=Z.labeloffset:Z.height+=Z.labeloffset)})}function O(V){e.forEach(V.edges(),function(G){var K=V.edge(G);if(K.width&&K.height){var Z=V.node(G.v),ee=V.node(G.w),re={rank:(ee.rank-Z.rank)/2+Z.rank,e:G};g.addDummyNode(V,"edge-proxy",re,"_ep")}})}function L(V){var G=0;e.forEach(V.nodes(),function(K){var Z=V.node(K);Z.borderTop&&(Z.minRank=V.node(Z.borderTop).rank,Z.maxRank=V.node(Z.borderBottom).rank,G=e.max(G,Z.maxRank))}),V.graph().maxRank=G}function z(V){e.forEach(V.nodes(),function(G){var K=V.node(G);K.dummy==="edge-proxy"&&(V.edge(K.e).labelRank=K.rank,V.removeNode(G))})}function M(V){var G=Number.POSITIVE_INFINITY,K=0,Z=Number.POSITIVE_INFINITY,ee=0,re=V.graph(),ue=re.marginx||0,me=re.marginy||0;function ae(pe){var xe=pe.x,se=pe.y,ve=pe.width,fe=pe.height;G=Math.min(G,xe-ve/2),K=Math.max(K,xe+ve/2),Z=Math.min(Z,se-fe/2),ee=Math.max(ee,se+fe/2)}e.forEach(V.nodes(),function(pe){ae(V.node(pe))}),e.forEach(V.edges(),function(pe){var xe=V.edge(pe);e.has(xe,"x")&&ae(xe)}),G-=ue,Z-=me,e.forEach(V.nodes(),function(pe){var xe=V.node(pe);xe.x-=G,xe.y-=Z}),e.forEach(V.edges(),function(pe){var xe=V.edge(pe);e.forEach(xe.points,function(se){se.x-=G,se.y-=Z}),e.has(xe,"x")&&(xe.x-=G),e.has(xe,"y")&&(xe.y-=Z)}),re.width=K-G+ue,re.height=ee-Z+me}function $(V){e.forEach(V.edges(),function(G){var K=V.edge(G),Z=V.node(G.v),ee=V.node(G.w),re,ue;K.points?(re=K.points[0],ue=K.points[K.points.length-1]):(K.points=[],re=ee,ue=Z),K.points.unshift(g.intersectRect(Z,re)),K.points.push(g.intersectRect(ee,ue))})}function q(V){e.forEach(V.edges(),function(G){var K=V.edge(G);if(e.has(K,"x"))switch((K.labelpos==="l"||K.labelpos==="r")&&(K.width-=K.labeloffset),K.labelpos){case"l":K.x-=K.width/2+K.labeloffset;break;case"r":K.x+=K.width/2+K.labeloffset;break}})}function X(V){e.forEach(V.edges(),function(G){var K=V.edge(G);K.reversed&&K.points.reverse()})}function H(V){e.forEach(V.nodes(),function(G){if(V.children(G).length){var K=V.node(G),Z=V.node(K.borderTop),ee=V.node(K.borderBottom),re=V.node(e.last(K.borderLeft)),ue=V.node(e.last(K.borderRight));K.width=Math.abs(ue.x-re.x),K.height=Math.abs(ee.y-Z.y),K.x=re.x+K.width/2,K.y=Z.y+K.height/2}}),e.forEach(V.nodes(),function(G){V.node(G).dummy==="border"&&V.removeNode(G)})}function I(V){e.forEach(V.edges(),function(G){if(G.v===G.w){var K=V.node(G.v);K.selfEdges||(K.selfEdges=[]),K.selfEdges.push({e:G,label:V.edge(G)}),V.removeEdge(G)}})}function W(V){var G=g.buildLayerMatrix(V);e.forEach(G,function(K){var Z=0;e.forEach(K,function(ee,re){var ue=V.node(ee);ue.order=re+Z,e.forEach(ue.selfEdges,function(me){g.addDummyNode(V,"selfedge",{width:me.label.width,height:me.label.height,rank:ue.rank,order:re+ ++Z,e:me.e,label:me.label},"_se")}),delete ue.selfEdges})})}function F(V){e.forEach(V.nodes(),function(G){var K=V.node(G);if(K.dummy==="selfedge"){var Z=V.node(K.e.v),ee=Z.x+Z.width/2,re=Z.y,ue=K.x-ee,me=Z.height/2;V.setEdge(K.e,K.label),V.removeNode(G),K.label.points=[{x:ee+2*ue/3,y:re-me},{x:ee+5*ue/6,y:re-me},{x:ee+ue,y:re},{x:ee+5*ue/6,y:re+me},{x:ee+2*ue/3,y:re+me}],K.label.x=K.x,K.label.y=K.y}})}function Y(V,G){return e.mapValues(e.pick(V,G),Number)}function J(V){var G={};return e.forEach(V,function(K,Z){G[Z.toLowerCase()]=K}),G}return Fv}var Bv,YA;function UQ(){if(YA)return Bv;YA=1;var e=ut(),t=dn(),n=dr().Graph;Bv={debugOrdering:r};function r(s){var o=t.buildLayerMatrix(s),l=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(s.nodes(),function(u){l.setNode(u,{label:u}),l.setParent(u,"layer"+s.node(u).rank)}),e.forEach(s.edges(),function(u){l.setEdge(u.v,u.w,{},u.name)}),e.forEach(o,function(u,d){var h="layer"+d;l.setNode(h,{rank:"same"}),e.reduce(u,function(f,p){return l.setEdge(f,p,{style:"invis"}),p})}),l}return Bv}var qv,XA;function zQ(){return XA||(XA=1,qv="0.8.5"),qv}var Uv,ZA;function WQ(){return ZA||(ZA=1,Uv={graphlib:dr(),layout:qQ(),debug:UQ(),util:{time:dn().time,notime:dn().notime},version:zQ()}),Uv}var HQ=WQ();const JA=sb(HQ),vd=240,EO=130,Vx=Aa*2+xx+s$,VQ=72,ti=Vx+VQ,Hu=24,CO=Aa*2+Hu,xd=ti;function TO(e,t){var r;let n=vd;for(const s of e)n=Math.max(n,((r=t.get(s.id))==null?void 0:r.width)??vd);return n}const bd=420,AO=1;function GQ(e,t,n,r){return Math.min(AO,n/Math.max(1,e),r/Math.max(1,t))}function ph(e){var n;return((n=e.data)==null?void 0:n.sessionId)??"_default"}function mh(e,t=()=>!0){const n=new Map;for(const r of e){if(!t(r))continue;const s=ph(r),o=n.get(s);o?o.push(r):n.set(s,[r])}return n}function KQ(e,t){return((t==null?void 0:t.get(e))??0)>0?bd:0}function YQ(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function kd(e,t){const n=t.get(e);return{w:(n==null?void 0:n.width)??vd,h:(n==null?void 0:n.height)??EO}}function Gl(e,t,n){const r=kd(e,t);return{w:r.w+KQ(e,n),h:Math.max(r.h,YQ(e,n))}}function XQ(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function ZQ(e,t,n){const r=mh(e,s=>!t.has(s.id)&&n(s.id)!=null);if(r.size===0)return e;for(const s of r.values())s.sort((o,l)=>o.id.localeCompare(l.id));return e.map(s=>{var h;if(t.has(s.id)||n(s.id))return s;const o=r.get(ph(s));if(!o)return s;const l=(h=s.data)==null?void 0:h.parentId,u=o.find(f=>f.id===l)??o[0],d=n(u.id);return{...s,position:{x:s.position.x+d.x-u.position.x,y:s.position.y+d.y-u.position.y}}})}function JQ(e,t,n,r,s,o,l){const u=_=>Gl(_,r,o),d=_=>n.get(_)??t.get(_),h=_=>{const{w:E,h:T}=kd(_,r);return{cw:E,ch:T}},f=l!=null&&l.width>0&&l.height>0,p=mh(e,_=>d(_.id)!=null),g=new Set;for(const[_,E]of p)E.every(T=>s.has(T.id)&&!n.has(T.id))&&g.add(_);const v=new Map,k=[];for(const _ of e){const E=d(_.id);if(!E)continue;const{w:T,h:A}=u(_.id),R=ph(_);g.has(R)?(v.get(R)??v.set(R,[]).get(R)).push(_):k.push({x:E.x,y:E.y,w:T,h:A,...h(_.id)})}if(v.size===0||f&&k.length===0)return[];const b=xd,x=(_,E,T,A)=>k.some(R=>_<R.x+R.w+Vx&&R.x<_+T+Vx&&E<R.y+R.h+b&&R.y<E+A+b),N=TO(e,r),S=[];for(const _ of[...v.keys()].sort()){const E=v.get(_);let T=1/0,A=1/0,R=-1/0,B=-1/0,P=-1/0,D=-1/0;for(const X of E){const H=d(X.id),{w:I,h:W}=u(X.id),{cw:F,ch:Y}=h(X.id);T=Math.min(T,H.x),A=Math.min(A,H.y),R=Math.max(R,H.x+I),B=Math.max(B,H.y+W),P=Math.max(P,H.x+F),D=Math.max(D,H.y+Y)}const O=R-T,L=B-A,z=[...new Set(k.map(X=>Math.round(X.x)))].sort((X,H)=>X-H),M=z.length?z:[T],$=[0,...k.map(X=>X.y+X.h+b)].sort((X,H)=>X-H);let q=null;if(f){let X=1/0,H=1/0,I=-1/0,W=-1/0;for(const K of k)X=Math.min(X,K.x),H=Math.min(H,K.y),I=Math.max(I,K.x+K.cw),W=Math.max(W,K.y+K.ch);const F=(K,Z)=>{const ee=l.width/(Math.max(I,K+P-T)-Math.min(X,K)+bd),re=l.height/(Math.max(W,Z+D-A)-Math.min(H,Z));return[Math.min(AO,ee,re),Math.min(ee,re),Math.max(ee,re)]},Y=(K,Z)=>{for(let ee=0;ee<K.length;ee++){if(K[ee]>Z[ee]+1e-9)return!0;if(K[ee]<Z[ee]-1e-9)return!1}return!1},J=Math.round(I+bd+N),V=[...new Set([...$,H])].sort((K,Z)=>K-Z);let G=null;for(const K of[...M,J])for(const Z of V){if(x(K,Z,O,L))continue;const ee=F(K,Z);(G===null||Y(ee,G))&&(G=ee,q={x:K,y:Z})}q&&q.x===T&&q.y===A&&(q=null)}else e:for(const X of M)for(const H of $){if(H>=A)break;if(!x(X,H,O,L)){q={x:X,y:H};break e}}if(q){const X=q.x-T,H=q.y-A;for(const I of E){const W=d(I.id);t.set(I.id,{x:W.x+X,y:W.y+H})}S.push(_)}for(const X of E){const H=d(X.id),{w:I,h:W}=u(X.id);k.push({x:H.x,y:H.y,w:I,h:W,...h(X.id)})}}return S}function QQ(e,t,n,r,s,o){const l=g=>Gl(g,r,s),u=new Map(e.map(g=>[g.id,ph(g)])),d=[],h=e.map(g=>({id:g.id,pos:n.get(g.id)??t.get(g.id)})).filter(g=>g.pos!=null).sort((g,v)=>g.pos.y-v.pos.y||g.pos.x-v.pos.x||g.id.localeCompare(v.id)),f=g=>(o==null?void 0:o.has(g))===!0&&!n.has(g);for(const{id:g,pos:v}of h){if(!f(g))continue;const{w:k,h:b}=l(g);d.push({x:v.x,y:v.y,w:k,h:b,sid:u.get(g)??"_default"})}const p=[];for(const{id:g,pos:v}of h){if(f(g))continue;const{w:k,h:b}=l(g),x=u.get(g)??"_default";if(n.has(g)){d.push({x:v.x,y:v.y,w:k,h:b,sid:x});continue}let N=v.y;for(let S=0;S<d.length+1;S++){const _=d.find(E=>{const T=E.sid===x?Hu:CO,A=E.sid===x?Hu:xd;return v.x<E.x+E.w+T&&E.x<v.x+k+T&&N<E.y+E.h+A&&E.y<N+b+A});if(!_)break;N=_.y+_.h+(_.sid===x?Hu:xd)}N!==v.y&&(t.set(g,{x:v.x,y:N}),p.push(g)),d.push({x:v.x,y:N,w:k,h:b,sid:x})}return p}function eee(e,t,n,r,s,o=!1,l){const d=CO+1,h=xd+1,f=8,p=1.75,g=200,v=.7,k=.01,b=L=>Gl(L,r,l),x=L=>n.get(L)??t.get(L),N=mh(e,L=>x(L.id)!=null),S=[],_=new Set,E=new Set,T=s.size===0;for(const L of[...N.keys()].sort()){const z=N.get(L);let M=1/0,$=1/0,q=-1/0,X=-1/0,H=!1;for(const Y of z){const J=x(Y.id),{w:V,h:G}=b(Y.id);M=Math.min(M,J.x),$=Math.min($,J.y),q=Math.max(q,J.x+V),X=Math.max(X,J.y+G),n.has(Y.id)&&(H=!0)}const I=q-M,W=X-$;E.add(L);const F=s.get(L);F&&(I>F.w+f||W>F.h+f)&&_.add(L),s.set(L,{w:I,h:W}),S.push({sid:L,members:z.map(Y=>Y.id),x:M,y:$,w:I,h:W,anchored:H,mass:1})}for(const L of[...s.keys()])E.has(L)||s.delete(L);if(o||T)return[];let A=!1;for(let L=0;L<S.length&&!A;L++)for(let z=L+1;z<S.length;z++){const M=S[L],$=S[z];if(!(M.anchored&&$.anchored)&&Math.abs(M.x+M.w/2-($.x+$.w/2))<(M.w+$.w)/2+d&&Math.abs(M.y+M.h/2-($.y+$.h/2))<(M.h+$.h)/2+h){A=!0;break}}if(_.size===0&&!A)return[];if(_.size>0)for(const L of S)_.has(L.sid)&&(L.mass=8);else for(const L of S)L.mass=Math.max(1,L.w*L.h/(vd*EO));const R=new Map(S.map(L=>[L.sid,L.x])),B=new Map(S.map(L=>[L.sid,L.y])),P=new Map(S.map(L=>[L.sid,Math.min(0,L.x)])),D=new Map(S.map(L=>[L.sid,Math.min(0,L.y)]));for(let L=0;L<g;L++){const z=new Map,M=new Map;let $=0;for(let q=0;q<S.length;q++)for(let X=q+1;X<S.length;X++){const H=S[q],I=S[X];if(H.anchored&&I.anchored)continue;const W=H.x+H.w/2,F=H.y+H.h/2,Y=I.x+I.w/2,J=I.y+I.h/2,V=(H.w+I.w)/2+d-Math.abs(W-Y),G=(H.h+I.h)/2+h-Math.abs(F-J);if(V<=0||G<=0)continue;const K=($e,Oe)=>!$e.anchored&&!(Oe<0&&$e.x<=P.get($e.sid)),Z=($e,Oe)=>!$e.anchored&&!(Oe<0&&$e.y<=D.get($e.sid)),ee=($e,Oe,ze)=>{const nt=$e===Oe,it=nt?H.sid<I.sid?-1:1:Math.sign($e-Oe);return ze(H,it)||ze(I,-it)?it:nt&&(ze(H,-it)||ze(I,it))?-it:0},re=ee(W,Y,K),ue=ee(F,J,Z),me=re!==0,ae=ue!==0;if(!me&&!ae)continue;const pe=me&&(!ae||V*p<G),[xe,se,ve,fe]=pe?[re,V,z,K]:[ue,G,M,Z],he=fe(H,xe),_e=fe(I,-xe),Fe=H.mass,Le=I.mass,Ve=he?_e?Le/(Fe+Le):1:0,le=_e?he?Fe/(Fe+Le):1:0,je=se*v;ve.set(H.sid,(ve.get(H.sid)??0)+xe*je*Ve),ve.set(I.sid,(ve.get(I.sid)??0)-xe*je*le),$+=je}for(const q of S)q.anchored||(q.x=Math.max(P.get(q.sid),q.x+(z.get(q.sid)??0)),q.y=Math.max(D.get(q.sid),q.y+(M.get(q.sid)??0)));if($<k)break}const O=[];for(const L of S){const z=L.x-R.get(L.sid),M=L.y-B.get(L.sid);if(!(Math.abs(z)<1&&Math.abs(M)<1)){for(const $ of L.members){if(n.has($))continue;const q=t.get($);q&&t.set($,{x:q.x+z,y:q.y+M})}O.push(L.sid)}}return O}function tee(e,t,n,r,s,o){const l=new JA.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const u=e.filter(N=>!s.has(N)),d=new Set(u);for(const N of u){const{w:S,h:_}=Gl(N,r,o);l.setNode(N,{width:S,height:_})}for(const N of t)d.has(N.source)&&d.has(N.target)&&l.setEdge(N.source,N.target);JA.layout(l);const h=new Map;let f=1/0,p=1/0,g=-1/0,v=-1/0;for(const N of u){const S=l.node(N);if(!S)continue;const{w:_,h:E}=kd(N,r),T=Gl(N,r,o),A=S.x-T.w/2,R=S.y-T.h/2;h.set(N,{x:A,y:R}),A<f&&(f=A),R<p&&(p=R),A+_>g&&(g=A+_),R+E>v&&(v=R+E)}if(Number.isFinite(f)&&Number.isFinite(p))for(const[N,S]of h)h.set(N,{x:S.x-f,y:S.y-p});const k=Number.isFinite(g)?g-f:0,b=Number.isFinite(v)?v-p:0;let x=null;for(const N of e){const S=s.get(N);if(!S)continue;const{w:_,h:E}=kd(N,r);x=x===null?{minX:S.x,minY:S.y,maxX:S.x+_,maxY:S.y+E}:{minX:Math.min(x.minX,S.x),minY:Math.min(x.minY,S.y),maxX:Math.max(x.maxX,S.x+_),maxY:Math.max(x.maxY,S.y+E)}}return{positions:h,width:k,height:b,pinnedBox:x}}function RO(e,t,n){const r=n.direction??"LR",s=n.pinned??new Map,o=n.measured??new Map,l=n.lanes,u=mh(e);return{laid:Array.from(u.keys()).sort().map(f=>({sid:f,...tee(u.get(f).map(p=>p.id),t,r,o,s,l)})),gap:TO(e,o)}}const MO=e=>e.reduce((t,n)=>Math.max(t,n.width),0)+bd,nee=e=>e.reduce((t,n)=>t+n.height,0)+ti*Math.max(0,e.length-1);function Gx(e,t,n,r){const s=d=>{const h=[[]];let f=0;for(const p of e)f>0&&f+p.height>d&&(h.push([]),f=0),h[h.length-1].push(p),f+=p.height+ti;return h},o=[];for(let d=0;d<e.length;d++){let h=-ti;for(let f=d;f<e.length;f++)o.push(h+=e[f].height+ti)}o.sort((d,h)=>d-h);const l=d=>{let h=0,f=o.length-1;for(;h<f;){const p=h+f>>1;s(o[p]).length<=d?f=p:h=p+1}return s(o[h])};let u=[e];if(n>0&&r>0){const d=f=>GQ(f.reduce((p,g)=>p+MO(g),0)+t*(f.length-1),Math.max(...f.map(nee)),n,r);let h=d(u);for(let f=2;f<=e.length;f++){const p=l(f),g=d(p);g>h+1e-9&&(h=g,u=p)}}return u}function ree(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}=RO(e,t,n);return o.length<2?!1:Gx(o,l,r.width,r.height).length!==Gx(o,l,s.width,s.height).length}function see(e,t,n={}){const r=n.pinned??new Map,{laid:s,gap:o}=RO(e,t,n),l=Gx(s,o,n.availableWidth??0,n.availableHeight??0),u=new Map;let d=0;for(const h of l){const f=MO(h);let p=0;for(const{positions:g,height:v,pinnedBox:k}of h){for(const[x,N]of g)u.set(x,{x:N.x+d,y:N.y+p});let b=p+v;k&&k.maxY>b&&k.minX<d+f&&d<k.maxX&&(b=k.maxY),p=b+ti}d+=f+o}return e.map(h=>{const f=r.get(h.id);if(f)return{...h,position:f};const p=u.get(h.id);return p?{...h,position:p}:h})}function Vu(e,t,n){return!t.has(e)||n.has(e)}function aee(e,t,n,r){return!t.has(e)&&Vu(e,n,r)}function oee(e,t,n){const r={x:0,y:0};return t.set(e,r),n.add(e),r}function QA(e,t,n,r){n.set(e,t),r.delete(e)}const iee=300,eR=130,lee=160,tR=new WeakMap;function cee(e,t){let n=tR.get(e);(!n||n.revision!==e.revision||n.open!==t)&&(n={revision:e.revision,open:t,byId:new Map,branches:E8(e.agents.values())},tR.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 N0(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 uee(e,t,n,r,s,o,l,u,d,h,f,p,g,v,k,b,x,N,S,_){var q,X,H,I;const E=[],T=[],A=cee(e,N);for(const W of e.agents.values()){if(!x.has(W.id))continue;const F=W.exitAt!=null,Y=b!=null&&!b.has(W.id),J=[F?"rf-exiting":"",Y?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,V=o.get(W.id);if(E.push({id:W.id,type:"agent",position:{x:0,y:0},data:A(W),className:J,ariaLabel:Uq(W,t,k.has(W.id)),...V?{width:V.width,height:V.height}:null}),W.parentId&&x.has(W.parentId)){const Z=sd(W.sessionId),ee=F,re=k.size>0&&(k.has(W.id)||k.has(W.parentId)),ue=b!=null&&!b.has(W.id)&&!b.has(W.parentId),me=W.state==="active"?2:1.5,ae=re?me+1.5:me,pe=ee?.2:ue?.12:1,xe=["sess-edge",W.state==="active"?"sess-live":"sess-idle",ee?"rf-edge-exiting":"",re?"rf-edge-selected":""].filter(Boolean).join(" ");T.push({id:`e:${W.parentId}->${W.id}`,source:W.parentId,target:W.id,animated:(W.state==="active"||re)&&!ee,type:"smoothstep",style:{"--session-hue":Z,strokeWidth:`calc(${ae}px * var(--edge-k, 1))`,opacity:pe,transition:"var(--edge-transition)"},className:xe})}const G=W.kind==="root"?Pd(W):null,K=G?FM(W.sessionId,G.at):null;if(G&&K&&!b8(K)){const Z=Ob(W.id),ee=sd(W.sessionId),re=o.get(Z);E.push({id:Z,type:"recapNote",position:{x:0,y:0},data:{sessionId:W.sessionId,parentId:W.id,recap:G,noteKey:K,hue:ee},className:Y?"rf-spotlit-out":void 0,selectable:!1,focusable:!1,ariaLabel:`Claude Code's recap for ${W.label}`,...re?{width:re.width,height:re.height}:null}),T.push({id:`e:recap:${W.id}`,source:Z,target:W.id,type:"recapTie",className:"recap-edge",focusable:!1,style:{"--session-hue":ee}})}}const R=N0(e),B=_.size>0&&!(d&&S);B||_.clear();const P=`${g}#lanes:${XQ(R)}${B?"#held":""}`,D=new Set(E.filter(W=>W.type==="recapNote").map(W=>W.id));for(const W of Array.from(f.keys()))S&&S8(W)&&!D.has(W)&&!s.has(W)&&(f.delete(W),p.delete(W));const O=E.filter(W=>aee(W.id,s,f,p));if(O.length>0||P!==v.current){if(O.length>0){for(const F of O)_.delete(F.id);const W=ZQ(see(E,T,{direction:"LR",pinned:s,measured:o,availableWidth:n,availableHeight:r,lanes:R}),s,F=>Vu(F,f,p)?void 0:f.get(F));for(const F of W)Vu(F.id,f,p)&&QA(F.id,F.position,f,p);JQ(E,f,s,o,new Set(O.filter(F=>F.type!=="recapNote").map(F=>F.id)),R,{width:n,height:r});for(const F of O){if(F.type!=="recapNote")continue;const Y=(q=F.data)==null?void 0:q.parentId;if(!Y)continue;const J=s.get(Y)??(Vu(Y,f,p)?void 0:f.get(Y));if(!J)continue;const V=((X=o.get(F.id))==null?void 0:X.width)??iee,G=((H=o.get(F.id))==null?void 0:H.height)??eR,K=((I=o.get(Y))==null?void 0:I.height)??eR;QA(F.id,{x:J.x-lee-V,y:J.y+(K-G)/2},f,p)}}QQ(E,f,s,o,R,B?_:void 0),v.current=P}const L=eee(E,f,s,o,l,!d||h,R);L.length>0&&u(L);const z=SX(e.agents.values());S&&Ru(f,z),Ru(p,z),S&&Ru(s,z),Ru(o,jX(e.agents.values()));const M=[];let $=!1;for(const W of E){let F=s.get(W.id)??f.get(W.id);F||(F=oee(W.id,f,p),$=!0),M.push({...W,position:F})}return $&&(v.current=""),{nodes:M,edges:T}}function dee(e){return e.slice().sort((t,n)=>t.y-n.y||t.x-n.x)}function hee(e,t,n){var l;if(e.length===0)return null;const r=dee(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 fee=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Backspace"]);function pee(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:fee.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const mee=new Set(["","BODY","HTML","#DOCUMENT"]);function gee(e){return!e||Ld(e)?!1:!mee.has(String(e.tagName??"").toUpperCase())}const $O="react-flow__node";function j0(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,$O))===!0}function yee(e){try{const t=document.querySelector(`.${$O}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}let Oa=null,Vo=null;const Kx=new Set,Yx=()=>{for(const e of Kx)e()},wee=e=>(Kx.add(e),()=>{Kx.delete(e)}),nR=()=>Oa,vee=90;function IO(e){!Vo||e!=null&&Vo.at.id!==e||(clearTimeout(Vo.timer),Vo=null)}function OO(e,t,n="pointer"){IO();const r={id:e,anchor:t,by:n};if(Oa||n==="focus"){Oa=r,Yx();return}Vo={at:r,timer:setTimeout(()=>{Vo=null,Oa=r,Yx()},vee)}}function ea(e){IO(e),!(!Oa||e!=null&&Oa.id!==e)&&(Oa=null,Yx())}function xee({agentFor:e,recapFor:t,labelFor:n,bounds:r}){const s=w.useSyncExternalStore(wee,nR,nR),o=s?e(s.id):void 0,l=s&&!o?t(s.id):void 0,u=s!=null&&(!o&&!l||!s.anchor.isConnected);return w.useEffect(()=>{u&&s&&ea(s.id)},[u,s]),!s||u?null:o?a.jsx(kee,{a:o,anchor:s.anchor,parentLabel:o.parentId?n(o.parentId):void 0,bounds:r},s.id):l?a.jsx(bee,{r:l,anchor:s.anchor,bounds:r},s.id):null}function LO(e,t){const n=w.useRef(null),r=w.useCallback(()=>{const s=n.current;if(!s||!e.isConnected)return;const o=Wb(e.getBoundingClientRect(),{width:s.offsetWidth,height:s.offsetHeight},t());s.style.top=`${o.top}px`,s.style.left=`${o.left}px`,s.style.maxHeight=o.maxHeight==null?"":`${o.maxHeight}px`,s.dataset.side=o.side},[e,t]);return w.useLayoutEffect(()=>{r()}),n}function bee({r:e,anchor:t,bounds:n}){const r=LO(t,n),s=vi(3e4),o=ld(e.recap.at,s);return Lt.createPortal(a.jsxs("div",{ref:r,className:"ap-peek node-peek recap-peek",role:"tooltip",id:"node-peek",style:{"--session-hue":e.hue},children:[a.jsxs("div",{className:"node-peek-head",children:[a.jsxs("span",{className:"recap-peek-mark",children:[a.jsx(Fl,{}),"recap"]}),a.jsx("span",{className:"node-peek-time",title:o.title,children:o.label})]}),e.sessionLabel&&a.jsx("div",{className:"node-peek-kind",children:a.jsxs("span",{children:["Claude Code's recap of ",e.sessionLabel]})}),a.jsx("p",{className:"recap-peek-text",children:e.recap.text}),a.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for its details"})]}),document.body)}function kee({a:e,anchor:t,parentLabel:n,bounds:r}){const s=LO(t,r),o=vi(1e3),l=$b(e.sessionName,e.sessionTitle),u=e.tools.filter(k=>k.ok===!1).length,d=e.tools.filter(k=>!k.endedAt).length,h=hn(e,o).total,f=e.usage.inputTokens+e.usage.outputTokens,p=e.kind==="root"&&fr(e.waiting),g=e.kind==="root"?"session":n?`subagent of ${n}`:"subagent",v=[`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,d>0?`${d} in-flight`:null,f>0?`${ot(f)} tok`:null,h>0?`${qe(h)}${Dl(e,o)>0?"+":""}`:null].filter(Boolean).join(" · ");return Lt.createPortal(a.jsxs("div",{ref:s,className:"ap-peek node-peek",role:"tooltip",id:"node-peek",children:[a.jsxs("div",{className:"node-peek-head",children:[a.jsx("span",{className:"node-peek-name",children:e.label}),a.jsxs("span",{className:"node-peek-time",children:[e.synthetic?"≥ ":"",li(e.startedAt,e.endedAt,o)]})]}),a.jsxs("div",{className:"node-peek-kind",children:[a.jsxs("span",{className:"node-peek-state","data-kind":mx(e.state),children:[a.jsx(GM,{kind:mx(e.state)}),oi(e.state)]}),a.jsx("span",{children:g}),e.model?a.jsx("span",{children:Js(e.model)}):null]}),e.kind==="root"&&l.face&&a.jsx("p",{className:"node-peek-title",children:l.face}),e.kind==="root"&&e.waiting&&a.jsxs("p",{className:`node-peek-wait${p?" warn":""}`,children:[p&&a.jsx(Db,{}),a.jsx("span",{children:Mb(e.waiting)}),a.jsx("b",{children:li(e.waiting.since,void 0,o)})]}),a.jsxs("p",{className:"node-peek-facts",children:[v,u>0&&a.jsxs("span",{className:"node-peek-failed",children:[" · ",u," failed"]})]}),e.branch&&e.branch.total>0&&a.jsx("p",{className:"node-peek-branch",children:BM(e.branch)}),a.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for details"})]}),document.body)}function Nee(e){const t=e.minZoom??TY,n=e.maxZoom??AY,r=e.fill??.9,s=e.insets.left,o=e.insets.top,l=Math.max(1,e.pane.width-e.insets.left-e.insets.right),u=Math.max(1,e.pane.height-e.insets.top-e.insets.bottom),d=e.context,h=e.anchor,f=Math.min(l/Math.max(1,d.width),u/Math.max(1,d.height))*r,p=Math.max(t,Math.min(n,f)),g=(v,k,b,x,N,S)=>{let _=v+(k-x*p)/2-b*p;const E=N*p+_,T=(N+S)*p+_;return S*p<=k?E<v?_+=v-E:T>v+k&&(_-=T-(v+k)):_+=v-E,_};return{x:g(s,l,d.x,d.width,h.x,h.width),y:g(o,u,d.y,d.height,h.y,h.height),zoom:p}}function jee(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 xn(e){const t=w.useRef(e);return t.current=e,t}const Xx=80,Zx=.86;function PO(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 See({canvasRef:e,canvasSize:t,machinePhase:n,usagePhase:r,usagePanelOpen:s,detailShown:o}){const[l,u]=w.useState(0);w.useEffect(()=>{const p=PO(e.current);u(g=>Math.abs(g-p)>40?p:g)},[n,r,s,o,t.w]);const d=xn(l),h=t.w>0?Math.max(0,(t.w-l-Xx*2)*Zx):0,f=t.h>0?Math.max(0,(t.h-Xx*2)*Zx):0;return{railInsetRef:d,availableWidth:h,availableHeight:f}}const DO=420;function _ee(){const e=mi(),t=kt(),n=w.useCallback((d,h)=>{if(hx({durationMs:h,documentHidden:document.hidden})){e.setViewport(d,{duration:h});return}const{d3Zoom:f,d3Selection:p}=t.getState(),g=p==null?void 0:p.property("__zoom");if(f&&p&&g&&g.k>0&&d.zoom>0){f.transform(p,g.scale(d.zoom/g.k).translate((d.x-g.x)/d.zoom,(d.y-g.y)/d.zoom));return}e.setViewport(d,{duration:0})},[e,t]),r=w.useRef(null),s=w.useRef(0),o=w.useRef(0),l=w.useCallback((d,h)=>{const f=++s.current;return n(d,h),o.current=Date.now(),r.current=hx({durationMs:h,documentHidden:document.hidden})?{target:d,until:Date.now()+h+60}:null,f},[n]),u=w.useCallback((d=500)=>{const h=Xx,f=1,p=.2,g=Zx;try{const v=document.querySelector(".canvas-wrap"),k=Array.from(document.querySelectorAll(".react-flow__node")).filter($=>$.offsetWidth>0);if(!v||k.length===0)return;const b=v.getBoundingClientRect(),x=e.getViewport();if(!Number.isFinite(x.zoom)||x.zoom<=0)return;const N=$=>($-b.left-x.x)/x.zoom,S=$=>($-b.top-x.y)/x.zoom,_=k.map($=>$.getBoundingClientRect()),E=Math.min(..._.map($=>N($.left))),T=Math.max(..._.map($=>N($.right))),A=Math.min(..._.map($=>S($.top))),R=Math.max(..._.map($=>S($.bottom))),B=T-E,P=R-A;if(!(B>0&&P>0))return;const D=PO(v),O=$=>Math.max(p,Math.min(f,(b.width-D-h*2)/(B+$)*g,(b.height-h*2)/P*g)),L=CY(O(DO),O(0)),z={x:h-E*L,y:Math.max(h,(b.height-P*L)/2)-A*L,zoom:L},M=l(z,d);window.setTimeout(()=>{var $;try{if((($=r.current)==null?void 0:$.target)===z&&(r.current=null),s.current!==M)return;const q=e.getViewport();(Math.abs(q.zoom-L)>.01||Math.abs(q.x-z.x)>2)&&n(z,0)}catch{}},d+60)}catch{}},[e,n,l]);return w.useEffect(()=>{const d=()=>{if(!document.hidden)return;const h=r.current;if(r.current=null,!(!h||Date.now()>h.until)){try{n(h.target,0)}catch{}o.current=Date.now()}};return document.addEventListener("visibilitychange",d),()=>document.removeEventListener("visibilitychange",d)},[n]),{applyViewport:n,moveCamera:l,fitLeft:u,cameraEpochRef:s,lastFitTimeRef:o}}const Eee=450;function Cee({canvasRef:e,stateRef:t,measuredRef:n,nodesRef:r,railInsetRef:s,moveCamera:o,disableAutoFit:l,lastFocusRef:u,focusAgentRef:d,selectAgent:h,primarySelectedIdRef:f}){const p=w.useCallback(k=>{var B;const b=e.current,x=t.current.agents.get(k);if(!b||!x)return;const N=N0(t.current),S=(P,D)=>{const O=n.current.get(P.id);if(!O)return null;const L=D&&N.has(P.id)?DO:0;return{x:P.position.x,y:P.position.y,width:O.width+L,height:O.height}},_=r.current.find(P=>P.id===k),E=_?S(_,!1):null;if(!E)return;const T=[];for(const P of r.current){if(P.type!=="agent"&&P.type!=="recapNote"||((B=P.data)==null?void 0:B.sessionId)!==x.sessionId)continue;const D=S(P,P.type==="agent");D&&T.push(D)}const A=b.getBoundingClientRect(),R=Nee({pane:{width:A.width,height:A.height},insets:{top:56,left:72,bottom:32,right:s.current+32},context:jee(T)??E,anchor:E});ea(),l(),u.current={id:k,at:Date.now()},o(R,Eee)},[o,l]);d.current=p;const g=w.useCallback(k=>{const b=r.current.filter(_=>_.type==="agent"),x=hee(b.map(_=>({id:_.id,x:_.position.x,y:_.position.y})),f.current,k),N=x?b.find(_=>_.id===x):void 0;if(!N)return;const S=j0(document.activeElement);h(N.id,!1),window.setTimeout(()=>{try{p(N.id)}catch{}S&&yee(N.id)},30)},[h,p]),v=w.useCallback(k=>{h(k,!1),window.setTimeout(()=>{try{p(k)}catch{}},60)},[h,p]);return{focusAgent:p,stepAgent:g,focusSession:v}}function Tee({nodesRef:e,stateRef:t,canvasRef:n,railInsetRef:r}){const s=w.useCallback(d=>{const h=e.current.find(f=>f.id===d&&f.type==="agent");return h?h.data:void 0},[]),o=w.useCallback(d=>{var h;return(h=t.current.agents.get(d))==null?void 0:h.label},[]),l=w.useCallback(d=>{var p;const h=e.current.find(g=>g.id===d&&g.type==="recapNote");if(!h)return;const f=h.data;return{recap:f.recap,hue:f.hue,sessionLabel:(p=t.current.agents.get(f.parentId))==null?void 0:p.label}},[]),u=w.useCallback(()=>{var f;const d=(f=n.current)==null?void 0:f.getBoundingClientRect(),h=document.documentElement;return d?{width:d.right-r.current,height:d.bottom}:{width:h.clientWidth,height:h.clientHeight}},[]);return{peekAgent:s,peekLabel:o,peekRecap:l,peekBounds:u}}function Aee(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 rR(e){return Object.entries(e??{}).filter(([,t])=>t&&typeof t.x=="number"&&typeof t.y=="number")}function Ree(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=rR(n);return{positions:s,pins:s.map(([o])=>o)}}const r=n;return{positions:rR(r.positions),pins:Array.isArray(r.pins)?r.pins:[]}}function Mee(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 $ee(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 S0="agent-dag.layout",_0="agent-dag.layoutFrame",E0="agent-dag.viewport";function Iee(){return Ree(et(S0))}function Kl(e,t){Xe(S0,Mee(e,t))}function Oee(){return $ee(et(_0))}function FO(e){Xe(_0,JSON.stringify(e))}function Lee(){return wB(et(E0))}function Pee(e){Xe(E0,JSON.stringify(e))}function BO(){cs(S0),cs(E0),cs(_0)}function Dee(e){const t=w.useState(()=>Aee(Iee()))[0],n=w.useRef(t.pinned),r=w.useRef(t.positions),s=w.useRef(new Set),o=w.useRef(""),[l,u]=w.useState(0),d=w.useState(Oee)[0],h=w.useRef(d),f=w.useCallback(()=>{n.current.clear(),r.current.clear(),o.current="",BO(),u(p=>p+1),window.setTimeout(()=>{Kl(r.current,n.current),h.current&&FO(h.current),e(500)},80)},[e]);return{restoredLayout:t,pinnedRef:n,positionsRef:r,provisionalRef:s,lastLayoutSigRef:o,layoutEpoch:l,setLayoutEpoch:u,lastLayoutFrameRef:h,handleRelayout:f}}function Fee(e,t){const{positionsRef:n,pinnedRef:r}=t,s=w.useRef(null);w.useEffect(()=>(s.current!=null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{Kl(n.current,r.current)},1500),()=>{s.current!=null&&window.clearTimeout(s.current)}),[e])}function Bee({nodes:e,edges:t,settled:n,dragging:r,availableWidth:s,availableHeight:o,layout:l,camera:u,rf:d,measuredRef:h,stateRef:f,lastFocusRef:p,primarySelectedIdRef:g,focusAgentRef:v,autoFitDisabledRef:k}){const{lastLayoutFrameRef:b,pinnedRef:x,positionsRef:N,provisionalRef:S,lastLayoutSigRef:_,setLayoutEpoch:E}=l,{applyViewport:T,fitLeft:A,cameraEpochRef:R,lastFitTimeRef:B}=u;w.useEffect(()=>{if(!n||r)return;const P={width:s,height:o};if(!(P.width>0&&P.height>0))return;const D=b.current;if(b.current=P,FO(P),!D||D.width===P.width&&D.height===P.height)return;const O={direction:"LR",pinned:x.current,measured:h.current,lanes:N0(f.current)};if(!ree(e,t,O,D,P))return;const L=p.current&&Date.now()-p.current.at<1500?p.current.id:null,z=L??g.current,M=z?x.current.get(z)??N.current.get(z):void 0;for(const $ of Array.from(N.current.keys()))x.current.has($)||N.current.delete($);S.current.clear(),_.current="",E($=>$+1),window.setTimeout(()=>{if(Kl(N.current,x.current),k.current){if(L){v.current(L);return}const $=z?x.current.get(z)??N.current.get(z):void 0;if(M&&$&&($.x!==M.x||$.y!==M.y)){const q=d.getViewport();R.current+=1,T({x:q.x-($.x-M.x)*q.zoom,y:q.y-($.y-M.y)*q.zoom,zoom:q.zoom},0),B.current=Date.now()}return}A(500)},80)},[s,o,n,r,A,d,T])}const qee=600;function C0(e,t){return!(e.exitAt!=null&&t-e.exitAt>qee||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function Uee(e,t){const n=new Set;for(const r of e.agents.values())C0(r,t)&&n.add(r.id);return n}function zee(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 Wee(e,t,n=0){if(!e)return!1;for(const r of t)if(zee(e,r,n))return!0;return!1}function Hee(e,t,n,r,s){const o=[];for(const l of e)!C0(l,t)||n.has(l.id)||o.push(l.id+(l.parentId?`>${l.parentId}`:""));return o.sort(),`${o.join("|")}#sv${r}.${s}`}const T0="agent-dag.removedNodes";function Vee(e){try{const t=JSON.parse((e==null?void 0:e.getItem(T0))??"[]");return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function sR(e,t){try{e==null||e.setItem(T0,JSON.stringify([...t]))}catch{}}function qO(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 Gee(e,t){if(t.size===0)return new Set;const n=[...e],r=qO(n,t);return new Set(n.filter(r).map(s=>s.id))}function Kee(e,t,n){const r=u=>({id:u.id,parentId:u.data.parentId,sessionId:u.data.sessionId}),s=qO(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 Yee(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 Xee(e,t){return t.size===0?[]:[...e].filter(n=>t.has(n.id)).map(n=>n.id)}function Zee(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 Jee(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 Qee(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=Zee(u);if(d<=s)continue;const h=[],f=new Set,p=v=>{var k;for(let b=v;b&&!f.has(b);b=(k=e.get(b))==null?void 0:k.parentId)f.add(b),n.has(b)&&h.push(b)};p(u.id),p(u.sessionId);let g=-1/0;for(const v of h)g=Math.max(g,r.get(v)??1/0);if(d>g)for(const v of h)o.add(v)}return[...o]}const UO="sessionGroup";function ete(e,t){var r,s;if(e.type===UO)return"transparent";if(fr((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=Aa;function tte(e){const t=new Map;for(const r of e){const s=r.data;if(!(s!=null&&s.sessionId)||s.exitAt!=null)continue;const o=r.width,l=r.height;if(o==null||l==null)continue;const u=r.position.x,d=r.position.y,h=u+o,f=d+l,p=t.get(s.sessionId);p?(p.minX=Math.min(p.minX,u),p.minY=Math.min(p.minY,d),p.maxX=Math.max(p.maxX,h),p.maxY=Math.max(p.maxY,f)):t.set(s.sessionId,{minX:u,minY:d,maxX:h,maxY:f})}const n=[];for(const[r,s]of t){const o=s.maxX-s.minX+Mu*2,l=s.maxY-s.minY+Mu*2;n.push({id:`group:${r}`,type:UO,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 nte(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 rte(e,t){const n=new Set;for(const r of t){const s=nte(e,r);if(s)for(const o of s)n.add(o)}return n.size>0?n:null}function ste({stateRef:e,now:t,removedAgentIds:n,sizeVersion:r,domSizeVersion:s}){return w.useMemo(()=>Hee(e.current.agents.values(),t,n,r,s),[e.current,e.current.revision,t,r,s,n])}function ate({stateRef:e,now:t,availableWidth:n,availableHeight:r,layout:s,measuredRef:o,onBubble:l,settled:u,dragging:d,layoutSig:h,selectedIds:f,openContext:p,historyReplayed:g,removedNodes:v,removedAgentIds:k,dragTick:b,dragPatchRef:x,dragMoveTick:N}){const{pinnedRef:S,positionsRef:_,provisionalRef:E,lastLayoutSigRef:T,restoredLayout:A,layoutEpoch:R}=s,B=w.useMemo(()=>rte(e.current,f),[e.current,e.current.revision,f]),P=w.useMemo(()=>{const q=Uee(e.current,t);for(const X of k)q.delete(X);return q},[e.current,e.current.revision,t,k]),D=w.useRef(new Map),O=_8(),{nodes:L,edges:z}=w.useMemo(()=>{const q=uee(e.current,t,n,r,S.current,o.current,D.current,l,u,d,_.current,E.current,h,T,f,B,P,p,g,A.restored);return Kee(q.nodes,q.edges,v)},[e.current,e.current.revision,t,n,r,u,d,h,f,B,P,p,b,O,v,R,g]),M=w.useMemo(()=>tte(L),[L]),$=w.useMemo(()=>{const q=[...M,...L],X=x.current;return!X||X.size===0?q:q.map(H=>{const I=X.get(H.id);return I?{...H,position:I}:H})},[M,L,N]);return{spotlightSet:B,visibleAgentIds:P,nodes:L,edges:z,allNodes:$}}function ote(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 ite({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,ote(s,t,e))return!1;return r}function lte({layoutSig:e,rf:t,stateRef:n,measuredRef:r,pinnedRef:s,positionsRef:o,paneSizeRef:l,lastInteractRef:u,autoFitDisabledRef:d,lastFitTimeRef:h,fitLeft:f}){const p=w.useRef(null),g=w.useRef("");w.useEffect(()=>{const v=setInterval(()=>{if(d.current||Date.now()-u.current<800)return;const k=n.current,b=Date.now(),x=[];for(const S of k.agents.values())C0(S,b)&&x.push({id:S.id});if(x.length===0)return;const N=[];for(const{id:S}of x){const _=r.current.get(S),E=s.current.get(S)??o.current.get(S);!_||!E||N.push({x:E.x,y:E.y,width:_.width,height:_.height})}ite({pane:l.current,viewport:t.getViewport(),boxes:N})&&f(600)},1500);return()=>clearInterval(v)},[t]),w.useEffect(()=>{if(g.current===e)return;const v=g.current;if(g.current=e,!v||d.current)return;Date.now()-h.current>1200&&f(400),p.current&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{d.current||f(500)},280)},[e,t,f])}function cte({stateRef:e,pinnedRef:t,positionsRef:n,canvasRef:r,clearSelection:s,primarySelectedId:o}){const[l,u]=w.useState(()=>Vee(Sl())),[d,h]=w.useState(null),f=w.useMemo(()=>Gee(e.current.agents.values(),l),[e.current,e.current.revision,l]),p=w.useCallback(N=>{const S=e.current.agents.get(N);S&&(u(_=>{const E=new Set(_);return E.add(N),sR(Sl(),E),E}),h({id:N,label:S.label}),t.current.delete(N),n.current.delete(N),s())},[s]),g=w.useCallback(()=>{o&&p(o)},[o,p]),v=d&&l.has(d.id)?d:null;w.useEffect(()=>{var N;d&&((N=r.current)==null||N.focus())},[d]);const k=w.useCallback(N=>{const S=[...N];u(_=>{const E=Yee(_,S);return E!==_&&sR(Sl(),E),E})},[]),b=w.useCallback(()=>{k([...l]),h(null)},[k,l]),x=w.useCallback(()=>{u(new Set),h(null),cs(T0)},[]);return{removedNodes:l,lastRemoval:d,removedAgentIds:f,removeNode:p,removeSelectedNode:g,removalNotice:v,bringBack:k,bringBackAll:b,forgetRemovals:x}}function ute({stateRef:e,waitingSessions:t,removedAgentIds:n,removedNodes:r,bringBack:s}){const o=w.useRef(new Map);w.useEffect(()=>{o.current=Jee(o.current,r,Date.now());const l=[...Xee(t,n),...Qee(e.current.agents,n,r,o.current)];l.length>0&&s(l)},[t,n,r,s])}function dte({waiting:e,running:t,connected:n=!0}){return{title:e>0?`(${e}) ${bt}`:bt,icon:n?e>0?"waiting":t>0?"running":"idle":"offline"}}const hte=Object.freeze({offline:"/state/favicon-error.svg",waiting:"/state/favicon-waiting.svg",running:"/state/favicon-syncing.svg",idle:"/favicon.svg"}),fte=Object.freeze({offline:"/state/favicon-error-32.png",waiting:"/state/favicon-waiting-32.png",running:"/state/favicon-syncing-32.png",idle:"/favicon.ico"});function pte({stateRef:e,waitingSessions:t,live:n}){const r=w.useMemo(()=>Iq(e.current.agents.values()),[e.current,e.current.revision]),s=w.useRef(null);w.useEffect(()=>{const o=dte({waiting:t.length,running:r,connected:n}),l=s.current;if(s.current=o,(l==null?void 0:l.title)!==o.title&&(document.title=o.title),(l==null?void 0:l.icon)!==o.icon){const u=document.querySelector('link[rel="icon"][type="image/svg+xml"]');u&&(u.href=hte[o.icon]);const d=document.querySelector('link[rel="icon"][sizes="32x32"]');d&&(d.href=fte[o.icon])}},[t.length,r,n])}const mte=1200,gte=1e3;function zv(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<mte?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<gte}function yte({applyViewport:e,lastFitTimeRef:t,cameraEpochRef:n,disableAutoFit:r,markInteract:s,canvasRef:o,applyZoom:l}){const u=w.useState(()=>Lee())[0];w.useEffect(()=>{if(!u)return;const k=window.setTimeout(()=>{try{e(u,0)}catch{}t.current=Date.now()},60);return()=>window.clearTimeout(k)},[e,u]);const d=w.useRef(null),h=w.useRef(0),f=w.useCallback(()=>{h.current=Date.now()},[]),p=w.useCallback(k=>({hasSourceEvent:!!k,at:Date.now(),lastDeckFitAt:t.current,lastCanvasInputAt:h.current}),[]);return{restoredViewport:u,markCanvasInput:f,onMoveStart:k=>{ea(),zv(p(k))&&(n.current+=1),zv(p(k))&&r()},onMove:(k,b)=>{var x;s(),zv(p(k))&&r(),(x=o.current)==null||x.style.setProperty("--zoom",String(b.zoom)),l(b.zoom)==="detail"&&ea(),d.current&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>Pee(b),250)}}}function wte({clearSelection:e,selectAgent:t,detailOpen:n,setDetailOpen:r,detailShown:s,focusAgent:o,draggingRef:l,lodRef:u}){return{onNodeClick:(v,k)=>{if(k.type==="sessionGroup"){e();return}const b=k.type==="recapNote"?k.data.parentId:k.id;t(b,v.shiftKey,!1),!v.shiftKey&&(n&&r(!1),s?window.setTimeout(()=>{try{o(b)}catch{}},80):o(b))},onPaneClick:()=>{ea(),e()},onNodeDoubleClick:(v,k)=>{if(k.type!=="agent"&&k.type!=="recapNote")return;const b=k.type==="recapNote"?k.data.parentId:k.id;t(b,!1),window.setTimeout(()=>{try{o(b)}catch{}},80)},onNodeMouseEnter:(v,k)=>{k.type!=="agent"&&k.type!=="recapNote"||l.current||u.current==null||u.current==="detail"||OO(k.id,v.currentTarget)},onNodeMouseLeave:(v,k)=>ea(k.id)}}function vte(){const e=w.useRef(null),t=w.useRef(null),[n,r]=w.useState({w:0,h:0});return w.useEffect(()=>{const s=t.current;if(!s||typeof ResizeObserver>"u")return;const o=new ResizeObserver(l=>{var d;const u=(d=l[0])==null?void 0:d.contentRect;u&&(e.current={width:u.width,height:u.height},r(h=>Math.abs(h.w-u.width)>40||Math.abs(h.h-u.height)>40?{w:u.width,h:u.height}:h))});return o.observe(s),e.current={width:s.clientWidth,height:s.clientHeight},r({w:s.clientWidth,h:s.clientHeight}),()=>o.disconnect()},[]),{canvasRef:t,canvasSize:n,paneSizeRef:e}}function xte(e){const t=w.useRef(new Map),n=w.useRef(0),r=w.useCallback(u=>{const d=t.current;let h=!1;for(const f of u.nodeInternals.values()){const p=f.width,g=f.height;if(p==null||g==null)continue;const v=d.get(f.id);v?(Math.abs(v.height-g)>4||Math.abs(v.width-p)>4)&&(d.set(f.id,{width:p,height:g}),h=!0):(d.set(f.id,{width:p,height:g}),h=!0)}return h&&(n.current+=1),n.current},[]),s=Ye(r),[o,l]=w.useState(0);return w.useEffect(()=>{let u=0;const d=()=>{const f=t.current;let p=!1;for(const g of document.querySelectorAll(".react-flow__node[data-id]")){const v=g.getAttribute("data-id");if(!v)continue;const k=g.offsetWidth,b=g.offsetHeight;if(!k||!b)continue;const x=f.get(v);(!x||Math.abs(x.width-k)>4||Math.abs(x.height-b)>4)&&(f.set(v,{width:k,height:b}),p=!0)}p&&l(g=>g+1)};if(e.current)return;let h=0;return document.visibilityState==="hidden"?h=window.setTimeout(d,32):u=requestAnimationFrame(d),()=>{cancelAnimationFrame(u),window.clearTimeout(h)}}),{measuredRef:t,measuredVersionRef:n,sizeVersion:s,domSizeVersion:o}}function bte(){const[e,t]=w.useState(!1);return w.useEffect(()=>{const n=window.setTimeout(()=>t(!0),2500);return()=>window.clearTimeout(n)},[]),e}function kte(){const e=w.useRef(null);return w.useEffect(()=>{let t=-1/0;const n=()=>{t=performance.now()},r=s=>{e.current=performance.now()-t<250?s.target:null};return window.addEventListener("pointerdown",n,!0),window.addEventListener("focusin",r,!0),()=>{window.removeEventListener("pointerdown",n,!0),window.removeEventListener("focusin",r,!0)}},[]),e}function Nte({pointerFocusRef:e,nodesRef:t,stateRef:n,primarySelectedIdRef:r,providersRef:s,soundOnRef:o,keyHelpOpenRef:l,modalOpenRef:u,waitingCursorRef:d,removeSelectedRef:h,activateSoundRef:f,clearSelection:p,selectAgent:g,focusAgent:v,stepAgent:k,focusSession:b,requestClear:x,handleRelayout:N,handleFit:S,togglePause:_,toggleSessionList:E,toggleAccountsPanel:T,setDetailOpen:A,setUsageHistoryOpen:R,setUsagePanelOpen:B,setMachinePanelOpen:P,setBrowserWatchOpen:D,setSoundMenuOpen:O,setKeyHelpOpen:L,setTheme:z}){w.useEffect(()=>{const M=$=>{var F,Y;const q=$.target,X={tagName:q==null?void 0:q.tagName,isContentEditable:q==null?void 0:q.isContentEditable,role:(F=q==null?void 0:q.getAttribute)==null?void 0:F.call(q,"role"),type:q==null?void 0:q.type,pointerFocused:q!=null&&q===e.current};if($.key==="Escape"){const J=Zq({overlayOpen:Jo.depth()>0,typing:Ld(X)});J==="dismiss"?Jo.dismissTop():J==="blur"?q==null||q.blur():(gee(X)&&(q==null||q.blur()),p());return}if(Od($))return;const H=j0(q)?(Y=q==null?void 0:q.getAttribute)==null?void 0:Y.call(q,"data-id"):null,I=H&&t.current.some(J=>J.id===H)?H:null,W=pee($,I);if(W.kind==="activate"){$.preventDefault(),g(W.nodeId,W.additive);return}if(W.kind!=="node"&&!(W.nodeId==null&&o8(X,$.key))&&!i8({key:$.key,modalOpen:l8({appModal:u.current,dialogDepth:Jo.dialogDepth()}),sheetOpen:l.current})){if($.key===" "&&($.preventDefault(),_()),($.key==="c"||$.key==="C")&&x("shortcut"),($.key==="r"||$.key==="R")&&N(),($.key==="f"||$.key==="F")&&S(),($.key==="z"||$.key==="Z")&&r.current&&v(r.current),$.key==="Delete"&&h.current(),($.key==="l"||$.key==="L")&&E(),$.key==="d"||$.key==="D")if(r.current)A(J=>!J);else{const J=fx(n.current.agents.values());J.length>0?b(J[0].id):k(1)}if(($.key==="h"||$.key==="H")&&R(J=>!J),($.key==="u"||$.key==="U")&&B(J=>!J),($.key==="a"||$.key==="A")&&s.current.claude&&T(),($.key==="j"||$.key==="J")&&k(1),($.key==="k"||$.key==="K")&&k(-1),$.key==="w"||$.key==="W"){const J=$q(fx(n.current.agents.values()),d.current);J&&(d.current=J.id,b(J.id))}($.key==="t"||$.key==="T")&&z(J=>J==="dark"?"light":"dark"),($.key==="m"||$.key==="M")&&s.current.claude&&o.current!==null&&f.current($.shiftKey),($.key==="s"||$.key==="S")&&P(J=>!J),($.key==="b"||$.key==="B")&&D(J=>!J),($.key==="v"||$.key==="V")&&s.current.claude&&o.current!==null&&O(J=>!J),$.key==="?"&&L(J=>!J)}};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[x,N,S,p,g,k,b,v,_])}function jte({nodes:e,stateRef:t,pinnedRef:n,positionsRef:r,draggingRef:s,dragPatchRef:o,setDragging:l,setDragMoveTick:u,setDragTick:d,endBubble:h,markInteract:f,disableAutoFit:p,beginTrashDrag:g,trackTrashDrag:v,endTrashDrag:k,removeNode:b}){const x=w.useRef(null);return{onNodeDragStart:(E,T)=>{var A,R;if(ea(),h(),s.current=!0,o.current=new Map,l(!0),g(T.type==="agent"?((A=t.current.agents.get(T.id))==null?void 0:A.label)??"":null),f(),p(),T.type==="sessionGroup"){const B=(R=T.data)==null?void 0:R.sessionId,P=new Map;if(B)for(const D of e){const O=D.data;(O==null?void 0:O.sessionId)===B&&P.set(D.id,{x:D.position.x,y:D.position.y})}x.current={start:{x:T.position.x,y:T.position.y},members:P};return}n.current.set(T.id,{x:T.position.x,y:T.position.y})},onNodeDrag:(E,T)=>{var A;if(f(),T.type==="agent"&&v(E),T.type==="sessionGroup"){const R=x.current;if(!R)return;const B=T.position.x-R.start.x,P=T.position.y-R.start.y;for(const[O,L]of R.members){const z={x:L.x+B,y:L.y+P};n.current.set(O,z),r.current.set(O,z)}const D=o.current;if(D){for(const[O,L]of R.members)D.set(O,{x:L.x+B,y:L.y+P});D.set(T.id,{x:T.position.x,y:T.position.y})}u(O=>O+1);return}n.current.set(T.id,{x:T.position.x,y:T.position.y}),r.current.set(T.id,{x:T.position.x,y:T.position.y}),(A=o.current)==null||A.set(T.id,{x:T.position.x,y:T.position.y}),u(R=>R+1)},onNodeDragStop:(E,T)=>{f();const A=k(E,T.type==="agent");if(s.current=!1,o.current=null,l(!1),d(R=>R+1),T.type==="sessionGroup"){const R=x.current;if(R){const B=T.position.x-R.start.x,P=T.position.y-R.start.y;for(const[D,O]of R.members){const L={x:O.x+B,y:O.y+P};n.current.set(D,L),r.current.set(D,L)}}x.current=null,Kl(r.current,n.current),d(B=>B+1);return}if(n.current.set(T.id,{x:T.position.x,y:T.position.y}),r.current.set(T.id,{x:T.position.x,y:T.position.y}),A){b(T.id);return}Kl(r.current,n.current)}}}function Ste(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const _te={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent",zcode:"ZCode"};function Ete(e){const t=e.toLowerCase(),n=Ot(_te,t);return n!==void 0?n:t?t[0].toUpperCase()+t.slice(1):""}function Cte(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function cie(e,t=[]){const n=t.length?Cte(t.map(Ete)):Ste(e);return n?`via ccusage · local ${n} logs`:"via ccusage · local agent logs"}function Tte(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 Ate(e,t){const n=t.prefs??Hx,r=hi(n.done.level),s=hi(n["needs-input"].level),o=r===s?`${r}%`:`${r}% and ${s}%`,l=t.on?`Sound: on at ${o} — a tone when a turn finishes, another when Claude asks for you (M)`:"Sound: off — press M, or use the switch in here, for a tone when a turn finishes (M)",u=e.codex?`
86
+
87
+ Both CLIs get the finish tone. The second tone — Claude is waiting for you — has no Codex equivalent to fire on, so it only ever plays for Claude Code.`:"",d=t.on&&t.locked?`
88
+
89
+ Waiting for a click: this browser plays no sound until the page has been used at least once. Anything you press unlocks it.`:"";return l+u+d+`
90
+
91
+ Click to set the volume and the sound of each tone, and to hear either one.`}function Rte(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 Mte(){return a.jsxs("div",{className:"empty-hero",children:[a.jsxs("div",{className:"orbit-stack","aria-hidden":!0,children:[a.jsx("div",{className:"core"}),a.jsxs("div",{className:"orbit r1",children:[a.jsx("span",{className:"dot"}),a.jsx("span",{className:"dot b"})]}),a.jsxs("div",{className:"orbit r2",children:[a.jsx("span",{className:"dot"}),a.jsx("span",{className:"dot b"})]}),a.jsxs("div",{className:"orbit r3",children:[a.jsx("span",{className:"dot"}),a.jsx("span",{className:"dot b"})]})]}),a.jsxs("h2",{children:["Too many ",bt," tabs are open"]}),a.jsxs("p",{children:["This browser keeps at most six live connections to one address, and other ",a.jsx("code",{children:bt})," tabs are holding them. Close one and this tab connects on its own."]})]})}function $te({live:e,everConnected:t,providers:n,workspace:r,onTour:s}){const o=!e;return a.jsxs("div",{className:"empty-hero",children:[a.jsxs("div",{className:"orbit-stack","aria-hidden":!0,children:[a.jsx("div",{className:"core"}),a.jsxs("div",{className:"orbit r1",children:[a.jsx("span",{className:"dot"}),a.jsx("span",{className:"dot b"})]}),a.jsxs("div",{className:"orbit r2",children:[a.jsx("span",{className:"dot"}),a.jsx("span",{className:"dot b"})]}),a.jsxs("div",{className:"orbit r3",children:[a.jsx("span",{className:"dot"}),a.jsx("span",{className:"dot b"})]})]}),o?a.jsxs(a.Fragment,{children:[a.jsx("h2",{children:t?"Disconnected from server":"Server unreachable"}),a.jsxs("p",{children:[t?"This page lost its connection to ":"This page cannot reach ",a.jsx("code",{children:bt}),". Check that it is still running in your terminal — the page picks up again on its own."]})]}):Ite(n,r),!o&&a.jsx("button",{type:"button",className:"btn empty-tour",onClick:s,children:"Take the tour"})]})}function Ite(e,t){const n=Rte(t);return a.jsxs(a.Fragment,{children:[a.jsx("h2",{children:"Waiting for Claude Code or Codex"}),n.kind==="scoped"?a.jsxs("p",{children:[n.lead," ",a.jsx("code",{children:n.workspace}),n.tail]}):a.jsxs("p",{children:["Run ",a.jsx("code",{children:"claude"})," or ",a.jsx("code",{children:"codex"})," in any folder. As soon as a session sends an event, a node appears here and grows as subagents fork and tools are called."]}),Tte(e).map(r=>a.jsx("p",{className:"hint-row",children:r.spans.map((s,o)=>s.code?a.jsx("code",{children:s.text},o):a.jsx("span",{children:s.text},o))},r.provider))]})}const Ote=1;function Lte(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 Pte(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:Ote,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(Lte)}))}}function Dte(e,t){const n=(e||"session").replace(/[^a-z0-9._-]/gi,"_");return`${bt}-${n}-${Bb(t,8)}.json`}const zO={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Fte={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 Bte({cat:e}){return a.jsx("svg",{className:"cat-glyph",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:Fte[e]})})}const Nd={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},WO=UM;function qte({agent:e,now:t,onOpenTool:n,onShowSummary:r,onExportSession:s,onRemove:o}){var b;const l=`${e.synthetic?"≥ ":""}${li(e.startedAt,e.endedAt,t)}`,u=hn(e),d=u.total>0,h=e.usage.inputTokens+e.usage.outputTokens,f=new Map;for(const[x,N]of e.toolCountByName??[]){const S=WO(x);f.set(S,(f.get(S)??0)+N)}const p=e.toolErrorCount??0,g=e.tools.filter(x=>!x.endedAt).length,v=Array.from(f.entries()).sort((x,N)=>N[1]-x[1]),k=f.has("mcp")?rU(((b=e.toolCountByName)==null?void 0:b.keys())??[]):null;return a.jsxs(a.Fragment,{children:[a.jsxs("header",{className:"detail-hero",children:[a.jsxs("div",{className:"hero-line",children:[a.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),a.jsx("h2",{className:"hero-title",title:e.cwd??e.label,children:e.label})]}),a.jsxs("div",{className:"hero-meta",children:[a.jsx("span",{className:"hero-meta-item",children:e.kind==="root"?"session":"subagent"}),a.jsx("span",{className:"hero-sep",children:"·"}),a.jsx("span",{className:"hero-meta-item",title:`started ${new Date(e.startedAt).toLocaleString()}`,children:l}),e.model&&(()=>{const x=TM(e);return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"hero-sep",children:"·"}),a.jsxs("span",{className:"model-chip","data-family":$d(e.model),title:x.length>0?`${e.model}
92
+ spend on this panel also covers:
93
+ ${x.join(`
94
+ `)}`:e.model,children:[Js(e.model),x.length>0?` +${x.length}`:""]})]})})()]}),d&&a.jsxs("div",{className:"hero-cost",children:[a.jsxs("div",{className:"hero-cost-headline",children:[a.jsx("span",{className:"hero-cost-value",children:qe(u.total)}),a.jsx("span",{className:"hero-cost-label",children:"spend"})]}),a.jsx(qb,{cost:u})]}),a.jsxs("div",{className:"hero-actions",children:[e.kind==="root"&&e.state==="done"&&r&&a.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>r(e.sessionId),title:"Reopen the end-of-session recap modal",children:"Show recap"}),s&&a.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>s(e.sessionId),title:"Download this session as JSON",children:"Export JSON"}),o&&a.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:o,title:e.kind==="root"?"Take this session's cards off the board (Delete). The session carries on; the session list (L) brings it back":"Take this card and the ones under it off the board (Delete). The session list (L) brings it back",children:"Remove from board"})]})]}),(()=>{const x=Pd(e);if(!x)return null;const N=ld(x.at,t);return a.jsxs("section",{className:"detail-section",children:[a.jsxs("h3",{children:["Recap ",a.jsx("span",{className:"section-count",title:N.title,children:N.label})]}),a.jsx("p",{className:"detail-recap",children:x.text})]})})(),e.tools.length>0&&a.jsxs("section",{className:"detail-section",children:[a.jsx("h3",{children:"Activity"}),a.jsxs("div",{className:"activity-row",children:[a.jsxs("div",{className:"activity-counters",children:[a.jsxs("span",{className:"ac-item",children:[a.jsx("b",{children:e.toolCount})," calls"]}),g>0&&a.jsxs("span",{className:"ac-item ac-live",children:[a.jsx("b",{children:g})," live"]}),p>0&&a.jsxs("span",{className:"ac-item ac-err",children:[a.jsx("b",{children:p})," err"]})]}),a.jsx("div",{className:"cat-strip",children:v.map(([x,N])=>{const S=x==="mcp"?k:null,_=S==null?void 0:S.hue,E=`${N} ${Nd[x]} call${N===1?"":"s"}`;return a.jsxs("span",{className:`cat-chip cat-${x}${_!=null?" mcp-hue":""}`,style:_!=null?{"--mcp-hue":_}:void 0,title:S?`${E}, all to ${S.label}`:E,children:[a.jsx("span",{className:"cat-emoji","aria-hidden":!0,children:zO[x]}),a.jsx("span",{className:"cat-name",children:Nd[x]}),a.jsx("span",{className:"cat-count",children:N}),S&&a.jsx("span",{className:"cat-server",children:S.label})]},x)})})]})]}),h>0&&a.jsxs("section",{className:"detail-section",children:[a.jsx("h3",{children:"Tokens"}),a.jsxs("div",{className:"tokens-grid",children:[a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"in"}),a.jsx("b",{title:e.usage.inputTokens.toLocaleString(),children:ot(e.usage.inputTokens)})]}),a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"out"}),a.jsx("b",{title:e.usage.outputTokens.toLocaleString(),children:ot(e.usage.outputTokens)})]}),a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"cache r"}),a.jsx("b",{title:e.usage.cacheReadTokens.toLocaleString(),children:ot(e.usage.cacheReadTokens)})]}),a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"cache c"}),a.jsx("b",{title:e.usage.cacheCreateTokens.toLocaleString(),children:ot(e.usage.cacheCreateTokens)})]})]})]}),a.jsxs("section",{className:"detail-section",children:[a.jsx("h3",{children:"Identity"}),a.jsxs("div",{children:[e.cwd&&a.jsxs("div",{className:"row",children:[a.jsx("span",{className:"k",children:"cwd"}),a.jsx("span",{className:"v",title:e.cwd,children:e.cwd})]}),a.jsxs("div",{className:"row",children:[a.jsx("span",{className:"k",children:"session"}),a.jsxs("span",{className:"v",children:[e.sessionId.slice(0,12),"…"]})]}),e.parentId&&a.jsxs("div",{className:"row",children:[a.jsx("span",{className:"k",children:"parent"}),a.jsxs("span",{className:"v",children:[e.parentId.slice(0,12),"…"]})]})]})]}),e.prompts.length>0&&a.jsxs("section",{className:"detail-section",children:[a.jsxs("h3",{children:["Prompts ",a.jsx("span",{className:"section-count",children:gM(e.prompts).length})]}),a.jsx("div",{className:"prompts",children:Ute(e.prompts).reverse().map(({pr:x,key:N})=>{const S=ld(x.at,t),_=Tb(x.text);return _?a.jsxs("details",{className:"prompt-entry prompt-injected",children:[a.jsxs("summary",{children:[a.jsx("span",{className:"prompt-time",title:S.title,children:S.label}),a.jsx("span",{className:"prompt-injected-label",children:_.label})]}),_.detail&&a.jsx("div",{className:"prompt-injected-detail",children:_.detail})]},N):a.jsxs("div",{className:"prompt-entry",children:[a.jsx("div",{className:"prompt-time",title:S.title,children:S.label}),a.jsx("div",{className:"prompt-text",children:x.text})]},N)})})]}),a.jsxs("section",{className:"detail-section",children:[a.jsxs("h3",{children:["Tool calls ",a.jsx("span",{className:"section-count",children:e.tools.length})]}),e.tools.length===0&&a.jsx("div",{className:"empty",children:"No tool calls yet."}),a.jsx("div",{children:e.tools.slice().reverse().map(x=>a.jsx(Wte,{t:x,onClick:()=>n(e.id,x.id)},x.id))})]})]})}function Ute(e){const t=new Map;return e.map(n=>{const r=t.get(n.at)??0;return t.set(n.at,r+1),{pr:n,key:r===0?String(n.at):`${n.at}:${r}`}})}const zte={inflight:"in-flight",done:"done",err:"error"};function Wte({t:e,onClick:t}){const n=e.endedAt==null?"inflight":e.ok===!1?"err":"done",r=RM(e,"…");return a.jsxs("button",{className:"tool clickable",title:e.inputPreview||e.name,onClick:t,children:[a.jsxs("span",{className:"name",children:[a.jsx("span",{className:`status-dot ${n}`,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:zte[n]}),e.name]}),a.jsx("span",{style:{color:"var(--muted)"},children:r})]})}function Hte(e,t){const n=Pte(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=Dte(n.label,t),document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(o),1e3)}function Vte({selected:e,now:t,openTool:n,setSummaryFor:r,setDetailOpen:s,stateRef:o,removeSelectedNode:l}){return a.jsxs("aside",{className:"detail","aria-label":"Detail",children:[a.jsx("button",{type:"button",className:"glyph-btn detail-close",title:"Close panel","aria-label":"Close detail panel",onClick:()=>s(!1),children:"×"}),a.jsx(qte,{agent:e,now:t,onOpenTool:n,onShowSummary:r,onExportSession:u=>Hte(o.current,u),onRemove:l})]})}function HO({id:e,value:t,onLevel:n,"aria-describedby":r}){return a.jsxs("div",{className:"sm-row",children:[a.jsx("label",{htmlFor:e,children:"Volume"}),a.jsx("input",{id:e,type:"range",min:Wu,max:gd,step:Wx,value:t,"aria-describedby":r,onChange:s=>n(Number(s.target.value)),style:{"--sm-level":`${(t-Wu)/(gd-Wu)*100}%`}}),a.jsxs("span",{className:"sm-read",children:[t,"%"]})]})}const VO="agent-dag.character-enabled",GO="agent-dag.fm-volume",aR="agent-dag.fm-source",Gte=[{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 Kte(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 Yte(e){return e!=="0"}function Xte(){return Yte(et(VO))}function Zte(e){return _I(e)}function Jte(){return Zte(et(GO))}const Bo=["light","dark"],Qte={light:"Light",dark:"Dark"},oR=Gte,qo="Give the station a name.",ene="Use an https YouTube live or channel link, or a .mp3, .aac, .ogg or .m3u8 stream.";function tne({theme:e}){return a.jsx("span",{className:"appearance-preview","data-swatch":e,children:a.jsxs("svg",{viewBox:"0 0 112 56","aria-hidden":!0,focusable:"false",children:[a.jsx("rect",{className:"tp-canvas",width:"112",height:"56"}),a.jsx("rect",{className:"tp-surface",width:"112",height:"7"}),a.jsx("rect",{className:"tp-rule",y:"7",width:"112",height:"1"}),a.jsx("rect",{className:"tp-surface",y:"8",width:"25",height:"48"}),a.jsx("rect",{className:"tp-rule",x:"25",y:"8",width:"1",height:"48"}),a.jsx("rect",{className:"tp-card",x:"36.5",y:"27.5",width:"28",height:"14",rx:"2.5"}),a.jsx("rect",{className:"tp-tag",x:"39.5",y:"25.5",width:"13",height:"4",rx:"2"}),a.jsx("rect",{className:"tp-card",x:"76.5",y:"14.5",width:"29",height:"20",rx:"2.5"}),a.jsx("rect",{className:"tp-rule",x:"81",y:"23",width:"20",height:"2",rx:"1"}),a.jsx("rect",{className:"tp-accent",x:"81",y:"23",width:"12",height:"2",rx:"1"})]})})}function nne({theme:e,onTheme:t,characterEnabled:n,onToggleCharacter:r,fmVolume:s,onFmVolume:o,fmMuted:l,onFmMuted:u,fmSource:d,onFmSource:h,customFmStations:f,unavailableFmStations:p,onAddFmStation:g,onRenameFmStation:v,onRemoveFmStation:k,reportsOn:b,reportsVetoed:x,onToggleReports:N,onFeedback:S,onClose:_}){var Ve;const E=ft(_),T=[...oR.map(le=>({...le,label:p.has(le.value)?`${le.label} · not live`:le.label,unavailable:p.has(le.value)})),...f.map(le=>({group:"🎵 Your stations",value:Fa(le.id),label:p.has(le.id)?`${le.name} · unavailable`:le.name,unavailable:p.has(le.id)}))],A=T.some(le=>le.value===d&&le.unavailable),R=[];T.forEach((le,je)=>{const $e=R[R.length-1];$e&&$e.group===le.group?$e.indexes.push(je):R.push({group:le.group,indexes:[je]})});const[B,P]=w.useState(!1),[D,O]=w.useState(()=>Math.max(0,T.findIndex(le=>le.value===d))),[L,z]=w.useState(!1),[M,$]=w.useState(""),[q,X]=w.useState(""),[H,I]=w.useState(""),[W,F]=w.useState(!1),[Y,J]=w.useState(""),[V,G]=w.useState(""),K=w.useRef(null),Z=w.useRef(null),ee=w.useRef(null),re=w.useRef(null),ue=w.useRef(null),me=ai(d),ae=me?f.find(le=>le.id===me):void 0;w.useEffect(()=>{const le=T.findIndex(je=>je.value===d);O(le<0?0:le)},[d,f,p]),w.useEffect(()=>{F(!1),J((ae==null?void 0:ae.name)??"")},[ae==null?void 0:ae.id,ae==null?void 0:ae.name]),w.useEffect(()=>{var le;B&&((le=document.getElementById(`appearance-fm-option-${D}`))==null||le.scrollIntoView({block:"nearest"}))},[D,B]),w.useEffect(()=>{if(!B)return;const le=je=>{var Oe,ze;const $e=je.target;!((Oe=K.current)!=null&&Oe.contains($e))&&!((ze=ue.current)!=null&&ze.contains($e))&&P(!1)};return document.addEventListener("pointerdown",le),()=>document.removeEventListener("pointerdown",le)},[B]);const pe=le=>{const je=le.relatedTarget;je&&!le.currentTarget.contains(je)&&P(!1)},xe=le=>{var $e;const je=T[le];je&&(O(le),h(je.value),P(!1),($e=K.current)==null||$e.focus())},se=le=>{if(Xq(le.key)){if(!B)return;le.preventDefault(),le.stopPropagation(),P(!1);return}if(le.key==="Tab"){P(!1);return}if(le.key==="Enter"||le.key===" "){le.preventDefault(),B?xe(D):P(!0);return}le.key!=="ArrowDown"&&le.key!=="ArrowUp"&&le.key!=="Home"&&le.key!=="End"||(le.preventDefault(),P(!0),O(je=>le.key==="Home"?0:le.key==="End"?T.length-1:Math.min(T.length-1,Math.max(0,je+(le.key==="ArrowDown"?1:-1)))))},ve=()=>{var le;return(le=K.current)==null?void 0:le.focus()},fe=le=>{var $e,Oe;if(le.preventDefault(),!M.trim()){I(qo),($e=Z.current)==null||$e.focus();return}const je=yB(M,q);if(!je){I(ene),(Oe=ee.current)==null||Oe.focus();return}g(je),h(Fa(je.id)),$(""),X(""),I(""),z(!1),ve()},he=le=>{var je;if(le.preventDefault(),!!me){if(!Y.trim()){G(qo),(je=re.current)==null||je.focus();return}v(me,Y),F(!1),ve()}},_e=le=>{var Oe;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(le.key))return;le.preventDefault();const $e=(Bo.indexOf(e)+(le.key==="ArrowLeft"||le.key==="ArrowUp"?-1:1)+Bo.length)%Bo.length;t(Bo[$e]),(Oe=le.currentTarget.querySelectorAll('[role="radio"]')[$e])==null||Oe.focus()},Fe=le=>{var $e;if(le.key===" "){le.stopPropagation();return}if(Ld(le.target)||le.key!=="t"&&le.key!=="T"||le.ctrlKey||le.metaKey||le.altKey)return;le.preventDefault(),le.stopPropagation();const je=e==="dark"?"light":"dark";t(je),le.target.getAttribute("role")==="radio"&&(($e=le.currentTarget.querySelectorAll('[role="radio"]')[Bo.indexOf(je)])==null||$e.focus())},Le=le=>{const je=T[le],$e="unavailable"in je&&je.unavailable;return a.jsxs("div",{className:"appearance-source-option",role:"option",id:`appearance-fm-option-${le}`,"aria-selected":d===je.value,"data-highlighted":D===le||void 0,"data-unavailable":$e||void 0,onMouseEnter:()=>O(le),onClick:()=>xe(le),children:[a.jsx("span",{children:je.label}),d===je.value&&a.jsx("span",{"aria-hidden":!0,children:"✓"})]},je.value)};return Lt.createPortal(a.jsx("div",{className:"modal-backdrop appearance-backdrop",onClick:_,role:"presentation",children:a.jsxs("div",{ref:E,id:"appearance-menu",className:"modal appearance-menu appearance-modal",role:"dialog","aria-modal":"true","aria-labelledby":"appearance-title",onClick:le=>le.stopPropagation(),onKeyDown:Fe,children:[a.jsxs("div",{className:"appearance-head",children:[a.jsxs("div",{className:"appearance-heading",children:[a.jsx("h2",{id:"appearance-title",className:"appearance-title",children:"Appearance"}),a.jsx("p",{className:"appearance-subtitle",children:"Tune the deck to your workspace."})]}),a.jsx("button",{type:"button",className:"glyph-btn appearance-close",onClick:_,"aria-label":"Close appearance settings",title:"Close (Esc)",children:"×"})]}),a.jsxs("section",{className:"appearance-section","aria-labelledby":"appearance-theme-caption",children:[a.jsxs("div",{className:"appearance-caption",children:[a.jsxs("div",{children:[a.jsx("h3",{id:"appearance-theme-caption",children:"Color theme"}),a.jsx("p",{className:"appearance-section-note",children:"Choose how the dashboard looks."})]}),a.jsx("kbd",{className:"appearance-key","aria-hidden":!0,title:"Press T anywhere to switch themes",children:"T"})]}),a.jsx("div",{className:"appearance-themes",role:"radiogroup","aria-labelledby":"appearance-theme-caption","aria-keyshortcuts":"T",onKeyDown:_e,children:Bo.map(le=>a.jsxs("button",{type:"button",className:"appearance-theme",role:"radio","aria-checked":e===le,tabIndex:e===le?0:-1,onClick:()=>t(le),children:[a.jsx(tne,{theme:le}),a.jsxs("span",{className:"appearance-theme-name",children:[Qte[le],a.jsx("svg",{className:"appearance-check",viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 6.4 4.9 8.7 9.5 3.6"})})]})]},le))})]}),a.jsxs("section",{className:"appearance-section","aria-labelledby":"appearance-fm-caption",children:[a.jsx("div",{className:"appearance-caption",children:a.jsx("h3",{id:"appearance-fm-caption",children:"Music source"})}),a.jsxs("div",{className:"appearance-controls",children:[a.jsxs("div",{className:"appearance-source-row",children:[a.jsx("label",{htmlFor:"appearance-fm-source",children:"Station"}),a.jsxs("div",{className:`appearance-source-picker${B?" is-open":""}`,onBlur:pe,children:[a.jsxs("button",{ref:K,type:"button",id:"appearance-fm-source",className:"appearance-source-trigger",role:"combobox","aria-haspopup":"listbox","aria-expanded":B,"aria-controls":B?"appearance-fm-source-list":void 0,"aria-activedescendant":B?`appearance-fm-option-${D}`:void 0,"aria-describedby":"appearance-fm-source-note",onClick:()=>P(le=>!le),onKeyDown:se,children:[a.jsx("span",{children:((Ve=T.find(le=>le.value===d))==null?void 0:Ve.label)??oR[0].label}),a.jsx("svg",{viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"m2.5 4.5 3.5 3 3.5-3"})})]}),B&&a.jsx("div",{ref:ue,id:"appearance-fm-source-list",className:"appearance-source-list",role:"listbox","aria-label":"Music stations",children:R.map((le,je)=>le.group?a.jsxs("div",{role:"group","aria-labelledby":`appearance-fm-group-${je}`,children:[a.jsx("div",{id:`appearance-fm-group-${je}`,className:"appearance-source-group",role:"presentation",children:le.group}),le.indexes.map(Le)]},`group-${je}`):le.indexes.map(Le))})]})]}),a.jsx("span",{id:"appearance-fm-source-note",className:"vis-hidden",children:"Changing station starts live playback automatically."}),a.jsx("p",{className:"appearance-fm-status",role:"status",children:A?dB(ai(d)!==null):""}),a.jsxs("div",{className:"appearance-station-manage",children:[a.jsx("button",{type:"button",className:"btn appearance-station-action","aria-expanded":L,onClick:()=>{z(le=>!le),I("")},children:L?"Cancel":"+ Add station"}),ae&&!W&&a.jsxs("span",{className:"appearance-station-edit",children:[a.jsx("button",{type:"button",className:"btn appearance-station-action",onClick:()=>{J(ae.name),G(""),F(!0)},children:"Rename"}),a.jsx("button",{type:"button",className:"btn danger appearance-station-action",onClick:()=>{k(ae.id),ve()},children:"Remove"})]})]}),L&&a.jsxs("form",{className:"appearance-station-form",onSubmit:fe,noValidate:!0,children:[a.jsxs("label",{className:"appearance-station-field",children:[a.jsx("span",{children:"Station name"}),a.jsx("input",{ref:Z,className:"ap-manage-input",value:M,onChange:le=>$(le.target.value),"aria-invalid":H===qo||void 0,"aria-describedby":H===qo?"appearance-station-error":void 0,maxLength:Ll,autoFocus:!0})]}),a.jsxs("label",{className:"appearance-station-field",children:[a.jsx("span",{children:"Link"}),a.jsx("input",{ref:ee,className:"ap-manage-input",value:q,onChange:le=>X(le.target.value),placeholder:"https://…","aria-invalid":H!==""&&H!==qo||void 0,"aria-describedby":H&&H!==qo?"appearance-station-error":void 0,inputMode:"url",autoComplete:"off",spellCheck:!1,maxLength:sM})]}),a.jsx("button",{type:"submit",className:"btn primary",children:"Add"}),H&&a.jsx("p",{id:"appearance-station-error",className:"appearance-station-error",role:"alert",children:H})]}),ae&&W&&a.jsxs("form",{className:"appearance-station-form is-rename",onSubmit:he,noValidate:!0,children:[a.jsxs("label",{className:"appearance-station-field",children:[a.jsx("span",{children:"Station name"}),a.jsx("input",{ref:re,className:"ap-manage-input",value:Y,onChange:le=>J(le.target.value),"aria-invalid":V!==""||void 0,"aria-describedby":V?"appearance-rename-error":void 0,maxLength:Ll,autoFocus:!0})]}),a.jsx("button",{type:"submit",className:"btn primary",children:"Save"}),a.jsx("button",{type:"button",className:"btn",onClick:()=>{F(!1),ve()},children:"Cancel"}),V&&a.jsx("p",{id:"appearance-rename-error",className:"appearance-station-error",role:"alert",children:V})]}),a.jsxs("label",{className:"appearance-row",children:[a.jsx("span",{className:"appearance-row-label",id:"appearance-character-label",children:"Show character on minimap"}),a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":n,"aria-labelledby":"appearance-character-label","aria-describedby":"appearance-character-note",onClick:r,children:a.jsx("span",{className:"switch-knob"})}),a.jsx("span",{id:"appearance-character-note",className:"vis-hidden",children:"Shows the animated minimap character and enables music playback."})]}),a.jsx(HO,{id:"appearance-fm-volume",value:s,"aria-describedby":"appearance-fm-volume-note",onLevel:o}),a.jsxs("label",{className:"appearance-row",children:[a.jsx("span",{className:"appearance-row-label",id:"appearance-fm-mute-label",children:"Mute music"}),a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":l,"aria-labelledby":"appearance-fm-mute-label",onClick:u,children:a.jsx("span",{className:"switch-knob"})})]})]}),a.jsx("span",{id:"appearance-fm-volume-note",className:"vis-hidden",children:"Controls live music volume."})]}),a.jsxs("section",{className:"appearance-section","aria-labelledby":"appearance-improve-caption",children:[a.jsx("div",{className:"appearance-caption",children:a.jsx("h3",{id:"appearance-improve-caption",children:"Help improve ccdeck"})}),a.jsxs("div",{className:"appearance-controls",children:[a.jsxs("label",{className:"appearance-row",children:[a.jsx("span",{className:"appearance-row-label",id:"appearance-reports-label",children:"Send usage reports"}),a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":b,"aria-labelledby":"appearance-reports-label","aria-describedby":"appearance-reports-note",disabled:x,onClick:N,children:a.jsx("span",{className:"switch-knob"})})]}),a.jsx("p",{id:"appearance-reports-note",className:"appearance-section-note",children:x?"Off: this deck was started with AGENTS_DECK_NO_REPORTS=1 or AGENTS_DECK_NO_INSTALL=1.":"On by default. The deck reports installs, updates, daily use and errors, plus your IP address and a device fingerprint (a stable hashed machine id) — no longer anonymous. Your sessions, prompts and files never leave. Turning it off deletes what was sent."}),a.jsx("div",{className:"appearance-improve-actions",children:a.jsx("button",{type:"button",className:"btn appearance-station-action",onClick:S,children:"Send feedback…"})})]})]})]})}),document.body)}const rne="With no deck tab open, get a notification wherever a sound would have played.",sne="With the ccdeck window closed, get a notification wherever a sound would have played.";function ane(e){return e?sne:rne}const one="Held off for this run — the deck was started with alerts disabled. Your choice is saved for the next start.",iR="Get notified when you're away from this tab.";function ine(e){switch(e){case"granted":return{status:"Enabled",ask:!1,ok:!0,note:iR};case"default":return{status:null,ask:!0,ok:!1,note:iR};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 Yl(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}const lne=["audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4"];function cne(e){return lne.find(t=>e(t))}const une=4400;function dne(e){const t=e.split(";")[0];return{name:`Recorded voice.${t==="audio/mp4"?"m4a":t==="audio/ogg"?"ogg":"webm"}`,type:t}}function hne({full:e,setCustomError:t,runCustom:n,onImportCustom:r}){const[s,o]=w.useState(!1),l=w.useRef(null),u=w.useRef(null),d=w.useRef(!1),h=()=>{var p;u.current!==null&&clearTimeout(u.current),u.current=null,((p=l.current)==null?void 0:p.state)==="recording"&&l.current.stop()},f=async()=>{var g;if(e)return;if(t(""),!((g=navigator.mediaDevices)!=null&&g.getUserMedia)||typeof MediaRecorder>"u"){t("Microphone recording is unavailable in this browser.");return}let p;try{p=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{d.current||t("Microphone access was denied or unavailable.");return}if(d.current||l.current){p.getTracks().forEach(v=>v.stop());return}try{const v=cne(x=>MediaRecorder.isTypeSupported(x)),k=new MediaRecorder(p,v?{mimeType:v}:void 0),b=[];l.current=k,k.ondataavailable=x=>{x.data.size&&b.push(x.data)},k.onerror=()=>t("Recording failed. Please try again."),k.onstop=()=>{p.getTracks().forEach(_=>_.stop()),u.current!==null&&clearTimeout(u.current),u.current=null;const x=l.current===k;if(x&&(l.current=null),o(!1),!x||!b.length)return;const N=dne(k.mimeType),S=new File(b,N.name,{type:N.type});n(()=>r(S))},k.start(200),o(!0),u.current=setTimeout(h,une)}catch{l.current=null,p.getTracks().forEach(v=>v.stop()),t("This browser cannot record a supported audio format.")}};return w.useEffect(()=>(d.current=!1,()=>{d.current=!0,u.current!==null&&clearTimeout(u.current);const p=l.current;l.current=null,(p==null?void 0:p.state)==="recording"&&p.stop()}),[]),{recording:s,startRecording:f,stopRecording:h}}function fne({full:e,fullProps:t,runCustom:n,onCreateVoice:r}){const[s,o]=w.useState("Custom voice"),[l,u]=w.useState("Your turn"),[d,h]=w.useState(""),[f,p]=w.useState("1"),[g,v]=w.useState("1"),[k,b]=w.useState([]);return w.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const x=()=>{b(window.speechSynthesis.getVoices())};return x(),window.speechSynthesis.addEventListener("voiceschanged",x),()=>window.speechSynthesis.removeEventListener("voiceschanged",x)},[]),a.jsxs("details",{className:"sm-voice",children:[a.jsxs("summary",{...t,onClick:x=>{const N=x.currentTarget.parentElement;e&&N&&!N.open&&x.preventDefault()},children:[a.jsx("span",{children:"Spoken voice"}),a.jsx("span",{children:"Create from text"})]}),a.jsxs("div",{className:"sm-voice-fields",children:[a.jsxs("label",{children:[a.jsx("span",{children:"Name"}),a.jsx("input",{className:"ap-manage-input",value:s,maxLength:80,onChange:x=>o(x.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Text"}),a.jsx("input",{className:"ap-manage-input",value:l,maxLength:180,onChange:x=>u(x.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Voice"}),a.jsxs("select",{className:"sm-select",value:d,onChange:x=>h(x.target.value),children:[a.jsx("option",{value:"",children:"System default"}),k.map(x=>a.jsx("option",{value:x.voiceURI,children:x.name},x.voiceURI))]})]}),a.jsxs("div",{className:"sm-voice-pair",children:[a.jsxs("label",{children:[a.jsx("span",{children:"Rate"}),a.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:f,onChange:x=>p(x.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Pitch"}),a.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:g,onChange:x=>v(x.target.value)})]})]}),a.jsx("button",{type:"button",className:"btn sm-custom-action",...t,onClick:()=>{e||n(async()=>{await r({name:s,text:l,voiceURI:d,rate:parseFloat(f),pitch:parseFloat(g)}),u("Your turn")})},children:"Add spoken voice"})]})]})}function pne({customAssets:e,onImportCustom:t,onCreateVoice:n,onRenameCustom:r,onPreviewCustom:s,onDeleteCustom:o}){const[l,u]=w.useState(""),d=e.length,h=Ux(d),f=h!==null,p=f?{"aria-disabled":!0,"aria-describedby":"sm-custom-full"}:{},[g,v]=w.useState(null),k=w.useRef(0),b=w.useRef(new Map),x=w.useRef(null);w.useEffect(()=>{if(!g)return;const A=window.setTimeout(()=>v(null),4e3);return()=>window.clearTimeout(A)},[g]);const N=async A=>{u("");try{await A()}catch(R){u(R instanceof Error?R.message:"Custom audio could not be saved.")}},S=(A,R)=>{const B=Date.now(),P=ql({armedFor:g,target:A,armedAt:k.current,now:B,gapMs:Bl});if(P==="arm"){v(A),k.current=B;return}if(P==="ignore")return;v(null);const D=UY(e.map(O=>O.id),A);N(async()=>{var L;await o(A);const O=document.activeElement;O!==R&&!Pr((O==null?void 0:O.tagName)??null)||(L=D?b.current.get(D):x.current)==null||L.focus()})},{recording:_,startRecording:E,stopRecording:T}=hne({full:f,setCustomError:u,runCustom:N,onImportCustom:t});return a.jsxs("section",{className:"sm-custom","aria-labelledby":"sm-custom-title",children:[a.jsxs("div",{className:"sm-custom-head",children:[a.jsx("h3",{className:"sm-tone-name",id:"sm-custom-title",children:"Custom sounds"}),a.jsxs("span",{children:[d," of ",qx,", kept on this machine"]})]}),f&&a.jsx("p",{className:"sm-note",id:"sm-custom-full",children:h}),a.jsxs("div",{className:"sm-custom-actions",children:[a.jsxs("label",{className:"sm-custom-card sm-file",children:[a.jsxs("span",{className:"sm-custom-card-copy",children:[a.jsx("strong",{children:"Import audio"}),a.jsx("span",{children:"WAV, MP3 or OGG"})]}),a.jsx("span",{className:"btn sm-custom-action","aria-hidden":"true",children:"Choose file"}),a.jsx("input",{ref:x,type:"file",accept:"audio/wav,audio/x-wav,audio/mpeg,audio/mp3,audio/ogg,.wav,.mp3,.ogg",...p,onClick:A=>{f&&A.preventDefault()},onChange:A=>{var B;const R=(B=A.target.files)==null?void 0:B[0];A.currentTarget.value="",R&&!f&&N(()=>t(R))}})]}),a.jsxs("div",{className:"sm-custom-card",children:[a.jsxs("span",{className:"sm-custom-card-copy",children:[a.jsx("strong",{children:"Record a clip"}),a.jsx("span",{children:_?"Recording…":"Up to 5 seconds"})]}),_?a.jsx("button",{type:"button",className:"btn sm-custom-action",onClick:T,children:"Stop & save"}):a.jsx("button",{type:"button",className:"btn sm-custom-action",...p,onClick:()=>void E(),children:"Record"})]})]}),a.jsx(fne,{full:f,fullProps:p,runCustom:N,onCreateVoice:n}),e.length>0&&a.jsx("div",{className:"sm-custom-list",children:e.map(A=>a.jsxs("div",{className:"sm-custom-item",children:[a.jsx("input",{className:"ap-manage-input","aria-label":`Rename ${A.name}`,defaultValue:A.name,maxLength:80,onBlur:R=>{if(!R.target.value.trim()){R.target.value=A.name;return}N(()=>r(A.id,R.target.value))},onKeyDown:R=>{R.key==="Enter"&&R.currentTarget.blur()}}),a.jsx("span",{children:A.kind==="audio"?`${A.duration.toFixed(1)}s`:"Voice"}),a.jsx("button",{type:"button",className:"btn sm-custom-icon","aria-label":`Play ${A.name}`,onClick:()=>s(A.id),children:"Play"}),a.jsx("button",{type:"button",ref:R=>{R?b.current.set(A.id,R):b.current.delete(A.id)},className:`btn sm-custom-icon${g===A.id?" armed":""}`,onKeyDown:R=>{R.repeat&&R.preventDefault()},onClick:R=>S(A.id,R.currentTarget),"aria-label":g===A.id?`Confirm deleting ${A.name}`:`Delete ${A.name}`,title:g===A.id?"Press again to delete this sound. It cannot be brought back.":"Delete this sound",children:g===A.id?"Confirm":"Delete"})]},A.id))}),l&&a.jsx("p",{className:"sm-custom-error",role:"alert",children:l})]})}const Jx="custom:";function lR(e){return`${Jx}${e}`}function mne(e){return e.startsWith(Jx)?e.slice(Jx.length):null}const cR={done:"Turn finished","needs-input":"Claude is asking"},gne={done:"Plays when Claude or Codex finishes a turn.","needs-input":"Available in Claude Code only."};function yne({chime:e,tone:t,soundOn:n,customAssets:r,customSelections:s,onLevel:o,onFigure:l,onPreview:u,onBuiltInSelected:d,onCustomSelected:h}){const f=`sm-level-${e}`,p=`sm-figure-${e}`,g=s[e];return a.jsxs("section",{className:"sm-tone","aria-labelledby":`sm-name-${e}`,children:[a.jsxs("div",{className:"sm-tone-head",children:[a.jsx("h3",{className:"sm-tone-name",id:`sm-name-${e}`,children:cR[e]}),a.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>u(e),"aria-label":`Hear the ${cR[e].toLowerCase()} tone`,title:n?"Play this tone now, at what it is set to":"Plays even when Sounds is off","aria-describedby":n?void 0:"sm-preview-note",children:[a.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:a.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),"Hear it"]})]}),a.jsx(HO,{id:f,value:t.level,onLevel:v=>o(e,v)}),a.jsxs("div",{className:"sm-row",children:[a.jsx("label",{htmlFor:p,children:"Tone"}),a.jsxs("select",{id:p,className:"sm-select",value:g?lR(g):t.figure,onChange:v=>{const k=v.target.value,b=mne(k);b!==null?h(e,b):(d(e),l(e,k))},children:[r0[e].map(v=>a.jsx("option",{value:v.id,children:v.label},v.id)),r.length>0&&a.jsx("optgroup",{label:"Custom",children:r.map(v=>a.jsx("option",{value:lR(v.id),children:v.name},v.id))})]})]}),a.jsx("p",{className:"sm-note",children:gne[e]})]})}function wne({onClose:e,soundOn:t,onToggleSound:n,prefs:r,onLevel:s,onFigure:o,onPreview:l,openerRef:u,customAssets:d,customSelections:h,onBuiltInSelected:f,onCustomSelected:p,onImportCustom:g,onCreateVoice:v,onRenameCustom:k,onPreviewCustom:b,onDeleteCustom:x,notifyOn:N,onToggleNotify:S,notifyVetoed:_,notifyPermission:E,onAskNotify:T}){var $;const A=ine(E),R=Yl(),B=N&&!_&&!R,P=BY(h),D=(($=d.find(q=>q.id===P))==null?void 0:$.name)??"the same custom sound",O=P?`Both tones use “${D}”. They may be harder to tell apart.`:"",L=ft(e,{popover:!0});E$(L,()=>u.current,e);const z=w.useRef(null),M=md(!A.ask,z);return a.jsxs("div",{ref:L,id:"sound-menu",className:"sound-menu",role:"dialog","aria-label":"Sound settings",children:[a.jsxs("div",{className:"sm-switches",children:[a.jsxs("label",{className:"sm-switch",children:[a.jsx("span",{className:"sm-switch-label",id:"sm-sound-label",children:"Sounds"}),a.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-labelledby":"sm-sound-label",className:"switch",onClick:n,title:"A tone when a turn finishes, and when Claude asks for something",children:a.jsx("span",{className:"switch-knob"})})]}),a.jsxs("div",{className:"sm-setting",children:[a.jsxs("label",{className:"sm-switch",children:[a.jsx("span",{className:"sm-switch-label",id:"sm-notify-label",children:"Notifications while closed"}),a.jsx("button",{ref:z,type:"button",role:"switch","aria-checked":N,"aria-labelledby":"sm-notify-label",className:"switch",onClick:S,title:"With no deck tab open, a notification wherever a sound would play",children:a.jsx("span",{className:"switch-knob"})})]}),a.jsx("p",{className:"sm-note",children:_?one:ane(R)})]})]}),B&&a.jsxs("section",{className:"sm-channel","aria-labelledby":"sm-channel-name",children:[a.jsxs("div",{className:"sm-channel-head",children:[a.jsx("h3",{className:"sm-channel-name",id:"sm-channel-name",children:"Browser notifications"}),A.ask?a.jsx("button",{type:"button",className:"btn sm-channel-action",onClick:()=>{M(),T()},children:"Enable"}):a.jsxs("span",{className:"sm-channel-state","data-ok":A.ok||void 0,children:[A.ok&&a.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M1.5 5.2 3.9 7.6 8.5 2.4"})}),A.status]})]}),a.jsx("p",{className:"sm-note",children:A.note})]}),!t&&a.jsx("span",{id:"sm-preview-note",className:"vis-hidden",children:"Plays even when Sounds is off, so you can set a tone before turning sounds back on."}),a.jsx("div",{className:"sm-tones",children:zu.map(q=>a.jsx(yne,{chime:q,tone:r[q],soundOn:t,customAssets:d,customSelections:h,onLevel:s,onFigure:o,onPreview:l,onBuiltInSelected:f,onCustomSelected:p},q))}),O&&a.jsx("p",{className:"sm-note","aria-hidden":!0,children:O}),a.jsx("p",{className:"vis-hidden",role:"status",children:O}),a.jsx(pne,{customAssets:d,onImportCustom:g,onCreateVoice:v,onRenameCustom:k,onPreviewCustom:b,onDeleteCustom:x}),a.jsxs("p",{className:"sm-foot",children:[a.jsx("kbd",{children:"M"}),"Mute or unmute sounds anywhere."]})]})}function vne({sessionListOpen:e,toggleSessionList:t,usagePanelOpen:n,setUsagePanelOpen:r,setUsageHistoryOpen:s}){return a.jsxs("div",{className:"action-run",children:[a.jsxs("button",{className:"btn icon-btn",onClick:t,title:`${e?"Hide":"Show"} session list (L)`,"aria-label":"Toggle session list","aria-expanded":e,"aria-controls":e?"session-list":void 0,children:[a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M5.4 3.6h6.6M5.4 7h6.6M5.4 10.4h6.6"}),a.jsx("path",{d:"M2.2 3.6h.2M2.2 7h.2M2.2 10.4h.2"})]}),a.jsx("span",{className:"tb-word",children:"Session list"})]}),a.jsxs("button",{className:"btn icon-btn",onClick:()=>r(o=>!o),title:`${n?"Hide":"Show"} usage panel (U)`,"aria-label":"Toggle usage panel","aria-expanded":n,"aria-controls":n?"usage-panel":void 0,children:[a.jsxs("svg",{className:"tb-glyph-narrow",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M9.4 4.5C9 3.6 8.1 3.1 7 3.1c-1.4 0-2.4.8-2.4 1.9 0 1.2 1.2 1.6 2.4 2s2.4.8 2.4 2c0 1.1-1 1.9-2.4 1.9-1.1 0-2-.5-2.4-1.4"}),a.jsx("path",{d:"M7 1.6v1.5M7 10.9v1.5"})]}),a.jsx("span",{className:"tb-word",children:"Usage"})]}),a.jsxs("button",{className:"btn icon-btn",onClick:()=>s(o=>!o),title:"Usage history — ccusage (H)","aria-label":"Open usage history","aria-haspopup":"dialog",children:[a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("line",{x1:"3",y1:"11.5",x2:"3",y2:"7"}),a.jsx("line",{x1:"7",y1:"11.5",x2:"7",y2:"3"}),a.jsx("line",{x1:"11",y1:"11.5",x2:"11",y2:"8.5"})]}),a.jsx("span",{className:"tb-word",children:"History"})]})]})}function xne({providers:e,accountsPanelOpen:t,toggleAccountsPanel:n,machinePanelOpen:r,setMachinePanelOpen:s,watchOn:o,watchUnseen:l,setBrowserWatchOpen:u}){return a.jsxs("div",{className:"action-run",children:[e.claude&&a.jsxs("button",{className:"btn icon-btn",onClick:n,title:`${t?"Hide":"Show"} accounts (A)`,"aria-label":"Toggle accounts panel","aria-expanded":t,"aria-controls":t?"accounts-panel":void 0,children:[a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("circle",{cx:"7",cy:"4.6",r:"2.4"}),a.jsx("path",{d:"M2.4 12c0-2.3 2.1-3.7 4.6-3.7s4.6 1.4 4.6 3.7"})]}),a.jsx("span",{className:"tb-word",children:"Accounts"})]}),a.jsxs("button",{className:"btn icon-btn",onClick:()=>s(d=>!d),title:`${r?"Hide":"Show"} this machine — cores, memory, temperature (S)`,"aria-label":"Toggle machine detail","aria-expanded":r,"aria-controls":r?"system-panel":void 0,children:[a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("rect",{x:"3.6",y:"3.6",width:"6.8",height:"6.8",rx:"1.2"}),a.jsx("path",{d:"M5.8 1.4v2.2M8.2 1.4v2.2M5.8 10.4v2.2M8.2 10.4v2.2M1.4 5.8h2.2M1.4 8.2h2.2M10.4 5.8h2.2M10.4 8.2h2.2"})]}),a.jsx("span",{className:"tb-word",children:"Machine"})]}),a.jsxs("button",{className:"btn icon-btn bw-btn",onClick:()=>u(d=>!d),title:o?"Browser watch — watching; the deck is keeping its own copy (B)":"Browser watch — not watching; reading the browser's history live (B)","aria-label":`Browser watch, ${o?"watching":"not watching"}`+(l>0?`, ${l} unread`:""),"aria-haspopup":"dialog",children:[a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M0.9 7s2.2-4 6.1-4 6.1 4 6.1 4-2.2 4-6.1 4S0.9 7 0.9 7Z"}),o||l>0?a.jsx("circle",{cx:"7",cy:"7",r:"1.8",fill:"currentColor",stroke:"none"}):a.jsx("line",{x1:"2.4",y1:"11.6",x2:"11.6",y2:"2.4"})]}),a.jsx("span",{className:"tb-word",children:"Browser watch"}),l>0&&a.jsx("span",{className:"bw-badge","aria-hidden":!0,children:l})]})]})}function bne({providers:e,sound:t,tones:n,customTones:r,notify:s,chimeState:o,menus:l,appearance:u,fm:d,reports:h,onFeedback:f}){const{soundOn:p,toggleSound:g}=t,{tonePrefs:v,previewTone:k,changeTone:b}=n,{customSelections:x,customAssets:N,clearCustomOnly:S,selectCustomTone:_,importNotificationAudio:E,createNotificationVoice:T,renameCustomAsset:A,deleteCustomAsset:R,previewCustomAsset:B}=r,{notifyPermission:P,notifyOn:D,notifyVetoed:O,toggleNotify:L,notifySupported:z,askForNotifications:M}=s,{soundMenuOpen:$,setSoundMenuOpen:q,soundButtonRef:X,appearanceMenuOpen:H,setAppearanceMenuOpen:I,appearanceButtonRef:W}=l,{theme:F,setTheme:Y,characterEnabled:J,setCharacterEnabled:V}=u,{fmVolume:G,setFmVolume:K,fmMuted:Z,setFmMuted:ee,fmSource:re,customFmStations:ue,unavailableFmStations:me,addFmStation:ae,renameFmStation:pe,removeFmStation:xe,pickFmSource:se}=d;return a.jsxs("div",{className:"action-run action-run-utility",children:[e.claude&&p!==null&&a.jsxs("div",{className:"sound-slot",children:[a.jsxs("button",{ref:X,className:"btn icon-btn",onClick:()=>q(ve=>!ve),...Ir(!1),title:Ate(e,{on:p===!0,locked:o==="locked",prefs:v}),"aria-label":`Sound settings, ${p?"on":"off"}`,"aria-haspopup":"dialog","aria-expanded":$,"aria-controls":$?"sound-menu":void 0,children:[a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),p?a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M9.8 5.4a2.4 2.4 0 0 1 0 3.2"}),a.jsx("path",{d:"M11.3 3.9a4.6 4.6 0 0 1 0 6.2"})]}):a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M10 5.6l2.6 2.8"}),a.jsx("path",{d:"M12.6 5.6L10 8.4"})]})]}),a.jsx("span",{className:"tb-word",children:"Sound"})]}),$&&a.jsx(wne,{onClose:()=>q(!1),soundOn:p===!0,onToggleSound:g,prefs:v,onLevel:(ve,fe)=>b(ve,{level:fe}),onFigure:(ve,fe)=>b(ve,{figure:fe}),onPreview:ve=>k(ve),customAssets:N,customSelections:x,onBuiltInSelected:S,onCustomSelected:_,onImportCustom:E,onCreateVoice:T,onRenameCustom:A,onPreviewCustom:B,onDeleteCustom:R,notifyOn:D,onToggleNotify:L,notifyVetoed:O,notifyPermission:z?P:"unsupported",onAskNotify:M,openerRef:X})]}),a.jsxs("div",{className:"appearance-slot",children:[a.jsx("button",{ref:W,className:"btn icon-btn",onClick:()=>{q(!1),I(ve=>!ve)},title:"Appearance settings","aria-label":`Appearance settings, ${F} theme, character ${J?"shown":"hidden"}`,"aria-haspopup":"dialog","aria-expanded":H,"aria-controls":H?"appearance-menu":void 0,children:F==="dark"?a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("circle",{cx:"7",cy:"7",r:"2.5"}),a.jsx("path",{d:"M7 1.5v1.2M7 11.3v1.2M1.5 7h1.2M11.3 7h1.2M3.1 3.1l.85.85M10.05 10.05l.85.85M3.1 10.9l.85-.85M10.05 3.95l.85-.85"})]}):a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M11.8 8.4A5 5 0 1 1 5.6 2.2a4 4 0 0 0 6.2 6.2Z"})})}),H&&a.jsx(nne,{theme:F,onTheme:Y,characterEnabled:J,onToggleCharacter:()=>V(ve=>!ve),fmVolume:G,onFmVolume:K,fmMuted:Z,onFmMuted:()=>ee(ve=>!ve),fmSource:re,onFmSource:se,customFmStations:ue,unavailableFmStations:me,onAddFmStation:ae,onRenameFmStation:pe,onRemoveFmStation:xe,reportsOn:h.reportsOn!==!1&&!h.reportsVetoed,reportsVetoed:h.reportsVetoed,onToggleReports:()=>{h.answerReports(h.reportsOn===!1)},onFeedback:()=>{I(!1),f()},onClose:()=>I(!1)})]}),a.jsxs("button",{className:"btn icon-btn",onClick:f,title:"Send feedback — a problem, an idea or anything else, to the people who make ccdeck","aria-label":"Send feedback","aria-haspopup":"dialog",children:[a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M2.2 3.3h9.6v5.3H6.1L3.5 10.8V8.6H2.2Z"}),a.jsx("path",{d:"M7 4.9v1.7"}),a.jsx("path",{d:"M7 7.7v.05"})]}),a.jsx("span",{className:"tb-word-wide",children:"Feedback"})]})]})}const kne=5*6e4,Nne=6e4;function jne({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>=kne}function uR(e=new Date){return i$("month",e)}function Sne(e){const t=Ud(e);return{cost:t.cost,tokens:t.tokens}}function dR(e){return e>0?qe(e):"$0.00"}const _ne=new Set(["idle","checking","current","downloading","ready","error"]);function hR(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.status!="string"||!_ne.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 Ene(e){return(e==null?void 0:e.status)==="ready"&&e.version?{version:e.version}:null}function Cne(e=typeof navigator>"u"?"":navigator.userAgent){var t;return((t=/\bccdeck-desktop\/(\d[^\s]*)/.exec(e))==null?void 0:t[1])??null}const jd="Restart to update",KO=3e4;function Tne(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 Ane(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 ${jd} comes first`}}function Rne(e){const t=e==null?void 0:e.reason;return t==="app_disconnected"||t==="update_not_ready"?t:"refused"}function Mne(e,t,n=typeof navigator>"u"?"":navigator.userAgent){const r=Tne(n),s=`Use ${jd} 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, ${jd} is in ${r}.`;case"timeout":return`ccdeck has not restarted after ${KO/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 $ne="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",Wv="click for what's new";function Ine(e){if(e.checkDisabled)return`${$ne} · ${Wv}`;if(e.checking)return`Asking npm for the newest release… · ${Wv}`;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 · ${Wv}, and to check npm now`}function One(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 Lne(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 YO(e){return e?`${e.kind}:${e.to}`:""}function Pne(e,t){return e!=null&&t!==YO(e)}function Dne({readyAppUpdate:e,notice:t,noticeOpen:n,version:r,chipVersion:s,versionChecking:o,now:l,openReleaseNotes:u,showNotice:d,loadVersion:h}){return a.jsx(a.Fragment,{children:e?(()=>{const f=Ane(Cne()??s,e.version);return a.jsxs("button",{type:"button",className:"v ready",onClick:u,"aria-haspopup":"dialog","aria-label":f.label,title:f.title,children:[f.text,a.jsx("span",{className:"v-dot","aria-hidden":!0})]})})():t?a.jsxs("button",{type:"button",className:"v stale",onClick:()=>{u(),d()},"aria-haspopup":"dialog","aria-label":Lne({...t,open:n}),title:t.kind==="restart"?`Running v${t.from}; v${t.to} is installed on disk. Restart to pick it up · click for what's new`:`Running v${t.from}; v${t.to} is on npm · click for what's new`,children:["v",t.from,a.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const f={running:s,latest:r==null?void 0:r.latest,latestPending:r==null?void 0:r.latestPending,checkedAgo:r!=null&&r.checkedAt?id(l-r.checkedAt):null,checkFailedAgo:r!=null&&r.checkFailedAt&&r.checkFailedAt>(r.checkedAt??0)?id(l-r.checkFailedAt):null,checkDisabled:r==null?void 0:r.checkDisabled,checking:o};return a.jsxs("button",{type:"button",className:o?"v checking":"v",onClick:()=>{u(),h(!0)},"aria-busy":o||void 0,"aria-haspopup":"dialog","aria-label":One(f),title:Ine(f),children:["v",f.running]})})()})}function Fne({live:e,paused:t,pauseGate:n,monthUsageRef:r,monthlyUsage:s,monthlyUsageUnavailable:o}){return a.jsxs("span",{className:"status",children:[(()=>{const l=xU({connected:e,paused:t,held:n.size,dropped:n.dropped});return l.resting?null:a.jsx("span",{className:`pill ${l.tone}`,title:l.title,children:a.jsxs("span",{className:"pill-box",children:[a.jsx("span",{className:"pill-widest","aria-hidden":!0,children:l.widest}),a.jsx("span",{className:"pill-label",children:l.label})]})})})(),a.jsxs("span",{ref:r,className:"month-usage",title:s?`${s.tokens.toLocaleString()} tokens · ${dR(s.cost)} spent since the 1st of this local calendar month`:o?"Monthly usage is unavailable — ccusage could not be read":"Loading usage since the 1st of this local calendar month",children:[a.jsx("span",{className:"month-usage-label",children:"this month"}),s?a.jsxs(a.Fragment,{children:[a.jsx("b",{children:ot(s.tokens)}),a.jsx("span",{className:"month-usage-unit",children:"tokens"}),a.jsx("span",{className:"month-usage-sep","aria-hidden":!0,children:"·"}),a.jsx("b",{children:dR(s.cost)})]}):a.jsx("span",{className:"month-usage-pending",children:o?"unavailable":"…"})]})]})}function Bne({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:r}){return a.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>{t.current=e[0].id,n(e[0].id)},title:`Blocked waiting for you — click, or press W, to go to the one that has been stuck longest:
95
+ ${e.map(s=>` ${s.label}: ${ii(s.waiting)} (${id(r-s.waiting.since)})`).join(`
96
+ `)}`,"aria-label":`${e.length} session${e.length===1?"":"s"} waiting for you`,children:[a.jsx("span",{className:"ap-pulse","aria-hidden":!0}),a.jsx("b",{children:e.length})," ",a.jsx("span",{className:"ws-word",children:"waiting"})]})}const Qx={on:"The deck will raise a system notification when a session blocks on you and this tab is in the background",blocked:"Notifications are blocked for this page. Only your browser can undo that — its site settings for this address"};function qne(e){return e==="on"?`Notifications on. ${Qx.on}.`:e==="blocked"?`${Qx.blocked}.`:""}function Une({notifySaid:e}){return a.jsx("span",{className:e==="on"?"notify-said":"notify-said notify-said-blocked","aria-hidden":!0,title:Qx[e],children:e==="on"?"notifications on":"notifications blocked"})}function zne({versionCheck:e,welcome:t,desktopUpdate:n,pause:r,monthly:s,announcements:o,notify:l,waitingSessions:u,waitingCursorRef:d,focusSession:h,live:f,now:p,incidents:g}){const{version:v,notice:k,noticeOpen:b,showNotice:x,versionChecking:N,loadVersion:S}=e,{chipVersion:_,openReleaseNotes:E}=t,{readyAppUpdate:T}=n,{paused:A,pauseGate:R}=r,{monthlyUsage:B,monthlyUsageUnavailable:P,monthUsageRef:D}=s,{blockedSaid:O,watchSaid:L,incidentSaid:z}=o,{notifySaid:M}=l;return a.jsxs("div",{className:"readout",children:[a.jsxs("div",{className:"brand",children:[a.jsx("img",{className:"logo logo-on-dark",src:LW,width:19,height:16,alt:""}),a.jsx("img",{className:"logo logo-on-light",src:PW,width:19,height:16,alt:""}),a.jsx("h1",{children:bt}),a.jsx(Dne,{readyAppUpdate:T,notice:k,noticeOpen:b,version:v,chipVersion:_,versionChecking:N,now:p,openReleaseNotes:E,showNotice:x,loadVersion:S})]}),a.jsx(Fne,{live:f,paused:A,pauseGate:R,monthUsageRef:D,monthlyUsage:B,monthlyUsageUnavailable:P}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:O}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:L}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:z}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:qne(M)}),a.jsx(DW,{incidents:g}),u.length>0&&a.jsx(Bne,{waitingSessions:u,waitingCursorRef:d,focusSession:h,now:p}),M&&a.jsx(Une,{notifySaid:M})]})}function Wne({selected:e,now:t,selectedIds:n,focusAgent:r,clearSelection:s}){const o=hn(e),l=Math.max(0,((e.endedAt??t)-e.startedAt)/1e3),u=e.state==="active"?Rb(o.total,l):null,d=n.size-1;return a.jsxs("button",{type:"button",className:"selected-ribbon",title:`Zoom to ${e.label} and its session (Z)${o.total>0?`
97
+ ${qe(o.total)} spent${u?` · ${u}`:""}`:""}`,onClick:()=>{try{r(e.id)}catch{}},children:[a.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),a.jsx("span",{className:"selected-label",children:e.label}),o.total>0&&a.jsxs("span",{className:"selected-cost",children:[qe(o.total),u?a.jsxs("span",{className:"selected-rate",children:[" · ",u]}):null]}),d>0&&a.jsxs("span",{className:"selected-extra",children:["+",d]}),a.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:h=>{h.stopPropagation(),s()},children:"×"})]})}function Hne({catBarRef:e,catBarOccluded:t,presentCats:n,hiddenCats:r,toggleCat:s}){return a.jsx("div",{ref:e,className:`cat-filter-bar${t?" occluded":""}`,role:"group","aria-label":"Filter tools by category",children:n.map(o=>{const l=r.has(o);return a.jsxs("button",{type:"button",className:`cat-filter${l?" off":""}`,onClick:()=>s(o),"aria-pressed":!l,title:`${l?"Show":"Hide"} ${Nd[o]} tools`,children:[a.jsx(Bte,{cat:o}),a.jsx("span",{className:"cat-name",children:Nd[o]})]},o)})})}const Vne=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(",");function Gne(e){var n,r;const t=e.target;!(t!=null&&t.closest)||t.closest(Vne)!==e.currentTarget||(e.preventDefault(),(r=(n=document.activeElement)==null?void 0:n.blur)==null||r.call(n))}function Kne({trashZoneRef:e,trashState:t,trashPhase:n,trashLabel:r}){return a.jsxs("div",{ref:e,className:`drag-trash-zone ${t}${n==="leaving"?" leaving":""}`,role:"status",children:[a.jsx("svg",{className:"drag-trash-icon",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{d:"M8 7V5.8C8 4.8 8.8 4 9.8 4h4.4c1 0 1.8.8 1.8 1.8V7m-10 0h12M8 10v8m4-8v8m4-8v8M7 7l.7 13h8.6L17 7"})}),a.jsxs("span",{className:"drag-trash-copy",children:[a.jsx("span",{className:"drag-trash-text",children:t==="over"?a.jsxs(a.Fragment,{children:["Release to remove ",a.jsx("strong",{className:"drag-trash-name",children:r||"this card"})]}):"Drop here to remove from the board"}),a.jsx("span",{className:"drag-trash-hint",children:t==="over"?"The session list (L) brings it back":"The session keeps running"})]})]})}function Yne({canvasRef:e,bubbling:t,dragging:n,trash:r,zoom:s,viewport:o,stateRef:l,peek:u,children:d}){const{trashDragging:h,trashState:f,trashPhase:p,trashZoneRef:g,trashLabel:v}=r,{lod:k,lodRef:b}=s,{markCanvasInput:x}=o,{peekAgent:N,peekLabel:S,peekRecap:_,peekBounds:E}=u;return a.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${t?" bubbling":""}${n?" dragging-any":""}${h&&f==="over"?" trash-hover":""}`,"data-lod":k,ref:e,onMouseDownCapture:Gne,onPointerDownCapture:x,onPointerUpCapture:x,onWheelCapture:x,onFocusCapture:T=>{const A=T.target;if(!j0(A)||b.current==null||b.current==="detail")return;const R=A.getAttribute("data-id");R&&l.current.agents.has(R)&&A.matches(":focus-visible")&&OO(R,A,"focus")},onBlurCapture:T=>{var R,B;const A=(B=(R=T.target).getAttribute)==null?void 0:B.call(R,"data-id");A&&ea(A)},children:[d,Du(p)&&a.jsx(Kne,{trashZoneRef:g,trashState:f,trashPhase:p,trashLabel:v}),a.jsx(xee,{agentFor:N,recapFor:_,labelFor:S,bounds:E})]})}function Xne({restarting:e,restartMode:t,live:n,paused:r}){return a.jsxs("div",{className:"conn-banner",role:"alert",children:[a.jsx("span",{className:"conn-dot"}),e?t==="npx"?"Fetching the new version with npx — this can take a minute…":`Restarting ${bt}…`:(()=>{const s=wU({connected:n,paused:r});return a.jsxs(a.Fragment,{children:[`Lost connection to the ${bt} server. Reconnecting…`,s&&a.jsx("span",{className:"conn-sub",children:s})]})})()]})}function Zne({oldName:e,version:t,dismissOldName:n}){return a.jsxs("div",{className:"ver-banner",role:"status",children:[a.jsx("span",{className:"ver-dot"}),a.jsxs("strong",{children:[e," still works — the deck is called ",bt," now."]}),t!=null&&t.renameFix?a.jsx("span",{className:"ver-sub",children:t.renameFix}):null,a.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}const Jne=3e4;function Qne({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function ere({bundle:e,running:t,pending:n,lastTried:r}){return t?Qne({bundle:e,running:t,lastTried:r})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function tre(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function nre({asked:e,reported:t}){return t?t!==e:!1}function XO(e){const t=e.thresholdMs??Jne;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 rre(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 sre(e,t){return e?t==null?"auto when idle":`auto in ${rre(t)}`:"auto-restart off"}function fR(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function are(e,t=!1){return e<=0&&t?{label:"Restart anyway",clause:"the canvas is paused — running agents cannot be seen"}:e<=0?{label:"Restart now",clause:"nothing is running"}:{label:"Restart anyway",clause:`${e===1?"1 agent is running":`${e} agents are running`} — their events during the restart are lost`}}function ore(e){const t=XO(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 pR={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 ire({notice:e,version:t,dismissNotice:n,upgradeState:r,startUpgrade:s,copyCommand:o,cmdCopied:l,autoRestart:u,toggleAutoRestart:d,askRestart:h,restartCopy:f,restartFuseMs:p,restarting:g}){var v,k,b;return a.jsxs("div",{className:`ver-banner ${e.kind}`,role:"status",children:[a.jsx("span",{className:`ver-dot${p==null?"":" armed"}`}),e.kind==="restart"?a.jsxs(a.Fragment,{children:[a.jsxs("strong",{children:["v",e.to," is installed — this deck still runs v",e.from,"."]}),t!=null&&t.canRestart?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:"ver-act",onClick:()=>h(),...Ir(g),title:`Stop this process and bring it back on the same port. The canvas replays from the event log.
98
+
99
+ Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.`,children:g?"restarting…":f.label}),!g&&a.jsx("span",{className:"ver-sub",children:f.clause}),a.jsxs("label",{className:"ver-auto",children:[a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":u,onClick:d,"aria-label":"Auto-restart when idle",title:u?"Updates on its own. While you are here it restarts once nothing has been running for 30 seconds; while you are away it also installs the new version first. Click to require a click instead.":"Only updates when you click. Click to let it update itself when idle or while you are away.",children:a.jsx("span",{className:"switch-knob"})}),a.jsx("span",{"aria-hidden":!0,children:sre(u,p)})]})]}):a.jsx("span",{className:"ver-sub",title:"Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.",children:"Restart it to pick up the new code."})]}):a.jsxs(a.Fragment,{children:[a.jsxs("strong",{children:[bt," v",e.to," is out — you are on v",e.from,"."]}),(t==null?void 0:t.upgradeMode)==="install"&&r!=="failed"&&a.jsx("button",{type:"button",className:"ver-act",onClick:s,...Ir(r==="running",r==="done"),title:`Runs ${((v=t==null?void 0:t.upgrade)==null?void 0:v.command)??(t==null?void 0:t.command)??"npm i -g"} here, then restarts once nothing is running.`,children:r==="running"?"installing…":r==="done"?"installed":"Update now"}),(t==null?void 0:t.upgradeMode)==="npx"&&(t==null?void 0:t.canRestart)&&a.jsx("button",{type:"button",className:"ver-act",onClick:()=>h({upgrade:!0}),...Ir(g),title:`Runs ${t==null?void 0:t.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`,children:g?"fetching…":r==="failed"?"Retry update":"Update & restart"}),r==="failed"?a.jsxs("span",{className:"ver-sub fail",title:((k=t==null?void 0:t.upgrade)==null?void 0:k.error)??"",children:[(t==null?void 0:t.upgradeMode)==="npx"?"update failed":"install failed",": ",((b=t==null?void 0:t.upgrade)==null?void 0:b.error)??"unknown error"," — run it yourself:"]}):(t==null?void 0:t.upgradeMode)==="npx"?a.jsx("span",{className:"ver-sub",children:t!=null&&t.canRestart?"npx cannot upgrade in place, so the deck re-runs:":pR.npx}):t!=null&&t.upgradeBlocked?a.jsx("span",{className:"ver-sub",children:Ot(pR,t.upgradeBlocked)??"cannot install from here"}):null,a.jsxs("button",{type:"button",className:"ver-cmd",onClick:o,title:"Copy to clipboard",children:[a.jsx("code",{children:t==null?void 0:t.command}),a.jsx("span",{className:"ver-cmd-hint",children:l?"copied":"copy"})]})]}),a.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}function lre({restart:e,versionCheck:t,upgrade:n,oldNameNotice:r,everConnected:s,live:o,paused:l}){const{autoRestart:u,toggleAutoRestart:d,restarting:h,restartMode:f,restartedTo:p,askRestart:g,restartCopy:v,restartFuseMs:k}=e,{version:b,notice:x,noticeOpen:N,dismissNotice:S}=t,{upgradeState:_,startUpgrade:E,copyCommand:T,cmdCopied:A}=n,{oldName:R,oldNameOpen:B,dismissOldName:P}=r;return p?a.jsxs("div",{className:"ver-banner done",role:"status",children:[a.jsx("span",{className:"ver-dot"}),a.jsxs("strong",{children:["Restarted — now running v",p,"."]}),a.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):s&&!o?a.jsx(Xne,{restarting:h,restartMode:f,live:o,paused:l}):N&&x?a.jsx(ire,{notice:x,version:b,dismissNotice:S,upgradeState:_,startUpgrade:E,copyCommand:T,cmdCopied:A,autoRestart:u,toggleAutoRestart:d,askRestart:g,restartCopy:v,restartFuseMs:k,restarting:h}):B&&R?a.jsx(Zne,{oldName:R,version:b,dismissOldName:P}):null}function cre(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function ure(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 dre(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function hre(e,t){const n=dre(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 fre({agentCount:e,onConfirm:t,onCancel:n}){const r=w.useRef(null),s=ft(n,{focusRef:r,layer:Kq}),[o,l]=w.useState(null);w.useEffect(()=>{let p=!1;return fetch("/api/clear").then(g=>g.ok?g.json():null).then(g=>{p||l(ure(g))}).catch(()=>{}),()=>{p=!0}},[]);const{goes:u,stays:d,final:h,confirm:f}=hre(e,o);return a.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal clear-confirm",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:"status-dot err","aria-hidden":!0}),a.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("dl",{className:"cc-plan",children:[a.jsx("dt",{children:"Goes"}),a.jsx("dd",{children:u.map(p=>a.jsx("span",{children:p},p))}),a.jsx("dt",{children:"Stays"}),a.jsx("dd",{children:d.length>0?d.map(p=>a.jsx("span",{children:p},p)):a.jsx("span",{children:"nothing"})})]}),h&&a.jsx("p",{className:"cc-final",children:h}),a.jsxs("div",{className:"cc-actions",children:[a.jsx("button",{type:"button",ref:r,className:"btn",onClick:n,children:"Cancel"}),a.jsx("button",{type:"button",className:"btn danger",onClick:t,children:f})]})]})]})})}const eb=[{value:"bug",label:"Bug",question:"What happened?",placeholder:`I was trying to…
100
+ What did you expect to happen?`},{value:"idea",label:"Idea",question:"What would make ccdeck better?",placeholder:"It would be useful if…"},{value:"other",label:"Other",question:"What would you like to tell us?",placeholder:"Write anything…"}];function ZO(e){return eb.find(t=>t.value===e)??eb[0]}const tb=3,Hv=120,pre=1e4,mre=200,gre="Write something first.";function mR(e){return e.trim()!==""}function yre(e){var o;const t=e.trim();if(t==="")return"";const n=gR(t.split(/\r?\n/,1)[0]),r=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,s=Vv(r).length>=tb?Vv(r):Vv(n);return vre(s.length>=tb?s:gR(t))}function wre(e,t){const n=yre(t);return n.length>=tb?n:`${ZO(e).label}: ${n}`}function gR(e){return e.replace(/\s+/g," ").trim()}function Vv(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function vre(e){if(e.length<=Hv)return e;const t=e.slice(0,Hv-1),n=t.lastIndexOf(" ");return`${(n>=Hv/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function xre({kind:e,body:t,contact:n}){const r={kind:e,title:wre(e,t),body:t.trim()};return n.trim()!==""&&(r.contact=n.trim()),r}function bre(e){const t=e;return(t==null?void 0:t.ok)!==!0||typeof t.appVersion!="string"||typeof t.platform!="string"||t.appVersion===""||t.platform===""?null:{appVersion:t.appVersion,platform:t.platform}}const kre={darwin:"macOS",win32:"Windows",linux:"Linux"};function Nre(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),r=t===-1?"":e.slice(t+1),s=kre[n]??n;return r?`${s} · ${r}`:s}function jre(e){return e?`ccdeck ${e.appVersion} · ${Nre(e.platform)}`:null}const Sre="sent with it",_re="Your ccdeck version and system are sent with it.",Ere="Add details",Cre="How to reach you",Tre="Email or GitHub @name",Are="Only if you would like an answer.",Rre=["It all goes to the people who make ccdeck, with the version and system below.","Nothing becomes public by being sent. They may open a public GitHub issue from it, choosing its title and text; your contact and screenshots are never put on one."];function Mre(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function $re(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function Ire(e){return/mac|iphone|ipad/i.test(e)?["⌘","Enter"]:["Ctrl","Enter"]}function Ore(e){return[...e].length===1}const JO="Thanks — feedback sent.";function yR(e,t,n){if(t==="vetoed")return"This deck was started with AGENTS_DECK_NO_INSTALL=1, which keeps it off the network, so nothing was sent.";if(e===429||t==="too_many")return"Too much feedback from this network in the last hour. Try again later; your text is still here.";if(e===413||t==="too_large")return"The images are too large to send together. Remove one and send again; your text is still here.";const r=n==null?void 0:n.images;return e===400&&Array.isArray(r)&&typeof r[0]=="string"?`The server did not accept an image. ${r[0]} Remove it and send again; your text is still here.`:e===400?"The server did not accept the message. It is still here; check it and send again.":"ccdeck's server could not be reached. Nothing was sent; your text is still here, so try again in a moment."}function Lre(e){return e==="sending"?"Sending…":e==="sent"?JO:""}const wR=1400,Pre=160;function Dre({kind:e,onChange:t}){return a.jsxs("fieldset",{className:"fb-kinds",children:[a.jsx("legend",{className:"vis-hidden",children:"Kind of feedback"}),eb.map(n=>a.jsxs("label",{className:"fb-kind",children:[a.jsx("input",{type:"radio",name:"feedback-kind",value:n.value,checked:e===n.value,onChange:()=>t(n.value)}),n.label]},n.value))]})}const QO="fb-details";function Fre({open:e,onToggle:t}){return a.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":QO,onClick:t,children:[Ere,a.jsx("svg",{className:"fb-chev",width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 3.75 5 6.25l2.5-2.5"})})]})}function Bre({open:e,contact:t,onContact:n}){const r=w.useId();return a.jsx("div",{id:QO,className:"fb-details","data-open":e||void 0,children:a.jsx("div",{className:"fb-details-clip",children:a.jsxs("div",{className:"fb-details-body",children:[a.jsxs("div",{className:"fb-field",children:[a.jsxs("label",{className:"fb-field-label",htmlFor:"fb-contact",children:[Cre,a.jsx("span",{className:"fb-optional",children:"optional"})]}),a.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:mre,autoComplete:"email",placeholder:Tre,"aria-describedby":r,onChange:s=>n(s.target.value),onKeyDown:s=>{$re(s.nativeEvent)&&s.preventDefault()}}),a.jsx("p",{id:r,className:"fb-hint",children:Are})]}),a.jsx("div",{className:"fb-where",children:Rre.map(s=>a.jsx("p",{children:s},s))})]})})})}const Go=3,qre=5*1024*1024,Ure=12*1024*1024,nb=8192,zre=64*1024,Wre=256*1024,Hre=.92,Vre=640,eL=.9,Gre=.85,Kre=6,Yre=512*1024,Sd={png:"image/png",jpeg:"image/jpeg"},Xre={png:"png",jpeg:"jpg"},Zre=[137,80,78,71,13,10,26,10],Jre=[255,216,255];function tL(e){const t=n=>e.length>=n.length&&n.every((r,s)=>e[s]===r);return t(Zre)?"png":t(Jre)?"jpeg":null}function Qre(e){const t=tL(e);return t==="png"?ese(e):t==="jpeg"?nse(e):null}function ese(e){const t=[73,72,68,82];if(e.length<24||!t.every((r,s)=>e[12+s]===r))return null;const n=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:n.getUint32(16),height:n.getUint32(20)}}function tse(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function nse(e){let t=2;for(;t<e.length;){if(e[t]!==255)return null;for(;t<e.length&&e[t]===255;)t++;const n=e[t++];if(n===void 0||n===217||n===218)return null;if(n===1||n>=208&&n<=215)continue;if(t+2>e.length)return null;const r=e[t]<<8|e[t+1];if(r<2)return null;if(tse(n))return t+7>e.length?null:{height:e[t+3]<<8|e[t+4],width:e[t+5]<<8|e[t+6]};t+=r}return null}function vR(e,t){return e.bytes>t||e.width>nb||e.height>nb}function rse(e){return Math.min(qre,Ure-zre-e)}function nL(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function sse(e,t){const n=nb/Math.max(e.width,e.height),r=e.bytes>t?Math.sqrt(t/e.bytes)*eL:1;return nL(e,Math.min(1,n,r))}async function ase(e,t,n){let r=sse(e,t),s=e.format;for(let o=0;o<Kre;o++){const l=await n(r,s,s==="jpeg"?Hre:void 0);if(!l)return null;if(l.size<=t)return{...r,blob:l,format:s};if(s==="png"){s="jpeg";continue}if(r=nL(r,Math.min(Gre,Math.sqrt(t/l.size)*eL)),Math.max(r.width,r.height)<Vre)return null}return null}async function ose(e,t,n){const r=new Uint8Array(await e.slice(0,Yre).arrayBuffer()),s=tL(r);if(!s)return{ok:!1,problem:"type"};if(t<Wre)return{ok:!1,problem:"no_room"};const o=e.type===Sd[s]?e:new Blob([e],{type:Sd[s]}),l=Qre(r);if(l&&!vR({...l,bytes:e.size},t))return{ok:!0,blob:o,resized:null};const u=await n(e).catch(()=>null);if(!u)return{ok:!1,problem:"unreadable"};try{const d={width:u.width,height:u.height,bytes:e.size,format:s};if(!vR(d,t))return{ok:!0,blob:o,resized:null};const h=await ase(d,t,u.encoder);return h?{ok:!0,blob:h.blob,resized:{width:h.width,height:h.height}}:{ok:!1,problem:"too_large"}}finally{u.release()}}function ise(e){return({width:t,height:n},r,s)=>new Promise(o=>{const l=document.createElement("canvas");l.width=t,l.height=n;const u=l.getContext("2d");if(!u)return o(null);r==="jpeg"&&(u.fillStyle="white",u.fillRect(0,0,t,n)),u.imageSmoothingQuality="high",u.drawImage(e,0,0,t,n),l.toBlob(d=>{l.width=0,l.height=0,o(d)},Sd[r],s)})}const lse=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:ise(t),release:()=>t.close()}};function cse(e){return e.includes("Files")}function use({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function dse(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function hse(e,t){if(t.length===0)return{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)};const n=new FormData;return n.append("kind",e.kind),n.append("title",e.title),n.append("body",e.body),e.contact!==void 0&&n.append("contact",e.contact),t.forEach((r,s)=>{const o=r.type===Sd.jpeg?"jpeg":"png";n.append("images",r,`image-${s+1}.${Xre[o]}`)}),{method:"POST",body:n}}const fse="Add screenshot",xR="PNG or JPEG, up to three. You can also paste one, or drop it on this dialog.",pse="A screenshot can show emails, costs and paths. Crop out what should not be seen.",bR="Three images at most. Remove one to add another.";function mse(e,t,n){const r=n?`, resized to ${n.width} × ${n.height} to fit`:"";return`Replace image ${e+1}: ${t}${r}`}function gse(e,t){const n=`${e} of ${Go}`;return t>0?`${n} · ${t} resized to fit`:n}function yse(e){return`Three images at most, so ${e===1?"one was":`${e} were`} left out.`}function wse(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function vse(e,t){const n=wse(t);return e==="type"?`${n} is not a PNG or a JPEG, so it was not added. GIF, WebP and HEIC are not converted; save it as a PNG or a JPEG first.`:e==="no_room"?`There is no room left for ${n}: images go at up to 12 MB in all. Remove one to add it.`:e==="unreadable"?`${n} could not be read as an image.`:`${n} could not be made small enough to send: images go at up to 5 MB each.`}const rL="image/png,image/jpeg";function sL({className:e="fb-glyph"}){return a.jsxs("svg",{className:e,width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:[a.jsx("rect",{x:"1.8",y:"2.4",width:"10.4",height:"9.2",rx:"1.6"}),a.jsx("circle",{cx:"5",cy:"5.6",r:"1"}),a.jsx("path",{d:"M2.4 10.4 5.5 7.6l2.1 1.8 1.5-1.3 2.5 2.2"})]})}function xse({images:e,buttonRef:t}){const n=w.useRef(null),r=e.shots.length>=Go;return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:t,type:"button",className:"fb-tool",title:xR,"aria-describedby":"fb-attach-hint",onClick:()=>{var s;return r?e.sayFull():(s=n.current)==null?void 0:s.click()},children:[a.jsx(sL,{}),fse]}),a.jsx("span",{id:"fb-attach-hint",hidden:!0,children:xR}),a.jsx("input",{ref:n,type:"file",accept:rL,multiple:!0,hidden:!0,onChange:s=>{e.add(Array.from(s.target.files??[])),s.target.value=""}})]})}function bse({images:e,addRef:t}){const n=w.useRef(new Map),r=w.useRef(null),s=w.useRef(null),o=w.useRef(null),[l,u]=w.useState(null),{shots:d}=e,h=gse(d.length,d.filter(g=>g.resized).length);w.useLayoutEffect(()=>{var g;l!==null&&((g=l==="add"?t.current:n.current.get(l))==null||g.focus(),u(null))},[l,t]),w.useEffect(()=>{var g;e.problem&&((g=r.current)==null||g.scrollIntoView({block:"nearest"}))},[e.problem]);function f(g){u(dse(d.map(v=>v.id),g)??"add"),e.remove(g)}function p(g){var v;o.current=g,(v=s.current)==null||v.click()}return a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"vis-hidden",role:"status",children:e.announcement}),a.jsx("input",{ref:s,type:"file",accept:rL,hidden:!0,onChange:g=>{const v=o.current;v!==null&&e.replace(v,Array.from(g.target.files??[])),o.current=null,g.target.value=""}}),d.length>0&&a.jsxs("div",{className:"fb-shots",children:[a.jsxs("div",{className:"fb-shots-row",children:[a.jsx("ul",{className:"fb-shots-list",children:d.map((g,v)=>a.jsxs("li",{className:"fb-shot","data-fitting":g.blob?void 0:!0,children:[a.jsxs("button",{type:"button",className:"fb-shot-pick","aria-label":mse(v,g.name,g.resized),onClick:()=>p(g.id),children:[a.jsx("img",{className:"fb-shot-img",src:g.url,alt:""}),g.blob?a.jsx("span",{className:"fb-shot-cue","aria-hidden":"true",children:"Replace"}):a.jsx("span",{className:"fb-shot-busy","aria-hidden":"true",children:"Resizing…"})]}),a.jsx("button",{ref:k=>{k?n.current.set(g.id,k):n.current.delete(g.id)},type:"button",className:"glyph-btn fb-shot-remove","aria-label":`Remove image ${v+1}`,title:`Remove image ${v+1}`,onClick:()=>f(g.id),children:a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 2.5 7.5 7.5M7.5 2.5 2.5 7.5"})})})]},g.id))}),a.jsx("span",{className:"fb-shots-count",children:h})]}),a.jsx("p",{className:"fb-hint",children:pse})]}),e.problem&&a.jsx("p",{ref:r,className:"fb-error",role:"alert",children:e.problem})]})}function kse(e,t,n){return n?e.map(r=>r.id===t.id?t:r):[...e,t]}function Nse(e,t,n){return n?e.map(r=>r.id===t?n:r):e.filter(r=>r.id!==t)}function jse(){const[e,t]=w.useState([]),[n,r]=w.useState(""),[s,o]=w.useState(""),l=w.useRef([]),u=w.useRef(null),d=w.useRef(1),h=w.useRef(!0),f=w.useCallback(E=>{l.current=E(l.current),t(l.current)},[]);w.useEffect(()=>(h.current=!0,()=>{h.current=!1;for(const E of l.current)URL.revokeObjectURL(E.url)}),[]);const p=w.useCallback(async(E,T)=>{const A=l.current.reduce((M,$)=>{var q;return M+($.id===(T==null?void 0:T.id)?0:((q=$.blob)==null?void 0:q.size)??0)},0),R=(T==null?void 0:T.id)??d.current++,B=URL.createObjectURL(E),P={id:R,name:E.name||"image",url:B,blob:null,resized:null};let D=!1;const O=()=>{D||(D=!0,f(M=>kse(M,P,T!==void 0)))},L=await ose(E,rse(A),async M=>(O(),lse(M))).catch(()=>({ok:!1,problem:"unreadable"})),z=l.current.some(M=>M.id===R);return!h.current||!z&&(D||T)?(URL.revokeObjectURL(B),T&&URL.revokeObjectURL(T.url),""):L.ok?(O(),T&&URL.revokeObjectURL(T.url),f(M=>M.map($=>$.id===R?{...$,blob:L.blob,resized:L.resized}:$)),""):(URL.revokeObjectURL(B),D&&f(M=>Nse(M,R,T)),vse(L.problem,E.name||"image"))},[f]),g=w.useCallback(async E=>{r("");const T=[];let A=0,R=0;for(const P of E){if(!h.current)return;if(l.current.length>=Go){A++;continue}const D=l.current.length,O=await p(P);O&&T.push(O),l.current.length>D&&R++}if(!h.current)return;A>0&&T.push(R===0&&T.length===0?bR:yse(A)),r(T.join(" "));const B=l.current.length;R>0&&o(`${R===1?"Image":`${R} images`} added, ${B} of ${Go}.`)},[p]),v=w.useCallback(async(E,T)=>{r("");const A=l.current.find(P=>P.id===E);if(!A)return g([T]);const R=await p(T,A);if(!h.current)return;r(R);const B=l.current.findIndex(P=>P.id===E);!R&&B!==-1&&o(`Image ${B+1} replaced, ${l.current.length} of ${Go}.`)},[g,p]),k=w.useCallback(E=>{u.current=(u.current??Promise.resolve()).then(E).catch(()=>{})},[]),b=w.useCallback(E=>{E.length>0&&k(()=>g(E))},[g,k]),x=w.useCallback((E,T)=>{const A=T[0];A&&k(()=>v(E,A))},[k,v]),N=w.useCallback(E=>{const T=l.current.find(A=>A.id===E);T&&(URL.revokeObjectURL(T.url),f(A=>A.filter(R=>R.id!==E)),r(""),o(`Image removed, ${l.current.length} of ${Go}.`))},[f]),S=w.useCallback(()=>r(bR),[]),_=w.useCallback(async()=>(await u.current,l.current.flatMap(E=>E.blob?[E.blob]:[])),[]);return{shots:e,problem:n,announcement:s,add:b,replace:x,remove:N,sayFull:S,ready:_}}function Sse(){const[e,t]=w.useState(null);return w.useEffect(()=>{let n=!0;return fetch("/api/feedback").then(r=>r.ok?r.json():null).then(r=>{n&&t(bre(r))}).catch(()=>{}),()=>{n=!1}},[]),e}function _se(e){const[t,n]=w.useState({state:"idle"}),r=w.useRef(!1);async function s(o){if(ir(r.current)){r.current=!0,n({state:"sending"});try{const l=await e.ready(),u=await fetch("/api/feedback",hse(xre(o),l)),d=await u.json().catch(()=>null);n(u.ok&&(d!=null&&d.ok)?{state:"sent"}:{state:"failed",message:yR(u.status,d==null?void 0:d.reason,d==null?void 0:d.errors)})}catch{n({state:"failed",message:yR(0,null)})}finally{r.current=!1}}}return{outcome:t,sending:t.state==="sending",send:s}}function Ese(e,t){const[n,r]=w.useState(!1),s=w.useRef(t);return s.current=t,w.useEffect(()=>{if(!e)return;const o=window.setTimeout(()=>r(!0),wR),l=window.setTimeout(()=>s.current(),wR+Pre);return()=>{window.clearTimeout(o),window.clearTimeout(l)}},[e]),n}function Cse(){var t;return typeof navigator>"u"?"":((t=navigator.userAgentData)==null?void 0:t.platform)||navigator.platform||""}function aL({onClose:e,initialKind:t,initialBody:n}){const r=w.useRef(null),s=w.useRef(null),o=w.useRef(null),l=w.useRef(null),u=w.useRef(0),d=ft(e,{focusRef:r}),[h,f]=w.useState(t??"bug"),[p,g]=w.useState(n??""),[v,k]=w.useState(""),[b,x]=w.useState(!1),[N,S]=w.useState(!1),[_,E]=w.useState(!1),T=jse(),A=jre(Sse()),{outcome:R,sending:B,send:P}=_se(T),D=R.state==="sent",O=Ese(D,e),L=ZO(h),z=N&&!mR(p),[M,$]=Ire(Cse());w.useEffect(()=>{var ee,re;const K=l.current;if(!K)return;const Z=K.contains(document.activeElement)||Pr(((ee=document.activeElement)==null?void 0:ee.tagName)??null);K.inert=D,D&&Z&&((re=s.current)==null||re.focus())},[D]);function q(K){var Z;if(K.preventDefault(),!mR(p)){S(!0),(Z=r.current)==null||Z.focus();return}P({kind:h,body:p,contact:v})}const X=!D,H=K=>cse(Array.from(K.dataTransfer.types));function I(K){!H(K)||!X||(K.preventDefault(),u.current++,E(!0))}function W(K){H(K)&&(K.preventDefault(),K.dataTransfer.dropEffect=X?"copy":"none")}function F(K){H(K)&&(u.current=Math.max(0,u.current-1),u.current===0&&E(!1))}function Y(K){H(K)&&(K.preventDefault(),u.current=0,E(!1),X&&T.add(Array.from(K.dataTransfer.files)))}function J(K){K.target!==K.currentTarget||!H(K)||(K.preventDefault(),K.dataTransfer.dropEffect="none")}function V(K){H(K)&&K.preventDefault()}function G(K){if(!X)return;const Z=Array.from(K.clipboardData.files),ee=K.target,re=ee instanceof HTMLTextAreaElement||ee instanceof HTMLInputElement,ue=Array.from(K.clipboardData.types).includes("text/plain");use({files:Z.length,hasText:ue,intoTextField:re})&&(K.preventDefault(),T.add(Z))}return a.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",onDragOver:J,onDrop:V,"data-leaving":O||void 0,children:a.jsxs("div",{ref:d,className:"modal feedback-dialog",onClick:K=>K.stopPropagation(),onDragEnter:I,onDragOver:W,onDragLeave:F,onDrop:Y,onPaste:G,role:"dialog","aria-modal":"true","aria-labelledby":"feedback-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"feedback-title",className:"modal-tool-name",children:"Send feedback"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:s,type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsx("p",{className:"vis-hidden",role:"status",children:Lre(R.state)}),a.jsxs("div",{className:"fb-stage",children:[a.jsxs("form",{ref:l,className:"fb-form",onSubmit:q,onKeyDown:K=>{Mre(K.nativeEvent)&&(K.preventDefault(),K.currentTarget.requestSubmit())},noValidate:!0,children:[a.jsxs("section",{className:"modal-body fb-body",children:[a.jsx(Dre,{kind:h,onChange:f}),a.jsxs("div",{className:"fb-compose",children:[a.jsx("label",{className:"fb-label",htmlFor:"fb-body",children:L.question}),a.jsx("textarea",{ref:r,id:"fb-body",className:"ap-manage-input fb-message",value:p,maxLength:pre,rows:5,placeholder:L.placeholder,onChange:K=>g(K.target.value),"aria-invalid":z||void 0,"aria-describedby":z?"fb-body-error":void 0,required:!0}),z&&a.jsx("p",{id:"fb-body-error",className:"fb-error",children:gre}),a.jsx(bse,{images:T,addRef:o}),a.jsxs("div",{className:"fb-tools",children:[a.jsx(xse,{images:T,buttonRef:o}),a.jsx(Fre,{open:b,onToggle:()=>x(K=>!K)})]}),a.jsx(Bre,{open:b,contact:v,onContact:k})]}),a.jsx("p",{className:"fb-facts",children:A?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"fb-facts-value",children:A})," — ",Sre]}):_re}),R.state==="failed"&&a.jsx("p",{className:"fb-error",role:"alert",children:R.message})]}),a.jsxs("div",{className:"fb-foot",children:[a.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[a.jsx("kbd",{"data-symbol":Ore(M)||void 0,children:M}),a.jsx("kbd",{children:$})," to send"]}),a.jsx("button",{type:"button",className:"btn",onClick:e,children:"Cancel"}),a.jsx("button",{type:"submit",className:"btn primary fb-send","aria-keyshortcuts":"Meta+Enter Control+Enter",...Ir(B),children:a.jsxs("span",{className:"fb-send-label",children:[a.jsx("span",{className:"fb-send-idle",children:"Send feedback"}),a.jsx("span",{className:"fb-send-busy",children:"Sending…"})]})})]})]}),D&&a.jsxs("div",{className:"fb-done",children:[a.jsx(dd,{}),a.jsx("p",{className:"fb-done-line",children:JO})]})]}),a.jsx("div",{className:"fb-drop","aria-hidden":"true","data-active":_||void 0,children:a.jsxs("div",{className:"fb-drop-frame",children:[a.jsx(sL,{className:"fb-drop-glyph"}),a.jsx("p",{className:"fb-drop-title",children:"Drop to attach"}),a.jsx("p",{className:"fb-drop-note",children:"PNG or JPEG, up to three"})]})})]})})}const Tse="Press Esc first if a key does nothing.",Ase=[{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 Rse({onClose:e,onTour:t}){const n=ft(e);return a.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:a.jsxs("div",{ref:n,className:"modal key-help",onClick:r=>r.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[t&&a.jsxs("div",{className:"guide-door",children:[a.jsx("span",{children:"Eight pictures of what the deck shows."}),a.jsx("button",{type:"button",className:"btn",onClick:t,children:"Take the tour"})]}),a.jsx("div",{className:"shortcuts",children:Ase.map(r=>a.jsxs(w.Fragment,{children:[a.jsx("h3",{className:"kh-group",children:r.title}),r.rows.map(s=>a.jsxs("div",{className:"sc",children:[a.jsx("kbd",{children:s.cap}),a.jsx("span",{children:s.action})]},`${r.title}:${s.cap}:${s.action}`))]},r.title))}),a.jsx("p",{className:"kh-foot",children:Tse})]})]})})}function Mse(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 $se({request:e,waiting:t,busy:n,now:r,onAccept:s,onDecline:o,onLater:l}){const u=w.useRef(null),d=ft(l,{focusRef:u}),h=Qs(n,"accept"),f=Qs(n,"dismiss");return a.jsx("div",{className:"modal-backdrop",onClick:l,role:"presentation",children:a.jsxs("div",{ref:d,className:"modal lan-ask",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-ask-title","aria-describedby":"lan-ask-who",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("i",{className:"ap-pulse","aria-hidden":!0}),a.jsx("span",{id:"lan-ask-title",className:"modal-tool-name",children:"A deck wants to pair"})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:l,"aria-label":"Answer later (Esc)",title:"Answer later (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("p",{id:"lan-ask-who",className:"lan-ask-who",children:[a.jsx("strong",{className:"lan-ask-name",children:e.name})," at ",a.jsx("code",{className:"ap-lan-code",children:e.addr})," · asked ",Jb(e.at,r)]}),a.jsx("p",{className:"modal-note",children:"Paired decks repair each other's expired logins. Accept only if you know this machine — what it shares is an account, not a screen."}),a.jsxs("p",{className:"lan-ask-fp",children:["Its fingerprint is ",a.jsx("code",{className:"ap-lan-code",children:e.fp})," — that machine shows its own under This deck on the network; the two should match."]}),t>0&&a.jsx("p",{className:"lan-ask-more",children:t===1?"One more deck is waiting behind this one.":`${t} more decks are waiting behind this one.`}),a.jsxs("div",{className:"lan-ask-acts",children:[a.jsx("button",{type:"button",ref:u,className:"btn",disabled:f.disabled,"aria-busy":f.busy,onClick:o,title:"Nothing is shared. If that deck asks again, this comes back.",children:n==="dismiss"?"declining…":"Decline"}),a.jsx("button",{type:"button",className:"btn primary",disabled:h.disabled,"aria-busy":h.busy,onClick:s,title:"Talk to this deck from now on, and repair its expired logins with this deck's own.",children:n==="accept"?"accepting…":"Accept"})]})]})]})})}function Ise({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:r,deferLanPair:s}){const{request:o,waiting:l}=Mse(e,t.current);return o?a.jsx($se,{request:o,waiting:l,busy:n,now:Date.now(),onAccept:()=>void r("accept",o.fp),onDecline:()=>void r("dismiss",o.fp),onLater:()=>s(o.fp)},o.fp):null}function Ose(e,t){return`${e}#${t}`}function Lse(e,{lan:t,now:n,closed:r}){if(t===void 0)return[];const s=[];for(const o of e??[]){const l=o.reauth;if(!l||l.dismissed||o.origin!=="ccdeck_signin")continue;const u=Ose(l.key,l.since);if(r.has(u)||CV(l.key,o.email,t,n))continue;const d=o.email??"";s.push({id:u,key:l.key,since:l.since,num:o.num,email:d,name:d||o.alias||`Account ${o.num}`,alias:d&&o.alias?o.alias:null})}return s}function Pse(e,t){const n=String((t==null?void 0:t.email)??"").trim().toLowerCase();return n?e.filter(r=>r.email.toLowerCase()===n&&((t==null?void 0:t.num)==null||String(r.num)===String(t.num))).map(r=>r.id):[]}function Dse({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function Fse(e){return e===1?"Account needs your attention":"Accounts need your attention"}function Bse(e){return`${e===1?"One Claude account needs":`${e} Claude accounts need`} you to sign in again.`}const qse="Login expired",Use="Until then the deck cannot read its usage or switch to it. Signing in again brings it back — it keeps its slot, its alias and its history.",zse="The account stays marked in the Accounts panel. This will not ask again until it has worked and stopped again.";function Wse({rows:e,onSignIn:t,onLater:n,firstRef:r}){const s=e.length===1?e[0]:null;return a.jsxs("section",{className:"modal-body",children:[s?a.jsxs(a.Fragment,{children:[a.jsxs("p",{id:"reauth-lead",className:"reauth-lead",children:["The Claude login for ",a.jsx("strong",{className:"reauth-name",children:s.name}),s.alias?a.jsxs("span",{className:"reauth-alias",children:[" (",s.alias,")"]}):null," ","has expired and needs a new sign","‑","in."]}),a.jsx("p",{className:"reauth-note",children:Use})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:Bse(e.length)}),a.jsx("ul",{className:"reauth-list",children:e.map((o,l)=>a.jsxs("li",{className:"reauth-row",children:[a.jsxs("span",{className:"reauth-who",title:o.alias?`${o.alias} — ${o.name}`:o.name,children:[o.name,o.alias?a.jsxs("span",{className:"reauth-alias",children:[" ",o.alias]}):null]}),a.jsx("span",{className:"reauth-what",children:qse}),a.jsx("button",{type:"button",className:"btn",ref:l===0?r:void 0,"aria-label":`Sign in again as ${o.name}`,onClick:()=>t(o),children:"Sign in again"})]},o.id))}),a.jsx("p",{className:"reauth-note",children:"Each keeps its slot, its alias and its history."})]}),a.jsxs("div",{className:"reauth-acts",children:[a.jsx("button",{type:"button",className:"btn",title:zse,onClick:n,children:"Not now"}),s&&a.jsx("button",{type:"button",className:"btn primary",ref:r,onClick:()=>t(s),children:"Sign in again"})]})]})}function Hse({rows:e,onSignIn:t,onLater:n}){const r=w.useRef(null),s=ft(n,{focusRef:r});return a.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal reauth-ask",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"reauth-title","aria-describedby":"reauth-lead",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"reauth-title",className:"modal-tool-name",children:Fse(e.length)})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Not now (Esc)",title:"Not now (Esc)",children:"×"})})]}),a.jsx(Wse,{rows:e,onSignIn:t,onLater:n,firstRef:r})]})})}function Vse({rows:e,signingIn:t,signIn:n,signedIn:r,refresh:s,closeSignIn:o,later:l}){const u=w.useRef(!1),d=t!=null||Dse({rows:e.length,ours:u.current,dialogs:Jo.dialogDepth()});return u.current=d,t?a.jsx(W$,{email:t.email||null,onClose:o,onChanged:s,onSignedIn:r}):d?a.jsx(Hse,{rows:e,onSignIn:n,onLater:l},e.length===1?"one":"many"):null}const Gse={"//":["What a user would NOTICE. One key per version that has something to say,","and no key at all for a version that has nothing — which is most of them.","","The rule this file exists to serve: before every release, ask 'what would a","user notice?' and write the answer here. 'Nothing user-visible' is a valid","and expected answer, and it is spelled by adding no key. A release with no","key shows no modal, and that silence is what keeps the modal worth reading","on the day it is not silent.","","What belongs here: something that changed on the user's machine or under","their hands — a hook written to or removed from settings.json, a default","that flipped, a control that moved or went away, a stored preference that","changed meaning. What does not: bounds, races, assertions that could not","fire, anything that is invisible when it is correct.","","Write it for the person running the deck, not for the person reading the","diff. `title` is the sentence they scan; `body` is what they need in order","to act on it, or to stop worrying about it.","","Keys are versions exactly as package.json spells them. A key that is not a","version, or an entry missing either field, fails the suite rather than","being quietly dropped — see src/web/__tests__/release-notes-file.test.ts.","Ordering here is for humans; the deck sorts by version itself.","","A title may open with an emoji, and if it does, put exactly ONE space after","it. Not two: the dialog gives a leading emoji its own optical gap, because","a colour glyph is drawn edge to edge inside its advance and one word space","after one reads as none. A second space here would be a lie in the data","about a defect in the type, and the suite refuses both it and no space at","all.","","A release that genuinely has nothing to say is spelled TWICE: no key here,",'and its version written into "//nothing-to-say" below. One spelling on its',"own is ambiguous — a missing key reads the same whether it was a decision","or a forgotten step, and five releases in a row were once forgotten. The list","is what tells the two apart, and release-notes-current-version.test.ts fails","the release whose version is in neither place. Any key opening with // is a","note to the author and never a release."],"//nothing-to-say":["3.23.1","3.23.2","3.23.3","3.23.4","3.26.0","3.26.1","3.26.3","3.26.4","3.26.5","3.27.6","3.27.7","3.28.0","3.28.1","3.29.3","3.29.4","3.29.6","3.29.7","3.29.9","3.33.1","3.35.0","3.35.1","3.36.0","3.36.1"],"3.36.3":[{title:"🔑 An expired login asks to be signed in again",body:"When an account you added with + → Sign in stops working, the deck now tells you in one dialog, with every affected account together and Sign in again beside each. That opens the usual sign-in with the address already filled in, and the account keeps its slot, its alias and its history. Not now leaves it marked in the Accounts panel and does not ask again until it has worked and stopped again. A paired deck holding a working copy gets to repair it first, and accounts that came from a share or Local network are never asked about."}],"3.34.1":[{title:"🗂️ The tray menu stays open while you read it",body:"On Linux the menu behind the tray icon could close by itself while agents were working, often before the row you pressed took the click, so it had to be opened and pressed again. It now changes only when something it says has changed, and stays open while you choose."}],"3.34.0":[{title:"🗺️ The network map shows who you are connected to",body:"Paired decks that are on stand closest to this one, and a light runs along their wires. Paired decks that are away come next, in a colour of their own, with how long they have been gone, and machines that are not paired stand outside in grey. Decks reached over Tailscale sit together in their own shaded slice instead of on dashed wires. Pointing at a deck opens its details beside the map: whether it is there, what to do next if anything, its address and what it runs, and every login the two share, the ones that need a look first."},{title:"🔑 A login that expired everywhere says so",body:`When a shared login expired on this deck and every paired deck that is on held an expired copy too, the row said "Login expired" and waited for a repair that could never come. It now says "Login expired on all online decks". Claude retires a login's other copies each time one machine refreshes it, so shared copies expire together: sign in again on any one machine and the others repair from it on their next round.`},{title:"💬 Send feedback from inside the deck",body:'Appearance settings has a "Send feedback…" button: pick what kind it is, write a title and a few lines, and add a way to reach you if you want an answer. It goes to the people who make ccdeck, who may open a public issue from it, never with your contact in it. If it cannot be sent, the form stays filled in and says why.'}],"3.33.0":[{title:"🪝 Hooks you add in Claude Code are no longer removed",body:"Claude Code's hook editor often files a new hook into the same group as the deck's own. Starting the deck, or uninstalling it, then removed the whole group, and your hook went with it without a word. The deck now takes out only its own command and leaves yours where it was, and the same goes for the old finish-sound hook. `ccdeck --uninstall` also stops the decks that are running, so an update in the background cannot put the hooks back."},{title:"🧵 Resumed Codex sessions show up again",body:"A Codex session picked up with `codex resume`, or one that ran for days, could go dark on the canvas and drop out of the 5-hour and 7-day usage, because the deck only looked in the two newest day folders. It now follows those sessions and counts their tokens. Two Codex sessions in the same folder get different id suffixes, and a `bash -lc` call shows the command it runs."},{title:"🤝 A deck paired by the accept switch brings in less",body:'A deck that paired through the automatic accept switch, and not through an invite, now brings in only the logins you have ticked on this deck, and nothing from it is ticked for sharing onward. Its dialog says "paired automatically — pair by invite to take it". Pairing by invite works as before. A typed address is no longer dropped after one failed round, and the sync port stays the same after a rename.'},{title:"⬆️ Desktop updates install when you expect them",body:'On Windows and Linux a downloaded update now installs when you quit. On a Mac, Quit installs it and the app stays closed. The Linux .deb needs an administrator password to install, so it no longer does that by itself: it waits for "Restart to update" and says a password is coming. "Start at login" now works on Linux, and "Restart ccdeck" stops a deck that has hung.'},{title:"🕵️ Browser Watch waits before it acts, and quits only its own browser",body:"A program's visit is now logged and reacted to once its quiet window has closed, about 16 minutes after it, and not on the first poll, so a visit that is withdrawn no longer quits the browser. On Linux the quit reaction ends only the browser that holds the watched profile; other Chrome channels and headless browsers keep running. When it cannot tell which process that is, it does nothing and says so, which includes a Flatpak Brave."},{title:"🧮 Figures that were off are right",body:`Spend by labelled and workflow subagents counts toward a session's tokens and cost. The Projects report prices 1-hour cache writes the way ccusage does, so its dollars match the Usage panel. After a restart the deck rebuilds its whole event history, where it used to rebuild about a third. On Linux the process list shows what each process is using now, not its lifetime average. A count near a boundary reads "1.00M", and a full quota window says "used up".`},{title:"🔑 The Usage panel's reads answer the deck's own page only",body:"The routes behind the Usage panel (/api/quota, /api/ccusage, /api/codex-usage, /api/codex-quota and /api/cswap-auto) now answer the deck's own page, or a client that sends the deck's token. A script that read them with a plain request gets 401 from this version on. The hook, the desktop app and the `ccdeck` command are not affected."},{title:"🛠️ Smaller fixes you may notice",body:"With the canvas paused, an update no longer restarts the server while an agent is working: it waits until no turn is open. `ccdeck --stop -p4317` stops that one deck. A deck started at login can update itself on Homebrew and nvm setups. Dialogs keep keyboard focus after a button goes away, screen readers hear pairing requests by deck name and the machine panel's readings, dim text is readable in both themes, Windows High Contrast shows what is selected, and below 640px the detail panel opens over the canvas."}],"3.32.2":[{title:"🔒 Self-updates wait until your screen is unlocked",body:"On Linux with GNOME, the app installs an update by itself when you leave it alone, which is often while your screen is locked. GNOME switches the panel's tray off under the lock screen, and a version that started then never showed its icon. The app now waits until you are back before restarting by itself, so its icon comes back with it."}],"3.32.1":[{title:"🔔 The tray icon comes back on Linux",body:"On Linux the app could lose its icon in the panel, after it updated itself or when the panel restarted, and stay without it until it was quit. It now notices within a minute and restarts by itself the next time you are away from its window, the way it installs an update. It does this at most once every six hours, and not again if a restart did not help."},{title:"🔕 A window you closed stays closed after a self-update",body:"When the app restarted by itself to install an update, it opened its window again even if you had closed it, and while that window was open the deck held back its notifications. A window you closed now stays closed."},{title:"🪟 No empty icon when ccdeck is already open",body:'Opening ccdeck again while it was running flashed an empty "…" icon in the Linux panel before bringing the window forward. It now only brings the window forward.'}],"3.32.0":[{title:"🗺️ A map of your network",body:"A new button on the Local network row, and in its view's header, opens a map of every deck around this one. This deck is at the centre and the paired decks that are on stand around it. Further out are the quiet ones, the machines nearby and any deck asking to pair. Wires are solid on your local network and dashed over Tailscale. Pointing at a deck says how it is reached, what it runs and which logins the two share, and pressing it opens that deck's own dialog."}],"3.31.0":[{title:"📊 Account capacity",body:"A gauge button in the accounts panel's header opens Account capacity: how many of your Claude accounts are ready now, what the 5-hour and 7-day windows have left across all of them, and a row for each account with its use, its state (Ready, Limited, Exhausted or Stale) and when it was last read. Each window also says whose reset comes next."},{title:"🚦 Claude and Codex incidents",body:"When Anthropic's or OpenAI's status page reports an incident on something your sessions use, the deck says so in the topbar, the Usage panel and the tray, and every mark links to the status page. A provider with nothing wrong draws nothing."},{title:"↕️ Order your other accounts",body:"The Other accounts row can sort the list by slot, by how full a window is, or by most room, and open every account at once. Both stay as you left them after a reload."},{title:"🔐 A settings folder left by sudo can be given back",body:'On a Mac, running ccdeck once with sudo left its settings folder owned by another user, and every settings change was refused, sharing an account included. The message now offers "give it back": macOS asks for your password, the folder is yours again, and the deck reads its settings back without a restart.'}],"3.30.0":[{title:"🧮 Token counts and costs are no longer doubled",body:"Claude Code writes a reply that has thinking, text and tool calls as several transcript lines, each carrying the whole request's usage. The deck added up every line, so a session's tokens and cost on its card came out close to twice what it was billed, and the context panel counted each part of a reply as its own message. Each request is now counted once. Expect the totals on your cards to come down."},{title:"⏳ Claude's saved limit resets on the Usage panel",body:`When your Claude account has free limit resets to spend ("Reset for free" in Claude's Settings → Usage), the Claude card now says how many there are and when the first one expires, the way the Codex card already did. The deck only reports them; you spend them in Claude's own settings.`},{title:"🔑 LAN invites need the other deck updated",body:`An invite's code is now a long random secret instead of six digits, so nobody else on the network can work it out and pair in your place, and a wrong code is refused by name. An invite made on this version can only be joined from a deck on this version or later: an older deck answers "That is not an invite". Update that deck, or make the invite on the older one and join it here.`},{title:"🔕 AGENTS_DECK_NO_NOTIFY keeps Browser Watch quiet too",body:"A deck started with AGENTS_DECK_NO_NOTIFY=1 still raised a desktop notification for every new Browser Watch finding. It no longer does. The finding is still in the Browser Watch panel and its log, which says why no notification came."},{title:"🛠️ Smaller fixes",body:'Delete removes the card you just clicked. A LAN address you typed stays in the list when a round cannot reach it, and the status line under the LAN switch now agrees with the rows below it. In the desktop app, a dismissed "update is ready" notice stays dismissed after you answer the first-launch question. Sizes read the same in every panel ("1.1 KB"). Faded text stays readable, a keyboard can see the scrollbar, and numbers use a monospaced font on Windows and Linux as well.'}],"3.29.11":[{title:"💲 Claude Sonnet 5.5 has a price",body:`Sessions on Claude Sonnet 5.5 showed "not priced" on the board, and the Projects report could only show a minimum for them. They are now priced at Anthropic's published rate, the same as Sonnet 5: $2 per million input tokens and $10 per million output tokens.`}],"3.29.10":[{title:"💲 Claude Opus 5.5 has a price",body:`Sessions on Claude Opus 5.5 showed "not priced" on the board, and the Projects report counted them as costing nothing, so its totals read far too low. They are now priced at Anthropic's published rate. If a model still has no price, Projects shows its total as a minimum, like $11.19+, and names the model, instead of a total that looks complete.`}],"3.29.8":[{title:"🔁 Removed cards come back when their agent works again",body:"Remove from board is for finished work. If the agent behind a card you removed starts a tool call, gets a new prompt or starts a subagent, the card returns on its own, together with the card it hangs from, and it stays back after a reload. Cards whose agents stay idle stay removed."}],"3.29.1":[{title:"🗂️ One row per project in Projects",body:"The Projects report now counts a session's work under the folder you started it in, the same name its card has on the canvas, instead of adding a row for every folder the agent moved into. The first start after updating re-reads your transcripts once to regroup the report."},{title:"🔔 Tidier custom sounds",body:"Importing a sound, recording one and choosing a spoken voice now sit in compact cards that respond to clicks and focus like the rest of the deck."}],"3.29.0":[{title:"🎵 Your own stations in Claude FM",body:"Add any YouTube live link or radio stream as a station in Appearance, next to the built-in ones, and mute the music without losing your volume. When a station is not live, the picker now says so instead of staying silent."},{title:"🔔 Notification sounds and voices of your own",body:"Pick a local audio file or a spoken voice for each alert, so the sound that means an agent is waiting is one you will recognise."},{title:"🗑️ Drag a card off the board to remove it",body:"Drag a card to the target at the bottom of the canvas to take it off the board, or use Remove from board in the detail panel (Delete). The session keeps running, and the session list (L) brings it back."},{title:"🔐 Optional invite-only pairing",body:"Pairing works as before, with or without an invite. If you want, Local network can now be set to accept only decks that join with an invite you created, so a nearby machine cannot ask to pair on its own."},{title:"🌐 Account sharing between your machines is more reliable",body:"A locked macOS Keychain is explained instead of failing silently, a login that is broken or belongs to another account is never shared, and a sync that stops partway keeps what already arrived."},{title:"📅 Projects opens on Today",body:"The Projects report per account starts with today's work, and an empty window offers the next wider one. The topbar also shows this month's usage, and the desktop app can restart into an update from its own window."}],"3.27.0":[{title:"📊 Projects: where each account spent its work",body:"Each account card's ⋯ menu now breaks its cost down by project, over 7d / 30d / all."}],"3.27.1":[{title:"🎨 Make Appearance easier to tune",body:"The Appearance dialog now has clearer sections, stronger selection states, and a calmer layout for choosing a theme and configuring music. Your existing settings and keyboard shortcuts continue to work."}],"3.27.2":[{title:"💰 Project costs now match Usage",body:"Project cost totals no longer count the same Claude request once for every content block. Existing project history is rebuilt automatically so the totals align with the Usage panel."}],"3.27.3":[{title:"🎵 Station selection works in the desktop app",body:"The music station picker now opens inside ccdeck instead of relying on the operating system popup, so choosing a station works reliably in the Electron app."}],"3.27.4":[{title:"✅ Desktop picker release checks are green",body:"The station picker now keeps the same keyboard, motion, focus, and layout behavior as the rest of ccdeck across desktop and browser builds."}],"3.27.5":[{title:"🧭 The welcome tour stays dismissed",body:"Electron now remembers that you completed the onboarding tour at the deck level, so an update or loopback port change no longer shows the same tour again."},{title:"🎵 The station picker has a clearer finish",body:"The music selector has a tighter trigger, a purposeful chevron, and more deliberate option spacing so it reads like a native part of Appearance."}],"3.25.0":[{title:"🖱️ A click goes to the session, a double-click opens the details",body:"Clicking a card frames it with the rest of its session and leaves the detail panel shut. Double-click a card to open its details; `j`/`k`, the session list, Enter and `D` still open them too."},{title:"🔭 Cards stay readable when you zoom out",body:"At every zoom a card shows its name, its state and anything waiting on you, instead of shrinking to a coloured pill. Hover or focus a card to see it whole. Recap notes read at a distance too, and show the full recap on hover."},{title:"🌐 The Machine panel shows your network",body:"A new Network section shows download, upload and the round trip to Claude's API, and names the route when traffic goes through a VPN or a Tailscale exit node. Those checks run only while the panel is open. The panel is regrouped into CPU, Memory, Network and Thermal, with a flag at the top when something needs attention."},{title:"🎨 See each theme before you pick it",body:"The Appearance menu shows a small preview of the deck in Light and in Dark. Claude FM also keeps its volume when a notification chime plays, instead of dipping under it."}],"3.24.1":[{title:"🎛️ Appearance is one small menu now",body:"The topbar's appearance control opens a compact menu where you can choose Light or Dark and show or hide the character. The character stays on by default, and your choice is remembered."}],"3.24.0":[{title:"🎧 Claude FM plays from the minimap",body:"A small character stands on the minimap's top edge. Press it and the Claude channel's live stream plays; press it again and it stops. It only turns up when the channel is actually broadcasting, so a deck with no network never shows it at all."},{title:"🤠 And it gets on with its day",body:"It walks that edge, tidies up what it finds, kicks a ball along it, sits with its legs over the side, and watches the board through a scope. Now and then it drops onto the canvas and ropes its way back up. Headphones on while the music plays, a hat when it does not."}],"3.23.5":[{title:"🧭 The accounts panel opens on the account you are on",body:"Its windows, its resets and how old the numbers are — whole, at the top of the column. Every other account stands behind one row that says how many of them a switch could actually reach; press it to see them, or rest on it to be shown their names and how much room each has left."},{title:"⚙️ Auto-switch moved in there with them",body:"It is behind that same row now, after the accounts it switches between, rather than at the foot of the panel. The row says `auto 90%` or `auto off` so you can tell what the policy is doing without opening it — and says so in amber when it is armed with nowhere left to go."}],"3.23.0":[{title:"🧭 The accounts column leads with accounts",body:`The live account is the open row: its windows as bars, when each one resets, and how old the numbers are. Every other account rests on the two figures a switch is decided by, and opens with a click when you want the rest.
101
+
102
+ A problem stays on the row — an expired login, one that was never stored, a keychain the deck cannot open — with the reason and the sign-in one press away. Auto-switch is one row now: its threshold and its switch. Local network moved out of the column into a view of its own, reached from a row at the foot that says how many of the paired machines are on right now, and shows which ones when you hover it.`},{title:"💬 A resting session shows Claude Code's recap beside its card",body:"When a session stops, Claude Code's own recap of what it did is drawn beside the card — so a board you come back to says what happened without opening anything."},{title:"🪟 The chrome went quiet",body:`The topbar is borderless, one set of corners runs through the app, the canvas ground is flat, and the minimap, the zoom controls, the type filter and the Machine and Usage panels read as tooling rather than as cards.
103
+
104
+ The canvas also says when auto-fit is off, with one press to bring new sessions back into view.`},{title:"🔍 A tool call's detail reads as the call",body:"A tool call's arguments are shown as the call rather than as escaped JSON, and can be copied."},{title:"🔐 Saying yes to every deck that asks takes two presses",body:"The switch that accepts every pairing request arms first and says what it hands over, so one stray click cannot put this machine's logins on another deck."},{title:"🖐️ Targets, themes and contrast",body:"The panel's smallest controls reach the 24px target floor, and grow further under a finger. A first run follows the system's light or dark setting instead of picking one. Status dots, meters and switch knobs survive a Windows Contrast theme."}],"3.22.15":[{title:"🖱️ Clicking a card opens its details",body:"Selecting an agent is inspecting it: a click, `j`/`k`, a session picked from the list and Enter on a focused card all open the detail panel — prompt, every tool call, tokens, timing. It used to open only with `D`, so anybody who closed it with its × and never found the key did not get it back. The × still closes it until the next selection, and `D` still toggles it.\n\n`D` with nothing selected now picks a card first — the session that has waited longest, or the one `j` would land on — instead of flipping a switch with nothing on screen to show for it."},{title:"⌨️ The keyboard and screen readers reach the whole deck",body:`Shortcuts keep working after a mouse click on a button. A click left focus on the button it pressed, and the key handler leaves a focused control its own keys, so every single-key shortcut was dead until you pressed Esc — with nothing on screen to say so.
105
+
106
+ Tab follows the page now — topbar, the accounts column, the canvas, usage, machine — instead of zig-zagging left and right across it, and a canvas card reached by Tab draws the focus ring. A screen reader hears each card by name, with its kind, state, model and cost, rather than every word on it run together; the machine panel has a heading its region is named by; and the theme button is named for the theme it switches to.
107
+
108
+ With **Reduce motion** set, the camera no longer flies across the canvas to a card.`},{title:"💵 The money figures say what they measure",body:"The usage header's **$/min** is spend over a trailing window, and says which span it measured: `$3.54/min · 2 min`. It used to divide the live agents' cost by how long the longest of them had been running, so one deck read $2.39/min in a tab left open and $19.49/min in a tab opened minutes later.\n\nA quota bar's pace says **over pace** or **under pace**. It said `ahead`, which is how plain English says winning, on the very line meant to warn you that you are burning the window faster than it lasts.\n\nA card's clock reads `≥ 53m 52s` for a session this page joined after it had started, instead of presenting the part it saw as the whole of it — and that card's per-minute burn is left out rather than divided by the short clock."},{title:"↔️ Narrow windows keep every topbar control on screen",body:`At 400px six of the topbar's buttons sat past the right edge and the page scrolled sideways. The readouts give way first now and the controls stay; below 640px the side panels span the window instead of leaving the canvas a sliver; and the category filter wraps inside the canvas rather than being clipped by it.
109
+
110
+ Zoomed out, a card's name and a cluster's label stay readable instead of shrinking to about four pixels — which is the view a board of any size actually sits at.`},{title:"🔑 A paired deck's dialog says which account that machine is on",body:`The lane of the account the other machine is working on takes the accent and a slow ring on that machine's end. An account is named only if that deck shares it: on one it does not share, the dialog reads "on another account" and never which. A new switch under **SHARE THESE ACCOUNTS**, on by default, turns the telling off, and paired decks then read "current account hidden".
111
+
112
+ **This deck on the network** prints this deck's own fingerprint again. A pairing request asks you to match it against the one on the other machine's screen, and no screen here was showing it — so the one check a person can make against a rogue deck could not be made, on the step that hands over logins.`},{title:"💬 The deck's messages send you somewhere worth going",body:'An empty canvas no longer ends with "Make sure ccdeck is running" while the page is plainly connected to it. The capture hints under that line, one per CLI, are the real reasons a canvas stays empty, and they stay. With the stream down the screen says whether this page lost a deck that was there or never found one, in those words, rather than naming the `/events` route nobody who typed `npx ccdeck` has seen.\n\nAnd a slow `claude-swap` now reads as a slow answer — "still waiting on the deck server" — instead of "couldn\'t reach the deck server", which sent people off to restart a server that was fine.'}],"3.22.10":[{title:"🖱️ Icon buttons are easier to hit",body:"Icon buttons react when the pointer is near them — no need to hit the icon exactly."},{title:"🧩 Sessions spread across the canvas",body:"Sessions now spread across the canvas in columns instead of one tall column, and new sessions and subagents land in the free space beside them. Nothing is placed under the Machine or Usage panels. Press R once to rearrange a board you already have."}],"3.21.0":[{title:"🖼️ The deck explains itself in pictures",body:"🎬 First run opens an eight-picture tour instead of the changelog — who is waiting on you, the tree, a node's inside, cost and quota, this machine, accounts, local network, how to start. `Take the tour` on an empty canvas brings it back.\n\n📡 **Local network** has a guide: a card while it is off, `How it works` under an empty list, four pictures ending on `Turn it on`. A machine's row opens its own dialog — address, version and system, the logins it offers, and a name of your own for it. Setup ends on Done.\n\n🔄 The deck updates itself when nobody is looking: no tab focused, no agent mid-turn, thirty seconds quiet. The banner's `auto when idle` switch governs it.\n\n🔑 An account whose numbers were paused resumes on its own, and the panel is titled **Claude accounts** — a Codex login is not in it."}],"3.20.0":[{title:"🟢 The deck keeps running after you close the terminal",body:"`ccdeck` prints the same boot report and gives you the prompt back. The deck stays up, and starts again when you log in.\n\n🛑 **`ccdeck --stop` is the off switch now** — Ctrl+C only cancels a start that is still printing. `--status` says what is running, `--logs` shows what the deck wrote while you were away, and `--foreground` holds the terminal the way every version before this one did.\n\n🔁 Typing `ccdeck` beside a deck that is already up opens **that deck's tab** instead of building a second one. `ccdeck --stop --all` clears any older deck still running from before this version. An `npx` run cannot start at login — `npx ccdeck --install` puts it on your PATH and sets that up.\n\n🔑 An account that will not collect now says which of three things is wrong: **no stored login**, a **login that expired**, or a **keychain the deck cannot open** — with the fix beside it. One with no stored login is filled over the local network by a paired deck that has it.\n\n📡 And decks find each other again on a machine with a VPN up: the beacon was going to an address that never left the machine, so this deck could hear colleagues and none of them could hear it."}],"3.19.0":[{title:"🟢 Local network: fixes and improvements",body:`The list of decks is quiet now. A deck that is **on**, with nothing to repair, is a name and a green mark — no sentence under it. Every healthy row used to carry the same words, so the one row worth reading looked like all the others. A failure, a login that arrived, a machine that is away, still say so, and they are now the only rows with anything written on them.
113
+
114
+ \`unpair\` arrives when you point at a row rather than sitting on every one of them, two machines that share a name show their addresses, and the ↻ turns while a round is out.
115
+
116
+ **Add a deck** is two ways in — by address, or with an invite — with \`make one to send\` beside the invite heading instead of under the paste field, where it read as that field's button. A refused address now says which mistake it was, and an invite that will not work says whether it ran out, was not an invite, or reached nothing.
117
+
118
+ Switching **Local network** on opens your name and shared logins, every time, so nothing goes on the network without you having just seen what goes with it.`}],"3.18.3":[{title:"🟢 The list shows what is on, and folds the rest",body:'A machine that is off, or nearby and unpaired, or one you said no to, is context rather than an answer to "who can I use right now" — so the decks that are **on** lead the list and everything else is one line: `2 more`. Nothing worrying is hidden by it: a deck that cannot be reached is counted in that line, in the warning colour, so the fold says whether it is worth opening.\n\nThe round moved to a **↻ beside the switch**, where the accounts header has kept the same act since it was written, and the line under the state now says when it last ran — `checked 2m ago`, or `not checked yet`. A list that refreshes itself and a list that has stopped used to look identical, and pressing the button to find out was the only way to tell.'}],"3.18.1":[{title:"🔁 A deck stops asking to pair over and over",body:"Several decks on one computer share a config directory, so they start with one key. Each read the others' beacons as somebody wearing its name, took a fresh key, and wrote it to the file the others read — a loop that never settles. Every new key is a **new deck** to everyone else on the network, so one machine sent a fresh pairing request every few seconds and accepting one accomplished nothing: the deck that asked no longer existed by the time the answer arrived.\n\nDecks on one computer now recognise each other as the same machine and leave the key alone. The clash still worth healing — a `~/.claude` copied to a second machine — is unchanged.\n\nThis also collapses the rows: a computer that has run the deck a few times appeared several times on everybody else's panel and is one row now. **Both machines need this version** for that to take effect on the other one's screen.\n\nA deck that answered is no longer counted as unreachable, the list refreshes itself in seconds while somebody is deciding rather than at the next minute, and a failed round says what happened — `not listening`, `no route to it` — with the address and the raw error on the hover."}],"3.18.0":[{title:"🟢 A deck that is switched off no longer reads as on",body:"A paired deck this one has no address for was drawn **live** on the strength of being paired — a machine closed an hour ago still sat under `1 deck ready`. Every row now leads with whether that machine is actually there, and when it last was: `online · 1 login arrived`, `no answer · last online 20m ago`, `never reached`. The mark beside the name is a traffic light — green for a deck that answered, amber for one that cannot be reached, grey for one nothing has heard from.\n\n**+ add a deck** opens a dialog now instead of unfolding inside the panel. An address, an invite and the firewall note never fitted a 288px column, and unfolded they turned a list of machines into a form."}],"3.17.0":[{title:"🔔 Pairing is two presses",body:`When another deck asks to pair, the question now arrives **over the deck** rather than in a row three sections down a panel: its name, its address, the fingerprint to compare, **Accept** or **Decline**. Escape means later — the request stays in the panel until you answer it.
119
+
120
+ The rest is one list. Every deck you are paired with, every deck on the network, and every one you turned away, each a row with its state under the name and one verb at the end — and a deck that cannot be reached now reads differently from one that is fine. Saying no also reaches the other machine now, instead of leaving it waiting forever; you can take it back.
121
+
122
+ The dialog behind **setup** is down to the two things it is really about: what this deck is called, and which logins it offers.`}],"3.15.0":[{title:"🔗 Decks on one network heal each other's dead logins",body:`A login dies on the machine that has not used it while the same account keeps working on the machine that has. The fix was a blob copied out of one deck and pasted into another. Now: **Accounts ▸ Local network**, the same passphrase on each deck — it offers you six words — and they find each other and repair themselves.
123
+
124
+ A deck only **adds** an account it does not have, or **replaces one it has proven dead** — proven by Anthropic refusing the token, not guessed. A credential that works is never touched. The passphrase is the only gate; a stranger on the same wifi sees that a deck exists and nothing else.`},{title:"⚠️ What sharing a login actually means",body:`**A login you share is a live one, and it cannot be taken back.** Turning the switch off stops what has not happened yet; a credential that has left your machine is gone, and the only real revocation is signing in again at Anthropic — which ends the session everywhere at once.
125
+
126
+ Sharing a Claude account may also be against Anthropic's terms. Your call; the deck says it once and does not nag.`}],"3.14.0":[{title:"📊 The machine comes back beside the list that covers it",body:`**Busiest processes** opens over the machine panel and hides the very readings that sent you looking. They are back beside the list — cores, memory, swap, queued work, temperature — with up to an hour behind each: a column down the side on a wide screen, a band under the table on a narrow one.
127
+
128
+ Each is drawn against the line it is measured to — memory and swap at 90%, load at your core count, the GPU at 75° and again at 90° — so swap sitting *on* its line is something you see rather than work out. The processor readings get no line on purpose: a CPU at 90% is your machine doing what you asked for. Throttling appears only once your machine has actually been held back, and the band says how much history it really has rather than claiming an hour it has not had.`},{title:"📋 The process dialog's footnote moved onto the columns it was about",body:"A band ran along the bottom of **Busiest processes** saying three things. Two were worth keeping and are now on the header of the column they describe — hover `memory` to read what that number measures, `process` to read that the command-line redaction is a filter rather than a promise.\n\nThe third said the list is the busiest by processor and memory, refreshed every four seconds. The heading, the count beside it and the moving numbers were already saying that."},{title:"📝 These notes render what they were written in",body:`Every note in this dialog is written in Markdown — **bold** for the sentence that carries the change, backticks for a flag or a path — and the dialog printed the string raw. So the first window you see after an upgrade has been showing you \`**this**\`, backticks and all, since the feature shipped: 25 of 52 notes, 52 bold spans, 54 code spans.
129
+
130
+ What you are reading is the first version that does not.
131
+
132
+ No Markdown library came along for it. Counted in the file: bold 52, code 54, links 0, headings 0, lists 0 — and the smallest library that reads all of Markdown is 40KB on a bundle the deck fetches while you wait for it to start.`},{title:"⎋ Esc leaves the machine panel where it is",body:"The × on **This machine** read `Close (Esc)`, so Escape put the panel away. Escape belongs to the canvas — it deselects and hands the keyboard back — and pressing it while you are reading your instruments should not close them.\n\nThe panel now closes the two ways it opens: its ×, and the meter in the topbar. The × says `Close`, and names no key it does not answer."},{title:"🖥 The machine moved out of the topbar and into a button",body:"The small CPU sparkline and memory bar in the topbar are gone. A chip glyph in the icon row beside `$` and the accounts silhouette opens the same **This machine** panel — cores, memory, swap, load, temperature, busiest processes — and the bar stops moving in the corner of your eye.\n\nIt also stops asking. The deck read your machine every three seconds for the life of every tab to feed that meter; it now reads only while the panel is open, and the history behind the readings is kept by the deck itself, so a panel opened an hour from now still has the hour behind it."},{title:"🔎 The panel's eight process rows became one way in",body:"The machine panel drew eight processes in a 280px box: three columns, names cut off mid-word, and a `ps` run every four seconds to keep them moving. **Busiest processes** is a single row you press now, and the dialog behind it is what it always was — every candidate the deck sees, its memory in bytes, threads, user, pid, and the command line that tells you which `node` this one is.\n\nWith that dialog closed, the deck reads no process list at all."},{title:"⏱ The restart banner says whether the press is safe, and shows the fuse",body:"The button read `Restart now` whether the machine was idle or five agents were mid-turn — and the events fired while the server is down are lost for good. It reads **`Restart anyway`** now when something is running, with the count beside it, and `Restart now` with *nothing is running* when the machine is quiet.\n\nThe automatic restart said only `auto when idle`, while a 30-second clock ran where nobody could see it. It counts — **`auto in 18s`** — which is also how you stop it, since the switch is the label. The amber dot pulses only while that clock runs.\n\nThe switch also says `auto-restart off` in words rather than in a colour, both its label and the button are readable in the light theme now, and a tab you are not looking at no longer restarts the deck under the tab you are."}],"3.13.0":[{title:"📊 Usage history stops jumping out from under you",body:`Pressing **H** put \`running ccusage…\` in a box 186px tall. Two to four seconds later the chart, the totals and the legend arrived and the box became 429px — and because the dialog is centred, that growth moved the whole thing **121px upward**, under the cursor that had just pressed something.
133
+
134
+ The chart's place is now reserved from the first frame: the 168px the chart is tall plus the 16px it keeps for its day labels, both taken from the chart's own rule so the placeholder and the thing it holds room for cannot drift apart. The jump goes from 243px to 156px. It deliberately stops there — the totals and the legend are content, the legend's height depends on how many models ran, and reserving those would have meant drawing four plausible empty cards for a reading that had not arrived.
135
+
136
+ What is drawn in the reserved space is **the chart's baseline and nothing else**: one line, in the same colour, at the height the columns will land on. Not a skeleton of grey bars — a skeleton stands in for content, an axis is furniture, and furniture is honest before the data exists. The light on it travels rather than fills, because the deck knows a subprocess is running and does not know how far through your transcripts it has got.
137
+
138
+ Then the days rise out of that line, **oldest first**. The stagger is divided rather than fixed — 200ms of spread whether the range is 7 days or 90 — so the longest range is not also the slowest to appear.
139
+
140
+ With reduced motion both loops and both entrances are off. The reserved space is layout, not animation, and stays outside that rule: asking for less movement gets you the same dialog that does not jump.`},{title:"⏳ The period mark says it is being read",body:"The first read of **today**, **month** or **all** takes two to three seconds — it walks the transcripts on this machine, and the cost is the walk, not the size of the range you asked for. Until now the panel said nothing for the whole of it, so pressing `month` looked like pressing nothing, and the honest response was to press it again.\n\nThe mark under the period now pulses while that read is in flight, and it **pulses rather than fills**: nothing measures how far through the transcripts ccusage has got, so a bar that filled would be inventing a number. Hovering the pending period says which one is being read, and screen readers are told the same thing through a live region rather than being left with a silent button."}],"3.12.0":[{title:"🔍 Busiest processes tells you which one",body:"The list could say what was eating the machine and not **which** of nine identical `Google Chrome Helper` rows was the headless Chrome you left running. It now shows the arguments after the name — `--type=renderer` beside one, `serve admin-portal --port 44440` beside a node — and four columns it did not have: **memory in MB and GB** instead of a percentage, **threads**, **how long it has been up**, and **user**. Every column sorts; press its heading.\n\n**Command lines have anything secret-shaped removed before they leave your machine** — the value of any flag whose name says token, password, key or secret, the password in a URL, and the shapes that identify themselves. It is a filter and not a guarantee: a secret that looks like an ordinary word looks like an ordinary word. The reading happens only while this modal is open, so a deck whose process list you never open never reads a command line at all.\n\n**Memory is resident set size** — what `ps` and Windows Task Manager report. On macOS this is *not* the number Activity Monitor shows in its Memory column; that one is the physical footprint, and on the machine this was built on the two disagree by up to fourteen times on the same process. No unprivileged command reports the footprint quickly, so the deck shows the figure that means the same thing on all three platforms and says which one it is.\n\n**There is no Ports column**, and the reason is the same kind of honesty: Mach ports do not exist on Linux, are not what Windows calls a handle, and on macOS the only way to count them takes four seconds — against a list that refreshes every four."},{title:"🔢 A token count that stays a whole number",body:"Switching the Usage panel from **month** to **today** counted down smoothly and then, for a fraction of a second, showed something like `in 594.3268260610639` where a token count belongs.\n\nThe count was never wrong; the printing was. The figures animate between two readings, so the formatter is handed a fraction on most of its frames — every size above a thousand was already rounded and the one below it was not."}],"3.11.0":[{title:"🗂 The session list waits to be asked for",body:`**BY SESSION in the Usage panel now starts collapsed.** It is the one block in that panel with no ceiling — every other section is two or three rows, or a model table bounded by the models that exist — and it was the reason the panel scrolled at all. Shut, the whole panel is one screen: quota, period, money, models. Press the heading to open it, and it stays open; ccdeck remembers your answer from then on.
141
+
142
+ The count of what is behind it is on the heading's tooltip, so collapsing it does not hide how much there is.
143
+
144
+ **Scrollbars are also gone until you point at the thing that scrolls.** Nothing moves when they appear — the track keeps its width in both states, so no text shifts under the pointer as it arrives.`},{title:"📊 today · month · all, as tabs that remember",body:"**The Usage panel's period switcher is a full-width row of tabs** rather than a pill floating over the column, with a thin cyan mark under the word it belongs to. It governs the figures beneath it, so it now looks like it does.\n\n**Your chosen period survives a reload.** It was the one preference in that panel that did not.\n\n**It costs one Tab stop instead of three.** Tab into the strip, then move with ←/→ or Home/End, and press Enter to choose. Arrowing past a period no longer starts reading it — moving and choosing are separate now, which matters on `all`.\n\nAnd **`month` says which month.** Hover it: this is the calendar month, from the 1st — not the last 30 days. `today` and `all` say what they cover too."},{title:"🔔 Sounds and Notifications are two switches, and Browser notifications is a channel",body:`**The sound menu has been rebuilt.** Sounds and Notifications are real switches now instead of words that read like status. Under them, **Browser notifications** is named as what it is — one of the two ways ccdeck can reach you — rather than sitting there as a third setting that seemed to contradict the one above it.
145
+
146
+ There are two notifiers and they never both fire: the page raises one when the deck is open but hidden, and the server raises one when no page is open at all. Only the first needs a browser permission, which is why the permission belongs to a channel and not to the feature. **Turning Notifications on now asks the browser on that same press** — no second control to hunt for.
147
+
148
+ \`M\` mutes and unmutes sounds from anywhere. **Hear it** plays the tone even when Sounds is off, so you can pick one before turning them back on.`},{title:"🧹 No agent, no empty panel",body:`**The detail panel no longer appears when nothing is selected.** It used to sit there empty, and a tab on the edge of the canvas existed to bring it back after you closed it — both are gone. Select an agent and the panel is there; press **D** to toggle it yourself.
149
+
150
+ The canvas is that much wider whenever you are not reading one agent.`}],"3.10.0":[{title:"🔌 Who else can drive your browser, and where to see it",body:"**Browser Watch has a Remote control section.** The Claude in Chrome extension holds a connection open to Anthropic's relay, and that connection is registered against your **account**, not against this machine — so any Claude Code session signed in to the same account, running anywhere, can enumerate and drive this browser, and nothing prompts you on the machine being driven.\n\nThe panel now says whether that is the case here, and what the extension is actually allowed to do in each profile — enabled or switched off, every site or only the ones it was granted, and which of the powerful APIs it holds. That last part is not what `chrome://extensions` shows you: the per-site list there is enforced by the extension, on itself, while the grant underneath stays exactly as wide as it was.\n\nIf you want it closed, the section hands you the one command that closes it — as text, to paste in your own terminal. **ccdeck never runs it and never asks for your password**, and it never will: no part of this deck elevates, and a dashboard that could raise a password box on request would be a gift to anything else running on the machine. If the block is already in place, the section offers the command that takes it back out. And if something else in your hosts file already points that name somewhere, it says so and leaves the line alone — ccdeck only removes the line ccdeck wrote.\n\nAll of this is two file reads and no network call. It was written some releases ago and, until now, was not connected to any screen.\n\n**Also:** the README said `share` produces a `ccdeck1:` blob. It produces `ccdeck2:` — `ccdeck1:` has been read-only legacy for a while."}],"3.9.0":[{title:"🎛️ Five switches that were not where the thing they control is",body:'**The session list has a button again.** It lost one a while back and only the `L` key was left — and `L` is written down in one place, a shortcuts sheet behind a small `?` in the corner of the canvas. If you use a mouse there was no way to open the list at all. The `☰` is back at the left of the top bar.\n\n**The Notifications switch now tells you whether the browser will actually show one.** It said `on` while this browser had never been asked for permission, which is not the same thing. It now says so on that row and offers the ask right there. Before, the only place to grant it was a button that appears solely while a session is stuck waiting — so on a machine where that rarely happens you could not switch notifications on at all.\n\n**Started with `--workspace` or `--scope` and seeing nothing?** The empty screen used to tell everyone to "run `claude` or `codex` in any folder", which is the one thing that cannot work for you. It now names the folder the deck is actually watching.\n\n**Browser Watch says when a setting did not save.** Flipping the switch and having it fail showed a red line reading "Could not read" — about reading history, not about your press — and ten seconds later the panel wiped it and looked perfectly healthy with the setting unchanged. A failed save now says so, in its own words, and stays until you dismiss it. The "nobody browsing for" menu also follows the stored value again: change it in a second tab and this one never caught up.\n\n**The deck no longer restarts itself when nothing on screen offers to stop it.** Thirty seconds after the last agent went quiet, with a new version on disk, the server would exit, come back and reload the page. The `auto when idle` switch that controls that lives inside the update banner — so if you had closed the banner with its `×`, it happened with no visible setting anywhere. Closing the banner now also stands down the restart; clicking the version chip brings back both together.'}],"3.8.9":[{title:"🖥️ Four things that only went wrong on somebody else's operating system",body:"**Ubuntu:** the deck knew where Chromium and Brave keep their profiles when installed as a snap or a flatpak — which on a default Ubuntu is the only place Chromium is — but not what those programs are called. So it reported them as not running while they were, and refused to quit them. Both now work.\n\n**Windows:** the deck asked the system whether it could write to the folder an update installs into, and Windows always answers yes for a folder whatever the permissions say. It offered you an update that then died inside npm with a permission error. It now finds out by trying, and declines up front with the command to run yourself — which is what every other platform already got.\n\n**Linux:** if `XDG_DATA_HOME` was set to something starting with `~`, as it is from a systemd unit or a Dockerfile, the deck and claude-swap looked in two different places for your accounts. The panel said you had none while `cswap list` showed them all.\n\n**Plain terminals:** six messages used a typographic dash the old Windows console and the Linux text console cannot draw, so a box appeared mid-sentence — including in the line that explains why no events are arriving. They use the plain form on those terminals now, like everything else already did."}],"3.8.8":[{title:"📉 A false 99% on the memory chart, and three other quiet failures",body:`**The machine meter no longer invents a reading.** When the deck could not measure memory — a subprocess that would not start under load, or one that took too long — it substituted a number that means something else, and on a Mac that reads as about 99% used. The meter went red for half a minute, and because the chart keeps the highest value in each minute, that false peak stayed on it for a full day. A poll that cannot measure now keeps the last reading and records nothing: a gap in the chart is honest.
151
+
152
+ **A failed ccusage repair no longer disables the repair.** If the deck found a half-installed copy it removes it and starts again. On Windows that removal can fail for a few seconds because the program it just ran still has the folder open — and the deck then treated the attempt as spent and never tried again for the rest of the session, leaving the panel permanently unable to read your usage. It now only counts a repair that happened.
153
+
154
+ **Changing the auto-switch interval takes effect even during startup.** Set it in the first seconds after launch and the timer kept the old value for the life of the process, while the panel showed the new one.
155
+
156
+ **Codex sessions with very large histories no longer cost hundreds of megabytes to read.** The deck read the whole file to find four values that live at its two ends — measured at 185 MB of memory and 95ms of frozen interface for one 44 MB session. It now reads only the ends.`}],"3.8.7":[{title:"🧠 Four things in the panel that behaved wrongly",body:`**Today's figure no longer overshoots.** Once a minute, when a fresh reading landed, the headline briefly counted past the true number and back down — it was measuring the last minute of spend from a starting point one moment out of date. The reading and its starting point are now recorded together, so there is no moment where they can disagree.
157
+
158
+ **Browser Watch marks findings read when you close it, not when you open it.** It was clearing the badge immediately, and stamping every new finding as read the moment it arrived — so anything that turned up while you were reading was never badged at all. It was also writing to storage four times a second the whole time the panel was open.
159
+
160
+ **A hidden tool category can always be brought back.** Hide one, leave the deck running, and once the canvas had turned over the row of chips disappeared while the filter stayed on — no bubbles, and nothing to press. Only reloading fixed it. The chips now stay for as long as anything is hidden.
161
+
162
+ **Clicking a session's name no longer switches auto-fit off.** The deck was reading its own camera move as you grabbing the canvas, and remembered it across restarts, with nothing said.`}],"3.8.6":[{title:"🗂️ Two decks can no longer both claim the same log",body:"When several decks share one events log they elect a single writer for it, so nothing is recorded twice. That election compared the path as typed — so two decks reaching the SAME file by different spellings each thought they were alone, both wrote every event, and each believed the log was theirs to clear.\n\nDifferent spellings are ordinary, not exotic: a shortened Windows home directory, a mapped or substituted drive, a junction, or on macOS `/tmp` against `/private/tmp`. The visible symptoms were duplicated tool calls after a restart, and Clear wiping history belonging to another deck.\n\nThe path is now canonicalised the same way the watched folder already was. It works on a first run too, before the log file exists."}],"3.8.5":[{title:"⛔ Cancelling a sign-in no longer adds the account anyway",body:`Press Escape while adding a Claude account and the deck killed the sign-in — and then, sometimes, registered the account regardless, switched to it, and told you it had worked.
163
+
164
+ The deck asks the tools it runs whether they finished cleanly. A program that is well behaved about being cancelled tidies up and exits with a success code, and the deck was reading that as "it finished" rather than "I stopped it". \`claude auth login\` is exactly that kind of program.
165
+
166
+ A cancelled run now reports as cancelled. Everything that was not cancelled is unaffected.`}],"3.8.4":[{title:"🧷 Your own hooks can no longer be eaten by two decks starting together",body:'If you keep hooks of your own in `settings.json`, the deck parks them while it installs and puts them back afterwards. Two decks starting at the same moment could interleave inside that, and the loser wrote a version of the file computed before the restore — so your hook was gone from `settings.json` and gone from the park, which was its only other copy.\n\nThere was already a check for this, and it had a hole: if the last-moment re-read of the file failed, it read that as "nothing changed" and wrote anyway. A failed read is the one moment that check was most needed, because the usual reason a file cannot be read for a few milliseconds is that something else has just written it.\n\n`ccdeck --uninstall` had no such check at all and could overwrite a deck that was starting, then exit 0 saying it had succeeded. It has one now, and when it declines it says so and tells you to run it again rather than reporting that there was nothing to remove.'}],"3.8.3":[{title:"🪟 Windows: two settings files that could refuse to save",body:`On Windows a file cannot be moved into place while anything else has it open, and Defender and the search indexer open a file the instant it is written. The deck has had a retry for that for a long time, and two files written in the last few days were not using it: the notifications preference, and Browser Watch's episode archive.
167
+
168
+ When it bit, the notifications switch silently did not stick, and Browser Watch answered an error and showed an empty panel. Both now retry the way everything else in the deck already did.
169
+
170
+ Nothing changes on macOS or Linux, where the operating system never refused the move in the first place — which is why this got past a green test suite on both.`}],"3.8.2":[{title:"⌨️ A closed-behind-your-back dialog no longer kills every keyboard shortcut",body:`Open the context ring on a session's card and leave it open. The session finishes, and a couple of minutes later the canvas evicts it — or you press Clear. The dialog vanished, and from that moment every shortcut in the deck stopped working: Space, C, R, F, L, H, U, A, J, K, T, M, and the trash button too. Only reloading the page brought them back.
171
+
172
+ The deck was still counting the dialog as open, because it remembered which session you had opened it for rather than whether anything was on screen. It now closes the dialog when its session leaves the board, which is what should have happened in the first place. The end-of-session recap had the same problem and is fixed with it.`}],"3.8.1":[{title:"🔒 Security: update if the deck runs on a Mac",body:"A local process able to reach the deck's port — no token, no browser, no tab — could get a string of its choosing compiled as AppleScript when the deck raised a desktop notification with no page open. On macOS that is code running as you.\n\nThe strings were already passed as arguments rather than pasted into the script, which is normally the whole defence. It is not enough for `osascript`: its option parser reads any argument starting with a dash as an option, so a name beginning with `-e` was taken as more script instead of as text. Every place the deck hands `osascript` or `notify-send` something from outside now carries an explicit end-of-options marker, so nothing from outside can be read as an instruction again.\n\nNothing to change on your side beyond updating. If you would rather keep the deck off the desktop entirely, the Notifications switch in the sound menu does that, and `AGENTS_DECK_NO_NOTIFY=1` does it at launch — but the fix is the thing to have."}],"3.8.0":[{title:"🔕 Notifications now have an off switch",body:`3.7.0 gave you a "notify me" button and no way back. Turning them off meant digging into your browser's site settings — which no page can do for you — and that still left the other notifier, the one the deck raises when no page is open at all. Silencing that one meant quitting the deck and starting it again with \`AGENTS_DECK_NO_NOTIFY=1\` in front. The person who wanted quiet was the one doing the work.
173
+
174
+ There is a **Notifications** switch in the sound menu now, beside the one for sound — that menu is already "how loudly does this deck interrupt me". One switch governs both notifiers, it takes effect immediately without a restart, and it is remembered across restarts.
175
+
176
+ It is kept by the deck rather than by your browser, because the second notifier runs when no page exists and a setting living in a page could never reach it. \`AGENTS_DECK_NO_NOTIFY=1\` still wins over the switch — a machine told at launch to stay off the desktop stays off it — and when that is the case the menu says so instead of showing an "on" that will not happen.`}],"3.7.1":[{title:"🔔 The notifications now fire on the thing that actually stops your agent",body:`3.7.0 could tell you a session was waiting — but only when Claude Code asked permission to run a tool. If you work with permissions bypassed, that never happens, and the whole feature was silent for you. Measured on one real log: 1683 events, every one of them in bypassPermissions, and a single permission prompt in the entire history.
177
+
178
+ What fires constantly on that setup is the other kind: the agent asking you a question and stopping for the answer. The deck was throwing those away — no amber chip, no row in the sidebar, no notification, and no "notify me" button, because the button only appears while something is actually blocked.
179
+
180
+ Now they count. The card carries the question itself rather than a generic "Your turn" — "paycore needs your input: merge both branches to main, or just one?" — and so does the notification, on the desktop, whether the tab is behind something or not open at all.
181
+
182
+ An idle prompt still stays quiet: a turn that ended is not a session that is stuck, and a channel that cries wolf is one you switch off.`}],"3.7.0":[{title:"🔔 The deck can reach you when you are not looking at it",body:`The deck's whole point is telling you which agent is waiting on you, and until now it could only say so on screen — the amber chip, the tab title, the favicon. Every one of those is drawn inside a page, so the one moment it matters, when you have walked away and four agents have gone quiet, the deck was silent.
183
+
184
+ Now it reaches the desktop, two ways that never overlap. With the deck open behind something, the page raises the notification itself: a "notify me" button appears in the top bar the first time a session blocks, and the browser asks you — nothing is requested before there is something to notify you about. With no page open at all, the server raises it, because it can see that nobody is connected and therefore that no other surface is saying anything.
185
+
186
+ One notification per session, replaced rather than stacked if a second deck raises it too. Clicking it brings the tab forward. \`AGENTS_DECK_NO_NOTIFY=1\` turns the desktop side off entirely, and if you refuse the browser prompt the deck says so plainly instead of leaving you thinking you switched something on — after a refusal only your browser's site settings can undo it, which no page is allowed to touch.`},{title:"🧩 A blocked session now says what it is asking for",body:'"Waiting on you" told you to go and look. The session row and the card now carry the tool the prompt is most likely about, and the tooltip carries the one line of its input that a person actually reads — `rm -rf node_modules` rather than `{"command":"rm -rf node_modules"}`.\n\nIt is a guess and it is worded as one: the deck sees the tool calls, not the permission dialog, so it says "likely on". The deck still cannot allow, deny or answer anything for your agent, and it never will.'},{title:"🧮 Today's figure was counting some sessions twice",body:`The panel reads your usage from ccusage once a minute and fills the gap in between from what the deck is watching. The filling-in was wrong: any session that reached the canvas after the reading had landed was added in full, and since the canvas is still loading when the first reading arrives, that was most of them.
187
+
188
+ Measured on a deck four seconds old: ccusage said $450 for today and the panel said $1,006. The table underneath it said $450 the whole time, which is the disagreement to trust.
189
+
190
+ The deck now adds only work it has actually watched happen. A session that starts while you are looking shows up at the next reading instead of instantly — up to a minute — which is how the panel behaved before the live figure existed at all. Everything already on screen keeps moving as it did.`}],"3.6.0":[{title:"✂️ The two figures at the end of the top bar are gone",body:`The bar used to end with a token count and a dollar figure. Both were sums over what is on the canvas at that moment, and the canvas drops finished sessions a couple of minutes after they end — so both numbers fell on their own, with nothing on screen to explain the fall. They carried the word "board" and a three-line tooltip for exactly that reason.
191
+
192
+ The usage panel answers the same question without the apology: it reads the logs on disk, it covers sessions this deck never watched, and it does not forget. Press U for the panel, or H for the full history.
193
+
194
+ What is left in the bar is what is true right now — whether the stream is alive, and what your machine is doing.`}],"3.5.0":[{title:"⚡ The figures move when the work happens",body:`Reading your usage off the logs is not free — measured here, one reading is 7.8 seconds of CPU, because ccusage walks every transcript on the machine whatever period you asked for. Once a minute is affordable; once every ten seconds would be three quarters of a core, permanently, for numbers that move slowly.
195
+
196
+ So the reading stays on a minute and the deck fills the gap with what it already knows. Every hook event carries its session's running total, so the panel adds whatever has been spent since the last reading and counts up to it. The headline now moves when a turn finishes rather than on the clock, and it costs nothing extra.
197
+
198
+ It only ever adds. A session leaving the canvas cannot pull the figure down, and the next reading corrects whatever the estimate got wrong — the tokens are exact, and the dollars in between are priced by the deck's own table.
199
+
200
+ Two smaller things with it: pressing today, month or all now counts between the two figures instead of swapping them, and coming back to the tab only re-reads if what is on screen is actually stale.`}],"3.4.0":[{title:"🔢 The figures count to their new value, once a minute",body:`The Usage panel re-reads its numbers every minute now rather than every five, and it is a real minute — the server used to hold a reading for two, so a shorter poll would have handed the same figure back.
201
+
202
+ And they no longer teleport. Replaced in a single frame, $170 → $269 says only "this is different now": no direction, no sense of how much, and nothing at all if your eye was a few pixels away. Counted over a fifth of a second, the same change says up, and roughly how far.
203
+
204
+ What deliberately does not count: the first paint, a change of period — "today" and "all time" are different quantities rather than one that moved — the tables, a change too small to read, and anything at all if you have reduced motion on or the tab is in the background.`},{title:"🧹 The board's own figure is out of the Usage panel",body:`3.3.0 put the canvas's live spend on its own labelled line, under whichever period you had chosen. In front of a panel that answers today, this month and all time from the logs on disk, that second money figure answers a question nobody asked at that moment — and it invited a comparison it could never win, $7,385 on the board beneath $170 for today.
205
+
206
+ It is gone. The board's tokens and cost are still on the topbar, with the sentence that explains why they fall on their own, and the panel still shows them when ccusage cannot answer at all.`}],"3.3.0":[{title:"📊 The Usage panel answers for a period, not just for the board",body:`It used to add up the sessions drawn on the canvas — which is an honest number with a scope nobody reads it as having: finished sessions are evicted a couple of minutes after they end, so the figure fell on its own while nothing had happened and nothing was refunded.
207
+
208
+ It now reads ccusage, the same source the H modal uses, and offers today, this month and all time. BY MODEL and BY SESSION come from there too, and each session is named by the project the board knows it as rather than by a uuid.
209
+
210
+ The live figure is still there, on its own line and labelled — what the sessions currently on the board have spent — because that is a different question from what the month cost.
211
+
212
+ One thing worth knowing about the source: ccusage reports a session's LIFETIME total, so the rows under "active today" can add up to more than the day above them. The heading says so.`},{title:"🪟 Windows: a deck started from an elevated terminal was being treated as dead",body:"The hook decides whether a deck is still running by trying to signal it. On POSIX a process you may not signal answers EPERM; on Windows it answers EACCES, and only EPERM was accepted — so a deck started from an elevated terminal, or under another account, read as gone. Its registration was deleted on every event and rewritten five seconds later, while its banner went on saying it was connected and almost nothing arrived.\n\nThree more Windows-only faults went with it: a read-only settings.json made every hook install fail for good (the atomic write could not replace the file); the machine panel answered 500 every four seconds whenever the process read failed; and a bare command name was looked for in the working directory before PATH, which is where `npx ccdeck` was run."},{title:"👁 Browser Watch reads nothing while it is switched off",body:`The switch used to control only what was KEPT. The read happened anyway — every five minutes, on every deck, the panel's badge poll discovered each Chromium profile and copied its whole History database to a temp file to query it. A switch that says off while that continues is not a switch.
213
+
214
+ With the watch off, nothing touches a browser now. Opening the panel still reads live, because that is you looking, and a watch that is ON still records in the background — that is the feature. The trade is that the topbar badge no longer counts findings while the watch is off; open the panel to see them.
215
+
216
+ The README has a Browser Watch section now: what is read, when, where the copy goes, and that only visits after the deck started are ever considered.`},{title:"🔒 The deck's own data is no longer readable by anything on the machine",body:"Changing an account needed the deck's credential; reading the event ring did not. Anything running on your machine could `curl` the events — prompt text, the commands an agent ran, the paths and contents it touched — plus the account list and the browsing episodes.\n\nThose reads now answer to the same rule the mutations do: the deck's own page, or its token. Nothing changes for you in the browser. A script of yours that reads those routes needs the token from `~/.claude/agent-dag/<pid>.json`, sent as `x-ccdeck-token`."},{title:"💳 An API-key, Bedrock or Vertex install is told there is no quota window",body:`Those installs are billed per token and have no five-hour window. The CLI ran, printed no quota lines, and the deck read that as a genuine "under 1%" — drawing two empty bars for a measurement nobody had taken, or telling you to run /usage, which cannot help there.
217
+
218
+ It now says what it is, in one line, the way the Codex half already did.`},{title:"🎨 The model chip is coloured by its model again",body:`A session that switched model — Sonnet, then Opus — drew a chip reading "Opus 5 +1" in Sonnet blue, because the colour was picked from the tooltip and the tooltip lists every model the card's spend covers. Add a Fable turn and it went yellow.
219
+
220
+ Also fixed on the way past: an account import the CLI rejected could take the whole deck down with it, and a corrupt compressed Codex rollout leaked a file handle on every poll.`}],"3.2.1":[{title:"💵 Sonnet 5 was being costed fifty per cent high",body:`Sonnet 5 launched at $2/$10 per million tokens as introductory pricing, with a rise to $3/$15 announced for September 1. The deck implemented that schedule, and on September 1 it started charging the higher rate.
221
+
222
+ The increase was cancelled. Anthropic's pricing page now says the $2/$10 rate is simply the price and the rise "will not occur" — so every Sonnet 5 session since the 1st has been shown to you at half again what it cost.
223
+
224
+ It is corrected, and there is no date logic left in that rate to go stale a second time. Numbers already on your board are recomputed from the log the next time the deck starts; nothing was billed by us, only displayed.
225
+
226
+ Fable 5.1 and Mythos 5.1 are also priced now, including the cache read that is a quarter of Fable 5's — which is most of what a long session pays for.`}],"3.2.0":[{title:"🌡️ Windows shows a temperature where it can find one",body:`On most Windows laptops there is nothing to show, and that is Windows rather than this deck: modern machines declare no ACPI thermal zone, and the sensors that do exist sit behind an interface only an administrator may read. Measured on real hardware, elevated and not.
227
+
228
+ One thing does work, and it costs you nothing to have. If LibreHardwareMonitor happens to be running with its web server on, the deck now reads its numbers over localhost — which needs no privileges at all.
229
+
230
+ It is only ever a read. Nothing is installed, nothing is asked of you, and a machine without it shows no section, exactly as before.`}],"3.1.0":[{title:"🚀 The first run stops looking like it hung",body:`\`npx ccdeck\` on a machine that has never run it used to sit on a spinner at "checking claude-swap" and say nothing else. Measured on a Windows box: seventeen and a half seconds before it told you where to point a browser. It is now one and a half.
231
+
232
+ The deck was waiting for an install nobody asked for during that boot — a Python toolchain being fetched so the accounts panel would work. The port had been open the whole time; there was just nothing on screen to say so.
233
+
234
+ It no longer waits. Anything still working past the boot says so on its own line and keeps going in the background, and the deck comes up without it.`},{title:"⚡ Every start is quicker, and stays quicker",body:`The event log was read from the beginning on every boot to fill a buffer that only keeps the last two thousand events — so four fifths of that reading existed to be thrown away, and it got slower the longer you had been using the deck. It reads from the end now and stops when the buffer is full: 258ms down to 20ms here, on a 34 MB log, and it no longer grows.
235
+
236
+ The accounts tool is also asked for its version once instead of twice, which on this machine was the single largest thing in an ordinary boot.`},{title:"📉 Ten fewer packages to install",body:"Opening your browser used to cost a dependency that brought nine more with it — ten downloads on a cold `npx ccdeck` before the deck's own files were unpacked. It is now done with the commands the operating system already has.\n\nThe package has no runtime dependencies at all."},{title:"🌡️ Temperature, on the machines that could not show it",body:`On Windows the deck was asking somewhere it is not allowed to look: that reading lives behind a namespace that needs administrator, so it failed for everybody and the section never appeared. It reads a performance counter now, which needs nothing.
237
+
238
+ On Apple Silicon there is no command that ships with macOS which prints a temperature at all — the sensors are behind an interface only native code can reach. The deck fetches a small signed tool for it, verified against the checksum its release publishes, in the background and only on the Macs that need it. You do not have to install anything. \`AGENTS_DECK_NO_DOWNLOAD=1\` turns that off.
239
+
240
+ A machine with no sensor still shows no section, which includes every virtual machine. Nothing is drawn that was not measured.`},{title:"😌 The terminal goes quiet when there is nothing happening",body:`The dot at the bottom blinked every 800ms for as long as the deck ran, which is what a terminal does while it is working — so a deck that had finished in a second looked like one that never finished.
241
+
242
+ It now moves only while something actually is: a job still running, or hooks that cannot find the deck. Otherwise it is drawn once and left alone, and it says what the job is rather than just blinking. A step that takes more than three seconds shows how long it has been going, which is the whole of "is this stuck".
243
+
244
+ And a machine with no Claude Code installed stops being told about it every few seconds — that one is said once now, on its own line instead of across the status line.`}],"3.0.0":[{title:"📈 The machine panel now shows what it DID, not just what it is",body:`Click any section of the machine panel — Cores, Memory, Load average, Thermal — and it opens a chart of what that reading has done since the deck started.
245
+
246
+ The panel could always tell you the machine is busy now. It could not tell you whether it got hot while that three-hour build was running, or how deep the queue went while you were away, and those are the questions you actually have afterwards.
247
+
248
+ Thermal is new as well. Where the machine will give degrees, it gives degrees; on a Mac it also reports whether the CPU is being held back to cool down, which is the consequence a temperature has to be interpreted into anyway. Nothing is drawn that was not measured — a machine with no sensor gets no section at all, rather than a zero.`},{title:"🔍 The whole process list, not just the busiest eight",body:`"more" beside Busiest processes opens the full list the deck is watching — around fifty processes rather than eight — with the pid and the untruncated name.
249
+
250
+ This closes a gap. The panel's eight rows are the busiest, so sorting them by name only reorders those eight: "is my test runner still going" could not be answered if the test runner was not already on screen. Now it can.
251
+
252
+ It is deliberately not a task manager. Nothing here ends a process; Activity Monitor and Task Manager are better at that and it is not a thing this deck should own.`},{title:"🔤 Process names in Cyrillic, Greek or with accents read correctly",body:`An application named Яндекс Музыка was showing up as M-PM-/M-PM-=M-PM-4M-PM-5… in the process list, and so was every other name the deck could not spell in plain ASCII.
253
+
254
+ The deck was forcing a fixed locale on the commands it runs, to guarantee that a decimal point stays a point on a machine set to German or Russian — and that also forced the character set. It forces only the number format now. Your own character set is left alone, which is what makes the name arrive intact.`},{title:"📦 The text you copy to share accounts is a third of its size",body:`Sharing three accounts used to produce 6168 characters. It is now 1896.
255
+
256
+ Most of that text was never the credentials — two OAuth tokens are about two hundred characters between them, and the rest was the envelope, whose field names repeated in full for every account added. So the saving grows with the number of accounts rather than shrinking.
257
+
258
+ A blob you copied before this still imports until it expires. One made now cannot be read by a deck older than this version — that is the one thing in this release that older decks cannot follow.`}],"1.48.0":[{title:"👁 Browser Watch — see what a program opened while you were away",body:`There is a new eye in the top bar. It watches the browsers on this machine and tells you when a program — an extension, an agent, a command — opened pages while nobody was touching the browser.
259
+
260
+ Usually that is your own agent doing what you asked, and the panel says so rather than crying intrusion. What it gives you is the evidence: which pages, in which browser, at what time, with every address written out in full.
261
+
262
+ It is off until you switch it on, and nothing leaves this machine. It reads a copy of the browser's own history and only pages newer than the moment the deck started — never anything from before, never cookies, never saved passwords. Open ⚙ inside the panel and "What Browser Watch can access" says exactly what it reads, keeps and sends.
263
+
264
+ When it finds something the eye turns amber with a count. You can dismiss a finding once you have looked at it and it stays gone, while the log file on disk keeps the record. On a Mac it can also close the tab it found, or quit the browser.`},{title:"🔑 Move all your accounts to another machine in one paste",body:`Sharing accounts between two decks used to be one account at a time, and step four of six is where people stop — leaving the second deck half set up with nothing saying so.
265
+
266
+ Pick the accounts you want, copy one blob, paste it into the other deck. The import adds what is missing, leaves what already works alone, heals an account whose token has died, and tells you which of those happened to each one.
267
+
268
+ The blob carries real credentials, so it expires ten minutes after you make it and the deck refuses an expired one before it unwraps anything.`}],"1.47.0":[{title:"🔌 The top bar goes quiet when everything is fine",body:`The green "live" pill used to sit up there permanently to tell you nothing was broken. It is gone while things are working.
269
+
270
+ You will still see a pill when it matters: amber when you pause the canvas, with how many events are waiting, and red when the deck loses its connection to the server. No pill means all is well.`},{title:"🔴 The browser tab tells you when the connection drops",body:`The little icon in the tab has always shown what your sessions are doing — grey when it is quiet, blue when something is working, amber when a session is waiting on you.
271
+
272
+ It could not say the one thing that matters most: that the deck has stopped hearing from the server. Until now it just kept showing whatever it had last seen. It turns into a broken red ring instead, so you can spot it from another tab without switching over.`}],"1.46.0":[{title:"🔊 Pick a volume and a sound for each of the two tones",body:`Click the speaker in the top bar and a small menu opens. There are two tones — one when a turn finishes, one when Claude is waiting for you — and each has its own volume and its own sound, six to choose from. Press "Hear it" to try one straight away, without waiting for a real turn.
273
+
274
+ The two lists are separate on purpose, so you can never end up with both tones sounding the same. A finish tone always falls; an asking tone always rises. That is how you tell them apart without looking at the screen.
275
+
276
+ M still turns the sound on and off from anywhere.`},{title:"✨ This box is new",body:`After an update, the deck tells you what changed — once, and only when there is something worth telling. Most updates have nothing to say and you will see nothing at all.
277
+
278
+ Click the version at the top of the deck to read it again whenever you like.`}],"1.45.0":[{title:"🔕 The deck no longer puts anything in your settings.json",body:"It used to add a hook there so Claude Code would play a sound when a turn ended. That entry is removed the first time you start this version, and any sound hook you wrote yourself is put back exactly where you had it. Nothing else in that file is touched. The deck makes the sound itself now — which is also why you finally hear one when a Codex turn ends, not just a Claude one."}],"3.16.0":[{title:"🤝 Pair two decks with one piece of text",body:`**Accounts ▸ Local network ▸ setup… ▸ make an invite.** Send the text however you already talk to them; they paste it and the two decks are paired. Nobody presses accept, and neither of you has to know which of your addresses the other can reach — the invite carries them all and their deck tries each one.
279
+
280
+ Decks on the same router still find each other on their own and appear under **on this network right now**. An invite is for the case that does not work: another subnet, a VPN, a firewall.
281
+
282
+ The invite lasts 10 minutes and is used once. Anyone who gets hold of the text can pair with your deck until it runs out, so send it the way you would send anything else you would not want forwarded.`},{title:"⚠️ Both machines have to be on this version",body:`The two decks no longer speak the old protocol, and there is no fallback: a 3.15 deck and a 3.16 deck cannot see each other at all. Update both.
283
+
284
+ The group passphrase is gone. If you had one set, that pairing is not carried over — make an invite and pair again. It was replaced because a passphrase that differs by one character produced a closed socket and no other symptom on either machine, and a secret is the one thing a panel must never print, so neither person could check theirs against the other's.`}],"3.22.1":[{title:"🖥️ A first run now opens This machine too",body:`Accounts and usage already opened themselves the first time you ran the deck; the machine panel did not, and now does. It is the panel that answers "is this box coping" — cores, memory, load, temperature — and somebody meeting the deck for the first time cannot ask for a panel they do not know is there.
285
+
286
+ It only does this when you have never said otherwise. Close it once and it stays closed, on that browser, for good — the same rule the other two panels have always followed. Nothing reopens it behind you.
287
+
288
+ While it is open it polls this machine once every few seconds, and it stops the moment you close it or switch tabs.`}],"3.22.4":[{title:"📈 A card stops looking idle while it is thinking",body:`The activity chart on each card counted tool calls and nothing else, so the time an agent spends reading, reasoning and writing drew as a flat line — measured on this machine, 16.5% of all working time, more than the time spent inside the tools themselves. A session that was busy looked exactly like one that had died, and the only way to tell them apart was to wait and see whether anything ever appeared.
289
+
290
+ It marks that work now. A chart with bars in it means the agent is doing something, whether or not it has called a tool in the last minute; a flat chart means it genuinely is not. Hover it for the split — how many tool calls and how many blocks of thinking and writing landed in the last 60 seconds.
291
+
292
+ Nothing was added to the card and nothing new is polled. The deck already reads each session's transcript for its token counts; this reads the same file for what the model has finished writing, and a session that is quiet costs one file check per second and a half.`}]},A0="agent-dag.releaseNotesSeen";function kR(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function fi(e,t){const n=kR(e),r=kR(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 pi(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function Kse(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 Yse(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,r]of Object.entries(e)){if(!pi(n)||!Array.isArray(r))continue;const s=r.filter(Kse);s.length&&t.push({version:n,notes:s})}return t.sort((n,r)=>fi(r.version,n.version))}const NR=Yse(Gse);function oL(e,t,n){return e.filter(r=>fi(r.version,n)<=0&&(t===null||fi(r.version,t)>0))}function Xse(e,t){return e.filter(n=>fi(n.version,t)===0)}function Zse(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 Jse({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&&pi(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(!pi(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=fi(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 Qse=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function eae(e){const t=Qse.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function tae(e){if(!e)return null;let t=null;try{t=e.getItem(A0)}catch{return null}return pi(t)?t:null}function nae(e){if(!e)return!1;try{return e.getItem(A0),!0}catch{return!1}}function rae(e,t){if(!e)return!1;try{return e.setItem(A0,t),!0}catch{return!1}}const iL="agent-dag.tourSeen";function sae(e){if(!e)return!1;try{return e.getItem(iL)==="1"}catch{return!1}}function aae(e){if(!e)return!1;try{return e.setItem(iL,"1"),!0}catch{return!1}}function oae({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 iae({stored:e,running:t,notes:n,remembers:r=!0}){if(!pi(t))return{show:[],record:null,reason:"no-version"};if(!pi(e)){if(!r)return{show:[],record:t,reason:"cannot-remember"};const l=Xse(n,t);return l.length?{show:l,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const s=fi(e,t);if(s===0)return{show:[],record:null,reason:"seen"};if(s>0)return{show:[],record:null,reason:"ahead"};const o=oL(n,e,t);return o.length?{show:o,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function lae(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 lL(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=lae(e,o);if(l>0){s(),n.push({kind:"bold",kids:lL(e.slice(o+2,l),!1)}),o=l+2;continue}}r+=e[o],o+=1}return s(),n}function cae({entries:e,since:t,running:n,firstRun:r,onClose:s,onTour:o,updateVersion:l,updateBusy:u,onUpdateRestart:d,updateFailure:h,onRestart:f}){const p=ft(s),g=Zse(e);return a.jsx("div",{className:"modal-backdrop",onClick:s,role:"presentation",children:a.jsxs("div",{ref:p,className:"modal release-notes",onClick:v=>v.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"release-notes-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{id:"release-notes-title",className:"modal-tool-name",children:"What's new"}),g&&a.jsx("span",{className:"modal-tool-id",children:g})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[(l||h)&&a.jsxs("div",{className:"rn-update",children:[l&&d&&a.jsxs("div",{className:"guide-door",children:[a.jsxs("span",{children:["ccdeck v",l," is downloaded and verified."]}),a.jsx("button",{type:"button",className:"btn",onClick:d,"aria-busy":u||void 0,children:u?"Restarting…":jd})]}),a.jsx("p",{className:"rn-update-said",role:"status",children:h})]}),a.jsx("p",{className:"modal-note",children:Jse({since:t,running:n,firstRun:r,entries:e})}),o&&!l&&a.jsxs("div",{className:"guide-door",children:[a.jsx("span",{children:"Eight pictures of what the deck shows."}),a.jsx("button",{type:"button",className:"btn",onClick:o,children:"Take the tour"})]}),f&&a.jsxs("div",{className:"guide-door",children:[a.jsx("span",{children:"Restart the deck. Sessions, settings and pairings come back as they were."}),a.jsx("button",{type:"button",className:"btn",onClick:f,children:"Restart"})]}),e.map(v=>a.jsxs("section",{className:"modal-section",children:[a.jsxs("h3",{className:"rn-version",children:["v",v.version]}),a.jsx("ul",{className:"rn-notes",children:v.notes.map((k,b)=>{const{icon:x,rest:N}=eae(k.title);return a.jsxs("li",{className:"rn-note",children:[a.jsxs("p",{className:"rn-note-title",children:[x&&a.jsx("span",{className:"rn-note-icon",children:x}),N]}),a.jsx("p",{className:"rn-note-body",children:cL(lL(k.body))})]},b)})})]},v.version))]})]})})}function cL(e){return e.map((t,n)=>t.kind==="text"?t.text:t.kind==="code"?a.jsx("code",{className:"rn-code",children:t.text},n):a.jsx("strong",{className:"rn-strong",children:cL(t.kids)},n))}function uae({state:e,sessionId:t,onClose:n}){const r=w.useMemo(()=>dae(e,t),[e,t]),s=w.useRef(null),o=ft(n,{focusRef:s});return r?a.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:a.jsxs("div",{ref:o,className:"modal session-summary",onClick:l=>l.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[a.jsxs("div",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),a.jsx("span",{id:"ss-title",className:"modal-tool-name",title:r.cwd??r.sessionId,children:r.label}),a.jsxs("span",{className:"modal-tool-id",children:["· ",r.sessionId.slice(0,8)]})]}),a.jsxs("div",{className:"modal-actions",children:[a.jsx("span",{className:"modal-dur",title:"Total wall time",children:r.durationLabel}),a.jsx("button",{type:"button",ref:s,className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),a.jsxs("div",{className:"modal-body",children:[a.jsxs("section",{className:"ss-hero",children:[a.jsxs("div",{className:"ss-hero-left",children:[a.jsx("div",{className:"ss-cost-label",children:o$}),a.jsx("div",{className:"ss-cost",children:qe(r.cost.total)}),r.modelChips.length>0&&a.jsx("div",{className:"ss-models",children:r.modelChips.map(l=>a.jsx("span",{className:"model-chip","data-family":$d(l),title:l,children:Js(l)},l))})]}),a.jsx("div",{className:"ss-hero-right",children:r.cost.total>0&&a.jsxs(a.Fragment,{children:[a.jsx(qb,{cost:r.cost,size:"lg"}),a.jsxs("div",{className:"ss-cost-legend",children:[a.jsxs("span",{className:"ssl ssl-in",children:["input ",a.jsx("b",{children:qe(r.cost.input)})]}),a.jsxs("span",{className:"ssl ssl-out",children:["output ",a.jsx("b",{children:qe(r.cost.output)})]}),a.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",a.jsx("b",{children:qe(r.cost.cacheRead)})]}),a.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",a.jsx("b",{children:qe(r.cost.cacheWrite)})]})]})]})})]}),a.jsxs("section",{className:"ss-stats",children:[a.jsx(Uo,{label:"agents",value:r.agentCount}),a.jsx(Uo,{label:"subagents",value:r.subagentCount}),a.jsx(Uo,{label:"tool calls",value:r.toolCount}),a.jsx(Uo,{label:"prompts",value:r.promptCount}),a.jsx(Uo,{label:"tokens",value:r.tokensSum.toLocaleString()}),r.errCount>0&&a.jsx(Uo,{label:"errors",value:r.errCount,tone:"err"})]}),r.topTools.length>0&&a.jsxs("section",{className:"modal-section",children:[a.jsx("h4",{children:"Most-used tools"}),a.jsx("div",{className:"ss-top-tools",children:r.topTools.map(([l,u])=>a.jsxs("div",{className:"ss-tt",children:[a.jsx("span",{className:"ss-tt-name",children:l}),a.jsx("span",{className:"ss-tt-bar",children:a.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${u/r.topTools[0][1]*100}%`}})}),a.jsx("span",{className:"ss-tt-count",children:u})]},l))})]}),r.firstPrompt&&a.jsxs("section",{className:"modal-section",children:[a.jsx("h4",{children:"Opening prompt"}),a.jsx("div",{className:"ss-prompt",children:r.firstPrompt})]})]})]})}):null}function Uo({label:e,value:t,tone:n}){return a.jsxs("div",{className:`ss-stat${n?` tone-${n}`:""}`,children:[a.jsx("div",{className:"ss-stat-value",children:t}),a.jsx("div",{className:"ss-stat-label",children:e})]})}function dae(e,t){const n=e.agents.get(t);if(!n)return null;const r=[];for(const _ of e.agents.values())_.sessionId===t&&r.push(_);if(r.length===0)return null;const s={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},o=new Set,l=new Map;let u=0,d=0,h=0,f=0,p=0,g,v=1/0,k=0;for(const _ of r){const E=hn(_);s.input+=E.input,s.output+=E.output,s.cacheRead+=E.cacheRead,s.cacheWrite+=E.cacheWrite,s.total+=E.total;for(const A of CM(_))o.add(A);_.model&&o.add(_.model),_.kind==="subagent"&&p++;const T=gM(_.prompts);d+=T.length,!g&&T.length>0&&(g=T[0].text),h+=_.usage.inputTokens+_.usage.outputTokens,u+=_.toolCount,f+=_.toolErrorCount??0;for(const[A,R]of _.toolCountByName??[])l.set(A,(l.get(A)??0)+R);v=Math.min(v,_.startedAt),k=Math.max(k,_.endedAt??Date.now())}const b=Math.max(0,k-v),x=Math.floor(b/1e3),N=x<60?`${x}s`:x<3600?`${Math.floor(x/60)}m ${String(x%60).padStart(2,"0")}s`:`${Math.floor(x/3600)}h ${Math.floor(x%3600/60)}m`,S=Array.from(l.entries()).sort((_,E)=>E[1]-_[1]).slice(0,5);return{sessionId:t,label:n.label||n.cwdBasename||"session",cwd:n.cwd,durationLabel:N,cost:s,modelChips:Array.from(o),agentCount:r.length,subagentCount:p,toolCount:u,promptCount:d,tokensSum:h,errCount:f,topTools:S,firstPrompt:g}}const hae=60,fae=6e3,Lr=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),yn=e=>typeof e=="string"?e:null;function Ua(e,t=""){if(e==null)return"(none)";if(typeof e=="string")return e;if(typeof e!="object")return String(e);const n=Array.isArray(e),r=n?e.map((o,l)=>[String(l),o]):Object.entries(e);if(r.length===0)return n?"[]":"{}";const s=[];for(const[o,l]of r){const u=n?`${t}-`:`${t}${o}:`;if(typeof l=="string"&&l.includes(`
293
+ `)){s.push(u);for(const d of l.split(`
294
+ `))s.push(`${t} ${d}`)}else if(l!==null&&typeof l=="object"){const d=Ua(l,`${t} `);d==="[]"||d==="{}"?s.push(`${u} ${d}`):s.push(u,d)}else s.push(`${u} ${l===void 0?"(none)":String(l)}`)}return s.join(`
295
+ `)}function pae(e){return e.lines??e.text.split(`
296
+ `).map(t=>({text:t}))}function uL(e,t){if(t)return{shown:e,cut:!1};const n=[];let r=0;for(const s of e){if(n.length===hae)return{shown:n,cut:!0};const o=fae-r;if(s.text.length>o)return n.push({...s,text:`${s.text.slice(0,Math.max(o,0))}…`}),{shown:n,cut:!0};n.push(s),r+=s.text.length+1}return{shown:n,cut:!1}}function mae(e,t){return uL(e,!1).cut?t?{label:"show less",expanded:!0}:{label:"show all",expanded:!1}:null}const Jt=(e,t,n=!1)=>({...e?{label:e}:{},text:t,...n?{err:!0}:{}}),wn=(e,t)=>({label:e,text:t,inline:!0}),dL=(e,t)=>({label:e,text:t.map(n=>n.text).join(`
297
+ `),lines:t});function gae(e,t){return[...e.split(`
298
+ `).map(n=>({text:`- ${n}`,tone:"del"})),...t.split(`
299
+ `).map(n=>({text:`+ ${n}`,tone:"add"}))]}function yae(e){if(!Array.isArray(e)||e.length===0)return null;const t=[];for(const n of e){if(!Lr(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 jR(e){if(typeof e=="string")return[Jt(void 0,e)];if(!Lr(e))return[Jt(void 0,Ua(e))];const t=[],n=yn(e.type);n==="create"&&t.push(wn("result","created the file"));const r=yae(e.structuredPatch);return r&&t.push(dL("applied",r)),e.userModified===!0&&t.push(wn("note","the user changed it before it was applied")),t.length?t:[wn("result",n==="update"?"updated the file":"done")]}function wae(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 vae(e){if(typeof e=="string")return[Jt(void 0,e)];const t=Lr(e)&&Lr(e.file)?e.file:null,n=yn(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(wn("lines",o>=l?`all ${l}`:Number.isFinite(u)?`${u}–${u+o-1} of ${l}`:`${o} of ${l}`)),s.push(Jt("content",n)),s}const r=Lr(e)?yn(e.type):null;return r&&r!=="text"?[wn("result",`${/^[aeiou]/i.test(r)?"an":"a"} ${r} file`)]:[Jt(void 0,Ua(e))]}function xae(e){if(typeof e=="string")return[Jt("output",e)];if(!Lr(e))return[Jt(void 0,Ua(e))];const t=yn(e.stdout),n=yn(e.stderr);if(t==null&&n==null)return[Jt(void 0,Ua(e))];const r=[];return t&&r.push(Jt("output",t.replace(/\n$/,""))),n&&r.push(Jt("errors",n.replace(/\n$/,""),!0)),e.interrupted===!0&&r.push(wn("note","interrupted before it finished")),r.length?r:[wn("output","none")]}function bae(e,t,n){const r=Lr(t)?t:null;if(r&&(e==="Edit"||e==="MultiEdit")){const s=yn(r.file_path),o=(e==="MultiEdit"?Array.isArray(r.edits)?r.edits:[]:[r]).filter(Lr).filter(l=>yn(l.old_string)!=null&&yn(l.new_string)!=null);if(s&&o.length){const l=[wn("file",s)];return o.forEach((u,d)=>{const h=u.replace_all===!0?", every occurrence":"";l.push(dL(o.length>1?`change ${d+1}${h}`:`change${h}`,gae(u.old_string,u.new_string)))}),{input:l,response:jR(n)}}}if(r&&e==="Write"){const s=yn(r.file_path),o=yn(r.content);if(s&&o!=null)return{input:[wn("file",s),Jt("content",o)],response:jR(n)}}if(r&&e==="Read"){const s=yn(r.file_path);if(s){const o=wae(r);return{input:o?[wn("file",s),wn("lines",o)]:[wn("file",s)],response:vae(n)}}}if(r&&e==="Bash"){const s=yn(r.command);if(s!=null){const o=yn(r.description);return{input:o?[Jt("command",s),wn("why",o)]:[Jt("command",s)],response:xae(n)}}}return{input:[Jt(void 0,Ua(t))],response:[Jt(void 0,Ua(n))]}}function SR(e,t,n){if(n==null)return"";if(typeof n=="string")return n;if(Lr(n)){if(e==="Bash"&&t==="input"&&typeof n.command=="string")return n.command;if(e==="Bash"&&t==="response"&&(typeof n.stdout=="string"||typeof n.stderr=="string"))return[n.stdout,n.stderr].filter(r=>typeof r=="string"&&r!=="").join(`
300
+ `);if(e==="Read"&&t==="response"&&Lr(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 kae({tool:e,onClose:t}){const n=ft(t),r=e.endedAt==null?"inflight":e.ok===!1?"err":"done",s=e.input??e.inputPreview,o=e.response??e.errorPreview,l=bae(e.name,s,o);return a.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:a.jsxs("div",{ref:n,className:"modal",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:`status-dot ${r}`,"aria-hidden":!0}),a.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),a.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),a.jsxs("div",{className:"modal-actions",children:[a.jsx("span",{className:"modal-dur",children:RM(e,"in-flight…")}),a.jsx("button",{className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),a.jsxs("section",{className:"modal-body",children:[e.trimmed&&a.jsx("div",{className:"modal-section",children:a.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("div",{className:"tm-head",children:[a.jsx("h4",{children:"Input"}),a.jsx(ER,{text:SR(e.name,"input",s),what:"input"})]}),l.input.map((u,d)=>a.jsx(_R,{block:u},d))]}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("div",{className:"tm-head",children:[a.jsxs("h4",{children:["Response ",r==="err"&&a.jsx("span",{className:"err-tag",children:"error"})]}),e.endedAt!=null&&a.jsx(ER,{text:SR(e.name,"response",o),what:"response"})]}),e.endedAt==null?a.jsx("pre",{children:"(waiting…)"}):l.response.map((u,d)=>a.jsx(_R,{block:u},d))]})]})]})})}const Nae={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function _R({block:e}){const[t,n]=w.useState(!1);if(e.inline)return a.jsxs("p",{className:"tm-inline",children:[e.label&&a.jsx("span",{className:"tm-label",children:e.label}),a.jsx("code",{children:e.text})]});const r=pae(e),{shown:s}=uL(r,t),o=mae(r,t);return a.jsxs("div",{className:"tm-block",children:[e.label&&a.jsx("span",{className:"tm-label",children:e.label}),a.jsx("pre",{className:e.err?"tm-err":void 0,children:e.lines?s.map((l,u)=>a.jsxs("span",{className:l.tone?Nae[l.tone]:void 0,children:[l.text,u<s.length-1?`
301
+ `:""]},u)):s.map(l=>l.text).join(`
302
+ `)}),o&&a.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":o.expanded,onClick:()=>n(l=>!l),children:o.label})]})}function ER({text:e,what:t}){const[n,r]=w.useState(!1),s=w.useRef(!0);return w.useEffect(()=>()=>{s.current=!1},[]),a.jsx("button",{type:"button",className:"btn tm-copy",disabled:!e,"aria-label":n?`The ${t} was copied`:`Copy the ${t}`,onClick:()=>void Wa(e).then(o=>{!o||!s.current||(r(!0),window.setTimeout(()=>{s.current&&r(!1)},1600))}),children:n?"copied":"copy"})}const jae=w.lazy(()=>Fb(()=>import("./UsageHistoryModal-ClT1-0hN.js"),[])),Sae=w.lazy(()=>Fb(()=>import("./BrowserWatchModal-BJKk2x-P.js"),[]));function _ae({dialogs:e,welcome:t,desktopUpdate:n,versionCheck:r,restart:s,lanPairs:o,attention:l,clearFlow:u,watchBadge:d,announcements:h,appearance:f,providers:p,stateRef:g,agentCount:v}){const{openedTool:k,setOpenedToolKey:b,usageHistoryOpen:x,setUsageHistoryOpen:N,browserWatchOpen:S,setBrowserWatchOpen:_,contextAgent:E,setContextFor:T,summaryFor:A,setSummaryFor:R,keyHelpOpen:B,setKeyHelpOpen:P,feedbackOpen:D,setFeedbackOpen:O,feedbackPrefill:L,setFeedbackPrefill:z}=e,{tourOpen:M,openTour:$,closeTour:q,releaseNotes:X,closeReleaseNotes:H,chipVersion:I}=t,{desktopUpdateRestarting:W,desktopUpdateFailure:F,readyAppUpdate:Y,askDesktopUpdateRestart:J}=n,{version:V}=r,{askRestart:G}=s,{clearConfirmOpen:K,setClearConfirmOpen:Z,requestClear:ee}=u,{setWatchOn:re,markWatchSeen:ue}=d,{setWatchSaid:me}=h,{palette:ae}=f;return a.jsxs(a.Fragment,{children:[k&&a.jsx(kae,{tool:k,onClose:()=>b(null)}),x&&a.jsx(w.Suspense,{fallback:null,children:a.jsx(jae,{providers:p,onClose:()=>N(!1)})}),S&&a.jsx(w.Suspense,{fallback:null,children:a.jsx(Sae,{onClose:()=>_(!1),onSeen:pe=>{me(""),ue(pe)},onWatching:re,palette:ae})}),E&&a.jsx(f8,{agent:E,onClose:()=>T(null)}),D&&a.jsx(aL,{initialKind:L==null?void 0:L.initialKind,initialBody:L==null?void 0:L.initialBody,onClose:()=>{O(!1),z(null)}}),A&&a.jsx(uae,{state:g.current,sessionId:A,onClose:()=>R(null)}),X&&a.jsx(cae,{entries:X.entries,since:X.since,firstRun:X.firstRun,running:I,onClose:H,onTour:()=>{H(),$()},updateVersion:Y==null?void 0:Y.version,updateBusy:W,updateFailure:F&&(!Y||Y.version===F.version)?Mne(F.failure,F.version):void 0,onUpdateRestart:Y?()=>{J(Y.version)}:void 0,onRestart:!Y&&(V!=null&&V.canRestart)?()=>{H(),G()}:void 0}),a.jsx(Ise,{...o}),a.jsx(Vse,{...l}),B&&a.jsx(Rse,{onClose:()=>P(!1),onTour:()=>{P(!1),$()}}),M&&a.jsx(Z$,{title:"What the deck shows you",steps:KV,onClose:q}),K&&a.jsx(fre,{agentCount:v,onConfirm:()=>ee("confirmation"),onCancel:()=>Z(!1)})]})}const Eae=10,hL=500,fL=4e3,Cae=[/ResizeObserver loop/i,/^Script error\.?$/i];function CR(e){return String(e??"").replace(/\/(?:home|Users)\/[^/\s:'"]+/g,"~").replace(/[A-Za-z]:\\(?:Users|Documents and Settings)\\[^\\\r\n:'"]+/gi,"~").replace(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g,"<email>").replace(/\b(?:sk-ant-[A-Za-z0-9_-]{8,}|sk-[A-Za-z0-9_-]{20,}|gh[pousr]_[A-Za-z0-9]{20,}|xox[abpr]-[A-Za-z0-9-]{10,}|eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}|[A-Fa-f0-9]{40,}|[A-Za-z0-9+_=-]{48,})/g,"<secret>")}const pL=e=>{fetch("/api/client-error",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})};function Tae(e,t,n=pL){const r=String(e??"").slice(0,hL).trim();r&&n({message:r,stack:typeof t=="string"?t.slice(0,fL):void 0})}function Aae(e,t=window,n=pL){let r=0;const s=new Set,o=(d,h)=>{const f=String(d??"").slice(0,hL).trim();!e()||!f||r>=Eae||s.has(f)||Cae.some(p=>p.test(f))||(s.add(f),r++,n({message:f,stack:typeof h=="string"?h.slice(0,fL):void 0}))},l=d=>{var h,f;return o(((h=d.error)==null?void 0:h.message)??d.message,(f=d.error)==null?void 0:f.stack)},u=d=>typeof d.reason=="object"&&d.reason!==null?o(d.reason.message,d.reason.stack):o(d.reason,void 0);return t.addEventListener("error",l),t.addEventListener("unhandledrejection",u),()=>{t.removeEventListener("error",l),t.removeEventListener("unhandledrejection",u)}}const Rae=12;function Mae(e,t){const n=[CR(e).trim()||"The deck threw an error with no message."],r=t==null?void 0:t.trim();if(r){const s=r.split(`
303
+ `).slice(0,Rae).join(`
304
+ `);n.push("",CR(s).trim())}return n.join(`
305
+ `)}class $ae extends w.Component{constructor(){super(...arguments);U1(this,"state",{error:null,componentStack:null,reportOpen:!1})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,r){console.error("ccdeck hit a render error it could not draw past",n,r.componentStack),this.setState({componentStack:r.componentStack??null}),Tae(n.message,n.stack)}render(){const{error:n,componentStack:r,reportOpen:s}=this.state;return n?a.jsxs("div",{className:"error-fallback",role:"alert",children:[a.jsxs("div",{className:"error-fallback-card",children:[a.jsx("p",{className:"error-fallback-title",children:"Something went wrong"}),a.jsx("p",{className:"error-fallback-note",children:"The deck hit an error it could not draw past. Reloading usually clears it — and if it keeps happening, a report tells the people who make ccdeck what broke."}),a.jsxs("div",{className:"error-fallback-actions",children:[a.jsx("button",{type:"button",className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"}),a.jsx("button",{type:"button",className:"btn",onClick:()=>this.setState({reportOpen:!0}),"aria-haspopup":"dialog",children:"Send report"})]})]}),s&&a.jsx(aL,{initialKind:"bug",initialBody:Mae(n.message,r),onClose:()=>this.setState({reportOpen:!1})})]}):this.props.children}}const Iae=1e3;function Oae(e={}){const t=Math.max(1,Math.floor(e.limit??Iae)),n=e.protect;let r=!1,s=[],o=new Set,l=0,u=0,d=null;return{get paused(){return r},get size(){return s.length},get dropped(){return l},get overflowed(){return l>0},get through(){return u},accept(h){const f=typeof(h==null?void 0:h.seq)=="number"?h.seq:null,p=(h==null?void 0:h.epoch)??null,g=p!==null&&p!==d;g&&(d=p,u=0);const v=f!==null&&!g&&f<=u;if(f!==null&&f>u&&(u=f),!r)return!0;if(v)return!1;if(s.push(h),n!=null&&n(h)&&o.add(h),s.length>t){let k=0;if(o.size<s.length)for(;o.has(s[k]);)k++;const[b]=s.splice(k,1);o.delete(b),l++}return!1},setPaused(h){if(r=h,h)return[];const f=s;return s=[],o=new Set,l=0,f}}}function Lae(e){const t=w.useState(()=>Oae({protect:o=>UB(e.current,o)}))[0],[n,r]=w.useState(!1),s=w.useCallback(()=>{const o=t.paused&&t.dropped>0,l=t.setPaused(!t.paused);o&&wq(e.current);for(const u of l)e.current=NM(e.current,u);r(t.paused)},[t,e]);return{pauseGate:t,paused:n,togglePause:s}}const rb={kind:"assumed",claude:!0,codex:!0};function Pae(e){if(!e||typeof e!="object")return rb;const t=e.providers;if(!t||typeof t!="object")return rb;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function Dae(e){const[t,n]=w.useState(null),[r,s]=w.useState(rb);w.useEffect(()=>{let l=!1;return fetch("/api/health").then(u=>u.ok?u.json():null).then(u=>{l||(s(Pae(u)),!(!u||typeof u.workspace!="string")&&n(u.workspace))}).catch(()=>{}),()=>{l=!0}},[e]);const o=xn(r);return{workspace:t,providers:r,providersRef:o}}const mL=3*6e4,Fae=2e4;function Bae({fetchReport:e,visible:t,now:n,onReport:r}){let s=0,o=!0;const l=async()=>{if(!t())return;const u=await e();!o||!u||(s=n(),r(u))};return{tick:l,wake:async()=>{t()&&n()-s>=mL&&await l()},stop:()=>{o=!1}}}async function qae(){try{const e=await fetch("/api/provider-status",{signal:AbortSignal.timeout(Fae)});return e.ok?await e.json():null}catch{return null}}function Uae(e){const[t,n]=w.useState(null);return w.useEffect(()=>{if(!e){n(null);return}const r=Bae({fetchReport:qae,visible:()=>document.visibilityState==="visible",now:()=>Date.now(),onReport:n});r.tick();const s=window.setInterval(r.tick,mL),o=()=>{r.wake()};return document.addEventListener("visibilitychange",o),()=>{r.stop(),window.clearInterval(s),document.removeEventListener("visibilitychange",o)}},[e]),t}const zae={degraded:"degraded performance",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},Wae={degraded:"degraded",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},Hae={degraded:"degraded",partial_outage:"outage",major_outage:"outage",maintenance:"maint."},Vae={claude:"Claude",codex:"Codex"},Gae=new Set(["status.claude.com","status.openai.com"]),Kae=30*6e4,Yae=10*6e4;function Xae(e){if(typeof e!="string")return null;try{const t=new URL(e);return t.protocol==="https:"&&Gae.has(t.hostname)?t:null}catch{return null}}function TR(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}function Zae(e){const t=Math.floor(e/6e4);return t<1?"just now":t<60?`${t} min ago`:`${Math.floor(t/60)} h ago`}function Jae(e,t){if(!e||typeof e!="object")return null;const n=Ot(zae,e.state),r=Ot(Vae,e.provider);if(!n||!r||typeof e.checkedAt!="number"||t-e.checkedAt>Kae)return null;const s=Xae(e.statusPageUrl);if(!s)return null;const o=Array.isArray(e.components)?e.components:[],l=e.stale===!0||t-e.checkedAt>Yae,u=[`${r}: ${n}${e.summary?` — ${e.summary}`:""}`,o.length>0?`Affected: ${o.join(", ")}`:null,e.scope==="page"?`The page's overall status: it names none of ${r}'s components`:null,l?`Last read from ${s.hostname} at ${TR(e.checkedAt)}; this is the last thing it said`:`Reported by ${s.hostname}, checked ${Zae(t-e.checkedAt)}`,"Opens the status page"],d=l?TR(e.checkedAt):null;return{provider:e.provider,state:e.state,name:r,label:`${r} · ${n}${d?` · as of ${d}`:""}`,words:n,chipWords:Ot(Wae,e.state)??n,shortWords:Ot(Hae,e.state)??n,asOf:d,what:e.summary||(o.length>0?o.join(", "):null),href:s.href,host:s.hostname,stale:l,detail:u.filter(Boolean).join(`
306
+ `)}}function Qae(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>Jae(n,t)).filter(n=>n!==null)}function eoe(e){return e.map(t=>`${t.name}'s status page reports ${t.state.endsWith("outage")?`a ${t.words}`:t.words}.`).join(" ")}const toe="The providers' status pages report no incident.";function noe({version:e,loadVersion:t}){var h;const[n,r]=w.useState(!1),s=((h=e==null?void 0:e.upgrade)==null?void 0:h.state)??"idle",o=tre(e==null?void 0:e.upgrade),l=w.useRef(!1),u=w.useCallback(async()=>{if(ir(l.current||s==="running")){l.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await t(),l.current=!1}},[s,t]);w.useEffect(()=>{if(s!=="running")return;const f=window.setInterval(t,3e3);return()=>window.clearInterval(f)},[s,t]);const d=w.useCallback(async()=>{const f=e==null?void 0:e.command;!f||!await Wa(f)||(r(!0),window.setTimeout(()=>r(!1),1600))},[e==null?void 0:e.command]);return{upgradeState:s,upgradeFailure:o,startUpgrade:u,copyCommand:d,cmdCopied:n}}const AR="agent-dag.browserWatch.seenMs";function roe(e,t){return e.filter(n=>n.startMs>t)}function soe(){const[e,t]=w.useState(()=>Number(et(AR))||0),[n,r]=w.useState([]),[s,o]=w.useState(!1);w.useEffect(()=>{let d=!0;const h=()=>{fetch("/api/browser-watch?live=0").then(p=>p.ok?p.json():null).then(p=>{var g;!d||!(p!=null&&p.ok)||(r(p.episodes??[]),o(((g=p.settings)==null?void 0:g.enabled)===!0))}).catch(()=>{})};h();const f=setInterval(h,5*6e4);return()=>{d=!1,clearInterval(f)}},[]);const l=w.useMemo(()=>roe(n,e).length,[n,e]),u=w.useCallback(d=>{t(d),Xe(AR,String(d))},[]);return{watchOn:s,setWatchOn:o,watchUnseen:l,markWatchSeen:u}}const gL=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function RR(e){const t={};for(const n of gL)t[n]=e(n);return t}function aoe(e){return t=>e[t]??""}function ooe(e,t){return gL.every(n=>e[n]===t[n])}const yL="agent-dag.theme";function ioe(e,t=!1){return e==="light"||e==="dark"?e:t?"light":"dark"}function loe(){try{return window.matchMedia("(prefers-color-scheme: light)").matches}catch{return!1}}function coe(){return ioe(et(yL),loe())}function MR(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function uoe(){const[e,t]=w.useState(coe),[n,r]=w.useState(Xte),[s,o]=w.useState(()=>RR(MR)),l=w.useMemo(()=>aoe(s),[s]),u=w.useCallback(d=>ete(d,l),[l]);return w.useEffect(()=>{document.documentElement.dataset.theme=e,Xe(yL,e),o(d=>{const h=RR(MR);return ooe(d,h)?d:h})},[e]),w.useEffect(()=>{Xe(VO,n?"1":"0")},[n]),w.useEffect(()=>{const d=document.querySelector('meta[name="theme-color"]'),h=s["--panel"];d&&h&&d.setAttribute("content",h)},[s]),{theme:e,setTheme:t,characterEnabled:n,setCharacterEnabled:r,palette:s,minimapNodeFill:u}}function doe(e){const t=w.useRef(null),[n,r]=w.useState(!1),[s,o]=w.useState(()=>new Set),l=w.useMemo(()=>{const d=new Set;for(const h of e.current.agents.values())for(const f of h.tools)d.add(WO(f.name));return Object.keys(zO).filter(h=>d.has(h))},[e.current,e.current.revision]);w.useEffect(()=>{if(l.length<=1){r(!1);return}let d=0;const h=()=>{const f=t.current;if(f&&!document.hidden){const p=f.getBoundingClientRect(),g=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(k=>k.getBoundingClientRect()),v=Wee(p,g,8);r(k=>k===v?k:v)}d=window.setTimeout(h,300)};return h(),()=>window.clearTimeout(d)},[l.length]);const u=w.useCallback(d=>{o(h=>{const f=new Set(h);return f.has(d)?f.delete(d):f.add(d),f})},[]);return{presentCats:l,hiddenCats:s,toggleCat:u,catBarRef:t,catBarOccluded:n}}function hoe(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null;const r=()=>e.enabled()?(n==null?void 0:n.state)==="running"?"ready":"locked":"off",s=()=>{var f;return(f=e.onState)==null?void 0:f.call(e,r())};function o(){var f,p;if(!(!t||(n==null?void 0:n.state)==="running"))try{n||(n=new t,(f=n.addEventListener)==null||f.call(n,"statechange",s)),(p=n.resume)==null||p.call(n).then(s,()=>{}),s()}catch{}}function l(f,p,g=p.figure){if(!n||n.state!=="running")return!1;const v=zx(f,g),k=tX(p.level,v),b=n.currentTime;for(const x of v.notes){const N=n.createOscillator(),S=n.createGain();N.type=v.type??"sine",N.frequency.value=x.hz;const _=b+x.at,E=_+x.ms/1e3;S.gain.setValueAtTime(RS,_),S.gain.exponentialRampToValueAtTime(k,_+nX),S.gain.exponentialRampToValueAtTime(RS,E),N.connect(S).connect(n.destination),N.start(_),N.stop(E+.02)}return!0}async function u(f,p){if(!e.loadCustom)return"unavailable";let g;try{g=await e.loadCustom(f)}catch{return"unavailable"}if(!g)return"missing";if(g.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const k=new SpeechSynthesisUtterance(g.text),b=window.speechSynthesis.getVoices();k.voice=b.find(x=>x.voiceURI===g.voiceURI)??null,k.rate=g.rate,k.pitch=g.pitch,k.volume=rX(p.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(k),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let v;try{v=await n.decodeAudioData(g.bytes.slice(0))}catch{return"broken"}try{const k=n.createBufferSource(),b=n.createGain();return k.buffer=v,b.gain.setValueAtTime(sX(g.normalizationGain,p.level),n.currentTime),k.connect(b).connect(n.destination),k.start(n.currentTime),"played"}catch{return"unavailable"}}function d(f,p=!1){var k,b;if(!p&&!e.enabled())return!1;const g=dX((k=e.prefs)==null?void 0:k.call(e),f),v=((b=e.customSelection)==null?void 0:b.call(e)[f])??null;return v&&e.loadCustom?(u(v,g).then(x=>{var N;x==="played"||x==="locked"||((x==="missing"||x==="broken")&&((N=e.onCustomFailure)==null||N.call(e,f,v)),l(f,{...g,figure:vn},vn))}),!0):!n||n.state!=="running"?!1:l(f,g)}function h(f,p=qa){return u(f,{level:hi(p),figure:vn}),!0}return{unlock:o,play:d,previewCustom:h,state:r,get context(){return n}}}function foe({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:r,fallbackCustomRef:s}){const[o,l]=w.useState("locked");return w.useEffect(()=>{const u=hoe({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>r.current,loadCustom:XY,onCustomFailure:(p,g)=>s.current(p,g),onState:l});e.current=u,l(u.state());const d=["pointerdown","pointerup","keydown"],h=()=>{for(const p of d)window.removeEventListener(p,f,{capture:!0})},f=()=>{var p;u.unlock(),((p=u.context)==null?void 0:p.state)==="running"&&h()};for(const p of d)window.addEventListener(p,f,{capture:!0});return h},[]),{chimeState:o}}function poe(){const[e,t]=w.useState(Jte),[n,r]=w.useState(()=>fB(et(HN))),[s,o]=w.useState(()=>hB(et(VN))),[l,u]=w.useState(()=>pB(et(aR),n,Kte)),[d,h]=w.useState(()=>new Set),[f,p]=w.useState(0);w.useEffect(()=>{Xe(GO,String(e))},[e]),w.useEffect(()=>{Xe(VN,s?"1":"0")},[s]),w.useEffect(()=>{Xe(HN,JSON.stringify(n))},[n]),w.useEffect(()=>{Xe(aR,l)},[l]);const g=w.useCallback(N=>{r(S=>S.some(_=>_.id===N.id)?S:[...S,N]),h(S=>{if(!S.has(N.id))return S;const _=new Set(S);return _.delete(N.id),_})},[]),v=w.useCallback((N,S)=>{const _=S.trim();!_||_.length>Ll||r(E=>E.map(T=>T.id===N?{...T,name:_}:T))},[]),k=w.useCallback(N=>{r(S=>S.filter(_=>_.id!==N)),u(S=>mB(S,N)),h(S=>{if(!S.has(N))return S;const _=new Set(S);return _.delete(N),_})},[]),b=w.useCallback(N=>{const S=GN(N),_=d.has(S);N===l&&!_||(_&&h(E=>{const T=new Set(E);return T.delete(S),T}),u(N),p(E=>E+1))},[l,d]),x=w.useCallback((N,S)=>{const _=GN(N);h(E=>{if(E.has(_)===S)return E;const A=new Set(E);return S?A.add(_):A.delete(_),A})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:s,setFmMuted:o,fmSource:l,customFmStations:n,unavailableFmStations:d,fmPlayRequest:f,addFmStation:g,renameFmStation:v,removeFmStation:k,pickFmSource:b,markFmStationAvailability:x}}function moe(e){const[t,n]=w.useState(null),[r,s]=w.useState(!1),[o,l]=w.useState(null),u=w.useRef(0);w.useEffect(()=>{if(!e||!Yl())return;let k=!1;const b=u.current;return fetch("/api/desktop-update").then(x=>x.ok?x.json():null).then(x=>{if(k||u.current!==b)return;const N=hR(x);N&&n(N)}).catch(()=>{}),()=>{k=!0}},[e]);const d=Ene(t),h=w.useRef(!1),f=w.useRef(0),p=w.useRef(0);w.useEffect(()=>()=>window.clearTimeout(f.current),[]);const g=w.useCallback(async k=>{if(!ir(h.current))return;const b=++p.current;window.clearTimeout(f.current),h.current=!0,s(!0),l(null);const x=N=>{b===p.current&&(window.clearTimeout(f.current),h.current=!1,s(!1),l({failure:N,version:k}))};try{const N=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:k})});if(!N.ok)return x(Rne(await N.json().catch(()=>null)))}catch{return x("unreachable")}b===p.current&&(f.current=window.setTimeout(()=>x("timeout"),KO))},[]),v=w.useCallback(k=>{if(Yl())try{const b=hR(JSON.parse(k));b&&(u.current++,n(b),b.status!=="ready"&&(p.current++,window.clearTimeout(f.current),h.current=!1,s(!1)))}catch{}},[]);return{desktopUpdateRestarting:r,desktopUpdateFailure:o,readyAppUpdate:d,askDesktopUpdateRestart:g,onDesktopUpdateEvent:v}}const $u="agent-dag.autoRestart",$R="agent-dag.bundleReloadedFor";function goe({now:e,stateRef:t,version:n,notice:r,noticeOpen:s,upgradeFailure:o,paused:l}){const[u,d]=w.useState(()=>et($u)!=="0"),h=w.useRef(!1),f=w.useCallback(()=>{const D=!u;h.current=!0,cs($u),d(D),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:D})}).then(O=>O.ok?O.json():null).then(O=>{var L;O!=null&&O.ok&&d(((L=O.prefs)==null?void 0:L.autoUpdate)!==!1)}).catch(()=>{})},[u]),[p,g]=w.useState(!1),[v,k]=w.useState("restart"),[b,x]=w.useState(null),N=w.useRef(!1),S=w.useRef(null),_=w.useRef(0),E=w.useRef(null),T=w.useCallback(async D=>{if(!ir(N.current))return;const O=(D==null?void 0:D.upgrade)===!0,L=(D==null?void 0:D.whenIdle)===!0;N.current=!0,S.current=o;const z=++_.current,M=()=>{k(O?"npx":"restart"),g(!0)};L||M();try{window.sessionStorage.setItem("agent-dag.restartPending",(r==null?void 0:r.to)??"")}catch{}let $=!1;try{const q=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(L?{upgrade:O,whenIdle:L}:{upgrade:O})});$=L&&q.status===409}catch{}if($){N.current=!1,E.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}L&&M(),window.setTimeout(()=>{if(_.current===z&&N.current){N.current=!1,g(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},O?18e4:3e4)},[r==null?void 0:r.to,o]);w.useEffect(()=>{const D=fR(t.current.agents.values())>0,O=ore({enabled:u,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:D,idleSince:E.current,now:e});E.current=O.idleSince,O.restart&&T({whenIdle:!0})},[u,r==null?void 0:r.kind,n==null?void 0:n.canRestart,s,e,T]);const A=fR(t.current.agents.values()),R=are(A,l),B=XO({enabled:u,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:A>0,idleSince:E.current,now:e});w.useEffect(()=>{const D=n==null?void 0:n.running;let O=null,L=null;try{O=window.sessionStorage.getItem("agent-dag.restartPending"),L=window.sessionStorage.getItem($R)}catch{return}const z=ere({bundle:"3.36.3",running:D,pending:O,lastTried:L});if(z==="reload"){try{window.sessionStorage.setItem($R,D??"")}catch{return}window.location.reload();return}if(z!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}N.current=!1,g(!1),x(D??null);const M=window.setTimeout(()=>x(null),6e3);return()=>window.clearTimeout(M)},[n==null?void 0:n.running]),w.useEffect(()=>{if(p&&nre({asked:S.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}N.current=!1,g(!1)}},[p,o]);const P=w.useCallback(D=>{var O,L;if(!h.current){const z=et($u)==="0";cs($u),z&&((O=D.prefs)==null?void 0:O.autoUpdate)!==!1?(d(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):d(((L=D.prefs)==null?void 0:L.autoUpdate)!==!1)}},[]);return{autoRestart:u,toggleAutoRestart:f,restarting:p,restartMode:v,restartedTo:b,askRestart:T,restartCopy:R,restartFuseMs:B,loadAutoRestartPrefs:P}}function yoe(){const[e,t]=w.useState([]),n=w.useRef(new Set),[r,s]=w.useState(null),[o,l]=w.useState(void 0);w.useEffect(()=>{let h=!0,f=0;const p=()=>{fetch("/api/lan").then(g=>g.ok?g.json():null).then(g=>h?(g!=null&&g.ok&&t(sS(Array.isArray(g.pending)?g.pending:[],g.aliases)),g):null).catch(()=>null).then(g=>{h&&(l(v=>g!=null&&g.ok?g:v===void 0?null:v),f=window.setTimeout(p,(g==null?void 0:g.enabled)===!0?Lx:X$))})};return p(),()=>{h=!1,window.clearTimeout(f)}},[]);const u=w.useCallback(async(h,f)=>{if(!r){s(h);try{const g=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:h,fp:f})})).json().catch(()=>null);g&&Array.isArray(g.pending)?t(sS(g.pending,g.aliases)):t(v=>v.filter(k=>k.fp!==f))}catch{}finally{s(null)}}},[r]),d=w.useCallback(h=>{r||(n.current.add(h),t(f=>[...f]))},[r]);return{lanPending:e,lanDeferred:n,lanBusy:r,answerLanPair:u,deferLanPair:d,lanStatus:o}}const woe=6e4;function voe({enabled:e,lanStatus:t,now:n}){const[r,s]=w.useState(null),[o,l]=w.useState(()=>new Set),[u,d]=w.useState(null),h=w.useCallback(N=>{N!=null&&N.ok&&Array.isArray(N.accounts)&&s(N.accounts)},[]),f=w.useCallback(async N=>{try{const S=await fetch(`/api/claude-accounts${N?"?refresh=1":""}`);S.ok&&h(await S.json())}catch{}},[h]);w.useEffect(()=>{e&&f(!1)},[e,f]),w.useEffect(()=>{if(!e)return;let N=Date.now();const S=()=>{document.visibilityState!=="visible"||Date.now()-N<woe||(N=Date.now(),f(!1))};return document.addEventListener("visibilitychange",S),window.addEventListener("focus",S),()=>{document.removeEventListener("visibilitychange",S),window.removeEventListener("focus",S)}},[e,f]);const p=w.useMemo(()=>e?Lse(r,{lan:t,now:n,closed:o}):[],[e,r,t,n,o]),g=w.useRef(p);g.current=p;const v=w.useCallback(N=>{N.length&&l(S=>new Set([...S,...N]))},[]),k=w.useCallback(()=>{const N=g.current;N.length&&(v(N.map(S=>S.id)),fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reauth-later",incidents:N.map(S=>({key:S.key,since:S.since}))})}).catch(()=>{}))},[v]),b=w.useRef(u);b.current=u;const x=w.useCallback(N=>{const S=b.current;v(Pse(S?[S,...g.current]:g.current,N))},[v]);return{rows:p,signingIn:u,observe:h,signIn:d,signedIn:x,refresh:w.useCallback(()=>{f(!0)},[f]),closeSignIn:w.useCallback(()=>d(null),[]),later:k}}const wL="agent-dag.sessionListOpen",vL="agent-dag.accountsPanelOpen";function xoe(){return et(wL)==="1"}function boe(e){Xe(wL,e?"1":"0")}function koe(){const e=et(vL);return e===null?!0:e==="1"}function Noe(){const[e,t]=w.useState(xoe);w.useEffect(()=>{boe(e)},[e]);const n=w.useRef(!1),[r,s]=w.useState(()=>{const h=koe();return h&&e?(n.current=!0,!1):h});w.useEffect(()=>{!r&&n.current||Xe(vL,r?"1":"0")},[r]),w.useEffect(()=>{!e&&n.current&&(n.current=!1,s(!0))},[e]);const o=w.useCallback(()=>{t(h=>(h||s(f=>(f&&(n.current=!0),!1)),!h))},[]),l=w.useCallback(()=>{n.current=!1,s(h=>(h||t(!1),!h))},[]),u=w.useCallback(()=>t(!1),[]),d=w.useCallback(()=>s(!1),[]);return{sessionListOpen:e,accountsPanelOpen:r,toggleSessionList:o,toggleAccountsPanel:l,closeSessionList:u,closeAccountsPanel:d}}const xL="agent-dag.detailOpen",bL="agent-dag.usagePanelOpen",kL="agent-dag.systemPanelOpen";function joe(){return et(xL)==="1"}function Soe(e){Xe(xL,e?"1":"0")}function _oe(){const e=et(bL);return e===null?!0:e==="1"}function Eoe(e){Xe(bL,e?"1":"0")}function Coe(){const e=et(kL);return e===null?!0:e==="1"}function Toe(e){Xe(kL,e?"1":"0")}function Aoe(){const[e,t]=w.useState(joe);w.useEffect(()=>{Soe(e)},[e]);const[n,r]=w.useState(_oe);w.useEffect(()=>{Eoe(n)},[n]);const[s,o]=w.useState(Coe);return w.useEffect(()=>{Toe(s)},[s]),{detailOpen:e,setDetailOpen:t,usagePanelOpen:n,setUsagePanelOpen:r,machinePanelOpen:s,setMachinePanelOpen:o}}const Roe={permission:"your permission",asked:"your answer"},Moe="No sessions are waiting for you.";function $oe(e){if(e.length===0)return"";const[t,...n]=e,r=t.waiting.kind,s=n.every(l=>l.waiting.kind===r)?Roe[r]??"you":"you";if(n.length===0)return`${t.label} is waiting for ${s}.`;const o=`${n.length} more session${n.length===1?"":"s"}`;return`${t.label} and ${o} are waiting for ${s}.`}function Gv(e,t,n=Moe){return t!==""?t:e===""?"":n}function Ioe({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[r,s]=w.useState(""),o=$oe(e);w.useEffect(()=>{s(g=>Gv(g,o))},[o]);const[l,u]=w.useState(""),d=t>0?`Browser watch has ${t} unread ${t===1?"finding":"findings"}.`:"";w.useEffect(()=>{u(g=>Gv(g,d,"Browser watch has no unread findings."))},[d]);const[h,f]=w.useState(""),p=eoe(n);return w.useEffect(()=>{f(g=>Gv(g,p,toe))},[p]),{blockedSaid:r,watchSaid:l,setWatchSaid:u,incidentSaid:h}}const Ooe="/icon-192.png";function Loe({waitingSessions:e,liveSince:t,focusSession:n}){const[r,s]=w.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[o,l]=w.useState(null),[u,d]=w.useState(!1),[h,f]=w.useState(!1),p=w.useRef(()=>{}),g=w.useRef(new Set),v=xn(e),k=w.useCallback(()=>{const T=!u;d(T),T&&(g.current=vu(v.current)),T&&typeof Notification<"u"&&Notification.permission==="default"&&p.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:T})}).then(A=>A.ok?A.json():null).then(A=>{var R;A!=null&&A.ok&&(d(((R=A.prefs)==null?void 0:R.notifications)===!0),f(A.notificationsVetoed===!0))}).catch(()=>{})},[u]),b=typeof Notification<"u";w.useEffect(()=>{if(!o)return;const A=setTimeout(()=>l(null),o==="blocked"?8e3:4e3);return()=>clearTimeout(A)},[o]);const x=w.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(T=>{const A=T;s(A),A==="granted"?l("on"):A==="denied"&&l("blocked")})},[]);p.current=x;const N=w.useRef(null),S=e.map(T=>Id(T.id,T.waiting)).join("|");w.useEffect(()=>{Dq(N.current,r)&&(N.current=r,g.current=vu(e))},[r]);const _=w.useRef(!1);w.useEffect(()=>{Fq(_.current,t)&&(_.current=!0,g.current=vu(e))},[t]),w.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!Bq(N.current,t))return;const T=typeof document>"u"||!document.hidden,A=Lq(e,g.current,T,u);for(const R of A)try{const B=new Notification(R.title,{body:R.body,tag:R.key,icon:Ooe});B.onclick=()=>{window.focus(),n(R.sessionId),B.close()}}catch{}g.current=T?vu(e):Pq(e,A,g.current)},[S,t]);const E=w.useCallback(T=>{var A;d(((A=T.prefs)==null?void 0:A.notifications)===!0),f(T.notificationsVetoed===!0)},[]);return{notifyPermission:r,notifySaid:o,notifyOn:u,notifyVetoed:h,toggleNotify:k,notifySupported:b,askForNotifications:x,loadNotifyPrefs:E}}function Poe({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:r,summaryFor:s,browserWatchOpen:o,keyHelpOpen:l,releaseNotes:u,feedbackOpen:d}){const h=xn(l),f=w.useRef(!1);return f.current=e!=null||t||n!=null||r||s!=null||o||l||u!=null||d,{keyHelpOpenRef:h,modalOpenRef:f}}function Doe({stateRef:e,tourOpen:t,releaseNotes:n}){const[r,s]=w.useState(null),o=w.useCallback((D,O)=>s({agentId:D,toolId:O}),[]),[l,u]=w.useState(null),[d,h]=w.useState(null),f=w.useCallback(D=>h(D),[]),[p,g]=w.useState(!1),[v,k]=w.useState(!1),[b,x]=w.useState(!1),[N,S]=w.useState(!1),[_,E]=w.useState(null),T=w.useCallback(D=>{E(D??null),S(!0)},[]),A=r?PB(e.current.agents,r.agentId,r.toolId):null,R=d?e.current.agents.get(d):void 0,{keyHelpOpenRef:B,modalOpenRef:P}=Poe({openedTool:A,usageHistoryOpen:v,contextFor:d,tourOpen:t,summaryFor:l,browserWatchOpen:b,keyHelpOpen:p,releaseNotes:n,feedbackOpen:N});return{setOpenedToolKey:s,openTool:o,openedTool:A,summaryFor:l,setSummaryFor:u,contextFor:d,setContextFor:h,openContext:f,contextAgent:R,keyHelpOpen:p,setKeyHelpOpen:g,usageHistoryOpen:v,setUsageHistoryOpen:k,browserWatchOpen:b,setBrowserWatchOpen:x,feedbackOpen:N,setFeedbackOpen:S,feedbackPrefill:_,setFeedbackPrefill:E,openFeedback:T,keyHelpOpenRef:B,modalOpenRef:P}}function Foe({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:r,lastLayoutSigRef:s,forgetRemovals:o,clearSelection:l,rerender:u,modalOpenRef:d}){const[h,f]=w.useState(!1),p=w.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}e.current=Sb(),t.current.clear(),n.current.clear(),r.current.clear(),s.current="",BO(),o(),l(),u()},[u,l,o]),g=xn(h),v=w.useCallback(k=>{const b=cre(k,{confirmOpen:g.current,modalOpen:d.current});b==="confirm"?f(!0):b==="clear"&&(f(!1),p())},[p]);return{clearConfirmOpen:h,setClearConfirmOpen:f,requestClear:v}}const IR="agent-dag.oldNameNoticeDismissed";function Boe(e){const[t,n]=w.useState(()=>et(IR)??""),r=e!=null&&e.invokedAs&&e.invokedAs!==bt?e.invokedAs:null,s=r!=null&&t!==r,o=w.useCallback(()=>{r&&(n(r),Xe(IR,r))},[r]);return{oldName:r,oldNameOpen:s,dismissOldName:o}}function qoe({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:r}){const[s,o]=w.useState(()=>DY(et)),l=xn(s),[u,d]=w.useState([]),h=w.useCallback(S=>{o(_=>{const E={..._,[S]:null};return l.current=E,E}),cs(El[S])},[]),f=w.useCallback((S,_)=>{const E=l.current[S];_&&E!==_||(h(S),t(T=>{const A={...T,[S]:{...T[S],figure:vn}};return n.current=A,A}),Xe(yd[S],vn))},[h]),p=xn(f);w.useEffect(()=>{let S=!0;return YY().then(_=>{if(!S)return;d(_);const E=new Set(_.map(T=>T.id));for(const T of zu){const A=l.current[T];A&&!E.has(A)&&p.current(T,A)}},()=>{}),()=>{S=!1}},[]);const g=w.useCallback((S,_)=>{if(!u.some(T=>T.id===_))return;const E={...l.current,[S]:_};l.current=E,o(E),Xe(El[S],_),r(S,!0)},[u,r]),v=w.useCallback(async S=>{var A;const _=Ux(u.length);if(_)throw new Error(_);const E=window.AudioContext??window.webkitAudioContext;if(!E)throw new Error("This browser cannot decode audio files.");const T=new E;try{const R=await WY(S,P=>T.decodeAudioData(P));await TS(R);const B=Vl(R);d(P=>[...P.filter(D=>D.id!==B.id),B])}finally{(A=T.close)==null||A.call(T)}},[u.length]),k=w.useCallback(async S=>{const _=Ux(u.length);if(_)throw new Error(_);const E=HY(S);await TS(E);const T=Vl(E);d(A=>[...A.filter(R=>R.id!==T.id),T])},[u.length]),b=w.useCallback(async(S,_)=>{const E=u.find(A=>A.id===S),T=_.trim().slice(0,80);!E||!T||T===E.name||(await ZY(S,T),d(A=>A.map(R=>R.id===S?{...R,name:T}:R)))},[u]),x=w.useCallback(async S=>{await JY(S),d(A=>A.filter(R=>R.id!==S));const _=l.current,E=FY(_,S);l.current=E,o(E);const T=zu.filter(A=>_[A]===S);for(const A of T)cs(El[A]),Xe(yd[A],vn);T.length>0&&t(A=>{const R={...A};for(const B of T)R[B]={...R[B],figure:vn};return n.current=R,R})},[]),N=w.useCallback(S=>{var T,A;const _=zu.find(R=>l.current[R]===S),E=_?n.current[_].level:qa;(T=e.current)==null||T.unlock(),(A=e.current)==null||A.previewCustom(S,E)},[]);return{customSelections:s,customSelectionsRef:l,customAssets:u,clearCustomOnly:h,fallbackCustomRef:p,selectCustomTone:g,importNotificationAudio:v,createNotificationVoice:k,renameCustomAsset:b,deleteCustomAsset:x,previewCustomAsset:N}}function Uoe(e){const[t,n]=w.useState(()=>uX(et)),r=xn(t),s=w.useRef(null),o=w.useCallback((u,d=!1)=>{var h,f;if((h=e.current)==null||h.unlock(),s.current!==null&&clearTimeout(s.current),s.current=null,!d){(f=e.current)==null||f.play(u,!0);return}s.current=setTimeout(()=>{var p;s.current=null,(p=e.current)==null||p.play(u,!0)},aX)},[]),l=w.useCallback((u,d)=>{n(h=>{const f={level:hi(d.level??h[u].level),figure:jI(u,d.figure??h[u].figure)};return Xe(EI[u],String(f.level)),Xe(yd[u],f.figure),{...h,[u]:f}}),o(u,!0)},[o]);return w.useEffect(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]),{tonePrefs:t,setTonePrefs:n,tonePrefsRef:r,previewTone:o,changeTone:l}}const zoe=15e3;function Woe(e){return e.visibilityState==="visible"&&e.hasFocus()}function Hoe(e,t){return t||e===!0}function Voe(){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 Goe(){w.useEffect(()=>{const e=Voe();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=Woe(document);Hoe(t,l)&&n(l),t=l},s=()=>{t&&n(!1),t=!1};r();const o=window.setInterval(r,zoe);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 Koe({loadAutoRestartPrefs:e,loadNotifyPrefs:t,loadReportsPrefs:n}){w.useEffect(()=>{let r=!0;return fetch("/api/prefs").then(s=>s.ok?s.json():null).then(s=>{!r||!(s!=null&&s.ok)||(e(s),t(s),n(s))}).catch(()=>{}),()=>{r=!1}},[])}const Kv="agent-dag.versionNoticeDismissed",Yoe=15*6e4;function Xoe(e){const[t,n]=w.useState(null),[r,s]=w.useState(()=>et(Kv)??""),o=w.useRef(0),[l,u]=w.useState(!1),d=w.useCallback((b=!1)=>(b&&(o.current=Date.now(),u(!0)),fetch(b?"/api/version?refresh=1":"/api/version").then(x=>x.ok?x.json():null).then(x=>{x&&n(x)}).catch(()=>{}).finally(()=>{b&&u(!1)})),[]),h=w.useCallback(()=>{d(Date.now()-o.current>=Yoe)},[d]);w.useEffect(()=>{d();const b=window.setInterval(h,5*6e4),x=()=>{document.visibilityState==="visible"&&h()};return document.addEventListener("visibilitychange",x),()=>{window.clearInterval(b),document.removeEventListener("visibilitychange",x)}},[d,h]),w.useEffect(()=>{e&&d()},[e,d]);const f=(t==null?void 0:t.notice)??null,p=YO(f),g=Pne(f,r),v=w.useCallback(()=>{s(""),Xe(Kv,"")},[]),k=w.useCallback(()=>{f&&(s(p),Xe(Kv,p))},[f,p]);return{version:t,notice:f,noticeOpen:g,showNotice:v,dismissNotice:k,versionChecking:l,loadVersion:d}}function Zoe({version:e,readyAppUpdate:t}){const[n,r]=w.useState(!1),s=w.useRef(null),[o,l]=w.useState(null),u=o&&t?t.version:null,d=w.useRef(null);w.useEffect(()=>{!u||d.current===u||(d.current=u,fetch("/api/desktop-update/seen",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:u})}).catch(()=>{}))},[u]);const h=w.useRef(!1);w.useEffect(()=>{if(h.current)return;const x=Sl(),N=tae(x),S=iae({stored:N,running:(e==null?void 0:e.running)??null,notes:NR,remembers:nae(x)});if(S.reason==="no-version")return;h.current=!0,S.record&&rae(x,S.record);let _=!0;return(async()=>{var B;let T=sae(x);if(Yl())try{const P=await fetch("/api/prefs");if(!P.ok)throw new Error("desktop tour preferences unavailable");const D=await P.json();if(!(D!=null&&D.ok))throw new Error("desktop tour preferences unavailable");const O=((B=D.prefs)==null?void 0:B.tourSeen)===!0;T&&!O&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{}),T=T||O}catch{T=!0}if(!_)return;const A=oae({tourSeen:T,decision:S}),R=S.show.length?{entries:S.show,since:N,firstRun:!1}:null;A.tour&&r(!0),A.notes==="now"?l(R):A.notes==="after"&&(s.current=R)})(),()=>{_=!1}},[e==null?void 0:e.running]);const f=(e==null?void 0:e.running)??"3.36.3",p=w.useMemo(()=>oL(NR,null,f),[f]),g=w.useCallback(()=>{l({entries:p,since:null,firstRun:!1})},[p]),v=w.useCallback(()=>r(!0),[]),k=w.useCallback(()=>l(null),[]),b=w.useCallback(()=>{r(!1),aae(Sl()),Yl()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const x=s.current;s.current=null,x&&l(x)},[]);return{tourOpen:n,openTour:v,closeTour:b,releaseNotes:o,closeReleaseNotes:k,chipVersion:f,openReleaseNotes:g}}function Joe(){const[e,t]=w.useState(void 0),[n,r]=w.useState(!1),s=w.useRef(!1);s.current=e===!0&&!n,w.useEffect(()=>Aae(()=>s.current),[]);const o=w.useCallback(u=>{var d;t(((d=u.prefs)==null?void 0:d.reports)!==!1),r(u.reportsVetoed===!0)},[]),l=w.useCallback(async u=>{t(u);try{const h=await(await fetch("/api/reports",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({on:u})})).json();h!=null&&h.ok&&(t(h.reports!==!1),r(h.reportsVetoed===!0))}catch{}},[]);return{reportsOn:e,reportsVetoed:n,loadReportsPrefs:o,answerReports:l}}function Qoe(){const[e,t]=w.useState(null),[n,r]=w.useState(!1),s=w.useRef(null);return w.useEffect(()=>{let o=!0,l=!1,u=null,d=null,h="";const f=b=>{o&&(r(!0),b!==h&&t(null))},p=()=>{if(l)return;l=!0,u=Date.now();const b=uR();d=b,fetch(`/api/ccusage?since=${b}`).then(x=>x.ok?x.json():null).then(x=>{if(o){if(!(x!=null&&x.ok)){f(b);return}h=b,t(Sne(x)),r(!1)}}).catch(()=>f(b)).finally(()=>{l=!1})},g=()=>{const b=s.current;jne({shown:!!b&&b.getClientRects().length>0,tabVisible:document.visibilityState==="visible",lastSince:d,since:uR(),lastReadAt:u,now:Date.now()})&&p()};g();const v=window.setInterval(g,Nne);document.addEventListener("visibilitychange",g);let k=null;return s.current&&typeof ResizeObserver<"u"&&(k=new ResizeObserver(g),k.observe(s.current)),()=>{o=!1,window.clearInterval(v),document.removeEventListener("visibilitychange",g),k==null||k.disconnect()}},[]),{monthlyUsage:e,monthlyUsageUnavailable:n,monthUsageRef:s}}function eie(e){const[t,n]=w.useState(null);w.useEffect(()=>{const u=et("agent-dag.sound");n(u===null?!0:u==="on")},[]);const r=w.useCallback(()=>{n(u=>{var h;const d=u!==!0;return Xe("agent-dag.sound",d?"on":"off"),d&&((h=e.current)==null||h.unlock()),d})},[]),s=w.useCallback(u=>{r()},[r]),o=xn(s),l=xn(t);return{soundOn:t,toggleSound:r,activateSoundRef:o,soundOnRef:l}}function tie(){const[e,t]=w.useState(!1),n=w.useRef(null),[r,s]=w.useState(!1),o=w.useRef(null);return w.useEffect(()=>{e&&s(!1)},[e]),{soundMenuOpen:e,setSoundMenuOpen:t,soundButtonRef:n,appearanceMenuOpen:r,setAppearanceMenuOpen:s,appearanceButtonRef:o}}const nie="agent-dag.autoFitDisabled";function rie(e){const t=w.useRef(!1),[n,r]=w.useState(!1);w.useEffect(()=>{cs(nie)},[]);const s=w.useCallback(()=>{t.current||(t.current=!0,r(!0))},[]),o=w.useCallback(()=>{t.current=!1,r(!1),e(400)},[e]);return{autoFitDisabled:n,autoFitDisabledRef:t,disableAutoFit:s,enableAutoFitAndRefit:o}}function sie(){return a.jsx(kb,{children:a.jsx($ae,{children:a.jsx(aie,{})})})}function aie(){const e=mi(),t=w.useState(Sb)[0],n=w.useRef(t),[,r]=w.useState(0),s=w.useCallback(()=>r(Sr=>Sr+1),[]),{detailOpen:o,setDetailOpen:l,usagePanelOpen:u,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f}=Aoe(),{selectedIds:p,primarySelectedId:g,selectAgent:v,clearSelection:k,pruneSelectionToBoard:b}=CX(n,l),{sessionListOpen:x,accountsPanelOpen:N,toggleSessionList:S,toggleAccountsPanel:_,closeSessionList:E,closeAccountsPanel:T}=Noe(),A=Qoe(),R=Fu(N,200),B=Fu(u,130),P=Fu(h,130),D=w.useRef(null),O=eie(D),{activateSoundRef:L,soundOnRef:z}=O,M=Uoe(D),{setTonePrefs:$,tonePrefsRef:q,previewTone:X}=M,H=qoe({chimesRef:D,setTonePrefs:$,tonePrefsRef:q,previewTone:X}),{customSelectionsRef:I,fallbackCustomRef:W}=H,F=tie(),{setSoundMenuOpen:Y}=F,{chimeState:J}=foe({chimesRef:D,soundOnRef:z,tonePrefsRef:q,customSelectionsRef:I,fallbackCustomRef:W}),V=Lae(n),{pauseGate:G,paused:K,togglePause:Z}=V,ee=w.useRef(()=>{}),{live:re,tabCapped:ue,everConnected:me,liveSince:ae}=wX({stateRef:n,rerender:s,pauseGate:G,chimesRef:D,desktopUpdateRef:ee}),pe=Xoe(re),{version:xe,notice:se,noticeOpen:ve,loadVersion:fe}=pe,he=moe(re),{readyAppUpdate:_e,onDesktopUpdateEvent:Fe}=he;ee.current=Fe,Goe();const Le=Zoe({version:xe,readyAppUpdate:_e}),{tourOpen:Ve,openTour:le,releaseNotes:je}=Le,{workspace:$e,providers:Oe,providersRef:ze}=Dae(re),nt=Boe(xe),it=noe({version:xe,loadVersion:fe}),{upgradeFailure:At}=it,Ue=Doe({stateRef:n,tourOpen:Ve,releaseNotes:je}),{openTool:Ze,setSummaryFor:Je,setContextFor:rt,openContext:gt,setKeyHelpOpen:Rt,setUsageHistoryOpen:yt,setBrowserWatchOpen:lt,keyHelpOpenRef:Qt,modalOpenRef:Pt}=Ue,Dt=Joe(),Ft=soe(),{watchOn:Kt,watchUnseen:qr}=Ft,Un=yoe(),[Ur,zr]=w.useState(0),{presentCats:zn,hiddenCats:mr,toggleCat:Wn,catBarRef:Wr,catBarOccluded:kn}=doe(n),ms=w.useRef(null),[Nn,gr]=w.useState(0),vt=TX({stateRef:n,rerender:s,pruneSelectionToBoard:b,setContextFor:rt,setSummaryFor:Je}),yr=Uae(Oe.claude||Oe.codex),wr=Qae(yr,vt),Hr=voe({enabled:Oe.claude,lanStatus:Un.lanStatus,now:vt}),Hn=goe({now:vt,stateRef:n,version:xe,notice:se,noticeOpen:ve,upgradeFailure:At,paused:V.paused}),{askRestart:fn,loadAutoRestartPrefs:Vr}=Hn,jn=uoe(),{setTheme:we,palette:Be}=jn,We=poe(),en=_ee(),{applyViewport:gs,moveCamera:vr,fitLeft:Vn,cameraEpochRef:Qe,lastFitTimeRef:xr}=en,Gn=Dee(Vn),{pinnedRef:Gr,positionsRef:Kn,lastLayoutSigRef:Ya,handleRelayout:Xa}=Gn,Kr=w.useRef(null),Yt=w.useRef(()=>{}),ra=ae!==null,tn=w.useRef(0),uc=w.useCallback(()=>{tn.current=Date.now()},[]),{canvasRef:Yr,canvasSize:gh,paneSizeRef:Za}=vte(),sa=rie(Vn),{autoFitDisabledRef:ys,disableAutoFit:ws}=sa,Si=w.useRef(!1),{measuredRef:Xr,measuredVersionRef:_i,sizeVersion:dc,domSizeVersion:Ei}=xte(Si),{removedNodes:vs,removedAgentIds:xs,removeNode:Ci,removeSelectedNode:Ge,removalNotice:Ti,bringBack:Ja,bringBackAll:Ai,forgetRemovals:hc}=cte({stateRef:n,pinnedRef:Gr,positionsRef:Kn,canvasRef:Yr,clearSelection:k,primarySelectedId:g}),Qa=ste({stateRef:n,now:vt,removedAgentIds:xs,sizeVersion:dc,domSizeVersion:Ei});Fee(Qa,Gn),lte({layoutSig:Qa,rf:e,stateRef:n,measuredRef:Xr,pinnedRef:Gr,positionsRef:Kn,paneSizeRef:Za,lastInteractRef:tn,autoFitDisabledRef:ys,lastFitTimeRef:xr,fitLeft:Vn});const Ri=bte(),{bubbling:Mi,endBubble:eo,onBubble:br}=kY(),[Sn,kr]=w.useState(!1),bs=xY(),{beginTrashDrag:aa,trackTrashDrag:Nr,endTrashDrag:yh}=bs,$i=RY({stateRef:n,measuredRef:Xr,measuredVersionRef:_i,canvasRef:Yr}),{lodRef:oa,applyZoom:wh}=$i,Ii=yte({applyViewport:gs,lastFitTimeRef:xr,cameraEpochRef:Qe,disableAutoFit:ws,markInteract:uc,canvasRef:Yr,applyZoom:wh}),jr=g?n.current.agents.get(g):null,Oi=o&&jr!=null,{railInsetRef:fc,availableWidth:ks,availableHeight:Ns}=See({canvasRef:Yr,canvasSize:gh,machinePhase:P,usagePhase:B,usagePanelOpen:u,detailShown:Oi}),Zr=ate({stateRef:n,now:vt,availableWidth:ks,availableHeight:Ns,layout:Gn,measuredRef:Xr,onBubble:br,settled:Ri,dragging:Sn,layoutSig:Qa,selectedIds:p,openContext:gt,historyReplayed:ra,removedNodes:vs,removedAgentIds:xs,dragTick:Ur,dragPatchRef:ms,dragMoveTick:Nn}),{nodes:js,edges:vh}=Zr,Li=xn(g);Bee({nodes:js,edges:vh,settled:Ri,dragging:Sn,availableWidth:ks,availableHeight:Ns,layout:Gn,camera:en,rf:e,measuredRef:Xr,stateRef:n,lastFocusRef:Kr,primarySelectedIdRef:Li,focusAgentRef:Yt,autoFitDisabledRef:ys});const to=Foe({stateRef:n,pinnedRef:Gr,measuredRef:Xr,positionsRef:Kn,lastLayoutSigRef:Ya,forgetRemovals:hc,clearSelection:k,rerender:s,modalOpenRef:Pt}),{requestClear:ia}=to,Pi=jte({nodes:js,stateRef:n,pinnedRef:Gr,positionsRef:Kn,draggingRef:Si,dragPatchRef:ms,setDragging:kr,setDragMoveTick:gr,setDragTick:zr,endBubble:eo,markInteract:uc,disableAutoFit:ws,beginTrashDrag:aa,trackTrashDrag:Nr,endTrashDrag:yh,removeNode:Ci}),pc=w.useCallback(()=>Vn(500),[Vn]),_n=xn(js),{focusAgent:Ss,stepAgent:no,focusSession:_s}=Cee({canvasRef:Yr,stateRef:n,measuredRef:Xr,nodesRef:_n,railInsetRef:fc,moveCamera:vr,disableAutoFit:ws,lastFocusRef:Kr,focusAgentRef:Yt,selectAgent:v,primarySelectedIdRef:Li}),ro=wte({clearSelection:k,selectAgent:v,detailOpen:o,setDetailOpen:l,detailShown:Oi,focusAgent:Ss,draggingRef:Si,lodRef:oa}),so=Tee({nodesRef:_n,stateRef:n,canvasRef:Yr,railInsetRef:fc}),mc=xn(Ge),zt=w.useRef(null),Es=w.useCallback(Sr=>{xs.has(Sr)&&Ja([Sr]),_s(Sr)},[xs,Ja,_s]),Di=kte();Nte({pointerFocusRef:Di,nodesRef:_n,stateRef:n,primarySelectedIdRef:Li,providersRef:ze,soundOnRef:z,keyHelpOpenRef:Qt,modalOpenRef:Pt,waitingCursorRef:zt,removeSelectedRef:mc,activateSoundRef:L,clearSelection:k,selectAgent:v,focusAgent:Ss,stepAgent:no,focusSession:_s,requestClear:ia,handleRelayout:Xa,handleFit:pc,togglePause:Z,toggleSessionList:S,toggleAccountsPanel:_,setDetailOpen:l,setUsageHistoryOpen:yt,setUsagePanelOpen:d,setMachinePanelOpen:f,setBrowserWatchOpen:lt,setSoundMenuOpen:Y,setKeyHelpOpen:Rt,setTheme:we});const Cs=n.current.agents.size,la=w.useMemo(()=>fx(n.current.agents.values()),[n.current,n.current.revision]);ute({stateRef:n,waitingSessions:la,removedAgentIds:xs,removedNodes:vs,bringBack:Ja}),pte({stateRef:n,waitingSessions:la,live:re});const ao=Ioe({waitingSessions:la,watchUnseen:qr,incidents:wr}),ca=Loe({waitingSessions:la,liveSince:ae,focusSession:_s}),{loadNotifyPrefs:ua}=ca;return Koe({loadAutoRestartPrefs:Vr,loadNotifyPrefs:ua,loadReportsPrefs:Dt.loadReportsPrefs}),a.jsxs("div",{className:"app",children:[a.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),a.jsxs("header",{className:"topbar",children:[a.jsx(zne,{versionCheck:pe,welcome:Le,desktopUpdate:he,pause:V,monthly:A,announcements:ao,notify:ca,waitingSessions:la,waitingCursorRef:zt,focusSession:_s,live:re,now:vt,incidents:wr}),jr&&a.jsx(Wne,{selected:jr,now:vt,selectedIds:p,focusAgent:Ss,clearSelection:k}),a.jsxs("div",{className:"actions",children:[a.jsx(vne,{sessionListOpen:x,toggleSessionList:S,usagePanelOpen:u,setUsagePanelOpen:d,setUsageHistoryOpen:yt}),a.jsx(xne,{providers:Oe,accountsPanelOpen:N,toggleAccountsPanel:_,machinePanelOpen:h,setMachinePanelOpen:f,watchOn:Kt,watchUnseen:qr,setBrowserWatchOpen:lt}),a.jsx(bne,{providers:Oe,sound:O,tones:M,customTones:H,notify:ca,chimeState:J,menus:F,appearance:jn,fm:We,reports:Dt,onFeedback:()=>Ue.openFeedback()})]})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Ti?`${Ti.label} removed from the board.`:""}),a.jsx(lre,{restart:Hn,versionCheck:pe,upgrade:it,oldNameNotice:nt,everConnected:me,live:re,paused:K}),Du(R)&&Oe.claude&&a.jsx(fY,{leaving:R==="leaving",onClose:T,onReport:Ue.openFeedback,onRoster:Hr.observe}),x&&a.jsx(bW,{state:n.current,now:vt,selectedIds:p,onSelect:Es,onClose:E,removedIds:xs,onBringBackAll:Ai}),a.jsxs(Yne,{canvasRef:Yr,bubbling:Mi,dragging:Sn,trash:bs,zoom:$i,viewport:Ii,stateRef:n,peek:so,children:[Cs===0&&(!re&&ue?a.jsx(Mte,{}):a.jsx($te,{live:re,everConnected:me,providers:Oe,workspace:$e,onTour:le})),(zn.length>1||mr.size>0)&&a.jsx(Hne,{catBarRef:Wr,catBarOccluded:kn,presentCats:zn,hiddenCats:mr,toggleCat:Wn}),a.jsx(fW,{graph:Zr,layout:Gn,viewport:Ii,clicks:ro,drag:Pi,appearance:jn,fm:We,autoFit:sa,pause:V,stateRef:n,measuredRef:Xr,hiddenCats:mr,now:vt,openTool:Ze,focusAgent:Ss,requestClear:ia,setKeyHelpOpen:Rt})]}),Du(B)&&a.jsx(mH,{state:n.current,now:vt,providers:Oe,incidents:wr,liveSince:ae,leaving:B==="leaving",onClose:()=>d(!1)}),Du(P)&&a.jsx(JH,{usageOpen:u,leaving:P==="leaving",onClose:()=>f(!1)}),o&&jr?a.jsx(Vte,{selected:jr,now:vt,openTool:Ze,setSummaryFor:Je,setDetailOpen:l,stateRef:n,removeSelectedNode:Ge}):null,a.jsx(_ae,{dialogs:Ue,welcome:Le,desktopUpdate:he,versionCheck:pe,restart:Hn,lanPairs:Un,attention:Hr,clearFlow:to,watchBadge:Ft,announcements:ao,appearance:jn,providers:Oe,stateRef:n,agentCount:Cs})]})}try{v8(window.localStorage)}catch{}const oie=s3.createRoot(document.getElementById("root"));oie.render(a.jsx(sie,{}));export{Ete as a,ot as b,Js as c,md as d,cie as e,qe as f,Ir as g,lie as h,Wl as i,a as j,Pr as k,UY as l,Sa as m,Wa as n,Sx as p,w as r,ir as s,ft as u};